Skip to content

Commit 26b64f0

Browse files
committed
Add provider_ba_global_split_merge to the umf_test namespace
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 467be17 commit 26b64f0

File tree

2 files changed

+37
-21
lines changed

2 files changed

+37
-21
lines changed

test/common/provider.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,27 @@ struct provider_ba_global : public provider_base_t {
126126
const char *get_name() noexcept { return "umf_ba_global"; }
127127
};
128128

129+
struct provider_ba_global_split_merge : public provider_ba_global {
130+
const char *get_name() noexcept { return "umf_ba_global_split_merge"; }
131+
umf_result_t allocation_merge([[maybe_unused]] void *lowPtr,
132+
[[maybe_unused]] void *highPtr,
133+
[[maybe_unused]] size_t totalSize) {
134+
return UMF_RESULT_SUCCESS;
135+
}
136+
137+
umf_result_t allocation_split([[maybe_unused]] void *ptr,
138+
[[maybe_unused]] size_t totalSize,
139+
[[maybe_unused]] size_t firstSize) {
140+
return UMF_RESULT_SUCCESS;
141+
}
142+
};
143+
129144
umf_memory_provider_ops_t BA_GLOBAL_PROVIDER_OPS =
130145
umf::providerMakeCOps<provider_ba_global, void>();
131146

