Skip to content

Commit 371a6f5

Browse files
authored
Merge pull request #704 from EuphoricThinking/assertspr8
fix: substitute UT_ASSERTs with asserts from GTEST part 4
2 parents e082fc4 + 39cdf85 commit 371a6f5

File tree

4 files changed

+40
-15
lines changed

4 files changed

+40
-15
lines changed

test/common/base.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
namespace umf_test {
1616

17+
#define IS_SKIPPED_OR_FAILED() (HasFatalFailure() || IsSkipped())
18+
1719
#define NOEXCEPT_COND(cond, val, expected_val) \
1820
try { \
1921
cond(val, expected_val); \

test/memspaces/memspace_fixtures.hpp

Lines changed: 16 additions & 5 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,8 +82,18 @@ struct memspaceProviderTest : ::memspaceGetTest {
8182
void SetUp() override {
8283
::memspaceGetTest::SetUp();
8384

84-
if (::memspaceGetTest::IsSkipped()) {
85-
GTEST_SKIP();
85+
if (numa_available() == -1 || numa_all_nodes_ptr == nullptr) {
86+
GTEST_SKIP() << "No available NUMA support; skipped";
87+
}
88+
89+
auto [isQuerySupported, memspaceGet] = ::memspaceGetTest::GetParam();
90+
isQuerySupported(nodeIds.front());
91+
92+
// The test has been marked as skipped in isQuerySupported,
93+
// repeating GTEST_SKIP in fixture would only duplicate
94+
// the output message
95+
if (IS_SKIPPED_OR_FAILED()) {
96+
return;
8697
}
8798

8899
umf_result_t ret =

test/memspaces/memspace_highest_bandwidth.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@
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+
ASSERT_EQ(ret, 0);
16+
1617
ret = hwloc_topology_load(topology);
17-
UT_ASSERTeq(ret, 0);
18+
ASSERT_EQ(ret, 0);
1819

1920
hwloc_obj_t numaNode =
2021
hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, nodeId);
21-
UT_ASSERTne(numaNode, nullptr);
22+
ASSERT_NE(numaNode, nullptr);
2223

2324
// Setup initiator structure.
2425
struct hwloc_location initiator;
@@ -30,7 +31,12 @@ static bool canQueryBandwidth(size_t nodeId) {
3031
numaNode, &initiator, 0, &value);
3132

3233
hwloc_topology_destroy(topology);
33-
return (ret == 0);
34+
35+
if (ret != 0) {
36+
GTEST_SKIP()
37+
<< "Error: hwloc_memattr_get_value return value is equal to " << ret
38+
<< ", should be " << 0;
39+
}
3440
}
3541

3642
INSTANTIATE_TEST_SUITE_P(memspaceLowestLatencyTest, memspaceGetTest,

test/memspaces/memspace_lowest_latency.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@
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+
ASSERT_EQ(ret, 0);
16+
1617
ret = hwloc_topology_load(topology);
17-
UT_ASSERTeq(ret, 0);
18+
ASSERT_EQ(ret, 0);
1819

1920
hwloc_obj_t numaNode =
2021
hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, nodeId);
21-
UT_ASSERTne(numaNode, nullptr);
22+
ASSERT_NE(numaNode, nullptr);
2223

2324
// Setup initiator structure.
2425
struct hwloc_location initiator;
@@ -30,7 +31,12 @@ static bool canQueryLatency(size_t nodeId) {
3031
&initiator, 0, &value);
3132

3233
hwloc_topology_destroy(topology);
33-
return (ret == 0);
34+
35+
if (ret != 0) {
36+
GTEST_SKIP()
37+
<< "Error: hwloc_memattr_get_value return value is equal to " << ret
38+
<< ", should be " << 0;
39+
}
3440
}
3541

3642
INSTANTIATE_TEST_SUITE_P(memspaceLowestLatencyTest, memspaceGetTest,

0 commit comments

Comments
 (0)