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 : utest_auto_run
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: "A9", RTT_BSP: "bsp/qemu-vexpress-a9", QEMU_ARCH: "arm", QEMU_MACHINE: "vexpress-a9", SD_FILE: "sd.bin", KERNEL: "standard", "SMP_RUN":"" }
35
+ - { UTEST: "A9-rtsmart", RTT_BSP: "bsp/qemu-vexpress-a9", QEMU_ARCH: "arm", QEMU_MACHINE: "vexpress-a9", SD_FILE: "sd.bin", KERNEL: "rtsmart", "SMP_RUN":"" }
36
+ - { UTEST: "A9-smp", RTT_BSP: "bsp/qemu-vexpress-a9", QEMU_ARCH: "arm", QEMU_MACHINE: "vexpress-a9", SD_FILE: "sd.bin", KERNEL: "standard", "SMP_RUN":"smp" }
37
+
38
+ - { UTEST: "RISCV", RTT_BSP: "bsp/qemu-virt64-riscv", QEMU_ARCH: "riscv64", QEMU_MACHINE: "virt", SD_FILE: "None", KERNEL: "standard", "SMP_RUN":"" }
39
+ - { UTEST: "RISCV-rtsmart", RTT_BSP: "bsp/qemu-virt64-riscv", QEMU_ARCH: "riscv64", QEMU_MACHINE: "virt", SD_FILE: "None", KERNEL: "rtsmart", "SMP_RUN":"" }
40
+ # - { UTEST: "RISCV-smp", RTT_BSP: "bsp/qemu-virt64-riscv", QEMU_ARCH: "riscv64", QEMU_MACHINE: "virt", SD_FILE: "None", KERNEL: "standard", "SMP_RUN":"smp" }
41
+
42
+ - { UTEST: "AARCH64", RTT_BSP: "bsp/qemu-virt64-aarch64", QEMU_ARCH: "aarch64", QEMU_MACHINE: "virt", SD_FILE: "sd.bin", KERNEL: "standard", "SMP_RUN":"" }
43
+ - { UTEST: "AARCH64-rtsmart", RTT_BSP: "bsp/qemu-virt64-aarch64", QEMU_ARCH: "aarch64", QEMU_MACHINE: "virt", SD_FILE: "sd.bin", KERNEL: "rtsmart", "SMP_RUN":"" }
44
+ # - { UTEST: "AARCH64-smp", RTT_BSP: "bsp/qemu-virt64-aarch64", QEMU_ARCH: "aarch64", QEMU_MACHINE: "virt", SD_FILE: "sd.bin", KERNEL: "standard", "SMP_RUN":"smp" }
45
+
46
+ config_file :
47
+ - " default.cfg"
48
+
49
+ # cpp11
50
+ # - "cpp11/cpp11.cfg"
51
+
52
+ env :
53
+ TEST_QEMU_ARCH : ${{ matrix.platform.QEMU_ARCH }}
54
+ TEST_QEMU_MACHINE : ${{ matrix.platform.QEMU_MACHINE }}
55
+ TEST_BSP_ROOT : ${{ matrix.platform.RTT_BSP }}
56
+ TEST_CONFIG_FILE : ${{ matrix.config_file }}
57
+ TEST_SD_FILE : ${{ matrix.platform.SD_FILE }}
58
+ steps :
59
+ - uses : actions/checkout@v4
60
+
61
+ - name : Install Tools
62
+ shell : bash
63
+ run : |
64
+ sudo apt-get update
65
+ sudo apt-get -yqq install scons qemu-system git
66
+ pip3 install kconfiglib
67
+
68
+ - name : Install ToolChains
69
+ shell : bash
70
+ run : |
71
+ TOOLCHAIN_INSTALLED=""
72
+
73
+ # Install Arm ToolChains
74
+ if [[ "${{ matrix.platform.QEMU_ARCH }}" == "arm" && "${{ matrix.platform.KERNEL }}" == "standard" ]]; then
75
+ echo "Starting install Arm ToolChains"
76
+ 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
77
+ sudo tar xjf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 -C /opt
78
+ /opt/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc --version
79
+ echo "RTT_EXEC_PATH=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin" >> $GITHUB_ENV
80
+ echo "RTT_CC_PREFIX=arm-none-eabi-" >> $GITHUB_ENV
81
+ echo "TOOLCHAIN_INSTALLED=arm" >> $GITHUB_ENV
82
+ fi
83
+
84
+ # Install Arm Musl ToolChains
85
+ if [[ "${{ matrix.platform.QEMU_ARCH }}" == "arm" && "${{ matrix.platform.KERNEL }}" == "rtsmart" ]]; then
86
+ echo "Starting install Arm Musl ToolChains"
87
+ 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
88
+ sudo tar xjf arm-linux-musleabi_for_x86_64-pc-linux-gnu_stable.tar.bz2 -C /opt
89
+ /opt/arm-linux-musleabi_for_x86_64-pc-linux-gnu/bin/arm-linux-musleabi-gcc --version
90
+ echo "RTT_EXEC_PATH=/opt/arm-linux-musleabi_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
91
+ echo "RTT_CC_PREFIX=arm-linux-musleabi-" >> $GITHUB_ENV
92
+ echo "TOOLCHAIN_INSTALLED=arm-musl" >> $GITHUB_ENV
93
+ fi
94
+
95
+ # Install RISC-V ToolChains
96
+ if [[ "${{ matrix.platform.QEMU_ARCH }}" == "riscv64" && "${{ matrix.platform.KERNEL }}" == "standard" ]]; then
97
+ echo "Starting install RISC-V ToolChains"
98
+ 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
99
+ sudo tar zxvf riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz -C /opt
100
+ /opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc --version
101
+ echo "RTT_EXEC_PATH=/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin" >> $GITHUB_ENV
102
+ echo "TOOLCHAIN_INSTALLED=riscv" >> $GITHUB_ENV
103
+ fi
104
+
105
+ # Install RISC-V Musl ToolChains
106
+ if [[ "${{ matrix.platform.QEMU_ARCH }}" == "riscv64" && "${{ matrix.platform.KERNEL }}" == "rtsmart" ]]; then
107
+ echo "Starting install RISC-V Musl ToolChains"
108
+ 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
109
+ sudo tar xjf riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_latest.tar.bz2 -C /opt
110
+ /opt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin/riscv64-unknown-linux-musl-gcc --version
111
+ echo "RTT_EXEC_PATH=/opt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
112
+ echo "RTT_CC_PREFIX=riscv64-unknown-linux-musl-" >> $GITHUB_ENV
113
+ echo "TOOLCHAIN_INSTALLED=riscv-musl" >> $GITHUB_ENV
114
+ fi
115
+
116
+ # Install AARCH64 ToolChains
117
+ if [[ "${{ matrix.platform.QEMU_ARCH }}" == "aarch64" && "${{ matrix.platform.KERNEL }}" == "standard" ]]; then
118
+ echo "Starting install AARCH64 ToolChains"
119
+ wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.6/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf.tar.xz
120
+ sudo tar -xvJf gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf.tar.xz -C /opt
121
+ /opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gcc --version
122
+ echo "RTT_EXEC_PATH=/opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin" >> $GITHUB_ENV
123
+ echo "RTT_CC_PREFIX=aarch64-none-elf-" >> $GITHUB_ENV
124
+ echo "TOOLCHAIN_INSTALLED=aarch64" >> $GITHUB_ENV
125
+ fi
126
+
127
+ # Install AARCH64 Musl ToolChains
128
+ if [[ "${{ matrix.platform.QEMU_ARCH }}" == "aarch64" && "${{ matrix.platform.KERNEL }}" == "rtsmart" ]]; then
129
+ echo "Starting install AARCH64 Musl ToolChains"
130
+ 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
131
+ sudo tar xjf aarch64-linux-musleabi_for_x86_64-pc-linux-gnu_stable.tar.bz2 -C /opt
132
+ /opt/aarch64-linux-musleabi_for_x86_64-pc-linux-gnu/bin/aarch64-linux-musleabi-gcc --version
133
+ echo "RTT_EXEC_PATH=/opt/aarch64-linux-musleabi_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
134
+ echo "RTT_CC_PREFIX=aarch64-linux-musleabi-" >> $GITHUB_ENV
135
+ echo "TOOLCHAIN_INSTALLED=aarch64-musl" >> $GITHUB_ENV
136
+ fi
137
+
138
+ # Install CPP11 Preprocessing Toolchain
139
+ if [[ "${{ matrix.platform.QEMU_ARCH }}" == "arm" && "${{ matrix.config_file }}" == "cpp11/cpp11.cfg" && "${{ matrix.platform.KERNEL }}" == "standard" ]]; then
140
+ sudo rm -f /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/c++/10.2.1/thread
141
+ sudo rm -f /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/c++/10.2.1/mutex
142
+ sudo rm -f /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/c++/10.2.1/condition_variable
143
+ sudo rm -f /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/c++/10.2.1/future
144
+ sudo rm -f /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/pthread.h
145
+ sudo cat /dev/null > /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_pthreadtypes.h
146
+ sed -i 's/-fno-exceptions/ /g' $TEST_BSP_ROOT/rtconfig.py
147
+ fi
148
+
149
+ if [ "$TOOLCHAIN_INSTALLED" == "None" ]; then
150
+ echo "No valid toolchain installed, stopping the workflow."
151
+ fi
152
+
153
+ - name : Build BSP
154
+ if : ${{ env.TOOLCHAIN_INSTALLED != '' && success() }}
155
+ run : |
156
+ # Whether plan to run SMP?
157
+ if [[ "${{ matrix.platform.SMP_RUN }}" == "smp" ]]; then
158
+ cat .github/utest/smp/smp.cfg >> $TEST_BSP_ROOT/.config
159
+ fi
160
+
161
+ # Is the kernel rtsmart?
162
+ if [[ "${{ matrix.platform.KERNEL }}" == "rtsmart" ]]; then
163
+ cat .github/utest/rtsmart/rtsmart.cfg >> $TEST_BSP_ROOT/.config
164
+ fi
165
+
166
+ echo CONFIG_RT_USING_UTESTCASES=y >> $TEST_BSP_ROOT/.config
167
+ cat .github/utest/$TEST_CONFIG_FILE >> $TEST_BSP_ROOT/.config
168
+ scons --pyconfig-silent -C $TEST_BSP_ROOT
169
+ scons -j$(nproc) --strict -C $TEST_BSP_ROOT
170
+
171
+ - name : QEMU Run Test
172
+ if : ${{ env.TOOLCHAIN_INSTALLED != '' && success() }}
173
+ run : |
174
+ if [ "$TEST_SD_FILE" != "None" ]; then
175
+ dd if=/dev/zero of=$TEST_BSP_ROOT/sd.bin bs=1024 count=65536
176
+ mkfs.fat $TEST_BSP_ROOT/sd.bin
177
+ fi
178
+
179
+ if [[ "${{ matrix.platform.QEMU_ARCH }}" == "aarch64" ]]; then
180
+ qemu-system-$TEST_QEMU_ARCH -M virt,gic-version=2 -cpu cortex-a53 -smp 4 -kernel $TEST_BSP_ROOT/rtthread.bin -nographic \
181
+ -drive if=none,file=$TEST_BSP_ROOT/sd.bin,format=raw,id=blk0 -device virtio-blk-device,drive=blk0,bus=virtio-mmio-bus.0 \
182
+ -netdev user,id=net0 -device virtio-net-device,netdev=net0,bus=virtio-mmio-bus.1 \
183
+ > qemu_output_$TEST_QEMU_ARCH.log 2>&1 &
184
+ elif [[ "${{ matrix.platform.QEMU_ARCH }}" == "arm" ]]; then
185
+ qemu-system-$TEST_QEMU_ARCH \
186
+ -nographic \
187
+ -M $TEST_QEMU_MACHINE \
188
+ -kernel $TEST_BSP_ROOT/rtthread.bin \
189
+ -sd $TEST_BSP_ROOT/sd.bin \
190
+ > qemu_output_$TEST_QEMU_ARCH.log 2>&1 &
191
+ else
192
+ qemu-system-$TEST_QEMU_ARCH \
193
+ -nographic \
194
+ -M $TEST_QEMU_MACHINE \
195
+ -kernel $TEST_BSP_ROOT/rtthread.bin \
196
+ > qemu_output_$TEST_QEMU_ARCH.log 2>&1 &
197
+ fi
198
+
199
+ QEMU_PID=$!
200
+ disown $QEMU_PID
201
+
202
+ - name : Monitor qemu log
203
+ if : ${{ env.TOOLCHAIN_INSTALLED != '' && success() }}
204
+ run : |
205
+ FAILURE_DETECTED=false
206
+ ERROR_LOGS=""
207
+
208
+ echo "=========================================================================================="
209
+ echo " || || "
210
+ echo " || Start automatic running of Utest || "
211
+ echo " VV VV "
212
+ echo "=========================================================================================="
213
+ tail -n 0 -f qemu_output_$TEST_QEMU_ARCH.log | while read line; do
214
+ echo $line
215
+ if [[ "$line" == *"[ FAILED ] [ result ]"* ]]; then
216
+ ERROR_LOGS="$ERROR_LOGS$line"$'\n'
217
+ FAILURE_DETECTED=true
218
+ fi
219
+
220
+ if [[ "$line" == *"[==========] [ utest ] finished"* ]]; then
221
+ if $FAILURE_DETECTED; then
222
+ echo "=========================================================================================="
223
+ echo " || || "
224
+ echo " || Error: Failures detected in logs. Below are the failure details... || "
225
+ echo " VV VV "
226
+ echo "=========================================================================================="
227
+ echo "$ERROR_LOGS"
228
+ exit 1
229
+ fi
230
+ echo "=========================================================================================="
231
+ echo " Successed: Utest run completed. Exiting log monitoring "
232
+ echo "=========================================================================================="
233
+ break
234
+ fi
235
+ done
0 commit comments