Skip to content

Commit b559492

Browse files
authored
Add some error checking to 'select.pm' callback: (linux-test-project#453)
check that annotation and diff prerequisites are present and generate 'select' criteria application count. Goal is to aid user debugging - e.g., for typos in selection criteria: "why does my expected data not appear in the report?" Signed-off-by: Henry Cox <henry.cox@mediatek.com>
1 parent 5d08038 commit b559492

File tree

7 files changed

+297
-67
lines changed

7 files changed

+297
-67
lines changed

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,7 @@ test: check
267267
# once without - so we can merge the result
268268
check:
269269
if [ "x$(COVERAGE)" != 'x' ] ; then \
270-
if [ ! -d $(COVER_DB) ]; then \
271-
mkdir $(COVER_DB) ; \
272-
fi ; \
270+
mkdir -p $(COVER_DB) ; \
273271
echo "*** Run once, force parallel ***" ; \
274272
LCOV_FORCE_PARALLEL=1 $(MAKE) -s -C tests check LCOV_HOME=`pwd` ; \
275273
echo "*** Run again, no force ***" ; \
@@ -279,6 +277,10 @@ check:
279277
$(MAKE) -s -C example LCOV_HOME=`pwd`; \
280278
$(MAKE) -s -C tests report ; \
281279
fi
280+
grep uninitialized tests/test.log ; \
281+
if [ 1 != $$? ] ; then \
282+
echo "found 'uninitialized'" ; \
283+
fi
282284

283285
# Files to be checked for coding style issue issues -
284286
# - anything containing "#!/usr/bin/env perl" or the like

bin/genhtml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7538,11 +7538,17 @@ sub print_overall_rate($$$$$$)
75387538
my $plural = "ch" eq substr($name, -2, 2) ? "es" : "s";
75397539
my $label = "$name$plural";
75407540
my $fill = '.' x ($width - length($label));
7541+
my $found = $summary->get("found", $type);
7542+
# user was confused about why there was no coverage data
7543+
my $explain =
7544+
($type == SummaryInfo::LINE_DATA &&
7545+
0 == $found &&
7546+
$SummaryInfo::selectCallback) ?
7547+
" (your '--select-script' criteria may not match any coverpoints)" :
7548+
'';
75417549
info(-1,
7542-
" $name$plural$fill: %s\n",
7543-
get_overall_line($summary->get("found", $type),
7544-
$summary->get("hit", $type),
7545-
$name));
7550+
" $name$plural$fill: %s$explain\n",
7551+
get_overall_line($found, $summary->get("hit", $type), $name));
75467552
if ($main::show_tla) {
75477553
for my $tla (@SummaryInfo::tlaPriorityOrder) {
75487554
my $v = $summary->get($tla, $type);

man/genhtml.1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,12 @@ to a shell interpreter to be executed.
639639
The command line includes the script path followed by optional additional parameters
640640
separated by spaces. Care must be taken to provide proper quoting if script
641641
path or any parameter contains spaces or shell special characters.
642+
.br
643+
Note that module callbacks must be called via the 'list' method: they cannot be called as an executable with a space-separated set of arguments.
644+
.br
645+
For convenience: your callback module may need to implement its own
646+
'split_char' so that you can pass multiple parameters to your callback
647+
without interacting with genhtml's split mechanism.
642648
.PP
643649

644650
.IP 3. 3

scripts/criteria.pm

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ use Getopt::Long qw(GetOptionsFromArray);
4747
our @ISA = qw(Exporter);
4848
our @EXPORT_OK = qw(new);
4949

50-
use constant {SIGNOFF => 0,
51-
TYPES =>1,};
50+
use constant {
51+
SIGNOFF => 0,
52+
TYPES => 1,
53+
};
5254

5355
sub new
5456
{
@@ -57,27 +59,28 @@ sub new
5759
my $script = shift;
5860
my $standalone = $script eq $0;
5961
my @options = @_;
60-
my $function = 0;
61-
my $branch = 0;
62-
my $mcdc = 0;
62+
my $function = 0;
63+
my $branch = 0;
64+
my $mcdc = 0;
6365

64-
if (!GetOptionsFromArray(\@_, ('signoff' => \$signoff,
65-
'function' => \$function,
66-
'branch' => \$branch,
67-
'mcdc' => \$mcdc,
68-
)) ||
69-
(!$standalone && @_)) {
66+
if (!GetOptionsFromArray(\@_,
67+
('signoff' => \$signoff,
68+
'function' => \$function,
69+
'branch' => \$branch,
70+
'mcdc' => \$mcdc,)) ||
71+
(!$standalone && @_)
72+
) {
7073
print(STDERR "Error: unexpected option:\n " .
71-
join(' ', @options) .
72-
"\nusage: name type json-string [--signoff] [--branch] [--mcdc] [--function]\n");
74+
join(' ', @options) .
75+
"\nusage: name type json-string [--signoff] [--branch] [--mcdc] [--function]\n"
76+
);
7377
exit(1) if $standalone;
7478
return undef;
7579
}
7680
my @types = ('line');
77-
foreach my $t (['function', $function],
78-
['MC/DC', $mcdc],
79-
['branch', $branch]) {
80-
push(@types, $t->[0]) if $t->[1];
81+
foreach
82+
my $t (['function', $function], ['MC/DC', $mcdc], ['branch', $branch]) {
83+
push(@types, $t->[0]) if $t->[1];
8184
}
8285
my $self = [$signoff, \@types];
8386
return bless $self, $class;
@@ -92,20 +95,20 @@ sub check_criteria
9295
if ($type eq 'top') {
9396
# for the moment - only worry about the top-level coverage
9497

95-
my $s = '';
96-
foreach my $t (@{$self->[TYPES]}) {
97-
next unless exists($db->{$t});
98+
my $s = '';
99+
foreach my $t (@{$self->[TYPES]}) {
100+
next unless exists($db->{$t});
98101

99102
# our criteria is LBC + UNC + UIC == 0
100103
my $sep = '';
101104
my $sum = 0;
102105
my $msg = '';
103106
my $counts = '';
104-
my $data = $db->{$t};
105-
# say which type - if there is more than one
106-
$msg .= "$s$t: " if 1 <= $#{$self->[TYPES]};
107-
$s = ' ';
108-
107+
my $data = $db->{$t};
108+
# say which type - if there is more than one
109+
$msg .= "$s$t: " if 1 <= $#{$self->[TYPES]};
110+
$s = ' ';
111+
109112
foreach my $tla ('UNC', 'LBC', 'UIC') {
110113
$msg .= $sep . $tla;
111114
$counts .= $sep;

0 commit comments

Comments
 (0)