From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtVb5-0002eU-SG for qemu-devel@nongnu.org; Tue, 03 Nov 2015 02:01:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtVb4-00064d-Ny for qemu-devel@nongnu.org; Tue, 03 Nov 2015 02:01:35 -0500 From: Fam Zheng Date: Tue, 3 Nov 2015 15:01:18 +0800 Message-Id: <1446534078-11172-3-git-send-email-famz@redhat.com> In-Reply-To: <1446534078-11172-1-git-send-email-famz@redhat.com> References: <1446534078-11172-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH 2/2] iotests: Add tests for "json-file:" pseudo protocol List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz Signed-off-by: Fam Zheng --- tests/qemu-iotests/089 | 27 +++++++++++++++++++++++---- tests/qemu-iotests/089.out | 15 +++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/089 b/tests/qemu-iotests/089 index 3e0038d..6115563 100755 --- a/tests/qemu-iotests/089 +++ b/tests/qemu-iotests/089 @@ -67,9 +67,7 @@ $QEMU_IO -c 'write -P 42 0 512' -c 'write -P 23 512 512' \ $QEMU_IMG convert -f raw -O $IMGFMT "$TEST_IMG.base" "$TEST_IMG" -$QEMU_IO_PROG --cache $CACHEMODE \ - -c 'read -P 42 0 512' -c 'read -P 23 512 512' \ - -c 'read -P 66 1024 512' "json:{ +img_opts="{ \"driver\": \"$IMGFMT\", \"file\": { \"driver\": \"$IMGFMT\", @@ -77,7 +75,15 @@ $QEMU_IO_PROG --cache $CACHEMODE \ \"filename\": \"$TEST_IMG\" } } -}" | _filter_qemu_io +}" + +echo "$img_opts" > $TEST_IMG.json + +for f in "json:$img_opts" "json-file:$TEST_IMG.json"; do + $QEMU_IO_PROG --cache $CACHEMODE \ + -c 'read -P 42 0 512' -c 'read -P 23 512 512' \ + -c 'read -P 66 1024 512' "$f" | _filter_qemu_io +done # This should fail (see test 072) $QEMU_IO -c 'read -P 42 0 512' "$TEST_IMG" | _filter_qemu_io @@ -126,6 +132,19 @@ $QEMU_IO -c "open -o driver=qcow2 json:{\"file.filename\":\"$TEST_IMG\"}" \ $QEMU_IO -c "open -o driver=qcow2 json:{\"driver\":\"raw\",\"file.filename\":\"$TEST_IMG\"}" \ -c "info" 2>&1 | _filter_testdir | _filter_imgfmt +echo +echo "=== Test invalid json-file: ===" +echo + +echo "This is not a valid json file#^*)@" > $TEST_IMG.json +TEST_IMG="json-file:$TEST_IMG.json" _img_info + +echo +echo "=== Test large json-file: ===" +echo + +$QEMU_IMG create $TEST_IMG.json 1G +TEST_IMG="json-file:$TEST_IMG.json" _img_info # success, all done echo "*** done" diff --git a/tests/qemu-iotests/089.out b/tests/qemu-iotests/089.out index 5b541a3..6847f60 100644 --- a/tests/qemu-iotests/089.out +++ b/tests/qemu-iotests/089.out @@ -15,6 +15,12 @@ read 512/512 bytes at offset 512 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 512/512 bytes at offset 1024 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 512 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 1024 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Pattern verification failed at offset 0, 512 bytes read 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -53,4 +59,13 @@ Format specific information: lazy refcounts: false refcount bits: 16 corrupt: false + +=== Test invalid json-file: === + +qemu-img: Could not open 'json-TEST_DIR/t.IMGFMT.json': Could not parse the JSON options + +=== Test large json-file: === + +Formatting '/home/fam/build/last/tests/qemu-iotests/scratch/t.qcow2.json', fmt=raw size=1073741824 +qemu-img: Could not open 'json-TEST_DIR/t.IMGFMT.json': JSON file is too large *** done -- 2.4.3