xref: /openbmc/qemu/tests/qemu-iotests/143 (revision ecfa185400ade2abc9915efa924cbad1e15a21a4)
134250395SMax Reitz#!/bin/bash
234250395SMax Reitz#
334250395SMax Reitz# Test case for connecting to a non-existing NBD export name
434250395SMax Reitz#
534250395SMax Reitz# Copyright (C) 2016 Red Hat, Inc.
634250395SMax Reitz#
734250395SMax Reitz# This program is free software; you can redistribute it and/or modify
834250395SMax Reitz# it under the terms of the GNU General Public License as published by
934250395SMax Reitz# the Free Software Foundation; either version 2 of the License, or
1034250395SMax Reitz# (at your option) any later version.
1134250395SMax Reitz#
1234250395SMax Reitz# This program is distributed in the hope that it will be useful,
1334250395SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of
1434250395SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1534250395SMax Reitz# GNU General Public License for more details.
1634250395SMax Reitz#
1734250395SMax Reitz# You should have received a copy of the GNU General Public License
1834250395SMax Reitz# along with this program.  If not, see <http://www.gnu.org/licenses/>.
1934250395SMax Reitz#
2034250395SMax Reitz
2134250395SMax Reitz# creator
2234250395SMax Reitzowner=mreitz@redhat.com
2334250395SMax Reitz
2434250395SMax Reitzseq="$(basename $0)"
2534250395SMax Reitzecho "QA output created by $seq"
2634250395SMax Reitz
2734250395SMax Reitzhere="$PWD"
2834250395SMax Reitzstatus=1	# failure is the default!
2934250395SMax Reitz
3034250395SMax Reitz_cleanup()
3134250395SMax Reitz{
32*ecfa1854SJeff Cody    _cleanup_qemu
3334250395SMax Reitz    rm -f "$TEST_DIR/nbd"
3434250395SMax Reitz}
3534250395SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15
3634250395SMax Reitz
3734250395SMax Reitz# get standard environment, filters and checks
3834250395SMax Reitz. ./common.rc
3934250395SMax Reitz. ./common.filter
4034250395SMax Reitz. ./common.qemu
4134250395SMax Reitz
4234250395SMax Reitz_supported_fmt generic
4334250395SMax Reitz_supported_proto generic
4434250395SMax Reitz_supported_os Linux
4534250395SMax Reitz
4634250395SMax Reitzkeep_stderr=y \
4734250395SMax Reitz_launch_qemu 2> >(_filter_nbd)
4834250395SMax Reitz
4934250395SMax Reitz_send_qemu_cmd $QEMU_HANDLE \
5034250395SMax Reitz    "{ 'execute': 'qmp_capabilities' }" \
5134250395SMax Reitz    'return'
5234250395SMax Reitz
5334250395SMax Reitz_send_qemu_cmd $QEMU_HANDLE \
5434250395SMax Reitz    "{ 'execute': 'nbd-server-start',
5534250395SMax Reitz       'arguments': { 'addr': { 'type': 'unix',
5634250395SMax Reitz                                'data': { 'path': '$TEST_DIR/nbd' }}}}" \
5734250395SMax Reitz    'return'
5834250395SMax Reitz
5934250395SMax Reitz# This should just result in a client error, not in the server crashing
6034250395SMax Reitz$QEMU_IO_PROG -f raw -c quit \
6134250395SMax Reitz    "nbd+unix:///no_such_export?socket=$TEST_DIR/nbd" 2>&1 \
6234250395SMax Reitz    | _filter_qemu_io | _filter_nbd
6334250395SMax Reitz
6434250395SMax Reitz_send_qemu_cmd $QEMU_HANDLE \
6534250395SMax Reitz    "{ 'execute': 'quit' }" \
6634250395SMax Reitz    'return'
6734250395SMax Reitz
6834250395SMax Reitzwait=1 _cleanup_qemu
6934250395SMax Reitz
7034250395SMax Reitz# success, all done
7134250395SMax Reitzecho '*** done'
7234250395SMax Reitzrm -f $seq.full
7334250395SMax Reitzstatus=0
74