#!/bin/sh ############################################################################## # Copyright (c) 2026 Eclipse ThreadX contributors # # This program and the accompanying materials are made available under the # terms of the MIT License which is available at # https://opensource.org/licenses/MIT. # # AI Disclosure: This file was largely AI-generated by Codex (GPT-6-Sol). # The AI-generated portions may be considered public domain (CC0-1.0) # and not subject to the project's licence. The human contributor has # reviewed and verified that the code is correct. # # SPDX-License-Identifier: MIT and CC0-1.0 ############################################################################## set -eu ERBIUM_EMU=${ERBIUM_EMU:?Set ERBIUM_EMU to the erbium_emu executable} TEST_DIR=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) BUILD_DIR=${BUILD_DIR:-"${TEST_DIR}/build-tests"} RUN_DIR=$(mktemp -d) trap 'rm -rf "$RUN_DIR"' EXIT HUP INT TERM failed=0 cmake -S "$TEST_DIR" -B "$BUILD_DIR" -GNinja \ -DCMAKE_TOOLCHAIN_FILE="$TEST_DIR/erbium_gnu.cmake" cmake --build "$BUILD_DIR" --target test_uart_ticks test_plic_race for name in uart_ticks plic_race; do case "$name" in uart_ticks) cycles=20000000 expected=TEST_UART_NO_LOST_TICKS ;; plic_race) cycles=50000000 expected=TEST_PLIC_NO_LOST_UPDATE ;; esac "$ERBIUM_EMU" -elf_load "$BUILD_DIR/test_$name" \ -reset_pc 0x40000200 -minions 1 -single_thread \ -max_cycles "$cycles" -uart_rx_file /dev/null \ -uart_tx_file "$RUN_DIR/$name.uart" > "$RUN_DIR/$name.run" 2>&1 || true if grep -q -F "$expected" "$RUN_DIR/$name.uart" && grep -q -F 'max cycles reached' "$RUN_DIR/$name.run"; then printf '%s: PASS\n' "$name" else printf '%s: FAIL: ' "$name" grep -Eo 'TEST_[A-Z_]+' "$RUN_DIR/$name.uart" | tail -1 || true failed=1 fi done exit "$failed"