Skip to content

Commit 1f23a44

Browse files
ldoraulukaszstolarczuk
authored andcommitted
Verify result of umfPoolFree() in poolFixtures.hpp
Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
1 parent f74658d commit 1f23a44

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

test/poolFixtures.hpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,17 @@ TEST_P(umfPoolTest, allocFree) {
136136
auto *ptr = umfPoolMalloc(pool.get(), allocSize);
137137
ASSERT_NE(ptr, nullptr);
138138
std::memset(ptr, 0, allocSize);
139-
umfPoolFree(pool.get(), ptr);
139+
umf_result_t umf_result = umfPoolFree(pool.get(), ptr);
140+
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
140141
}
141142

142143
TEST_P(umfPoolTest, allocFreeNonAlignedSizes) {
143144
for (const auto &allocSize : nonAlignedAllocSizes) {
144145
auto *ptr = umfPoolMalloc(pool.get(), allocSize);
145146
ASSERT_NE(ptr, nullptr);
146147
std::memset(ptr, 0, allocSize);
147-
umfPoolFree(pool.get(), ptr);
148+
umf_result_t umf_result = umfPoolFree(pool.get(), ptr);
149+
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
148150
}
149151
}
150152

@@ -160,7 +162,8 @@ TEST_P(umfPoolTest, reallocFree) {
160162
auto *new_ptr = umfPoolRealloc(pool.get(), ptr, allocSize * multiplier);
161163
ASSERT_NE(new_ptr, nullptr);
162164
std::memset(new_ptr, 0, allocSize * multiplier);
163-
umfPoolFree(pool.get(), new_ptr);
165+
umf_result_t umf_result = umfPoolFree(pool.get(), new_ptr);
166+
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
164167
}
165168

166169
TEST_P(umfPoolTest, callocFree) {
@@ -174,7 +177,8 @@ TEST_P(umfPoolTest, callocFree) {
174177
for (size_t i = 0; i < num; ++i) {
175178
ASSERT_EQ(((int *)ptr)[i], 0);
176179
}
177-
umfPoolFree(pool.get(), ptr);
180+
umf_result_t umf_result = umfPoolFree(pool.get(), ptr);
181+
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
178182
}
179183

180184
void pow2AlignedAllocHelper(umf_memory_pool_handle_t pool) {
@@ -195,7 +199,8 @@ void pow2AlignedAllocHelper(umf_memory_pool_handle_t pool) {
195199
}
196200

197201
for (auto &ptr : allocs) {
198-
umfPoolFree(pool, ptr);
202+
umf_result_t umf_result = umfPoolFree(pool, ptr);
203+
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
199204
}
200205
}
201206
}
@@ -227,7 +232,8 @@ TEST_P(umfPoolTest, multiThreadedMallocFree) {
227232
}
228233

229234
for (auto allocation : allocations) {
230-
umfPoolFree(inPool, allocation);
235+
umf_result_t umf_result = umfPoolFree(inPool, allocation);
236+
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
231237
}
232238
};
233239

@@ -280,7 +286,8 @@ TEST_P(umfPoolTest, multiThreadedReallocFree) {
280286
for (auto allocation : allocations) {
281287
auto *ptr =
282288
umfPoolRealloc(inPool, allocation, allocSize * multiplier);
283-
umfPoolFree(inPool, ptr);
289+
umf_result_t umf_result = umfPoolFree(inPool, ptr);
290+
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
284291
}
285292
};
286293

@@ -310,7 +317,8 @@ TEST_P(umfPoolTest, multiThreadedCallocFree) {
310317
}
311318

312319
for (auto allocation : allocations) {
313-
umfPoolFree(inPool, allocation);
320+
umf_result_t umf_result = umfPoolFree(inPool, allocation);
321+
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
314322
}
315323
};
316324

@@ -335,7 +343,8 @@ TEST_P(umfPoolTest, multiThreadedMallocFreeRandomSizes) {
335343
}
336344

337345
for (auto allocation : allocations) {
338-
umfPoolFree(inPool, allocation);
346+
umf_result_t umf_result = umfPoolFree(inPool, allocation);
347+
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
339348
}
340349
};
341350

@@ -375,7 +384,8 @@ TEST_P(umfMemTest, outOfMem) {
375384
ASSERT_NE(allocations.back(), nullptr);
376385

377386
for (int i = 0; i < expectedRecycledPoolAllocs; i++) {
378-
umfPoolFree(hPool, allocations.back());
387+
umf_result_t umf_result = umfPoolFree(hPool, allocations.back());
388+
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
379389
allocations.pop_back();
380390
}
381391

@@ -385,7 +395,8 @@ TEST_P(umfMemTest, outOfMem) {
385395
}
386396

387397
for (auto allocation : allocations) {
388-
umfPoolFree(hPool, allocation);
398+
umf_result_t umf_result = umfPoolFree(hPool, allocation);
399+
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
389400
}
390401
}
391402

@@ -490,7 +501,8 @@ TEST_P(umfPoolTest, mallocUsableSize) {
490501
// Make sure we can write to this memory
491502
memset(ptr, 123, result);
492503

493-
umfPoolFree(pool.get(), ptr);
504+
umf_result_t umf_result = umfPoolFree(pool.get(), ptr);
505+
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
494506
}
495507
}
496508
}

0 commit comments

Comments
 (0)