From dde7ea54b857ffbd26f082d7e89538a55d033e52 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Wed, 10 Jan 2024 09:49:26 -0500 Subject: [PATCH] twister: hotfix for unimplemented harnesses 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 --- scripts/pylib/twister/twisterlib/harness.py | 14 +++++++++----- scripts/pylib/twister/twisterlib/runner.py | 5 +++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/scripts/pylib/twister/twisterlib/harness.py b/scripts/pylib/twister/twisterlib/harness.py index a70601e3de3c..bfdcb107ec8f 100644 --- a/scripts/pylib/twister/twisterlib/harness.py +++ b/scripts/pylib/twister/twisterlib/harness.py @@ -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 diff --git a/scripts/pylib/twister/twisterlib/runner.py b/scripts/pylib/twister/twisterlib/runner.py index bfaa5939fe2a..9ef53b386c9c 100644 --- a/scripts/pylib/twister/twisterlib/runner.py +++ b/scripts/pylib/twister/twisterlib/runner.py @@ -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)