Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: substitute UT_ASSERTs with asserts from GTEST part 4 #704

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/common/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace umf_test {

#define IS_SKIPPED_OR_FAILED() (HasFatalFailure() || IsSkipped())

#define NOEXCEPT_COND(cond, val, expected_val) \
try { \
cond(val, expected_val); \
Expand Down
21 changes: 16 additions & 5 deletions test/memspaces/memspace_fixtures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct numaNodesTest : ::umf_test::test {
unsigned long maxNodeId = 0;
};

using isQuerySupportedFunc = bool (*)(size_t);
using isQuerySupportedFunc = void (*)(size_t);
lukaszstolarczuk marked this conversation as resolved.
Show resolved Hide resolved
using memspaceGetFunc = umf_const_memspace_handle_t (*)();
using memspaceGetParams = std::tuple<isQuerySupportedFunc, memspaceGetFunc>;

Expand All @@ -65,9 +65,10 @@ struct memspaceGetTest : ::numaNodesTest,
}

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

if (!isQuerySupported(nodeIds.front())) {
GTEST_SKIP();
if (IS_SKIPPED_OR_FAILED()) {
return;
lukaszstolarczuk marked this conversation as resolved.
Show resolved Hide resolved
}

hMemspace = memspaceGet();
Expand All @@ -81,8 +82,18 @@ struct memspaceProviderTest : ::memspaceGetTest {
void SetUp() override {
::memspaceGetTest::SetUp();

if (::memspaceGetTest::IsSkipped()) {
GTEST_SKIP();
if (numa_available() == -1 || numa_all_nodes_ptr == nullptr) {
GTEST_SKIP() << "No available NUMA support; skipped";
}

auto [isQuerySupported, memspaceGet] = ::memspaceGetTest::GetParam();
isQuerySupported(nodeIds.front());

// The test has been marked as skipped in isQuerySupported,
// repeating GTEST_SKIP in fixture would only duplicate
// the output message
if (IS_SKIPPED_OR_FAILED()) {
return;
}

umf_result_t ret =
Expand Down
16 changes: 11 additions & 5 deletions test/memspaces/memspace_highest_bandwidth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@
#include "memspace_internal.h"
#include "test_helpers.h"

static bool canQueryBandwidth(size_t nodeId) {
static void canQueryBandwidth(size_t nodeId) {
hwloc_topology_t topology = nullptr;
int ret = hwloc_topology_init(&topology);
UT_ASSERTeq(ret, 0);
ASSERT_EQ(ret, 0);

ret = hwloc_topology_load(topology);
UT_ASSERTeq(ret, 0);
ASSERT_EQ(ret, 0);

hwloc_obj_t numaNode =
hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, nodeId);
UT_ASSERTne(numaNode, nullptr);
ASSERT_NE(numaNode, nullptr);

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

hwloc_topology_destroy(topology);
return (ret == 0);

if (ret != 0) {
GTEST_SKIP()
<< "Error: hwloc_memattr_get_value return value is equal to " << ret
<< ", should be " << 0;
}
}

INSTANTIATE_TEST_SUITE_P(memspaceLowestLatencyTest, memspaceGetTest,
Expand Down
16 changes: 11 additions & 5 deletions test/memspaces/memspace_lowest_latency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@
#include "memspace_internal.h"
#include "test_helpers.h"

static bool canQueryLatency(size_t nodeId) {
static void canQueryLatency(size_t nodeId) {
hwloc_topology_t topology = nullptr;
int ret = hwloc_topology_init(&topology);
UT_ASSERTeq(ret, 0);
ASSERT_EQ(ret, 0);

ret = hwloc_topology_load(topology);
UT_ASSERTeq(ret, 0);
ASSERT_EQ(ret, 0);

hwloc_obj_t numaNode =
hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, nodeId);
UT_ASSERTne(numaNode, nullptr);
ASSERT_NE(numaNode, nullptr);

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

hwloc_topology_destroy(topology);
return (ret == 0);

if (ret != 0) {
GTEST_SKIP()
<< "Error: hwloc_memattr_get_value return value is equal to " << ret
<< ", should be " << 0;
}
}

INSTANTIATE_TEST_SUITE_P(memspaceLowestLatencyTest, memspaceGetTest,
Expand Down
Loading