xref: /openbmc/qemu/tests/qemu-iotests/117 (revision 68894b5fed671d49587209697f2224b4e857fd1a)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
29dd003a9SVladimir Sementsov-Ogievskiy# group: rw auto
315a2b18fSMax Reitz#
415a2b18fSMax Reitz# Test case for shared BDS between backend trees
515a2b18fSMax Reitz#
615a2b18fSMax Reitz# Copyright (C) 2016 Red Hat, Inc.
715a2b18fSMax Reitz#
815a2b18fSMax Reitz# This program is free software; you can redistribute it and/or modify
915a2b18fSMax Reitz# it under the terms of the GNU General Public License as published by
1015a2b18fSMax Reitz# the Free Software Foundation; either version 2 of the License, or
1115a2b18fSMax Reitz# (at your option) any later version.
1215a2b18fSMax Reitz#
1315a2b18fSMax Reitz# This program is distributed in the hope that it will be useful,
1415a2b18fSMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of
1515a2b18fSMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1615a2b18fSMax Reitz# GNU General Public License for more details.
1715a2b18fSMax Reitz#
1815a2b18fSMax Reitz# You should have received a copy of the GNU General Public License
1915a2b18fSMax Reitz# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2015a2b18fSMax Reitz#
2115a2b18fSMax Reitz
2215a2b18fSMax Reitz# creator
23*42a5009dSJohn Snowowner=hreitz@redhat.com
2415a2b18fSMax Reitz
2515a2b18fSMax Reitzseq="$(basename $0)"
2615a2b18fSMax Reitzecho "QA output created by $seq"
2715a2b18fSMax Reitz
2815a2b18fSMax Reitzstatus=1	# failure is the default!
2915a2b18fSMax Reitz
3015a2b18fSMax Reitz_cleanup()
3115a2b18fSMax Reitz{
32ecfa1854SJeff Cody    _cleanup_qemu
3315a2b18fSMax Reitz	_cleanup_test_img
3415a2b18fSMax Reitz}
3515a2b18fSMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15
3615a2b18fSMax Reitz
3715a2b18fSMax Reitz# get standard environment, filters and checks
3815a2b18fSMax Reitz. ./common.rc
3915a2b18fSMax Reitz. ./common.filter
4015a2b18fSMax Reitz. ./common.qemu
4115a2b18fSMax Reitz
4215a2b18fSMax Reitz_supported_fmt qcow2
4357284d2aSMax Reitz_supported_proto file fuse
4415a2b18fSMax Reitz
4515a2b18fSMax Reitz_make_test_img 64k
4615a2b18fSMax Reitz
4715a2b18fSMax Reitz_launch_qemu
4815a2b18fSMax Reitz
4915a2b18fSMax Reitz_send_qemu_cmd $QEMU_HANDLE \
5015a2b18fSMax Reitz    "{ 'execute': 'qmp_capabilities' }" \
5115a2b18fSMax Reitz    'return'
5215a2b18fSMax Reitz
5315a2b18fSMax Reitz_send_qemu_cmd $QEMU_HANDLE \
5415a2b18fSMax Reitz    "{ 'execute': 'blockdev-add',
550153d2f5SKevin Wolf       'arguments': { 'node-name': 'protocol',
5615a2b18fSMax Reitz                      'driver': 'file',
570153d2f5SKevin Wolf                      'filename': '$TEST_IMG' } }" \
5815a2b18fSMax Reitz    'return'
5915a2b18fSMax Reitz
6015a2b18fSMax Reitz_send_qemu_cmd $QEMU_HANDLE \
6115a2b18fSMax Reitz    "{ 'execute': 'blockdev-add',
620153d2f5SKevin Wolf       'arguments': { 'node-name': 'format',
6315a2b18fSMax Reitz                      'driver': '$IMGFMT',
640153d2f5SKevin Wolf                      'file': 'protocol' } }" \
6515a2b18fSMax Reitz    'return'
6615a2b18fSMax Reitz
6715a2b18fSMax Reitz_send_qemu_cmd $QEMU_HANDLE \
6815a2b18fSMax Reitz    "{ 'execute': 'human-monitor-command',
6915a2b18fSMax Reitz       'arguments': { 'command-line': 'qemu-io format \"write -P 42 0 64k\"' } }" \
7015a2b18fSMax Reitz    'return'
7115a2b18fSMax Reitz
7215a2b18fSMax Reitz_send_qemu_cmd $QEMU_HANDLE \
7315a2b18fSMax Reitz    "{ 'execute': 'quit' }" \
7415a2b18fSMax Reitz    'return'
7515a2b18fSMax Reitz
7615a2b18fSMax Reitzwait=1 _cleanup_qemu
7715a2b18fSMax Reitz
7815a2b18fSMax Reitz_check_test_img
7915a2b18fSMax Reitz
8015a2b18fSMax Reitz$QEMU_IO -c 'read -P 42 0 64k' "$TEST_IMG" | _filter_qemu_io
8115a2b18fSMax Reitz
8215a2b18fSMax Reitz# success, all done
8315a2b18fSMax Reitzecho '*** done'
8415a2b18fSMax Reitzrm -f $seq.full
8515a2b18fSMax Reitzstatus=0
86