Skip to content

Commit 1d8c37c

Browse files
committed
Move jemalloc and scalable pool tests to a separate files
Each pool is expected to have some pool-specific tests. This change makes it simpler to manage them.
1 parent 9556068 commit 1d8c37c

File tree

6 files changed

+76
-63
lines changed

6 files changed

+76
-63
lines changed

test/CMakeLists.txt

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,13 @@ function(add_umf_test)
3434
umf
3535
GTest::gtest_main
3636
${ARG_LIBS})
37-
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
38-
set(TEST_LIBS ${TEST_LIBS} jemalloc_pool)
39-
endif()
40-
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
41-
set(TEST_LIBS ${TEST_LIBS} scalable_pool)
42-
endif()
4337
add_umf_executable(NAME ${TEST_TARGET_NAME} SRCS ${ARG_SRCS} LIBS ${TEST_LIBS})
4438

4539
target_include_directories(${TEST_TARGET_NAME} PRIVATE
4640
${UMF_CMAKE_SOURCE_DIR}/include
4741
${UMF_CMAKE_SOURCE_DIR}/src
48-
${UMF_TEST_DIR}/common)
42+
${UMF_TEST_DIR}/common
43+
${UMF_TEST_DIR})
4944

5045
add_test(NAME ${TEST_NAME}
5146
COMMAND ${TEST_TARGET_NAME}
@@ -61,12 +56,6 @@ function(add_umf_test)
6156
if (UMF_ENABLE_POOL_TRACKING)
6257
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE UMF_ENABLE_POOL_TRACKING_TESTS=1)
6358
endif()
64-
if (UMF_BUILD_LIBUMF_POOL_JEMALLOC)
65-
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE UMF_BUILD_LIBUMF_POOL_JEMALLOC=1)
66-
endif()
67-
if (UMF_BUILD_LIBUMF_POOL_SCALABLE)
68-
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE UMF_BUILD_LIBUMF_POOL_SCALABLE=1)
69-
endif()
7059
endfunction()
7160

