111a82d14SPhilippe 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 329a9c7c8fSMax Reitz rm -f "$SOCK_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 4434250395SMax Reitzkeep_stderr=y \ 4534250395SMax Reitz_launch_qemu 2> >(_filter_nbd) 4634250395SMax Reitz 4734250395SMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 4834250395SMax Reitz "{ 'execute': 'qmp_capabilities' }" \ 4934250395SMax Reitz 'return' 5034250395SMax Reitz 5134250395SMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 5234250395SMax Reitz "{ 'execute': 'nbd-server-start', 5334250395SMax Reitz 'arguments': { 'addr': { 'type': 'unix', 549a9c7c8fSMax Reitz 'data': { 'path': '$SOCK_DIR/nbd' }}}}" \ 5534250395SMax Reitz 'return' 5634250395SMax Reitz 5734250395SMax Reitz# This should just result in a client error, not in the server crashing 5834250395SMax Reitz$QEMU_IO_PROG -f raw -c quit \ 599a9c7c8fSMax Reitz "nbd+unix:///no_such_export?socket=$SOCK_DIR/nbd" 2>&1 \ 6034250395SMax Reitz | _filter_qemu_io | _filter_nbd 61*5c4fe018SEric Blake# Likewise, with longest possible name permitted in NBD protocol 62*5c4fe018SEric Blake$QEMU_IO_PROG -f raw -c quit \ 63*5c4fe018SEric Blake "nbd+unix:///$(printf %4096d 1 | tr ' ' a)?socket=$SOCK_DIR/nbd" 2>&1 \ 64*5c4fe018SEric Blake | _filter_qemu_io | _filter_nbd | sed 's/aaaa*aa/aa--aa/' 6534250395SMax Reitz 6634250395SMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 6734250395SMax Reitz "{ 'execute': 'quit' }" \ 6834250395SMax Reitz 'return' 6934250395SMax Reitz 7034250395SMax Reitzwait=1 _cleanup_qemu 7134250395SMax Reitz 7234250395SMax Reitz# success, all done 7334250395SMax Reitzecho '*** done' 7434250395SMax Reitzrm -f $seq.full 7534250395SMax Reitzstatus=0 76