RVBTCC/test.sh

47 lines
1.0 KiB
Bash
Raw Normal View History

2024-12-07 06:13:34 +00:00
cd test
2024-12-23 14:42:31 +00:00
gcc ../boot.c -o boot.elf
2024-12-24 03:31:50 +00:00
all_cnt=0
succ_cnt=0
2024-12-24 01:55:26 +00:00
for D in *; do
if [ -d "${D}" ]; then
echo "Testing subdirectory '$D'"
cd $D
for i in *.c; do
2024-12-24 03:31:50 +00:00
all_cnt=$((all_cnt+1))
failed=1
2024-12-24 01:55:26 +00:00
i=$(basename $i .c)
2024-12-24 03:31:50 +00:00
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
2024-12-24 01:55:26 +00:00
else
2024-12-24 03:31:50 +00:00
../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"
2024-12-24 01:55:26 +00:00
fi
done
cd ..
fi
2024-12-07 06:13:34 +00:00
done
2024-12-24 03:31:50 +00:00
echo "Passed $succ_cnt/$all_cnt tests"
2024-12-24 01:55:26 +00:00
rm boot.elf