1
+ # Automation utest run script for the QEMU platform
2
+ # Generate the corresponding config configuration for CI based on the configuration file under .github/utest.
3
+
4
+ name : action_auto_utest
5
+
6
+ on :
7
+ push :
8
+ branches :
9
+ - master
10
+ paths-ignore :
11
+ - documentation/**
12
+ - ' **/README.md'
13
+ - ' **/README_zh.md'
14
+ pull_request :
15
+ branches :
16
+ - master
17
+ paths-ignore :
18
+ - documentation/**
19
+ - ' **/README.md'
20
+ - ' **/README_zh.md'
21
+
22
+ permissions :
23
+ contents : read
24
+
25
+ jobs :
26
+ test :
27
+ runs-on : ubuntu-22.04
28
+ name : ${{ matrix.platform.UTEST }} - ${{ matrix.config_file }}
29
+ if : github.repository_owner == 'RT-Thread'
30
+ strategy :
31
+ fail-fast : false
32
+ matrix :
33
+ platform :
34
+ - { UTEST: "qemu-vexpress-a9", RTT_BSP: "bsp/qemu-vexpress-a9", QEMU_ARCH: "arm", QEMU_MACHINE: "vexpress-a9", SD_FILE: "sd.bin", RUN: "yes", KERNEL: "standard" }
35
+ - { UTEST: "qemu-virt64-riscv", RTT_BSP: "bsp/qemu-virt64-riscv", QEMU_ARCH: "riscv64", QEMU_MACHINE: "virt", SD_FILE: "None", RUN: "yes", KERNEL: "standard" }
36
+ - { UTEST: "qemu-virt64-aarch64", RTT_BSP: "bsp/qemu-virt64-aarch64", QEMU_ARCH: "aarch64", QEMU_MACHINE: "virt", SD_FILE: "sd.bin", RUN: "yes", KERNEL: "rtsmart" }
37
+ config_file :
38
+ - " default.cfg"
39
+
40
+ # cpp11
41
+ - " cpp11/cpp11.cfg"
42
+
43
+ # rtsmart
44
+ - " rtsmart/rtsmart.cfg"
45
+
46
+ env :
47
+ TEST_QEMU_ARCH : ${{ matrix.platform.QEMU_ARCH }}
48
+ TEST_QEMU_MACHINE : ${{ matrix.platform.QEMU_MACHINE }}
49
+ TEST_BSP_ROOT : ${{ matrix.platform.RTT_BSP }}
50
+ TEST_CONFIG_FILE : ${{ matrix.config_file }}
51
+ TEST_SD_FILE : ${{ matrix.platform.SD_FILE }}
52
+ steps :
53
+ - uses : actions/checkout@v4
54
+
55
+ - name : Install Tools
56
+ shell : bash
57
+ run : |
58
+ sudo apt-get update
59
+ sudo apt-get -yqq install scons qemu-system git
60
+ pip3 install kconfiglib
61
+
62
+ - name : Install ToolChains
63
+ shell : bash
64
+ run : |
65
+ TOOLCHAIN_INSTALLED=""
66
+
67
+ # Install Arm ToolChains
68
+ if [[ "${{ matrix.platform.QEMU_ARCH }}" == "arm" && "${{ matrix.config_file }}" != "rtsmart/rtsmart.cfg" ]]; then
69
+ echo "Starting install Arm ToolChains"
70
+ wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.3/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
71
+ sudo tar xjf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 -C /opt
72
+ /opt/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc --version
73
+ echo "RTT_EXEC_PATH=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin" >> $GITHUB_ENV
74
+ echo "RTT_CC_PREFIX=arm-none-eabi-" >> $GITHUB_ENV
75
+ echo "TOOLCHAIN_INSTALLED=arm" >> $GITHUB_ENV
76
+ fi
77
+
78
+ # Install Arm Musl ToolChains
79
+ if [[ "${{ matrix.platform.QEMU_ARCH }}" == "arm" && "${{ matrix.config_file }}" == "rtsmart/rtsmart.cfg" ]]; then
80
+ echo "Starting install Arm Musl ToolChains"
81
+ wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.7/arm-linux-musleabi_for_x86_64-pc-linux-gnu_stable.tar.bz2
82
+ sudo tar xjf arm-linux-musleabi_for_x86_64-pc-linux-gnu_stable.tar.bz2 -C /opt
83
+ /opt/arm-linux-musleabi_for_x86_64-pc-linux-gnu/bin/arm-linux-musleabi-gcc --version
84
+ echo "RTT_EXEC_PATH=/opt/arm-linux-musleabi_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
85
+ echo "RTT_CC_PREFIX=arm-linux-musleabi-" >> $GITHUB_ENV
86
+ echo "TOOLCHAIN_INSTALLED=arm-musl" >> $GITHUB_ENV
87
+ fi
88
+
89
+ # Install RISC-V ToolChains
90
+ if [[ "${{ matrix.platform.QEMU_ARCH }}" == "riscv64" && "${{ matrix.config_file }}" != "rtsmart/rtsmart.cfg" ]]; then
91
+ echo "Starting install RISC-V ToolChains"
92
+ wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.4/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz
93
+ sudo tar zxvf riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz -C /opt
94
+ /opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc --version
95
+ echo "RTT_EXEC_PATH=/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin" >> $GITHUB_ENV
96
+ echo "TOOLCHAIN_INSTALLED=riscv" >> $GITHUB_ENV
97
+ fi
98
+
99
+ # Install RISC-V Musl ToolChains
100
+ if [[ "${{ matrix.platform.QEMU_ARCH }}" == "riscv64" && "${{ matrix.config_file }}" == "rtsmart/rtsmart.cfg" ]]; then
101
+ echo "Starting install RISC-V Musl ToolChains"
102
+ wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.7/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_latest.tar.bz2
103
+ sudo tar xjf riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_latest.tar.bz2 -C /opt
104
+ /opt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin/riscv64-unknown-linux-musl-gcc --version
105
+ echo "RTT_EXEC_PATH=/opt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
106
+ echo "RTT_CC_PREFIX=riscv64-unknown-linux-musl-" >> $GITHUB_ENV
107
+ echo "TOOLCHAIN_INSTALLED=riscv-musl" >> $GITHUB_ENV
108
+ fi
109
+
110
+ # Install AARCH64 Musl ToolChains
111
+ if [[ "${{ matrix.platform.QEMU_ARCH }}" == "aarch64" && "${{ matrix.config_file }}" == "rtsmart/rtsmart.cfg" ]]; then
112
+ echo "Starting install AARCH64 Musl ToolChains"
113
+ wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.7/aarch64-linux-musleabi_for_x86_64-pc-linux-gnu_stable.tar.bz2
114
+ sudo tar xjf aarch64-linux-musleabi_for_x86_64-pc-linux-gnu_stable.tar.bz2 -C /opt
115
+ /opt/aarch64-linux-musleabi_for_x86_64-pc-linux-gnu/bin/aarch64-linux-musleabi-gcc --version
116
+ echo "RTT_EXEC_PATH=/opt/aarch64-linux-musleabi_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
117
+ echo "RTT_CC_PREFIX=aarch64-linux-musleabi-" >> $GITHUB_ENV
118
+ echo "TOOLCHAIN_INSTALLED=aarch64-musl" >> $GITHUB_ENV
119
+ fi
120
+
121
+ # Install CPP11 Preprocessing Toolchain
122
+ if [[ "${{ matrix.platform.QEMU_ARCH }}" == "arm" && "${{ matrix.config_file }}" == "cpp11/cpp11.cfg" ]]; then
123
+ sudo rm -f /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/c++/10.2.1/thread
124
+ sudo rm -f /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/c++/10.2.1/mutex
125
+ sudo rm -f /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/c++/10.2.1/condition_variable
126
+ sudo rm -f /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/c++/10.2.1/future
127
+ sudo rm -f /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/pthread.h
128
+ sudo cat /dev/null > /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_pthreadtypes.h
129
+ sed -i 's/-fno-exceptions/ /g' $TEST_BSP_ROOT/rtconfig.py
130
+ fi
131
+
132
+ if [ "$TOOLCHAIN_INSTALLED" == "None" ]; then
133
+ echo "No valid toolchain installed, stopping the workflow."
134
+ fi
135
+
136
+ - name : Build BSP
137
+ if : ${{ matrix.platform.RUN == 'yes' && env.TOOLCHAIN_INSTALLED != '' && success() }}
138
+ run : |
139
+ echo CONFIG_RT_USING_UTESTCASES=y >> $TEST_BSP_ROOT/.config
140
+ cat .github/utest/$TEST_CONFIG_FILE >> $TEST_BSP_ROOT/.config
141
+ scons --pyconfig-silent -C $TEST_BSP_ROOT
142
+ scons -j$(nproc) --strict -C $TEST_BSP_ROOT
143
+
144
+ - name : QEMU Run Test
145
+ if : ${{ matrix.platform.RUN == 'yes' && env.TOOLCHAIN_INSTALLED != '' && success() }}
146
+ run : |
147
+ if [ "$TEST_SD_FILE" != "None" ]; then
148
+ dd if=/dev/zero of=$TEST_BSP_ROOT/sd.bin bs=1024 count=65536
149
+ mkfs.fat $TEST_BSP_ROOT/sd.bin
150
+ fi
151
+
152
+ if [[ "${{ matrix.platform.QEMU_ARCH }}" == "aarch64" ]]; then
153
+ qemu-system-$TEST_QEMU_ARCH -M virt,gic-version=2 -cpu cortex-a53 -smp 4 -kernel $TEST_BSP_ROOT/rtthread.bin -nographic \
154
+ -drive if=none,file=$TEST_BSP_ROOT/sd.bin,format=raw,id=blk0 -device virtio-blk-device,drive=blk0,bus=virtio-mmio-bus.0 \
155
+ -netdev user,id=net0 -device virtio-net-device,netdev=net0,bus=virtio-mmio-bus.1 \
156
+ > qemu_output_$TEST_QEMU_ARCH.log 2>&1 &
157
+ elif [[ "${{ matrix.platform.QEMU_ARCH }}" == "arm" ]]; then
158
+ qemu-system-$TEST_QEMU_ARCH \
159
+ -nographic \
160
+ -M $TEST_QEMU_MACHINE \
161
+ -kernel $TEST_BSP_ROOT/rtthread.bin \
162
+ -sd $TEST_BSP_ROOT/sd.bin \
163
+ > qemu_output_$TEST_QEMU_ARCH.log 2>&1 &
164
+ else
165
+ qemu-system-$TEST_QEMU_ARCH \
166
+ -nographic \
167
+ -M $TEST_QEMU_MACHINE \
168
+ -kernel $TEST_BSP_ROOT/rtthread.bin \
169
+ > qemu_output_$TEST_QEMU_ARCH.log 2>&1 &
170
+ fi
171
+
172
+ QEMU_PID=$!
173
+ disown $QEMU_PID
174
+
175
+ - name : Monitor qemu log
176
+ if : ${{ matrix.platform.RUN == 'yes' && env.TOOLCHAIN_INSTALLED != '' && success() }}
177
+ run : |
178
+ FAILURE_DETECTED=false
179
+ ERROR_LOGS=""
180
+
181
+ tail -n 0 -f qemu_output_$TEST_QEMU_ARCH.log | while read line; do
182
+ echo $line
183
+ if [[ "$line" == *"[ FAILED ] [ result ]"* ]]; then
184
+ ERROR_LOGS="$ERROR_LOGS$line"$'\n'
185
+ FAILURE_DETECTED=true
186
+ fi
187
+
188
+ if [[ "$line" == *"[==========] [ utest ] finished"* ]]; then
189
+ if $FAILURE_DETECTED; then
190
+ echo "Error: Failures detected in logs. Below are the failure details..."
191
+ echo "$ERROR_LOGS"
192
+ exit 1
193
+ fi
194
+ echo "Utest run completed. Exiting log monitoring..."
195
+ break
196
+ fi
197
+ done
0 commit comments