diff --git a/rmw_implementation/src/functions.cpp b/rmw_implementation/src/functions.cpp index ddb8da33..9ff230f6 100644 --- a/rmw_implementation/src/functions.cpp +++ b/rmw_implementation/src/functions.cpp @@ -599,6 +599,16 @@ RMW_INTERFACE_FN( bool, rmw_topic_endpoint_info_array_t *)) +RMW_INTERFACE_FN( + rmw_qos_profile_check_compatible, + rmw_ret_t, RMW_RET_ERROR, + 5, ARG_TYPES( + const rmw_qos_profile_t, + const rmw_qos_profile_t, + rmw_qos_compatibility_t *, + char *, + size_t)) + #define GET_SYMBOL(x) symbol_ ## x = get_symbol(#x); void prefetch_symbols(void) @@ -676,6 +686,7 @@ void prefetch_symbols(void) GET_SYMBOL(rmw_set_log_severity) GET_SYMBOL(rmw_get_publishers_info_by_topic) GET_SYMBOL(rmw_get_subscriptions_info_by_topic) + GET_SYMBOL(rmw_qos_profile_check_compatible) } void * symbol_rmw_init = nullptr; @@ -775,6 +786,7 @@ unload_library() symbol_rmw_set_log_severity = nullptr; symbol_rmw_get_publishers_info_by_topic = nullptr; symbol_rmw_get_subscriptions_info_by_topic = nullptr; + symbol_rmw_qos_profile_check_compatible = nullptr; symbol_rmw_init = nullptr; g_rmw_lib.reset(); } diff --git a/test_rmw_implementation/CMakeLists.txt b/test_rmw_implementation/CMakeLists.txt index 2f6a1889..e518f0b1 100644 --- a/test_rmw_implementation/CMakeLists.txt +++ b/test_rmw_implementation/CMakeLists.txt @@ -160,6 +160,16 @@ if(BUILD_TESTING) ament_target_dependencies(test_client${target_suffix} osrf_testing_tools_cpp rcutils rmw rmw_implementation test_msgs ) + + ament_add_gtest(test_qos_profiles_are_compatible${target_suffix} + test/test_qos_profiles_are_compatible.cpp + ENV ${rmw_implementation_env_var} + ) + target_compile_definitions(test_qos_profiles_are_compatible${target_suffix} + PUBLIC "RMW_IMPLEMENTATION=${rmw_implementation}") + ament_target_dependencies(test_qos_profiles_are_compatible${target_suffix} + rmw rmw_implementation + ) endmacro() call_for_each_rmw_implementation(test_api) diff --git a/test_rmw_implementation/test/test_qos_profiles_are_compatible.cpp b/test_rmw_implementation/test/test_qos_profiles_are_compatible.cpp new file mode 100644 index 00000000..416b3de2 --- /dev/null +++ b/test_rmw_implementation/test/test_qos_profiles_are_compatible.cpp @@ -0,0 +1,59 @@ +// Copyright 2021 Open Source Robotics Foundation, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +// #include "osrf_testing_tools_cpp/memory_tools/gtest_quickstart.hpp" + +#include "rmw/qos_profiles.h" + +#ifdef RMW_IMPLEMENTATION +# define CLASSNAME_(NAME, SUFFIX) NAME ## __ ## SUFFIX +# define CLASSNAME(NAME, SUFFIX) CLASSNAME_(NAME, SUFFIX) +#else +# define CLASSNAME(NAME, SUFFIX) NAME +#endif + +TEST(CLASSNAME(TestQoSProfilesAreCompatible, RMW_IMPLEMENTATION), compatible) { + // All of the provided profiles should be compatible + EXPECT_TRUE( + rmw_qos_profile_check_compatible(rmw_qos_profile_sensor_data, rmw_qos_profile_sensor_data)); + EXPECT_TRUE( + rmw_qos_profile_check_compatible(rmw_qos_profile_default, rmw_qos_profile_default)); + EXPECT_TRUE( + rmw_qos_profile_check_compatible(rmw_qos_profile_parameters, rmw_qos_profile_parameters)); + EXPECT_TRUE( + rmw_qos_profile_check_compatible( + rmw_qos_profile_parameter_events, rmw_qos_profile_parameter_events)); + EXPECT_TRUE( + rmw_qos_profile_check_compatible( + rmw_qos_profile_services_default, rmw_qos_profile_services_default)); + EXPECT_TRUE( + rmw_qos_profile_check_compatible( + rmw_qos_profile_system_default, rmw_qos_profile_system_default)); +} + +TEST(CLASSNAME(TestQoSProfilesAreCompatible, RMW_IMPLEMENTATION), not_compatible) { + // Nothing should be compatible with "unknown" + EXPECT_FALSE( + rmw_qos_profile_check_compatible(rmw_qos_profile_sensor_data, rmw_qos_profile_unknown)); + EXPECT_FALSE(rmw_qos_profile_check_compatible(rmw_qos_profile_default, rmw_qos_profile_unknown)); + EXPECT_FALSE(rmw_qos_profile_check_compatible(rmw_qos_profile_parameters, rmw_qos_profile_unknown)); + EXPECT_FALSE( + rmw_qos_profile_check_compatible(rmw_qos_profile_parameter_events, rmw_qos_profile_unknown)); + EXPECT_FALSE( + rmw_qos_profile_check_compatible(rmw_qos_profile_services_default, rmw_qos_profile_unknown)); + EXPECT_FALSE( + rmw_qos_profile_check_compatible(rmw_qos_profile_system_default, rmw_qos_profile_unknown)); +}