Skip to content

Commit eba9ea7

Browse files
committed
[tests] Add test for creation a pool with NULL params
1 parent 885be41 commit eba9ea7

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-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: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
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+
#include "provider_null.h"
18+
19+
// Dummy provider implementation for testing
20+
static umf_memory_provider_ops_t dummy_provider_ops = UMF_NULL_PROVIDER_OPS;
21+
22+
using PoolOpsFn = const umf_memory_pool_ops_t *(*)();
23+
24+
class PoolNullParamsTest : public ::testing::TestWithParam<PoolOpsFn> {
25+
protected:
26+
umf_memory_provider_handle_t provider = NULL;
27+
void SetUp() override {
28+
ASSERT_EQ(umfMemoryProviderCreate(&dummy_provider_ops, NULL, &provider),
29+
UMF_RESULT_SUCCESS);
30+
}
31+
void TearDown() override {
32+
if (provider) {
33+
umfMemoryProviderDestroy(provider);
34+
}
35+
}
36+
};
37+
38+
TEST_P(PoolNullParamsTest, CreateWithNullParams) {
39+
umf_memory_pool_handle_t pool;
40+
PoolOpsFn opsFn = GetParam();
41+
umf_result_t res = umfPoolCreate(opsFn(), provider, NULL, 0, &pool);
42+
ASSERT_EQ(res, UMF_RESULT_SUCCESS);
43+
umfPoolDestroy(pool);
44+
}
45+
46+
INSTANTIATE_TEST_SUITE_P(poolNullParamsTest, PoolNullParamsTest,
47+
::testing::Values(&umfDisjointPoolOps,
48+
&umfScalablePoolOps,
49+
#if defined(UMF_POOL_JEMALLOC_ENABLED)
50+
&umfJemallocPoolOps,
51+
#endif
52+
&umfProxyPoolOps));

0 commit comments

Comments
 (0)