repo_id
stringlengths
19
138
file_path
stringlengths
32
200
content
stringlengths
1
12.9M
__index_level_0__
int64
0
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/test/dotname_cases.py
import unittest class CaseA(unittest.TestCase): def runTest(self): self.assertTrue(True) class CaseB(unittest.TestCase): def runTest(self): self.assertTrue(True) class DotnameLoadingSuite(unittest.TestSuite): def __init__(self): super(DotnameLoadingSuite, self).__init__() self.addTest(CaseA()) self.addTest(CaseB()) class DotnameLoadingTest(unittest.TestCase): def test_a(self): self.assertTrue(True) def test_b(self): self.assertTrue(True) class NotTestCase(): def not_test(self): pass
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/test/distro_version.test
<launch> <test pkg="rostest" type="test_distro_version.py" test-name="distro_version" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/test/test_clean_master.py
#!/usr/bin/env python # Software License Agreement (BSD License) # # Copyright (c) 2009, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import os import sys import unittest import rospy import rosunit class CleanMasterTest(unittest.TestCase): def test_clean_master(self): self.failIf(rospy.has_param('dirty')) rospy.set_param('dirty', True) if __name__ == '__main__': rosunit.unitrun('test_rostest', 'test_clean_master', CleanMasterTest, coverage_packages=[])
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/test/test_distro_version.py
#!/usr/bin/env python # Software License Agreement (BSD License) # # Copyright (c) 2009, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import os import sys import unittest import rospy import rostest import subprocess class VersionTest(unittest.TestCase): def test_distro_version(self): val = (subprocess.Popen(['rosversion', '-d'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] or '').strip() param = rospy.get_param('rosdistro').strip() self.assertEquals(val, param, "rosversion -d [%s] and roscore [%s] do not match"%(val, param)) if __name__ == '__main__': rostest.unitrun('test_rostest', 'test_distro_version', VersionTest, coverage_packages=[])
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/test/hztest0.test
<launch> <!-- verify that hztest works with 0 rate. NOTE: there is no test for failure here, which needs to be added somehow --> <param name="hztest0/topic" value="fake" /> <param name="hztest0/hz" value="0.0" /> <param name="hztest0/test_duration" value="5.0" /> <test test-name="hz0_test" pkg="rostest" type="hztest" name="hztest0" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/test/time_limit_test.py
#!/usr/bin/env python # Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # ## only point of this test is to be killed within a short period of time import rospy while not rospy.is_shutdown(): pass
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/test/test_dotname.py
#!/usr/bin/env python # This file should be run using a non-ros unit test framework such as nose using # nosetests test_dotname.py. import unittest import rostest from dotname_cases import DotnameLoadingTest, NotTestCase, DotnameLoadingSuite class TestDotnameLoading(unittest.TestCase): def test_class_basic(self): rostest.rosrun('test_rostest', 'test_class_basic', DotnameLoadingTest) def test_class_dotname(self): rostest.rosrun('test_rostest', 'test_class_dotname', 'dotname_cases.DotnameLoadingTest') def test_method_dotname(self): rostest.rosrun('test_rostest', 'test_method_dotname', 'dotname_cases.DotnameLoadingTest.test_a') def test_suite_dotname(self): rostest.rosrun('test_rostest', 'test_suite_dotname', 'dotname_cases.DotnameLoadingSuite') def test_class_basic_nottest(self): # class which exists but is not a TestCase with self.assertRaises(SystemExit): rostest.rosrun('test_rostest', 'test_class_basic_nottest', NotTestCase) def test_suite_basic(self): # can't load suites with the basic loader with self.assertRaises(SystemExit): rostest.rosrun('test_rosunit', 'test_suite_basic', DotnameLoadingSuite) def test_class_dotname_nottest(self): # class which exists but is not a valid test with self.assertRaises(TypeError): rostest.rosrun('test_rostest', 'test_class_dotname_nottest', 'dotname_cases.NotTestCase') def test_class_dotname_noexist(self): # class which does not exist in the module with self.assertRaises(AttributeError): rostest.rosrun('test_rostest', 'test_class_dotname_noexist', 'dotname_cases.DotnameLoading') def test_method_dotname_noexist(self): # method which does not exist in the class with self.assertRaises(AttributeError): rostest.rosrun('test_rostest', 'test_method_dotname_noexist', 'dotname_cases.DotnameLoadingTest.not_method') if __name__ == '__main__': unittest.main()
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/test/time-limit.test
<launch> <!-- as these tests are designed to fail, they aren't be added to the normal test regression suite. they must be manually run with the knowledge that they will fail --> <test test-name="time_limit_test" pkg="rostest" type="time_limit_test.py" time-limit="1" /> <!-- test normal timeout (60 seconds) --> <test test-name="time_limit_test__no_limit" pkg="rostest" type="time_limit_test.py" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/test/test_permuter.cpp
/* * Copyright (c) 2008, Willow Garage, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Willow Garage, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include <gtest/gtest.h> #include <string> #include "rostest/permuter.h" using namespace rostest; double epsilon = 1e-9; TEST(Permuter, PermuteOption) { std::vector<double> vals; vals.push_back(1.0); vals.push_back(2.0); vals.push_back(3.0); vals.push_back(4.0); double value = 0; PermuteOption<double> op(vals, &value); for ( unsigned int i = 0; i < vals.size(); i++) { EXPECT_NEAR(vals[i], value, epsilon); if (i < vals.size() -1) EXPECT_TRUE(op.step()); else EXPECT_FALSE(op.step()); }; } TEST(Permuter, OneDoublePermuteOption) { double epsilon = 1e-9; rostest::Permuter permuter; std::vector<double> vals; vals.push_back(1.0); vals.push_back(2.0); vals.push_back(3.0); vals.push_back(4.0); double value = 0; permuter.addOptionSet(vals, &value); for ( unsigned int i = 0; i < vals.size(); i++) { EXPECT_NEAR(vals[i], value, epsilon); if (i < vals.size() -1) EXPECT_TRUE(permuter.step()); else EXPECT_FALSE(permuter.step()); }; } TEST(Permuter, TwoDoubleOptions) { double epsilon = 1e-9; Permuter permuter; std::vector<double> vals; vals.push_back(1.0); vals.push_back(2.0); vals.push_back(3.0); vals.push_back(4.0); double value = 0; std::vector<double> vals2; vals2.push_back(9.0); vals2.push_back(8.0); vals2.push_back(7.0); vals2.push_back(6.0); double value2; permuter.addOptionSet(vals, &value); permuter.addOptionSet(vals2, &value2); for ( unsigned int j = 0; j < vals2.size(); j++) for ( unsigned int i = 0; i < vals.size(); i++) { //printf("%f?=%f %f?=%f\n", value, vals[i], value2, vals2[j]); EXPECT_NEAR(vals[i], value, epsilon); EXPECT_NEAR(vals2[j], value2, epsilon); if (i == vals.size() -1 && j == vals2.size() -1) EXPECT_FALSE(permuter.step()); else EXPECT_TRUE(permuter.step()); }; } TEST(Permuter, ThreeDoubleOptions) { double epsilon = 1e-9; Permuter permuter; std::vector<double> vals; vals.push_back(1.0); vals.push_back(2.0); vals.push_back(3.0); vals.push_back(4.0); double value = 0; std::vector<double> vals2; vals2.push_back(9.0); vals2.push_back(8.0); vals2.push_back(7.0); vals2.push_back(6.0); double value2; std::vector<double> vals3; vals3.push_back(99.0); vals3.push_back(88.0); vals3.push_back(78.0); vals3.push_back(63.0); double value3; permuter.addOptionSet(vals, &value); permuter.addOptionSet(vals2, &value2); permuter.addOptionSet(vals3, &value3); for ( unsigned int k = 0; k < vals3.size(); k++) for ( unsigned int j = 0; j < vals2.size(); j++) for ( unsigned int i = 0; i < vals.size(); i++) { EXPECT_NEAR(vals[i], value, epsilon); EXPECT_NEAR(vals2[j], value2, epsilon); EXPECT_NEAR(vals3[k], value3, epsilon); if (i == vals.size() -1 && j == vals2.size() -1&& k == vals3.size() -1) EXPECT_FALSE(permuter.step()); else EXPECT_TRUE(permuter.step()); }; } TEST(Permuter, DoubleStringPermuteOptions) { double epsilon = 1e-9; Permuter permuter; std::vector<double> vals; vals.push_back(1.0); vals.push_back(2.0); vals.push_back(3.0); vals.push_back(4.0); double value = 0; std::vector<std::string> vals2; vals2.push_back("hi"); vals2.push_back("there"); vals2.push_back("this"); vals2.push_back("works"); std::string value2; permuter.addOptionSet(vals, &value); permuter.addOptionSet(vals2, &value2); for ( unsigned int j = 0; j < vals2.size(); j++) for ( unsigned int i = 0; i < vals.size(); i++) { //printf("%f?=%f %s?=%s\n", value, vals[i], value2.c_str(), vals2[j].c_str()); EXPECT_NEAR(vals[i], value, epsilon); EXPECT_STREQ(vals2[j].c_str(), value2.c_str()); if (i == vals.size() -1 && j == vals2.size() -1) EXPECT_FALSE(permuter.step()); else EXPECT_TRUE(permuter.step()); }; } int main(int argc, char **argv){ testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/test/hztest.test
<launch> <node name="talker" pkg="rospy" type="talker.py" /> <param name="hztest1/topic" value="chatter" /> <param name="hztest1/hz" value="10.0" /> <param name="hztest1/hzerror" value="0.5" /> <param name="hztest1/test_duration" value="5.0" /> <param name="hztest1/wait_time" value="21.0" /> <test test-name="hztest_test" pkg="rostest" type="hztest" name="hztest1" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/cmake/rostest-extras.cmake.em
find_package(catkin REQUIRED) _generate_function_if_testing_is_disabled("add_rostest") include(CMakeParseArguments) function(add_rostest file) _warn_if_skip_testing("add_rostest") @[if DEVELSPACE]@ # bin in develspace set(ROSTEST_EXE "@(PROJECT_SOURCE_DIR)/scripts/rostest") @[else]@ # bin in installspace set(ROSTEST_EXE "${rostest_DIR}/../../../@(CATKIN_GLOBAL_BIN_DESTINATION)/rostest") @[end if]@ cmake_parse_arguments(_rostest "" "WORKING_DIRECTORY" "ARGS;DEPENDENCIES" ${ARGN}) # Check that the file exists, #1621 set(_file_name _file_name-NOTFOUND) if(IS_ABSOLUTE ${file}) set(_file_name ${file}) else() find_file(_file_name ${file} PATHS ${CMAKE_CURRENT_SOURCE_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) # for cross-compilation. thanks jeremy. if(NOT _file_name) message(FATAL_ERROR "Can't find rostest file \"${file}\"") endif() endif() # strip PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR from absolute filename to get unique test name (as rostest does it internally) set(_testname ${_file_name}) rostest__strip_prefix(_testname "${PROJECT_SOURCE_DIR}/") rostest__strip_prefix(_testname "${PROJECT_BINARY_DIR}/") # to support registering the same test with different ARGS # append the args to the test name if(_rostest_ARGS) get_filename_component(_ext ${_testname} EXT) get_filename_component(_testname ${_testname} NAME_WE) foreach(arg ${_rostest_ARGS}) string(REPLACE ":=" "_" arg_string "${arg}") set(_testname "${_testname}__${arg_string}") endforeach() set(_testname "${_testname}${_ext}") endif() string(REPLACE "/" "_" _testname ${_testname}) get_filename_component(_output_name ${_testname} NAME_WE) set(_output_name "${_output_name}.xml") string(REPLACE ";" " " _rostest_ARGS "${_rostest_ARGS}") set(cmd "${ROSTEST_EXE} --pkgdir=${PROJECT_SOURCE_DIR} --package=${PROJECT_NAME} --results-filename ${_output_name} --results-base-dir \"${CATKIN_TEST_RESULTS_DIR}\" ${_file_name} ${_rostest_ARGS}") catkin_run_tests_target("rostest" ${_testname} "rostest-${_output_name}" COMMAND ${cmd} WORKING_DIRECTORY ${_rostest_WORKING_DIRECTORY} DEPENDENCIES ${_rostest_DEPENDENCIES}) endfunction() # # Register the launch file with add_rostest() and compile all # passed files into a GTest binary. # # .. note:: The function does nothing if GTest was not found. The # target is only compiled when tests are build and linked against # the GTest libraries. # # :param target: target name of the GTest executable # :type target: string # :param launch_file: the relative path to the roslaunch file # :type launch_file: string # :param ARGN: the files to compile into a GTest executable # :type ARGN: list of files # function(add_rostest_gtest target launch_file) if("${ARGN}" STREQUAL "") message(FATAL_ERROR "add_rostest_gtest() needs at least one file argument to compile a GTest executable") endif() if(GTEST_FOUND) include_directories(${GTEST_INCLUDE_DIRS}) add_executable(${target} EXCLUDE_FROM_ALL ${ARGN}) target_link_libraries(${target} ${GTEST_LIBRARIES}) if(TARGET tests) add_dependencies(tests ${target}) endif() add_rostest(${launch_file} DEPENDENCIES ${target}) endif() endfunction() macro(rostest__strip_prefix var prefix) string(LENGTH ${prefix} prefix_length) string(LENGTH ${${var}} var_length) if(${var_length} GREATER ${prefix_length}) string(SUBSTRING "${${var}}" 0 ${prefix_length} var_prefix) if("${var_prefix}" STREQUAL "${prefix}") # passing length -1 does not work for CMake < 2.8.5 # http://public.kitware.com/Bug/view.php?id=10740 string(LENGTH "${${var}}" _rest) math(EXPR _rest "${_rest} - ${prefix_length}") string(SUBSTRING "${${var}}" ${prefix_length} ${_rest} ${var}) endif() endif() endmacro()
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/nodes/hztest
#!/usr/bin/env python # Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # Revision $Id$ ## Integration test node that subscribes to any topic and verifies ## the publishing rate to be within a specified bounds. The following ## parameters must be set: ## ## * ~/hz: expected hz ## * ~/hzerror: errors bound for hz ## * ~/test_duration: time (in secs) to run test ## from __future__ import print_function import sys import threading import time import unittest import rospy import rostest NAME = 'hztest' from threading import Thread class HzTest(unittest.TestCase): def __init__(self, *args): super(HzTest, self).__init__(*args) rospy.init_node(NAME) self.lock = threading.Lock() self.message_received = False def setUp(self): self.errors = [] # Count of all messages received self.msg_count = 0 # Time of first message received self.msg_t0 = -1.0 # Time of last message received self.msg_tn = -1.0 ## performs two tests of a node, first with /rostime off, then with /rostime on def test_hz(self): # Fetch parameters try: # expected publishing rate hz = float(rospy.get_param('~hz')) # length of test test_duration = float(rospy.get_param('~test_duration')) # topic to test topic = rospy.get_param('~topic') # time to wait before wait_time = rospy.get_param('~wait_time', 20.) except KeyError as e: self.fail('hztest not initialized properly. Parameter [%s] not set. debug[%s] debug[%s]'%(str(e), rospy.get_caller_id(), rospy.resolve_name(e.args[0]))) # We only require hzerror if hz is non-zero hzerror = 0.0 if hz != 0.0: try: # margin of error allowed hzerror = float(rospy.get_param('~hzerror')) except KeyError as e: self.fail('hztest not initialized properly. Parameter [%s] not set. debug[%s] debug[%s]'%(str(e), rospy.get_caller_id(), rospy.resolve_name(e.args[0]))) # We optionally check each inter-message interval try: self.check_intervals = bool(rospy.get_param('~check_intervals')) except KeyError: self.check_intervals = False # We optionally measure wall clock time try: self.wall_clock = bool(rospy.get_param('~wall_clock')) except KeyError: self.wall_clock = False print("""Hz: %s Hz Error: %s Topic: %s Test Duration: %s"""%(hz, hzerror, topic, test_duration)) self._test_hz(hz, hzerror, topic, test_duration, wait_time) def _test_hz(self, hz, hzerror, topic, test_duration, wait_time): self.assert_(hz >= 0.0, "bad parameter (hz)") self.assert_(hzerror >= 0.0, "bad parameter (hzerror)") self.assert_(test_duration > 0.0, "bad parameter (test_duration)") self.assert_(len(topic), "bad parameter (topic)") if hz == 0: self.min_rate = 0.0 self.max_rate = 0.0 self.min_interval = 0.0 self.max_interval = 0.0 else: self.min_rate = hz - hzerror self.max_rate = hz + hzerror self.min_interval = 1.0 / self.max_rate if self.min_rate <= 0.0: self.max_interval = 0.0 else: self.max_interval = 1.0 / self.min_rate # Start actual test sub = rospy.Subscriber(topic, rospy.AnyMsg, self.callback) self.assert_(not self.errors, "bad initialization state (errors)") print("Waiting for messages") # we have to wait until the first message is received before measuring the rate # as time can advance too much before publisher is up # - give the test 20 seconds to start, may parameterize this in the future wallclock_timeout_t = time.time() + wait_time while not self.message_received and time.time() < wallclock_timeout_t: time.sleep(0.1) if hz > 0.: self.assert_(self.message_received, "no messages before timeout") else: self.failIf(self.message_received, "message received") print("Starting rate measurement") if self.wall_clock: timeout_t = time.time() + test_duration while time.time() < timeout_t: time.sleep(0.1) else: timeout_t = rospy.get_time() + test_duration while rospy.get_time() < timeout_t: rospy.sleep(0.1) print("Done waiting, validating results") sub.unregister() # Check that we got at least one message if hz > 0: self.assert_(self.msg_count > 0, "no messages received") else: self.assertEquals(0, self.msg_count) # Check whether inter-message intervals were violated (if we were # checking them) self.assert_(not self.errors, '\n'.join(self.errors)) # If we have a non-zero rate target, make sure that we hit it on # average if hz > 0.0: self.assert_(self.msg_t0 >= 0.0, "no first message received") self.assert_(self.msg_tn >= 0.0, "no last message received") dt = self.msg_tn - self.msg_t0 self.assert_(dt > 0.0, "only one message received") rate = ( self.msg_count - 1) / dt self.assert_(rate >= self.min_rate, "average rate (%.3fHz) exceeded minimum (%.3fHz)" % (rate, self.min_rate)) self.assert_(rate <= self.max_rate, "average rate (%.3fHz) exceeded maximum (%.3fHz)" % (rate, self.max_rate)) def callback(self, msg): # flag that message has been received self.message_received = True try: self.lock.acquire() if self.wall_clock: curr = time.time() else: curr_rostime = rospy.get_rostime() #print "CURR ROSTIME", curr_rostime.to_sec() if curr_rostime.is_zero(): return curr = curr_rostime.to_sec() if self.msg_t0 <= 0.0 or self.msg_t0 > curr: self.msg_t0 = curr self.msg_count = 1 last = 0 else: self.msg_count += 1 last = self.msg_tn self.msg_tn = curr # If we're instructed to check each inter-message interval, do # so if self.check_intervals and last > 0: interval = curr - last if interval < self.min_interval: print("CURR", str(curr), file=sys.stderr) print("LAST", str(last), file=sys.stderr) print("msg_count", str(self.msg_count), file=sys.stderr) print("msg_tn", str(self.msg_tn), file=sys.stderr) self.errors.append( 'min_interval exceeded: %s [actual] vs. %s [min]'%\ (interval, self.min_interval)) # If max_interval is <= 0.0, then we have no max elif self.max_interval > 0.0 and interval > self.max_interval: self.errors.append( 'max_interval exceeded: %s [actual] vs. %s [max]'%\ (interval, self.max_interval)) finally: self.lock.release() if __name__ == '__main__': # A dirty hack to work around an apparent race condition at startup # that causes some hztests to fail. Most evident in the tests of # rosstage. time.sleep(0.75) try: rostest.run('rostest', NAME, HzTest, sys.argv) except KeyboardInterrupt: pass print("exiting")
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/include
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/include/rostest/permuter.h
/* * Copyright (c) 2009, Willow Garage, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Willow Garage, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /** \author Tully Foote */ #ifndef ROSTEST_PERMUTER_H #define ROSTEST_PERMUTER_H #include <vector> #include "boost/thread/mutex.hpp" namespace rostest { /** \brief A base class for storing pointers to generic data types */ class PermuteOptionBase { public: virtual void reset() =0; virtual bool step() =0; virtual ~PermuteOptionBase() {}; }; /**\brief A class to hold a set of option values and currently used state * This class holds */ template<class T> class PermuteOption : public PermuteOptionBase { public: PermuteOption(const std::vector<T>& options, T* output) { options_ = options; output_ = output; reset(); } virtual ~PermuteOption(){}; void reset(){ boost::mutex::scoped_lock lock(access_mutex_); current_element_ = options_.begin(); *output_ = *current_element_; }; bool step() { boost::mutex::scoped_lock lock(access_mutex_); current_element_++; if (current_element_ == options_.end()) return false; *output_ = *current_element_; return true; }; private: /// Local storage of the possible values std::vector<T> options_; /// The output variable T* output_; typedef typename std::vector<T>::iterator V_T_iterator; /// The last updated element V_T_iterator current_element_; boost::mutex access_mutex_; }; /** \brief A class to provide easy permutation of options * This class provides a way to collapse independent * permutations of options into a single loop. */ class Permuter { public: /** \brief Destructor to clean up allocated data */ virtual ~Permuter(){ clearAll();}; /** \brief Add a set of values and an output to the iteration * @param values The set of possible values for this output * @param output The value to set at each iteration */ template<class T> void addOptionSet(const std::vector<T>& values, T* output) { boost::mutex::scoped_lock lock(access_mutex_); options_.push_back(static_cast<PermuteOptionBase*> (new PermuteOption<T>(values, output))); lock.unlock();//reset locks on its own reset(); }; /** \brief Reset the internal counters */ void reset(){ boost::mutex::scoped_lock lock(access_mutex_); for (unsigned int level= 0; level < options_.size(); level++) options_[level]->reset(); }; /** \brief Iterate to the next value in the iteration * Returns true unless done iterating. */ bool step() { boost::mutex::scoped_lock lock(access_mutex_); // base case just iterating for (unsigned int level= 0; level < options_.size(); level++) { if(options_[level]->step()) { //printf("stepping level %d returning true \n", level); return true; } else { //printf("reseting level %d\n", level); options_[level]->reset(); } } return false; }; /** \brief Clear all stored data */ void clearAll() { boost::mutex::scoped_lock lock(access_mutex_); for ( unsigned int i = 0 ; i < options_.size(); i++) { delete options_[i]; } options_.clear(); }; private: std::vector<PermuteOptionBase*> options_; ///< Store all the option objects boost::mutex access_mutex_; }; } #endif //ROSTEST_PERMUTER_H
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/scripts/rostest
#!/usr/bin/env python # Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from rostest import rostestmain rostestmain()
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/src
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/src/rostest/rostestutil.py
# Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # Revision $Id$ from __future__ import print_function """ rostest helper routines. """ # IMPORTANT: no routine here can in anyway cause rospy to be loaded (that includes roslaunch) import os import sys import logging def printlog(msg, *args): if args: msg = msg%args logging.getLogger('rostest').info(msg) print("[ROSTEST]" + msg) def printlogerr(msg, *args): if args: msg = msg%args logging.getLogger('rostest').error(msg) print("[ROSTEST]" + msg, file=sys.stderr) _errors = None def getErrors(): return _errors # Most of this code has been moved down into rosunit import rosunit rostest_name_from_path = rosunit.rostest_name_from_path def printRostestSummary(result, rostest_results): """ Print summary of rostest results to stdout. """ # TODO: probably can removed this global _errors _errors = result.errors return rosunit.print_runner_summary(result, rostest_results, runner_name='ROSTEST') printSummary = rosunit.print_unittest_summary createXMLRunner = rosunit.create_xml_runner xmlResultsFile = rosunit.xml_results_file test_failure_junit_xml = rosunit.junitxml.test_failure_junit_xml test_success_junit_xml = rosunit.junitxml.test_success_junit_xml
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/src
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/src/rostest/runner.py
# Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from __future__ import print_function import os import sys import logging import time import unittest import rospkg from rospkg.environment import ROS_TEST_RESULTS_DIR import roslaunch import roslib.packages from rostest.rostestutil import createXMLRunner, printSummary, printRostestSummary, \ xmlResultsFile, printlog, printlogerr from rostest.rostest_parent import ROSTestLaunchParent import rosunit.junitxml # NOTE: ignoring Python style guide as unittest is sadly written with Java-like camel casing _results = rosunit.junitxml.Result('rostest', 0, 0, 0) def _accumulateResults(results): _results.accumulate(results) def getResults(): return _results _textMode = False def setTextMode(val): global _textMode _textMode = val # global store of all ROSLaunchRunners so we can do an extra shutdown # in the rare event a tearDown fails to execute _test_parents = [] _config = None def _addRostestParent(runner): global _test_parents, _config logging.getLogger('rostest').info("_addRostestParent [%s]", runner) _test_parents.append(runner) _config = runner.config def getConfig(): return _config def getRostestParents(): return _test_parents # TODO: convert most of this into a run() routine of a RoslaunchRunner subclass ## generate test failure if tests with same name in launch file def failDuplicateRunner(testName): def fn(self): print("Duplicate tests named [%s] in rostest suite"%testName) self.fail("Duplicate tests named [%s] in rostest suite"%testName) return fn def failRunner(testName, message): def fn(self): print(message, file=sys.stderr) self.fail(message) return fn def rostestRunner(test, test_pkg, results_base_dir=None): """ Test function generator that takes in a roslaunch Test object and returns a class instance method that runs the test. TestCase setUp() is responsible for ensuring that the rest of the roslaunch state is correct and tearDown() is responsible for tearing everything down cleanly. @param test: rost test to run @type test: roslaunch.Test @return: function object to run testObj @rtype: fn """ ## test case pass/fail is a measure of whether or not the test ran def fn(self): done = False while not done: self.assert_(self.test_parent is not None, "ROSTestParent initialization failed") test_name = test.test_name printlog("Running test [%s]", test_name) #launch the other nodes succeeded, failed = self.test_parent.launch() self.assert_(not failed, "Test Fixture Nodes %s failed to launch"%failed) #setup the test # - we pass in the output test_file name so we can scrape it env = None if results_base_dir: env = {ROS_TEST_RESULTS_DIR: results_base_dir} test_file = xmlResultsFile(test_pkg, test_name, False, env=env) if os.path.exists(test_file): printlog("removing previous test results file [%s]", test_file) os.remove(test_file) # TODO: have to redeclare this due to a bug -- this file # needs to be renamed as it aliases the module where the # constant is elsewhere defined. The fix is to rename # rostest.py XML_OUTPUT_FLAG='--gtest_output=xml:' #use gtest-compatible flag test.args = "%s %s%s"%(test.args, XML_OUTPUT_FLAG, test_file) if _textMode: test.output = 'screen' test.args = test.args + " --text" # run the test, blocks until completion printlog("running test %s"%test_name) timeout_failure = False try: self.test_parent.run_test(test) except roslaunch.launch.RLTestTimeoutException as e: if test.retry: timeout_failure = True else: raise if not timeout_failure: printlog("test [%s] finished"%test_name) else: printlogerr("test [%s] timed out"%test_name) # load in test_file if not _textMode or timeout_failure: if not timeout_failure: self.assert_(os.path.isfile(test_file), "test [%s] did not generate test results"%test_name) printlog("test [%s] results are in [%s]", test_name, test_file) results = rosunit.junitxml.read(test_file, test_name) test_fail = results.num_errors or results.num_failures else: test_fail = True if test.retry > 0 and test_fail: test.retry -= 1 printlog("test [%s] failed, retrying. Retries left: %s"%(test_name, test.retry)) self.tearDown() self.setUp() else: done = True _accumulateResults(results) printlog("test [%s] results summary: %s errors, %s failures, %s tests", test_name, results.num_errors, results.num_failures, results.num_tests) #self.assertEquals(0, results.num_errors, "unit test reported errors") #self.assertEquals(0, results.num_failures, "unit test reported failures") else: if test.retry: printlogerr("retry is disabled in --text mode") done = True printlog("[ROSTEST] test [%s] done", test_name) return fn ## Function that becomes TestCase.setup() def setUp(self): # new test_parent for each run. we are a bit inefficient as it would be possible to # reuse the roslaunch base infrastructure for each test, but the roslaunch code # is not abstracted well enough yet self.test_parent = ROSTestLaunchParent(self.config, [self.test_file], reuse_master=self.reuse_master, clear=self.clear) printlog("setup[%s] run_id[%s] starting", self.test_file, self.test_parent.run_id) self.test_parent.setUp() # the config attribute makes it easy for tests to access the ROSLaunchConfig instance self.config = self.test_parent.config _addRostestParent(self.test_parent) printlog("setup[%s] run_id[%s] done", self.test_file, self.test_parent.run_id) ## Function that becomes TestCase.tearDown() def tearDown(self): printlog("tearDown[%s]", self.test_file) if self.test_parent: self.test_parent.tearDown() printlog("rostest teardown %s complete", self.test_file) def createUnitTest(pkg, test_file, reuse_master=False, clear=False, results_base_dir=None): """ Unit test factory. Constructs a unittest class based on the roslaunch @param pkg: package name @type pkg: str @param test_file: rostest filename @type test_file: str """ # parse the config to find the test files config = roslaunch.parent.load_config_default([test_file], None) # pass in config to class as a property so that test_parent can be initialized classdict = { 'setUp': setUp, 'tearDown': tearDown, 'config': config, 'test_parent': None, 'test_file': test_file, 'reuse_master': reuse_master, 'clear': clear } # add in the tests testNames = [] for test in config.tests: # #1989: find test first to make sure it exists and is executable err_msg = None try: rp = rospkg.RosPack() cmd = roslib.packages.find_node(test.package, test.type, rp) if not cmd: err_msg = "Test node [%s/%s] does not exist or is not executable"%(test.package, test.type) except rospkg.ResourceNotFound as e: err_msg = "Package [%s] for test node [%s/%s] does not exist"%(test.package, test.package, test.type) testName = 'test%s'%(test.test_name) if err_msg: classdict[testName] = failRunner(test.test_name, err_msg) elif testName in testNames: classdict[testName] = failDuplicateRunner(test.test_name) else: classdict[testName] = rostestRunner(test, pkg, results_base_dir=results_base_dir) testNames.append(testName) # instantiate the TestCase instance with our magically-created tests return type('RosTest',(unittest.TestCase,),classdict)
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/src
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/src/rostest/__init__.py
# Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # Revision $Id$ """ Interface for using rostest from other Python code as well as running Python unittests with additional reporting mechanisms and rosbuild (CMake) integration. """ from __future__ import print_function import sys import rosunit import rosgraph XML_OUTPUT_FLAG = '--gtest_output=xml:' #use gtest-compatible flag _GLOBAL_CALLER_ID = '/script' #TODO: replace with rosgraph.masterapi def get_master(): """ Get an XMLRPC handle to the Master. It is recommended to use the `rosgraph.masterapi` library instead, as it provides many conveniences. @return: XML-RPC proxy to ROS master @rtype: xmlrpclib.ServerProxy """ try: import xmlrpc.client as xmlrpcclient #Python 3.x except ImportError: import xmlrpclib as xmlrpcclient #Python 2.x uri = rosgraph.get_master_uri() return xmlrpcclient.ServerProxy(uri) def is_subscriber(topic, subscriber_id): """ Check whether or not master think subscriber_id subscribes to topic :returns: ``True`` if still register as a subscriber, ``bool`` :raises: IOError If communication with master fails """ m = get_master() code, msg, state = m.getSystemState(_GLOBAL_CALLER_ID) if code != 1: raise IOError("Unable to retrieve master state: %s"%msg) _, subscribers, _ = state for t, l in subscribers: if t == topic: return subscriber_id in l else: return False def is_publisher(topic, publisher_id): """ Predicate to check whether or not master think publisher_id publishes topic :returns: ``True`` if still register as a publisher, ``bool`` :raises: IOError If communication with master fails """ m = get_master() code, msg, state = m.getSystemState(_GLOBAL_CALLER_ID) if code != 1: raise IOError("Unable to retrieve master state: %s"%msg) pubs, _, _ = state for t, l in pubs: if t == topic: return publisher_id in l else: return False def rosrun(package, test_name, test, sysargs=None): """ Run a rostest/unittest-based integration test. @param package: name of package that test is in @type package: str @param test_name: name of test that is being run @type test_name: str @param test: a test case instance or a name resolving to a test case or suite @type test: unittest.TestCase, or string @param sysargs: command-line args. If not specified, this defaults to sys.argv. rostest will look for the --text and --gtest_output parameters @type sysargs: list """ if sysargs is None: # lazy-init sys args import sys sysargs = sys.argv #parse sysargs result_file = None for arg in sysargs: if arg.startswith(XML_OUTPUT_FLAG): result_file = arg[len(XML_OUTPUT_FLAG):] text_mode = '--text' in sysargs coverage_mode = '--cov' in sysargs if coverage_mode: _start_coverage([package]) import unittest import rospy suite = None if isinstance(test, str): suite = unittest.TestLoader().loadTestsFromName(test) else: # some callers pass a TestCase type (instead of an instance) suite = unittest.TestLoader().loadTestsFromTestCase(test) if text_mode: result = unittest.TextTestRunner(verbosity=2).run(suite) else: result = rosunit.create_xml_runner(package, test_name, result_file).run(suite) if coverage_mode: _stop_coverage([package]) rosunit.print_unittest_summary(result) # shutdown any node resources in case test forgets to rospy.signal_shutdown('test complete') if not result.wasSuccessful(): import sys sys.exit(1) # TODO: rename to rosrun -- migrating name to avoid confusion and enable easy xmlrunner use run = rosrun import warnings def deprecated(func): """This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emmitted when the function is used.""" def newFunc(*args, **kwargs): warnings.warn("Call to deprecated function %s." % func.__name__, category=DeprecationWarning, stacklevel=2) return func(*args, **kwargs) newFunc.__name__ = func.__name__ newFunc.__doc__ = func.__doc__ newFunc.__dict__.update(func.__dict__) return newFunc @deprecated def unitrun(package, test_name, test, sysargs=None, coverage_packages=None): """ Wrapper routine from running python unitttests with JUnit-compatible XML output. This is meant for unittests that do not not need a running ROS graph (i.e. offline tests only). This enables JUnit-compatible test reporting so that test results can be reported to higher-level tools. @param package: name of ROS package that is running the test @type package: str @param coverage_packages: list of Python package to compute coverage results for. Defaults to package @type coverage_packages: [str] """ rosunit.unitrun(package, test_name, test, sysargs=sysargs, coverage_packages=coverage_packages) # coverage instance _cov = None def _start_coverage(packages): global _cov try: import coverage try: _cov = coverage.coverage() # load previous results as we need to accumulate _cov.load() _cov.start() except coverage.CoverageException: print("WARNING: you have an older version of python-coverage that is not support. Please update to the version provided by 'easy_install coverage'", file=sys.stderr) except ImportError as e: print("""WARNING: cannot import python-coverage, coverage tests will not run. To install coverage, run 'easy_install coverage'""", file=sys.stderr) try: # reload the module to get coverage for package in packages: if package in sys.modules: reload(sys.modules[package]) except ImportError as e: print("WARNING: cannot import '%s', will not generate coverage report"%package, file=sys.stderr) return def _stop_coverage(packages, html=None): """ @param packages: list of packages to generate coverage reports for @type packages: [str] @param html: (optional) if not None, directory to generate html report to @type html: str """ if _cov is None: return import sys, os try: _cov.stop() # accumulate results _cov.save() # - update our own .coverage-modules file list for # coverage-html tool. The reason we read and rewrite instead # of append is that this does a uniqueness check to keep the # file from growing unbounded if os.path.exists('.coverage-modules'): with open('.coverage-modules','r') as f: all_packages = set([x for x in f.read().split('\n') if x.strip()] + packages) else: all_packages = set(packages) with open('.coverage-modules','w') as f: f.write('\n'.join(all_packages)+'\n') try: # list of all modules for html report all_mods = [] # iterate over packages to generate per-package console reports for package in packages: pkg = __import__(package) m = [v for v in sys.modules.values() if v and v.__name__.startswith(package)] all_mods.extend(m) # generate overall report and per module analysis _cov.report(m, show_missing=0) for mod in m: res = _cov.analysis(mod) print("\n%s:\nMissing lines: %s"%(res[0], res[3])) if html: print("="*80+"\ngenerating html coverage report to %s\n"%html+"="*80) _cov.html_report(all_mods, directory=html) except ImportError as e: print("WARNING: cannot import '%s', will not generate coverage report"%package, file=sys.stderr) except ImportError as e: print("""WARNING: cannot import python-coverage, coverage tests will not run. To install coverage, run 'easy_install coverage'""", file=sys.stderr) #502: backwards compatibility for unbuilt rostest packages def rostestmain(): #NOTE: this is importing from rostest.rostest from rostest.rostest_main import rostestmain as _main _main()
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/src
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/src/rostest/rostest_parent.py
# Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # Revision $Id$ import logging import sys import rosgraph import roslaunch.config from roslaunch.core import printlog_bold, RLException import roslaunch.launch import roslaunch.pmon import roslaunch.server import roslaunch.xmlloader import roslaunch.parent from rosmaster.master import Master from rospy import logwarn class ROSTestLaunchParent(roslaunch.parent.ROSLaunchParent): def __init__(self, config, roslaunch_files, port=0, reuse_master=False, clear=False): if config is None: raise Exception("config not initialized") # we generate a run_id for each test if reuse_master: param_server = rosgraph.Master('/roslaunch') try: run_id = param_server.getParam('/run_id') except Exception as e: # The user asked us to connect to an existing ROS master, and # we can't. Throw an exception and die raise Exception("Could not connect to existing ROS master. " + "Original exception was: %s" % str(e)) except: # oh boy; we got something that wasn't an exception. # Throw an exception and die raise Exception("Could not connect to existing ROS master.") if clear: params = param_server.getParamNames() # whitelist of parameters to keep whitelist = ['/run_id', '/rosversion', '/rosdistro'] for i in reversed(range(len(params))): param = params[i] if param in whitelist: del params[i] elif param.startswith('/roslaunch/'): del params[i] for param in params: param_server.deleteParam(param) else: run_id = roslaunch.core.generate_run_id() super(ROSTestLaunchParent, self).__init__(run_id, roslaunch_files, is_core=False, is_rostest=True) self.config = config self.port = port self.reuse_master = reuse_master self.master = None def _load_config(self): # disable super, just in case, though this shouldn't get called pass def setUp(self): """ initializes self.config and xmlrpc infrastructure """ self._start_infrastructure() if not self.reuse_master: self.master = Master(port=self.port) self.master.start() self.config.master.uri = self.master.uri self._init_runner() def tearDown(self): if self.runner is not None: runner = self.runner runner.stop() if self.master is not None: self.master.stop() self.master = None self._stop_infrastructure() def launch(self): """ perform launch of nodes, does not launch tests. rostest_parent follows a different pattern of init/run than the normal roslaunch, which is why it does not reuse start()/spin() """ if self.runner is not None: return self.runner.launch() else: raise Exception("no runner to launch") def run_test(self, test): """ run the test, blocks until completion """ if self.runner is not None: # run the test, blocks until completion return self.runner.run_test(test) else: raise Exception("no runner")
0
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/src
apollo_public_repos/apollo-platform/ros/ros_comm/rostest/src/rostest/rostest_main.py
# Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # Revision $Id$ from __future__ import print_function # NOTE: this has not survived the many refactorings and roslaunch changes well. There are too many ugly globals and bad # code organizational choices at this point, but it's not a high priority to cleanup. import os import sys import time import unittest import logging import roslaunch import rospkg from rospkg.environment import ROS_TEST_RESULTS_DIR import rosgraph.roslogging from rostest.rostestutil import createXMLRunner, printRostestSummary, \ xmlResultsFile, rostest_name_from_path from rostest.rostest_parent import ROSTestLaunchParent import rostest.runner _NAME = 'rostest' def configure_logging(): import socket logfile_basename = 'rostest-%s-%s.log'%(socket.gethostname(), os.getpid()) logfile_name = rosgraph.roslogging.configure_logging('rostest', filename=logfile_basename) if logfile_name: print("... logging to %s"%logfile_name) return logfile_name def write_bad_filename_failure(test_file, results_file, outname): # similar to rostest-check-results results_file_dir = os.path.dirname(results_file) if not os.path.isdir(results_file_dir): os.makedirs(results_file_dir) with open(results_file, 'w') as f: d = {'test': outname, 'test_file': test_file } f.write("""<?xml version="1.0" encoding="UTF-8"?> <testsuite tests="1" failures="1" time="1" errors="0" name="%(test)s"> <testcase name="test_ran" status="run" time="1" classname="Results"> <failure message="rostest file [%(test_file)s] does not exist" type=""/> </testcase> </testsuite>"""%d) def rostestmain(): import roslaunch.rlutil from optparse import OptionParser parser = OptionParser(usage="usage: %prog [options] [package] <filename>", prog=_NAME) parser.add_option("-t", "--text", action="store_true", dest="text_mode", default=False, help="Run with stdout output instead of XML output") parser.add_option("--pkgdir", metavar="PKG_DIR", dest="pkg_dir", default=None, help="package dir") parser.add_option("--package", metavar="PACKAGE", dest="package", default=None, help="package") parser.add_option("--results-filename", metavar="RESULTS_FILENAME", dest="results_filename", default=None, help="results_filename") parser.add_option("--results-base-dir", metavar="RESULTS_BASE_DIR", help="The base directory of the test results. The test result file is " + "created in a subfolder name PKG_DIR.") parser.add_option("-r", "--reuse-master", action="store_true", help="Connect to an existing ROS master instead of spawning a new ROS master on a custom port") parser.add_option("-c", "--clear", action="store_true", help="Clear all parameters when connecting to an existing ROS master (only works with --reuse-master)") (options, args) = parser.parse_args() if options.clear and not options.reuse_master: print("The --clear option is only valid with --reuse-master", file=sys.stderr) sys.exit(1) try: args = roslaunch.rlutil.resolve_launch_arguments(args) except roslaunch.core.RLException as e: print(str(e), file=sys.stderr) sys.exit(1) # make sure all loggers are configured properly logfile_name = configure_logging() logger = logging.getLogger('rostest') import roslaunch.core roslaunch.core.add_printlog_handler(logger.info) roslaunch.core.add_printerrlog_handler(logger.error) logger.info('rostest starting with options %s, args %s'%(options, args)) if len(args) == 0: parser.error("You must supply a test file argument to rostest.") if len(args) != 1: parser.error("rostest only accepts a single test file") # compute some common names we'll be using to generate test names and files test_file = args[0] if options.pkg_dir and options.package: # rosbuild2: the build system knows what package and directory, so let it tell us, # instead of shelling back out to rospack pkg_dir, pkg = options.pkg_dir, options.package else: pkg = rospkg.get_package_name(test_file) r = rospkg.RosPack() pkg_dir = r.get_path(pkg) if options.results_filename: outname = options.results_filename if '.' in outname: outname = outname[:outname.rfind('.')] else: outname = rostest_name_from_path(pkg_dir, test_file) env = None if options.results_base_dir: env = {ROS_TEST_RESULTS_DIR: options.results_base_dir} # #1140 if not os.path.isfile(test_file): results_file = xmlResultsFile(pkg, outname, True, env=env) write_bad_filename_failure(test_file, results_file, outname) parser.error("test file is invalid. Generated failure case result file in %s"%results_file) try: testCase = rostest.runner.createUnitTest(pkg, test_file, options.reuse_master, options.clear, options.results_base_dir) suite = unittest.TestLoader().loadTestsFromTestCase(testCase) if options.text_mode: rostest.runner.setTextMode(True) result = unittest.TextTestRunner(verbosity=2).run(suite) else: is_rostest = True results_file = xmlResultsFile(pkg, outname, is_rostest, env=env) xml_runner = createXMLRunner(pkg, outname, \ results_file=results_file, \ is_rostest=is_rostest) result = xml_runner.run(suite) finally: # really make sure that all of our processes have been killed test_parents = rostest.runner.getRostestParents() for r in test_parents: logger.info("finally rostest parent tearDown [%s]", r) r.tearDown() del test_parents[:] from roslaunch.pmon import pmon_shutdown logger.info("calling pmon_shutdown") pmon_shutdown() logger.info("... done calling pmon_shutdown") # print config errors after test has run so that we don't get caught up in .xml results config = rostest.runner.getConfig() if config: if config.config_errors: print("\n[ROSTEST WARNINGS]"+'-'*62+'\n', file=sys.stderr) for err in config.config_errors: print(" * %s"%err, file=sys.stderr) print('') # summary is worthless if textMode is on as we cannot scrape .xml results subtest_results = rostest.runner.getResults() if not options.text_mode: printRostestSummary(result, subtest_results) else: print("WARNING: overall test result is not accurate when --text is enabled") if logfile_name: print("rostest log file is in %s"%logfile_name) if not result.wasSuccessful(): sys.exit(1) elif subtest_results.num_errors or subtest_results.num_failures: sys.exit(2) if __name__ == '__main__': rostestmain()
0
apollo_public_repos/apollo-platform/ros/ros_comm
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3) project(roslaunch) find_package(catkin REQUIRED) catkin_package(CFG_EXTRAS roslaunch-extras.cmake) if(CMAKE_HOST_UNIX) catkin_add_env_hooks(10.roslaunch SHELLS sh DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/env-hooks) else() catkin_add_env_hooks(10.roslaunch SHELLS bat DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/env-hooks) endif() catkin_python_setup() install(FILES resources/roscore.xml DESTINATION ${CATKIN_GLOBAL_ETC_DESTINATION}/ros) # install example launch files install(DIRECTORY resources DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}) # required for old rosbuild macro to be under PKGNAME/scripts catkin_install_python(PROGRAMS scripts/roslaunch-check DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/scripts) if(CATKIN_ENABLE_TESTING) catkin_add_nosetests(test/unit) endif()
0
apollo_public_repos/apollo-platform/ros/ros_comm
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/package.xml
<package> <name>roslaunch</name> <version>1.11.21</version> <description> roslaunch is a tool for easily launching multiple ROS <a href="http://ros.org/wiki/Nodes">nodes</a> locally and remotely via SSH, as well as setting parameters on the <a href="http://ros.org/wiki/Parameter Server">Parameter Server</a>. It includes options to automatically respawn processes that have already died. roslaunch takes in one or more XML configuration files (with the <tt>.launch</tt> extension) that specify the parameters to set and nodes to launch, as well as the machines that they should be run on. </description> <maintainer email="dthomas@osrfoundation.org">Dirk Thomas</maintainer> <license>BSD</license> <url>http://ros.org/wiki/roslaunch</url> <author>Ken Conley</author> <buildtool_depend version_gte="0.5.78">catkin</buildtool_depend> <run_depend>python-paramiko</run_depend> <run_depend version_gte="1.0.37">python-rospkg</run_depend> <run_depend>python-yaml</run_depend> <run_depend>rosclean</run_depend> <run_depend>rosgraph_msgs</run_depend> <run_depend>roslib</run_depend> <run_depend version_gte="1.11.16">rosmaster</run_depend> <run_depend>rosout</run_depend> <run_depend>rosparam</run_depend> <run_depend>rosunit</run_depend> <test_depend>rosbuild</test_depend> <export> <rosdoc config="rosdoc.yaml"/> <architecture_independent/> </export> </package>
0
apollo_public_repos/apollo-platform/ros/ros_comm
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/rosdoc.yaml
- builder: epydoc
0
apollo_public_repos/apollo-platform/ros/ros_comm
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/setup.py
#!/usr/bin/env python from distutils.core import setup from catkin_pkg.python_setup import generate_distutils_setup d = generate_distutils_setup( packages=['roslaunch'], package_dir={'': 'src'}, scripts=['scripts/roscore', 'scripts/roslaunch', 'scripts/roslaunch-complete', 'scripts/roslaunch-deps', 'scripts/roslaunch-logs'], requires=['genmsg', 'genpy', 'roslib', 'rospkg'] ) setup(**d)
0
apollo_public_repos/apollo-platform/ros/ros_comm
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/.tar
{!!python/unicode 'url': 'https://github.com/ros-gbp/ros_comm-release/archive/release/indigo/roslaunch/1.11.21-0.tar.gz', !!python/unicode 'version': ros_comm-release-release-indigo-roslaunch-1.11.21-0}
0
apollo_public_repos/apollo-platform/ros/ros_comm
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/CHANGELOG.rst
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package roslaunch ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1.11.21 (2017-03-06) -------------------- * improve error message for invalid tags (`#989 <https://github.com/ros/ros_comm/pull/989>`_) * fix caching logic to improve performance (`#931 <https://github.com/ros/ros_comm/pull/931>`_) 1.11.20 (2016-06-27) -------------------- * fix roslaunch check for multiple tests with multiple args (`#814 <https://github.com/ros/ros_comm/pull/814>`_) 1.11.19 (2016-04-18) -------------------- 1.11.18 (2016-03-17) -------------------- 1.11.17 (2016-03-11) -------------------- * improve roslaunch-check to not fail if recursive dependencies lack dependencies (`#730 <https://github.com/ros/ros_comm/pull/730>`_) * add "pass_all_args" attribute to roslaunch "include" tag (`#710 <https://github.com/ros/ros_comm/pull/710>`_) * fix a typo in unknown host error message (`#735 <https://github.com/ros/ros_comm/pull/735>`_) * wait for param server to be available before trying to get param (`#711 <https://github.com/ros/ros_comm/pull/711>`_) 1.11.16 (2015-11-09) -------------------- * add `-w` and `-t` options (`#687 <https://github.com/ros/ros_comm/pull/687>`_) * fix missing minimum version for rospkg dependency (`#693 <https://github.com/ros/ros_comm/issues/693>`_) 1.11.15 (2015-10-13) -------------------- * improve performance by reusing the rospack instance across nodes with the same default environment (`#682 <https://github.com/ros/ros_comm/pull/682>`_) 1.11.14 (2015-09-19) -------------------- * add more information when test times out 1.11.13 (2015-04-28) -------------------- 1.11.12 (2015-04-27) -------------------- 1.11.11 (2015-04-16) -------------------- 1.11.10 (2014-12-22) -------------------- * fix exception at roscore startup if python has IPv6 disabled (`#515 <https://github.com/ros/ros_comm/issues/515>`_) * fix error handling (`#516 <https://github.com/ros/ros_comm/pull/516>`_) * fix compatibility with paramiko 1.10.0 (`#498 <https://github.com/ros/ros_comm/pull/498>`_) 1.11.9 (2014-08-18) ------------------- * fix usage of logger before it is initialized (`#490 <https://github.com/ros/ros_comm/issues/490>`_) (regression from 1.11.6) 1.11.8 (2014-08-04) ------------------- * remove implicit rostest dependency and use rosunit instead (`#475 <https://github.com/ros/ros_comm/issues/475>`_) * accept stdin input alongside files (`#472 <https://github.com/ros/ros_comm/issues/472>`_) 1.11.7 (2014-07-18) ------------------- * fix the ROS_MASTER_URI environment variable logic on Windows (`#2 <https://github.com/windows/ros_comm/issues/2>`_) 1.11.6 (2014-07-10) ------------------- * fix printing of non-ascii roslaunch parameters (`#454 <https://github.com/ros/ros_comm/issues/454>`_) * add respawn_delay attribute to node tag in roslaunch (`#446 <https://github.com/ros/ros_comm/issues/446>`_) * write traceback for exceptions in roslaunch to log file 1.11.5 (2014-06-24) ------------------- 1.11.4 (2014-06-16) ------------------- * fix handling of if/unless attributes on args (`#437 <https://github.com/ros/ros_comm/issues/437>`_) * improve parameter printing in roslaunch (`#89 <https://github.com/ros/ros_comm/issues/89>`_) * Python 3 compatibility (`#426 <https://github.com/ros/ros_comm/issues/426>`_, `#427 <https://github.com/ros/ros_comm/issues/427>`_, `#429 <https://github.com/ros/ros_comm/issues/429>`_) 1.11.3 (2014-05-21) ------------------- 1.11.2 (2014-05-08) ------------------- 1.11.1 (2014-05-07) ------------------- * fix roslaunch anonymous function to generate the same output for the same input (`#297 <https://github.com/ros/ros_comm/issues/297>`_) * add doc attribute to roslaunch arg tags (`#379 <https://github.com/ros/ros_comm/issues/379>`_) * print parameter values in roslaunch (`#89 <https://github.com/ros/ros_comm/issues/89>`_) * add architecture_independent flag in package.xml (`#391 <https://github.com/ros/ros_comm/issues/391>`_) 1.11.0 (2014-03-04) ------------------- * use catkin_install_python() to install Python scripts (`#361 <https://github.com/ros/ros_comm/issues/361>`_) 1.10.0 (2014-02-11) ------------------- * add optional DEPENDENCIES argument to roslaunch_add_file_check() * add explicit run dependency (`#347 <https://github.com/ros/ros_comm/issues/347>`_) 1.9.54 (2014-01-27) ------------------- * add missing run/test dependencies on rosbuild to get ROS_ROOT environment variable 1.9.53 (2014-01-14) ------------------- 1.9.52 (2014-01-08) ------------------- 1.9.51 (2014-01-07) ------------------- * fix roslaunch-check for unreleased wet dependencies (`#332 <https://github.com/ros/ros_comm/issues/332>`_) 1.9.50 (2013-10-04) ------------------- * add option to disable terminal title setting * fix roslaunch-check to handle more complex launch files 1.9.49 (2013-09-16) ------------------- 1.9.48 (2013-08-21) ------------------- * update roslaunch to support ROS_NAMESPACE (`#58 <https://github.com/ros/ros_comm/issues/58>`_) * make roslaunch relocatable (`ros/catkin#490 <https://github.com/ros/catkin/issues/490>`_) * change roslaunch resolve order (`#256 <https://github.com/ros/ros_comm/issues/256>`_) * fix roslaunch check script in install space (`#257 <https://github.com/ros/ros_comm/issues/257>`_) 1.9.47 (2013-07-03) ------------------- * improve roslaunch completion to include launch file arguments (`#230 <https://github.com/ros/ros_comm/issues/230>`_) * check for CATKIN_ENABLE_TESTING to enable configure without tests 1.9.46 (2013-06-18) ------------------- * add CMake function roslaunch_add_file_check() (`#241 <https://github.com/ros/ros_comm/issues/241>`_) 1.9.45 (2013-06-06) ------------------- * modified roslaunch $(find PKG) to consider path behind it for resolve strategy (`#233 <https://github.com/ros/ros_comm/pull/233>`_) * add boolean attribute 'subst_value' to rosparam tag in launch files (`#218 <https://github.com/ros/ros_comm/issues/218>`_) * add command line parameter to print out launch args * fix missing import in arg_dump.py 1.9.44 (2013-03-21) ------------------- * fix 'roslaunch --files' with non-unique anononymous ids (`#186 <https://github.com/ros/ros_comm/issues/186>`_) * fix ROS_MASTER_URI for Windows 1.9.43 (2013-03-13) ------------------- * implement process killer for Windows 1.9.42 (2013-03-08) ------------------- * add option --skip-log-check (`#133 <https://github.com/ros/ros_comm/issues/133>`_) * update API doc to list raised exceptions in config.py * fix invocation of Python scripts under Windows (`#54 <https://github.com/ros/ros_comm/issues/54>`_) 1.9.41 (2013-01-24) ------------------- * improve performance of $(find ...) 1.9.40 (2013-01-13) ------------------- * fix 'roslaunch --pid=' when pointing to ROS_HOME but folder does not exist (`#43 <https://github.com/ros/ros_comm/issues/43>`_) * fix 'roslaunch --pid=' to use shell expansion for the pid value (`#44 <https://github.com/ros/ros_comm/issues/44>`_) 1.9.39 (2012-12-29) ------------------- * first public release for Groovy
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/dump-params.yaml
string1: bar dict1: { head: 1, shoulders: 2, knees: 3, toes: 4}
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/params.yaml
string1: bar string2: !!str 10 preformattedtext: | This is the first line This is the second line Line breaks are preserved Indentation is stripped list1: - head - shoulders - knees - toes list2: [1, 1, 2, 3, 5, 8] dict1: { head: 1, shoulders: 2, knees: 3, toes: 4} integer1: 1 integer2: 2 float1: 3.14159 float2: 1.2345e+3 robots: childparam: a child namespace parameter child: grandchildparam: a grandchild namespace param
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/params_empty2.yaml
# # #
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/unit/test_roslaunch_remote.py
# Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import os import sys import unittest import roslaunch.core import roslaunch.remote ## Unit tests for roslaunch.remote class TestRoslaunchRemote(unittest.TestCase): def test_remote_node_xml(self): # these are fairly brittle tests, but need to make sure there aren't regressions here Node = roslaunch.core.Node n = Node('pkg1', 'type1') self.assertEquals('<node pkg="pkg1" type="type1" ns="/" args="" respawn="False" respawn_delay="0.0" required="False">\n</node>', n.to_remote_xml()) n = Node('pkg2', 'type2', namespace="/ns2/") self.assertEquals('<node pkg="pkg2" type="type2" ns="/ns2/" args="" respawn="False" respawn_delay="0.0" required="False">\n</node>', n.to_remote_xml()) # machine_name should be a noop for remote xml n = Node('pkg3', 'type3', namespace="/ns3/", machine_name="machine3") self.assertEquals('<node pkg="pkg3" type="type3" ns="/ns3/" args="" respawn="False" respawn_delay="0.0" required="False">\n</node>', n.to_remote_xml()) # test args n = Node('pkg4', 'type4', args="arg4a arg4b") self.assertEquals('<node pkg="pkg4" type="type4" ns="/" args="arg4a arg4b" respawn="False" respawn_delay="0.0" required="False">\n</node>', n.to_remote_xml()) # test respawn n = Node('pkg5', 'type5', respawn=True) self.assertEquals('<node pkg="pkg5" type="type5" ns="/" args="" respawn="True" respawn_delay="0.0" required="False">\n</node>', n.to_remote_xml()) n = Node('pkg5', 'type5', respawn=True, respawn_delay=1.0) self.assertEquals('<node pkg="pkg5" type="type5" ns="/" args="" respawn="True" respawn_delay="1.0" required="False">\n</node>', n.to_remote_xml()) n = Node('pkg6', 'type6', respawn=False) self.assertEquals('<node pkg="pkg6" type="type6" ns="/" args="" respawn="False" respawn_delay="0.0" required="False">\n</node>', n.to_remote_xml()) # test remap_args n = Node('pkg6', 'type6', remap_args=[('from6a', 'to6a'), ('from6b', 'to6b')]) self.assertEquals("""<node pkg="pkg6" type="type6" ns="/" args="" respawn="False" respawn_delay="0.0" required="False"> <remap from="from6a" to="to6a" /> <remap from="from6b" to="to6b" /> </node>""", n.to_remote_xml()) # test env args n = Node('pkg7', 'type7', env_args=[('key7a', 'val7a'), ('key7b', 'val7b')]) self.assertEquals("""<node pkg="pkg7" type="type7" ns="/" args="" respawn="False" respawn_delay="0.0" required="False"> <env name="key7a" value="val7a" /> <env name="key7b" value="val7b" /> </node>""", n.to_remote_xml()) # test cwd n = Node('pkg8', 'type8', cwd='ROS_HOME') self.assertEquals('<node pkg="pkg8" type="type8" ns="/" args="" cwd="ROS_HOME" respawn="False" respawn_delay="0.0" required="False">\n</node>', n.to_remote_xml()) n = Node('pkg9', 'type9', cwd='node') self.assertEquals('<node pkg="pkg9" type="type9" ns="/" args="" cwd="node" respawn="False" respawn_delay="0.0" required="False">\n</node>', n.to_remote_xml()) # test output n = Node('pkg10', 'type10', output='screen') self.assertEquals('<node pkg="pkg10" type="type10" ns="/" args="" output="screen" respawn="False" respawn_delay="0.0" required="False">\n</node>', n.to_remote_xml()) n = Node('pkg11', 'type11', output='log') self.assertEquals('<node pkg="pkg11" type="type11" ns="/" args="" output="log" respawn="False" respawn_delay="0.0" required="False">\n</node>', n.to_remote_xml()) # test launch-prefix n = Node('pkg12', 'type12', launch_prefix='xterm -e') self.assertEquals('<node pkg="pkg12" type="type12" ns="/" args="" respawn="False" respawn_delay="0.0" launch-prefix="xterm -e" required="False">\n</node>', n.to_remote_xml()) # test required n = Node('pkg13', 'type13', required=True) self.assertEquals('<node pkg="pkg13" type="type13" ns="/" args="" respawn="False" respawn_delay="0.0" required="True">\n</node>', n.to_remote_xml()) #test everything n = Node('pkg20', 'type20', namespace="/ns20/", machine_name="foo", remap_args=[('from20a', 'to20a'), ('from20b', 'to20b')], env_args=[('key20a', 'val20a'), ('key20b', 'val20b')], output="screen", cwd="ROS_HOME", respawn=True, args="arg20a arg20b", launch_prefix="nice", required=False) self.assertEquals("""<node pkg="pkg20" type="type20" ns="/ns20/" args="arg20a arg20b" output="screen" cwd="ROS_HOME" respawn="True" respawn_delay="0.0" launch-prefix="nice" required="False"> <remap from="from20a" to="to20a" /> <remap from="from20b" to="to20b" /> <env name="key20a" value="val20a" /> <env name="key20b" value="val20b" /> </node>""", n.to_remote_xml()) def test_remote_test_node_xml(self): Test = roslaunch.core.Test #TODO: will certainly fail right now # these are fairly brittle tests, but need to make sure there aren't regressions here Test = roslaunch.core.Test n = Test('test1', 'pkg1', 'type1') self.assertEquals('<test pkg="pkg1" type="type1" ns="/" args="" output="log" required="False" test-name="test1">\n</test>', n.to_remote_xml()) n = Test('test2', 'pkg2', 'type2', namespace="/ns2/") self.assertEquals('<test pkg="pkg2" type="type2" ns="/ns2/" args="" output="log" required="False" test-name="test2">\n</test>', n.to_remote_xml()) # machine_name should be a noop for remote xml n = Test('test3', 'pkg3', 'type3', namespace="/ns3/", machine_name="machine3") self.assertEquals('<test pkg="pkg3" type="type3" ns="/ns3/" args="" output="log" required="False" test-name="test3">\n</test>', n.to_remote_xml()) # test args n = Test('test4', 'pkg4', 'type4', args="arg4a arg4b") self.assertEquals('<test pkg="pkg4" type="type4" ns="/" args="arg4a arg4b" output="log" required="False" test-name="test4">\n</test>', n.to_remote_xml()) # test remap_args n = Test('test6', 'pkg6', 'type6', remap_args=[('from6a', 'to6a'), ('from6b', 'to6b')]) self.assertEquals("""<test pkg="pkg6" type="type6" ns="/" args="" output="log" required="False" test-name="test6"> <remap from="from6a" to="to6a" /> <remap from="from6b" to="to6b" /> </test>""", n.to_remote_xml()) # test env args n = Test('test7', 'pkg7', 'type7', env_args=[('key7a', 'val7a'), ('key7b', 'val7b')]) self.assertEquals("""<test pkg="pkg7" type="type7" ns="/" args="" output="log" required="False" test-name="test7"> <env name="key7a" value="val7a" /> <env name="key7b" value="val7b" /> </test>""", n.to_remote_xml()) # test cwd n = Test('test8', 'pkg8', 'type8', cwd='ROS_HOME') self.assertEquals('<test pkg="pkg8" type="type8" ns="/" args="" output="log" cwd="ROS_HOME" required="False" test-name="test8">\n</test>', n.to_remote_xml()) n = Test('test9', 'pkg9', 'type9', cwd='node') self.assertEquals('<test pkg="pkg9" type="type9" ns="/" args="" output="log" cwd="node" required="False" test-name="test9">\n</test>', n.to_remote_xml()) #test everything n = Test('test20', 'pkg20', 'type20', namespace="/ns20/", machine_name="foo", remap_args=[('from20a', 'to20a'), ('from20b', 'to20b')], env_args=[('key20a', 'val20a'), ('key20b', 'val20b')], cwd="ROS_HOME", args="arg20a arg20b") self.assertEquals("""<test pkg="pkg20" type="type20" ns="/ns20/" args="arg20a arg20b" output="log" cwd="ROS_HOME" required="False" test-name="test20"> <remap from="from20a" to="to20a" /> <remap from="from20b" to="to20b" /> <env name="key20a" value="val20a" /> <env name="key20b" value="val20b" /> </test>""", n.to_remote_xml())
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/unit/test_roslaunch_rlutil.py
#!/usr/bin/env python # Software License Agreement (BSD License) # # Copyright (c) 2009, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # Revision $Id: roslaunch_node_args.py 5229 2009-07-16 22:31:17Z sfkwc $ import os import sys import unittest import roslaunch import roslaunch.rlutil def get_test_path(): # two directories up from here return os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) # path to example.launch directory def get_example_path(): return os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'resources')) ## Test roslaunch.node_args class TestRoslaunchRlutil(unittest.TestCase): def test_resolve_launch_arguments(self): from roslaunch.rlutil import resolve_launch_arguments roslaunch_dir = get_test_path() example_xml_p = os.path.join(get_example_path(), 'example.launch') tests = [ ([], []), (['roslaunch', 'example.launch'], [example_xml_p]), ([example_xml_p], [example_xml_p]), (['roslaunch', 'example.launch', 'foo', 'bar'], [example_xml_p, 'foo', 'bar']), ([example_xml_p, 'foo', 'bar'], [example_xml_p,'foo', 'bar']), ] bad = [ ['does_not_exist'], ['does_not_exist', 'foo.launch'], ['roslaunch', 'does_not_exist.launch'], ] for test, result in tests: for v1, v2 in zip(result, resolve_launch_arguments(test)): # workaround for nfs if os.path.exists(v1): self.assert_(os.path.samefile(v1, v2)) else: self.assertEquals(v1, v2) for test in bad: try: resolve_launch_arguments(test) self.fail("should have failed") except roslaunch.RLException: pass
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/unit/test_substitution_args.py
# Software License Agreement (BSD License) # # Copyright (c) 2009, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import os import sys import rospkg def test__arg(): import random from roslaunch.substitution_args import _arg, ArgException, SubstitutionException ctx = { 'arg': { 'foo': '12345', 'bar': 'hello world', 'baz': 'sim', 'empty': '', } } # test invalid try: _arg('$(arg)', 'arg', [], ctx) assert False, "should have thrown" except SubstitutionException: pass # test normal tests = [ ('12345', ('$(arg foo)', 'arg foo', ['foo'], ctx)), ('', ('$(arg empty)', 'arg empty', ['empty'], ctx)), ('sim', ('$(arg baz)', 'arg baz', ['baz'], ctx)), # test with other args present, should only resolve match ('1234512345', ('$(arg foo)$(arg foo)', 'arg foo', ['foo'], ctx)), ('12345$(arg baz)', ('$(arg foo)$(arg baz)', 'arg foo', ['foo'], ctx)), ('$(arg foo)sim', ('$(arg foo)$(arg baz)', 'arg baz', ['baz'], ctx)), # test double-resolve safe ('12345', ('12345', 'arg foo', ['foo'], ctx)), ] for result, test in tests: resolved, a, args, context = test assert result == _arg(resolved, a, args, context) # - test that all fail if ctx is not set for result, test in tests: resolved, a, args, context = test try: _arg(resolved, a, args, {}) assert False, "should have thrown" except ArgException as e: assert args[0] == str(e) try: _arg(resolved, a, args, {'arg': {}}) assert False, "should have thrown" except ArgException as e: assert args[0] == str(e) def test_resolve_args(): from roslaunch.substitution_args import resolve_args, SubstitutionException r = rospkg.RosPack() roslaunch_dir = r.get_path('roslaunch') assert roslaunch_dir anon_context = {'foo': 'bar'} arg_context = {'fuga': 'hoge', 'car': 'cdr'} context = {'anon': anon_context, 'arg': arg_context } tests = [ ('$(find roslaunch)', roslaunch_dir), ('hello$(find roslaunch)', 'hello'+roslaunch_dir), ('$(find roslaunch )', roslaunch_dir), ('$$(find roslaunch )', '$'+roslaunch_dir), ('$( find roslaunch )', roslaunch_dir), ('$(find roslaunch )', roslaunch_dir), ('$(find roslaunch)$(find roslaunch)', roslaunch_dir+os.sep+roslaunch_dir), ('$(find roslaunch)/foo/bar.xml', roslaunch_dir+os.sep+'foo'+os.sep+'bar.xml'), (r'$(find roslaunch)\foo\bar.xml $(find roslaunch)\bar.xml', roslaunch_dir+os.sep+'foo'+os.sep+'bar.xml '+roslaunch_dir+os.sep+'bar.xml'), ('$(find roslaunch)\\foo\\bar.xml more/stuff\\here', roslaunch_dir+os.sep+'foo'+os.sep+'bar.xml more/stuff\\here'), ('$(env ROS_ROOT)', os.environ['ROS_ROOT']), ('$(env ROS_ROOT)', os.environ['ROS_ROOT']), ('$(env ROS_ROOT )', os.environ['ROS_ROOT']), ('$(optenv ROS_ROOT)', os.environ['ROS_ROOT']), ('$(optenv ROS_ROOT)$(optenv ROS_ROOT)', os.environ['ROS_ROOT']+os.environ['ROS_ROOT']), ('$(optenv ROS_ROOT alternate text)', os.environ['ROS_ROOT']), ('$(optenv NOT_ROS_ROOT)', ''), ('$(optenv NOT_ROS_ROOT)more stuff', 'more stuff'), ('$(optenv NOT_ROS_ROOT alternate)', 'alternate'), ('$(optenv NOT_ROS_ROOT alternate text)', 'alternate text'), # #1776 ('$(anon foo)', 'bar'), ('$(anon foo)/baz', 'bar/baz'), ('$(anon foo)/baz/$(anon foo)', 'bar/baz/bar'), # arg ('$(arg fuga)', 'hoge'), ('$(arg fuga)$(arg fuga)', 'hogehoge'), ('$(arg car)$(arg fuga)', 'cdrhoge'), ('$(arg fuga)hoge', 'hogehoge'), ] for arg, val in tests: assert val == resolve_args(arg, context=context) # more #1776 r = resolve_args('$(anon foo)/bar') assert '/bar' in r assert not '$(anon foo)' in r # test against strings that should not match noop_tests = [ '$(find roslaunch', '$find roslaunch', '', ' ', 'noop', 'find roslaunch', 'env ROS_ROOT', '$$', ')', '(', '()', None, ] for t in noop_tests: assert t == resolve_args(t) failures = [ '$((find roslaunch))', '$(find $roslaunch)', '$(find)', '$(find roslaunch roslaunch)', '$(export roslaunch)', '$(env)', '$(env ROS_ROOT alternate)', '$(env NOT_SET)', '$(optenv)', '$(anon)', '$(anon foo bar)', ] for f in failures: try: resolve_args(f) assert False, "resolve_args(%s) should have failed"%f except SubstitutionException: pass def test_resolve_duplicate_anon(): from roslaunch.config import ROSLaunchConfig from roslaunch.core import RLException from roslaunch.xmlloader import XmlLoader loader = XmlLoader() config = ROSLaunchConfig() test_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'xml')) try: loader.load(os.path.join(test_path, 'test-substitution-duplicate-anon-names.xml'), config) assert False, 'loading a launch file with duplicate anon node names should have raised an exception' except RLException: pass
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/unit/test_roslaunch_parent.py
# Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import os import sys import unittest import time import rospkg import rosgraph.network import roslaunch.parent import rosgraph master = rosgraph.Master('test_roslaunch_parent') def get_param(*args): return master.getParam(*args) ## Fake Process object class ProcessMock(roslaunch.pmon.Process): def __init__(self, package, name, args, env, respawn=False): super(ProcessMock, self).__init__(package, name, args, env, respawn) self.stopped = False def stop(self): self.stopped = True ## Fake ProcessMonitor object class ProcessMonitorMock(object): def __init__(self): self.core_procs = [] self.procs = [] self.listeners = [] self.is_shutdown = False def join(self, timeout=0): pass def add_process_listener(self, l): self.listeners.append(l) def register(self, p): self.procs.append(p) def register_core_proc(self, p): self.core_procs.append(p) def registrations_complete(self): pass def unregister(self, p): self.procs.remove(p) def has_process(self, name): return len([p for p in self.procs if p.name == name]) > 0 def get_process(self, name): val = [p for p in self.procs if p.name == name] if val: return val[0] return None def has_main_thread_jobs(self): return False def do_main_thread_jobs(self): pass def kill_process(self, name): pass def shutdown(self): self.is_shutdown = True def get_active_names(self): return [p.name for p in self.procs] def get_process_names_with_spawn_count(self): actives = [(p.name, p.spawn_count) for p in self.procs] deads = [] return [actives, deads] def mainthread_spin_once(self): pass def mainthread_spin(self): pass def run(self): pass ## Test roslaunch.server class TestRoslaunchParent(unittest.TestCase): def setUp(self): self.pmon = ProcessMonitorMock() def test_roslaunchParent(self): try: self._subroslaunchParent() finally: self.pmon.shutdown() def _subroslaunchParent(self): from roslaunch.parent import ROSLaunchParent pmon = self.pmon try: # if there is a core up, we have to use its run id run_id = get_param('/run_id') except: run_id = 'test-rl-parent-%s'%time.time() name = 'foo-bob' server_uri = 'http://localhost:12345' p = ROSLaunchParent(run_id, [], is_core = True, port=None, local_only=False) self.assertEquals(run_id, p.run_id) self.assertEquals(True, p.is_core) self.assertEquals(False, p.local_only) rl_dir = rospkg.RosPack().get_path('roslaunch') rl_file = os.path.join(rl_dir, 'resources', 'example.launch') self.assert_(os.path.isfile(rl_file)) # validate load_config logic p = ROSLaunchParent(run_id, [rl_file], is_core = False, port=None, local_only=True) self.assertEquals(run_id, p.run_id) self.assertEquals(False, p.is_core) self.assertEquals(True, p.local_only) self.assert_(p.config is None) p._load_config() self.assert_(p.config is not None) self.assert_(p.config.nodes) # try again with port override p = ROSLaunchParent(run_id, [rl_file], is_core = False, port=11312, local_only=True) self.assertEquals(11312, p.port) self.assert_(p.config is None) p._load_config() # - make sure port got passed into master _, port = rosgraph.network.parse_http_host_and_port(p.config.master.uri) self.assertEquals(11312, port) # try again with bad file p = ROSLaunchParent(run_id, ['non-existent-fake.launch']) self.assert_(p.config is None) try: p._load_config() self.fail("load config should have failed due to bad rl file") except roslaunch.core.RLException: pass # try again with bad xml rl_dir = rospkg.RosPack().get_path('roslaunch') rl_file = os.path.join(rl_dir, 'test', 'xml', 'test-params-invalid-1.xml') self.assert_(os.path.isfile(rl_file)) p = ROSLaunchParent(run_id, [rl_file]) self.assert_(p.config is None) try: p._load_config() self.fail("load config should have failed due to bad rl file") except roslaunch.core.RLException: pass # Mess around with internal repr to get code coverage on _init_runner/_init_remote p = ROSLaunchParent(run_id, [], is_core = False, port=None, local_only=True) # no config, _init_runner/_init_remote/_start_server should fail for m in ['_init_runner', '_init_remote', '_start_server']: try: getattr(p, m)() self.fail('should have raised') except roslaunch.core.RLException: pass # - initialize p.config p.config = roslaunch.config.ROSLaunchConfig() # no pm, _init_runner/_init_remote/_start_server should fail for m in ['_init_runner', '_init_remote', '_start_server']: try: getattr(p, m)() self.fail('should have raised') except roslaunch.core.RLException: pass # - initialize p.pm p.pm = pmon for m in ['_init_runner', '_init_remote']: try: getattr(p, m)() self.fail('should have raised') except roslaunch.core.RLException: pass from roslaunch.server import ROSLaunchParentNode p.server = ROSLaunchParentNode(p.config, pmon) p._init_runner() # roslaunch runner should be initialized self.assert_(p.runner is not None) # test _init_remote p.local_only = True p._init_remote() p.local_only = False # - this violates many abstractions to do this def ftrue(): return True p.config.has_remote_nodes = ftrue p._init_remote() self.assert_(p.remote_runner is not None) self.failIf(pmon.is_shutdown) p.shutdown() self.assert_(pmon.is_shutdown) def kill_parent(p, delay=1.0): # delay execution so that whatever pmon method we're calling has time to enter time.sleep(delay) print("stopping parent") p.shutdown()
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/unit/test_nodeprocess.py
#!/usr/bin/env python # Software License Agreement (BSD License) # # Copyright (c) 2009, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import os import sys import unittest import rospkg import roslib.packages import logging logging.getLogger('roslaunch').setLevel(logging.CRITICAL) ## Test roslaunch.nodeprocess class TestNodeprocess(unittest.TestCase): def test_create_master_process(self): from roslaunch.core import Node, Machine, Master, RLException from roslaunch.nodeprocess import create_master_process, LocalProcess ros_root = '/ros/root' port = 1234 type = Master.ROSMASTER run_id = 'foo' # test invalid params try: create_master_process(run_id, type, ros_root, -1) self.fail("shoud have thrown RLException") except RLException: pass try: create_master_process(run_id, type, ros_root, 10000000) self.fail("shoud have thrown RLException") except RLException: pass try: create_master_process(run_id, 'foo', ros_root, port) self.fail("shoud have thrown RLException") except RLException: pass # test valid params p = create_master_process(run_id, type, ros_root, port) self.assert_(isinstance(p, LocalProcess)) self.assertEquals(p.args[0], 'rosmaster') idx = p.args.index('-p') self.failIf(idx < 1) self.assertEquals(p.args[idx+1], str(port)) self.assert_('--core' in p.args) self.assertEquals(p.package, 'rosmaster') p = create_master_process(run_id, type, ros_root, port) # TODO: have to think more as to the correct environment for the master process def test_create_node_process(self): from roslaunch.core import Node, Machine, RLException from roslaunch.node_args import NodeParamsException from roslaunch.nodeprocess import create_node_process, LocalProcess # have to use real ROS configuration for these tests ros_root = os.environ['ROS_ROOT'] rpp = os.environ.get('ROS_PACKAGE_PATH', None) master_uri = 'http://masteruri:1234' m = Machine('name1', ros_root, rpp, '1.2.3.4') run_id = 'id' # test invalid params n = Node('not_a_real_package','not_a_node') n.machine = m n.name = 'foo' try: # should fail b/c node cannot be found create_node_process(run_id, n, master_uri) self.fail("should have failed") except NodeParamsException: pass # have to specify a real node n = Node('rospy','talker.py') n.machine = m try: # should fail b/c n.name is not set create_node_process(run_id, n, master_uri) self.fail("should have failed") except ValueError: pass # have to specify a real node n = Node('rospy','talker.py') n.machine = None n.name = 'talker' try: # should fail b/c n.machine is not set create_node_process(run_id, n, master_uri) self.fail("should have failed") except RLException: pass # basic integration test n.machine = m p = create_node_process(run_id, n, master_uri) self.assert_(isinstance(p, LocalProcess)) # repeat some setup_local_process_env tests d = p.env self.assertEquals(d['ROS_MASTER_URI'], master_uri) self.assertEquals(d['ROS_ROOT'], ros_root) self.assertEquals(d['PYTHONPATH'], os.environ['PYTHONPATH']) if rpp: self.assertEquals(d['ROS_PACKAGE_PATH'], rpp) for k in ['ROS_IP', 'ROS_NAMESPACE']: if k in d: self.fail('%s should not be set: %s'%(k,d[k])) # test package and name self.assertEquals(p.package, 'rospy') # - no 'correct' full answer here self.assert_(p.name.startswith('talker'), p.name) # test log_output n.output = 'log' self.assert_(create_node_process(run_id, n, master_uri).log_output) n.output = 'screen' self.failIf(create_node_process(run_id, n, master_uri).log_output) # test respawn n.respawn = True self.assert_(create_node_process(run_id, n, master_uri).respawn) n.respawn = False self.failIf(create_node_process(run_id, n, master_uri).respawn) # test cwd n.cwd = None self.assertEquals(create_node_process(run_id, n, master_uri).cwd, None) n.cwd = 'ros-root' self.assertEquals(create_node_process(run_id, n, master_uri).cwd, 'ros-root') n.cwd = 'node' self.assertEquals(create_node_process(run_id, n, master_uri).cwd, 'node') # test args # - simplest test (no args) n.args = '' p = create_node_process(run_id, n, master_uri) # - the first arg should be the path to the node executable rospack = rospkg.RosPack() cmd = roslib.packages.find_node('rospy', 'talker.py', rospack)[0] self.assertEquals(p.args[0], cmd) # - test basic args n.args = "arg1 arg2 arg3" p = create_node_process(run_id, n, master_uri) self.assertEquals(p.args[0], cmd) for a in "arg1 arg2 arg3".split(): self.assert_(a in p.args) # - test remap args n.remap_args = [('KEY1', 'VAL1'), ('KEY2', 'VAL2')] p = create_node_process(run_id, n, master_uri) self.assert_('KEY1:=VAL1' in p.args) self.assert_('KEY2:=VAL2' in p.args) # - test __name n = Node('rospy','talker.py') n.name = 'fooname' n.machine = m self.assert_('__name:=fooname' in create_node_process(run_id, n, master_uri).args) # - test substitution args os.environ['SUB_TEST'] = 'subtest' os.environ['SUB_TEST2'] = 'subtest2' n.args = 'foo $(env SUB_TEST) $(env SUB_TEST2)' p = create_node_process(run_id, n, master_uri) self.failIf('SUB_TEST' in p.args) self.assert_('foo' in p.args) self.assert_('subtest' in p.args) self.assert_('subtest2' in p.args) def test__cleanup_args(self): # #1595 from roslaunch.nodeprocess import _cleanup_remappings args = [ 'ROS_PACKAGE_PATH=foo', '/home/foo/monitor', '__log:=/home/pr2/21851/ros-0.7.2/log/8d769688-897d-11de-8e93-00238bdfe0ab/monitor-3.log', '__name:=bar', '__log:=/home/pr2/21851/ros-0.7.2/log/8d769688-897d-11de-8e93-00238bdfe0ab/monitor-3.log', 'topic:=topic2', '__log:=/home/pr2/21851/ros-0.7.2/log/8d769688-897d-11de-8e93-00238bdfe0ab/monitor-3.log', '__log:=/home/pr2/21851/ros-0.7.2/log/8d769688-897d-11de-8e93-00238bdfe0ab/monitor-3.log', '__log:=/home/pr2/21851/ros-0.7.2/log/8d769688-897d-11de-8e93-00238bdfe0ab/monitor-3.log', '__log:=/home/pr2/21851/ros-0.7.2/log/8d769688-897d-11de-8e93-00238bdfe0ab/monitor-3.log', '__log:=/home/pr2/21851/ros-0.7.2/log/8d769688-897d-11de-8e93-00238bdfe0ab/monitor-3.log'] clean_args = [ 'ROS_PACKAGE_PATH=foo', '/home/foo/monitor', '__name:=bar', 'topic:=topic2'] self.assertEquals([], _cleanup_remappings([], '__log:=')) self.assertEquals(clean_args, _cleanup_remappings(args, '__log:=')) self.assertEquals(clean_args, _cleanup_remappings(clean_args, '__log:=')) self.assertEquals(args, _cleanup_remappings(args, '_foo')) def test__next_counter(self): from roslaunch.nodeprocess import _next_counter x = _next_counter() y = _next_counter() self.assert_(x +1 == y) self.assert_(x > 0) def test_create_master_process2(self): # accidentally wrote two versions of this, need to merge from roslaunch.core import Master, RLException import rospkg from roslaunch.nodeprocess import create_master_process ros_root = rospkg.get_ros_root() # test failures failed = False try: create_master_process('runid-unittest', Master.ROSMASTER, rospkg.get_ros_root(), 0) failed = True except RLException: pass self.failIf(failed, "invalid port should have triggered error") # test success with ROSMASTER m1 = create_master_process('runid-unittest', Master.ROSMASTER, ros_root, 1234) self.assertEquals('runid-unittest', m1.run_id) self.failIf(m1.started) self.failIf(m1.stopped) self.assertEquals(None, m1.cwd) self.assertEquals('master', m1.name) master_p = 'rosmaster' self.assert_(master_p in m1.args) # - it should have the default environment self.assertEquals(os.environ, m1.env) # - check args self.assert_('--core' in m1.args) # - make sure port arguent is correct idx = m1.args.index('-p') self.assertEquals('1234', m1.args[idx+1]) # test port argument m2 = create_master_process('runid-unittest', Master.ROSMASTER, ros_root, 1234) self.assertEquals('runid-unittest', m2.run_id) # test ros_root argument m3 = create_master_process('runid-unittest', Master.ROSMASTER, ros_root, 1234) self.assertEquals('runid-unittest', m3.run_id) master_p = 'rosmaster' self.assert_(master_p in m3.args)
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/unit/test_roslaunch_param_dump.py
# Software License Agreement (BSD License) # # Copyright (c) 2012, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import os import sys try: from cStringIO import StringIO except ImportError: from io import StringIO from contextlib import contextmanager @contextmanager def fakestdout(): realstdout = sys.stdout fakestdout = StringIO() sys.stdout = fakestdout yield fakestdout sys.stdout = realstdout import rospkg import logging SAMPLE1 = """/rosparam_load/dict1/head: 1 /rosparam_load/dict1/knees: 3 /rosparam_load/dict1/shoulders: 2 /rosparam_load/dict1/toes: 4 /rosparam_load/integer1: 1 /rosparam_load/integer2: 2 /rosparam_load/list1: [head, shoulders, knees, toes] /rosparam_load/list2: [1, 1, 2, 3, 5, 8] /rosparam_load/preformattedtext: 'This is the first line This is the second line Line breaks are preserved Indentation is stripped ' /rosparam_load/robots/child/grandchildparam: a grandchild namespace param /rosparam_load/robots/childparam: a child namespace parameter /rosparam_load/string1: bar /rosparam_load/string2: '10'""" SAMPLE2 = """/load_ns/subns/dict1/head: 1 /load_ns/subns/dict1/knees: 3 /load_ns/subns/dict1/shoulders: 2 /load_ns/subns/dict1/toes: 4 /load_ns/subns/integer1: 1 /load_ns/subns/integer2: 2 /load_ns/subns/list1: [head, shoulders, knees, toes] /load_ns/subns/list2: [1, 1, 2, 3, 5, 8] /load_ns/subns/preformattedtext: 'This is the first line This is the second line Line breaks are preserved Indentation is stripped ' /load_ns/subns/robots/child/grandchildparam: a grandchild namespace param /load_ns/subns/robots/childparam: a child namespace parameter /load_ns/subns/string1: bar /load_ns/subns/string2: '10'""" def test_dump_params(): # normal entrypoint has logging configured logger = logging.getLogger('roslaunch').setLevel(logging.CRITICAL) from roslaunch.param_dump import dump_params roslaunch_d = rospkg.RosPack().get_path('roslaunch') test_d = os.path.join(roslaunch_d, 'test', 'xml') node_rosparam_f = os.path.join(test_d, 'test-node-rosparam-load.xml') with fakestdout() as b: assert dump_params([node_rosparam_f]) s = b.getvalue().strip() # remove float vals as serialization is not stable s = '\n'.join([x for x in s.split('\n') if not 'float' in x]) assert str(s) == str(SAMPLE1), "[%s]\nvs\n[%s]"%(s, SAMPLE1) node_rosparam_f = os.path.join(test_d, 'test-node-rosparam-load-ns.xml') with fakestdout() as b: assert dump_params([node_rosparam_f]) s = b.getvalue().strip() # remove float vals as serialization is not stable s = '\n'.join([x for x in s.split('\n') if not 'float' in x]) assert str(s) == str(SAMPLE2), "[%s]\nvs\n[%s]"%(s, SAMPLE2) invalid_f = os.path.join(test_d, 'invalid-xml.xml') with fakestdout() as b: assert not dump_params([invalid_f])
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/unit/test_roslaunch_depends.py
# Software License Agreement (BSD License) # # Copyright (c) 2012, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import os import sys import rospkg class Foo: pass def test_RoslaunchDeps(): from roslaunch.depends import RoslaunchDeps min_deps = RoslaunchDeps(nodes=[('rospy', 'talker.py')], pkgs=['rospy']) assert min_deps == min_deps assert min_deps == RoslaunchDeps(nodes=[('rospy', 'talker.py')], pkgs=['rospy']) assert not min_deps.__eq__(Foo()) assert Foo() != min_deps assert min_deps != RoslaunchDeps(nodes=[('rospy', 'talker.py')]) assert min_deps != RoslaunchDeps(pkgs=['rospy']) assert 'talker.py' in repr(min_deps) assert 'talker.py' in str(min_deps) try: from cStringIO import StringIO except ImportError: from io import StringIO from contextlib import contextmanager @contextmanager def fakestdout(): realstdout = sys.stdout fakestdout = StringIO() sys.stdout = fakestdout yield fakestdout sys.stdout = realstdout def test_roslaunch_deps_main(): from roslaunch.depends import roslaunch_deps_main roslaunch_d = rospkg.RosPack().get_path('roslaunch') rosmaster_d = rospkg.RosPack().get_path('rosmaster') f = os.path.join(roslaunch_d, 'resources', 'example.launch') rosmaster_f = os.path.join(rosmaster_d, 'test', 'rosmaster.test') invalid_f = os.path.join(roslaunch_d, 'test', 'xml', 'invalid-xml.xml') not_f = os.path.join(roslaunch_d, 'test', 'xml', 'not-launch.xml') with fakestdout() as b: roslaunch_deps_main(['roslaunch-deps', f]) s = b.getvalue() assert s.strip() == 'rospy', "buffer value [%s]"%(s) with fakestdout() as b: roslaunch_deps_main(['roslaunch-deps', f, '--warn']) s = b.getvalue() assert s.strip() == """Dependencies: rospy Missing declarations: roslaunch/manifest.xml: <depend package="rospy" />""", s # tripwire, don't really care about exact verbose output with fakestdout() as b: roslaunch_deps_main(['roslaunch-deps', f, '--verbose']) # try with no file with fakestdout() as b: try: roslaunch_deps_main(['roslaunch-deps']) assert False, "should have failed" except SystemExit: pass # try with non-existent file with fakestdout() as b: try: roslaunch_deps_main(['roslaunch-deps', 'fakefile', '--verbose']) assert False, "should have failed" except SystemExit: pass # try with bad file with fakestdout() as b: try: roslaunch_deps_main(['roslaunch-deps', invalid_f, '--verbose']) assert False, "should have failed: %s"%b.getvalue() except SystemExit: pass with fakestdout() as b: try: roslaunch_deps_main(['roslaunch-deps', not_f, '--verbose']) assert False, "should have failed: %s"%b.getvalue() except SystemExit: pass # try with files from different pacakges with fakestdout() as b: try: roslaunch_deps_main(['roslaunch-deps', f, rosmaster_f, '--verbose']) assert False, "should have failed" except SystemExit: pass def test_roslaunch_deps(): from roslaunch.depends import roslaunch_deps, RoslaunchDeps example_d = os.path.join(rospkg.RosPack().get_path('roslaunch'), 'resources') min_deps = RoslaunchDeps(nodes=[('rospy', 'talker.py')], pkgs=['rospy']) include_deps = RoslaunchDeps(nodes=[('rospy', 'talker.py'), ('rospy', 'listener.py')], pkgs=['rospy']) example_deps = RoslaunchDeps(nodes=[('rospy', 'talker.py'), ('rospy', 'listener.py')], pkgs=['rospy'], includes=[os.path.join(example_d, 'example-include.launch')]) example_file_deps = { os.path.join(example_d, 'example.launch') : example_deps, os.path.join(example_d, 'example-include.launch') : include_deps, } example_min_file_deps = { os.path.join(example_d, 'example-min.launch') : min_deps, } r_missing = {'roslaunch': set(['rospy'])} tests = [ ([os.path.join(example_d, 'example-min.launch')], ('roslaunch', example_min_file_deps, r_missing)), ([os.path.join(example_d, 'example.launch')], ('roslaunch', example_file_deps, r_missing)), ] for files, results in tests: for v in [True, False]: base_pkg, file_deps, missing = roslaunch_deps(files, verbose=v) assert base_pkg == results[0] assert file_deps == results[1], "\n%s vs \n%s"%(file_deps, results[1]) assert missing == results[2], "\n%s vs \n%s"%(missing, results[2])
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/unit/test_core.py
#!/usr/bin/env python # Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. NAME = 'test_core' import os import sys import unittest import rospkg _lastmsg = None def printlog_cb(msg): global _lastmsg _lastmsg = msg def printlog_cb_exception(msg): raise Exception(msg) ## Test roslaunch.core class TestCore(unittest.TestCase): def test_xml_escape(self): from roslaunch.core import _xml_escape self.assertEquals('', _xml_escape('')) self.assertEquals(' ', _xml_escape(' ')) self.assertEquals('&quot;', _xml_escape('"')) self.assertEquals('&quot;hello world&quot;', _xml_escape('"hello world"')) self.assertEquals('&gt;', _xml_escape('>')) self.assertEquals('&lt;', _xml_escape('<')) self.assertEquals('&amp;', _xml_escape('&')) self.assertEquals('&amp;amp;', _xml_escape('&amp;')) self.assertEquals('&amp;&quot;&gt;&lt;&quot;', _xml_escape('&"><"')) def test_child_mode(self): from roslaunch.core import is_child_mode, set_child_mode set_child_mode(False) self.failIf(is_child_mode()) set_child_mode(True) self.assert_(is_child_mode()) set_child_mode(False) self.failIf(is_child_mode()) def test_printlog(self): from roslaunch.core import add_printlog_handler, add_printerrlog_handler, printlog, printlog_bold, printerrlog add_printlog_handler(printlog_cb) add_printlog_handler(printlog_cb_exception) add_printerrlog_handler(printlog_cb) add_printerrlog_handler(printlog_cb_exception) #can't really test functionality, just make sure it doesn't crash global _lastmsg _lastmsg = None printlog('foo') self.assertEquals('foo', _lastmsg) printlog_bold('bar') self.assertEquals('bar', _lastmsg) printerrlog('baz') self.assertEquals('baz', _lastmsg) def test_setup_env(self): from roslaunch.core import setup_env, Node, Machine master_uri = 'http://masteruri:1234' n = Node('nodepkg','nodetype') m = Machine('name1', '1.2.3.4') d = setup_env(n, m, master_uri) self.assertEquals(d['ROS_MASTER_URI'], master_uri) m = Machine('name1', '1.2.3.4') d = setup_env(n, m, master_uri) val = os.environ['ROS_ROOT'] self.assertEquals(d['ROS_ROOT'], val) # test ROS_NAMESPACE # test stripping n = Node('nodepkg','nodetype', namespace="/ns2/") d = setup_env(n, m, master_uri) self.assertEquals(d['ROS_NAMESPACE'], "/ns2") # test node.env_args n = Node('nodepkg','nodetype', env_args=[('NENV1', 'val1'), ('NENV2', 'val2'), ('ROS_ROOT', '/new/root')]) d = setup_env(n, m, master_uri) self.assertEquals(d['ROS_ROOT'], "/new/root") self.assertEquals(d['NENV1'], "val1") self.assertEquals(d['NENV2'], "val2") def test_local_machine(self): try: env_copy = os.environ.copy() from roslaunch.core import local_machine lm = local_machine() self.failIf(lm is None) #singleton self.assert_(lm == local_machine()) self.assertEquals(lm.name, '') self.assertEquals(lm.assignable, True) self.assertEquals(lm.env_loader, None) self.assertEquals(lm.user, None) self.assertEquals(lm.password, None) finally: os.environ = env_copy def test_Master(self): from roslaunch.core import Master old_env = os.environ.get('ROS_MASTER_URI', None) try: os.environ['ROS_MASTER_URI'] = 'http://foo:789' m = Master() self.assertEquals(m.type, Master.ROSMASTER) self.assertEquals(m.uri, 'http://foo:789') self.assertEquals(m, m) self.assertEquals(m, Master()) m = Master(Master.ROSMASTER, 'http://foo:1234') self.assertEquals(m.type, Master.ROSMASTER) self.assertEquals(m.uri, 'http://foo:1234') self.assertEquals(m, m) self.assertEquals(m, Master(Master.ROSMASTER, 'http://foo:1234')) try: from xmlrpc.client import ServerProxy except ImportError: from xmlrpclib import ServerProxy self.assert_(isinstance(m.get(), ServerProxy)) m.uri = 'http://foo:567' self.assertEquals(567, m.get_port()) self.failIf(m.is_running()) finally: if old_env is None: del os.environ['ROS_MASTER_URI'] else: os.environ['ROS_MASTER_URI'] = old_env def test_Executable(self): from roslaunch.core import Executable, PHASE_SETUP, PHASE_RUN, PHASE_TEARDOWN e = Executable('ls', ['-alF']) self.assertEquals('ls', e.command) self.assertEquals(['-alF'], e.args) self.assertEquals(PHASE_RUN, e.phase) self.assertEquals('ls -alF', str(e)) self.assertEquals('ls -alF', repr(e)) e = Executable('ls', ['-alF', 'b*'], PHASE_TEARDOWN) self.assertEquals('ls', e.command) self.assertEquals(['-alF', 'b*'], e.args) self.assertEquals(PHASE_TEARDOWN, e.phase) self.assertEquals('ls -alF b*', str(e)) self.assertEquals('ls -alF b*', repr(e)) def test_RosbinExecutable(self): from roslaunch.core import RosbinExecutable, PHASE_SETUP, PHASE_RUN, PHASE_TEARDOWN e = RosbinExecutable('ls', ['-alF']) self.assertEquals('ls', e.command) self.assertEquals(['-alF'], e.args) self.assertEquals(PHASE_RUN, e.phase) self.assertEquals('ros/bin/ls -alF', str(e)) self.assertEquals('ros/bin/ls -alF', repr(e)) e = RosbinExecutable('ls', ['-alF', 'b*'], PHASE_TEARDOWN) self.assertEquals('ls', e.command) self.assertEquals(['-alF', 'b*'], e.args) self.assertEquals(PHASE_TEARDOWN, e.phase) self.assertEquals('ros/bin/ls -alF b*', str(e)) self.assertEquals('ros/bin/ls -alF b*', repr(e))
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/unit/test_xmlloader.py
#!/usr/bin/env python # Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import os import sys import unittest import roslaunch.loader import roslaunch.xmlloader def get_test_path(): return os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'xml')) # path to example.launch directory def get_example_path(): return os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'resources')) ## Fake RosLaunch object class RosLaunchMock(object): def __init__(self): self.nodes_core = [] self.nodes = [] self.tests = [] self.params = [] self.executables = [] self.clear_params = [] self.machines = [] self.master = None self.config_errors = [] self.roslaunch_files = [] def set_master(self, m): self.master = m def add_machine(self, m, verbose=True): self.machines.append(m) def add_roslaunch_file(self, f): self.roslaunch_files.append(f) def add_node(self, n, core=False, verbose=True): if not core: self.nodes.append(n) else: self.nodes_core.append(n) def add_config_error(self, msg): self.config_errors.append(msg) def add_test(self, t, verbose=True): self.tests.append(t) def add_executable(self, t): self.executables.append(t) def add_param(self, p, filename=None, verbose=True): matches = [x for x in self.params if x.key == p.key] for m in matches: self.params.remove(m) self.params.append(p) def add_clear_param(self, param): self.clear_params.append(param) ## Test Roslaunch XML parser class TestXmlLoader(unittest.TestCase): def setUp(self): self.xml_dir = get_test_path() def _load(self, test_file): loader = roslaunch.xmlloader.XmlLoader() mock = RosLaunchMock() self.assert_(os.path.exists(test_file), "cannot locate test file %s"%test_file) loader.load(test_file, mock) return mock def _load_valid_nodes(self, tests): mock = self._load(os.path.join(self.xml_dir, 'test-node-valid.xml')) nodes = [n for n in mock.nodes if n.type in tests] self.assertEquals(len(tests), len(nodes)) return nodes def _load_valid_rostests(self, tests): mock = self._load(os.path.join(self.xml_dir, 'test-test-valid.xml')) nodes = [n for n in mock.tests if n.type in tests] self.assertEquals(len(tests), len(nodes)) return nodes def _load_valid_machines(self, tests): mock = self._load(os.path.join(self.xml_dir, 'test-machine-valid.xml')) machines = [m for m in mock.machines if m.name in tests] self.assertEquals(len(tests), len(machines)) return machines def test_load_string(self): # make sure load_string isn't broken loader = roslaunch.xmlloader.XmlLoader() mock = RosLaunchMock() # test with no <launch /> element # #1582: test error message as well try: loader.load_string('<foo />', mock) self.fail("no root lauch element passed") except Exception as e: self.assertEquals(str(e), "Invalid roslaunch XML syntax: no root <launch> tag") f = open(os.path.join(self.xml_dir, 'test-node-valid.xml'), 'r') try: s = f.read() finally: f.close() loader.load_string(s, mock) # sanity check self.assert_(mock.nodes) self.assert_([n for n in mock.nodes if n.type == 'test_base']) # check exception case f = open(os.path.join(self.xml_dir, 'invalid-xml.xml'), 'r') try: s = f.read() finally: f.close() try: loader.load_string(s, mock) self.fail('load_string should have thrown an exception') except roslaunch.xmlloader.XmlParseException: pass def test_load(self): # make sure load isn't broken loader = roslaunch.xmlloader.XmlLoader() # test against empty data loader.load(os.path.join(self.xml_dir, 'test-valid.xml'), RosLaunchMock()) # sanity check with real data mock = RosLaunchMock() loader.load(os.path.join(self.xml_dir, 'test-node-valid.xml'), mock) self.assert_(mock.nodes) self.assert_([n for n in mock.nodes if n.type == 'test_base']) # check exception case try: loader.load(os.path.join(self.xml_dir, 'invalid-xml.xml'), mock) self.fail('load_string should have thrown an exception') except roslaunch.xmlloader.XmlParseException: pass def test_params_invalid(self): tests = ['test-params-invalid-%s.xml'%i for i in range(1, 6)] loader = roslaunch.xmlloader.XmlLoader() for filename in tests: filename = os.path.join(self.xml_dir, filename) try: self.assert_(os.path.exists(filename)) loader.load(filename, RosLaunchMock()) self.fail("xmlloader did not throw an xmlparseexception for [%s]"%filename) except roslaunch.xmlloader.XmlParseException: pass except roslaunch.loader.LoadException: pass def test_params(self): mock = self._load(os.path.join(self.xml_dir, 'test-params-valid.xml')) param_d = {} for p in mock.params: param_d[p.key] = p.value self.assertEquals('pass', param_d['/override']) self.assertEquals('bar2', param_d['/somestring1']) self.assertEquals('10', param_d['/somestring2']) self.assertEquals(1, param_d['/someinteger1']) self.assertEquals(2, param_d['/someinteger2']) self.assertAlmostEquals(3.14159, param_d['/somefloat1'], 2) self.assertAlmostEquals(5.0, param_d['/somefloat2'], 1) self.assertEquals("a child namespace parameter 1", param_d['/wg/wgchildparam'], p.value) self.assertEquals("a child namespace parameter 2", param_d['/wg2/wg2childparam1'], p.value) self.assertEquals("a child namespace parameter 3", param_d['/wg2/wg2childparam2'], p.value) try: from xmlrpc.client import Binary except ImportError: from xmlrpclib import Binary f = open(os.path.join(get_example_path(), 'example.launch')) try: contents = f.read() finally: f.close() p = [p for p in mock.params if p.key == '/configfile'][0] self.assertEquals(contents, p.value, 1) p = [p for p in mock.params if p.key == '/binaryfile'][0] self.assertEquals(Binary(contents), p.value, 1) f = open(os.path.join(get_example_path(), 'example.launch')) try: contents = f.read() finally: f.close() p = [p for p in mock.params if p.key == '/commandoutput'][0] self.assertEquals(contents, p.value, 1) def test_rosparam_valid(self): mock = self._load(os.path.join(self.xml_dir, 'test-rosparam-valid.xml')) for prefix in ['', '/rosparam', '/node_rosparam']: p = [p for p in mock.params if p.key == prefix+'/string1'][0] self.assertEquals('bar', p.value) p = [p for p in mock.params if p.key == prefix+'/robots/childparam'][0] self.assertEquals('a child namespace parameter', p.value) p = [p for p in mock.params if p.key == '/node_rosparam/string1'][0] self.assertEquals('bar', p.value) p = [p for p in mock.params if p.key == '/node_rosparam/robots/childparam'][0] self.assertEquals('a child namespace parameter', p.value) exes = [e for e in mock.executables if e.command == 'rosparam'] self.assertEquals(len(exes), 2, "expected 2 rosparam exes, got %s"%len(exes)) from roslaunch.core import PHASE_SETUP for e in exes: self.assertEquals(PHASE_SETUP, e.phase) args = e.args self.assertEquals(3, len(args), "expected 3 args, got %s"%str(args)) rp_cmd, rp_file, rp_ctx = args self.failIf('$(find' in rp_file, "file attribute was not evaluated") self.assertEquals('dump', rp_cmd) # verify that the context is passed in correctly if rp_file.endswith('dump.yaml'): self.assertEquals('/', rp_ctx) elif rp_file.endswith('dump2.yaml'): self.assertEquals('/rosparam/', rp_ctx) # test inline yaml examples p = [p for p in mock.params if p.key == '/inline_str'][0] self.assertEquals('value1', p.value) p = [p for p in mock.params if p.key == '/inline_list'][0] self.assertEquals([1, 2, 3, 4], p.value) p = [p for p in mock.params if p.key == '/inline_dict/key1'][0] self.assertEquals('value1', p.value) p = [p for p in mock.params if p.key == '/inline_dict/key2'][0] self.assertEquals('value2', p.value) p = [p for p in mock.params if p.key == '/inline_dict2/key3'][0] self.assertEquals('value3', p.value) p = [p for p in mock.params if p.key == '/inline_dict2/key4'][0] self.assertEquals('value4', p.value) # verify that later tags override # - key2 is overriden self.assertEquals(1, len([p for p in mock.params if p.key == '/override/key1'])) p = [p for p in mock.params if p.key == '/override/key1'][0] self.assertEquals('override1', p.value) # - key2 is not overriden p = [p for p in mock.params if p.key == '/override/key2'][0] self.assertEquals('value2', p.value) # verify that 'param' attribute is not required p = [p for p in mock.params if p.key == '/noparam1'][0] self.assertEquals('value1', p.value) p = [p for p in mock.params if p.key == '/noparam2'][0] self.assertEquals('value2', p.value) # #3580: test degree/rad conversions import math p = [p for p in mock.params if p.key == '/inline_degrees0'][0] self.assertAlmostEquals(0, p.value) p = [p for p in mock.params if p.key == '/inline_degrees180'][0] self.assertAlmostEquals(p.value, math.pi) p = [p for p in mock.params if p.key == '/inline_degrees360'][0] self.assertAlmostEquals(p.value, 2 * math.pi) p = [p for p in mock.params if p.key == '/dict_degrees/deg0'][0] self.assertAlmostEquals(0, p.value) p = [p for p in mock.params if p.key == '/dict_degrees/deg180'][0] self.assertAlmostEquals(p.value, math.pi) p = [p for p in mock.params if p.key == '/dict_degrees/deg360'][0] self.assertAlmostEquals(p.value, 2 * math.pi) p = [p for p in mock.params if p.key == '/inline_rad0'][0] self.assertAlmostEquals(0, p.value) p = [p for p in mock.params if p.key == '/inline_radpi'][0] self.assertAlmostEquals(p.value, math.pi) p = [p for p in mock.params if p.key == '/inline_rad2pi'][0] self.assertAlmostEquals(p.value, 2 * math.pi) p = [p for p in mock.params if p.key == '/dict_rad/rad0'][0] self.assertAlmostEquals(0, p.value) p = [p for p in mock.params if p.key == '/dict_rad/radpi'][0] self.assertAlmostEquals(p.value, math.pi) p = [p for p in mock.params if p.key == '/dict_rad/rad2pi'][0] self.assertAlmostEquals(p.value, 2 * math.pi) # rosparam file also contains empty params mock = self._load(os.path.join(self.xml_dir, 'test-rosparam-empty.xml')) self.assertEquals([], mock.params) def test_rosparam_invalid(self): tests = ['test-rosparam-invalid-%s.xml'%i for i in range(1, 6)] loader = roslaunch.xmlloader.XmlLoader() for filename in tests: filename = os.path.join(self.xml_dir, filename) try: self.assert_(os.path.exists(filename)) loader.load(filename, RosLaunchMock()) self.fail("xmlloader did not throw an xmlloadexception for [%s]"%filename) except roslaunch.loader.LoadException: pass def test_node_valid(self): nodes = self._load_valid_nodes([]) def test_rostest_valid(self): nodes = self._load_valid_rostests([]) def test_node_rosparam_invalid(self): tests = ['test-node-rosparam-invalid-name.xml'] loader = roslaunch.xmlloader.XmlLoader() for filename in tests: filename = os.path.join(self.xml_dir, filename) try: self.assert_(os.path.exists(filename)) loader.load(filename, RosLaunchMock()) self.fail("xmlloader did not throw an xmlparseexception for [%s]"%filename) except roslaunch.xmlloader.XmlParseException: pass def test_node_rosparam(self): from roslaunch.core import PHASE_SETUP tests = [("test-node-rosparam-load.xml", "test_node_rosparam_load"), ("test-node-rosparam-dump.xml","test_node_rosparam_dump"), ("test-node-rosparam-delete.xml","test_node_rosparam_delete"), ("test-node-rosparam-load-multi.xml", "test_node_rosparam_multi"), ("test-node-rosparam-load-param.xml", "test_node_rosparam_load_param"), ("test-node-rosparam-load-ns.xml", "test_node_rosparam_load_ns")] for f, test in tests: mock = self._load(os.path.join(self.xml_dir, f)) nodes = [n for n in mock.nodes if n.type == test] self.assertEquals(1, len(nodes)) n = nodes[0] exes = [e for e in mock.executables if e.command == 'rosparam'] if n.type == "test_node_rosparam_load": self.assertEquals(0, len(exes)) p = [p for p in mock.params if p.key == '/rosparam_load/string1'][0] self.assertEquals('bar', p.value) p = [p for p in mock.params if p.key == '/rosparam_load/robots/childparam'][0] self.assertEquals('a child namespace parameter', p.value) elif n.type == "test_node_rosparam_delete": self.assertEquals(1, len(exes)) self.assert_(len(exes[0].args) == 2, "invalid arg: %s"%(str(exes[0].args))) rp_cmd, rp_param = exes[0].args self.assertEquals("delete", rp_cmd) self.assertEquals("/ns1/rosparam_delete/ns2/param", rp_param) elif n.type == "test_node_rosparam_dump": self.assertEquals(1, len(exes)) rp_cmd, rp_file, rp_ctx = exes[0].args self.assertEquals("dump", rp_cmd) self.assertEquals("dump.yaml", rp_file) self.assertEquals('/rosparam_dump/', rp_ctx) elif n.type == "test_node_rosparam_load_ns": self.assertEquals(0, len(exes)) p = [p for p in mock.params if p.key == '/load_ns/subns/string1'][0] self.assertEquals('bar', p.value) p = [p for p in mock.params if p.key == '/load_ns/subns/robots/childparam'][0] self.assertEquals('a child namespace parameter', p.value) elif n.type == "test_node_rosparam_load_param": self.assertEquals(0, len(exes)) p = [p for p in mock.params if p.key == '/load_param/param/string1'][0] self.assertEquals('bar', p.value) p = [p for p in mock.params if p.key == '/load_param/param/robots/childparam'][0] self.assertEquals('a child namespace parameter', p.value) elif n.type == "test_node_rosparam_multi": self.assertEquals(1, len(exes)) e = exes[0] rp_cmd, rp_file, rp_ctx = e.args self.assertEquals("dump", rp_cmd) self.assertEquals("mdump.yaml", rp_file) self.assertEquals('/rosparam_multi/', rp_ctx) # test two other rosparam tags p = [p for p in mock.params if p.key == '/rosparam_multi/string1'][0] self.assertEquals('bar', p.value) p = [p for p in mock.params if p.key == '/rosparam_multi/robots/childparam'][0] self.assertEquals('a child namespace parameter', p.value) p = [p for p in mock.params if p.key == '/rosparam_multi/msubns/string1'][0] self.assertEquals('bar', p.value) p = [p for p in mock.params if p.key == '/rosparam_multi/msubns/robots/childparam'][0] self.assertEquals('a child namespace parameter', p.value) ## test that ~params in groups get applied to later members of group def test_local_param_group(self): mock = self._load(os.path.join(self.xml_dir, 'test-local-param-group.xml')) correct = [ u'/group1/g1node1/gparam1', u'/group1/g1node2/gparam1', u'/group1/g1node2/gparam2', u'/node1/param1', ] p_names = [p.key for p in mock.params] self.assertEquals(set([]), set(correct) ^ set(p_names), "%s does not match %s"%(p_names, correct)) def test_node_param(self): mock = self._load(os.path.join(self.xml_dir, 'test-node-valid.xml')) tests = [('/test_private_param1/foo1', 'bar1'), ('/ns_test/test_private_param2/foo2', 'bar2'), ('/test_private_param3/foo3', 'bar3'), ] for k, v in tests: p = [p for p in mock.params if p.key == k] self.assertEquals(1, len(p), "%s not present in parameters: %s"%(k, mock.params)) self.assertEquals(v, p[0].value) node_types = [n.type for n in mock.nodes] def test_roslaunch_files(self): f = os.path.join(self.xml_dir, 'test-env.xml') f2 = os.path.join(self.xml_dir, 'test-env-include.xml') mock = self._load(f) mock_files = [os.path.realpath(x) for x in mock.roslaunch_files] actual_files = [os.path.realpath(x) for x in [f, f2]] self.assertEquals(len(set(actual_files)), len(set(mock_files))) def test_launch_prefix(self): nodes = self._load_valid_nodes(['test_launch_prefix']) self.assertEquals(1, len(nodes)) self.assertEquals('xterm -e gdb --args', nodes[0].launch_prefix) nodes = self._load_valid_nodes(['test_base']) self.assertEquals(1, len(nodes)) self.assertEquals(None, nodes[0].launch_prefix) def test_respawn(self): tests = ["test_respawn_true", "test_respawn_TRUE", "test_respawn_false", "test_respawn_FALSE", "test_respawn_none",] respawn_nodes = self._load_valid_nodes(tests) self.assertEquals(len(tests), len(respawn_nodes)) for n in respawn_nodes: if n.type in ['test_respawn_true', 'test_respawn_TRUE']: self.assertEquals(True, n.respawn, "respawn for [%s] should be True"%n.type) else: self.assertEquals(False, n.respawn, "respawn for [%s] should be False"%n.type) def test_env_and_include(self): mock = self._load(os.path.join(self.xml_dir, 'test-env.xml')) expected = ['test_none', 'test_one', 'test_one_two', 'test_one_two_priv', 'test_one_two_include',] self.assertEquals(set(expected), set([n.type for n in mock.nodes])) for n in mock.nodes: if n.type == 'test_none': self.assertEquals([], n.env_args) elif n.type == 'test_one': self.assertEquals([("ONE", "one")], n.env_args) elif n.type == 'test_one_two': self.assert_(("ONE", "one") in n.env_args) self.assert_(("TWO", "two") in n.env_args) elif n.type == 'test_one_two_priv': self.assert_(("ONE", "one") in n.env_args) self.assert_(("TWO", "two") in n.env_args) self.assert_(("PRIVATE_TWO", "private_two") in n.env_args) elif n.type == 'test_one_two_include': self.assert_(("ONE", "one") in n.env_args) self.assert_(("TWO", "two") in n.env_args) self.assert_(("INCLUDE", "include") in n.env_args) def test_clear_params(self): true_tests = ["/test_clear_params1/","/test_clear_params2/", "/clear_params_ns/test_clear_params_ns/", "/group_test/","/embed_group_test/embedded_group/", "/include_test/", ] mock = self._load(os.path.join(self.xml_dir, 'test-clear-params.xml')) self.assertEquals(len(true_tests), len(mock.clear_params), "clear params did not match expected true: %s"%(str(mock.clear_params))) for t in true_tests: self.assert_(t in mock.clear_params, "%s was not marked for clear: %s"%(t, mock.clear_params)) def test_clear_params_invalid(self): tests = ['test-clear-params-invalid-1.xml', 'test-clear-params-invalid-2.xml', 'test-clear-params-invalid-3.xml','test-clear-params-invalid-4.xml',] loader = roslaunch.xmlloader.XmlLoader() for filename in tests: filename = os.path.join(self.xml_dir, filename) try: self.assert_(os.path.exists(filename)) loader.load(filename, RosLaunchMock()) self.fail("xmlloader did not throw an xmlparseexception for [%s]"%filename) except roslaunch.xmlloader.XmlParseException: pass def _subtest_node_base(self, nodes): node = nodes[0] self.assertEquals("package", node.package) self.assertEquals("test_base", node.type) def test_node_base(self): self._subtest_node_base(self._load_valid_nodes(['test_base'])) tests = self._load_valid_rostests(['test_base']) self._subtest_node_base(tests) self.assertEquals('test1', tests[0].test_name) self.assertEquals(roslaunch.core.TEST_TIME_LIMIT_DEFAULT, tests[0].time_limit) def _subtest_node_args(self, nodes): for n in nodes: if n.type == 'test_args': self.assertEquals("args test", n.args) elif n.type == 'test_args_empty': self.assertEquals("", n.args) def test_node_args(self): self._subtest_node_args(self._load_valid_nodes(['test_args', 'test_args_empty'])) tests = self._load_valid_rostests(['test_args', 'test_args_empty']) self._subtest_node_args(tests) for n in tests: if n.type == 'test_args': self.assertEquals("test2", n.test_name) elif n.type == 'test_args_empty': self.assertEquals("test3", n.test_name) def test_rostest_time_limit(self): tests = self._load_valid_rostests(['test_time_limit_int_1', 'test_time_limit_float_10_1']) for n in tests: if n.type == 'test_time_limit_int_1': self.assertAlmostEquals(1.0, n.time_limit, 3) elif n.type == 'test_time_limit_float_10_1': self.assertAlmostEquals(10.1, n.time_limit, 3) def test_rostest_retry(self): n = self._load_valid_rostests(['test_retry'])[0] self.assertEquals(2, n.retry) def test_node_cwd(self): nodes = self._load_valid_nodes(['test_base', 'test_cwd_2', 'test_cwd_3', 'test_cwd_4']) for n in nodes: if n.type == 'test_base': self.assertEquals(None, n.cwd) elif n.type == 'test_cwd_2': self.assertEquals("node", n.cwd) elif n.type in ['test_cwd_3', 'test_cwd_4']: self.assertEquals("ROS_HOME", n.cwd) def test_node_output(self): nodes = self._load_valid_nodes(['test_output_log', 'test_output_screen']) for n in nodes: if n.type == 'test_output_log': self.assertEquals("log", n.output) elif n.type == 'test_output_screen': self.assertEquals("screen", n.output) def test_node_required(self): nodes = self._load_valid_nodes(['test_base', 'test_required_true_1', 'test_required_true_2', 'test_required_false_1', 'test_required_false_2', ]) for n in nodes: if n.type.startswith('test_required_true'): self.assertEquals(True, n.required) else: self.assertEquals(False, n.required) def test_node_machine(self): nodes = self._load_valid_nodes(['test_machine']) node = nodes[0] self.assertEquals("machine_test", node.machine_name) def test_node_ns(self): nodes = self._load_valid_nodes(['test_ns1', 'test_ns2','test_ns3']) for n in nodes: if n.type == 'test_ns1': self.assertEquals("/ns_test1/", n.namespace) elif n.type == 'test_ns2': self.assertEquals("/ns_test2/child2/", n.namespace) elif n.type == 'test_ns3': self.assertEquals("/ns_test3/child3/", n.namespace) def test_machines(self): tests = ['test-machine-invalid.xml', \ 'test-machine-invalid-4.xml', 'test-machine-invalid-5.xml', 'test-machine-invalid-6.xml', 'test-machine-invalid-7.xml', 'test-machine-invalid-8.xml', 'test-machine-invalid-9.xml', 'test-machine-invalid-10.xml', 'test-machine-invalid-11.xml', 'test-machine-invalid-12.xml', ] loader = roslaunch.xmlloader.XmlLoader() for filename in tests: filename = os.path.join(self.xml_dir, filename) try: self.assert_(os.path.exists(filename)) loader.load(filename, RosLaunchMock()) self.fail("xmlloader did not throw an xmlparseexception for [%s]"%filename) except roslaunch.xmlloader.XmlParseException: pass machines = self._load_valid_machines(['machine1', 'machine6', 'machine7', 'machine8', 'machine9']) for m in machines: if m.name == 'machine1': self.assertEquals(m.address, 'address1') elif m.name == 'machine7': self.assertEquals(m.timeout, 10.0) elif m.name == 'machine8': self.assertEquals(m.timeout, 1.) elif m.name == 'machine9': self.assertEquals(m.env_loader, '/opt/ros/fuerte/env.sh') def test_node_subst(self): test_file =os.path.join(self.xml_dir, 'test-node-substitution.xml') keys = ['PACKAGE', 'TYPE', 'OUTPUT', 'RESPAWN'] for k in keys: if k in os.environ: del os.environ[k] import random r = random.randint(0, 100000) if r%2: output = 'screen' respawn = 'true' else: output = 'log' respawn = 'false' # append all but one required key and make sure we fail for k in keys[:-1]: if k in ['PACKAGE', 'TYPE']: os.environ[k] = "%s-%s"%(k.lower(), r) elif k == 'OUTPUT': os.environ['OUTPUT'] = output try: mock = self._load(test_file) self.fail("xml loader should have thrown an exception due to missing environment var") except roslaunch.xmlloader.XmlParseException: pass # load the last required env var os.environ['RESPAWN'] = respawn mock = self._load(test_file) self.assertEquals(1, len(mock.nodes), "should only be one test node") n = mock.nodes[0] self.assertEquals(n.package, 'package-%s'%r) self.assertEquals(n.type, 'type-%s'%r) self.assertEquals(n.output, output) if respawn == 'true': self.assert_(n.respawn) else: self.failIf(n.respawn) def test_machine_subst(self): test_file = os.path.join(self.xml_dir, 'test-machine-substitution.xml') keys = ['NAME', 'ADDRESS'] for k in keys: if k in os.environ: del os.environ[k] import random r = random.randint(0, 100000) # append all but one required key and make sure we fail for k in keys[:-1]: os.environ[k] = "%s-%s"%(k.lower(), r) try: mock = self._load(test_file) self.fail("xml loader should have thrown an exception due to missing environment var") except roslaunch.xmlloader.XmlParseException: pass os.environ['NAME'] = "name-foo" os.environ['ADDRESS'] = "address-foo" # load the last required env var mock = self._load(test_file) self.assertEquals(1, len(mock.machines), "should only be one test machine") m = mock.machines[0] self.assertEquals(m.name, 'name-foo') self.assertEquals(m.address, 'address-foo') def test_env(self): nodes = self._load_valid_nodes(['test_env', 'test_env_empty']) for n in nodes: if n.type == 'test_env': self.assert_(("env1", "env1 value1") in n.env_args) self.assert_(("env2", "env2 value2") in n.env_args) self.assertEquals(2, len(n.env_args)) elif n.type == 'test_env_empty': self.assert_(("env1", "") in n.env_args) def test_remap(self): loader = roslaunch.xmlloader.XmlLoader() mock = RosLaunchMock() loader.load(os.path.join(self.xml_dir, 'test-remap-valid.xml'), mock) names = ["node%s"%i for i in range(1, 7)] nodes = [n for n in mock.nodes if n.type in names] for n in nodes: if n.type == 'node1': self.assertEquals([['foo', 'bar']], n.remap_args) elif n.type == 'node2': self.assertEquals([['foo', 'baz']], n.remap_args) elif n.type == 'node3': self.assertEquals([['foo', 'bar']], n.remap_args) elif n.type == 'node4': self.assertEquals([['foo', 'far']], n.remap_args) elif n.type == 'node5': self.assertEquals([['foo', 'fad'], ['a', 'b'], ['c', 'd']], n.remap_args) elif n.type == 'node6': self.assertEquals([['foo', 'far'], ['old1', 'new1'], ['old2', 'new2'], ['old3', 'new3']], n.remap_args) def test_substitution(self): mock = self._load(os.path.join(self.xml_dir, 'test-substitution.xml')) # for now this is mostly a trip wire test due to #1776 for p in mock.params: self.assert_('$' not in p.key) self.assert_('$' not in p.value) for n in mock.nodes: self.assert_('$' not in n.package) self.assert_('$' not in n.type) for e in n.env_args: self.assert_('$' not in e[0]) self.assert_('$' not in e[1]) for r in n.remap_args: self.assert_('$' not in r[0]) self.assert_('$' not in r[1]) for a in n.args: self.assert_('$' not in a) def test_node_invalid(self): tests = ['test-node-invalid-type.xml','test-node-invalid-type-2.xml', 'test-node-invalid-pkg.xml','test-node-invalid-pkg-2.xml', # 1 and 2 have been disabled for now until we re-remove ability to have unnamed nodes with params 'test-node-invalid-name-1.xml', 'test-node-invalid-name-2.xml', 'test-node-invalid-name-3.xml', 'test-node-invalid-machine.xml', 'test-node-invalid-respawn.xml', 'test-node-invalid-respawn-required.xml', 'test-node-invalid-required-1.xml', 'test-node-invalid-required-2.xml', 'test-node-invalid-ns.xml','test-node-invalid-ns-2.xml', 'test-node-invalid-env-name.xml','test-node-invalid-env-name-2.xml', 'test-node-invalid-env-value.xml', 'test-node-invalid-output.xml', 'test-node-invalid-cwd.xml', 'test-node-invalid-exception.xml', # rostest <test> tests 'test-test-invalid-reqd-1.xml', 'test-test-invalid-reqd-2.xml', 'test-test-invalid-respawn.xml', 'test-test-invalid-output.xml', 'test-test-invalid-time-limit-1.xml', 'test-test-invalid-time-limit-2.xml', 'test-test-invalid-retry.xml', ] loader = roslaunch.xmlloader.XmlLoader() for filename in tests: filename = os.path.join(self.xml_dir, filename) try: self.assert_(os.path.exists(filename)) loader.load(filename, RosLaunchMock()) self.fail("xmlloader did not throw an xmlparseexception for [%s]"%filename) except roslaunch.xmlloader.XmlParseException: pass def test_remap_invalid(self): tests = ['test-remap-invalid-1.xml', 'test-remap-invalid-2.xml', 'test-remap-invalid-3.xml', 'test-remap-invalid-4.xml', 'test-remap-invalid-name-from.xml', 'test-remap-invalid-name-to.xml', ] loader = roslaunch.xmlloader.XmlLoader() for filename in tests: filename = os.path.join(self.xml_dir, filename) try: self.assert_(os.path.exists(filename)) loader.load(filename, RosLaunchMock()) self.fail("xmlloader did not throw an xmlparseexception for [%s]"%filename) except roslaunch.xmlloader.XmlParseException: pass def test_if_unless(self): mock = RosLaunchMock() loader = roslaunch.xmlloader.XmlLoader() filename = os.path.join(self.xml_dir, 'test-if-unless.xml') loader.load(filename, mock, argv=[]) param_d = {} for p in mock.params: param_d[p.key] = p.value keys = ['group_if', 'group_unless', 'param_if', 'param_unless'] for k in keys: self.assert_('/'+k+'_pass' in param_d, param_d) self.failIf('/'+k+'_fail' in param_d, k) n = mock.nodes[0] for k in ['if', 'unless']: self.assert_(['from_%s_pass'%k, 'to_%s_pass'%k] in n.remap_args) self.failIf(['from_%s_fail'%k, 'to_%s_fail'%k] in n.remap_args) def test_if_unless_invalid(self): mock = RosLaunchMock() loader = roslaunch.xmlloader.XmlLoader() filename = os.path.join(self.xml_dir, 'test-if-unless-invalid-both.xml') # this should raise, not sure XmlParseException is what we want as it destroys semantic info try: loader.load(filename, mock, argv=[]) self.fail("should have raised with invalid if and unless spec") except roslaunch.xmlloader.XmlParseException as e: self.assert_('unless' in str(e)) self.assert_('if' in str(e)) def test_arg_invalid(self): mock = RosLaunchMock() loader = roslaunch.xmlloader.XmlLoader() filename = os.path.join(self.xml_dir, 'test-arg.xml') # this should raise, not sure XmlParseException is what we want as it destroys semantic info try: loader.load(filename, mock, argv=[]) self.fail("should have raised with missing arg") except roslaunch.xmlloader.XmlParseException as e: self.assert_('required' in str(e)) # test with invalid $(arg unknown) filename = os.path.join(self.xml_dir, 'test-arg-invalid-sub.xml') try: loader.load(filename, mock, argv=[]) self.fail("should have raised with unknown arg") except roslaunch.xmlloader.XmlParseException as e: self.assert_('missing' in str(e)) # test with invalid $(arg unknown) filename = os.path.join(self.xml_dir, 'test-arg-invalid-redecl.xml') try: loader.load(filename, mock, argv=[]) self.fail("should have raised with multiple decl") except roslaunch.xmlloader.XmlParseException as e: self.assert_('grounded' in str(e)) def test_arg(self): loader = roslaunch.xmlloader.XmlLoader() filename = os.path.join(self.xml_dir, 'test-arg.xml') mock = RosLaunchMock() loader.load(filename, mock, argv=["required:=test_arg", "if_test:=0"]) param_d = {} for p in mock.params: param_d[p.key] = p.value self.assertEquals(param_d['/p1_test'], 'test_arg') self.assertEquals(param_d['/p2_test'], 'not_set') self.assertEquals(param_d['/p3_test'], 'set') self.assertEquals(param_d['/succeed'], 'yes') self.assertEquals(param_d['/if_test'], 'not_ran') self.assertEquals(param_d['/if_param'], False) self.assertEquals(param_d['/int_param'], 1234) self.assertAlmostEquals(param_d['/float_param'], 3.) self.failIf('/fail' in param_d) # context tests # - args are scoped to their context, and thus can be rebound in a sibling context self.assertEquals(param_d['/context1'], 'group1') self.assertEquals(param_d['/context2'], 'group2') # include tests self.assertEquals(param_d['/include_test/p1_test'], 'required1') self.assertEquals(param_d['/include_test/p2_test'], 'not_set') self.assertEquals(param_d['/include_test/p3_test'], 'set') self.assertEquals(param_d['/include_test/p4_test'], 'initial') self.assertEquals(param_d['/include2/include_test/p1_test'], 'required2') self.assertEquals(param_d['/include2/include_test/p2_test'], 'optional2') self.assertEquals(param_d['/include2/include_test/p3_test'], 'set') self.assertEquals(param_d['/include2/include_test/p4_test'], 'new2') self.assert_('/include3/include_test/p1_test' not in param_d) self.assert_('/include3/include_test/p2_test' not in param_d) self.assert_('/include3/include_test/p3_test' not in param_d) self.assert_('/include3/include_test/p4_test' not in param_d) # test again with optional value set mock = RosLaunchMock() loader.load(filename, mock, argv=["required:=test_arg", "optional:=test_arg2", "if_test:=1"]) param_d = {} for p in mock.params: param_d[p.key] = p.value self.assertEquals(param_d['/p1_test'], 'test_arg') self.assertEquals(param_d['/p2_test'], 'test_arg2') self.assertEquals(param_d['/p3_test'], 'set') self.assertEquals(param_d['/context1'], 'group1') self.assertEquals(param_d['/context2'], 'group2') self.assertEquals(param_d['/succeed'], 'yes') self.assertEquals(param_d['/if_test'], 'ran') self.assertEquals(param_d['/if_param'], True) self.failIf('/fail' in param_d) # include tests self.assertEquals(param_d['/include_test/p1_test'], 'required1') self.assertEquals(param_d['/include_test/p2_test'], 'not_set') self.assertEquals(param_d['/include_test/p3_test'], 'set') self.assertEquals(param_d['/include_test/p4_test'], 'initial') self.assertEquals(param_d['/include2/include_test/p1_test'], 'required2') self.assertEquals(param_d['/include2/include_test/p2_test'], 'optional2') self.assertEquals(param_d['/include2/include_test/p3_test'], 'set') self.assertEquals(param_d['/include2/include_test/p4_test'], 'new2') self.assertEquals(param_d['/include3/include_test/p1_test'], 'required3') self.assertEquals(param_d['/include3/include_test/p2_test'], 'optional3') self.assertEquals(param_d['/include3/include_test/p3_test'], 'set') self.assertEquals(param_d['/include3/include_test/p4_test'], 'new3') # Test the new attribute <include pass_all_args={"true"|"false"}> def test_arg_all(self): loader = roslaunch.xmlloader.XmlLoader() filename = os.path.join(self.xml_dir, 'test-arg-all.xml') # Test suite A: load without an optional arg set externally mock = RosLaunchMock() loader.load(filename, mock, argv=["required:=test_arg"]) param_d = {} for p in mock.params: param_d[p.key] = p.value # Sanity check: Parent namespace self.assertEquals(param_d['/p1_test'], 'test_arg') self.assertEquals(param_d['/p2_test'], 'not_set') self.assertEquals(param_d['/p3_test'], 'parent') # Test case 1: include without pass_all_args self.assertEquals(param_d['/notall/include_test/p1_test'], 'test_arg') self.assertEquals(param_d['/notall/include_test/p2_test'], 'not_set') self.assertEquals(param_d['/notall/include_test/p3_test'], 'set') # Test case 2: include without pass_all_args attribute, and pass optional arg # internally self.assertEquals(param_d['/notall_optional/include_test/p1_test'], 'test_arg') self.assertEquals(param_d['/notall_optional/include_test/p2_test'], 'not_set') self.assertEquals(param_d['/notall_optional/include_test/p3_test'], 'set') # Test case 3: include with pass_all_args attribute, instead of passing individual # args self.assertEquals(param_d['/all/include_test/p1_test'], 'test_arg') self.assertEquals(param_d['/all/include_test/p2_test'], 'not_set') self.assertEquals(param_d['/all/include_test/p3_test'], 'set') # Test case 4: include with pass_all_args attribute, and override one # arg inside the include tag self.assertEquals(param_d['/all_override/include_test/p1_test'], 'override') self.assertEquals(param_d['/all_override/include_test/p2_test'], 'not_set') self.assertEquals(param_d['/all_override/include_test/p3_test'], 'set') # Test suite B: load with an optional arg set externally mock = RosLaunchMock() loader.load(filename, mock, argv=["required:=test_arg", "optional:=test_arg2"]) param_d = {} for p in mock.params: param_d[p.key] = p.value # Sanity check: Parent namespace self.assertEquals(param_d['/p1_test'], 'test_arg') self.assertEquals(param_d['/p2_test'], 'test_arg2') self.assertEquals(param_d['/p3_test'], 'parent') # Test case 1: include without pass_all_args attribute self.assertEquals(param_d['/notall/include_test/p1_test'], 'test_arg') self.assertEquals(param_d['/notall/include_test/p2_test'], 'not_set') self.assertEquals(param_d['/notall/include_test/p3_test'], 'set') # Test case 2: include without pass_all_args attribute, and pass optional arg # internally self.assertEquals(param_d['/notall_optional/include_test/p1_test'], 'test_arg') self.assertEquals(param_d['/notall_optional/include_test/p2_test'], 'test_arg2') self.assertEquals(param_d['/notall_optional/include_test/p3_test'], 'set') # Test case 3: include with pass_all_args attribute, instead of passing individual # args self.assertEquals(param_d['/all/include_test/p1_test'], 'test_arg') self.assertEquals(param_d['/all/include_test/p2_test'], 'test_arg2') self.assertEquals(param_d['/all/include_test/p3_test'], 'set') # Test case 4: include with pass_all_args attribute, and override one # arg inside the include tag self.assertEquals(param_d['/all_override/include_test/p1_test'], 'override') self.assertEquals(param_d['/all_override/include_test/p2_test'], 'test_arg2') self.assertEquals(param_d['/all_override/include_test/p3_test'], 'set') def test_arg_all_includes(self): loader = roslaunch.xmlloader.XmlLoader() # Test 1: # Can't explicitly set an arg when including a file that sets the same # arg as constant. mock = RosLaunchMock() filename = os.path.join(self.xml_dir, 'test-arg-invalid-include.xml') try: loader.load(filename, mock) self.fail('should have thrown an exception') except roslaunch.xmlloader.XmlParseException: pass # Test 2: # Can have arg set in parent launch file, then include a file that sets # it constant, with pass_all_args="true" mock = RosLaunchMock() filename = os.path.join(self.xml_dir, 'test-arg-valid-include.xml') # Just make sure there's no exception loader.load(filename, mock) # This test checks for exception behavior that would be nice to have, # but would require intrusive changes to how roslaunch passes arguments # to included contexts. It currently fails. I'm leaving it here as a # reference for potential future work. ## Test 3: ## Can't do explicit override of arg during inclusion of file that sets ## it constant, even when pass_all_args="true" #mock = RosLaunchMock() #filename = os.path.join(self.xml_dir, 'test-arg-invalid-include2.xml') #try: # loader.load(filename, mock) # self.fail('should have thrown an exception') #except roslaunch.xmlloader.XmlParseException: # pass
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/unit/test_roslaunch_server.py
# Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import os import sys import unittest import time import roslaunch.pmon import roslaunch.server from roslaunch.server import ProcessListener try: from xmlrpc.client import ServerProxy except ImportError: from xmlrpclib import ServerProxy import rosgraph master = rosgraph.Master('test_roslaunch_server') def get_param(*args): return master.getParam(*args) class MockProcessListener(ProcessListener): def process_died(self, name, code): self.process_name = name self.exit_code = code ## Fake Process object class ProcessMock(roslaunch.pmon.Process): def __init__(self, package, name, args, env, respawn=False): super(ProcessMock, self).__init__(package, name, args, env, respawn) self.stopped = False def stop(self): self.stopped = True ## Fake ProcessMonitor object class ProcessMonitorMock(object): def __init__(self): self.core_procs = [] self.procs = [] self.listeners = [] self.is_shutdown = False def join(self, timeout=0): pass def add_process_listener(self, l): self.listeners.append(l) def register(self, p): self.procs.append(p) def register_core_proc(self, p): self.core_procs.append(p) def registrations_complete(self): pass def unregister(self, p): self.procs.remove(p) def has_process(self, name): return len([p for p in self.procs if p.name == name]) > 0 def get_process(self, name): val = [p for p in self.procs if p.name == name] if val: return val[0] return None def has_main_thread_jobs(self): return False def do_main_thread_jobs(self): pass def kill_process(self, name): pass def shutdown(self): self.is_shutdown = True def get_active_names(self): return [p.name for p in self.procs] def get_process_names_with_spawn_count(self): actives = [(p.name, p.spawn_count) for p in self.procs] deads = [] return [actives, deads] def mainthread_spin_once(self): pass def mainthread_spin(self): pass def run(self): pass class TestHandler(roslaunch.server.ROSLaunchBaseHandler): def __init__(self, pm): super(TestHandler, self).__init__(pm) self.pinged = None def ping(self, val): self.pinged = val return True ## Test roslaunch.server class TestRoslaunchServer(unittest.TestCase): def setUp(self): self.pmon = ProcessMonitorMock() roslaunch.core.clear_printlog_handlers() roslaunch.core.clear_printerrlog_handlers() def test_ChildRoslaunchProcess(self): # test that constructor is wired up correctly from roslaunch.server import ChildROSLaunchProcess name = 'foo-%s'%time.time() args = [time.time(), time.time()] env = { 'key-%s'%time.time() : str(time.time()) } cp = ChildROSLaunchProcess(name, args, env) self.assertEquals(name, cp.name) self.assertEquals(args, cp.args) self.assertEquals(env, cp.env) self.assertEquals(None, cp.uri) uri = 'http://foo:1234' cp.set_uri(uri) self.assertEquals(uri, cp.uri) def _succeed(self, retval): code, msg, val = retval self.assertEquals(1, code) self.assert_(type(msg) == str) return val def test_ROSLaunchBaseHandler(self): from roslaunch.server import ROSLaunchBaseHandler try: ROSLaunchBaseHandler(None) self.fail("should not allow pm as None") except: pass pmon = self.pmon h = ROSLaunchBaseHandler(pmon) self._test_ROSLaunchBaseHandler(h) # reusable parent class test def _test_ROSLaunchBaseHandler(self, h): pmon = self.pmon # - test get pid self.assertEquals(os.getpid(), self._succeed(h.get_pid())) # - test list processes process_list = self._succeed(h.list_processes()) self.assertEquals([[], []], process_list) p = ProcessMock('pack', 'name', [], {}) p.spawn_count = 1 pmon.register(p) process_list = self._succeed(h.list_processes()) self.assertEquals([('name', 1),], process_list[0]) self.assertEquals([], process_list[1]) p.spawn_count = 2 process_list = self._succeed(h.list_processes()) self.assertEquals([('name', 2),], process_list[0]) self.assertEquals([], process_list[1]) # - cleanup our work pmon.unregister(p) # - test process_info code, msg, val = h.process_info('fubar') self.assertEquals(-1, code) self.assert_(type(msg) == str) self.assertEquals({}, val) pmon.register(p) self.assertEquals(p.get_info(), self._succeed(h.process_info(p.name))) pmon.unregister(p) # - test get_node_names # - reach into instance to get branch-complete h.pm = None code, msg, val = h.get_node_names() self.assertEquals(0, code) self.assert_(type(msg) == str) self.assertEquals([], val) h.pm = pmon self.assertEquals(pmon.get_active_names(), self._succeed(h.get_node_names())) pmon.register(p) self.assertEquals(pmon.get_active_names(), self._succeed(h.get_node_names())) pmon.unregister(p) def test_ROSLaunchParentHandler(self): from roslaunch.server import ROSLaunchParentHandler from roslaunch.server import ChildROSLaunchProcess try: ROSLaunchParentHandler(None, {}, []) self.fail("should not allow pm as None") except: pass pmon = self.pmon child_processes = {} listeners = [] h = ROSLaunchParentHandler(pmon, child_processes, listeners) self.assertEquals(child_processes, h.child_processes) self.assertEquals(listeners, h.listeners) self._test_ROSLaunchBaseHandler(h) from rosgraph_msgs.msg import Log h.log('client-1', Log.FATAL, "message") h.log('client-1', Log.ERROR, "message") h.log('client-1', Log.DEBUG, "message") h.log('client-1', Log.INFO, "started with pid 1234") # test process_died # - no listeners self._succeed(h.process_died('dead1', -1)) # - well-behaved listener l = roslaunch.pmon.ProcessListener() listeners.append(l) self._succeed(h.process_died('dead2', -1)) # - bad listener with exception def bad(): raise Exception("haha") l.process_died = bad self._succeed(h.process_died('dead3', -1)) # test register # - verify clean slate with list_children self.assertEquals([], self._succeed(h.list_children())) # - first register with unknown code, msg, val = h.register('client-unknown', 'http://unroutable:1234') self.assertEquals(-1, code) self.assertEquals([], self._succeed(h.list_children())) # - now register with known uri = 'http://unroutable:1324' child_processes['client-1'] = ChildROSLaunchProcess('foo', [], {}) val = self._succeed(h.register('client-1', uri)) self.assert_(type(val) == int) self.assertEquals([uri], self._succeed(h.list_children())) def test_ROSLaunchChildHandler(self): from roslaunch.server import ROSLaunchChildHandler pmon = self.pmon try: # if there is a core up, we have to use its run id run_id = get_param('/run_id') except: run_id = 'foo-%s'%time.time() name = 'foo-bob' server_uri = 'http://localhost:12345' try: h = ROSLaunchChildHandler(run_id, name, server_uri, None) self.fail("should not allow pm as None") except: pass try: h = ROSLaunchChildHandler(run_id, name, 'http://bad_uri:0', pmon) self.fail("should not allow bad uri") except: pass try: h = ROSLaunchChildHandler(run_id, name, None, pmon) self.fail("should not allow None server_uri") except: pass h = ROSLaunchChildHandler(run_id, name, server_uri, pmon) self.assertEquals(run_id, h.run_id) self.assertEquals(name, h.name) self.assertEquals(server_uri, h.server_uri) self._test_ROSLaunchBaseHandler(h) # test _log() from rosgraph_msgs.msg import Log h._log(Log.INFO, 'hello') # test shutdown() # should uninitialize pm h.shutdown() self.assert_(pmon.is_shutdown) # - this check is mostly to make sure that the launch() call below will exit self.assert_(h.pm is None) code, msg, val = h.launch('<launch></launch>') self.assertEquals(0, code) # TODO: actual launch. more difficult as we need a core def test__ProcessListenerForwarder(self): from roslaunch.server import _ProcessListenerForwarder, ProcessListener # test with bad logic first f = _ProcessListenerForwarder(None) # - should trap exceptions f.process_died("foo", -1) # test with actual listener l = MockProcessListener() f = _ProcessListenerForwarder(l) # - should run normally f.process_died("foo", -1) self.assertEquals(l.process_name, 'foo') self.assertEquals(l.exit_code, -1) def test_ROSLaunchNode(self): #exercise the basic ROSLaunchNode API from roslaunch.server import ROSLaunchNode # - create a node with a handler handler = TestHandler(self.pmon) node = ROSLaunchNode(handler) # - start the node node.start() self.assert_(node.uri) # - call the ping API that we added s = ServerProxy(node.uri) test_val = 'test-%s'%time.time() s.ping(test_val) self.assertEquals(handler.pinged, test_val) # - call the pid API code, msg, pid = s.get_pid() self.assertEquals(1, code) self.assert_(type(msg) == str) self.assertEquals(os.getpid(), pid) # - shut it down node.shutdown('test done') def test_ROSLaunchParentNode(self): from roslaunch.server import ROSLaunchParentNode from roslaunch.server import ChildROSLaunchProcess from roslaunch.config import ROSLaunchConfig from roslaunch.pmon import ProcessListener rosconfig = ROSLaunchConfig() try: ROSLaunchParentNode(rosconfig, None) self.fail("should not allow pm as None") except: pass pmon = self.pmon n = ROSLaunchParentNode(rosconfig, pmon) self.assertEquals(rosconfig, n.rosconfig) self.assertEquals([], n.listeners) self.assertEquals({}, n.child_processes) self.assertEquals(n.handler.listeners, n.listeners) self.assertEquals(n.handler.child_processes, n.child_processes) # test add listener self.assertEquals(n.handler.listeners, n.listeners) l = ProcessListener() n.add_process_listener(l) self.assertEquals([l], n.listeners) self.assertEquals(n.handler.listeners, n.listeners) # now, lets make some xmlrpc calls against it import roslaunch.config server = roslaunch.server.ROSLaunchParentNode(roslaunch.config.ROSLaunchConfig(), self.pmon) # it's really dangerous for logging when both a parent and a # child are in the same process, so out of paranoia, clear the # logging handlers roslaunch.core.clear_printlog_handlers() roslaunch.core.clear_printerrlog_handlers() # - register a fake child with the server so that it accepts registration from ROSLaunchChild child_name = 'child-%s'%time.time() child_proc = ChildROSLaunchProcess('foo', [], {}) server.add_child(child_name, child_proc) try: server.start() self.assert_(server.uri, "server URI did not initialize") s = ServerProxy(server.uri) child_uri = 'http://fake-unroutable:1324' # - list children should be empty val = self._succeed(s.list_children()) self.assertEquals([], val) # - register val = self._succeed(s.register(child_name, child_uri)) self.assertEquals(1, val) # - list children val = self._succeed(s.list_children()) self.assertEquals([child_uri], val) finally: server.shutdown('test done') def test_ROSLaunchChildNode(self): from roslaunch.server import ROSLaunchChildNode from roslaunch.server import ChildROSLaunchProcess pmon = self.pmon try: # if there is a core up, we have to use its run id run_id = get_param('/run_id') except: run_id = 'foo-%s'%time.time() name = 'foo-bob' server_uri = 'http://localhost:12345' try: ROSLaunchChildNode(run_id, name, server_uri, None) self.fail("should not allow pm as None") except: pass try: ROSLaunchChildNode(run_id, name, 'http://bad_uri:0', pmon) self.fail("should not allow bad uri") except: pass n = ROSLaunchChildNode(run_id, name, server_uri, pmon) self.assertEquals(run_id, n.run_id) self.assertEquals(name, n.name) self.assertEquals(server_uri, n.server_uri) # tests for actual registration with server import roslaunch.config server = roslaunch.server.ROSLaunchParentNode(roslaunch.config.ROSLaunchConfig(), self.pmon) # - register a fake child with the server so that it accepts registration from ROSLaunchChild child_proc = ChildROSLaunchProcess('foo', [], {}) server.add_child(name, child_proc) try: server.start() self.assert_(server.uri, "server URI did not initialize") s = ServerProxy(server.uri) print("SERVER STARTED") # start the child n = ROSLaunchChildNode(run_id, name, server.uri, pmon) n.start() print("CHILD STARTED") self.assert_(n.uri, "child URI did not initialize") # verify registration print("VERIFYING REGISTRATION") self.assertEquals(child_proc.uri, n.uri) child_uri = 'http://fake-unroutable:1324' # - list children val = self._succeed(s.list_children()) self.assertEquals([n.uri], val) finally: print("SHUTTING DOWN") n.shutdown('test done') server.shutdown('test done')
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/unit/test_roslaunch_list_files.py
# Software License Agreement (BSD License) # # Copyright (c) 2011, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. from __future__ import print_function import os import sys import time import unittest import roslib.packages from subprocess import Popen, PIPE, check_call, call def get_test_path(): return os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'xml')) class TestListFiles(unittest.TestCase): def setUp(self): pass def test_list_files(self): cmd = 'roslaunch' # check error behavior p = Popen([cmd, '--files'], stdout = PIPE) p.communicate() self.assert_(p.returncode != 0, "Should have failed w/o file argument. Code: %d" % (p.returncode)) d = get_test_path() p = Popen([cmd, '--files', 'roslaunch', 'test-valid.xml'], stdout = PIPE) o = p.communicate()[0] o = o.decode() self.assert_(p.returncode == 0, "Return code nonzero for list files! Code: %d" % (p.returncode)) self.assertEquals(os.path.realpath(os.path.join(d, 'test-valid.xml')), os.path.realpath(o.strip())) print("check 1", o) p = Popen([cmd, '--files', 'roslaunch', 'test-env.xml'], stdout = PIPE) o = p.communicate()[0] o = o.decode() self.assert_(p.returncode == 0, "Return code nonzero for list files! Code: %d" % (p.returncode)) self.assertEquals(set([os.path.realpath(os.path.join(d, 'test-env.xml')), os.path.realpath(os.path.join(d, 'test-env-include.xml'))]), set([os.path.realpath(x.strip()) for x in o.split() if x.strip()])) print("check 2", o)
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/unit/test_roslaunch_core.py
# Software License Agreement (BSD License) # # Copyright (c) 2012, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import os import sys import rospkg try: from xmlrpc.client import MultiCall, ServerProxy except ImportError: from xmlrpclib import MultiCall, ServerProxy import roslaunch.core def test_Executable(): from roslaunch.core import Executable, PHASE_SETUP e = Executable('cmd', ('arg1', 'arg2'), PHASE_SETUP) assert e.command == 'cmd' assert e.args == ('arg1', 'arg2') assert e.phase == PHASE_SETUP assert 'cmd' in str(e) assert 'arg2' in str(e) assert 'cmd' in repr(e) assert 'arg2' in repr(e) def test__xml_escape(): # this is a really bad xml escaper from roslaunch.core import _xml_escape assert _xml_escape("&<foo>") == "&amp;&lt;foo&gt;" def test_RosbinExecutable(): from roslaunch.core import RosbinExecutable, PHASE_SETUP, PHASE_RUN e = RosbinExecutable('cmd', ('arg1', 'arg2'), PHASE_SETUP) assert e.command == 'cmd' assert e.args == ('arg1', 'arg2') assert e.phase == PHASE_SETUP assert 'cmd' in str(e) assert 'arg2' in str(e) assert 'cmd' in repr(e) assert 'arg2' in repr(e) assert 'ros/bin' in str(e) assert 'ros/bin' in repr(e) e = RosbinExecutable('cmd', ('arg1', 'arg2')) assert e.phase == PHASE_RUN def test_generate_run_id(): from roslaunch.core import generate_run_id assert generate_run_id() def test_Node(): from roslaunch.core import Node n = Node('package', 'node_type') assert n.package == 'package' assert n.type == 'node_type' assert n.xmltype() == 'node' assert n.xmlattrs() == [('pkg', 'package'), ('type', 'node_type'), ('machine', None), ('ns', '/'), ('args', ''), ('output', None), ('cwd', None), ('respawn', False), ('respawn_delay', 0.0), ('name', None), ('launch-prefix', None), ('required', False)], \ n.xmlattrs() assert n.output == None #tripwire for now n.to_xml() val = n.to_remote_xml() assert 'machine' not in val # test bad constructors try: n = Node('package', 'node_type', cwd='foo') assert False except ValueError: pass try: n = Node('package', 'node_type', output='foo') assert False except ValueError: pass try: n = Node('package', '') assert False except ValueError: pass try: n = Node('', 'node_type') assert False except ValueError: pass try: n = Node('package', 'node_type', name='ns/node') assert False except ValueError: pass try: n = Node('package', 'node_type', respawn=True, required=True) assert False except ValueError: pass def test_Param(): from roslaunch.core import Param p = Param('key/', 'value') assert p.key == 'key' assert p.value == 'value' assert p == Param('key', 'value') assert p != Param('key2', 'value') assert p != 1 assert 'key' in str(p) assert 'key' in repr(p) assert 'value' in str(p) assert 'value' in repr(p) def test_local_machine(): from roslaunch.core import local_machine m = local_machine() assert m is local_machine() assert m == local_machine() assert m.env_loader == None assert m.name == '' assert m.address == 'localhost' assert m.ssh_port == 22 def test_Machine(): from roslaunch.core import Machine m = Machine('foo', 'localhost') assert 'foo' in str(m) assert m.name == 'foo' assert m.env_loader == None assert m.assignable == True assert m == m assert not m.__eq__(1) assert not m.config_equals(1) assert m == Machine('foo', 'localhost') assert m.config_equals(Machine('foo', 'localhost')) assert m.config_key() == Machine('foo', 'localhost').config_key() assert m.config_equals(Machine('foo', 'localhost')) assert m.config_key() == Machine('foo', 'localhost', ssh_port=22).config_key() assert m.config_equals(Machine('foo', 'localhost', ssh_port=22)) assert m.config_key() == Machine('foo', 'localhost', assignable=False).config_key() assert m.config_equals(Machine('foo', 'localhost', assignable=False)) # original test suite m = Machine('name1', '1.2.3.4') str(m), m.config_key() #test for error assert m == m assert m == Machine('name1', '1.2.3.4') # verify that config_equals is not tied to name or assignable, but is tied to other properties assert m.config_equals(Machine('name1b', '1.2.3.4')) assert m.config_equals(Machine('name1c', '1.2.3.4', assignable=False)) assert not m.config_equals(Machine('name1f', '2.2.3.4')) assert m.name == 'name1' assert m.address == '1.2.3.4' assert m.assignable == True assert m.ssh_port == 22 assert m.env_loader == None for p in ['user', 'password']: assert getattr(m, p) is None m = Machine('name2', '2.2.3.4', assignable=False) assert not m.assignable str(m), m.config_key() #test for error assert m == m assert m == Machine('name2', '2.2.3.4', assignable=False) assert m.config_equals(Machine('name2b', '2.2.3.4', assignable=False)) assert m.config_equals(Machine('name2c', '2.2.3.4', assignable=True)) m = Machine('name3', '3.3.3.4') str(m) #test for error assert m == m assert m == Machine('name3', '3.3.3.4') assert m.config_equals(Machine('name3b', '3.3.3.4')) m = Machine('name4', '4.4.3.4', user='user4') assert m.user == 'user4' str(m), m.config_key() #test for error assert m == m assert m == Machine('name4', '4.4.3.4', user='user4') assert m.config_equals(Machine('name4b', '4.4.3.4', user='user4')) assert not m.config_equals(Machine('name4b', '4.4.3.4', user='user4b')) m = Machine('name5', '5.5.3.4', password='password5') assert m.password == 'password5' str(m), m.config_key() #test for error assert m == m assert m == Machine('name5', '5.5.3.4', password='password5') assert m.config_equals(Machine('name5b', '5.5.3.4', password='password5')) assert not m.config_equals(Machine('name5c', '5.5.3.4', password='password5c')) m = Machine('name6', '6.6.3.4', ssh_port=23) assert m.ssh_port == 23 str(m) #test for error m.config_key() assert m == m assert m == Machine('name6', '6.6.3.4', ssh_port=23) assert m.config_equals(Machine('name6b', '6.6.3.4', ssh_port=23)) assert not m.config_equals(Machine('name6c', '6.6.3.4', ssh_port=24)) m = Machine('name6', '6.6.3.4', env_loader='/opt/ros/fuerte/setup.sh') assert m.env_loader == '/opt/ros/fuerte/setup.sh' str(m) #test for error m.config_key() assert m == m assert m == Machine('name6', '6.6.3.4', env_loader='/opt/ros/fuerte/setup.sh') assert m.config_equals(Machine('name6b', '6.6.3.4', env_loader='/opt/ros/fuerte/setup.sh')) assert not m.config_equals(Machine('name6c', '6.6.3.4', env_loader='/opt/ros/groovy/setup.sh')) def test_Master(): from roslaunch.core import Master # can't verify value of is_running for actual master m = Master(uri='http://localhost:11311') assert m .type == Master.ROSMASTER m.get_host() == 'localhost' m.get_port() == 11311 assert m.is_running() in [True, False] assert isinstance(m.get(), ServerProxy) assert isinstance(m.get_multi(), MultiCall) m = Master(uri='http://badhostname:11312') m.get_host() == 'badhostname' m.get_port() == 11312 assert m.is_running() == False def test_Test(): from roslaunch.core import Test, TEST_TIME_LIMIT_DEFAULT t = Test('test_name', 'package', 'node_type') assert t.xmltype() == 'test' assert t.xmlattrs() == [('pkg', 'package'), ('type', 'node_type'), ('machine', None), ('ns', '/'), ('args', ''), ('output', 'log'), ('cwd', None), ('name', None), ('launch-prefix', None), ('required', False), ('test-name', 'test_name')] assert t.output == 'log' assert t.test_name == 'test_name' assert t.package == 'package' assert t.type == 'node_type' assert t.name == None assert t.namespace == '/' assert t.machine_name == None assert t.args == '' assert t.remap_args == [], t.remap_args assert t.env_args == [] assert t.time_limit == TEST_TIME_LIMIT_DEFAULT assert t.cwd is None assert t.launch_prefix is None assert t.retry == 0 assert t.filename == '<unknown>' t = Test('test_name', 'package', 'node_type', 'name', '/namespace', 'machine_name', 'arg1 arg2', remap_args=[('from', 'to')], env_args=[('ENV', 'val')], time_limit=1.0, cwd='ros_home', launch_prefix='foo', retry=1, filename="filename.txt") xmlattrs = t.xmlattrs() assert ('time-limit', 1.0) in xmlattrs assert ('retry', '1') in xmlattrs assert t.launch_prefix == 'foo' assert t.remap_args == [('from', 'to')] assert t.env_args == [('ENV', 'val')] assert t.name == 'name' assert t.namespace == '/namespace/', t.namespace assert t.machine_name == 'machine_name' assert t.args == 'arg1 arg2' assert t.filename == 'filename.txt' assert t.time_limit == 1.0 assert t.cwd == 'ROS_HOME' assert t.retry == 1 try: t = Test('test_name', 'package', 'node_type', time_limit=-1.0) assert False except ValueError: pass try: t = Test('test_name', 'package', 'node_type', time_limit=True) assert False except ValueError: pass
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/unit/test_roslaunch_dump_params.py
#!/usr/bin/env python # Software License Agreement (BSD License) # # Copyright (c) 2010, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import os import sys import time import unittest import yaml from subprocess import Popen, PIPE, check_call, call class TestDumpParams(unittest.TestCase): def setUp(self): pass def test_roslaunch(self): # network is initialized cmd = 'roslaunch' # Smoke test for testing parameters p = Popen([cmd, '--dump-params', 'roslaunch', 'noop.launch'], stdout = PIPE) o, e = p.communicate() self.assert_(p.returncode == 0, "Return code nonzero for param dump! Code: %d" % (p.returncode)) self.assertEquals({'/noop': 'noop'}, yaml.load(o)) p = Popen([cmd, '--dump-params', 'roslaunch', 'test-dump-rosparam.launch'], stdout = PIPE) o, e = p.communicate() self.assert_(p.returncode == 0, "Return code nonzero for param dump! Code: %d" % (p.returncode)) val = { '/string1': 'bar', '/dict1/head': 1, '/dict1/shoulders': 2, '/dict1/knees': 3, '/dict1/toes': 4, '/rosparam/string1': 'bar', '/rosparam/dict1/head': 1, '/rosparam/dict1/shoulders': 2, '/rosparam/dict1/knees': 3, '/rosparam/dict1/toes': 4, '/node_rosparam/string1': 'bar', '/node_rosparam/dict1/head': 1, '/node_rosparam/dict1/shoulders': 2, '/node_rosparam/dict1/knees': 3, '/node_rosparam/dict1/toes': 4, '/inline_str': 'value1', '/inline_list': [1, 2, 3, 4], '/inline_dict/key1': 'value1', '/inline_dict/key2': 'value2', '/inline_dict2/key3': 'value3', '/inline_dict2/key4': 'value4', '/override/key1': 'override1', '/override/key2': 'value2', '/noparam1': 'value1', '/noparam2': 'value2', } output_val = yaml.load(o) if not val == output_val: for k, v in val.items(): if k not in output_val: self.fail("key [%s] not in output: %s"%(k, output_val)) elif v != output_val[k]: self.fail("key [%s] value [%s] does not match output: %s"%(k, v, output_val[k])) self.assertEquals(val, output_val)
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/unit/test_roslaunch_pmon.py
# Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import os import sys import unittest import time import threading import roslaunch.server ## handy class for kill_pmon to check whether it was called class Marker(object): def __init__(self): self.marked = False def mark(self): self.marked = True ## Fake ProcessMonitor object class ProcessMonitorMock(object): def __init__(self): self.core_procs = [] self.procs = [] self.listeners = [] self.alive = False self.is_shutdown = False def isAlive(self): return self.alive def join(self, *args): return def add_process_listener(self, l): self.listeners.append(l) def register(self, p): self.procs.append(p) def register_core_proc(self, p): self.core_procs.append(p) def registrations_complete(self): pass def unregister(self, p): self.procs.remove(p) def has_process(self, name): return len([p for p in self.procs if p.name == name]) > 0 def get_process(self, name): return self.procs.get(p, None) def has_main_thread_jobs(self): return False def do_main_thread_jobs(self): pass def kill_process(self, name): pass def shutdown(self): pass def get_active_names(self): return [p.name for p in self.procs] def get_process_names_with_spawn_count(self): actives = [(p.name, p.spawn_count) for p in self.procs] deads = [] retval = [actives, deads] def mainthread_spin_once(self): pass def mainthread_spin(self): pass def run(self): pass class ProcessMock(roslaunch.pmon.Process): def __init__(self, package, name, args, env, respawn=False): super(ProcessMock, self).__init__(package, name, args, env, respawn) self.stopped = False def stop(self, errors): self.stopped = True class RespawnOnceProcessMock(ProcessMock): def __init__(self, package, name, args, env, respawn=True): super(ProcessMock, self).__init__(package, name, args, env, respawn) self.spawn_count = 0 def is_alive(self): self.time_of_death = time.time() return False def start(self): self.spawn_count += 1 if self.spawn_count > 1: self.respawn = False self.time_of_death = None class RespawnOnceWithDelayProcessMock(ProcessMock): def __init__(self, package, name, args, env, respawn=True, respawn_delay=1.0): super(ProcessMock, self).__init__(package, name, args, env, respawn, respawn_delay=respawn_delay) self.spawn_count = 0 self.respawn_interval = None def is_alive(self): if self.time_of_death is None: self.time_of_death = time.time() return False def start(self): self.spawn_count += 1 if self.spawn_count > 1: self.respawn = False self.respawn_interval = time.time() - self.time_of_death self.time_of_death = None ## Test roslaunch.server class TestRoslaunchPmon(unittest.TestCase): def setUp(self): self.pmon = roslaunch.pmon.ProcessMonitor() ## test all apis of Process instance. part coverage/sanity test def _test_Process(self, p, package, name, args, env, respawn, respawn_delay): self.assertEquals(package, p.package) self.assertEquals(name, p.name) self.assertEquals(args, p.args) self.assertEquals(env, p.env) self.assertEquals(respawn, p.respawn) self.assertEquals(respawn_delay, p.respawn_delay) self.assertEquals(0, p.spawn_count) self.assertEquals(None, p.exit_code) self.assert_(p.get_exit_description()) self.failIf(p.is_alive()) info = p.get_info() self.assertEquals(package, info['package']) self.assertEquals(name, info['name']) self.assertEquals(args, info['args']) self.assertEquals(env, info['env']) self.assertEquals(respawn, info['respawn']) self.assertEquals(respawn_delay, info['respawn_delay']) self.assertEquals(0, info['spawn_count']) self.failIf('exit_code' in info) p.start() self.assertEquals(1, p.spawn_count) self.assertEquals(1, p.get_info()['spawn_count']) p.start() self.assertEquals(2, p.spawn_count) self.assertEquals(2, p.get_info()['spawn_count']) # noop p.stop() p.exit_code = 0 self.assertEquals(0, p.get_info()['exit_code']) self.assert_('cleanly' in p.get_exit_description()) p.exit_code = 1 self.assertEquals(1, p.get_info()['exit_code']) self.assert_('[exit code 1]' in p.get_exit_description()) ## tests to make sure that our Process base class has 100% coverage def test_Process(self): from roslaunch.pmon import Process # test constructor params respawn = False package = 'foo-%s'%time.time() name = 'name-%s'%time.time() args = [time.time(), time.time(), time.time()] env = { 'key': time.time(), 'key2': time.time() } p = Process(package, name, args, env, 0.0) self._test_Process(p, package, name, args, env, False, 0.0) p = Process(package, name, args, env, True, 0.0) self._test_Process(p, package, name, args, env, True, 0.0) p = Process(package, name, args, env, False, 0.0) self._test_Process(p, package, name, args, env, False, 0.0) p = Process(package, name, args, env, True, 1.0) self._test_Process(p, package, name, args, env, True, 1.0) def _test_DeadProcess(self, p0, package, name, args, env, respawn, respawn_delay): from roslaunch.pmon import DeadProcess p0.exit_code = -1 dp = DeadProcess(p0) self.assertEquals(package, dp.package) self.assertEquals(name, dp.name) self.assertEquals(args, dp.args) self.assertEquals(env, dp.env) self.assertEquals(respawn, dp.respawn) self.assertEquals(respawn_delay, dp.respawn_delay) self.assertEquals(0, dp.spawn_count) self.assertEquals(-1, dp.exit_code) self.failIf(dp.is_alive()) info = dp.get_info() info0 = p0.get_info() self.assertEquals(info0['package'], info['package']) self.assertEquals(info0['name'], info['name']) self.assertEquals(info0['args'], info['args']) self.assertEquals(info0['env'], info['env']) self.assertEquals(info0['respawn'], info['respawn']) self.assertEquals(info0['respawn_delay'], info['respawn_delay']) self.assertEquals(0, info['spawn_count']) try: dp.start() self.fail("should not be able to start a dead process") except: pass # info should be frozen p0.package = 'dead package' p0.name = 'dead name' p0.spawn_count = 1 self.assertEquals(package, dp.package) self.assertEquals(name, dp.name) self.assertEquals(0, dp.spawn_count) self.assertEquals(package, dp.get_info()['package']) self.assertEquals(name, dp.get_info()['name']) self.assertEquals(0, dp.get_info()['spawn_count']) p0.start() self.assertEquals(0, dp.spawn_count) self.assertEquals(0, dp.get_info()['spawn_count']) # noop p0.stop() def test_DeadProcess(self): from roslaunch.pmon import Process, DeadProcess # test constructor params respawn = False package = 'foo-%s'%time.time() name = 'name-%s'%time.time() args = [time.time(), time.time(), time.time()] env = { 'key': time.time(), 'key2': time.time() } p = Process(package, name, args, env, 0.0) self._test_DeadProcess(p, package, name, args, env, False, 0.0) p = Process(package, name, args, env, True, 0.0) self._test_DeadProcess(p, package, name, args, env, True, 0.0) p = Process(package, name, args, env, False, 0.0) self._test_DeadProcess(p, package, name, args, env, False, 0.0) p = Process(package, name, args, env, True, 1.0) self._test_DeadProcess(p, package, name, args, env, True, 1.0) def test_start_shutdown_process_monitor(self): def failer(): raise Exception("oops") # noop self.failIf(roslaunch.pmon.shutdown_process_monitor(None)) # test with fake pmon so we can get branch-complete pmon = ProcessMonitorMock() # - by setting alive to true, shutdown fails, though it can't really do anything about it pmon.alive = True self.failIf(roslaunch.pmon.shutdown_process_monitor(pmon)) # make sure that exceptions get trapped pmon.shutdown = failer # should cause an exception during execution, but should get caught self.failIf(roslaunch.pmon.shutdown_process_monitor(pmon)) # Test with a real process monitor pmon = roslaunch.pmon.start_process_monitor() self.assert_(pmon.isAlive()) self.assert_(roslaunch.pmon.shutdown_process_monitor(pmon)) self.failIf(pmon.isAlive()) # fiddle around with some state that would shouldn't be roslaunch.pmon._shutting_down = True pmon = roslaunch.pmon.start_process_monitor() if pmon != None: self.failIf(roslaunch.pmon.shutdown_process_monitor(pmon)) self.fail("start_process_monitor should fail if during shutdown sequence") def test_pmon_shutdown(self): # should be noop roslaunch.pmon.pmon_shutdown() # start two real process monitors and kill them # pmon_shutdown pmon1 = roslaunch.pmon.start_process_monitor() pmon2 = roslaunch.pmon.start_process_monitor() self.assert_(pmon1.isAlive()) self.assert_(pmon2.isAlive()) roslaunch.pmon.pmon_shutdown() self.failIf(pmon1.isAlive()) self.failIf(pmon2.isAlive()) def test_add_process_listener(self): # coverage test, not a functionality test as that would be much more difficult to simulate from roslaunch.pmon import ProcessListener l = ProcessListener() self.pmon.add_process_listener(l) def test_kill_process(self): from roslaunch.core import RLException pmon = self.pmon # should return False self.failIf(pmon.kill_process('foo')) p1 = ProcessMock('foo', 'name1', [], {}) p2 = ProcessMock('bar', 'name2', [], {}) pmon.register(p1) pmon.register(p2) self.failIf(p1.stopped) self.failIf(p2.stopped) self.assert_(p1.name in pmon.get_active_names()) self.assert_(p2.name in pmon.get_active_names()) # should fail as pmon API is string-based try: self.assert_(pmon.kill_process(p1)) self.fail("kill_process should have thrown RLException") except RLException: pass self.assert_(pmon.kill_process(p1.name)) self.assert_(p1.stopped) # - pmon should not have removed yet as the pmon thread cannot catch the death self.assert_(pmon.has_process(p1.name)) self.assert_(p1.name in pmon.get_active_names()) self.failIf(p2.stopped) self.assert_(p2.name in pmon.get_active_names()) pmon.kill_process(p2.name) self.assert_(p2.stopped) # - pmon should not have removed yet as the pmon thread cannot catch the death self.assert_(pmon.has_process(p2.name)) self.assert_(p2.name in pmon.get_active_names()) p3 = ProcessMock('bar', 'name3', [], {}) def bad(x): raise Exception("ha ha ha") p3.stop = bad pmon.register(p3) # make sure kill_process is safe pmon.kill_process(p3.name) def f(): return False p1.is_alive = f p2.is_alive = f p3.is_alive = f # Now that we've 'killed' all the processes, we should be able # to run through the ProcessMonitor run loop and it should # exit. But first, important that we check that pmon has no # other extra state in it self.assertEquals(3, len(pmon.get_active_names())) # put pmon into exitable state pmon.registrations_complete() # and run it -- but setup a safety timer to kill it if it doesn't exit marker = Marker() t = threading.Thread(target=kill_pmon, args=(pmon, marker, 10.)) t.setDaemon(True) t.start() pmon.run() self.failIf(marker.marked, "pmon had to be externally killed") self.assert_(pmon.done) self.failIf(pmon.has_process(p1.name)) self.failIf(pmon.has_process(p2.name)) alive, dead = pmon.get_process_names_with_spawn_count() self.failIf(alive) self.assert_((p1.name, p1.spawn_count) in dead) self.assert_((p2.name, p2.spawn_count) in dead) def test_run(self): # run is really hard to test... pmon = self.pmon # put pmon into exitable state pmon.registrations_complete() # give the pmon a process that raises an exception when it's # is_alive is checked. this should be marked as a dead process p1 = ProcessMock('bar', 'name1', [], {}) def bad(): raise Exception('ha ha') p1.is_alive = bad pmon.register(p1) # give pmon a well-behaved but dead process p2 = ProcessMock('bar', 'name2', [], {}) def f(): return False p2.is_alive = f pmon.register(p2) # give pmon a process that wants to respawn once p3 = RespawnOnceProcessMock('bar', 'name3', [], {}) pmon.register(p3) # give pmon a process that wants to respawn once after a delay p4 = RespawnOnceWithDelayProcessMock('bar', 'name4', [], {}) pmon.register(p4) # test assumptions about pmon's internal data structures # before we begin test self.assert_(p1 in pmon.procs) self.assert_(pmon._registrations_complete) self.failIf(pmon.is_shutdown) # and run it -- but setup a safety timer to kill it if it doesn't exit marker = Marker() t = threading.Thread(target=kill_pmon, args=(self.pmon, marker, 10.)) t.setDaemon(True) t.start() pmon.run() self.failIf(marker.marked, "pmon had to be externally killed") self.failIf(p3.spawn_count < 2, "process did not respawn") self.failIf(p4.respawn_interval < p4.respawn_delay, "Respawn delay not respected: %s %s" % (p4.respawn_interval, p4.respawn_delay)) # retest assumptions self.failIf(pmon.procs) self.assert_(pmon.is_shutdown) pmon.is_shutdown = False def test_get_process_names_with_spawn_count(self): p1 = ProcessMock('foo', 'name1', [], {}) p2 = ProcessMock('bar', 'name2', [], {}) pmon = self.pmon self.assertEquals([[], []], pmon.get_process_names_with_spawn_count()) pmon.register(p1) self.assertEquals([[('name1', 0),], []], pmon.get_process_names_with_spawn_count()) pmon.register(p2) alive, dead = pmon.get_process_names_with_spawn_count() self.assertEquals([], dead) self.assert_(('name1', 0) in alive) self.assert_(('name2', 0) in alive) import random p1.spawn_count = random.randint(1, 10000) p2.spawn_count = random.randint(1, 10000) alive, dead = pmon.get_process_names_with_spawn_count() self.assertEquals([], dead) self.assert_((p1.name, p1.spawn_count) in alive) self.assert_((p2.name, p2.spawn_count) in alive) #TODO figure out how to test dead_list ## Tests ProcessMonitor.register(), unregister(), has_process(), and get_process() def test_registration(self): from roslaunch.core import RLException from roslaunch.pmon import Process pmon = self.pmon p1 = Process('foo', 'name1', [], {}) p2 = Process('bar', 'name2', [], {}) corep1 = Process('core', 'core1', [], {}) corep2 = Process('core', 'core2', [], {}) pmon.register(p1) self.assert_(pmon.has_process('name1')) self.assertEquals(p1, pmon.get_process('name1')) self.failIf(pmon.has_process('name2')) self.assertEquals(['name1'], pmon.get_active_names()) try: pmon.register(Process('foo', p1.name, [], {})) self.fail("should not allow duplicate process name") except RLException: pass pmon.register(p2) self.assert_(pmon.has_process('name2')) self.assertEquals(p2, pmon.get_process('name2')) self.assertEquals(set(['name1', 'name2']), set(pmon.get_active_names())) pmon.register_core_proc(corep1) self.assert_(pmon.has_process('core1')) self.assertEquals(corep1, pmon.get_process('core1')) self.assertEquals(set(['name1', 'name2', 'core1']), set(pmon.get_active_names())) pmon.register_core_proc(corep2) self.assert_(pmon.has_process('core2')) self.assertEquals(corep2, pmon.get_process('core2')) self.assertEquals(set(['name1', 'name2', 'core1', 'core2']), set(pmon.get_active_names())) pmon.unregister(p2) self.failIf(pmon.has_process('name2')) pmon.unregister(p1) self.failIf(pmon.has_process('name1')) pmon.unregister(corep1) self.failIf(pmon.has_process('core1')) pmon.unregister(corep2) self.failIf(pmon.has_process('core2')) pmon.shutdown() try: pmon.register(Process('shutdown_fail', 'shutdown_fail', [], {})) self.fail("registration should fail post-shutdown") except RLException: pass def test_mainthread_spin_once(self): # shouldn't do anything self.pmon.done = False self.pmon.mainthread_spin_once() self.pmon.done = True self.pmon.mainthread_spin_once() def test_mainthread_spin(self): # can't test actual spin as that would go forever self.pmon.done = False t = threading.Thread(target=kill_pmon, args=(self.pmon, Marker())) t.setDaemon(True) t.start() self.pmon.mainthread_spin() def kill_pmon(pmon, marker, delay=1.0): # delay execution so that whatever pmon method we're calling has time to enter time.sleep(delay) if not pmon.is_shutdown: marker.mark() print("stopping pmon") # pmon has two states that need to be set, as many of the tests do not start the actual process monitor pmon.shutdown() pmon.done = True
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/unit/test_roslaunch_child.py
#!/usr/bin/env python # Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import os, sys, unittest import time import rosgraph import roslaunch.child import roslaunch.server ## Fake RemoteProcess object class ChildProcessMock(roslaunch.server.ChildROSLaunchProcess): def __init__(self, name, args=[], env={}): super(ChildProcessMock, self).__init__(name, args, env) self.stopped = False def stop(self): self.stopped = True ## Fake ProcessMonitor object class ProcessMonitorMock(object): def __init__(self): self.core_procs = [] self.procs = [] self.listeners = [] def join(self, timeout=0): pass def add_process_listener(self, l): self.listeners.append(l) def register(self, p): self.procs.append(p) def register_core_proc(self, p): self.core_procs.append(p) def registrations_complete(self): pass def unregister(self, p): self.procs.remove(p) def has_process(self, name): return len([p for p in self.procs if p.name == name]) > 0 def get_process(self, name): val = [p for p in self.procs if p.name == name] if val: return val[0] return None def has_main_thread_jobs(self): return False def do_main_thread_jobs(self): pass def kill_process(self, name): pass def shutdown(self): pass def get_active_names(self): return [p.name for p in self.procs] def get_process_names_with_spawn_count(self): actives = [(p.name, p.spawn_count) for p in self.procs] deads = [] return [actives, deads] def mainthread_spin_once(self): pass def mainthread_spin(self): pass def run(self): pass ## Test roslaunch.server class TestRoslaunchChild(unittest.TestCase): def setUp(self): self.pmon = ProcessMonitorMock() try: # if there is a core up, we have to use its run id m = rosgraph.Master('/roslaunch') self.run_id = m.getParam('/run_id') except: self.run_id = 'foo-%s'%time.time() def test_roslaunchChild(self): # this is mainly a code coverage test to try and make sure that we don't # have any uninitialized references, etc... from roslaunch.child import ROSLaunchChild name = 'child-%s'%time.time() server_uri = 'http://unroutable:1234' c = ROSLaunchChild(self.run_id, name, server_uri) self.assertEquals(self.run_id, c.run_id) self.assertEquals(name, c.name) self.assertEquals(server_uri, c.server_uri) # - this check tests our assumption about c's process monitor field self.assertEquals(None, c.pm) self.assertEquals(None, c.child_server) # should be a noop c.shutdown() # create a new child to test _start_pm() and shutdown() c = ROSLaunchChild(self.run_id, name, server_uri) # - test _start_pm and shutdown logic c._start_pm() self.assert_(c.pm is not None) c.shutdown() # create a new child to test run() with a fake process # monitor. this requires an actual parent server to be running import roslaunch.config server = roslaunch.server.ROSLaunchParentNode(roslaunch.config.ROSLaunchConfig(), self.pmon) # - register a fake child with the server so that it accepts registration from ROSLaunchChild server.add_child(name, ChildProcessMock('foo')) try: server.start() self.assert_(server.uri, "server URI did not initialize") c = ROSLaunchChild(self.run_id, name, server.uri) c.pm = self.pmon # - run should speed through c.run() finally: server.shutdown('test done') # one final test for code completness: raise an exception during run() c = ROSLaunchChild(self.run_id, name, server_uri) def bad(): raise Exception('haha') # - violate some encapsulation here just to make sure the exception happens c._start_pm = bad try: # this isn't really a correctness test, this just manually # tests that the exception is logged c.run() except: pass def kill_parent(p, delay=1.0): # delay execution so that whatever pmon method we're calling has time to enter import time time.sleep(delay) print("stopping parent") p.shutdown()
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/unit/test_roslaunch_launch.py
# Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import os import sys import unittest ## Test roslaunch.launch class TestRoslaunchLaunch(unittest.TestCase): def setUp(self): self.printerrlog_msg = None def my_printerrlog(self, msg): self.printerrlog_msg = msg def test_validate_master_launch(self): import roslaunch.launch from roslaunch.core import Master from roslaunch.launch import validate_master_launch roslaunch.launch.printerrlog = self.my_printerrlog # Good configurations os.environ['ROS_MASTER_URI'] = 'http://localhost:11311' m = Master(uri='http://localhost:11311') validate_master_launch(m, True) self.assertEquals(None, self.printerrlog_msg) validate_master_launch(m, False) self.assertEquals(None, self.printerrlog_msg) # roscore with mismatched port in environment os.environ['ROS_MASTER_URI'] = 'http://localhost:11312' validate_master_launch(m, True) self.assert_('port' in self.printerrlog_msg) self.printerrlog_msg = None # roscore with mismatched hostname in environment os.environ['ROS_MASTER_URI'] = 'http://fake:11311' validate_master_launch(m, True) self.assert_('host' in self.printerrlog_msg) self.printerrlog_msg = None # roslaunch with remote master that cannot be contacted os.environ['ROS_MASTER_URI'] = 'http://fake:11311' self.assertEquals(None, self.printerrlog_msg) # environment doesn't matter for remaining tests os.environ['ROS_MASTER_URI'] = 'http://localhost:11311' m = Master(uri="http://fake:11311") # roscore with hostname that points elsewhere, warn user. This # generally could only happen if the user has a bad local host # config. validate_master_launch(m, True) self.assert_("WARNING" in self.printerrlog_msg) self.printerrlog_msg = None # roscore with host that is not ours m = Master(uri="http://willowgarage.com:11311") validate_master_launch(m, True) self.assert_("WARNING" in self.printerrlog_msg) self.printerrlog_msg = None # roslaunch with remote master that is out of contact, fail try: validate_master_launch(m, False) self.fail("should not pass if remote master cannot be contacted") except roslaunch.RLException: pass def test__unify_clear_params(self): from roslaunch.launch import _unify_clear_params self.assertEquals([], _unify_clear_params([])) for t in [['/foo'], ['/foo/'], ['/foo/', '/foo'], ['/foo/', '/foo/'], ['/foo/', '/foo/bar', '/foo/'], ['/foo/', '/foo/bar', '/foo/bar/baz']]: self.assertEquals(['/foo/'], _unify_clear_params(t)) for t in [['/'], ['/', '/foo/'], ['/foo/', '/', '/baz', '/car/dog']]: self.assertEquals(['/'], _unify_clear_params(t)) self.assertEquals(['/foo/', '/bar/', '/baz/'], _unify_clear_params(['/foo', '/bar', '/baz'])) self.assertEquals(['/foo/', '/bar/', '/baz/'], _unify_clear_params(['/foo', '/bar', '/baz', '/bar/delta', '/baz/foo'])) self.assertEquals(['/foo/bar/'], _unify_clear_params(['/foo/bar', '/foo/bar/baz'])) def test__hostname_to_rosname(self): from roslaunch.launch import _hostname_to_rosname self.assertEquals("host_ann", _hostname_to_rosname('ann')) self.assertEquals("host_ann", _hostname_to_rosname('ANN')) self.assertEquals("host_", _hostname_to_rosname('')) self.assertEquals("host_1", _hostname_to_rosname('1')) self.assertEquals("host__", _hostname_to_rosname('_')) self.assertEquals("host__", _hostname_to_rosname('-')) self.assertEquals("host_foo_laptop", _hostname_to_rosname('foo-laptop')) def test_roslaunchListeners(self): import roslaunch.launch class L(roslaunch.launch.ROSLaunchListener): def process_died(self, process_name, exit_code): self.process_name = process_name self.exit_code = exit_code class LBad(roslaunch.launch.ROSLaunchListener): def process_died(self, process_name, exit_code): raise Exception("foo") listeners = roslaunch.launch._ROSLaunchListeners() l1 = L() l2 = L() lbad = L() l3 = L() # test with no listeners listeners.process_died('p0', 0) # test with 1 listener listeners.add_process_listener(l1) listeners.process_died('p1', 1) self.assertEquals(l1.process_name, 'p1') self.assertEquals(l1.exit_code, 1) # test with 2 listeners listeners.add_process_listener(l2) listeners.process_died('p2', 2) for l in [l1, l2]: self.assertEquals(l.process_name, 'p2') self.assertEquals(l.exit_code, 2) listeners.add_process_listener(lbad) # make sure that this catches errors listeners.process_died('p3', 3) for l in [l1, l2]: self.assertEquals(l.process_name, 'p3') self.assertEquals(l.exit_code, 3) # also add a third listener to make sure that listeners continues after lbad throws listeners.add_process_listener(l3) listeners.process_died('p4', 4) for l in [l1, l2, l3]: self.assertEquals(l.process_name, 'p4') self.assertEquals(l.exit_code, 4) # this is just to get coverage, it's an empty class def test_ROSRemoteRunnerIF(): from roslaunch.launch import ROSRemoteRunnerIF r = ROSRemoteRunnerIF() r.setup() r.add_process_listener(1) r.launch_remote_nodes() def test_ROSLaunchListener(): from roslaunch.launch import ROSLaunchListener r = ROSLaunchListener() r.process_died(1, 2)
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-machine-invalid-4.xml
<launch> <!-- address is required --> <machine name="machine1" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-invalid-ns.xml
<launch> <node pkg="package" type="test_ns_invalid" ns="" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-test-invalid-output.xml
<launch> <test test-name="test4" pkg="package" type="test_output_screen" output="screen" /> <test test-name="test5" pkg="package" type="test_output_log" output="log" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-rosparam-load-multi.xml
<launch> <node pkg="package" type="test_node_rosparam_multi" name="rosparam_multi"> <rosparam file="$(find roslaunch)/test/params.yaml" command="load" /> <rosparam file="mdump.yaml" command="dump" /> <rosparam ns="msubns" file="$(find roslaunch)/test/params.yaml" command="load" /> </node> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-machine-invalid.xml
<launch> <machine name="machine1" address="address1" default="foo" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-valid.xml
<launch> <node name="n1" pkg="package" type="test_base" /> <node name="n2" pkg="package" type="test_args" args="args test" /> <node name="n3" pkg="package" type="test_args_empty" args="" /> <!-- TODO: more substitution args? --> <node name="n4" pkg="package" type="test_output_screen" output="screen" /> <node name="n5" pkg="package" type="test_output_log" output="log" /> <node name="n6" pkg="package" type="test_machine" machine="machine_test" /> <node name="n7" pkg="package" type="test_ns1" ns="ns_test1" /> <node name="n8" pkg="package" type="test_ns2" ns="ns_test2/child2" /> <node name="n9" pkg="package" type="test_ns3" ns="ns_test3/child3/" /> <node name="n10" pkg="package" type="test_respawn_true" respawn="true" /> <node name="n11" pkg="package" type="test_respawn_TRUE" respawn="TRUE" /> <node name="n12" pkg="package" type="test_respawn_false" respawn="false" /> <node name="n13" pkg="package" type="test_respawn_FALSE" respawn="FALSE" /> <node name="n14" pkg="package" type="test_respawn_none" /> <node name="n15" pkg="package" type="test_env"> <env name="env1" value="env1 value1" /> <env name="env2" value="env2 value2" /> </node> <node name="n16" pkg="package" type="test_fake"> <!-- unrecognized tags are ok, but will print warnings to screen --> <fake name="env2" value="env2 value2" /> </node> <node name="n17" pkg="package" type="test_env_empty"> <env name="env1" value="" /> </node> <!-- base test of private parameter --> <node name="test_private_param1" pkg="package" type="test_param"> <param name="foo1" value="bar1" /> </node> <!-- test ns attribute --> <node name="test_private_param2" ns="ns_test" pkg="package" type="test_param"> <param name="foo2" value="bar2" /> </node> <!-- test with noop tilde syntax --> <node name="test_private_param3" pkg="package" type="test_param"> <param name="~foo3" value="bar3" /> </node> <node name="n21" pkg="package" type="test_cwd_2" cwd="node" /> <node name="n22" pkg="package" type="test_cwd_3" cwd="ROS_HOME" /> <node name="n23" pkg="package" type="test_cwd_3" cwd="ros_home" /> <node pkg="package" type="test_node_rosparam_load" name="rosparam_load"> <rosparam file="$(find roslaunch)/test/params.yaml" command="load" /> </node> <node pkg="package" type="test_node_rosparam_dump" name="rosparam_dump"> <rosparam file="dump.yaml" command="dump" /> </node> <node pkg="package" type="test_node_rosparam_load_ns" name="load_ns"> <rosparam ns="subns" file="$(find roslaunch)/test/params.yaml" command="load" /> </node> <node pkg="package" type="test_node_rosparam_multi" name="rosparam_multi"> <rosparam file="$(find roslaunch)/test/params.yaml" command="load" /> <rosparam file="mdump.yaml" command="dump" /> <rosparam ns="msubns" file="$(find roslaunch)/test/params.yaml" command="load" /> </node> <node name="n26" pkg="package" type="test_required_true_1" required="true" /> <node name="n27" pkg="package" type="test_required_true_2" required="True" /> <node name="n28" pkg="package" type="test_required_false_1" required="false" /> <node name="n29" pkg="package" type="test_required_false_2" required="FALSE" /> <!-- TODO remap args test --> <node name="n30" pkg="package" type="test_launch_prefix" launch-prefix="xterm -e gdb --args" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-machine-invalid-5.xml
<launch> <!-- name is required --> <machine address="address1" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/noop.launch
<launch> <!-- roslaunch file that loads no nodes, and thus should exit immediately --> <param name="noop" value="noop" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-arg-all.xml
<launch> <arg name="required" /> <arg name="optional" default="not_set" /> <arg name="grounded" value="parent" /> <arg name="include_arg" value="dontcare" /> <arg name="if_test" value="dontcare" /> <arg name="param1_name" value="p1" /> <arg name="param2_name" value="p2" /> <arg name="param3_name" value="p3" /> <arg name="param1_value" value="$(arg required)" /> <arg name="param2_value" value="$(arg optional)" /> <arg name="param3_value" value="$(arg grounded)" /> <param name="$(arg param1_name)_test" value="$(arg param1_value)" /> <param name="$(arg param2_name)_test" value="$(arg param2_value)" /> <param name="$(arg param3_name)_test" value="$(arg param3_value)" /> <!-- Normal include: explicitly set args --> <include ns="notall" file="$(find roslaunch)/test/xml/test-arg-include.xml"> <arg name="required" value="$(arg required)" /> <arg name="include_arg" value="$(arg include_arg)" /> <arg name="if_test" value="$(arg if_test)" /> </include> <!-- Normal include: explicitly set args, including an optional one --> <include ns="notall_optional" file="$(find roslaunch)/test/xml/test-arg-include.xml"> <arg name="required" value="$(arg required)" /> <arg name="optional" value="$(arg optional)" /> <arg name="include_arg" value="$(arg include_arg)" /> <arg name="if_test" value="$(arg if_test)" /> </include> <!-- Include with passing in all args in my namespace --> <include ns="all" file="$(find roslaunch)/test/xml/test-arg-include.xml" pass_all_args="true"> </include> <!-- Include with passing in all args in my namespace, and then override one of them explicitly --> <include ns="all_override" file="$(find roslaunch)/test/xml/test-arg-include.xml" pass_all_args="true"> <arg name="required" value="override" /> </include> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-machine-invalid-7.xml
<launch> <!-- timeout must be a number --> <machine timeout="ten" name="one" address="address1" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/invalid-xml.xml
<blah>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-invalid-machine.xml
<launch> <node name="n" pkg="package" type="test_ns_invalid" machine="" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-env.xml
<launch> <node name="n0" pkg="package" type="test_none" /> <env name="ONE" value="one" /> <node name="n1" pkg="package" type="test_one"> </node> <env name="TWO" value="two" /> <node name="n2" pkg="package" type="test_one_two_priv"> <env name="PRIVATE_TWO" value="private_two" /> </node> <node name="n3" pkg="package" type="test_one_two" /> <include file="$(find roslaunch)/test/xml/test-env-include.xml"> <env name="INCLUDE" value="include" /> </include> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-machine-invalid-6.xml
<launch> <!-- timeout must be non-empty --> <machine timeout="" name="one" address="address1" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-invalid-required-1.xml
<launch> <node name="n" pkg="package" type="type" required="" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-dump-rosparam.launch
<launch> <rosparam file="$(find roslaunch)/test/dump-params.yaml" command="load" /> <group ns="rosparam"> <rosparam file="$(find roslaunch)/test/dump-params.yaml" command="load" /> </group> <node pkg="package" type="test_base" name="node_rosparam"> <rosparam file="$(find roslaunch)/test/dump-params.yaml" command="load" /> </node> <rosparam param="inline_str">value1</rosparam> <rosparam param="inline_list">[1, 2, 3, 4]</rosparam> <rosparam param="inline_dict">{key1: value1, key2: value2}</rosparam> <rosparam param="inline_dict2"> key3: value3 key4: value4 </rosparam> <rosparam param="override">{key1: value1, key2: value2}</rosparam> <rosparam param="override">{key1: override1}</rosparam> <!-- no key tests --> <rosparam> noparam1: value1 noparam2: value2 </rosparam> <!-- allow empty files. we test absense of loading in test-rosparam-empty. Here we include to make sure this doesn't blank out other parameters --> <rosparam file="$(find roslaunch)/test/params_empty1.yaml" command="load" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-invalid-required-2.xml
<launch> <node name="n" pkg="package" type="type" required="foo" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-test-invalid-respawn.xml
<launch> <test test-name="test10" pkg="package" type="test_respawn_true" respawn="true" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-rosparam-delete.xml
<launch> <group ns="ns1"> <node pkg="package" type="test_node_rosparam_delete" name="rosparam_delete"> <rosparam ns="ns2" param="param" command="delete" /> </node> </group> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-invalid-pkg.xml
<launch> <node type="type" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-env-include.xml
<launch> <node name="n12i" pkg="package" type="test_one_two_include" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-invalid-respawn.xml
<launch> <node name="n" pkg="package" type="type" respawn="foo" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-invalid-env-name-2.xml
<launch> <node name="n" pkg="package" type="env_test_invalid_name"> <env name="" value="env1 value1" /> </node> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-params-valid.xml
<launch> <!-- Parameter Server parameters. You can omit the 'type' attribute if value is unambiguous. Supported types are str, int, double, bool. You can also specify the contents of a file instead using the 'textfile' or 'binfile' attributes. --> <param name="somestring1" value="bar2" /> <!-- force to string instead of integer --> <param name="somestring2" value="10" type="str" /> <param name="someinteger1" value="1" type="int" /> <param name="someinteger2" value="2" /> <param name="somefloat1" value="3.14159" type="double" /> <param name="somefloat2" value="5.0" /> <!-- you can set parameters in child namespaces --> <param name="wg/wgchildparam" value="a child namespace parameter 1" /> <group ns="wg2"> <param name="wg2childparam1" value="a child namespace parameter 2" /> <param name="wg2childparam2" value="a child namespace parameter 3" /> </group> <!-- upload the contents of a file as a param --> <param name="configfile" textfile="$(find roslaunch)/resources/example.launch" /> <!-- upload the contents of a file as base64 binary as a param --> <param name="binaryfile" binfile="$(find roslaunch)/resources/example.launch" /> <!-- upload the output of a command as a param. --> <param name="commandoutput" command="cat &quot;$(find roslaunch)/resources/example.launch&quot;" /> <!-- test that we can override params --> <param name="override" value="fail" /> <param name="override" value="pass" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-invalid-cwd.xml
<launch> <node name="n" pkg="package" type="test_cwd_invalid" cwd="foo" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-invalid-ns-2.xml
<launch> <node pkg="package" type="test_ns_invalid" ns="" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-if-unless-invalid-both.xml
<launch> <group if="1" unless="1"> </group> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-rosparam-invalid-5.xml
<launch> <rosparam>1</rosparam> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-if-unless.xml
<launch> <group if="1"> <param name="group_if_pass" value="1" /> </group> <group if="0"> <param name="group_if_fail" value="1" /> </group> <group unless="0"> <param name="group_unless_pass" value="1" /> </group> <group unless="1"> <param name="group_unless_fail" value="1" /> </group> <param name="param_if_pass" value="1" if="1" /> <param name="param_if_fail" value="1" if="0" /> <param name="param_unless_pass" value="1" unless="0" /> <param name="param_unless_fail" value="1" unless="1" /> <remap from="from_if_pass" to="to_if_pass" if="1" /> <remap from="from_if_fail" to="to_if_fail" if="0" /> <remap from="from_unless_pass" to="to_unless_pass" unless="0" /> <remap from="from_unless_fail" to="to_unless_fail" unless="1" /> <node name="remap" pkg="rospy" type="talker.py" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-rosparam-invalid-4.xml
<launch> <rosparam command="bad" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-invalid-ns-3.xml
<launch> <node pkg="package" type="test_ns_invalid" ns="/global" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-substitution.xml
<launch> <env name="$(anon foo)/bar" value="$(anon foo)/baz" /> <remap from="$(anon foo)/bar" to="$(anon foo)/baz" /> <node name="n1" pkg="$(optenv FOO foo)" type="$(optenv BAR bar)" args="$(find roslib)"> <param name="$(anon foo)/bar" value="$(anon foo)/bar" /> </node> <node name="n2" pkg="$(anon foo)" type="$(anon bar)" args="$(anon baz)" /> <param name="$(anon foo)/bar" value="$(anon foo)/bar" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-invalid-name-3.xml
<launch> <!-- names cannot have namespaces --> <node pkg="package" type="test_cwd_invalid" name="ns/name" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-valid.xml
<launch> <!-- allowed to have new tags, just warns --> <newtag /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-invalid-name-2.xml
<launch> <node pkg="package" type="name_test_invalid_value" name="ns/foo" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-rosparam-valid.xml
<launch> <rosparam file="$(find roslaunch)/test/params.yaml" command="load" /> <rosparam file="$(find roslaunch)/test/dump.yaml" command="dump" /> <group ns="rosparam"> <rosparam file="$(find roslaunch)/test/params.yaml" command="load" /> <rosparam file="$(find roslaunch)/test/dump2.yaml" command="dump" /> </group> <node pkg="package" type="test_base" name="node_rosparam"> <rosparam file="$(find roslaunch)/test/params.yaml" command="load" /> </node> <rosparam param="inline_str">value1</rosparam> <rosparam param="inline_list">[1, 2, 3, 4]</rosparam> <rosparam param="inline_dict">{key1: value1, key2: value2}</rosparam> <rosparam param="inline_dict2"> key3: value3 key4: value4 </rosparam> <rosparam param="override">{key1: value1, key2: value2}</rosparam> <rosparam param="override">{key1: override1}</rosparam> <!-- no key tests --> <rosparam> noparam1: value1 noparam2: value2 </rosparam> <!-- #3580: make sure angle/deg conversions work --> <rosparam param="dict_degrees"> deg0: deg(0) deg180: deg(180) deg360: deg(360) </rosparam> <rosparam param="dict_rad"> rad0: rad(0) radpi: rad(pi) rad2pi: rad(2*pi) </rosparam> <rosparam param="inline_degrees0">deg(0)</rosparam> <rosparam param="inline_degrees180">deg(180)</rosparam> <rosparam param="inline_degrees360">deg(360)</rosparam> <rosparam param="inline_rad0">rad(0)</rosparam> <rosparam param="inline_radpi">rad(pi)</rosparam> <rosparam param="inline_rad2pi">rad(2*pi)</rosparam> <!-- allow empty files. we test absense of loading in test-rosparam-empty. Here we include to make sure this doesn't blank out other parameters --> <rosparam file="$(find roslaunch)/test/params_empty1.yaml" command="load" /> <rosparam file="$(find roslaunch)/test/params_empty2.yaml" command="load" /> <rosparam command="load"/> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-rosparam-invalid-1.xml
<launch> <rosparam file="$(find rosparam)/example.yaml" command="foo" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-test-invalid-time-limit-1.xml
<launch> <test test-name="test4" pkg="package" type="test_time_limit" time-limit="string" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-local-param-group.xml
<launch> <!-- no local params --> <node pkg="pkg" type="type0" name="node0"/> <group ns="group1"> <!-- basic test, named nodes --> <node pkg="pkg" type="gtype0" name="g1node0" /> <param name="~gparam1" value="val1" /> <node pkg="pkg" type="g1type1" name="g1node1" /> <param name="~gparam2" value="val1" /> <node pkg="pkg" type="g1type2" name="g1node2" /> </group> <!-- make sure scope is cleared by end of group --> <param name="~param1" value="val1" /> <node pkg="pkg" type="type1" name="node1" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-invalid-env-name.xml
<launch> <node name="n" pkg="package" type="env_test_invalid_name"> <env value="env1 value1" /> </node> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-rosparam-invalid-3.xml
<launch> <rosparam file="$(find rosparam)/foo.yaml" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-arg-invalid-include.xml
<launch> <include file="$(find roslaunch)/test/xml/test-arg-invalid-included.xml"> <arg name="grounded" value="not_set"/> </include> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-arg-include.xml
<launch> <arg name="required" /> <arg name="if_test" /> <arg name="include_arg" /> <arg name="optional" default="not_set" /> <arg name="grounded" value="set" /> <arg name="param1_name" value="p1" /> <arg name="param2_name" value="p2" /> <arg name="param3_name" value="p3" /> <arg name="param4_name" value="p4" /> <arg name="param1_value" value="$(arg required)" /> <arg name="param2_value" value="$(arg optional)" /> <arg name="param3_value" value="$(arg grounded)" /> <group ns="include_test"> <param name="$(arg param1_name)_test" value="$(arg param1_value)" /> <param name="$(arg param2_name)_test" value="$(arg param2_value)" /> <param name="$(arg param3_name)_test" value="$(arg param3_value)" /> <param name="$(arg param4_name)_test" value="$(arg include_arg)" /> </group> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-invalid-name-1.xml
<launch> <!-- this test is currently disabled is this is legal right now --> <!-- name attribute missing with param set --> <node pkg="package" type="name_test_invalid_value"> <param name="foo" value="bar" /> </node> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-clear-params.xml
<launch> <node pkg="package" type="type" name="test_clear_params1" clear_params="true" /> <node pkg="package" type="type" name="test_clear_params2" clear_params="True" /> <node pkg="package" type="type" name="test_clear_params_ns" ns="clear_params_ns" clear_params="true"/> <node pkg="package" type="type" name="test_clear_params_default" ns="clear_params_default" /> <node pkg="package" type="type" name="test_clear_params_false" ns="clear_params_false" clear_params="False"/> <group ns="group_test" clear_params="true"> </group> <group ns="group_test_default"> </group> <group ns="group_test_false" clear_params="false"> </group> <group ns="embed_group_test"> <group ns="embedded_group" clear_params="true" /> </group> <include ns="include_test" clear_params="true" file="$(find roslaunch)/test/xml/test-clear-params-include.xml" /> <include ns="include_test_false" clear_params="false" file="$(find roslaunch)/test/xml/test-clear-params-include.xml" /> <include ns="include_test_default" file="$(find roslaunch)/test/xml/test-clear-params-include.xml" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-rosparam-invalid-2.xml
<launch> <rosparam file="" command="load" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-invalid-env-value.xml
<launch> <node name="n" pkg="package" type="env_test_invalid_value"> <env name="env1" /> </node> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-rosparam-load-param.xml
<launch> <node pkg="package" type="test_node_rosparam_load_param" name="load_param"> <rosparam param="param" file="$(find roslaunch)/test/params.yaml" command="load" /> </node> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-test-invalid-time-limit-2.xml
<launch> <test test-name="test4" pkg="package" type="test_time_limit" time-limit="-1" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-machine-invalid-10.xml
<launch> <machine name="machine3" address="address3" ros-ip="hostname" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/not-launch.xml
<foo />
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-node-invalid-pkg-2.xml
<launch> <node pkg="" type="type" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-remap-valid.xml
<launch> <!-- remap tags are evaluated sequentially and are scoped --> <remap from="foo" to="bar" /> <!-- should just get foo-bar --> <node name="n1" pkg="pkg" type="node1" /> <group ns="ns1"> <remap from="foo" to="baz" /> <node name="n2" pkg="pkg" type="node2" /> </group> <!-- foo-baz should leave scope, should get foo-bar --> <node name="n3" pkg="pkg" type="node3" /> <!-- should override existing, now foo-bar --> <remap from="foo" to="far" /> <node name="n4" pkg="pkg" type="node4" /> <!-- test remaps within node's scope --> <node name="n5" pkg="pkg" type="node5"> <remap from="foo" to="fad" /> <remap from="a" to="b" /> <remap from="c" to="d" /> </node> <!-- test multiple remaps --> <remap from="old1" to="new1" /> <remap from="old2" to="new2" /> <remap from="old3" to="new3" /> <node name="n6" pkg="pkg" type="node6" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-machine-substitution.xml
<launch> <machine name="$(env NAME)" address="$(env ADDRESS)" /> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-machine-invalid-11.xml
<launch> <machine name="machine4" address="address4"> <env name="ENV1" value="value1" /> <env name="ENV2" value="value2" /> <env name="ENV3" value="value3" /> </machine> </launch>
0
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test
apollo_public_repos/apollo-platform/ros/ros_comm/roslaunch/test/xml/test-arg-valid-include.xml
<launch> <arg name="grounded" value="not_set"/> <include file="$(find roslaunch)/test/xml/test-arg-invalid-included.xml" pass_all_args="true"/> </launch>
0