Update Red Hat Copyright Notices
[nbdkit.git] / tests / test-truncate2.sh
bloba5c4b744c5b040cc26ab40636a26645c3d37f595
1 #!/usr/bin/env bash
2 # nbdkit
3 # Copyright Red Hat
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 truncate filter using the pattern plugin.
35 source ./functions.sh
36 set -e
37 set -x
39 requires qemu-io --version
41 sock=$(mktemp -u /tmp/nbdkit-test-sock.XXXXXX)
42 files="truncate2.out truncate2.pid $sock"
43 rm -f $files
44 cleanup_fn rm -f $files
46 # Run nbdkit with pattern plugin and truncate filter in front.
47 start_nbdkit -P truncate2.pid -U $sock \
48 --filter=truncate \
49 pattern 503 \
50 round-up=512
52 qemu-io -r -f raw "nbd+unix://?socket=$sock" \
53 -c 'r -v 0 512' | grep -E '^[[:xdigit:]]+:' > truncate2.out
54 if [ "$(cat truncate2.out)" != "00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 ................
55 00000010: 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 18 ................
56 00000020: 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 28 ................
57 00000030: 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 38 .......0.......8
58 00000040: 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 48 ...............H
59 00000050: 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 58 .......P.......X
60 00000060: 00 00 00 00 00 00 00 60 00 00 00 00 00 00 00 68 ...............h
61 00000070: 00 00 00 00 00 00 00 70 00 00 00 00 00 00 00 78 .......p.......x
62 00000080: 00 00 00 00 00 00 00 80 00 00 00 00 00 00 00 88 ................
63 00000090: 00 00 00 00 00 00 00 90 00 00 00 00 00 00 00 98 ................
64 000000a0: 00 00 00 00 00 00 00 a0 00 00 00 00 00 00 00 a8 ................
65 000000b0: 00 00 00 00 00 00 00 b0 00 00 00 00 00 00 00 b8 ................
66 000000c0: 00 00 00 00 00 00 00 c0 00 00 00 00 00 00 00 c8 ................
67 000000d0: 00 00 00 00 00 00 00 d0 00 00 00 00 00 00 00 d8 ................
68 000000e0: 00 00 00 00 00 00 00 e0 00 00 00 00 00 00 00 e8 ................
69 000000f0: 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 f8 ................
70 00000100: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 08 ................
71 00000110: 00 00 00 00 00 00 01 10 00 00 00 00 00 00 01 18 ................
72 00000120: 00 00 00 00 00 00 01 20 00 00 00 00 00 00 01 28 ................
73 00000130: 00 00 00 00 00 00 01 30 00 00 00 00 00 00 01 38 .......0.......8
74 00000140: 00 00 00 00 00 00 01 40 00 00 00 00 00 00 01 48 ...............H
75 00000150: 00 00 00 00 00 00 01 50 00 00 00 00 00 00 01 58 .......P.......X
76 00000160: 00 00 00 00 00 00 01 60 00 00 00 00 00 00 01 68 ...............h
77 00000170: 00 00 00 00 00 00 01 70 00 00 00 00 00 00 01 78 .......p.......x
78 00000180: 00 00 00 00 00 00 01 80 00 00 00 00 00 00 01 88 ................
79 00000190: 00 00 00 00 00 00 01 90 00 00 00 00 00 00 01 98 ................
80 000001a0: 00 00 00 00 00 00 01 a0 00 00 00 00 00 00 01 a8 ................
81 000001b0: 00 00 00 00 00 00 01 b0 00 00 00 00 00 00 01 b8 ................
82 000001c0: 00 00 00 00 00 00 01 c0 00 00 00 00 00 00 01 c8 ................
83 000001d0: 00 00 00 00 00 00 01 d0 00 00 00 00 00 00 01 d8 ................
84 000001e0: 00 00 00 00 00 00 01 e0 00 00 00 00 00 00 01 e8 ................
85 000001f0: 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 ................" ]
86 then
87 echo "$0: unexpected pattern:"
88 cat truncate2.out
89 exit 1