Skip to content

Commit fc88217

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

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

test/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ add_umf_test(
238238
${BA_SOURCES_FOR_TEST}
239239
LIBS ${UMF_UTILS_FOR_TEST})
240240

241+
add_umf_test(
242+
NAME pool_null_params
243+
SRCS test_pool_null_params.cpp
244+
LIBS ${UMF_UTILS_FOR_TEST})
245+
241246
add_umf_test(
242247
NAME c_api_disjoint_pool
243248
SRCS c_api/disjoint_pool.c

test/test_pool_null_params.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
#ifdef UMF_POOL_JEMALLOC_ENABLED
47+
INSTANTIATE_TEST_SUITE_P(poolNullParamsTest, PoolNullParamsTest,
48+
::testing::Values(&umfDisjointPoolOps,
49+
&umfScalablePoolOps,
50+
&umfJemallocPoolOps,
51+
&umfProxyPoolOps));
52+
#else
53+
INSTANTIATE_TEST_SUITE_P(poolNullParamsTest, PoolNullParamsTest,
54+
::testing::Values(&umfDisjointPoolOps,
55+
&umfScalablePoolOps,
56+
&umfProxyPoolOps));
57+
#endif

0 commit comments

Comments
 (0)