Skip to content

Commit

Permalink
wip tests
Browse files Browse the repository at this point in the history
  • Loading branch information
klaxalk committed Dec 7, 2023
1 parent bdb0c17 commit e475cf2
Show file tree
Hide file tree
Showing 17 changed files with 143 additions and 532 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ set(CATKIN_DEPENDENCIES
tf2
tf2_ros
tf2_geometry_msgs
mrs_uav_testing
)

find_package(catkin REQUIRED COMPONENTS
Expand Down
3 changes: 3 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<depend>tf2_ros</depend>
<depend>tf2_geometry_msgs</depend>
<depend>rostest</depend>
<depend>mrs_uav_testing</depend>

<test_depend>mrs_uav_gazebo_simulation</test_depend>

<export>
<nodelet plugin="${prefix}/nodelets.xml" />
Expand Down
126 changes: 1 addition & 125 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,127 +1,3 @@
find_package(rostest REQUIRED)

# takeoff test

add_rostest_gtest(MrsUavManagers_UavManagerTakeoffTest
uav_manager/takeoff/uav_manager_takeoff.test
uav_manager/takeoff/takeoff_test.cpp
)

target_link_libraries(
MrsUavManagers_UavManagerTakeoffTest
${catkin_LIBRARIES}
)

add_dependencies(
MrsUavManagers_UavManagerTakeoffTest
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
)

# landing test

add_rostest_gtest(MrsUavManagers_UavManagerLandingTest
uav_manager/landing/uav_manager_landing.test
uav_manager/landing/landing_test.cpp
)

target_link_libraries(
MrsUavManagers_UavManagerLandingTest
${catkin_LIBRARIES}
)

add_dependencies(
MrsUavManagers_UavManagerLandingTest
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
)

# goto service test

add_rostest_gtest(MrsUavManagers_ControlManagerGotoServiceTest
control_manager/goto_service/control_manager_goto_service.test
control_manager/goto_service/goto_service_test.cpp
)

target_link_libraries(
MrsUavManagers_ControlManagerGotoServiceTest
${catkin_LIBRARIES}
)

add_dependencies(
MrsUavManagers_ControlManagerGotoServiceTest
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
)

# eland innovation test

add_rostest_gtest(MrsUavManagers_ControlManagerElandInnovationTest
control_manager/eland_innovation/control_manager_eland_innovation.test
control_manager/eland_innovation/eland_innovation_test.cpp
)

target_link_libraries(
MrsUavManagers_ControlManagerElandInnovationTest
${catkin_LIBRARIES}
)

add_dependencies(
MrsUavManagers_ControlManagerElandInnovationTest
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
)

# eland controlerror test

add_rostest_gtest(MrsUavManagers_ControlManagerElandControlErrorTest
control_manager/eland_control_error/control_manager_eland_control_error.test
control_manager/eland_control_error/eland_control_error_test.cpp
)

target_link_libraries(
MrsUavManagers_ControlManagerElandControlErrorTest
${catkin_LIBRARIES}
)

add_dependencies(
MrsUavManagers_ControlManagerElandControlErrorTest
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
)

# failsafe controlerror test

add_rostest_gtest(MrsUavManagers_ControlManagerFailsafeControlErrorTest
control_manager/failsafe_control_error/control_manager_failsafe_control_error.test
control_manager/failsafe_control_error/failsafe_control_error_test.cpp
)

target_link_libraries(
MrsUavManagers_ControlManagerFailsafeControlErrorTest
${catkin_LIBRARIES}
)

add_dependencies(
MrsUavManagers_ControlManagerFailsafeControlErrorTest
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
)

# eland service test

add_rostest_gtest(MrsUavManagers_ControlManagerElandServiceTest
control_manager/eland_service/control_manager_eland_service.test
control_manager/eland_service/eland_service_test.cpp
)

target_link_libraries(
MrsUavManagers_ControlManagerElandServiceTest
${catkin_LIBRARIES}
)

add_dependencies(
MrsUavManagers_ControlManagerElandServiceTest
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
)
add_subdirectory(control_manager)
43 changes: 21 additions & 22 deletions test/all_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,30 @@ set -e
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
trap 'echo "$0: \"${last_command}\" command failed with exit code $?"' ERR

PACKAGE="mrs_uav_managers"
VERBOSE=1

[ "$VERBOSE" = "0" ] && TEXT_OUTPUT=""
[ "$VERBOSE" = "1" ] && TEXT_OUTPUT="-t"

# build the package
catkin build $PACKAGE # it has to be fully built normally before building with --catkin-make-args tests
catkin build $PACKAGE --no-deps --catkin-make-args tests

TEST_FILES=$(find . -name "*.test" -type f -printf "%f\n")
ORIGINAL_PATH=`pwd`

while [ ! -e ".catkin_tools" ]; do
cd ..
if [[ `pwd` == "/" ]]; then
# we reached the root and didn't find the build/COLCON_IGNORE file - that's a fail!
echo "$0: could not find the root of the current workspace".
return 1
fi
done

for TEST_FILE in `echo $TEST_FILES`; do
cd build

echo "$0: running test '$TEST_FILE'"
OLD_FILES=$(find . -name "*.gcda")

# folder for test results
TEST_RESULT_PATH=$(realpath /tmp/$RANDOM)
mkdir -p $TEST_RESULT_PATH
for FILE in $OLD_FILES; do
echo "$0: removing old coverage file '$FILE'"
rm $FILE
done

# run the test
rostest $PACKAGE $TEST_FILE $TEXT_OUTPUT --results-filename=$PACKAGE.test --results-base-dir="$TEST_RESULT_PATH"
cd $ORIGINAL_PATH

# evaluate the test results
echo test result path is $TEST_RESULT_PATH
catkin_test_results "$TEST_RESULT_PATH"
# build the package
catkin build --this # it has to be fully built normally before building with --catkin-make-args tests
catkin build --this --no-deps --catkin-make-args tests

done
catkin test --this -i -p 1 -s
1 change: 1 addition & 0 deletions test/control_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(goto_service)
21 changes: 21 additions & 0 deletions test/control_manager/goto_service/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
get_filename_component(TEST_NAME "${CMAKE_CURRENT_SOURCE_DIR}" NAME)

catkin_add_executable_with_gtest(test_${TEST_NAME}
test.cpp
)

target_link_libraries(test_${TEST_NAME}
${catkin_LIBRARIES}
)

add_dependencies(test_${TEST_NAME}
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
)

add_rostest(${TEST_NAME}.test
ARGS
test_path:=${CMAKE_CURRENT_SOURCE_DIR}
package_name:=${PROJECT_NAME}
test_name:=${TEST_NAME}
)

This file was deleted.

30 changes: 30 additions & 0 deletions test/control_manager/goto_service/goto_service.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<launch>

<arg name="UAV_NAME" default="uav1" />
<arg name="UAV_TYPE" default="x500" />

<!-- these will be filled in from the CMakeLists -->
<arg name="test_path" default="" />
<arg name="test_name" default="" />
<arg name="package_name" default="" />

<include file="$(find mrs_uav_testing)/launch/mrs_simulator.launch">
<arg name="UAV_NAME" default="$(arg UAV_NAME)" />
</include>

<include file="$(find mrs_multirotor_simulator)/launch/hw_api.launch">
<arg name="UAV_NAME" default="$(arg UAV_NAME)" />
</include>

<include file="$(find mrs_uav_testing)/launch/mrs_uav_system.launch">
<arg name="automatic_start" default="false" />
<arg name="platform_config" default="$(find mrs_multirotor_simulator)/config/mrs_uav_system/$(arg UAV_TYPE).yaml" />
<arg name="UAV_NAME" default="$(arg UAV_NAME)" />
</include>

<test pkg="$(arg package_name)" type="test_$(arg test_name)" test-name="$(arg test_name)" time-limit="60.0">
<param name="test_name" value="$(arg test_name)" />
<param name="uav_name" value="$(arg UAV_NAME)" />
</test>

</launch>
Loading

0 comments on commit e475cf2

Please sign in to comment.