Skip to content

Commit 45c78ee

Browse files
committed
[tests] Add test for creation a pool with NULL params
1 parent c2199c2 commit 45c78ee

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ if(UMF_POOL_SCALABLE_ENABLED AND (NOT UMF_DISABLE_HWLOC))
269269
NAME scalable_pool
270270
SRCS pools/scalable_pool.cpp malloc_compliance_tests.cpp
271271
LIBS ${UMF_UTILS_FOR_TEST} ${UMF_BA_FOR_TEST})
272+
add_umf_test(
273+
NAME test_pool_null_params
274+
SRCS test_pool_null_params.cpp
275+
LIBS ${UMF_UTILS_FOR_TEST})
272276
endif()
273277

274278
if(LINUX AND (NOT UMF_DISABLE_HWLOC)) # OS-specific functions are implemented

test/test_pool_null_params.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright (C) 2025 Intel Corporation
3+
*
4+
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
5+
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
*/
7+
8+
#include <gtest/gtest.h>
9+
#include <provider_null.h>
10+
#include <umf/memory_pool.h>
11+
#include <umf/memory_provider.h>
12+
#include <umf/pools/pool_disjoint.h>
13+
#include <umf/pools/pool_jemalloc.h>
14+
#include <umf/pools/pool_proxy.h>
15+
#include <umf/pools/pool_scalable.h>
16+
17+
// Use correct macro for provider ops version
18+
#define UMF_MEMORY_PROVIDER_OPS_VERSION_CURRENT UMF_PROVIDER_OPS_VERSION_CURRENT
19+
20+
// Dummy provider implementation for testing
21+
static umf_memory_provider_ops_t dummy_provider_ops = UMF_NULL_PROVIDER_OPS;
22+
23+
using PoolOpsFn = const umf_memory_pool_ops_t *(*)();
24+
25+
class PoolNullParamsTest : public ::testing::TestWithParam<PoolOpsFn> {
26+
protected:
27+
umf_memory_provider_handle_t provider = NULL;
28+
void SetUp() override {
29+
ASSERT_EQ(umfMemoryProviderCreate(&dummy_provider_ops, NULL, &provider),
30+
UMF_RESULT_SUCCESS);
31+
}
32+
void TearDown() override {
33+
if (provider) {
34+
umfMemoryProviderDestroy(provider);
35+
}
36+
}
37+
};
38+
39+
TEST_P(PoolNullParamsTest, CreateWithNullParams) {
40+
umf_memory_pool_handle_t pool;
41+
PoolOpsFn opsFn = GetParam();
42+
umf_result_t res = umfPoolCreate(opsFn(), provider, NULL, 0, &pool);
43+
ASSERT_EQ(res, UMF_RESULT_SUCCESS);
44+
umfPoolDestroy(pool);
45+
}
46+
47+
INSTANTIATE_TEST_SUITE_P(
48+
poolNullParamsTest,
49+
PoolNullParamsTest,
50+
::testing::Values(
51+
&umfDisjointPoolOps,
52+
&umfScalablePoolOps,
53+
#ifdef UMF_POOL_JEMALLOC_ENABLED
54+
&umfJemallocPoolOps,
55+
#endif
56+
&umfProxyPoolOps
57+
)
58+
);

0 commit comments

Comments
 (0)