gcc coverage: remove -b from gcov invocation
Removing branch coverage for gcc because of a gcov issue that segfaults when both `-i` and `-b` are used (gcov 0.7 and later).
Fixes #7417.
RELNTOES: Branch coverage for gcc (using the `--experimental_cc_coverage` flag) is not available anymore due to [a gcc segfault issue](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84879).
Closes #7419.
PiperOrigin-RevId: 234103459
diff --git a/src/test/shell/bazel/bazel_cc_code_coverage_test.sh b/src/test/shell/bazel/bazel_cc_code_coverage_test.sh
index fa1ded3..b102cae 100755
--- a/src/test/shell/bazel/bazel_cc_code_coverage_test.sh
+++ b/src/test/shell/bazel/bazel_cc_code_coverage_test.sh
@@ -288,8 +288,6 @@
function:4,1,_Z1ab
lcount:4,1
lcount:5,1
-branch:5,taken
-branch:5,nottaken
lcount:6,1
lcount:8,0"
assert_coverage_entry_in_file "$expected_gcov_result_a_cc" "$output_file"
@@ -320,8 +318,6 @@
function:1,1,_Z1bi
lcount:1,1
lcount:2,1
-branch:2,taken
-branch:2,nottaken
lcount:3,1
lcount:5,0"
assert_coverage_entry_in_file "$expected_gcov_result" "$output_file"
@@ -382,9 +378,9 @@
# This assertion is needed to make sure no other source files are included
# in the output file.
local nr_lines="$(wc -l < "$output_file")"
- [[ "$nr_lines" == 21 ]] || \
+ [[ "$nr_lines" == 17 ]] || \
fail "Number of lines in C++ gcov coverage output file is "\
- "$nr_lines and different than 21"
+ "$nr_lines and different than 17"
}
run_suite "Testing tools/test/collect_cc_coverage.sh"
diff --git a/src/test/shell/bazel/bazel_coverage_cc_test_gcc.sh b/src/test/shell/bazel/bazel_coverage_cc_test_gcc.sh
index d26c1a1..070bad0 100755
--- a/src/test/shell/bazel/bazel_coverage_cc_test_gcc.sh
+++ b/src/test/shell/bazel/bazel_coverage_cc_test_gcc.sh
@@ -174,9 +174,6 @@
FNDA:1,_Z1ab
FNF:1
FNH:1
-BA:4,2
-BRF:1
-BRH:1
DA:3,1
DA:4,1
DA:5,1
@@ -322,10 +319,6 @@
FNDA:1,_ZN5hello8HelloLibC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
FNF:4
FNH:4
-BA:11,2
-BA:19,2
-BRF:2
-BRH:2
DA:11,1
DA:12,1
DA:14,1
@@ -438,10 +431,6 @@
FNDA:1,_Z41__static_initialization_and_destruction_0ii
FNF:3
FNH:3
-BA:6,2
-BA:13,2
-BRF:2
-BRH:2
DA:5,1
DA:6,1
DA:7,1
@@ -457,9 +446,6 @@
FNDA:1,_Z1bi
FNF:1
FNH:1
-BA:2,2
-BRF:1
-BRH:1
DA:1,1
DA:2,1
DA:3,1
@@ -563,10 +549,6 @@
FNDA:1,_Z41__static_initialization_and_destruction_0ii
FNF:3
FNH:3
-BA:6,2
-BA:13,2
-BRF:2
-BRH:2
DA:5,1
DA:6,1
DA:7,1
@@ -582,9 +564,6 @@
FNDA:1,_Z1bi
FNF:1
FNH:1
-BA:2,2
-BRF:1
-BRH:1
DA:1,1
DA:2,1
DA:3,1
@@ -714,9 +693,6 @@
FNDA:1,_Z1ab
FNF:1
FNH:1
-BA:5,2
-BRF:1
-BRH:1
DA:4,1
DA:5,1
DA:6,1
@@ -731,10 +707,6 @@
FNDA:1,_Z7b_for_ci
FNF:2
FNH:2
-BA:3,2
-BA:12,2
-BRF:2
-BRH:2
DA:2,1
DA:3,1
DA:4,1
@@ -751,9 +723,6 @@
FNDA:1,_Z1cb
FNF:1
FNH:1
-BA:5,2
-BRF:1
-BRH:1
DA:4,1
DA:5,1
DA:6,0
@@ -891,9 +860,6 @@
FNDA:1,_Z1ab
FNF:2
FNH:2
-BA:5,2
-BRF:1
-BRH:1
DA:4,1
DA:5,1
DA:6,1
@@ -912,10 +878,6 @@
FNDA:3,_Z9b_for_allv
FNF:3
FNH:3
-BA:3,2
-BA:12,2
-BRF:2
-BRH:2
DA:2,1
DA:3,1
DA:4,1
@@ -936,9 +898,6 @@
FNDA:1,_Z1cb
FNF:2
FNH:2
-BA:5,2
-BRF:1
-BRH:1
DA:4,1
DA:5,1
DA:6,0
diff --git a/src/test/shell/bazel/bazel_coverage_sh_test.sh b/src/test/shell/bazel/bazel_coverage_sh_test.sh
index 12b1318..985f45b 100755
--- a/src/test/shell/bazel/bazel_coverage_sh_test.sh
+++ b/src/test/shell/bazel/bazel_coverage_sh_test.sh
@@ -283,10 +283,6 @@
FNDA:1,_ZN5hello8HelloLibC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
FNF:4
FNH:4
-BA:11,2
-BA:18,2
-BRF:2
-BRH:2
DA:11,1
DA:12,1
DA:14,1
@@ -302,13 +298,6 @@
FNDA:1,main
FNF:1
FNH:1
-BA:9,2
-BA:10,2
-BA:11,2
-BA:12,0
-BA:14,2
-BRF:5
-BRH:4
DA:8,1
DA:9,2
DA:10,2
@@ -481,10 +470,6 @@
FNDA:1,_ZN5hello8HelloLibC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
FNF:4
FNH:4
-BA:11,2
-BA:18,2
-BRF:2
-BRH:2
DA:11,1
DA:12,1
DA:14,1
@@ -501,13 +486,6 @@
FNDA:1,main
FNF:1
FNH:1
-BA:9,2
-BA:10,2
-BA:11,2
-BA:12,0
-BA:14,2
-BRF:5
-BRH:4
DA:8,1
DA:9,2
DA:10,2
diff --git a/tools/test/collect_cc_coverage.sh b/tools/test/collect_cc_coverage.sh
index af59eda..2960db6 100755
--- a/tools/test/collect_cc_coverage.sh
+++ b/tools/test/collect_cc_coverage.sh
@@ -135,8 +135,6 @@
# -i Output gcov file in an intermediate text format.
# The output is a single .gcov file per .gcda file.
# No source code is required.
- # -b Write branch frequencies to the output file, and
- # write branch summary info to the standard output.
# -o directory The directory containing the .gcno and
# .gcda data files.
# "${gcda"} The input file name. gcov is looking for data files
@@ -146,7 +144,10 @@
# they correspond to. One .gcov file is produced for each source
# (or header) file containing code which was compiled to produce the
# .gcda files.
- "${GCOV}" -i -b -o "$(dirname ${gcda})" "${gcda}" &> "$gcov_log"
+ # Don't generate branch coverage (-b) because of a gcov issue that
+ # segfaults when both -i and -b are used (see
+ # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84879).
+ "${GCOV}" -i -o "$(dirname ${gcda})" "${gcda}" &> "$gcov_log"
# Go through all the files that were created by the gcov command above
# and append their content to the output .gcov file.