1 | ////////////////////////////////////////////////////////////////////////////// |
---|---|
2 | // |
3 | // (C) Copyright Ion Gaztanaga 2024-2024. Distributed under the Boost |
4 | // Software License, Version 1.0. (See accompanying file |
5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
6 | // |
7 | // See http://www.boost.org/libs/interprocess for documentation. |
8 | // |
9 | ////////////////////////////////////////////////////////////////////////////// |
10 | |
11 | #ifndef BOOST_INTERPROCESS_TEST_NAMED_MUTEX_HELPERS_HEADER |
12 | #define BOOST_INTERPROCESS_TEST_NAMED_MUTEX_HELPERS_HEADER |
13 | |
14 | #include <boost/interprocess/detail/config_begin.hpp> |
15 | #include <boost/interprocess/detail/workaround.hpp> |
16 | |
17 | #include "mutex_test_template.hpp" |
18 | #include "named_creation_template.hpp" |
19 | #include "get_process_id_name.hpp" |
20 | #include <exception> |
21 | |
22 | namespace boost { namespace interprocess { namespace test { |
23 | |
24 | template<class NamedMutex> |
25 | int test_named_mutex() |
26 | { |
27 | int ret = 0; |
28 | BOOST_TRY{ |
29 | NamedMutex::remove(test::get_process_id_name()); |
30 | test::test_named_creation< test::named_sync_creation_test_wrapper<NamedMutex> >(); |
31 | #if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) |
32 | test::test_named_creation< test::named_sync_creation_test_wrapper_w<NamedMutex> >(); |
33 | #endif //defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) |
34 | test::test_all_lock< test::named_sync_wrapper<NamedMutex> >(); |
35 | test::test_all_mutex<test::named_sync_wrapper<NamedMutex> >(); |
36 | } |
37 | BOOST_CATCH(std::exception& ex) { |
38 | std::cout << ex.what() << std::endl; |
39 | ret = 1; |
40 | } BOOST_CATCH_END |
41 | NamedMutex::remove(test::get_process_id_name()); |
42 | return ret; |
43 | } |
44 | |
45 | template<class NamedRecursiveMutex> |
46 | int test_named_recursive_mutex() |
47 | { |
48 | int ret = 0; |
49 | BOOST_TRY{ |
50 | NamedRecursiveMutex::remove(test::get_process_id_name()); |
51 | test::test_named_creation< test::named_sync_creation_test_wrapper<NamedRecursiveMutex> >(); |
52 | #if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) |
53 | test::test_named_creation< test::named_sync_creation_test_wrapper_w<NamedRecursiveMutex> >(); |
54 | #endif //defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) |
55 | test::test_all_lock< test::named_sync_wrapper<NamedRecursiveMutex> >(); |
56 | test::test_all_mutex<test::named_sync_wrapper<NamedRecursiveMutex> >(); |
57 | test::test_all_recursive_lock<test::named_sync_wrapper<NamedRecursiveMutex> >(); |
58 | } |
59 | BOOST_CATCH(std::exception& ex) { |
60 | std::cout << ex.what() << std::endl; |
61 | ret = 1; |
62 | } BOOST_CATCH_END |
63 | NamedRecursiveMutex::remove(test::get_process_id_name()); |
64 | return ret; |
65 | } |
66 | |
67 | |
68 | |
69 | }}} //namespace boost { namespace interprocess { namespace test { |
70 | |
71 | #include <boost/interprocess/detail/config_end.hpp> |
72 | |
73 | #endif //BOOST_INTERPROCESS_TEST_NAMED_MUTEX_HELPERS_HEADER |
74 |