Skip to content

Commit f9aabb0

Browse files
committed
Add integer overflow tests
1 parent 5bf1b5e commit f9aabb0

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
@@ -260,6 +260,12 @@ TEST_P(umfProviderTest, alloc_WRONG_SIZE) {
260260
UMF_OS_RESULT_ERROR_ALLOC_FAILED);
261261
}
262262

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

265271
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
@@ -774,3 +774,21 @@ TEST_F(testNuma, checkModeInterleaveIllegalArgSet) {
774774
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_INVALID_ARGUMENT);
775775
ASSERT_EQ(os_memory_provider, nullptr);
776776
}
777+
778+
// Interleave mode set with SIZE_MAX part size
779+
TEST_F(testNuma, maxPartSize) {
780+
std::vector<unsigned> numa_nodes = get_available_numa_nodes();
781+
782+
umf_os_memory_provider_params_t os_memory_provider_params =
783+
UMF_OS_MEMORY_PROVIDER_PARAMS_TEST;
784+
os_memory_provider_params.numa_mode = UMF_NUMA_MODE_INTERLEAVE;
785+
os_memory_provider_params.part_size = SIZE_MAX;
786+
os_memory_provider_params.numa_list = numa_nodes.data();
787+
os_memory_provider_params.numa_list_len = numa_nodes.size();
788+
789+
auto res = umfMemoryProviderCreate(umfOsMemoryProviderOps(),
790+
&os_memory_provider_params,
791+
&os_memory_provider);
792+
ASSERT_EQ(res, UMF_RESULT_ERROR_INVALID_ARGUMENT);
793+
ASSERT_EQ(os_memory_provider, nullptr);
794+
}

0 commit comments

Comments
 (0)