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+ schedule :
8+ - cron : ' 0 16 1 * *'
9+ push :
10+ branches :
11+ - master
12+ paths-ignore :
13+ - documentation/**
14+ - ' **/README.md'
15+ - ' **/README_zh.md'
16+ pull_request :
17+ branches :
18+ - master
19+ paths-ignore :
20+ - documentation/**
21+ - ' **/README.md'
22+ - ' **/README_zh.md'
23+
24+ permissions :
25+ contents : read
26+
27+ jobs :
28+ test :
29+ runs-on : ubuntu-22.04
30+ name : ${{ matrix.platform.UTEST }} - ${{ matrix.config_file }}
31+ if : github.repository_owner == 'RT-Thread'
32+ strategy :
33+ fail-fast : false
34+ matrix :
35+ platform :
36+ - { UTEST: "qemu-vexpress-a9", RTT_BSP: "bsp/qemu-vexpress-a9", QEMU_ARCH: "arm", QEMU_MACHINE: "vexpress-a9", SD_FILE: "sd.bin", RUN: "yes" }
37+ # - { UTEST: "qemu-virt64-aarch64", RTT_BSP: "bsp/qemu-virt64-aarch64", QEMU_ARCH: "aarch64", QEMU_MACHINE: "virt", SD_FILE: "sd.bin", RUN: "no" }
38+ - { UTEST: "qemu-virt64-riscv", RTT_BSP: "bsp/qemu-virt64-riscv", QEMU_ARCH: "riscv64", QEMU_MACHINE: "virt", SD_FILE: "None", RUN: "yes" }
39+ config_file :
40+ - " default.cfg"
41+ # - "rtduino/rtduino.cfg"
42+ env :
43+ TEST_QEMU_ARCH : ${{ matrix.platform.QEMU_ARCH }}
44+ TEST_QEMU_MACHINE : ${{ matrix.platform.QEMU_MACHINE }}
45+ TEST_BSP_ROOT : ${{ matrix.platform.RTT_BSP }}
46+ TEST_CONFIG_FILE : ${{ matrix.config_file }}
47+ TEST_SD_FILE : ${{ matrix.platform.SD_FILE }}
48+ RUN_FLAG : ${{ matrix.platform.RUN }}
49+ steps :
50+ - uses : actions/checkout@v4
51+
52+ - name : Install Tools
53+ shell : bash
54+ run : |
55+ wget https://raw.githubusercontent.com/RT-Thread/env/master/install_ubuntu.sh
56+ chmod 777 install_ubuntu.sh
57+ ./install_ubuntu.sh
58+ git config --global http.postBuffer 524288000
59+ git remote -v
60+ git fetch origin
61+
62+ - name : Install Arm ToolChains
63+ if : ${{ matrix.platform.QEMU_ARCH == 'arm' && matrix.platform.UTEST != 'rtsmart/arm' && success() }}
64+ shell : bash
65+ run : |
66+ 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
67+ sudo tar xjf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 -C /opt
68+ /opt/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc --version
69+ echo "RTT_EXEC_PATH=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin" >> $GITHUB_ENV
70+
71+ - name : Install Arm Musl ToolChains
72+ if : ${{ matrix.platform.QEMU_ARCH == 'arm' && matrix.platform.UTEST == 'rtsmart/arm' && success() }}
73+ shell : bash
74+ run : |
75+ 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
76+ sudo tar xjf arm-linux-musleabi_for_x86_64-pc-linux-gnu_stable.tar.bz2 -C /opt
77+ /opt/arm-linux-musleabi_for_x86_64-pc-linux-gnu/bin/arm-linux-musleabi-gcc --version
78+ echo "RTT_EXEC_PATH=/opt/arm-linux-musleabi_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
79+ echo "RTT_CC_PREFIX=arm-linux-musleabi-" >> $GITHUB_ENV
80+
81+ - name : Install RISC-V ToolChains
82+ if : ${{ matrix.platform.QEMU_ARCH == 'riscv64' && matrix.platform.UTEST != 'rtsmart/riscv64' && success() }}
83+ run : |
84+ 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
85+ sudo tar zxvf riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz -C /opt
86+ /opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc --version
87+ echo "RTT_EXEC_PATH=/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin" >> $GITHUB_ENV
88+
89+ - name : Install RISC-V Musl ToolChains
90+ if : ${{ matrix.platform.QEMU_ARCH == 'riscv64' && matrix.platform.UTEST == 'rtsmart/riscv64' && success() }}
91+ shell : bash
92+ run : |
93+ 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
94+ sudo tar xjf riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_latest.tar.bz2 -C /opt
95+ /opt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin/riscv64-unknown-linux-musl-gcc --version
96+ echo "RTT_EXEC_PATH=/opt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
97+ echo "RTT_CC_PREFIX=riscv64-unknown-linux-musl-" >> $GITHUB_ENV
98+
99+ - name : Install AARCH64 Musl ToolChains
100+ if : ${{ matrix.platform.QEMU_ARCH == 'aarch64' && matrix.platform.UTEST == 'rtsmart/aarch64' && success() }}
101+ shell : bash
102+ run : |
103+ 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
104+ sudo tar xjf aarch64-linux-musleabi_for_x86_64-pc-linux-gnu_stable.tar.bz2 -C /opt
105+ /opt/aarch64-linux-musleabi_for_x86_64-pc-linux-gnu/bin/aarch64-linux-musleabi-gcc --version
106+ echo "RTT_EXEC_PATH=/opt/aarch64-linux-musleabi_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
107+ echo "RTT_CC_PREFIX=aarch64-linux-musleabi-" >> $GITHUB_ENV
108+
109+ - name : CPP11 Preprocessing Toolchain
110+ if : ${{ matrix.platform.QEMU_ARCH == 'arm' && matrix.platform.UTEST == 'components/cpp11' && success() }}
111+ shell : bash
112+ run : |
113+ sudo rm -f /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/c++/10.2.1/{thread,mutex,condition_variable,future}
114+ sudo rm -f /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/pthread.h
115+ sudo sh -c 'echo "" > /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_pthreadtypes.h'
116+ sed -i 's/-fno-exceptions//g' $TEST_BSP_ROOT/rtconfig.py
117+
118+ - name : Build BSP
119+ run : |
120+ echo CONFIG_RT_USING_UTESTCASES=y >> $TEST_BSP_ROOT/.config
121+ cat .github/utest/$TEST_CONFIG_FILE >> $TEST_BSP_ROOT/.config
122+ scons --pyconfig-silent -C $TEST_BSP_ROOT
123+ scons -j$(nproc) --strict -C $TEST_BSP_ROOT
124+
125+ - name : QEMU Run Test
126+ if : ${{ matrix.platform.RUN == 'yes' && success() }}
127+ run : |
128+ if [ "$TEST_SD_FILE" != "None" ]; then
129+ dd if=/dev/zero of=$TEST_BSP_ROOT/sd.bin bs=1024 count=65536
130+ qemu-system-$TEST_QEMU_ARCH -nographic -M $TEST_QEMU_MACHINE -kernel $TEST_BSP_ROOT/rtthread.bin -nographic -sd $TEST_BSP_ROOT/sd.bin > qemu_output_${TEST_QEMU_ARCH}.log 2>&1 &
131+ else
132+ qemu-system-$TEST_QEMU_ARCH -nographic -M $TEST_QEMU_MACHINE -kernel $TEST_BSP_ROOT/rtthread.bin -nographic > qemu_output_${TEST_QEMU_ARCH}.log 2>&1 &
133+ fi
134+
135+ QEMU_PID=$!
136+ disown $QEMU_PID
137+
138+ # - name: Monitor qemu log
139+ # run: |
140+ # FAILURE_DETECTED=false
141+ # ERROR_LOGS=""
142+
143+ # tail -n 0 -f qemu_output_${TEST_QEMU_ARCH}.log | while read line; do
144+ # echo $line
145+ # if [[ "$line" == *"[ FAILED ] [ result ]"* ]]; then
146+ # ERROR_LOGS="$ERROR_LOGS$line"$'\n'
147+ # FAILURE_DETECTED=true
148+ # fi
149+
150+ # if [[ "$line" == *"[==========] [ utest ] end"* ]]; then
151+ # echo "Utest run completed. Exiting log monitoring..."
152+ # if $FAILURE_DETECTED; then
153+ # echo "Error: Failures detected in logs. Below are the failure details..."
154+ # echo "$ERROR_LOGS"
155+ # exit 1
156+ # fi
157+ # break
158+ # fi
159+ # done
0 commit comments