Skip to content

Commit

Permalink
twister: hotfix for unimplemented harnesses
Browse files Browse the repository at this point in the history
Harness is freeform right now in the yaml file and if the harness is not
implemented in class, things fail. While we cleanup and enforce
implementations, this should serve as a quick fix dealing with such
unimplemented harnesses.

Signed-off-by: Anas Nashif <[email protected]>
  • Loading branch information
nashif committed Jan 10, 2024
1 parent d33f8c7 commit 4e72696
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
14 changes: 9 additions & 5 deletions scripts/pylib/twister/twisterlib/harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,12 @@ class HarnessImporter:
@staticmethod
def get_harness(harness_name):
thismodule = sys.modules[__name__]
if harness_name:
harness_class = getattr(thismodule, harness_name)
else:
harness_class = getattr(thismodule, 'Test')
return harness_class()
try:
if harness_name:
harness_class = getattr(thismodule, harness_name)
else:
harness_class = getattr(thismodule, 'Test')
return harness_class()
except AttributeError as e:
logger.debug(f"harness {harness_name} not implemented: {e}")
return None
5 changes: 3 additions & 2 deletions scripts/pylib/twister/twisterlib/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,8 +1055,9 @@ def build(self):
harness = HarnessImporter.get_harness(self.instance.testsuite.harness.capitalize())
build_result = self.run_build(['--build', self.build_dir])
try:
harness.instance = self.instance
harness.build()
if harness:
harness.instance = self.instance
harness.build()
except ConfigurationError as error:
self.instance.status = "error"
self.instance.reason = str(error)
Expand Down

0 comments on commit 4e72696

Please sign in to comment.