Skip to content

Commit d0a9cb1

Browse files
committed
add names to test cases
1 parent 6f02c80 commit d0a9cb1

32 files changed

+374
-214
lines changed

test/coarse_lib.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,14 @@ INSTANTIATE_TEST_SUITE_P(
114114
CoarseWithMemoryStrategyTest, CoarseWithMemoryStrategyTest,
115115
::testing::Values(UMF_COARSE_MEMORY_STRATEGY_FASTEST,
116116
UMF_COARSE_MEMORY_STRATEGY_FASTEST_BUT_ONE,
117-
UMF_COARSE_MEMORY_STRATEGY_CHECK_ALL_SIZE));
117+
UMF_COARSE_MEMORY_STRATEGY_CHECK_ALL_SIZE),
118+
([](auto const &info) {
119+
static const char *names[] = {
120+
"UMF_COARSE_MEMORY_STRATEGY_FASTEST",
121+
"UMF_COARSE_MEMORY_STRATEGY_FASTEST_BUT_ONE",
122+
"UMF_COARSE_MEMORY_STRATEGY_CHECK_ALL_SIZE"};
123+
return names[info.index];
124+
}));
118125

119126
TEST_P(CoarseWithMemoryStrategyTest, coarseTest_basic_provider) {
120127
umf_memory_provider_handle_t malloc_memory_provider;

test/common/provider.hpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,36 @@
1818
#include "test_helpers.h"
1919
#include "utils/cpp_helpers.hpp"
2020

21+
typedef void *(*pfnProviderParamsCreate)();
22+
typedef umf_result_t (*pfnProviderParamsDestroy)(void *);
23+
24+
using providerCreateExtParams =
25+
std::tuple<const umf_memory_provider_ops_t *, void *>;
26+
27+
std::string providerCreateExtParamsNameGen(
28+
const testing::TestParamInfo<providerCreateExtParams> param) {
29+
const umf_memory_provider_ops_t *provider_ops = std::get<0>(param.param);
30+
31+
const char *providerName = NULL;
32+
provider_ops->get_name(NULL, &providerName);
33+
34+
return providerName;
35+
}
36+
37+
void providerCreateExt(providerCreateExtParams params,
38+
umf_test::provider_unique_handle_t *handle) {
39+
umf_memory_provider_handle_t hProvider = nullptr;
40+
auto [provider_ops, provider_params] = params;
41+
42+
auto ret =
43+
umfMemoryProviderCreate(provider_ops, provider_params, &hProvider);
44+
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
45+
ASSERT_NE(hProvider, nullptr);
46+
47+
*handle = umf_test::provider_unique_handle_t(hProvider,
48+
&umfMemoryProviderDestroy);
49+
}
50+
2151
namespace umf_test {
2252

2353
umf_memory_provider_handle_t

test/disjoint_pool_file_prov.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ INSTANTIATE_TEST_SUITE_P(
3737
FileWithMemoryStrategyTest, FileWithMemoryStrategyTest,
3838
::testing::Values(UMF_COARSE_MEMORY_STRATEGY_FASTEST,
3939
UMF_COARSE_MEMORY_STRATEGY_FASTEST_BUT_ONE,
40-
UMF_COARSE_MEMORY_STRATEGY_CHECK_ALL_SIZE));
40+
UMF_COARSE_MEMORY_STRATEGY_CHECK_ALL_SIZE),
41+
([](auto const &info) {
42+
const char *names[] = {"UMF_COARSE_MEMORY_STRATEGY_FASTEST",
43+
"UMF_COARSE_MEMORY_STRATEGY_FASTEST_BUT_ONE",
44+
"UMF_COARSE_MEMORY_STRATEGY_CHECK_ALL_SIZE"};
45+
return names[info.index];
46+
}));
4147

4248
TEST_P(FileWithMemoryStrategyTest, disjointFileMallocPool_simple1) {
4349
umf_memory_provider_handle_t malloc_memory_provider = nullptr;

test/ipcAPI.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,5 @@ INSTANTIATE_TEST_SUITE_P(umfIpcTestSuite, umfIpcTest,
128128
::testing::Values(ipcTestParams{
129129
umfProxyPoolOps(), nullptr, nullptr,
130130
&IPC_MOCK_PROVIDER_OPS, nullptr, nullptr,
131-
&hostMemoryAccessor}));
131+
&hostMemoryAccessor}),
132+
ipcTestParamsNameGen);

test/ipcFixtures.hpp

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,29 @@
55
#ifndef UMF_TEST_IPC_FIXTURES_HPP
66
#define UMF_TEST_IPC_FIXTURES_HPP
77

8-
#include "base.hpp"
9-
#include "multithread_helpers.hpp"
10-
#include "pool.hpp"
11-
#include "test_helpers.h"
8+
#include <algorithm>
9+
#include <cstring>
10+
#include <numeric>
11+
#include <random>
12+
#include <tuple>
1213

1314
#include <umf/ipc.h>
1415
#include <umf/memory_pool.h>
1516
#include <umf/memory_provider.h>
1617
#include <umf/pools/pool_proxy.h>
1718

18-
#include <algorithm>
19-
#include <cstring>
20-
#include <numeric>
21-
#include <random>
22-
#include <tuple>
19+
#include "base.hpp"
20+
#include "multithread_helpers.hpp"
21+
#include "pool.hpp"
22+
#include "test_helpers.h"
2323

2424
class MemoryAccessor {
2525
public:
2626
virtual ~MemoryAccessor() = default;
2727
virtual void fill(void *ptr, size_t size, const void *pattern,
2828
size_t pattern_size) = 0;
2929
virtual void copy(void *dst_ptr, void *src_ptr, size_t size) = 0;
30+
virtual const char *getName() = 0;
3031
};
3132

3233
class HostMemoryAccessor : public MemoryAccessor {
@@ -47,6 +48,8 @@ class HostMemoryAccessor : public MemoryAccessor {
4748
void copy(void *dst_ptr, void *src_ptr, size_t size) override {
4849
std::memcpy(dst_ptr, src_ptr, size);
4950
}
51+
52+
const char *getName() override { return "HostMemoryAccessor"; }
5053
};
5154

5255
typedef void *(*pfnPoolParamsCreate)();
@@ -65,6 +68,28 @@ using ipcTestParams =
6568
pfnProviderParamsCreate, pfnProviderParamsDestroy,
6669
MemoryAccessor *>;
6770

71+
std::string
72+
ipcTestParamsNameGen(const ::testing::TestParamInfo<ipcTestParams> &info) {
73+
const umf_memory_pool_ops_t *pool_ops = std::get<0>(info.param);
74+
const umf_memory_provider_ops_t *provider_ops = std::get<3>(info.param);
75+
76+
const char *poolName = NULL;
77+
const char *providerName = NULL;
78+
79+
pool_ops->get_name(NULL, &poolName);
80+
provider_ops->get_name(NULL, &providerName);
81+
82+
std::string poolParams =
83+
std::get<1>(info.param)
84+
? std::string("_w_params_") + std::to_string(info.index)
85+
: std::string("");
86+
87+
MemoryAccessor *memAccessor = std::get<6>(info.param);
88+
89+
return std::string(poolName) + poolParams + "_" + providerName + "_" +
90+
memAccessor->getName();
91+
}
92+
6893
struct umfIpcTest : umf_test::test,
6994
::testing::WithParamInterface<ipcTestParams> {
7095
umfIpcTest() {}

test/memoryPoolAPI.cpp

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44
// This file contains tests for UMF pool API
55

6-
#include "base.hpp"
7-
#include "pool.hpp"
8-
#include "poolFixtures.hpp"
9-
#include "provider.hpp"
10-
#include "provider_null.h"
11-
#include "provider_trace.h"
12-
#include "test_helpers.h"
6+
#include <array>
7+
#include <string>
8+
#include <thread>
9+
#include <type_traits>
10+
#include <unordered_map>
11+
#include <variant>
1312

1413
#include <umf/memory_provider.h>
1514
#include <umf/pools/pool_disjoint.h>
@@ -19,12 +18,13 @@
1918
#include <umf/proxy_lib_new_delete.h>
2019
#endif
2120

22-
#include <array>
23-
#include <string>
24-
#include <thread>
25-
#include <type_traits>
26-
#include <unordered_map>
27-
#include <variant>
21+
#include "base.hpp"
22+
#include "pool.hpp"
23+
#include "poolFixtures.hpp"
24+
#include "provider.hpp"
25+
#include "provider_null.h"
26+
#include "provider_trace.h"
27+
#include "test_helpers.h"
2828

2929
using umf_test::test;
3030
using namespace umf_test;
@@ -309,16 +309,23 @@ INSTANTIATE_TEST_SUITE_P(
309309
&BA_GLOBAL_PROVIDER_OPS, nullptr, nullptr},
310310
poolCreateExtParams{umfDisjointPoolOps(), defaultDisjointPoolConfig,
311311
defaultDisjointPoolConfigDestroy,
312-
&BA_GLOBAL_PROVIDER_OPS, nullptr, nullptr}));
312+
&BA_GLOBAL_PROVIDER_OPS, nullptr, nullptr}),
313+
poolCreateExtParamsNameGen);
313314

314315
INSTANTIATE_TEST_SUITE_P(mallocMultiPoolTest, umfMultiPoolTest,
315316
::testing::Values(poolCreateExtParams{
316317
umfProxyPoolOps(), nullptr, nullptr,
317-
&BA_GLOBAL_PROVIDER_OPS, nullptr, nullptr}));
318+
&BA_GLOBAL_PROVIDER_OPS, nullptr, nullptr}),
319+
poolCreateExtParamsNameGen);
318320

319321
INSTANTIATE_TEST_SUITE_P(umfPoolWithCreateFlagsTest, umfPoolWithCreateFlagsTest,
320322
::testing::Values(0,
321-
UMF_POOL_CREATE_FLAG_OWN_PROVIDER));
323+
UMF_POOL_CREATE_FLAG_OWN_PROVIDER),
324+
([](auto const &info) {
325+
static const char *names[] = {
326+
"NONE", "UMF_POOL_CREATE_FLAG_OWN_PROVIDER"};
327+
return names[info.index];
328+
}));
322329

323330
////////////////// Negative test cases /////////////////
324331

@@ -382,7 +389,14 @@ INSTANTIATE_TEST_SUITE_P(
382389
::testing::Values(UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY,
383390
UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC,
384391
UMF_RESULT_ERROR_INVALID_ARGUMENT,
385-
UMF_RESULT_ERROR_UNKNOWN));
392+
UMF_RESULT_ERROR_UNKNOWN),
393+
([](auto const &info) {
394+
static const char *names[] = {
395+
"UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY",
396+
"UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC",
397+
"UMF_RESULT_ERROR_INVALID_ARGUMENT", "UMF_RESULT_ERROR_UNKNOWN"};
398+
return names[info.index];
399+
}));
386400

387401
TEST_P(poolInitializeTest, errorPropagation) {
388402
auto nullProvider = umf_test::wrapProviderUnique(nullProviderCreate());
@@ -559,4 +573,19 @@ INSTANTIATE_TEST_SUITE_P(
559573
umf_test::withGeneratedArgs(umfPoolGetMemoryProvider),
560574
umf_test::withGeneratedArgs(umfPoolByPtr),
561575
umf_test::withGeneratedArgs(umfPoolSetTag),
562-
umf_test::withGeneratedArgs(umfPoolGetTag)));
576+
umf_test::withGeneratedArgs(umfPoolGetTag)),
577+
([](auto const &info) {
578+
static const char *names[] = {"umfPoolMalloc",
579+
"umfPoolAlignedMalloc",
580+
"umfPoolFree",
581+
"umfPoolCalloc",
582+
"umfPoolRealloc",
583+
"umfPoolMallocUsableSize",
584+
"umfPoolGetLastAllocationError",
585+
"umfPoolGetName",
586+
"umfPoolGetMemoryProvider",
587+
"umfPoolByPtr",
588+
"umfPoolSetTag",
589+
"umfPoolGetTag"};
590+
return names[info.index];
591+
}));

test/memoryProviderAPI.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,14 @@ INSTANTIATE_TEST_SUITE_P(
338338
::testing::Values(UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY,
339339
UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC,
340340
UMF_RESULT_ERROR_INVALID_ARGUMENT,
341-
UMF_RESULT_ERROR_UNKNOWN));
341+
UMF_RESULT_ERROR_UNKNOWN),
342+
([](auto const &info) {
343+
static const char *names[] = {
344+
"UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY",
345+
"UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC",
346+
"UMF_RESULT_ERROR_INVALID_ARGUMENT", "UMF_RESULT_ERROR_UNKNOWN"};
347+
return names[info.index];
348+
}));
342349

343350
TEST_P(providerInitializeTest, errorPropagation) {
344351
struct provider : public umf_test::provider_base_t {
@@ -389,4 +396,14 @@ INSTANTIATE_TEST_SUITE_P(
389396
umf_test::withGeneratedArgs(umfMemoryProviderGetMinPageSize),
390397
umf_test::withGeneratedArgs(umfMemoryProviderPurgeLazy),
391398
umf_test::withGeneratedArgs(umfMemoryProviderPurgeForce),
392-
umf_test::withGeneratedArgs(umfMemoryProviderGetName)));
399+
umf_test::withGeneratedArgs(umfMemoryProviderGetName)),
400+
([](auto const &info) {
401+
static const char *names[] = {"umfMemoryProviderAlloc",
402+
"umfMemoryProviderFree",
403+
"umfMemoryProviderGetRecommendedPageSize",
404+
"umfMemoryProviderGetMinPageSize",
405+
"umfMemoryProviderPurgeLazy",
406+
"umfMemoryProviderPurgeForce",
407+
"umfMemoryProviderGetName"};
408+
return names[info.index];
409+
}));

