44
55check_platform
66
7- function cleanup {
7+ function cleanup
8+ {
89 sleep 1
910 pkill -9 rv32emu
1011}
1112
12- function ASSERT {
13+ function ASSERT
14+ {
1315 $*
1416 local RES=$?
1517 if [ ${RES} -ne 0 ]; then
@@ -30,45 +32,45 @@ OPTS_BASE+=" -i build/linux-image/rootfs.cpio"
3032
3133TEST_OPTIONS=(" base (${OPTS_BASE} )" )
3234EXPECT_CMDS=('
33- expect "buildroot login:" { send "root\n" } timeout { exit 1 }
34- expect "# " { send "uname -a\n" } timeout { exit 2 }
35- expect "riscv32 GNU/Linux" { send "\x01"; send "x" } timeout { exit 3 }
35+ expect "buildroot login:" { send "root\n" } timeout { exit 1 }
36+ expect "# " { send "uname -a\n" } timeout { exit 2 }
37+ expect "riscv32 GNU/Linux" { send "\x01"; send "x" } timeout { exit 3 }
3638' )
3739
3840COLOR_G=' \e[32;01m' # Green
3941COLOR_R=' \e[31;01m' # Red
4042COLOR_Y=' \e[33;01m' # Yellow
41- COLOR_N=' \e[0m' # No color
43+ COLOR_N=' \e[0m' # No color
4244
43- MESSAGES=(" ${COLOR_G} OK!" \
44- " ${COLOR_R} Fail to boot" \
45- " ${COLOR_R} Fail to login" \
46- " ${COLOR_R} Fail to run commands" \
47- " ${COLOR_R} Fail to find emu.txt in ${VBLK_IMG} " \
45+ MESSAGES=(" ${COLOR_G} OK!"
46+ " ${COLOR_R} Fail to boot"
47+ " ${COLOR_R} Fail to login"
48+ " ${COLOR_R} Fail to run commands"
49+ " ${COLOR_R} Fail to find emu.txt in ${VBLK_IMG} "
4850)
4951
5052if [ " ${ENABLE_VBLK} " -eq " 1" ]; then
5153 # Read-only
5254 TEST_OPTIONS+=(" ${OPTS_BASE} -x vblk:${VBLK_IMG} ,readonly" )
5355 EXPECT_CMDS+=('
54- expect "buildroot login:" { send "root\n" } timeout { exit 1 }
55- expect "# " { send "uname -a\n" } timeout { exit 2 }
56- expect "riscv32 GNU/Linux" { send "mkdir mnt && mount /dev/vda mnt\n" } timeout { exit 3 }
57- expect "# " { send "echo rv32emu > mnt/emu.txt\n" } timeout { exit 3 }
58- expect -ex "-sh: can' \' ' t create mnt/emu.txt: Read-only file system" {} timeout { exit 3 }
59- expect "# " { send "\x01"; send "x" } timeout { exit 3 }
56+ expect "buildroot login:" { send "root\n" } timeout { exit 1 }
57+ expect "# " { send "uname -a\n" } timeout { exit 2 }
58+ expect "riscv32 GNU/Linux" { send "mkdir mnt && mount /dev/vda mnt\n" } timeout { exit 3 }
59+ expect "# " { send "echo rv32emu > mnt/emu.txt\n" } timeout { exit 3 }
60+ expect -ex "-sh: can' \' ' t create mnt/emu.txt: Read-only file system" {} timeout { exit 3 }
61+ expect "# " { send "\x01"; send "x" } timeout { exit 3 }
6062 ' )
6163
6264 # Read-write using disk image
6365 TEST_OPTIONS+=(" ${OPTS_BASE} -x vblk:${VBLK_IMG} " )
6466 VBLK_EXPECT_CMDS='
65- expect "buildroot login:" { send "root\n" } timeout { exit 1 }
66- expect "# " { send "uname -a\n" } timeout { exit 2 }
67- expect "riscv32 GNU/Linux" { send "mkdir mnt && mount /dev/vda mnt\n" } timeout { exit 3 }
68- expect "# " { send "echo rv32emu > mnt/emu.txt\n" } timeout { exit 3 }
69- expect "# " { send "sync\n" } timeout { exit 3 }
70- expect "# " { send "umount mnt\n" } timeout { exit 3 }
71- expect "# " { send "\x01"; send "x" } timeout { exit 3 }
67+ expect "buildroot login:" { send "root\n" } timeout { exit 1 }
68+ expect "# " { send "uname -a\n" } timeout { exit 2 }
69+ expect "riscv32 GNU/Linux" { send "mkdir mnt && mount /dev/vda mnt\n" } timeout { exit 3 }
70+ expect "# " { send "echo rv32emu > mnt/emu.txt\n" } timeout { exit 3 }
71+ expect "# " { send "sync\n" } timeout { exit 3 }
72+ expect "# " { send "umount mnt\n" } timeout { exit 3 }
73+ expect "# " { send "\x01"; send "x" } timeout { exit 3 }
7274 '
7375 EXPECT_CMDS+=(" ${VBLK_EXPECT_CMDS} " )
7476
@@ -87,7 +89,7 @@ for i in "${!TEST_OPTIONS[@]}"; do
8789 fi
8890 RUN_LINUX=" build/rv32emu ${OPTS} "
8991
90- ASSERT expect << -DONE
92+ ASSERT expect << - DONE
9193 set timeout ${TIMEOUT}
9294 spawn ${RUN_LINUX}
9395 ${EXPECT_CMDS[$i]}
@@ -100,7 +102,7 @@ for i in "${!TEST_OPTIONS[@]}"; do
100102 if [[ " ${TEST_OPTIONS[$i]} " =~ vblk ]]; then
101103 # read-only test first, so the emu.txt definitely does not exist, skipping the check
102104 if [[ ! " ${TEST_OPTIONS[$i]} " =~ readonly ]]; then
103- 7z l ${VBLK_IMG} | grep emu.txt > /dev/null 2>&1 || ret=4
105+ 7z l ${VBLK_IMG} | grep emu.txt > /dev/null 2>&1 || ret=4
104106 fi
105107 printf " Virtio-blk Test: [ ${MESSAGES[$ret]}${COLOR_N} ]\n"
106108 fi
0 commit comments