Files
tatu/sim/scripts/run_privileged_tests.sh
2026-06-29 07:00:55 +00:00

76 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
set -u
TESTBENCH="../verilator/obj_dir/VCore"
TESTS_DIR="../../riscv-tests/isa"
RESULTS_DIR="../results"
RESULTS_FILE="$RESULTS_DIR/privileged_test_results.txt"
TIMEOUT_SECONDS="${TIMEOUT_SECONDS:-5}"
mkdir -p "$RESULTS_DIR"
if [ ! -x "$TESTBENCH" ]; then
echo "Error: Testbench not found. Run 'make -C sim/verilator compile' first."
exit 1
fi
echo "Running privileged RISC-V tests..." > "$RESULTS_FILE"
echo "=================================" >> "$RESULTS_FILE"
PASS=0
FAIL=0
TIMEOUT=0
shopt -s nullglob
tests=(
"$TESTS_DIR"/rv64mi-p-*
"$TESTS_DIR"/rv64si-p-*
"$TESTS_DIR"/rv64ui-p-fence_i
)
for test in "${tests[@]}"; do
[[ "$test" == *.dump ]] && continue
[ ! -f "$test" ] && continue
testname=$(basename "$test")
printf "Running %s... " "$testname"
output=$(timeout "${TIMEOUT_SECONDS}s" "$TESTBENCH" "$test" 2>&1)
exitcode=$?
if [ "$exitcode" -eq 0 ]; then
echo "PASS"
echo "$testname: exit=0 PASS" >> "$RESULTS_FILE"
PASS=$((PASS + 1))
elif [ "$exitcode" -eq 124 ]; then
echo "TIMEOUT"
echo "$testname: exit=124 TIMEOUT" >> "$RESULTS_FILE"
TIMEOUT=$((TIMEOUT + 1))
else
echo "FAIL (exit code $exitcode)"
echo "$testname: exit=$exitcode FAIL" >> "$RESULTS_FILE"
printf '%s\n' "$output" >> "$RESULTS_FILE"
FAIL=$((FAIL + 1))
fi
done
TOTAL=$((PASS + FAIL + TIMEOUT))
{
echo ""
echo "================================="
echo "Summary:"
echo " PASS: $PASS"
echo " FAIL: $FAIL"
echo " TIMEOUT: $TIMEOUT"
echo " TOTAL: $TOTAL"
} >> "$RESULTS_FILE"
echo ""
echo "Summary:"
echo " PASS: $PASS"
echo " FAIL: $FAIL"
echo " TIMEOUT: $TIMEOUT"
echo " TOTAL: $TOTAL"
echo ""
echo "Results saved to $RESULTS_FILE"