diff options
author | Jim Meyering <jim@meyering.net> | 1995-07-27 14:43:01 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1995-07-27 14:43:01 +0000 |
commit | 7e93c0f64b24e2aab9194ad73f513d112c201477 (patch) | |
tree | 9ab87595f97fc24f47c8416c733c1d07739c4aab /tests/sort/build-script | |
parent | 1126d3b93e118d3af0966dd64ce5f787d8bb0a04 (diff) | |
download | coreutils-7e93c0f64b24e2aab9194ad73f513d112c201477.tar.xz |
Initial revision
Diffstat (limited to 'tests/sort/build-script')
-rwxr-xr-x | tests/sort/build-script | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/sort/build-script b/tests/sort/build-script new file mode 100755 index 000000000..230a3fad9 --- /dev/null +++ b/tests/sort/build-script @@ -0,0 +1,64 @@ +#!/p/bin/perl -w + +$sort = './sort'; +$test = 0; +$| = 1; + +print "#! /bin/sh\nsort='$sort'\necho testing with sort=\$sort\nerrors=0\n"; +$expected = ''; +$input = ''; +$options = ''; + +while (<>) + { + next if (/^\s*#/); + + $test++; + chop; + $prog = '($test_name, $options,$input,$expected,$e_ret_code) = ' . $_ . ';'; + eval $prog; + if (defined ($seen{$test_name})) + { + die "$0: $.: duplicate test name \`$test_name'\n"; + } + $seen{$test_name} = 1; + $in = "t$test_name.in"; + $exp_name = 't' . $test_name . '.exp'; + $out = "t$test_name.out"; + + 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); + $err_output = "t$test_name.err"; + $cmd = "\$sort $options $in > $out 2> $err_output"; + print <<EOF ; +$cmd +code=\$? +if test \$code != $e_ret_code ; then + echo Test $test_name failed: sort return code \$code differs from expected value $e_ret_code 1>&2 + errors=`expr \$errors + 1` +else + cmp $out $exp_name + case \$? in + 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; + errors=`expr \$errors + 1` ;; + 2) echo Test $test_name may have failed. 1>&2; + echo The command \"cmp $out $exp_name\" failed. 1>&2 ; + errors=`expr \$errors + 1` ;; + esac +fi +test -s $err_output || rm -f $err_output +EOF + } +print <<EOF2 ; +if test \$errors = 0 ; then + echo Passed all tests. 1>&2 +else + echo Failed \$errors tests. 1>&2 +fi +EOF2 |