diff options
author | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-06-22 05:12:27 +0000 |
---|---|---|
committer | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-06-22 05:12:27 +0000 |
commit | 7cc92b65a3185aa242088d830e166e495674efc9 (patch) | |
tree | 681fe5237612a4e96ce36fb9fabef00042c8ee61 /tests/tools/compare-statistics.pl | |
parent | 37728b8be4d0b3df9da81fdda2198ff55b4b2d91 (diff) |
initial checkin
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@2 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'tests/tools/compare-statistics.pl')
-rwxr-xr-x | tests/tools/compare-statistics.pl | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/tools/compare-statistics.pl b/tests/tools/compare-statistics.pl new file mode 100755 index 00000000..3122c534 --- /dev/null +++ b/tests/tools/compare-statistics.pl @@ -0,0 +1,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; } + |