xref: /openbmc/qemu/tests/qemu-iotests/170 (revision 86ce1f6e2b73b33c4a52818e245378bf52d27200)
1*86ce1f6eSReda Sallahi#! /bin/bash
2*86ce1f6eSReda Sallahi#
3*86ce1f6eSReda Sallahi# qemu-img dd test
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 Sallahiecho
45*86ce1f6eSReda Sallahiecho "== Creating image =="
46*86ce1f6eSReda Sallahi
47*86ce1f6eSReda Sallahisize=1M
48*86ce1f6eSReda Sallahi_make_test_img $size
49*86ce1f6eSReda Sallahi_check_test_img
50*86ce1f6eSReda Sallahi
51*86ce1f6eSReda Sallahi$QEMU_IO -c "write -P 0xa 0 $size" "$TEST_IMG" | _filter_qemu_io
52*86ce1f6eSReda Sallahi
53*86ce1f6eSReda Sallahiecho
54*86ce1f6eSReda Sallahiecho "== Converting the image with dd =="
55*86ce1f6eSReda Sallahi
56*86ce1f6eSReda Sallahi$QEMU_IMG dd if="$TEST_IMG" of="$TEST_IMG.out" -O "$IMGFMT"
57*86ce1f6eSReda SallahiTEST_IMG="$TEST_IMG.out" _check_test_img
58*86ce1f6eSReda Sallahi
59*86ce1f6eSReda Sallahiecho
60*86ce1f6eSReda Sallahiecho "== Compare the images with qemu-img compare =="
61*86ce1f6eSReda Sallahi
62*86ce1f6eSReda Sallahi$QEMU_IMG compare "$TEST_IMG" "$TEST_IMG.out"
63*86ce1f6eSReda Sallahi
64*86ce1f6eSReda Sallahiecho
65*86ce1f6eSReda Sallahiecho "*** done"
66*86ce1f6eSReda Sallahirm -f "$seq.full"
67*86ce1f6eSReda Sallahistatus=0
68