cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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