[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/19] qemu-iotests: let "check" spawn an arbitrary test command
From: |
Max Reitz |
Subject: |
[PULL 08/19] qemu-iotests: let "check" spawn an arbitrary test command |
Date: |
Fri, 14 May 2021 18:45:03 +0200 |
From: Paolo Bonzini <pbonzini@redhat.com>
Right now there is no easy way for "check" to print a reproducer command.
Because such a reproducer command line would be huge, we can instead teach
check to start a command of our choice. This can be for example a Python
unit test with arguments to only run a specific subtest.
Move the trailing empty line to print_env(), since it always looks better
and one caller was not adding it.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Tested-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-Id: <20210323181928.311862-5-pbonzini@redhat.com>
Message-Id: <20210503110110.476887-5-pbonzini@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
tests/qemu-iotests/check | 19 ++++++++++++++++++-
tests/qemu-iotests/testenv.py | 3 ++-
tests/qemu-iotests/testrunner.py | 1 -
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index 08f51366f1..2dd529eb75 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -19,6 +19,9 @@
import os
import sys
import argparse
+import shutil
+from pathlib import Path
+
from findtests import TestFinder
from testenv import TestEnv
from testrunner import TestRunner
@@ -100,7 +103,7 @@ def make_argparser() -> argparse.ArgumentParser:
'rerun failed ./check command, starting from the '
'middle of the process.')
g_sel.add_argument('tests', metavar='TEST_FILES', nargs='*',
- help='tests to run')
+ help='tests to run, or "--" followed by a command')
return p
@@ -113,6 +116,20 @@ if __name__ == '__main__':
imgopts=args.imgopts, misalign=args.misalign,
debug=args.debug, valgrind=args.valgrind)
+ if len(sys.argv) > 1 and sys.argv[-len(args.tests)-1] == '--':
+ if not args.tests:
+ sys.exit("missing command after '--'")
+ cmd = args.tests
+ env.print_env()
+ exec_pathstr = shutil.which(cmd[0])
+ if exec_pathstr is None:
+ sys.exit('command not found: ' + cmd[0])
+ exec_path = Path(exec_pathstr).resolve()
+ cmd[0] = str(exec_path)
+ full_env = env.prepare_subprocess(cmd)
+ os.chdir(exec_path.parent)
+ os.execve(cmd[0], cmd, full_env)
+
testfinder = TestFinder(test_dir=env.source_iotests)
groups = args.groups.split(',') if args.groups else None
diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py
index fca3a609e0..cd0e39b789 100644
--- a/tests/qemu-iotests/testenv.py
+++ b/tests/qemu-iotests/testenv.py
@@ -284,7 +284,8 @@ def print_env(self) -> None:
PLATFORM -- {platform}
TEST_DIR -- {TEST_DIR}
SOCK_DIR -- {SOCK_DIR}
-SOCKET_SCM_HELPER -- {SOCKET_SCM_HELPER}"""
+SOCKET_SCM_HELPER -- {SOCKET_SCM_HELPER}
+"""
args = collections.defaultdict(str, self.get_env())
diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py
index 519924dc81..2f56ac545d 100644
--- a/tests/qemu-iotests/testrunner.py
+++ b/tests/qemu-iotests/testrunner.py
@@ -316,7 +316,6 @@ def run_tests(self, tests: List[str]) -> bool:
if not self.makecheck:
self.env.print_env()
- print()
test_field_width = max(len(os.path.basename(t)) for t in tests) + 2
--
2.31.1
- [PULL 01/19] iotests/231: Update expected deprecation message, (continued)
- [PULL 01/19] iotests/231: Update expected deprecation message, Max Reitz, 2021/05/14
- [PULL 04/19] mirror: stop cancelling in-flight requests on non-force cancel in READY, Max Reitz, 2021/05/14
- [PULL 02/19] block/rbd: Add an escape-aware strchr helper, Max Reitz, 2021/05/14
- [PULL 06/19] qemu-iotests: allow passing unittest.main arguments to the test scripts, Max Reitz, 2021/05/14
- [PULL 05/19] qemu-iotests: do not buffer the test output, Max Reitz, 2021/05/14
- [PULL 09/19] qemu-iotests: fix case of SOCK_DIR already in the environment, Max Reitz, 2021/05/14
- [PULL 07/19] qemu-iotests: move command line and environment handling from TestRunner to TestEnv, Max Reitz, 2021/05/14
- [PULL 03/19] monitor: hmp_qemu_io: acquire aio contex, fix crash, Max Reitz, 2021/05/14
- [PULL 08/19] qemu-iotests: let "check" spawn an arbitrary test command,
Max Reitz <=
- [PULL 12/19] qemu-iotests: fix pylint 2.8 consider-using-with error, Max Reitz, 2021/05/14
- [PULL 11/19] block/copy-on-read: use bdrv_drop_filter() and drop s->active, Max Reitz, 2021/05/14
- [PULL 10/19] Document qemu-img options data_file and data_file_raw, Max Reitz, 2021/05/14
- [PULL 14/19] block: drop write notifiers, Max Reitz, 2021/05/14
- [PULL 13/19] block/write-threshold: don't use write notifiers, Max Reitz, 2021/05/14
- [PULL 15/19] test-write-threshold: rewrite test_threshold_(not_)trigger tests, Max Reitz, 2021/05/14
- [PULL 16/19] block/write-threshold: drop extra APIs, Max Reitz, 2021/05/14
- [PULL 17/19] test-write-threshold: drop extra tests, Max Reitz, 2021/05/14
- [PULL 18/19] test-write-threshold: drop extra TestStruct structure, Max Reitz, 2021/05/14
- [PULL 19/19] write-threshold: deal with includes, Max Reitz, 2021/05/14