| 1 |
#!/usr/bin/perl |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
use Cwd qw(realpath); |
| 5 |
|
| 6 |
my ($bindir, $sep) = $0 =~ /^(.*)(\\|\/).*/; |
| 7 |
$bindir = realpath $bindir; |
| 8 |
chdir $bindir or die("Error: Could not change directory to $bindir !"); |
| 9 |
|
| 10 |
my $binary_comp = $ARGV[0]; |
| 11 |
$binary_comp =~ s@/vislcg3([^/]*)$@/cg-comp$1@; |
| 12 |
if (!$binary_comp || $binary_comp eq '' || !(-x $binary_comp)) { |
| 13 |
die("Error: $binary_comp is not executable!"); |
| 14 |
} |
| 15 |
|
| 16 |
my $binary_relabel = $ARGV[0]; |
| 17 |
$binary_relabel =~ s@/vislcg3([^/]*)$@/cg-relabel$1@; |
| 18 |
if (!$binary_relabel || $binary_relabel eq '' || !(-x $binary_relabel)) { |
| 19 |
die("Error: $binary_relabel is not executable!"); |
| 20 |
} |
| 21 |
|
| 22 |
my $binary_proc = $ARGV[0]; |
| 23 |
if (!$binary_proc || $binary_proc eq '' || !(-x $binary_proc)) { |
| 24 |
die("Error: $binary_proc is not executable!"); |
| 25 |
} |
| 26 |
|
| 27 |
my @unlinks = ( |
| 28 |
'grammar.cg3b', |
| 29 |
'grammar-out.cg3b', |
| 30 |
); |
| 31 |
for my $u (@unlinks) { |
| 32 |
if (-e $u) { |
| 33 |
unlink $u; |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
my $bad = 0; |
| 38 |
|
| 39 |
`"$binary_comp" grammar.cg3 grammar.cg3b >stdout.txt 2>stderr.txt`; |
| 40 |
`"$binary_relabel" grammar.cg3b relabel.cg3r grammar-out.cg3b >>stdout.txt 2>>stderr.txt`; |
| 41 |
|
| 42 |
if (-s "grammar.cg3b" && -s "grammar-out.cg3b") { |
| 43 |
print STDERR "Success "; |
| 44 |
} else { |
| 45 |
print STDERR "Fail "; |
| 46 |
$bad = 1; |
| 47 |
} |
| 48 |
|
| 49 |
`"$binary_proc" -g grammar-out.cg3b -I input.txt -O output.txt 2>>stderr.txt`; |
| 50 |
`diff -B expected.txt output.txt >diff.txt`; |
| 51 |
|
| 52 |
if (-s "diff.txt") { |
| 53 |
print STDERR "Fail\n"; |
| 54 |
$bad = 1; |
| 55 |
} else { |
| 56 |
print STDERR "Success\n"; |
| 57 |
} |
| 58 |
|
| 59 |
exit($bad); |