Skip to content

Commit

Permalink
#249: location: fix debug print in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hobywan committed Feb 22, 2019
1 parent cb08477 commit 5a158d4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
26 changes: 14 additions & 12 deletions tests/unit/location/test_location.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<TypeParam*>(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++;
}
Expand All @@ -255,9 +256,11 @@ TYPED_TEST_P(TestLocationRoute, test_route_entity) {
vt::theMsg()->broadcastMsg< locat::EntityMsg, locat::routeTestHandler<TypeParam> >(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
Expand Down Expand Up @@ -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++;
}
);
Expand Down
27 changes: 12 additions & 15 deletions tests/unit/location/test_location_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -96,7 +95,7 @@ struct LongMsg : vt::LocationRoutedMsg<int, vt::Message> {
template <typename MsgT>
void routeTestHandler(EntityMsg* msg) {

auto const& my_node = vt::theContext()->getNode();
auto const my_node = vt::theContext()->getNode();
auto test_msg = vt::makeMessage<MsgT>(magic_number + my_node, my_node);
auto const& test_msg_size = sizeof(*test_msg);

Expand All @@ -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<MsgT>(msg->entity_, msg->home_, test_msg);
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5a158d4

Please sign in to comment.