From 2b12baf0e3f5679d685ff19ca4ad5e54de0585bb Mon Sep 17 00:00:00 2001 From: Jeff Cody Date: Tue, 14 Feb 2017 11:21:16 -0500 Subject: qemu-iotests: Test 137 only supports 'file' protocol Since test 137 make uses of qcow2.py, only local files are supported. Signed-off-by: Jeff Cody Signed-off-by: Kevin Wolf --- tests/qemu-iotests/137 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137 index e5e30de..eb91e51 100755 --- a/tests/qemu-iotests/137 +++ b/tests/qemu-iotests/137 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.qemu _supported_fmt qcow2 -_supported_proto generic +_supported_proto file _supported_os Linux -- cgit v1.1 From dfac03dcd4e88ad218e3c0800720eb60a9aa9bae Mon Sep 17 00:00:00 2001 From: Jeff Cody Date: Tue, 14 Feb 2017 11:21:17 -0500 Subject: qemu-iotests: add ability to exclude certain protocols from tests Add the ability for shell script tests to exclude specific protocols. This is useful to allow all protocols except ones known to not support a feature used in the test (e.g. .bdrv_create). Signed-off-by: Jeff Cody Signed-off-by: Kevin Wolf --- tests/qemu-iotests/common.rc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index a3d904f..6c0fd4c 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -379,6 +379,18 @@ _supported_proto() _notrun "not suitable for this image protocol: $IMGPROTO" } +# tests whether $IMGPROTO is specified as an unsupported image protocol for a test +# +_unsupported_proto() +{ + for f; do + if [ "$f" = "$IMGPROTO" ]; then + _notrun "not suitable for this image protocol: $IMGPROTO" + return + fi + done +} + # tests whether the host OS is one of the supported OSes for a test # _supported_os() -- cgit v1.1 From 43421ea05f8dfe85dcbb2d4932730fe8cb74dbf4 Mon Sep 17 00:00:00 2001 From: Jeff Cody Date: Tue, 14 Feb 2017 13:15:07 -0500 Subject: qemu-iotests: redirect nbd server stdout to /dev/null Some iotests (e.g. 174) try to filter the output of _make_test_image by piping the stdout. Pipe the server stdout to /dev/null, so that filter pipe does not need to wait until process completion. Signed-off-by: Jeff Cody Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- tests/qemu-iotests/common.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index 6c0fd4c..08065dc 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -172,7 +172,7 @@ _make_test_img() # Start an NBD server on the image file, which is what we'll be talking to if [ $IMGPROTO = "nbd" ]; then - eval "$QEMU_NBD -v -t -b 127.0.0.1 -p 10810 -f $IMGFMT $TEST_IMG_FILE &" + eval "$QEMU_NBD -v -t -b 127.0.0.1 -p 10810 -f $IMGFMT $TEST_IMG_FILE >/dev/null &" sleep 1 # FIXME: qemu-nbd needs to be listening before we continue fi } -- cgit v1.1 From 6f993f3fca4763a6b494ff587d4400b6e8a5ef31 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Fri, 17 Feb 2017 02:51:25 +0200 Subject: qemu-img: Add tests for raw image preallocation Add tests for creating raw image with and without the preallocation option. Signed-off-by: Nir Soffer Signed-off-by: Kevin Wolf --- tests/qemu-iotests/175 | 61 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/175.out | 18 ++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 80 insertions(+) create mode 100755 tests/qemu-iotests/175 create mode 100644 tests/qemu-iotests/175.out (limited to 'tests') diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175 new file mode 100755 index 0000000..ca56e82 --- /dev/null +++ b/tests/qemu-iotests/175 @@ -0,0 +1,61 @@ +#!/bin/bash +# +# Test creating raw image preallocation mode +# +# Copyright (C) 2017 Nir Soffer +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=nirsof@gmail.com + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt raw +_supported_proto file +_supported_os Linux + +size=1m + +echo +echo "== creating image with default preallocation ==" +_make_test_img $size | _filter_imgfmt +stat -c "size=%s, blocks=%b" $TEST_IMG + +for mode in off full falloc; do + echo + echo "== creating image with preallocation $mode ==" + IMGOPTS=preallocation=$mode _make_test_img $size | _filter_imgfmt + stat -c "size=%s, blocks=%b" $TEST_IMG +done + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out new file mode 100644 index 0000000..76c02c6 --- /dev/null +++ b/tests/qemu-iotests/175.out @@ -0,0 +1,18 @@ +QA output created by 175 + +== creating image with default preallocation == +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 +size=1048576, blocks=0 + +== creating image with preallocation off == +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=off +size=1048576, blocks=0 + +== creating image with preallocation full == +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=full +size=1048576, blocks=2048 + +== creating image with preallocation falloc == +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc +size=1048576, blocks=2048 + *** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 985b9a6..1f4bf03 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -167,3 +167,4 @@ 172 auto 173 rw auto 174 auto +175 auto quick -- cgit v1.1 From 2c3b44da07d341557a8203cc509ea07fe3605e11 Mon Sep 17 00:00:00 2001 From: John Snow Date: Thu, 16 Feb 2017 17:00:00 -0500 Subject: iotests: Fix another race in 030 We can't rely on a non-paused job to be present and running for us. Assume that if the job is not present that it completed already. Signed-off-by: John Snow Reviewed-by: Fam Zheng Signed-off-by: Kevin Wolf --- tests/qemu-iotests/030 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index 54db54a..0d472d5 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -547,11 +547,14 @@ class TestEIO(TestErrors): while not completed: for event in self.vm.get_qmp_events(wait=True): if event['event'] == 'BLOCK_JOB_ERROR': + error = True self.assert_qmp(event, 'data/device', 'drive0') self.assert_qmp(event, 'data/operation', 'read') result = self.vm.qmp('query-block-jobs') + if result == {'return': []}: + # Job finished too quickly + continue self.assert_qmp(result, 'return[0]/paused', False) - error = True elif event['event'] == 'BLOCK_JOB_COMPLETED': self.assertTrue(error, 'job completed unexpectedly') self.assert_qmp(event, 'data/type', 'stream') -- cgit v1.1 From 4e4bf5c42c8b2847a90367936a6df6c277f4a76a Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Fri, 16 Dec 2016 18:52:37 +0100 Subject: block: Attach bs->file only during .bdrv_open() The way that attaching bs->file worked was a bit unusual in that it was the only child that would be attached to a node which is not opened yet. Because of this, the block layer couldn't know yet which permissions the driver would eventually need. This patch moves the point where bs->file is attached to the beginning of the individual .bdrv_open() implementations, so drivers already know what they are going to do with the child. This is also more consistent with how driver-specific children work. For a moment, bdrv_open() gets its own BdrvChild to perform image probing, but instead of directly assigning this BdrvChild to the BDS, it becomes a temporary one and the node name is passed as an option to the drivers, so that they can simply use bdrv_open_child() to create another reference for their own use. This duplicated child for (the not opened yet) bs is not the final state, a follow-up patch will change the image probing code to use a BlockBackend, which is completely independent of bs. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- tests/qemu-iotests/051.out | 4 ++-- tests/qemu-iotests/051.pc.out | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out index 42bf416..7524c62 100644 --- a/tests/qemu-iotests/051.out +++ b/tests/qemu-iotests/051.out @@ -225,7 +225,7 @@ Testing: -drive driver=nbd QEMU_PROG: -drive driver=nbd: NBD server address missing Testing: -drive driver=raw -QEMU_PROG: -drive driver=raw: Can't use 'raw' as a block driver for the protocol level +QEMU_PROG: -drive driver=raw: A block device must be specified for "file" Testing: -drive file.driver=file QEMU_PROG: -drive file.driver=file: The 'file' block driver requires a file name @@ -234,7 +234,7 @@ Testing: -drive file.driver=nbd QEMU_PROG: -drive file.driver=nbd: NBD server address missing Testing: -drive file.driver=raw -QEMU_PROG: -drive file.driver=raw: Can't use 'raw' as a block driver for the protocol level +QEMU_PROG: -drive file.driver=raw: A block device must be specified for "file" Testing: -drive foo=bar QEMU_PROG: -drive foo=bar: Must specify either driver or file diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out index f8047a2..e206ad6 100644 --- a/tests/qemu-iotests/051.pc.out +++ b/tests/qemu-iotests/051.pc.out @@ -323,7 +323,7 @@ Testing: -drive driver=nbd QEMU_PROG: -drive driver=nbd: NBD server address missing Testing: -drive driver=raw -QEMU_PROG: -drive driver=raw: Can't use 'raw' as a block driver for the protocol level +QEMU_PROG: -drive driver=raw: A block device must be specified for "file" Testing: -drive file.driver=file QEMU_PROG: -drive file.driver=file: The 'file' block driver requires a file name @@ -332,7 +332,7 @@ Testing: -drive file.driver=nbd QEMU_PROG: -drive file.driver=nbd: NBD server address missing Testing: -drive file.driver=raw -QEMU_PROG: -drive file.driver=raw: Can't use 'raw' as a block driver for the protocol level +QEMU_PROG: -drive file.driver=raw: A block device must be specified for "file" Testing: -drive foo=bar QEMU_PROG: -drive foo=bar: Must specify either driver or file -- cgit v1.1 From d185cf0ec64cd183218ca7e0810d9130c96ebebc Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Mon, 16 Jan 2017 17:17:38 +0100 Subject: tests: Use opened block node for block job tests blk_insert_bs() and block job related functions will soon require an opened block node (permission calculations will involve the block driver), so let our tests be consistent with the real users in this respect. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- tests/test-blockjob-txn.c | 6 +++++- tests/test-blockjob.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c index b132e39..f6dfd08 100644 --- a/tests/test-blockjob-txn.c +++ b/tests/test-blockjob-txn.c @@ -96,7 +96,10 @@ static BlockJob *test_block_job_start(unsigned int iterations, char job_id[24]; data = g_new0(TestBlockJobCBData, 1); - bs = bdrv_new(); + + bs = bdrv_open("null-co://", NULL, NULL, 0, &error_abort); + g_assert_nonnull(bs); + snprintf(job_id, sizeof(job_id), "job%u", counter++); s = block_job_create(job_id, &test_block_job_driver, bs, 0, BLOCK_JOB_DEFAULT, test_block_job_cb, @@ -242,6 +245,7 @@ static void test_pair_jobs_fail_cancel_race(void) int main(int argc, char **argv) { qemu_init_main_loop(&error_abort); + bdrv_init(); g_test_init(&argc, &argv, NULL); g_test_add_func("/single/success", test_single_job_success); diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c index 60b78a3..068c9e4 100644 --- a/tests/test-blockjob.c +++ b/tests/test-blockjob.c @@ -54,7 +54,10 @@ static BlockJob *do_test_id(BlockBackend *blk, const char *id, static BlockBackend *create_blk(const char *name) { BlockBackend *blk = blk_new(); - BlockDriverState *bs = bdrv_new(); + BlockDriverState *bs; + + bs = bdrv_open("null-co://", NULL, NULL, 0, &error_abort); + g_assert_nonnull(bs); blk_insert_bs(blk, bs); bdrv_unref(bs); @@ -140,6 +143,7 @@ static void test_job_ids(void) int main(int argc, char **argv) { qemu_init_main_loop(&error_abort); + bdrv_init(); g_test_init(&argc, &argv, NULL); g_test_add_func("/blockjob/ids", test_job_ids); -- cgit v1.1