From 6b95fd090f80cdbf2b68bd7064d963ac1046f7e3 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 07:33:11 -0400 Subject: [PATCH] Fix up rmw_cyclonedds timestamp testing. (#1156) (#1157) We are about to fix it so that rmw_cyclonedds has receive_timestamp support, so we also need to enable that support here in rcl. We actually rewrite the logic a bit because now the only combination that doesn't work is rmw_connextdds on Windows. Signed-off-by: Chris Lalancette (cherry picked from commit 6d53d24a863c3e9e4a41e9fe5f550271210d9d9d) Co-authored-by: Chris Lalancette --- rcl/test/CMakeLists.txt | 20 +++++--------------- rcl/test/rcl/test_service.cpp | 8 -------- rcl/test/rcl/test_subscription.cpp | 4 ---- 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/rcl/test/CMakeLists.txt b/rcl/test/CMakeLists.txt index 03fc0bc4d..77245e46c 100644 --- a/rcl/test/CMakeLists.txt +++ b/rcl/test/CMakeLists.txt @@ -287,24 +287,14 @@ function(test_target) ) # TODO(asorbini) Enable message timestamp tests for rmw_connextdds on Windows # once clock incompatibilities are resolved. - if(rmw_implementation STREQUAL "rmw_fastrtps_cpp" OR - rmw_implementation STREQUAL "rmw_fastrtps_dynamic_cpp" OR - (rmw_implementation STREQUAL "rmw_connextdds" AND NOT WIN32)) + if(rmw_implementation STREQUAL "rmw_connextdds" AND WIN32) + message(STATUS "Disabling message timestamp test for ${rmw_implementation}") + else() message(STATUS "Enabling message timestamp test for ${rmw_implementation}") target_compile_definitions(test_subscription${target_suffix} - PUBLIC "RMW_TIMESTAMPS_SUPPORTED=1" "RMW_RECEIVED_TIMESTAMP_SUPPORTED=1") + PRIVATE "RMW_TIMESTAMPS_SUPPORTED=1") target_compile_definitions(test_service${target_suffix} - PUBLIC "RMW_TIMESTAMPS_SUPPORTED=1" "RMW_RECEIVED_TIMESTAMP_SUPPORTED=1") - else() - if(rmw_implementation STREQUAL "rmw_cyclonedds_cpp") - message(STATUS "Enabling only source timestamp test for ${rmw_implementation}") - target_compile_definitions(test_subscription${target_suffix} - PUBLIC "RMW_TIMESTAMPS_SUPPORTED=1") - target_compile_definitions(test_service${target_suffix} - PUBLIC "RMW_TIMESTAMPS_SUPPORTED=1") - else() - message(STATUS "Disabling message timestamp test for ${rmw_implementation}") - endif() + PRIVATE "RMW_TIMESTAMPS_SUPPORTED=1") endif() ament_add_gtest_test(test_events diff --git a/rcl/test/rcl/test_service.cpp b/rcl/test/rcl/test_service.cpp index 1a20f5013..0d637c74b 100644 --- a/rcl/test/rcl/test_service.cpp +++ b/rcl/test/rcl/test_service.cpp @@ -183,12 +183,8 @@ TEST_F(TestServiceFixture, test_service_nominal) { EXPECT_EQ(2UL, service_request.uint32_value); #ifdef RMW_TIMESTAMPS_SUPPORTED EXPECT_GE(header.source_timestamp, start_timestamp); -#ifdef RMW_RECEIVED_TIMESTAMP_SUPPORTED EXPECT_GE(header.received_timestamp, start_timestamp); EXPECT_GE(header.received_timestamp, header.source_timestamp); -#else - EXPECT_EQ(0u, header.received_timestamp); -#endif #else EXPECT_EQ(0u, header.source_timestamp); EXPECT_EQ(0u, header.received_timestamp); @@ -214,12 +210,8 @@ TEST_F(TestServiceFixture, test_service_nominal) { EXPECT_EQ(header.request_id.sequence_number, 1); #ifdef RMW_TIMESTAMPS_SUPPORTED EXPECT_GE(header.source_timestamp, start_timestamp); -#ifdef RMW_RECEIVED_TIMESTAMP_SUPPORTED EXPECT_GE(header.received_timestamp, start_timestamp); EXPECT_GE(header.received_timestamp, header.source_timestamp); -#else - EXPECT_EQ(0u, header.received_timestamp); -#endif #else EXPECT_EQ(0u, header.source_timestamp); EXPECT_EQ(0u, header.received_timestamp); diff --git a/rcl/test/rcl/test_subscription.cpp b/rcl/test/rcl/test_subscription.cpp index dbb7435d1..243eb20e0 100644 --- a/rcl/test/rcl/test_subscription.cpp +++ b/rcl/test/rcl/test_subscription.cpp @@ -318,13 +318,9 @@ TEST_F(TestSubscriptionFixture, test_subscription_nominal) { EXPECT_NE(0u, message_info.source_timestamp); EXPECT_TRUE(pre_publish_time <= message_info.source_timestamp) << pre_publish_time << " > " << message_info.source_timestamp; - #ifdef RMW_RECEIVED_TIMESTAMP_SUPPORTED EXPECT_NE(0u, message_info.received_timestamp); EXPECT_TRUE(pre_publish_time <= message_info.received_timestamp); EXPECT_TRUE(message_info.source_timestamp <= message_info.received_timestamp); - #else - EXPECT_EQ(0u, message_info.received_timestamp); - #endif #else EXPECT_EQ(0u, message_info.source_timestamp); EXPECT_EQ(0u, message_info.received_timestamp);