xref: /openbmc/qemu/tests/qemu-iotests/159 (revision 86ce1f6e2b73b33c4a52818e245378bf52d27200)
1*86ce1f6eSReda Sallahi#! /bin/bash
2*86ce1f6eSReda Sallahi#
3*86ce1f6eSReda Sallahi# qemu-img dd test with different block sizes
4*86ce1f6eSReda Sallahi#
5*86ce1f6eSReda Sallahi# Copyright (C) 2016 Reda Sallahi
6*86ce1f6eSReda Sallahi#
7*86ce1f6eSReda Sallahi# This program is free software; you can redistribute it and/or modify
8*86ce1f6eSReda Sallahi# it under the terms of the GNU General Public License as published by
9*86ce1f6eSReda Sallahi# the Free Software Foundation; either version 2 of the License, or
10*86ce1f6eSReda Sallahi# (at your option) any later version.
11*86ce1f6eSReda Sallahi#
12*86ce1f6eSReda Sallahi# This program is distributed in the hope that it will be useful,
13*86ce1f6eSReda Sallahi# but WITHOUT ANY WARRANTY; without even the implied warranty of
14*86ce1f6eSReda Sallahi# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*86ce1f6eSReda Sallahi# GNU General Public License for more details.
16*86ce1f6eSReda Sallahi#
17*86ce1f6eSReda Sallahi# You should have received a copy of the GNU General Public License
18*86ce1f6eSReda Sallahi# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19*86ce1f6eSReda Sallahi#
20*86ce1f6eSReda Sallahi
21*86ce1f6eSReda Sallahiowner=fullmanet@gmail.com
22*86ce1f6eSReda Sallahi
23*86ce1f6eSReda Sallahiseq="$(basename $0)"
24*86ce1f6eSReda Sallahiecho "QA output created by $seq"
25*86ce1f6eSReda Sallahi
26*86ce1f6eSReda Sallahihere="$PWD"
27*86ce1f6eSReda Sallahistatus=1
28*86ce1f6eSReda Sallahi
29*86ce1f6eSReda Sallahi_cleanup()
30*86ce1f6eSReda Sallahi{
31*86ce1f6eSReda Sallahi    _cleanup_test_img
32*86ce1f6eSReda Sallahi    rm -f "$TEST_IMG.out"
33*86ce1f6eSReda Sallahi}
34*86ce1f6eSReda Sallahitrap "_cleanup; exit \$status" 0 1 2 3 15
35*86ce1f6eSReda Sallahi
36*86ce1f6eSReda Sallahi. ./common.rc
37*86ce1f6eSReda Sallahi. ./common.filter
38*86ce1f6eSReda Sallahi. ./common.pattern
39*86ce1f6eSReda Sallahi
40*86ce1f6eSReda Sallahi_supported_fmt generic
41*86ce1f6eSReda Sallahi_supported_proto file
42*86ce1f6eSReda Sallahi_supported_os Linux
43*86ce1f6eSReda Sallahi
44*86ce1f6eSReda SallahiTEST_SIZES="5 512 1024 1999 1K 64K 1M"
45*86ce1f6eSReda Sallahi
46*86ce1f6eSReda Sallahifor bs in $TEST_SIZES; do
47*86ce1f6eSReda Sallahi    echo
48*86ce1f6eSReda Sallahi    echo "== Creating image =="
49*86ce1f6eSReda Sallahi
50*86ce1f6eSReda Sallahi    size=1M
51*86ce1f6eSReda Sallahi    _make_test_img $size
52*86ce1f6eSReda Sallahi    _check_test_img
53*86ce1f6eSReda Sallahi    $QEMU_IO -c "write -P 0xa 0 $size" "$TEST_IMG" | _filter_qemu_io
54*86ce1f6eSReda Sallahi
55*86ce1f6eSReda Sallahi    echo
56*86ce1f6eSReda Sallahi    echo "== Converting the image with dd with a block size of $bs =="
57*86ce1f6eSReda Sallahi
58*86ce1f6eSReda Sallahi    $QEMU_IMG dd if="$TEST_IMG" of="$TEST_IMG.out" bs=$bs -O "$IMGFMT"
59*86ce1f6eSReda Sallahi    TEST_IMG="$TEST_IMG.out" _check_test_img
60*86ce1f6eSReda Sallahi
61*86ce1f6eSReda Sallahi    echo
62*86ce1f6eSReda Sallahi    echo "== Compare the images with qemu-img compare =="
63*86ce1f6eSReda Sallahi
64*86ce1f6eSReda Sallahi    $QEMU_IMG compare "$TEST_IMG" "$TEST_IMG.out"
65*86ce1f6eSReda Sallahidone
66*86ce1f6eSReda Sallahi
67*86ce1f6eSReda Sallahiecho
68*86ce1f6eSReda Sallahiecho "*** done"
69*86ce1f6eSReda Sallahirm -f "$seq.full"
70*86ce1f6eSReda Sallahistatus=0
71