4 #include <catch_ros/catch.hpp> 6 #include "../../src/launch/launch_config.h" 8 #include <boost/filesystem.hpp> 21 <node name="test_node" pkg="rosmon_core" type="abort" /> 27 auto nodes = config.
nodes();
30 REQUIRE(nodes.size() == 1);
32 auto node =
getNode(nodes,
"test_node");
34 CHECK(node->name() ==
"test_node");
35 CHECK(node->package() ==
"rosmon_core");
36 CHECK(node->type() ==
"abort");
39 namespace fs = boost::filesystem;
41 fs::path executable = node->executable();
42 CAPTURE(executable.string());
43 CHECK((fs::status(executable).permissions() & fs::owner_exe));
51 <node name="test_node" /> 61 <node name="test_node" pkg="rosmon_core" type="abort" args="arg1 arg2 'long arg'" /> 67 auto nodes = config.
nodes();
70 REQUIRE(nodes.size() == 1);
72 auto node =
getNode(nodes,
"test_node");
74 auto args = node->extraArguments();
76 REQUIRE(args.size() == 3);
77 CHECK(args[0] ==
"arg1");
78 CHECK(args[1] ==
"arg2");
79 CHECK(args[2] ==
"long arg");
87 <node name="test_node" pkg="rosmon_core" type="abort" respawn="true" respawn_delay="10" /> 93 auto nodes = config.
nodes();
96 REQUIRE(nodes.size() == 1);
98 auto node =
getNode(nodes,
"test_node");
100 CHECK(node->respawn());
101 CHECK(node->respawnDelay().toSec() == Approx(10.0));
109 <node name="test_node" pkg="rosmon_core" type="abort" required="true" /> 115 auto nodes = config.
nodes();
118 REQUIRE(nodes.size() == 1);
120 auto node =
getNode(nodes,
"test_node");
122 CHECK(node->required());
130 <node name="test_node" pkg="rosmon_core" type="abort" ns="namespace" /> 133 <node name="test_node" pkg="rosmon_core" type="abort" /> 135 <node name="test_node" pkg="rosmon_core" type="abort" ns="namespace" /> 142 auto nodes = config.
nodes();
145 REQUIRE(nodes.size() == 3);
148 auto node =
getNode(nodes,
"test_node",
"/namespace");
149 CHECK(node->namespaceString() ==
"/namespace");
152 auto node =
getNode(nodes,
"test_node",
"/ns1");
153 CHECK(node->namespaceString() ==
"/ns1");
156 auto node =
getNode(nodes,
"test_node",
"/ns1/namespace");
157 CHECK(node->namespaceString() ==
"/ns1/namespace");
166 <node name="test_node_on" pkg="rosmon_core" type="abort" clear_params="true" /> 167 <node name="test_node_off" pkg="rosmon_core" type="abort" clear_params="false" /> 168 <node name="test_node_def" pkg="rosmon_core" type="abort" /> 174 auto nodes = config.
nodes();
177 CHECK(
getNode(nodes,
"test_node_on")->clearParams() ==
true);
178 CHECK(
getNode(nodes,
"test_node_off")->clearParams() ==
false);
179 CHECK(
getNode(nodes,
"test_node_def")->clearParams() ==
false);
187 <node name="test_node" pkg="rosmon_core" type="abort" cwd="/my_cwd/" /> 193 auto nodes = config.
nodes();
196 auto node =
getNode(nodes,
"test_node");
198 CHECK(node->workingDirectory() ==
"/my_cwd/");
206 <node name="test_node" pkg="rosmon_core" type="abort" launch-prefix="echo my command is:" /> 212 auto nodes = config.
nodes();
215 auto node =
getNode(nodes,
"test_node");
217 auto prefix = node->launchPrefix();
220 REQUIRE(prefix.size() == 4);
221 CHECK(prefix[0] ==
"echo");
222 CHECK(prefix[1] ==
"my");
223 CHECK(prefix[2] ==
"command");
224 CHECK(prefix[3] ==
"is:");
232 <node name="test_node" pkg="rosmon_core" type="abort"> 233 <remap from="private1" to="/global_target" /> 234 <remap from="private2" to="local_target" /> 241 auto nodes = config.
nodes();
244 auto node =
getNode(nodes,
"test_node");
246 auto remappings = node->remappings();
249 CHECK(remappings.size() == 2);
250 CHECK(remappings.at(
"private1") ==
"/global_target");
251 CHECK(remappings.at(
"private2") ==
"local_target");
261 <node name="test_node_on" pkg="rosmon_core" type="abort" enable-coredumps="true" /> 262 <node name="test_node_off" pkg="rosmon_core" type="abort" enable-coredumps="false" /> 268 auto nodes = config.
nodes();
271 CHECK(
getNode(nodes,
"test_node_on")->coredumpsEnabled() ==
true);
272 CHECK(
getNode(nodes,
"test_node_off")->coredumpsEnabled() ==
false);
const std::vector< Node::Ptr > & nodes() const
void evaluateParameters()
rosmon::launch::Node::Ptr getNode(const std::vector< rosmon::launch::Node::Ptr > &nodes, const std::string &name, const std::string &namespaceString)
static void requireParsingException(const std::string &input)
void parseString(const std::string &input, bool onlyArguments=false)
TEST_CASE("node basic","[node]")
std::string printMapping(const std::map< std::string, std::string > &mapping)