This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 5d7ce1c9594e94c748034ac36f32d4dd1b9eac69 Author: Afonso Oliveira <[email protected]> AuthorDate: Thu Oct 8 13:18:43 2026 +0100 boards/risc-v/erbium/minion: Fix false results in test_emu.py. Three problems could make the emulator test runner report wrong results: * The ostest check required "wqueue_test: teardown done", which nuttx-apps prints only since September 2026. Older apps never print it, and apps 12.8 to 12.12 do not run the work queue test from user_main at all, so a passing suite was reported as failed. ostest_main exiting with status 0 after user_main's final memory report already shows that every configured stage ran, and the current work queue test asserts on its own failures. * The failure pattern was case-insensitive, so lines that are not failures counted as failures: the ostest watchdog warning "wdog latency ticks N (> 10 may indicate timing error)" and, with CONFIG_SIG_EVTHREAD, "sigev_thread_test: Awakened with no error!". Only an uppercase ERROR, the form NuttX and ostest use for real errors, now marks a failure. * The reset PC was fixed at 0x40000200. Take it from the ELF entry point so that images linked at another CONFIG_RAM_START start correctly. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Afonso Oliveira <[email protected]> --- boards/risc-v/erbium/minion/tools/test_emu.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/boards/risc-v/erbium/minion/tools/test_emu.py b/boards/risc-v/erbium/minion/tools/test_emu.py index 3befaf42c1c..d96ffda74db 100644 --- a/boards/risc-v/erbium/minion/tools/test_emu.py +++ b/boards/risc-v/erbium/minion/tools/test_emu.py @@ -24,18 +24,32 @@ import argparse import hashlib import json import re +import struct import subprocess import time from pathlib import Path +# Only an uppercase ERROR marks a failure. ostest also prints a lowercase +# "error" in lines that are not failures, such as its watchdog latency +# warning ("... may indicate timing error"). + FAILURE = re.compile( - r"\bERROR\b|Assertion failed|ASSERTION|PANIC|riscv_exception:|Unhandled exception" - r"|nsh: .*?(?:failed|not found|invalid)" + r"(?-i:\bERROR\b)|Assertion failed|ASSERTION|PANIC|riscv_exception:" + r"|Unhandled exception|nsh: .*?(?:failed|not found|invalid)" r"|ostest_main: Exiting with status -?[1-9]", re.I, ) +def elf_entry(path): + """Return the entry point of a little-endian ELF64 image.""" + with path.open("rb") as image: + header = image.read(32) + if len(header) < 32 or header[:4] != b"\x7fELF" or header[4:6] != b"\x02\x01": + raise ValueError(f"Not a little-endian ELF64 image: {path}") + return struct.unpack_from("<Q", header, 24)[0] + + def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--emu", type=Path, required=True) @@ -51,6 +65,10 @@ def main(): for path in (args.emu, args.elf): if not path.is_file(): parser.error(f"Input file does not exist: {path}") + try: + entry = elf_entry(args.elf) + except ValueError as error: + parser.error(str(error)) args.output.mkdir(parents=True, exist_ok=True) uart = args.output / "uart.log" emulator = args.output / "emulator.log" @@ -60,7 +78,7 @@ def main(): "-elf_load", str(args.elf.resolve()), "-reset_pc", - "0x40000200", + hex(entry), "-max_cycles", args.max_cycles, "-uart_tx_file", @@ -109,7 +127,6 @@ def main(): "user_main: semaphore test", "user_main: signal handler test", "user_main: pthread_exit() test", - "wqueue_test: teardown done", ]: if marker.lower() not in text.lower(): raise RuntimeError(
