qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH 2/2] iotests: Add tests for "json-file:" pseudo protocol
Date: Tue,  3 Nov 2015 15:01:18 +0800	[thread overview]
Message-ID: <1446534078-11172-3-git-send-email-famz@redhat.com> (raw)
In-Reply-To: <1446534078-11172-1-git-send-email-famz@redhat.com>

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 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

  parent reply	other threads:[~2015-11-03  7:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-03  7:01 [Qemu-devel] [PATCH 0/2] block: Introduce "json-file:" protocol Fam Zheng
2015-11-03  7:01 ` [Qemu-devel] [PATCH 1/2] block: Add "json-file:" pseudo protocol Fam Zheng
2015-11-03  7:01 ` Fam Zheng [this message]
2015-11-03  7:35 ` [Qemu-devel] [PATCH 0/2] block: Introduce "json-file:" protocol Daniel P. Berrange
2015-11-03  7:56   ` Fam Zheng

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=1446534078-11172-3-git-send-email-famz@redhat.com \
    --to=famz@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).