|
13 | 13 | #include "provider_null.h" |
14 | 14 | #include "provider_trace.h" |
15 | 15 |
|
16 | | -static constexpr size_t DEFAULT_DISJOINT_SLAB_MIN_SIZE = 4096; |
17 | | -static constexpr size_t DEFAULT_DISJOINT_MAX_POOLABLE_SIZE = 4096; |
18 | | -static constexpr size_t DEFAULT_DISJOINT_CAPACITY = 4; |
19 | | -static constexpr size_t DEFAULT_DISJOINT_MIN_BUCKET_SIZE = 64; |
20 | | - |
21 | | -void *defaultPoolConfig() { |
22 | | - umf_disjoint_pool_params_handle_t config = nullptr; |
23 | | - umf_result_t res = umfDisjointPoolParamsCreate(&config); |
24 | | - if (res != UMF_RESULT_SUCCESS) { |
25 | | - throw std::runtime_error("Failed to create pool params"); |
26 | | - } |
27 | | - res = umfDisjointPoolParamsSetSlabMinSize(config, |
28 | | - DEFAULT_DISJOINT_SLAB_MIN_SIZE); |
29 | | - if (res != UMF_RESULT_SUCCESS) { |
30 | | - umfDisjointPoolParamsDestroy(config); |
31 | | - throw std::runtime_error("Failed to set slab min size"); |
32 | | - } |
33 | | - res = umfDisjointPoolParamsSetMaxPoolableSize( |
34 | | - config, DEFAULT_DISJOINT_MAX_POOLABLE_SIZE); |
35 | | - if (res != UMF_RESULT_SUCCESS) { |
36 | | - umfDisjointPoolParamsDestroy(config); |
37 | | - throw std::runtime_error("Failed to set max poolable size"); |
38 | | - } |
39 | | - res = umfDisjointPoolParamsSetCapacity(config, DEFAULT_DISJOINT_CAPACITY); |
40 | | - if (res != UMF_RESULT_SUCCESS) { |
41 | | - umfDisjointPoolParamsDestroy(config); |
42 | | - throw std::runtime_error("Failed to set capacity"); |
43 | | - } |
44 | | - res = umfDisjointPoolParamsSetMinBucketSize( |
45 | | - config, DEFAULT_DISJOINT_MIN_BUCKET_SIZE); |
46 | | - if (res != UMF_RESULT_SUCCESS) { |
47 | | - umfDisjointPoolParamsDestroy(config); |
48 | | - throw std::runtime_error("Failed to set min bucket size"); |
49 | | - } |
50 | | - |
51 | | - return config; |
52 | | -} |
53 | | - |
54 | | -umf_result_t poolConfigDestroy(void *config) { |
55 | | - return umfDisjointPoolParamsDestroy( |
56 | | - static_cast<umf_disjoint_pool_params_handle_t>(config)); |
57 | | -} |
58 | | - |
59 | 16 | using umf_test::test; |
60 | 17 | using namespace umf_test; |
61 | 18 |
|
@@ -92,7 +49,7 @@ TEST_F(test, internals) { |
92 | 49 | provider_handle = providerUnique.get(); |
93 | 50 |
|
94 | 51 | umf_disjoint_pool_params_handle_t params = |
95 | | - (umf_disjoint_pool_params_handle_t)defaultPoolConfig(); |
| 52 | + (umf_disjoint_pool_params_handle_t)defaultDisjointPoolConfig(); |
96 | 53 | // set to maximum tracing |
97 | 54 | params->pool_trace = 3; |
98 | 55 | params->max_poolable_size = 1024 * 1024; |
@@ -256,7 +213,7 @@ TEST_F(test, sharedLimits) { |
256 | 213 | static constexpr size_t MaxSize = 4 * SlabMinSize; |
257 | 214 |
|
258 | 215 | umf_disjoint_pool_params_handle_t params = |
259 | | - (umf_disjoint_pool_params_handle_t)defaultPoolConfig(); |
| 216 | + (umf_disjoint_pool_params_handle_t)defaultDisjointPoolConfig(); |
260 | 217 | umf_result_t ret = umfDisjointPoolParamsSetSlabMinSize(params, SlabMinSize); |
261 | 218 | EXPECT_EQ(ret, UMF_RESULT_SUCCESS); |
262 | 219 |
|
@@ -373,22 +330,23 @@ TEST_F(test, disjointPoolInvalidBucketSize) { |
373 | 330 |
|
374 | 331 | INSTANTIATE_TEST_SUITE_P(disjointPoolTests, umfPoolTest, |
375 | 332 | ::testing::Values(poolCreateExtParams{ |
376 | | - umfDisjointPoolOps(), defaultPoolConfig, |
377 | | - poolConfigDestroy, &BA_GLOBAL_PROVIDER_OPS, |
378 | | - nullptr, nullptr})); |
| 333 | + umfDisjointPoolOps(), defaultDisjointPoolConfig, |
| 334 | + defaultDisjointPoolConfigDestroy, |
| 335 | + &BA_GLOBAL_PROVIDER_OPS, nullptr, nullptr})); |
379 | 336 |
|
380 | 337 | void *memProviderParams() { return (void *)&DEFAULT_DISJOINT_CAPACITY; } |
381 | 338 |
|
382 | 339 | INSTANTIATE_TEST_SUITE_P( |
383 | 340 | disjointPoolTests, umfMemTest, |
384 | 341 | ::testing::Values(std::make_tuple( |
385 | | - poolCreateExtParams{umfDisjointPoolOps(), defaultPoolConfig, |
386 | | - poolConfigDestroy, &MOCK_OUT_OF_MEM_PROVIDER_OPS, |
387 | | - memProviderParams, nullptr}, |
| 342 | + poolCreateExtParams{umfDisjointPoolOps(), defaultDisjointPoolConfig, |
| 343 | + defaultDisjointPoolConfigDestroy, |
| 344 | + &MOCK_OUT_OF_MEM_PROVIDER_OPS, memProviderParams, |
| 345 | + nullptr}, |
388 | 346 | static_cast<int>(DEFAULT_DISJOINT_CAPACITY) / 2))); |
389 | 347 |
|
390 | 348 | INSTANTIATE_TEST_SUITE_P(disjointMultiPoolTests, umfMultiPoolTest, |
391 | 349 | ::testing::Values(poolCreateExtParams{ |
392 | | - umfDisjointPoolOps(), defaultPoolConfig, |
393 | | - poolConfigDestroy, &BA_GLOBAL_PROVIDER_OPS, |
394 | | - nullptr, nullptr})); |
| 350 | + umfDisjointPoolOps(), defaultDisjointPoolConfig, |
| 351 | + defaultDisjointPoolConfigDestroy, |
| 352 | + &BA_GLOBAL_PROVIDER_OPS, nullptr, nullptr})); |
0 commit comments