|
2 | 2 | // Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. |
3 | 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
4 | 4 |
|
5 | | -#ifndef UMF_TEST_MEMORY_POOL_OPS_HPP |
6 | | -#define UMF_TEST_MEMORY_POOL_OPS_HPP |
| 5 | +#ifndef UMF_TEST_POOL_FIXTURES_HPP |
| 6 | +#define UMF_TEST_POOL_FIXTURES_HPP 1 |
7 | 7 |
|
8 | 8 | #include "pool.hpp" |
9 | 9 | #include "provider.hpp" |
| 10 | +#include "umf/providers/provider_coarse.h" |
10 | 11 |
|
11 | 12 | #include <array> |
12 | 13 | #include <cstring> |
|
17 | 18 |
|
18 | 19 | #include "../malloc_compliance_tests.hpp" |
19 | 20 |
|
20 | | -using poolCreateExtParams = std::tuple<umf_memory_pool_ops_t *, void *, |
21 | | - umf_memory_provider_ops_t *, void *>; |
| 21 | +using poolCreateExtParams = |
| 22 | + std::tuple<umf_memory_pool_ops_t *, void *, umf_memory_provider_ops_t *, |
| 23 | + void *, void *>; |
22 | 24 |
|
23 | 25 | umf::pool_unique_handle_t poolCreateExtUnique(poolCreateExtParams params) { |
24 | 26 | umf_memory_pool_handle_t hPool; |
25 | | - auto [pool_ops, pool_params, provider_ops, provider_params] = params; |
| 27 | + auto [pool_ops, pool_params, provider_ops, provider_params, coarse_params] = |
| 28 | + params; |
26 | 29 |
|
27 | 30 | umf_memory_provider_handle_t provider = nullptr; |
28 | 31 | auto ret = |
29 | 32 | umfMemoryProviderCreate(provider_ops, provider_params, &provider); |
30 | 33 | EXPECT_EQ(ret, UMF_RESULT_SUCCESS); |
31 | 34 |
|
| 35 | + if (coarse_params) { |
| 36 | + coarse_memory_provider_params_t *coarse_memory_provider_params = |
| 37 | + (coarse_memory_provider_params_t *)coarse_params; |
| 38 | + coarse_memory_provider_params->upstream_memory_provider = provider; |
| 39 | + coarse_memory_provider_params->destroy_upstream_memory_provider = true; |
| 40 | + |
| 41 | + umf_memory_provider_handle_t coarse_provider = nullptr; |
| 42 | + auto ret = umfMemoryProviderCreate(umfCoarseMemoryProviderOps(), |
| 43 | + coarse_params, &coarse_provider); |
| 44 | + EXPECT_EQ(ret, UMF_RESULT_SUCCESS); |
| 45 | + |
| 46 | + provider = coarse_provider; |
| 47 | + } |
| 48 | + |
32 | 49 | ret = umfPoolCreate(pool_ops, provider, pool_params, |
33 | 50 | UMF_POOL_CREATE_FLAG_OWN_PROVIDER, &hPool); |
34 | 51 | EXPECT_EQ(ret, UMF_RESULT_SUCCESS); |
@@ -407,4 +424,4 @@ TEST_P(umfPoolTest, realloc_compliance) { |
407 | 424 |
|
408 | 425 | TEST_P(umfPoolTest, free_compliance) { free_compliance_test(pool.get()); } |
409 | 426 |
|
410 | | -#endif /* UMF_TEST_MEMORY_POOL_OPS_HPP */ |
| 427 | +#endif /* UMF_TEST_POOL_FIXTURES_HPP */ |
0 commit comments