|
27 | 27 |
|
28 | 28 | #include <ddsrouter_core/configuration/DdsRouterConfiguration.hpp> |
29 | 29 |
|
| 30 | +#include <ddsrouter_yaml/CommandlineArgsRouter.hpp> |
30 | 31 | #include <ddsrouter_yaml/YamlReaderConfiguration.hpp> |
31 | 32 |
|
32 | 33 | using namespace eprosima; |
| 34 | +using namespace eprosima::ddsrouter::yaml; |
33 | 35 |
|
34 | 36 | /** |
35 | 37 | * Test load a whole DDS Router Configuration from yaml node. |
@@ -142,6 +144,59 @@ TEST(YamlGetConfigurationDdsRouterTest, get_ddsrouter_configuration_ros_case) |
142 | 144 | } |
143 | 145 | } |
144 | 146 |
|
| 147 | +/** |
| 148 | + * Check DdsRouterConfiguration structure creation. |
| 149 | + * |
| 150 | + * CASES: |
| 151 | + * Check if chooses correctly log configuration when parsing from terminal and from YAML. |
| 152 | + * In this case, it checks that: |
| 153 | + * - The error filter is the one configured through the YAML |
| 154 | + * - The warning filter is the one configured through the Command-Line |
| 155 | + * - The info filter is the default (DDSROUTER) |
| 156 | + */ |
| 157 | +TEST(YamlGetConfigurationDdsRouterTest, get_ddsrouter_configuration_yaml_vs_commandline) |
| 158 | +{ |
| 159 | + CommandlineArgsRouter commandline_args; |
| 160 | + |
| 161 | + // Setting CommandLine arguments as if configured from CommandLine |
| 162 | + commandline_args.log_filter[eprosima::utils::VerbosityKind::Warning].set_value("DDSROUTER|DDSPIPE|DEBUG"); |
| 163 | + |
| 164 | + const char* yml_str = |
| 165 | + R"( |
| 166 | + version: v4.0 |
| 167 | + specs: |
| 168 | + logging: |
| 169 | + verbosity: info |
| 170 | + filter: |
| 171 | + error: "DEBUG" |
| 172 | + warning: "DDSROUTER" |
| 173 | + participants: |
| 174 | + - name: "P1" |
| 175 | + kind: "local" |
| 176 | + domain: 0 |
| 177 | + )"; |
| 178 | + |
| 179 | + Yaml yml = YAML::Load(yml_str); |
| 180 | + |
| 181 | + // Load configuration from YAML |
| 182 | + ddsrouter::core::DdsRouterConfiguration configuration = |
| 183 | + ddsrouter::yaml::YamlReaderConfiguration::load_ddsrouter_configuration(yml, &commandline_args); |
| 184 | + |
| 185 | + utils::Formatter error_msg; |
| 186 | + |
| 187 | + ASSERT_TRUE(configuration.ddspipe_configuration.log_configuration.is_valid(error_msg)); |
| 188 | + ASSERT_EQ(configuration.ddspipe_configuration.log_configuration.verbosity.get_value(), utils::VerbosityKind::Info); |
| 189 | + ASSERT_EQ( |
| 190 | + configuration.ddspipe_configuration.log_configuration.filter[utils::VerbosityKind::Error].get_value(), |
| 191 | + "DEBUG"); |
| 192 | + ASSERT_EQ( |
| 193 | + configuration.ddspipe_configuration.log_configuration.filter[utils::VerbosityKind::Warning].get_value(), |
| 194 | + "DDSROUTER|DDSPIPE|DEBUG"); |
| 195 | + ASSERT_EQ( |
| 196 | + configuration.ddspipe_configuration.log_configuration.filter[utils::VerbosityKind::Info].get_value(), |
| 197 | + "DDSROUTER"); |
| 198 | +} |
| 199 | + |
145 | 200 | int main( |
146 | 201 | int argc, |
147 | 202 | char** argv) |
|
0 commit comments