cleanup.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 from __future__ import print_function
4 
5 import unittest
6 import rostest
7 import subprocess
8 import rospkg
9 import roslib.packages
10 
11 PKGNAME = "moveit_ros_planning_interface"
12 NODENAME = "moveit_cleanup_tests"
13 
14 # As issue #592 is related to a crash during program exit,
15 # we cannot perform a standard unit test.
16 # We have to check the return value of the called program.
17 # As rostest doesn't do this automatically, we do it ourselves
18 # and call the actual test program here.
19 class CleanupTest(unittest.TestCase):
20  def __init__(self, *args, **kwargs):
21  super(CleanupTest, self).__init__(*args, **kwargs)
22  self._rospack = rospkg.RosPack()
23 
24  def run_cmd(self, cmd, num=5):
25  failures = 0
26  for i in range(num):
27  if subprocess.call(cmd) != 0:
28  failures += 1
29  self.assertEqual(failures, 0, "%d of %d runs failed" % (failures, num))
30 
31  def test_py(self):
32  self.run_cmd(
33  roslib.packages.find_node(PKGNAME, "test_cleanup.py", self._rospack)
34  )
35 
36  def test_cpp(self):
37  self.run_cmd(roslib.packages.find_node(PKGNAME, "test_cleanup", self._rospack))
38 
39 
40 if __name__ == "__main__":
41  rostest.rosrun(PKGNAME, NODENAME, CleanupTest)
cleanup.CleanupTest.test_cpp
def test_cpp(self)
Definition: cleanup.py:36
cleanup.CleanupTest._rospack
_rospack
Definition: cleanup.py:22
cleanup.CleanupTest.__init__
def __init__(self, *args, **kwargs)
Definition: cleanup.py:20
cleanup.CleanupTest.run_cmd
def run_cmd(self, cmd, num=5)
Definition: cleanup.py:24
cleanup.CleanupTest
Definition: cleanup.py:19
cleanup.CleanupTest.test_py
def test_py(self)
Definition: cleanup.py:31


planning_interface
Author(s): Ioan Sucan
autogenerated on Fri May 3 2024 02:30:20