mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
qemu-iotests: let "check" spawn an arbitrary test command
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>
This commit is contained in:
parent
c64430d238
commit
480b75ee14
3 changed files with 20 additions and 3 deletions
|
@ -19,6 +19,9 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
|
import shutil
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from findtests import TestFinder
|
from findtests import TestFinder
|
||||||
from testenv import TestEnv
|
from testenv import TestEnv
|
||||||
from testrunner import TestRunner
|
from testrunner import TestRunner
|
||||||
|
@ -100,7 +103,7 @@ def make_argparser() -> argparse.ArgumentParser:
|
||||||
'rerun failed ./check command, starting from the '
|
'rerun failed ./check command, starting from the '
|
||||||
'middle of the process.')
|
'middle of the process.')
|
||||||
g_sel.add_argument('tests', metavar='TEST_FILES', nargs='*',
|
g_sel.add_argument('tests', metavar='TEST_FILES', nargs='*',
|
||||||
help='tests to run')
|
help='tests to run, or "--" followed by a command')
|
||||||
|
|
||||||
return p
|
return p
|
||||||
|
|
||||||
|
@ -113,6 +116,20 @@ if __name__ == '__main__':
|
||||||
imgopts=args.imgopts, misalign=args.misalign,
|
imgopts=args.imgopts, misalign=args.misalign,
|
||||||
debug=args.debug, valgrind=args.valgrind)
|
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)
|
testfinder = TestFinder(test_dir=env.source_iotests)
|
||||||
|
|
||||||
groups = args.groups.split(',') if args.groups else None
|
groups = args.groups.split(',') if args.groups else None
|
||||||
|
|
|
@ -284,7 +284,8 @@ IMGPROTO -- {IMGPROTO}
|
||||||
PLATFORM -- {platform}
|
PLATFORM -- {platform}
|
||||||
TEST_DIR -- {TEST_DIR}
|
TEST_DIR -- {TEST_DIR}
|
||||||
SOCK_DIR -- {SOCK_DIR}
|
SOCK_DIR -- {SOCK_DIR}
|
||||||
SOCKET_SCM_HELPER -- {SOCKET_SCM_HELPER}"""
|
SOCKET_SCM_HELPER -- {SOCKET_SCM_HELPER}
|
||||||
|
"""
|
||||||
|
|
||||||
args = collections.defaultdict(str, self.get_env())
|
args = collections.defaultdict(str, self.get_env())
|
||||||
|
|
||||||
|
|
|
@ -316,7 +316,6 @@ class TestRunner(ContextManager['TestRunner']):
|
||||||
|
|
||||||
if not self.makecheck:
|
if not self.makecheck:
|
||||||
self.env.print_env()
|
self.env.print_env()
|
||||||
print()
|
|
||||||
|
|
||||||
test_field_width = max(len(os.path.basename(t)) for t in tests) + 2
|
test_field_width = max(len(os.path.basename(t)) for t in tests) + 2
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue