Advertisement
Slapoguzov

Untitled

Feb 11th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.18 KB | None | 0 0
  1. #!/usr/bin/bash +H
  2. # 2'nd labwork
  3. # ./2 variant current_testing_script
  4.  
  5. # dir w/ results for all labs
  6. #TESTDIR=/usr/local/labtest/lab_2/
  7. TESTDIR=d/
  8.  
  9. panic(){ echo "error: $* " >&2 ;exit 1 ;}
  10.  
  11. cd -- "$TESTDIR/${1:-variant}/" || panic no such dir
  12. for arg in `/usr/xpg4/bin/ls -aq` ;do
  13.    case $arg in
  14.       .|..) continue ;;
  15.       NULL) unset arg ;;
  16.       *SPACE*) arg=${arg//SPACE/ } ;;
  17.       *TAB*) arg=${arg//TAB/    } ;;
  18.    esac
  19.  
  20.    OUT=$HOME/test_$arg.out
  21.    ERR=$HOME/test_$arg.err
  22.  
  23.    /usr/bin/echo "\"${2:?no script}\" \"$arg\" > \"$OUT\" 2> \"$ERR\" "
  24.  
  25.    [ -f "$HOME/test_$arg.out" ] || panic no output file
  26.    [ -f "$HOME/test_$arg.err" ] || panic no errors file
  27.  
  28.    # here is diff check w/ $arg/out & $arg/err
  29.    diff "$TESTDIR/$1/$arg/err" $ERR &> /dev/null
  30.    result_diff=$?;
  31.  
  32.    diff "$TESTDIR/$1/$arg/out" $OUT &> /dev/null
  33.    result_diff+=$?;
  34.  
  35.    [ $result_diff -eq 0 ] || { /usr/bin/echo "The result of a script with \"$arg\" argument is incorrect"; exit 0; }
  36.  
  37.    # exit if differs, so they willn't be deleted
  38.    /usr/bin/echo "/usr/xpg4/bin/rm -- \"$HOME/test_$arg\".{out,err} "
  39. done
  40. /usr/bin/echo "The result of a script with all arguments is correct"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement