This commit is contained in:
Ivan
2022-04-05 11:42:28 +03:00
commit 6dc0eb0fcf
5565 changed files with 1200500 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 2.8.3)
project(test_roslaunch)
find_package(catkin REQUIRED COMPONENTS rostest)
catkin_package()
if(CATKIN_ENABLE_TESTING)
add_rostest(test/roslaunch.test)
add_rostest(test/env.test)
add_rostest(test/params_basic.test)
endif()

View File

@@ -0,0 +1,20 @@
<package>
<name>test_roslaunch</name>
<version>1.12.14</version>
<description>
Tests for roslaunch which depend on rostest.
</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.68">catkin</buildtool_depend>
<build_depend>rostest</build_depend>
<test_depend>python-rospkg</test_depend>
<test_depend>rosgraph</test_depend>
<test_depend>roslaunch</test_depend>
</package>

View File

@@ -0,0 +1,2 @@
string1: bar
dict1: { head: 1, shoulders: 2, knees: 3, toes: 4}

View File

@@ -0,0 +1,57 @@
#!/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.
PKG = 'test_roslaunch'
NAME = 'test_env'
import os, sys, unittest
import rostest
import rospkg
## Test Roslaunch 'env' tags
class TestEnv(unittest.TestCase):
def test_env(self):
if '--noenv' in sys.argv:
self.assertEquals(None, os.environ.get('TEST_ENV', None))
self.assertEquals(None, os.environ.get('TEST_ENV_SUBSTITUTION', None))
else:
self.assertEquals('test env', os.environ.get('TEST_ENV', None))
rospack = rospkg.RosPack()
path1 = os.path.join(rospack.get_path('roslaunch'), 'src')
path2 = os.environ.get('TEST_ENV_SUBSTITUTION', None)
self.assertEquals(os.path.abspath(path1), os.path.abspath(path2))
if __name__ == '__main__':
rostest.rosrun(PKG, NAME, TestEnv)

View File

@@ -0,0 +1,7 @@
<launch>
<test test-name="env" pkg="test_roslaunch" type="env.py" >
<env name="TEST_ENV" value="test env"/>
<env name="TEST_ENV_SUBSTITUTION" value="$(find roslaunch)/src/"/>
</test>
<test test-name="noenv" pkg="test_roslaunch" type="env.py" args="--noenv" />
</launch>

View File

@@ -0,0 +1,22 @@
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

View File

