@@ -30,6 +30,20 @@ declare opt_coverage_per_test=false
3030declare opt_suite=false
3131declare opt_testCase=" "
3232
33+ declare branchCoverage=lcov_branch_coverage
34+ declare -a lcovArgs=(--ignore-errors unused)
35+ declare -a lcovCaptureArgs=()
36+ declare -ar lcovExcludeArgs=(--exclude ' */lex.yy.c' --exclude ' */parser.c' --exclude ' */lexer.l' --exclude ' */parser.y' )
37+
38+ if [[ $( uname) == " Darwin" ]]; then
39+ branchCoverage=branch_coverage
40+ lcovArgs+=(--rc derive_function_end_line=0)
41+ fi
42+
43+ if [[ -n " ${GCOV_TOOL:- } " ]]; then
44+ lcovCaptureArgs+=(--gcov-tool " ${GCOV_TOOL} " )
45+ fi
46+
3347
3448function print_usage()
3549{
@@ -111,7 +125,8 @@ function cov_baseline()
111125 if [ ! -f ${BASELINE_FILE} ]; then
112126 echo " Creating coverage baseline ..."
113127 lcov --capture --initial --no-recursion --directory ${OUT_DIR} --base-directory ${SRC_DIR} \
114- --exclude ' */lex.yy.c' --exclude ' */parser.c' --output-file ${BASELINE_FILE}
128+ " ${lcovCaptureArgs[@]} " " ${lcovExcludeArgs[@]} " " ${lcovArgs[@]} " --rc " ${branchCoverage} =1" \
129+ --output-file ${BASELINE_FILE}
115130 echo -e " Coverage baseline created in ${BASELINE_FILE} \n"
116131 fi
117132 fi
@@ -160,7 +175,7 @@ function measure_coverage()
160175 mkdir -p " ${testResultsDir} "
161176 cp ${OUT_DIR} /* .gc* " ${testResultsDir} "
162177 lcov --capture --directory " ${testResultsDir} " --base-directory ${SRC_DIR} --test-name " ${tcBaseName} " --quiet \
163- --exclude ' */lex.yy.c ' --exclude ' */parser.c ' --rc " ${branchCoverage} =1" \
178+ " ${lcovCaptureArgs[@]} " " ${lcovExcludeArgs[@]} " " ${lcovArgs[@]} " --rc " ${branchCoverage} =1" \
164179 --output-file " ${testResultsDir} /coverage.info"
165180 echo -n " Coverage: "
166181 lcov --summary " ${testResultsDir} /coverage.info" 2>&1 | grep ' lines...' | grep -oP ' \d+\.\d*%'
@@ -174,7 +189,7 @@ function consolidate_coverage()
174189 echo -e " \nConsolidating test coverage ..."
175190 pushd ${OUT_DIR} /test-results || exit 1
176191 find . -name " *.info" | xargs printf -- ' --add-tracefile %s\n' | xargs --exit \
177- lcov --rc " ${branchCoverage} =1" --exclude ' */lex.yy.c ' --exclude ' */parser.c ' \
192+ lcov --rc " ${branchCoverage} =1" " ${lcovExcludeArgs[@]} " " ${lcovArgs[@]} " \
178193 --output-file ../${COVERAGE_FILE} --add-tracefile ../${BASELINE_FILE}
179194 popd || exit 1
180195 echo " "
@@ -305,10 +320,6 @@ check_prereqs
305320cov_baseline
306321
307322declare tcBaseName=${opt_testCase% .txt}
308- declare branchCoverage=lcov_branch_coverage
309- if [[ $( uname) == " Darwin" ]]; then
310- branchCoverage=branch_coverage
311- fi
312323
313324# Execute the entire test suite
314325if [ ${opt_suite} == true ]; then
@@ -317,7 +328,7 @@ if [ ${opt_suite} == true ]; then
317328 execute_suite
318329
319330 if [ ${opt_coverage_per_test} == false ]; then
320- tcBaseName=black-box-all
331+ tcBaseName=black_box_all
321332 measure_coverage
322333 fi
323334 if [ ${opt_coverage} == true ]; then
0 commit comments