[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 04/32] tests/functional: remove duplicated 'which' function im
From: |
Daniel P . Berrangé |
Subject: |
[PATCH v3 04/32] tests/functional: remove duplicated 'which' function impl |
Date: |
Tue, 17 Dec 2024 15:59:25 +0000 |
Put the 'which' function into shared code.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
tests/functional/qemu_test/__init__.py | 2 +-
tests/functional/qemu_test/cmd.py | 10 ++++++++++
tests/functional/test_acpi_bits.py | 13 +------------
tests/functional/test_ppc64_hv.py | 13 +------------
4 files changed, 13 insertions(+), 25 deletions(-)
diff --git a/tests/functional/qemu_test/__init__.py
b/tests/functional/qemu_test/__init__.py
index 67f87be9c4..8fddddbe67 100644
--- a/tests/functional/qemu_test/__init__.py
+++ b/tests/functional/qemu_test/__init__.py
@@ -10,6 +10,6 @@
from .config import BUILD_DIR
from .cmd import has_cmd, has_cmds, run_cmd, is_readable_executable_file, \
interrupt_interactive_console_until_pattern, wait_for_console_pattern, \
- exec_command, exec_command_and_wait_for_pattern, get_qemu_img
+ exec_command, exec_command_and_wait_for_pattern, get_qemu_img, which
from .testcase import QemuBaseTest, QemuUserTest, QemuSystemTest
from .linuxkernel import LinuxKernelTest
diff --git a/tests/functional/qemu_test/cmd.py
b/tests/functional/qemu_test/cmd.py
index 11c8334a7c..4106f1ee7c 100644
--- a/tests/functional/qemu_test/cmd.py
+++ b/tests/functional/qemu_test/cmd.py
@@ -18,6 +18,16 @@
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):
"""
diff --git a/tests/functional/test_acpi_bits.py
b/tests/functional/test_acpi_bits.py
index 3df9562394..1e6d082ecb 100755
--- a/tests/functional/test_acpi_bits.py
+++ b/tests/functional/test_acpi_bits.py
@@ -47,7 +47,7 @@
)
from qemu.machine import QEMUMachine
from unittest import skipIf
-from qemu_test import QemuSystemTest, Asset
+from qemu_test import QemuSystemTest, Asset, which
deps = ["xorriso", "mformat"] # dependent tools needed in the test setup/box.
supported_platforms = ['x86_64'] # supported test platforms.
@@ -55,17 +55,6 @@
# default timeout of 120 secs is sometimes not enough for bits test.
BITS_TIMEOUT = 200
-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 missing_deps():
""" returns True if any of the test dependent tools are absent.
"""
diff --git a/tests/functional/test_ppc64_hv.py
b/tests/functional/test_ppc64_hv.py
index d97b62e364..7c6f8234f5 100755
--- a/tests/functional/test_ppc64_hv.py
+++ b/tests/functional/test_ppc64_hv.py
@@ -11,7 +11,7 @@
from unittest import skipIf, skipUnless
from qemu_test import QemuSystemTest, Asset
-from qemu_test import wait_for_console_pattern, exec_command
+from qemu_test import wait_for_console_pattern, exec_command, which
import os
import time
import subprocess
@@ -19,17 +19,6 @@
deps = ["xorriso"] # dependent tools needed in the test setup/box.
-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 missing_deps():
""" returns True if any of the test dependent tools are absent.
"""
--
2.46.0
- [PATCH v3 00/32] tests/functional: various improvements wrt assets/scratch files, Daniel P . Berrangé, 2024/12/17
- [PATCH v3 01/32] tests/functional: add execute permission to aspeed tests, Daniel P . Berrangé, 2024/12/17
- [PATCH v3 02/32] tests/functional: remove many unused imports, Daniel P . Berrangé, 2024/12/17
- [PATCH v3 04/32] tests/functional: remove duplicated 'which' function impl,
Daniel P . Berrangé <=
- [PATCH v3 05/32] tests/functional: simplify 'which' implementation, Daniel P . Berrangé, 2024/12/17
- [PATCH v3 03/32] tests/functional: resolve str(Asset) to cache file path, Daniel P . Berrangé, 2024/12/17
- [PATCH v3 06/32] tests/functional: drop 'tesseract_available' helper, Daniel P . Berrangé, 2024/12/17
- [PATCH v3 07/32] tests/functional: introduce some helpful decorators, Daniel P . Berrangé, 2024/12/17
- [PATCH v3 08/32] tests/functional: switch to new test skip decorators, Daniel P . Berrangé, 2024/12/17
- [PATCH v3 10/32] tests/functional: add helpers for building file paths, Daniel P . Berrangé, 2024/12/17
- [PATCH v3 09/32] tests/functional: drop 'has_cmd' and 'has_cmds' helpers, Daniel P . Berrangé, 2024/12/17
- [PATCH v3 11/32] tests/functional: switch over to using self.log_file(...), Daniel P . Berrangé, 2024/12/17