xref: /openbmc/qemu/tests/qemu-iotests/143 (revision 11a82d14293cd66f428f535741717ff338c0722b)
1*11a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env 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 Reitzstatus=1	# failure is the default!
2834250395SMax Reitz
2934250395SMax Reitz_cleanup()
3034250395SMax Reitz{
31ecfa1854SJeff Cody    _cleanup_qemu
3234250395SMax Reitz    rm -f "$TEST_DIR/nbd"
3334250395SMax Reitz}
3434250395SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15
3534250395SMax Reitz
3634250395SMax Reitz# get standard environment, filters and checks
3734250395SMax Reitz. ./common.rc
3834250395SMax Reitz. ./common.filter
3934250395SMax Reitz. ./common.qemu
4034250395SMax Reitz
4134250395SMax Reitz_supported_fmt generic
4234250395SMax Reitz_supported_proto generic
4334250395SMax Reitz_supported_os Linux
4434250395SMax Reitz
4534250395SMax Reitzkeep_stderr=y \
4634250395SMax Reitz_launch_qemu 2> >(_filter_nbd)
4734250395SMax Reitz
4834250395SMax Reitz_send_qemu_cmd $QEMU_HANDLE \
4934250395SMax Reitz    "{ 'execute': 'qmp_capabilities' }" \
5034250395SMax Reitz    'return'
5134250395SMax Reitz
5234250395SMax Reitz_send_qemu_cmd $QEMU_HANDLE \
5334250395SMax Reitz    "{ 'execute': 'nbd-server-start',
5434250395SMax Reitz       'arguments': { 'addr': { 'type': 'unix',
5534250395SMax Reitz                                'data': { 'path': '$TEST_DIR/nbd' }}}}" \
5634250395SMax Reitz    'return'
5734250395SMax Reitz
5834250395SMax Reitz# This should just result in a client error, not in the server crashing
5934250395SMax Reitz$QEMU_IO_PROG -f raw -c quit \
6034250395SMax Reitz    "nbd+unix:///no_such_export?socket=$TEST_DIR/nbd" 2>&1 \
6134250395SMax Reitz    | _filter_qemu_io | _filter_nbd
6234250395SMax Reitz
6334250395SMax Reitz_send_qemu_cmd $QEMU_HANDLE \
6434250395SMax Reitz    "{ 'execute': 'quit' }" \
6534250395SMax Reitz    'return'
6634250395SMax Reitz
6734250395SMax Reitzwait=1 _cleanup_qemu
6834250395SMax Reitz
6934250395SMax Reitz# success, all done
7034250395SMax Reitzecho '*** done'
7134250395SMax Reitzrm -f $seq.full
7234250395SMax Reitzstatus=0
73