BASH   61

test exec

Guest on 8th May 2022 07:36:37 AM

  1. #! /bin/sh
  2.  
  3. TESTS="test-smat sh_reg_sim sh_reg_opt sh_reg_count sh_reg_view  \
  4.       sh_reg_plot sh_random"
  5.  
  6. TMPDIR=${TMP-/tmp}/smat$$; rm -rf $TMPDIR; mkdir $TMPDIR || exit 1
  7. trap 'rm -rf $TMPDIR' 0 1 2 15
  8.  
  9. sh_reg_sim () {
  10.     ./test-readlog < test-reg.log | ./smatsim -vt > $TMPDIR/out || return 1
  11.     cmp $TMPDIR/out ans-reg-sim.txt || return 1
  12.     return 0
  13. }
  14. sh_reg_opt () {
  15.     ./test-readlog < test-reg.log | ./smatopt \
  16.         | ./smatview > $TMPDIR/out || return 1
  17.     cmp $TMPDIR/out ans-reg-opt.txt || return 1
  18.     return 0
  19. }
  20. sh_reg_count () {
  21.     ./test-readlog < test-reg.log | ./smatcount -v > $TMPDIR/out || return 1
  22.     cmp $TMPDIR/out ans-reg-count.txt || return 1
  23.     return 0
  24. }
  25. sh_reg_view () {
  26.     ./test-readlog < test-reg.log | ./smatview -v > $TMPDIR/out || return 1
  27.     cmp $TMPDIR/out test-reg.log || return 1
  28.     return 0
  29. }
  30. sh_reg_plot () {
  31.     ./test-readlog < test-reg.log | ./smatplot -a > $TMPDIR/out || return 1
  32.     cmp $TMPDIR/out ans-reg-plot.txt || return 1
  33.     return 0
  34. }
  35. sh_random () {
  36.   ./test-random > $TMPDIR/out || return 1
  37.   cmp $TMPDIR/out ans-random.txt || return 1
  38.   return 0
  39. }
  40.  
  41. failed=0; all=0; for tst in $TESTS; do
  42.   if test -f ./$tst; then tst=./$tst; fi
  43.   if $tst > /dev/null; then all=`expr $all + 1`; echo "PASS: $tst";
  44.   elif test $? -ne 77; then all=`expr $all + 1`; failed=`expr $failed + 1`;
  45.   echo "FAIL: $tst"; fi;
  46. done;
  47. if test "$failed" -eq 0; then banner="All $all tests passed";
  48. else banner="$failed of $all tests failed"; fi;
  49. dashes=`echo "$banner" | sed s/./=/g`;
  50. echo "$dashes"; echo "$banner"; echo "$dashes"; test "$failed" -eq 0

Raw Paste


Login or Register to edit or fork this paste. It's free.