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