Fix Add test and coverage report to CI
@@ -8,17 +8,17 @@ addons:
sources:
- ubuntu-toolchain-r-test
packages:
- - cmake
-
-before_install:
- - sudo apt-get install cppcheck
+ - cmake cppcheck lcov
+_functional_test: &functional_test
script:
# Check versions
- cppcheck --version
#cppcheck flight software osal/src/bsp, osal/src/os
- - cppcheck --force --inline-suppr --std=c99 --language=c --error-exitcode=1 --enable=warning,performance,portability,style --suppress=variableScope --inconclusive src/bsp src/os 2>cppcheck_flight_osal.txt
+ - cppcheck --force --inline-suppr --std=c99 --language=c --error-exitcode=1
+ --enable=warning,performance,portability,style --suppress=variableScope
+ --inconclusive --quiet src/bsp src/os 2>cppcheck_flight_osal.txt
- |
if [[ -s cppcheck_flight_osal.txt ]]; then
echo "You must fix cppcheck errors before submitting a pull request"
@@ -27,3 +27,36 @@ script:
exit -1
fi
+ # Setup
+ - mkdir build
+ - cd build
+
+ # Prep and build
+ - cmake -DENABLE_UNIT_TESTS=true -DOSAL_SYSTEM_OSTYPE=posix -DOSAL_SYSTEM_BSPTYPE=pc-linux
+ -DOSAL_INCLUDEDIR=src/bsp/pc-linux/config/ ..
+ - make
+
+ # lcov capture pre-execution
+ - lcov --rc lcov_branch_coverage=1 --capture --initial --directory ./ --output-file coverage_base.info
+
+ # Test
+ - make test
+
+ # lcov post run analysis
+ - lcov --rc lcov_branch_coverage=1 --capture --directory ./ --output-file coverage_test.info
+ - lcov --rc lcov_branch_coverage=1 --add-tracefile coverage_base.info --add-tracefile
+ coverage_test.info --output-file coverage_total.info
+ - lcov --rc lcov_branch_coverage=1 --remove coverage_total.info '*unit-test-coverage*'
+ --output-file coverage_filtered.info
+ - genhtml coverage_filtered.info --output-directory lcov
+
+jobs:
+ include:
+ - env: BUILDTYPE=release OSAL_OMIT_DEPRECATED=true
+ <<: *functional_test
+ - env: BUILDTYPE=release OSAL_OMIT_DEPRECATED=false
+ <<: *functional_test
+ - env: BUILDTYPE=debug OSAL_OMIT_DEPRECATED=true
+ <<: *functional_test
+ - env: BUILDTYPE=debug OSAL_OMIT_DEPRECATED=false
+ <<: *functional_test
