RVBTCC/test.sh
2024-12-24 11:31:50 +08:00

47 lines
1.0 KiB
Bash

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