yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
26ba25
From 2491da98d7e2b2026075fb1ab87bc1a242f3dd1e Mon Sep 17 00:00:00 2001
26ba25
From: Max Reitz <mreitz@redhat.com>
26ba25
Date: Mon, 18 Jun 2018 16:43:11 +0200
26ba25
Subject: [PATCH 052/268] iotests.py: Add qemu_io_silent
26ba25
26ba25
RH-Author: Max Reitz <mreitz@redhat.com>
26ba25
Message-id: <20180618164312.24423-5-mreitz@redhat.com>
26ba25
Patchwork-id: 80777
26ba25
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 4/5] iotests.py: Add qemu_io_silent
26ba25
Bugzilla: 1519617
26ba25
RH-Acked-by: John Snow <jsnow@redhat.com>
26ba25
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
26ba25
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
26ba25
With qemu-io now returning a useful exit code, some tests may find it
26ba25
sufficient to just query that instead of logging (and filtering) the
26ba25
whole output.
26ba25
26ba25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26ba25
Reviewed-by: Eric Blake <eblake@redhat.com>
26ba25
Message-id: 20180509194302.21585-5-mreitz@redhat.com
26ba25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26ba25
(cherry picked from commit 745f2bf4a5b973d1a69b21db97f9e4219da60624)
26ba25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
---
26ba25
 tests/qemu-iotests/iotests.py | 9 +++++++++
26ba25
 1 file changed, 9 insertions(+)
26ba25
26ba25
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
26ba25
index 26e6046..2ce85a1 100644
26ba25
--- a/tests/qemu-iotests/iotests.py
26ba25
+++ b/tests/qemu-iotests/iotests.py
26ba25
@@ -120,6 +120,15 @@ def qemu_io(*args):
26ba25
         sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitcode, ' '.join(args)))
26ba25
     return subp.communicate()[0]
26ba25
 
26ba25
+def qemu_io_silent(*args):
26ba25
+    '''Run qemu-io and return the exit code, suppressing stdout'''
26ba25
+    args = qemu_io_args + list(args)
26ba25
+    exitcode = subprocess.call(args, stdout=open('/dev/null', 'w'))
26ba25
+    if exitcode < 0:
26ba25
+        sys.stderr.write('qemu-io received signal %i: %s\n' %
26ba25
+                         (-exitcode, ' '.join(args)))
26ba25
+    return exitcode
26ba25
+
26ba25
 
26ba25
 class QemuIoInteractive:
26ba25
     def __init__(self, *args):
26ba25
-- 
26ba25
1.8.3.1
26ba25