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 89b660c commit 0a23572
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 15 deletions.
16 changes: 12 additions & 4 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 = bool (*)(size_t);
using isQuerySupportedFunc = void (*)(size_t);
using memspaceGetFunc = umf_const_memspace_handle_t (*)();
using memspaceGetParams = std::tuple<isQuerySupportedFunc, memspaceGetFunc>;

Expand All @@ -64,9 +64,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 @@ -80,10 +81,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
2 changes: 1 addition & 1 deletion test/memspaces/memspace_highest_capacity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ TEST_F(memspaceHighestCapacityProviderTest, highestCapacityVerify) {
memset(ptr, 0, alloc_size);
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);

int nodeId;
int nodeId = 0;

ASSERT_NO_FATAL_FAILURE(getNumaNodeByPtr(ptr, &nodeId));

Expand Down
18 changes: 13 additions & 5 deletions test/memspaces/memspace_lowest_latency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@
#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 +35,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 0a23572

Please sign in to comment.