diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/prom-env-test.c | 13 | ||||
| -rw-r--r-- | tests/qemu-iotests/.gitignore | 2 | ||||
| -rw-r--r-- | tests/qemu-iotests/059.out | 5 | ||||
| -rw-r--r-- | tests/qemu-iotests/070.out | 1 | ||||
| -rw-r--r-- | tests/qemu-iotests/075.out | 7 | ||||
| -rw-r--r-- | tests/qemu-iotests/076.out | 3 | ||||
| -rw-r--r-- | tests/qemu-iotests/078.out | 6 | ||||
| -rw-r--r-- | tests/qemu-iotests/080.out | 18 | ||||
| -rw-r--r-- | tests/qemu-iotests/083.out | 17 | ||||
| -rw-r--r-- | tests/qemu-iotests/088.out | 6 | ||||
| -rw-r--r-- | tests/qemu-iotests/092.out | 12 | ||||
| -rw-r--r-- | tests/qemu-iotests/116.out | 7 | ||||
| -rw-r--r-- | tests/qemu-iotests/131.out | 1 | ||||
| -rw-r--r-- | tests/qemu-iotests/140.out | 1 | ||||
| -rwxr-xr-x | tests/qemu-iotests/173 | 97 | ||||
| -rw-r--r-- | tests/qemu-iotests/173.out | 12 | ||||
| -rwxr-xr-x | tests/qemu-iotests/174 | 59 | ||||
| -rw-r--r-- | tests/qemu-iotests/174.out | 7 | ||||
| -rw-r--r-- | tests/qemu-iotests/Makefile | 2 | ||||
| -rwxr-xr-x | tests/qemu-iotests/check | 12 | ||||
| -rw-r--r-- | tests/qemu-iotests/common.config | 6 | ||||
| -rw-r--r-- | tests/qemu-iotests/common.filter | 2 | ||||
| -rw-r--r-- | tests/qemu-iotests/common.qemu | 10 | ||||
| -rw-r--r-- | tests/qemu-iotests/common.rc | 17 | ||||
| -rw-r--r-- | tests/qemu-iotests/group | 2 |
25 files changed, 220 insertions, 105 deletions
diff --git a/tests/prom-env-test.c b/tests/prom-env-test.c index 0ba6f48607..bd33bc353d 100644 --- a/tests/prom-env-test.c +++ b/tests/prom-env-test.c @@ -30,8 +30,8 @@ static void check_guest_memory(void) uint32_t signature; int i; - /* Poll until code has run and modified memory. Wait at most 30 seconds */ - for (i = 0; i < 10000; ++i) { + /* Poll until code has run and modified memory. Wait at most 120 seconds */ + for (i = 0; i < 12000; ++i) { signature = readl(ADDRESS); if (signature == MAGIC) { break; @@ -45,9 +45,14 @@ static void check_guest_memory(void) static void test_machine(const void *machine) { char *args; + const char *extra_args; - args = g_strdup_printf("-M %s,accel=tcg -prom-env 'boot-command=%x %x l!'", - (const char *)machine, MAGIC, ADDRESS); + /* The pseries firmware boots much faster without the default devices */ + extra_args = strcmp(machine, "pseries") == 0 ? "-nodefaults" : ""; + + args = g_strdup_printf("-M %s,accel=tcg %s -prom-env 'use-nvramrc?=true' " + "-prom-env 'nvramrc=%x %x l!' ", + (const char *)machine, extra_args, MAGIC, ADDRESS); qtest_start(args); check_guest_memory(); diff --git a/tests/qemu-iotests/.gitignore b/tests/qemu-iotests/.gitignore index 0711cbdbf3..da62054000 100644 --- a/tests/qemu-iotests/.gitignore +++ b/tests/qemu-iotests/.gitignore @@ -1,5 +1,5 @@ check.log -check.time +check.time* common.env *.out.bad *.notrun diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out index 678adb4379..6154509bc3 100644 --- a/tests/qemu-iotests/059.out +++ b/tests/qemu-iotests/059.out @@ -3,17 +3,14 @@ QA output created by 059 === Testing invalid granularity === Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 can't open device TEST_DIR/t.vmdk: Invalid granularity, image may be corrupt -no file open, try 'help open' === Testing too big L2 table size === Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 can't open device TEST_DIR/t.vmdk: L2 table size too big -no file open, try 'help open' === Testing too big L1 table size === Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 can't open device TEST_DIR/t.vmdk: L1 size too big -no file open, try 'help open' === Testing monolithicFlat creation and opening === Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat @@ -2361,5 +2358,5 @@ Offset Length Mapped to File 0x140000000 0x10000 0x50000 TEST_DIR/iotest-version3-s003.vmdk === Testing afl image with a very large capacity === -qemu-img: Can't get size of device 'image': File too large +qemu-img: Can't get image size 'TEST_DIR/afl9.IMGFMT': File too large *** done diff --git a/tests/qemu-iotests/070.out b/tests/qemu-iotests/070.out index 131a5b17dc..c269d99483 100644 --- a/tests/qemu-iotests/070.out +++ b/tests/qemu-iotests/070.out @@ -4,7 +4,6 @@ QA output created by 070 can't open device TEST_DIR/iotest-dirtylog-10G-4M.vhdx: VHDX image file 'TEST_DIR/iotest-dirtylog-10G-4M.vhdx' opened read-only, but contains a log that needs to be replayed To replay the log, run: qemu-img check -r all 'TEST_DIR/iotest-dirtylog-10G-4M.vhdx' - no file open, try 'help open' === Verify open image replays log === read 18874368/18874368 bytes at offset 0 18 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) diff --git a/tests/qemu-iotests/075.out b/tests/qemu-iotests/075.out index 87beae4e3c..b234b758e0 100644 --- a/tests/qemu-iotests/075.out +++ b/tests/qemu-iotests/075.out @@ -10,29 +10,22 @@ read 512/512 bytes at offset 1048064 == block_size must be a multiple of 512 == can't open device TEST_DIR/simple-pattern.cloop: block_size 513 must be a multiple of 512 -no file open, try 'help open' == block_size cannot be zero == can't open device TEST_DIR/simple-pattern.cloop: block_size cannot be zero -no file open, try 'help open' == huge block_size === can't open device TEST_DIR/simple-pattern.cloop: block_size 4294966784 must be 64 MB or less -no file open, try 'help open' == offsets_size overflow === can't open device TEST_DIR/simple-pattern.cloop: n_blocks 4294967295 must be 536870911 or less -no file open, try 'help open' == refuse images that require too many offsets === can't open device TEST_DIR/simple-pattern.cloop: image requires too many offsets, try increasing block size -no file open, try 'help open' == refuse images with non-monotonically increasing offsets == can't open device TEST_DIR/simple-pattern.cloop: offsets not monotonically increasing at index 1, image file is corrupt -no file open, try 'help open' == refuse images with invalid compressed block size == can't open device TEST_DIR/simple-pattern.cloop: invalid compressed block size at index 1, image file is corrupt -no file open, try 'help open' *** done diff --git a/tests/qemu-iotests/076.out b/tests/qemu-iotests/076.out index 72645b2522..9c66c5fb46 100644 --- a/tests/qemu-iotests/076.out +++ b/tests/qemu-iotests/076.out @@ -6,15 +6,12 @@ read 65536/65536 bytes at offset 0 == Negative catalog size == can't open device TEST_DIR/parallels-v1: Catalog too large -no file open, try 'help open' == Overflow in catalog allocation == can't open device TEST_DIR/parallels-v1: Catalog too large -no file open, try 'help open' == Zero sectors per track == can't open device TEST_DIR/parallels-v1: Invalid image: Zero sectors per track -no file open, try 'help open' == Read from a valid v2 image == read 65536/65536 bytes at offset 0 diff --git a/tests/qemu-iotests/078.out b/tests/qemu-iotests/078.out index 42b8a83015..c3d6aa4fe4 100644 --- a/tests/qemu-iotests/078.out +++ b/tests/qemu-iotests/078.out @@ -6,23 +6,17 @@ read 512/512 bytes at offset 0 == Negative catalog size == can't open device TEST_DIR/empty.bochs: Catalog size is too large -no file open, try 'help open' == Overflow for catalog size * sizeof(uint32_t) == can't open device TEST_DIR/empty.bochs: Catalog size is too large -no file open, try 'help open' == Too small catalog bitmap for image size == can't open device TEST_DIR/empty.bochs: Catalog size is too small for this disk size -no file open, try 'help open' can't open device TEST_DIR/empty.bochs: Catalog size is too small for this disk size -no file open, try 'help open' == Negative extent size == can't open device TEST_DIR/empty.bochs: Extent size 2147483648 is too large -no file open, try 'help open' == Zero extent size == can't open device TEST_DIR/empty.bochs: Extent size must be at least 512 -no file open, try 'help open' *** done diff --git a/tests/qemu-iotests/080.out b/tests/qemu-iotests/080.out index 0daac48b12..6a7fda1356 100644 --- a/tests/qemu-iotests/080.out +++ b/tests/qemu-iotests/080.out @@ -3,46 +3,33 @@ QA output created by 080 == Huge header size == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 can't open device TEST_DIR/t.qcow2: qcow2 header exceeds cluster size -no file open, try 'help open' can't open device TEST_DIR/t.qcow2: qcow2 header exceeds cluster size -no file open, try 'help open' == Huge unknown header extension == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 can't open device TEST_DIR/t.qcow2: Invalid backing file offset -no file open, try 'help open' can't open device TEST_DIR/t.qcow2: Header extension too large -no file open, try 'help open' can't open device TEST_DIR/t.qcow2: Header extension too large -no file open, try 'help open' == Huge refcount table size == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 can't open device TEST_DIR/t.qcow2: Reference count table too large -no file open, try 'help open' can't open device TEST_DIR/t.qcow2: Reference count table too large -no file open, try 'help open' == Misaligned refcount table == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 can't open device TEST_DIR/t.qcow2: Invalid reference count table offset -no file open, try 'help open' == Huge refcount offset == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 can't open device TEST_DIR/t.qcow2: Invalid reference count table offset -no file open, try 'help open' == Invalid snapshot table == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 can't open device TEST_DIR/t.qcow2: Too many snapshots -no file open, try 'help open' can't open device TEST_DIR/t.qcow2: Too many snapshots -no file open, try 'help open' can't open device TEST_DIR/t.qcow2: Invalid snapshot table offset -no file open, try 'help open' can't open device TEST_DIR/t.qcow2: Invalid snapshot table offset -no file open, try 'help open' == Hitting snapshot table size limit == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 @@ -53,13 +40,9 @@ read 512/512 bytes at offset 0 == Invalid L1 table == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 can't open device TEST_DIR/t.qcow2: Active L1 table too large -no file open, try 'help open' can't open device TEST_DIR/t.qcow2: Active L1 table too large -no file open, try 'help open' can't open device TEST_DIR/t.qcow2: Invalid L1 table offset -no file open, try 'help open' can't open device TEST_DIR/t.qcow2: Invalid L1 table offset -no file open, try 'help open' == Invalid L1 table (with internal snapshot in the image) == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 @@ -68,7 +51,6 @@ qemu-img: Could not open 'TEST_DIR/t.IMGFMT': L1 table is too small == Invalid backing file size == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 can't open device TEST_DIR/t.qcow2: Backing file name too long -no file open, try 'help open' == Invalid L2 entry (huge physical offset) == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 diff --git a/tests/qemu-iotests/083.out b/tests/qemu-iotests/083.out index ef3d1e32a5..0c13888ba1 100644 --- a/tests/qemu-iotests/083.out +++ b/tests/qemu-iotests/083.out @@ -2,52 +2,42 @@ QA output created by 083 === Check disconnect before neg1 === can't open device nbd:127.0.0.1:PORT:exportname=foo -no file open, try 'help open' === Check disconnect after neg1 === can't open device nbd:127.0.0.1:PORT:exportname=foo -no file open, try 'help open' === Check disconnect 8 neg1 === can't open device nbd:127.0.0.1:PORT:exportname=foo -no file open, try 'help open' === Check disconnect 16 neg1 === can't open device nbd:127.0.0.1:PORT:exportname=foo -no file open, try 'help open' === Check disconnect before export === can't open device nbd:127.0.0.1:PORT:exportname=foo -no file open, try 'help open' === Check disconnect after export === can't open device nbd:127.0.0.1:PORT:exportname=foo -no file open, try 'help open' === Check disconnect 4 export === can't open device nbd:127.0.0.1:PORT:exportname=foo -no file open, try 'help open' === Check disconnect 12 export === can't open device nbd:127.0.0.1:PORT:exportname=foo -no file open, try 'help open' === Check disconnect 16 export === can't open device nbd:127.0.0.1:PORT:exportname=foo -no file open, try 'help open' === Check disconnect before neg2 === can't open device nbd:127.0.0.1:PORT:exportname=foo -no file open, try 'help open' === Check disconnect after neg2 === @@ -56,12 +46,10 @@ read failed: Input/output error === Check disconnect 8 neg2 === can't open device nbd:127.0.0.1:PORT:exportname=foo -no file open, try 'help open' === Check disconnect 10 neg2 === can't open device nbd:127.0.0.1:PORT:exportname=foo -no file open, try 'help open' === Check disconnect before request === @@ -99,27 +87,22 @@ read 512/512 bytes at offset 0 === Check disconnect before neg-classic === can't open device nbd:127.0.0.1:PORT -no file open, try 'help open' === Check disconnect 8 neg-classic === can't open device nbd:127.0.0.1:PORT -no file open, try 'help open' === Check disconnect 16 neg-classic === can't open device nbd:127.0.0.1:PORT -no file open, try 'help open' === Check disconnect 24 neg-classic === can't open device nbd:127.0.0.1:PORT -no file open, try 'help open' === Check disconnect 28 neg-classic === can't open device nbd:127.0.0.1:PORT -no file open, try 'help open' === Check disconnect after neg-classic === diff --git a/tests/qemu-iotests/088.out b/tests/qemu-iotests/088.out index a2a83b8a1c..1f6bcf0abc 100644 --- a/tests/qemu-iotests/088.out +++ b/tests/qemu-iotests/088.out @@ -3,15 +3,9 @@ QA output created by 088 == Invalid block size == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 can't open device TEST_DIR/t.vpc: Invalid block size 0 -no file open, try 'help open' can't open device TEST_DIR/t.vpc: Invalid block size 0 -no file open, try 'help open' can't open device TEST_DIR/t.vpc: Invalid block size 128 -no file open, try 'help open' can't open device TEST_DIR/t.vpc: Invalid block size 128 -no file open, try 'help open' can't open device TEST_DIR/t.vpc: Invalid block size 305419896 -no file open, try 'help open' can't open device TEST_DIR/t.vpc: Invalid block size 305419896 -no file open, try 'help open' *** done diff --git a/tests/qemu-iotests/092.out b/tests/qemu-iotests/092.out index e18f54c200..6eda321fc6 100644 --- a/tests/qemu-iotests/092.out +++ b/tests/qemu-iotests/092.out @@ -3,36 +3,24 @@ QA output created by 092 == Invalid cluster size == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k -no file open, try 'help open' can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k -no file open, try 'help open' can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k -no file open, try 'help open' can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k -no file open, try 'help open' == Invalid L2 table size == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k -no file open, try 'help open' can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k -no file open, try 'help open' can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k -no file open, try 'help open' can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k -no file open, try 'help open' == Invalid size == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 can't open device TEST_DIR/t.qcow: Image too large -no file open, try 'help open' can't open device TEST_DIR/t.qcow: Image too large -no file open, try 'help open' == Invalid backing file length == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 can't open device TEST_DIR/t.qcow: Backing file name too long -no file open, try 'help open' can't open device TEST_DIR/t.qcow: Backing file name too long -no file open, try 'help open' *** done diff --git a/tests/qemu-iotests/116.out b/tests/qemu-iotests/116.out index 1f11d4446d..24bee57783 100644 --- a/tests/qemu-iotests/116.out +++ b/tests/qemu-iotests/116.out @@ -3,35 +3,28 @@ QA output created by 116 == truncated header cluster == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument -no file open, try 'help open' == invalid header magic == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 can't open device TEST_DIR/t.qed: Image not in QED format -no file open, try 'help open' == invalid cluster size == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument -no file open, try 'help open' == invalid table size == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument -no file open, try 'help open' == invalid header size == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument -no file open, try 'help open' == invalid L1 table offset == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument -no file open, try 'help open' == invalid image size == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument -no file open, try 'help open' *** done diff --git a/tests/qemu-iotests/131.out b/tests/qemu-iotests/131.out index ae2412ebf7..27c2c5389b 100644 --- a/tests/qemu-iotests/131.out +++ b/tests/qemu-iotests/131.out @@ -23,7 +23,6 @@ read 32768/32768 bytes at offset 0 32 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) == Corrupt image == can't open device TEST_DIR/t.parallels: parallels: Image was not closed correctly; cannot be opened read/write -no file open, try 'help open' ERROR image was not closed correctly 1 errors were found on the image. diff --git a/tests/qemu-iotests/140.out b/tests/qemu-iotests/140.out index 0409cd0174..6c0445603a 100644 --- a/tests/qemu-iotests/140.out +++ b/tests/qemu-iotests/140.out @@ -9,7 +9,6 @@ read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": {}} can't open device nbd+unix:///drv?socket=TEST_DIR/nbd: No export with name 'drv' available -no file open, try 'help open' {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"} *** done diff --git a/tests/qemu-iotests/173 b/tests/qemu-iotests/173 new file mode 100755 index 0000000000..bdaa092979 --- /dev/null +++ b/tests/qemu-iotests/173 @@ -0,0 +1,97 @@ +#!/bin/bash +# +# Test QAPI commands looking up protocol based images with relative +# filename backing strings +# +# Copyright (C) 2017 Red Hat, Inc. +# +# 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 <http://www.gnu.org/licenses/>. +# +# creator +owner=jcody@redhat.com + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_qemu + rm -f "${QEMU_TEST_DIR}/image.base" "${QEMU_TEST_DIR}/image.snp1" + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +_supported_fmt qcow2 +_supported_proto nfs +_supported_os Linux + +size=100M + +BASE_IMG="${TEST_DIR}/image.base" +TOP_IMG="${TEST_DIR}/image.snp1" + +TEST_IMG="${BASE_IMG}" _make_test_img $size + +TEST_IMG="${TOP_IMG}" _make_test_img $size + +echo +echo === Running QEMU, using block-stream to find backing image === +echo + +qemu_comm_method="qmp" +_launch_qemu -drive file="${BASE_IMG}",if=virtio,id=disk2 +h=$QEMU_HANDLE + +_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" "return" + +_send_qemu_cmd $h "{ 'arguments': { + 'device': 'disk2', + 'format': '${IMGFMT}', + 'mode': 'existing', + 'snapshot-file': '${TOP_IMG}', + 'snapshot-node-name': 'snp1' + }, + 'execute': 'blockdev-snapshot-sync' + }" "return" + + +_send_qemu_cmd $h "{ 'arguments': { + 'backing-file': 'image.base', + 'device': 'disk2', + 'image-node-name': 'snp1' + }, + 'execute': 'change-backing-file' + }" "return" + +_send_qemu_cmd $h "{ 'arguments': { + 'base': '${BASE_IMG}', + 'device': 'disk2' + }, + 'execute': 'block-stream' + }" "BLOCK_JOB_COMPLETED" + +_cleanup_qemu + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/173.out b/tests/qemu-iotests/173.out new file mode 100644 index 0000000000..f477a0099a --- /dev/null +++ b/tests/qemu-iotests/173.out @@ -0,0 +1,12 @@ +QA output created by 173 +Formatting 'TEST_DIR/image.base', fmt=IMGFMT size=104857600 +Formatting 'TEST_DIR/image.snp1', fmt=IMGFMT size=104857600 + +=== Running QEMU, using block-stream to find backing image === + +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "disk2", "len": 104857600, "offset": 104857600, "speed": 0, "type": "stream"}} +*** done diff --git a/tests/qemu-iotests/174 b/tests/qemu-iotests/174 new file mode 100755 index 0000000000..c1c20a1a57 --- /dev/null +++ b/tests/qemu-iotests/174 @@ -0,0 +1,59 @@ +#!/bin/bash +# +# Test that qemu-io fail with non-zero exit code +# +# Copyright (C) 2017 Nir Soffer <nirsof@gmail.com> +# +# 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 <http://www.gnu.org/licenses/>. +# + +# 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 + +_unsupported_fmt raw + + +size=256K +IMGFMT=raw IMGOPTS= _make_test_img $size | _filter_imgfmt + +echo +echo "== reading wrong format should fail ==" +$QEMU_IO -f $IMGFMT -c "read 0 $size" "$TEST_IMG" 2>/dev/null +test $? -eq 1 || _fail "did not fail" + +echo +echo "== reading missing file should fail ==" +$QEMU_IO -c "read 0 $size" "$TEST_DIR/missing" 2>/dev/null +test $? -eq 1 || _fail "did not fail" + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/174.out b/tests/qemu-iotests/174.out new file mode 100644 index 0000000000..a06d23792e --- /dev/null +++ b/tests/qemu-iotests/174.out @@ -0,0 +1,7 @@ +QA output created by 174 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=262144 + +== reading wrong format should fail == + +== reading missing file should fail == +*** done diff --git a/tests/qemu-iotests/Makefile b/tests/qemu-iotests/Makefile index 2fb527c5b5..27380e60c1 100644 --- a/tests/qemu-iotests/Makefile +++ b/tests/qemu-iotests/Makefile @@ -1,5 +1,5 @@ -CLEANFILES= *.out.bad *.notrun check.log check.time +CLEANFILES= *.out.bad *.notrun check.log check.time* # no default target default: diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check index 4cba2151e4..4b1c6749b7 100755 --- a/tests/qemu-iotests/check +++ b/tests/qemu-iotests/check @@ -129,6 +129,8 @@ fi # exit 1 #fi +TIMESTAMP_FILE=check.time-$IMGPROTO-$IMGFMT + tmp="${TEST_DIR}"/$$ _wallclock() @@ -155,9 +157,9 @@ _wrapup() : elif $needwrap then - if [ -f check.time -a -f $tmp.time ] + if [ -f $TIMESTAMP_FILE -a -f $tmp.time ] then - cat check.time $tmp.time \ + cat $TIMESTAMP_FILE $tmp.time \ | $AWK_PROG ' { t[$1] = $2 } END { if (NR > 0) { @@ -165,7 +167,7 @@ END { if (NR > 0) { } }' \ | sort -n >$tmp.out - mv $tmp.out check.time + mv $tmp.out $TIMESTAMP_FILE fi if [ -f $tmp.expunged ] @@ -223,7 +225,7 @@ echo "preamble" > "${TEST_DIR}"/check.sts # don't leave old full output behind on a clean run rm -f check.full -[ -f check.time ] || touch check.time +[ -f $TIMESTAMP_FILE ] || touch $TIMESTAMP_FILE FULL_IMGFMT_DETAILS=`_full_imgfmt_details` FULL_IMGPROTO_DETAILS=`_full_imgproto_details` @@ -277,7 +279,7 @@ do # really going to try and run this one # rm -f $seq.out.bad - lasttime=`sed -n -e "/^$seq /s/.* //p" <check.time` + lasttime=`sed -n -e "/^$seq /s/.* //p" <$TIMESTAMP_FILE` if [ "X$lasttime" != X ]; then echo -n " ${lasttime}s ..." else diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config index f6384fbae7..55527aac87 100644 --- a/tests/qemu-iotests/common.config +++ b/tests/qemu-iotests/common.config @@ -109,7 +109,7 @@ _qemu_wrapper() { ( if [ -n "${QEMU_NEED_PID}" ]; then - echo $BASHPID > "${TEST_DIR}/qemu-${_QEMU_HANDLE}.pid" + echo $BASHPID > "${QEMU_TEST_DIR}/qemu-${_QEMU_HANDLE}.pid" fi exec "$QEMU_PROG" $QEMU_OPTIONS "$@" ) @@ -151,7 +151,7 @@ _qemu_io_wrapper() _qemu_nbd_wrapper() { ( - echo $BASHPID > "${TEST_DIR}/qemu-nbd.pid" + echo $BASHPID > "${QEMU_TEST_DIR}/qemu-nbd.pid" exec "$QEMU_NBD_PROG" $QEMU_NBD_OPTIONS "$@" ) } @@ -186,6 +186,8 @@ if [ -z "$TEST_DIR" ]; then TEST_DIR=`pwd`/scratch fi +QEMU_TEST_DIR="${TEST_DIR}" + if [ ! -e "$TEST_DIR" ]; then mkdir "$TEST_DIR" fi diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter index 240ed0697a..4befd865f4 100644 --- a/tests/qemu-iotests/common.filter +++ b/tests/qemu-iotests/common.filter @@ -35,7 +35,7 @@ _filter_generated_node_ids() # replace occurrences of the actual TEST_DIR value with TEST_DIR _filter_testdir() { - sed -e "s#$TEST_DIR#TEST_DIR#g" + sed -e "s#$TEST_DIR/#TEST_DIR/#g" } # replace occurrences of the actual IMGFMT value with IMGFMT diff --git a/tests/qemu-iotests/common.qemu b/tests/qemu-iotests/common.qemu index e657361790..42787896af 100644 --- a/tests/qemu-iotests/common.qemu +++ b/tests/qemu-iotests/common.qemu @@ -27,8 +27,8 @@ QEMU_COMM_TIMEOUT=10 -QEMU_FIFO_IN="${TEST_DIR}/qmp-in-$$" -QEMU_FIFO_OUT="${TEST_DIR}/qmp-out-$$" +QEMU_FIFO_IN="${QEMU_TEST_DIR}/qmp-in-$$" +QEMU_FIFO_OUT="${QEMU_TEST_DIR}/qmp-out-$$" QEMU_HANDLE=0 @@ -204,9 +204,9 @@ function _cleanup_qemu() for i in "${!QEMU_OUT[@]}" do local QEMU_PID - if [ -f "${TEST_DIR}/qemu-${i}.pid" ]; then - read QEMU_PID < "${TEST_DIR}/qemu-${i}.pid" - rm -f "${TEST_DIR}/qemu-${i}.pid" + if [ -f "${QEMU_TEST_DIR}/qemu-${i}.pid" ]; then + read QEMU_PID < "${QEMU_TEST_DIR}/qemu-${i}.pid" + rm -f "${QEMU_TEST_DIR}/qemu-${i}.pid" if [ -z "${wait}" ] && [ -n "${QEMU_PID}" ]; then kill -KILL ${QEMU_PID} 2>/dev/null fi diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index 3213765f4e..a3d904fc22 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -193,11 +193,11 @@ _cleanup_test_img() case "$IMGPROTO" in nbd) - if [ -f "${TEST_DIR}/qemu-nbd.pid" ]; then + if [ -f "${QEMU_TEST_DIR}/qemu-nbd.pid" ]; then local QEMU_NBD_PID - read QEMU_NBD_PID < "${TEST_DIR}/qemu-nbd.pid" + read QEMU_NBD_PID < "${QEMU_TEST_DIR}/qemu-nbd.pid" kill ${QEMU_NBD_PID} - rm -f "${TEST_DIR}/qemu-nbd.pid" + rm -f "${QEMU_TEST_DIR}/qemu-nbd.pid" fi rm -f "$TEST_IMG_FILE" ;; @@ -355,6 +355,17 @@ _supported_fmt() _notrun "not suitable for this image format: $IMGFMT" } +# tests whether $IMGFMT is one of the unsupported image format for a test +# +_unsupported_fmt() +{ + for f; do + if [ "$f" = "$IMGFMT" ]; then + _notrun "not suitable for this image format: $IMGFMT" + fi + done +} + # tests whether $IMGPROTO is one of the supported image protocols for a test # _supported_proto() diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 866c1a032d..985b9a6a36 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -165,3 +165,5 @@ 170 rw auto quick 171 rw auto quick 172 auto +173 rw auto +174 auto |