1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-19 02:10:57 +02:00
Files
coreutils/tests/tr/build-script

69 lines
1.7 KiB
Plaintext
Raw Normal View History

#!/p/bin/perl -w
1993-03-02 14:10:31 +00:00
1995-11-30 20:26:33 +00:00
$xx = './tr';
1993-03-02 14:10:31 +00:00
$test = 0;
$| = 1;
1995-11-30 20:26:33 +00:00
print "#! /bin/sh\nxx='$xx'\necho testing with $xx=\$xx\nerrors=0\n";
print "$xx --version 2> /dev/null\n";
1994-11-07 04:36:07 +00:00
$expected = '';
$s1 = '';
$input = '';
$flags = '';
$s1 = '';
1993-03-02 14:10:31 +00:00
while (<>)
{
next if (/^\s*#/);
$test++;
chop;
1994-11-07 04:36:07 +00:00
$prog = '($test_name, $input,$flags,$s1,$s2,$expected,$e_ret_code) = ' . $_ . ';';
1993-03-02 14:10:31 +00:00
eval $prog;
1995-11-30 20:26:33 +00:00
if (defined ($seen{$test_name}))
{
die "$0: $.: duplicate test name \`$test_name'\n";
}
$seen{$test_name} = 1;
1995-11-30 20:06:49 +00:00
$in = "t$test_name.in";
$exp_name = 't' . $test_name . '.exp';
$out = "t$test_name.out";
1993-03-02 14:10:31 +00:00
open(IN, ">$in") || die "Couldn't open $in for writing.\n";
print IN $input;
close(IN);
open(EXP, ">$exp_name")
|| die "Couldn't open $exp_name for writing.\n";
print EXP $expected;
close(EXP);
$arg2 = ($s2 ? " '$s2'" : '');
1995-05-16 17:19:46 +00:00
$err_output = "t$test_name.err";
1995-11-30 20:26:33 +00:00
$cmd = "\$xx $flags \'$s1\'$arg2 < $in > $out 2> $err_output";
1993-03-02 14:10:31 +00:00
print <<EOF ;
1995-05-16 17:19:46 +00:00
$cmd
1993-03-02 14:10:31 +00:00
code=\$?
if test \$code != $e_ret_code ; then
1995-11-30 20:26:33 +00:00
echo Test $test_name failed: $xx return code \$code differs from expected value $e_ret_code 1>&2
1993-03-02 14:10:31 +00:00
errors=`expr \$errors + 1`
else
cmp $out $exp_name
case \$? in
1994-11-07 05:38:19 +00:00
0) if test "\$verbose" ; then echo passed $test_name; fi ;; # equal files
1) echo Test $test_name failed: files $out and $exp_name differ 1>&2;
1993-03-02 14:10:31 +00:00
errors=`expr \$errors + 1` ;;
1994-11-07 05:38:19 +00:00
2) echo Test $test_name may have failed. 1>&2;
1993-03-02 14:10:31 +00:00
echo The command \"cmp $out $exp_name\" failed. 1>&2 ;
errors=`expr \$errors + 1` ;;
esac
fi
1995-05-16 17:19:46 +00:00
test -s $err_output || rm -f $err_output
1993-03-02 14:10:31 +00:00
EOF
}
print <<EOF2 ;
if test \$errors = 0 ; then
echo Passed all tests. 1>&2
else
1993-03-02 14:10:31 +00:00
echo Failed \$errors tests. 1>&2
fi
EOF2