| 1 | #!/usr/bin/perl |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use warnings; |
|---|
| 5 | |
|---|
| 6 | my $ARBHOME = $ENV{ARBHOME}; |
|---|
| 7 | if (not defined $ARBHOME) { die "environment variable 'ARBHOME' is not defined"; } |
|---|
| 8 | |
|---|
| 9 | my %locs = (); |
|---|
| 10 | sub get_loc($) { |
|---|
| 11 | my ($makevar) = @_; |
|---|
| 12 | |
|---|
| 13 | my $loc = $locs{$makevar}; |
|---|
| 14 | if (not defined $loc) { |
|---|
| 15 | my $makefile = $ARBHOME.'/Makefile'; |
|---|
| 16 | open(IN,'<'.$makefile) || die "cannot read $makefile"; |
|---|
| 17 | |
|---|
| 18 | my $reg = qr/$makevar/; |
|---|
| 19 | my $line; |
|---|
| 20 | LINE: while (defined($line=<IN>)) { |
|---|
| 21 | if ($line =~ $reg) { |
|---|
| 22 | if (not $line =~ /^\s*\#/o) { |
|---|
| 23 | $locs{$makevar} = $loc = $.; |
|---|
| 24 | last LINE; |
|---|
| 25 | } |
|---|
| 26 | } |
|---|
| 27 | } |
|---|
| 28 | close(IN); |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | return "Makefile:$loc"; |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | sub main() { |
|---|
| 35 | my $args = scalar(@ARGV); |
|---|
| 36 | if ($args<1) { |
|---|
| 37 | print "Usage: list_undefined_units.pl [defined*] -- [archives*]\n"; |
|---|
| 38 | print "detects inconsistencies in listed testunits\n"; |
|---|
| 39 | } |
|---|
| 40 | else { |
|---|
| 41 | my @def = (); |
|---|
| 42 | |
|---|
| 43 | while (scalar(@ARGV) and ($ARGV[0] ne '--')) { |
|---|
| 44 | push @def, shift @ARGV; |
|---|
| 45 | } |
|---|
| 46 | if (not ((scalar(@ARGV)>0) and ($ARGV[0] eq '--'))) { |
|---|
| 47 | die "expected to see argument '--'"; |
|---|
| 48 | } |
|---|
| 49 | shift @ARGV; # drop '--' |
|---|
| 50 | |
|---|
| 51 | my @arch = @ARGV; |
|---|
| 52 | |
|---|
| 53 | my %def = map { $_ => 1; } @def; |
|---|
| 54 | my %arch = map { $_ => 1; } @arch; |
|---|
| 55 | |
|---|
| 56 | my @both = sort ( @arch, @def ); |
|---|
| 57 | |
|---|
| 58 | foreach my $unit (@both) { |
|---|
| 59 | if (exists $arch{$unit}) { |
|---|
| 60 | if (not exists $def{$unit}) { |
|---|
| 61 | my $manual_loc = get_loc('DEFINED_TEST_UNITS'); |
|---|
| 62 | print "${manual_loc}: Warning: $unit not listed in DEFINED_TEST_UNITS (manual lists)\n"; |
|---|
| 63 | } |
|---|
| 64 | # else ok |
|---|
| 65 | } |
|---|
| 66 | elsif (exists $def{$unit}) { |
|---|
| 67 | my $auto_loc = get_loc('TESTED_UNITS_AUTO'); |
|---|
| 68 | print "${auto_loc}: Warning: $unit not listed in TESTED_UNITS_AUTO (detected archives)\n"; |
|---|
| 69 | } |
|---|
| 70 | else { |
|---|
| 71 | die; |
|---|
| 72 | } |
|---|
| 73 | } |
|---|
| 74 | } |
|---|
| 75 | } |
|---|
| 76 | main(); |
|---|