master
text 129 lines 3.12 KB
Raw
1 #!/usr/bin/env bash
2 # group: quick
3 #
4 # Test write zeros unmap.
5 #
6 # Copyright (C) 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 seq="$(basename $0)"
23 echo "QA output created by $seq"
24
25 trap _cleanup_test_img exit
26
27 # get standard environment, filters and checks
28 cd ..
29 . ./common.rc
30 . ./common.filter
31
32 _supported_fmt raw
33 _supported_proto file
34 _supported_os Linux
35 _require_disk_usage
36 _require_hmp
37
38 create_test_image() {
39 _make_test_img -f $IMGFMT 1m
40 }
41
42 filter_command() {
43 _filter_testdir | _filter_qemu_io | _filter_qemu | _filter_hmp
44 }
45
46 print_disk_usage() {
47 du -sh $TEST_IMG | _filter_testdir
48 }
49
50 echo
51 echo "=== defaults - write zeros ==="
52 echo
53
54 create_test_image
55 echo -e 'qemu-io none0 "write -z 0 1m"\nquit' \
56 | $QEMU -monitor stdio -drive if=none,file=$TEST_IMG,format=$IMGFMT \
57 | filter_command
58 print_disk_usage
59
60 echo
61 echo "=== defaults - write zeros unmap ==="
62 echo
63
64 create_test_image
65 echo -e 'qemu-io none0 "write -zu 0 1m"\nquit' \
66 | $QEMU -monitor stdio -drive if=none,file=$TEST_IMG,format=$IMGFMT \
67 | filter_command
68 print_disk_usage
69
70
71 echo
72 echo "=== defaults - write actual zeros ==="
73 echo
74
75 create_test_image
76 echo -e 'qemu-io none0 "write -P 0 0 1m"\nquit' \
77 | $QEMU -monitor stdio -drive if=none,file=$TEST_IMG,format=$IMGFMT \
78 | filter_command
79 print_disk_usage
80
81 echo
82 echo "=== discard=off - write zeroes unmap ==="
83 echo
84
85 create_test_image
86 echo -e 'qemu-io none0 "write -zu 0 1m"\nquit' \
87 | $QEMU -monitor stdio -drive if=none,file=$TEST_IMG,format=$IMGFMT,discard=off \
88 | filter_command
89 print_disk_usage
90
91 echo
92 echo "=== detect-zeroes=on - write actual zeros ==="
93 echo
94
95 create_test_image
96 echo -e 'qemu-io none0 "write -P 0 0 1m"\nquit' \
97 | $QEMU -monitor stdio -drive if=none,file=$TEST_IMG,format=$IMGFMT,detect-zeroes=on \
98 | filter_command
99 print_disk_usage
100
101 echo
102 echo "=== detect-zeroes=on,discard=on - write actual zeros ==="
103 echo
104
105 create_test_image
106 echo -e 'qemu-io none0 "write -P 0 0 1m"\nquit' \
107 | $QEMU -monitor stdio -drive if=none,file=$TEST_IMG,format=$IMGFMT,detect-zeroes=on,discard=on \
108 | filter_command
109 print_disk_usage
110
111 echo
112 echo "=== discard=on - write zeroes ==="
113 echo
114
115 create_test_image
116 echo -e 'qemu-io none0 "write -z 0 1m"\nquit' \
117 | $QEMU -monitor stdio -drive if=none,file=$TEST_IMG,format=$IMGFMT,discard=on \
118 | filter_command
119 print_disk_usage
120
121 echo
122 echo "=== discard=on - write zeroes unmap ==="
123 echo
124
125 create_test_image
126 echo -e 'qemu-io none0 "write -zu 0 1m"\nquit' \
127 | $QEMU -monitor stdio -drive if=none,file=$TEST_IMG,format=$IMGFMT,discard=on \
128 | filter_command
129 print_disk_usage