5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # * Neither the name of Red Hat nor the names of its contributors may be
17 # used to endorse or promote products derived from this software without
18 # specific prior written permission.
20 # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
21 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
24 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 requires nbdsh
-c 'print(h.set_full_info)'
42 sock
=$
(mktemp
-u /tmp
/nbdkit-test-sock.XXXXXX
)
43 files
="$sock ext2-exportname.pid ext2-exportname.out ext2-exportname.err"
45 cleanup_fn
rm -f $files
47 # Set up a long-running server responsive to the client's export name
48 start_nbdkit
-P ext2-exportname.pid
-U $sock --filter=ext2 \
49 --filter=exportname
file ext2.img ext2file
=exportname \
50 exportname-list
=explicit exportname
=hidden
52 # Test that when serving by exportname, our description varies according
53 # to the client's request.
54 nbdinfo nbd
+unix
:///manifest
\?socket
=$sock > ext2-exportname.out
55 cat ext2-exportname.out
56 grep manifest ext2-exportname.out
57 grep 'content.*ASCII' ext2-exportname.out
59 nbdinfo nbd
+unix
:///disks
/disk.img
\?socket
=$sock > ext2-exportname.out
60 cat ext2-exportname.out
61 grep disk.img ext2-exportname.out
62 grep 'content.*MBR' ext2-exportname.out
64 # nbdinfo 1.6.2 accidentally reported an error but had status 0
66 nbdinfo nbd
+unix
://?socket
=$sock > ext2-exportname.out \
67 2> ext2-exportname.err || st
=$?
68 cat ext2-exportname.out ext2-exportname.err
69 if test $?
= 0 && ! grep "server replied with error" ext2-exportname.err
; then
70 echo "unexpected success"
74 # Test that there is no export list advertised
75 nbdinfo
--list --json nbd
+unix
://?socket
=$sock > ext2-exportname.out
76 cat ext2-exportname.out
77 grep '"exports": \[]' ext2-exportname.out