smarter and error test

This commit is contained in:
Yaossg 2024-12-24 11:31:50 +08:00
parent bf7f456967
commit 49ed7c5df5
37 changed files with 83 additions and 36 deletions

44
test.sh
View file

@ -1,28 +1,46 @@
cd test
gcc ../boot.c -o boot.elf
all=0
succ=0
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=$((all+1))
all_cnt=$((all_cnt+1))
failed=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
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
echo "Test '$i' failed"
../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/$all tests"
echo "Passed $succ_cnt/$all_cnt tests"
rm boot.elf