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.

This commit also removes -b argument when starting the emulator, as it
is refined to be used to accept custom bootargs.
  • Loading branch information
otteryc committed Feb 1, 2025
1 parent 15af061 commit fd051c2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
50 changes: 41 additions & 9 deletions .ci/boot-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,63 @@ function ASSERT {

cleanup

ENABLE_VBLK=1
VBLK_IMG=build/disk.img
which dd >/dev/null 2>&1 || ENABLE_VBLK=0
which mkfs.ext4 >/dev/null 2>&1 || which $(brew --prefix e2fsprogs)/sbin/mkfs.ext4 >/dev/null 2>&1 || ENABLE_VBLK=0
which 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=$VBLK_IMG bs=4M count=32
mkfs.ext4 $VBLK_IMG || $(brew --prefix e2fsprogs)/sbin/mkfs.ext4 $VBLK_IMG
OPTS+=" -x vblk:$VBLK_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" \
)

COLOR_G='\e[32;01m' # Green
COLOR_R='\e[31;01m' # Red
COLOR_N='\e[0m' # No color
printf "\n[ ${COLOR_G}${MESSAGES[$ret]}${COLOR_N} ]\n"

MESSAGES=("${COLOR_G}OK!" \
"${COLOR_R}Fail to boot" \
"${COLOR_R}Fail to login" \
"${COLOR_R}Fail to run commands" \
"${COLOR_R}Fail to find emu.txt in $VBLK_IMG"\
)

printf "\nBoot Linux Test: [ ${MESSAGES[$ret]}${COLOR_N} ]\n"
if [ "$ENABLE_VBLK" -eq "1" ]; then
7z l $VBLK_IMG | grep emu.txt >/dev/null 2>&1 || ret=4
printf "Virtio-blk Test: [ ${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 fd051c2

Please sign in to comment.