00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 PKG = 'test_rostopic'
00037 NAME = 'test_rostopic_command_line_online'
00038 import roslib; roslib.load_manifest(PKG)
00039
00040 import os
00041 import signal
00042 import sys
00043 import time
00044 import unittest
00045
00046 import rospy
00047 import rostest
00048
00049 import std_msgs.msg
00050
00051 from subprocess import Popen, PIPE, check_call, call
00052
00053 def run_for(cmd, secs):
00054 popen = Popen(cmd, stdout=PIPE, stderr=PIPE, close_fds=True)
00055 timeout_t = time.time() + secs
00056 while time.time() < timeout_t:
00057 time.sleep(0.1)
00058 os.kill(popen.pid, signal.SIGKILL)
00059
00060 class TestRostopicOnline(unittest.TestCase):
00061
00062 def setUp(self):
00063 self.vals = set()
00064 self.msgs = {}
00065
00066
00067 def test_cmd_help(self):
00068 cmd = 'roswtf'
00069 output = Popen([cmd, '-h'], stdout=PIPE).communicate()[0]
00070 self.assert_('Options' in output)
00071
00072 def test_offline(self):
00073
00074
00075 cmd = 'roswtf'
00076
00077
00078 env = os.environ.copy()
00079 import roslib.stacks
00080
00081 env['ROS_PACKAGE_PATH'] = roslib.stacks.get_stack_dir('ros_comm')
00082
00083 import roslib.packages
00084 cwd = roslib.packages.get_pkg_dir('test_roswtf')
00085 kwds = { 'env': env, 'stdout': PIPE, 'stderr': PIPE, 'cwd': cwd}
00086
00087
00088
00089
00090
00091 output, err = Popen([cmd], **kwds).communicate()
00092 self.assert_('No errors or warnings' in output, "OUTPUT[%s]\nstderr[%s}"%(output, err))
00093 self.assert_('ERROR' not in output, "OUTPUT[%s]"%output)
00094
00095
00096 import roslib.packages
00097 p = os.path.join(roslib.packages.get_pkg_dir('test_roswtf'), 'test', 'min.launch')
00098 output = Popen([cmd, p], **kwds).communicate()[0]
00099 self.assert_('No errors or warnings' in output, "OUTPUT[%s]"%output)
00100 self.assert_('ERROR' not in output, "OUTPUT[%s]"%output)
00101
00102 if __name__ == '__main__':
00103 rostest.run(PKG, NAME, TestRostopicOnline, sys.argv)