xref: /openbmc/qemu/tests/qemu-iotests/048 (revision e930d201)
1*e930d201SMiroslav Rezanina#!/bin/bash
2*e930d201SMiroslav Rezanina##
3*e930d201SMiroslav Rezanina## qemu-img compare test
4*e930d201SMiroslav Rezanina##
5*e930d201SMiroslav Rezanina##
6*e930d201SMiroslav Rezanina## Copyright (C) 2013 Red Hat, Inc.
7*e930d201SMiroslav Rezanina##
8*e930d201SMiroslav Rezanina## This program is free software; you can redistribute it and/or modify
9*e930d201SMiroslav Rezanina## it under the terms of the GNU General Public License as published by
10*e930d201SMiroslav Rezanina## the Free Software Foundation; either version 2 of the License, or
11*e930d201SMiroslav Rezanina## (at your option) any later version.
12*e930d201SMiroslav Rezanina##
13*e930d201SMiroslav Rezanina## This program is distributed in the hope that it will be useful,
14*e930d201SMiroslav Rezanina## but WITHOUT ANY WARRANTY; without even the implied warranty of
15*e930d201SMiroslav Rezanina## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*e930d201SMiroslav Rezanina## GNU General Public License for more details.
17*e930d201SMiroslav Rezanina##
18*e930d201SMiroslav Rezanina## You should have received a copy of the GNU General Public License
19*e930d201SMiroslav Rezanina## along with this program.  If not, see <http://www.gnu.org/licenses/>.
20*e930d201SMiroslav Rezanina##
21*e930d201SMiroslav Rezanina#
22*e930d201SMiroslav Rezanina# creator
23*e930d201SMiroslav Rezaninaowner=mrezanin@redhat.com
24*e930d201SMiroslav Rezanina
25*e930d201SMiroslav Rezaninaseq=`basename $0`
26*e930d201SMiroslav Rezaninaecho "QA output created by $seq"
27*e930d201SMiroslav Rezanina
28*e930d201SMiroslav Rezaninastatus=1        # failure is the default!
29*e930d201SMiroslav Rezanina
30*e930d201SMiroslav Rezanina_cleanup()
31*e930d201SMiroslav Rezanina{
32*e930d201SMiroslav Rezanina    echo "Cleanup"
33*e930d201SMiroslav Rezanina    _cleanup_test_img
34*e930d201SMiroslav Rezanina    rm ${TEST_IMG2}
35*e930d201SMiroslav Rezanina}
36*e930d201SMiroslav Rezaninatrap "_cleanup; exit \$status" 0 1 2 3 15
37*e930d201SMiroslav Rezanina
38*e930d201SMiroslav Rezanina_compare()
39*e930d201SMiroslav Rezanina{
40*e930d201SMiroslav Rezanina    $QEMU_IMG compare "$@" $TEST_IMG ${TEST_IMG2}
41*e930d201SMiroslav Rezanina    echo $?
42*e930d201SMiroslav Rezanina}
43*e930d201SMiroslav Rezanina
44*e930d201SMiroslav Rezanina# get standard environment, filters and checks
45*e930d201SMiroslav Rezanina. ./common.rc
46*e930d201SMiroslav Rezanina. ./common.filter
47*e930d201SMiroslav Rezanina. ./common.pattern
48*e930d201SMiroslav Rezanina
49*e930d201SMiroslav Rezanina_supported_fmt raw qcow qcow2 qed
50*e930d201SMiroslav Rezanina_supported_proto file
51*e930d201SMiroslav Rezanina_supported_os Linux
52*e930d201SMiroslav Rezanina
53*e930d201SMiroslav Rezanina# Setup test basic parameters
54*e930d201SMiroslav RezaninaTEST_IMG2=$TEST_IMG.2
55*e930d201SMiroslav RezaninaCLUSTER_SIZE=4096
56*e930d201SMiroslav Rezaninasize=1024M
57*e930d201SMiroslav Rezanina
58*e930d201SMiroslav Rezanina_make_test_img $size
59*e930d201SMiroslav Rezaninaio_pattern write 524288 $CLUSTER_SIZE $CLUSTER_SIZE 4 45
60*e930d201SMiroslav Rezanina
61*e930d201SMiroslav Rezanina# Compare identical images
62*e930d201SMiroslav Rezaninacp $TEST_IMG ${TEST_IMG2}
63*e930d201SMiroslav Rezanina_compare
64*e930d201SMiroslav Rezanina_compare -q
65*e930d201SMiroslav Rezanina
66*e930d201SMiroslav Rezanina# Compare images with different size
67*e930d201SMiroslav Rezanina$QEMU_IMG resize $TEST_IMG +512M
68*e930d201SMiroslav Rezanina_compare
69*e930d201SMiroslav Rezanina_compare -s
70*e930d201SMiroslav Rezanina
71*e930d201SMiroslav Rezanina# Compare images with different content
72*e930d201SMiroslav Rezaninaio_pattern write 1228800 $CLUSTER_SIZE 0 1 67
73*e930d201SMiroslav Rezanina_compare
74*e930d201SMiroslav Rezaninaio_pattern write 0 $CLUSTER_SIZE 0 1 123
75*e930d201SMiroslav Rezanina_compare
76*e930d201SMiroslav Rezanina
77*e930d201SMiroslav Rezanina# Cleanup
78*e930d201SMiroslav Rezaninastatus=0
79