diff --git a/scripts/P4version.pm b/scripts/P4version.pm index 8ad35ae6..8a572ff5 100644 --- a/scripts/P4version.pm +++ b/scripts/P4version.pm @@ -148,7 +148,14 @@ sub new die("unexpected p4 have line '$_'"); } } - close(P4) or die("error on close 'p4 have' pipe: $!"); + unless (close(P4)) { + # there might not be a repo here.. + die("error on close 'p4 have' pipe: $!") if %filehash; + $depot = '.' unless $depot; + lcovutil::ignorable_error($lcovutil::ERROR_USAGE, + "'$depot' seems to not be a perforce repo."); + goto done; + } open(WHERE, '-|', "$cd p4 where $depot") or die("unable to execute p4 where: $!"); @@ -199,6 +206,7 @@ sub new } close(EDITS) or die("error on close 'p4 opened' pipe: $!"); + done: my $self = [$allow_missing, $local_edit, $use_md5, $prefix, $depot, \%filehash]; return bless $self, $class; diff --git a/tests/common.mak b/tests/common.mak index 42435a1f..d0cc9fe1 100644 --- a/tests/common.mak +++ b/tests/common.mak @@ -27,6 +27,7 @@ endif TESTBINDIR := $(TOPDIR)bin IS_GIT := $(shell git -C $(TOPDIR) rev-parse 2>&1 > /dev/null ; if [ 0 -eq $$? ]; then echo 1 ; else echo 0 ; fi) +IS_P4 = $(shell p4 have ... 2>&1 > /dev/null ; if [ 0 -eq $$? ]; then echo 1 ; else echo 0 ; fi) ifeq (1,$(IS_GIT)) ANNOTATE_SCRIPT=$(SCRIPTDIR)/gitblame.pm diff --git a/tests/common.tst b/tests/common.tst new file mode 100644 index 00000000..4509982a --- /dev/null +++ b/tests/common.tst @@ -0,0 +1,163 @@ +# common utility for testing - mainly argument parsing + +CLEAN_ONLY=0 +COVER= + +PARALLEL='--parallel 0' +PROFILE="--profile" +LOCAL_COVERAGE=1 +KEEP_GOING=0 + +#echo "CMD: $0 $@" + +while [ $# -gt 0 ] ; do + + OPT=$1 + shift + case $OPT in + + --clean | clean ) + CLEAN_ONLY=1 + ;; + + -v | --verbose | verbose ) + set -x + ;; + + --keep-going | -k ) + KEEP_GOING=1 + ;; + + --coverage ) + if [[ "$1"x != 'x' && $1 != "-"* ]] ; then + COVER_DB=$1 + LOCAL_COVERAGE=0 + shift + else + COVER_DB='cover_db.dat' + fi + export PYCOV_DB="${COVER_DB}_py" + COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine,-silent,1 " + + if [ '' != "${COVERAGE_COMMAND}" ] ; then + CMD=${COVERAGE_COMMAND} + else + CMD='coverage' + which $CMD + if [ 0 != $? ] ; then + CMD='python3-coverage' # ubuntu? + fi + fi + which $CMD + if [ 0 != $? ] ; then + echo "cannot find 'coverage' or 'python3-coverage'" + echo "unable to run py2lcov - please install python Coverage.py package" + exit 1 + fi + + PYCOVER="COVERAGE_FILE=$PYCOV_DB $CMD run --branch --append" + ;; + + --home | -home ) + LCOV_HOME=$1 + shift + if [ ! -f $LCOV_HOME/bin/lcov ] ; then + echo "LCOV_HOME '$LCOV_HOME' does not exist" + exit 1 + fi + ;; + + --no-parallel ) + PARALLEL='' + ;; + + --no-profile ) + PROFILE='' + ;; + + --llvm ) + LLVM=1 + module load como/tools/llvm-gnu/11.0.0-1 + # seems to have been using same gcov version as gcc/4.8.3 + module load gcc/4.8.3 + #EXTRA_GCOV_OPTS="--gcov-tool '\"llvm-cov gcov\"'" + CXX="clang++" + ;; + + * ) + echo "Error: unexpected option '$OPT'" + exit 1 + ;; + esac +done + +if [[ "x" == ${LCOV_HOME}x ]] ; then + if [ -f ../../../bin/lcov ] ; then + LCOV_HOME=../../.. + else + LCOV_HOME=../../../../releng/coverage/lcov + fi +fi +LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` + +if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then + echo "LCOV_HOME '$LCOV_HOME' seems not to be valid" + exit 1 +fi + +export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} +export MANPATH=${MANPATH}:${LCOV_HOME}/man + +ROOT=`pwd` +PARENT=`(cd .. ; pwd)` +if [ -f $LCOV_HOME/scripts/getp4version ] ; then + SCRIPT_DIR=$LCOV_HOME/scripts +else + # running test from lcov install + SCRIPT_DIR=$LCOV_HOME/share/lcov/support-scripts + MD5_OPT='--version-script --md5' +fi +if [ 'x' == "x$GENHTML_TOOL" ] ; then + GENHTML_TOOL=${LCOV_HOME}/bin/genhtml + LCOV_TOOL=${LCOV_HOME}/bin/lcov + GENINFO_TOOL=${LCOV_HOME}/bin/geninfo + SPREADSHEET_TOOL=${SCRIPT_DIR}/spreadsheet.py + LLVM2LCOV_TOOL=${LCOV_HOME}/bin/llvm2lcov + PERL2LCOV_TOOL=${LCOV_HOME}/bin/perl2lcov + PY2LCOV_TOOL=${LCOV_HOME}/bin/py2lcov + XML2LCOV_TOOL=${LCOV_HOME}/bin/xml2lcov +fi + +# is this git or P4? +IS_GIT=0 +IS_P4=0 +git -C . rev-parse > /dev/null 2>&1 +if [ 0 == $? ] ; then + # this is git + IS_GIT=1 + USE_GIT=1 + GET_VERSION=${SCRIPT_DIR}/gitversion.pm + GET_VERSION_EXE=${SCRIPT_DIR}/gitversion + ANNOTATE=${SCRIPT_DIR}/gitblame.pm +else + p4 have ... > /dev/null 2>&1 + if [ 0 == $? ] ; then + IS_P4=1 + fi + USE_P4=1 + GET_VERSION=${SCRIPT_DIR}/getp4version + GET_VERSION_EXE=${SCRIPT_DIR}/getp4version + ANNOTATE=${SCRIPT_DIR}/p4annotate.pm +fi +CRITERIA=${SCRIPT_DIR}/criteria +SELECT=${SCRIPT_DIR}/select.pm + +function clean_cover() +{ + if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then + if [ -d $COVER_DB ] ; then + cover -delete -db $COVER_DB + fi + rm -rf $PYCOV_DB + fi +} diff --git a/tests/gendiffcov/errs/msgtest.sh b/tests/gendiffcov/errs/msgtest.sh index 997317d9..212b5de7 100755 --- a/tests/gendiffcov/errs/msgtest.sh +++ b/tests/gendiffcov/errs/msgtest.sh @@ -1,129 +1,35 @@ #!/bin/bash set +x -CLEAN_ONLY=0 -COVER= -UPDATE=0 -PARALLEL='--parallel 0' -PROFILE="--profile" -CC="${CC:-gcc}" -CXX="${CXX:-g++}" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - if [ ! -d ${COVER_DB} ] ; then - mkdir -p ${COVER_DB} - fi - COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - --llvm ) - LLVM=1 - module load como/tools/llvm-gnu/11.0.0-1 - # seems to have been using same gcov version as gcc/4.8.3 - module load gcc/4.8.3 - #EXTRA_GCOV_OPTS="--gcov-tool '\"llvm-cov gcov\"'" - CXX="clang++" - ;; - - --update ) - UPDATE=1 - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` +source ../../common.tst -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 -fi +rm -f test.cpp *.gcno *.gcda a.out *.info *.log *.json diff.txt +rm -rf select criteria annotate empty unused_src scriptErr scriptFixed epoch inconsistent highlight etc mycache cacheFail expect subset context labels -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man +clean_cover -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo +if [[ 1 == $CLEAN_ONLY ]] ; then + exit 0 fi -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` -if [ -f $LCOV_HOME/scripts/getp4version ] ; then - SCRIPTS_DIR=$LCOV_HOME/scripts -else - SCRIPTS_DIR=$LCOV_HOME/share/lcov/support-scripts +if ! type "${CXX}" >/dev/null 2>&1 ; then + echo "Missing tool: $CXX" >&2 + exit 2 fi -SELECT_SCRIPT=$SCRIPTS_DIR/select.pm -CRITERIA_SCRIPT=$SCRIPTS_DIR/criteria.pm -GITBLAME_SCRIPT=$SCRIPTS_DIR/gitblame.pm -GITVERSION_SCRIPT=$SCRIPTS_DIR/gitversion.pm -P4VERSION_SCRIPT=$SCRIPTS_DIR/P4version.pm -# is this git or P4? -git -C . rev-parse > /dev/null 2>&1 -if [ 0 == $? ] ; then +SELECT_SCRIPT=$SCRIPT_DIR/select.pm +CRITERIA_SCRIPT=$SCRIPT_DIR/criteria.pm +GITBLAME_SCRIPT=$SCRIPT_DIR/gitblame.pm +GITVERSION_SCRIPT=$SCRIPT_DIR/gitversion.pm +P4VERSION_SCRIPT=$SCRIPT_DIR/P4version.pm + +if [ 1 == "$USE_GIT" ] ; then # this is git - VERSION_SCRIPT=${SCRIPTS_DIR}/gitversion.pm - ANNOTATE_SCRIPT=${SCRIPTS_DIR}/gitblame.pm + VERSION_SCRIPT=${SCRIPT_DIR}/gitversion.pm + ANNOTATE_SCRIPT=${SCRIPT_DIR}/gitblame.pm else - VERSION_SCRIPT=${SCRIPTS_DIR}/getp4version - ANNOTATE_SCRIPT=${SCRIPTS_DIR}/p4annotate.pm + VERSION_SCRIPT=${SCRIPT_DIR}/getp4version + ANNOTATE_SCRIPT=${SCRIPT_DIR}/p4annotate.pm fi @@ -132,21 +38,6 @@ LCOV_BASE="$EXTRA_GCOV_OPTS --branch-coverage $PARALLEL $PROFILE --no-external - LCOV_OPTS="$LCOV_BASE" DIFFCOV_OPTS="--filter line,branch,function --function-coverage --branch-coverage --demangle-cpp --prefix $PARENT_VERSION $PROFILE " -rm -f test.cpp *.gcno *.gcda a.out *.info *.log *.json diff.txt -rm -rf select criteria annotate empty unused_src scriptErr scriptFixed epoch inconsistent highlight etc mycache cacheFail expect subset context labels - -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete -fi - -if [[ 1 == $CLEAN_ONLY ]] ; then - exit 0 -fi - -if ! type "${CXX}" >/dev/null 2>&1 ; then - echo "Missing tool: $CXX" >&2 - exit 2 -fi # old version of gcc has inconsistent line/function data IFS='.' read -r -a VER <<< `${CC} -dumpversion` @@ -185,8 +76,8 @@ if [ 0 != $? ] ; then fi # need data for version error message checking as well -echo lcov $LCOV_OPTS --capture --directory . --output-file version.info --test-name myTest --version-script $SCRIPTS_DIR/getp4version -$COVER $LCOV_TOOL $LCOV_OPTS --capture --directory . --output-file version.info --test-name myTest --version-script $SCRIPTS_DIR/getp4version | tee version.log +echo lcov $LCOV_OPTS --capture --directory . --output-file version.info --test-name myTest --version-script $SCRIPT_DIR/getp4version +$COVER $LCOV_TOOL $LCOV_OPTS --capture --directory . --output-file version.info --test-name myTest --version-script $SCRIPT_DIR/getp4version | tee version.log if [ 0 != $? ] ; then echo "ERROR: lcov --capture failed" if [ 0 == $KEEP_GOING ] ; then @@ -442,17 +333,23 @@ if [ 0 != $? ] ; then exit 1 fi fi + +if [ $IS_GIT == 0 ] && [ $IS_P4 == 0 ] ; then + IGNORE_ANNOTATE='--ignore annotate' +fi + # and again, as a differential report with annotation NOW=`date` rm -rf mycache -echo genhtml $DIFCOV_OPTS initial.info -o select --select-script ./select.sh --annotate $ANNOTATE_SCRIPT,--cache,mycache --baseline-file initial.info -$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o select --select-script ./select.sh --annotate $ANNOTATE_SCRIPT,--cache,mycache --baseline-file initial.info --title 'selectExample' --header-title 'this is the header' --date-bins 1,5,22 --baseline-date "$NOW" --prefix x --no-prefix 2>&1 | tee select_scr.log +echo genhtml $DIFCOV_OPTS initial.info -o select --select-script ./select.sh --annotate $ANNOTATE_SCRIPT,--cache,mycache --baseline-file initial.info $IGNORE_ANNOTATE +$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o select --select-script ./select.sh --annotate $ANNOTATE_SCRIPT,--cache,mycache --baseline-file initial.info --title 'selectExample' --header-title 'this is the header' --date-bins 1,5,22 --baseline-date "$NOW" --prefix x --no-prefix $IGNORE_ANNOTATE 2>&1 | tee select_scr.log if [ 0 != ${PIPESTATUS[0]} ] ; then echo "ERROR: genhtml cache failed" if [ 0 == $KEEP_GOING ] ; then exit 1 fi fi + if [ ! -d mycache ] ; then echo "did not create 'mycache'" fi @@ -463,43 +360,48 @@ for i in `find mycache -type f` ; do echo xyz > $i done # have to ignore version mismatch becaure p4annotate also computes version -echo genhtml $DIFCOV_OPTS initial.info -o cacheFail --select-script ./select.sh --annotate $ANNOTATE_SCRIPT,--cache,mycache --baseline-file initial.info --ignore version -$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o cacheFail --select-script ./select.sh --annotate $ANNOTATE_SCRIPT,--cache,mycache --baseline-file initial.info --title 'selectExample' --header-title 'this is the header' --date-bins 1,5,22 --baseline-date "$NOW" --prefix x --no-prefix --ignore version 2>&1 | tee cacheFail.log -if [ 0 == ${PIPESTATUS[0]} ] ; then - echo "ERROR: genhtml corrupt deserialize failed" - if [ 0 == $KEEP_GOING ] ; then - exit 1 +echo genhtml $DIFCOV_OPTS initial.info -o cacheFail --select-script ./select.sh --annotate $ANNOTATE_SCRIPT,--cache,mycache --baseline-file initial.info --ignore version $IGNORE_ANNOTATE +$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o cacheFail --select-script ./select.sh --annotate $ANNOTATE_SCRIPT,--cache,mycache --baseline-file initial.info --title 'selectExample' --header-title 'this is the header' --date-bins 1,5,22 --baseline-date "$NOW" --prefix x --no-prefix --ignore version $IGNORE_ANNOTATE 2>&1 | tee cacheFail.log + +if [ '' == $IGNORE_ANNOTATE ] ; then + if [ 0 == ${PIPESTATUS[0]} ] ; then + echo "ERROR: genhtml corrupt deserialize failed" + if [ 0 == $KEEP_GOING ] ; then + exit 1 + fi fi -fi -grep -E "corrupt.*unable to deserialize" cacheFail.log -if [ 0 != $? ] ; then - echo "ERROR: failed to file cache corruption" - if [ 0 == $KEEP_GOING ] ; then - exit 1 + grep -E "corrupt.*unable to deserialize" cacheFail.log + if [ 0 != $? ] && [ '' == $IGNORE_ANNOTATE ]; then + echo "ERROR: failed to find cache corruption" + if [ 0 == $KEEP_GOING ] ; then + exit 1 + fi fi fi # make cache file unreadable find mycache -type f -exec chmod ugo-r {} \; -echo genhtml $DIFCOV_OPTS initial.info -o cacheFail --select-script ./select.sh --annotate $ANNOTATE_SCRIPT,--cache,mycache --baseline-file initial.info -$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o cacheFail --select-script ./select.sh --annotate $ANNOTATE_SCRIPT,--cache,mycache --baseline-file initial.info --title 'selectExample' --header-title 'this is the header' --date-bins 1,5,22 --baseline-date "$NOW" --prefix x --no-prefix 2>&1 | tee cacheFail2.log -if [ 0 == ${PIPESTATUS[0]} ] ; then - echo "ERROR: genhtml unreadable cache failed" - if [ 0 == $KEEP_GOING ] ; then - exit 1 +echo genhtml $DIFCOV_OPTS initial.info -o cacheFail --select-script ./select.sh --annotate $ANNOTATE_SCRIPT,--cache,mycache --baseline-file initial.info $IGNORE_ANNOTATE +$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o cacheFail --select-script ./select.sh --annotate $ANNOTATE_SCRIPT,--cache,mycache --baseline-file initial.info --title 'selectExample' --header-title 'this is the header' --date-bins 1,5,22 --baseline-date "$NOW" --prefix x $IGNORE_ANNOTATE --no-prefix 2>&1 | tee cacheFail2.log + +if [ '' == $IGNORE_ANNOTATE ] ; then + if [ 0 == ${PIPESTATUS[0]} ] ; then + echo "ERROR: genhtml unreadable cache failed" + if [ 0 == $KEEP_GOING ] ; then + exit 1 + fi fi -fi -grep -E "callback.*can't open" cacheFail2.log -if [ 0 != $? ] ; then - echo "ERROR: failed to file cache error" - if [ 0 == $KEEP_GOING ] ; then - exit 1 + grep -E "callback.*can't open" cacheFail2.log + if [ 0 != $? ] ; then + echo "ERROR: failed to find cache error" + if [ 0 == $KEEP_GOING ] ; then + exit 1 + fi fi fi - # differential report with empty diff file touch diff.txt echo genhtml $DIFCOV_OPTS initial.info -o empty --diff diff.txt --annotate $ANNOTATE_SCTIPT --baseline-file initial.info @@ -722,8 +624,8 @@ fi mkdir -p etc echo "genhtml_highlight = 1" > etc/lcovrc -echo genhtml $DIFFCOV_OPTS initial.info -o highlight --config-file LCOV_HOME/etc/lcovrc -LCOV_HOME=. $COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info --annotate $ANNOTATE_SCRIPT -o highlight 2>&1 | tee highlight2.log +echo genhtml $DIFFCOV_OPTS initial.info -o highlight --config-file LCOV_HOME/etc/lcovrc $IGNORE_ANNOTATE +LCOV_HOME=. $COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info --annotate $ANNOTATE_SCRIPT -o highlight $IGNORE_ANNOTATE 2>&1 | tee highlight2.log if [ 0 != ${PIPESTATUS[0]} ] ; then echo "ERROR: deprecated error was fatal" if [ 0 == $KEEP_GOING ] ; then @@ -739,8 +641,8 @@ if [ 0 != $? ] ; then fi for err in "--rc truncate_owner_table=top,x" "--rc owner_table_entries=abc" "--rc owner_table_entries=-1" ; do - echo genhtml $DIFCOV_OPTS initial.info -o subset --annotate $ANNOTATE_SCRIPT --baseline-file initial.info --show-owners - $COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o subset --annotate $ANNOTATE_SCRIPT --baseline-file initial.info --title 'subset' --header-title 'this is the header' --date-bins 1,5,22 --baseline-date "$NOW" --prefix x --no-prefix $err --show-owners + echo genhtml $DIFCOV_OPTS initial.info -o subset --annotate $ANNOTATE_SCRIPT --baseline-file initial.info --show-owners $IGNORE_ANNOTATE + $COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o subset --annotate $ANNOTATE_SCRIPT --baseline-file initial.info --title 'subset' --header-title 'this is the header' --date-bins 1,5,22 --baseline-date "$NOW" --prefix x --no-prefix $err --show-owners $IGNORE_ANNOTATE if [ 0 == $? ] ; then echo "ERROR: genhtml $err unexpectedly passed" if [ 0 == $KEEP_GOING ] ; then @@ -753,7 +655,7 @@ done # test error checks for --expect-message-count expressions for expr in "malformed" "noSuchMsg:%C<5" "inconsistent:%c<5" 'inconsistent:%C<$x' 'inconsistent:0,inconsistent:2' ; do - $COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o expect --annotate $ANNOTATE_SCRIPT --baseline-file initial.info --title 'subset' --header-title 'this is the header' --date-bins 1,5,22 --baseline-date "$NOW" --prefix x --no-prefix --expect-message $expr --show-owners + $COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o expect --annotate $ANNOTATE_SCRIPT --baseline-file initial.info --title 'subset' --header-title 'this is the header' --date-bins 1,5,22 --baseline-date "$NOW" --prefix x --no-prefix --expect-message $expr --show-owners $IGNORE_ANNOTATE if [ 0 == $? ] ; then echo "ERROR: genhtml $expr unexpectedly passed" if [ 0 == $KEEP_GOING ] ; then @@ -761,7 +663,7 @@ for expr in "malformed" "noSuchMsg:%C<5" "inconsistent:%c<5" 'inconsistent:%C<$x fi fi - $COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o expect --annotate $ANNOTATE_SCRIPT --baseline-file initial.info --title 'subset' --header-title 'this is the header' --date-bins 1,5,22 --baseline-date "$NOW" --prefix x --no-prefix --expect-message $expr --show-owners --ignore usage + $COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o expect --annotate $ANNOTATE_SCRIPT --baseline-file initial.info --title 'subset' --header-title 'this is the header' --date-bins 1,5,22 --baseline-date "$NOW" --prefix x --no-prefix --expect-message $expr --show-owners --ignore usage $IGNORE_ANNOTATE if [ 0 != $? ] ; then echo "ERROR: genhtml $expr with ignore unexpectedly failed" if [ 0 == $KEEP_GOING ] ; then @@ -772,7 +674,7 @@ done # slightly more complicated case...hack a bit so that 'expect' eval fails # in summary callback -$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o context --annotate $ANNOTATE_SCRIPT --baseline-file initial.info --title 'context' --header-title 'this is the header' --date-bins 1,5,22 --baseline-date "$NOW" --prefix x --no-prefix --context-script ./MsgContext.pm --expect-message 'usage:MsgContext::test(%C)' --show-owners --ignore callback 2>&1 | tee expect.log +$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o context --annotate $ANNOTATE_SCRIPT --baseline-file initial.info --title 'context' --header-title 'this is the header' --date-bins 1,5,22 --baseline-date "$NOW" --prefix x --no-prefix --context-script ./MsgContext.pm --expect-message 'usage:MsgContext::test(%C)' --show-owners --ignore callback $IGNORE_ANNOTATE 2>&1 | tee expect.log if [ 0 != ${PIPESTATUS[0]} ] ; then echo "ERROR: genhtml context with ignore unexpectedly failed" if [ 0 == $KEEP_GOING ] ; then @@ -788,7 +690,7 @@ if [ 0 != $? ] ; then fi # generate error for case that number of date labels doesn't match -$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o labels --annotate $ANNOTATE_SCRIPT --baseline-file initial.info --title 'context' --header-title 'this is the header' --date-bins 1,5,22 --date-labels a,b,c,d,e --baseline-date "$NOW" --msg-log labels.log +$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o labels --annotate $ANNOTATE_SCRIPT --baseline-file initial.info --title 'context' --header-title 'this is the header' --date-bins 1,5,22 --date-labels a,b,c,d,e --baseline-date "$NOW" --msg-log labels.log $IGNORE_ANNOTATE if [ 0 == $? ] ; then echo "ERROR: genhtml --date-labels didn't fail" if [ 0 == $KEEP_GOING ] ; then diff --git a/tests/gendiffcov/function/function.sh b/tests/gendiffcov/function/function.sh index 62e10663..61413ede 100755 --- a/tests/gendiffcov/function/function.sh +++ b/tests/gendiffcov/function/function.sh @@ -1,112 +1,25 @@ #!/bin/bash set +x -CLEAN_ONLY=0 -COVER= -UPDATE=0 -PARALLEL='--parallel 0' -PROFILE="--profile" -CC="${CC:-gcc}" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - if [ ! -d ${COVER_DB} ] ; then - mkdir -p ${COVER_DB} - fi - COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - --llvm ) - LLVM=1 - module load como/tools/llvm-gnu/11.0.0-1 - # seems to have been using same gcov version as gcc/4.8.3 - module load gcc/4.8.3 - #EXTRA_GCOV_OPTS="--gcov-tool '\"llvm-cov gcov\"'" - CXX="clang++" - ;; - - --update ) - UPDATE=1 - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done +source ../../common.tst -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` +rm -f test.cpp *.gcno *.gcda a.out *.info *.info.gz diff.txt diff_r.txt diff_broken.txt *.log *.err *.json dumper* results.xlsx *.diff *.txt template *gcov +rm -rf baseline_*call_current*call alias* no_alias* -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 -fi +clean_cover -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man +if [[ 1 == $CLEAN_ONLY ]] ; then + exit 0 +fi -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo +if ! type "${CXX}" >/dev/null 2>&1 ; then + echo "Missing tool: $CXX" >&2 + exit 2 fi -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` -if [ -f $LCOV_HOME/scripts/getp4version ] ; then - GET_VERSION=$LCOV_HOME/scripts/getp4version -else - GET_VERSION=$LCOV_HOME/share/lcov/support-scripts/getp4version +if ! python3 -c "import xlsxwriter" >/dev/null 2>&1 ; then + echo "Missing python module: xlsxwriter" >&2 + exit 2 fi #PARALLEL='' @@ -120,26 +33,6 @@ DIFFCOV_OPTS="--filter line,branch,function --function-coverage --branch-coverag #DIFFCOV_OPTS="--function-coverage --branch-coverage --demangle-cpp --frame" #DIFFCOV_OPTS='--function-coverage --branch-coverage --demangle-cpp' -rm -f test.cpp *.gcno *.gcda a.out *.info *.info.gz diff.txt diff_r.txt diff_broken.txt *.log *.err *.json dumper* results.xlsx *.diff *.txt template *gcov -rm -rf baseline_*call_current*call alias* no_alias* - -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete -fi - -if [[ 1 == $CLEAN_ONLY ]] ; then - exit 0 -fi - -if ! type "${CXX}" >/dev/null 2>&1 ; then - echo "Missing tool: $CXX" >&2 - exit 2 -fi - -if ! python3 -c "import xlsxwriter" >/dev/null 2>&1 ; then - echo "Missing python module: xlsxwriter" >&2 - exit 2 -fi echo * diff --git a/tests/gendiffcov/insensitive/insensitive.sh b/tests/gendiffcov/insensitive/insensitive.sh index ddfadf11..25024ccd 100755 --- a/tests/gendiffcov/insensitive/insensitive.sh +++ b/tests/gendiffcov/insensitive/insensitive.sh @@ -1,138 +1,35 @@ #!/bin/bash set +x -CLEAN_ONLY=0 -COVER= - -PARALLEL='--parallel 0' -PROFILE="--profile" -CC="${CC:-gcc}" -CXX="${CXX:-g++}" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 - -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine,-silent,1 " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - --llvm ) - LLVM=1 - module load como/tools/llvm-gnu/11.0.0-1 - # seems to have been using same gcov version as gcc/4.8.3 - module load gcc/4.8.3 - #EXTRA_GCOV_OPTS="--gcov-tool '\"llvm-cov gcov\"'" - CXX="clang++" - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` +source ../../common.tst -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 -fi +rm -f *.cpp *.gcno *.gcda a.out *.info *.info.gz diff.txt *.log *.err *.json dumper* *.annotated *.log TEST.cpp TeSt.cpp +rm -rf ./baseline ./current ./differential* ./cover_db -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man +clean_cover -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo +if [[ 1 == $CLEAN_ONLY ]] ; then + exit 0 fi -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` -if [ -f $LCOV_HOME/scripts/getp4version ] ; then - GET_VERSION=$LCOV_HOME/scripts/getp4version - ANNOTATE=$LCOV_HOME/scripts/p4annotate -else - GET_VERSION=$LCOV_HOME/share/lcov/support-scripts/getp4version - ANNOTATE=$LCOV_HOME/share/lcov/support-scripts/p4annotate +if ! type "${CXX}" >/dev/null 2>&1 ; then + echo "Missing tool: $CXX" >&2 + exit 2 fi +ANNOTATE=${SCRIPT_DIR}/p4annotate + if [ ! -f $ANNOTATE ] ; then echo "annotate '$ANNOTATE' not found" exit 1 fi - #PARALLEL='' #PROFILE="'' - LCOV_OPTS="$EXTRA_GCOV_OPTS --branch-coverage --version-script `pwd`/version.sh $PARALLEL $PROFILE" DIFFCOV_OPTS="--function-coverage --branch-coverage --demangle-cpp --frame --prefix $PARENT --version-script `pwd`/version.sh $PROFILE $PARALLEL" -rm -f *.cpp *.gcno *.gcda a.out *.info *.info.gz diff.txt *.log *.err *.json dumper* *.annotated *.log TEST.cpp TeSt.cpp -rm -rf ./baseline ./current ./differential* ./cover_db - -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete -fi - -if [[ 1 == $CLEAN_ONLY ]] ; then - exit 0 -fi - -if ! type "${CXX}" >/dev/null 2>&1 ; then - echo "Missing tool: $CXX" >&2 - exit 2 -fi echo * @@ -263,7 +160,7 @@ rm -f TeSt.cpp # check annotation failure message... # check that this works with test names -echo genhtml $DIFFCOV_OPTS --baseline-file ./baseline.info --diff-file diff.txt --annotate-script $ANNOTATATE --show-owners all --show-noncode -o differential2 ./current.info --ignore source $IGNORE --rc check_existence_before_callback=0 +echo genhtml $DIFFCOV_OPTS --baseline-file ./baseline.info --diff-file diff.txt --annotate-script $ANNOTATE --show-owners all --show-noncode -o differential2 ./current.info --ignore source $IGNORE --rc check_existence_before_callback=0 $COVER $GENHTML_TOOL $DIFFCOV_OPTS --baseline-file ./baseline.info --diff-file diff.txt --annotate-script $ANNOTATE --show-owners all --show-noncode -o differential2 ./current.info $GENHTML_PORT --ignore source $IGNORE --rc check_existence_before_callback=0 2>&1 | tee fail.log if [ 0 == ${PIPESTATUS[0]} ] ; then echo "ERROR: expected annotation error but didn't find" diff --git a/tests/gendiffcov/simple/script.sh b/tests/gendiffcov/simple/script.sh index cd752c5c..7115cea8 100755 --- a/tests/gendiffcov/simple/script.sh +++ b/tests/gendiffcov/simple/script.sh @@ -168,6 +168,12 @@ fi echo * +CRITERIA=${SCRIPT_DIR}/criteria +SELECT=${SCRIPT_DIR}/select.pm + +#PARALLEL='' +#PROFILE="'' + echo "COVER = '$COVER'" echo "COVER_DB = '$COVER_DB'" echo "PYCOVER = '$PYCOVER'" @@ -254,7 +260,8 @@ fi sed -i -E 's/VER:#1/VER:#2/' baseline_name.info # test merge with differing version -sed -e 's/VER:/VER:x/g' < baseline.info > baseline2.info +# - sed, to make sure versions look different +sed -e 's/VER:/VER:x/g' -e 's/ md5:/ md5:0/g' < baseline.info > baseline2.info $COVER $LCOV_TOOL $LCOV_OPTS --output merge.info -a baseline.info -a baseline2.info $IGNORE if [ 0 == $? ] ; then echo "ERROR: merge with mismatched version did not fail" diff --git a/tests/gendiffcov/synthesize/synthesize.sh b/tests/gendiffcov/synthesize/synthesize.sh index af2d1949..98ae5465 100755 --- a/tests/gendiffcov/synthesize/synthesize.sh +++ b/tests/gendiffcov/synthesize/synthesize.sh @@ -1,116 +1,15 @@ #!/bin/bash set +x -CLEAN_ONLY=0 -COVER= - -PARALLEL='--parallel 0' -PROFILE="--profile" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 - -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine,-silent,1 " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - --llvm ) - LLVM=1 - module load como/tools/llvm-gnu/11.0.0-1 - # seems to have been using same gcov version as gcc/4.8.3 - module load gcc/4.8.3 - #EXTRA_GCOV_OPTS="--gcov-tool '\"llvm-cov gcov\"'" - CXX="clang++" - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` - -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 -fi - -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man - -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo - PERL2LCOV_TOOL=${LCOV_HOME}/bin/perl2lcov -fi - -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` +source ../../common.tst #PARALLEL='' #PROFILE="'' - -LCOV_OPTS="$EXTRA_GCOV_OPTS --branch-coverage $PARALLEL $PROFILE" -DIFFCOV_OPTS="--function-coverage --branch-coverage --demangle-cpp --frame --prefix $PARENT $PROFILE $PARALLEL" - rm -f *.cpp *.gcno *.gcda a.out *.info *.log *.json dumper* *.annotated annotate.sh rm -rf ./vanilla ./annotated ./annotateErr ./annotated2 ./annotateErr2 ./range ./filter ./cover_db annotated_nofunc -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete - rm -rf coverage -fi +clean_cover if [[ 1 == $CLEAN_ONLY ]] ; then exit 0 @@ -121,6 +20,10 @@ if ! type "${CXX}" >/dev/null 2>&1 ; then exit 2 fi +LCOV_OPTS="$EXTRA_GCOV_OPTS --branch-coverage $PARALLEL $PROFILE" +DIFFCOV_OPTS="--function-coverage --branch-coverage --demangle-cpp --frame --prefix $PARENT $PROFILE $PARALLEL" + + echo * # filename was all upper case diff --git a/tests/genhtml/lambda/lambda.sh b/tests/genhtml/lambda/lambda.sh index e6b70c2c..03c193bc 100755 --- a/tests/genhtml/lambda/lambda.sh +++ b/tests/genhtml/lambda/lambda.sh @@ -3,99 +3,10 @@ # lambda function extents set +x -CLEAN_ONLY=0 -COVER= - -PARALLEL='--parallel 0' -PROFILE="--profile" -CC="${CC:-gcc}" -CXX="${CXX:-g++}" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` - -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 -fi - -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man - -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo -fi - -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` - +source ../../common.tst rm -rf *.txt* *.json dumper* report lambda *.gcda *.gcno *.info -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete -fi +clean_cover if [[ 1 == "$CLEAN_ONLY" ]] ; then exit 0 diff --git a/tests/genhtml/relative/relative.sh b/tests/genhtml/relative/relative.sh index 3807e376..9979b8b6 100755 --- a/tests/genhtml/relative/relative.sh +++ b/tests/genhtml/relative/relative.sh @@ -3,93 +3,16 @@ # test relative path usage set +x -CLEAN_ONLY=0 -COVER= +source ../../common.tst -PARALLEL='--parallel 0' -PROFILE="--profile" -CC="${CC:-gcc}" -CXX="${CXX:-g++}" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` - -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 -fi +rm -rf *.txt* *.json dumper* relative -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man +clean_cover -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo +if [[ 1 == "$CLEAN_ONLY" ]] ; then + exit 0 fi -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` - LCOV_OPTS="--branch $PARALLEL $PROFILE" # gcc/4.8.5 (and possibly other old versions) generate inconsistent line/function data IFS='.' read -r -a VER <<< `${CC} -dumpversion` @@ -99,16 +22,6 @@ if [ "${VER[0]}" -lt 5 ] ; then FILTER='--filter branch' fi -rm -rf *.txt* *.json dumper* relative - -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete -fi - -if [[ 1 == $CLEAN_ONLY ]] ; then - exit 0 -fi - if ! type ${CXX} >/dev/null 2>&1 ; then echo "Missing tool: ${CXX}" >&2 exit 2 diff --git a/tests/lcov/branch/branch.sh b/tests/lcov/branch/branch.sh index cf2ed049..25a0b987 100755 --- a/tests/lcov/branch/branch.sh +++ b/tests/lcov/branch/branch.sh @@ -1,89 +1,18 @@ #!/bin/bash set +x -CLEAN_ONLY=0 -COVER= - -PARALLEL='--parallel 0' -PROFILE="--profile" -CC="${CC:-gcc}" -CXX="${CXX:-g++}" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,$COVER_DB,-coverage,statement,branch,condition,subroutine " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` - -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 +source ../../common.tst + +rm -rf *.gcda *.gcno a.out *.info* *.txt* *.json dumper* testRC *.gcov *.gcov.* no_macro* macro* total.* +if [ -d separate ] ; then + chmod -R u+w separate + rm -rf separate fi -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man +clean_cover -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo +if [[ 1 == $CLEAN_ONLY ]] ; then + exit 0 fi #use geninfo to capture - to collect coverage data @@ -103,19 +32,6 @@ fi # filter exception branches to avoid spurious differences for old compiler FILTER='--filter branch' -rm -rf *.gcda *.gcno a.out *.info* *.txt* *.json dumper* testRC *.gcov *.gcov.* no_macro* macro* total.* -if [ -d separate ] ; then - chmod -R u+w separate - rm -rf separate -fi - -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete -fi - -if [[ 1 == $CLEAN_ONLY ]] ; then - exit 0 -fi if ! type ${CXX} >/dev/null 2>&1 ; then echo "Missing tool: ${CXX}" >&2 diff --git a/tests/lcov/demangle/demangle.sh b/tests/lcov/demangle/demangle.sh index 3bb5e5a6..7bb26c63 100755 --- a/tests/lcov/demangle/demangle.sh +++ b/tests/lcov/demangle/demangle.sh @@ -1,94 +1,13 @@ #!/bin/bash set +x -CLEAN_ONLY=0 -COVER= - -PARALLEL='--parallel 0' -PROFILE="--profile" -CXX="${CXX:-g++}" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,$COVER_DB,-coverage,statement,branch,condition,subroutine " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` - -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 -fi - -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man - -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` +source ../../common.tst LCOV_OPTS="--branch-coverage --no-external $PARALLEL $PROFILE" rm -rf *.gcda *.gcno a.out *.info* *.txt* *.json dumper* testRC *.gcov *.gcov.* *.log -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete -fi +clean_cover if [[ 1 == $CLEAN_ONLY ]] ; then exit 0 diff --git a/tests/lcov/errs/errs.sh b/tests/lcov/errs/errs.sh index 5c31de2e..5d1c2fbd 100755 --- a/tests/lcov/errs/errs.sh +++ b/tests/lcov/errs/errs.sh @@ -1,94 +1,22 @@ #!/bin/bash set +x -CLEAN_ONLY=0 -COVER= +source ../../common.tst -PARALLEL='--parallel 0' -PROFILE="--profile" -CC="${CC:-gcc}" -CXX="${CXX:-g++}" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,$COVER_DB,-coverage,statement,branch,condition,subroutine,-silent,1 " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done +rm -f *.log *.json dumper* *.out +rm -rf emptyDir -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` +clean_cover -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 +if [[ 1 == $CLEAN_ONLY ]] ; then + exit 0 fi -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man - -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo +if ! type ${CXX} >/dev/null 2>&1 ; then + echo "Missing tool: ${CXX}" >&2 + exit 2 fi -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` - LCOV_OPTS="--branch $PARALLEL $PROFILE" # gcc/4.8.5 (and possibly other old versions) generate inconsistent line/function data IFS='.' read -r -a VER <<< `${CC} -dumpversion` @@ -98,22 +26,6 @@ if [ "${VER[0]}" -lt 5 ] ; then FILTER='--filter branch' fi -rm -f *.log *.json dumper* *.out -rm -rf emptyDir - -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete -fi - -if [[ 1 == $CLEAN_ONLY ]] ; then - exit 0 -fi - -if ! type ${CXX} >/dev/null 2>&1 ; then - echo "Missing tool: ${CXX}" >&2 - exit 2 -fi - status=0 for f in badFncLine badFncEndLine fncMismatch badBranchLine badLine ; do diff --git a/tests/lcov/exception/exception.sh b/tests/lcov/exception/exception.sh index b7cf93cf..73fe55f6 100755 --- a/tests/lcov/exception/exception.sh +++ b/tests/lcov/exception/exception.sh @@ -1,106 +1,20 @@ #!/bin/bash set +x -CLEAN_ONLY=0 -COVER= - -PARALLEL='--parallel 0' -PROFILE="--profile" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,$COVER_DB,-coverage,statement,branch,condition,subroutine " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` - -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 -fi - -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man - -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo -fi +source ../../common.tst # use geninfo to capture - so we collect coverage data... CAPTURE="$GENINFO_TOOL ." # CAPTURE="$LCOV_TOOL --capture -d ." -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` - LCOV_OPTS="--branch-coverage $PARALLEL $PROFILE" IFS='.' read -r -a VER <<< `${CC} -dumpversion` rm -rf *.gcda *.gcno a.out *.info* *.txt* *.json dumper* testRC *.gcov *.gcov.* *.log precedence.rc -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete -fi +clean_cover if [[ 1 == $CLEAN_ONLY ]] ; then exit 0 diff --git a/tests/lcov/extract/extract.sh b/tests/lcov/extract/extract.sh index 7b351bf3..e4902a2b 100755 --- a/tests/lcov/extract/extract.sh +++ b/tests/lcov/extract/extract.sh @@ -1,103 +1,26 @@ #!/bin/bash set +x -CLEAN_ONLY=0 -COVER= - -PARALLEL='--parallel 0' -PROFILE="--profile" -CC="${CC:-gcc}" -CXX="${CXX:-g++}" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,$COVER_DB,-coverage,statement,branch,condition,subroutine " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; +source ../../common.tst - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` -if [ -d $LCOV_HOME/scripts ] ; then - SCRIPTS=$LCOV_HOME/scripts -else - SCRIPTS=$LCOV_HOME/share/lcov/support-scripts -fi +rm -rf *.gcda *.gcno a.out *.info* *.txt* *.json dumper* testRC *.gcov *.gcov.* *.log *.o errs *.msg *.dat +rm -rf rcOptBug -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 +if [ -d separate ] ; then + chmod -R ug+rxw separate + rm -rf separate fi -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man +clean_cover -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo +if [[ 1 == $CLEAN_ONLY ]] ; then + exit 0 fi #use geninfo for capture - so we can collect coverage info CAPTURE=$GENINFO_TOOL #CAPTURE="$LCOV_TOOL --capture --directory" -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` - LCOV_OPTS="--branch-coverage $PARALLEL $PROFILE" # gcc/4.8.5 (and possibly other old versions) generate inconsistent line/function data IFS='.' read -r -a VER <<< `${CC} -dumpversion` @@ -107,21 +30,6 @@ if [ "${VER[0]}" -lt 5 ] ; then FILTER='--filter branch' fi -rm -rf *.gcda *.gcno a.out *.info* *.txt* *.json dumper* testRC *.gcov *.gcov.* *.log *.o errs *.msg *.dat -rm -rf rcOptBug - -if [ -d separate ] ; then - chmod -R ug+rxw separate - rm -rf separate -fi - -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete -fi - -if [[ 1 == $CLEAN_ONLY ]] ; then - exit 0 -fi if ! type ${CXX} >/dev/null 2>&1 ; then echo "Missing tool: ${CXX}" >&2 @@ -217,8 +125,8 @@ if [ $COUNT == '1' ] ; then fi # callback tests -echo $COVER $CAPTURE . $LCOV_OPTS -o callback.info $FILTER $IGNORE --criteria $SCRIPTS/threshold.pm,--line,90,--branch,65,--function,100 -$COVER $CAPTURE . $LCOV_OPTS -o callback.info $FILTER $IGNORE --criteria $SCRIPTS/threshold.pm,--line,90,--branch,65,--function,100 2>&1 | tee callback_fail.log +echo $COVER $CAPTURE . $LCOV_OPTS -o callback.info $FILTER $IGNORE --criteria $SCRIPT_DIR/threshold.pm,--line,90,--branch,65,--function,100 +$COVER $CAPTURE . $LCOV_OPTS -o callback.info $FILTER $IGNORE --criteria $SCRIPT_DIR/threshold.pm,--line,90,--branch,65,--function,100 2>&1 | tee callback_fail.log if [ 0 == ${PIPESTATUS[0]} ] ; then echo "Error: expected criteria fail from lcov --capture - but not found" if [ $KEEP_GOING == 0 ] ; then @@ -232,8 +140,8 @@ if [ 0 != $? ] ; then exit 1 fi fi -echo $COVER $CAPTURE . $LCOV_OPTS -o callback2.info $FILTER $IGNORE --criteria $SCRIPTS/threshold.pm,--line,20 -$COVER $CAPTURE . $LCOV_OPTS -o callback2.info $FILTER $IGNORE --criteria $SCRIPTS/threshold.pm,--line,20 +echo $COVER $CAPTURE . $LCOV_OPTS -o callback2.info $FILTER $IGNORE --criteria $SCRIPT_DIR/threshold.pm,--line,20 +$COVER $CAPTURE . $LCOV_OPTS -o callback2.info $FILTER $IGNORE --criteria $SCRIPT_DIR/threshold.pm,--line,20 if [ 0 != $? ] ; then echo "Error: expected criteria pass from lcov --capture - but failed" if [ $KEEP_GOING == 0 ] ; then @@ -242,8 +150,8 @@ if [ 0 != $? ] ; then fi -echo $COVER $LCOV_TOOL $LCOV_OPTS -o aggregata.info -a callback.info $FILTER $IGNORE --criteria $SCRIPTS/threshold.pm,--line,90,--branch,65,--function,100 -$COVER $LCOV_TOOL $LCOV_OPTS -o aggregata.info -a callback.info $FILTER $IGNORE --criteria $SCRIPTS/threshold.pm,--line,90,--branch,65,--function,100 2>&1 | tee callback_fail2.log +echo $COVER $LCOV_TOOL $LCOV_OPTS -o aggregata.info -a callback.info $FILTER $IGNORE --criteria $SCRIPT_DIR/threshold.pm,--line,90,--branch,65,--function,100 +$COVER $LCOV_TOOL $LCOV_OPTS -o aggregata.info -a callback.info $FILTER $IGNORE --criteria $SCRIPT_DIR/threshold.pm,--line,90,--branch,65,--function,100 2>&1 | tee callback_fail2.log if [ 0 == ${PIPESTATUS[0]} ] ; then echo "Error: expected criteria fail from lcov --aggregate - but not found" if [ $KEEP_GOING == 0 ] ; then @@ -257,7 +165,7 @@ if [ 0 != $? ] ; then exit 1 fi fi -$COVER $LCOV_TOOL $LCOV_OPTS -o aggregate2.info -a callback.info $FILTER $IGNORE --criteria $SCRIPTS/threshold.pm,--line,20 +$COVER $LCOV_TOOL $LCOV_OPTS -o aggregate2.info -a callback.info $FILTER $IGNORE --criteria $SCRIPT_DIR/threshold.pm,--line,20 if [ 0 != $? ] ; then echo "Error: expected criteria pass from lcov --aggregate - but failed" if [ $KEEP_GOING == 0 ] ; then @@ -266,8 +174,8 @@ if [ 0 != $? ] ; then fi # error check for typo in command line - "--branchy" -echo $COVER $CAPTURE . $LCOV_OPTS -o callback.info $FILTER $IGNORE --criteria $SCRIPTS/threshold.pm,--line,90,--branchy,65,--function,100 -$COVER $CAPTURE . $LCOV_OPTS -o callback.info $FILTER $IGNORE --criteria $SCRIPTS/threshold.pm,--line,90,--branchy,65,--function,100 2>&1 | tee callback_err.log +echo $COVER $CAPTURE . $LCOV_OPTS -o callback.info $FILTER $IGNORE --criteria $SCRIPT_DIR/threshold.pm,--line,90,--branchy,65,--function,100 +$COVER $CAPTURE . $LCOV_OPTS -o callback.info $FILTER $IGNORE --criteria $SCRIPT_DIR/threshold.pm,--line,90,--branchy,65,--function,100 2>&1 | tee callback_err.log if [ 0 == ${PIPESTATUS[0]} ] ; then echo "Error: expected criteria config fail from lcov --capture" if [ $KEEP_GOING == 0 ] ; then @@ -283,8 +191,8 @@ if [ 0 != $? ] ; then fi #bad value - not numeric -echo $COVER $CAPTURE . $LCOV_OPTS -o callback.info $FILTER $IGNORE --criteria $SCRIPTS/threshold.pm,--line,90,--branch,x,--function,100 -$COVER $CAPTURE . $LCOV_OPTS -o callback.info $FILTER $IGNORE --criteria $SCRIPTS/threshold.pm,--line,90,--branch,x,--function,100 2>&1 | tee callback_err2.log +echo $COVER $CAPTURE . $LCOV_OPTS -o callback.info $FILTER $IGNORE --criteria $SCRIPT_DIR/threshold.pm,--line,90,--branch,x,--function,100 +$COVER $CAPTURE . $LCOV_OPTS -o callback.info $FILTER $IGNORE --criteria $SCRIPT_DIR/threshold.pm,--line,90,--branch,x,--function,100 2>&1 | tee callback_err2.log if [ 0 == ${PIPESTATUS[0]} ] ; then echo "Error: expected another criteria config fail from lcov --capture" if [ $KEEP_GOING == 0 ] ; then @@ -300,8 +208,8 @@ if [ 0 != $? ] ; then fi # context callbacks... -echo $CAPTURE . $LCOV_OPTS --all -o context.info $IGNORE $IGNORE_EMPTY $IGNORE_USAGE --context $SCRIPTS/context.pm -$COVER $CAPTURE . $LCOV_OPTS --all -o context.info $IGNORE $IGNORE_EMPTY $IGNORE_USAGE --context $SCRIPTS/context.pm +echo $CAPTURE . $LCOV_OPTS --all -o context.info $IGNORE $IGNORE_EMPTY $IGNORE_USAGE --context $SCRIPT_DIR/context.pm +$COVER $CAPTURE . $LCOV_OPTS --all -o context.info $IGNORE $IGNORE_EMPTY $IGNORE_USAGE --context $SCRIPT_DIR/context.pm if [ 0 != $? ] ; then echo "Error: unexpected error code from lcov --capture --context" if [ $KEEP_GOING == 0 ] ; then @@ -324,8 +232,8 @@ if [ 0 == $? ] ; then fi fi -echo $CAPTURE . $LCOV_OPTS --all -o context_comment.info $IGNORE $IGNORE_EMPTY $IGNORE_USAGE --context $SCRIPTS/context.pm,--comment -$COVER $CAPTURE . $LCOV_OPTS --all -o context_comment.info $IGNORE $IGNORE_EMPTY $IGNORE_USAGE --context $SCRIPTS/context.pm,--comment +echo $CAPTURE . $LCOV_OPTS --all -o context_comment.info $IGNORE $IGNORE_EMPTY $IGNORE_USAGE --context $SCRIPT_DIR/context.pm,--comment +$COVER $CAPTURE . $LCOV_OPTS --all -o context_comment.info $IGNORE $IGNORE_EMPTY $IGNORE_USAGE --context $SCRIPT_DIR/context.pm,--comment if [ 0 != $? ] ; then echo "Error: unexpected error code from lcov --capture --context" if [ $KEEP_GOING == 0 ] ; then @@ -350,7 +258,7 @@ fi # check error... -$COVER $LCOV_TOOL -d . $LCOV_OPTS --all -o err.info $IGNORE $IGNORE_EMPTY $IGNORE_USAGE --context $SCRIPTS/context.pm --context tooManyArgs +$COVER $LCOV_TOOL -d . $LCOV_OPTS --all -o err.info $IGNORE $IGNORE_EMPTY $IGNORE_USAGE --context $SCRIPT_DIR/context.pm --context tooManyArgs if [ 0 == $? ] ; then echo "Error: expected error lcov --capture --context ..." if [ $KEEP_GOING == 0 ] ; then diff --git a/tests/lcov/follow/follow.sh b/tests/lcov/follow/follow.sh index 768ccc1c..5ce90393 100755 --- a/tests/lcov/follow/follow.sh +++ b/tests/lcov/follow/follow.sh @@ -1,97 +1,16 @@ #!/bin/bash set +x -CLEAN_ONLY=0 -COVER= - -PARALLEL='--parallel 0' -PROFILE="--profile" -CC="${CC:-gcc}" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,$COVER_DB,-coverage,statement,branch,condition,subroutine " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` -if [ -d $LCOV_HOME/scripts ] ; then - SCRIPTS=$LCOV_HOME/scripts -else - SCRIPTS=$LCOV_HOME/share/lcov/support-scripts -fi +source ../../common.tst -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 -fi +rm -rf rundir *.info -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man +clean_cover -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo +if [[ 1 == $CLEAN_ONLY ]] ; then + exit 0 fi -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` LCOV_OPTS="$PARALLEL $PROFILE" # gcc/4.8.5 (and possibly other old versions) generate inconsistent line/function data @@ -100,15 +19,6 @@ if [ "${VER[0]}" -lt 5 ] ; then IGNORE="--ignore inconsistent" fi -rm -rf rundir *.info - -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete -fi - -if [[ 1 == $CLEAN_ONLY ]] ; then - exit 0 -fi mkdir -p rundir cd rundir diff --git a/tests/lcov/format/format.sh b/tests/lcov/format/format.sh index 0c70b458..960aa429 100755 --- a/tests/lcov/format/format.sh +++ b/tests/lcov/format/format.sh @@ -3,94 +3,7 @@ set +x # test various errors in .info data -CLEAN_ONLY=0 -COVER= - -PARALLEL='--parallel 0' -PROFILE="--profile" -CC="${CC:-gcc}" -CXX="${CXX:-g++}" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` - -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 -fi - -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man - -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo -fi - - -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` +source ../../common.tst LCOV_OPTS="--branch $PARALLEL $PROFILE" # gcc/4.8.5 (and possibly other old versions) generate inconsistent line/function data @@ -103,9 +16,7 @@ fi rm -rf *.gcda *.gcno a.out out.info out2.info *.txt* *.json dumper* testRC *.gcov *.gcov.* *.log -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete -fi +clean_cover if [[ 1 == $CLEAN_ONLY ]] ; then exit 0 diff --git a/tests/lcov/gcov-tool/path.sh b/tests/lcov/gcov-tool/path.sh index 24ad0c1c..53123f4d 100755 --- a/tests/lcov/gcov-tool/path.sh +++ b/tests/lcov/gcov-tool/path.sh @@ -20,94 +20,11 @@ function check_tools() { set +x -CLEAN_ONLY=0 -COVER= - -PARALLEL='--parallel 0' -PROFILE="--profile" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,$COVER_DB,-coverage,statement,branch,condition,subroutine " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` - -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 -fi - -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man - -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo -fi +source ../../common.tst rm -f test *.gcno *.gcda -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete -fi +clean_cover if [[ 1 == $CLEAN_ONLY ]] ; then exit 0 diff --git a/tests/lcov/initializer/initializer.sh b/tests/lcov/initializer/initializer.sh index 56bdbc2c..13d5a98e 100755 --- a/tests/lcov/initializer/initializer.sh +++ b/tests/lcov/initializer/initializer.sh @@ -3,99 +3,11 @@ # lambda function extents set +x -CLEAN_ONLY=0 -COVER= - -PARALLEL='--parallel 0' -PROFILE="--profile" -CC="${CC:-gcc}" -CXX="${CXX:-g++}" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` - -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 -fi - -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man - -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo -fi - -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` +source ../../common.tst rm -rf *.log *.json report initializer *.gcda *.gcno *.info -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete -fi +clean_cover if [[ 1 == "$CLEAN_ONLY" ]] ; then exit 0 diff --git a/tests/lcov/lambda/lambda.sh b/tests/lcov/lambda/lambda.sh index 2e94093e..f24c1462 100755 --- a/tests/lcov/lambda/lambda.sh +++ b/tests/lcov/lambda/lambda.sh @@ -3,97 +3,11 @@ # lambda function filtering, in java set +x -CLEAN_ONLY=0 -COVER= - -PARALLEL='--parallel 0' -PROFILE="--profile" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` - -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 -fi - -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man - -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo -fi - -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` +source ../../common.tst rm -rf *.txt* *.json dumper* report lambda *.gcda *.gcno *.info -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete -fi +clean_cover if [[ 1 == "$CLEAN_ONLY" ]] ; then exit 0 diff --git a/tests/lcov/mcdc/mcdc.sh b/tests/lcov/mcdc/mcdc.sh index 1b65a2e0..0b9cd2a8 100755 --- a/tests/lcov/mcdc/mcdc.sh +++ b/tests/lcov/mcdc/mcdc.sh @@ -1,119 +1,26 @@ #! /usr/bin/env bash -CLEAN_ONLY=0 -COVER= -PARALLEL='--parallel 0' -PROFILE="--profile" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do +source ../../common.tst - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine,-silent,1 " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` - -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && -f $LCOV_HOME/lib/lcovutil.pm ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 -fi +rm -rf *.xml *.dat *.info *.jsn cover_one *_rpt *Test[123]* *.gcno *.gcda gccTest* llvmTest* -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man +clean_cover -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo - LLVM2LCOV_TOOL=${LCOV_HOME}/bin/llvm2lcov - PERL2LCOV_TOOL=${LCOV_HOME}/bin/perl2lcov +if [[ 1 == $CLEAN_ONLY ]] ; then + exit 0 fi -if [ -f $LCOV_HOME/scripts/getp4version ] ; then - SCRIPT_DIR=$LCOV_HOME/scripts -else - # running test from lcov install - SCRIPT_DIR=$LCOV_HOME/share/lcov/support-scripts -fi # is this git or P4? -git -C . rev-parse > /dev/null 2>&1 -if [ 0 == $? ] ; then +if [ 1 == "$USE_GIT" ] ; then # this is git GET_VERSION=${SCRIPT_DIR}/gitversion.pm else GET_VERSION=${SCRIPT_DIR}/P4version.pm,--local-edit,--md5 fi -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` LCOV_OPTS="--branch-coverage $PARALLEL $PROFILE" -rm -rf *.xml *.dat *.info *.jsn cover_one *_rpt *Test[123]* *.gcno *.gcda gccTest* llvmTest* - -if [ "x$COVER" != "x" ] && [ $LOCAL_COVERAGE == 1 ]; then - cover -delete -fi - -if [[ 1 == $CLEAN_ONLY ]] ; then - exit 0 -fi - IFS='.' read -r -a VER <<< `${CC} -dumpversion` if [ "${VER[0]}" -ge 14 ] ; then ENABLE_MCDC=1 diff --git a/tests/lcov/merge/merge.sh b/tests/lcov/merge/merge.sh index 0723e62d..53bf5651 100755 --- a/tests/lcov/merge/merge.sh +++ b/tests/lcov/merge/merge.sh @@ -3,94 +3,22 @@ set +x -CLEAN_ONLY=0 -COVER= +source ../../common.tst -PARALLEL='--parallel 0' -PROFILE="--profile" -CC="${CC:-gcc}" -CXX="${CXX:-g++}" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going | -k ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,$COVER_DB,-coverage,statement,branch,condition,subroutine " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done +rm -f *.txt* *.json dumper* intersect*.info gen.info func.info inconsistent.info diff* *.log +rm -rf cover_db -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` +clean_cover -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 +if [[ 1 == $CLEAN_ONLY ]] ; then + exit 0 fi -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man - -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo +if ! type ${CXX} >/dev/null 2>&1 ; then + echo "Missing tool: ${CXX}" >&2 + exit 2 fi -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` - LCOV_OPTS="--branch $PARALLEL $PROFILE --mcdc-coverage" # gcc/4.8.5 (and possibly other old versions) generate inconsistent line/function data IFS='.' read -r -a VER <<< `${CC} -dumpversion` @@ -100,22 +28,6 @@ if [ "${VER[0]}" -lt 5 ] ; then FILTER='--filter branch' fi -rm -f *.txt* *.json dumper* intersect*.info gen.info func.info inconsistent.info diff* *.log -rm -rf cover_db - -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete -fi - -if [[ 1 == $CLEAN_ONLY ]] ; then - exit 0 -fi - -if ! type ${CXX} >/dev/null 2>&1 ; then - echo "Missing tool: ${CXX}" >&2 - exit 2 -fi - status=0 # note that faked data is not consistent - but just ignoring the issue for now $COVER $LCOV_TOOL $LCOV_OPTS -o intersect.info a.info --intersect b.info --ignore inconsistent diff --git a/tests/lcov/misc/help.sh b/tests/lcov/misc/help.sh index fd01ddac..ff457ae7 100755 --- a/tests/lcov/misc/help.sh +++ b/tests/lcov/misc/help.sh @@ -5,32 +5,7 @@ # Test lcov --help # -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - case $OPT in - - --coverage ) - shift - COVER_DB=$1 - shift - - COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine " - KEEP_GOING=1 - - ;; - - -v | --verbose ) - set -x - shift - ;; - - * ) - break - ;; - esac -done +source ../../common.mak STDOUT=help_stdout.log STDERR=help_stderr.log diff --git a/tests/lcov/misc/version.sh b/tests/lcov/misc/version.sh index 77a2ae96..2cd2494d 100755 --- a/tests/lcov/misc/version.sh +++ b/tests/lcov/misc/version.sh @@ -5,32 +5,8 @@ # Test lcov --version # -KEEP_GOING=0 -while [ $# -gt 0 ] ; do +source ../../common.tst - OPT=$1 - case $OPT in - - --coverage ) - shift - COVER_DB=$1 - shift - - COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine " - KEEP_GOING=1 - - ;; - - -v | --verbose ) - set -x - shift - ;; - - * ) - break - ;; - esac -done STDOUT=version_stdout.log STDERR=version_stderr.log diff --git a/tests/lcov/multiple/multiple.sh b/tests/lcov/multiple/multiple.sh index df82eb9d..d6f2fec0 100755 --- a/tests/lcov/multiple/multiple.sh +++ b/tests/lcov/multiple/multiple.sh @@ -1,97 +1,7 @@ #!/bin/bash set +x -CLEAN_ONLY=0 -COVER= - -PARALLEL='--parallel 0' -PROFILE="--profile" -CC="${CC:-gcc}" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,$COVER_DB,-coverage,statement,branch,condition,subroutine " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - -if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../../bin/lcov ] ; then - LCOV_HOME=../../.. - else - LCOV_HOME=../../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` -if [ -d $LCOV_HOME/scripts ] ; then - SCRIPTS=$LCOV_HOME/scripts -else - SCRIPTS=$LCOV_HOME/share/lcov/support-scripts -fi - -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && ( -f $LCOV_HOME/lib/lcovutil.pm || -f $LCOV_HOME/lib/lcov/lcovutil.pm ) ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 -fi - -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man - -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo -fi - -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` +source ../../common.tst LCOV_OPTS="$PARALLEL $PROFILE" # gcc/4.8.5 (and possibly other old versions) generate inconsistent line/function data @@ -102,9 +12,7 @@ fi rm -rf rundir -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete -fi +clean_cover if [[ 1 == $CLEAN_ONLY ]] ; then exit 0 diff --git a/tests/perl2lcov/perltest1.sh b/tests/perl2lcov/perltest1.sh index 8a3b3533..fed03221 100755 --- a/tests/perl2lcov/perltest1.sh +++ b/tests/perl2lcov/perltest1.sh @@ -1,104 +1,24 @@ #!/bin/bash set +x -CLEAN_ONLY=0 -COVER= - -PARALLEL='--parallel 0' -PROFILE="--profile" -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine,-silent,1 " - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; - - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - if [[ "x" == ${LCOV_HOME}x ]] ; then - if [ -f ../../bin/lcov ] ; then - LCOV_HOME=../.. - else - LCOV_HOME=../../../releng/coverage/lcov - fi -fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` - -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && -f $LCOV_HOME/lib/lcovutil.pm ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 -fi - -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man - -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - PERL2LCOV_TOOL=${LCOV_HOME}/bin/perl2lcov + if [ -f ../../bin/lcov ] ; then + LCOV_HOME=../.. + fi fi - -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` - -LCOV_OPTS="--branch-coverage $PARALLEL $PROFILE" +source ../common.tst rm -rf *.xml *.dat *.info *.json cover_one perl2lcov_report cover_genhtml *.log -if [ "x$COVER" != "x" ] && [ $LOCAL_COVERAGE == 1 ]; then - cover -delete -fi +clean_cover if [[ 1 == $CLEAN_ONLY ]] ; then exit 0 fi +LCOV_OPTS="--branch-coverage $PARALLEL $PROFILE" + + perl -MDevel::Cover=-db,cover_one,-coverage,statement,branch,condition,subroutine,-silent,1 example.pl if [ 0 != $? ] ; then echo "perl exec failed" @@ -257,7 +177,7 @@ if [ 0 != $? ] ; then fi # now try running genhtml on the perl2lcov-generated .info file... -perl -MDevel::Cover=-db,cover_genhtml,-silent,1 ../../bin/genhtml -o perl2lcov_report --flat --show-navigation one.info --branch --validate +perl -MDevel::Cover=-db,cover_genhtml,-silent,1 $LCOV_HOME/bin/genhtml -o perl2lcov_report --flat --show-navigation one.info --branch --validate if [ 0 != $? ] ; then echo "genhtml failed" if [ 0 == $KEEP_GOING ] ; then diff --git a/tests/py2lcov/py2lcov.sh b/tests/py2lcov/py2lcov.sh index ab140bc3..22e461fd 100755 --- a/tests/py2lcov/py2lcov.sh +++ b/tests/py2lcov/py2lcov.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -x +set +x CLEAN_ONLY=0 COVER= @@ -276,8 +276,13 @@ for l in `grep -E '^DA:' checksum.info` ; do fi done +if [ $IS_GIT == 0 ] && [ $IS_P4 == 0 ] ; then + D= +else + D=$DEPOT +fi # should be valid data to generate HTML -$GENHTML_TOOL -o rpt2 $VERSION$DEPOT $ANNOTATE functions.info checksum.info --validate +$GENHTML_TOOL -o rpt2 $VERSION$D $ANNOTATE functions.info checksum.info --validate if [ 0 != $? ] ; then echo "genhtml 2 failed" if [ 0 == $KEEP_GOING ] ; then @@ -354,28 +359,31 @@ if [ 0 != $? ] ; then fi fi -# some usage errors -eval ${PYCOV} ${PY2LCOV_TOOL} functions.dat -o paramErr.info --cmd $CMD ${VERSION},-x -if [ 0 == $? ] ; then - echo "coverage version did not see error" - if [ 0 == $KEEP_GOING ] ; then - exit 1 +if [ $IS_GIT == 1 ] || [ $IS_P4 == 1 ] ; then + + # some usage errors + eval ${PYCOV} ${PY2LCOV_TOOL} functions.dat -o paramErr.info --cmd $CMD ${VERSION},-x + if [ 0 == $? ] ; then + echo "coverage version did not see error" + if [ 0 == $KEEP_GOING ] ; then + exit 1 + fi fi -fi -# run again with --keep-going flag - should generate same result as we see without version script -eval ${PYCOV} ${PY2LCOV_TOOL} functions.dat -o keepGoing.info --cmd $CMD ${VERSION},-x --keep-going --verbose -if [ 0 != $? ] ; then - echo "keepGoing version saw error" - if [ 0 == $KEEP_GOING ] ; then - exit 1 + # run again with --keep-going flag - should generate same result as we see without version script + eval ${PYCOV} ${PY2LCOV_TOOL} functions.dat -o keepGoing.info --cmd $CMD ${VERSION},-x --keep-going --verbose + if [ 0 != $? ] ; then + echo "keepGoing version saw error" + if [ 0 == $KEEP_GOING ] ; then + exit 1 + fi fi -fi -diff no_version.info keepGoing.info -if [ 0 != $? ] ; then - echo "no_version vs keepGoing failed" - if [ 0 == $KEEP_GOING ] ; then - exit 1 + diff no_version.info keepGoing.info + if [ 0 != $? ] ; then + echo "no_version vs keepGoing failed" + if [ 0 == $KEEP_GOING ] ; then + exit 1 + fi fi fi diff --git a/tests/xml2lcov/xml2lcov.sh b/tests/xml2lcov/xml2lcov.sh index 603f297e..c751e685 100755 --- a/tests/xml2lcov/xml2lcov.sh +++ b/tests/xml2lcov/xml2lcov.sh @@ -1,116 +1,24 @@ #!/bin/bash set +x -CLEAN_ONLY=0 -COVER= - -PARALLEL='--parallel 0' -PROFILE="--profile" -if [ 'x' == "x${COVER_DB}" ] ; then - COVER_DB='cover_db' -fi -if [ 'x' == "x${PYCOV_DB}" ] ; then - PYCOV_DB='pycov.dat' +if [[ "x" == ${LCOV_HOME}x ]] ; then + if [ -f ../../bin/lcov ] ; then + LCOV_HOME=../.. + fi fi -LOCAL_COVERAGE=1 -KEEP_GOING=0 -while [ $# -gt 0 ] ; do - - OPT=$1 - shift - case $OPT in - - --clean | clean ) - CLEAN_ONLY=1 - ;; - - -v | --verbose | verbose ) - set -x - ;; - - -k | --keep-going ) - KEEP_GOING=1 - ;; - - --coverage ) - #COVER="perl -MDevel::Cover " - if [[ "$1"x != 'x' && $1 != "-"* ]] ; then - COVER_DB=$1 - LOCAL_COVERAGE=0 - shift - fi - COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine,-silent,1 " - if [ '' != "${COVERAGE_COMMAND}" ] ; then - CMD=${COVERAGE_COMMAND} - else - CMD='coverage' - which $CMD - if [ 0 != $? ] ; then - CMD='python3-coverage' # ubuntu? - fi - fi - which $CMD - if [ 0 != $? ] ; then - echo "cannot find 'coverage' or 'python3-coverage'" - echo "unable to run py2lcov - please install python Coverage.py package" - exit 1 - fi - PYCOV="COVERAGE_FILE=${PYCOV_DB} $CMD run --branch --append" - #PYCOV="coverage run --data-file=${PYCOV_DB} --branch --append" - ;; - - --home | -home ) - LCOV_HOME=$1 - shift - if [ ! -f $LCOV_HOME/bin/lcov ] ; then - echo "LCOV_HOME '$LCOV_HOME' does not exist" - exit 1 - fi - ;; +source ../common.tst - --no-parallel ) - PARALLEL='' - ;; - - --no-profile ) - PROFILE='' - ;; +rm -rf *.info *.json __pycache__ help.txt *.pyc *.dat - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done +clean_cover -if [ "x" == "x$LCOV_HOME" ] ; then - if [ -f ../../bin/lcov ] ; then - LCOV_HOME=../.. - else - LCOV_HOME=../../../releng/coverage/lcov - fi +if [[ 1 == $CLEAN_ONLY ]] ; then + exit 0 fi -LCOV_HOME=`(cd ${LCOV_HOME} ; pwd)` - -if [ 'x' == "x$XML2LCOV_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - PERLLCOV_TOOL=${LCOV_HOME}/bin/perl2lcov - PY2LCOV_TOOL=${LCOV_HOME}/bin/py2lcov - XML2LCOV_TOOL=${LCOV_HOME}/bin/xml2lcov -fi -if [ -f $LCOV_HOME/scripts/getp4version ] ; then - SCRIPT_DIR=$LCOV_HOME/scripts -else - # running test from lcov install - SCRIPT_DIR=$LCOV_HOME/share/lcov/support-scripts - MD5_OPT='--version-script --md5' -fi # is this git or P4? -git -C . rev-parse > /dev/null 2>&1 -if [ 0 == $? ] ; then +if [ 1 == "$USE_GIT" ] ; then # this is git VERSION="--version-script ${SCRIPT_DIR}/gitversion.pm" ANNOTATE="--annotate-script ${SCRIPT_DIR}/gitblame.pm" @@ -119,41 +27,18 @@ else ANNOTATE="--annotate-script ${SCRIPT_DIR}/p4annotate.pm" fi +if [ $IS_GIT == 0 ] && [ $IS_P4 == 0 ] ; then + VERSION="$VERSION --ignore usage" +fi if [ ! -x $PY2LCOV_SCRIPT ] ; then echo "missing py2lcov script - dying" exit 1 fi -if [[ ! ( -d $LCOV_HOME/bin && -d $LCOV_HOME/lib && -x $LCOV_HOME/bin/genhtml && -f $LCOV_HOME/lib/lcovutil.pm ) ]] ; then - echo "LCOV_HOME '$LCOV_HOME' seems not to be invalid" - exit 1 -fi - -export PATH=${LCOV_HOME}/bin:${LCOV_HOME}/share:${PATH} -export MANPATH=${MANPATH}:${LCOV_HOME}/man - -if [ 'x' == "x$GENHTML_TOOL" ] ; then - GENHTML_TOOL=${LCOV_HOME}/bin/genhtml - LCOV_TOOL=${LCOV_HOME}/bin/lcov - GENINFO_TOOL=${LCOV_HOME}/bin/geninfo -fi - -ROOT=`pwd` -PARENT=`(cd .. ; pwd)` LCOV_OPTS="--branch-coverage $PARALLEL $PROFILE" -rm -rf *.info *.json __pycache__ help.txt *.pyc *.dat - -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete - rm -rf pycov -fi - -if [[ 1 == $CLEAN_ONLY ]] ; then - exit 0 -fi # NOTE: the 'coverage.xml' file here is a copy of the one at # https://gist.github.com/apetro/fcfffb8c4cdab2c1061d @@ -162,7 +47,7 @@ fi # in the remove data that was significant from a test perspective. # no source - so can't compute version -eval ${PYCOV} ${XML2LCOV_TOOL} -o test.info coverage.xml # $VERSION +eval ${PYCOV} ${XML2LCOV_TOOL} -o test.info coverage.xml -v -v # $VERSION if [ 0 != $? ] ; then echo "xml2lcov failed" if [ 0 == $KEEP_GOING ] ; then