From 4cdf1e39bbee3dd50a9d4b1a38da4ee78ad3bc22 Mon Sep 17 00:00:00 2001 From: Chung Min Kim Date: Fri, 22 Jun 2018 14:27:46 -0700 Subject: [PATCH 1/6] Add code coverage for bro source files after btest test suite Adds --enable-coverage flag to configure Bro with gcov. A new directory named /testing/bro-code-coverage/ contains a new coverage target that as part of `make coverage` in /testing/. This coverage option creates coverage.log of all important directories in /src/ and places all generated .gcov files alongside the corresponding source file. --- configure | 7 ++ testing/Makefile | 2 + testing/bro-core-coverage/Makefile | 9 ++ testing/bro-core-coverage/code_coverage.sh | 134 +++++++++++++++++++++ testing/btest/Makefile | 1 + 5 files changed, 153 insertions(+) create mode 100644 testing/bro-core-coverage/Makefile create mode 100755 testing/bro-core-coverage/code_coverage.sh diff --git a/configure b/configure index fdbca263c6..56d10e393b 100755 --- a/configure +++ b/configure @@ -45,6 +45,7 @@ Usage: $0 [OPTION]... [VAR=VALUE]... Optional Features: --enable-debug compile in debugging mode (like --build-type=Debug) + --enable-coverage compile with code coverage support (implies debugging mode) --enable-mobile-ipv6 analyze mobile IPv6 features defined by RFC 6275 --enable-perftools force use of Google perftools on non-Linux systems (automatically on when perftools is present on Linux) @@ -142,6 +143,8 @@ append_cache_entry INSTALL_BROCTL BOOL true append_cache_entry CPACK_SOURCE_IGNORE_FILES STRING append_cache_entry ENABLE_MOBILE_IPV6 BOOL false append_cache_entry DISABLE_PERFTOOLS BOOL false +append_cache_entry DISABLE_RUBY_BINDINGS BOOL true +append_cache_entry ENABLE_COVERAGE BOOL false # parse arguments while [ $# -ne 0 ]; do @@ -197,6 +200,10 @@ while [ $# -ne 0 ]; do --logdir=*) append_cache_entry BRO_LOG_DIR PATH $optarg ;; + --enable-coverage) + append_cache_entry ENABLE_COVERAGE BOOL true + append_cache_entry ENABLE_DEBUG BOOL true + ;; --enable-debug) append_cache_entry ENABLE_DEBUG BOOL true ;; diff --git a/testing/Makefile b/testing/Makefile index e83ec09396..e34aaca939 100644 --- a/testing/Makefile +++ b/testing/Makefile @@ -8,6 +8,7 @@ brief: make-brief coverage distclean: @rm -f coverage.log $(MAKE) -C btest $@ + $(MAKE) -C bro-core-coverage $@ make-verbose: @for repo in $(DIRS); do (cd $$repo && make -s ); done @@ -22,4 +23,5 @@ coverage: @echo "Complete test suite code coverage:" @./scripts/coverage-calc "brocov.tmp.*" coverage.log `pwd`/../scripts @rm -f brocov.tmp.* + @cd bro-core-coverage && make coverage diff --git a/testing/bro-core-coverage/Makefile b/testing/bro-core-coverage/Makefile new file mode 100644 index 0000000000..e7db4894fd --- /dev/null +++ b/testing/bro-core-coverage/Makefile @@ -0,0 +1,9 @@ +coverage: cleanup + @./code_coverage.sh + +cleanup: + @rm -f coverage.log + @find ../../ -name "*.gcov" -exec rm {} \; + +distclean: cleanup + @find ../../ -name "*.gcno" -exec rm {} \; diff --git a/testing/bro-core-coverage/code_coverage.sh b/testing/bro-core-coverage/code_coverage.sh new file mode 100755 index 0000000000..b1eb8c599a --- /dev/null +++ b/testing/bro-core-coverage/code_coverage.sh @@ -0,0 +1,134 @@ +#!/bin/bash +# +# On a Bro build configured with --enable-coverage, this script +# produces a code coverage report after Bro has been invoked. The +# intended application of this script is after the btest testsuite has +# run. This combination (btests first, coverage computation afterward) +# happens automatically when running "make" in the testing directory. +# +# This depends on gcov, which should come with your gcc. +# +# AUTOMATES CODE COVERAGE TESTING +# 1. Run test suite +# 2. Check for .gcda files existing. +# 3a. Run gcov (-p to preserve path) +# 3b. Prune .gcov files for objects outside of the Bro tree +# 4a. Analyze .gcov files generated and create summary file +# 4b. Send .gcov files to appropriate path +# +CURR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Location of script +BASE="$(realpath "${CURR}/../../")" +TMP="${CURR}/tmp.$$" +mkdir -p $TMP + +# DEFINE CLEANUP PROCESS +function finish { + find "$BASE" -name "*.gcda" -exec rm {} \; > /dev/null 2>&1 + rm -rf $TMP +} +trap finish EXIT + +# DEFINE CRUCIAL FUNCTIONS FOR COVERAGE CHECKING +function check_file_coverage { + GCOVDIR="$1" + + for i in $GCOVDIR/*.gcov; do + # Effective # of lines: starts with a number (# of runs in line) or ##### (line never run) + TOTAL=$(cut -d: -f 1 "$i" | sed 's/ //g' | grep -v "^[[:alpha:]]" | grep -v "-" | wc -l) + + # Count number of lines never run + UNRUN=$(grep "#####" "$i" | wc -l) + + # Lines in code are either run or unrun + RUN=$(($TOTAL - $UNRUN)) + + # Avoid division-by-zero problems: + PERCENTAGE=0.000 + [ $RUN -gt 0 ] && PERCENTAGE=$(bc <<< "scale=3; 100*$RUN/$TOTAL") + + # Find correlation between % of lines run vs. "Runs" + echo -e "$PERCENTAGE\t$RUN\t$TOTAL\t$(grep "0:Runs" "$i" | sed 's/.*://')\t$i" + done +} + +function check_group_coverage { + DATA="$1" # FILE CONTAINING COVERAGE DATA + SRC_FOLDER="$2" # WHERE BRO WAS COMPILED + OUTPUT="$3" + + # Prints all the relevant directories + DIRS=$(for i in $(cut -f 5 "$DATA"); do basename "$i" | sed 's/#[^#]*$//'; done \ + | sort | uniq | sed 's/^.*'"${SRC_FOLDER}"'//' | grep "^#s\+" ) + # "Generalize" folders unless it's from analyzers + DIRS=$(for i in $DIRS; do + if !(echo "$i" | grep "src#analyzer"); then + echo "$i" | cut -d "#" -f 1,2,3 + fi + done | sort | uniq ) + + for i in $DIRS; do + # For elements in #src, we only care about the files direclty in the directory. + if [[ "$i" = "#src" ]]; then + RUN=$(echo $(grep "$i#[^#]\+$" $DATA | grep "$SRC_FOLDER$i\|build$i" | cut -f 2) | tr " " "+" | bc) + TOTAL=$(echo $(grep "$i#[^#]\+$" $DATA | grep "$SRC_FOLDER$i\|build$i" | cut -f 3) | tr " " "+" | bc) + else + RUN=$(echo $(grep "$i" $DATA | cut -f 2) | tr " " "+" | bc) + TOTAL=$(echo $(grep "$i" $DATA | cut -f 3) | tr " " "+" | bc) + fi + + PERCENTAGE=$( echo "scale=3;100*$RUN/$TOTAL" | bc | tr "\n" " " ) + printf "%-50s\t%12s\t%6s %%\n" "$i" "$RUN/$TOTAL" $PERCENTAGE \ + | sed 's|#|/|g' >>$OUTPUT + done +} + +# 1. Run test suite +# SHOULD HAVE ALREADY BEEN RUN BEFORE THIS SCRIPT (BASED ON MAKEFILE TARGETS) + +# 2. Check for .gcno and .gcda file presence +echo -n "Checking for coverage files... " +for pat in gcda gcno; do + if [ -z "$(find "$BASE" -name "*.$pat" 2>/dev/null)" ]; then + echo "no .$pat files, nothing to do" + exit 0 + fi +done +echo "ok" + +# 3a. Run gcov (-p to preserve path) and move into tmp directory +echo -n "Creating coverage files... " +( cd "$TMP" && find "$BASE" -name "*.o" -exec gcov -p {} > /dev/null 2>&1 \; ) +NUM_GCOVS=$(ls "$TMP"/*.gcov | wc -l) +if [ $NUM_GCOVS -eq 0 ]; then + echo "no gcov files produced, aborting" + exit 1 +fi +echo "ok, $NUM_GCOVS coverage files" + +# 3b. Prune gcov files that fall outside of the Bro tree: +# Look for files containing gcov's slash substitution character "#" +# and remove any that don't contain the Bro path root. +echo -n "Pruning out-of-tree coverage files... " +PREFIX=$(echo "$BASE" | sed 's|/|#|g') +for i in "$TMP"/*#*.gcov; do + if ! [[ "$i" = *$PREFIX* ]]; then + rm -f $i + fi +done +NUM_GCOVS=$(ls "$TMP"/*.gcov | wc -l) +echo "ok, $NUM_GCOVS coverage files remain" + +# 4a. Analyze .gcov files generated and create summary file +echo -n "Creating summary file... " +DATA="${TMP}/data.txt" +SUMMARY="$CURR/coverage.log" +check_file_coverage "$TMP" > "$DATA" +check_group_coverage "$DATA" ${BASE##*/} $SUMMARY +echo "ok" + +# 4b. Send .gcov files to appropriate path +echo -n "Sending coverage files to respective directories... " +for i in "$TMP"/*#*.gcov; do + mv $i $(echo $(basename $i) | sed 's/#/\//g') +done +echo "ok" diff --git a/testing/btest/Makefile b/testing/btest/Makefile index c9bcfff5ee..c6f2438ad1 100644 --- a/testing/btest/Makefile +++ b/testing/btest/Makefile @@ -21,6 +21,7 @@ coverage: cleanup: @rm -f $(DIAG) @rm -rf $(SCRIPT_COV)* + @find ../../ -name "*.gcda" -exec rm {} \; distclean: cleanup @rm -rf .btest.failed.dat \ From 4ca4b0504350fa3546726a4732bfb60f450af30f Mon Sep 17 00:00:00 2001 From: Chung Min Kim Date: Tue, 24 Jul 2018 13:19:14 -0700 Subject: [PATCH 2/6] Refactoring, making error messages nicer, & lcov Directory name for bro core coverage changed to "coverage", error messages made nicer. Use `make html` in testing/coverage to create logs in HTML format when lcov exists on the system. --- .gitignore | 1 + testing/Makefile | 4 ++-- .../{bro-core-coverage => coverage}/Makefile | 6 ++++++ testing/coverage/README | 13 ++++++++++++ .../code_coverage.sh | 20 ++++++++++++------- 5 files changed, 35 insertions(+), 9 deletions(-) rename testing/{bro-core-coverage => coverage}/Makefile (52%) create mode 100644 testing/coverage/README rename testing/{bro-core-coverage => coverage}/code_coverage.sh (90%) diff --git a/.gitignore b/.gitignore index d59a62b7e1..fa397f98d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ build tmp +*.gcov diff --git a/testing/Makefile b/testing/Makefile index e34aaca939..c5610fc97b 100644 --- a/testing/Makefile +++ b/testing/Makefile @@ -8,7 +8,7 @@ brief: make-brief coverage distclean: @rm -f coverage.log $(MAKE) -C btest $@ - $(MAKE) -C bro-core-coverage $@ + $(MAKE) -C coverage $@ make-verbose: @for repo in $(DIRS); do (cd $$repo && make -s ); done @@ -23,5 +23,5 @@ coverage: @echo "Complete test suite code coverage:" @./scripts/coverage-calc "brocov.tmp.*" coverage.log `pwd`/../scripts @rm -f brocov.tmp.* - @cd bro-core-coverage && make coverage + @cd coverage && make coverage diff --git a/testing/bro-core-coverage/Makefile b/testing/coverage/Makefile similarity index 52% rename from testing/bro-core-coverage/Makefile rename to testing/coverage/Makefile index e7db4894fd..1aa8036bbf 100644 --- a/testing/bro-core-coverage/Makefile +++ b/testing/coverage/Makefile @@ -7,3 +7,9 @@ cleanup: distclean: cleanup @find ../../ -name "*.gcno" -exec rm {} \; + +html: + @(cd ../../; if which lcov; then\ + lcov --capture --directory . --output-file coverage.info \ + && genhtml coverage.info && rm coverage.info; \ + fi) diff --git a/testing/coverage/README b/testing/coverage/README new file mode 100644 index 0000000000..0c19e14d51 --- /dev/null +++ b/testing/coverage/README @@ -0,0 +1,13 @@ +On a Bro build configured with --enable-coverage, this script produces a code coverage report after Bro has been invoked. The intended application of this script is after the btest testsuite has run. This combination (btests first, coverage computation afterward) happens automatically when running "make" in the testing directory. This script puts .gcov files (which are included in .gitignore) alongside the corresponding source files. + +This depends on gcov, which should come with your gcc. If gcov is not installed, the script will abort with an error message. + +TODO: Use `make html` as make target in this directory to output the html files that gcov can create (must have lcov on system). + +The goal of code-coverage.sh script is to automate code coverage testing. See the following steps for the code structure: + 1. Run test suite + 2. Check for .gcda files existing. + 3a. Run gcov (-p to preserve path) + 3b. Prune .gcov files for objects outside of the Bro tree + 4a. Analyze .gcov files generated and create summary file + 4b. Send .gcov files to appropriate path diff --git a/testing/bro-core-coverage/code_coverage.sh b/testing/coverage/code_coverage.sh similarity index 90% rename from testing/bro-core-coverage/code_coverage.sh rename to testing/coverage/code_coverage.sh index b1eb8c599a..ec583b1e5e 100755 --- a/testing/bro-core-coverage/code_coverage.sh +++ b/testing/coverage/code_coverage.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # On a Bro build configured with --enable-coverage, this script # produces a code coverage report after Bro has been invoked. The @@ -17,7 +17,7 @@ # 4b. Send .gcov files to appropriate path # CURR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Location of script -BASE="$(realpath "${CURR}/../../")" +BASE="$(readlink -f "${CURR}/../../")" TMP="${CURR}/tmp.$$" mkdir -p $TMP @@ -96,14 +96,20 @@ done echo "ok" # 3a. Run gcov (-p to preserve path) and move into tmp directory +# ... if system does not have gcov installed, exit with message. echo -n "Creating coverage files... " -( cd "$TMP" && find "$BASE" -name "*.o" -exec gcov -p {} > /dev/null 2>&1 \; ) -NUM_GCOVS=$(ls "$TMP"/*.gcov | wc -l) -if [ $NUM_GCOVS -eq 0 ]; then - echo "no gcov files produced, aborting" +if which gcov; then + ( cd "$TMP" && find "$BASE" -name "*.o" -exec gcov -p {} > /dev/null 2>&1 \; ) + NUM_GCOVS=$(find "$TMP" -name *.gcov | wc -l) + if [ $NUM_GCOVS -eq 0 ]; then + echo "no gcov files produced, aborting" + exit 1 + fi + echo "ok, $NUM_GCOVS coverage files" +else + echo "gcov is not installed on system, aborting" exit 1 fi -echo "ok, $NUM_GCOVS coverage files" # 3b. Prune gcov files that fall outside of the Bro tree: # Look for files containing gcov's slash substitution character "#" From a8e65d908ea49c51c4e95565dfe11711d2a484df Mon Sep 17 00:00:00 2001 From: Chung Min Kim Date: Mon, 30 Jul 2018 09:35:55 -0700 Subject: [PATCH 3/6] Fixing up `make html` target Add types of files that genhtml (the program that generates html files from .gcno/.gcda files, included in lcov) should ignore, such as .yy and .ll files. --- testing/coverage/Makefile | 5 +-- testing/coverage/README | 11 ++---- testing/coverage/code_coverage.sh | 12 ++++-- testing/coverage/lcov_html.sh | 61 +++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 15 deletions(-) create mode 100755 testing/coverage/lcov_html.sh diff --git a/testing/coverage/Makefile b/testing/coverage/Makefile index 1aa8036bbf..7f458a4f9c 100644 --- a/testing/coverage/Makefile +++ b/testing/coverage/Makefile @@ -9,7 +9,4 @@ distclean: cleanup @find ../../ -name "*.gcno" -exec rm {} \; html: - @(cd ../../; if which lcov; then\ - lcov --capture --directory . --output-file coverage.info \ - && genhtml coverage.info && rm coverage.info; \ - fi) + @./lcov_html.sh $(COVERAGE_HTML_DIR) diff --git a/testing/coverage/README b/testing/coverage/README index 0c19e14d51..2cda389452 100644 --- a/testing/coverage/README +++ b/testing/coverage/README @@ -2,12 +2,7 @@ On a Bro build configured with --enable-coverage, this script produces a code co This depends on gcov, which should come with your gcc. If gcov is not installed, the script will abort with an error message. -TODO: Use `make html` as make target in this directory to output the html files that gcov can create (must have lcov on system). +After `make all` in the upper directory, use `make html` as make target in this directory to output the html files that lcov can create. By default, the html files will be contained in a directory named "coverage-html" in the base directory. To set a custom name, use `make html COVERAGE_HTML_DIR=custom-dir-name`. -The goal of code-coverage.sh script is to automate code coverage testing. See the following steps for the code structure: - 1. Run test suite - 2. Check for .gcda files existing. - 3a. Run gcov (-p to preserve path) - 3b. Prune .gcov files for objects outside of the Bro tree - 4a. Analyze .gcov files generated and create summary file - 4b. Send .gcov files to appropriate path +The script code_coverage.sh is triggered by `make coverage` (included in `make` in /testing), and its goal is to automate code coverage testing. +The script lcov_html.sh is triggered by `make html`, and its goal is to create html files from the aforementioned coverage data. diff --git a/testing/coverage/code_coverage.sh b/testing/coverage/code_coverage.sh index ec583b1e5e..758b2fa915 100755 --- a/testing/coverage/code_coverage.sh +++ b/testing/coverage/code_coverage.sh @@ -17,13 +17,12 @@ # 4b. Send .gcov files to appropriate path # CURR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Location of script -BASE="$(readlink -f "${CURR}/../../")" +BASE="$( cd "$CURR" && cd ../../ && pwd )" TMP="${CURR}/tmp.$$" mkdir -p $TMP # DEFINE CLEANUP PROCESS function finish { - find "$BASE" -name "*.gcda" -exec rm {} \; > /dev/null 2>&1 rm -rf $TMP } trap finish EXIT @@ -98,13 +97,20 @@ echo "ok" # 3a. Run gcov (-p to preserve path) and move into tmp directory # ... if system does not have gcov installed, exit with message. echo -n "Creating coverage files... " -if which gcov; then +if which gcov > /dev/null 2>&1; then ( cd "$TMP" && find "$BASE" -name "*.o" -exec gcov -p {} > /dev/null 2>&1 \; ) NUM_GCOVS=$(find "$TMP" -name *.gcov | wc -l) if [ $NUM_GCOVS -eq 0 ]; then echo "no gcov files produced, aborting" exit 1 fi + + # Account for '^' that occurs in macOS due to LLVM + # This character seems to be equivalent to ".." (up 1 dir) + for file in $(ls $TMP/*.gcov | grep '\^'); do + mv $file "$(sed 's/#[^#]*#\^//g' <<< "$file")" + done + echo "ok, $NUM_GCOVS coverage files" else echo "gcov is not installed on system, aborting" diff --git a/testing/coverage/lcov_html.sh b/testing/coverage/lcov_html.sh new file mode 100755 index 0000000000..d1af203437 --- /dev/null +++ b/testing/coverage/lcov_html.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +# +# On a Bro build configured with --enable-coverage, this script +# produces a code coverage report in HTML format after Bro has been invoked. The +# intended application of this script is after the btest testsuite has run. + +# This depends on lcov to run. + +function die { + echo "$@" + exit 1 +} +function finish { + rm -rf "$TMP" +} +function verify-run { + if bash -c "$1" > /dev/null 2>&1; then + echo ${2:-"ok"} + else + die ${3:-"error, abort"} + fi +} +trap finish EXIT + +COVERAGE_FILE="./$TMP/coverage.info" +COVERAGE_HTML_DIR="${1:-"coverage-html"}" +REMOVE_TARGETS="*.yy *.ll *.y *.l" + +# 1. Move to base dir, create tmp dir +cd ../../; +TMP=".tmp.$$" +mkdir "$TMP" + +# 2. Check for .gcno and .gcda file presence +echo -n "Checking for coverage files... " +for pat in gcda gcno; do + if [ -z "$(find "$BASE" -name "*.$pat" 2>/dev/null)" ]; then + echo "no .$pat files, nothing to do" + exit 0 + fi +done +echo "ok" + +# 3. If lcov does not exist, abort process. +echo -n "Checking for lcov... " +verify-run "which lcov" \ + "lcov installed on system, continue" \ + "lcov not installed, abort" + +# 4. Create a "tracefile" through lcov, which is necessary to create html files later on. +echo -n "Creating tracefile for html generation... " +verify-run "lcov --no-external --capture --directory . --output-file $COVERAGE_FILE" + +for TARGET in $REMOVE_TARGETS; do + echo -n "Getting rid of $TARGET files from tracefile... " + verify-run "lcov --remove $COVERAGE_FILE $TARGET --output-file $COVERAGE_FILE" +done + +# 5. Create HTML files. +echo -n "Creating HTML files... " +verify-run "genhtml -q -o $COVERAGE_HTML_DIR $COVERAGE_FILE" From c4cb27b12f2033f9e17a6e562c26a22180b7b5b6 Mon Sep 17 00:00:00 2001 From: Chung Min Kim Date: Mon, 30 Jul 2018 12:17:40 -0700 Subject: [PATCH 4/6] Added coverage to .PHONY in Makefile due to testing/coverage --- testing/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/Makefile b/testing/Makefile index c5610fc97b..98c6b239a2 100644 --- a/testing/Makefile +++ b/testing/Makefile @@ -25,3 +25,4 @@ coverage: @rm -f brocov.tmp.* @cd coverage && make coverage +.PHONY: coverage From e11cc8778f1e061fbdb49cdcf75e71f150951b2e Mon Sep 17 00:00:00 2001 From: Chung Min Kim Date: Mon, 30 Jul 2018 13:34:53 -0700 Subject: [PATCH 5/6] Minor edits due to typo and field changes --- testing/coverage/lcov_html.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testing/coverage/lcov_html.sh b/testing/coverage/lcov_html.sh index d1af203437..f4ff6f2b29 100755 --- a/testing/coverage/lcov_html.sh +++ b/testing/coverage/lcov_html.sh @@ -22,19 +22,19 @@ function verify-run { } trap finish EXIT +TMP=".tmp.$$" COVERAGE_FILE="./$TMP/coverage.info" COVERAGE_HTML_DIR="${1:-"coverage-html"}" -REMOVE_TARGETS="*.yy *.ll *.y *.l" +REMOVE_TARGETS="*.yy *.ll *.y *.l */bro.dir/* *.bif" # 1. Move to base dir, create tmp dir cd ../../; -TMP=".tmp.$$" mkdir "$TMP" # 2. Check for .gcno and .gcda file presence echo -n "Checking for coverage files... " for pat in gcda gcno; do - if [ -z "$(find "$BASE" -name "*.$pat" 2>/dev/null)" ]; then + if [ -z "$(find . -name "*.$pat" 2>/dev/null)" ]; then echo "no .$pat files, nothing to do" exit 0 fi @@ -58,4 +58,4 @@ done # 5. Create HTML files. echo -n "Creating HTML files... " -verify-run "genhtml -q -o $COVERAGE_HTML_DIR $COVERAGE_FILE" +verify-run "genhtml -o $COVERAGE_HTML_DIR $COVERAGE_FILE" From 9edd38026230119042dd71e1ea77840c68f63e0f Mon Sep 17 00:00:00 2001 From: Chung Min Kim Date: Tue, 31 Jul 2018 13:28:21 -0700 Subject: [PATCH 6/6] Renamed verify-run to verify_run --- testing/coverage/lcov_html.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/testing/coverage/lcov_html.sh b/testing/coverage/lcov_html.sh index f4ff6f2b29..c729b2145c 100755 --- a/testing/coverage/lcov_html.sh +++ b/testing/coverage/lcov_html.sh @@ -13,7 +13,7 @@ function die { function finish { rm -rf "$TMP" } -function verify-run { +function verify_run { if bash -c "$1" > /dev/null 2>&1; then echo ${2:-"ok"} else @@ -43,19 +43,19 @@ echo "ok" # 3. If lcov does not exist, abort process. echo -n "Checking for lcov... " -verify-run "which lcov" \ +verify_run "which lcov" \ "lcov installed on system, continue" \ "lcov not installed, abort" # 4. Create a "tracefile" through lcov, which is necessary to create html files later on. echo -n "Creating tracefile for html generation... " -verify-run "lcov --no-external --capture --directory . --output-file $COVERAGE_FILE" +verify_run "lcov --no-external --capture --directory . --output-file $COVERAGE_FILE" for TARGET in $REMOVE_TARGETS; do echo -n "Getting rid of $TARGET files from tracefile... " - verify-run "lcov --remove $COVERAGE_FILE $TARGET --output-file $COVERAGE_FILE" + verify_run "lcov --remove $COVERAGE_FILE $TARGET --output-file $COVERAGE_FILE" done # 5. Create HTML files. echo -n "Creating HTML files... " -verify-run "genhtml -o $COVERAGE_HTML_DIR $COVERAGE_FILE" +verify_run "genhtml -o $COVERAGE_HTML_DIR $COVERAGE_FILE"