Skip to content

Commit

Permalink
Add a simple test for wait_for_all_acked
Browse files Browse the repository at this point in the history
Signed-off-by: Barry Xu <barry.xu@sony.com>
  • Loading branch information
Barry-Xu-2018 committed May 30, 2021
1 parent e1c1b94 commit cc154d9
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test_rmw_implementation/test/test_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,38 @@ TEST_F(CLASSNAME(TestPublisherUse, RMW_IMPLEMENTATION), publish_serialized_with_
});
}

TEST_F(CLASSNAME(TestPublisherUse, RMW_IMPLEMENTATION), wait_for_all_acked_with_best_effort) {
test_msgs__msg__BasicTypes input_message{};
ASSERT_TRUE(test_msgs__msg__BasicTypes__init(&input_message));
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT(
{
test_msgs__msg__BasicTypes__fini(&input_message);
});

rmw_subscription_options_t options = rmw_get_default_subscription_options();
rmw_subscription_t * sub = rmw_create_subscription(node, ts, topic_name, &qos_profile, &options);
ASSERT_NE(nullptr, sub) << rmw_get_error_string().str;
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT(
{
rmw_ret_t ret = rmw_destroy_subscription(node, sub);
EXPECT_EQ(RMW_RET_OK, ret) << rmw_get_error_string().str;
});

size_t subscription_count = 0u;
rmw_ret_t ret = rmw_publisher_count_matched_subscriptions(pub, &subscription_count);
ASSERT_EQ(subscription_count, static_cast<size_t>(1));

ret = rmw_publish(pub, &input_message, nullptr);
ASSERT_EQ(ret, RMW_RET_OK);

// For best effort, alway return RMW_RET_OK immediately
ret = rmw_publisher_wait_for_all_acked(pub, {0, 0});
EXPECT_EQ(ret, RMW_RET_OK);

ret = rmw_publisher_wait_for_all_acked(nullptr, {0, 0});
EXPECT_EQ(ret, RMW_RET_INVALID_ARGUMENT);
}


class CLASSNAME (TestPublisherUseLoan, RMW_IMPLEMENTATION)
: public CLASSNAME(TestPublisherUse, RMW_IMPLEMENTATION)
Expand Down

0 comments on commit cc154d9

Please sign in to comment.