From bb70152df927282e4404c5390880c783f8f2dcd5 Mon Sep 17 00:00:00 2001
From: Douglas Raillard <douglas.raillard@arm.com>
Date: Tue, 30 Jul 2024 12:23:46 +0100
Subject: [PATCH] lisa._kmod: Forbid empty toolchain-path

FIX

Make sure an empty string for toolchain-path is not treated the same way
as no toolchain-path specified.
---
 lisa/_kmod.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisa/_kmod.py b/lisa/_kmod.py
index 13d41fe55..d22bbb3f7 100644
--- a/lisa/_kmod.py
+++ b/lisa/_kmod.py
@@ -1489,6 +1489,7 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor):
     def _make_toolchain_env(cls, toolchain_path=None, env=None):
         env = env or os.environ
         if toolchain_path is not None:
+            assert toolchain_path
             path = env.get('PATH', '')
             env = {
                 **env,
@@ -1715,13 +1716,13 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor):
             toolchain_path = build_conf['build-env-settings']['host'].get('toolchain-path', None)
 
             def is_in_toolchain_path(cc, cross_compile):
-                if toolchain_path:
+                if toolchain_path is None:
+                    return True
+                else:
                     cmd = cc_cmd(cc, cross_compile, opts=[])
                     bin_, *_ = cmd
                     bin_ = shutil.which(bin_, path=toolchain_path)
                     return bin_ is not None
-                else:
-                    return True
 
             ccs = [
                 (cc, cross_compile)
-- 
GitLab