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