tobast

[PetitScala] checkExec.sh

Dec 27th, 2015
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.52 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. score=0
  4. scorePos=0
  5. scoreNeg=0
  6. max=0
  7. maxPos=0
  8. maxNeg=0
  9.  
  10. prgmFail=0
  11.  
  12. echo "Tests positifs (fichiers dans tests/good/)"
  13.  
  14. for f in tests/exec/*.scala; do
  15.     maxPos=`expr $maxPos + 1`;
  16.     echo $f
  17.     ./pscala -o /tmp/pscala_tmp.s "$f" 2>&1 > /dev/null
  18.     out=$?
  19.     if [ -f /tmp/pscala_tmp.s ] ; then
  20.         gcc -o /tmp/pscala_tmp /tmp/pscala_tmp.s 2>&1 > /dev/null
  21.         out=`expr $out + $?`
  22.     fi
  23.     if (( $out > 0 )) ; then
  24.         prgmFail=`expr $prgmFail + 1`;echo "  ECHEC de pscala pour $f"
  25.  
  26.     else
  27.         outfile="`dirname $f`/`basename $f .scala`.out"
  28.         /tmp/pscala_tmp 2>/dev/null | diff - "$outfile" > /dev/null
  29.         if (( $? == 0 )); then
  30.             scorePos=`expr $scorePos + 1`
  31.         else
  32.             echo -e "\tExecution failed or wrong result."
  33.         fi
  34.     fi
  35. done
  36. echo
  37.  
  38. echo "Tests négatifs (fichiers dans tests/bad/)"
  39.  
  40. for f in tests/exec-fail/*.scala ; do
  41.     maxNeg=`expr $maxNeg + 1`;
  42.     echo $f
  43.     ./pscala -o /tmp/pscala_tmp.s "$f" > /dev/null 2>&1
  44.     out=$?
  45.     if [ -f /tmp/pscala_tmp.s ] ; then
  46.         gcc -o /tmp/pscala_tmp /tmp/pscala_tmp.s 2>&1 >/dev/null
  47.         out=`expr $out + $?`
  48.     fi
  49.     if (( $out == 0 )); then
  50.         /tmp/pscala_tmp > /dev/null 2>&1
  51.         if (( $? > 0 )); then
  52.             scoreNeg=`expr $scoreNeg + 1`
  53.         else
  54.             echo "ERREUR: le programme, censé échouer, a terminé correctement."
  55.         fi
  56.     else
  57.         scoreNeg=`expr $scoreNeg + 1`  
  58.     fi
  59. done
  60.  
  61. rm -f /tmp/pscala_tmp{,.s}
  62.  
  63. echo
  64. max=`expr $maxPos + $maxNeg`
  65. score=`expr $scorePos + $scoreNeg`
  66. percent=`expr 100 \* $score / $max`;
  67. echo "Score: $score / $max tests, soit $percent%"
  68. echo "Dont $scorePos / $maxPos positifs, $scoreNeg / $maxNeg négatifs"
Advertisement
Add Comment
Please, Sign In to add comment