test/memspaces/memspace_highest_bandwidth.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,25 @@ static void canQueryBandwidth(size_t nodeId) {
4040
}
4141
}
4242

43-
INSTANTIATE_TEST_SUITE_P(memspaceLowestLatencyTest, memspaceGetTest,
44-
::testing::Values(memspaceGetParams{
45-
canQueryBandwidth,
46-
umfMemspaceHighestBandwidthGet}));
47-
48-
INSTANTIATE_TEST_SUITE_P(memspaceLowestLatencyProviderTest,
49-
memspaceProviderTest,
50-
::testing::Values(memspaceGetParams{
51-
canQueryBandwidth,
52-
umfMemspaceHighestBandwidthGet}));
43+
INSTANTIATE_TEST_SUITE_P(
44+
memspaceLowestLatencyTest, memspaceGetTest,
45+
::testing::Values(memspaceGetParams{canQueryBandwidth,
46+
umfMemspaceHighestBandwidthGet}),
47+
([](auto const &info) {
48+
static const char *names[] = {"canQueryBandwidth",
49+
"umfMemspaceHighestBandwidthGet"};
50+
return names[info.index];
51+
}));
52+
53+
INSTANTIATE_TEST_SUITE_P(
54+
memspaceLowestLatencyProviderTest, memspaceProviderTest,
55+
::testing::Values(memspaceGetParams{canQueryBandwidth,
56+
umfMemspaceHighestBandwidthGet}),
57+
([](auto const &info) {
58+
static const char *names[] = {"canQueryBandwidth",
59+
"umfMemspaceHighestBandwidthGet"};
60+
return names[info.index];
61+
}));
5362

5463
TEST_F(numaNodesTest, PerCoreBandwidthPlacement) {
5564
const size_t allocSize = 4096;

test/memspaces/memspace_lowest_latency.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,21 @@ static void canQueryLatency(size_t nodeId) {
4141

4242
INSTANTIATE_TEST_SUITE_P(memspaceLowestLatencyTest, memspaceGetTest,
4343
::testing::Values(memspaceGetParams{
44-
canQueryLatency, umfMemspaceLowestLatencyGet}));
44+
canQueryLatency, umfMemspaceLowestLatencyGet}),
45+
([](auto const &info) {
46+
static const char *names[] = {
47+
"canQueryLatency",
48+
"umfMemspaceLowestLatencyGet"};
49+
return names[info.index];
50+
}));
4551

4652
INSTANTIATE_TEST_SUITE_P(memspaceLowestLatencyProviderTest,
4753
memspaceProviderTest,
4854
::testing::Values(memspaceGetParams{
49-
canQueryLatency, umfMemspaceLowestLatencyGet}));
55+
canQueryLatency, umfMemspaceLowestLatencyGet}),
56+
([](auto const &info) {
57+
static const char *names[] = {
58+
"canQueryLatency",
59+
"umfMemspaceLowestLatencyGet"};
60+
return names[info.index];
61+
}));

test/poolFixtures.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,26 @@ using poolCreateExtParams =
3434
pfnPoolParamsDestroy, const umf_memory_provider_ops_t *,
3535
pfnProviderParamsCreate, pfnProviderParamsDestroy>;
3636

37+
std::string poolCreateExtParamsNameGen(
38+
const testing::TestParamInfo<poolCreateExtParams> &info) {
39+
40+
const umf_memory_pool_ops_t *pool_ops = std::get<0>(info.param);
41+
const umf_memory_provider_ops_t *provider_ops = std::get<3>(info.param);
42+
43+
const char *poolName = NULL;
44+
const char *providerName = NULL;
45+
46+
pool_ops->get_name(NULL, &poolName);
47+
provider_ops->get_name(NULL, &providerName);
48+
49+
std::string poolParams =
50+
std::get<1>(info.param)
51+
? std::string("_w_params_") + std::to_string(info.index)
52+
: std::string("");
53+
54+
return std::string(poolName) + poolParams + "_" + providerName;
55+
}
56+
3757
umf_test::pool_unique_handle_t poolCreateExtUnique(poolCreateExtParams params) {
3858
auto [pool_ops, poolParamsCreate, poolParamsDestroy, provider_ops,
3959
providerParamsCreate, providerParamsDestroy] = params;

0 commit comments

Comments
 (0)