Skip to content

Commit

Permalink
in executor_fini function assigned handles to NULL and updated test c…
Browse files Browse the repository at this point in the history
…ases.

Signed-off-by: Staschulat Jan <jan.staschulat@de.bosch.com>
  • Loading branch information
JanStaschulat committed Nov 26, 2019
1 parent ff05897 commit 25a9529
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions rcl_executor/src/let_executor.c
Expand Up @@ -148,6 +148,7 @@ rcle_let_executor_fini(rcle_let_executor_t * executor)

if (_rcle_let_executor_is_valid(executor)) {
executor->allocator->deallocate(executor->handles, executor->allocator->state);
executor->handles = NULL;
executor->max_handles = 0;
executor->index = 0;
rcle_handle_size_zero_init(&executor->info);
Expand All @@ -163,8 +164,7 @@ rcle_let_executor_fini(rcle_let_executor_t * executor)
}
executor->timeout_ns = DEFAULT_WAIT_TIMEOUT_MS;
} else {
RCL_SET_ERROR_MSG("executor not initialized or called _fini function twice");
ret = RCL_RET_ERROR; // TODO(jst3si) better name for "calling this function multiple times"
ret = RCL_RET_ERROR;
}
return ret;
}
Expand Down
15 changes: 8 additions & 7 deletions rcl_executor/test/test_let_executor.cpp
Expand Up @@ -386,6 +386,7 @@ TEST_F(TestDefaultExecutor, executor_init) {
rcl_ret_t rc;

rcle_let_executor_t executor;
executor = rcle_let_executor_get_zero_initialized_executor();
rc = rcle_let_executor_init(&executor, this->context_ptr, 10, this->allocator);
EXPECT_EQ(RCL_RET_OK, rc) << rcl_get_error_string().str;

Expand Down Expand Up @@ -427,7 +428,7 @@ TEST_F(TestDefaultExecutor, executor_fini) {
// rcutils_reset_error();
// result : is not detected, even in un-initialized executor had in this case
// executor->initialized == true !!!

executor = rcle_let_executor_get_zero_initialized_executor();
rc = rcle_let_executor_init(&executor, this->context_ptr, 10, this->allocator);
EXPECT_EQ(RCL_RET_OK, rc) << rcl_get_error_string().str;

Expand All @@ -444,7 +445,7 @@ TEST_F(TestDefaultExecutor, executor_fini) {
TEST_F(TestDefaultExecutor, executor_add_subscription) {
rcl_ret_t rc;
rcle_let_executor_t executor;

executor = rcle_let_executor_get_zero_initialized_executor();
// test with normal arguemnt and NULL pointers as arguments
rc = rcle_let_executor_init(&executor, this->context_ptr, 10, this->allocator);
EXPECT_EQ(RCL_RET_OK, rc) << rcl_get_error_string().str;
Expand Down Expand Up @@ -498,7 +499,7 @@ TEST_F(TestDefaultExecutor, executor_add_subscription) {
TEST_F(TestDefaultExecutor, executor_add_subscription_too_many) {
rcl_ret_t rc;
rcle_let_executor_t executor;

executor = rcle_let_executor_get_zero_initialized_executor();
// insert one handle, add two subscriptions

rc = rcle_let_executor_init(&executor, this->context_ptr, 1, this->allocator);
Expand Down Expand Up @@ -528,7 +529,7 @@ TEST_F(TestDefaultExecutor, executor_add_subscription_too_many) {
TEST_F(TestDefaultExecutor, executor_add_timer) {
rcl_ret_t rc;
rcle_let_executor_t executor;

executor = rcle_let_executor_get_zero_initialized_executor();
// add a timer
rc = rcle_let_executor_init(&executor, this->context_ptr, 10, this->allocator);
EXPECT_EQ(RCL_RET_OK, rc) << rcl_get_error_string().str;
Expand All @@ -548,7 +549,7 @@ TEST_F(TestDefaultExecutor, executor_add_timer) {
TEST_F(TestDefaultExecutor, executor_spin_some_API) {
rcl_ret_t rc;
rcle_let_executor_t executor;

executor = rcle_let_executor_get_zero_initialized_executor();
// add a timer
rc = rcle_let_executor_init(&executor, this->context_ptr, 10, this->allocator);
EXPECT_EQ(RCL_RET_OK, rc) << rcl_get_error_string().str;
Expand Down Expand Up @@ -679,7 +680,7 @@ TEST_F(TestDefaultExecutor, spin_some_let_semantic) {
rcl_ret_t ret;
rcle_let_executor_t executor;
unsigned int expected_msg;

executor = rcle_let_executor_get_zero_initialized_executor();
// publisher 1
rcl_publisher_t publisher1 = rcl_get_zero_initialized_publisher();
const rosidl_message_type_support_t * ts1 =
Expand Down Expand Up @@ -943,7 +944,7 @@ TEST_F(TestDefaultExecutor, invocation_type) {
// by Jan Staschulat, under Apache 2.0 License
rcl_ret_t ret;
rcle_let_executor_t executor;

executor = rcle_let_executor_get_zero_initialized_executor();
// publisher 1
rcl_publisher_t publisher1 = rcl_get_zero_initialized_publisher();
const rosidl_message_type_support_t * ts1 =
Expand Down

0 comments on commit 25a9529

Please sign in to comment.