Skip to content

Commit

Permalink
Add integer overflow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PatKamin committed Jul 5, 2024
1 parent 4eaed40 commit 34d38ee
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/poolFixtures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ TEST_P(umfPoolTest, allocFree) {
umfPoolFree(pool.get(), ptr);
}

TEST_P(umfPoolTest, allocMaxSize) {
auto *ptr = umfPoolMalloc(pool.get(), SIZE_MAX);
ASSERT_EQ(ptr, nullptr);
}

TEST_P(umfPoolTest, allocFreeNonAlignedSizes) {
for (const auto &allocSize : nonAlignedAllocSizes) {
auto *ptr = umfPoolMalloc(pool.get(), allocSize);
Expand Down
6 changes: 6 additions & 0 deletions test/provider_os_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ TEST_P(umfProviderTest, alloc_WRONG_SIZE) {
UMF_OS_RESULT_ERROR_ALLOC_FAILED);
}

TEST_P(umfProviderTest, alloc_MAX_SIZE) {
test_alloc_failure(provider.get(), SIZE_MAX, 0,
UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC,
UMF_OS_RESULT_ERROR_ALLOC_FAILED);
}

// other positive tests

TEST_P(umfProviderTest, get_min_page_size) {
Expand Down
18 changes: 18 additions & 0 deletions test/provider_os_memory_multiple_numa_nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,3 +711,21 @@ TEST_F(testNuma, checkModeInterleaveIllegalArgSet) {
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_INVALID_ARGUMENT);
ASSERT_EQ(os_memory_provider, nullptr);
}

// Interleave mode set with SIZE_MAX part size
TEST_F(testNuma, maxPartSize) {
std::vector<unsigned> numa_nodes = get_available_numa_nodes();

umf_os_memory_provider_params_t os_memory_provider_params =
UMF_OS_MEMORY_PROVIDER_PARAMS_TEST;
os_memory_provider_params.numa_mode = UMF_NUMA_MODE_INTERLEAVE;
os_memory_provider_params.part_size = SIZE_MAX;
os_memory_provider_params.numa_list = numa_nodes.data();
os_memory_provider_params.numa_list_len = numa_nodes.size();

auto res = umfMemoryProviderCreate(umfOsMemoryProviderOps(),
&os_memory_provider_params,
&os_memory_provider);
ASSERT_EQ(res, UMF_RESULT_ERROR_INVALID_ARGUMENT);
ASSERT_EQ(os_memory_provider, nullptr);
}

0 comments on commit 34d38ee

Please sign in to comment.