qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Colin Lord <clord@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com,
	Colin Lord <clord@redhat.com>
Subject: [Qemu-devel] [PATCH 2/3] iotests: Add python functions for using sample images
Date: Mon, 11 Jul 2016 15:50:35 -0400	[thread overview]
Message-ID: <1468266636-16861-3-git-send-email-clord@redhat.com> (raw)
In-Reply-To: <1468266636-16861-1-git-send-email-clord@redhat.com>

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

Signed-off-by: Colin Lord <clord@redhat.com>
---
 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

  parent reply	other threads:[~2016-07-11 19:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-11 19:50 [Qemu-devel] [PATCH 0/3] Add tests for block driver format probes Colin Lord
2016-07-11 19:50 ` [Qemu-devel] [PATCH 1/3] iotests: Add dmg format option Colin Lord
2016-07-12 20:01   ` [Qemu-devel] [Qemu-block] " John Snow
2016-07-11 19:50 ` Colin Lord [this message]
2016-07-11 19:50 ` [Qemu-devel] [PATCH 3/3] iotests: Test format probes Colin Lord
2016-07-12 21:17   ` [Qemu-devel] [Qemu-block] " John Snow
2016-07-13 13:33     ` Colin Lord

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1468266636-16861-3-git-send-email-clord@redhat.com \
    --to=clord@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).