Guest User

Untitled

a guest
Oct 19th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. cpc () {
  2. if (($# > 5)); then
  3. echo "Function cpc() takes at most 5 parameters."
  4. echo "Usage: cpc src_1 src_2 test_generator test_from test_to"
  5. return
  6. fi
  7.  
  8. echo "Compiling default solution $1."
  9. echo "======================================================================"
  10. g++ -O2 -std=gnu++14 -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic "$1" -o a
  11. echo "======================================================================"
  12. echo "Default solution compiled.\n"
  13.  
  14. if (($# >= 2)); then
  15. echo "Compiling alternative solution $2."
  16. echo "======================================================================"
  17. g++ -O2 -std=gnu++14 -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic "$2" -o b
  18. echo "======================================================================"
  19. echo "Alternative solution compiled.\n"
  20. fi
  21.  
  22. if (($# >= 3)); then
  23. echo "Compiling test generator $3."
  24. echo "======================================================================"
  25. g++ -O2 -std=gnu++14 -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic "$3" -o c
  26. echo "======================================================================"
  27. echo "Test generator compiled.\n"
  28.  
  29. for i in `seq -w $4 $5`; do
  30. ./c >> $i.in
  31. done
  32. fi
  33.  
  34. echo "Checking test cases."
  35. echo "======================================================================"
  36. for i in *.in; do
  37. ./a < $i >> ${i%in}re
  38.  
  39. if (($# >= 2)); then
  40. ./b < $i >> ${i%in}ok
  41. fi
  42.  
  43. diff -u ${i%in}re ${i%in}ok
  44. if [ $? -ne 0 ]; then
  45. echo "Test ${i%.in} failed."
  46. # return
  47. else
  48. echo "Test ${i%.in} passed."
  49. fi
  50. done
  51. echo "======================================================================"
  52.  
  53. rm *.re
  54. rm -f a b c
  55. }
Add Comment
Please, Sign In to add comment