Skip to content

Commit

Permalink
feat: ci script associated with auto_utest.
Browse files Browse the repository at this point in the history
  • Loading branch information
kurisaW committed Feb 12, 2025
1 parent ab1f438 commit 7aa4331
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/utest/cpp11/cpp11.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CONFIG_UTEST_CPP11_THREAD_TC=y
# dependencies
CONFIG_RT_USING_CI_ACTION=y
CONFIG_RT_USING_CPLUSPLUS=y
CONFIG_RT_USING_CPLUSPLUS11=y
1 change: 1 addition & 0 deletions .github/utest/default.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_RT_USING_CI_ACTION=y
7 changes: 7 additions & 0 deletions .github/utest/rtsmart/rtsmart.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CONFIG_UTEST_MEMHEAP_TC=y

# dependencies
CONFIG_RT_USING_CI_ACTION=y
CONFIG_RT_USING_SMART=y
CONFIG_RT_USING_MEMHEAP=y
CONFIG_RT_USING_DFS_V2=y
186 changes: 186 additions & 0 deletions .github/workflows/action_auto_utest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
# Automation utest run script for the QEMU platform
# Generate the corresponding config configuration for CI based on the configuration file under .github/utest.

name: action_auto_utest

on:
push:
branches:
- master
paths-ignore:
- documentation/**
- '**/README.md'
- '**/README_zh.md'
pull_request:
branches:
- master
paths-ignore:
- documentation/**
- '**/README.md'
- '**/README_zh.md'

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-22.04
name: ${{ matrix.platform.UTEST }}-${{ matrix.platform.KERNEL }} - ${{ matrix.config_file }}
if: github.repository_owner == 'RT-Thread'
strategy:
fail-fast: false
matrix:
platform:
- { 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" }
- { UTEST: "qemu-virt64-riscv", RTT_BSP: "bsp/qemu-virt64-riscv", QEMU_ARCH: "riscv64", QEMU_MACHINE: "virt", SD_FILE: "None", RUN: "yes", KERNEL: "standard" }
- { UTEST: "qemu-virt64-aarch64", RTT_BSP: "bsp/qemu-virt64-aarch64", QEMU_ARCH: "aarch64", QEMU_MACHINE: "virt", SD_FILE: "sd.bin", RUN: "yes", KERNEL: "rtsmart" }
config_file:
- "default.cfg"

# kernel
- "kernel/atomic_c11.cfg"
- "kernel/atomic.cfg"
- "kernel/device.cfg"
- "kernel/ipc.cfg"
- "kernel/irq.cfg"
- "kernel/mem.cfg"
- "kernel/thread.cfg"
- "kernel/timer.cfg"

# cpp11
- "cpp11/cpp11.cfg"

# rtsmart
- "rtsmart/rtsmart.cfg"

env:
TEST_QEMU_ARCH: ${{ matrix.platform.QEMU_ARCH }}
TEST_QEMU_MACHINE: ${{ matrix.platform.QEMU_MACHINE }}
TEST_BSP_ROOT: ${{ matrix.platform.RTT_BSP }}
TEST_CONFIG_FILE: ${{ matrix.config_file }}
TEST_SD_FILE: ${{ matrix.platform.SD_FILE }}
RUN_FLAG: ${{ RUN_FLAG }}
KERNEL_FLAG: ${{ matrix.platform.KERNEL }}
steps:
- uses: actions/checkout@v4

- name: Install Tools
shell: bash
run: |
sudo apt-get update
sudo apt-get -yqq install scons qemu-system git
pip3 install kconfiglib
- name: Install ToolChains
shell: bash
run: |
TOOLCHAIN_INSTALLED=""
# Install Arm ToolChains
if [ TEST_QEMU_ARCH == "arm" && KERNEL_FLAG == "standard" && TEST_CONFIG_FILE != "rtsmart/rtsmart.cfg" ]; then
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
sudo tar xjf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 -C /opt
/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc --version
echo "RTT_EXEC_PATH=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin" >> $GITHUB_ENV
echo "RTT_CC_PREFIX=arm-none-eabi-" >> $GITHUB_ENV
echo "TOOLCHAIN_INSTALLED=arm" >> $GITHUB_ENV
fi
# Install Arm Musl ToolChains
if [ TEST_QEMU_ARCH == "arm" && KERNEL_FLAG == "rtsmart" && TEST_CONFIG_FILE == "rtsmart/rtsmart.cfg" ]; then
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
sudo tar xjf arm-linux-musleabi_for_x86_64-pc-linux-gnu_stable.tar.bz2 -C /opt
/opt/arm-linux-musleabi_for_x86_64-pc-linux-gnu/bin/arm-linux-musleabi-gcc --version
echo "RTT_EXEC_PATH=/opt/arm-linux-musleabi_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
echo "RTT_CC_PREFIX=arm-linux-musleabi-" >> $GITHUB_ENV
echo "TOOLCHAIN_INSTALLED=arm-musl" >> $GITHUB_ENV
fi
# Install RISC-V ToolChains
if [ "TEST_QEMU_ARCH == "riscv64" && KERNEL_FLAG == "standard" && TEST_CONFIG_FILE != "rtsmart/rtsmart.cfg" ]; then
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
sudo tar zxvf riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz -C /opt
/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc --version
echo "RTT_EXEC_PATH=/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin" >> $GITHUB_ENV
echo "TOOLCHAIN_INSTALLED=riscv" >> $GITHUB_ENV
fi
# Install RISC-V Musl ToolChains
if [ TEST_QEMU_ARCH == "riscv64" && KERNEL_FLAG == "rtsmart" && TEST_CONFIG_FILE == "rtsmart/rtsmart.cfg" ]; then
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
sudo tar xjf riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_latest.tar.bz2 -C /opt
/opt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin/riscv64-unknown-linux-musl-gcc --version
echo "RTT_EXEC_PATH=/opt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
echo "RTT_CC_PREFIX=riscv64-unknown-linux-musl-" >> $GITHUB_ENV
echo "TOOLCHAIN_INSTALLED=riscv-musl" >> $GITHUB_ENV
fi
# Install AARCH64 Musl ToolChains
if [ TEST_QEMU_ARCH == "aarch64" && KERNEL_FLAG == "rtsmart" && TEST_CONFIG_FILE == "rtsmart/rtsmart.cfg" ]; then
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
sudo tar xjf aarch64-linux-musleabi_for_x86_64-pc-linux-gnu_stable.tar.bz2 -C /opt
/opt/aarch64-linux-musleabi_for_x86_64-pc-linux-gnu/bin/aarch64-linux-musleabi-gcc --version
echo "RTT_EXEC_PATH=/opt/aarch64-linux-musleabi_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
echo "RTT_CC_PREFIX=aarch64-linux-musleabi-" >> $GITHUB_ENV
echo "TOOLCHAIN_INSTALLED=aarch64-musl" >> $GITHUB_ENV
fi
# Install CPP11 Preprocessing Toolchain
if [ TEST_QEMU_ARCH == "arm" && TEST_CONFIG_FILE == "cpp11/cpp11.cfg" ]; then
sudo rm -f /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/c++/10.2.1/thread
sudo rm -f /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/c++/10.2.1/mutex
sudo rm -f /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/c++/10.2.1/condition_variable
sudo rm -f /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/c++/10.2.1/future
sudo rm -f /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/pthread.h
sudo cat /dev/null > /opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_pthreadtypes.h
sed -i 's/-fno-exceptions/ /g' $TEST_BSP_ROOT/rtconfig.py
fi
if [[ -z "$TOOLCHAIN_INSTALLED" ]]; then
echo "No valid toolchain installed, stopping the workflow."
fi
- name: Build BSP
if: ${{ RUN_FLAG == 'yes' && env.TOOLCHAIN_INSTALLED != '' && success() }}
run: |
echo CONFIG_RT_USING_UTESTCASES=y >> $TEST_BSP_ROOT/.config
cat .github/utest/$TEST_CONFIG_FILE >> $TEST_BSP_ROOT/.config
scons --pyconfig-silent -C $TEST_BSP_ROOT
scons -j$(nproc) --strict -C $TEST_BSP_ROOT
- name: QEMU Run Test
if: ${{ RUN_FLAG == 'yes' && env.TOOLCHAIN_INSTALLED != '' && success() }}
run: |
if [ "$TEST_SD_FILE" != "None" ]; then
dd if=/dev/zero of=$TEST_BSP_ROOT/sd.bin bs=1024 count=65536
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 &
else
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 &
fi
QEMU_PID=$!
disown $QEMU_PID
- name: Monitor qemu log
if: ${{ RUN_FLAG == 'yes' && env.TOOLCHAIN_INSTALLED != '' && success() }}
run: |
FAILURE_DETECTED=false
ERROR_LOGS=""
tail -n 0 -f qemu_output_${TEST_QEMU_ARCH}.log | while read line; do
echo $line
if [[ "$line" == *"[ FAILED ] [ result ]"* ]]; then
ERROR_LOGS="$ERROR_LOGS$line"$'\n'
FAILURE_DETECTED=true
fi
if [[ "$line" == *"[==========] [ utest ] finished"* ]]; then
echo "Utest run completed. Exiting log monitoring..."
if $FAILURE_DETECTED; then
echo "Error: Failures detected in logs. Below are the failure details..."
echo "$ERROR_LOGS"
exit 1
fi
break
fi
done
2 changes: 1 addition & 1 deletion components/utilities/utest/utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ static void utest_do_run(const char *utest_name)
break;
}

LOG_I("[==========] [ utest ] finished");
LOG_I("[==========] [ utest ] %d tests from %d testcase ran.", tc_run_num, tc_num);
LOG_I("[ PASSED ] [ result ] %d tests.", tc_run_num - tc_fail_num);
LOG_I("[==========] [ utest ] finished");

if(tc_fail_list && (tc_fail_num > 0))
{
Expand Down

0 comments on commit 7aa4331

Please sign in to comment.