]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/interprocess/test/named_mutex_test.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / interprocess / test / named_mutex_test.cpp
CommitLineData
7c673cae
FG
1//////////////////////////////////////////////////////////////////////////////
2//
3// (C) Copyright Ion Gaztanaga 2004-2012. 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
7c673cae
FG
11#include <boost/interprocess/sync/named_mutex.hpp>
12#include <boost/interprocess/sync/scoped_lock.hpp>
13#include "mutex_test_template.hpp"
14#include "named_creation_template.hpp"
7c673cae 15#include <boost/interprocess/detail/interprocess_tester.hpp>
1e59de90
TL
16#include <exception>
17
18#if defined(BOOST_INTERPROCESS_WINDOWS)
19#include <boost/interprocess/sync/windows/named_mutex.hpp>
20#endif
7c673cae
FG
21
22using namespace boost::interprocess;
23
1e59de90
TL
24template<class NamedMutex>
25int test_named_mutex()
7c673cae 26{
1e59de90
TL
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> >();
7c673cae 36 }
1e59de90 37 BOOST_CATCH(std::exception &ex){
7c673cae 38 std::cout << ex.what() << std::endl;
1e59de90
TL
39 ret = 1;
40 } BOOST_CATCH_END
41 NamedMutex::remove(test::get_process_id_name());
42 return ret;
43}
44
45int main()
46{
47 int ret;
48 #if defined(BOOST_INTERPROCESS_WINDOWS)
49 ret = test_named_mutex<ipcdetail::winapi_named_mutex>();
50 if (ret)
51 return ret;
52 #endif
53 ret = test_named_mutex<named_mutex>();
54
55 return ret;
7c673cae 56}