Advertisement
Pweebs

Untitled

Nov 16th, 2019
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. SRCDIR=https://raw.githubusercontent.com/KohdMonkey/cmps101-pt-f19-grading/master/pa3
  4. NUMTESTS=5
  5. PNTSPERTEST=2
  6. let MAXPTS=$NUMTESTS*$PNTSPERTEST
  7. TIME=5
  8.  
  9. if [ ! -e backup ]; then
  10. mkdir backup
  11. fi
  12.  
  13. cp *.c *.h Makefile backup # copy all files of importance into backup
  14.  
  15. for NUM in $(seq 1 $NUMTESTS); do
  16. curl $SRCDIR/infile$NUM.txt > infile$NUM.txt
  17. curl $SRCDIR/model-outfile$NUM.txt > model-outfile$NUM.txt
  18. rm -f outfile$NUM.txt
  19. done
  20.  
  21.  
  22. rm -f *.o Arithmetic
  23.  
  24. gcc -c -Wall -std=c99 -g Arithmetic.c BigInteger.c List.c
  25. gcc -o Arithmetic Arithmetic.o BigInteger.o List.o
  26.  
  27.  
  28. echo ""
  29. echo ""
  30.  
  31. passed=$(expr 0)
  32. echo "Please be warned that the following tests discard all output to stdout/stderr"
  33. echo "Arithmetic tests: If nothing between '=' signs, then test is passed"
  34. echo "Press enter to continue"
  35. read verbose
  36. for NUM in $(seq 1 $NUMTESTS); do
  37. rm -f outfile$NUM.txt
  38. timeout 10 ./Arithmetic infile$NUM.txt outfile$NUM.txt &> garbage >> garbage #all stdout/stderr thrown away
  39. diff -bBwu outfile$NUM.txt model-outfile$NUM.txt > diff$NUM.txt &>> diff$NUM.txt
  40. echo "Arithmetic Test $NUM:"
  41. echo "=========="
  42. cat diff$NUM.txt
  43. echo "=========="
  44. if [ -e diff$NUM.txt ] && [[ ! -s diff$NUM.txt ]]; then # increment number of tests passed counter
  45. let passed+=1
  46. fi
  47. done
  48.  
  49. echo ""
  50. echo ""
  51.  
  52. timeout 10 valgrind -v --leak-check=full ./Arithmetic infile3.txt outfile3.txt
  53.  
  54. echo ""
  55. echo ""
  56.  
  57. let testspoints=$PNTSPERTEST*$passed
  58. if [ "$testspoints" -gt "$MAXPTS" ]; then # max 10 points
  59. let testspoints=$(expr $MAXPTS)
  60. fi
  61. echo "Passed $passed Arithmetic tests for a total of $testspoints / $MAXPTS points"
  62.  
  63. echo ""
  64. echo ""
  65.  
  66. rm -f *.o Arithmetic garbage diff*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement