summaryrefslogtreecommitdiff
path: root/common/tests/get-cov.pl
blob: 273db8509c6a837488514e3e61bfd91194fc867f (plain)
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
#!/usr/bin/perl
#
# Get the list of coverage trace files.
#
use strict;
use warnings;

my $base = shift @ARGV;
my $dir;
my $fail = 0;

# Return truth if the given info file contains at least one trace
# information.
sub not_empty
{
    my $f = shift;
    open FILE, "<$f" or die;
    while (<FILE>)
    {
       if (/^SF:/)
       {
           close FILE;
           return 1;
       }
    }
    close FILE;
    return 0;
}

# Read tests file.
while (<STDIN>)
{
    chomp;
    # Drop comments.
    next if /^\s*(?:#.*)?$/;
    if (/^(.*):(:)?$/)
    {
	# Directory line.
	$dir = $1;
	-d "$base/$dir"
	    or die "cannot change directory";
    }
    elsif (/^cov.*? (.*?): .*$/)
    {
	# Coverage test line.
	my $f = "$base/$dir/obj/$1.info";
	-f $f && not_empty ($f)
	    and print "$f\n";
    }
}