Skip to content

Commit

Permalink
fix leak in test_service
Browse files Browse the repository at this point in the history
Signed-off-by: Abby Xu <[email protected]>
  • Loading branch information
xabxx committed May 20, 2019
1 parent 5450765 commit 7518802
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rcl/test/rcl/test_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ TEST_F(CLASSNAME(TestServiceFixture, RMW_IMPLEMENTATION), test_service_nominal)
rcl_service_options_t service_options = rcl_service_get_default_options();
ret = rcl_service_init(&service, this->node_ptr, ts, topic, &service_options);
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
ret = rcl_service_fini(&service, this->node_ptr);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;

// Check if null service is valid
EXPECT_FALSE(rcl_service_is_valid(nullptr));
Expand Down Expand Up @@ -202,12 +204,14 @@ TEST_F(CLASSNAME(TestServiceFixture, RMW_IMPLEMENTATION), test_service_nominal)
ret = rcl_take_request(&service, &header, &service_request);
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;


EXPECT_EQ(1, service_request.uint8_value);
EXPECT_EQ(2UL, service_request.uint32_value);
// Simulate a response callback by summing the request and send the response..
service_response.uint64_value = service_request.uint8_value + service_request.uint32_value;
ret = rcl_send_response(&service, &header, &service_response);
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
test_msgs__srv__BasicTypes_Request__fini(&service_request);
}
wait_for_service_to_be_ready(&service, context_ptr, 10, 100, success);

Expand All @@ -220,4 +224,5 @@ TEST_F(CLASSNAME(TestServiceFixture, RMW_IMPLEMENTATION), test_service_nominal)
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
EXPECT_EQ(client_response.uint64_value, 3ULL);
EXPECT_EQ(header.sequence_number, 1);
test_msgs__srv__BasicTypes_Response__fini(&client_response);
}

0 comments on commit 7518802

Please sign in to comment.