summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Honscheid <honscheid@google.com>2022-08-15 16:15:18 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-16 21:07:55 +0000
commit40e0183a6ab68e5d22528bdf6d54c52dc95f2589 (patch)
tree5cbe967e666f9ec4610211189227f4ce6fa7aa3d
parent9825445cdfa6ab45c4005d80b60897e9aed0a131 (diff)
downloadchrome-ec-40e0183a6ab68e5d22528bdf6d54c52dc95f2589.tar.gz
zephyr: twister: Allow overriding toolchain options
Allow overriding the TOOLCHAIN_ROOT and ZEPHYR_TOOLCHAIN_VARIANT environment variables, as well as the --gcov-tool CLI parameter. This is necessary for running tests with GCC outside of the chroot, such as in Gitlab. By default, the usual LLVM toolchain is used and there is no impact on users. BUG=b:242067249 BRANCH=None TEST=./twister -v -v Signed-off-by: Tristan Honscheid <honscheid@google.com> Change-Id: I2369c251ac43d05bc0246d8e1b35e1bc4a28b783 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3831536 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
-rwxr-xr-xutil/twister_launcher.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/util/twister_launcher.py b/util/twister_launcher.py
index 9725aa03a6..aad4a05931 100755
--- a/util/twister_launcher.py
+++ b/util/twister_launcher.py
@@ -90,12 +90,16 @@ def main():
zephyr_modules = find_modules(zephyr_modules_dir)
zephyr_modules.append(ec_base)
- # Prepare environment variables for export to Twister and inherit the
- # parent environment.
+ # Prepare environment variables for export to Twister. Inherit the parent
+ # process's environment, but set some default values if not already set.
twister_env = dict(os.environ)
extra_env_vars = {
- "TOOLCHAIN_ROOT": str(ec_base / "zephyr"),
- "ZEPHYR_TOOLCHAIN_VARIANT": "llvm",
+ "TOOLCHAIN_ROOT": os.environ.get(
+ "TOOLCHAIN_ROOT", str(ec_base / "zephyr")
+ ),
+ "ZEPHYR_TOOLCHAIN_VARIANT": os.environ.get(
+ "ZEPHYR_TOOLCHAIN_VARIANT", "llvm"
+ ),
}
twister_env.update(extra_env_vars)
@@ -107,8 +111,6 @@ def main():
f"-x=SYSCALL_INCLUDE_DIRS={str(ec_base / 'zephyr' / 'include' / 'drivers')}",
f"-x=ZEPHYR_BASE={zephyr_base}",
f"-x=ZEPHYR_MODULES={';'.join([str(p) for p in zephyr_modules])}",
- "--gcov-tool",
- ec_base / "util" / "llvm-gcov.sh",
]
# `-T` flags (used for specifying test directories to build and run)
@@ -122,6 +124,9 @@ def main():
parser = argparse.ArgumentParser(add_help=False, allow_abbrev=False)
parser.add_argument("-T", "--testsuite-root", action="append")
parser.add_argument("-v", "--verbose", action="count", default=0)
+ parser.add_argument(
+ "--gcov-tool", default=str(ec_base / "util" / "llvm-gcov.sh")
+ )
intercepted_args, other_args = parser.parse_known_args()
for _ in range(intercepted_args.verbose):
@@ -138,6 +143,15 @@ def main():
twister_cli.extend(["-T", str(ec_base)])
twister_cli.extend(["-T", str(zephyr_base / "tests/subsys/shell")])
+ # Pass through the chosen coverage tool, or fall back on the default choice
+ # (see add_argument above).
+ twister_cli.extend(
+ [
+ "--gcov-tool",
+ intercepted_args.gcov_tool,
+ ]
+ )
+
# Append additional user-supplied args
twister_cli.extend(other_args)