2024-12-24 13:31:12 +00:00
|
|
|
if [ $(uname -m) != "riscv64" ]; then
|
|
|
|
function compile() {
|
|
|
|
riscv64-linux-gnu-gcc-12 -static $1.s -o $1.elf
|
|
|
|
}
|
|
|
|
function run_with_input() {
|
|
|
|
qemu-riscv64 $1.elf < $1.in > $1.ans
|
|
|
|
}
|
|
|
|
function run_without_input() {
|
|
|
|
qemu-riscv64 $1.elf > $1.ans
|
|
|
|
}
|
|
|
|
else
|
|
|
|
function compile() {
|
|
|
|
gcc $1.s -o $1.elf
|
|
|
|
}
|
|
|
|
function run_with_input() {
|
|
|
|
./$1.elf < $1.in > $1.ans
|
|
|
|
}
|
|
|
|
function run_without_input() {
|
|
|
|
./$1.elf > $1.ans
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
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 &&
|
2024-12-24 13:31:12 +00:00
|
|
|
compile $i
|
2024-12-24 03:31:50 +00:00
|
|
|
if [[ $? == 0 ]]; then
|
|
|
|
if [ -f $i.in ]; then
|
2024-12-24 13:31:12 +00:00
|
|
|
run_with_input $i
|
2024-12-24 03:31:50 +00:00
|
|
|
else
|
2024-12-24 13:31:12 +00:00
|
|
|
run_without_input $i
|
2024-12-24 03:31:50 +00:00
|
|
|
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
|