[PATCH v2 02/15] KVM: selftests: Enable selftests runner to find executables in different path
Vipin Sharma
vipinsh at google.com
Fri Jun 6 16:56:06 PDT 2025
Add command line option, --executable/-e, to specify a directory where
test binaries are present. If this option is not provided then default
to the current directory.
Example:
python3 runner --test-dirs test -e ~/build/selftests
This option enables executing tests from out-of-tree builds.
Signed-off-by: Vipin Sharma <vipinsh at google.com>
---
tools/testing/selftests/kvm/runner/__main__.py | 8 +++++++-
tools/testing/selftests/kvm/runner/selftest.py | 4 ++--
tools/testing/selftests/kvm/runner/test_runner.py | 4 ++--
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/kvm/runner/__main__.py b/tools/testing/selftests/kvm/runner/__main__.py
index b2c85606c516..599300831504 100644
--- a/tools/testing/selftests/kvm/runner/__main__.py
+++ b/tools/testing/selftests/kvm/runner/__main__.py
@@ -29,6 +29,12 @@ def cli():
default=[],
help="Run tests in the given directory and all of its sub directories. Provide the space separated paths to add multiple directories.")
+ parser.add_argument("-e",
+ "--executable",
+ nargs='?',
+ default=".",
+ help="Finds the test executables in the given directory. Default is the current directory.")
+
return parser.parse_args()
@@ -85,7 +91,7 @@ def main():
args = cli()
setup_logging(args)
test_files = fetch_test_files(args)
- return TestRunner(test_files).start()
+ return TestRunner(test_files, args).start()
if __name__ == "__main__":
diff --git a/tools/testing/selftests/kvm/runner/selftest.py b/tools/testing/selftests/kvm/runner/selftest.py
index cc56c45b1c93..a0b06f150087 100644
--- a/tools/testing/selftests/kvm/runner/selftest.py
+++ b/tools/testing/selftests/kvm/runner/selftest.py
@@ -30,12 +30,12 @@ class Selftest:
Extract the test execution command from test file and executes it.
"""
- def __init__(self, test_path):
+ def __init__(self, test_path, executable_dir):
test_command = pathlib.Path(test_path).read_text().strip()
if not test_command:
raise ValueError("Empty test command in " + test_path)
- test_command = os.path.join(".", test_command)
+ test_command = os.path.join(executable_dir, test_command)
self.exists = os.path.isfile(test_command.split(maxsplit=1)[0])
self.test_path = test_path
self.command = command.Command(test_command)
diff --git a/tools/testing/selftests/kvm/runner/test_runner.py b/tools/testing/selftests/kvm/runner/test_runner.py
index 20ea523629de..104f0b4c2e4e 100644
--- a/tools/testing/selftests/kvm/runner/test_runner.py
+++ b/tools/testing/selftests/kvm/runner/test_runner.py
@@ -11,11 +11,11 @@ logger = logging.getLogger("runner")
class TestRunner:
- def __init__(self, test_files):
+ def __init__(self, test_files, args):
self.tests = []
for test_file in test_files:
- self.tests.append(Selftest(test_file))
+ self.tests.append(Selftest(test_file, args.executable))
def _log_result(self, test_result):
logger.log(test_result.status,
--
2.50.0.rc0.604.gd4ff7b7c86-goog
More information about the linux-arm-kernel
mailing list