xref: /qemu/tests/qemu-iotests/123 (revision 723bfab5cb229436ab31498a19aed931723cd3be)
1*723bfab5SMax Reitz#!/bin/bash
2*723bfab5SMax Reitz#
3*723bfab5SMax Reitz# Test case for qemu-img convert to NBD
4*723bfab5SMax Reitz#
5*723bfab5SMax Reitz# Copyright (C) 2015 Red Hat, Inc.
6*723bfab5SMax Reitz#
7*723bfab5SMax Reitz# This program is free software; you can redistribute it and/or modify
8*723bfab5SMax Reitz# it under the terms of the GNU General Public License as published by
9*723bfab5SMax Reitz# the Free Software Foundation; either version 2 of the License, or
10*723bfab5SMax Reitz# (at your option) any later version.
11*723bfab5SMax Reitz#
12*723bfab5SMax Reitz# This program is distributed in the hope that it will be useful,
13*723bfab5SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of
14*723bfab5SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*723bfab5SMax Reitz# GNU General Public License for more details.
16*723bfab5SMax Reitz#
17*723bfab5SMax Reitz# You should have received a copy of the GNU General Public License
18*723bfab5SMax Reitz# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19*723bfab5SMax Reitz#
20*723bfab5SMax Reitz
21*723bfab5SMax Reitz# creator
22*723bfab5SMax Reitzowner=mreitz@redhat.com
23*723bfab5SMax Reitz
24*723bfab5SMax Reitzseq="$(basename $0)"
25*723bfab5SMax Reitzecho "QA output created by $seq"
26*723bfab5SMax Reitz
27*723bfab5SMax Reitzhere="$PWD"
28*723bfab5SMax Reitztmp=/tmp/$$
29*723bfab5SMax Reitzstatus=1	# failure is the default!
30*723bfab5SMax Reitz
31*723bfab5SMax Reitz_cleanup()
32*723bfab5SMax Reitz{
33*723bfab5SMax Reitz    _cleanup_test_img
34*723bfab5SMax Reitz    rm -f "$SRC_IMG"
35*723bfab5SMax Reitz}
36*723bfab5SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15
37*723bfab5SMax Reitz
38*723bfab5SMax Reitz# get standard environment, filters and checks
39*723bfab5SMax Reitz. ./common.rc
40*723bfab5SMax Reitz. ./common.filter
41*723bfab5SMax Reitz
42*723bfab5SMax Reitz_supported_fmt raw
43*723bfab5SMax Reitz_supported_proto nbd
44*723bfab5SMax Reitz_supported_os Linux
45*723bfab5SMax Reitz
46*723bfab5SMax ReitzSRC_IMG="$TEST_DIR/source.$IMGFMT"
47*723bfab5SMax Reitz
48*723bfab5SMax Reitz_make_test_img 1M
49*723bfab5SMax Reitz$QEMU_IMG create -f $IMGFMT "$SRC_IMG" 1M | _filter_img_create
50*723bfab5SMax Reitz
51*723bfab5SMax Reitz$QEMU_IO -c 'write -P 42 0 1M' "$SRC_IMG" | _filter_qemu_io
52*723bfab5SMax Reitz
53*723bfab5SMax Reitz$QEMU_IMG convert -n -f $IMGFMT -O raw "$SRC_IMG" "$TEST_IMG"
54*723bfab5SMax Reitz
55*723bfab5SMax Reitz$QEMU_IO -c 'read -P 42 0 1M' "$TEST_IMG" | _filter_qemu_io
56*723bfab5SMax Reitz
57*723bfab5SMax Reitz
58*723bfab5SMax Reitz# success, all done
59*723bfab5SMax Reitzecho
60*723bfab5SMax Reitzecho '*** done'
61*723bfab5SMax Reitzrm -f $seq.full
62*723bfab5SMax Reitzstatus=0
63