xref: /openbmc/qemu/tests/qemu-iotests/074 (revision 34602dd6)
1*34602dd6SFam Zheng#!/bin/bash
2*34602dd6SFam Zheng##
3*34602dd6SFam Zheng## qemu-img compare test (qcow2 only ones)
4*34602dd6SFam Zheng##
5*34602dd6SFam Zheng##
6*34602dd6SFam Zheng## Copyright (C) 2013 Red Hat, Inc.
7*34602dd6SFam Zheng##
8*34602dd6SFam Zheng## This program is free software; you can redistribute it and/or modify
9*34602dd6SFam Zheng## it under the terms of the GNU General Public License as published by
10*34602dd6SFam Zheng## the Free Software Foundation; either version 2 of the License, or
11*34602dd6SFam Zheng## (at your option) any later version.
12*34602dd6SFam Zheng##
13*34602dd6SFam Zheng## This program is distributed in the hope that it will be useful,
14*34602dd6SFam Zheng## but WITHOUT ANY WARRANTY; without even the implied warranty of
15*34602dd6SFam Zheng## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*34602dd6SFam Zheng## GNU General Public License for more details.
17*34602dd6SFam Zheng##
18*34602dd6SFam Zheng## You should have received a copy of the GNU General Public License
19*34602dd6SFam Zheng## along with this program.  If not, see <http://www.gnu.org/licenses/>.
20*34602dd6SFam Zheng##
21*34602dd6SFam Zheng#
22*34602dd6SFam Zheng# creator
23*34602dd6SFam Zhengowner=famz@redhat.com
24*34602dd6SFam Zheng
25*34602dd6SFam Zhengseq=`basename $0`
26*34602dd6SFam Zhengecho "QA output created by $seq"
27*34602dd6SFam Zheng
28*34602dd6SFam Zhengstatus=1        # failure is the default!
29*34602dd6SFam Zheng
30*34602dd6SFam Zheng_cleanup()
31*34602dd6SFam Zheng{
32*34602dd6SFam Zheng    echo "Cleanup"
33*34602dd6SFam Zheng    _cleanup_test_img
34*34602dd6SFam Zheng    rm "${TEST_IMG2}"
35*34602dd6SFam Zheng}
36*34602dd6SFam Zhengtrap "_cleanup; exit \$status" 0 1 2 3 15
37*34602dd6SFam Zheng
38*34602dd6SFam Zheng_compare()
39*34602dd6SFam Zheng{
40*34602dd6SFam Zheng    $QEMU_IMG compare "$@" "$TEST_IMG" "${TEST_IMG2}"
41*34602dd6SFam Zheng    echo $?
42*34602dd6SFam Zheng}
43*34602dd6SFam Zheng
44*34602dd6SFam Zheng# get standard environment, filters and checks
45*34602dd6SFam Zheng. ./common.rc
46*34602dd6SFam Zheng. ./common.filter
47*34602dd6SFam Zheng. ./common.pattern
48*34602dd6SFam Zheng
49*34602dd6SFam Zheng_supported_fmt qcow2
50*34602dd6SFam Zheng_supported_proto file
51*34602dd6SFam Zheng_supported_os Linux
52*34602dd6SFam Zheng
53*34602dd6SFam Zheng# Setup test basic parameters
54*34602dd6SFam ZhengTEST_IMG2=$TEST_IMG.2
55*34602dd6SFam ZhengCLUSTER_SIZE=4096
56*34602dd6SFam Zhengsize=1024M
57*34602dd6SFam Zheng
58*34602dd6SFam Zheng# Test cluster allocated in one, with IO error
59*34602dd6SFam Zhengcat > "$TEST_DIR/blkdebug.conf"<<EOF
60*34602dd6SFam Zheng[inject-error]
61*34602dd6SFam Zhengevent = "read_aio"
62*34602dd6SFam Zhengerrno = "5"
63*34602dd6SFam Zhengonce ="off"
64*34602dd6SFam ZhengEOF
65*34602dd6SFam Zheng_make_test_img $size
66*34602dd6SFam Zhengcp "$TEST_IMG" "$TEST_IMG2"
67*34602dd6SFam Zhengio_pattern write 512 512 0 1 102
68*34602dd6SFam ZhengTEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG" _compare 2>&1 |\
69*34602dd6SFam Zheng    _filter_testdir | _filter_imgfmt
70*34602dd6SFam Zheng
71*34602dd6SFam Zheng# Test cluster allocated in one, with different sizes and IO error in the part
72*34602dd6SFam Zheng# that exists only in one image
73*34602dd6SFam Zhengcat > "$TEST_DIR/blkdebug.conf"<<EOF
74*34602dd6SFam Zheng[inject-error]
75*34602dd6SFam Zhengevent = "read_aio"
76*34602dd6SFam Zhengerrno = "5"
77*34602dd6SFam Zhengonce ="off"
78*34602dd6SFam ZhengEOF
79*34602dd6SFam Zheng_make_test_img $size
80*34602dd6SFam ZhengTEST_IMG="$TEST_IMG2" _make_test_img 0
81*34602dd6SFam Zhengio_pattern write 512 512 0 1 102
82*34602dd6SFam ZhengTEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG" _compare 2>&1 |\
83*34602dd6SFam Zheng    _filter_testdir | _filter_imgfmt
84*34602dd6SFam Zheng
85*34602dd6SFam Zheng# Cleanup
86*34602dd6SFam Zhengstatus=0
87