twister: improve handling of ELF file parsing
We have been dealing with missing and multiple binaries the same way and both would result in a build error, which is not accurate. multiple binaries in the build directory are fine, we just need to pick the right one for parsing. If we get no binaries, raise an exception and report failure, however, if we have multiple binaries, filter intermediate artifacts out and parse what remains. qemu binaries generated after a run are also being filtered here. Those are not build artificats and appear only after running in qemu. However they have been causing issues on retries. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
250748bfe6
commit
3191d08130
|
@ -680,7 +680,8 @@ class ProjectBuilder(FilterBuilder):
|
||||||
yaml_testsuite_name = self.instance.testsuite.id
|
yaml_testsuite_name = self.instance.testsuite.id
|
||||||
logger.debug(f"Determine test cases for test suite: {yaml_testsuite_name}")
|
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.")
|
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]*)")
|
new_ztest_unit_test_regex = re.compile(r"z_ztest_unit_test__([^\s]*)__([^\s]*)")
|
||||||
|
@ -702,6 +703,7 @@ class ProjectBuilder(FilterBuilder):
|
||||||
detected_cases.append(testcase_id)
|
detected_cases.append(testcase_id)
|
||||||
|
|
||||||
if detected_cases:
|
if detected_cases:
|
||||||
|
logger.debug(f"{', '.join(detected_cases)} in {elf_file}")
|
||||||
self.instance.testcases.clear()
|
self.instance.testcases.clear()
|
||||||
self.instance.testsuite.testcases.clear()
|
self.instance.testsuite.testcases.clear()
|
||||||
|
|
||||||
|
|
|
@ -290,15 +290,17 @@ class TestInstance:
|
||||||
build_dir = self.build_dir
|
build_dir = self.build_dir
|
||||||
|
|
||||||
fns = glob.glob(os.path.join(build_dir, "zephyr", "*.elf"))
|
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")))
|
fns.extend(glob.glob(os.path.join(build_dir, "testbinary")))
|
||||||
blocklist = [
|
blocklist = [
|
||||||
'remapped', # used for xtensa plaforms
|
'remapped', # used for xtensa plaforms
|
||||||
'zefi', # EFI for Zephyr
|
'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)]
|
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':
|
if not fns:
|
||||||
raise BuildError("Missing/multiple output ELF binary")
|
raise BuildError("Missing output binary")
|
||||||
|
elif len(fns) > 1:
|
||||||
|
logger.warning(f"multiple ELF files detected: {', '.join(fns)}")
|
||||||
return fns[0]
|
return fns[0]
|
||||||
|
|
||||||
def get_buildlog_file(self) -> str:
|
def get_buildlog_file(self) -> str:
|
||||||
|
|
Loading…
Reference in a new issue