test_downward.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # Author: Yuki Furuta <furushchev@jsk.imi.i.u-tokyo.ac.jp>
4 
5 from __future__ import print_function
6 import os
7 import subprocess
8 import time
9 import sys
10 import unittest
11 from optparse import OptionParser
12 import rospy
13 
14 
15 class TestDownward(unittest.TestCase):
16  def test_plan(self):
17  self.assertTrue(os.path.isfile(DOMAIN))
18  domain = DOMAIN
19  self.assertTrue(os.path.isfile(PROBLEM))
20  problem = PROBLEM
21  config = "ipc seq-sat-fd-autotune-1"
22  self.assertIsInstance(PLAN, str)
23  plan_path = PLAN
24  cmd = "rosrun downward plan %s %s %s --plan-file %s" % (domain,
25  problem,
26  config,
27  plan_path)
28  print("EXECUTING: ", cmd, file=sys.stderr)
29  status = 0
30  try:
31  output = subprocess.check_output(cmd, shell=True)
32  except subprocess.CalledProcessError as e:
33  status = e.returncode
34  print("DOWNWARD STATUS: %d, OUTPUT: %s" % (status, output), file=sys.stderr)
35  self.assertEqual(status, 0)
36 
37  plan_real_path = plan_path + ".1"
38  self.assertTrue(os.path.isfile(plan_real_path))
39 
40  with open(REF) as f_ref:
41  ref_lines = f_ref.readlines()
42  with open(plan_real_path) as f_plan:
43  plan_lines = f_plan.readlines()
44  self.assertSequenceEqual(ref_lines, plan_lines)
45 
46 if __name__ == '__main__':
47  ARGV = rospy.myargv(argv=sys.argv)
48  DOMAIN=ARGV[1]
49  PROBLEM=ARGV[2]
50  PLAN=ARGV[3]
51  REF=ARGV[4]
52  import rostest
53  rostest.rosrun("downward", "test_downward", TestDownward)


downward
Author(s):
autogenerated on Tue May 11 2021 02:55:31