diff --git a/main.sh b/main.sh old mode 100644 new mode 100755 index 0efab7c0..0f0bb0ea --- a/main.sh +++ b/main.sh @@ -1,21 +1,36 @@ -BENCHMARK="$1" - -cd "$(dirname "$0")/$BENCHMARK" || exit 1 - error() { echo "Error: $1" > /dev/stderr exit 1 } -# Download dependencies -./deps.sh || error "Failed to download dependencies for $BENCHMARK" +correct() { [ "$(cat $BENCHMARK.hash | cut -d' ' -f 2 | grep -c 1)" -eq 0 ]; } + +main() +{ + cd "$(dirname "$0")/$BENCHMARK" || exit 1 + # Download dependencies + ./deps.sh $@ || error "Failed to download dependencies for $BENCHMARK" + + # Fetch inputs + ./inputs.sh $@ || error "Failed to fetch inputs for $BENCHMARK" -# Fetch inputs -./input.sh || error "Failed to fetch inputs for $BENCHMARK" + # Run benchmark + ( ./run.sh $@ > $BENCHMARK.out 2> $BENCHMARK.err ) || error "Failed to run $BENCHMARK" + + # Verify output + ./verify.sh $@ > $BENCHMARK.hash || error "Failed to verify output for $BENCHMARK" + + if correct; then + echo "$BENCHMARK [pass]" + else + error "$BENCHMARK [fail]" + fi + + cd - || exit 1 +} -# Run benchmark -./run.sh > $BENCHMARK.out 2> $BENCHMARK.err || error "Failed to run $BENCHMARK" +export BENCHMARK="$1" +shift -# Verify output -./verify.sh > $BENCHMARK.hash || error "Failed to verify output for $BENCHMARK" +main $@