From 89766be464a7f20296c2b3c3712428d9a1efaadd Mon Sep 17 00:00:00 2001 From: dmronga Date: Thu, 6 Jun 2024 00:07:32 +0200 Subject: [PATCH] Add tests in cmake --- .../workflows/build_and_test_ubuntu20.04.yml | 5 +- .../workflows/build_and_test_ubuntu22.04.yml | 4 +- CMakeLists.txt | 1 + scripts/run_tests.sh | 105 ------------------ src/controllers/test/CMakeLists.txt | 4 + src/core/test/CMakeLists.txt | 2 + src/robot_models/hyrodyn/test/CMakeLists.txt | 2 + src/robot_models/kdl/test/CMakeLists.txt | 2 + .../pinocchio/test/CMakeLists.txt | 2 + src/robot_models/rbdl/test/CMakeLists.txt | 2 + src/scenes/acceleration/test/CMakeLists.txt | 2 + .../test/CMakeLists.txt | 2 + .../acceleration_tsid/test/CMakeLists.txt | 2 + src/scenes/velocity/test/CMakeLists.txt | 2 + src/scenes/velocity_qp/test/CMakeLists.txt | 2 + src/solvers/eiquadprog/test/CMakeLists.txt | 2 + src/solvers/hls/test/CMakeLists.txt | 2 + src/solvers/osqp/test/CMakeLists.txt | 2 + src/solvers/proxqp/test/CMakeLists.txt | 2 + src/solvers/qpoases/test/CMakeLists.txt | 2 + src/solvers/qpswift/test/CMakeLists.txt | 2 + 21 files changed, 42 insertions(+), 109 deletions(-) delete mode 100644 scripts/run_tests.sh diff --git a/.github/workflows/build_and_test_ubuntu20.04.yml b/.github/workflows/build_and_test_ubuntu20.04.yml index 1b9e70db..5409b2bc 100644 --- a/.github/workflows/build_and_test_ubuntu20.04.yml +++ b/.github/workflows/build_and_test_ubuntu20.04.yml @@ -21,5 +21,6 @@ jobs: run: | export LD_LIBRARY_PATH=/usr/local/lib export PYTHONPATH=/usr/local/lib/python3.8/site-packages - cd wbc - sh scripts/run_tests.sh + cd wbc/build + make test + diff --git a/.github/workflows/build_and_test_ubuntu22.04.yml b/.github/workflows/build_and_test_ubuntu22.04.yml index 47b14dec..ca4f68b2 100644 --- a/.github/workflows/build_and_test_ubuntu22.04.yml +++ b/.github/workflows/build_and_test_ubuntu22.04.yml @@ -21,5 +21,5 @@ jobs: run: | export LD_LIBRARY_PATH=/usr/local/lib export PYTHONPATH=/usr/local/lib/python3.10/site-packages - cd wbc - sh scripts/run_tests.sh + cd wbc/build + make test diff --git a/CMakeLists.txt b/CMakeLists.txt index dcadc39d..9fb8f2f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required (VERSION 3.16.3) project(wbc) +include(CTest) find_package(PkgConfig REQUIRED) find_package(Boost REQUIRED COMPONENTS system filesystem unit_test_framework serialization) diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh deleted file mode 100644 index a1c6a277..00000000 --- a/scripts/run_tests.sh +++ /dev/null @@ -1,105 +0,0 @@ -# Controllers -echo "Testing controllers ..." -cd build/src -cd controllers/test -./test_pid_controllers -./test_pos_pd_controllers -./test_pot_field_controllers -cd ../.. - -# Core -echo "Testing core library ..." -cd core/test -./test_core -cd ../.. - -# Robot Models -echo "Testing robot models ..." -echo "Testing RobotModelPinocchio ..." -cd robot_models/pinocchio/test -./test_robot_model_pinocchio -cd ../.. -if [ -d "kdl" ]; then - echo "Testing RobotModelKDL ..." - cd kdl/test - ./test_robot_model_kdl - cd ../.. -fi -if [ -d "rbdl" ]; then - echo "Testing RobotModelRBDL ..." - cd rbdl/test - ./test_robot_model_rbdl - cd ../.. -fi -if [ -d "hyrodyn" ]; then - echo "Testing RobotModelHyrodyn ..." - cd hyrodyn/test - ./test_robot_model_hyrodyn - cd ../.. -fi -cd .. - -# Scenes -echo "Testing scenes ..." - -echo "Testing VelocityScene ..." -cd scenes/velocity/test -./test_velocity_scene -cd ../.. - -echo "Testing VelocitySceneQuadraticCost ..." -cd velocity_qp/test -./test_velocity_scene_quadratic_cost -cd ../.. - - -echo "Testing AccelerationScene ..." -cd acceleration/test -./test_acceleration_scene -cd ../.. - -echo "Testing AccelerationSceneTSID ..." -cd acceleration_tsid/test -./test_acceleration_scene_tsid -cd ../.. - -echo "Testing AccelerationSceneReducedTSID ..." -cd acceleration_reduced_tsid/test -./test_acceleration_scene_reduced_tsid -cd ../../.. - -# Solvers -echo "Testing hls ..." -cd solvers/hls/test -./test_hls_solver -cd ../.. - -echo "Testing QPOasesSolver ..." -cd qpoases/test -./test_qpoases_solver -cd ../.. -if [ -d "eiquadprog" ]; then - echo "Testing EiquadprogSolver ..." - cd eiquadprog/test - ./test_eiquadprog_solver - cd ../.. -fi -if [ -d "proxqp" ]; then - echo "Testing ProxQPSolver ..." - cd proxqp/test - ./test_proxqp_solver - cd ../.. -fi -if [ -d "qpswift" ]; then - echo "Testing QPSwiftSolver ..." - cd qpswift/test - ./test_qpswift_solver - cd ../.. -fi -if [ -d "osqp" ]; then - echo "Testing OSQPsolver ..." - cd osqp/test - ./test_osqp_solver - cd ../.. -fi -cd .. diff --git a/src/controllers/test/CMakeLists.txt b/src/controllers/test/CMakeLists.txt index a3dc751e..028f6a6c 100644 --- a/src/controllers/test/CMakeLists.txt +++ b/src/controllers/test/CMakeLists.txt @@ -13,3 +13,7 @@ add_executable(test_pid_controllers test_pid_controllers.cpp) target_link_libraries(test_pid_controllers wbc-controllers Boost::unit_test_framework) + +add_test(NAME test_pot_field_controllers COMMAND test_pot_field_controllers) +add_test(NAME test_pos_pd_controllers COMMAND test_pos_pd_controllers) +add_test(NAME test_pid_controllers COMMAND test_pid_controllers) diff --git a/src/core/test/CMakeLists.txt b/src/core/test/CMakeLists.txt index 45619cb3..8a575f47 100644 --- a/src/core/test/CMakeLists.txt +++ b/src/core/test/CMakeLists.txt @@ -2,3 +2,5 @@ add_executable(test_core test_core.cpp) target_link_libraries(test_core wbc-core Boost::unit_test_framework) + +add_test(NAME test_core COMMAND test_core) diff --git a/src/robot_models/hyrodyn/test/CMakeLists.txt b/src/robot_models/hyrodyn/test/CMakeLists.txt index 90b73905..6a1ffbcf 100644 --- a/src/robot_models/hyrodyn/test/CMakeLists.txt +++ b/src/robot_models/hyrodyn/test/CMakeLists.txt @@ -2,3 +2,5 @@ add_executable(test_robot_model_hyrodyn test_robot_model_hyrodyn.cpp ../../test/ target_link_libraries(test_robot_model_hyrodyn wbc-robot_models-hyrodyn Boost::unit_test_framework) + +add_test(NAME test_robot_model_hyrodyn COMMAND test_robot_model_hyrodyn) diff --git a/src/robot_models/kdl/test/CMakeLists.txt b/src/robot_models/kdl/test/CMakeLists.txt index ce6b02ed..e5abb73f 100644 --- a/src/robot_models/kdl/test/CMakeLists.txt +++ b/src/robot_models/kdl/test/CMakeLists.txt @@ -2,3 +2,5 @@ add_executable(test_robot_model_kdl test_robot_model_kdl.cpp ../../test/test_rob target_link_libraries(test_robot_model_kdl wbc-robot_models-kdl Boost::unit_test_framework) + +add_test(NAME test_robot_model_kdl COMMAND test_robot_model_kdl) diff --git a/src/robot_models/pinocchio/test/CMakeLists.txt b/src/robot_models/pinocchio/test/CMakeLists.txt index bdcd2a9c..f2d3ca13 100644 --- a/src/robot_models/pinocchio/test/CMakeLists.txt +++ b/src/robot_models/pinocchio/test/CMakeLists.txt @@ -5,3 +5,5 @@ target_link_libraries(test_robot_model_pinocchio Boost::system Boost::filesystem Boost::serialization) + +add_test(NAME test_robot_model_pinocchio COMMAND test_robot_model_pinocchio) diff --git a/src/robot_models/rbdl/test/CMakeLists.txt b/src/robot_models/rbdl/test/CMakeLists.txt index 81aa315c..72e715c8 100644 --- a/src/robot_models/rbdl/test/CMakeLists.txt +++ b/src/robot_models/rbdl/test/CMakeLists.txt @@ -2,3 +2,5 @@ add_executable(test_robot_model_rbdl test_robot_model_rbdl.cpp ../../test/test_r target_link_libraries(test_robot_model_rbdl wbc-robot_models-rbdl Boost::unit_test_framework) + +add_test(NAME test_robot_model_rbdl COMMAND test_robot_model_rbdl) diff --git a/src/scenes/acceleration/test/CMakeLists.txt b/src/scenes/acceleration/test/CMakeLists.txt index 0d0911b9..70d7d0ed 100644 --- a/src/scenes/acceleration/test/CMakeLists.txt +++ b/src/scenes/acceleration/test/CMakeLists.txt @@ -4,3 +4,5 @@ target_link_libraries(test_acceleration_scene wbc-robot_models-pinocchio wbc-solvers-qpoases Boost::unit_test_framework) + +add_test(NAME test_acceleration_scene COMMAND test_acceleration_scene) diff --git a/src/scenes/acceleration_reduced_tsid/test/CMakeLists.txt b/src/scenes/acceleration_reduced_tsid/test/CMakeLists.txt index 658aedf1..55f8790f 100644 --- a/src/scenes/acceleration_reduced_tsid/test/CMakeLists.txt +++ b/src/scenes/acceleration_reduced_tsid/test/CMakeLists.txt @@ -4,3 +4,5 @@ target_link_libraries(test_acceleration_scene_reduced_tsid wbc-robot_models-pinocchio wbc-solvers-qpoases Boost::unit_test_framework) + +add_test(NAME test_acceleration_scene_reduced_tsid COMMAND test_acceleration_scene_reduced_tsid) diff --git a/src/scenes/acceleration_tsid/test/CMakeLists.txt b/src/scenes/acceleration_tsid/test/CMakeLists.txt index 0cd238a4..e429b425 100644 --- a/src/scenes/acceleration_tsid/test/CMakeLists.txt +++ b/src/scenes/acceleration_tsid/test/CMakeLists.txt @@ -4,3 +4,5 @@ target_link_libraries(test_acceleration_scene_tsid wbc-robot_models-pinocchio wbc-solvers-qpoases Boost::unit_test_framework) + +add_test(NAME test_acceleration_scene_tsid COMMAND test_acceleration_scene_tsid) diff --git a/src/scenes/velocity/test/CMakeLists.txt b/src/scenes/velocity/test/CMakeLists.txt index b453c850..d2929dbd 100644 --- a/src/scenes/velocity/test/CMakeLists.txt +++ b/src/scenes/velocity/test/CMakeLists.txt @@ -5,3 +5,5 @@ target_link_libraries(test_velocity_scene wbc-solvers-hls Boost::unit_test_framework) +add_test(NAME test_velocity_scene COMMAND test_velocity_scene) + diff --git a/src/scenes/velocity_qp/test/CMakeLists.txt b/src/scenes/velocity_qp/test/CMakeLists.txt index 7cc44f21..37e38417 100644 --- a/src/scenes/velocity_qp/test/CMakeLists.txt +++ b/src/scenes/velocity_qp/test/CMakeLists.txt @@ -5,3 +5,5 @@ target_link_libraries(test_velocity_scene_quadratic_cost wbc-solvers-qpoases Boost::unit_test_framework) +add_test(NAME test_velocity_scene_quadratic_cost COMMAND test_velocity_scene_quadratic_cost) + diff --git a/src/solvers/eiquadprog/test/CMakeLists.txt b/src/solvers/eiquadprog/test/CMakeLists.txt index 350dec69..9dbf673f 100644 --- a/src/solvers/eiquadprog/test/CMakeLists.txt +++ b/src/solvers/eiquadprog/test/CMakeLists.txt @@ -2,3 +2,5 @@ add_executable(test_eiquadprog_solver test_eiquadprog_solver.cpp) target_link_libraries(test_eiquadprog_solver wbc-solvers-eiquadprog Boost::unit_test_framework) + +add_test(NAME test_eiquadprog_solver COMMAND test_eiquadprog_solver) diff --git a/src/solvers/hls/test/CMakeLists.txt b/src/solvers/hls/test/CMakeLists.txt index 208592a5..5d629192 100644 --- a/src/solvers/hls/test/CMakeLists.txt +++ b/src/solvers/hls/test/CMakeLists.txt @@ -2,3 +2,5 @@ add_executable(test_hls_solver test_hls_solver.cpp) target_link_libraries(test_hls_solver wbc-solvers-hls Boost::unit_test_framework) + +add_test(NAME test_hls_solver COMMAND test_hls_solver) diff --git a/src/solvers/osqp/test/CMakeLists.txt b/src/solvers/osqp/test/CMakeLists.txt index a3d42c79..e740a614 100644 --- a/src/solvers/osqp/test/CMakeLists.txt +++ b/src/solvers/osqp/test/CMakeLists.txt @@ -2,3 +2,5 @@ add_executable(test_osqp_solver test_osqp_solver.cpp) target_link_libraries(test_osqp_solver wbc-solvers-osqp Boost::unit_test_framework) + +add_test(NAME test_osqp_solver COMMAND test_osqp_solver) diff --git a/src/solvers/proxqp/test/CMakeLists.txt b/src/solvers/proxqp/test/CMakeLists.txt index b5537de7..92f83990 100644 --- a/src/solvers/proxqp/test/CMakeLists.txt +++ b/src/solvers/proxqp/test/CMakeLists.txt @@ -2,3 +2,5 @@ add_executable(test_proxqp_solver test_proxqp_solver.cpp) target_link_libraries(test_proxqp_solver wbc-solvers-proxqp ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + +add_test(NAME test_proxqp_solver COMMAND test_proxqp_solver) diff --git a/src/solvers/qpoases/test/CMakeLists.txt b/src/solvers/qpoases/test/CMakeLists.txt index 678e93e1..a9011cd8 100644 --- a/src/solvers/qpoases/test/CMakeLists.txt +++ b/src/solvers/qpoases/test/CMakeLists.txt @@ -2,3 +2,5 @@ add_executable(test_qpoases_solver test_qpoases_solver.cpp) target_link_libraries(test_qpoases_solver wbc-solvers-qpoases Boost::unit_test_framework) + +add_test(NAME test_qpoases_solver COMMAND test_qpoases_solver) diff --git a/src/solvers/qpswift/test/CMakeLists.txt b/src/solvers/qpswift/test/CMakeLists.txt index 336a6e09..c6b46e09 100644 --- a/src/solvers/qpswift/test/CMakeLists.txt +++ b/src/solvers/qpswift/test/CMakeLists.txt @@ -2,3 +2,5 @@ add_executable(test_qpswift_solver test_qpswift_solver.cpp) target_link_libraries(test_qpswift_solver wbc-solvers-qpswift Boost::unit_test_framework) + +add_test(NAME test_qpswift_solver COMMAND test_qpswift_solver)