Update graph test for change to rmw names and types struct (#407)

* Update action graph tests to account for type namespace

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Enable OpenSplice action graph test

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Exclude some action graph tests with OpenSplice

It appears that getting graph information from finalized nodes succeeds with OpenSplice, unlike the other RMW implementations.
Since we do not have tests covering this case in rcl, it's not clear if this is a bug or expected behaviour.
In the meantime, I've disabled testing this specific case for OpenSplice.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* const bool

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
This commit is contained in:
Jacob Perron 2019-05-07 22:47:37 -07:00 committed by Dirk Thomas
parent ac8ee90740
commit 0c24c7ec8e
2 changed files with 25 additions and 19 deletions

View file

@ -153,12 +153,8 @@ if(BUILD_TESTING)
custom_test_c(test_action_interaction custom_test_c(test_action_interaction
"test/rcl_action/test_action_interaction.cpp") "test/rcl_action/test_action_interaction.cpp")
# TODO(jacobperron): Graph tests fail with opensplice. Re-enable after resolving custom_test_c(test_graph
# https://github.com/ros2/ros2/issues/677 "test/rcl_action/test_graph.cpp")
if(NOT rmw_implementation STREQUAL "rmw_opensplice_cpp")
custom_test_c(test_graph
"test/rcl_action/test_graph.cpp")
endif()
endmacro() endmacro()
call_for_each_rmw_implementation(targets) call_for_each_rmw_implementation(targets)

View file

@ -15,6 +15,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <chrono> #include <chrono>
#include <string>
#include <thread> #include <thread>
#include "rcl_action/action_client.h" #include "rcl_action/action_client.h"
@ -35,6 +36,9 @@
# define CLASSNAME(NAME, SUFFIX) NAME # define CLASSNAME(NAME, SUFFIX) NAME
#endif #endif
const bool is_opensplice =
std::string(rmw_get_implementation_identifier()).find("rmw_opensplice") == 0;
class CLASSNAME (TestActionGraphFixture, RMW_IMPLEMENTATION) : public ::testing::Test class CLASSNAME (TestActionGraphFixture, RMW_IMPLEMENTATION) : public ::testing::Test
{ {
public: public:
@ -132,10 +136,13 @@ TEST_F(
EXPECT_EQ(RCL_RET_ERROR, ret) << rcl_get_error_string().str; EXPECT_EQ(RCL_RET_ERROR, ret) << rcl_get_error_string().str;
rcl_reset_error(); rcl_reset_error();
// Non-existent node // Non-existent node
ret = rcl_action_get_client_names_and_types_by_node( // Note, Opensplice successfully reports graph information about finalized nodes
&this->node, &this->allocator, this->test_graph_old_node_name, "", &nat); if (!is_opensplice) {
EXPECT_EQ(RCL_RET_ERROR, ret) << rcl_get_error_string().str; ret = rcl_action_get_client_names_and_types_by_node(
rcl_reset_error(); &this->node, &this->allocator, this->test_graph_old_node_name, "", &nat);
EXPECT_EQ(RCL_RET_ERROR, ret) << rcl_get_error_string().str;
rcl_reset_error();
}
// Invalid names and types // Invalid names and types
ret = rcl_action_get_client_names_and_types_by_node( ret = rcl_action_get_client_names_and_types_by_node(
&this->node, &this->allocator, this->test_graph_node_name, "", nullptr); &this->node, &this->allocator, this->test_graph_node_name, "", nullptr);
@ -185,10 +192,13 @@ TEST_F(
EXPECT_EQ(RCL_RET_ERROR, ret) << rcl_get_error_string().str; EXPECT_EQ(RCL_RET_ERROR, ret) << rcl_get_error_string().str;
rcl_reset_error(); rcl_reset_error();
// Non-existent node // Non-existent node
ret = rcl_action_get_server_names_and_types_by_node( // Note, Opensplice successfully reports graph information about finalized nodes
&this->node, &this->allocator, this->test_graph_old_node_name, "", &nat); if (!is_opensplice) {
EXPECT_EQ(RCL_RET_ERROR, ret) << rcl_get_error_string().str; ret = rcl_action_get_server_names_and_types_by_node(
rcl_reset_error(); &this->node, &this->allocator, this->test_graph_old_node_name, "", &nat);
EXPECT_EQ(RCL_RET_ERROR, ret) << rcl_get_error_string().str;
rcl_reset_error();
}
// Invalid names and types // Invalid names and types
ret = rcl_action_get_server_names_and_types_by_node( ret = rcl_action_get_server_names_and_types_by_node(
&this->node, &this->allocator, this->test_graph_node_name, "", nullptr); &this->node, &this->allocator, this->test_graph_node_name, "", nullptr);
@ -391,7 +401,7 @@ TEST_F(TestActionGraphMultiNodeFixture, test_action_get_names_and_types) {
ASSERT_EQ(nat.names.size, 1u); ASSERT_EQ(nat.names.size, 1u);
EXPECT_STREQ(nat.names.data[0], client_action_name); EXPECT_STREQ(nat.names.data[0], client_action_name);
ASSERT_EQ(nat.types[0].size, 1u); ASSERT_EQ(nat.types[0].size, 1u);
EXPECT_STREQ(nat.types[0].data[0], "test_msgs/Fibonacci"); EXPECT_STREQ(nat.types[0].data[0], "test_msgs/action/Fibonacci");
ret = rcl_names_and_types_fini(&nat); ret = rcl_names_and_types_fini(&nat);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
@ -427,9 +437,9 @@ TEST_F(TestActionGraphMultiNodeFixture, test_action_get_names_and_types) {
EXPECT_STREQ(nat.names.data[0], client_action_name); EXPECT_STREQ(nat.names.data[0], client_action_name);
EXPECT_STREQ(nat.names.data[1], server_action_name); EXPECT_STREQ(nat.names.data[1], server_action_name);
ASSERT_EQ(nat.types[0].size, 1u); ASSERT_EQ(nat.types[0].size, 1u);
EXPECT_STREQ(nat.types[0].data[0], "test_msgs/Fibonacci"); EXPECT_STREQ(nat.types[0].data[0], "test_msgs/action/Fibonacci");
ASSERT_EQ(nat.types[1].size, 1u); ASSERT_EQ(nat.types[1].size, 1u);
EXPECT_STREQ(nat.types[1].data[0], "test_msgs/Fibonacci"); EXPECT_STREQ(nat.types[1].data[0], "test_msgs/action/Fibonacci");
ret = rcl_names_and_types_fini(&nat); ret = rcl_names_and_types_fini(&nat);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
@ -492,7 +502,7 @@ TEST_F(TestActionGraphMultiNodeFixture, test_action_get_server_names_and_types_b
ASSERT_EQ(nat.names.size, 1u); ASSERT_EQ(nat.names.size, 1u);
EXPECT_STREQ(nat.names.data[0], this->action_name); EXPECT_STREQ(nat.names.data[0], this->action_name);
ASSERT_EQ(nat.types[0].size, 1u); ASSERT_EQ(nat.types[0].size, 1u);
EXPECT_STREQ(nat.types[0].data[0], "test_msgs/Fibonacci"); EXPECT_STREQ(nat.types[0].data[0], "test_msgs/action/Fibonacci");
ret = rcl_names_and_types_fini(&nat); ret = rcl_names_and_types_fini(&nat);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
@ -556,7 +566,7 @@ TEST_F(TestActionGraphMultiNodeFixture, test_action_get_client_names_and_types_b
ASSERT_EQ(nat.names.size, 1u); ASSERT_EQ(nat.names.size, 1u);
EXPECT_STREQ(nat.names.data[0], this->action_name); EXPECT_STREQ(nat.names.data[0], this->action_name);
ASSERT_EQ(nat.types[0].size, 1u); ASSERT_EQ(nat.types[0].size, 1u);
EXPECT_STREQ(nat.types[0].data[0], "test_msgs/Fibonacci"); EXPECT_STREQ(nat.types[0].data[0], "test_msgs/action/Fibonacci");
ret = rcl_names_and_types_fini(&nat); ret = rcl_names_and_types_fini(&nat);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;