Files
micropython/tests/inlineasm/rv32/asm_ext_zba.py
Alessandro Gatti cb9d8fcc31 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>
2025-12-19 17:06:53 +11:00

19 lines
312 B
Python

@micropython.asm_rv32
def test_sh1add(a0, a1):
sh1add(a0, a0, a1)
@micropython.asm_rv32
def test_sh2add(a0, a1):
sh2add(a0, a0, a1)
@micropython.asm_rv32
def test_sh3add(a0, a1):
sh3add(a0, a0, a1)
print(hex(test_sh1add(10, 20)))
print(hex(test_sh2add(10, 20)))
print(hex(test_sh3add(10, 20)))