mirror of
https://github.com/boostorg/interprocess.git
synced 2026-01-19 04:12:13 +00:00
Split several sync utility tests to improve parallelization. Windows:
* Spin and Shm based utilities will be tested independently. * Includes some refactoring to avoid copy-pasting some code in several similar synchronization primitive tests.
This commit is contained in:
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
################################################################################
|
||||
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
|
||||
################################################################################
|
||||
|
||||
/test/test_intermod_holder.cpp.wrk
|
||||
/test/test_intermod_holder.hpp.wrk
|
||||
/test/intermod_holder_dll.hpp
|
||||
/test/test_intermod_holder_main.cpp.wrk
|
||||
@@ -13,23 +13,10 @@
|
||||
#include <boost/interprocess/sync/interprocess_mutex.hpp>
|
||||
#include "condition_test_template.hpp"
|
||||
|
||||
#if defined(BOOST_INTERPROCESS_WINDOWS)
|
||||
#include <boost/interprocess/sync/windows/condition.hpp>
|
||||
#include <boost/interprocess/sync/windows/mutex.hpp>
|
||||
#include <boost/interprocess/sync/spin/condition.hpp>
|
||||
#include <boost/interprocess/sync/spin/mutex.hpp>
|
||||
#endif
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
int main ()
|
||||
{
|
||||
#if defined(BOOST_INTERPROCESS_WINDOWS)
|
||||
if(!test::do_test_condition<ipcdetail::winapi_condition, ipcdetail::winapi_mutex>())
|
||||
return 1;
|
||||
if(!test::do_test_condition<ipcdetail::spin_condition, ipcdetail::spin_mutex>())
|
||||
return 1;
|
||||
#endif
|
||||
if(!test::do_test_condition<interprocess_condition, interprocess_mutex>())
|
||||
return 1;
|
||||
|
||||
|
||||
@@ -12,22 +12,10 @@
|
||||
#include <boost/interprocess/sync/interprocess_mutex.hpp>
|
||||
#include "mutex_test_template.hpp"
|
||||
|
||||
#if defined(BOOST_INTERPROCESS_WINDOWS)
|
||||
#include <boost/interprocess/sync/windows/mutex.hpp>
|
||||
#include <boost/interprocess/sync/spin/mutex.hpp>
|
||||
#endif
|
||||
|
||||
int main ()
|
||||
{
|
||||
using namespace boost::interprocess;
|
||||
|
||||
#if defined(BOOST_INTERPROCESS_WINDOWS)
|
||||
test::test_all_lock<ipcdetail::winapi_mutex>();
|
||||
test::test_all_mutex<ipcdetail::winapi_mutex>();
|
||||
test::test_all_lock<ipcdetail::spin_mutex>();
|
||||
test::test_all_mutex<ipcdetail::spin_mutex>();
|
||||
#endif
|
||||
|
||||
test::test_all_lock<interprocess_mutex>();
|
||||
test::test_all_mutex<interprocess_mutex>();
|
||||
return 0;
|
||||
|
||||
@@ -270,9 +270,7 @@ void test_mutex_lock()
|
||||
boost::interprocess::ipcdetail::thread_launch(tm2, thread_adapter<M>(&lock_and_sleep, &d2, mtx));
|
||||
|
||||
//Wait completion
|
||||
|
||||
boost::interprocess::ipcdetail::thread_join(tm1);
|
||||
boost::interprocess::ipcdetail::thread_sleep_ms(unsigned(1*BaseMs));
|
||||
boost::interprocess::ipcdetail::thread_join(tm2);
|
||||
|
||||
BOOST_INTERPROCESS_CHECK(d1.m_value == 1);
|
||||
@@ -347,6 +345,7 @@ void test_mutex_timed_lock()
|
||||
{
|
||||
for (int flag = 0; flag != (int)ETimedLockFlagsMax; ++flag)
|
||||
{
|
||||
//int flag = 2;
|
||||
shared_val = 0;
|
||||
|
||||
M mtx, m2;
|
||||
|
||||
@@ -10,30 +10,11 @@
|
||||
|
||||
#include <boost/interprocess/sync/named_mutex.hpp>
|
||||
#include <boost/interprocess/sync/named_condition.hpp>
|
||||
#include <boost/interprocess/sync/detail/locks.hpp>
|
||||
#include "condition_test_template.hpp"
|
||||
#include "named_creation_template.hpp"
|
||||
#include "named_condition_test_helpers.hpp"
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include "get_process_id_name.hpp"
|
||||
|
||||
#if defined(BOOST_INTERPROCESS_WINDOWS)
|
||||
#include <boost/interprocess/sync/windows/named_condition.hpp>
|
||||
#include <boost/interprocess/sync/windows/named_mutex.hpp>
|
||||
#endif
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
int main()
|
||||
{
|
||||
int ret;
|
||||
#if defined(BOOST_INTERPROCESS_WINDOWS)
|
||||
ret = test::test_named_condition<ipcdetail::winapi_named_condition, ipcdetail::winapi_named_mutex>();
|
||||
if (ret)
|
||||
return ret;
|
||||
#endif
|
||||
ret = test::test_named_condition<named_condition, named_mutex>();
|
||||
|
||||
return ret;
|
||||
return test::test_named_condition<named_condition, named_mutex>();
|
||||
}
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
#define BOOST_INTERPROCESS_TEST_NAMED_CONDITION_HELPERS_HEADER
|
||||
|
||||
#include <boost/interprocess/detail/config_begin.hpp>
|
||||
#include <boost/interprocess/sync/cv_status.hpp>
|
||||
#include <boost/interprocess/detail/interprocess_tester.hpp>
|
||||
#include <boost/interprocess/sync/detail/locks.hpp>
|
||||
#include "condition_test_template.hpp"
|
||||
#include "named_creation_template.hpp"
|
||||
#include "get_process_id_name.hpp"
|
||||
|
||||
namespace boost { namespace interprocess { namespace test {
|
||||
|
||||
|
||||
@@ -9,48 +9,11 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <boost/interprocess/sync/named_mutex.hpp>
|
||||
#include <boost/interprocess/sync/scoped_lock.hpp>
|
||||
#include "mutex_test_template.hpp"
|
||||
#include "named_creation_template.hpp"
|
||||
#include <boost/interprocess/detail/interprocess_tester.hpp>
|
||||
#include <exception>
|
||||
|
||||
#if defined(BOOST_INTERPROCESS_WINDOWS)
|
||||
#include <boost/interprocess/sync/windows/named_mutex.hpp>
|
||||
#endif
|
||||
#include "named_mutex_test_helpers.hpp"
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
template<class NamedMutex>
|
||||
int test_named_mutex()
|
||||
{
|
||||
int ret = 0;
|
||||
BOOST_TRY{
|
||||
NamedMutex::remove(test::get_process_id_name());
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper<NamedMutex> >();
|
||||
#if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper_w<NamedMutex> >();
|
||||
#endif //defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
test::test_all_lock< test::named_sync_wrapper<NamedMutex> >();
|
||||
test::test_all_mutex<test::named_sync_wrapper<NamedMutex> >();
|
||||
}
|
||||
BOOST_CATCH(std::exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
ret = 1;
|
||||
} BOOST_CATCH_END
|
||||
NamedMutex::remove(test::get_process_id_name());
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int ret;
|
||||
#if defined(BOOST_INTERPROCESS_WINDOWS)
|
||||
ret = test_named_mutex<ipcdetail::winapi_named_mutex>();
|
||||
if (ret)
|
||||
return ret;
|
||||
#endif
|
||||
ret = test_named_mutex<named_mutex>();
|
||||
|
||||
return ret;
|
||||
return test::test_named_mutex<named_mutex>();
|
||||
}
|
||||
|
||||
73
test/named_mutex_test_helpers.hpp
Normal file
73
test/named_mutex_test_helpers.hpp
Normal file
@@ -0,0 +1,73 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2024-2024. 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_INTERPROCESS_TEST_NAMED_MUTEX_HELPERS_HEADER
|
||||
#define BOOST_INTERPROCESS_TEST_NAMED_MUTEX_HELPERS_HEADER
|
||||
|
||||
#include <boost/interprocess/detail/config_begin.hpp>
|
||||
#include <boost/interprocess/detail/workaround.hpp>
|
||||
|
||||
#include "mutex_test_template.hpp"
|
||||
#include "named_creation_template.hpp"
|
||||
#include "get_process_id_name.hpp"
|
||||
#include <exception>
|
||||
|
||||
namespace boost { namespace interprocess { namespace test {
|
||||
|
||||
template<class NamedMutex>
|
||||
int test_named_mutex()
|
||||
{
|
||||
int ret = 0;
|
||||
BOOST_TRY{
|
||||
NamedMutex::remove(test::get_process_id_name());
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper<NamedMutex> >();
|
||||
#if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper_w<NamedMutex> >();
|
||||
#endif //defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
test::test_all_lock< test::named_sync_wrapper<NamedMutex> >();
|
||||
test::test_all_mutex<test::named_sync_wrapper<NamedMutex> >();
|
||||
}
|
||||
BOOST_CATCH(std::exception& ex) {
|
||||
std::cout << ex.what() << std::endl;
|
||||
ret = 1;
|
||||
} BOOST_CATCH_END
|
||||
NamedMutex::remove(test::get_process_id_name());
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class NamedRecursiveMutex>
|
||||
int test_named_recursive_mutex()
|
||||
{
|
||||
int ret = 0;
|
||||
BOOST_TRY{
|
||||
NamedRecursiveMutex::remove(test::get_process_id_name());
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper<NamedRecursiveMutex> >();
|
||||
#if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper_w<NamedRecursiveMutex> >();
|
||||
#endif //defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
test::test_all_lock< test::named_sync_wrapper<NamedRecursiveMutex> >();
|
||||
test::test_all_mutex<test::named_sync_wrapper<NamedRecursiveMutex> >();
|
||||
test::test_all_recursive_lock<test::named_sync_wrapper<NamedRecursiveMutex> >();
|
||||
}
|
||||
BOOST_CATCH(std::exception& ex) {
|
||||
std::cout << ex.what() << std::endl;
|
||||
ret = 1;
|
||||
} BOOST_CATCH_END
|
||||
NamedRecursiveMutex::remove(test::get_process_id_name());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}}} //namespace boost { namespace interprocess { namespace test {
|
||||
|
||||
#include <boost/interprocess/detail/config_end.hpp>
|
||||
|
||||
#endif //BOOST_INTERPROCESS_TEST_NAMED_MUTEX_HELPERS_HEADER
|
||||
@@ -9,50 +9,11 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <boost/interprocess/sync/named_recursive_mutex.hpp>
|
||||
#include <boost/interprocess/sync/scoped_lock.hpp>
|
||||
#include "mutex_test_template.hpp"
|
||||
#include "named_creation_template.hpp"
|
||||
#include "get_process_id_name.hpp"
|
||||
#include <exception>
|
||||
|
||||
#if defined(BOOST_INTERPROCESS_WINDOWS)
|
||||
#include <boost/interprocess/sync/windows/named_recursive_mutex.hpp>
|
||||
#endif
|
||||
#include "named_mutex_test_helpers.hpp"
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
|
||||
template<class NamedRecursiveMutex>
|
||||
int test_named_recursive_mutex()
|
||||
{
|
||||
int ret = 0;
|
||||
BOOST_TRY{
|
||||
NamedRecursiveMutex::remove(test::get_process_id_name());
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper<NamedRecursiveMutex> >();
|
||||
#if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper_w<NamedRecursiveMutex> >();
|
||||
#endif //defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
test::test_all_lock< test::named_sync_wrapper<NamedRecursiveMutex> >();
|
||||
test::test_all_mutex<test::named_sync_wrapper<NamedRecursiveMutex> >();
|
||||
test::test_all_recursive_lock<test::named_sync_wrapper<NamedRecursiveMutex> >();
|
||||
}
|
||||
BOOST_CATCH(std::exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
ret = 1;
|
||||
} BOOST_CATCH_END
|
||||
NamedRecursiveMutex::remove(test::get_process_id_name());
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int ret;
|
||||
#if defined(BOOST_INTERPROCESS_WINDOWS)
|
||||
ret = test_named_recursive_mutex<ipcdetail::winapi_named_recursive_mutex>();
|
||||
if (ret)
|
||||
return ret;
|
||||
#endif
|
||||
ret = test_named_recursive_mutex<named_recursive_mutex>();
|
||||
|
||||
return ret;
|
||||
return test::test_named_recursive_mutex<named_recursive_mutex>();
|
||||
}
|
||||
|
||||
@@ -9,147 +9,11 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <boost/interprocess/sync/named_semaphore.hpp>
|
||||
#include <boost/interprocess/detail/interprocess_tester.hpp>
|
||||
#include <boost/interprocess/exceptions.hpp>
|
||||
#include "named_creation_template.hpp"
|
||||
#include "mutex_test_template.hpp"
|
||||
#include "get_process_id_name.hpp"
|
||||
#include <exception>
|
||||
|
||||
#if defined(BOOST_INTERPROCESS_WINDOWS)
|
||||
#include <boost/interprocess/sync/windows/named_semaphore.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/interprocess/detail/timed_utils.hpp>
|
||||
#include "named_semaphore_test_helpers.hpp"
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
static const std::size_t RecSemCount = 100;
|
||||
|
||||
//This wrapper is necessary to plug this class
|
||||
//in lock tests
|
||||
template<class NamedSemaphore>
|
||||
class lock_test_wrapper
|
||||
: public NamedSemaphore
|
||||
{
|
||||
public:
|
||||
|
||||
template <class CharT>
|
||||
lock_test_wrapper(create_only_t, const CharT *name, unsigned int count = 1)
|
||||
: NamedSemaphore(create_only, name, count)
|
||||
{}
|
||||
|
||||
template <class CharT>
|
||||
lock_test_wrapper(open_only_t, const CharT *name)
|
||||
: NamedSemaphore(open_only, name)
|
||||
{}
|
||||
|
||||
template <class CharT>
|
||||
lock_test_wrapper(open_or_create_t, const CharT *name, unsigned int count = 1)
|
||||
: NamedSemaphore(open_or_create, name, count)
|
||||
{}
|
||||
|
||||
~lock_test_wrapper()
|
||||
{}
|
||||
|
||||
void lock()
|
||||
{ this->wait(); }
|
||||
|
||||
bool try_lock()
|
||||
{ return this->try_wait(); }
|
||||
|
||||
template<class TimePoint>
|
||||
bool timed_lock(const TimePoint &pt)
|
||||
{ return this->timed_wait(pt); }
|
||||
|
||||
template<class TimePoint> bool try_lock_until(const TimePoint &abs_time)
|
||||
{ return this->timed_lock(abs_time); }
|
||||
|
||||
template<class Duration> bool try_lock_for(const Duration &dur)
|
||||
{ return this->timed_lock(boost::interprocess::ipcdetail::duration_to_ustime(dur)); }
|
||||
|
||||
void unlock()
|
||||
{ this->post(); }
|
||||
};
|
||||
|
||||
//This wrapper is necessary to plug this class
|
||||
//in recursive tests
|
||||
template<class NamedSemaphore>
|
||||
class recursive_test_wrapper
|
||||
: public lock_test_wrapper<NamedSemaphore>
|
||||
{
|
||||
public:
|
||||
recursive_test_wrapper(create_only_t, const char *name)
|
||||
: lock_test_wrapper<NamedSemaphore>(create_only, name, RecSemCount)
|
||||
{}
|
||||
|
||||
recursive_test_wrapper(open_only_t, const char *name)
|
||||
: lock_test_wrapper<NamedSemaphore>(open_only, name)
|
||||
{}
|
||||
|
||||
recursive_test_wrapper(open_or_create_t, const char *name)
|
||||
: lock_test_wrapper<NamedSemaphore>(open_or_create, name, RecSemCount)
|
||||
{}
|
||||
};
|
||||
|
||||
template<class NamedSemaphore>
|
||||
bool test_named_semaphore_specific()
|
||||
{
|
||||
NamedSemaphore::remove(test::get_process_id_name());
|
||||
//Test persistance
|
||||
{
|
||||
NamedSemaphore sem(create_only, test::get_process_id_name(), 3);
|
||||
}
|
||||
{
|
||||
NamedSemaphore sem(open_only, test::get_process_id_name());
|
||||
BOOST_INTERPROCESS_CHECK(sem.try_wait() == true);
|
||||
BOOST_INTERPROCESS_CHECK(sem.try_wait() == true);
|
||||
BOOST_INTERPROCESS_CHECK(sem.try_wait() == true);
|
||||
BOOST_INTERPROCESS_CHECK(sem.try_wait() == false);
|
||||
sem.post();
|
||||
}
|
||||
{
|
||||
NamedSemaphore sem(open_only, test::get_process_id_name());
|
||||
BOOST_INTERPROCESS_CHECK(sem.try_wait() == true);
|
||||
BOOST_INTERPROCESS_CHECK(sem.try_wait() == false);
|
||||
}
|
||||
|
||||
NamedSemaphore::remove(test::get_process_id_name());
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class NamedSemaphore>
|
||||
int test_named_semaphore()
|
||||
{
|
||||
int ret = 0;
|
||||
BOOST_TRY{
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper<lock_test_wrapper<NamedSemaphore> > >();
|
||||
#if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper_w<lock_test_wrapper<NamedSemaphore> > >();
|
||||
#endif //defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
|
||||
test::test_all_lock< test::named_sync_wrapper<lock_test_wrapper<NamedSemaphore> > >();
|
||||
test::test_all_mutex<test::named_sync_wrapper<lock_test_wrapper<NamedSemaphore> > >();
|
||||
test::test_all_recursive_lock<test::named_sync_wrapper<recursive_test_wrapper<NamedSemaphore> > >();
|
||||
test_named_semaphore_specific<NamedSemaphore>();
|
||||
}
|
||||
BOOST_CATCH(std::exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
ret = 1;
|
||||
} BOOST_CATCH_END
|
||||
NamedSemaphore::remove(test::get_process_id_name());
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int ret;
|
||||
#if defined(BOOST_INTERPROCESS_WINDOWS)
|
||||
ret = test_named_semaphore<ipcdetail::winapi_named_semaphore>();
|
||||
if (ret)
|
||||
return ret;
|
||||
#endif
|
||||
ret = test_named_semaphore<named_semaphore>();
|
||||
|
||||
return ret;
|
||||
return test::test_named_semaphore<named_semaphore>();
|
||||
}
|
||||
|
||||
150
test/named_semaphore_test_helpers.hpp
Normal file
150
test/named_semaphore_test_helpers.hpp
Normal file
@@ -0,0 +1,150 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2024-2024. 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_INTERPROCESS_TEST_NAMED_SEMAPHORE_HELPERS_HEADER
|
||||
#define BOOST_INTERPROCESS_TEST_NAMED_SEMAPHORE_HELPERS_HEADER
|
||||
|
||||
#include <boost/interprocess/detail/config_begin.hpp>
|
||||
#include <boost/interprocess/detail/workaround.hpp>
|
||||
|
||||
#include <boost/interprocess/detail/interprocess_tester.hpp>
|
||||
#include <boost/interprocess/exceptions.hpp>
|
||||
#include "named_creation_template.hpp"
|
||||
#include "mutex_test_template.hpp"
|
||||
#include "get_process_id_name.hpp"
|
||||
#include <exception>
|
||||
#include <boost/interprocess/detail/timed_utils.hpp>
|
||||
|
||||
#include <exception>
|
||||
|
||||
namespace boost { namespace interprocess { namespace test {
|
||||
|
||||
static const std::size_t RecSemCount = 100;
|
||||
|
||||
//This wrapper is necessary to plug this class
|
||||
//in lock tests
|
||||
template<class NamedSemaphore>
|
||||
class lock_test_wrapper
|
||||
: public NamedSemaphore
|
||||
{
|
||||
public:
|
||||
|
||||
template <class CharT>
|
||||
lock_test_wrapper(create_only_t, const CharT *name, unsigned int count = 1)
|
||||
: NamedSemaphore(create_only, name, count)
|
||||
{}
|
||||
|
||||
template <class CharT>
|
||||
lock_test_wrapper(open_only_t, const CharT *name)
|
||||
: NamedSemaphore(open_only, name)
|
||||
{}
|
||||
|
||||
template <class CharT>
|
||||
lock_test_wrapper(open_or_create_t, const CharT *name, unsigned int count = 1)
|
||||
: NamedSemaphore(open_or_create, name, count)
|
||||
{}
|
||||
|
||||
~lock_test_wrapper()
|
||||
{}
|
||||
|
||||
void lock()
|
||||
{ this->wait(); }
|
||||
|
||||
bool try_lock()
|
||||
{ return this->try_wait(); }
|
||||
|
||||
template<class TimePoint>
|
||||
bool timed_lock(const TimePoint &pt)
|
||||
{ return this->timed_wait(pt); }
|
||||
|
||||
template<class TimePoint> bool try_lock_until(const TimePoint &abs_time)
|
||||
{ return this->timed_lock(abs_time); }
|
||||
|
||||
template<class Duration> bool try_lock_for(const Duration &dur)
|
||||
{ return this->timed_lock(boost::interprocess::ipcdetail::duration_to_ustime(dur)); }
|
||||
|
||||
void unlock()
|
||||
{ this->post(); }
|
||||
};
|
||||
|
||||
//This wrapper is necessary to plug this class
|
||||
//in recursive tests
|
||||
template<class NamedSemaphore>
|
||||
class recursive_test_wrapper
|
||||
: public lock_test_wrapper<NamedSemaphore>
|
||||
{
|
||||
public:
|
||||
recursive_test_wrapper(create_only_t, const char *name)
|
||||
: lock_test_wrapper<NamedSemaphore>(create_only, name, RecSemCount)
|
||||
{}
|
||||
|
||||
recursive_test_wrapper(open_only_t, const char *name)
|
||||
: lock_test_wrapper<NamedSemaphore>(open_only, name)
|
||||
{}
|
||||
|
||||
recursive_test_wrapper(open_or_create_t, const char *name)
|
||||
: lock_test_wrapper<NamedSemaphore>(open_or_create, name, RecSemCount)
|
||||
{}
|
||||
};
|
||||
|
||||
template<class NamedSemaphore>
|
||||
bool test_named_semaphore_specific()
|
||||
{
|
||||
NamedSemaphore::remove(test::get_process_id_name());
|
||||
//Test persistance
|
||||
{
|
||||
NamedSemaphore sem(create_only, test::get_process_id_name(), 3);
|
||||
}
|
||||
{
|
||||
NamedSemaphore sem(open_only, test::get_process_id_name());
|
||||
BOOST_INTERPROCESS_CHECK(sem.try_wait() == true);
|
||||
BOOST_INTERPROCESS_CHECK(sem.try_wait() == true);
|
||||
BOOST_INTERPROCESS_CHECK(sem.try_wait() == true);
|
||||
BOOST_INTERPROCESS_CHECK(sem.try_wait() == false);
|
||||
sem.post();
|
||||
}
|
||||
{
|
||||
NamedSemaphore sem(open_only, test::get_process_id_name());
|
||||
BOOST_INTERPROCESS_CHECK(sem.try_wait() == true);
|
||||
BOOST_INTERPROCESS_CHECK(sem.try_wait() == false);
|
||||
}
|
||||
|
||||
NamedSemaphore::remove(test::get_process_id_name());
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class NamedSemaphore>
|
||||
int test_named_semaphore()
|
||||
{
|
||||
int ret = 0;
|
||||
BOOST_TRY{
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper<lock_test_wrapper<NamedSemaphore> > >();
|
||||
#if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
test::test_named_creation< test::named_sync_creation_test_wrapper_w<lock_test_wrapper<NamedSemaphore> > >();
|
||||
#endif //defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
|
||||
|
||||
test::test_all_lock< test::named_sync_wrapper<lock_test_wrapper<NamedSemaphore> > >();
|
||||
test::test_all_mutex<test::named_sync_wrapper<lock_test_wrapper<NamedSemaphore> > >();
|
||||
test::test_all_recursive_lock<test::named_sync_wrapper<recursive_test_wrapper<NamedSemaphore> > >();
|
||||
test_named_semaphore_specific<NamedSemaphore>();
|
||||
}
|
||||
BOOST_CATCH(std::exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
ret = 1;
|
||||
} BOOST_CATCH_END
|
||||
NamedSemaphore::remove(test::get_process_id_name());
|
||||
return ret;
|
||||
}
|
||||
|
||||
}}} //namespace boost { namespace interprocess { namespace test {
|
||||
|
||||
#include <boost/interprocess/detail/config_end.hpp>
|
||||
|
||||
#endif //BOOST_INTERPROCESS_TEST_NAMED_SEMAPHORE_HELPERS_HEADER
|
||||
@@ -9,10 +9,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <boost/interprocess/detail/workaround.hpp>
|
||||
#if defined(BOOST_INTERPROCESS_WINDOWS)
|
||||
#include <boost/interprocess/sync/windows/recursive_mutex.hpp>
|
||||
#include <boost/interprocess/sync/spin/recursive_mutex.hpp>
|
||||
#endif
|
||||
#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
|
||||
#include <boost/interprocess/sync/scoped_lock.hpp>
|
||||
#include "mutex_test_template.hpp"
|
||||
@@ -20,17 +16,6 @@
|
||||
int main ()
|
||||
{
|
||||
using namespace boost::interprocess;
|
||||
#if defined(BOOST_INTERPROCESS_WINDOWS)
|
||||
//
|
||||
test::test_all_lock<ipcdetail::winapi_recursive_mutex>();
|
||||
test::test_all_mutex<ipcdetail::winapi_recursive_mutex>();
|
||||
test::test_all_recursive_lock<ipcdetail::winapi_recursive_mutex>();
|
||||
//
|
||||
test::test_all_lock<ipcdetail::spin_recursive_mutex>();
|
||||
test::test_all_mutex<ipcdetail::spin_recursive_mutex>();
|
||||
test::test_all_recursive_lock<ipcdetail::spin_recursive_mutex>();
|
||||
#endif
|
||||
//
|
||||
test::test_all_lock<interprocess_recursive_mutex>();
|
||||
test::test_all_mutex<interprocess_recursive_mutex>();
|
||||
test::test_all_recursive_lock<interprocess_recursive_mutex>();
|
||||
|
||||
@@ -9,65 +9,10 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <boost/interprocess/sync/interprocess_semaphore.hpp>
|
||||
#include <boost/interprocess/exceptions.hpp>
|
||||
#include "named_creation_template.hpp"
|
||||
#include "mutex_test_template.hpp"
|
||||
#include "semaphore_test_template.hpp"
|
||||
|
||||
static const std::size_t SemCount = 1;
|
||||
static const std::size_t RecSemCount = 100;
|
||||
|
||||
//This wrapper is necessary to plug this class
|
||||
//in named creation tests and interprocess_mutex tests
|
||||
class semaphore_test_wrapper
|
||||
: public boost::interprocess::interprocess_semaphore
|
||||
{
|
||||
public:
|
||||
semaphore_test_wrapper()
|
||||
: boost::interprocess::interprocess_semaphore(SemCount)
|
||||
{}
|
||||
|
||||
void lock()
|
||||
{ this->wait(); }
|
||||
|
||||
bool try_lock()
|
||||
{ return this->try_wait(); }
|
||||
|
||||
template<class TimePoint>
|
||||
bool timed_lock(const TimePoint &pt)
|
||||
{ return this->timed_wait(pt); }
|
||||
|
||||
template<class TimePoint> bool try_lock_until(const TimePoint &abs_time)
|
||||
{ return this->timed_lock(abs_time); }
|
||||
|
||||
template<class Duration> bool try_lock_for(const Duration &dur)
|
||||
{ return this->timed_lock(boost::interprocess::ipcdetail::duration_to_ustime(dur)); }
|
||||
|
||||
void unlock()
|
||||
{ this->post(); }
|
||||
|
||||
protected:
|
||||
semaphore_test_wrapper(std::size_t initial_count)
|
||||
: boost::interprocess::interprocess_semaphore(unsigned(initial_count))
|
||||
{}
|
||||
};
|
||||
|
||||
//This wrapper is necessary to plug this class
|
||||
//in recursive tests
|
||||
class recursive_semaphore_test_wrapper
|
||||
: public semaphore_test_wrapper
|
||||
{
|
||||
public:
|
||||
recursive_semaphore_test_wrapper()
|
||||
: semaphore_test_wrapper(RecSemCount)
|
||||
{}
|
||||
};
|
||||
|
||||
int main ()
|
||||
int main()
|
||||
{
|
||||
using namespace boost::interprocess;
|
||||
|
||||
test::test_all_lock<semaphore_test_wrapper>();
|
||||
test::test_all_recursive_lock<recursive_semaphore_test_wrapper>();
|
||||
test::test_all_mutex<semaphore_test_wrapper>();
|
||||
return 0;
|
||||
return test::test_all_semaphore<interprocess_semaphore>();
|
||||
}
|
||||
|
||||
101
test/semaphore_test_template.hpp
Normal file
101
test/semaphore_test_template.hpp
Normal file
@@ -0,0 +1,101 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2001-2003
|
||||
// William E. Kempf
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appear in all copies and
|
||||
// that both that copyright notice and this permission notice appear
|
||||
// in supporting documentation. William E. Kempf makes no representations
|
||||
// about the suitability of this software for any purpose.
|
||||
// It is provided "as is" without express or implied warranty.
|
||||
|
||||
#ifndef BOOST_INTERPROCESS_TEST_SEMAPHORE_TEST_TEMPLATE_HEADER
|
||||
#define BOOST_INTERPROCESS_TEST_SEMAPHORE_TEST_TEMPLATE_HEADER
|
||||
|
||||
#include <boost/interprocess/detail/config_begin.hpp>
|
||||
#include <boost/interprocess/exceptions.hpp>
|
||||
#include "named_creation_template.hpp"
|
||||
#include "mutex_test_template.hpp"
|
||||
|
||||
namespace boost { namespace interprocess { namespace test {
|
||||
|
||||
#include <boost/interprocess/exceptions.hpp>
|
||||
#include "named_creation_template.hpp"
|
||||
#include "mutex_test_template.hpp"
|
||||
|
||||
static const std::size_t SemCount = 1;
|
||||
static const std::size_t RecSemCount = 100;
|
||||
|
||||
//This wrapper is necessary to plug this class
|
||||
//in named creation tests and interprocess_mutex tests
|
||||
template<class Semaphore>
|
||||
class semaphore_test_wrapper
|
||||
: public Semaphore
|
||||
{
|
||||
public:
|
||||
semaphore_test_wrapper()
|
||||
: Semaphore(SemCount)
|
||||
{}
|
||||
|
||||
void lock()
|
||||
{ this->wait(); }
|
||||
|
||||
bool try_lock()
|
||||
{ return this->try_wait(); }
|
||||
|
||||
template<class TimePoint>
|
||||
bool timed_lock(const TimePoint &pt)
|
||||
{ return this->timed_wait(pt); }
|
||||
|
||||
template<class TimePoint> bool try_lock_until(const TimePoint &abs_time)
|
||||
{ return this->timed_lock(abs_time); }
|
||||
|
||||
template<class Duration> bool try_lock_for(const Duration &dur)
|
||||
{ return this->timed_lock(boost::interprocess::ipcdetail::duration_to_ustime(dur)); }
|
||||
|
||||
void unlock()
|
||||
{ this->post(); }
|
||||
|
||||
protected:
|
||||
semaphore_test_wrapper(std::size_t initial_count)
|
||||
: Semaphore(unsigned(initial_count))
|
||||
{}
|
||||
};
|
||||
|
||||
//This wrapper is necessary to plug this class
|
||||
//in recursive tests
|
||||
template<class Semaphore>
|
||||
class recursive_semaphore_test_wrapper
|
||||
: public semaphore_test_wrapper<Semaphore>
|
||||
{
|
||||
public:
|
||||
recursive_semaphore_test_wrapper()
|
||||
: semaphore_test_wrapper<Semaphore>(RecSemCount)
|
||||
{}
|
||||
};
|
||||
|
||||
template <class Semaphore>
|
||||
inline int test_all_semaphore()
|
||||
{
|
||||
using namespace boost::interprocess;
|
||||
|
||||
test::test_all_lock<semaphore_test_wrapper<Semaphore> >();
|
||||
test::test_all_recursive_lock<recursive_semaphore_test_wrapper<Semaphore> >();
|
||||
test::test_all_mutex<semaphore_test_wrapper<Semaphore> >();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}}} //namespace boost { namespace interprocess { namespace test {
|
||||
|
||||
#include <boost/interprocess/detail/config_end.hpp>
|
||||
|
||||
#endif //BOOST_INTERPROCESS_TEST_SEMAPHORE_TEST_TEMPLATE_HEADER
|
||||
@@ -86,24 +86,27 @@ void test_plain_sharable_mutex()
|
||||
{
|
||||
shared_val = 0;
|
||||
SM mtx;
|
||||
data<SM> s1(1);
|
||||
data<SM> s2(2);
|
||||
data<SM> e1(1);
|
||||
data<SM> e2(2);
|
||||
data<SM> s1(1);
|
||||
data<SM> s2(2);
|
||||
|
||||
// Writer one launches, holds the lock for 3*BaseMs seconds.
|
||||
boost::interprocess::ipcdetail::OS_thread_t tw1;
|
||||
boost::interprocess::ipcdetail::thread_launch(tw1, thread_adapter<SM>(plain_exclusive, &e1, mtx));
|
||||
|
||||
//Give time to e1 to grab the mutex
|
||||
boost::interprocess::ipcdetail::thread_sleep_ms(unsigned(1*BaseMs/2));
|
||||
|
||||
// Writer two launches, tries to grab the lock, "clearly"
|
||||
// after Writer one will already be holding it.
|
||||
boost::interprocess::ipcdetail::thread_sleep_ms(unsigned(1*BaseMs));
|
||||
boost::interprocess::ipcdetail::OS_thread_t tw2;
|
||||
boost::interprocess::ipcdetail::thread_launch(tw2, thread_adapter<SM>(plain_exclusive, &e2, mtx));
|
||||
|
||||
// Reader one launches, "clearly" after writer two, and "clearly"
|
||||
boost::interprocess::ipcdetail::thread_sleep_ms(unsigned(1*BaseMs/2));
|
||||
|
||||
// Readers launche, "clearly" after writer two, and "clearly"
|
||||
// while writer 1 still holds the lock
|
||||
boost::interprocess::ipcdetail::thread_sleep_ms(unsigned(1*BaseMs));
|
||||
boost::interprocess::ipcdetail::OS_thread_t thr1;
|
||||
boost::interprocess::ipcdetail::thread_launch(thr1, thread_adapter<SM>(plain_shared,&s1, mtx));
|
||||
boost::interprocess::ipcdetail::OS_thread_t thr2;
|
||||
@@ -136,7 +139,7 @@ void test_plain_sharable_mutex()
|
||||
boost::interprocess::ipcdetail::thread_launch(thr2, thread_adapter<SM>(plain_shared,&s2, mtx));
|
||||
|
||||
//Make sure they try to hold the sharable lock
|
||||
boost::interprocess::ipcdetail::thread_sleep_ms(unsigned(1*BaseMs));
|
||||
boost::interprocess::ipcdetail::thread_sleep_ms(unsigned(1*BaseMs/2u));
|
||||
|
||||
// We launch two writers, that should block until the readers end
|
||||
boost::interprocess::ipcdetail::OS_thread_t tw1;
|
||||
@@ -168,16 +171,16 @@ void test_try_sharable_mutex()
|
||||
data<SM> e2(3);
|
||||
|
||||
// We start with some specialized tests for "try" behavior
|
||||
|
||||
shared_val = 0;
|
||||
|
||||
// Writer one launches, holds the lock for 3*BaseMs seconds.
|
||||
boost::interprocess::ipcdetail::OS_thread_t tw1;
|
||||
boost::interprocess::ipcdetail::thread_launch(tw1, thread_adapter<SM>(try_exclusive,&e1,mtx));
|
||||
|
||||
boost::interprocess::ipcdetail::thread_sleep_ms(unsigned(1*BaseMs/2u));
|
||||
|
||||
// Reader one launches, "clearly" after writer #1 holds the lock
|
||||
// and before it releases the lock.
|
||||
boost::interprocess::ipcdetail::thread_sleep_ms(unsigned(1*BaseMs));
|
||||
boost::interprocess::ipcdetail::OS_thread_t thr1;
|
||||
boost::interprocess::ipcdetail::thread_launch(thr1, thread_adapter<SM>(try_shared,&s1,mtx));
|
||||
|
||||
@@ -238,9 +241,7 @@ void timed_shared(void *arg, SM &sm)
|
||||
}
|
||||
|
||||
if (r){
|
||||
if(pdata->m_msecs){
|
||||
boost::interprocess::ipcdetail::thread_sleep_ms(unsigned(pdata->m_msecs));
|
||||
}
|
||||
boost::interprocess::ipcdetail::thread_sleep_ms(unsigned(3 * BaseMs));
|
||||
pdata->m_value = shared_val;
|
||||
}
|
||||
}
|
||||
@@ -251,10 +252,10 @@ void test_timed_sharable_mutex()
|
||||
for (int flag = 0; flag != (int)ETimedLockFlagsMax; ++flag)
|
||||
{
|
||||
SM mtx;
|
||||
data<SM> s1(1,1*BaseMs, flag);
|
||||
data<SM> s2(2,3*BaseMs, flag);
|
||||
data<SM> e1(3,3*BaseMs, flag);
|
||||
data<SM> e2(4,1*BaseMs, flag);
|
||||
data<SM> e1(3, 3*BaseMs, flag);
|
||||
data<SM> e2(4, 1*BaseMs, flag);
|
||||
data<SM> s1(1, 1*BaseMs, flag);
|
||||
data<SM> s2(2, 3*BaseMs, flag);
|
||||
|
||||
// We begin with some specialized tests for "timed" behavior
|
||||
|
||||
@@ -264,7 +265,7 @@ void test_timed_sharable_mutex()
|
||||
boost::interprocess::ipcdetail::OS_thread_t tw1;
|
||||
boost::interprocess::ipcdetail::thread_launch(tw1, thread_adapter<SM>(timed_exclusive,&e1,mtx));
|
||||
|
||||
boost::interprocess::ipcdetail::thread_sleep_ms(unsigned(1*BaseMs));
|
||||
boost::interprocess::ipcdetail::thread_sleep_ms(unsigned(1*BaseMs)/2);
|
||||
// Writer two will "clearly" try for the lock after the readers
|
||||
// have tried for it. Writer will wait up 1*BaseMs seconds for the lock.
|
||||
// This write will fail.
|
||||
@@ -288,9 +289,9 @@ void test_timed_sharable_mutex()
|
||||
boost::interprocess::ipcdetail::thread_join(tw1);
|
||||
|
||||
BOOST_INTERPROCESS_CHECK(e1.m_value == 10);
|
||||
BOOST_INTERPROCESS_CHECK(e2.m_value == -1);
|
||||
BOOST_INTERPROCESS_CHECK(s1.m_value == -1);
|
||||
BOOST_INTERPROCESS_CHECK(s2.m_value == 10);
|
||||
BOOST_INTERPROCESS_CHECK(e2.m_value == -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
20
test/shm_named_condition_test.cpp
Normal file
20
test/shm_named_condition_test.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. 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 "named_condition_test_helpers.hpp"
|
||||
#include <boost/interprocess/sync/shm/named_condition.hpp>
|
||||
#include <boost/interprocess/sync/shm/named_mutex.hpp>
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
int main()
|
||||
{
|
||||
return test::test_named_condition<ipcdetail::shm_named_condition, ipcdetail::shm_named_mutex>();
|
||||
}
|
||||
19
test/shm_named_mutex_test.cpp
Normal file
19
test/shm_named_mutex_test.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. 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 "named_mutex_test_helpers.hpp"
|
||||
#include <boost/interprocess/sync/shm/named_mutex.hpp>
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
int main()
|
||||
{
|
||||
return test::test_named_mutex<ipcdetail::shm_named_mutex>();
|
||||
}
|
||||
19
test/shm_named_recursive_mutex_test.cpp
Normal file
19
test/shm_named_recursive_mutex_test.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. 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 "named_mutex_test_helpers.hpp"
|
||||
#include <boost/interprocess/sync/shm/named_recursive_mutex.hpp>
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
int main()
|
||||
{
|
||||
return test::test_named_recursive_mutex<ipcdetail::shm_named_recursive_mutex>();
|
||||
}
|
||||
19
test/shm_named_semaphore_test.cpp
Normal file
19
test/shm_named_semaphore_test.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. 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 <boost/interprocess/sync/shm/named_semaphore.hpp>
|
||||
#include "named_semaphore_test_helpers.hpp"
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
int main()
|
||||
{
|
||||
return test::test_named_semaphore<ipcdetail::shm_named_semaphore>();
|
||||
}
|
||||
25
test/spin_condition_test.cpp
Normal file
25
test/spin_condition_test.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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 <boost/interprocess/detail/workaround.hpp>
|
||||
#include "condition_test_template.hpp"
|
||||
|
||||
#include <boost/interprocess/sync/spin/condition.hpp>
|
||||
#include <boost/interprocess/sync/spin/semaphore.hpp>
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
int main ()
|
||||
{
|
||||
if(!test::do_test_condition<ipcdetail::spin_condition, ipcdetail::spin_mutex>())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
23
test/spin_mutex_test.cpp
Normal file
23
test/spin_mutex_test.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. 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 <boost/interprocess/detail/workaround.hpp>
|
||||
#include "mutex_test_template.hpp"
|
||||
|
||||
#include <boost/interprocess/sync/spin/mutex.hpp>
|
||||
|
||||
int main ()
|
||||
{
|
||||
using namespace boost::interprocess;
|
||||
|
||||
test::test_all_lock<ipcdetail::spin_mutex>();
|
||||
test::test_all_mutex<ipcdetail::spin_mutex>();
|
||||
return 0;
|
||||
}
|
||||
25
test/spin_recursive_mutex_test.cpp
Normal file
25
test/spin_recursive_mutex_test.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. 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 <boost/interprocess/detail/workaround.hpp>
|
||||
#include <boost/interprocess/sync/spin/recursive_mutex.hpp>
|
||||
#include <boost/interprocess/sync/scoped_lock.hpp>
|
||||
#include "mutex_test_template.hpp"
|
||||
|
||||
int main ()
|
||||
{
|
||||
using namespace boost::interprocess;
|
||||
//
|
||||
test::test_all_lock<ipcdetail::spin_recursive_mutex>();
|
||||
test::test_all_mutex<ipcdetail::spin_recursive_mutex>();
|
||||
test::test_all_recursive_lock<ipcdetail::spin_recursive_mutex>();
|
||||
|
||||
return 0;
|
||||
}
|
||||
18
test/spin_semaphore_test.cpp
Normal file
18
test/spin_semaphore_test.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. 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 <boost/interprocess/sync/spin/semaphore.hpp>
|
||||
#include "semaphore_test_template.hpp"
|
||||
|
||||
int main ()
|
||||
{
|
||||
using namespace boost::interprocess;
|
||||
return test::test_all_semaphore<ipcdetail::spin_semaphore>();
|
||||
}
|
||||
32
test/winapi_condition_test.cpp
Normal file
32
test/winapi_condition_test.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2012. 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 <boost/interprocess/detail/workaround.hpp>
|
||||
#include "condition_test_template.hpp"
|
||||
|
||||
#if defined(BOOST_INTERPROCESS_WINDOWS)
|
||||
#include <boost/interprocess/sync/windows/condition.hpp>
|
||||
#include <boost/interprocess/sync/windows/mutex.hpp>
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
int main ()
|
||||
{
|
||||
if(!test::do_test_condition<ipcdetail::winapi_condition, ipcdetail::winapi_mutex>())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
32
test/winapi_mutex_test.cpp
Normal file
32
test/winapi_mutex_test.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. 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 <boost/interprocess/detail/workaround.hpp>
|
||||
|
||||
#if defined(BOOST_INTERPROCESS_WINDOWS)
|
||||
#include <boost/interprocess/sync/windows/mutex.hpp>
|
||||
#include "mutex_test_template.hpp"
|
||||
|
||||
int main ()
|
||||
{
|
||||
using namespace boost::interprocess;
|
||||
|
||||
test::test_all_lock<ipcdetail::winapi_mutex>();
|
||||
test::test_all_mutex<ipcdetail::winapi_mutex>();
|
||||
return 0;
|
||||
}
|
||||
#else //BOOST_INTERPROCESS_WINDOWS
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif //BOOST_INTERPROCESS_WINDOWS
|
||||
33
test/winapi_named_condition_test.cpp
Normal file
33
test/winapi_named_condition_test.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. 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 <boost/interprocess/detail/workaround.hpp>
|
||||
|
||||
#ifdef BOOST_INTERPROCESS_WINDOWS
|
||||
#include "named_condition_test_helpers.hpp"
|
||||
|
||||
#include <boost/interprocess/sync/windows/named_condition.hpp>
|
||||
#include <boost/interprocess/sync/windows/named_mutex.hpp>
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
int main()
|
||||
{
|
||||
return test::test_named_condition<ipcdetail::winapi_named_condition, ipcdetail::winapi_named_mutex>();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
32
test/winapi_named_mutex_test.cpp
Normal file
32
test/winapi_named_mutex_test.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. 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 <boost/interprocess/detail/workaround.hpp>
|
||||
|
||||
#ifdef BOOST_INTERPROCESS_WINDOWS
|
||||
|
||||
#include "named_mutex_test_helpers.hpp"
|
||||
#include <boost/interprocess/sync/windows/named_mutex.hpp>
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
int main()
|
||||
{
|
||||
return test::test_named_mutex<ipcdetail::winapi_named_mutex>();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
32
test/winapi_named_recursive_mutex_test.cpp
Normal file
32
test/winapi_named_recursive_mutex_test.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. 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 <boost/interprocess/detail/workaround.hpp>
|
||||
|
||||
#ifdef BOOST_INTERPROCESS_WINDOWS
|
||||
|
||||
#include "named_mutex_test_helpers.hpp"
|
||||
#include <boost/interprocess/sync/windows/named_recursive_mutex.hpp>
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
int main()
|
||||
{
|
||||
return test::test_named_recursive_mutex<ipcdetail::winapi_named_recursive_mutex>();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
31
test/winapi_named_semaphore_test.cpp
Normal file
31
test/winapi_named_semaphore_test.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. 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 <boost/interprocess/detail/workaround.hpp>
|
||||
|
||||
#ifdef BOOST_INTERPROCESS_WINDOWS
|
||||
#include <boost/interprocess/sync/windows/named_semaphore.hpp>
|
||||
#include "named_semaphore_test_helpers.hpp"
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
int main()
|
||||
{
|
||||
return test::test_named_semaphore<ipcdetail::winapi_named_semaphore>();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
33
test/winapi_recursive_mutex_test.cpp
Normal file
33
test/winapi_recursive_mutex_test.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. 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 <boost/interprocess/detail/workaround.hpp>
|
||||
#if defined(BOOST_INTERPROCESS_WINDOWS)
|
||||
#include <boost/interprocess/sync/windows/recursive_mutex.hpp>
|
||||
#include "mutex_test_template.hpp"
|
||||
|
||||
int main ()
|
||||
{
|
||||
using namespace boost::interprocess;
|
||||
//
|
||||
test::test_all_lock<ipcdetail::winapi_recursive_mutex>();
|
||||
test::test_all_mutex<ipcdetail::winapi_recursive_mutex>();
|
||||
test::test_all_recursive_lock<ipcdetail::winapi_recursive_mutex>();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
28
test/winapi_semaphore_test.cpp
Normal file
28
test/winapi_semaphore_test.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2012. 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 <boost/interprocess/detail/workaround.hpp>
|
||||
#ifdef BOOST_INTERPROCESS_WINDOWS
|
||||
#include <boost/interprocess/sync/windows/semaphore.hpp>
|
||||
#include "semaphore_test_template.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::interprocess;
|
||||
return test::test_all_semaphore<ipcdetail::winapi_semaphore>();
|
||||
}
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user