@@ -0,0 +1,121 @@
#!/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.
PKG = 'test_roslaunch'
import os, sys, unittest
try:
from xmlrpc.client import Binary
except ImportError:
from xmlrpclib import Binary
import rostest
import rospkg
import rosgraph
master = rosgraph.Master('params_basic')
def get_param(*args):
return master.getParam(*args)
## Test Roslaunch 'param' tags
class TestParamsBasic(unittest.TestCase):
## test primitive values
def test_values(self):
## Test roslaunch string params
self.assertEquals(get_param('stringempty'), '')
print(get_param('stringbar'))
self.assertEquals(get_param('stringbar'), 'bar')
self.assertEquals(get_param('str10'), '10')
self.assertEquals(get_param('string10'), '10')
self.assertEquals(get_param('stringentity'), '<stringentity/>')
## Test roslaunch integer params
self.assertEquals(get_param("integerneg1"), -1)
self.assertEquals(get_param("integer0"), 0)
self.assertEquals(get_param("integer1"), 1)
self.assertEquals(get_param("integernoop1"), 1)
self.assertEquals(get_param("integer12345"), 12345)
## Test roslaunch float params
self.assertEquals(get_param("floatpi"),3.14159)
self.assertEquals(get_param("floatnooppi"),3.14159)
self.assertEquals(get_param("float3"),3.0)
self.assertEquals(get_param("floatneg1"),-1.0)
## Test roslaunch boolean params
for p in ['true', 'TRUE', 'True']:
self.assertTrue(get_param(p), "[%s] is not false: %s"%(p, get_param(p)))
for p in ['false', "FALSE", 'False']:
self.assertFalse(get_param(p), "[%s] is not false: %s"%(p, get_param(p)))
## Test roslaunch ns attribute (namespace) on params
def test_ns(self):
self.assertEquals(get_param("/wg/childparam"),"wg")
self.assertEquals(get_param("/wg2/childparam"),"wg2")
self.assertEquals(get_param("/wg3/childparam"),"wg3")
self.assertEquals(get_param("/wg/wg4/childparam"),"wg4")
self.assertEquals(get_param("/wg/wg4/wg5/childparam"),"wg5")
## Test roslaunch <group> tag with and without ns attribute
self.assertEquals(get_param("/wga/wg/childparam"),"wg")
self.assertEquals(get_param("/wga/wg2/childparam"),"wg2")
self.assertEquals(get_param("/wga/wg3/childparam"),"wg3")
self.assertEquals(get_param("/wga/wg/wg4/childparam"),"wg4")
self.assertEquals(get_param("/wga/wg/wg4/wg5/childparam"),"wg5")
# test second-level group
self.assertEquals(get_param("/wga/wgb/wg/childparam"),"bwg")
self.assertEquals(get_param("/wga/wgb/wg2/childparam"),"bwg2")
self.assertEquals(get_param("/wga/wgb/wg3/childparam"),"bwg3")
self.assertEquals(get_param("/wga/wgb/wg/wg4/childparam"),"bwg4")
self.assertEquals(get_param("/wga/wgb/wg/wg4/wg5/childparam"),"bwg5")
# test unscoped group
self.assertEquals(get_param("/wgc/childparam"),"wg")
self.assertEquals(get_param("/wgc2/childparam"),"wg2")
self.assertEquals(get_param("/wgc3/childparam"),"wg3")
self.assertEquals(get_param("/wgc/wg4/childparam"),"wg4")
self.assertEquals(get_param("/wgc/wg4/wg5/childparam"),"wg5")
## test 'command' attribute
def test_commandandfile(self):
dir = rospkg.RosPack().get_path('roslaunch')
with open(os.path.join(dir, 'resources', 'example.launch'), 'r') as f:
text_data = f.read()
with open(os.path.join(dir, 'resources', 'example.launch'), 'rb') as f:
binary_data = f.read()
self.assertEquals(get_param("commandoutput"), binary_data)
self.assertEquals(get_param("textfile"), text_data)
## test 'binfile' attribute
bindata = get_param("binaryfile")
self.assertTrue(isinstance(bindata, Binary))
self.assertEquals(bindata.data, binary_data)
if __name__ == '__main__':
rostest.rosrun(PKG, sys.argv[0], TestParamsBasic, sys.argv)

View File

@@ -0,0 +1,66 @@
<launch>
<!-- string parameters -->
<param name="stringempty" value="" />
<param name="stringbar" value="bar" />
<param name="str10" value="10" type="str" />
<param name="string10" value="10" type="string" /> <!-- type alias -->
<param name="stringentity" value="&lt;stringentity/&gt;" />
<!-- integer parameters -->
<param name="integer0" value="0" />
<param name="integer1" value="1" />
<param name="integernoop1" value="1" />
<param name="integer12345" value="12345" />
<param name="integerneg1" value="-1"/>
<!-- float parameters -->
<param name="floatpi" value="3.14159" />
<param name="floatnooppi" value="3.14159" type="double" />
<param name="float3" value="3.0" />
<param name="floatneg1" value="-1.0" />
<!-- boolean parameters -->
<param name="true" value="true" />
<param name="false" value="false" />
<param name="TRUE" value="TRUE" />
<param name="FALSE" value="FALSE" />
<param name="True" value="True" />
<param name="False" value="False" />
<!-- child namespace parameters -->
<param name="wg/childparam" value="wg" />
<param name="wg2/childparam" value="wg2" />
<param name="wg3/childparam" value="wg3" />
<param name="wg/wg4/wg5/childparam" value="wg5" />
<param name="wg/wg4/childparam" value="wg4" />
<group ns="wga">
<param name="wg/childparam" value="wg" />
<param name="wg2/childparam" value="wg2" />
<param name="wg3/childparam" value="wg3" />
<param name="wg/wg4/wg5/childparam" value="wg5" />
<param name="wg/wg4/childparam" value="wg4" />
<group ns="wgb">
<param name="wg/childparam" value="bwg" />
<param name="wg2/childparam" value="bwg2" />
<param name="wg3/childparam" value="bwg3" />
<param name="wg/wg4/wg5/childparam" value="bwg5" />
<param name="wg/wg4/childparam" value="bwg4" />
</group>
</group>
<group> <!-- no ns attribute -->
<param name="wgc/childparam" value="wg" />
<param name="wgc2/childparam" value="wg2" />
<param name="wgc3/childparam" value="wg3" />
<param name="wgc/wg4/wg5/childparam" value="wg5" />
<param name="wgc/wg4/childparam" value="wg4" />
</group>
<param name="textfile" textfile="$(find roslaunch)/resources/example.launch" />
<param name="binaryfile" binfile="$(find roslaunch)/resources/example.launch" />
<param name="commandoutput" command="cat &quot;$(find roslaunch)/resources/example.launch&quot;" />
<test test-name="params_basic" pkg="test_roslaunch" type="params_basic.py" />
</launch>

