Skip to content

Commit b47aece

Browse files
committed
CI: Add bring-up Linux kernel automation script
Also, adding macOS environment to embrace more working environments.
1 parent 4ef0ff4 commit b47aece

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

.ci/boot-linux.sh

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

.github/workflows/main.yml

Lines changed: 20 additions & 1 deletion
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
@@ -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]
@@ -120,6 +125,20 @@ jobs:
120125
make ENABLE_JIT=1 clean && make ENABLE_EXT_F=0 ENABLE_JIT=1 check -j$(nproc)
121126
make ENABLE_JIT=1 clean && make ENABLE_EXT_C=0 ENABLE_JIT=1 check -j$(nproc)
122127
128+
# Currently, this environment only for system emulation testing
129+
macOS:
130+
runs-on: macos-latest
131+
steps:
132+
- uses: actions/checkout@v4
133+
- name: install-dependencies
134+
run: |
135+
brew install make dtc expect
136+
- name: boot Linux kernel test
137+
run: |
138+
make clean && make ENABLE_SYSTEM=1 && make ENABLE_SYSTEM=1 artifact -j$(nproc)
139+
.ci/boot-linux.sh
140+
make ENABLE_SYSTEM=1 clean
141+
123142
coding-style:
124143
needs: [detect-code-related-file-changes]
125144
if: needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'

0 commit comments

Comments
 (0)