1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#!/usr/bin/env perl
# Copyright (c) MediaTek USA Inc., 2021-2023
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see
# <http://www.gnu.org/licenses/>.
#
# criteria
#
# This script is used as a genhtml "--criteria-script criteria" callback.
# It is called by genhtml at each level of hierarchy - but ignores all but
# the top level, and looks only at line coverage.
#
# Format of the JSON input is:
# {"line":{"found":10,"hit:2,"UNC":2,..},"function":{...},"branch":{}"
# Only non-zero elements are included.
# See the 'criteria-script' section in "man genhtml" for details.
#
# The coverage criteria implemented here is "UNC + LBC + UIC == 0"
# If the criterial is violated, then this script emits a single line message
# to stdout and returns a non-zero exit code.
#
# If passed the "--suppress" flag, this script will exit with status 0,
# even if the coverage criteria is not met.
# genhtml --criteria-script 'path/criteria --signoff' ....
#
# It is not hard to envision much more complicated coverage criteria.
use strict;
use FindBin;
use Getopt::Long;
use lib "$FindBin::RealBin";
use criteria qw(new);
use lib "$FindBin::RealBin/../lib";
use lib "$FindBin::RealBin/../../../lib"; # path from 'support-scripts'
use lcovutil;
my $obj = criteria->new($0, @ARGV);
my $signoff;
if (!defined($obj) ||
!GetOptions('signoff' => \$signoff)) {
print(STDERR "usage: name type json-string [--signoff]\n");
exit(1) if caller;
return undef;
}
my $json = pop(@ARGV);
my $db = JsonSupport::decode($json);
my ($status, $msgs) = $obj->check_criteria(@ARGV, $db);
foreach my $m (@$msgs) {
print($m, "\n");
}
exit $status;
|