]> git.proxmox.com Git - mirror_qemu.git/blob - scripts/test-driver.py
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20210709' into...
[mirror_qemu.git] / scripts / test-driver.py
1 #! /usr/bin/env python3
2
3 # Wrapper for tests that hides the output if they succeed.
4 # Used by "make check"
5 #
6 # Copyright (C) 2020 Red Hat, Inc.
7 #
8 # Author: Paolo Bonzini <pbonzini@redhat.com>
9
10 import subprocess
11 import sys
12 import os
13 import argparse
14
15 parser = argparse.ArgumentParser(description='Test driver for QEMU')
16 parser.add_argument('-C', metavar='DIR', dest='dir', default='.',
17 help='change to DIR before doing anything else')
18 parser.add_argument('-v', '--verbose', dest='verbose', action='store_true',
19 help='be more verbose')
20 parser.add_argument('test_args', nargs=argparse.REMAINDER)
21
22 args = parser.parse_args()
23 os.chdir(args.dir)
24
25 test_args = args.test_args
26 if test_args[0] == '--':
27 test_args = test_args[1:]
28
29 if args.verbose:
30 result = subprocess.run(test_args, stdout=None, stderr=None)
31 else:
32 result = subprocess.run(test_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
33 if result.returncode:
34 sys.stdout.buffer.write(result.stdout)
35 sys.exit(result.returncode)