From 5a158d4bbc0a3f5826990755e46da2c3fa0e2820 Mon Sep 17 00:00:00 2001 From: Hoby Rakotoarivelo Date: Fri, 22 Feb 2019 19:19:27 +0100 Subject: [PATCH] #249: location: fix debug print in tests --- tests/unit/location/test_location.cc | 26 +++++++++++---------- tests/unit/location/test_location_common.h | 27 ++++++++++------------ 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/tests/unit/location/test_location.cc b/tests/unit/location/test_location.cc index 2801da3e45..d2f3e6695d 100644 --- a/tests/unit/location/test_location.cc +++ b/tests/unit/location/test_location.cc @@ -241,9 +241,10 @@ TYPED_TEST_P(TestLocationRoute, test_route_entity) { // count the number of routed messages received by the home node auto msg = static_cast(raw_msg); auto dst = vt::theContext()->getNode(); - #if DEBUG_LOCATION_TESTS - fmt::print("{}: a message arrived with data: {}.\n", dst, msg->entity_); - #endif + debug_print( + location, node, + "rank:{} a message arrived for entity: {}\n", dst, msg->entity_ + ); EXPECT_EQ(msg->entity_, locat::magic_number + msg->from_); msg_count++; } @@ -255,9 +256,11 @@ TYPED_TEST_P(TestLocationRoute, test_route_entity) { vt::theMsg()->broadcastMsg< locat::EntityMsg, locat::routeTestHandler >(msg); while (msg_count < nb_nodes - 1) { vt::runScheduler(); } - #if DEBUG_LOCATION_TESTS - fmt::print("all messages have been arrived.\n"); - #endif + debug_print( + location, node, + "all messages have been arrived.\n" + ); + EXPECT_EQ(msg_count, nb_nodes - 1); } // finalize @@ -317,12 +320,11 @@ TYPED_TEST_P(TestLocationRoute, test_entity_cache_migrated_entity){ // receive migrated entity: register it and keep in cache vt::theLocMan()->virtual_loc->registerEntityMigrated( entity, my_node, [entity,&nb_received](vt::BaseMessage* in_msg) { - #if DEBUG_LOCATION_TESTS - fmt::print( - "rank:{}: a message arrived to me for a migrated entity {}.\n", - vt::theContext()->getNode(), entity - ); - #endif + debug_print( + location, node, + "rank:{}: a message arrived to me for a migrated entity {}.\n", + vt::theContext()->getNode(), entity + ); nb_received++; } ); diff --git a/tests/unit/location/test_location_common.h b/tests/unit/location/test_location_common.h index b7d0098cd7..d4e4212302 100644 --- a/tests/unit/location/test_location_common.h +++ b/tests/unit/location/test_location_common.h @@ -48,7 +48,6 @@ #include "data_message.h" #include "vt/transport.h" #include "test_parallel_harness.h" -#define DEBUG_LOCATION_TESTS 0 namespace vt { namespace tests { namespace unit { namespace locat { @@ -96,7 +95,7 @@ struct LongMsg : vt::LocationRoutedMsg { template void routeTestHandler(EntityMsg* msg) { - auto const& my_node = vt::theContext()->getNode(); + auto const my_node = vt::theContext()->getNode(); auto test_msg = vt::makeMessage(magic_number + my_node, my_node); auto const& test_msg_size = sizeof(*test_msg); @@ -109,13 +108,11 @@ void routeTestHandler(EntityMsg* msg) { EXPECT_TRUE(correct_size); - #if DEBUG_LOCATION_TESTS - fmt::print( - "rank {}: routing entity:{}, home_node={}, {} message of {} bytes.\n", - my_node, msg->entity_, msg->home_, (msg->is_large_ ? "long" : "short"), test_msg_size - ); - #endif - + debug_print( + location, node, + "rank {}: routing entity:{}, home_node={}, {} message of {} bytes.\n", + my_node, msg->entity_, msg->home_, (msg->is_large_ ? "long" : "short"), test_msg_size + ); // route message vt::theLocMan()->virtual_loc->routeMsg(msg->entity_, msg->home_, test_msg); } @@ -148,12 +145,12 @@ void verifyCacheConsistency( // check for cache updates bool is_entity_cached = isCached(entity); - #if DEBUG_LOCATION_TESTS - fmt::print( - "iter:{}, rank {}: route_test: entityID={}, home_node={}, {} message of {} bytes, is in cache ? {}.\n", - iter, my_node, msg->data_, msg->from_, (is_long ? "long" : "short"), sizeof(*msg), is_entity_cached - ); - #endif + + debug_print( + location, node, + "iter:{}, rank {}: route_test: entityID={}, home_node={}, {} message of {} bytes, is in cache ? {}.\n", + iter, my_node, msg->data_, msg->from_, (is_long ? "long" : "short"), sizeof(*msg), is_entity_cached + ); if (not is_eager) { // On non eager case: the location is first explicitly resolved