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.

40 lines
851 B

8 months ago
3 years ago
  1. #!/usr/bin/env bash
  2. PROG="Main"
  3. PROG="Main"
  4. [ ! -f *.in ] && echo -e "No input found.\n" && exit 127
  5. # compilation stage.
  6. # using sanitizers to prevent dumb buffer overflows.
  7. make $PROG || exit 1
  8. # diffing program output against actual output.
  9. for i in *.in; do
  10. NAME=$(echo $i | sed "s/.in//g")
  11. echo -e "running test: $NAME \n"
  12. echo -e "INPUT:"
  13. cat $NAME.in
  14. echo -e "\nOUTPUT:"
  15. timeout 2s ./$PROG < $NAME.in > $NAME.res
  16. case $? in
  17. 0)
  18. ;;
  19. 124)
  20. echo -e "TLE.\n"
  21. exit 124
  22. ;;
  23. *)
  24. exit *
  25. ;;
  26. esac
  27. cat $NAME.res
  28. if [ -f $NAME.out ]; then
  29. echo -e "ANSWER:"
  30. cat $NAME.out
  31. echo -e "\nDIFF:"
  32. diff $NAME.res $NAME.out
  33. fi
  34. echo -e "\n___________________________________"
  35. echo -e "\n"
  36. done
  37. exit 0