RVBTCC/test.sh
2024-12-24 09:55:26 +08:00

29 lines
607 B
Bash

cd test
gcc ../boot.c -o boot.elf
all=0
succ=0
for D in *; do
if [ -d "${D}" ]; then
echo "Testing subdirectory '$D'"
cd $D
for i in *.c; do
all=$((all+1))
i=$(basename $i .c)
../boot.elf < $i.c > $i.s &&
riscv64-linux-gnu-gcc-12 -static $i.s -o $i.elf &&
qemu-riscv64 $i.elf < $i.in > $i.ans
echo $? >> $i.ans
if cmp $i.out $i.ans; then
succ=$((succ+1))
echo "Test '$i' passed"
rm $i.ans $i.s $i.elf
else
echo "Test '$i' failed"
fi
done
cd ..
fi
done
echo "Passed $succ/$all tests"
rm boot.elf