blob: 3122c534086e2dca77950f436e326f57b08e8b1f (
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
|
#!/usr/bin/perl -w
use strict;
die "Usage: $0 gold.statistics < test.statistics\n" unless scalar @ARGV == 1;
my $gold_file = shift @ARGV;
open G, "<$gold_file" or die "Can't read $gold_file: $!";
my @gold_keys = ();
my @gold_vals = ();
while(<G>) {
chomp;
if (/^([^ ]+)\s*(.*)$/) {
push @gold_keys, $1;
push @gold_vals, $2;
} else {
die "Unexpected line in $gold_file: $_\n";
}
}
my $sc = 0;
my $MATCH = 0;
my $MISMATCH = 0;
while(<>) {
my $gold_key = $gold_keys[$sc];
my $gold_val = $gold_vals[$sc];
$sc++;
if (/^([^ ]+)\s*(.*)$/) {
my $test_key = $1;
my $test_val = $2;
if ($test_key ne $gold_key) {
die "Missing key in output! Expected '$gold_key' but got '$test_key'\n";
}
if ($gold_val ne 'IGNORE') {
if ($gold_val eq $test_val) { $MATCH++; } else {
$MISMATCH++;
print STDERR "[VALUE FAILURE] key: '$gold_key'\n expected value: '$gold_val'\n actual value: '$test_val'\n";
}
}
} else {
die "Unexpected line in test data: $_\n";
}
}
my $TOT = $MISMATCH + $MATCH;
print "$MATCH $TOT\n";
if ($MISMATCH > 0) { exit 1; } else { exit 0; }
|