View File

@@ -0,0 +1,3 @@
#
#
#

View File

@@ -0,0 +1,7 @@
<launch>
<arg name="foo" default="true" doc="I pity the foo'."/>
<arg name="bar" doc="Someone walks into this."/>
<arg name="baz" default="false"/>
<arg name="nop"/>
<arg name="fix" value="true"/>
</launch>

View File

@@ -0,0 +1,4 @@
<launch>
<test test-name="roslaunch_command_line_online" pkg="test_roslaunch" type="test_roslaunch_command_line_online.py" />
<test test-name="roslaunch_ros_args" pkg="test_roslaunch" type="test_roslaunch_ros_args.py" />
</launch>

View File

@@ -0,0 +1,68 @@
#!/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: test_roslaunch_command_line_online.py 6411 2009-10-02 21:32:01Z kwc $
PKG = 'roslaunch'
NAME = 'test_roslaunch_command_line_online'
import os
import sys
import time
import unittest
import yaml
import rostest
from subprocess import Popen, PIPE, check_call, call
class TestRoslaunchOnline(unittest.TestCase):
def setUp(self):
self.vals = set()
self.msgs = {}
def test_roslaunch(self):
# network is initialized
cmd = 'roslaunch'
# regression test for #1994
# --wait
# master is already running, noop only sets params, so this should return
check_call([cmd, '--wait', 'roslaunch', 'noop.launch'])
# tripwire test for #2370, not really possible to validate output on this
check_call([cmd, '--screen', 'roslaunch', 'noop.launch'])
if __name__ == '__main__':
rostest.run(PKG, NAME, TestRoslaunchOnline, sys.argv)

View File

@@ -0,0 +1,67 @@
#!/usr/bin/env python
# Software License Agreement (BSD License)
#
# Copyright (c) 2014, The Johns Hopkins University
# 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.
PKG = 'roslaunch'
NAME = 'test_roslaunch_ros_args'
import os
import sys
import unittest
import rostest
import rospkg
import roslaunch.arg_dump
class TestRoslaunchRosArgs(unittest.TestCase):
def setUp(self):
self.vals = set()
self.msgs = {}
def test_roslaunch(self):
rospack = rospkg.RosPack()
filename = os.path.join(rospack.get_path('test_roslaunch'), 'test', 'ros_args.launch')
args = roslaunch.arg_dump.get_args([filename])
expected_args = {
'foo': ("I pity the foo'.", 'true'),
'bar': ("Someone walks into this.", None,),
'baz': (None, 'false'),
'nop': (None, None)}
self.assertEqual(args, expected_args)
if __name__ == '__main__':
rostest.run(PKG, NAME, TestRoslaunchRosArgs, sys.argv)