Browse Source

split tests for SITL ctest

sbg
Daniel Agar 8 years ago committed by Lorenz Meier
parent
commit
74231e6656
  1. 2
      .gitignore
  2. 2
      Makefile
  3. 0
      posix-configs/SITL/init/test/test
  4. 22
      posix-configs/SITL/init/test/test_template.in
  5. 57
      src/firmware/posix/CMakeLists.txt
  6. 2
      src/systemcmds/tests/CMakeLists.txt
  7. 4
      src/systemcmds/tests/test_dataman.c
  8. 0
      src/systemcmds/tests/test_param.c
  9. 15
      src/systemcmds/tests/tests_main.c

2
.gitignore vendored

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

2
Makefile

@ -275,7 +275,7 @@ unittest: posix_sitl_default
@(cd build_unittest && ctest -j2 --output-on-failure) @(cd build_unittest && ctest -j2 --output-on-failure)
run_tests_posix: posix_sitl_default 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 tests: unittest run_tests_posix

0
posix-configs/SITL/init/test/iris → posix-configs/SITL/init/test/test

22
posix-configs/SITL/init/test/test_template.in

@ -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

57
src/firmware/posix/CMakeLists.txt

@ -141,17 +141,50 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/posix-configs DESTINATION ${CMAKE_INSTAL
# tests # tests
# #
add_test(NAME rcS_tests file(GLOB test_src_files
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh RELATIVE
$<TARGET_FILE:px4> ${PX4_SOURCE_DIR}/src/systemcmds/tests/
posix-configs/SITL/init/test ${PX4_SOURCE_DIR}/src/systemcmds/tests/test_*.c*)
none
none #TODO: find a way to keep this in sync with tests_main
none set(tests_exclude
${PX4_SOURCE_DIR} adc
${PX4_BINARY_DIR} dataman
WORKING_DIRECTORY ${SITL_WORKING_DIR}) file
set_tests_properties(rcS_tests PROPERTIES hott_telemetry
PASS_REGULAR_EXPRESSION "All tests passed") 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 : # vim: set noet ft=cmake fenc=utf-8 ff=unix :

2
src/systemcmds/tests/CMakeLists.txt

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

4
src/systemcmds/tests/test_dataman.c

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

0
src/systemcmds/tests/test_params.c → src/systemcmds/tests/test_param.c

15
src/systemcmds/tests/tests_main.c

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

Loading…
Cancel
Save