diff --git a/doc/interprocess.qbk b/doc/interprocess.qbk
index 88735d1..740716b 100644
--- a/doc/interprocess.qbk
+++ b/doc/interprocess.qbk
@@ -70,7 +70,6 @@ to avoid Boost from trying to automatically link the [*Boost.DateTime].
* GCC 3.4.4 Cygwin
* Intel 9.1 Windows XP
* GCC 4.1.2 Linux
-* Codewarrior 9.4 Windows XP
* GCC 3.4.3 Solaris 11
* GCC 4.0 MacOs 10.4.1
@@ -6336,24 +6335,6 @@ documentation. Hewlett-Packard Company makes no representations about the suitab
of this software for any purpose. It is provided "as is" without express or implied
warranty.
-[*Boost.Interprocess] atomic integer manipulation functions are based on
-Apache Portable Runtime:
-
-Copyright 2000-2005 The Apache Software Foundation or its licensors, as
-applicable.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
[endsect]
[endsect]
diff --git a/example/doc_anonymous_upgradable_mutexA.cpp b/example/doc_anonymous_upgradable_mutexA.cpp
index 29ca49c..5cd7865 100644
--- a/example/doc_anonymous_upgradable_mutexA.cpp
+++ b/example/doc_anonymous_upgradable_mutexA.cpp
@@ -74,4 +74,4 @@ int main ()
return 0;
}
-//]
\ No newline at end of file
+//]
diff --git a/proj/cygwin/MakeAll b/proj/cygwin/MakeAll
index bb5a269..4073873 100644
--- a/proj/cygwin/MakeAll
+++ b/proj/cygwin/MakeAll
@@ -5,23 +5,17 @@ endif
BOOST_ROOT=../../../..
-INTERPROCESS_CPP := $(wildcard ../../src/*.cpp)
-INTERPROCESS_OBJ := $(patsubst ../../src/%.cpp, lib_%.o, $(INTERPROCESS_CPP))
-
INTERPROCESSTEST_CPP := $(wildcard ../../test/*.cpp)
INTERPROCESSTEST_OUT := $(patsubst ../../test/%.cpp, ../../bin/cygwin/test_%.out, $(INTERPROCESSTEST_CPP))
-INTERPROCESSEXAMPLE_CPP := $(wildcard ../../example/*.cpp)
-INTERPROCESSEXAMPLE_OUT := $(patsubst ../../example/%.cpp, ../../bin/cygwin/ex_%.out, $(INTERPROCESSEXAMPLE_CPP))
-
-INTERPROCESSEXAMPLE_CPP := $(wildcard ../../example/*.cpp)
-INTERPROCESSEXAMPLE_OUT := $(patsubst ../../example/%.cpp, ../../bin/cygwin/ex__%.out, $(INTERPROCESSEXAMPLE_CPP))
+#INTERPROCESSEXAMPLE_CPP := $(wildcard ../../example/*.cpp)
+#INTERPROCESSEXAMPLE_OUT := $(patsubst ../../example/%.cpp, ../../bin/cygwin/ex_%.out, $(INTERPROCESSEXAMPLE_CPP))
LIBDIR:= ../../../../stage/lib
.PHONY: createdir clean
-all: createdir $(INTERPROCESSEXAMPLE_OUT) $(INTERPROCESSTEST_OUT) $(INTERPROCESSEXAMPLE_OUT)
+all: createdir $(INTERPROCESSEXAMPLE_OUT) $(INTERPROCESSTEST_OUT)
@cd .
createdir:
@@ -30,8 +24,8 @@ createdir:
../../bin/cygwin/test_%.out: ../../test/%.cpp
$(CC) -g $< -Wall -DBOOST_DATE_TIME_NO_LIB -L$(LIBDIR) -lboost_thread-gcc-mt -I$(BOOST_ROOT) -lstdc++ -o $@
-../../bin/cygwin/ex_%.out: ../../example/%.cpp
- $(CC) -g $< -Wall -DBOOST_DATE_TIME_NO_LIB -L$(LIBDIR)-lboost_thread-gcc-mt -I$(BOOST_ROOT) -lstdc++ -o $@
+#../../bin/cygwin/ex_%.out: ../../example/%.cpp
+# $(CC) -g $< -Wall -DBOOST_DATE_TIME_NO_LIB -L$(LIBDIR)-lboost_thread-gcc-mt -I$(BOOST_ROOT) -lstdc++ -o $@
clean:
diff --git a/proj/vc7ide/Interprocess.sln b/proj/vc7ide/Interprocess.sln
index 158dfd3..0c7730a 100644
--- a/proj/vc7ide/Interprocess.sln
+++ b/proj/vc7ide/Interprocess.sln
@@ -403,6 +403,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_shared_ptr", "doc_share
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "managed_shared_memory_test", "managed_shared_memory.vcproj", "{58DF28E3-0926-F47A-E28A-B03A4D619631}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
@@ -815,6 +819,10 @@ Global
{51CE89A3-6092-F4EA-48A7-B4B9AC326093}.Debug.Build.0 = Debug|Win32
{51CE89A3-6092-F4EA-48A7-B4B9AC326093}.Release.ActiveCfg = Release|Win32
{51CE89A3-6092-F4EA-48A7-B4B9AC326093}.Release.Build.0 = Release|Win32
+ {58DF28E3-0926-F47A-E28A-B03A4D619631}.Debug.ActiveCfg = Debug|Win32
+ {58DF28E3-0926-F47A-E28A-B03A4D619631}.Debug.Build.0 = Debug|Win32
+ {58DF28E3-0926-F47A-E28A-B03A4D619631}.Release.ActiveCfg = Release|Win32
+ {58DF28E3-0926-F47A-E28A-B03A4D619631}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
diff --git a/proj/vc7ide/interprocesslib.vcproj b/proj/vc7ide/interprocesslib.vcproj
index 3263916..429ce55 100644
--- a/proj/vc7ide/interprocesslib.vcproj
+++ b/proj/vc7ide/interprocesslib.vcproj
@@ -386,6 +386,9 @@
+
+
diff --git a/proj/vc7ide/managed_shared_memory.vcproj b/proj/vc7ide/managed_shared_memory.vcproj
new file mode 100644
index 0000000..528972d
--- /dev/null
+++ b/proj/vc7ide/managed_shared_memory.vcproj
@@ -0,0 +1,136 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/deque_test.cpp b/test/deque_test.cpp
index c8a6b8d..c9a6934 100644
--- a/test/deque_test.cpp
+++ b/test/deque_test.cpp
@@ -28,6 +28,7 @@
#include
#include
#include
+#include
#include
#include "get_process_id_name.hpp"
@@ -177,7 +178,6 @@ bool do_test()
}
if(!copyable_only(shmdeque, stddeque
-// ,boost::integral_constant
,detail::bool_::value>())){
return false;
}
diff --git a/test/managed_mapped_file_test.cpp b/test/managed_mapped_file_test.cpp
index 17c76ac..c33b97e 100644
--- a/test/managed_mapped_file_test.cpp
+++ b/test/managed_mapped_file_test.cpp
@@ -79,6 +79,25 @@ int main ()
mfile.flush();
}
{
+ //Map preexisting file again in memory
+ managed_mapped_file mfile(open_only, FileName);
+
+ //Check vector is still there
+ MyVect *mfile_vect = mfile.find("MyVector").first;
+ if(!mfile_vect)
+ return -1;
+ }
+
+ {
+ std::size_t old_free_memory;
+ {
+ //Map preexisting file again in memory
+ managed_mapped_file mfile(open_only, FileName);
+ old_free_memory = mfile.get_free_memory();
+ }
+
+ //Now grow the file
+ managed_mapped_file::grow(FileName, FileSize);
//Map preexisting file again in memory
managed_mapped_file mfile(open_only, FileName);
@@ -88,11 +107,63 @@ int main ()
if(!mfile_vect)
return -1;
- //Destroy and check it is not present
- mfile.destroy_ptr(mfile_vect);
- if(0 != mfile.find("MyVector").first)
+ if(mfile.get_size() != (FileSize*2))
+ return -1;
+ if(mfile.get_free_memory() <= old_free_memory)
return -1;
}
+ {
+ std::size_t old_free_memory, next_free_memory,
+ old_file_size, next_file_size, final_file_size;
+ {
+ //Map preexisting file again in memory
+ managed_mapped_file mfile(open_only, FileName);
+ old_free_memory = mfile.get_free_memory();
+ old_file_size = mfile.get_size();
+ }
+
+ //Now shrink the file
+ managed_mapped_file::shrink_to_fit(FileName);
+
+ {
+ //Map preexisting file again in memory
+ managed_mapped_file mfile(open_only, FileName);
+ next_file_size = mfile.get_size();
+
+ //Check vector is still there
+ MyVect *mfile_vect = mfile.find("MyVector").first;
+ if(!mfile_vect)
+ return -1;
+
+ next_free_memory = mfile.get_free_memory();
+ if(next_free_memory >= old_free_memory)
+ return -1;
+ if(old_file_size <= next_file_size)
+ return -1;
+ }
+
+ //Now destroy the vector
+ {
+ //Map preexisting file again in memory
+ managed_mapped_file mfile(open_only, FileName);
+
+ //Destroy and check it is not present
+ mfile.destroy("MyVector");
+ if(0 != mfile.find("MyVector").first)
+ return -1;
+ }
+
+ //Now shrink the file
+ managed_mapped_file::shrink_to_fit(FileName);
+ {
+ //Map preexisting file again in memory
+ managed_mapped_file mfile(open_only, FileName);
+ final_file_size = mfile.get_size();
+ if(next_file_size <= final_file_size)
+ return -1;
+ }
+ }
+
std::remove(FileName);
return 0;
}
diff --git a/test/managed_shared_memory_test.cpp b/test/managed_shared_memory_test.cpp
new file mode 100644
index 0000000..9d7d94c
--- /dev/null
+++ b/test/managed_shared_memory_test.cpp
@@ -0,0 +1,168 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2004-2007. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include "get_process_id_name.hpp"
+
+using namespace boost::interprocess;
+
+int main ()
+{
+ const int ShmemSize = 65536;
+ const char *const ShmemName = test::get_process_id_name();
+
+ //STL compatible allocator object for memory-mapped shmem
+ typedef allocator
+ allocator_int_t;
+ //A vector that uses that allocator
+ typedef boost::interprocess::vector MyVect;
+
+ {
+ //Remove the shmem it is already created
+ shared_memory_object::remove(ShmemName);
+
+ const int max = 100;
+ void *array[max];
+ //Named allocate capable shared memory allocator
+ managed_shared_memory shmem(create_only, ShmemName, ShmemSize);
+
+ int i;
+ //Let's allocate some memory
+ for(i = 0; i < max; ++i){
+ array[i] = shmem.allocate(i+1);
+ }
+
+ //Deallocate allocated memory
+ for(i = 0; i < max; ++i){
+ shmem.deallocate(array[i]);
+ }
+ }
+
+ {
+ //Remove the shmem it is already created
+ shared_memory_object::remove(ShmemName);
+
+ //Named allocate capable memory mapped shmem managed memory class
+ managed_shared_memory shmem(create_only, ShmemName, ShmemSize);
+
+ //Construct the STL-like allocator with the segment manager
+ const allocator_int_t myallocator (shmem.get_segment_manager());
+
+ //Construct vector
+ MyVect *shmem_vect = shmem.construct ("MyVector") (myallocator);
+
+ //Test that vector can be found via name
+ if(shmem_vect != shmem.find("MyVector").first)
+ return -1;
+
+ //Destroy and check it is not present
+ shmem.destroy ("MyVector");
+ if(0 != shmem.find("MyVector").first)
+ return -1;
+
+ //Construct a vector in the memory-mapped shmem
+ shmem_vect = shmem.construct ("MyVector") (myallocator);
+ }
+ {
+ //Map preexisting shmem again in memory
+ managed_shared_memory shmem(open_only, ShmemName);
+
+ //Check vector is still there
+ MyVect *shmem_vect = shmem.find("MyVector").first;
+ if(!shmem_vect)
+ return -1;
+ }
+
+ {
+ std::size_t old_free_memory;
+ {
+ //Map preexisting shmem again in memory
+ managed_shared_memory shmem(open_only, ShmemName);
+ old_free_memory = shmem.get_free_memory();
+ }
+
+ //Now grow the shmem
+ managed_shared_memory::grow(ShmemName, ShmemSize);
+
+ //Map preexisting shmem again in memory
+ managed_shared_memory shmem(open_only, ShmemName);
+
+ //Check vector is still there
+ MyVect *shmem_vect = shmem.find("MyVector").first;
+ if(!shmem_vect)
+ return -1;
+
+ if(shmem.get_size() != (ShmemSize*2))
+ return -1;
+ if(shmem.get_free_memory() <= old_free_memory)
+ return -1;
+ }
+ {
+ std::size_t old_free_memory, next_free_memory,
+ old_shmem_size, next_shmem_size, final_shmem_size;
+ {
+ //Map preexisting shmem again in memory
+ managed_shared_memory shmem(open_only, ShmemName);
+ old_free_memory = shmem.get_free_memory();
+ old_shmem_size = shmem.get_size();
+ }
+
+ //Now shrink the shmem
+ managed_shared_memory::shrink_to_fit(ShmemName);
+
+ {
+ //Map preexisting shmem again in memory
+ managed_shared_memory shmem(open_only, ShmemName);
+ next_shmem_size = shmem.get_size();
+
+ //Check vector is still there
+ MyVect *shmem_vect = shmem.find("MyVector").first;
+ if(!shmem_vect)
+ return -1;
+
+ next_free_memory = shmem.get_free_memory();
+ if(next_free_memory >= old_free_memory)
+ return -1;
+ if(old_shmem_size <= next_shmem_size)
+ return -1;
+ }
+
+ //Now destroy the vector
+ {
+ //Map preexisting shmem again in memory
+ managed_shared_memory shmem(open_only, ShmemName);
+
+ //Destroy and check it is not present
+ shmem.destroy("MyVector");
+ if(0 != shmem.find("MyVector").first)
+ return -1;
+ }
+
+ //Now shrink the shmem
+ managed_shared_memory::shrink_to_fit(ShmemName);
+ {
+ //Map preexisting shmem again in memory
+ managed_shared_memory shmem(open_only, ShmemName);
+ final_shmem_size = shmem.get_size();
+ if(next_shmem_size <= final_shmem_size)
+ return -1;
+ }
+ }
+
+ shared_memory_object::remove(ShmemName);
+ return 0;
+}
+
+#include
diff --git a/test/mapped_file_test.cpp b/test/mapped_file_test.cpp
index 06a05f5..233e907 100644
--- a/test/mapped_file_test.cpp
+++ b/test/mapped_file_test.cpp
@@ -73,7 +73,7 @@ int main ()
}
//Overwrite all memory
- std::memset(file1.get_address(), 0, file1.get_size());
+ std::memset(file1.get_user_address(), 0, file1.get_user_size());
}
std::remove(FileName);
return 0;
diff --git a/test/named_allocation_test_template.hpp b/test/named_allocation_test_template.hpp
index a4ce3e9..7cb60bc 100644
--- a/test/named_allocation_test_template.hpp
+++ b/test/named_allocation_test_template.hpp
@@ -28,6 +28,14 @@
namespace boost { namespace interprocess { namespace test {
+namespace {
+ const wchar_t *get_prefix(wchar_t)
+ { return L"prefix_name_"; }
+
+ const char *get_prefix(char)
+ { return "prefix_name_"; }
+}
+
//This test allocates until there is no more memory
//and after that deallocates all in the same order
template
@@ -43,7 +51,7 @@ bool test_names_and_types(ManagedMemory &m)
for(int i = 0; true; ++i){
formatter.seekp(0);
- formatter << "prefix_name_" << i << std::ends;
+ formatter << get_prefix(char_type()) << i << std::ends;
char *ptr = m.template construct(name, std::nothrow)(i);
@@ -105,7 +113,7 @@ bool test_named_iterators(ManagedMemory &m)
for(int i = 0; true; ++i){
formatter.seekp(0);
- formatter << "prefix_name_" << i << std::ends;
+ formatter << get_prefix(char_type()) << i << std::ends;
char *ptr = m.template construct(name, std::nothrow)(i);
if(!ptr)
break;
@@ -175,7 +183,7 @@ bool test_shrink_to_fit(ManagedMemory &m)
for(int i = 0; true; ++i){
formatter.seekp(0);
- formatter << "prefix_name_" << i << std::ends;
+ formatter << get_prefix(char_type()) << i << std::ends;
char *ptr = m.template construct(name, std::nothrow)(i);
@@ -215,7 +223,7 @@ bool test_direct_named_allocation_destruction(ManagedMemory &m)
for(int i = 0; true; ++i){
formatter.seekp(0);
- formatter << "prefix_name_" << i << std::ends;
+ formatter << get_prefix(char_type()) << i << std::ends;
char *ptr = m.template construct(name, std::nothrow)(i);
if(!ptr)
break;
@@ -257,7 +265,7 @@ bool test_named_allocation_inverse_destruction(ManagedMemory &m)
for(int i = 0; true; ++i){
formatter.seekp(0);
- formatter << "prefix_name_" << i << std::ends;
+ formatter << get_prefix(char_type()) << i << std::ends;
char *ptr = m.template construct(name, std::nothrow)(i);
if(!ptr)
break;
@@ -297,7 +305,7 @@ bool test_named_allocation_mixed_destruction(ManagedMemory &m)
for(int i = 0; true; ++i){
formatter.seekp(0);
- formatter << "prefix_name_" << i << std::ends;
+ formatter << get_prefix(char_type()) << i << std::ends;
char *ptr = m.template construct(name, std::nothrow)(i);
if(!ptr)
break;
@@ -339,7 +347,7 @@ bool test_inverse_named_allocation_destruction(ManagedMemory &m)
for(unsigned int i = 0; true; ++i){
formatter.seekp(0);
- formatter << "prefix_name_" << i << std::ends;
+ formatter << get_prefix(char_type()) << i << std::ends;
char *ptr = m.template construct(name, std::nothrow)(i);
if(!ptr)
break;
@@ -426,6 +434,7 @@ template class Index>
bool test_named_allocation()
{
using namespace boost::interprocess;
+
const int memsize = 163840;
const char *const shMemName = test::get_process_id_name();
try
diff --git a/test/named_condition_test.cpp b/test/named_condition_test.cpp
index 34caef2..be04499 100644
--- a/test/named_condition_test.cpp
+++ b/test/named_condition_test.cpp
@@ -66,17 +66,27 @@ class named_condition_creation_test_wrapper
public:
named_condition_creation_test_wrapper(create_only_t)
: named_condition(create_only, test::add_to_process_id_name("named_condition"))
- {}
+ { ++count_; }
named_condition_creation_test_wrapper(open_only_t)
: named_condition(open_only, test::add_to_process_id_name("named_condition"))
- {}
+ { ++count_; }
named_condition_creation_test_wrapper(open_or_create_t)
: named_condition(open_or_create, test::add_to_process_id_name("named_condition"))
- {}
+ { ++count_; }
+
+ ~named_condition_creation_test_wrapper() {
+ if(--count_){
+ detail::interprocess_tester::
+ dont_close_on_destruction(static_cast(*this));
+ }
+ }
+ static int count_;
};
+int named_condition_creation_test_wrapper::count_ = 0;
+
struct mutex_deleter
{
std::string name;
diff --git a/test/named_mutex_test.cpp b/test/named_mutex_test.cpp
index 8b21603..eb64286 100644
--- a/test/named_mutex_test.cpp
+++ b/test/named_mutex_test.cpp
@@ -15,6 +15,7 @@
#include "named_creation_template.hpp"
#include
#include "get_process_id_name.hpp"
+#include
using namespace boost::interprocess;
@@ -32,9 +33,21 @@ class named_mutex_lock_test_wrapper
public:
named_mutex_lock_test_wrapper()
: named_mutex(open_or_create, test::get_process_id_name())
- {}
+ { ++count_; }
+
+ ~named_mutex_lock_test_wrapper()
+ {
+ if(--count_){
+ detail::interprocess_tester::
+ dont_close_on_destruction(static_cast(*this));
+ }
+ }
+
+ static int count_;
};
+int named_mutex_lock_test_wrapper::count_ = 0;
+
//This wrapper is necessary to have a common constructor
//in generic named_creation_template functions
class named_mutex_creation_test_wrapper
@@ -43,17 +56,29 @@ class named_mutex_creation_test_wrapper
public:
named_mutex_creation_test_wrapper(create_only_t)
: named_mutex(create_only, test::get_process_id_name())
- {}
+ { ++count_; }
named_mutex_creation_test_wrapper(open_only_t)
: named_mutex(open_only, test::get_process_id_name())
- {}
+ { ++count_; }
named_mutex_creation_test_wrapper(open_or_create_t)
: named_mutex(open_or_create, test::get_process_id_name())
- {}
+ { ++count_; }
+
+ ~named_mutex_creation_test_wrapper()
+ {
+ if(--count_){
+ detail::interprocess_tester::
+ dont_close_on_destruction(static_cast(*this));
+ }
+ }
+
+ static int count_;
};
+int named_mutex_creation_test_wrapper::count_ = 0;
+
int main ()
{
try{
diff --git a/test/named_recursive_mutex_test.cpp b/test/named_recursive_mutex_test.cpp
index 8aa151e..6080b76 100644
--- a/test/named_recursive_mutex_test.cpp
+++ b/test/named_recursive_mutex_test.cpp
@@ -33,9 +33,21 @@ class named_recursive_mutex_lock_test_wrapper
public:
named_recursive_mutex_lock_test_wrapper()
: named_recursive_mutex(open_or_create, test::get_process_id_name())
- {}
+ { ++count_; }
+
+ ~named_recursive_mutex_lock_test_wrapper()
+ {
+ if(--count_){
+ detail::interprocess_tester::
+ dont_close_on_destruction(static_cast(*this));
+ }
+ }
+
+ static int count_;
};
+int named_recursive_mutex_lock_test_wrapper::count_ = 0;
+
//This wrapper is necessary to have a common constructor
//in generic named_creation_template functions
class named_mutex_creation_test_wrapper
@@ -44,17 +56,29 @@ class named_mutex_creation_test_wrapper
public:
named_mutex_creation_test_wrapper(create_only_t)
: named_recursive_mutex(create_only, test::get_process_id_name())
- {}
+ { ++count_; }
named_mutex_creation_test_wrapper(open_only_t)
: named_recursive_mutex(open_only, test::get_process_id_name())
- {}
+ { ++count_; }
named_mutex_creation_test_wrapper(open_or_create_t)
: named_recursive_mutex(open_or_create, test::get_process_id_name())
- {}
+ { ++count_; }
+
+ ~named_mutex_creation_test_wrapper()
+ {
+ if(--count_){
+ detail::interprocess_tester::
+ dont_close_on_destruction(static_cast(*this));
+ }
+ }
+
+ static int count_;
};
+int named_mutex_creation_test_wrapper::count_ = 0;
+
int main ()
{
try{
diff --git a/test/named_semaphore_test.cpp b/test/named_semaphore_test.cpp
index 7e73e66..dd527c7 100644
--- a/test/named_semaphore_test.cpp
+++ b/test/named_semaphore_test.cpp
@@ -10,6 +10,7 @@
#include
#include
+#include
#include
#include
#include "named_creation_template.hpp"
@@ -37,26 +38,25 @@ class named_semaphore_test_wrapper
public:
named_semaphore_test_wrapper()
: named_semaphore(open_or_create, SemName, SemCount)
- {}
+ { ++count_; }
named_semaphore_test_wrapper(create_only_t)
: named_semaphore(create_only, SemName, SemCount)
- {}
+ { ++count_; }
named_semaphore_test_wrapper(open_only_t)
: named_semaphore(open_only, SemName)
- {}
+ { ++count_; }
named_semaphore_test_wrapper(open_or_create_t)
: named_semaphore(open_or_create, SemName, SemCount)
- {}
+ { ++count_; }
~named_semaphore_test_wrapper()
{
- try{
-
- }
- catch(...){
+ if(--count_){
+ detail::interprocess_tester::
+ dont_close_on_destruction(static_cast(*this));
}
}
@@ -76,8 +76,12 @@ class named_semaphore_test_wrapper
named_semaphore_test_wrapper(int initial_count)
: named_semaphore(create_only, SemName, initial_count)
{}
+
+ static int count_;
};
+int named_semaphore_test_wrapper::count_ = 0;
+
//This wrapper is necessary to plug this class
//in recursive tests
class recursive_named_semaphore_test_wrapper
@@ -87,8 +91,12 @@ class recursive_named_semaphore_test_wrapper
recursive_named_semaphore_test_wrapper()
: named_semaphore_test_wrapper(RecSemCount)
{}
+
+ static int count_;
};
+int recursive_named_semaphore_test_wrapper::count_ = 0;
+
int main ()
{
try{
diff --git a/test/named_upgradable_mutex_test.cpp b/test/named_upgradable_mutex_test.cpp
index 37f8297..9f5eaa5 100644
--- a/test/named_upgradable_mutex_test.cpp
+++ b/test/named_upgradable_mutex_test.cpp
@@ -32,9 +32,22 @@ class named_upgradable_mutex_lock_test_wrapper
public:
named_upgradable_mutex_lock_test_wrapper()
: named_upgradable_mutex(open_or_create, test::get_process_id_name())
- {}
+ { ++count_; }
+
+ ~named_upgradable_mutex_lock_test_wrapper()
+ {
+ if(--count_){
+ detail::interprocess_tester::
+ dont_close_on_destruction(static_cast(*this));
+ }
+ }
+
+ static int count_;
};
+int named_upgradable_mutex_lock_test_wrapper::count_ = 0;
+
+
//This wrapper is necessary to have a common constructor
//in generic named_creation_template functions
class named_upgradable_mutex_creation_test_wrapper
@@ -44,27 +57,39 @@ class named_upgradable_mutex_creation_test_wrapper
named_upgradable_mutex_creation_test_wrapper
(create_only_t)
: named_upgradable_mutex(create_only, test::get_process_id_name())
- {}
+ { ++count_; }
named_upgradable_mutex_creation_test_wrapper
(open_only_t)
: named_upgradable_mutex(open_only, test::get_process_id_name())
- {}
+ { ++count_; }
named_upgradable_mutex_creation_test_wrapper
(open_or_create_t)
: named_upgradable_mutex(open_or_create, test::get_process_id_name())
- {}
+ { ++count_; }
+
+ ~named_upgradable_mutex_creation_test_wrapper()
+ {
+ if(--count_){
+ detail::interprocess_tester::
+ dont_close_on_destruction(static_cast(*this));
+ }
+ }
+
+ static int count_;
};
+int named_upgradable_mutex_creation_test_wrapper::count_ = 0;
+
int main ()
{
try{
named_upgradable_mutex::remove(test::get_process_id_name());
test::test_named_creation();
-// test::test_all_lock();
-// test::test_all_mutex();
-// test::test_all_sharable_mutex();
+ test::test_all_lock();
+ test::test_all_mutex();
+ test::test_all_sharable_mutex();
}
catch(std::exception &ex){
named_upgradable_mutex::remove(test::get_process_id_name());
diff --git a/test/node_pool_test.cpp b/test/node_pool_test.cpp
index 0d36e0b..85d21e1 100644
--- a/test/node_pool_test.cpp
+++ b/test/node_pool_test.cpp
@@ -12,6 +12,7 @@
#include
#include
#include
+#include
#include
#include
#include
diff --git a/test/shared_memory_test.cpp b/test/shared_memory_test.cpp
index 9d5af3a..012e619 100644
--- a/test/shared_memory_test.cpp
+++ b/test/shared_memory_test.cpp
@@ -73,7 +73,7 @@ int main ()
}
//Overwrite all memory
- std::memset(shm1.get_address(), 0, shm1.get_size());
+ std::memset(shm1.get_user_address(), 0, shm1.get_user_size());
}
}
catch(std::exception &ex){
diff --git a/test/user_buffer_test.cpp b/test/user_buffer_test.cpp
index ce4c45d..232b253 100644
--- a/test/user_buffer_test.cpp
+++ b/test/user_buffer_test.cpp
@@ -189,8 +189,10 @@ int main ()
const char *insert_beg = detail::char_ptr_cast(heap_buffer.get_address());
const char *insert_end = insert_beg + heap_buffer.get_size();
std::vector grow_copy (insert_beg, insert_end);
+
//Destroy old list
heap_buffer.destroy(L"MyHeapList");
+
//Resize copy buffer
grow_copy.resize(memsize*2);