moveit2
The MoveIt Motion Planning Framework for ROS 2.
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_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_cmdrun_cmd(
33  roslib.packages.find_node(PKGNAME, "test_cleanup.py", self._rospack_rospack)
34  )
35 
36  def test_cpp(self):
37  self.run_cmdrun_cmd(roslib.packages.find_node(PKGNAME, "test_cleanup", self._rospack_rospack))
38 
39 
40 if __name__ == "__main__":
41  rostest.rosrun(PKGNAME, NODENAME, CleanupTest)
def test_py(self)
Definition: cleanup.py:31
def __init__(self, *args, **kwargs)
Definition: cleanup.py:20
def test_cpp(self)
Definition: cleanup.py:36
def run_cmd(self, cmd, num=5)
Definition: cleanup.py:24