diff options
-rw-r--r-- | .gitlab-ci.yml | 6 | ||||
-rw-r--r-- | CMakeLists.txt | 42 | ||||
-rw-r--r-- | tools/hscript-simulate/CMakeLists.txt | 7 | ||||
-rw-r--r-- | tools/hscript-validate/CMakeLists.txt | 7 |
4 files changed, 50 insertions, 12 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4a4c0c2..62f90a2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,9 +17,9 @@ test: - cd tests - PATH=../build/tools/hscript-validate:../build/tools/hscript-simulate:$PATH rspec --format RspecJunitFormatter --out rspec.xml - cd .. - - lcov --exclude '/usr/include/c++/*' --exclude '*/3rdparty/*' --capture --directory build --output-file coverage.info - - genhtml coverage.info --output-directory cov_html - - printf 'coverage %s\n' $(lcov --summary coverage.info | grep lines | cut -d ' ' -f4) > metrics.txt + - make lcov_report + - make lcov_html + - printf 'coverage %s\n' $(lcov --summary horizon.coverage | grep lines | cut -d ' ' -f4) > metrics.txt coverage: '/lines.+: \d+.\d+%/' artifacts: paths: diff --git a/CMakeLists.txt b/CMakeLists.txt index 94af0d1..a311188 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,10 +8,24 @@ project(Horizon VERSION 0.1.0) option(BUILD_TOOLS "Enable building of tools (Validator, Simulator, etc)" ON) + + +## Code Coverage stuff ## option(COVERAGE "Build for code coverage tests (slow)" OFF) +IF(COVERAGE) + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} --coverage") + SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} --coverage") +ENDIF(COVERAGE) + + +## Valgrind stuff ## +find_program(VALGRIND_EXECUTABLE NAMES valgrind) +IF(VALGRIND_EXECUTABLE) option(VALGRIND "Run Valgrind during test phase" OFF) -option(INSTALL "Build Installation Environment support (Linux only)" ON) +ENDIF(VALGRIND_EXECUTABLE) + +## Firmware stuff ## option(UNSUPPORTED_NONFREE_FIRMWARE "Support loading and installation of non-libre firmware (DANGEROUS)" OFF) mark_as_advanced(FORCE UNSUPPORTED_NONFREE_FIRMWARE) @@ -19,6 +33,10 @@ IF(UNSUPPORTED_NONFREE_FIRMWARE) add_definitions(-DNON_LIBRE_FIRMWARE) ENDIF(UNSUPPORTED_NONFREE_FIRMWARE) + +## Installation Environment support stuff ## +option(INSTALL "Build Installation Environment support (Linux only)" ON) + check_include_files(linux/wireless.h HAVE_LINUX_WIRELESS_H) IF(NOT HAVE_LINUX_WIRELESS_H) SET(INSTALL OFF) @@ -32,15 +50,29 @@ IF(INSTALL) find_library(BCNM_LIBRARY REQUIRED wpactrl PATH_SUFFIXES bcnm) ENDIF(INSTALL) -IF(COVERAGE) - SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} --coverage") - SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} --coverage") -ENDIF(COVERAGE) include_directories(.) + + +## Test stuff ## +find_program(RSPEC_EXECUTABLE NAMES rspec) enable_testing() add_subdirectory(hscript) IF(BUILD_TOOLS) add_subdirectory(tools) ENDIF(BUILD_TOOLS) + + +IF(COVERAGE) + find_program(LCOV_EXECUTABLE NAMES lcov) + + IF(LCOV_EXECUTABLE) + add_custom_command(OUTPUT horizon.coverage + COMMAND lcov ARGS --exclude '/usr/include/c++/*' --exclude '*/3rdparty/*' --capture --directory ${CMAKE_BINARY_DIR} --output-file horizon.coverage) + add_custom_target(lcov_report DEPENDS horizon.coverage) + add_custom_command(OUTPUT cov_html + COMMAND genhtml ARGS horizon.coverage --output-directory cov_html) + add_custom_target(lcov_html DEPEND cov_html) + ENDIF(LCOV_EXECUTABLE) +ENDIF(COVERAGE) diff --git a/tools/hscript-simulate/CMakeLists.txt b/tools/hscript-simulate/CMakeLists.txt index 98ec9e4..45e8d95 100644 --- a/tools/hscript-simulate/CMakeLists.txt +++ b/tools/hscript-simulate/CMakeLists.txt @@ -6,12 +6,15 @@ target_link_libraries(hscript-simulate hscript) install(TARGETS hscript-simulate DESTINATION bin) +IF(RSPEC_EXECUTABLE) add_test(NAME "RSpecSimulator" - COMMAND rspec spec/simulator_spec.rb + COMMAND ${RSPEC_EXECUTABLE} spec/simulator_spec.rb WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) set_property(TEST "RSpecSimulator" PROPERTY ENVIRONMENT "PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}") +ENDIF(RSPEC_EXECUTABLE) + IF(VALGRIND) add_test(NAME "ValgrindSimulator" - COMMAND valgrind ${CMAKE_CURRENT_BINARY_DIR}/hscript-simulate ${CMAKE_SOURCE_DIR}/tests/fixtures/0001-basic.installfile) + COMMAND ${VALGRIND_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/hscript-simulate ${CMAKE_SOURCE_DIR}/tests/fixtures/0001-basic.installfile) ENDIF(VALGRIND) diff --git a/tools/hscript-validate/CMakeLists.txt b/tools/hscript-validate/CMakeLists.txt index a02d90b..f8b579a 100644 --- a/tools/hscript-validate/CMakeLists.txt +++ b/tools/hscript-validate/CMakeLists.txt @@ -6,12 +6,15 @@ target_link_libraries(hscript-validate hscript) install(TARGETS hscript-validate DESTINATION bin) +IF(RSPEC_EXECUTABLE) add_test(NAME "RSpecValidator" - COMMAND rspec spec/validator_spec.rb + COMMAND ${RSPEC_EXECUTABLE} spec/validator_spec.rb WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) set_property(TEST "RSpecValidator" PROPERTY ENVIRONMENT "PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}") +ENDIF(RSPEC_EXECUTABLE) + IF(VALGRIND) add_test(NAME "ValgrindValidator" - COMMAND valgrind ${CMAKE_CURRENT_BINARY_DIR}/hscript-validate ${CMAKE_SOURCE_DIR}/tests/fixtures/0001-basic.installfile) + COMMAND ${VALGRIND_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/hscript-validate ${CMAKE_SOURCE_DIR}/tests/fixtures/0001-basic.installfile) ENDIF(VALGRIND) |