ipxe: update binaries
[qemu/ar7.git] / tests / qemu-iotests / 099
blob65e8e9257200c2951a088def307b55d2e1c0e3d5
1 #!/usr/bin/env bash
3 # Test valid filenames for blkdebug and blkverify representatively for
4 # other protocols (such as NBD) when queried
6 # Copyright (C) 2014 Red Hat, Inc.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 # creator
23 owner=mreitz@redhat.com
25 seq="$(basename $0)"
26 echo "QA output created by $seq"
28 status=1 # failure is the default!
30 _cleanup()
32 _cleanup_test_img
33 _rm_test_img "$TEST_IMG.compare"
34 rm -f "$TEST_DIR/blkdebug.conf"
37 trap "_cleanup; exit \$status" 0 1 2 3 15
39 # get standard environment, filters and checks
40 . ./common.rc
41 . ./common.filter
43 # Basically all formats, but "raw" has issues with _filter_imgfmt regarding the
44 # raw comparison image for blkverify; also, all images have to support creation
45 _supported_fmt qcow qcow2 qed vdi vhdx vmdk vpc
46 _supported_proto file
47 _supported_os Linux
48 _require_drivers blkdebug blkverify
49 # data_file would change the json:{} filenames
50 _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
51 "subformat=twoGbMaxExtentSparse" data_file
53 do_run_qemu()
55 $QEMU -nographic -qmp stdio -serial none "$@"
58 run_qemu()
60 # Get the "file": "foo" entry ($foo may only contain escaped double quotes,
61 # which is how we can extract it)
62 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_imgfmt | _filter_qmp \
63 | _filter_qemu | grep "drv0" \
64 | sed -e 's/^.*"file": "\(\(\\"\|[^"]\)*\)".*$/\1/' -e 's/\\"/"/g'
67 test_qemu()
69 run_qemu -drive "if=none,id=drv0,$1" <<EOF
70 { 'execute': 'qmp_capabilities' }
71 { 'execute': 'query-block' }
72 { 'execute': 'quit' }
73 EOF
78 IMG_SIZE=128K
80 _make_test_img $IMG_SIZE
81 $QEMU_IMG create -f raw "$TEST_IMG.compare" $IMG_SIZE \
82 | _filter_testdir | _filter_imgfmt
84 echo
85 echo '=== Testing simple filename for blkverify ==='
86 echo
88 # This should return simply the filename itself
89 test_qemu "file=blkverify:$TEST_IMG.compare:$TEST_IMG"
91 echo
92 echo '=== Testing filename reconstruction for blkverify ==='
93 echo
95 # This should return the same filename as above
96 test_qemu "file.driver=blkverify,file.raw.filename=$TEST_IMG.compare,file.test.file.filename=$TEST_IMG"
98 echo
99 echo '=== Testing JSON filename for blkdebug ==='
100 echo
102 # blkdebug cannot create a configuration file, therefore it is unable to
103 # generate a plain filename here; thus this should return a JSON filename
104 test_qemu "file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=l1_update"
106 echo
107 echo '=== Testing indirectly enforced JSON filename ==='
108 echo
110 # Because blkdebug cannot return a plain filename, blkverify is forced to
111 # generate a JSON object here as well
112 test_qemu "file.driver=blkverify,file.raw.filename=$TEST_IMG.compare,file.test.file.driver=blkdebug,file.test.file.image.filename=$TEST_IMG,file.test.file.inject-error.0.event=l1_update"
114 echo
115 echo '=== Testing plain filename for blkdebug ==='
116 echo
118 touch "$TEST_DIR/blkdebug.conf"
119 test_qemu "file.driver=blkdebug,file.config=$TEST_DIR/blkdebug.conf,file.image.filename=$TEST_IMG"
121 echo
122 echo '=== Testing plain filename for blkdebug without configuration file ==='
123 echo
125 test_qemu "file.driver=blkdebug,file.image.filename=$TEST_IMG"
128 # success, all done
129 echo "*** done"
130 rm -f $seq.full
131 status=0