Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash on no class found #2415

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions rclcpp_components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,25 @@ if(BUILD_TESTING)
set(components "")
add_library(test_component SHARED test/components/test_component.cpp)
target_link_libraries(test_component PRIVATE component)
# Fake version of this macro so that rclcpp_components_register_node works
macro(_rclcpp_components_register_package_hook)
set(rclcpp_components_NODE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/src/node_main.cpp.in)
add_library(rclcpp_components::component ALIAS component)
endmacro()
include(./cmake/rclcpp_components_register_node.cmake)
rclcpp_components_register_node(test_component
PLUGIN "test_rclcpp_components::DoesNotExist"
EXECUTABLE test_component_does_not_exist_executable
)
find_program(BASH_PROGRAM bash)
add_test(
NAME test_non_existent_plugin
# Check to make sure the executable returns a non-zero exit code
COMMAND ${BASH_PROGRAM} -c "${BASH_PROGRAM} -c \"$<TARGET_FILE:test_component_does_not_exist_executable>\"; test $? -ne 0;"
)
set_tests_properties(test_non_existent_plugin PROPERTIES
# Need to preload this library since it doesn't get installed
ENVIRONMENT LD_PRELOAD=$<TARGET_FILE:test_component>)
#rclcpp_components_register_nodes(test_component "test_rclcpp_components::TestComponent")
set(components "${components}test_rclcpp_components::TestComponentFoo;$<TARGET_FILE:test_component>\n")
set(components "${components}test_rclcpp_components::TestComponentBar;$<TARGET_FILE:test_component>\n")
Expand Down
9 changes: 9 additions & 0 deletions rclcpp_components/src/node_main.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ int main(int argc, char * argv[])
}
}

if (exec.get_all_callback_groups().empty()) {
RCLCPP_ERROR(
logger,
"Class %s not found in library %s",
class_name.c_str(),
library_name.c_str());
return 1;
}

exec.spin();

for (auto wrapper : node_wrappers) {
Expand Down