Skip to content

Commit 333ff79

Browse files
committed
Add provider_ba_global_split_merge to the umf_test namespace
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 0dd3648 commit 333ff79

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;
@@ -224,20 +222,20 @@ TEST_P(CoarseWithMemoryStrategyTest, disjointCoarseMallocPool_basic) {
224222
ASSERT_EQ(GetStats(prov).alloc_size, init_buffer_size);
225223

226224
umfPoolDestroy(pool);
227-
// Both coarse_memory_provider and malloc_memory_provider
225+
// Both coarse_memory_provider and ba_global_split_merge_provider
228226
// have already been destroyed by umfPoolDestroy(), because:
229227
// UMF_POOL_CREATE_FLAG_OWN_PROVIDER was set in umfPoolCreate() and
230228
// coarse_memory_provider_params.destroy_upstream_memory_provider = true;
231229
}
232230

233231
TEST_P(CoarseWithMemoryStrategyTest, disjointCoarseMallocPool_simple1) {
234-
umf_memory_provider_handle_t malloc_memory_provider;
232+
umf_memory_provider_handle_t ba_global_split_merge_provider;
235233
umf_result_t umf_result;
236234

237-
umf_result = umfMemoryProviderCreate(&UMF_MALLOC_MEMORY_PROVIDER_OPS, NULL,
238-
&malloc_memory_provider);
235+
umf_result = umfMemoryProviderCreate(&BA_GLOBAL_SPLIT_MERGE_OPS, NULL,
236+
&ba_global_split_merge_provider);
239237
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
240-
ASSERT_NE(malloc_memory_provider, nullptr);
238+
ASSERT_NE(ba_global_split_merge_provider, nullptr);
241239

242240
const size_t init_buffer_size = 20 * MB;
243241

@@ -247,7 +245,7 @@ TEST_P(CoarseWithMemoryStrategyTest, disjointCoarseMallocPool_simple1) {
247245
sizeof(coarse_memory_provider_params));
248246
coarse_memory_provider_params.allocation_strategy = allocation_strategy;
249247
coarse_memory_provider_params.upstream_memory_provider =
250-
malloc_memory_provider;
248+
ba_global_split_merge_provider;
251249
coarse_memory_provider_params.immediate_init_from_upstream = true;
252250
coarse_memory_provider_params.init_buffer = NULL;
253251
coarse_memory_provider_params.init_buffer_size = init_buffer_size;
@@ -337,17 +335,17 @@ TEST_P(CoarseWithMemoryStrategyTest, disjointCoarseMallocPool_simple1) {
337335

338336
umfPoolDestroy(pool);
339337
umfMemoryProviderDestroy(coarse_memory_provider);
340-
umfMemoryProviderDestroy(malloc_memory_provider);
338+
umfMemoryProviderDestroy(ba_global_split_merge_provider);
341339
}
342340

343341
TEST_P(CoarseWithMemoryStrategyTest, disjointCoarseMallocPool_simple2) {
344-
umf_memory_provider_handle_t malloc_memory_provider;
342+
umf_memory_provider_handle_t ba_global_split_merge_provider;
345343
umf_result_t umf_result;
346344

347-
umf_result = umfMemoryProviderCreate(&UMF_MALLOC_MEMORY_PROVIDER_OPS, NULL,
348-
&malloc_memory_provider);
345+
umf_result = umfMemoryProviderCreate(&BA_GLOBAL_SPLIT_MERGE_OPS, NULL,
346+
&ba_global_split_merge_provider);
349347
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
350-
ASSERT_NE(malloc_memory_provider, nullptr);
348+
ASSERT_NE(ba_global_split_merge_provider, nullptr);
351349

352350
const size_t init_buffer_size = 20 * MB;
353351

@@ -357,7 +355,7 @@ TEST_P(CoarseWithMemoryStrategyTest, disjointCoarseMallocPool_simple2) {
357355
sizeof(coarse_memory_provider_params));
358356
coarse_memory_provider_params.allocation_strategy = allocation_strategy;
359357
coarse_memory_provider_params.upstream_memory_provider =
360-
malloc_memory_provider;
358+
ba_global_split_merge_provider;
361359
coarse_memory_provider_params.immediate_init_from_upstream = true;
362360
coarse_memory_provider_params.init_buffer = NULL;
363361
coarse_memory_provider_params.init_buffer_size = init_buffer_size;
@@ -416,7 +414,7 @@ TEST_P(CoarseWithMemoryStrategyTest, disjointCoarseMallocPool_simple2) {
416414

417415
umfPoolDestroy(pool);
418416
umfMemoryProviderDestroy(coarse_memory_provider);
419-
umfMemoryProviderDestroy(malloc_memory_provider);
417+
umfMemoryProviderDestroy(ba_global_split_merge_provider);
420418
}
421419

422420
struct alloc_ptr_size {

0 commit comments

Comments
 (0)