test subdirectory

This commit is contained in:
Yaossg 2024-12-24 09:55:26 +08:00
parent b4dbce76cf
commit bf7f456967
31 changed files with 19 additions and 13 deletions

32
test.sh
View File

@ -2,21 +2,27 @@ cd test
gcc ../boot.c -o boot.elf
all=0
succ=0
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
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
else
rm $i.ans $i.s $i.elf
else
echo "Test '$i' failed"
exit 1
fi
fi
done
cd ..
fi
done
echo "Passed $succ/$all tests"
rm *.elf
rm boot.elf