tests: ocaml: Test NBDKit.version () binding
[nbdkit.git] / tests / test-data-64b.sh
blobfe50a4baefc86c0168590c80efc9e071dea86143
1 #!/usr/bin/env bash
2 # nbdkit
3 # Copyright (C) 2018-2020 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 > 4G (64 bit) nesting.
35 # This was broken before 1.23.5 because 64 bit counts were being
36 # truncated to 32 bit in the allocator layer.
38 source ./functions.sh
39 set -e
40 set -x
42 requires_nbdsh_uri
44 sock=$(mktemp -u /tmp/nbdkit-test-sock.XXXXXX)
45 files="data-64b.pid $sock"
46 rm -f $files
47 cleanup_fn rm -f $files
49 # Run nbdkit.
50 start_nbdkit -P data-64b.pid -U $sock \
51 data '
52 # Construct a named subexpression which is larger than 32 bits
53 # in size and has markers at the beginning and end. This is 8 GB
54 # (sparse).
55 ( 0x55 0xAA @0x200000000 @-2 0x55 0xAA ) -> \1
57 # Construct a sparse disk containing several copies using the "*"
58 # operator. The total disk image will be 8*4 = 32 GB (sparse).
59 \1 * 4
62 nbdsh --connect "nbd+unix://?socket=$sock" \
63 -c '
64 print ("%d" % h.get_size())
65 assert h.get_size() == 0x800000000
67 # Read the markers.
68 for i in range(4):
69 offset = i * 0x200000000
70 buf = h.pread(2, offset)
71 assert buf == b"\x55\xAA"
72 buf = h.pread(2, offset + 0x200000000 - 2)
73 assert buf == b"\x55\xAA"