File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 99namespace CppUtils2
1010{
1111
12+ inline Result unlink (const std::string &path)
13+ {
14+ auto ret = std::remove (path.c_str ());
15+ if (ret == 0 )
16+ {
17+ return Result::RET_OK;
18+ }
19+ return Result::RET_ERROR;
20+ }
21+
1222 inline bool file_exists (const std::string &name)
1323 {
1424 std::ifstream f (name.c_str ());
Original file line number Diff line number Diff line change @@ -120,7 +120,17 @@ namespace
120120
121121 TEST (ExampleFutex, TestShared)
122122 {
123- CppUtils2::SharedFutex futex (" /test_futex" );
123+ if (CppUtils2::file_exists (" /dev/shm/test_futex" ))
124+ {
125+ CppUtils2::unlink (" /dev/shm/test_futex" );
126+ }
127+
128+ CppUtils2::Shm shm (" /test_futex" );
129+ shm.allocate (sizeof (int32_t ));
130+ void *ptr = shm.get_raw_ptr ();
131+
132+ CppUtils2::SharedFutex futex;
133+ futex.init (" /test_futex" );
124134 futex.lock ();
125135 futex.unlock ();
126136
You can’t perform that action at this time.
0 commit comments