Skip to content

Commit

Permalink
Relax a lot more timers.
Browse files Browse the repository at this point in the history
This should keep the intent of the original, but make it much
less flaky and should work on Windows.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
  • Loading branch information
clalancette committed May 11, 2020
1 parent 7f4e208 commit a64f2ca
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions rcl/test/rcl/test_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ TEST_F(TestTimerFixture, test_two_timers) {
rcl_timer_t timer2 = rcl_get_zero_initialized_timer();

ret = rcl_timer_init(
&timer, &clock, this->context_ptr, RCL_MS_TO_NS(5), nullptr, rcl_get_default_allocator());
&timer, &clock, this->context_ptr, RCL_MS_TO_NS(50), nullptr, rcl_get_default_allocator());
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;

ret = rcl_timer_init(
&timer2, &clock, this->context_ptr, RCL_MS_TO_NS(20), nullptr, rcl_get_default_allocator());
&timer2, &clock, this->context_ptr, RCL_MS_TO_NS(100), nullptr, rcl_get_default_allocator());
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;

rcl_wait_set_t wait_set = rcl_get_zero_initialized_wait_set();
Expand All @@ -141,7 +141,7 @@ TEST_F(TestTimerFixture, test_two_timers) {
ret = rcl_wait_set_fini(&wait_set);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
});
ret = rcl_wait(&wait_set, RCL_MS_TO_NS(10));
ret = rcl_wait(&wait_set, RCL_MS_TO_NS(100));
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
uint8_t nonnull_timers = 0;
for (uint8_t i = 0; i < wait_set.size_of_timers; i++) {
Expand Down Expand Up @@ -230,7 +230,7 @@ TEST_F(TestTimerFixture, test_timer_not_ready) {
rcl_timer_t timer = rcl_get_zero_initialized_timer();

ret = rcl_timer_init(
&timer, &clock, this->context_ptr, RCL_MS_TO_NS(5), nullptr, rcl_get_default_allocator());
&timer, &clock, this->context_ptr, RCL_MS_TO_NS(1000), nullptr, rcl_get_default_allocator());
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;

rcl_wait_set_t wait_set = rcl_get_zero_initialized_wait_set();
Expand All @@ -247,7 +247,7 @@ TEST_F(TestTimerFixture, test_timer_not_ready) {
ret = rcl_wait_set_fini(&wait_set);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
});
ret = rcl_wait(&wait_set, RCL_MS_TO_NS(1));
ret = rcl_wait(&wait_set, RCL_MS_TO_NS(100));
EXPECT_EQ(RCL_RET_TIMEOUT, ret) << rcl_get_error_string().str;
uint8_t nonnull_timers = 0;
for (uint8_t i = 0; i < wait_set.size_of_timers; i++) {
Expand Down Expand Up @@ -276,7 +276,7 @@ TEST_F(TestTimerFixture, test_canceled_timer) {
rcl_timer_t timer = rcl_get_zero_initialized_timer();

ret = rcl_timer_init(
&timer, &clock, this->context_ptr, 500, nullptr, rcl_get_default_allocator());
&timer, &clock, this->context_ptr, RCL_MS_TO_NS(500), nullptr, rcl_get_default_allocator());
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;

ret = rcl_timer_cancel(&timer);
Expand All @@ -296,7 +296,7 @@ TEST_F(TestTimerFixture, test_canceled_timer) {
ret = rcl_wait_set_fini(&wait_set);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
});
ret = rcl_wait(&wait_set, RCL_MS_TO_NS(1));
ret = rcl_wait(&wait_set, RCL_MS_TO_NS(100));
EXPECT_EQ(RCL_RET_TIMEOUT, ret) << rcl_get_error_string().str;
uint8_t nonnull_timers = 0;
for (uint8_t i = 0; i < wait_set.size_of_timers; i++) {
Expand Down

0 comments on commit a64f2ca

Please sign in to comment.