From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMhE5-0002LF-Od for qemu-devel@nongnu.org; Mon, 11 Jul 2016 15:50:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMhE4-00040P-VH for qemu-devel@nongnu.org; Mon, 11 Jul 2016 15:50:45 -0400 From: Colin Lord Date: Mon, 11 Jul 2016 15:50:35 -0400 Message-Id: <1468266636-16861-3-git-send-email-clord@redhat.com> In-Reply-To: <1468266636-16861-1-git-send-email-clord@redhat.com> References: <1468266636-16861-1-git-send-email-clord@redhat.com> Subject: [Qemu-devel] [PATCH 2/3] iotests: Add python functions for using sample images List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com, Colin Lord This adds a python equivalent of the _use_sample_img and _rm_sample_img testing functions. Signed-off-by: Colin Lord --- 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