test_include.cpp
Go to the documentation of this file.
1 // Unit tests for include tags
2 // Author: Max Schwarz <max.schwarz@ais.uni-bonn.de>
3 
4 #include <catch_ros/catch.hpp>
5 
6 #include "../../src/launch/launch_config.h"
7 
8 #include "node_utils.h"
9 #include "param_utils.h"
10 
11 using namespace rosmon::launch;
12 
13 TEST_CASE("include basic", "[include]")
14 {
15  LaunchConfig config;
16  config.parseString(R"EOF(
17  <launch>
18  <arg name="test_argument" value="hello" />
19 
20  <include file="$(find rosmon_core)/test/basic_sub.launch">
21  <arg name="test_argument" value="$(arg test_argument)" />
22  </include>
23  </launch>
24  )EOF");
25 
26  config.evaluateParameters();
27 
28  auto params = config.parameters();
29 
30  CHECK(getTypedParam<std::string>(params, "/test_argument") == "hello");
31 }
32 
33 TEST_CASE("include default", "[include]")
34 {
35  // roslaunch allows this - to me it seems quite confusing, since the value
36  // of the arg tag cannot be overriden, despite using "default".
37 
38  std::stringstream warnings;
39 
40  LaunchConfig config;
41  config.setWarningOutput(&warnings);
42  config.parseString(R"EOF(
43  <launch>
44  <arg name="test_argument" value="hello" />
45 
46  <include file="$(find rosmon_core)/test/basic_sub.launch">
47  <arg name="test_argument" default="$(arg test_argument)" />
48  </include>
49  </launch>
50  )EOF");
51 
52  config.evaluateParameters();
53 
54  auto params = config.parameters();
55 
56  CHECK(getTypedParam<std::string>(params, "/test_argument") == "hello");
57 
58  CAPTURE(warnings.str());
59  CHECK(warnings.str().find("default") != std::string::npos);
60 }
61 
62 TEST_CASE("include pass_all", "[include]")
63 {
64  LaunchConfig config;
65  config.parseString(R"EOF(
66  <launch>
67  <arg name="test_argument" value="hello" />
68 
69  <include file="$(find rosmon_core)/test/basic_sub.launch" pass_all_args="true" />
70  </launch>
71  )EOF");
72 
73  config.evaluateParameters();
74 
75  auto params = config.parameters();
76 
77  CHECK(getTypedParam<std::string>(params, "/test_argument") == "hello");
78 }
79 
80 TEST_CASE("include scoped attributes", "[include]")
81 {
82  LaunchConfig config;
83  config.parseString(R"EOF(
84  <launch>
85  <include file="$(find rosmon_core)/test/basic_sub.launch"
86  enable-coredumps="false" rosmon-memory-limit="100" rosmon-stop-timeout="10.0" />
87  </launch>
88  )EOF");
89 
90  config.evaluateParameters();
91 
92  auto nodes = config.nodes();
93  CAPTURE(nodes);
94 
95  auto n = getNode(nodes, "test_node");
96  CHECK(!n->coredumpsEnabled());
97  CHECK(n->memoryLimitByte() == 100);
98  CHECK(n->stopTimeout() == Approx(10.0));
99 }
const std::vector< Node::Ptr > & nodes() const
auto & params
Definition: test_param.cpp:226
const std::map< std::string, XmlRpc::XmlRpcValue > & parameters() const
void setWarningOutput(std::ostream *warningStream)
rosmon::launch::Node::Ptr getNode(const std::vector< rosmon::launch::Node::Ptr > &nodes, const std::string &name, const std::string &namespaceString)
Definition: node_utils.cpp:23
void parseString(const std::string &input, bool onlyArguments=false)
TEST_CASE("include basic","[include]")


rosmon_core
Author(s): Max Schwarz
autogenerated on Sat Jan 9 2021 03:35:43