From 17fc84a4f60536d5a761ffbd058c9d5f992b6e5f Mon Sep 17 00:00:00 2001 From: Keith Short Date: Thu, 9 Jan 2025 14:16:37 -0700 Subject: [PATCH] twister: Fix toolchain assignment for posix twister was unconditionally setting the toolchain to "host" for the "posix" and "unit" architectures, clobbering the toolchain setup in the environment. Signed-off-by: Keith Short --- scripts/pylib/twister/twisterlib/environment.py | 14 +++----------- scripts/pylib/twister/twisterlib/testplan.py | 7 +++++-- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/scripts/pylib/twister/twisterlib/environment.py b/scripts/pylib/twister/twisterlib/environment.py index 0cf1ea18ce6f7c..985373d6905ea3 100644 --- a/scripts/pylib/twister/twisterlib/environment.py +++ b/scripts/pylib/twister/twisterlib/environment.py @@ -1143,14 +1143,6 @@ def run_cmake_script(args=None): return results def get_toolchain(self): - toolchain_script = Path(ZEPHYR_BASE) / Path('cmake/verify-toolchain.cmake') - result = self.run_cmake_script([toolchain_script, "FORMAT=json"]) - - try: - if result['returncode']: - raise TwisterRuntimeError(f"E: {result['returnmsg']}") - except Exception as e: - print(str(e)) - sys.exit(2) - self.toolchain = json.loads(result['stdout'])['ZEPHYR_TOOLCHAIN_VARIANT'] - logger.info(f"Using '{self.toolchain}' toolchain.") + self.toolchain = os.environ.get("ZEPHYR_TOOLCHAIN_VARIANT") + if self.toolchain: + logger.info(f"Using '{self.toolchain}' toolchain.") diff --git a/scripts/pylib/twister/twisterlib/testplan.py b/scripts/pylib/twister/twisterlib/testplan.py index 7c29df275ebabb..f1694af741f1b2 100755 --- a/scripts/pylib/twister/twisterlib/testplan.py +++ b/scripts/pylib/twister/twisterlib/testplan.py @@ -898,9 +898,12 @@ def apply_filters(self, **kwargs): ): if itoolchain: toolchain = itoolchain + elif self.env.toolchain: + toolchain = self.env.toolchain + elif plat.arch in ['posix', 'unit']: + toolchain = "host" else: - default_toolchain = "zephyr" if not self.env.toolchain else self.env.toolchain - toolchain = default_toolchain if plat.arch not in ['posix', 'unit'] else "host" + toolchain = "zephyr" instance = TestInstance(ts, plat, toolchain, self.env.outdir) instance.run = instance.check_runnable(