Skip to content

Commit

Permalink
Drop unnecessary rcl_reset_error() calls.
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
  • Loading branch information
hidmic committed Jun 19, 2020
1 parent d2bd754 commit 6aa785e
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions rcl/test/rcl/test_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ TEST_F(TestTimerFixture, test_timer_with_invalid_clock) {
{
rcl_ret_t ret = rcl_clock_fini(&clock);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
rcl_reset_error();
});

ret = rcl_timer_init(
Expand All @@ -176,7 +175,6 @@ TEST_F(TestTimerFixture, test_timer_with_invalid_clock) {
{
rcl_ret_t ret = rcl_timer_fini(&timer);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
rcl_reset_error();
});

rcl_clock_t * timer_clock;
Expand All @@ -187,7 +185,6 @@ TEST_F(TestTimerFixture, test_timer_with_invalid_clock) {
// Trigger clock jump callbacks
ret = rcl_enable_ros_time_override(timer_clock);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
rcl_reset_error();

ret = rcl_timer_call(&timer);
EXPECT_EQ(RCL_RET_ERROR, ret);
Expand Down Expand Up @@ -383,7 +380,6 @@ TEST_F(TestTimerFixture, test_timer_overrun) {
{
rcl_ret_t ret = rcl_clock_fini(&clock);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
rcl_reset_error();
});

rcl_timer_t timer = rcl_get_zero_initialized_timer();
Expand All @@ -394,7 +390,6 @@ TEST_F(TestTimerFixture, test_timer_overrun) {
{
rcl_ret_t ret = rcl_timer_fini(&timer);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
rcl_reset_error();
});

rcl_wait_set_t wait_set = rcl_get_zero_initialized_wait_set();
Expand All @@ -404,7 +399,6 @@ TEST_F(TestTimerFixture, test_timer_overrun) {
{
rcl_ret_t ret = rcl_wait_set_fini(&wait_set);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
rcl_reset_error();
});

// Force multiple timer timeouts.
Expand All @@ -416,14 +410,11 @@ TEST_F(TestTimerFixture, test_timer_overrun) {
ret = rcl_timer_is_ready(&timer, &is_ready);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
EXPECT_TRUE(is_ready);
rcl_reset_error();

EXPECT_EQ(RCL_RET_OK, rcl_timer_call(&timer)) << rcl_get_error_string().str;
rcl_reset_error();

ret = rcl_wait_set_add_timer(&wait_set, &timer, NULL);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
rcl_reset_error();

// Ensure period is re-aligned.
ret = rcl_wait(&wait_set, RCL_MS_TO_NS(10));
Expand All @@ -433,7 +424,6 @@ TEST_F(TestTimerFixture, test_timer_overrun) {
ret = rcl_timer_is_ready(&timer, &is_ready);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
EXPECT_FALSE(is_ready);
rcl_reset_error();
}

TEST_F(TestTimerFixture, test_timer_with_zero_period) {
Expand All @@ -459,17 +449,15 @@ TEST_F(TestTimerFixture, test_timer_with_zero_period) {

bool is_ready = false;
ret = rcl_timer_is_ready(&timer, &is_ready);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
EXPECT_TRUE(is_ready) << rcl_get_error_string().str;
rcl_reset_error();

int64_t time_until_next_call = 0;
ret = rcl_timer_get_time_until_next_call(&timer, &time_until_next_call);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
EXPECT_LE(time_until_next_call, 0);
rcl_reset_error();

EXPECT_EQ(RCL_RET_OK, rcl_timer_call(&timer)) << rcl_get_error_string().str;
rcl_reset_error();
}

TEST_F(TestTimerFixture, test_canceled_timer) {
Expand Down Expand Up @@ -856,7 +844,6 @@ TEST_F(TestPreInitTimer, test_invalid_init_fini) {
rcl_allocator_t bad_allocator = get_failing_allocator();
rcl_timer_t timer_fail = rcl_get_zero_initialized_timer();

rcl_reset_error();
EXPECT_EQ(
RCL_RET_ALREADY_INIT, rcl_timer_init(
&timer, &clock, this->context_ptr, 500, nullptr,
Expand All @@ -869,8 +856,7 @@ TEST_F(TestPreInitTimer, test_invalid_init_fini) {
bad_allocator)) << rcl_get_error_string().str;
rcl_reset_error();

EXPECT_EQ(RCL_RET_OK, rcl_timer_fini(nullptr));
rcl_reset_error();
EXPECT_EQ(RCL_RET_OK, rcl_timer_fini(nullptr)) << rcl_get_error_string().str;
}

TEST_F(TestPreInitTimer, test_timer_get_period) {
Expand Down

0 comments on commit 6aa785e

Please sign in to comment.