| 1 |
#!/usr/bin/perl |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
use Cwd qw(realpath); |
| 5 |
|
| 6 |
if (exists($ENV{'WINDIR'})) { |
| 7 |
print STDERR "Skipped on Windows.\n"; |
| 8 |
exit(0); |
| 9 |
} |
| 10 |
|
| 11 |
my ($bindir, $sep) = $0 =~ /^(.*)(\\|\/).*/; |
| 12 |
$bindir = realpath $bindir; |
| 13 |
chdir $bindir or die("Error: Could not change directory to $bindir !"); |
| 14 |
|
| 15 |
my $binary = $ARGV[0]; |
| 16 |
if (!$binary || $binary eq '' || !(-x $binary)) { |
| 17 |
die("Error: $binary is not executable!"); |
| 18 |
} |
| 19 |
|
| 20 |
my $bad = 0; |
| 21 |
|
| 22 |
`"$binary" $ARGV[1] -g grammar.cg3 -I input.txt -O output.txt >stdout.txt 2>stderr.txt`; |
| 23 |
`diff -B expected.txt output.txt >diff.txt`; |
| 24 |
|
| 25 |
if (-s "diff.txt") { |
| 26 |
print STDERR "Fail "; |
| 27 |
$bad = 1; |
| 28 |
} else { |
| 29 |
print STDERR "Success "; |
| 30 |
} |
| 31 |
|
| 32 |
`"$binary" $ARGV[1] -g grammar.cg3 --grammar-only --grammar-bin grammar.cg3b >stdout.bin.txt 2>stderr.bin.txt`; |
| 33 |
`"$binary" $ARGV[1] -g grammar.cg3b -I input.txt -O output.bin.txt >>stdout.bin.txt 2>>stderr.bin.txt`; |
| 34 |
`diff -B expected.txt output.bin.txt >diff.bin.txt`; |
| 35 |
|
| 36 |
if (-s "diff.bin.txt") { |
| 37 |
print STDERR "Fail\n"; |
| 38 |
$bad = 1; |
| 39 |
} else { |
| 40 |
print STDERR "Success\n"; |
| 41 |
} |
| 42 |
|
| 43 |
exit($bad); |