186ce1f6eSReda Sallahi#! /bin/bash 286ce1f6eSReda Sallahi# 386ce1f6eSReda Sallahi# qemu-img dd test with different block sizes 486ce1f6eSReda Sallahi# 586ce1f6eSReda Sallahi# Copyright (C) 2016 Reda Sallahi 686ce1f6eSReda Sallahi# 786ce1f6eSReda Sallahi# This program is free software; you can redistribute it and/or modify 886ce1f6eSReda Sallahi# it under the terms of the GNU General Public License as published by 986ce1f6eSReda Sallahi# the Free Software Foundation; either version 2 of the License, or 1086ce1f6eSReda Sallahi# (at your option) any later version. 1186ce1f6eSReda Sallahi# 1286ce1f6eSReda Sallahi# This program is distributed in the hope that it will be useful, 1386ce1f6eSReda Sallahi# but WITHOUT ANY WARRANTY; without even the implied warranty of 1486ce1f6eSReda Sallahi# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1586ce1f6eSReda Sallahi# GNU General Public License for more details. 1686ce1f6eSReda Sallahi# 1786ce1f6eSReda Sallahi# You should have received a copy of the GNU General Public License 1886ce1f6eSReda Sallahi# along with this program. If not, see <http://www.gnu.org/licenses/>. 1986ce1f6eSReda Sallahi# 2086ce1f6eSReda Sallahi 2186ce1f6eSReda Sallahiowner=fullmanet@gmail.com 2286ce1f6eSReda Sallahi 2386ce1f6eSReda Sallahiseq="$(basename $0)" 2486ce1f6eSReda Sallahiecho "QA output created by $seq" 2586ce1f6eSReda Sallahi 2686ce1f6eSReda Sallahihere="$PWD" 2786ce1f6eSReda Sallahistatus=1 2886ce1f6eSReda Sallahi 2986ce1f6eSReda Sallahi_cleanup() 3086ce1f6eSReda Sallahi{ 3186ce1f6eSReda Sallahi _cleanup_test_img 3286ce1f6eSReda Sallahi rm -f "$TEST_IMG.out" 3386ce1f6eSReda Sallahi} 3486ce1f6eSReda Sallahitrap "_cleanup; exit \$status" 0 1 2 3 15 3586ce1f6eSReda Sallahi 3686ce1f6eSReda Sallahi. ./common.rc 3786ce1f6eSReda Sallahi. ./common.filter 3886ce1f6eSReda Sallahi. ./common.pattern 3986ce1f6eSReda Sallahi 4086ce1f6eSReda Sallahi_supported_fmt generic 4186ce1f6eSReda Sallahi_supported_proto file 4286ce1f6eSReda Sallahi_supported_os Linux 43*2c6f6006SDaniel P. Berrange_unsupported_fmt luks 4486ce1f6eSReda Sallahi 4586ce1f6eSReda SallahiTEST_SIZES="5 512 1024 1999 1K 64K 1M" 4686ce1f6eSReda Sallahi 4786ce1f6eSReda Sallahifor bs in $TEST_SIZES; do 4886ce1f6eSReda Sallahi echo 4986ce1f6eSReda Sallahi echo "== Creating image ==" 5086ce1f6eSReda Sallahi 5186ce1f6eSReda Sallahi size=1M 5286ce1f6eSReda Sallahi _make_test_img $size 5386ce1f6eSReda Sallahi _check_test_img 5486ce1f6eSReda Sallahi $QEMU_IO -c "write -P 0xa 0 $size" "$TEST_IMG" | _filter_qemu_io 5586ce1f6eSReda Sallahi 5686ce1f6eSReda Sallahi echo 5786ce1f6eSReda Sallahi echo "== Converting the image with dd with a block size of $bs ==" 5886ce1f6eSReda Sallahi 5986ce1f6eSReda Sallahi $QEMU_IMG dd if="$TEST_IMG" of="$TEST_IMG.out" bs=$bs -O "$IMGFMT" 6086ce1f6eSReda Sallahi TEST_IMG="$TEST_IMG.out" _check_test_img 6186ce1f6eSReda Sallahi 6286ce1f6eSReda Sallahi echo 6386ce1f6eSReda Sallahi echo "== Compare the images with qemu-img compare ==" 6486ce1f6eSReda Sallahi 6586ce1f6eSReda Sallahi $QEMU_IMG compare "$TEST_IMG" "$TEST_IMG.out" 6686ce1f6eSReda Sallahidone 6786ce1f6eSReda Sallahi 6886ce1f6eSReda Sallahiecho 6986ce1f6eSReda Sallahiecho "*** done" 7086ce1f6eSReda Sallahirm -f "$seq.full" 7186ce1f6eSReda Sallahistatus=0 72