From c1e3678797d5249268756287a33e5aca729a7631 Mon Sep 17 00:00:00 2001 From: Akif Ejaz Date: Tue, 19 May 2026 20:03:23 +0500 Subject: Add QEMU based CI regression test infra for RV32 and RV64 (#526) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added a QEMU virt-machine BSP and CTest infrastructure to run the ThreadX regression suite on both RISC-V 32-bit and 64-bit targets in CI. New components: - BSP (entry, trap, PLIC, CLINT timer, UART, linker script) targeting QEMU virt machine for RV32 and RV64 - CMake build system with Ninja, supporting multiple build configs - CI scripts: install_riscv.sh (toolchain + QEMU), build_tx_riscv.sh, test_tx_riscv.sh - GitHub Actions workflow job for RISC-V regression gating Port fixes: - RV32 tx_thread_context_restore.S: set MPIE alongside MPP (0x1800 → 0x1880) so mret re-enables interrupts - RV32/RV64 tx_port.h: add TX_REGRESSION_TEST extension macros needed by the test harness - RV32/RV64 example_build scripts: add compile and QEMU launch steps Regression test portability fixes: - Block memory tests: increase pool sizes (320 → 340) to accommodate larger RISC-V block-header alignment - Byte memory test: replace hardcoded offsets with BYTE_POOL_OVERHEAD macro for portable pool-size computation - Event flag timeout test: make counter tolerance unconditional, removing linux-only guard Signed-off-by: Akif Ejaz --- scripts/build_tx_riscv.sh | 15 +++++++++++++++ scripts/install_riscv.sh | 32 ++++++++++++++++++++++++++++++++ scripts/test_tx_riscv.sh | 19 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100755 scripts/build_tx_riscv.sh create mode 100755 scripts/install_riscv.sh create mode 100755 scripts/test_tx_riscv.sh (limited to 'scripts') diff --git a/scripts/build_tx_riscv.sh b/scripts/build_tx_riscv.sh new file mode 100755 index 00000000..bad952df --- /dev/null +++ b/scripts/build_tx_riscv.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# Build RISC-V regression tests for both RV32 and RV64. +# Usage: build_tx_riscv.sh [all|] + +SCRIPT_DIR="$(dirname "$(realpath "$0")")" +RUN_SH="${SCRIPT_DIR}/../test/tx/cmake/riscv/run.sh" + +ARGS="${@:-all}" + +echo "=== Building RISC-V32 ===" +"$RUN_SH" riscv32 build $ARGS + +echo "" +echo "=== Building RISC-V64 ===" +"$RUN_SH" riscv64 build $ARGS diff --git a/scripts/install_riscv.sh b/scripts/install_riscv.sh new file mode 100755 index 00000000..9c2f2cdb --- /dev/null +++ b/scripts/install_riscv.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# Install RISC-V bare-metal cross-compiler toolchain and QEMU for CI. +set -e + +RELEASE_TAG="2026.04.26" +BASE_URL="https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/${RELEASE_TAG}" +# Use ubuntu-24.04 binaries to match ubuntu-latest runners. +RV32_TARBALL="riscv32-elf-ubuntu-24.04-gcc.tar.xz" +RV64_TARBALL="riscv64-elf-ubuntu-24.04-gcc.tar.xz" + +echo "=== Installing QEMU and build tools ===" +sudo apt-get update -qq +sudo apt-get install -y -qq qemu-system-misc ninja-build cmake + +echo "=== Downloading RISC-V GCC toolchain (${RELEASE_TAG}) ===" + +# Both tarballs extract into riscv/ with non-overlapping prefixes +# (riscv32-unknown-elf-* and riscv64-unknown-elf-*). +for tarball in "$RV32_TARBALL" "$RV64_TARBALL"; do + echo "Downloading ${tarball} ..." + wget --no-verbose "${BASE_URL}/${tarball}" -O "/tmp/${tarball}" + sudo tar xJf "/tmp/${tarball}" -C /opt + rm "/tmp/${tarball}" +done + +TOOLCHAIN_BIN=/opt/riscv/bin +echo "$TOOLCHAIN_BIN" >> "$GITHUB_PATH" + +echo "=== Verifying installation ===" +"$TOOLCHAIN_BIN/riscv32-unknown-elf-gcc" --version | head -1 +"$TOOLCHAIN_BIN/riscv64-unknown-elf-gcc" --version | head -1 +qemu-system-riscv64 --version | head -1 diff --git a/scripts/test_tx_riscv.sh b/scripts/test_tx_riscv.sh new file mode 100755 index 00000000..7d35c53f --- /dev/null +++ b/scripts/test_tx_riscv.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Run RISC-V regression tests for both RV32 and RV64 on QEMU. +# Usage: test_tx_riscv.sh [all|] + +SCRIPT_DIR="$(dirname "$(realpath "$0")")" +RUN_SH="${SCRIPT_DIR}/../test/tx/cmake/riscv/run.sh" + +ARGS="${@:-all}" + +exit_code=0 + +echo "=== Testing RISC-V32 ===" +CTEST_PARALLEL_LEVEL=4 "$RUN_SH" riscv32 test $ARGS || exit_code=$? + +echo "" +echo "=== Testing RISC-V64 ===" +CTEST_PARALLEL_LEVEL=4 "$RUN_SH" riscv64 test $ARGS || exit_code=$? + +exit $exit_code -- cgit v1.3.1