7261
add_subdirectory(common)
@@ -82,13 +71,25 @@ add_umf_test(NAME memory_pool_internal
8271

8372
if(UMF_BUILD_LIBUMF_POOL_DISJOINT)
8473
add_umf_test(NAME disjointPool
85-
SRCS disjoint_pool.cpp malloc_compliance_tests.cpp
74+
SRCS pools/disjoint_pool.cpp malloc_compliance_tests.cpp
8675
LIBS disjoint_pool)
8776
add_umf_test(NAME c_api_disjoint_pool
8877
SRCS c_api/disjoint_pool.c
8978
LIBS disjoint_pool)
9079
endif()
9180

81+
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
82+
add_umf_test(NAME jemalloc_pool
83+
SRCS pools/jemalloc_pool.cpp malloc_compliance_tests.cpp
84+
LIBS jemalloc_pool)
85+
endif()
86+
87+
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
88+
add_umf_test(NAME scalable_pool
89+
SRCS pools/scalable_pool.cpp malloc_compliance_tests.cpp
90+
LIBS scalable_pool)
91+
endif()
92+
9293
if(LINUX) # OS-specific functions are implemented only for Linux now
9394
add_umf_test(NAME provider_os_memory
9495
SRCS provider_os_memory.cpp

test/memoryPoolAPI.cpp

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,13 @@
44
// This file contains tests for UMF pool API
55

66
#include "pool.hpp"
7+
#include "poolFixtures.hpp"
78
#include "provider.hpp"
89
#include "provider_null.h"
910
#include "test_helpers.h"
1011

11-
#include "memoryPool.hpp"
1212
#include "umf/memory_provider.h"
1313

14-
#if (defined UMF_BUILD_LIBUMF_POOL_JEMALLOC) || \
15-
(defined UMF_BUILD_LIBUMF_POOL_SCALABLE)
16-
#include "umf/providers/provider_os_memory.h"
17-
#endif
18-
19-
#ifdef UMF_BUILD_LIBUMF_POOL_JEMALLOC
20-
#include "umf/pools/pool_jemalloc.h"
21-
#endif
22-
23-
#ifdef UMF_BUILD_LIBUMF_POOL_SCALABLE
24-
#include "umf/pools/pool_scalable.h"
25-
#endif
26-
2714
#include <array>
2815
#include <string>
2916
#include <thread>
@@ -140,39 +127,6 @@ INSTANTIATE_TEST_SUITE_P(
140127
poolCreateExtParams{&PROXY_POOL_OPS, nullptr,
141128
&MALLOC_PROVIDER_OPS, nullptr}));
142129

143-
#if (defined UMF_BUILD_LIBUMF_POOL_JEMALLOC) || \
144-
(defined UMF_BUILD_LIBUMF_POOL_SCALABLE)
145-
static umf_os_memory_provider_params_t UMF_OS_MEMORY_PROVIDER_PARAMS = {
146-
/* .protection = */ UMF_PROTECTION_READ | UMF_PROTECTION_WRITE,
147-
/* .visibility = */ UMF_VISIBILITY_PRIVATE,
148-
149-
// NUMA config
150-
/* .nodemask = */ NULL,
151-
/* .maxnode = */ 0,
152-
/* .numa_mode = */ UMF_NUMA_MODE_DEFAULT,
153-
/* .numa_flags = */ 0,
154-
155-
// others
156-
/* .traces = */ 0,
157-
};
158-
#endif
159-
160-
#ifdef UMF_BUILD_LIBUMF_POOL_JEMALLOC
161-
INSTANTIATE_TEST_SUITE_P(jemallocPoolTest, umfPoolTest,
162-
::testing::Values(poolCreateExtParams{
163-
&UMF_JEMALLOC_POOL_OPS, nullptr,
164-
&UMF_OS_MEMORY_PROVIDER_OPS,
165-
&UMF_OS_MEMORY_PROVIDER_PARAMS}));
166-
#endif
167-
168-
#ifdef UMF_BUILD_LIBUMF_POOL_SCALABLE
169-
INSTANTIATE_TEST_SUITE_P(tbbPoolTest, umfPoolTest,
170-
::testing::Values(poolCreateExtParams{
171-
&UMF_SCALABLE_POOL_OPS, nullptr,
172-
&UMF_OS_MEMORY_PROVIDER_OPS,
173-
&UMF_OS_MEMORY_PROVIDER_PARAMS}));
174-
#endif
175-
176130
INSTANTIATE_TEST_SUITE_P(mallocMultiPoolTest, umfMultiPoolTest,
177131
::testing::Values(poolCreateExtParams{
178132
&PROXY_POOL_OPS, nullptr, &MALLOC_PROVIDER_OPS,

test/memoryPool.hpp renamed to test/poolFixtures.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <string>
1616
#include <thread>
1717

18-
#include "malloc_compliance_tests.hpp"
18+
#include "../malloc_compliance_tests.hpp"
1919

2020
using poolCreateExtParams = std::tuple<umf_memory_pool_ops_t *, void *,
2121
umf_memory_provider_ops_t *, void *>;

test/disjoint_pool.cpp renamed to test/pools/disjoint_pool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
33
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

5-
#include "memoryPool.hpp"
65
#include "pool.hpp"
6+
#include "poolFixtures.hpp"
77
#include "pool_disjoint.h"
88
#include "provider.hpp"
99
#include "provider_null.h"

test/pools/jemalloc_pool.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (C) 2023 Intel Corporation
2+
// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
3+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
#include "umf/pools/pool_jemalloc.h"
6+
#include "umf/providers/provider_os_memory.h"
7+
8+
#include "pool.hpp"
9+
#include "poolFixtures.hpp"
10+
11+
static umf_os_memory_provider_params_t UMF_OS_MEMORY_PROVIDER_PARAMS = {
12+
/* .protection = */ UMF_PROTECTION_READ | UMF_PROTECTION_WRITE,
13+
/* .visibility = */ UMF_VISIBILITY_PRIVATE,
14+
15+
// NUMA config
16+
/* .nodemask = */ NULL,
17+
/* .maxnode = */ 0,
18+
/* .numa_mode = */ UMF_NUMA_MODE_DEFAULT,
19+
/* .numa_flags = */ 0,
20+
21+
// others
22+
/* .traces = */ 0,
23+
};
24+
25+
INSTANTIATE_TEST_SUITE_P(jemallocPoolTest, umfPoolTest,
26+
::testing::Values(poolCreateExtParams{
27+
&UMF_JEMALLOC_POOL_OPS, nullptr,
28+
&UMF_OS_MEMORY_PROVIDER_OPS,
29+
&UMF_OS_MEMORY_PROVIDER_PARAMS}));

test/pools/scalable_pool.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (C) 2023 Intel Corporation
2+
// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
3+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
#include "umf/pools/pool_scalable.h"
6+
#include "umf/providers/provider_os_memory.h"
7+
8+
#include "pool.hpp"
9+
#include "poolFixtures.hpp"
10+
11+
static umf_os_memory_provider_params_t UMF_OS_MEMORY_PROVIDER_PARAMS = {
12+
/* .protection = */ UMF_PROTECTION_READ | UMF_PROTECTION_WRITE,
13+
/* .visibility = */ UMF_VISIBILITY_PRIVATE,
14+
15+
// NUMA config
16+
/* .nodemask = */ NULL,
17+
/* .maxnode = */ 0,
18+
/* .numa_mode = */ UMF_NUMA_MODE_DEFAULT,
19+
/* .numa_flags = */ 0,
20+
21+
// others
22+
/* .traces = */ 0,
23+
};
24+
25+
INSTANTIATE_TEST_SUITE_P(scalablePoolTest, umfPoolTest,
26+
::testing::Values(poolCreateExtParams{
27+
&UMF_SCALABLE_POOL_OPS, nullptr,
28+
&UMF_OS_MEMORY_PROVIDER_OPS,
29+
&UMF_OS_MEMORY_PROVIDER_PARAMS}));

0 commit comments

Comments
 (0)