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

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