1# 2# Copyright 2015-2016 Nest Labs Inc. All Rights Reserved. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17# 18# Description: 19# This file defines automake variables and macros common to all 20# other automake headers and files for code coverage. 21# 22 23# Suffixes 24 25# 26# Suffix for the code coverage report "bundle". 27# 28NL_COVERAGE_BUNDLE_SUFFIX = .lcov 29 30# 31# Suffix for the lcov "info" file inside the code coverage report bundle. 32# 33NL_COVERAGE_INFO_SUFFIX = .info 34 35# 36# Verbosity macros and flags 37# 38 39NL_V_LCOV = $(nl__v_LCOV_$(V)) 40nl__v_LCOV_ = $(nl__v_LCOV_$(AM_DEFAULT_VERBOSITY)) 41nl__v_LCOV_0 = @echo " LCOV $(@)"; 42nl__v_LCOV_1 = 43 44NL_V_LCOV_FLAGS = $(nl__v_LCOV_FLAGS_$(V)) 45nl__v_LCOV_FLAGS_ = $(nl__v_LCOV_FLAGS_$(AM_DEFAULT_VERBOSITY)) 46nl__v_LCOV_FLAGS_0 = --quiet 47nl__v_LCOV_FLAGS_1 = 48 49NL_V_GENHTML = $(nl__v_GENHTML_$(V)) 50nl__v_GENHTML_ = $(nl__v_GENHTML_$(AM_DEFAULT_VERBOSITY)) 51nl__v_GENHTML_0 = @echo " GENHTML $(@)"; 52nl__v_GENHTML_1 = 53 54NL_V_GENHTML_FLAGS = $(nl__v_GENHTML_FLAGS_$(V)) 55nl__v_GENHTML_FLAGS_ = $(nl__v_GENHTML_FLAGS_$(AM_DEFAULT_VERBOSITY)) 56nl__v_GENHTML_FLAGS_0 = --quiet 57nl__v_GENHTML_FLAGS_1 = 58 59# 60# generate-coverage-report <directory> 61# 62# Capture, using lcov, a coverage report from the specified directory 'directory' 63# with an final output "info" file as specified by the target variable. 64# 65# <directory> - The directory from which lcov should search for coverage data (*.gcno & *.gcda) 66# 67# - create baseline coverage data file (base.info) with '-i|--initial' option 68# - create test coverage data file (test.info) 69# - combine baseline and test coverage data to create the final "info" file 70# 71# Then, on success, generate an HTML-based coverage report using genhtml. 72# 73define generate-coverage-report 74$(NL_V_LCOV)$(LCOV) $(NL_V_LCOV_FLAGS) --config-file="$(abs_top_nlbuild_autotools_dir)/etc/lcov.config" --initial --capture --directory "$(1)" --output-file "base.info" 75$(NL_V_LCOV)$(LCOV) $(NL_V_LCOV_FLAGS) --config-file="$(abs_top_nlbuild_autotools_dir)/etc/lcov.config" --capture --directory "$(1)" --output-file "test.info" 76$(NL_V_LCOV)$(LCOV) $(NL_V_LCOV_FLAGS) --config-file="$(abs_top_nlbuild_autotools_dir)/etc/lcov.config" --add-tracefile "base.info" --add-tracefile "test.info" --output-file "$(@)" 77$(NL_V_GENHTML)$(GENHTML) $(NL_V_GENHTML_FLAGS) --config-file="$(abs_top_nlbuild_autotools_dir)/etc/lcov.config" "$(@)" --output-directory "$(@D)" 78endef # generate-coverage-report 79 80# 81# generate-coverage-report-with-filter <directory> <remove_filter> 82# 83# Capture, using lcov, a coverage report from the specified directory 'directory' and a filter 'remove_filter' 84# with an final output "info" file as specified by the target variable. 85# 86# <directory> - The directory from which lcov should search for coverage data (*.gcno & *.gcda) 87# 88# <remove_filter> - The filter is a whitespace-separated list of shell wildcard patterns. (note that they may need to be escaped accordingly to prevent 89# the shell from expanding them first). Every file entry in tracefile which matches at least one of those patterns will be removed. 90# 91# - create baseline coverage data file (base.info) with '-i|--initial' option 92# - create test coverage data file (test.info) 93# - combine baseline and test coverage data to create the final "info" file 94# - remove particular coverage data specifiled by the remove_filter (no change if remove_filter is null) 95# 96# Then, on success, generate an HTML-based coverage report using genhtml. 97# 98define generate-coverage-report-with-filter 99$(NL_V_LCOV)$(LCOV) $(NL_V_LCOV_FLAGS) --config-file="$(abs_top_nlbuild_autotools_dir)/etc/lcov.config" --initial --capture --directory "$(1)" --output-file "base.info" 100$(NL_V_LCOV)$(LCOV) $(NL_V_LCOV_FLAGS) --config-file="$(abs_top_nlbuild_autotools_dir)/etc/lcov.config" --capture --directory "$(1)" --output-file "test.info" 101$(NL_V_LCOV)$(LCOV) $(NL_V_LCOV_FLAGS) --config-file="$(abs_top_nlbuild_autotools_dir)/etc/lcov.config" --add-tracefile "base.info" --add-tracefile "test.info" --output-file "$(@)" 102$(NL_V_LCOV)$(LCOV) $(NL_V_LCOV_FLAGS) --config-file="$(abs_top_nlbuild_autotools_dir)/etc/lcov.config" --remove "$(@)" $(foreach pattern,$(2),"$(pattern)") --output-file "$(@)" 103$(NL_V_GENHTML)$(GENHTML) $(NL_V_GENHTML_FLAGS) --config-file="$(abs_top_nlbuild_autotools_dir)/etc/lcov.config" "$(@)" --output-directory "$(@D)" 104endef # generate-coverage-report-with-filter 105 106 107