diff options
| author | Alessandro Gatti <a.gatti@frob.it> | 2025-09-25 00:12:00 +0200 | 
|---|---|---|
| committer | Alessandro Gatti <a.gatti@frob.it> | 2025-10-24 19:13:15 +0200 | 
| commit | 849c67bcdc9f848a674554f3e03ef850a8f70692 (patch) | |
| tree | 665bc4e4fa86ad4b565680eabd027e61e0395ae6 /tests/run-tests.py | |
| parent | 331a5c46aa21a2ff973a9060d2d62ed73247ffed (diff) | |
tests/run-tests.py: Pass auto-detected architecture flags to mpy-cross.
This commit lets "run-tests.py" use the encoded architecture flags
provided by the interpreter when invoking "mpy-cross".
If architecture flags are detected, they're mapped into the necessary
strings needed by "mpy-cross"'s "-march-flags" argument, so that tests
will always use all available extensions reported by the target.
Currently this is limited to the RV32 platform, as it is the only one
that is making use of this facility as of now.  This also lets the QEMU
port remove forced arguments to "mpy-cross" when running the test suite.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Diffstat (limited to 'tests/run-tests.py')
| -rwxr-xr-x | tests/run-tests.py | 24 | 
1 files changed, 22 insertions, 2 deletions
diff --git a/tests/run-tests.py b/tests/run-tests.py index f184203a8..d8d2c42ad 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -22,6 +22,8 @@ TEST_TIMEOUT = float(os.environ.get("MICROPY_TEST_TIMEOUT", 30))  # are guaranteed to always work, this one should though.  BASEPATH = os.path.dirname(os.path.abspath(inspect.getsourcefile(lambda: None))) +RV32_ARCH_FLAGS = {"zba": 1 << 0} +  def base_path(*p):      return os.path.abspath(os.path.join(BASEPATH, *p)).replace("\\", "/") @@ -382,6 +384,17 @@ def detect_inline_asm_arch(pyb, args):      return None +def map_rv32_arch_flags(flags): +    mapped_flags = [] +    for extension, bit in RV32_ARCH_FLAGS.items(): +        if flags & bit: +            mapped_flags.append(extension) +        flags &= ~bit +    if flags: +        raise Exception("Unexpected flag bits set in value {}".format(flags)) +    return mapped_flags + +  def detect_test_platform(pyb, args):      # Run a script to detect various bits of information about the target test instance.      output = run_feature_check(pyb, args, "target_info.py") @@ -397,12 +410,18 @@ def detect_test_platform(pyb, args):          thread = None      float_prec = int(float_prec)      unicode = unicode == "True" +    if arch == "rv32imc": +        arch_flags = map_rv32_arch_flags(int(arch_flags)) +    else: +        arch_flags = None      args.platform = platform      args.arch = arch +    args.arch_flags = arch_flags      if arch and not args.mpy_cross_flags:          args.mpy_cross_flags = "-march=" + arch -    args.arch_flags = arch_flags +        if arch_flags: +            args.mpy_cross_flags += " -march-flags=" + ",".join(arch_flags)      args.inlineasm_arch = inlineasm_arch      args.build = build      args.thread = thread @@ -413,7 +432,8 @@ def detect_test_platform(pyb, args):      print("platform={}".format(platform), end="")      if arch:          print(" arch={}".format(arch), end="") -        print(" arch_flags={}".format(arch_flags), end="") +        if arch_flags: +            print(" arch_flags={}".format(",".join(arch_flags)), end="")      if inlineasm_arch:          print(" inlineasm={}".format(inlineasm_arch), end="")      if thread:  | 
