Skip to content

Commit 47aa449

Browse files
committed
Add umIpcTest.AllocFreeAllocTest test
1 parent 0252728 commit 47aa449

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

test/ipcFixtures.hpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,55 @@ TEST_P(umfIpcTest, GetPoolByOpenedHandle) {
286286
}
287287
}
288288

289+
TEST_P(umfIpcTest, AllocFreeAllocTest) {
290+
constexpr size_t SIZE = 64 * 1024;
291+
umf::pool_unique_handle_t pool = makePool();
292+
void *ptr = umfPoolMalloc(pool.get(), SIZE);
293+
EXPECT_NE(ptr, nullptr);
294+
295+
umf_ipc_handle_t ipcHandle = nullptr;
296+
size_t handleSize = 0;
297+
umf_result_t ret = umfGetIPCHandle(ptr, &ipcHandle, &handleSize);
298+
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
299+
300+
void *opened_ptr = nullptr;
301+
ret = umfOpenIPCHandle(pool.get(), ipcHandle, &opened_ptr);
302+
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
303+
304+
ret = umfCloseIPCHandle(opened_ptr);
305+
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);
306+
307+
ret = umfPutIPCHandle(ipcHandle);
308+
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);
309+
310+
ret = umfPoolFree(pool.get(), ptr);
311+
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);
312+
313+
ptr = umfPoolMalloc(pool.get(), SIZE);
314+
ASSERT_NE(ptr, nullptr);
315+
316+
ret = umfGetIPCHandle(ptr, &ipcHandle, &handleSize);
317+
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
318+
319+
ret = umfOpenIPCHandle(pool.get(), ipcHandle, &opened_ptr);
320+
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
321+
322+
ret = umfCloseIPCHandle(opened_ptr);
323+
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);
324+
325+
ret = umfPutIPCHandle(ipcHandle);
326+
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);
327+
328+
ret = umfPoolFree(pool.get(), ptr);
329+
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);
330+
331+
pool.reset(nullptr);
332+
EXPECT_EQ(stat.allocCount, stat.getCount);
333+
EXPECT_EQ(stat.getCount, stat.putCount);
334+
EXPECT_EQ(stat.openCount, stat.getCount);
335+
EXPECT_EQ(stat.openCount, stat.closeCount);
336+
}
337+
289338
TEST_P(umfIpcTest, ConcurrentGetPutHandles) {
290339
std::vector<void *> ptrs;
291340
constexpr size_t ALLOC_SIZE = 100;

0 commit comments

Comments
 (0)