115a2b18fSMax Reitz#!/bin/bash 215a2b18fSMax Reitz# 315a2b18fSMax Reitz# Test case for shared BDS between backend trees 415a2b18fSMax Reitz# 515a2b18fSMax Reitz# Copyright (C) 2016 Red Hat, Inc. 615a2b18fSMax Reitz# 715a2b18fSMax Reitz# This program is free software; you can redistribute it and/or modify 815a2b18fSMax Reitz# it under the terms of the GNU General Public License as published by 915a2b18fSMax Reitz# the Free Software Foundation; either version 2 of the License, or 1015a2b18fSMax Reitz# (at your option) any later version. 1115a2b18fSMax Reitz# 1215a2b18fSMax Reitz# This program is distributed in the hope that it will be useful, 1315a2b18fSMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of 1415a2b18fSMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1515a2b18fSMax Reitz# GNU General Public License for more details. 1615a2b18fSMax Reitz# 1715a2b18fSMax Reitz# You should have received a copy of the GNU General Public License 1815a2b18fSMax Reitz# along with this program. If not, see <http://www.gnu.org/licenses/>. 1915a2b18fSMax Reitz# 2015a2b18fSMax Reitz 2115a2b18fSMax Reitz# creator 2215a2b18fSMax Reitzowner=mreitz@redhat.com 2315a2b18fSMax Reitz 2415a2b18fSMax Reitzseq="$(basename $0)" 2515a2b18fSMax Reitzecho "QA output created by $seq" 2615a2b18fSMax Reitz 2715a2b18fSMax Reitzhere="$PWD" 2815a2b18fSMax Reitzstatus=1 # failure is the default! 2915a2b18fSMax Reitz 3015a2b18fSMax Reitz_cleanup() 3115a2b18fSMax Reitz{ 32*ecfa1854SJeff 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 4315a2b18fSMax Reitz_supported_proto file 4415a2b18fSMax Reitz_supported_os Linux 4515a2b18fSMax Reitz 4615a2b18fSMax Reitz_make_test_img 64k 4715a2b18fSMax Reitz 4815a2b18fSMax Reitz_launch_qemu 4915a2b18fSMax Reitz 5015a2b18fSMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 5115a2b18fSMax Reitz "{ 'execute': 'qmp_capabilities' }" \ 5215a2b18fSMax Reitz 'return' 5315a2b18fSMax Reitz 5415a2b18fSMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 5515a2b18fSMax Reitz "{ 'execute': 'blockdev-add', 560153d2f5SKevin Wolf 'arguments': { 'node-name': 'protocol', 5715a2b18fSMax Reitz 'driver': 'file', 580153d2f5SKevin Wolf 'filename': '$TEST_IMG' } }" \ 5915a2b18fSMax Reitz 'return' 6015a2b18fSMax Reitz 6115a2b18fSMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 6215a2b18fSMax Reitz "{ 'execute': 'blockdev-add', 630153d2f5SKevin Wolf 'arguments': { 'node-name': 'format', 6415a2b18fSMax Reitz 'driver': '$IMGFMT', 650153d2f5SKevin Wolf 'file': 'protocol' } }" \ 6615a2b18fSMax Reitz 'return' 6715a2b18fSMax Reitz 6815a2b18fSMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 6915a2b18fSMax Reitz "{ 'execute': 'human-monitor-command', 7015a2b18fSMax Reitz 'arguments': { 'command-line': 'qemu-io format \"write -P 42 0 64k\"' } }" \ 7115a2b18fSMax Reitz 'return' 7215a2b18fSMax Reitz 7315a2b18fSMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 7415a2b18fSMax Reitz "{ 'execute': 'quit' }" \ 7515a2b18fSMax Reitz 'return' 7615a2b18fSMax Reitz 7715a2b18fSMax Reitzwait=1 _cleanup_qemu 7815a2b18fSMax Reitz 7915a2b18fSMax Reitz_check_test_img 8015a2b18fSMax Reitz 8115a2b18fSMax Reitz$QEMU_IO -c 'read -P 42 0 64k' "$TEST_IMG" | _filter_qemu_io 8215a2b18fSMax Reitz 8315a2b18fSMax Reitz# success, all done 8415a2b18fSMax Reitzecho '*** done' 8515a2b18fSMax Reitzrm -f $seq.full 8615a2b18fSMax Reitzstatus=0 87