Skip to content

Commit 34d38ee

Browse files
committed
Add integer overflow tests
1 parent 4eaed40 commit 34d38ee

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

test/poolFixtures.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ TEST_P(umfPoolTest, allocFree) {
9898
umfPoolFree(pool.get(), ptr);
9999
}
100100

101+
TEST_P(umfPoolTest, allocMaxSize) {
102+
auto *ptr = umfPoolMalloc(pool.get(), SIZE_MAX);
103+
ASSERT_EQ(ptr, nullptr);
104+
}
105+
101106
TEST_P(umfPoolTest, allocFreeNonAlignedSizes) {
102107
for (const auto &allocSize : nonAlignedAllocSizes) {
103108
auto *ptr = umfPoolMalloc(pool.get(), allocSize);

test/provider_os_memory.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ TEST_P(umfProviderTest, alloc_WRONG_SIZE) {
259259
UMF_OS_RESULT_ERROR_ALLOC_FAILED);
260260
}
261261

262+
TEST_P(umfProviderTest, alloc_MAX_SIZE) {
263+
test_alloc_failure(provider.get(), SIZE_MAX, 0,
264+
UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC,
265+
UMF_OS_RESULT_ERROR_ALLOC_FAILED);
266+
}
267+
262268
// other positive tests
263269

264270
TEST_P(umfProviderTest, get_min_page_size) {

test/provider_os_memory_multiple_numa_nodes.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,3 +711,21 @@ TEST_F(testNuma, checkModeInterleaveIllegalArgSet) {
711711
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_INVALID_ARGUMENT);
712712
ASSERT_EQ(os_memory_provider, nullptr);
713713
}
714+
715+
// Interleave mode set with SIZE_MAX part size
716+
TEST_F(testNuma, maxPartSize) {
717+
std::vector<unsigned> numa_nodes = get_available_numa_nodes();
718+
719+
umf_os_memory_provider_params_t os_memory_provider_params =
720+
UMF_OS_MEMORY_PROVIDER_PARAMS_TEST;
721+
os_memory_provider_params.numa_mode = UMF_NUMA_MODE_INTERLEAVE;
722+
os_memory_provider_params.part_size = SIZE_MAX;
723+
os_memory_provider_params.numa_list = numa_nodes.data();
724+
os_memory_provider_params.numa_list_len = numa_nodes.size();
725+
726+
auto res = umfMemoryProviderCreate(umfOsMemoryProviderOps(),
727+
&os_memory_provider_params,
728+
&os_memory_provider);
729+
ASSERT_EQ(res, UMF_RESULT_ERROR_INVALID_ARGUMENT);
730+
ASSERT_EQ(os_memory_provider, nullptr);
731+
}

0 commit comments

Comments
 (0)