split tests for SITL ctest

This commit is contained in:
Daniel Agar 2016-12-30 20:57:10 -05:00 committed by Lorenz Meier
parent cbc9680800
commit 74231e6656
9 changed files with 83 additions and 21 deletions

2
.gitignore vendored
View File

@ -84,3 +84,5 @@ cmake-build-*/
# gcov code coverage
coverage-html/
coverage.info
posix-configs/SITL/init/test/*_generated

View File

@ -275,7 +275,7 @@ unittest: posix_sitl_default
@(cd build_unittest && ctest -j2 --output-on-failure)
run_tests_posix: posix_sitl_default
@(cd build_posix_sitl_default/ && ctest -V)
@(cd build_posix_sitl_default/ && ctest --output-on-failure)
tests: unittest run_tests_posix

View File

@ -0,0 +1,22 @@
uorb start
param load
param set SYS_RESTART_TYPE 0
dataman start
rgbledsim start
tone_alarm start
#simulator start -s
#gyrosim start
#accelsim start
#barosim start
#adcsim start
#gpssim start
#pwm_out_sim mode_pwm
tests @test_name@
shutdown

View File

@ -141,17 +141,50 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/posix-configs DESTINATION ${CMAKE_INSTAL
# tests
#
add_test(NAME rcS_tests
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh
$<TARGET_FILE:px4>
posix-configs/SITL/init/test
none
none
none
${PX4_SOURCE_DIR}
${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR})
set_tests_properties(rcS_tests PROPERTIES
PASS_REGULAR_EXPRESSION "All tests passed")
file(GLOB test_src_files
RELATIVE
${PX4_SOURCE_DIR}/src/systemcmds/tests/
${PX4_SOURCE_DIR}/src/systemcmds/tests/test_*.c*)
#TODO: find a way to keep this in sync with tests_main
set(tests_exclude
adc
dataman
file
hott_telemetry
jig_voltages
led
mount
ppm_loopback
sensors
time
uart_baudchange
uart_break
uart_console
uart_loopback
)
foreach(test_name ${test_src_files})
string(REPLACE "test_" "" test_name ${test_name})
string(REPLACE ".cpp" "" test_name ${test_name})
string(REPLACE ".c" "" test_name ${test_name})
configure_file(${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/test_template.in ${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/${test_name}_generated)
list(FIND tests_exclude ${test_name} _index)
if (${_index} EQUAL -1)
add_test(NAME ${test_name}
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh
$<TARGET_FILE:px4>
posix-configs/SITL/init/test/
none
none
${test_name}_generated
${PX4_SOURCE_DIR}
${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR})
set_tests_properties(${test_name} PROPERTIES PASS_REGULAR_EXPRESSION "${test_name} PASSED")
endif()
endforeach()
# vim: set noet ft=cmake fenc=utf-8 ff=unix :

View File

@ -51,7 +51,7 @@ set(srcs
test_matrix.cpp
test_mixer.cpp
test_mount.c
test_params.c
test_param.c
test_perf.c
test_ppm_loopback.c
test_rc.c

View File

@ -46,7 +46,6 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <debug.h>
#include <arch/board/board.h>
@ -55,8 +54,7 @@
#include <drivers/drv_hrt.h>
#include <semaphore.h>
#include "tests.h"
#include "tests_main.h"
#include "dataman/dataman.h"

View File

@ -79,11 +79,13 @@ const struct {
{"jig", test_jig, OPT_NOJIGTEST | OPT_NOALLTEST},
#ifdef __PX4_NUTTX
{"adc", test_adc, OPT_NOJIGTEST},
{"file", test_file, OPT_NOJIGTEST | OPT_NOALLTEST},
{"led", test_led, 0},
{"sensors", test_sensors, 0},
{"time", test_time, OPT_NOJIGTEST},
{"uart_baudchange", test_uart_baudchange, OPT_NOJIGTEST},
{"uart_break", test_uart_break, OPT_NOJIGTEST | OPT_NOALLTEST},
{"uart_console", test_uart_console, OPT_NOJIGTEST | OPT_NOALLTEST},
#else
{"rc", rc_tests_main, 0},
#endif /* __PX4_NUTTX */
@ -102,8 +104,7 @@ const struct {
{"autodeclination", test_autodeclination, 0},
{"bson", test_bson, 0},
{"conv", test_conv, 0},
//{"dataman", test_dataman, 0}, // Enable for by hand testing
{"file", test_file, OPT_NOJIGTEST | OPT_NOALLTEST},
//{"dataman", test_dataman, OPT_NOJIGTEST | OPT_NOALLTEST}, // Enable for by hand testing
{"file2", test_file2, OPT_NOJIGTEST},
{"float", test_float, 0},
{"gpio", test_gpio, OPT_NOJIGTEST | OPT_NOALLTEST},
@ -122,7 +123,6 @@ const struct {
{"servo", test_servo, OPT_NOJIGTEST | OPT_NOALLTEST},
{"sleep", test_sleep, OPT_NOJIGTEST},
{"tone", test_tone, 0},
{"uart_console", test_uart_console, OPT_NOJIGTEST | OPT_NOALLTEST},
{"uart_loopback", test_uart_loopback, OPT_NOJIGTEST | OPT_NOALLTEST},
{"uart_send", test_uart_send, OPT_NOJIGTEST | OPT_NOALLTEST},
{NULL, NULL, 0}
@ -264,7 +264,14 @@ int tests_main(int argc, char *argv[])
for (unsigned i = 0; tests[i].name; i++) {
if (!strcmp(tests[i].name, argv[1])) {
return tests[i].fn(argc - 1, argv + 1);
if (tests[i].fn(argc - 1, argv + 1) == 0) {
printf("%s PASSED\n", tests[i].name);
return 0;
} else {
printf("%s FAILED\n", tests[i].name);
return -1;
}
}
}