diff --git a/bin/genhtml b/bin/genhtml index dd229d8a..8ee18615 100755 --- a/bin/genhtml +++ b/bin/genhtml @@ -6817,7 +6817,7 @@ our $hierarchical = 0; # if true: show directory hierarchy # default: legacy two-level report our $flat = 0; # if true: single table of all files in top level -our $sort = 1; # If set, provide directory listings with sorted entries +our $sort_tables = 1; # If set, provide directory listings with sorted entries our $no_sort; # Disable sort our $frames; # If set, use frames for source code view our $keep_descriptions; # If set, do not remove unused test case descriptions @@ -6899,7 +6899,7 @@ my %genhtml_rc_opts = ( "genhtml_mcdc_field_width" => \$mcdc_field_width, "genhtml_owner_field_width" => \$owner_field_width, "genhtml_age_field_width" => \$age_field_width, - "genhtml_sort" => \$sort, + "genhtml_sort" => \$sort_tables, "genhtml_charset" => \$charset, "genhtml_desc_html" => \$rc_desc_html, 'merge_function_aliases' => \$merge_function_aliases, @@ -6975,7 +6975,7 @@ my %genhtml_options = ("output-directory|o=s" => \$output_directory, "html-gzip" => \$html_gzip, "hierarchical" => \$hierarchical, "flat" => \$flat, - "sort" => \$sort, + "sort-tables" => \$sort_tables, "no-sort" => \$no_sort, "precision=i" => \$lcovutil::default_precision, "missed" => \$opt_missed, @@ -6985,6 +6985,15 @@ my %genhtml_options = ("output-directory|o=s" => \$output_directory, "merge-aliases" => \$merge_function_aliases, "suppress-aliases" => \$suppress_function_aliases, 'validate' => \$validateHTML,); + +# remove ambiguous entry from common table - +# (genhtml has '--sort-inputs' and '--sort-tables') +# handle the (no obsolete) '--sort' option +Getopt::Long::Configure("pass_through", "no_auto_abbrev"); +my $obsoleteSort; +Getopt::Long::GetOptions('sort' => \$obsoleteSort); +Getopt::Long::Configure('default'); + # Parse command line options if ( !lcovutil::parseOptions(\%genhtml_rc_opts, \%genhtml_options, @@ -6994,6 +7003,13 @@ if ( exit(1); } +if (defined($obsoleteSort)) { + $sort_tables = $obsoleteSort; + lcovutil::ignorable_warning($lcovutil::ERROR_DEPRECATED, + "option '--sort' is deprecated and will be removed in a future release; please use '--sort-tables' instead." + ); +} + $merge_function_aliases = 1 if ($suppress_function_aliases || defined($lcovutil::cov_filter[$lcovutil::FILTER_FUNCTION_ALIAS])); @@ -7037,7 +7053,7 @@ if (defined($lcovutil::stop_on_error) && } # Merge sort options -$sort = 0 +$sort_tables = 0 if ($no_sort); die( "unsupported use of mutually exclusive '--flat' and '--hierachical' options") @@ -7244,7 +7260,7 @@ if ($no_prefix && @dir_prefix) { @fileview_sortlist = ($SORT_FILE); @funcview_sortlist = ($SORT_FILE); -if ($sort) { +if ($sort_tables) { push(@fileview_sortlist, $SORT_LINE); push(@fileview_sortlist, $SORT_FUNC) if ($lcovutil::func_coverage); push(@fileview_sortlist, $SORT_BRANCH) if ($lcovutil::br_coverage); @@ -8659,7 +8675,7 @@ sub write_png_files() 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 ]; - if ($sort) { + if ($sort_tables) { $data{"updown.png"} = $dark_mode ? [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, @@ -11960,7 +11976,7 @@ sub write_header(*$$$$$$$) %$differentialFunctionMap) { $view .= ""; if ($type == $HDR_SOURCE) { - my $suffix = $sort ? '-c' : ''; + my $suffix = $sort_tables ? '-c' : ''; $view .= " (source / functions)"; } elsif ($type == $HDR_FUNC) { @@ -12652,7 +12668,7 @@ sub write_file_table(*$$$$$$) } my $file_col_title = ($fileview || $main::flat) ? 'File' : 'Directory'; # don't insert the 'sort' controls if there is just a single source file - my $use_sort_button = $sort && 1 < scalar($dirSummary->sources()); + my $use_sort_button = $sort_tables && 1 < scalar($dirSummary->sources()); my $file_code = get_file_code($hide, $file_col_title, $use_sort_button && $sort_type != $SORT_FILE, @@ -13372,23 +13388,23 @@ sub funcview_get_label($$$$) my $link; if (!defined($col)) { - if ($sort && $sort_type != $SORT_FILE) { + if ($sort_tables && $sort_type != $SORT_FILE) { $link = "$name.func.$html_ext"; } return "Function Name" . get_sort_code($link, "function name", $base); } elsif ($col eq 'hit') { - if ($sort && $sort_type != $SORT_LINE) { + if ($sort_tables && $sort_type != $SORT_LINE) { $link = "$name.func-c.$html_ext"; } return "Hit count" . get_sort_code($link, "function hit count", $base); } elsif ($col eq 'missed_line') { - if ($sort && $sort_type != $SORT_MISSING_LINE) { + if ($sort_tables && $sort_type != $SORT_MISSING_LINE) { $link = "$name.func-l.$html_ext"; } return "Lines" . get_sort_code($link, "unexercised lines in function", $base); } elsif ($col eq 'missed_mcdc') { - if ($sort && $sort_type != $SORT_MISSING_MCDC) { + if ($sort_tables && $sort_type != $SORT_MISSING_MCDC) { $link = "$name.func-m.$html_ext"; } return "MC/DC" @@ -13397,7 +13413,7 @@ sub funcview_get_label($$$$) $base); } else { die("unexpected sort $col") unless ($col eq 'missed_branch'); - if ($sort && $sort_type != $SORT_MISSING_BRANCH) { + if ($sort_tables && $sort_type != $SORT_MISSING_BRANCH) { $link = "$name.func-b.$html_ext"; } return "Branches" . diff --git a/bin/geninfo b/bin/geninfo index f494885a..e1c478ff 100755 --- a/bin/geninfo +++ b/bin/geninfo @@ -1288,7 +1288,18 @@ sub gen_info(@) $builder->find_files(2, @_); } my $filelist = $builder->worklist(); - my $total = scalar(@$filelist); + my @sorted_filelist; + if ($lcovutil::sort_inputs) { + @sorted_filelist = sort({ + my $na = $a->[0] . + (defined($a->[1]) ? $a->[1] : $a->[2]); + my $nb = $b->[0] . + (defined($b->[1]) ? $b->[1] : $b->[2]); + $na cmp $nb + } @$filelist); + $filelist = \@sorted_filelist; + } + my $total = scalar(@$filelist); if (1 < $lcovutil::maxParallelism) { my $floor = $lcovutil::maxParallelism ? @@ -1326,7 +1337,7 @@ sub gen_info(@) FILE: foreach my $j (@$filelist) { my ($dir, $gcda, $gcno) = @$j; foreach my $f ($gcda, $gcno) { - next unless defined($f); # might not be a GCDA file + next unless defined($f); # might not be a GCDA file my $filename = $dir . $lcovutil::dirseparator . $f; if (grep({ $filename =~ $_ } @main::large_files)) { lcovutil::info(1, "large file: $filename\n"); diff --git a/lcovrc b/lcovrc index c02dcaac..0e7b50ad 100644 --- a/lcovrc +++ b/lcovrc @@ -490,6 +490,11 @@ lcov_json_module = auto # directives, etc #case_insensitive = 0 +# sort file names before capture and/or aggregation - to reduce certain +# types of processing order dependencies which can affect coverage results. +# see the lcovrc man page for more details. +#sort_input = 1 + # override line default line exclusion regexp #lcov_excl_line = LCOV_EXCL_LINE diff --git a/lib/lcovutil.pm b/lib/lcovutil.pm index e1e32c66..e6b9cd6a 100644 --- a/lib/lcovutil.pm +++ b/lib/lcovutil.pm @@ -117,6 +117,7 @@ our $lcov_url = "https://github.com//linux-test-project/lcov"; our @temp_dirs; our $tmp_dir = '/tmp'; # where to put temporary/intermediate files our $preserve_intermediates; # this is useful only for debugging +our $sort_inputs; # sort input file lists - to reduce unpredictability our $devnull = File::Spec->devnull(); # portable way to do it our $dirseparator = ($^O =~ /Win/) ? '\\' : '/'; our $interp = ($^O =~ /Win/) ? $^X : undef; @@ -1126,7 +1127,8 @@ my %rc_common = ( "demangle_cpp" => \@lcovutil::cpp_demangle, 'excessive_count_threshold' => \$excessive_count_threshold, - , + 'sort_input' => \$lcovutil::sort_inputs, + "fail_under_lines" => \$fail_under_lines, "fail_under_branches" => \$fail_under_branches, 'lcov_filter_parallel' => \$lcovutil::lcov_filter_parallel, @@ -1214,7 +1216,8 @@ our %argCommon = ("tempdir=s" => \$tempdirname, "parallel|j:i" => \$lcovutil::maxParallelism, "memory=i" => \$lcovutil::maxMemory, "forget-test-names" => \$TraceFile::ignore_testcase_name, - "preserve" => \$lcovutil::preserve_intermediates,); + "preserve" => \$lcovutil::preserve_intermediates, + 'sort-input' => \$lcovutil::sort_inputs,); sub warnDeprecated { @@ -9248,6 +9251,13 @@ sub merge $lcovutil::maxParallelism = $num; } } + # use a particular file sort order - to somewhat minimize order effects + my $filelist = \@_; + my @sorted_filelist; + if ($lcovutil::sort_inputs) { + @sorted_filelist = sort({ $a cmp $b } @_); + $filelist = \@sorted_filelist; + } if (1 != $lcovutil::maxParallelism && (exists($ENV{LCOV_FORCE_PARALLEL}) || @@ -9277,7 +9287,7 @@ sub merge $lcovutil::maxParallelism) : 1; my $idx = 0; - foreach my $tracefile (@_) { + foreach my $tracefile (@$filelist) { my $seg = $idx / $testsPerSegment; $seg -= 1 if $seg == $lcovutil::maxParallelism; push(@segments, []) @@ -9524,7 +9534,7 @@ sub merge } while (@segments); } else { # sequential - @effective = _process_segment($total_trace, $readSourceFile, \@_); + @effective = _process_segment($total_trace, $readSourceFile, $filelist); } if (defined($lcovutil::tempdirname) && !$lcovutil::preserve_intermediates) { diff --git a/man/genhtml.1 b/man/genhtml.1 index ff6a96ca..e18fe5a3 100644 --- a/man/genhtml.1 +++ b/man/genhtml.1 @@ -71,7 +71,7 @@ genhtml \- Generate HTML view from LCOV coverage data files .IR extension ] .br .RB [ \-\-html\-gzip ] -.RB [ \-\-sort ] +.RB [ \-\-sort\-tables ] .RB [ \-\-no\-sort ] .br .RB [ \-\-function\-coverage ] @@ -213,6 +213,8 @@ genhtml \- Generate HTML view from LCOV coverage data files .br .RB [ \-\-save ] .br +.RB [ \-\-sort\-input ] +.br .RB [ \-\-serialize .IR serialize_output_file ] .br @@ -2671,14 +2673,22 @@ option .IR genhtml_html_gzip . .RE -.B \-\-sort +.B \-\-sort-tables .br .B \-\-no\-sort .RS Specify whether to include sorted views of file and directory overviews. +This option replaces the deprecated +.I "\-\-sort" +option. +.I "\-\-sort" +is still supported and is treated as an alias of +.I "\-\-sort\-tables" +but will be removed in a subsequent LCOV release. + Use -.B \-\-sort +.B \-\-sort-tables to include sorted views or .B \-\-no\-sort to not include them. @@ -3356,7 +3366,7 @@ Show counts of missed lines, functions, branches, and MC/DC expressions. Use this option to change overview pages to show the count of lines, functions, branches, or MC/DC expressions that were not hit. These counts are represented by negative numbers. -When specified together with \-\-sort, file and directory views will be sorted +When specified together with \-\-sort\-tables, file and directory views will be sorted by missed counts. This option can also be configured permanently using the configuration file @@ -3397,6 +3407,19 @@ Keeping copies of the input data files may help to debug any issues or to regene .RE +.B \-\-sort\-input +.br +.RS +Specify whether to sort file names before capture and/or aggregation. +Sorting reduces certain types of processing order-dependent output differences. +See the +.BI sort_input +section in +man +.B lcovrc(5). + +.RE + .BI "\-\-serialize " file_name .RS Save coverage database to diff --git a/man/geninfo.1 b/man/geninfo.1 index f4306096..699ed186 100644 --- a/man/geninfo.1 +++ b/man/geninfo.1 @@ -79,6 +79,8 @@ geninfo \- Generate tracefiles from GCOV coverage data files .RB [ \-\-external ] .RB [ \-\-no\-external ] .br +.RB [ \-\-sort\-input ] +.br .RB [ \-\-config\-file .IR config\-file ] .RB [ \-\-no\-markers ] @@ -677,6 +679,21 @@ config file option. See man .B lcovrc(5) for more information. .RE +.RE + +.B \-\-sort\-input +.br +.RS +Specify whether to sort file names before capture and/or aggregation. +Sorting reduces certain types of processing order-dependent output differences. +See the +.BI sort_input +section in +man +.B lcovrc(5). + +.RE + .B \-\-gcov\-tool .I tool .br diff --git a/man/lcov.1 b/man/lcov.1 index 208fbf15..9df75aeb 100644 --- a/man/lcov.1 +++ b/man/lcov.1 @@ -58,6 +58,8 @@ format is described in man .RB [ \-\-no\-recursion ] .RB [ \-f | \-\-follow ] .br +.RB [ \-\-sort\-input ] +.br .RB [ \-\-compat\-libtool ] .RB [ \-\-no\-compat\-libtool ] .br @@ -159,6 +161,8 @@ Aggregate multiple coverage tracefiles into one: .RB [ \-\-checksum ] .RB [ \-\-no\-checksum ] .br +.RB [ \-\-sort\-input ] +.br .RE Depending on your use model, it may not be necessary to create aggregate coverage data files. @@ -1213,6 +1217,19 @@ want to perform the .info file creation on the build machine. See \-\-to\-package for more information. .RE +.B \-\-sort\-input +.br +.RS +Specify whether to sort file names before capture and/or aggregation. +Sorting reduces certain types of processing order-dependent output differences. +See the +.BI sort_input +section in +man +.B lcovrc(5). + +.RE + .B \-\-gcov\-tool .I tool .br diff --git a/man/lcovrc.5 b/man/lcovrc.5 index a83fb500..bafb8ce4 100644 --- a/man/lcovrc.5 +++ b/man/lcovrc.5 @@ -3172,6 +3172,19 @@ Default is '0': case sensitive matching. .PP +.BR sort_input " =" +.IR [0|1] +.IP +Specify whether to sort file names before capture and/or aggregation. +Sorting reduces certain types of processing order-dependent output differences - +.I e.g., +due to ambiguities in branch data generated by gcc. +.br + +Default is '0': no sorting - process files in the order they were specified on the command line and/or were found during traversal of the filesystem. + +.PP + .SH FILES diff --git a/tests/gendiffcov/errs/msgtest.sh b/tests/gendiffcov/errs/msgtest.sh index 7b64388f..d3c77a6c 100755 --- a/tests/gendiffcov/errs/msgtest.sh +++ b/tests/gendiffcov/errs/msgtest.sh @@ -4,7 +4,7 @@ set +x source ../../common.tst rm -f test.cpp *.gcno *.gcda a.out *.info *.log *.json diff.txt loop*.rc markers.err* -rm -rf select criteria annotate empty unused_src scriptErr scriptFixed epoch inconsistent highlight etc mycache cacheFail expect subset context labels +rm -rf select criteria annotate empty unused_src scriptErr scriptFixed epoch inconsistent highlight etc mycache cacheFail expect subset context labels sortTables clean_cover @@ -51,6 +51,19 @@ elif [ "${VER[0]}" -ge 14 ] ; then COVERAGE_OPTS="-fcondition-coverage" fi +NO_INITIAL_CAPTURE=0 +if [[ "${VER[0]}" -gt 4 && "${VER[0]}" -lt 7 ]] ; then + # no data generated by initial capture + IGNORE_EMPTY="--ignore empty" + NO_INITIAL_CAPTURE=1 +fi + +if [ 1 == $NO_INITIAL_CAPTURE ] ; then + # all test test use --initial + echo 'all tests skipped' + exit 0 +fi + echo `which gcov` echo `which lcov` @@ -285,6 +298,7 @@ if [ 0 != $? ] ; then fi fi + for arg in "--select-script $SELECT_SCRIPT,--range,0:10" \ "--criteria-script $CRITERIA_SCRIPT,--signoff" \ "--annotate-script $ANNOTATE_SCRIPT" \ @@ -319,6 +333,23 @@ for arg in "--select-script $SELECT_SCRIPT,--range,0:10" \ fi done +echo genhtml $DIFCOV_OPTS initial.info -o sortTables --sort +$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o sortTables --sort 2>&1 | tee sort.log +if [ 0 != ${PIPESTATUS[0]} ] ; then + echo "ERROR: genhtml --sort failed" + if [ 0 == $KEEP_GOING ] ; then + exit 1 + fi +fi +grep "is deprecated and will be removed" sort.log +if [ 0 != $? ] ; then + echo "ERROR: missing --sort message" + if [ 0 == $KEEP_GOING ] ; then + exit 1 + fi +fi + + echo genhtml $DIFCOV_OPTS initial.info -o p4err --version-script $P4VERSION_SCRIPT,-x $COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o p4err --version-script $P4VERSION_SCRIPT,-x 2>&1 | tee p4err.log if [ 0 == ${PIPESTATUS[0]} ] ; then diff --git a/tests/lcov/add/prune.sh b/tests/lcov/add/prune.sh index d0fce9c1..7ad38ccd 100755 --- a/tests/lcov/add/prune.sh +++ b/tests/lcov/add/prune.sh @@ -1,70 +1,11 @@ #!/usr/bin/env bash +set +x +: ${USER:="$(id -u -n)"} -COVER_DB='cover_db' -LOCAL_COVERAGE=1 -KEEP_GOING=0 -COVER= +source ../../common.tst -echo "LCOV = $LCOV" -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 - echo $LCOV - if [[ $LCOV =~ 'perl' ]] ; then - # cover command already included - don't include again - COVER= - else - COVER="perl -MDevel::Cover=-db,$COVER_DB,-coverage,statement,branch,condition,subroutine " - fi - KEEP_GOING=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 - ;; - - - * ) - echo "Error: unexpected option '$OPT'" - exit 1 - ;; - esac -done - -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 - -if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then - cover -delete +if [[ 1 == $CLEAN_ONLY ]] ; then + exit 0 fi # adding zero does not change anything @@ -90,7 +31,33 @@ fi PRUNED2=`cat prune2` EXP=$(printf "$PART1INFO\n$PART2INFO\n$FULLINFO\n") if [ "$PRUNED2" != "$EXP" ] ; then - echo "Expected '$EXP' - got '$PRUNED2'" + echo "Expected 1 '$EXP' - got '$PRUNED2'" + exit 1 +fi + +# sorting the input changes order so different file is pruned (only 'full' remains) +$COVER $LCOV_TOOL -o prune3s -a $PART1INFO -a $PART2INFO -a $FULLINFO --prune --ignore inconsistent --rc sort_input=1 +if [[ $? != 0 && $KEEP_GOING != 1 ]] ; then + echo "lcov -prune2 failed" + exit 1 +fi +PRUNED3S=`cat prune3s` +EXP2=$(printf "$FULLINFO\n") +if [ "$PRUNED3S" != "$EXP2" ] ; then + echo "Expected 1 '$EXP2' - got '$PRUNED3S'" + exit 1 +fi + +# using the --sort-input flag +$COVER $LCOV_TOOL -o prune3t -a $PART1INFO -a $PART2INFO -a $FULLINFO --prune --ignore inconsistent --sort-input +if [[ $? != 0 && $KEEP_GOING != 1 ]] ; then + echo "lcov -prune2 failed" + exit 1 +fi +PRUNED3T=`cat prune3t` +EXP3=$(printf "$FULLINFO\n") +if [ "$PRUNED3T" != "$EXP3" ] ; then + echo "Expected 2 '$EXP3' - got '$PRUNED3T'" exit 1 fi diff --git a/tests/lcov/exception/exception.sh b/tests/lcov/exception/exception.sh index 73fe55f6..bd03f815 100755 --- a/tests/lcov/exception/exception.sh +++ b/tests/lcov/exception/exception.sh @@ -30,16 +30,18 @@ if [ 0 != $? ] ; then echo "Error: unexpected error from gcc" exit 1 fi +NO_INITIAL_CAPTURE=0 if [[ "${VER[0]}" -gt 4 && "${VER[0]}" -lt 7 ]] ; then # no data generated by initial capture IGNORE_EMPTY="--ignore empty" + NO_INITIAL_CAPTURE=1 fi if [ "${VER[0]}" -lt 8 ] ; then # cannot generate branch data unless 'intermediate' IGNORE_USAGE="--ignore usage" fi $COVER $CAPTURE $LCOV_OPTS --initial -o initial.info $IGNORE_EMPTY $IGNORE_USAGE -if [ 0 != $? ] ; then +if [ $NO_INITIAL_CAPTURE != $? ] ; then echo "Error: unexpected error code from lcov --initial" if [ $KEEP_GOING == 0 ] ; then exit 1 diff --git a/tests/lcov/extract/extract.sh b/tests/lcov/extract/extract.sh index 0f551184..dfa1cc2f 100755 --- a/tests/lcov/extract/extract.sh +++ b/tests/lcov/extract/extract.sh @@ -63,12 +63,13 @@ if [ "${VER[0]}" -lt 8 ] ; then DERIVE_END='--rc derive_function_end_line=0' fi - -$COVER $CAPTURE . $LCOV_OPTS --initial -o initial.info $IGNORE_EMPTY $IGNORE_USAGE -if [ 0 != $? ] ; then - echo "Error: unexpected error code from lcov --initial" - if [ $KEEP_GOING == 0 ] ; then - exit 1 +if [ 1 != $NO_INITIAL_CAPTURE ] ; then + $COVER $CAPTURE . $LCOV_OPTS --initial -o initial.info $IGNORE_EMPTY $IGNORE_USAGE + if [ 0 != $? ] ; then + echo "Error: unexpected error code from lcov --initial" + if [ $KEEP_GOING == 0 ] ; then + exit 1 + fi fi fi @@ -77,16 +78,17 @@ if [ 0 != $? ] ; then echo "Error: unexpected error from gcc" exit 1 fi -# capture 'all' - which will pick up the unused file -$COVER $CAPTURE . $LCOV_OPTS --all -o all_initial.info $IGNORE_EMPTY $IGNORE_USAGE -if [ 0 != $? ] ; then - echo "Error: unexpected error code from lcov --capture --all" - if [ $KEEP_GOING == 0 ] ; then - exit 1 - fi -fi if [ "$NO_INITIAL_CAPTURE" != 1 ] ; then + # capture 'all' - which will pick up the unused file + $COVER $CAPTURE . $LCOV_OPTS --all -o all_initial.info $IGNORE_EMPTY $IGNORE_USAGE + if [ 0 != $? ] ; then + echo "Error: unexpected error code from lcov --capture --all" + if [ $KEEP_GOING == 0 ] ; then + exit 1 + fi + fi + # does the result contain file 'uused' grep -E "SF:.+unused.c$" all_initial.info if [ $? != 0 ] ; then @@ -891,27 +893,29 @@ mkdir -pv ./mytest echo "int main(){}" > './mytest/main space.cpp' ( cd ./mytest ; ${CXX} -c 'main space.cpp' --coverage ) -$COVER $CAPTURE mytest -i -o spaces.info -if [ 0 != $? ] ; then - echo "Error: unexpected error from filename containing space" - if [ $KEEP_GOING == 0 ] ; then - exit 1 +if [ 1 != $NO_INITIAL_CAPTURE ] ; then + $COVER $CAPTURE mytest -i -o spaces.info + if [ 0 != $? ] ; then + echo "Error: unexpected error from filename containing space" + if [ $KEEP_GOING == 0 ] ; then + exit 1 + fi fi -fi -$COVER $LCOV_TOOL --list spaces.info -if [ 0 != $? ] ; then - echo "Error: unable to list filename containing space" - if [ $KEEP_GOING == 0 ] ; then - exit 1 + $COVER $LCOV_TOOL --list spaces.info + if [ 0 != $? ] ; then + echo "Error: unable to list filename containing space" + if [ $KEEP_GOING == 0 ] ; then + exit 1 + fi fi -fi -$COVER $GENHTML_TOOL -o spaces spaces.info -if [ 0 != $? ] ; then - echo "Error: unable to generate HTML for filename containing space" - if [ $KEEP_GOING == 0 ] ; then - exit 1 + $COVER $GENHTML_TOOL -o spaces spaces.info + if [ 0 != $? ] ; then + echo "Error: unable to generate HTML for filename containing space" + if [ $KEEP_GOING == 0 ] ; then + exit 1 + fi fi fi diff --git a/tests/lcov/follow/follow.sh b/tests/lcov/follow/follow.sh index 5ce90393..b3f0a8e2 100755 --- a/tests/lcov/follow/follow.sh +++ b/tests/lcov/follow/follow.sh @@ -11,13 +11,24 @@ if [[ 1 == $CLEAN_ONLY ]] ; then exit 0 fi - LCOV_OPTS="$PARALLEL $PROFILE" # gcc/4.8.5 (and possibly other old versions) generate inconsistent line/function data IFS='.' read -r -a VER <<< `${CC} -dumpversion` if [ "${VER[0]}" -lt 5 ] ; then IGNORE="--ignore inconsistent" fi +NO_INITIAL_CAPTURE=0 +if [[ "${VER[0]}" -gt 4 && "${VER[0]}" -lt 7 ]] ; then + # no data generated by initial capture + IGNORE_EMPTY="--ignore empty" + NO_INITIAL_CAPTURE=1 +fi + +if [ 1 == $NO_INITIAL_CAPTURE ] ; then + # all test test use --initial + echo 'all tests skipped' + exit 0 +fi mkdir -p rundir diff --git a/tests/lcov/initializer/initializer.sh b/tests/lcov/initializer/initializer.sh index 13d5a98e..88096cae 100755 --- a/tests/lcov/initializer/initializer.sh +++ b/tests/lcov/initializer/initializer.sh @@ -26,6 +26,12 @@ if [ "${VER[0]}" -lt 5 ] ; then exit 0 fi +if [[ "${VER[0]}" -lt 8 ]] ; then + # c++17 not supported + echo "no c++ support" + exit 0 +fi + if ! type ${CXX} >/dev/null 2>&1 ; then echo "Missing tool: ${CXX}" >&2 exit 2 diff --git a/tests/lcov/multiple/multiple.sh b/tests/lcov/multiple/multiple.sh index d6f2fec0..8d5d0549 100755 --- a/tests/lcov/multiple/multiple.sh +++ b/tests/lcov/multiple/multiple.sh @@ -9,6 +9,12 @@ IFS='.' read -r -a VER <<< `${CC} -dumpversion` if [ "${VER[0]}" -lt 5 ] ; then IGNORE="--ignore inconsistent" fi +NO_INITIAL_CAPTURE=0 +if [[ "${VER[0]}" -gt 4 && "${VER[0]}" -lt 7 ]] ; then + # no data generated by initial capture + IGNORE_EMPTY="--ignore empty" + NO_INITIAL_CAPTURE=1 +fi rm -rf rundir @@ -30,6 +36,12 @@ echo 'int b (int x) { return x + 2;}' > b/b.c ( cd a ; ${CC} -c --coverage a.c -o a.o ) ( cd b ; ${CC} -c --coverage b.c -o b.o ) +if [ 1 == $NO_INITIAL_CAPTURE ] ; then + # all test test use --initial + echo 'all tests skipped' + exit 0 +fi + $COVER $LCOV_TOOL -o out.info --capture --initial --no-external -d a -d b if [ 0 != $? ] ; then echo "Error: unexpected error code from lcov --initial"