Skip to content

Commit e404fc2

Browse files
committed
Add integer overflow tests
1 parent 8a74b8f commit e404fc2

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
@@ -726,3 +726,21 @@ TEST_F(testNuma, checkModeInterleaveIllegalArgSet) {
726726
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_INVALID_ARGUMENT);
727727
ASSERT_EQ(os_memory_provider, nullptr);
728728
}
729+
730+
// Interleave mode set with SIZE_MAX part size
731+
TEST_F(testNuma, maxPartSize) {
732+
std::vector<unsigned> numa_nodes = get_available_numa_nodes();
733+
734+
umf_os_memory_provider_params_t os_memory_provider_params =
735+
UMF_OS_MEMORY_PROVIDER_PARAMS_TEST;
736+
os_memory_provider_params.numa_mode = UMF_NUMA_MODE_INTERLEAVE;
737+
os_memory_provider_params.part_size = SIZE_MAX;
738+
os_memory_provider_params.numa_list = numa_nodes.data();
739+
os_memory_provider_params.numa_list_len = numa_nodes.size();
740+
741+
auto res = umfMemoryProviderCreate(umfOsMemoryProviderOps(),
742+
&os_memory_provider_params,
743+
&os_memory_provider);
744+
ASSERT_EQ(res, UMF_RESULT_ERROR_INVALID_ARGUMENT);
745+
ASSERT_EQ(os_memory_provider, nullptr);
746+
}

0 commit comments

Comments
 (0)