qemu/scripts/test-driver.py
<<
>>
Prefs
   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
  10import subprocess
  11import sys
  12import os
  13import argparse
  14
  15parser = argparse.ArgumentParser(description='Test driver for QEMU')
  16parser.add_argument('-C', metavar='DIR', dest='dir', default='.',
  17                    help='change to DIR before doing anything else')
  18parser.add_argument('-v', '--verbose', dest='verbose', action='store_true',
  19                    help='be more verbose')
  20parser.add_argument('test_args', nargs=argparse.REMAINDER)
  21
  22args = parser.parse_args()
  23os.chdir(args.dir)
  24
  25test_args = args.test_args
  26if test_args[0] == '--':
  27    test_args = test_args[1:]
  28
  29if args.verbose:
  30    result = subprocess.run(test_args, stdout=None, stderr=None)
  31else:
  32    result = subprocess.run(test_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  33    if result.returncode:
  34        sys.stdout.buffer.write(result.stdout)
  35sys.exit(result.returncode)
  36