tests/run-tests.py: Discover RV32 extension inlineasm tests.

This commit extends the test runner to automatically discover inline
assembler tests for known RV32 extensions, and checks whether to add the
discovered tests to the enabled tests list.

Automatic discovery requires that inline assembler tests for RV32
extensions follow a specific pattern both for filenames and for the
tests' output in case of success.  A valid RV32 extension test must
have:

  * A code fragment that checks for support of the extension on the
    running target in "/tests/feature_check", called
    "inlineasm_rv32_<extensionname>.py" that should print the string
    "rv32_<extensionname>" if the extension is supported
  * A matching expected result file in "/tests/feature_check" called
    "inlineasm_rv32_<extensionname>.py.exp" that must contain the string
    "rv32_<extensionname>" (without quotes)
  * A regular MicroPython test file in "/tests/inlineasm/rv32" called
    "asm_ext_<extensionname>.py"

For example, to test the Zba extension, there must be a file called
"/tests/feature_check/inlineasm_rv32_zba.py" that should print the
string "rv32_zba" if the extension is supported, together with a file
called "/test/feature_check/inlineasm_rv32_zba.py.exp" that contains the
string "rv32_zba" in it, and finally there must be a regular MicroPython
test file called "/tests/inlineasm/rv32/asm_ext_zba.py".

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit is contained in:
Alessandro Gatti
2025-10-28 05:29:38 +01:00
committed by Damien George
parent f0895f0ea0
commit cb9d8fcc31
3 changed files with 9 additions and 4 deletions

View File

@@ -950,10 +950,15 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
skip_tests.add("inlineasm/thumb/asmfpsqrt.py")
if args.inlineasm_arch == "rv32":
# Check if @micropython.asm_rv32 supports Zba instructions, and skip such tests if it doesn't
output = run_feature_check(pyb, args, "inlineasm_rv32_zba.py")
if output != b"rv32_zba\n":
skip_tests.add("inlineasm/rv32/asmzba.py")
# Discover extension-specific inlineasm tests and add them to the
# list of tests to run if applicable.
for extension in RV32_ARCH_FLAGS:
try:
output = run_feature_check(pyb, args, "inlineasm_rv32_{}.py".format(extension))
if output.strip() != "rv32_{}".format(extension).encode():
skip_tests.add("inlineasm/rv32/asm_ext_{}.py".format(extension))
except FileNotFoundError:
pass
# Check if emacs repl is supported, and skip such tests if it's not
t = run_feature_check(pyb, args, "repl_emacs_check.py")