diff --git a/CMakeLists.txt b/CMakeLists.txt index f420289ddbdb4e0657e692bb627f683874c5bd1b..d8c14df4aca73c799c90d291a20c6f59db0ec39e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,5 +72,6 @@ endif() PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME}) ADD_SUBDIRECTORY(src) +ADD_SUBDIRECTORY(tests) CONFIG_FILES (include/${CUSTOM_HEADER_DIR}/doc.hh) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..2b86bd5d92c1e4b6e28c1acb7ea0bc9385aa2b45 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1 @@ +ADD_SUBDIRECTORY(python) diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..589410afe02bc5b5081368a4409477404419bc41 --- /dev/null +++ b/tests/python/CMakeLists.txt @@ -0,0 +1,8 @@ +SET(${PROJECT_NAME}_PYTHON_TESTS + test_talos_walk_contacts + test_talos_walk_path + ) + +FOREACH(TEST ${${PROJECT_NAME}_PYTHON_TESTS}) + ADD_PYTHON_UNIT_TEST("py-${TEST}" "tests/python/${TEST}.py") +ENDFOREACH(TEST ${${PROJECT_NAME}_PYTHON_TESTS}) diff --git a/tests/python/test_talos.py b/tests/python/test_talos.py deleted file mode 100644 index a3882cb91640f70114acbe22d189981eabb73bd5..0000000000000000000000000000000000000000 --- a/tests/python/test_talos.py +++ /dev/null @@ -1,3 +0,0 @@ -# Copyright (c) 20120, CNRS -# Authors: Pierre Fernbach <pfernbac@laas.fr> - diff --git a/tests/python/test_talos_walk_contacts.py b/tests/python/test_talos_walk_contacts.py new file mode 100644 index 0000000000000000000000000000000000000000..452fe467e7cafc83a2482644c3d305bc9791fa2c --- /dev/null +++ b/tests/python/test_talos_walk_contacts.py @@ -0,0 +1,32 @@ +# Copyright (c) 2020, CNRS +# Authors: Pierre Fernbach <pfernbac@laas.fr> +import subprocess +from importlib import import_module +import os +import unittest +import time + +PATH = "hpp.corbaserver.rbprm.scenarios.demos" + + +class TestTalosWalkContact(unittest.TestCase): + + def test_talos_walk_contacts(self): + subprocess.run(["killall", "hpp-rbprm-server"]) + process = subprocess.Popen("hpp-rbprm-server") + time.sleep(3) + module_scenario = import_module(PATH+".talos_flatGround") + if not hasattr(module_scenario, 'ContactGenerator'): + self.assertTrue(False) + ContactGenerator = getattr(module_scenario, 'ContactGenerator') + cg = ContactGenerator() + cg.run() + self.assertTrue(len(cg.configs) > 5) + self.assertTrue(len(cg.configs) < 10) + self.assertEqual(cg.q_init, cg.configs[0]) + self.assertEqual(cg.q_goal, cg.configs[-1]) + process.kill() + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/python/test_talos_walk_path.py b/tests/python/test_talos_walk_path.py new file mode 100644 index 0000000000000000000000000000000000000000..6af0d31d8b2763c4893f583f942cb97c133d60bb --- /dev/null +++ b/tests/python/test_talos_walk_path.py @@ -0,0 +1,36 @@ +# Copyright (c) 2020, CNRS +# Authors: Pierre Fernbach <pfernbac@laas.fr> +import subprocess +from importlib import import_module +import os +import unittest +import time + +PATH = "hpp.corbaserver.rbprm.scenarios.demos" + + +class TestTalosWalkPath(unittest.TestCase): + + def test_talos_walk_path(self): + subprocess.run(["killall", "hpp-rbprm-server"]) + process = subprocess.Popen("hpp-rbprm-server") + time.sleep(3) + module_scenario = import_module(PATH+".talos_flatGround_path") + if not hasattr(module_scenario, 'PathPlanner'): + self.assertTrue(False) + PathPlanner = getattr(module_scenario, 'PathPlanner') + planner = PathPlanner() + planner.run() + ps = planner.ps + self.assertEqual(ps.numberPaths(), 2) + self.assertEqual(ps.pathLength(0), ps.pathLength(1)) + self.assertTrue(ps.pathLength(1) > 6.) + self.assertTrue(ps.pathLength(1) < 7.) + self.assertEqual(planner.q_init, ps.configAtParam(1,0)) + self.assertEqual(planner.q_goal, ps.configAtParam(1, ps.pathLength(1))) + process.kill() + + + +if __name__ == '__main__': + unittest.main()