111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 29dd003a9SVladimir Sementsov-Ogievskiy# group: auto quick 334250395SMax Reitz# 434250395SMax Reitz# Test case for connecting to a non-existing NBD export name 534250395SMax Reitz# 634250395SMax Reitz# Copyright (C) 2016 Red Hat, Inc. 734250395SMax Reitz# 834250395SMax Reitz# This program is free software; you can redistribute it and/or modify 934250395SMax Reitz# it under the terms of the GNU General Public License as published by 1034250395SMax Reitz# the Free Software Foundation; either version 2 of the License, or 1134250395SMax Reitz# (at your option) any later version. 1234250395SMax Reitz# 1334250395SMax Reitz# This program is distributed in the hope that it will be useful, 1434250395SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of 1534250395SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1634250395SMax Reitz# GNU General Public License for more details. 1734250395SMax Reitz# 1834250395SMax Reitz# You should have received a copy of the GNU General Public License 1934250395SMax Reitz# along with this program. If not, see <http://www.gnu.org/licenses/>. 2034250395SMax Reitz# 2134250395SMax Reitz 2234250395SMax Reitz# creator 23*42a5009dSJohn Snowowner=hreitz@redhat.com 2434250395SMax Reitz 2534250395SMax Reitzseq="$(basename $0)" 2634250395SMax Reitzecho "QA output created by $seq" 2734250395SMax Reitz 2834250395SMax Reitzstatus=1 # failure is the default! 2934250395SMax Reitz 3034250395SMax Reitz_cleanup() 3134250395SMax Reitz{ 32ecfa1854SJeff Cody _cleanup_qemu 339a9c7c8fSMax Reitz rm -f "$SOCK_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 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', 559a9c7c8fSMax Reitz 'data': { 'path': '$SOCK_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 \ 609a9c7c8fSMax Reitz "nbd+unix:///no_such_export?socket=$SOCK_DIR/nbd" 2>&1 \ 6134250395SMax Reitz | _filter_qemu_io | _filter_nbd 625c4fe018SEric Blake# Likewise, with longest possible name permitted in NBD protocol 635c4fe018SEric Blake$QEMU_IO_PROG -f raw -c quit \ 645c4fe018SEric Blake "nbd+unix:///$(printf %4096d 1 | tr ' ' a)?socket=$SOCK_DIR/nbd" 2>&1 \ 655c4fe018SEric Blake | _filter_qemu_io | _filter_nbd | sed 's/aaaa*aa/aa--aa/' 6634250395SMax Reitz 6734250395SMax Reitz_send_qemu_cmd $QEMU_HANDLE \ 6834250395SMax Reitz "{ 'execute': 'quit' }" \ 6934250395SMax Reitz 'return' 7034250395SMax Reitz 7134250395SMax Reitzwait=1 _cleanup_qemu 7234250395SMax Reitz 7334250395SMax Reitz# success, all done 7434250395SMax Reitzecho '*** done' 7534250395SMax Reitzrm -f $seq.full 7634250395SMax Reitzstatus=0 77