Skip to content

Commit 79e7b81

Browse files
committed
Add tests for umfPoolCreateFromMemspace()
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 490eeac commit 79e7b81

File tree

3 files changed

+94
-2
lines changed

3 files changed

+94
-2
lines changed

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ if(LINUX) # OS-specific functions are implemented only for Linux now
165165
LIBS ${UMF_UTILS_FOR_TEST} ${LIBNUMA_LIBRARIES})
166166
add_umf_test(
167167
NAME memspace_numa
168-
SRCS memspaces/memspace_numa.cpp
168+
SRCS memspaces/memspace_numa.cpp malloc_compliance_tests.cpp
169169
LIBS ${LIBNUMA_LIBRARIES})
170170
add_umf_test(
171171
NAME provider_os_memory_config

test/memspaces/memspace_helpers.hpp

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,26 @@ struct memspaceNumaProviderTest : ::memspaceNumaTest {
8181
umf_memory_provider_handle_t hProvider = nullptr;
8282
};
8383

84+
struct memspaceNumaPoolTest : ::memspaceNumaTest {
85+
void SetUp() override {
86+
::memspaceNumaTest::SetUp();
87+
88+
umf_result_t ret = umfPoolCreateFromMemspace(hMemspace, nullptr, &pool);
89+
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
90+
ASSERT_NE(pool, nullptr);
91+
}
92+
93+
void TearDown() override {
94+
::memspaceNumaTest::TearDown();
95+
96+
if (pool != nullptr) {
97+
umfPoolDestroy(pool);
98+
}
99+
}
100+
101+
umf_memory_pool_handle_t pool = nullptr;
102+
};
103+
84104
struct memspaceHostAllTest : ::numaNodesTest {
85105
void SetUp() override {
86106
::numaNodesTest::SetUp();
@@ -105,10 +125,32 @@ struct memspaceHostAllProviderTest : ::memspaceHostAllTest {
105125
void TearDown() override {
106126
::memspaceHostAllTest::TearDown();
107127

108-
umfMemoryProviderDestroy(hProvider);
128+
if (hProvider != nullptr) {
129+
umfMemoryProviderDestroy(hProvider);
130+
}
109131
}
110132

111133
umf_memory_provider_handle_t hProvider = nullptr;
112134
};
113135

136+
struct memspaceHostAllPoolTest : ::memspaceHostAllTest {
137+
void SetUp() override {
138+
::memspaceHostAllTest::SetUp();
139+
140+
umf_result_t ret = umfPoolCreateFromMemspace(hMemspace, nullptr, &pool);
141+
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
142+
ASSERT_NE(pool, nullptr);
143+
}
144+
145+
void TearDown() override {
146+
::memspaceHostAllTest::TearDown();
147+
148+
if (pool != nullptr) {
149+
umfPoolDestroy(pool);
150+
}
151+
}
152+
153+
umf_memory_pool_handle_t pool = nullptr;
154+
};
155+
114156
#endif /* UMF_MEMSPACE_HELPERS_HPP */

test/memspaces/memspace_numa.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
#include "memspaces/memspace_numa.h"
66
#include "base.hpp"
7+
#include "malloc_compliance_tests.hpp"
78
#include "memspace_helpers.hpp"
89
#include "memspace_internal.h"
10+
#include "pool.hpp"
911

1012
#include <umf/providers/provider_os_memory.h>
1113

@@ -65,3 +67,51 @@ TEST_F(memspaceNumaProviderTest, allocFree) {
6567
ret = umfMemoryProviderFree(hProvider, ptr, size);
6668
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
6769
}
70+
71+
/* malloc compliance tests of memspaceNumaPoolTest */
72+
73+
TEST_F(memspaceNumaPoolTest, malloc_compliance) {
74+
malloc_compliance_test(pool);
75+
}
76+
77+
TEST_F(memspaceNumaPoolTest, calloc_compliance) {
78+
if (!umf_test::isCallocSupported(pool)) {
79+
GTEST_SKIP();
80+
}
81+
82+
calloc_compliance_test(pool);
83+
}
84+
85+
TEST_F(memspaceNumaPoolTest, realloc_compliance) {
86+
if (!umf_test::isReallocSupported(pool)) {
87+
GTEST_SKIP();
88+
}
89+
90+
realloc_compliance_test(pool);
91+
}
92+
93+
TEST_F(memspaceNumaPoolTest, free_compliance) { free_compliance_test(pool); }
94+
95+
/* malloc compliance tests of memspaceHostAllPoolTest */
96+
97+
TEST_F(memspaceHostAllPoolTest, malloc_compliance) {
98+
malloc_compliance_test(pool);
99+
}
100+
101+
TEST_F(memspaceHostAllPoolTest, calloc_compliance) {
102+
if (!umf_test::isCallocSupported(pool)) {
103+
GTEST_SKIP();
104+
}
105+
106+
calloc_compliance_test(pool);
107+
}
108+
109+
TEST_F(memspaceHostAllPoolTest, realloc_compliance) {
110+
if (!umf_test::isReallocSupported(pool)) {
111+
GTEST_SKIP();
112+
}
113+
114+
realloc_compliance_test(pool);
115+
}
116+
117+
TEST_F(memspaceHostAllPoolTest, free_compliance) { free_compliance_test(pool); }

0 commit comments

Comments
 (0)