Initial contribution

This commit is contained in:
Michiel Beemster 2018-04-10 17:03:59 +02:00
parent 7b5cc4fa59
commit 11d9ce37aa
580 changed files with 155133 additions and 162 deletions

View file

@ -0,0 +1,134 @@
#
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
#
# This script will run all tests and generates various coverage reports.
#
# Example usage:
# $ cmake -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoverageConvenience.cmake
# If you start the scripts while in <cham bld> then you don't have to provide the COVERAGE_SETTINGS file.
#
cmake_minimum_required(VERSION 3.5)
# Get Coverage configuration file
if(NOT COVERAGE_SETTINGS)
set(COVERAGE_SETTINGS ${CMAKE_CURRENT_BINARY_DIR}/CoverageSettings.cmake)
endif()
include(${COVERAGE_SETTINGS})
message(STATUS "Config file: ${COVERAGE_SETTINGS}")
message(STATUS "Source directory: ${COVERAGE_SOURCE_DIR}")
message(STATUS "Test directory: ${COVERAGE_RUN_DIR}")
message(STATUS "Output directory: ${COVERAGE_OUTPUT_DIR}")
set(COVERAGE_SCRIPTS_DIR "${COVERAGE_SOURCE_DIR}/cmake/scripts")
###############################################################################
#
# Detect generators
#
###############################################################################
set(GENERATE_COVERAGE TRUE)
if(GENERATE_COVERAGE)
find_program(GCOV_PATH gcov PARENT_SCOPE)
if(NOT GCOV_PATH)
set(GENERATE_COVERAGE FALSE)
message(STATUS "[SKIP] Coverage generators - gcov (could not find gcov)")
endif()
endif()
if(GENERATE_COVERAGE)
message(STATUS "[ OK ] Coverage generators - gcov")
endif()
set(GENERATE_COVERAGE_HTML TRUE)
if(GENERATE_COVERAGE_HTML)
find_program(LCOV_PATH lcov PARENT_SCOPE)
if(NOT LCOV_PATH)
set(GENERATE_COVERAGE_HTML FALSE)
message(STATUS "[SKIP] Coverage generators - HTML (could not find lcov)")
endif()
endif()
if(GENERATE_COVERAGE_HTML)
find_program(GENHTML_PATH genhtml PARENT_SCOPE)
if(NOT GENHTML_PATH)
set(GENERATE_COVERAGE_HTML FALSE)
message(STATUS "[SKIP] Coverage generators - HTML (could not find genhtml)")
endif()
endif()
if(GENERATE_COVERAGE_HTML)
message(STATUS "[ OK ] Coverage generators - HTML (lcov and genhtml)")
endif()
set(GENERATE_COVERAGE_COBERTURA TRUE)
if(GENERATE_COVERAGE_COBERTURA)
find_program(GCOVR_PATH gcovr PARENT_SCOPE)
if(NOT GCOVR_PATH)
set(GENERATE_COVERAGE_COBERTURA FALSE)
message(STATUS "[SKIP] Coverage generators - Cobertura (could not find gcovr)")
endif()
endif()
if(GENERATE_COVERAGE_COBERTURA)
message(STATUS "[ OK ] Coverage generators - Cobertura (gcovr)")
endif()
if(NOT GENERATE_COVERAGE)
message(FATAL_ERROR "Could not find the main coverage generator 'gcov'")
elseif(NOT GENERATE_COVERAGE_HTML AND NOT GENERATE_COVERAGE_COBERTURA)
message(FATAL_ERROR "Could not find either of the two coverage report generators")
endif()
###############################################################################
#
# Setup environment
#
###############################################################################
message(STATUS "Setup environment")
if(GENERATE_COVERAGE_HTML)
execute_process(COMMAND ${CMAKE_COMMAND} -DCOVERAGE_SETTINGS=${COVERAGE_SETTINGS} -P ${COVERAGE_SCRIPTS_DIR}/CoveragePreHtml.cmake
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
endif()
if(GENERATE_COVERAGE_COBERTURA)
execute_process(COMMAND ${CMAKE_COMMAND} -DCOVERAGE_SETTINGS=${COVERAGE_SETTINGS} -P ${COVERAGE_SCRIPTS_DIR}/CoveragePreCobertura.cmake
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
endif()
###############################################################################
#
# Generate coverage results by running all the tests
#
###############################################################################
message(STATUS "Run all test to get coverage")
execute_process(COMMAND ctest ${COVERAGE_QUIET_FLAG} -T test
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
execute_process(COMMAND ctest ${COVERAGE_QUIET_FLAG} -T coverage
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
###############################################################################
#
# Generate coverage reports
#
###############################################################################
if(GENERATE_COVERAGE_HTML)
execute_process(COMMAND ${CMAKE_COMMAND} -DCOVERAGE_SETTINGS=${COVERAGE_SETTINGS} -P ${COVERAGE_SCRIPTS_DIR}/CoveragePostHtml.cmake
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
endif()
if(GENERATE_COVERAGE_COBERTURA)
execute_process(COMMAND ${CMAKE_COMMAND} -DCOVERAGE_SETTINGS=${COVERAGE_SETTINGS} -P ${COVERAGE_SCRIPTS_DIR}/CoveragePostCobertura.cmake
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
endif()

View file

@ -0,0 +1,52 @@
#
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
#
# This script assumes that all test have been run and gcov results are available.
# It will generate the Cobertura output from the gcov results.
#
# Example usage:
# $ cmake -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePreCobertura.cmake
# $ ctest -T test
# $ ctest -T coverage
# $ ctest -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePostCobertura.cmake
# If you start the scripts while in <cham bld> then you don't have to provide the COVERAGE_SETTINGS file.
#
cmake_minimum_required(VERSION 3.5)
# Get Coverage configuration file
if(NOT COVERAGE_SETTINGS)
set(COVERAGE_SETTINGS ${CMAKE_CURRENT_BINARY_DIR}/CoverageSettings.cmake)
endif()
include(${COVERAGE_SETTINGS})
# Some debug
#message(STATUS "Config file: ${COVERAGE_SETTINGS}")
#message(STATUS "Source directory: ${COVERAGE_SOURCE_DIR}")
#message(STATUS "Test directory: ${COVERAGE_RUN_DIR}")
#message(STATUS "Output directory: ${COVERAGE_OUTPUT_DIR}")
# Find gcovr to generate Cobertura results
find_program(GCOVR_PATH gcovr PARENT_SCOPE)
if(NOT GCOVR_PATH)
message(FATAL_ERROR "Could not find gcovr to generate Cobertura coverage.")
endif()
# Create location to put the result file.
file(MAKE_DIRECTORY ${COVERAGE_OUTPUT_DIR})
execute_process(COMMAND ${GCOVR_PATH} -x -r ${COVERAGE_SOURCE_DIR} -e ".*/${COVERAGE_EXCLUDE_TESTS}/.*" -e ".*/${COVERAGE_EXCLUDE_EXAMPLES}/.*" -e ".*/${COVERAGE_EXCLUDE_BUILD_SUPPORT}/.*" -o ${COVERAGE_OUTPUT_DIR}/cobertura.xml
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
message(STATUS "The Cobertura report can be found here: ${COVERAGE_OUTPUT_DIR}/cobertura.xml")

View file

@ -0,0 +1,71 @@
#
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
#
# This script assumes that all test have been run and gcov results are available.
# It will generate the HTML output from the gcov results.
#
# Example usage:
# $ cmake -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePreHtml.cmake
# $ ctest -T test
# $ ctest -T coverage
# $ ctest -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePostHtml.cmake
# If you start the scripts while in <cham bld> then you don't have to provide the COVERAGE_SETTINGS file.
#
cmake_minimum_required(VERSION 3.5)
# Get Coverage configuration file
if(NOT COVERAGE_SETTINGS)
set(COVERAGE_SETTINGS ${CMAKE_CURRENT_BINARY_DIR}/CoverageSettings.cmake)
endif()
include(${COVERAGE_SETTINGS})
# Some debug
#message(STATUS "Config file: ${COVERAGE_SETTINGS}")
#message(STATUS "Source directory: ${COVERAGE_SOURCE_DIR}")
#message(STATUS "Test directory: ${COVERAGE_RUN_DIR}")
#message(STATUS "Output directory: ${COVERAGE_OUTPUT_DIR}")
# Find tools to generate HTML coverage results
find_program(LCOV_PATH lcov PARENT_SCOPE)
if(NOT LCOV_PATH)
message(FATAL_ERROR "Could not find lcov to generate HTML coverage.")
endif()
find_program(GENHTML_PATH genhtml PARENT_SCOPE)
if(NOT GENHTML_PATH)
message(FATAL_ERROR "Could not find genhtml to generate HTML coverage.")
endif()
# Create location to put the result file.
file(MAKE_DIRECTORY ${COVERAGE_OUTPUT_DIR})
set(COVERAGE_HTML_OUTPUT "${COVERAGE_OUTPUT_DIR}/html")
file(MAKE_DIRECTORY ${COVERAGE_HTML_OUTPUT})
# Setup tmp analysis files
set(COVERAGE_INFO "${COVERAGE_HTML_OUTPUT}/coverage_html.info")
set(COVERAGE_CLEANED "${COVERAGE_INFO}.cleaned")
# Execute lcov and genhtml commands to get HTML results
execute_process(COMMAND ${LCOV_PATH} ${COVERAGE_QUIET_FLAG} --directory . --capture --output-file ${COVERAGE_INFO}
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
execute_process(COMMAND ${LCOV_PATH} ${COVERAGE_QUIET_FLAG} --remove ${COVERAGE_INFO} "${COVERAGE_EXCLUDE_TESTS}/*" "${COVERAGE_EXCLUDE_EXAMPLES}/*" "${COVERAGE_EXCLUDE_BUILD_SUPPORT}/*" "/usr/*" --output-file ${COVERAGE_CLEANED}
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
execute_process(COMMAND ${GENHTML_PATH} ${COVERAGE_QUIET_FLAG} -o ${COVERAGE_HTML_OUTPUT} ${COVERAGE_CLEANED}
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
# Remove tmp analysis files
execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${COVERAGE_INFO} ${COVERAGE_CLEANED}
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})
message(STATUS "The HTML coverage report can be found here: ${COVERAGE_HTML_OUTPUT}/index.html")

View file

@ -0,0 +1,30 @@
#
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
#
# This script assumes that it is called before all tests are run and gcov results are available.
# It can be used to setup the environment needed to get proper Cobertura coverage results.
#
# Example usage:
# $ cmake -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePreCobertura.cmake
# $ ctest -T test
# $ ctest -T coverage
# $ ctest -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePostCobertura.cmake
# If you start the scripts while in <cham bld> then you don't have to provide the COVERAGE_SETTINGS file.
#
cmake_minimum_required(VERSION 3.5)
#
# Nothing to do really.
# This is just added to provide consistency between Coverage scripts.
#

View file

@ -0,0 +1,52 @@
#
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
#
# This script assumes that it is called before all tests are run and gcov results are available.
# It can be used to setup the environment needed to get proper HTML coverage results.
#
# Example usage:
# $ cmake -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePreHtml.cmake
# $ ctest -T test
# $ ctest -T coverage
# $ ctest -DCOVERAGE_SETTINGS=<cham bld>/CoverageSettings.cmake -P <cham src>/cmake/scripts/CoveragePostHtml.cmake
# If you start the scripts while in <cham bld> then you don't have to provide the COVERAGE_SETTINGS file.
#
cmake_minimum_required(VERSION 3.5)
# Get Coverage configuration file
if(NOT COVERAGE_SETTINGS)
set(COVERAGE_SETTINGS ${CMAKE_CURRENT_BINARY_DIR}/CoverageSettings.cmake)
endif()
include(${COVERAGE_SETTINGS})
# Some debug
#message(STATUS "Config file: ${COVERAGE_SETTINGS}")
#message(STATUS "Source directory: ${COVERAGE_SOURCE_DIR}")
#message(STATUS "Test directory: ${COVERAGE_RUN_DIR}")
#message(STATUS "Output directory: ${COVERAGE_OUTPUT_DIR}")
# Find tools to generate HTML coverage results
find_program(LCOV_PATH lcov PARENT_SCOPE)
if(NOT LCOV_PATH)
message(FATAL_ERROR "Could not find lcov to generate HTML coverage.")
endif()
find_program(GENHTML_PATH genhtml PARENT_SCOPE)
if(NOT GENHTML_PATH)
message(FATAL_ERROR "Could not find genhtml to generate HTML coverage.")
endif()
# Reset LCOV environment
execute_process(COMMAND ${LCOV_PATH} ${COVERAGE_QUIET_FLAG} --directory . --zerocounters
WORKING_DIRECTORY ${COVERAGE_RUN_DIR})