tests: Place sockets in /tmp.
[nbdkit/ericb.git] / tests / test-data-base64.sh
blobdbae7cfc2c7178cdd1ad730c39ef17e41f60631d
1 #!/usr/bin/env bash
2 # nbdkit
3 # Copyright (C) 2018 Red Hat Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
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
31 # SUCH DAMAGE.
33 # Test the data plugin with base64= parameter.
35 source ./functions.sh
36 set -e
37 set -x
39 requires qemu-io --version
41 # Test if the base64 parameter is supported in this build.
42 if ! nbdkit data --dump-plugin | grep -sq "data_base64=yes"; then
43 echo "$0: base64 parameter is not supported in this build"
44 exit 77
47 sock=`mktemp -u`
48 files="data-base64.out data-base64.pid $sock"
49 rm -f $files
50 cleanup_fn rm -f $files
52 # Run nbdkit.
53 start_nbdkit -P data-base64.pid -U $sock \
54 data base64=MTIz size=512
56 qemu-io -r -f raw "nbd+unix://?socket=$sock" \
57 -c 'r -v 0 512' | grep -E '^[[:xdigit:]]+:' > data-base64.out
58 if [ "$(cat data-base64.out)" != "00000000: 31 32 33 00 00 00 00 00 00 00 00 00 00 00 00 00 123.............
59 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
60 00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
61 00000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
62 00000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
63 00000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
64 00000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
65 00000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
66 00000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
67 00000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
68 000000a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
69 000000b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
70 000000c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
71 000000d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
72 000000e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
73 000000f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
74 00000100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
75 00000110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
76 00000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
77 00000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
78 00000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
79 00000150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
80 00000160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
81 00000170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
82 00000180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
83 00000190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
84 000001a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
85 000001b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
86 000001c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
87 000001d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
88 000001e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
89 000001f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................" ]
90 then
91 echo "$0: unexpected pattern:"
92 cat data-base64.out
93 exit 1