Skip to content

Commit

Permalink
fix: replace UT_ASSERTs with GTEST asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
EuphoricThinking committed Sep 18, 2024
1 parent 5101d9e commit cafcfb6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 42 deletions.
18 changes: 7 additions & 11 deletions test/memspaces/memspace_fixtures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct numaNodesTest : ::umf_test::test {
unsigned long maxNodeId = 0;
};

using isQuerySupportedFunc = assert_res (*)(size_t);
using isQuerySupportedFunc = void (*)(size_t);
using memspaceGetFunc = umf_const_memspace_handle_t (*)();
using memspaceGetParams = std::tuple<isQuerySupportedFunc, memspaceGetFunc>;

Expand All @@ -64,12 +64,10 @@ struct memspaceGetTest : ::numaNodesTest,
}

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

assert_res queryCheck = isQuerySupported(nodeIds.front());
if (queryCheck == SKIP_RES) {
GTEST_SKIP();
} else if (queryCheck == FATAL_RES) {
GTEST_FAIL();
if (IS_SKIPPED_OR_FAILED()) {
return;
}

hMemspace = memspaceGet();
Expand All @@ -88,12 +86,10 @@ struct memspaceProviderTest : ::memspaceGetTest {
}

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

assert_res queryCheck = isQuerySupported(nodeIds.front());
if (queryCheck == SKIP_RES) {
GTEST_SKIP();
} else if (queryCheck == FATAL_RES) {
GTEST_FAIL();
if (IS_SKIPPED_OR_FAILED()) {
return;
}

umf_result_t ret =
Expand Down
2 changes: 2 additions & 0 deletions test/memspaces/memspace_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#define SIZE_4K (4096UL)
#define SIZE_4M (SIZE_4K * 1024UL)

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

///
/// @brief Retrieves the memory policy information for \p ptr.
/// @param ptr allocation pointer.
Expand Down
20 changes: 6 additions & 14 deletions test/memspaces/memspace_highest_bandwidth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,20 @@
#include "memspace_internal.h"
#include "test_helpers.h"

static assert_res canQueryBandwidth(size_t nodeId) {
static void canQueryBandwidth(size_t nodeId) {
hwloc_topology_t topology = nullptr;
int ret = hwloc_topology_init(&topology);

if (!GTEST_OUT_EQ(ret, 0)) {
return FATAL_RES;
}
ASSERT_EQ(ret, 0);

ret = hwloc_topology_load(topology);

if (!GTEST_OUT_EQ(ret, 0)) {
return FATAL_RES;
}
ASSERT_EQ(ret, 0);

hwloc_obj_t numaNode =
hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, nodeId);

if (!GTEST_OUT_NE(numaNode, nullptr)) {
return FATAL_RES;
}
ASSERT_NE(numaNode, nullptr);

// Setup initiator structure.
struct hwloc_location initiator;
Expand All @@ -41,10 +35,8 @@ static assert_res canQueryBandwidth(size_t nodeId) {

hwloc_topology_destroy(topology);

if (!GTEST_OUT_EQ(ret, 0)) {
return SKIP_RES;
} else {
return SUCCESS_RES;
if (ret != 0) {
GTEST_SKIP() << "ret is equal to " << ret << ", should be " << 0;
}
}

Expand Down
23 changes: 6 additions & 17 deletions test/memspaces/memspace_lowest_latency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,21 @@
#include "memspace_internal.h"
#include "test_helpers.h"

/*
canQueryLatency is used in a parameter generator as a functional pointer and is not a standalone test, thus it cannot contain GTEST asserts. EXPECT_* or ADD_FAILURE() do not cancel the execution of the code following after, but they interfere with GTEST_SKIP() in fixtures: the execution of the tests included in the suite assigned to the given fixture is not cancelled if EXPECT_* or ADD_FAILURE() are used. Therefore a custom logging macro is used.
*/

static assert_res canQueryLatency(size_t nodeId) {
static void canQueryLatency(size_t nodeId) {
hwloc_topology_t topology = nullptr;
int ret = hwloc_topology_init(&topology);

if (!GTEST_OUT_EQ(ret, 0)) {
return FATAL_RES;
}
ASSERT_EQ(ret, 0);

ret = hwloc_topology_load(topology);

if (!GTEST_OUT_EQ(ret, 0)) {
return FATAL_RES;
}
ASSERT_EQ(ret, 0);

hwloc_obj_t numaNode =
hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, nodeId);

if (!GTEST_OUT_NE(numaNode, nullptr)) {
return FATAL_RES;
}
ASSERT_NE(numaNode, nullptr);

// Setup initiator structure.
struct hwloc_location initiator;
Expand All @@ -45,10 +36,8 @@ static assert_res canQueryLatency(size_t nodeId) {

hwloc_topology_destroy(topology);

if (!GTEST_OUT_EQ(ret, 0)) {
return SKIP_RES;
} else {
return SUCCESS_RES;
if (ret != 0) {
GTEST_SKIP() << "ret is equal to " << ret << ", should be " << 0;
}
}

Expand Down

0 comments on commit cafcfb6

Please sign in to comment.