| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | set +x |
| 3 | |
| 4 | source ../../common.tstscip-shell source . . `../../common.tst`. |
| 5 | |
| 6 | #PARALLEL='' |
| 7 | #PROFILE="'' |
| 8 | |
| 9 | rmscip-shell system . . rm. -f *.cpp *.gcno *.gcda a.out *.info *.log *.json dumper* *.annotated annotate.sh |
| 10 | rmscip-shell system . . rm. -rf ./vanilla ./annotated ./annotateErr ./annotated2 ./annotateErr2 ./range ./filter ./cover_db annotated_nofunc |
| 11 | |
| 12 | clean_cover |
| 13 | |
| 14 | if [[ 1 == $CLEAN_ONLY ]] ; then |
| 15 | exit 0 |
| 16 | fi |
| 17 | |
| 18 | if ! type "${CXX}" >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 ; then |
| 19 | echoscip-shell system . . echo. "Missing tool: $CXX" >&2 |
| 20 | exit 2 |
| 21 | fi |
| 22 | |
| 23 | LCOV_OPTS="$EXTRA_GCOV_OPTS --branch-coverage $PARALLEL $PROFILE" |
| 24 | DIFFCOV_OPTS="--function-coverage --branch-coverage --demangle-cpp --frame --prefix $PARENT $PROFILE $PARALLEL" |
| 25 | |
| 26 | |
| 27 | echoscip-shell system . . echo. * |
| 28 | |
| 29 | # filename was all upper case |
| 30 | lnscip-shell system . . ln. -s ../simple/simple2.cpp test.cpp |
| 31 | lnscip-shell system . . ln. -s ../simple/simple2.cpp.annotated test.cpp.annotated |
| 32 | lnscip-shell system . . ln. -s ../simple/annotate.sh . |
| 33 | |
| 34 | ${CXX} --coverage test.cpp |
| 35 | ./a.out |
| 36 | |
| 37 | echoscip-shell system . . echo. `whichscip-shell system . . which. gcov` |
| 38 | echoscip-shell system . . echo. `whichscip-shell system . . which. lcov` |
| 39 | |
| 40 | # old gcc version generates inconsistent line/function data |
| 41 | IFS='.' read -r -a VER <<< `${CC} -dumpversion` |
| 42 | if [scip-shell system . . `[`. "${VER[0]}" -lt 5 ] ; then |
| 43 | IGNORE="--ignore inconsistent" |
| 44 | fi |
| 45 | |
| 46 | echoscip-shell system . . echo. lcov $LCOV_OPTS --capture --directory . --output-file current.info --no-external $IGNORE |
| 47 | $COVER $LCOV_TOOL $LCOV_OPTS --capture --directory . --output-file current.info --no-external $IGNORE |
| 48 | if [scip-shell system . . `[`. 0 != $? ] ; then |
| 49 | echoscip-shell system . . echo. "ERROR: lcov --capture failed" |
| 50 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 51 | exit 1 |
| 52 | fi |
| 53 | fi |
| 54 | |
| 55 | # add an out-of-range line to the coverage data |
| 56 | perlscip-shell system . . perl. munge.pl current.info > munged.info |
| 57 | # remove a line which has a branch: create branch with no corresponding line |
| 58 | # LLVM seems to generate this kind of inconsistent data, at times |
| 59 | perlscip-shell system . . perl. munge2.pl current.info > munged2.info |
| 60 | |
| 61 | echoscip-shell system . . echo. genhtml $DIFFCOV_OPTS --annotate-script `pwdscip-shell system . . pwd.`/annotate.sh --show-owners all -o annotateErr ./munged.info |
| 62 | $COVER $GENHTML_TOOL $DIFFCOV_OPTS --annotate-script `pwdscip-shell system . . pwd.`/annotate.sh --show-owners all -o annotateErr ./munged.info 2>&1 | teescip-shell system . . tee. err.log |
| 63 | if [scip-shell system . . `[`. 0 == ${[PIPESTATUS[0]} ] ; then |
| 64 | echoscip-shell system . . echo. "ERROR: genhtml did not return error" |
| 65 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 66 | exit 1 |
| 67 | fi |
| 68 | fi |
| 69 | grepscip-shell system . . grep. -E "ERROR.*? contains only .+? lines but coverage data refers to line" err.log |
| 70 | if [scip-shell system . . `[`. 0 != $? ] ; then |
| 71 | echoscip-shell system . . echo. "did not find expected range error message in err.log" |
| 72 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 73 | exit 1 |
| 74 | fi |
| 75 | fi |
| 76 | |
| 77 | |
| 78 | echoscip-shell system . . echo. genhtml $DIFFCOV_OPTS --annotate-script `pwdscip-shell system . . pwd.`/annotate.sh --show-owners all -o annotated --ignore range ./munged.info |
| 79 | $COVER $GENHTML_TOOL $DIFFCOV_OPTS --annotate-script `pwdscip-shell system . . pwd.`/annotate.sh --show-owners all -o annotated ./munged.info --ignore range 2>&1 | teescip-shell system . . tee. annotate.log |
| 80 | if [scip-shell system . . `[`. 0 != ${PIPESTATUS[0]} ] ; then |
| 81 | echoscip-shell system . . echo. "ERROR: genhtml annotated failed" |
| 82 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 83 | exit 1 |
| 84 | fi |
| 85 | fi |
| 86 | # expect to see generated function labels |
| 87 | for label in 'BEGIN' 'END' ; do |
| 88 | grepscip-shell system . . grep. -E "$label: function .+outOfRangeFnc" annotated/synthesize/test.cpp.gcov.html |
| 89 | if [scip-shell system . . `[`. 0 != $? ] ; then |
| 90 | echoscip-shell system . . echo. "ERROR: genhtml didn't generate function $label label" |
| 91 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 92 | exit 1 |
| 93 | fi |
| 94 | fi |
| 95 | done |
| 96 | |
| 97 | echoscip-shell system . . echo. genhtml $DIFFCOV_OPTS --annotate-script `pwdscip-shell system . . pwd.`/annotate.sh --show-owners all -o annotated_nofunc --no-function-coverage --ignore range ./munged.info |
| 98 | $COVER $GENHTML_TOOL $DIFFCOV_OPTS --annotate-script `pwdscip-shell system . . pwd.`/annotate.sh --show-owners all -o annotated_nofunc --no-function-coverage ./munged.info --ignore range 2>&1 | teescip-shell system . . tee. annotate.log |
| 99 | if [scip-shell system . . `[`. 0 != ${PIPESTATUS[0]} ] ; then |
| 100 | echoscip-shell system . . echo. "ERROR: genhtml annotated_nofunc failed" |
| 101 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 102 | exit 1 |
| 103 | fi |
| 104 | fi |
| 105 | # should not be generated.. |
| 106 | grepscip-shell system . . grep. -E "function .+outOfRangeFnc" annotated_nofunc/synthesize/test.cpp.gcov.html |
| 107 | if [scip-shell system . . `[`. 0 == $? ] ; then |
| 108 | echoscip-shell system . . echo. "ERROR: genhtml should not have generated function label" |
| 109 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 110 | exit 1 |
| 111 | fi |
| 112 | fi |
| 113 | |
| 114 | echoscip-shell system . . echo. genhtml $DIFFCOV_OPTS -o vanilla --ignore range ./munged.info |
| 115 | $COVER $GENHTML_TOOL $DIFFCOV_OPTS -o vanilla --ignore range ./munged.info 2>&1 | teescip-shell system . . tee. vanilla.log |
| 116 | if [scip-shell system . . `[`. 0 != ${PIPESTATUS[0]} ] ; then |
| 117 | echoscip-shell system . . echo. "ERROR: genhtml vanilla failed" |
| 118 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 119 | exit 1 |
| 120 | fi |
| 121 | fi |
| 122 | |
| 123 | for log in annotate.log vanilla.log ; do |
| 124 | grepscip-shell system . . grep. -E "WARNING.*? contains only .+? lines but coverage data refers to line" $log |
| 125 | if [scip-shell system . . `[`. 0 != $? ] ; then |
| 126 | echoscip-shell system . . echo. "did not find expected synthesize warning message in log" |
| 127 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 128 | exit 1 |
| 129 | fi |
| 130 | fi |
| 131 | done |
| 132 | |
| 133 | for dir in annotated vanilla ; do |
| 134 | grepscip-shell system . . grep. -E "not long enough" $dir/synthesize/test.cpp.gcov.html |
| 135 | if [scip-shell system . . `[`. 0 != $? ] ; then |
| 136 | echoscip-shell system . . echo. "did not find expected synthesize warning message in HTML" |
| 137 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 138 | exit 1 |
| 139 | fi |
| 140 | fi |
| 141 | done |
| 142 | |
| 143 | echoscip-shell system . . echo. genhtml $DIFFCOV_OPTS --annotate-script `pwdscip-shell system . . pwd.`/annotate.sh --show-owners all -o annotateErr2 ./munged2.info |
| 144 | $COVER $GENHTML_TOOL $DIFFCOV_OPTS --annotate-script `pwdscip-shell system . . pwd.`/annotate.sh --show-owners all -o annotateErr2 ./munged2.info 2>&1 | teescip-shell system . . tee. err2.log |
| 145 | if [scip-shell system . . `[`. 0 == ${[PIPESTATUS[0]} ] ; then |
| 146 | echoscip-shell system . . echo. "ERROR: genhtml did not return error" |
| 147 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 148 | exit 1 |
| 149 | fi |
| 150 | fi |
| 151 | grepscip-shell system . . grep. -E "ERROR.*? has branchcov but no linecov data" err2.log |
| 152 | if [scip-shell system . . `[`. 0 != $? ] ; then |
| 153 | echoscip-shell system . . echo. "did not find expected inconsistent error message in err2.log" |
| 154 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 155 | exit 1 |
| 156 | fi |
| 157 | fi |
| 158 | |
| 159 | |
| 160 | echoscip-shell system . . echo. genhtml $DIFFCOV_OPTS --annotate-script `pwdscip-shell system . . pwd.`/annotate.sh --show-owners all -o annotated2 --ignore inconsistent ./munged2.info |
| 161 | $COVER $GENHTML_TOOL $DIFFCOV_OPTS --annotate-script `pwdscip-shell system . . pwd.`/annotate.sh --show-owners all -o annotated2 ./munged2.info --ignore inconsistent 2>&1 | teescip-shell system . . tee. annotate2.log |
| 162 | if [scip-shell system . . `[`. 0 != ${PIPESTATUS[0]} ] ; then |
| 163 | echoscip-shell system . . echo. "ERROR: genhtml annotated failed" |
| 164 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 165 | exit 1 |
| 166 | fi |
| 167 | fi |
| 168 | grepscip-shell system . . grep. -E "WARNING.*? has branchcov but no linecov data" annotate2.log |
| 169 | if [scip-shell system . . `[`. 0 != $? ] ; then |
| 170 | echoscip-shell system . . echo. "did not find expected inconsistent error message in annotate2.log" |
| 171 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 172 | exit 1 |
| 173 | fi |
| 174 | fi |
| 175 | |
| 176 | |
| 177 | echoscip-shell system . . echo. lcov $LCOV_OPTS --ignore range -o range.info -a ./munged.info --filter branch |
| 178 | $COVER $LCOV_TOOL $LCOV_OPTS --ignore range -o range.info -a ./munged.info --filter branch 2>&1 | teescip-shell system . . tee. range.log |
| 179 | if [scip-shell system . . `[`. 0 != ${PIPESTATUS[0]} ] ; then |
| 180 | echoscip-shell system . . echo. "ERROR: lcov --ignore range failed" |
| 181 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 182 | exit 1 |
| 183 | fi |
| 184 | fi |
| 185 | COUNT1=`grepscip-shell system . . grep. -c -i "warning: .*range.* unknown.* line .* there are only" range.log` |
| 186 | if [scip-shell system . . `[`. 1 != $COUNT1 ] ; then |
| 187 | echoscip-shell system . . echo. "Missing expected warning: expected 1 found $COUNT1" |
| 188 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 189 | exit 1 |
| 190 | fi |
| 191 | fi |
| 192 | |
| 193 | echoscip-shell system . . echo. lcov $LCOV_OPTS --ignore range -o range.info -a ./munged.info --filter branch --rc warn_once_per_file=0 |
| 194 | $COVER $LCOV_TOOL $LCOV_OPTS --ignore range -o range.info -a ./munged.info --filter branch --rc warn_once_per_file=0 --comment 'insert a comment' 2>&1 | teescip-shell system . . tee. range2.log |
| 195 | if [scip-shell system . . `[`. 0 != ${PIPESTATUS[0]} ] ; then |
| 196 | echoscip-shell system . . echo. "ERROR: lcov --ignore range2 failed" |
| 197 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 198 | exit 1 |
| 199 | fi |
| 200 | fi |
| 201 | COUNT2=`grepscip-shell system . . grep. -c -i "warning: .*range.* unknown.* line .* there are only" range2.log` |
| 202 | if [scip-shell system . . `[`. 2 != $COUNT2 ] ; then |
| 203 | echoscip-shell system . . echo. "Expected 2 messages found $COUNT2" |
| 204 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 205 | exit 1 |
| 206 | fi |
| 207 | fi |
| 208 | |
| 209 | echoscip-shell system . . echo. lcov $LCOV_OPTS -o filter.info --filter range -a ./munged.info --filter branch |
| 210 | $COVER $LCOV_TOOL $LCOV_OPTS -o filter.info --filter range -a ./munged.info --filter branch 2>&1 | teescip-shell system . . tee. filter.log |
| 211 | if [scip-shell system . . `[`. 0 != ${PIPESTATUS[0]} ] ; then |
| 212 | echoscip-shell system . . echo. "ERROR: lcov --filter range failed" |
| 213 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 214 | exit 1 |
| 215 | fi |
| 216 | fi |
| 217 | grepscip-shell system . . grep. -i "warning: .*range.* unknown line .* there are only" filter.log |
| 218 | if [scip-shell system . . `[`. 0 == $? ] ; then |
| 219 | echoscip-shell system . . echo. "Found unexpected warning" |
| 220 | if [scip-shell system . . `[`. 0 == $KEEP_GOING ] ; then |
| 221 | exit 1 |
| 222 | fi |
| 223 | fi |
| 224 | |
| 225 | |
| 226 | echoscip-shell system . . echo. "Tests passed" |
| 227 | |
| 228 | if [scip-shell system . . `[`. "x$COVER" != "x" ] && [scip-shell system . . `[`. 0 != $LOCAL_COVERAGE ] ; then |
| 229 | cover $COVER_DB |
| 230 | $PERL2LCOV_TOOL -o perlcov.info $COVER_DB |
| 231 | $GENHTML_TOOL -o coverage perlcov.info |
| 232 | fi |