]>
Commit | Line | Data |
---|---|---|
4dc9f9d6 KW |
1 | #!/bin/bash |
2 | # | |
3 | # Check qemu-img option parsing | |
4 | # | |
5 | # Copyright (C) 2013 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 | here=`pwd` | |
4dc9f9d6 KW |
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 | _supported_fmt qcow2 | |
41 | _supported_proto file | |
42 | _supported_os Linux | |
43 | ||
44 | function filter_test_dir() | |
45 | { | |
46 | sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ | |
47 | -e "s#$TEST_DIR#TEST_DIR#g" | |
48 | } | |
49 | ||
50 | function test_qemu_img() | |
51 | { | |
52 | echo qemu-img "$@" | filter_test_dir | |
53 | $QEMU_IMG "$@" 2>&1 | filter_test_dir | |
54 | echo | |
55 | } | |
56 | ||
57 | echo "=== Check correct interpretation of suffixes for image size ===" | |
58 | echo | |
59 | sizes="1024 1024b 1k 1K 1M 1G 1T " | |
60 | sizes+="1024.0 1024.0b 1.5k 1.5K 1.5M 1.5G 1.5T" | |
61 | ||
62 | echo "== 1. Traditional size parameter ==" | |
63 | echo | |
64 | for s in $sizes; do | |
fef9c191 | 65 | test_qemu_img create -f $IMGFMT "$TEST_IMG" $s |
4dc9f9d6 KW |
66 | done |
67 | ||
68 | echo "== 2. Specifying size via -o ==" | |
69 | echo | |
70 | for s in $sizes; do | |
fef9c191 | 71 | test_qemu_img create -f $IMGFMT -o size=$s "$TEST_IMG" |
4dc9f9d6 KW |
72 | done |
73 | ||
74 | echo "== 3. Invalid sizes ==" | |
75 | echo | |
76 | sizes="-1024 -1k 1kilobyte foobar" | |
77 | ||
78 | for s in $sizes; do | |
fef9c191 JC |
79 | test_qemu_img create -f $IMGFMT "$TEST_IMG" -- $s |
80 | test_qemu_img create -f $IMGFMT -o size=$s "$TEST_IMG" | |
4dc9f9d6 KW |
81 | done |
82 | ||
83 | echo "== Check correct interpretation of suffixes for cluster size ==" | |
84 | echo | |
85 | sizes="1024 1024b 1k 1K 1M " | |
86 | sizes+="1024.0 1024.0b 0.5k 0.5K 0.5M" | |
87 | ||
88 | for s in $sizes; do | |
fef9c191 | 89 | test_qemu_img create -f $IMGFMT -o cluster_size=$s "$TEST_IMG" 64M |
4dc9f9d6 KW |
90 | done |
91 | ||
92 | echo "== Check compat level option ==" | |
93 | echo | |
fef9c191 JC |
94 | test_qemu_img create -f $IMGFMT -o compat=0.10 "$TEST_IMG" 64M |
95 | test_qemu_img create -f $IMGFMT -o compat=1.1 "$TEST_IMG" 64M | |
4dc9f9d6 | 96 | |
fef9c191 JC |
97 | test_qemu_img create -f $IMGFMT -o compat=0.42 "$TEST_IMG" 64M |
98 | test_qemu_img create -f $IMGFMT -o compat=foobar "$TEST_IMG" 64M | |
4dc9f9d6 KW |
99 | |
100 | echo "== Check preallocation option ==" | |
101 | echo | |
fef9c191 JC |
102 | test_qemu_img create -f $IMGFMT -o preallocation=off "$TEST_IMG" 64M |
103 | test_qemu_img create -f $IMGFMT -o preallocation=metadata "$TEST_IMG" 64M | |
104 | test_qemu_img create -f $IMGFMT -o preallocation=1234 "$TEST_IMG" 64M | |
4dc9f9d6 KW |
105 | |
106 | echo "== Check encryption option ==" | |
107 | echo | |
fef9c191 | 108 | test_qemu_img create -f $IMGFMT -o encryption=off "$TEST_IMG" 64M |
b25b387f | 109 | test_qemu_img create -f $IMGFMT --object secret,id=sec0,data=123456 -o encryption=on,encrypt.key-secret=sec0 "$TEST_IMG" 64M |
4dc9f9d6 KW |
110 | |
111 | echo "== Check lazy_refcounts option (only with v3) ==" | |
112 | echo | |
fef9c191 JC |
113 | test_qemu_img create -f $IMGFMT -o compat=1.1,lazy_refcounts=off "$TEST_IMG" 64M |
114 | test_qemu_img create -f $IMGFMT -o compat=1.1,lazy_refcounts=on "$TEST_IMG" 64M | |
4dc9f9d6 | 115 | |
fef9c191 JC |
116 | test_qemu_img create -f $IMGFMT -o compat=0.10,lazy_refcounts=off "$TEST_IMG" 64M |
117 | test_qemu_img create -f $IMGFMT -o compat=0.10,lazy_refcounts=on "$TEST_IMG" 64M | |
4dc9f9d6 KW |
118 | |
119 | # success, all done | |
120 | echo "*** done" | |
121 | rm -f $seq.full | |
122 | status=0 |