Skip to content

Commit ebe4ac6

Browse files
committed
Add IPC tests for umfPoolMalloc() after umfCloseIPCHandle()
Test if umfCloseIPCHandle() did not corrupt the pool and if umfPoolMalloc() works correctly after umfCloseIPCHandle(). Signed-off-by: Lukasz Dorau <[email protected]>
1 parent b3bbdd4 commit ebe4ac6

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

test/ipcFixtures.hpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,18 @@ TEST_P(umfIpcTest, BasicFlow) {
220220
ret = umfPoolFree(pool.get(), ptr);
221221
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);
222222

223+
// Test if umfCloseIPCHandle() did not corrupt the pool
224+
// and if umfPoolMalloc() works correctly after umfCloseIPCHandle().
225+
ptr = (int *)umfPoolMalloc(pool.get(), SIZE);
226+
EXPECT_NE(ptr, nullptr);
227+
228+
// use the allocated memory - fill it with a 0xAB pattern
229+
const uint32_t pattern = 0xAB;
230+
memAccessor->fill(ptr, SIZE, &pattern, sizeof(pattern));
231+
232+
ret = umfPoolFree(pool.get(), ptr);
233+
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);
234+
223235
pool.reset(nullptr);
224236
EXPECT_EQ(stat.getCount, 1);
225237
EXPECT_EQ(stat.putCount, stat.getCount);
@@ -328,8 +340,19 @@ TEST_P(umfIpcTest, AllocFreeAllocTest) {
328340
ret = umfPoolFree(pool.get(), ptr);
329341
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);
330342

343+
// Test if umfCloseIPCHandle() did not corrupt the pool
344+
// and if umfPoolMalloc() works correctly after umfCloseIPCHandle().
345+
ptr = umfPoolMalloc(pool.get(), SIZE);
346+
EXPECT_NE(ptr, nullptr);
347+
348+
// use the allocated memory - fill it with a 0xAB pattern
349+
const uint32_t pattern = 0xAB;
350+
memAccessor->fill(ptr, SIZE, &pattern, sizeof(pattern));
351+
352+
ret = umfPoolFree(pool.get(), ptr);
353+
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);
354+
331355
pool.reset(nullptr);
332-
EXPECT_EQ(stat.allocCount, stat.getCount);
333356
EXPECT_EQ(stat.getCount, stat.putCount);
334357
EXPECT_EQ(stat.openCount, stat.getCount);
335358
EXPECT_EQ(stat.openCount, stat.closeCount);

0 commit comments

Comments
 (0)