diff --git a/tools/rostest/nodes/publishtest b/tools/rostest/nodes/publishtest index b298491e9f..92bd0e74bf 100755 --- a/tools/rostest/nodes/publishtest +++ b/tools/rostest/nodes/publishtest @@ -54,6 +54,7 @@ Author: Kentaro Wada """ import sys +import time import unittest from nose.tools import assert_true @@ -107,10 +108,15 @@ class PublishTest(unittest.TestCase): def test_publish(self): """Test topics are published and messages come""" use_sim_time = rospy.get_param('/use_sim_time', False) - while use_sim_time and (rospy.Time.now() == rospy.Time(0)): - rospy.logwarn('/use_sim_time is specified and rostime is 0, ' - '/clock is published?') - rospy.sleep(0.1) + t_start = time.time() + while not rospy.is_shutdown() and \ + use_sim_time and (rospy.Time.now() == rospy.Time(0)): + rospy.logwarn_throttle( + 1, '/use_sim_time is specified and rostime is 0, /clock is published?') + if time.time() - t_start > 10: + self.fail('Timed out (10s) of /clock publication.') + # must use time.sleep because /clock isn't yet published, so rospy.sleep hangs. + time.sleep(0.1) # subscribe topics checkers = [] for topic in self.topics: