Skip to content

Commit

Permalink
fix: replace UT_ASSERTs with GTEST asserts
Browse files Browse the repository at this point in the history
Ref. #569
  • Loading branch information
EuphoricThinking committed Sep 19, 2024
1 parent e9b0630 commit b910d72
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
16 changes: 12 additions & 4 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);
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;
}

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

if (::memspaceGetTest::IsSkipped()) {
if (numa_available() == -1 || numa_all_nodes_ptr == nullptr) {
GTEST_SKIP();
}

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

if (IS_SKIPPED_OR_FAILED()) {
return;
}

umf_result_t ret =
umfMemoryProviderCreateFromMemspace(hMemspace, nullptr, &hProvider);
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
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
17 changes: 12 additions & 5 deletions test/memspaces/memspace_highest_bandwidth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@
#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 +34,10 @@ static bool canQueryBandwidth(size_t nodeId) {
numaNode, &initiator, 0, &value);

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

if (ret != 0) {
GTEST_SKIP() << "ret is equal to " << ret << ", should be " << 0;
}
}

INSTANTIATE_TEST_SUITE_P(memspaceLowestLatencyTest, memspaceGetTest,
Expand Down
17 changes: 12 additions & 5 deletions test/memspaces/memspace_lowest_latency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@
#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 +34,10 @@ static bool canQueryLatency(size_t nodeId) {
&initiator, 0, &value);

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

if (ret != 0) {
GTEST_SKIP() << "ret is equal to " << ret << ", should be " << 0;
}
}

INSTANTIATE_TEST_SUITE_P(memspaceLowestLatencyTest, memspaceGetTest,
Expand Down

0 comments on commit b910d72

Please sign in to comment.