From d22d42e54363e1cc264c203189838f54bb5a2421 Mon Sep 17 00:00:00 2001 From: Yiyang Wu Date: Tue, 29 Oct 2024 11:35:00 +0800 Subject: [PATCH] fix: add checks around return code 255 Signed-off-by: Yiyang Wu --- Scripts/capturer.py | 2 +- Scripts/extras/lab5/grader.sh | 16 ++++++++++++++++ Scripts/grader.sh | 6 ++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Scripts/capturer.py b/Scripts/capturer.py index 2124f42d..e3d24437 100755 --- a/Scripts/capturer.py +++ b/Scripts/capturer.py @@ -11,7 +11,7 @@ print( "This script requires Python version 3.7 and later. Please upgrade your Python version to grade this lab." ) - sys.exit(0) + sys.exit(255) try: import psutil diff --git a/Scripts/extras/lab5/grader.sh b/Scripts/extras/lab5/grader.sh index e9cc11bc..21ac0e0c 100755 --- a/Scripts/extras/lab5/grader.sh +++ b/Scripts/extras/lab5/grader.sh @@ -25,21 +25,37 @@ cp "${CMAKE_EXTRA_DIR}/cmake-fsm-full.txt" "${FSM_DIR}/CMakeLists.txt" cp "${CMAKE_EXTRA_DIR}/cmake-fs_base-part1.txt" "${FS_BASE_DIR}/CMakeLists.txt" ${SCRIPTS}/capturer.py -f ${LABDIR}/scores-part1.json -t 30 make qemu-grade 2> /dev/null score=$(($score+$?)) +if [[ $score -eq 255 ]]; then + error "Something went wrong. Please check the output of your program" + exit 0 +fi # Part2 VNode cp "${CMAKE_EXTRA_DIR}/cmake-fsm-part2.txt" "${FSM_DIR}/CMakeLists.txt" cp "${CMAKE_EXTRA_DIR}/cmake-fs_base-part2-vnode.txt" "${FS_BASE_DIR}/CMakeLists.txt" ${SCRIPTS}/capturer.py -f ${LABDIR}/scores-part2.json -t 30 make qemu-grade 2> /dev/null score=$(($score+$?)) +if [[ $score -eq 255 ]]; then + error "Something went wrong. Please check the output of your program" + exit 0 +fi # Part3 Server Entry cp "${CMAKE_EXTRA_DIR}/cmake-fsm-part2.txt" "${FSM_DIR}/CMakeLists.txt" cp "${CMAKE_EXTRA_DIR}/cmake-fs_base-part2-server_entry.txt" "${FS_BASE_DIR}/CMakeLists.txt" ${SCRIPTS}/capturer.py -f ${LABDIR}/scores-part3.json -t 30 make qemu-grade 2> /dev/null score=$(($score+$?)) +if [[ $score -eq 255 ]]; then + error "Something went wrong. Please check the output of your program" + exit 0 +fi # Part4 Ops mv "${FSM_DIR}/CMakeLists.txt.bak" "${FSM_DIR}/CMakeLists.txt" mv "${FS_BASE_DIR}/CMakeLists.txt.bak" "${FS_BASE_DIR}/CMakeLists.txt" ${SCRIPTS}/capturer.py -f ${LABDIR}/scores-part4.json -t 30 make qemu-grade 2> /dev/null score=$(($score+$?)) +if [[ $score -eq 255 ]]; then + error "Something went wrong. Please check the output of your program" + exit 0 +fi info "Score: $score/100" bold "===========================================" diff --git a/Scripts/grader.sh b/Scripts/grader.sh index 4993a7f4..c76dcd86 100755 --- a/Scripts/grader.sh +++ b/Scripts/grader.sh @@ -14,6 +14,12 @@ info "Grading lab ${LAB} ...(may take ${TIMEOUT} seconds)" bold "===========================================" ${LABROOT}/Scripts/capturer.py $@ 2> /dev/null score=$? + +if [[ $score -eq 255 ]]; then + error "Something went wrong. Please check the output of your program" + exit 0 +fi + info "Score: $score/100" bold "==========================================="