From 5de5d6ea49e25ab846e82e7b8cf60c3e70e38dcd Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Sat, 5 May 2018 16:55:36 -0400 Subject: [PATCH] Jenkins simple mission code coverage build --- Jenkinsfile | 18 ++++++++++++++++++ Makefile | 9 ++++++++- cmake/common/coverage.cmake | 6 +++--- platforms/posix/cmake/sitl_tests.cmake | 3 ++- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index dd005f9fb6..51cace3605 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -225,6 +225,24 @@ pipeline { } } + stage('test mission (code coverage)') { + agent { + docker { + image 'px4io/px4-dev-ros:2018-03-30' + args '-e CCACHE_BASEDIR=$WORKSPACE -v ${CCACHE_DIR}:${CCACHE_DIR}:rw -e HOME=$WORKSPACE' + } + } + steps { + sh 'export' + sh 'make distclean; rm -rf .ros; rm -rf .gazebo' + sh 'make tests_mission_coverage' + withCredentials([string(credentialsId: 'FIRMWARE_CODECOV_TOKEN', variable: 'CODECOV_TOKEN')]) { + sh 'curl -s https://codecov.io/bash | bash -s' + } + sh 'make distclean' + } + } + stage('check stack') { agent { docker { diff --git a/Makefile b/Makefile index 1b20acf043..88df8d7b58 100644 --- a/Makefile +++ b/Makefile @@ -279,7 +279,7 @@ format: # Testing # -------------------------------------------------------------------- -.PHONY: tests tests_coverage tests_mission tests_offboard rostest +.PHONY: tests tests_coverage tests_mission tests_mission_coverage tests_offboard rostest tests: @$(MAKE) --no-print-directory posix_sitl_default test_results \ @@ -302,6 +302,13 @@ rostest: posix_sitl_default tests_mission: rostest @$(SRC_DIR)/test/rostest_px4_run.sh mavros_posix_tests_missions.test +tests_mission_coverage: + @$(MAKE) clean + @$(MAKE) --no-print-directory posix_sitl_default PX4_CMAKE_BUILD_TYPE=Coverage + @$(MAKE) --no-print-directory posix_sitl_default sitl_gazebo PX4_CMAKE_BUILD_TYPE=Coverage + @$(SRC_DIR)/test/rostest_px4_run.sh mavros_posix_test_mission.test mission:=vtol_new_1 vehicle:=standard_vtol + @$(MAKE) --no-print-directory posix_sitl_default generate_coverage + tests_offboard: rostest @$(SRC_DIR)/test/rostest_px4_run.sh mavros_posix_tests_offboard_attctl.test @$(SRC_DIR)/test/rostest_px4_run.sh mavros_posix_tests_offboard_posctl.test diff --git a/cmake/common/coverage.cmake b/cmake/common/coverage.cmake index 605b01efa7..e963be4c6a 100644 --- a/cmake/common/coverage.cmake +++ b/cmake/common/coverage.cmake @@ -69,15 +69,15 @@ FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) message(FATAL_ERROR "genhtml required") endif() - set(coverage_info "${CMAKE_BINARY_DIR}/coverage.info") + set(coverage_info "${CMAKE_BINARY_DIR}/${_outputname}.info") set(coverage_cleaned "${coverage_info}.cleaned") separate_arguments(test_command UNIX_COMMAND "${_testrunner}") # Setup target - add_custom_COMMAND(OUTPUT ${coverage_info} + add_custom_command(OUTPUT ${coverage_info} # Cleanup lcov - COMMAND ${LCOV_PATH} --quiet --directory . --zerocounters + #COMMAND ${LCOV_PATH} --quiet --directory . --zerocounters # Run tests COMMAND ${test_command} ${ARGV3} diff --git a/platforms/posix/cmake/sitl_tests.cmake b/platforms/posix/cmake/sitl_tests.cmake index 9743dd5a11..47ba74564f 100644 --- a/platforms/posix/cmake/sitl_tests.cmake +++ b/platforms/posix/cmake/sitl_tests.cmake @@ -95,7 +95,8 @@ add_custom_target(test_results set_target_properties(test_results PROPERTIES EXCLUDE_FROM_ALL TRUE) if (CMAKE_BUILD_TYPE STREQUAL Coverage) - setup_target_for_coverage(test_coverage "${CMAKE_CTEST_COMMAND} --output-on-failure -T Test" coverage.info) + setup_target_for_coverage(test_coverage "${CMAKE_CTEST_COMMAND} --output-on-failure -T Test" tests) + setup_target_for_coverage(generate_coverage "${CMAKE_COMMAND} -E echo" generic) endif() add_custom_target(test_results_junit