Skip to content

Commit fd051c2

Browse files
committed
CI: Add virtio-blk verification
Virtio-blk verification has been integrated into boot-linux test, and is enabled by default. The p7zip-full package, providing command '7z', is added to dependencies in order to validate the success of writes to the Virtio-blk device. This commit also removes -b argument when starting the emulator, as it is refined to be used to accept custom bootargs.
1 parent 15af061 commit fd051c2

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

.ci/boot-linux.sh

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,63 @@ function ASSERT {
1616

1717
cleanup
1818

19+
ENABLE_VBLK=1
20+
VBLK_IMG=build/disk.img
21+
which dd >/dev/null 2>&1 || ENABLE_VBLK=0
22+
which mkfs.ext4 >/dev/null 2>&1 || which $(brew --prefix e2fsprogs)/sbin/mkfs.ext4 >/dev/null 2>&1 || ENABLE_VBLK=0
23+
which 7z >/dev/null 2>&1 || ENABLE_VBLK=0
24+
1925
TIMEOUT=50
2026
OPTS=" -k build/linux-image/Image "
2127
OPTS+=" -i build/linux-image/rootfs.cpio "
22-
OPTS+=" -b build/minimal.dtb "
28+
if [ "$ENABLE_VBLK" -eq "1" ]; then
29+
dd if=/dev/zero of=$VBLK_IMG bs=4M count=32
30+
mkfs.ext4 $VBLK_IMG || $(brew --prefix e2fsprogs)/sbin/mkfs.ext4 $VBLK_IMG
31+
OPTS+=" -x vblk:$VBLK_IMG "
32+
else
33+
printf "Virtio-blk Test...Passed\n"
34+
fi
2335
RUN_LINUX="build/rv32emu ${OPTS}"
2436

37+
if [ "$ENABLE_VBLK" -eq "1" ]; then
38+
ASSERT expect <<DONE
39+
set timeout ${TIMEOUT}
40+
spawn ${RUN_LINUX}
41+
expect "buildroot login:" { send "root\n" } timeout { exit 1 }
42+
expect "# " { send "uname -a\n" } timeout { exit 2 }
43+
expect "riscv32 GNU/Linux" { send "mkdir mnt && mount /dev/vda mnt\n" } timeout { exit 3 }
44+
expect "# " { send "echo rv32emu > mnt/emu.txt\n" } timeout { exit 3 }
45+
expect "# " { send "sync\n" } timeout { exit 3 }
46+
expect "# " { send "umount mnt\n" } timeout { exit 3 }
47+
expect "# " { send "\x01"; send "x" } timeout { exit 3 }
48+
DONE
49+
else
2550
ASSERT expect <<DONE
2651
set timeout ${TIMEOUT}
2752
spawn ${RUN_LINUX}
2853
expect "buildroot login:" { send "root\n" } timeout { exit 1 }
2954
expect "# " { send "uname -a\n" } timeout { exit 2 }
3055
expect "riscv32 GNU/Linux" { send "\x01"; send "x" } timeout { exit 3 }
3156
DONE
32-
57+
fi
3358
ret=$?
3459
cleanup
3560

36-
MESSAGES=("OK!" \
37-
"Fail to boot" \
38-
"Fail to login" \
39-
"Fail to run commands" \
40-
)
41-
4261
COLOR_G='\e[32;01m' # Green
62+
COLOR_R='\e[31;01m' # Red
4363
COLOR_N='\e[0m' # No color
44-
printf "\n[ ${COLOR_G}${MESSAGES[$ret]}${COLOR_N} ]\n"
64+
65+
MESSAGES=("${COLOR_G}OK!" \
66+
"${COLOR_R}Fail to boot" \
67+
"${COLOR_R}Fail to login" \
68+
"${COLOR_R}Fail to run commands" \
69+
"${COLOR_R}Fail to find emu.txt in $VBLK_IMG"\
70+
)
71+
72+
printf "\nBoot Linux Test: [ ${MESSAGES[$ret]}${COLOR_N} ]\n"
73+
if [ "$ENABLE_VBLK" -eq "1" ]; then
74+
7z l $VBLK_IMG | grep emu.txt >/dev/null 2>&1 || ret=4
75+
printf "Virtio-blk Test: [ ${MESSAGES[$ret]}${COLOR_N} ]\n"
76+
fi
4577

4678
exit ${ret}

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: install-dependencies
4747
run: |
4848
sudo apt-get update -q -y
49-
sudo apt-get install -q -y libsdl2-dev libsdl2-mixer-dev device-tree-compiler expect bc
49+
sudo apt-get install -q -y libsdl2-dev libsdl2-mixer-dev device-tree-compiler expect bc p7zip-full
5050
.ci/riscv-toolchain-install.sh
5151
echo "${{ github.workspace }}/toolchain/bin" >> $GITHUB_PATH
5252
wget https://apt.llvm.org/llvm.sh

0 commit comments

Comments
 (0)