Skip to content

Commit 44c3121

Browse files
committed
Implement GitHub Action to verify Virtio-blk
This test relies on dd and mkfs.ext4, which are not available on non-Unix-like systems. Due to this limitation, integrating it into the boot-linux test could negatively impact portability. Therefore, it has been deemed inappropriate to merge it with that test.
1 parent f475a45 commit 44c3121

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

.ci/virtio-blk.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
3+
function cleanup {
4+
sleep 1
5+
pkill -9 rv32emu
6+
}
7+
8+
function ASSERT {
9+
$*
10+
local RES=$?
11+
if [ $RES -ne 0 ]; then
12+
echo 'Assert failed: "' $* '"'
13+
exit $RES
14+
fi
15+
}
16+
17+
cleanup
18+
19+
TIMEOUT=50
20+
OPTS=" -k build/linux-image/Image "
21+
OPTS+=" -i build/linux-image/rootfs.cpio "
22+
OPTS+=" -b build/minimal.dtb "
23+
OPTS+=" -x vblk:build/disk.img "
24+
RUN_LINUX="build/rv32emu ${OPTS}"
25+
26+
dd if=/dev/zero of=build/disk.img bs=4M count=32
27+
mkfs.ext4 build/disk.img
28+
29+
ASSERT expect <<DONE
30+
set timeout ${TIMEOUT}
31+
spawn ${RUN_LINUX}
32+
expect "buildroot login:" { send "root\n" } timeout { exit 2 }
33+
expect "# " { send "mkdir mnt && mount /dev/vda mnt\n" } timeout { exit 3 }
34+
expect "# " { send "echo rv32emu > mnt/emu.txt && umount mnt\n" } timeout { exit 4 }
35+
expect "# " { send "\x01"; send "x" } timeout { exit 4 }
36+
DONE
37+
38+
file_list=`7z l build/disk.img`
39+
echo $file_list | grep emu.txt
40+
41+
cleanup
42+
43+
MESSAGES=("OK!" \
44+
"Virtio-blk verification failed: emu.txt not found in disk.img" \
45+
"Fail to boot" \
46+
"Fail to login" \
47+
"Fail to run commands" \
48+
)
49+
50+
COLOR_G='\e[32;01m' # Green
51+
COLOR_N='\e[0m' # No color
52+
printf "\n[ ${COLOR_G}${MESSAGES[$ret]}${COLOR_N} ]\n"
53+
54+
exit ${ret}

.github/workflows/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ jobs:
142142
.ci/boot-linux.sh
143143
make ENABLE_SYSTEM=1 clean
144144
if: ${{ always() }}
145+
- name: virtio-blk test
146+
env:
147+
CC: ${{ steps.install_cc.outputs.cc }}
148+
run: |
149+
make clean && make ENABLE_SYSTEM=1 && make ENABLE_SYSTEM=1 artifact -j$(nproc)
150+
.ci/virtio-blk.sh
151+
make ENABLE_SYSTEM=1 clean
152+
if: ${{ always() }}
145153

146154
host-arm64:
147155
needs: [detect-code-related-file-changes]

0 commit comments

Comments
 (0)