]> Git Repo - qemu.git/blob - tests/qemu-iotests/082
tests/docker: Remove old Debian 9 containers
[qemu.git] / tests / qemu-iotests / 082
1 #!/usr/bin/env bash
2 #
3 # Test qemu-img command line parsing
4 #
5 # Copyright (C) 2014 Red Hat, Inc.
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20
21 # creator
22 [email protected]
23
24 seq=`basename $0`
25 echo "QA output created by $seq"
26
27 status=1        # failure is the default!
28
29 _cleanup()
30 {
31         _cleanup_test_img
32 }
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 # get standard environment, filters and checks
36 . ./common.rc
37 . ./common.filter
38
39 _supported_fmt qcow2
40 _supported_proto file nfs
41 _require_drivers bochs
42
43 run_qemu_img()
44 {
45     echo
46     echo Testing: "$@" | _filter_testdir
47     "$QEMU_IMG" "$@" 2>&1 | _filter_testdir
48 }
49
50 size=128M
51
52 echo
53 echo === create: Options specified more than once ===
54
55 # Last -f should win
56 run_qemu_img create -f foo -f $IMGFMT "$TEST_IMG" $size
57 _img_info
58
59 # Multiple -o should be merged
60 run_qemu_img create -f $IMGFMT -o cluster_size=4k -o lazy_refcounts=on "$TEST_IMG" $size
61 _img_info --format-specific
62
63 # If the same -o key is specified more than once, the last one wins
64 run_qemu_img create -f $IMGFMT -o cluster_size=4k -o lazy_refcounts=on -o cluster_size=8k "$TEST_IMG" $size
65 _img_info --format-specific
66 run_qemu_img create -f $IMGFMT -o cluster_size=4k,cluster_size=8k "$TEST_IMG" $size
67 _img_info
68
69 echo
70 echo === create: help for -o ===
71
72 # Adding the help option to a command without other -o options
73 run_qemu_img create -f $IMGFMT -o help "$TEST_IMG" $size
74 run_qemu_img create -f $IMGFMT -o \? "$TEST_IMG" $size
75
76 # Adding the help option to the same -o option
77 run_qemu_img create -f $IMGFMT -o cluster_size=4k,help "$TEST_IMG" $size
78 run_qemu_img create -f $IMGFMT -o cluster_size=4k,\? "$TEST_IMG" $size
79 run_qemu_img create -f $IMGFMT -o help,cluster_size=4k "$TEST_IMG" $size
80 run_qemu_img create -f $IMGFMT -o \?,cluster_size=4k "$TEST_IMG" $size
81
82 # Adding the help option to a separate -o option
83 run_qemu_img create -f $IMGFMT -o cluster_size=4k -o help "$TEST_IMG" $size
84 run_qemu_img create -f $IMGFMT -o cluster_size=4k -o \? "$TEST_IMG" $size
85
86 # Looks like a help option, but is part of the backing file name
87 run_qemu_img create -f $IMGFMT -u -o backing_file="$TEST_IMG",,help \
88     -F $IMGFMT "$TEST_IMG" $size
89 run_qemu_img create -f $IMGFMT -u -o backing_file="$TEST_IMG",,\? \
90     -F $IMGFMT "$TEST_IMG" $size
91
92 # Try to trick qemu-img into creating escaped commas
93 run_qemu_img create -f $IMGFMT -o backing_file="$TEST_IMG", -o help "$TEST_IMG" $size
94 run_qemu_img create -f $IMGFMT -o backing_file="$TEST_IMG" -o ,help "$TEST_IMG" $size
95 run_qemu_img create -f $IMGFMT -o backing_file="$TEST_IMG" -o ,, -o help "$TEST_IMG" $size
96
97 # Leave out everything that isn't needed
98 run_qemu_img create -f $IMGFMT -o help
99 run_qemu_img create -o help
100
101 # Try help option for a format that does not support creation
102 run_qemu_img create -f bochs -o help
103
104 echo
105 echo === convert: Options specified more than once ===
106
107 # We need a valid source image
108 run_qemu_img create -f $IMGFMT "$TEST_IMG" $size
109
110 # Last -f should win
111 run_qemu_img convert -f foo -f $IMGFMT "$TEST_IMG" "$TEST_IMG".base
112 TEST_IMG="${TEST_IMG}.base" _img_info
113
114 # Last -O should win
115 run_qemu_img convert -O foo -O $IMGFMT "$TEST_IMG" "$TEST_IMG".base
116 TEST_IMG="${TEST_IMG}.base" _img_info
117
118 # Multiple -o should be merged
119 run_qemu_img convert -O $IMGFMT -o cluster_size=4k -o lazy_refcounts=on "$TEST_IMG" "$TEST_IMG".base
120 TEST_IMG="${TEST_IMG}.base" _img_info --format-specific
121
122 # If the same -o key is specified more than once, the last one wins
123 run_qemu_img convert -O $IMGFMT -o cluster_size=4k -o lazy_refcounts=on -o cluster_size=8k "$TEST_IMG" "$TEST_IMG".base
124 TEST_IMG="${TEST_IMG}.base" _img_info --format-specific
125 run_qemu_img convert -O $IMGFMT -o cluster_size=4k,cluster_size=8k "$TEST_IMG" "$TEST_IMG".base
126 TEST_IMG="${TEST_IMG}.base" _img_info
127
128 echo
129 echo === convert: help for -o ===
130
131 # Adding the help option to a command without other -o options
132 run_qemu_img convert -O $IMGFMT -o help "$TEST_IMG" "$TEST_IMG".base
133 run_qemu_img convert -O $IMGFMT -o \? "$TEST_IMG" "$TEST_IMG".base
134
135 # Adding the help option to the same -o option
136 run_qemu_img convert -O $IMGFMT -o cluster_size=4k,help "$TEST_IMG" "$TEST_IMG".base
137 run_qemu_img convert -O $IMGFMT -o cluster_size=4k,\? "$TEST_IMG" "$TEST_IMG".base
138 run_qemu_img convert -O $IMGFMT -o help,cluster_size=4k "$TEST_IMG" "$TEST_IMG".base
139 run_qemu_img convert -O $IMGFMT -o \?,cluster_size=4k "$TEST_IMG" "$TEST_IMG".base
140
141 # Adding the help option to a separate -o option
142 run_qemu_img convert -O $IMGFMT -o cluster_size=4k -o help "$TEST_IMG" "$TEST_IMG".base
143 run_qemu_img convert -O $IMGFMT -o cluster_size=4k -o \? "$TEST_IMG" "$TEST_IMG".base
144
145 # Looks like a help option, but is part of the backing file name
146 run_qemu_img convert -O $IMGFMT -o backing_fmt=$IMGFMT,backing_file="$TEST_IMG",,help "$TEST_IMG" "$TEST_IMG".base
147 run_qemu_img convert -O $IMGFMT -o backing_fmt=$IMGFMT,backing_file="$TEST_IMG",,\? "$TEST_IMG" "$TEST_IMG".base
148
149 # Try to trick qemu-img into creating escaped commas
150 run_qemu_img convert -O $IMGFMT -o backing_file="$TEST_IMG", -o help "$TEST_IMG" "$TEST_IMG".base
151 run_qemu_img convert -O $IMGFMT -o backing_file="$TEST_IMG" -o ,help "$TEST_IMG" "$TEST_IMG".base
152 run_qemu_img convert -O $IMGFMT -o backing_file="$TEST_IMG" -o ,, -o help "$TEST_IMG" "$TEST_IMG".base
153
154 # Leave out everything that isn't needed
155 run_qemu_img convert -O $IMGFMT -o help
156 run_qemu_img convert -o help
157
158 # Try help option for a format that does not support creation
159 run_qemu_img convert -O bochs -o help
160
161 echo
162 echo === convert: -C and other options ===
163
164 # Adding the help option to a command without other -o options
165 run_qemu_img convert -C -S 4k -O $IMGFMT "$TEST_IMG" "$TEST_IMG".target
166 run_qemu_img convert -C -S 8k -O $IMGFMT "$TEST_IMG" "$TEST_IMG".target
167 run_qemu_img convert -C -c -O $IMGFMT "$TEST_IMG" "$TEST_IMG".target
168 run_qemu_img convert -C --salvage -O $IMGFMT "$TEST_IMG" "$TEST_IMG".target
169
170 echo
171 echo === amend: Options specified more than once ===
172
173 # Last -f should win
174 run_qemu_img amend -f foo -f $IMGFMT -o lazy_refcounts=on "$TEST_IMG"
175 _img_info --format-specific
176
177 # Multiple -o should be merged
178 run_qemu_img amend -f $IMGFMT -o size=130M -o lazy_refcounts=off "$TEST_IMG"
179 _img_info --format-specific
180
181 # If the same -o key is specified more than once, the last one wins
182 run_qemu_img amend -f $IMGFMT -o size=8M -o lazy_refcounts=on -o size=132M "$TEST_IMG"
183 _img_info --format-specific
184 run_qemu_img amend -f $IMGFMT -o size=4M,size=148M "$TEST_IMG"
185 _img_info
186
187 echo
188 echo === amend: help for -o ===
189
190 # Adding the help option to a command without other -o options
191 run_qemu_img amend -f $IMGFMT -o help "$TEST_IMG"
192 run_qemu_img amend -f $IMGFMT -o \? "$TEST_IMG"
193
194 # Adding the help option to the same -o option
195 run_qemu_img amend -f $IMGFMT -o cluster_size=4k,help "$TEST_IMG"
196 run_qemu_img amend -f $IMGFMT -o cluster_size=4k,\? "$TEST_IMG"
197 run_qemu_img amend -f $IMGFMT -o help,cluster_size=4k "$TEST_IMG"
198 run_qemu_img amend -f $IMGFMT -o \?,cluster_size=4k "$TEST_IMG"
199
200 # Adding the help option to a separate -o option
201 run_qemu_img amend -f $IMGFMT -o cluster_size=4k -o help "$TEST_IMG"
202 run_qemu_img amend -f $IMGFMT -o cluster_size=4k -o \? "$TEST_IMG"
203
204 # Looks like a help option, but is part of the backing file name
205 run_qemu_img amend -f $IMGFMT -o backing_file="$TEST_IMG",,help "$TEST_IMG"
206 run_qemu_img rebase -u -b "" -f $IMGFMT "$TEST_IMG"
207
208 run_qemu_img amend -f $IMGFMT -o backing_file="$TEST_IMG",,\? "$TEST_IMG"
209 run_qemu_img rebase -u -b "" -f $IMGFMT "$TEST_IMG"
210
211 # Try to trick qemu-img into creating escaped commas
212 run_qemu_img amend -f $IMGFMT -o backing_file="$TEST_IMG", -o help "$TEST_IMG"
213 run_qemu_img amend -f $IMGFMT -o backing_file="$TEST_IMG" -o ,help "$TEST_IMG"
214 run_qemu_img amend -f $IMGFMT -o backing_file="$TEST_IMG" -o ,, -o help "$TEST_IMG"
215
216 # Leave out everything that isn't needed
217 run_qemu_img amend -f $IMGFMT -o help
218
219 # amend requires specifying either a format explicitly, or a file
220 # which it can probe
221 run_qemu_img amend -o help
222
223 # Try help option for a format that does not support amendment
224 run_qemu_img amend -f bochs -o help
225
226 # success, all done
227 echo "*** done"
228 rm -f $seq.full
229 status=0
This page took 0.036628 seconds and 4 git commands to generate.