Skip to content

Commit

Permalink
Merge pull request #75 from ldorau/Add_test_for_jemalloc_pool_manager
Browse files Browse the repository at this point in the history
Add test for jemalloc pool manager
  • Loading branch information
vinser52 authored Dec 18, 2023
2 parents d6955ef + 5a11983 commit e4b2600
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,19 @@ function(add_umf_test)
if (UMF_ENABLE_POOL_TRACKING)
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE UMF_ENABLE_POOL_TRACKING_TESTS=1)
endif()
if (UMF_BUILD_LIBUMF_POOL_JEMALLOC)
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE UMF_BUILD_LIBUMF_POOL_JEMALLOC=1)
endif()
endfunction()

add_subdirectory(common)

if (UMF_BUILD_LIBUMF_POOL_JEMALLOC)
set(LIBS_JEMALLOC pool_jemalloc jemalloc numa)
endif()

add_umf_test(NAME base SRCS base.cpp)
add_umf_test(NAME memoryPool SRCS memoryPoolAPI.cpp malloc_compliance_tests.cpp)
add_umf_test(NAME memoryPool SRCS memoryPoolAPI.cpp malloc_compliance_tests.cpp LIBS ${LIBS_JEMALLOC})
add_umf_test(NAME memoryProvider SRCS memoryProviderAPI.cpp)
add_umf_test(NAME disjointPool SRCS disjoint_pool.cpp malloc_compliance_tests.cpp)
add_umf_test(NAME c_api_disjoint_pool SRCS c_api/disjoint_pool.c)
Expand Down
27 changes: 27 additions & 0 deletions test/memoryPoolAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
#include "memoryPool.hpp"
#include "umf/memory_provider.h"

#ifdef UMF_BUILD_LIBUMF_POOL_JEMALLOC
#include "umf/pools/pool_jemalloc.h"
#include "umf/providers/provider_os_memory.h"
#endif

#include <array>
#include <string>
#include <thread>
Expand Down Expand Up @@ -127,6 +132,28 @@ INSTANTIATE_TEST_SUITE_P(
poolCreateExtParams{&PROXY_POOL_OPS, nullptr,
&MALLOC_PROVIDER_OPS, nullptr}));

#ifdef UMF_BUILD_LIBUMF_POOL_JEMALLOC
static umf_os_memory_provider_params_t UMF_OS_MEMORY_PROVIDER_PARAMS = {
/* .protection = */ UMF_PROTECTION_READ | UMF_PROTECTION_WRITE,
/* .visibility = */ UMF_VISIBILITY_PRIVATE,

// NUMA config
/* .nodemask = */ NULL,
/* .maxnode = */ 0,
/* .numa_mode = */ UMF_NUMA_MODE_DEFAULT,
/* .numa_flags = */ 0,

// others
/* .traces = */ 0,
};

INSTANTIATE_TEST_SUITE_P(jemallocPoolTest, umfPoolTest,
::testing::Values(poolCreateExtParams{
&UMF_JEMALLOC_POOL_OPS, nullptr,
&UMF_OS_MEMORY_PROVIDER_OPS,
&UMF_OS_MEMORY_PROVIDER_PARAMS}));
#endif

INSTANTIATE_TEST_SUITE_P(mallocMultiPoolTest, umfMultiPoolTest,
::testing::Values(poolCreateExtParams{
&PROXY_POOL_OPS, nullptr, &MALLOC_PROVIDER_OPS,
Expand Down

0 comments on commit e4b2600

Please sign in to comment.