Skip to content

Commit 2715785

Browse files
committed
CI: Add Linux booting verification
The .ci/boot-linux.sh script has been introduced to automatically run booting verification.
1 parent e701b40 commit 2715785

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed

.ci/boot-linux.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
RUN_LINUX="build/rv32emu ${OPTS}"
24+
25+
ASSERT expect <<DONE
26+
set timeout ${TIMEOUT}
27+
spawn ${RUN_LINUX}
28+
expect "buildroot login:" { send "root\n" } timeout { exit 1 }
29+
expect "# " { send "uname -a\n" } timeout { exit 2 }
30+
expect "riscv32 GNU/Linux" { send "\x01"; send "x" } timeout { exit 3 }
31+
DONE
32+
33+
ret=$?
34+
cleanup
35+
36+
MESSAGES=("OK!" \
37+
"Fail to boot" \
38+
"Fail to login" \
39+
"Fail to run commands" \
40+
)
41+
42+
COLOR_G='\e[32;01m' # Green
43+
COLOR_N='\e[0m' # No color
44+
printf "\n[ ${COLOR_G}${MESSAGES[$ret]}${COLOR_N} ]\n"
45+
46+
exit ${ret}

.github/workflows/main.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: install-dependencies
4343
run: |
4444
sudo apt-get update -q -y
45-
sudo apt-get install -q -y libsdl2-dev libsdl2-mixer-dev
45+
sudo apt-get install -q -y libsdl2-dev libsdl2-mixer-dev device-tree-compiler expect
4646
.ci/riscv-toolchain-install.sh
4747
echo "${{ github.workspace }}/toolchain/bin" >> $GITHUB_PATH
4848
wget https://apt.llvm.org/llvm.sh
@@ -67,11 +67,11 @@ jobs:
6767
- name: misalignment test in block emulation
6868
run: |
6969
make -C tests/system/alignment/
70-
make distclean && make ENABLE_EXT_C=0 ENABLE_SYSTEM=1 misalign-in-blk-emu -j$(nproc)
70+
make distclean && make ENABLE_ELF_LOADER=1 ENABLE_EXT_C=0 ENABLE_SYSTEM=1 misalign-in-blk-emu -j$(nproc)
7171
- name: MMU test
7272
run: |
7373
make -C tests/system/mmu/
74-
make distclean && make ENABLE_SYSTEM=1 mmu-test -j$(nproc)
74+
make distclean && make ENABLE_ELF_LOADER=1 ENABLE_SYSTEM=1 mmu-test -j$(nproc)
7575
- name: gdbstub test
7676
run: |
7777
make distclean && make ENABLE_GDBSTUB=1 gdbstub-test -j$(nproc)
@@ -85,6 +85,11 @@ jobs:
8585
run: |
8686
make clean && make ENABLE_UBSAN=1 check -j$(nproc)
8787
make ENABLE_JIT=1 clean && make ENABLE_JIT=1 ENABLE_UBSAN=1 check -j$(nproc)
88+
- name: boot Linux kernel test
89+
run: |
90+
make clean && make ENABLE_SYSTEM=1 && make ENABLE_SYSTEM=1 artifact -j$(nproc)
91+
.ci/boot-linux.sh
92+
make ENABLE_SYSTEM=1 clean
8893
8994
host-arm64:
9095
needs: [detect-code-related-file-changes]

0 commit comments

Comments
 (0)