aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/qemu_test/cmd.py
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2024-12-17 15:59:25 +0000
committerThomas Huth <thuth@redhat.com>2024-12-17 19:39:53 +0100
commit0da341a78f00d6feae98f38d1dfbe2e9f88d0b93 (patch)
tree48591e7113f35c84d88e351dd7c646d280a90d8e /tests/functional/qemu_test/cmd.py
parentc27f452d61a4741605da2e03c0e6c756dd249f25 (diff)
downloadqemu-0da341a78f00d6feae98f38d1dfbe2e9f88d0b93.zip
qemu-0da341a78f00d6feae98f38d1dfbe2e9f88d0b93.tar.gz
qemu-0da341a78f00d6feae98f38d1dfbe2e9f88d0b93.tar.bz2
tests/functional: remove duplicated 'which' function impl
Put the 'which' function into shared code. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20241217155953.3950506-5-berrange@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/functional/qemu_test/cmd.py')
-rw-r--r--tests/functional/qemu_test/cmd.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/functional/qemu_test/cmd.py b/tests/functional/qemu_test/cmd.py
index 11c8334..4106f1e 100644
--- a/tests/functional/qemu_test/cmd.py
+++ b/tests/functional/qemu_test/cmd.py
@@ -18,6 +18,16 @@ import subprocess
from .config import BUILD_DIR
+def which(tool):
+ """ looks up the full path for @tool, returns None if not found
+ or if @tool does not have executable permissions.
+ """
+ paths=os.getenv('PATH')
+ for p in paths.split(os.path.pathsep):
+ p = os.path.join(p, tool)
+ if os.path.exists(p) and os.access(p, os.X_OK):
+ return p
+ return None
def has_cmd(name, args=None):
"""