Last active
November 10, 2019 08:31
-
-
Save jw910731/b8481deef55ef40afd1173b38d8a49b5 to your computer and use it in GitHub Desktop.
NPSC Test Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| realpath(){ | |
| echo "$(cd "$(dirname "$1")"; pwd -P)/$(basename "$1")" | |
| } | |
| target="$(cd "$(dirname "$2")"; pwd -P)/$(basename "$2")" | |
| pushd "$1" > /dev/null | |
| BASE_DIR=/var/tmp/judge | |
| if [[ -z "$1" ]]; then | |
| echo argument not set or being blank | |
| exit | |
| fi | |
| if [[ ! -d "$BASE_DIR" ]]; then | |
| mkdir "$BASE_DIR" | |
| mkdir "$BASE_DIR/bin" | |
| mkdir "$BASE_DIR/ans" | |
| fi | |
| test_list=($(ls)) | |
| echo ===Available Tests=== | |
| for key in "${!test_list[@]}"; do | |
| echo "$key"\)"${test_list[$key]}" | |
| done | |
| read choice | |
| pushd "${test_list[$choice]}/data" > /dev/null | |
| pushd "secret" > /dev/null | |
| file_list=($(ls)) | |
| #test_case=() | |
| for key in "${!file_list[@]}"; do | |
| val=${file_list[$key]} | |
| file_name=$(basename -- "$val") | |
| ext="${file_name##*.}" | |
| file_name=$(echo "$file_name" | cut -f 1 -d '.') | |
| if [[ $ext == "ans" ]]; then | |
| test_case+=("$file_name") | |
| fi | |
| done | |
| for key in ${!test_case[@]}; do | |
| val=${test_case[$key]} | |
| cat "$val.in" | time "$target" > "$BASE_DIR/ans/$val.ans" | |
| diff -qEbBw "$val.ans" "$BASE_DIR/ans/$val.ans" | |
| diff -EbBw "$val.ans" "$BASE_DIR/ans/$val.ans" | |
| done | |
| popd > /dev/null | |
| popd > /dev/null | |
| popd > /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment