From 2e13c3c843cc63f15bb54ae7268778bd7e65643d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dr=2E=20Denis=20=C5=A0togl?= Date: Thu, 1 Feb 2024 19:44:01 +0100 Subject: [PATCH] Add some additional tests. --- .../test/test_resource_manager.cpp | 12 ++ .../ros2_control_test_assets/descriptions.hpp | 134 ++++++++++++++++-- 2 files changed, 131 insertions(+), 15 deletions(-) diff --git a/hardware_interface_testing/test/test_resource_manager.cpp b/hardware_interface_testing/test/test_resource_manager.cpp index 730410ddd7..7446e885cc 100644 --- a/hardware_interface_testing/test/test_resource_manager.cpp +++ b/hardware_interface_testing/test/test_resource_manager.cpp @@ -228,6 +228,12 @@ TEST_F( ros2_control_test_assets::minimal_robot_not_existing_system_plugin); } +TEST_F(ResourceManagerTest, expect_load_and_initialize_to_fail_when_there_are_dupplicate_of_hw_comp) +{ + test_load_and_initialized_components_failure( + ros2_control_test_assets::minimal_robot_duplicated_component); +} + TEST_F( ResourceManagerTest, expect_load_and_initialize_to_fail_when_a_hw_component_initialization_fails) { @@ -250,6 +256,12 @@ TEST_F(ResourceManagerTest, load_and_initialize_components_called_if_urdf_is_val ASSERT_TRUE(rm.are_components_initialized()); } +TEST_F(ResourceManagerTest, load_and_initialize_components_called_if_async_urdf_is_valid) +{ + TestableResourceManager rm(ros2_control_test_assets::minimal_async_robot_urdf); + ASSERT_TRUE(rm.are_components_initialized()); +} + TEST_F(ResourceManagerTest, can_load_and_initialize_components_later) { TestableResourceManager rm; diff --git a/ros2_control_test_assets/include/ros2_control_test_assets/descriptions.hpp b/ros2_control_test_assets/include/ros2_control_test_assets/descriptions.hpp index 713453bf62..d70f9c0869 100644 --- a/ros2_control_test_assets/include/ros2_control_test_assets/descriptions.hpp +++ b/ros2_control_test_assets/include/ros2_control_test_assets/descriptions.hpp @@ -176,6 +176,55 @@ const auto hardware_resources = )"; +const auto async_hardware_resources = + R"( + + + test_actuator + + + + + + + + + + + test_sensor + 2 + 2 + + + + + + + + test_system + 2 + 2 + + + + + + + + + + + + + + + + + + + +)"; + const auto unitilizable_hardware_resources = R"( @@ -253,25 +302,25 @@ const auto hardware_resources_not_existing_actuator_plugin = test_system 2 2 - - + + - - + + - + - - + + )"; const auto hardware_resources_not_existing_sensor_plugin = @@ -302,25 +351,25 @@ const auto hardware_resources_not_existing_sensor_plugin = test_system 2 2 - - + + - - + + - - + + - - + + )"; const auto hardware_resources_not_existing_system_plugin = R"( @@ -371,6 +420,55 @@ const auto hardware_resources_not_existing_system_plugin = )"; +const auto hardware_resources_duplicated_component = + R"( + + + test_actuator + + + + + + + + + + + test_sensor + 2 + 2 + + + + + + + + test_system + 2 + 2 + + + + + + + + + + + + + + + + + + + +)"; + const auto hardware_resources_actuator_initializaion_error = R"( @@ -731,6 +829,8 @@ const auto diffbot_urdf = const auto minimal_robot_urdf = std::string(urdf_head) + std::string(hardware_resources) + std::string(urdf_tail); +const auto minimal_async_robot_urdf = + std::string(urdf_head) + std::string(async_hardware_resources) + std::string(urdf_tail); const auto minimal_unitilizable_robot_urdf = std::string(urdf_head) + std::string(unitilizable_hardware_resources) + std::string(urdf_tail); @@ -744,6 +844,10 @@ const auto minimal_robot_not_existing_system_plugin = std::string(urdf_head) + std::string(hardware_resources_not_existing_system_plugin) + std::string(urdf_tail); +const auto minimal_robot_duplicated_component = + std::string(urdf_head) + std::string(hardware_resources_duplicated_component) + + std::string(urdf_tail); + const auto minimal_robot_actuator_initialization_error = std::string(urdf_head) + std::string(hardware_resources_not_existing_actuator_plugin) + std::string(urdf_tail);