home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2610 / do-test.sh next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1991-01-25  |  1.1 KB  |  54 lines

  1. #!/bin/sh
  2. # sh do-test.sh [min-corruptions(50) [initial-reps(50) [inc(def to 25)]]]
  3.  
  4. if [ "$1" = "-h" ] ; then
  5.   echo "sh do-test.sh [min-corruptions(50) [initial-reps(50) [inc(def to 25)]]]"
  6.   exit
  7. fi
  8. # find an appropriate rep count
  9.  
  10. MIN=${1:-50}
  11. REP=${2:-50}
  12. INC=${3:-25}
  13. trap "rm /tmp/t-$$ ; exit 0" 0
  14. trap "rm /tmp/t-$$ ; exit 1" 1 2 3 15
  15.  
  16. if [ -s test.log ] ; then
  17.   echo "backing up previous test.log to test.log-"
  18.   mv test.log test.log-
  19. fi
  20.  
  21. echo "detail output saved in test.log"
  22. echo "computing min reps in order to get $MIN mixed outputs"
  23. while true ; do
  24.   echo "trying nolock_raw with $REP reps"
  25.   nolock_raw $REP | tee test.log |
  26.   awk '
  27.   $0 ~ /corrupt sequences found$/ { corrupt = $2 }
  28.   END { print corrupt }
  29.   ' - >/tmp/t-$$
  30.   COUNT=`cat /tmp/t-$$`
  31.   if [ $COUNT -lt $MIN ] ; then
  32.     REP=`expr $REP + $INC`
  33.   else
  34.     break;
  35.   fi
  36. done
  37.  
  38. echo "$REP repetions satisfy criterion"
  39. mv test-tmp test-tmp.nolock_raw
  40.  
  41. for x in nolock_buf \
  42.   fcntl_raw fcntl_buf \
  43.   flock_raw flock_buf \
  44.   lockf_raw lockf_buf
  45. do
  46.  if [ -x $x ] ; then
  47.    echo "testing $x"
  48.    echo "" >>test.log
  49.    echo "testing $x" >>test.log
  50.    $x $REP >>test.log
  51.    mv test-tmp test-tmp.$x
  52.  fi
  53. done
  54.