File: test-driver.py

package info (click to toggle)
qemu 1%3A7.2%2Bdfsg-7%2Bdeb12u16
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-proposed-updates
  • size: 291,516 kB
  • sloc: ansic: 2,702,024; pascal: 112,708; python: 62,697; sh: 50,281; asm: 48,732; makefile: 17,260; cpp: 9,441; perl: 8,084; xml: 2,911; objc: 1,870; php: 1,299; tcl: 1,188; yacc: 604; lex: 363; sql: 71; awk: 35; sed: 11; javascript: 7
file content (35 lines) | stat: -rw-r--r-- 1,041 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! /usr/bin/env python3

# Wrapper for tests that hides the output if they succeed.
# Used by "make check"
#
# Copyright (C) 2020 Red Hat, Inc.
#
# Author: Paolo Bonzini <pbonzini@redhat.com>

import subprocess
import sys
import os
import argparse

parser = argparse.ArgumentParser(description='Test driver for QEMU')
parser.add_argument('-C', metavar='DIR', dest='dir', default='.',
                    help='change to DIR before doing anything else')
parser.add_argument('-v', '--verbose', dest='verbose', action='store_true',
                    help='be more verbose')
parser.add_argument('test_args', nargs=argparse.REMAINDER)

args = parser.parse_args()
os.chdir(args.dir)

test_args = args.test_args
if test_args[0] == '--':
    test_args = test_args[1:]

if args.verbose:
    result = subprocess.run(test_args, stdout=None, stderr=None)
else:
    result = subprocess.run(test_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    if result.returncode:
        sys.stdout.buffer.write(result.stdout)
sys.exit(result.returncode)