《操作系统》的实验代码。
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.

65 lines
1.4 KiB

  1. #!/bin/bash
  2. # change working dir to where this script resides in
  3. pushd `dirname "$0"` > /dev/null
  4. if [ -n "$1" ]; then
  5. RESULT_SAVETO=""
  6. fi
  7. BASE_COMMIT=1d8c85670d03ce745e32bbc57147835b210fe560
  8. if [ -n "$2" ] && git log $2 > /dev/null 2>&1; then
  9. BASE_COMMIT=$2
  10. elif ! git log $BASE_COMMIT > /dev/null 2>&1; then
  11. echo "No valid base commit found."
  12. exit 0
  13. fi
  14. LABS=`git diff $BASE_COMMIT --stat | grep -o "lab[1-8]" | sort | uniq`
  15. COMMIT=`git rev-parse HEAD`
  16. if [ "$LABS" = "" ]; then
  17. echo "No updated lab found. Skip."
  18. exit 0
  19. fi
  20. failed=0
  21. pwd=`pwd`
  22. summary=$pwd/.score_summary
  23. echo -n > $summary
  24. for lab in $LABS; do
  25. pushd $lab > /dev/null
  26. if ! make grade > .score 2>&1; then
  27. failed=`echo $lab | grep -o [0-9]`
  28. fi
  29. if [ -n "$RESULT_SAVETO" ]; then
  30. mkdir -p $RESULT_SAVETO/$COMMIT/$lab
  31. mv .score .score_orig
  32. ../tools/split_score_log.py .score_orig > .score
  33. for i in .*.log .*.error; do
  34. cp $i $RESULT_SAVETO/$COMMIT/$lab/${i#.}
  35. done
  36. fi
  37. score=`egrep -o "Score: [0-9]+/[0-9]+" .score`
  38. echo "$lab $score" >> $summary
  39. make clean > /dev/null
  40. popd > /dev/null
  41. done
  42. echo "Labs with changes detected: " $LABS
  43. echo
  44. echo "============================== Summary =============================="
  45. cat $summary
  46. rm $summary
  47. echo
  48. for lab in $LABS; do
  49. echo "================================ $lab ==============================="
  50. cat $lab/.score
  51. done
  52. find . -name '.*' -delete
  53. popd > /dev/null
  54. exit $failed