|
12 | 12 | #include "provider.hpp"
|
13 | 13 | #include "provider_null.h"
|
14 | 14 | #include "provider_trace.h"
|
| 15 | +#include "umf/base.h" |
| 16 | +#include "umf/memory_pool.h" |
15 | 17 |
|
16 | 18 | using umf_test::test;
|
17 | 19 | using namespace umf_test;
|
@@ -327,6 +329,54 @@ TEST_F(test, disjointPoolInvalidBucketSize) {
|
327 | 329 | umfDisjointPoolParamsDestroy(params);
|
328 | 330 | }
|
329 | 331 |
|
| 332 | +TEST_F(test, disjointPoolName) { |
| 333 | + umf_disjoint_pool_params_handle_t params = nullptr; |
| 334 | + umf_result_t res = umfDisjointPoolParamsCreate(¶ms); |
| 335 | + EXPECT_EQ(res, UMF_RESULT_SUCCESS); |
| 336 | + umf_memory_provider_handle_t provider_handle = nullptr; |
| 337 | + umf_memory_pool_handle_t pool = NULL; |
| 338 | + |
| 339 | + struct memory_provider : public umf_test::provider_base_t { |
| 340 | + umf_result_t expectedResult; |
| 341 | + umf_result_t alloc(size_t size, size_t alignment, void **ptr) noexcept { |
| 342 | + *ptr = umf_ba_global_aligned_alloc(size, alignment); |
| 343 | + return UMF_RESULT_SUCCESS; |
| 344 | + } |
| 345 | + |
| 346 | + umf_result_t free(void *ptr, [[maybe_unused]] size_t size) noexcept { |
| 347 | + // do the actual free only when we expect the success |
| 348 | + if (expectedResult == UMF_RESULT_SUCCESS) { |
| 349 | + umf_ba_global_free(ptr); |
| 350 | + } |
| 351 | + return expectedResult; |
| 352 | + } |
| 353 | + |
| 354 | + umf_result_t |
| 355 | + get_min_page_size([[maybe_unused]] void *ptr, |
| 356 | + [[maybe_unused]] size_t *pageSize) noexcept { |
| 357 | + *pageSize = 1024; |
| 358 | + return UMF_RESULT_SUCCESS; |
| 359 | + } |
| 360 | + }; |
| 361 | + umf_memory_provider_ops_t provider_ops = |
| 362 | + umf_test::providerMakeCOps<memory_provider, void>(); |
| 363 | + |
| 364 | + auto providerUnique = |
| 365 | + wrapProviderUnique(createProviderChecked(&provider_ops, nullptr)); |
| 366 | + |
| 367 | + provider_handle = providerUnique.get(); |
| 368 | + |
| 369 | + res = |
| 370 | + umfPoolCreate(umfDisjointPoolOps(), provider_handle, params, 0, &pool); |
| 371 | + EXPECT_EQ(res, UMF_RESULT_SUCCESS); |
| 372 | + const char *name = umfPoolGetName(pool); |
| 373 | + EXPECT_STREQ(name, "disjoint"); |
| 374 | + |
| 375 | + EXPECT_EQ(umfPoolGetName(nullptr), nullptr); |
| 376 | + umfPoolDestroy(pool); |
| 377 | + umfDisjointPoolParamsDestroy(params); |
| 378 | +} |
| 379 | + |
330 | 380 | INSTANTIATE_TEST_SUITE_P(disjointPoolTests, umfPoolTest,
|
331 | 381 | ::testing::Values(poolCreateExtParams{
|
332 | 382 | umfDisjointPoolOps(), defaultDisjointPoolConfig,
|
|
0 commit comments