Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix various test problems #1601

Merged
merged 5 commits into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions test/test_rostest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 2.8.3)

project(test_rostest)

find_package(catkin REQUIRED COMPONENTS rostest)

catkin_package()

if(CATKIN_ENABLE_TESTING)
add_rostest(test/publishtest.test)
endif()
17 changes: 17 additions & 0 deletions test/test_rostest/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<package>
<name>test_rostest</name>
<version>1.14.3</version>
<description>
Tests for rostest.
</description>
<maintainer email="dthomas@osrfoundation.org">Dirk Thomas</maintainer>
<license>BSD</license>

<url>http://ros.org/wiki/rostest</url>

<buildtool_depend>catkin</buildtool_depend>

<build_depend>rostest</build_depend>

<test_depend>rostopic</test_depend>
</package>
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<launch>

<node name="talker_0"
pkg="rospy" type="talker.py">
pkg="test_rostest" type="talker.py">
<remap from="chatter" to="~output" />
</node>

<node name="talker_1"
pkg="rospy" type="talker.py">
pkg="test_rostest" type="talker.py">
<remap from="chatter" to="~output" />
</node>

<node name="talker_2"
pkg="rostest" type="just_advertise">
pkg="test_rostest" type="just_advertise">
<rosparam>
msg_name: std_msgs/String
</rosparam>
Expand Down
53 changes: 53 additions & 0 deletions test/test_rostest/test_nodes/talker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/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.

## Simple talker demo that published std_msgs/Strings messages
## to the 'chatter' topic

import rospy
from std_msgs.msg import String

def talker():
rospy.init_node('talker', anonymous=True)
pub = rospy.Publisher('chatter', String, queue_size=10)
r = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
str = "hello world %s"%rospy.get_time()
rospy.loginfo(str)
pub.publish(str)
r.sleep()

if __name__ == '__main__':
try:
talker()
except rospy.ROSInterruptException: pass
2 changes: 1 addition & 1 deletion tools/rosbag_storage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if(NOT WIN32)
endif()

find_package(console_bridge REQUIRED)
find_package(catkin REQUIRED COMPONENTS cpp_common pluginlib roscpp_serialization roscpp_traits rostime roslz4)
find_package(catkin REQUIRED COMPONENTS cpp_common pluginlib roscpp_serialization roscpp_traits rostime roslz4 std_msgs)
find_package(Boost REQUIRED COMPONENTS date_time filesystem program_options regex)
find_package(BZip2 REQUIRED)

Expand Down
1 change: 1 addition & 0 deletions tools/rosbag_storage/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<build_depend>rostest</build_depend>
<build_depend>rostime</build_depend>
<build_depend>roslz4</build_depend>
<build_depend>std_msgs</build_depend>

<run_depend>boost</run_depend>
<run_depend>bzip2</run_depend>
Expand Down
3 changes: 2 additions & 1 deletion tools/rosgraph/test/test_roslogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def test_rosconsole__logging_format():
this_file,
'[0-9]*',
function,
'/unnamed',
# depending if rospy.get_name() is available
'(/unnamed|<unknown_node_name>)',
'[0-9]*\.[0-9]*',
])
assert_regexp_matches(lout.getvalue().splitlines()[i], log_out)
Expand Down
3 changes: 2 additions & 1 deletion tools/rosgraph/test/test_roslogging_user_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ def test_roslogging_user_logger():
'<filename>',
'<lineno>',
'<func_name>',
'/unnamed',
# depending if rospy.get_name() is available
'(/unnamed|<unknown_node_name>)',
'[0-9]*\.[0-9]*',
])
assert_regexp_matches(lout.getvalue().strip(), log_expected)
Expand Down
10 changes: 5 additions & 5 deletions tools/roslaunch/test/unit/test_nodeprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_create_node_process(self):
pass

# have to specify a real node
n = Node('rospy','talker.py')
n = Node('roslaunch','talker.py')
n.machine = m
try: # should fail b/c n.name is not set
create_node_process(run_id, n, master_uri)
Expand All @@ -113,7 +113,7 @@ def test_create_node_process(self):
pass

# have to specify a real node
n = Node('rospy','talker.py')
n = Node('roslaunch','talker.py')

n.machine = None
n.name = 'talker'
Expand All @@ -140,7 +140,7 @@ def test_create_node_process(self):
self.fail('%s should not be set: %s'%(k,d[k]))

# test package and name
self.assertEquals(p.package, 'rospy')
self.assertEquals(p.package, 'roslaunch')
# - no 'correct' full answer here
self.assert_(p.name.startswith('talker'), p.name)

Expand Down Expand Up @@ -171,7 +171,7 @@ def test_create_node_process(self):
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]
cmd = roslib.packages.find_node('roslaunch', 'talker.py', rospack)[0]
self.assertEquals(p.args[0], cmd)

# - test basic args
Expand All @@ -188,7 +188,7 @@ def test_create_node_process(self):
self.assert_('KEY2:=VAL2' in p.args)

# - test __name
n = Node('rospy','talker.py')
n = Node('roslaunch','talker.py')
n.name = 'fooname'
n.machine = m
self.assert_('__name:=fooname' in create_node_process(run_id, n, master_uri).args)
Expand Down
53 changes: 53 additions & 0 deletions tools/roslaunch/test_nodes/talker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/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.

## Simple talker demo that published std_msgs/Strings messages
## to the 'chatter' topic

import rospy
from std_msgs.msg import String

def talker():
rospy.init_node('talker', anonymous=True)
pub = rospy.Publisher('chatter', String, queue_size=10)
r = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
str = "hello world %s"%rospy.get_time()
rospy.loginfo(str)
pub.publish(str)
r.sleep()

if __name__ == '__main__':
try:
talker()
except rospy.ROSInterruptException: pass
1 change: 0 additions & 1 deletion tools/rostest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ if(CATKIN_ENABLE_TESTING)

add_rostest(test/hztest0.test)
add_rostest(test/hztest.test)
add_rostest(test/publishtest.test)
add_rostest(test/clean_master.test)
add_rostest(test/distro_version.test)
add_rostest(test/param.test)
Expand Down
2 changes: 1 addition & 1 deletion tools/rostest/test/hztest.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<launch>
<node name="talker" pkg="rospy" type="talker.py" />
<node name="talker" pkg="rostest" type="talker.py" />

<param name="hztest1/topic" value="chatter" />
<param name="hztest1/hz" value="10.0" />
Expand Down
53 changes: 53 additions & 0 deletions tools/rostest/test_nodes/talker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/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.

## Simple talker demo that published std_msgs/Strings messages
## to the 'chatter' topic

import rospy
from std_msgs.msg import String

def talker():
rospy.init_node('talker', anonymous=True)
pub = rospy.Publisher('chatter', String, queue_size=10)
r = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
str = "hello world %s"%rospy.get_time()
rospy.loginfo(str)
pub.publish(str)
r.sleep()

if __name__ == '__main__':
try:
talker()
except rospy.ROSInterruptException: pass