Skip to content

Commit b910d72

Browse files
fix: replace UT_ASSERTs with GTEST asserts
Ref. #569
1 parent e9b0630 commit b910d72

File tree

4 files changed

+38
-14
lines changed

4 files changed

+38
-14
lines changed

test/memspaces/memspace_fixtures.hpp

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

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

@@ -65,9 +65,10 @@ struct memspaceGetTest : ::numaNodesTest,
6565
}
6666

6767
auto [isQuerySupported, memspaceGet] = this->GetParam();
68+
isQuerySupported(nodeIds.front());
6869

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

7374
hMemspace = memspaceGet();
@@ -81,10 +82,17 @@ struct memspaceProviderTest : ::memspaceGetTest {
8182
void SetUp() override {
8283
::memspaceGetTest::SetUp();
8384

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

89+
auto [isQuerySupported, memspaceGet] = ::memspaceGetTest::GetParam();
90+
isQuerySupported(nodeIds.front());
91+
92+
if (IS_SKIPPED_OR_FAILED()) {
93+
return;
94+
}
95+
8896
umf_result_t ret =
8997
umfMemoryProviderCreateFromMemspace(hMemspace, nullptr, &hProvider);
9098
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_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)