qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-block] [PATCH 2/3] iotests: Add python functions for using sample


From: Colin Lord
Subject: [Qemu-block] [PATCH 2/3] iotests: Add python functions for using sample images
Date: Mon, 11 Jul 2016 15:50:35 -0400

This adds a python equivalent of the _use_sample_img and _rm_sample_img
testing functions.

Signed-off-by: Colin Lord <address@hidden>
---
 tests/qemu-iotests/iotests.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 1687c33..3ba0de2 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -29,6 +29,7 @@ import qmp
 import qtest
 import struct
 import json
+import bz2
 
 
 # This will not work if arguments contain spaces but is necessary if we
@@ -53,6 +54,20 @@ cachemode = os.environ.get('CACHEMODE')
 qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE')
 
 socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper')
+sample_img_dir = os.environ.get('SAMPLE_IMG_DIR')
+
+def use_sample_image(sample_image_file):
+    sample_img_path = os.path.join(sample_img_dir, sample_image_file + '.bz2')
+    sample_img_file = bz2.BZ2File(sample_img_path)
+    output_img_path = os.path.join(test_dir, sample_image_file)
+    output_img = open(output_img_path, 'wb')
+    output_img.write(sample_img_file.read())
+    sample_img_file.close()
+    output_img.close()
+    return output_img_path
+
+def rm_test_image(test_image):
+    os.remove(test_image)
 
 def qemu_img(*args):
     '''Run qemu-img and return the exit code'''
-- 
2.5.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]