2 # group: img auto quick
4 ## qemu-img compare test
7 ## Copyright (C) 2013 Red Hat, Inc.
9 ## This program is free software; you can redistribute it and/or modify
10 ## it under the terms of the GNU General Public License as published by
11 ## the Free Software Foundation; either version 2 of the License, or
12 ## (at your option) any later version.
14 ## This program is distributed in the hope that it will be useful,
15 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ## GNU General Public License for more details.
19 ## You should have received a copy of the GNU General Public License
20 ## along with this program. If not, see <http://www.gnu.org/licenses/>.
24 owner=mrezanin@redhat.com
27 echo "QA output created by $seq"
29 status=1 # failure is the default!
35 _rm_test_img "${TEST_IMG_FILE2}"
37 trap "_cleanup; exit \$status" 0 1 2 3 15
41 $QEMU_IMG compare $QEMU_IMG_EXTRA_ARGS "$@" "$TEST_IMG" "${TEST_IMG2}"
45 # get standard environment, filters and checks
50 _supported_fmt raw qcow2 qed luks
53 # Using 'cp' is incompatible with external data files
54 _unsupported_imgopts data_file
56 # Remove once all tests are fixed to use TEST_IMG_FILE
57 # correctly and common.rc sets it unconditionally
58 test -z "$TEST_IMG_FILE" && TEST_IMG_FILE=$TEST_IMG
60 # Setup test basic parameters
62 TEST_IMG_FILE2=$TEST_IMG_FILE.2
67 io_pattern write 524288 $CLUSTER_SIZE $CLUSTER_SIZE 4 45
69 # Compare identical images
70 cp "$TEST_IMG_FILE" "${TEST_IMG_FILE2}"
74 # Compare images with different size
75 if [ "$IMGOPTSSYNTAX" = "true" ]; then
76 $QEMU_IMG resize $QEMU_IMG_EXTRA_ARGS "$TEST_IMG" +32M
78 $QEMU_IMG resize -f $IMGFMT "$TEST_IMG" +32M
80 # Ensure extended space is zero-initialized
81 $QEMU_IO "$TEST_IMG" -c "write -z $size 32M" | _filter_qemu_io
86 # Compare images with different content
87 io_pattern write 1228800 $CLUSTER_SIZE 0 1 67
89 io_pattern write 0 $CLUSTER_SIZE 0 1 123
92 # Test unaligned case of mismatch offsets in allocated clusters
94 io_pattern write 0 512 0 1 100
95 cp "$TEST_IMG_FILE" "$TEST_IMG_FILE2"
96 io_pattern write 512 512 0 1 101