xref: /qemu/tests/qemu-iotests/117 (revision 15a2b18fe5824388debe958e21c5dfa51457c7b6)
1*15a2b18fSMax Reitz#!/bin/bash
2*15a2b18fSMax Reitz#
3*15a2b18fSMax Reitz# Test case for shared BDS between backend trees
4*15a2b18fSMax Reitz#
5*15a2b18fSMax Reitz# Copyright (C) 2016 Red Hat, Inc.
6*15a2b18fSMax Reitz#
7*15a2b18fSMax Reitz# This program is free software; you can redistribute it and/or modify
8*15a2b18fSMax Reitz# it under the terms of the GNU General Public License as published by
9*15a2b18fSMax Reitz# the Free Software Foundation; either version 2 of the License, or
10*15a2b18fSMax Reitz# (at your option) any later version.
11*15a2b18fSMax Reitz#
12*15a2b18fSMax Reitz# This program is distributed in the hope that it will be useful,
13*15a2b18fSMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of
14*15a2b18fSMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*15a2b18fSMax Reitz# GNU General Public License for more details.
16*15a2b18fSMax Reitz#
17*15a2b18fSMax Reitz# You should have received a copy of the GNU General Public License
18*15a2b18fSMax Reitz# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19*15a2b18fSMax Reitz#
20*15a2b18fSMax Reitz
21*15a2b18fSMax Reitz# creator
22*15a2b18fSMax Reitzowner=mreitz@redhat.com
23*15a2b18fSMax Reitz
24*15a2b18fSMax Reitzseq="$(basename $0)"
25*15a2b18fSMax Reitzecho "QA output created by $seq"
26*15a2b18fSMax Reitz
27*15a2b18fSMax Reitzhere="$PWD"
28*15a2b18fSMax Reitztmp=/tmp/$$
29*15a2b18fSMax Reitzstatus=1	# failure is the default!
30*15a2b18fSMax Reitz
31*15a2b18fSMax Reitz_cleanup()
32*15a2b18fSMax Reitz{
33*15a2b18fSMax Reitz	_cleanup_test_img
34*15a2b18fSMax Reitz}
35*15a2b18fSMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15
36*15a2b18fSMax Reitz
37*15a2b18fSMax Reitz# get standard environment, filters and checks
38*15a2b18fSMax Reitz. ./common.rc
39*15a2b18fSMax Reitz. ./common.filter
40*15a2b18fSMax Reitz. ./common.qemu
41*15a2b18fSMax Reitz
42*15a2b18fSMax Reitz_supported_fmt qcow2
43*15a2b18fSMax Reitz_supported_proto file
44*15a2b18fSMax Reitz_supported_os Linux
45*15a2b18fSMax Reitz
46*15a2b18fSMax Reitz_make_test_img 64k
47*15a2b18fSMax Reitz
48*15a2b18fSMax Reitz_launch_qemu
49*15a2b18fSMax Reitz
50*15a2b18fSMax Reitz_send_qemu_cmd $QEMU_HANDLE \
51*15a2b18fSMax Reitz    "{ 'execute': 'qmp_capabilities' }" \
52*15a2b18fSMax Reitz    'return'
53*15a2b18fSMax Reitz
54*15a2b18fSMax Reitz_send_qemu_cmd $QEMU_HANDLE \
55*15a2b18fSMax Reitz    "{ 'execute': 'blockdev-add',
56*15a2b18fSMax Reitz       'arguments': { 'options': { 'id': 'protocol',
57*15a2b18fSMax Reitz                                   'driver': 'file',
58*15a2b18fSMax Reitz                                   'filename': '$TEST_IMG' } } }" \
59*15a2b18fSMax Reitz    'return'
60*15a2b18fSMax Reitz
61*15a2b18fSMax Reitz_send_qemu_cmd $QEMU_HANDLE \
62*15a2b18fSMax Reitz    "{ 'execute': 'blockdev-add',
63*15a2b18fSMax Reitz       'arguments': { 'options': { 'id': 'format',
64*15a2b18fSMax Reitz                                   'driver': '$IMGFMT',
65*15a2b18fSMax Reitz                                   'file': 'protocol' } } }" \
66*15a2b18fSMax Reitz    'return'
67*15a2b18fSMax Reitz
68*15a2b18fSMax Reitz_send_qemu_cmd $QEMU_HANDLE \
69*15a2b18fSMax Reitz    "{ 'execute': 'human-monitor-command',
70*15a2b18fSMax Reitz       'arguments': { 'command-line': 'qemu-io format \"write -P 42 0 64k\"' } }" \
71*15a2b18fSMax Reitz    'return'
72*15a2b18fSMax Reitz
73*15a2b18fSMax Reitz_send_qemu_cmd $QEMU_HANDLE \
74*15a2b18fSMax Reitz    "{ 'execute': 'quit' }" \
75*15a2b18fSMax Reitz    'return'
76*15a2b18fSMax Reitz
77*15a2b18fSMax Reitzwait=1 _cleanup_qemu
78*15a2b18fSMax Reitz
79*15a2b18fSMax Reitz_check_test_img
80*15a2b18fSMax Reitz
81*15a2b18fSMax Reitz$QEMU_IO -c 'read -P 42 0 64k' "$TEST_IMG" | _filter_qemu_io
82*15a2b18fSMax Reitz
83*15a2b18fSMax Reitz# success, all done
84*15a2b18fSMax Reitzecho '*** done'
85*15a2b18fSMax Reitzrm -f $seq.full
86*15a2b18fSMax Reitzstatus=0
87