xref: /qemu/tests/qemu-iotests/159 (revision f91ecbd74eb75e9d4c7b4016edaf69d070cb3f9b)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env 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 Sallahistatus=1
2786ce1f6eSReda Sallahi
2886ce1f6eSReda Sallahi_cleanup()
2986ce1f6eSReda Sallahi{
3086ce1f6eSReda Sallahi    _cleanup_test_img
31*f91ecbd7SMax Reitz    _rm_test_img "$TEST_IMG.out"
3286ce1f6eSReda Sallahi}
3386ce1f6eSReda Sallahitrap "_cleanup; exit \$status" 0 1 2 3 15
3486ce1f6eSReda Sallahi
3586ce1f6eSReda Sallahi. ./common.rc
3686ce1f6eSReda Sallahi. ./common.filter
3786ce1f6eSReda Sallahi. ./common.pattern
3886ce1f6eSReda Sallahi
3986ce1f6eSReda Sallahi_supported_fmt generic
4086ce1f6eSReda Sallahi_supported_proto file
412c6f6006SDaniel P. Berrange_unsupported_fmt luks
4286ce1f6eSReda Sallahi
4386ce1f6eSReda SallahiTEST_SIZES="5 512 1024 1999 1K 64K 1M"
4486ce1f6eSReda Sallahi
4586ce1f6eSReda Sallahifor bs in $TEST_SIZES; do
4686ce1f6eSReda Sallahi    echo
4786ce1f6eSReda Sallahi    echo "== Creating image =="
4886ce1f6eSReda Sallahi
4986ce1f6eSReda Sallahi    size=1M
5086ce1f6eSReda Sallahi    _make_test_img $size
5186ce1f6eSReda Sallahi    _check_test_img
5286ce1f6eSReda Sallahi    $QEMU_IO -c "write -P 0xa 0 $size" "$TEST_IMG" | _filter_qemu_io
5386ce1f6eSReda Sallahi
5486ce1f6eSReda Sallahi    echo
5586ce1f6eSReda Sallahi    echo "== Converting the image with dd with a block size of $bs =="
5686ce1f6eSReda Sallahi
5786ce1f6eSReda Sallahi    $QEMU_IMG dd if="$TEST_IMG" of="$TEST_IMG.out" bs=$bs -O "$IMGFMT"
5886ce1f6eSReda Sallahi    TEST_IMG="$TEST_IMG.out" _check_test_img
5986ce1f6eSReda Sallahi
6086ce1f6eSReda Sallahi    echo
6186ce1f6eSReda Sallahi    echo "== Compare the images with qemu-img compare =="
6286ce1f6eSReda Sallahi
6386ce1f6eSReda Sallahi    $QEMU_IMG compare "$TEST_IMG" "$TEST_IMG.out"
6486ce1f6eSReda Sallahidone
6586ce1f6eSReda Sallahi
6686ce1f6eSReda Sallahiecho
6786ce1f6eSReda Sallahiecho "*** done"
6886ce1f6eSReda Sallahirm -f "$seq.full"
6986ce1f6eSReda Sallahistatus=0
70