6
6
7
7
#include " cpp_helpers.hpp"
8
8
#include " test_helpers.h"
9
+ #include " test_helpers.hpp"
10
+
9
11
#ifndef _WIN32
10
12
#include " test_helpers_linux.h"
11
13
#endif
@@ -18,12 +20,6 @@ using umf_test::test;
18
20
#define FILE_PATH ((char *)" tmp_file" )
19
21
#define INVALID_PTR ((void *)0x01 )
20
22
21
- typedef enum purge_t {
22
- PURGE_NONE = 0 ,
23
- PURGE_LAZY = 1 ,
24
- PURGE_FORCE = 2 ,
25
- } purge_t ;
26
-
27
23
static const char *Native_error_str[] = {
28
24
" success" , // UMF_FILE_RESULT_SUCCESS
29
25
" memory allocation failed" , // UMF_FILE_RESULT_ERROR_ALLOC_FAILED
@@ -77,30 +73,6 @@ struct FileProviderParamsDefault
77
73
78
74
struct FileProviderParamsShared : FileProviderParamsDefault {};
79
75
80
- static void test_alloc_free_success (umf_memory_provider_handle_t provider,
81
- size_t size, size_t alignment,
82
- purge_t purge) {
83
- void *ptr = nullptr ;
84
-
85
- umf_result_t umf_result =
86
- umfMemoryProviderAlloc (provider, size, alignment, &ptr);
87
- ASSERT_EQ (umf_result, UMF_RESULT_SUCCESS);
88
- ASSERT_NE (ptr, nullptr );
89
-
90
- memset (ptr, 0xFF , size);
91
-
92
- if (purge == PURGE_LAZY) {
93
- umf_result = umfMemoryProviderPurgeLazy (provider, ptr, size);
94
- ASSERT_EQ (umf_result, UMF_RESULT_ERROR_NOT_SUPPORTED);
95
- } else if (purge == PURGE_FORCE) {
96
- umf_result = umfMemoryProviderPurgeForce (provider, ptr, size);
97
- ASSERT_EQ (umf_result, UMF_RESULT_SUCCESS);
98
- }
99
-
100
- umf_result = umfMemoryProviderFree (provider, ptr, size);
101
- ASSERT_EQ (umf_result, UMF_RESULT_ERROR_NOT_SUPPORTED);
102
- }
103
-
104
76
static void verify_last_native_error (umf_memory_provider_handle_t provider,
105
77
int32_t err) {
106
78
const char *message;
@@ -161,7 +133,7 @@ TEST_F(test, test_if_mapped_with_MAP_SYNC) {
161
133
ASSERT_EQ (flag_found, true );
162
134
}
163
135
164
- // positive tests using test_alloc_free_success
136
+ // positive tests using test_alloc_success_not_free
165
137
166
138
umf_file_memory_provider_params_t file_params_default =
167
139
umfFileMemoryProviderParamsDefault (FILE_PATH);
@@ -184,20 +156,20 @@ INSTANTIATE_TEST_SUITE_P(fileProviderTest, FileProviderParamsDefault,
184
156
TEST_P (FileProviderParamsDefault, create_destroy) {}
185
157
186
158
TEST_P (FileProviderParamsDefault, alloc_page64_align_0) {
187
- test_alloc_free_success (provider.get (), page_plus_64, 0 , PURGE_NONE);
159
+ test_alloc_success_not_free (provider.get (), page_plus_64, 0 , PURGE_NONE);
188
160
}
189
161
190
162
TEST_P (FileProviderParamsDefault, alloc_page64_align_page_div_2) {
191
- test_alloc_free_success (provider.get (), page_plus_64, page_size / 2 ,
192
- PURGE_NONE);
163
+ test_alloc_success_not_free (provider.get (), page_plus_64, page_size / 2 ,
164
+ PURGE_NONE);
193
165
}
194
166
195
167
TEST_P (FileProviderParamsDefault, purge_lazy) {
196
- test_alloc_free_success (provider.get (), page_plus_64, 0 , PURGE_LAZY);
168
+ test_alloc_success_not_free (provider.get (), page_plus_64, 0 , PURGE_LAZY);
197
169
}
198
170
199
171
TEST_P (FileProviderParamsDefault, purge_force) {
200
- test_alloc_free_success (provider.get (), page_plus_64, 0 , PURGE_FORCE);
172
+ test_alloc_success_not_free (provider.get (), page_plus_64, 0 , PURGE_FORCE);
201
173
}
202
174
203
175
// negative tests using test_alloc_failure
0 commit comments