test-rtshell-setup.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 PKG = 'openrtm_tools'
4 NAME = 'test_rthsell_setup'
5 
6 import unittest, os, sys
7 import subprocess
8 from subprocess import call, check_output, Popen, PIPE, STDOUT
9 
10 class TestOpenrtmTools(unittest.TestCase):
11 
12  def run_rt_command(self, command):
13  pkg_path = check_output("rospack find openrtm_tools", shell=True).rstrip()
14  script = os.path.join(pkg_path, "scripts/rtshell-setup.sh")
15  self.assertTrue(os.path.exists(script))
16  try:
17  check_output("bash -c 'source %s; RTCTREE_NAMESERVERS=localhost:2809 %s'"%(script, command), shell=True, stderr=subprocess.STDOUT)
18  except subprocess.CalledProcessError, (e):
19  self.assertTrue(False, 'subprocess.CalledProcessError: cmd:%s returncode:%s output:%s' % (e.cmd, e.returncode, e.output))
20  self.assertTrue(True) # ok rtls works
21 
22  def test_rtls(self):
23  self.run_rt_command('rtls')
24 
25  def test_rtprint(self):
26  self.run_rt_command('rtprint -n1 localhost:2809/SequenceOutComponent0.rtc:Float')
27  self.run_rt_command('rtprint -n1 localhost:2809/SequenceOutComponent0.rtc:FloatSeq')
28 
29  def test_rtcat(self):
30  self.run_rt_command('rtcat localhost:2809/SequenceOutComponent0.rtc')
31 
32 #unittest.main()
33 if __name__ == '__main__':
34  import rostest
35  rostest.run(PKG, NAME, TestOpenrtmTools, sys.argv)


openrtm_tools
Author(s): Kei Okada
autogenerated on Mon May 10 2021 02:30:55