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
820 B

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