From fcd6abd72a2c128856ad4295f1b212956fc1f968 Mon Sep 17 00:00:00 2001 From: Ivan Santiago Paunovic Date: Wed, 28 Oct 2020 11:31:47 -0300 Subject: [PATCH] Make test logging rosout more reliable Signed-off-by: Ivan Santiago Paunovic --- rcl/test/rcl/test_logging_rosout.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/rcl/test/rcl/test_logging_rosout.cpp b/rcl/test/rcl/test_logging_rosout.cpp index 3c02b6cd8..224d18036 100644 --- a/rcl/test/rcl/test_logging_rosout.cpp +++ b/rcl/test/rcl/test_logging_rosout.cpp @@ -141,7 +141,8 @@ class TEST_FIXTURE_P_RMW (TestLoggingRosoutFixture) }; void -wait_for_subscription_to_be_ready( +check_if_rosout_subscription_gets_a_message( + const char * logger_name, rcl_subscription_t * subscription, rcl_context_t * context, size_t max_tries, @@ -159,6 +160,7 @@ wait_for_subscription_to_be_ready( }); size_t iteration = 0; do { + RCUTILS_LOG_INFO_NAMED(logger_name, "SOMETHING"); ++iteration; ret = rcl_wait_set_clear(&wait_set); ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; @@ -182,11 +184,10 @@ wait_for_subscription_to_be_ready( /* Testing the subscriber of topic 'rosout' whether to get event from logging or not. */ TEST_P_RMW(TestLoggingRosoutFixture, test_logging_rosout) { - // log - RCUTILS_LOG_INFO_NAMED(rcl_node_get_logger_name(this->node_ptr), "SOMETHING"); - - bool success; - wait_for_subscription_to_be_ready(this->subscription_ptr, this->context_ptr, 10, 100, success); + bool success = false; + check_if_rosout_subscription_gets_a_message( + rcl_node_get_logger_name(this->node_ptr), this->subscription_ptr, + this->context_ptr, 30, 100, success); ASSERT_EQ(success, GetParam().expected_success); }