Skip to content

Commit

Permalink
CI: Add virtio-blk verification
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
otteryc committed Jan 25, 2025
1 parent 250af9d commit 15a105c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
35 changes: 33 additions & 2 deletions .ci/boot-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,62 @@ function ASSERT {

cleanup

ENABLE_VBLK=1
type dd >/dev/null 2>&1 || ENABLE_VBLK=0
(type mkfs.ext4 >/dev/null 2>&1 || type $(brew --prefix e2fsprogs)/sbin/mkfs.ext4) >/dev/null 2>&1 || ENABLE_VBLK=0
type 7z >/dev/null 2>&1 || ENABLE_VBLK=0

TIMEOUT=50
OPTS=" -k build/linux-image/Image "
OPTS+=" -i build/linux-image/rootfs.cpio "
OPTS+=" -b build/minimal.dtb "
if [ "$ENABLE_VBLK" -eq "1" ]; then
dd if=/dev/zero of=build/disk.img bs=4M count=32
mkfs.ext4 build/disk.img || $(brew --prefix e2fsprogs)/sbin/mkfs.ext4 build/disk.img
OPTS+=" -x vblk:build/disk.img "
else
printf "Virtio-blk Test...Passed\n"
fi
RUN_LINUX="build/rv32emu ${OPTS}"

if [ "$ENABLE_VBLK" -eq "1" ]; then
ASSERT expect <<DONE
set timeout ${TIMEOUT}
spawn ${RUN_LINUX}
expect "buildroot login:" { send "root\n" } timeout { exit 1 }
expect "# " { send "uname -a\n" } timeout { exit 2 }
expect "riscv32 GNU/Linux" { send "mkdir mnt && mount /dev/vda mnt\n" } timeout { exit 3 }
expect "# " { send "echo rv32emu > mnt/emu.txt\n" } timeout { exit 3 }
expect "# " { send "sync\n" } timeout { exit 3 }
expect "# " { send "umount mnt\n" } timeout { exit 3 }
expect "# " { send "\x01"; send "x" } timeout { exit 3 }
DONE
else
ASSERT expect <<DONE
set timeout ${TIMEOUT}
spawn ${RUN_LINUX}
expect "buildroot login:" { send "root\n" } timeout { exit 1 }
expect "# " { send "uname -a\n" } timeout { exit 2 }
expect "riscv32 GNU/Linux" { send "\x01"; send "x" } timeout { exit 3 }
DONE

fi
ret=$?
cleanup

MESSAGES=("OK!" \
"Fail to boot" \
"Fail to login" \
"Fail to run commands" \
"Fail to found emu.txt in disk.img"\
)

COLOR_G='\e[32;01m' # Green
COLOR_N='\e[0m' # No color
printf "\n[ ${COLOR_G}${MESSAGES[$ret]}${COLOR_N} ]\n"
printf "\nBoot Linux Test: [ ${COLOR_G}${MESSAGES[$ret]}${COLOR_N} ]\n"
if [ "$ENABLE_VBLK" -eq "1" ]; then
file_list=`7z l build/disk.img`
(echo $file_list | grep emu.txt) || ret=4
printf "Virtio-blk Test: [ ${COLOR_G}${MESSAGES[$ret]}${COLOR_N} ]\n"
fi

exit ${ret}
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: install-dependencies
run: |
sudo apt-get update -q -y
sudo apt-get install -q -y libsdl2-dev libsdl2-mixer-dev device-tree-compiler expect bc
sudo apt-get install -q -y libsdl2-dev libsdl2-mixer-dev device-tree-compiler expect bc p7zip-full
.ci/riscv-toolchain-install.sh
echo "${{ github.workspace }}/toolchain/bin" >> $GITHUB_PATH
wget https://apt.llvm.org/llvm.sh
Expand Down

0 comments on commit 15a105c

Please sign in to comment.