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

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