Skip to content

Commit 67331e3

Browse files
fix: replace UT_ASSERTs with GTEST asserts
Ref. #569
1 parent 89b660c commit 67331e3

File tree

5 files changed

+39
-15
lines changed

5 files changed

+39
-15
lines changed

test/memspaces/memspace_fixtures.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct numaNodesTest : ::umf_test::test {
5050
unsigned long maxNodeId = 0;
5151
};
5252

53-
using isQuerySupportedFunc = bool (*)(size_t);
53+
using isQuerySupportedFunc = void (*)(size_t);
5454
using memspaceGetFunc = umf_const_memspace_handle_t (*)();
5555
using memspaceGetParams = std::tuple<isQuerySupportedFunc, memspaceGetFunc>;
5656

@@ -64,9 +64,10 @@ struct memspaceGetTest : ::numaNodesTest,
6464
}
6565

6666
auto [isQuerySupported, memspaceGet] = this->GetParam();
67+
isQuerySupported(nodeIds.front());
6768

68-
if (!isQuerySupported(nodeIds.front())) {
69-
GTEST_SKIP();
69+
if (IS_SKIPPED_OR_FAILED()) {
70+
return;
7071
}
7172

7273
hMemspace = memspaceGet();
@@ -80,10 +81,17 @@ struct memspaceProviderTest : ::memspaceGetTest {
8081
void SetUp() override {
8182
::memspaceGetTest::SetUp();
8283

83-
if (::memspaceGetTest::IsSkipped()) {
84+
if (numa_available() == -1 || numa_all_nodes_ptr == nullptr) {
8485
GTEST_SKIP();
8586
}
8687

88+
auto [isQuerySupported, memspaceGet] = ::memspaceGetTest::GetParam();
89+
isQuerySupported(nodeIds.front());
90+
91+
if (IS_SKIPPED_OR_FAILED()) {
92+
return;
93+
}
94+
8795
umf_result_t ret =
8896
umfMemoryProviderCreateFromMemspace(hMemspace, nullptr, &hProvider);
8997
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);

test/memspaces/memspace_helpers.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#define SIZE_4K (4096UL)
1717
#define SIZE_4M (SIZE_4K * 1024UL)
1818

19+
#define IS_SKIPPED_OR_FAILED() (HasFatalFailure() || IsSkipped())
20+
1921
///
2022
/// @brief Retrieves the memory policy information for \p ptr.
2123
/// @param ptr allocation pointer.

test/memspaces/memspace_highest_bandwidth.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,20 @@
99
#include "memspace_internal.h"
1010
#include "test_helpers.h"
1111

12-
static bool canQueryBandwidth(size_t nodeId) {
12+
static void canQueryBandwidth(size_t nodeId) {
1313
hwloc_topology_t topology = nullptr;
1414
int ret = hwloc_topology_init(&topology);
15-
UT_ASSERTeq(ret, 0);
15+
16+
ASSERT_EQ(ret, 0);
17+
1618
ret = hwloc_topology_load(topology);
17-
UT_ASSERTeq(ret, 0);
19+
20+
ASSERT_EQ(ret, 0);
1821

1922
hwloc_obj_t numaNode =
2023
hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, nodeId);
21-
UT_ASSERTne(numaNode, nullptr);
24+
25+
ASSERT_NE(numaNode, nullptr);
2226

2327
// Setup initiator structure.
2428
struct hwloc_location initiator;
@@ -30,7 +34,10 @@ static bool canQueryBandwidth(size_t nodeId) {
3034
numaNode, &initiator, 0, &value);
3135

3236
hwloc_topology_destroy(topology);
33-
return (ret == 0);
37+
38+
if (ret != 0) {
39+
GTEST_SKIP() << "ret is equal to " << ret << ", should be " << 0;
40+
}
3441
}
3542

3643
INSTANTIATE_TEST_SUITE_P(memspaceLowestLatencyTest, memspaceGetTest,

test/memspaces/memspace_highest_capacity.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ TEST_F(memspaceHighestCapacityProviderTest, highestCapacityVerify) {
6060
memset(ptr, 0, alloc_size);
6161
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
6262

63-
int nodeId;
63+
int nodeId = 0;
6464

6565
ASSERT_NO_FATAL_FAILURE(getNumaNodeByPtr(ptr, &nodeId));
6666

test/memspaces/memspace_lowest_latency.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,20 @@
99
#include "memspace_internal.h"
1010
#include "test_helpers.h"
1111

12-
static bool canQueryLatency(size_t nodeId) {
12+
static void canQueryLatency(size_t nodeId) {
1313
hwloc_topology_t topology = nullptr;
1414
int ret = hwloc_topology_init(&topology);
15-
UT_ASSERTeq(ret, 0);
15+
16+
ASSERT_EQ(ret, 0);
17+
1618
ret = hwloc_topology_load(topology);
17-
UT_ASSERTeq(ret, 0);
19+
20+
ASSERT_EQ(ret, 0);
1821

1922
hwloc_obj_t numaNode =
2023
hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, nodeId);
21-
UT_ASSERTne(numaNode, nullptr);
24+
25+
ASSERT_NE(numaNode, nullptr);
2226

2327
// Setup initiator structure.
2428
struct hwloc_location initiator;
@@ -30,7 +34,10 @@ static bool canQueryLatency(size_t nodeId) {
3034
&initiator, 0, &value);
3135

3236
hwloc_topology_destroy(topology);
33-
return (ret == 0);
37+
38+
if (ret != 0) {
39+
GTEST_SKIP() << "ret is equal to " << ret << ", should be " << 0;
40+
}
3441
}
3542

3643
INSTANTIATE_TEST_SUITE_P(memspaceLowestLatencyTest, memspaceGetTest,

0 commit comments

Comments
 (0)