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.

39 lines
831 B

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