Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

twister: Fix toolchain assignment for posix #83762

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions scripts/pylib/twister/twisterlib/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# SPDX-License-Identifier: Apache-2.0

import argparse
import json

Check warning on line 11 in scripts/pylib/twister/twisterlib/environment.py

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

W0611

scripts/pylib/twister/twisterlib/environment.py:11 Unused import json (unused-import)

Check failure on line 11 in scripts/pylib/twister/twisterlib/environment.py

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

Python lint error (F401) see https://docs.astral.sh/ruff/rules/unused-import

scripts/pylib/twister/twisterlib/environment.py:11 `json` imported but unused
import logging
import os
import re
Expand All @@ -23,7 +23,7 @@
import zephyr_module
from twisterlib.constants import SUPPORTED_SIMS
from twisterlib.coverage import supported_coverage_formats
from twisterlib.error import TwisterRuntimeError

Check warning on line 26 in scripts/pylib/twister/twisterlib/environment.py

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

W0611

scripts/pylib/twister/twisterlib/environment.py:26 Unused TwisterRuntimeError imported from twisterlib.error (unused-import)

Check failure on line 26 in scripts/pylib/twister/twisterlib/environment.py

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

Python lint error (F401) see https://docs.astral.sh/ruff/rules/unused-import

scripts/pylib/twister/twisterlib/environment.py:26 `twisterlib.error.TwisterRuntimeError` imported but unused
from twisterlib.log_helper import log_command

logger = logging.getLogger('twister')
Expand Down Expand Up @@ -1143,14 +1143,6 @@
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.")
7 changes: 5 additions & 2 deletions scripts/pylib/twister/twisterlib/testplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading