competitive programming scripts on Linux
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
907 B

3 years ago
  1. #!/bin/bash
  2. PROG="Main"
  3. # compilation stage.
  4. # using sanitizers to prevent dumb buffer overflows.
  5. make $PROG
  6. if [ $? -ne 0 ]; then
  7. exit 1
  8. fi
  9. # diffing program output against actual output.
  10. for i in *.in; do
  11. name=`echo $i|sed "s/.in//"`
  12. echo -e "running test: $name \n"
  13. echo -e "INPUT:"
  14. cat $name.in
  15. echo -e "\nOUTPUT:"
  16. # clearing the .res files.
  17. if [ -f $name.res ]; then
  18. rm $name.res
  19. fi
  20. touch $name.res
  21. timeout 5s ./$PROG < $name.in > $name.res
  22. if [ $? -eq 124 ]; then
  23. echo -e "time limit exceeded."
  24. rm -rf $name.res
  25. exit 1
  26. fi
  27. if [ $? -ne 0 ]; then
  28. exit 1
  29. fi
  30. cat $name.res
  31. if [ -f $name.out ]; then
  32. echo -e "ANSWER:"
  33. cat $name.out
  34. echo -e "\nDIFF:"
  35. diff $name.res $name.out
  36. fi
  37. echo -e "\n___________________________________"
  38. echo -e "\n"
  39. done
  40. exit 0