test-hostname.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 PKG = 'hrpsys'
4 NAME = 'test-hostname'
5 
6 import imp ## for rosbuild
7 try:
8  imp.find_module(PKG)
9 except:
10  import roslib; roslib.load_manifest(PKG)
11 
12 from hrpsys import hrpsys_config
13 
14 import socket
15 import rtm
16 
17 import unittest
18 import rostest
19 import sys
20 import time
21 
22 class TestHrpsysHostname(unittest.TestCase):
23 
24  def check_initCORBA(self, nshost, nsport=2809):
25  try:
26  ms = rh = None
27  rtm.nshost = nshost
28  rtm.nsport = nsport
30  count = 0
31  while ( not (ms and rh) ) and count < 10:
32  ms = rtm.findRTCmanager()
33  rh = rtm.findRTC("RobotHardware0")
34  if ms and rh :
35  break
36  time.sleep(1)
37  print >>sys.stderr, "wait for RTCmanager=%r, RTC(RobotHardware0)=%r"%(ms,rh)
38  count += 1
39  self.assertTrue(ms and rh)
40  except Exception as e:
41  self.fail("%r, nshost=%r, nsport=%r RTCmanager=%r, RTC(RobotHardware0)=%r"%(str(e),nshost,nsport,ms,rh))
42  pass
43 
44  def test_gethostname(self):
45  self.check_initCORBA(socket.gethostname())
46  def test_localhost(self):
47  self.check_initCORBA('localhost')
48  def test_127_0_0_1(self):
49  self.check_initCORBA('127.0.0.1')
50  def test_None(self):
51  self.check_initCORBA(None)
52 
53  @unittest.expectedFailure
54  def test_X_unknown(self):
55  try:
56  self.check_initCORBA('unknown')
57  except SystemExit as e:
58  print "[This is Expected Failure]"
59  print str(e.message)
60 
61  @unittest.expectedFailure
63  try:
64  self.check_initCORBA('123.45.67.89')
65  except SystemExit as e:
66  print "[This is Expected Failure]"
67  print str(e.message)
68 
69 #unittest.main()
70 if __name__ == '__main__':
71  rostest.run(PKG, NAME, TestHrpsysHostname, sys.argv)
def check_initCORBA(self, nshost, nsport=2809)
def findRTC(name, rnc=None)
get RT component
Definition: jython/rtm.py:341
def findRTCmanager(hostname=None, rnc=None)
get RTCmanager
Definition: jython/rtm.py:321
def initCORBA()
initialize ORB
Definition: jython/rtm.py:272


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:51