147+
umf_memory_provider_ops_t BA_GLOBAL_SPLIT_MERGE_OPS =
148+
umf::providerMakeCOps<provider_ba_global_split_merge, void>();
149+
132150
struct provider_mock_out_of_mem : public provider_base_t {
133151
provider_ba_global helper_prov;
134152
int allocNum = 0;

test/disjointCoarseMallocPool.cpp

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@
1212
#include <umf/pools/pool_disjoint.h>
1313
#include <umf/providers/provider_coarse.h>
1414

15+
using umf_test::BA_GLOBAL_SPLIT_MERGE_OPS;
1516
using umf_test::KB;
1617
using umf_test::MB;
1718
using umf_test::test;
1819

1920
#define GetStats umfCoarseMemoryProviderGetStats
2021

21-
umf_memory_provider_ops_t UMF_MALLOC_MEMORY_PROVIDER_OPS =
22-
umf::providerMakeCOps<umf_test::provider_ba_global, void>();
23-
2422
struct CoarseWithMemoryStrategyTest
2523
: umf_test::test,
2624
::testing::WithParamInterface<coarse_memory_provider_strategy_t> {
@@ -39,13 +37,13 @@ INSTANTIATE_TEST_SUITE_P(
3937
UMF_COARSE_MEMORY_STRATEGY_CHECK_ALL_SIZE));
4038

4139
TEST_P(CoarseWithMemoryStrategyTest, disjointCoarseMallocPool_basic) {
42-
umf_memory_provider_handle_t malloc_memory_provider;
40+
umf_memory_provider_handle_t ba_global_split_merge_provider;
4341
umf_result_t umf_result;
4442

45-
umf_result = umfMemoryProviderCreate(&UMF_MALLOC_MEMORY_PROVIDER_OPS, NULL,
46-
&malloc_memory_provider);
43+
umf_result = umfMemoryProviderCreate(&BA_GLOBAL_SPLIT_MERGE_OPS, NULL,
44+
&ba_global_split_merge_provider);
4745
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
48-
ASSERT_NE(malloc_memory_provider, nullptr);
46+
ASSERT_NE(ba_global_split_merge_provider, nullptr);
4947

5048
const size_t init_buffer_size = 20 * MB;
5149

@@ -55,7 +53,7 @@ TEST_P(CoarseWithMemoryStrategyTest, disjointCoarseMallocPool_basic) {
5553
sizeof(coarse_memory_provider_params));
5654
coarse_memory_provider_params.allocation_strategy = allocation_strategy;
5755
coarse_memory_provider_params.upstream_memory_provider =
58-
malloc_memory_provider;
56+
ba_global_split_merge_provider;
5957
coarse_memory_provider_params.destroy_upstream_memory_provider = true;
6058
coarse_memory_provider_params.immediate_init_from_upstream = true;
6159
coarse_memory_provider_params.init_buffer = nullptr;
@@ -210,20 +208,20 @@ TEST_P(CoarseWithMemoryStrategyTest, disjointCoarseMallocPool_basic) {
210208
ASSERT_EQ(GetStats(prov).alloc_size, init_buffer_size);
211209

212210
umfPoolDestroy(pool);
213-
// Both coarse_memory_provider and malloc_memory_provider
211+
// Both coarse_memory_provider and ba_global_split_merge_provider
214212
// have already been destroyed by umfPoolDestroy(), because:
215213
// UMF_POOL_CREATE_FLAG_OWN_PROVIDER was set in umfPoolCreate() and
216214
// coarse_memory_provider_params.destroy_upstream_memory_provider = true;
217215
}
218216

219217
TEST_P(CoarseWithMemoryStrategyTest, disjointCoarseMallocPool_simple1) {
220-
umf_memory_provider_handle_t malloc_memory_provider;
218+
umf_memory_provider_handle_t ba_global_split_merge_provider;
221219
umf_result_t umf_result;
222220

223-
umf_result = umfMemoryProviderCreate(&UMF_MALLOC_MEMORY_PROVIDER_OPS, NULL,
224-
&malloc_memory_provider);
221+
umf_result = umfMemoryProviderCreate(&BA_GLOBAL_SPLIT_MERGE_OPS, NULL,
222+
&ba_global_split_merge_provider);
225223
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
226-
ASSERT_NE(malloc_memory_provider, nullptr);
224+
ASSERT_NE(ba_global_split_merge_provider, nullptr);
227225

228226
const size_t init_buffer_size = 20 * MB;
229227

@@ -233,7 +231,7 @@ TEST_P(CoarseWithMemoryStrategyTest, disjointCoarseMallocPool_simple1) {
233231
sizeof(coarse_memory_provider_params));
234232
coarse_memory_provider_params.allocation_strategy = allocation_strategy;
235233
coarse_memory_provider_params.upstream_memory_provider =
236-
malloc_memory_provider;
234+
ba_global_split_merge_provider;
237235
coarse_memory_provider_params.immediate_init_from_upstream = true;
238236
coarse_memory_provider_params.init_buffer = NULL;
239237
coarse_memory_provider_params.init_buffer_size = init_buffer_size;
@@ -310,17 +308,17 @@ TEST_P(CoarseWithMemoryStrategyTest, disjointCoarseMallocPool_simple1) {
310308

311309
umfPoolDestroy(pool);
312310
umfMemoryProviderDestroy(coarse_memory_provider);
313-
umfMemoryProviderDestroy(malloc_memory_provider);
311+
umfMemoryProviderDestroy(ba_global_split_merge_provider);
314312
}
315313

316314
TEST_P(CoarseWithMemoryStrategyTest, disjointCoarseMallocPool_simple2) {
317-
umf_memory_provider_handle_t malloc_memory_provider;
315+
umf_memory_provider_handle_t ba_global_split_merge_provider;
318316
umf_result_t umf_result;
319317

320-
umf_result = umfMemoryProviderCreate(&UMF_MALLOC_MEMORY_PROVIDER_OPS, NULL,
321-
&malloc_memory_provider);
318+
umf_result = umfMemoryProviderCreate(&BA_GLOBAL_SPLIT_MERGE_OPS, NULL,
319+
&ba_global_split_merge_provider);
322320
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
323-
ASSERT_NE(malloc_memory_provider, nullptr);
321+
ASSERT_NE(ba_global_split_merge_provider, nullptr);
324322

325323
const size_t init_buffer_size = 20 * MB;
326324

@@ -330,7 +328,7 @@ TEST_P(CoarseWithMemoryStrategyTest, disjointCoarseMallocPool_simple2) {
330328
sizeof(coarse_memory_provider_params));
331329
coarse_memory_provider_params.allocation_strategy = allocation_strategy;
332330
coarse_memory_provider_params.upstream_memory_provider =
333-
malloc_memory_provider;
331+
ba_global_split_merge_provider;
334332
coarse_memory_provider_params.immediate_init_from_upstream = true;
335333
coarse_memory_provider_params.init_buffer = NULL;
336334
coarse_memory_provider_params.init_buffer_size = init_buffer_size;
@@ -375,7 +373,7 @@ TEST_P(CoarseWithMemoryStrategyTest, disjointCoarseMallocPool_simple2) {
375373

376374
umfPoolDestroy(pool);
377375
umfMemoryProviderDestroy(coarse_memory_provider);
378-
umfMemoryProviderDestroy(malloc_memory_provider);
376+
umfMemoryProviderDestroy(ba_global_split_merge_provider);
379377
}
380378

381379
struct alloc_ptr_size {

0 commit comments

Comments
 (0)