]>
Commit | Line | Data |
---|---|---|
11a82d14 | 1 | #!/usr/bin/env bash |
911864c6 HR |
2 | # |
3 | # Test valid filenames for blkdebug and blkverify representatively for | |
4 | # other protocols (such as NBD) when queried | |
5 | # | |
6 | # Copyright (C) 2014 Red Hat, Inc. | |
7 | # | |
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. | |
12 | # | |
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. | |
17 | # | |
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/>. | |
20 | # | |
21 | ||
22 | # creator | |
23 | [email protected] | |
24 | ||
25 | seq="$(basename $0)" | |
26 | echo "QA output created by $seq" | |
27 | ||
911864c6 HR |
28 | status=1 # failure is the default! |
29 | ||
30 | _cleanup() | |
31 | { | |
32 | _cleanup_test_img | |
33 | } | |
34 | trap "_cleanup; exit \$status" 0 1 2 3 15 | |
35 | ||
36 | # get standard environment, filters and checks | |
37 | . ./common.rc | |
38 | . ./common.filter | |
39 | ||
40 | # Basically all formats, but "raw" has issues with _filter_imgfmt regarding the | |
41 | # raw comparison image for blkverify; also, all images have to support creation | |
550830f9 | 42 | _supported_fmt qcow qcow2 qed vdi vhdx vmdk vpc |
911864c6 HR |
43 | _supported_proto file |
44 | _supported_os Linux | |
0fc9b0d1 FZ |
45 | _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ |
46 | "subformat=twoGbMaxExtentSparse" | |
911864c6 | 47 | |
8cedcffd | 48 | do_run_qemu() |
911864c6 HR |
49 | { |
50 | $QEMU -nographic -qmp stdio -serial none "$@" | |
51 | } | |
52 | ||
8cedcffd | 53 | run_qemu() |
911864c6 HR |
54 | { |
55 | # Get the "file": "foo" entry ($foo may only contain escaped double quotes, | |
56 | # which is how we can extract it) | |
57 | do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_imgfmt | _filter_qmp \ | |
4dd7b8d3 | 58 | | _filter_qemu | grep "drv0" \ |
911864c6 HR |
59 | | sed -e 's/^.*"file": "\(\(\\"\|[^"]\)*\)".*$/\1/' -e 's/\\"/"/g' |
60 | } | |
61 | ||
8cedcffd | 62 | test_qemu() |
911864c6 HR |
63 | { |
64 | run_qemu -drive "if=none,id=drv0,$1" <<EOF | |
65 | { 'execute': 'qmp_capabilities' } | |
66 | { 'execute': 'query-block' } | |
67 | { 'execute': 'quit' } | |
68 | EOF | |
69 | } | |
70 | ||
71 | ||
72 | ||
73 | IMG_SIZE=128K | |
74 | ||
75 | _make_test_img $IMG_SIZE | |
76 | $QEMU_IMG create -f raw "$TEST_IMG.compare" $IMG_SIZE \ | |
77 | | _filter_testdir | _filter_imgfmt | |
78 | ||
79 | echo | |
80 | echo '=== Testing simple filename for blkverify ===' | |
81 | echo | |
82 | ||
83 | # This should return simply the filename itself | |
84 | test_qemu "file=blkverify:$TEST_IMG.compare:$TEST_IMG" | |
85 | ||
86 | echo | |
87 | echo '=== Testing filename reconstruction for blkverify ===' | |
88 | echo | |
89 | ||
90 | # This should return the same filename as above | |
91 | test_qemu "file.driver=blkverify,file.raw.filename=$TEST_IMG.compare,file.test.file.filename=$TEST_IMG" | |
92 | ||
93 | echo | |
94 | echo '=== Testing JSON filename for blkdebug ===' | |
95 | echo | |
96 | ||
97 | # blkdebug cannot create a configuration file, therefore it is unable to | |
98 | # generate a plain filename here; thus this should return a JSON filename | |
99 | test_qemu "file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=l1_update" | |
100 | ||
101 | echo | |
102 | echo '=== Testing indirectly enforced JSON filename ===' | |
103 | echo | |
104 | ||
105 | # Because blkdebug cannot return a plain filename, blkverify is forced to | |
106 | # generate a JSON object here as well | |
107 | 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" | |
108 | ||
f48a33b6 HR |
109 | echo |
110 | echo '=== Testing plain filename for blkdebug ===' | |
111 | echo | |
112 | ||
113 | touch "$TEST_DIR/blkdebug.conf" | |
114 | test_qemu "file.driver=blkdebug,file.config=$TEST_DIR/blkdebug.conf,file.image.filename=$TEST_IMG" | |
115 | ||
116 | echo | |
117 | echo '=== Testing plain filename for blkdebug without configuration file ===' | |
118 | echo | |
119 | ||
120 | test_qemu "file.driver=blkdebug,file.image.filename=$TEST_IMG" | |
121 | ||
911864c6 | 122 | |
f48a33b6 | 123 | rm -f "$TEST_IMG.compare" "$TEST_DIR/blkdebug.conf" |
911864c6 HR |
124 | |
125 | # success, all done | |
126 | echo "*** done" | |
127 | rm -f $seq.full | |
128 | status=0 |