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