]> Git Repo - qemu.git/blob - tests/qemu-iotests/106
block: Don't block_job_pause_all() in bdrv_drain_all()
[qemu.git] / tests / qemu-iotests / 106
1 #!/bin/bash
2 #
3 # Test preallocated resize of raw images
4 #
5 # Copyright (C) 2017 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 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 and filters
37 . ./common.rc
38 . ./common.filter
39
40 _supported_fmt raw
41 _supported_proto file
42 _supported_os Linux
43
44 # in kB
45 CREATION_SIZE=128
46 GROWTH_SIZE=256
47
48 echo '=== Testing image growth ==='
49
50 for create_mode in off falloc full; do
51     for growth_mode in off falloc full; do
52         echo
53         echo "--- create_mode=$create_mode growth_mode=$growth_mode ---"
54
55         IMGOPTS="preallocation=$create_mode" _make_test_img ${CREATION_SIZE}K
56         $QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K
57
58         expected_size=0
59         if [ $create_mode != off ]; then
60             expected_size=$CREATION_SIZE
61         fi
62         if [ $growth_mode != off ]; then
63             expected_size=$((expected_size + $GROWTH_SIZE))
64         fi
65
66         actual_size=$($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep 'disk size')
67         actual_size=$(echo "$actual_size" | sed -e 's/^[^0-9]*\([0-9]\+\).*$/\1/')
68
69         # The actual size may exceed the expected size, depending on the file
70         # system. Therefore we just test that the actual size is at least what
71         # we expect.
72         if [ $actual_size -lt $expected_size ]; then
73             echo "ERROR: Image should have at least ${expected_size}K, but has ${actual_size}K"
74         fi
75     done
76 done
77
78 echo
79 echo '=== Testing image shrinking ==='
80
81 # None of this should work except for "off", because other modes cannot be used
82 # for shrinking
83 for growth_mode in falloc full off; do
84     echo
85     echo "--- growth_mode=$growth_mode ---"
86     $QEMU_IMG resize -f "$IMGFMT" --shrink --preallocation=$growth_mode "$TEST_IMG" -${GROWTH_SIZE}K
87 done
88
89 # success, all done
90 echo '*** done'
91 rm -f $seq.full
92 status=0
This page took 0.028295 seconds and 4 git commands to generate.