Test files: Replace BOOST_TRY/CATCH family macros with BOOST_INTERPROCESS_TRY/CATCH

This commit is contained in:
Ion Gaztañaga
2024-08-03 22:47:34 +02:00
parent 865573a821
commit 4a011349db
36 changed files with 218 additions and 222 deletions

View File

@@ -37,7 +37,7 @@ int main ()
const int memsize = 16384;
const char *const shMemName = test::get_process_id_name();
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
shared_memory_object::remove(shMemName);
//Named allocate capable shared mem allocator
@@ -52,7 +52,7 @@ int main ()
typedef vector<InstanceCounter, inst_allocator_t> MyVect;
//We'll provoke an exception, let's see if exception handling works
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
//Fill vector until there is no more memory
MyVect myvec(myallocator);
while(true){
@@ -60,15 +60,15 @@ int main ()
myvec.push_back(a);
}
}
BOOST_CATCH(boost::interprocess::bad_alloc &){
BOOST_INTERPROCESS_CATCH(boost::interprocess::bad_alloc &){
if (InstanceCounter::counter != 0) {
std::cout << "Error: InstanceCounter::counter: " << InstanceCounter::counter;
return 1;
}
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
//We'll provoke an exception, let's see if exception handling works
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
//Fill vector at the beginning until there is no more memory
MyVect myvec(myallocator);
std::size_t i;
@@ -77,24 +77,24 @@ int main ()
myvec.insert(myvec.begin(), i, ic);
}
}
BOOST_CATCH(boost::interprocess::bad_alloc &){
BOOST_INTERPROCESS_CATCH(boost::interprocess::bad_alloc &){
if(InstanceCounter::counter != 0){
std::cout << "Error: InstanceCounter::counter: " << InstanceCounter::counter;
return 1;
}
}
BOOST_CATCH(std::length_error &){
BOOST_INTERPROCESS_CATCH(std::length_error &){
if(InstanceCounter::counter != 0){
std::cout << "Error: InstanceCounter::counter: " << InstanceCounter::counter;
return 1;
}
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
}
BOOST_CATCH(...){
BOOST_INTERPROCESS_CATCH(...){
shared_memory_object::remove(shMemName);
BOOST_RETHROW
BOOST_INTERPROCESS_RETHROW
}
BOOST_CATCH_END
BOOST_INTERPROCESS_CATCH_END
shared_memory_object::remove(shMemName);
return 0;

View File

@@ -18,7 +18,7 @@ using namespace boost::interprocess;
int main ()
{
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
const std::size_t MemSize = 99999*2;
{
//Now check anonymous mapping
@@ -43,9 +43,9 @@ int main ()
}
}
}
BOOST_CATCH(std::exception &exc){
BOOST_INTERPROCESS_CATCH(std::exception &exc){
std::cout << "Unhandled exception: " << exc.what() << std::endl;
return 1;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
return 0;
}

View File

@@ -26,7 +26,7 @@ int main ()
test::get_process_id_name(process_name);
const char *const shMemName = process_name.c_str();
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
shared_memory_object::remove(shMemName);
//Create shared memory
@@ -85,10 +85,10 @@ int main ()
return 1;
}
}
BOOST_CATCH(...){
BOOST_INTERPROCESS_CATCH(...){
shared_memory_object::remove(shMemName);
BOOST_RETHROW
} BOOST_CATCH_END
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
shared_memory_object::remove(shMemName);
return 0;
}

View File

@@ -124,7 +124,7 @@ bool do_test()
const char *const shMemName = test::get_process_id_name();
const int max = 100;
/*BOOST_TRY*/{
BOOST_INTERPROCESS_TRY{
shared_memory_object::remove(shMemName);
//Create shared memory
@@ -139,7 +139,7 @@ bool do_test()
MyStdDeque *stddeque = new MyStdDeque;
/*BOOST_TRY*/{
BOOST_INTERPROCESS_TRY{
//Compare several shared memory deque operations with std::deque
for(int i = 0; i < max*50; ++i){
IntType move_me(i);
@@ -269,18 +269,18 @@ bool do_test()
if(!segment.all_memory_deallocated())
return false;
}/*
BOOST_CATCH(std::exception &ex){
}
BOOST_INTERPROCESS_CATCH(std::exception &ex){
std::cout << ex.what() << std::endl;
return false;
} BOOST_CATCH_END*/
} BOOST_INTERPROCESS_CATCH_END
std::cout << std::endl << "Test OK!" << std::endl;
}/*
BOOST_CATCH(...){
}
BOOST_INTERPROCESS_CATCH(...){
shared_memory_object::remove(shMemName);
BOOST_RETHROW
} BOOST_CATCH_END*/
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
shared_memory_object::remove(shMemName);
return true;
}

View File

@@ -49,21 +49,21 @@ void test_enable_shared_this(ManagedMemory &managed_mem)
X v2(*p);
BOOST_TRY
BOOST_INTERPROCESS_TRY
{
//This should throw bad_weak_ptr
v_shared_ptr r = v2.shared_from_this();
BOOST_ERROR("v2.shared_from_this() failed to throw");
}
BOOST_CATCH(boost::interprocess::bad_weak_ptr const &)
BOOST_INTERPROCESS_CATCH(boost::interprocess::bad_weak_ptr const &)
{
//This is the expected path
}
BOOST_CATCH(...){
BOOST_INTERPROCESS_CATCH(...){
BOOST_ERROR("v2.shared_from_this() threw an unexpected exception");
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
BOOST_TRY
BOOST_INTERPROCESS_TRY
{
//This should not throw bad_weak_ptr
*p = X();
@@ -71,14 +71,14 @@ void test_enable_shared_this(ManagedMemory &managed_mem)
BOOST_TEST(p == r);
BOOST_TEST(!(p < r) && !(r < p));
}
BOOST_CATCH(boost::interprocess::bad_weak_ptr const &)
BOOST_INTERPROCESS_CATCH(boost::interprocess::bad_weak_ptr const &)
{
BOOST_ERROR("p->shared_from_this() threw bad_weak_ptr after *p = X()");
}
BOOST_CATCH(...)
BOOST_INTERPROCESS_CATCH(...)
{
BOOST_ERROR("p->shared_from_this() threw an unexpected exception after *p = X()");
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
}

View File

@@ -136,7 +136,7 @@ bool test_insert_with_expand_bwd()
for(std::size_t iteration = 0; iteration < Iterations; ++iteration)
{
value_type *memory = new value_type[MemorySize];
BOOST_TRY {
BOOST_INTERPROCESS_TRY {
std::vector<non_volatile_value_type> initial_data;
initial_data.resize(InitialSize[iteration]);
for(std::size_t i = 0; i < InitialSize[iteration]; ++i){
@@ -166,10 +166,10 @@ bool test_insert_with_expand_bwd()
return false;
}
}
BOOST_CATCH(...){
BOOST_INTERPROCESS_CATCH(...){
delete [](const_cast<non_volatile_value_type*>(memory));
BOOST_RETHROW
} BOOST_CATCH_END
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
delete [](const_cast<non_volatile_value_type*>(memory));
}
@@ -193,7 +193,7 @@ bool test_assign_with_expand_bwd()
for(std::size_t iteration = 0; iteration <Iterations; ++iteration)
{
value_type *memory = new value_type[MemorySize];
BOOST_TRY {
BOOST_INTERPROCESS_TRY {
//Create initial data
std::vector<non_volatile_value_type> initial_data;
initial_data.resize(InitialSize[iteration]);
@@ -227,10 +227,10 @@ bool test_assign_with_expand_bwd()
return false;
}
}
BOOST_CATCH(...){
BOOST_INTERPROCESS_CATCH(...){
delete [](const_cast<typename boost::interprocess::ipcdetail::remove_volatile<value_type>::type*>(memory));
BOOST_RETHROW
} BOOST_CATCH_END
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
delete [](const_cast<typename boost::interprocess::ipcdetail::remove_volatile<value_type>::type*>(memory));
}

View File

@@ -28,7 +28,7 @@ file_mapping get_file_mapping()
int main ()
{
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
const std::size_t FileSize = 99999*2;
{
//Create file with given size
@@ -164,11 +164,11 @@ int main ()
file_mapping ret(get_file_mapping());
}
}
BOOST_CATCH(std::exception &exc){
BOOST_INTERPROCESS_CATCH(std::exception &exc){
file_mapping::remove(get_filename().c_str());
std::cout << "Unhandled exception: " << exc.what() << std::endl;
BOOST_RETHROW
} BOOST_CATCH_END
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
file_mapping::remove(get_filename().c_str());
return 0;
}

View File

@@ -54,19 +54,19 @@ int intermodule_singleton_test()
bool exception_thrown = false;
bool exception_2_thrown = false;
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
IntermoduleType<MyThrowingClass, true, false>::get();
}
BOOST_CATCH(int &){
BOOST_INTERPROCESS_CATCH(int &){
exception_thrown = true;
//Second try
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
IntermoduleType<MyThrowingClass, true, false>::get();
}
BOOST_CATCH(interprocess_exception &){
BOOST_INTERPROCESS_CATCH(interprocess_exception &){
exception_2_thrown = true;
} BOOST_CATCH_END
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
if(!exception_thrown || !exception_2_thrown){
return 1;
@@ -79,12 +79,12 @@ int intermodule_singleton_test()
//Second try
exception_2_thrown = false;
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
IntermoduleType<MyThrowingClass, true, false>::get();
}
BOOST_CATCH(interprocess_exception &){
BOOST_INTERPROCESS_CATCH(interprocess_exception &){
exception_2_thrown = true;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
if(!exception_2_thrown){
return 1;
}
@@ -212,16 +212,16 @@ class LogDeadReferenceUser
std::cout << "~LogDeadReferenceUser(), LogSingleton: " << typeid(LogSingleton).name() << "\n" << std::endl;
//Make sure the exception is thrown as we are
//trying to use a dead non-phoenix singleton
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
LogSingleton::get().log_it();
std::string s("LogDeadReferenceUser failed for LogSingleton ");
s += typeid(LogSingleton).name();
std::cout << "~LogDeadReferenceUser(), error: " << s << std::endl;
std::abort();
}
BOOST_CATCH(interprocess_exception &){
BOOST_INTERPROCESS_CATCH(interprocess_exception &){
//Correct behaviour
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
}
};

View File

@@ -103,7 +103,7 @@ int list_test (bool copied_allocators_equal = true)
const int max = 100;
typedef push_data_function<DoublyLinked> push_data_t;
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
//Named new capable shared mem allocator
//Create shared memory
shared_memory_object::remove(shMemName);
@@ -264,10 +264,10 @@ int list_test (bool copied_allocators_equal = true)
if(!segment.all_memory_deallocated())
return 1;
}
BOOST_CATCH(...){
BOOST_INTERPROCESS_CATCH(...){
shared_memory_object::remove(shMemName);
BOOST_RETHROW
} BOOST_CATCH_END
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
shared_memory_object::remove(shMemName);
return 0;
}

View File

@@ -63,13 +63,13 @@ int main ()
{
bool throws_ok = false;
//Check memory is gone
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
managed_windows_shared_memory w_tmp(open_only, MemName);
}
BOOST_CATCH(interprocess_exception &e) {
BOOST_INTERPROCESS_CATCH(interprocess_exception &e) {
throws_ok = e.get_error_code() == not_found_error;
}
BOOST_CATCH_END
BOOST_INTERPROCESS_CATCH_END
if (!throws_ok)
return 1;
}

View File

@@ -25,14 +25,14 @@ using namespace boost::interprocess;
void remove_shared_memory(const xsi_key &key)
{
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
xsi_shared_memory xsi(open_only, key);
xsi_shared_memory::remove(xsi.get_shmid());
}
BOOST_CATCH(interprocess_exception &e){
BOOST_INTERPROCESS_CATCH(interprocess_exception &e){
if(e.get_error_code() != not_found_error)
BOOST_RETHROW
} BOOST_CATCH_END
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
}
class xsi_shared_memory_remover

View File

@@ -52,7 +52,7 @@ int map_test ()
const char *const shMemName = test::get_process_id_name();
const int max = 100;
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
//Create shared memory
shared_memory_object::remove(shMemName);
ManagedSharedMemory segment(create_only, shMemName, Memsize);
@@ -484,10 +484,10 @@ int map_test ()
if(!segment.all_memory_deallocated())
return 1;
}
BOOST_CATCH(...){
BOOST_INTERPROCESS_CATCH(...){
shared_memory_object::remove(shMemName);
BOOST_RETHROW
} BOOST_CATCH_END
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
shared_memory_object::remove(shMemName);
return 0;
}
@@ -507,7 +507,7 @@ int map_test_copyable ()
const char *const shMemName = test::get_process_id_name();
const int max = 100;
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
//Create shared memory
shared_memory_object::remove(shMemName);
ManagedSharedMemory segment(create_only, shMemName, Memsize);
@@ -578,10 +578,10 @@ int map_test_copyable ()
if(!segment.all_memory_deallocated())
return 1;
}
BOOST_CATCH(...){
BOOST_INTERPROCESS_CATCH(...){
shared_memory_object::remove(shMemName);
BOOST_RETHROW
} BOOST_CATCH_END
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
shared_memory_object::remove(shMemName);
return 0;
}

View File

@@ -153,14 +153,14 @@ bool test_serialize_db()
return false;
//Fill map1 until is full
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
std::size_t i = 0;
while(1){
(*map1)[i] = i;
++i;
}
}
BOOST_CATCH(boost::interprocess::bad_alloc &){} BOOST_CATCH_END
BOOST_INTERPROCESS_CATCH(boost::interprocess::bad_alloc &){} BOOST_INTERPROCESS_CATCH_END
//Data control data sending through the message queue
std::size_t sent = 0;
@@ -305,13 +305,13 @@ static void multireceive()
{
char buff;
size_t size;
int received_msgs = 0;
//int received_msgs = 0;
unsigned int priority;
do {
global_queue->receive(&buff, 1, size, priority);
++received_msgs;
//++received_msgs;
} while (size > 0);
--received_msgs;
//--received_msgs;
//std::cout << "reader thread complete, read msgs: " << received_msgs << std::endl;
}
@@ -320,7 +320,7 @@ bool test_multi_sender_receiver()
{
bool ret = true;
//std::cout << "Testing multi-sender / multi-receiver " << std::endl;
BOOST_TRY {
BOOST_INTERPROCESS_TRY {
boost::interprocess::message_queue::remove(test::get_process_id_name());
boost::interprocess::message_queue mq
(boost::interprocess::open_or_create, test::get_process_id_name(), MULTI_QUEUE_SIZE, 1);
@@ -343,10 +343,10 @@ bool test_multi_sender_receiver()
//std::cout << "Joined thread " << i << std::endl;
}
}
BOOST_CATCH(std::exception &e) {
BOOST_INTERPROCESS_CATCH(std::exception &e) {
std::cout << "error " << e.what() << std::endl;
ret = false;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
boost::interprocess::message_queue::remove(test::get_process_id_name());
return ret;
}
@@ -402,7 +402,7 @@ class msg_queue_named_test_wrapper_w
int main ()
{
int ret = 0;
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
message_queue::remove(test::get_process_id_name());
test::test_named_creation<msg_queue_named_test_wrapper>();
#if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
@@ -425,10 +425,10 @@ int main ()
return 1;
}
}
BOOST_CATCH(std::exception &ex) {
BOOST_INTERPROCESS_CATCH(std::exception &ex) {
std::cout << ex.what() << std::endl;
ret = 1;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
message_queue::remove(test::get_process_id_name());
return ret;

View File

@@ -35,7 +35,7 @@ typedef list<int, allocator<int, managed_shared_memory::segment_manager> >
int main(int argc, char *argv[])
{
std::string p_or_c = argc == 1 ? "parent" : "child";
BOOST_TRY {
BOOST_INTERPROCESS_TRY {
if(argc == 1){ //Parent process
shm_remove remover; (void)remover;
shared_memory_object::remove(test::get_process_id_name());
@@ -95,17 +95,17 @@ int main(int argc, char *argv[])
my_sem->post();
}
}
BOOST_CATCH(interprocess_exception &e){
BOOST_INTERPROCESS_CATCH(interprocess_exception &e){
std::cerr << p_or_c << " -> interprocess_exception::what(): " << e.what()
<< " native error: " << e.get_native_error()
<< " error code: " << e.get_error_code() << '\n';
return 2;
}
BOOST_CATCH(std::exception &e){
BOOST_INTERPROCESS_CATCH(std::exception &e){
std::cerr << p_or_c << " -> std::exception::what(): " << e.what() << '\n';
return 3;
}
BOOST_CATCH_END
BOOST_INTERPROCESS_CATCH_END
std::cerr << p_or_c << " -> Normal termination\n";

View File

@@ -74,17 +74,17 @@ int test_owner_dead_mutex_impl(EOwnerDeadLockType lock_type)
ipcdetail::OS_thread_t tm1;
ipcdetail::thread_launch(tm1, thread_adapter<M>(&lock_and_exit, 0, mtx));
ipcdetail::thread_join(tm1);
BOOST_TRY {
BOOST_INTERPROCESS_TRY {
test_owner_dead_mutex_do_lock(mtx, lock_type);
}
BOOST_CATCH(lock_exception& e) {
BOOST_INTERPROCESS_CATCH(lock_exception& e) {
#ifndef BOOST_NO_EXCEPTIONS
if (e.get_error_code() == not_recoverable){
//Now try once again to lock it, to make sure it's not recoverable
BOOST_TRY {
BOOST_INTERPROCESS_TRY {
test_owner_dead_mutex_do_lock(mtx, lock_type);
}
BOOST_CATCH(lock_exception& e) {
BOOST_INTERPROCESS_CATCH(lock_exception& e) {
if (e.get_error_code() == not_recoverable)
return 0;
else{
@@ -92,10 +92,10 @@ int test_owner_dead_mutex_impl(EOwnerDeadLockType lock_type)
return 3;
}
}
BOOST_CATCH(...) {
BOOST_INTERPROCESS_CATCH(...) {
std::cerr << "lock_exception not thrown! (2)";
return 4;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
std::cerr << "Exception not thrown (2)!";
return 5;
}
@@ -105,10 +105,10 @@ int test_owner_dead_mutex_impl(EOwnerDeadLockType lock_type)
}
#endif //BOOST_NO_EXCEPTIONS
}
BOOST_CATCH(...) {
BOOST_INTERPROCESS_CATCH(...) {
std::cerr << "lock_exception not thrown!";
return 2;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
std::cerr << "Exception not thrown!";
return 3;
}

View File

@@ -193,15 +193,15 @@ void lock_and_sleep(void *arg, M &sm)
template<typename M>
void lock_and_catch_errors(void *arg, M &sm)
{
BOOST_TRY
BOOST_INTERPROCESS_TRY
{
lock_and_sleep(arg, sm);
}
BOOST_CATCH(interprocess_exception const & e)
BOOST_INTERPROCESS_CATCH(interprocess_exception const & e)
{
data<M>* pdata = static_cast<data<M>*>(arg);
pdata->m_error = e.get_error_code();
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
}
template<typename M>

View File

@@ -437,7 +437,7 @@ bool test_named_allocation()
const int memsize = 163840;
const char *const shMemName = test::get_process_id_name();
BOOST_TRY
BOOST_INTERPROCESS_TRY
{
//A shared memory with rbtree best fit algorithm
typedef basic_managed_shared_memory
@@ -455,14 +455,14 @@ bool test_named_allocation()
return false;
}
}
BOOST_CATCH(...){
BOOST_INTERPROCESS_CATCH(...){
shared_memory_object::remove(shMemName);
BOOST_RETHROW
} BOOST_CATCH_END
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
shared_memory_object::remove(shMemName);
//Now test it with wchar_t
BOOST_TRY
BOOST_INTERPROCESS_TRY
{
//A shared memory with simple sequential fit algorithm
typedef basic_managed_shared_memory
@@ -480,10 +480,10 @@ bool test_named_allocation()
return false;
}
}
BOOST_CATCH(...){
BOOST_INTERPROCESS_CATCH(...){
shared_memory_object::remove(shMemName);
BOOST_RETHROW
} BOOST_CATCH_END
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
shared_memory_object::remove(shMemName);
return true;

View File

@@ -240,7 +240,7 @@ template<class NamedCondition, class NamedMutex>
int test_named_condition()
{
int ret = 0;
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
//Remove previous mutexes and conditions
NamedMutex::remove(test::add_to_process_id_name("test_mutex0"));
NamedCondition::remove(test::add_to_process_id_name("test_cond0"));
@@ -261,10 +261,10 @@ int test_named_condition()
test::do_test_condition<test::named_condition_test_wrapper<NamedCondition>
,test::named_mutex_test_wrapper<NamedMutex> >();
}
BOOST_CATCH(std::exception &ex){
BOOST_INTERPROCESS_CATCH(std::exception &ex){
std::cout << ex.what() << std::endl;
ret = 1;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
NamedMutex::remove(test::add_to_process_id_name("test_mutex0"));
NamedCondition::remove(test::add_to_process_id_name("test_cond0"));
NamedCondition::remove(test::add_to_process_id_name("test_cond1"));

View File

@@ -24,16 +24,16 @@ namespace boost { namespace interprocess { namespace test {
template <class NamedResource>
inline void create_then_open_then_open_or_create()
{
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
//Create it and open it twice
NamedResource nresource1(create_only);
NamedResource nresource2(open_only);
NamedResource nresource3(open_or_create);
}
BOOST_CATCH(...){
BOOST_INTERPROCESS_CATCH(...){
//This shouldn't throw so show the error
BOOST_INTERPROCESS_CHECK( false );
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
}
template <class NamedResource>
@@ -41,25 +41,25 @@ inline void open_or_create_then_create()
{
//Create it with open_or_create and try to create it twice
NamedResource nresource1(open_or_create);
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
NamedResource nresource2(create_only);
}
BOOST_CATCH(interprocess_exception &err){
BOOST_INTERPROCESS_CATCH(interprocess_exception &err){
BOOST_INTERPROCESS_CHECK(err.get_error_code() == already_exists_error);
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
}
template <class NamedResource>
inline void dont_create_and_open()
{
//Try to open it without creating
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
NamedResource nresource1(open_only);
}
BOOST_CATCH(interprocess_exception &err){
BOOST_INTERPROCESS_CATCH(interprocess_exception &err){
BOOST_INTERPROCESS_CHECK(err.get_error_code() == not_found_error);
return;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
//The mutex should not exist
BOOST_INTERPROCESS_CHECK(false);
}

View File

@@ -25,7 +25,7 @@ template<class NamedMutex>
int test_named_mutex()
{
int ret = 0;
BOOST_TRY{
BOOST_INTERPROCESS_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)
@@ -34,10 +34,10 @@ int test_named_mutex()
test::test_all_lock< test::named_sync_wrapper<NamedMutex> >();
test::test_all_mutex<test::named_sync_wrapper<NamedMutex> >();
}
BOOST_CATCH(std::exception& ex) {
BOOST_INTERPROCESS_CATCH(std::exception& ex) {
std::cout << ex.what() << std::endl;
ret = 1;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
NamedMutex::remove(test::get_process_id_name());
return ret;
}
@@ -46,7 +46,7 @@ template<class NamedRecursiveMutex>
int test_named_recursive_mutex()
{
int ret = 0;
BOOST_TRY{
BOOST_INTERPROCESS_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)
@@ -56,10 +56,10 @@ int test_named_recursive_mutex()
test::test_all_mutex<test::named_sync_wrapper<NamedRecursiveMutex> >();
test::test_all_recursive_lock<test::named_sync_wrapper<NamedRecursiveMutex> >();
}
BOOST_CATCH(std::exception& ex) {
BOOST_INTERPROCESS_CATCH(std::exception& ex) {
std::cout << ex.what() << std::endl;
ret = 1;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
NamedRecursiveMutex::remove(test::get_process_id_name());
return ret;
}

View File

@@ -124,7 +124,7 @@ template<class NamedSemaphore>
int test_named_semaphore()
{
int ret = 0;
BOOST_TRY{
BOOST_INTERPROCESS_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> > >();
@@ -135,10 +135,10 @@ int test_named_semaphore()
test::test_all_recursive_lock<test::named_sync_wrapper<recursive_test_wrapper<NamedSemaphore> > >();
test_named_semaphore_specific<NamedSemaphore>();
}
BOOST_CATCH(std::exception &ex){
BOOST_INTERPROCESS_CATCH(std::exception &ex){
std::cout << ex.what() << std::endl;
ret = 1;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
NamedSemaphore::remove(test::get_process_id_name());
return ret;
}

View File

@@ -20,7 +20,7 @@ using namespace boost::interprocess;
int main ()
{
int ret = 0;
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
named_sharable_mutex::remove(test::get_process_id_name());
test::test_named_creation< test::named_sync_creation_test_wrapper<named_sharable_mutex> >();
#if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
@@ -30,10 +30,10 @@ int main ()
test::test_all_mutex<test::named_sync_wrapper<named_sharable_mutex> >();
test::test_all_sharable_mutex<test::named_sync_wrapper<named_sharable_mutex> >();
}
BOOST_CATCH(std::exception &ex){
BOOST_INTERPROCESS_CATCH(std::exception &ex){
std::cout << ex.what() << std::endl;
ret = 1;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
named_sharable_mutex::remove(test::get_process_id_name());
return ret;
}

View File

@@ -20,7 +20,7 @@ using namespace boost::interprocess;
int main ()
{
int ret = 0;
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
named_upgradable_mutex::remove(test::get_process_id_name());
test::test_named_creation< test::named_sync_creation_test_wrapper<named_upgradable_mutex> >();
#if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES)
@@ -30,10 +30,10 @@ int main ()
test::test_all_mutex<test::named_sync_wrapper<named_upgradable_mutex> >();
test::test_all_sharable_mutex<test::named_sync_wrapper<named_upgradable_mutex> >();
}
BOOST_CATCH(std::exception &ex){
BOOST_INTERPROCESS_CATCH(std::exception &ex){
std::cout << ex.what() << std::endl;
ret = 1;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
named_upgradable_mutex::remove(test::get_process_id_name());
return ret;
}

View File

@@ -28,7 +28,7 @@ namespace test{
template<class RobustMutex>
int robust_mutex_test(int argc, char *argv[])
{
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
if(argc == 1){ //Parent process
//First usual mutex tests
{
@@ -101,12 +101,12 @@ int robust_mutex_test(int argc, char *argv[])
instance[1].unlock();
//Since it's NOT consistent, locking is NOT possible again
bool exception_thrown = false;
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
instance[1].lock();
}
BOOST_CATCH(interprocess_exception &){
BOOST_INTERPROCESS_CATCH(interprocess_exception &){
exception_thrown = true;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
if(!exception_thrown){
return 1;
}
@@ -125,12 +125,12 @@ int robust_mutex_test(int argc, char *argv[])
instance[2].unlock();
//Since it's NOT consistent, locking is NOT possible again
bool exception_thrown = false;
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
instance[2].lock();
}
BOOST_CATCH(interprocess_exception &){
BOOST_INTERPROCESS_CATCH(interprocess_exception &){
exception_thrown = true;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
if(!exception_thrown){
return 1;
}
@@ -192,10 +192,10 @@ int robust_mutex_test(int argc, char *argv[])
*go_ahead2 = true;
}
}
}BOOST_CATCH(...){
}BOOST_INTERPROCESS_CATCH(...){
std::cout << "Exception thrown error!" << std::endl;
BOOST_RETHROW
} BOOST_CATCH_END
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
return 0;
}

View File

@@ -93,7 +93,7 @@ bool test_segment_manager()
return false;
if(seg_mgr->get_free_memory() != free_mem_before)
return false;
BOOST_TRY{ seg_mgr->allocate(ShmSizeSize*2); }BOOST_CATCH(interprocess_exception&){} BOOST_CATCH_END
BOOST_INTERPROCESS_TRY{ seg_mgr->allocate(ShmSizeSize*2); }BOOST_INTERPROCESS_CATCH(interprocess_exception&){} BOOST_INTERPROCESS_CATCH_END
if(seg_mgr->get_free_memory() != free_mem_before)
return false;
if(seg_mgr->allocate(ShmSizeSize*2, std::nothrow))
@@ -121,7 +121,7 @@ bool test_segment_manager()
return false;
if(seg_mgr->get_free_memory() != free_mem_before)
return false;
BOOST_TRY{ seg_mgr->allocate_aligned(ShmSizeSize*2, Alignment); }BOOST_CATCH(interprocess_exception&){} BOOST_CATCH_END
BOOST_INTERPROCESS_TRY{ seg_mgr->allocate_aligned(ShmSizeSize*2, Alignment); }BOOST_INTERPROCESS_CATCH(interprocess_exception&){} BOOST_INTERPROCESS_CATCH_END
if(seg_mgr->get_free_memory() != free_mem_before)
return false;
if(seg_mgr->allocate_aligned(ShmSizeSize*2, Alignment, std::nothrow))
@@ -210,9 +210,9 @@ bool test_segment_manager()
if(seg_mgr->get_instance_name(int_array))
return false;
seg_mgr->destroy_ptr(int_array);
BOOST_TRY{ seg_mgr->template construct<int>(anonymous_instance)[ShmSizeSize](); }BOOST_CATCH(interprocess_exception&){} BOOST_CATCH_END
BOOST_INTERPROCESS_TRY{ seg_mgr->template construct<int>(anonymous_instance)[ShmSizeSize](); }BOOST_INTERPROCESS_CATCH(interprocess_exception&){} BOOST_INTERPROCESS_CATCH_END
if(seg_mgr->template construct<int>(anonymous_instance, std::nothrow)[ShmSizeSize]())
BOOST_TRY{ seg_mgr->template construct_it<long int>(anonymous_instance)[ShmSizeSize](&int_array_values[0]); }BOOST_CATCH(interprocess_exception&){} BOOST_CATCH_END
BOOST_INTERPROCESS_TRY{ seg_mgr->template construct_it<long int>(anonymous_instance)[ShmSizeSize](&int_array_values[0]); }BOOST_INTERPROCESS_CATCH(interprocess_exception&){} BOOST_INTERPROCESS_CATCH_END
if(seg_mgr->template construct_it<int>(anonymous_instance, std::nothrow)[ShmSizeSize](&int_array_values[0]))
return false;
if(seg_mgr->get_free_memory() != free_mem_before)
@@ -295,9 +295,9 @@ bool test_segment_manager()
seg_mgr->destroy_ptr(uint_object);
seg_mgr->template destroy<int>(object2_name);
}
BOOST_TRY{ seg_mgr->template construct<unsigned int>(object1_name)[ShmSizeSize](); }BOOST_CATCH(interprocess_exception&){} BOOST_CATCH_END
BOOST_INTERPROCESS_TRY{ seg_mgr->template construct<unsigned int>(object1_name)[ShmSizeSize](); }BOOST_INTERPROCESS_CATCH(interprocess_exception&){} BOOST_INTERPROCESS_CATCH_END
if(seg_mgr->template construct<int>(object2_name, std::nothrow)[ShmSizeSize]())
BOOST_TRY{ seg_mgr->template construct_it<int>(object1_name)[ShmSizeSize](&int_array_values[0]); }BOOST_CATCH(interprocess_exception&){} BOOST_CATCH_END
BOOST_INTERPROCESS_TRY{ seg_mgr->template construct_it<int>(object1_name)[ShmSizeSize](&int_array_values[0]); }BOOST_INTERPROCESS_CATCH(interprocess_exception&){} BOOST_INTERPROCESS_CATCH_END
if(seg_mgr->template construct_it<int>(object2_name, std::nothrow)[ShmSizeSize](&int_array_values[0]))
return false;
seg_mgr->shrink_to_fit_indexes();
@@ -385,9 +385,9 @@ bool test_segment_manager()
seg_mgr->destroy_ptr(uint_object);
seg_mgr->template destroy<int>(unique_instance);
}
BOOST_TRY{ seg_mgr->template construct<unsigned int>(unique_instance)[ShmSizeSize](); }BOOST_CATCH(interprocess_exception&){} BOOST_CATCH_END
BOOST_INTERPROCESS_TRY{ seg_mgr->template construct<unsigned int>(unique_instance)[ShmSizeSize](); }BOOST_INTERPROCESS_CATCH(interprocess_exception&){} BOOST_INTERPROCESS_CATCH_END
if(seg_mgr->template construct<int>(unique_instance, std::nothrow)[ShmSizeSize]())
BOOST_TRY{ seg_mgr->template construct_it<long int>(unique_instance)[ShmSizeSize](&int_array_values[0]); }BOOST_CATCH(interprocess_exception&){} BOOST_CATCH_END
BOOST_INTERPROCESS_TRY{ seg_mgr->template construct_it<long int>(unique_instance)[ShmSizeSize](&int_array_values[0]); }BOOST_INTERPROCESS_CATCH(interprocess_exception&){} BOOST_INTERPROCESS_CATCH_END
if(seg_mgr->template construct_it<int>(unique_instance, std::nothrow)[ShmSizeSize](&int_array_values[0]))
return false;
seg_mgr->shrink_to_fit_indexes();

View File

@@ -35,7 +35,7 @@ int set_test ()
const char *const shMemName = test::get_process_id_name();
const int max = 100;
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
//Create shared memory
shared_memory_object::remove(shMemName);
ManagedSharedMemory segment(create_only, shMemName, Memsize);
@@ -492,10 +492,10 @@ int set_test ()
return 1;
}
}
BOOST_CATCH(...){
BOOST_INTERPROCESS_CATCH(...){
shared_memory_object::remove(shMemName);
BOOST_RETHROW
} BOOST_CATCH_END
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
shared_memory_object::remove(shMemName);
return 0;
}
@@ -512,7 +512,7 @@ int set_test_copyable ()
const char *const shMemName = test::get_process_id_name();
const int max = 100;
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
//Create shared memory
shared_memory_object::remove(shMemName);
ManagedSharedMemory segment(create_only, shMemName, Memsize);
@@ -579,10 +579,10 @@ int set_test_copyable ()
if(!segment.all_memory_deallocated())
return 1;
}
BOOST_CATCH(...){
BOOST_INTERPROCESS_CATCH(...){
shared_memory_object::remove(shMemName);
BOOST_RETHROW
} BOOST_CATCH_END
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
shared_memory_object::remove(shMemName);
return 0;
}

View File

@@ -29,7 +29,7 @@ int main ()
std::string process_id = test::get_process_id_name();
std::string process_id2(process_id);
process_id2 += "_2";
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
const std::size_t FileSize = 99999*4;
{
//Remove shared memory
@@ -200,19 +200,19 @@ int main ()
mapped_region region (mapping, read_only);
shared_memory_object mapping2(create_only, process_id2.c_str(), read_write);
mapping2.truncate(FileSize);
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
mapped_region region2 (mapping2, read_only, 0, FileSize, region.get_address());
}
BOOST_CATCH(interprocess_exception &e){
BOOST_INTERPROCESS_CATCH(interprocess_exception &e){
shared_memory_object::remove(process_id2.c_str());
if(e.get_error_code() != busy_error){
throw e;
}
}
BOOST_CATCH(std::exception &){
BOOST_INTERPROCESS_CATCH(std::exception &){
shared_memory_object::remove(process_id2.c_str());
BOOST_RETHROW
} BOOST_CATCH_END
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
shared_memory_object::remove(process_id2.c_str());
}
{
@@ -246,12 +246,12 @@ int main ()
shared_memory_object ret(get_shared_memory_mapping());
}
}
BOOST_CATCH(std::exception &exc){
BOOST_INTERPROCESS_CATCH(std::exception &exc){
shared_memory_object::remove(process_id.c_str());
shared_memory_object::remove(process_id2.c_str());
std::cout << "Unhandled exception: " << exc.what() << std::endl;
return 1;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
shared_memory_object::remove(process_id.c_str());
return 0;
}

View File

@@ -81,7 +81,7 @@ class shared_memory_creation_test_wrapper_w
int main ()
{
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
shared_memory_object::remove(ShmName);
test::test_named_creation<shared_memory_creation_test_wrapper>();
#ifdef BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES
@@ -102,11 +102,11 @@ int main ()
move_assign = boost::move(move_ctor);
}
}
BOOST_CATCH(std::exception &ex){
BOOST_INTERPROCESS_CATCH(std::exception &ex){
shared_memory_object::remove(ShmName);
std::cout << ex.what() << std::endl;
return 1;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
shared_memory_object::remove(ShmName);
return 0;
}

View File

@@ -230,14 +230,14 @@ int string_shared_ptr_vector_insertion_test()
}
bool success = false;
//Now this should throw
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
string_shared_ptr_t dummy(*beg);
//We should never reach here
return 1;
}
BOOST_CATCH(const boost::interprocess::bad_weak_ptr &){
BOOST_INTERPROCESS_CATCH(const boost::interprocess::bad_weak_ptr &){
success = true;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
if(!success){
return 1;
}
@@ -466,12 +466,12 @@ int basic_shared_ptr_test()
BOOST_TEST(wp1.expired());
BOOST_TEST(wp1.use_count() == 0);
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
x_shared_ptr sp1(wp1);
BOOST_ERROR("shared_ptr<X, A, D> sp1(wp1) failed to throw");
}
BOOST_CATCH(boost::interprocess::bad_weak_ptr const &)
{} BOOST_CATCH_END
BOOST_INTERPROCESS_CATCH(boost::interprocess::bad_weak_ptr const &)
{} BOOST_INTERPROCESS_CATCH_END
test_is_zero(wp1.lock());

View File

@@ -42,7 +42,7 @@ int main()
{
//Remove any other old shared memory from the system
bip::shared_memory_object::remove(bip::test::get_process_id_name());
BOOST_TRY {
BOOST_INTERPROCESS_TRY {
bip::managed_shared_memory shm(bip::create_only, bip::test::get_process_id_name(), 65536);
//Elements to be inserted in unordered containers
@@ -91,11 +91,11 @@ int main()
return 1;
}
BOOST_CATCH(...){
BOOST_INTERPROCESS_CATCH(...){
//Remove shared memory from the system
bip::shared_memory_object::remove(bip::test::get_process_id_name());
BOOST_RETHROW
} BOOST_CATCH_END
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
//Remove shared memory from the system
bip::shared_memory_object::remove(bip::test::get_process_id_name());
return 0;

View File

@@ -131,22 +131,18 @@ int main ()
if(!CheckEqual(userlist, stdlist, heaplist)) return 1;
std::vector<int> aux_vect;
#if !BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
aux_vect.assign(50, -1);
userlist->assign(aux_vect.begin(), aux_vect.end());
heaplist->assign(aux_vect.begin(), aux_vect.end());
stdlist->assign(aux_vect.begin(), aux_vect.end());
if(!CheckEqual(userlist, stdlist, heaplist)) return 1;
#endif
userlist->sort();
heaplist->sort();
stdlist->sort();
if(!CheckEqual(userlist, stdlist, heaplist)) return 1;
#if !BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
aux_vect.assign(50, 0);
#endif
userlist->insert(userlist->begin(), aux_vect.begin(), aux_vect.end());
heaplist->insert(heaplist->begin(), aux_vect.begin(), aux_vect.end());
stdlist->insert(stdlist->begin(), aux_vect.begin(), aux_vect.end());
@@ -204,12 +200,12 @@ int main ()
delete stdlist;
//Fill heap buffer until is full
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
while(1){
heaplist->insert(heaplist->end(), 0);
}
}
BOOST_CATCH(boost::interprocess::bad_alloc &){} BOOST_CATCH_END
BOOST_INTERPROCESS_CATCH(boost::interprocess::bad_alloc &){} BOOST_INTERPROCESS_CATCH_END
MyHeapList::size_type heap_list_size = heaplist->size();
@@ -237,12 +233,12 @@ int main ()
}
//Fill user buffer until is full
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
while(1){
userlist->insert(userlist->end(), 0);
}
}
BOOST_CATCH(boost::interprocess::bad_alloc &){} BOOST_CATCH_END
BOOST_INTERPROCESS_CATCH(boost::interprocess::bad_alloc &){} BOOST_INTERPROCESS_CATCH_END
MyUserList::size_type user_list_size = userlist->size();

View File

@@ -89,7 +89,7 @@ int vector_test()
//Compare several shared memory vector operations with std::vector
//Create shared memory
shared_memory_object::remove(shMemName);
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
ManagedSharedMemory segment(create_only, shMemName, Memsize);
segment.reserve_named_objects(10);
@@ -233,11 +233,11 @@ int vector_test()
if(!segment.all_memory_deallocated())
return 1;
}
BOOST_CATCH(std::exception &ex){
BOOST_INTERPROCESS_CATCH(std::exception &ex){
shared_memory_object::remove(shMemName);
std::cout << ex.what() << std::endl;
return 1;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
}
shared_memory_object::remove(shMemName);
std::cout << std::endl << "Test OK!" << std::endl;

View File

@@ -125,7 +125,7 @@ class shared_memory_creation_test_wrapper_w
int main ()
{
int ret = 0;
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
shared_memory_object::remove(ShmName);
test::test_named_creation<shared_memory_creation_test_wrapper>();
#ifdef BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES
@@ -146,10 +146,10 @@ int main ()
move_assign = boost::move(move_ctor);
}
}
BOOST_CATCH(std::exception &ex){
BOOST_INTERPROCESS_CATCH(std::exception &ex){
std::cout << ex.what() << std::endl;
ret = 1;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
shared_memory_object::remove(ShmName);
return ret;
}

View File

@@ -23,7 +23,7 @@ using namespace boost::interprocess;
int main ()
{
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
const char *names[2] = { test::get_process_id_name(), 0 };
for(unsigned int i_name = 0; i_name < sizeof(names)/sizeof(names[0]); ++i_name)
{
@@ -116,11 +116,11 @@ int main ()
}
}
}
BOOST_CATCH(std::exception &exc){
BOOST_INTERPROCESS_CATCH(std::exception &exc){
//shared_memory_object::remove(test::get_process_id_name());
std::cout << "Unhandled exception: " << exc.what() << std::endl;
return 1;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
return 0;
}

View File

@@ -84,16 +84,16 @@ class shared_memory_creation_test_wrapper_w
int main ()
{
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
test::test_named_creation<shared_memory_creation_test_wrapper>();
#ifdef BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES
test::test_named_creation<shared_memory_creation_test_wrapper_w>();
#endif
}
BOOST_CATCH(std::exception &ex){
BOOST_INTERPROCESS_CATCH(std::exception &ex){
std::cout << ex.what() << std::endl;
return 1;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
return 0;
}

View File

@@ -27,14 +27,14 @@ using namespace boost::interprocess;
void remove_shared_memory(const xsi_key &key)
{
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
xsi_shared_memory xsi(open_only, key);
xsi_shared_memory::remove(xsi.get_shmid());
}
BOOST_CATCH(interprocess_exception &e){
BOOST_INTERPROCESS_CATCH(interprocess_exception &e){
if(e.get_error_code() != not_found_error)
BOOST_RETHROW
} BOOST_CATCH_END
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
}
class xsi_shared_memory_remover
@@ -63,27 +63,27 @@ int main ()
remove_shared_memory(key);
unsigned int i;
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
for(i = 0; i < sizeof(names)/sizeof(names[0]); ++i)
{
const std::size_t FileSize = 16*1024;
//Create a file mapping
xsi_shared_memory mapping (create_only, names[i] ? key : xsi_key(), FileSize);
xsi_shared_memory_remover rem(mapping);
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
{
//Partial mapping should fail fox XSI shared memory
bool thrown = false;
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
mapped_region region2(mapping, read_write, FileSize/2, FileSize - FileSize/2, 0);
}
BOOST_CATCH(...){
BOOST_INTERPROCESS_CATCH(...){
thrown = true;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
if(thrown == false){
return 1;
}
BOOST_TRY{
BOOST_INTERPROCESS_TRY{
//Create a mapped region
mapped_region region (mapping, read_write, 0, FileSize, 0);
@@ -93,9 +93,9 @@ int main ()
*filler++ = static_cast<unsigned char>(i);
}
}
BOOST_CATCH(std::exception& exc){
BOOST_INTERPROCESS_CATCH(std::exception& exc){
std::cout << "Unhandled exception 0: " << exc.what() << " name: " << (names[i] ? names[i] : "null") << std::endl;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
}
//Now check the pattern mapping a single read only mapped_region
@@ -112,16 +112,16 @@ int main ()
}
}
}
BOOST_CATCH(std::exception &exc){
BOOST_INTERPROCESS_CATCH(std::exception &exc){
std::cout << "Unhandled exception 1: " << exc.what() << " name: " << (names[i] ? names[i] : "null") << std::endl;
return 1;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
}
}
BOOST_CATCH(std::exception &exc){
BOOST_INTERPROCESS_CATCH(std::exception &exc){
std::cout << "Unhandled exception 2: " << exc.what() << " name: " << (names[i] ? names[i] : "null") << std::endl;
return 1;
} BOOST_CATCH_END
} BOOST_INTERPROCESS_CATCH_END
return 0;
}