Skip to content

Commit 3c18464

Browse files
committed
improve umfPoolGetName tests
1 parent 7d4e12b commit 3c18464

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

test/memoryPoolAPI.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,4 +554,9 @@ INSTANTIATE_TEST_SUITE_P(
554554
umf_test::withGeneratedArgs(umfPoolCalloc),
555555
umf_test::withGeneratedArgs(umfPoolRealloc),
556556
umf_test::withGeneratedArgs(umfPoolMallocUsableSize),
557-
umf_test::withGeneratedArgs(umfPoolGetLastAllocationError)));
557+
umf_test::withGeneratedArgs(umfPoolGetLastAllocationError),
558+
umf_test::withGeneratedArgs(umfPoolGetName),
559+
umf_test::withGeneratedArgs(umfPoolGetMemoryProvider),
560+
umf_test::withGeneratedArgs(umfPoolByPtr),
561+
umf_test::withGeneratedArgs(umfPoolSetTag),
562+
umf_test::withGeneratedArgs(umfPoolGetTag)));

test/poolFixtures.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,15 @@ TEST_P(umfPoolTest, umfPoolAlignedMalloc) {
586586
#endif /* !_WIN32 */
587587
}
588588

589+
TEST_P(umfPoolTest, umfPoolGetName) {
590+
umf_memory_pool_handle_t pool_get = pool.get();
591+
const char *name = nullptr;
592+
umf_result_t ret = umfPoolGetName(pool_get, &name);
593+
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
594+
ASSERT_NE(name, nullptr);
595+
ASSERT_GT(strlen(name), (size_t)0);
596+
}
597+
589598
TEST_P(umfPoolTest, pool_from_ptr_whole_size_success) {
590599
#ifdef _WIN32
591600
// TODO: implement support for windows

test/pools/jemalloc_pool.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,29 @@ TEST_F(test, jemallocPoolParamsInvalid) {
187187
ret = umfOsMemoryProviderParamsDestroy(provider_params);
188188
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);
189189
}
190+
191+
TEST_F(test, jemallocPoolName) {
192+
umf_jemalloc_pool_params_handle_t params = nullptr;
193+
umf_result_t res = umfJemallocPoolParamsCreate(&params);
194+
EXPECT_EQ(res, UMF_RESULT_SUCCESS);
195+
umf_memory_provider_handle_t provider_handle = nullptr;
196+
umf_memory_pool_handle_t pool = NULL;
197+
198+
struct memory_provider : public umf_test::provider_base_t {};
199+
umf_memory_provider_ops_t provider_ops =
200+
umf_test::providerMakeCOps<memory_provider, void>();
201+
auto providerUnique =
202+
wrapProviderUnique(createProviderChecked(&provider_ops, nullptr));
203+
provider_handle = providerUnique.get();
204+
205+
res =
206+
umfPoolCreate(umfJemallocPoolOps(), provider_handle, params, 0, &pool);
207+
EXPECT_EQ(res, UMF_RESULT_SUCCESS);
208+
const char *name = nullptr;
209+
res = umfPoolGetName(pool, &name);
210+
EXPECT_EQ(res, UMF_RESULT_SUCCESS);
211+
EXPECT_STREQ(name, "jemalloc");
212+
213+
umfPoolDestroy(pool);
214+
umfJemallocPoolParamsDestroy(params);
215+
}

0 commit comments

Comments
 (0)