Blame SOURCES/kvm-qemu-iotests-iotests.py-helper-for-non-file-protocol.patch

383d26
From a50830277403643e090bec4bfe7cf77d693f90e8 Mon Sep 17 00:00:00 2001
383d26
From: Kevin Wolf <kwolf@redhat.com>
383d26
Date: Tue, 26 Jun 2018 09:48:45 +0200
383d26
Subject: [PATCH 76/89] qemu-iotests: iotests.py helper for non-file protocols
383d26
383d26
RH-Author: Kevin Wolf <kwolf@redhat.com>
383d26
Message-id: <20180626094856.6924-63-kwolf@redhat.com>
383d26
Patchwork-id: 81081
383d26
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 62/73] qemu-iotests: iotests.py helper for non-file protocols
383d26
Bugzilla: 1513543
383d26
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
383d26
RH-Acked-by: Max Reitz <mreitz@redhat.com>
383d26
RH-Acked-by: Fam Zheng <famz@redhat.com>
383d26
383d26
This adds two helper functions that are useful for test cases that make
383d26
use of a non-file protocol (specifically ssh).
383d26
383d26
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
383d26
Reviewed-by: Max Reitz <mreitz@redhat.com>
383d26
Reviewed-by: Jeff Cody <jcody@redhat.com>
383d26
(cherry picked from commit 5a259e868b308564de9f2bfaef0606074a4f9028)
383d26
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 tests/qemu-iotests/iotests.py | 17 +++++++++++++++++
383d26
 1 file changed, 17 insertions(+)
383d26
383d26
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
383d26
index 390da6b..9f1759d 100644
383d26
--- a/tests/qemu-iotests/iotests.py
383d26
+++ b/tests/qemu-iotests/iotests.py
383d26
@@ -312,6 +312,13 @@ def file_path(*names):
383d26
 
383d26
     return paths[0] if len(paths) == 1 else paths
383d26
 
383d26
+def remote_filename(path):
383d26
+    if imgproto == 'file':
383d26
+        return path
383d26
+    elif imgproto == 'ssh':
383d26
+        return "ssh://127.0.0.1%s" % (path)
383d26
+    else:
383d26
+        raise Exception("Protocol %s not supported" % (imgproto))
383d26
 
383d26
 class VM(qtest.QEMUQtestMachine):
383d26
     '''A QEMU VM'''
383d26
@@ -610,6 +617,16 @@ def verify_image_format(supported_fmts=[], unsupported_fmts=[]):
383d26
     if not_sup or (imgfmt in unsupported_fmts):
383d26
         notrun('not suitable for this image format: %s' % imgfmt)
383d26
 
383d26
+def verify_protocol(supported=[], unsupported=[]):
383d26
+    assert not (supported and unsupported)
383d26
+
383d26
+    if 'generic' in supported:
383d26
+        return
383d26
+
383d26
+    not_sup = supported and (imgproto not in supported)
383d26
+    if not_sup or (imgproto in unsupported):
383d26
+        notrun('not suitable for this protocol: %s' % imgproto)
383d26
+
383d26
 def verify_platform(supported_oses=['linux']):
383d26
     if True not in [sys.platform.startswith(x) for x in supported_oses]:
383d26
         notrun('not suitable for this OS: %s' % sys.platform)
383d26
-- 
383d26
1.8.3.1
383d26