]>
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` | |
28 | tmp=/tmp/$$ | |
29 | status=1 # failure is the default! | |
30 | ||
31 | _cleanup() | |
32 | { | |
33 | _cleanup_test_img | |
34 | } | |
35 | trap "_cleanup; exit \$status" 0 1 2 3 15 | |
36 | ||
37 | # get standard environment, filters and checks | |
38 | . ./common.rc | |
39 | . ./common.filter | |
40 | ||
41 | _supported_fmt qcow2 | |
42 | _supported_proto file | |
43 | _supported_os Linux | |
44 | ||
45 | function filter_test_dir() | |
46 | { | |
47 | sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ | |
48 | -e "s#$TEST_DIR#TEST_DIR#g" | |
49 | } | |
50 | ||
51 | function test_qemu_img() | |
52 | { | |
53 | echo qemu-img "$@" | filter_test_dir | |
54 | $QEMU_IMG "$@" 2>&1 | filter_test_dir | |
55 | echo | |
56 | } | |
57 | ||
58 | echo "=== Check correct interpretation of suffixes for image size ===" | |
59 | echo | |
60 | sizes="1024 1024b 1k 1K 1M 1G 1T " | |
61 | sizes+="1024.0 1024.0b 1.5k 1.5K 1.5M 1.5G 1.5T" | |
62 | ||
63 | echo "== 1. Traditional size parameter ==" | |
64 | echo | |
65 | for s in $sizes; do | |
fef9c191 | 66 | test_qemu_img create -f $IMGFMT "$TEST_IMG" $s |
4dc9f9d6 KW |
67 | done |
68 | ||
69 | echo "== 2. Specifying size via -o ==" | |
70 | echo | |
71 | for s in $sizes; do | |
fef9c191 | 72 | test_qemu_img create -f $IMGFMT -o size=$s "$TEST_IMG" |
4dc9f9d6 KW |
73 | done |
74 | ||
75 | echo "== 3. Invalid sizes ==" | |
76 | echo | |
77 | sizes="-1024 -1k 1kilobyte foobar" | |
78 | ||
79 | for s in $sizes; do | |
fef9c191 JC |
80 | test_qemu_img create -f $IMGFMT "$TEST_IMG" -- $s |
81 | test_qemu_img create -f $IMGFMT -o size=$s "$TEST_IMG" | |
4dc9f9d6 KW |
82 | done |
83 | ||
84 | echo "== Check correct interpretation of suffixes for cluster size ==" | |
85 | echo | |
86 | sizes="1024 1024b 1k 1K 1M " | |
87 | sizes+="1024.0 1024.0b 0.5k 0.5K 0.5M" | |
88 | ||
89 | for s in $sizes; do | |
fef9c191 | 90 | test_qemu_img create -f $IMGFMT -o cluster_size=$s "$TEST_IMG" 64M |
4dc9f9d6 KW |
91 | done |
92 | ||
93 | echo "== Check compat level option ==" | |
94 | echo | |
fef9c191 JC |
95 | test_qemu_img create -f $IMGFMT -o compat=0.10 "$TEST_IMG" 64M |
96 | test_qemu_img create -f $IMGFMT -o compat=1.1 "$TEST_IMG" 64M | |
4dc9f9d6 | 97 | |
fef9c191 JC |
98 | test_qemu_img create -f $IMGFMT -o compat=0.42 "$TEST_IMG" 64M |
99 | test_qemu_img create -f $IMGFMT -o compat=foobar "$TEST_IMG" 64M | |
4dc9f9d6 KW |
100 | |
101 | echo "== Check preallocation option ==" | |
102 | echo | |
fef9c191 JC |
103 | test_qemu_img create -f $IMGFMT -o preallocation=off "$TEST_IMG" 64M |
104 | test_qemu_img create -f $IMGFMT -o preallocation=metadata "$TEST_IMG" 64M | |
105 | test_qemu_img create -f $IMGFMT -o preallocation=1234 "$TEST_IMG" 64M | |
4dc9f9d6 KW |
106 | |
107 | echo "== Check encryption option ==" | |
108 | echo | |
fef9c191 JC |
109 | test_qemu_img create -f $IMGFMT -o encryption=off "$TEST_IMG" 64M |
110 | test_qemu_img create -f $IMGFMT -o encryption=on "$TEST_IMG" 64M | |
4dc9f9d6 KW |
111 | |
112 | echo "== Check lazy_refcounts option (only with v3) ==" | |
113 | echo | |
fef9c191 JC |
114 | test_qemu_img create -f $IMGFMT -o compat=1.1,lazy_refcounts=off "$TEST_IMG" 64M |
115 | test_qemu_img create -f $IMGFMT -o compat=1.1,lazy_refcounts=on "$TEST_IMG" 64M | |
4dc9f9d6 | 116 | |
fef9c191 JC |
117 | test_qemu_img create -f $IMGFMT -o compat=0.10,lazy_refcounts=off "$TEST_IMG" 64M |
118 | test_qemu_img create -f $IMGFMT -o compat=0.10,lazy_refcounts=on "$TEST_IMG" 64M | |
4dc9f9d6 KW |
119 | |
120 | # success, all done | |
121 | echo "*** done" | |
122 | rm -f $seq.full | |
123 | status=0 |