From c446898d05a5315804d65c8bf39f436eeef106f1 Mon Sep 17 00:00:00 2001 From: Ben Dyer Date: Sun, 25 Oct 2015 10:42:23 +1100 Subject: [PATCH 1/2] Adding CONTINUOUS_INTEGRATION_BUILD flag --- .travis.yml | 2 +- CMakeLists.txt | 1 + libuavcan/CMakeLists.txt | 17 ++++++++++++++--- libuavcan/include/uavcan/build_config.hpp | 7 +++++++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1fe997ed73..6cc78db1d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ before_install: - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi - sudo apt-get install libgtest-dev gcc-arm-none-eabi - "cd /usr/src/gtest && sudo cmake . && sudo cmake --build . && sudo mv libg* /usr/local/lib/ ; cd -" -before_script: "mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Debug" +before_script: "mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Debug -DCONTINUOUS_INTEGRATION_BUILD=1" script: - if [ "${COVERITY_SCAN_BRANCH}" != 1 ] && [ "${TARGET}" == "native" ]; then make ; fi - if [ "${COVERITY_SCAN_BRANCH}" != 1 ] && [ "${TARGET}" == "lpc11c24" ]; then cd "$TRAVIS_BUILD_DIR/libuavcan_drivers/lpc11c24/test_olimex_lpc_p11c24" && make all ; fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ee028830e..04ee3d4d52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ set(opts "CMAKE_C_FLAGS:STRING:::C flags." "UAVCAN_USE_CPP03:BOOL:OFF::Use C++03 standard." "UAVCAN_PLATFORM:STRING:generic:generic linux stm32:Platform." + "CONTINUOUS_INTEGRATION_BUILD:BOOL:OFF::Disable error redirection and timing tests" ) foreach(_opt ${opts}) # arguments are : delimited diff --git a/libuavcan/CMakeLists.txt b/libuavcan/CMakeLists.txt index 7f16ab35e0..104c2e35e3 100644 --- a/libuavcan/CMakeLists.txt +++ b/libuavcan/CMakeLists.txt @@ -56,6 +56,10 @@ if (DEBUG_BUILD) add_definitions(-DUAVCAN_DEBUG=1) endif () +if (CONTINUOUS_INTEGRATION_BUILD) + add_definitions(-DUAVCAN_NO_TIMING_SENSITIVE_TESTS=1) +endif () + include_directories(include) # @@ -92,9 +96,16 @@ function(add_libuavcan_test name library flags) # Adds GTest executable and crea # Tests run automatically upon successful build # If failing tests need to be investigated with debugger, use 'make --ignore-errors' - add_custom_command(TARGET ${name} POST_BUILD - COMMAND ./${name} 1>"${name}.log" 2>&1 - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + if (CONTINUOUS_INTEGRATION_BUILD) + # Don't redirect test output + add_custom_command(TARGET ${name} POST_BUILD + COMMAND ./${name} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + else () + add_custom_command(TARGET ${name} POST_BUILD + COMMAND ./${name} 1>"${name}.log" 2>&1 + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + endif() endfunction() if (DEBUG_BUILD) diff --git a/libuavcan/include/uavcan/build_config.hpp b/libuavcan/include/uavcan/build_config.hpp index c1ee6dc1e0..f099856744 100644 --- a/libuavcan/include/uavcan/build_config.hpp +++ b/libuavcan/include/uavcan/build_config.hpp @@ -151,6 +151,13 @@ # define UAVCAN_USE_EXTERNAL_FLOAT16_CONVERSION 0 #endif +/* + * Disables timing-dependent tests in the test suite, since these may fail on virtualized machines + */ +#ifndef UAVCAN_NO_TIMING_SENSITIVE_TESTS +# define UAVCAN_NO_TIMING_SENSITIVE_TESTS 0 +#endif + /** * Run time checks. * Resolves to the standard assert() by default. From 8b178aaa6517336bf9e965b273f8c48c6e66d299 Mon Sep 17 00:00:00 2001 From: Ben Dyer Date: Sun, 25 Oct 2015 17:51:30 +1100 Subject: [PATCH 2/2] Use --gtest_filter to exclude real-time tests, instead of modifying source --- libuavcan/CMakeLists.txt | 8 ++------ libuavcan/include/uavcan/build_config.hpp | 7 ------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/libuavcan/CMakeLists.txt b/libuavcan/CMakeLists.txt index 104c2e35e3..137732bd1d 100644 --- a/libuavcan/CMakeLists.txt +++ b/libuavcan/CMakeLists.txt @@ -56,10 +56,6 @@ if (DEBUG_BUILD) add_definitions(-DUAVCAN_DEBUG=1) endif () -if (CONTINUOUS_INTEGRATION_BUILD) - add_definitions(-DUAVCAN_NO_TIMING_SENSITIVE_TESTS=1) -endif () - include_directories(include) # @@ -97,9 +93,9 @@ function(add_libuavcan_test name library flags) # Adds GTest executable and crea # Tests run automatically upon successful build # If failing tests need to be investigated with debugger, use 'make --ignore-errors' if (CONTINUOUS_INTEGRATION_BUILD) - # Don't redirect test output + # Don't redirect test output, and don't run tests suffixed with "RealTime" add_custom_command(TARGET ${name} POST_BUILD - COMMAND ./${name} + COMMAND ./${name} --gtest_filter=-*RealTime WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) else () add_custom_command(TARGET ${name} POST_BUILD diff --git a/libuavcan/include/uavcan/build_config.hpp b/libuavcan/include/uavcan/build_config.hpp index f099856744..c1ee6dc1e0 100644 --- a/libuavcan/include/uavcan/build_config.hpp +++ b/libuavcan/include/uavcan/build_config.hpp @@ -151,13 +151,6 @@ # define UAVCAN_USE_EXTERNAL_FLOAT16_CONVERSION 0 #endif -/* - * Disables timing-dependent tests in the test suite, since these may fail on virtualized machines - */ -#ifndef UAVCAN_NO_TIMING_SENSITIVE_TESTS -# define UAVCAN_NO_TIMING_SENSITIVE_TESTS 0 -#endif - /** * Run time checks. * Resolves to the standard assert() by default.