From bf7f4569678649c5d352b005824f3ee525cb86a8 Mon Sep 17 00:00:00 2001 From: Yaossg Date: Tue, 24 Dec 2024 09:55:26 +0800 Subject: [PATCH] test subdirectory --- test.sh | 32 +++++++++++++++++++------------- test/{ => old}/add.c | 0 test/{ => old}/add.in | 0 test/{ => old}/add.out | 0 test/{ => old}/enum.c | 0 test/{ => old}/enum.in | 0 test/{ => old}/enum.out | 0 test/{ => old}/escape.c | 0 test/{ => old}/escape.in | 0 test/{ => old}/escape.out | 0 test/{ => old}/hello.c | 0 test/{ => old}/hello.in | 0 test/{ => old}/hello.out | 0 test/{ => old}/inc.c | 0 test/{ => old}/inc.in | 0 test/{ => old}/inc.out | 0 test/{ => old}/loop.c | 0 test/{ => old}/loop.in | 0 test/{ => old}/loop.out | 0 test/{ => old}/overflow.c | 0 test/{ => old}/overflow.in | 0 test/{ => old}/overflow.out | 0 test/{ => old}/parse.c | 0 test/{ => old}/parse.in | 0 test/{ => old}/parse.out | 0 test/{ => old}/short.c | 0 test/{ => old}/short.in | 0 test/{ => old}/short.out | 0 test/{ => old}/sort.c | 0 test/{ => old}/sort.in | 0 test/{ => old}/sort.out | 0 31 files changed, 19 insertions(+), 13 deletions(-) rename test/{ => old}/add.c (100%) rename test/{ => old}/add.in (100%) rename test/{ => old}/add.out (100%) rename test/{ => old}/enum.c (100%) rename test/{ => old}/enum.in (100%) rename test/{ => old}/enum.out (100%) rename test/{ => old}/escape.c (100%) rename test/{ => old}/escape.in (100%) rename test/{ => old}/escape.out (100%) rename test/{ => old}/hello.c (100%) rename test/{ => old}/hello.in (100%) rename test/{ => old}/hello.out (100%) rename test/{ => old}/inc.c (100%) rename test/{ => old}/inc.in (100%) rename test/{ => old}/inc.out (100%) rename test/{ => old}/loop.c (100%) rename test/{ => old}/loop.in (100%) rename test/{ => old}/loop.out (100%) rename test/{ => old}/overflow.c (100%) rename test/{ => old}/overflow.in (100%) rename test/{ => old}/overflow.out (100%) rename test/{ => old}/parse.c (100%) rename test/{ => old}/parse.in (100%) rename test/{ => old}/parse.out (100%) rename test/{ => old}/short.c (100%) rename test/{ => old}/short.in (100%) rename test/{ => old}/short.out (100%) rename test/{ => old}/sort.c (100%) rename test/{ => old}/sort.in (100%) rename test/{ => old}/sort.out (100%) diff --git a/test.sh b/test.sh index 65147ce..41bf9cb 100644 --- a/test.sh +++ b/test.sh @@ -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 diff --git a/test/add.c b/test/old/add.c similarity index 100% rename from test/add.c rename to test/old/add.c diff --git a/test/add.in b/test/old/add.in similarity index 100% rename from test/add.in rename to test/old/add.in diff --git a/test/add.out b/test/old/add.out similarity index 100% rename from test/add.out rename to test/old/add.out diff --git a/test/enum.c b/test/old/enum.c similarity index 100% rename from test/enum.c rename to test/old/enum.c diff --git a/test/enum.in b/test/old/enum.in similarity index 100% rename from test/enum.in rename to test/old/enum.in diff --git a/test/enum.out b/test/old/enum.out similarity index 100% rename from test/enum.out rename to test/old/enum.out diff --git a/test/escape.c b/test/old/escape.c similarity index 100% rename from test/escape.c rename to test/old/escape.c diff --git a/test/escape.in b/test/old/escape.in similarity index 100% rename from test/escape.in rename to test/old/escape.in diff --git a/test/escape.out b/test/old/escape.out similarity index 100% rename from test/escape.out rename to test/old/escape.out diff --git a/test/hello.c b/test/old/hello.c similarity index 100% rename from test/hello.c rename to test/old/hello.c diff --git a/test/hello.in b/test/old/hello.in similarity index 100% rename from test/hello.in rename to test/old/hello.in diff --git a/test/hello.out b/test/old/hello.out similarity index 100% rename from test/hello.out rename to test/old/hello.out diff --git a/test/inc.c b/test/old/inc.c similarity index 100% rename from test/inc.c rename to test/old/inc.c diff --git a/test/inc.in b/test/old/inc.in similarity index 100% rename from test/inc.in rename to test/old/inc.in diff --git a/test/inc.out b/test/old/inc.out similarity index 100% rename from test/inc.out rename to test/old/inc.out diff --git a/test/loop.c b/test/old/loop.c similarity index 100% rename from test/loop.c rename to test/old/loop.c diff --git a/test/loop.in b/test/old/loop.in similarity index 100% rename from test/loop.in rename to test/old/loop.in diff --git a/test/loop.out b/test/old/loop.out similarity index 100% rename from test/loop.out rename to test/old/loop.out diff --git a/test/overflow.c b/test/old/overflow.c similarity index 100% rename from test/overflow.c rename to test/old/overflow.c diff --git a/test/overflow.in b/test/old/overflow.in similarity index 100% rename from test/overflow.in rename to test/old/overflow.in diff --git a/test/overflow.out b/test/old/overflow.out similarity index 100% rename from test/overflow.out rename to test/old/overflow.out diff --git a/test/parse.c b/test/old/parse.c similarity index 100% rename from test/parse.c rename to test/old/parse.c diff --git a/test/parse.in b/test/old/parse.in similarity index 100% rename from test/parse.in rename to test/old/parse.in diff --git a/test/parse.out b/test/old/parse.out similarity index 100% rename from test/parse.out rename to test/old/parse.out diff --git a/test/short.c b/test/old/short.c similarity index 100% rename from test/short.c rename to test/old/short.c diff --git a/test/short.in b/test/old/short.in similarity index 100% rename from test/short.in rename to test/old/short.in diff --git a/test/short.out b/test/old/short.out similarity index 100% rename from test/short.out rename to test/old/short.out diff --git a/test/sort.c b/test/old/sort.c similarity index 100% rename from test/sort.c rename to test/old/sort.c diff --git a/test/sort.in b/test/old/sort.in similarity index 100% rename from test/sort.in rename to test/old/sort.in diff --git a/test/sort.out b/test/old/sort.out similarity index 100% rename from test/sort.out rename to test/old/sort.out