BASH   35

test sort

Guest on 8th May 2022 07:33:08 AM

  1. #! /bin/sh
  2.  
  3. echo_n='echo -n'
  4. if [ -x /usr/ucb/echo ]; then echo_n='/usr/ucb/echo -n'; fi
  5.  
  6. TMPDIR=${TMP-/tmp}/smat$$; rm -rf $TMPDIR; mkdir $TMPDIR || exit 1
  7. trap 'rm -rf $TMPDIR' 0 1 2 15
  8.  
  9. failed () {
  10.     echo;
  11.     if [ -f $TMPDIR/out ]; then
  12.         SEED=`cat $TMPDIR/out | awk '{print $2}'`
  13.         echo "error found when executing \"./stlsort -s $SEED $algo $NELEM\""
  14.         exit 1
  15.     fi
  16.     exit 0
  17. }
  18.  
  19. for algo in early lomuto tiled; do
  20.     $echo_n "Testing $algo"
  21.     for N in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
  22.         NELEM=`./stlsort -S i 0 2>&1 >/dev/null | awk '{printf "%d\n", $2 % 5000}'`
  23.         ./stlsort -S $algo $NELEM 2>$TMPDIR/out 1>/dev/null || failed
  24.          $echo_n .
  25.     done
  26.     echo ' ok'
  27. done
  28.  
  29. exit 0

Raw Paste


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