xref: /qemu/tests/qemu-iotests/170 (revision 2c6f6006429a94fc3f1a2d2e68719f300744566d)
186ce1f6eSReda Sallahi#! /bin/bash
286ce1f6eSReda Sallahi#
386ce1f6eSReda Sallahi# qemu-img dd test
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 Sallahiecho
4686ce1f6eSReda Sallahiecho "== Creating image =="
4786ce1f6eSReda Sallahi
4886ce1f6eSReda Sallahisize=1M
4986ce1f6eSReda Sallahi_make_test_img $size
5086ce1f6eSReda Sallahi_check_test_img
5186ce1f6eSReda Sallahi
5286ce1f6eSReda Sallahi$QEMU_IO -c "write -P 0xa 0 $size" "$TEST_IMG" | _filter_qemu_io
5386ce1f6eSReda Sallahi
5486ce1f6eSReda Sallahiecho
5586ce1f6eSReda Sallahiecho "== Converting the image with dd =="
5686ce1f6eSReda Sallahi
5786ce1f6eSReda Sallahi$QEMU_IMG dd if="$TEST_IMG" of="$TEST_IMG.out" -O "$IMGFMT"
5886ce1f6eSReda SallahiTEST_IMG="$TEST_IMG.out" _check_test_img
5986ce1f6eSReda Sallahi
6086ce1f6eSReda Sallahiecho
6186ce1f6eSReda Sallahiecho "== Compare the images with qemu-img compare =="
6286ce1f6eSReda Sallahi
6386ce1f6eSReda Sallahi$QEMU_IMG compare "$TEST_IMG" "$TEST_IMG.out"
6486ce1f6eSReda Sallahi
6586ce1f6eSReda Sallahiecho
6686ce1f6eSReda Sallahiecho "*** done"
6786ce1f6eSReda Sallahirm -f "$seq.full"
6886ce1f6eSReda Sallahistatus=0
69