aboutsummaryrefslogtreecommitdiff
path: root/tests/qemu-iotests/common.rc
diff options
context:
space:
mode:
authorJeff Cody <jcody@redhat.com>2013-09-25 08:12:20 -0400
committerKevin Wolf <kwolf@redhat.com>2013-09-27 10:59:07 +0200
commit85edbd375b9ab451c6769011cb6b3e0287dc71e4 (patch)
tree204c1e7dcfecd0565a97b1f855eed6b8f9c165f5 /tests/qemu-iotests/common.rc
parent212774c5a5036b327dc10a0dd3e5fe194b509a18 (diff)
qemu-iotests: Add basic ability to use binary sample images
For image formats that are not "QEMU native", but supported for compatibility, it is useful to verify that an image created with the 'gold standard' native tool can be read / written to successfully by QEMU. In addition to testing non-native images, this could also be useful to test against image files created by older versions of QEMU. This provides a directory to store small sample images, for use by scripts in tests/qemu-iotests. Image files should be compressed with bzip2. To use a sample image from a bash script, the _use_sample_img function will copy and decompress the image into $TEST_DIR, and set $TEST_IMG to be the decompressed sample image copy. To cleanup, call _cleanup_test_img as normal. Signed-off-by: Jeff Cody <jcody@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/common.rc')
-rw-r--r--tests/qemu-iotests/common.rc16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index 28b39e429e..6730955288 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -91,6 +91,18 @@ _set_default_imgopts()
fi
}
+_use_sample_img()
+{
+ SAMPLE_IMG_FILE="${1%\.bz2}"
+ TEST_IMG="$TEST_DIR/$SAMPLE_IMG_FILE"
+ bzcat "$SAMPLE_IMG_DIR/$1" > "$TEST_IMG"
+ if [ $? -ne 0 ]
+ then
+ echo "_use_sample_img error, cannot extract '$SAMPLE_IMG_DIR/$1'"
+ exit 1
+ fi
+}
+
_make_test_img()
{
# extra qemu-img options can be added by tests
@@ -158,6 +170,10 @@ _cleanup_test_img()
rm -f $TEST_DIR/t.$IMGFMT
rm -f $TEST_DIR/t.$IMGFMT.orig
rm -f $TEST_DIR/t.$IMGFMT.base
+ if [ -n "$SAMPLE_IMG_FILE" ]
+ then
+ rm -f "$TEST_DIR/$SAMPLE_IMG_FILE"
+ fi
;;
rbd)