diff --git a/scripts/pylib/twister/twisterlib/runner.py b/scripts/pylib/twister/twisterlib/runner.py index af84994e5cbc93..2d8805903343c5 100644 --- a/scripts/pylib/twister/twisterlib/runner.py +++ b/scripts/pylib/twister/twisterlib/runner.py @@ -680,7 +680,8 @@ def determine_testcases(self, results): yaml_testsuite_name = self.instance.testsuite.id logger.debug(f"Determine test cases for test suite: {yaml_testsuite_name}") - elf = ELFFile(open(self.instance.get_elf_file(), "rb")) + elf_file = self.instance.get_elf_file() + elf = ELFFile(open(elf_file, "rb")) logger.debug(f"Test instance {self.instance.name} already has {len(self.instance.testcases)} cases.") new_ztest_unit_test_regex = re.compile(r"z_ztest_unit_test__([^\s]*)__([^\s]*)") @@ -702,6 +703,7 @@ def determine_testcases(self, results): detected_cases.append(testcase_id) if detected_cases: + logger.debug(f"{', '.join(detected_cases)} in {elf_file}") self.instance.testcases.clear() self.instance.testsuite.testcases.clear() diff --git a/scripts/pylib/twister/twisterlib/testinstance.py b/scripts/pylib/twister/twisterlib/testinstance.py index 62b0dd8cd335cd..4632de8c2b61be 100644 --- a/scripts/pylib/twister/twisterlib/testinstance.py +++ b/scripts/pylib/twister/twisterlib/testinstance.py @@ -290,15 +290,17 @@ def get_elf_file(self) -> str: build_dir = self.build_dir fns = glob.glob(os.path.join(build_dir, "zephyr", "*.elf")) - fns.extend(glob.glob(os.path.join(build_dir, "zephyr", "*.exe"))) fns.extend(glob.glob(os.path.join(build_dir, "testbinary"))) blocklist = [ 'remapped', # used for xtensa plaforms 'zefi', # EFI for Zephyr - '_pre' ] + 'qemu', # elf files generated after running in qemu + '_pre'] fns = [x for x in fns if not any(bad in os.path.basename(x) for bad in blocklist)] - if len(fns) != 1 and self.platform.type != 'native': - raise BuildError("Missing/multiple output ELF binary") + if not fns: + raise BuildError("Missing output binary") + elif len(fns) > 1: + logger.warning(f"multiple ELF files detected: {', '.join(fns)}") return fns[0] def get_buildlog_file(self) -> str: