11
11
using umf_test::test;
12
12
using namespace umf_test ;
13
13
14
- using os_params_unique_handle_t =
15
- std::unique_ptr<umf_os_memory_provider_params_t ,
16
- decltype (&umfOsMemoryProviderParamsDestroy)>;
14
+ using void_unique_ptr = std::unique_ptr<void , decltype (&free)>;
17
15
18
16
void *createOsMemoryProviderParams () {
19
17
umf_os_memory_provider_params_handle_t params = nullptr ;
@@ -30,11 +28,43 @@ umf_result_t destroyOsMemoryProviderParams(void *params) {
30
28
(umf_os_memory_provider_params_handle_t )params);
31
29
}
32
30
31
+ void *createFixedMemoryProviderParams () {
32
+ // Allocate a memory buffer to use with the fixed memory provider.
33
+ // The umfPoolTest.malloc_compliance test requires a lot of memory.
34
+ size_t memory_size = (1UL << 31 );
35
+ static void_unique_ptr memory_buffer =
36
+ void_unique_ptr (malloc (memory_size), free);
37
+ if (memory_buffer.get () == NULL ) {
38
+ throw std::runtime_error (
39
+ " Failed to allocate memory for Fixed memory provider" );
40
+ }
41
+
42
+ umf_fixed_memory_provider_params_handle_t params = nullptr ;
43
+ umf_result_t res = umfFixedMemoryProviderParamsCreate (
44
+ ¶ms, memory_buffer.get (), memory_size);
45
+ if (res != UMF_RESULT_SUCCESS) {
46
+ throw std::runtime_error (
47
+ " Failed to create Fixed memory provider params" );
48
+ }
49
+
50
+ return params;
51
+ }
52
+
53
+ umf_result_t destroyFixedMemoryProviderParams (void *params) {
54
+ return umfFixedMemoryProviderParamsDestroy (
55
+ (umf_fixed_memory_provider_params_handle_t )params);
56
+ }
57
+
33
58
INSTANTIATE_TEST_SUITE_P (
34
59
jemallocPoolTest, umfPoolTest,
35
- ::testing::Values (poolCreateExtParams{
36
- umfJemallocPoolOps (), nullptr , nullptr , umfOsMemoryProviderOps (),
37
- createOsMemoryProviderParams, destroyOsMemoryProviderParams}));
60
+ ::testing::Values (poolCreateExtParams{umfJemallocPoolOps (), nullptr ,
61
+ nullptr , umfOsMemoryProviderOps (),
62
+ createOsMemoryProviderParams,
63
+ destroyOsMemoryProviderParams},
64
+ poolCreateExtParams{umfJemallocPoolOps (), nullptr ,
65
+ nullptr , umfFixedMemoryProviderOps (),
66
+ createFixedMemoryProviderParams,
67
+ destroyFixedMemoryProviderParams}));
38
68
39
69
// this test makes sure that jemalloc does not use
40
70
// memory provider to allocate metadata (and hence
0 commit comments