tests: Skip test if file extents are not support
[nbdkit.git] / tests / test-pattern-largest-for-qemu.sh
blobdd3e6ad1e7debf51ebf32cc3a5728864635b5e53
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 pattern plugin with the largest possible size supported
34 # by qemu and nbdkit.
36 source ./functions.sh
37 set -e
38 set -x
40 requires qemu-io --version
42 sock=$(mktemp -u /tmp/nbdkit-test-sock.XXXXXX)
43 files="pattern-largest-for-qemu.out pattern-largest-for-qemu.pid $sock"
44 rm -f $files
45 cleanup_fn rm -f $files
47 # Run nbdkit with pattern plugin.
48 start_nbdkit -P pattern-largest-for-qemu.pid -U $sock pattern $largest_qemu_disk
50 # Ideally we would read the last sector only. However qemu-io has a
51 # bug where offsets are calculated using floating point numbers and
52 # silently truncated to 53 bits of precision. Reading the last 1024
53 # bytes happens to give the correct result here.
54 # https://www.mail-archive.com/qemu-devel@nongnu.org/msg770572.html
55 qemu-io -r -f raw "nbd+unix://?socket=$sock" \
56 -c 'r -v 9223372035781032960 1024' | grep -E '^[[:xdigit:]]+:' > pattern-largest-for-qemu.out
57 if [ "$(cat pattern-largest-for-qemu.out)" != "7fffffffbffffc00: 7f ff ff ff bf ff fc 00 7f ff ff ff bf ff fc 08 ................
58 7fffffffbffffc10: 7f ff ff ff bf ff fc 10 7f ff ff ff bf ff fc 18 ................
59 7fffffffbffffc20: 7f ff ff ff bf ff fc 20 7f ff ff ff bf ff fc 28 ................
60 7fffffffbffffc30: 7f ff ff ff bf ff fc 30 7f ff ff ff bf ff fc 38 .......0.......8
61 7fffffffbffffc40: 7f ff ff ff bf ff fc 40 7f ff ff ff bf ff fc 48 ...............H
62 7fffffffbffffc50: 7f ff ff ff bf ff fc 50 7f ff ff ff bf ff fc 58 .......P.......X
63 7fffffffbffffc60: 7f ff ff ff bf ff fc 60 7f ff ff ff bf ff fc 68 ...............h
64 7fffffffbffffc70: 7f ff ff ff bf ff fc 70 7f ff ff ff bf ff fc 78 .......p.......x
65 7fffffffbffffc80: 7f ff ff ff bf ff fc 80 7f ff ff ff bf ff fc 88 ................
66 7fffffffbffffc90: 7f ff ff ff bf ff fc 90 7f ff ff ff bf ff fc 98 ................
67 7fffffffbffffca0: 7f ff ff ff bf ff fc a0 7f ff ff ff bf ff fc a8 ................
68 7fffffffbffffcb0: 7f ff ff ff bf ff fc b0 7f ff ff ff bf ff fc b8 ................
69 7fffffffbffffcc0: 7f ff ff ff bf ff fc c0 7f ff ff ff bf ff fc c8 ................
70 7fffffffbffffcd0: 7f ff ff ff bf ff fc d0 7f ff ff ff bf ff fc d8 ................
71 7fffffffbffffce0: 7f ff ff ff bf ff fc e0 7f ff ff ff bf ff fc e8 ................
72 7fffffffbffffcf0: 7f ff ff ff bf ff fc f0 7f ff ff ff bf ff fc f8 ................
73 7fffffffbffffd00: 7f ff ff ff bf ff fd 00 7f ff ff ff bf ff fd 08 ................
74 7fffffffbffffd10: 7f ff ff ff bf ff fd 10 7f ff ff ff bf ff fd 18 ................
75 7fffffffbffffd20: 7f ff ff ff bf ff fd 20 7f ff ff ff bf ff fd 28 ................
76 7fffffffbffffd30: 7f ff ff ff bf ff fd 30 7f ff ff ff bf ff fd 38 .......0.......8
77 7fffffffbffffd40: 7f ff ff ff bf ff fd 40 7f ff ff ff bf ff fd 48 ...............H
78 7fffffffbffffd50: 7f ff ff ff bf ff fd 50 7f ff ff ff bf ff fd 58 .......P.......X
79 7fffffffbffffd60: 7f ff ff ff bf ff fd 60 7f ff ff ff bf ff fd 68 ...............h
80 7fffffffbffffd70: 7f ff ff ff bf ff fd 70 7f ff ff ff bf ff fd 78 .......p.......x
81 7fffffffbffffd80: 7f ff ff ff bf ff fd 80 7f ff ff ff bf ff fd 88 ................
82 7fffffffbffffd90: 7f ff ff ff bf ff fd 90 7f ff ff ff bf ff fd 98 ................
83 7fffffffbffffda0: 7f ff ff ff bf ff fd a0 7f ff ff ff bf ff fd a8 ................
84 7fffffffbffffdb0: 7f ff ff ff bf ff fd b0 7f ff ff ff bf ff fd b8 ................
85 7fffffffbffffdc0: 7f ff ff ff bf ff fd c0 7f ff ff ff bf ff fd c8 ................
86 7fffffffbffffdd0: 7f ff ff ff bf ff fd d0 7f ff ff ff bf ff fd d8 ................
87 7fffffffbffffde0: 7f ff ff ff bf ff fd e0 7f ff ff ff bf ff fd e8 ................
88 7fffffffbffffdf0: 7f ff ff ff bf ff fd f0 7f ff ff ff bf ff fd f8 ................
89 7fffffffbffffe00: 7f ff ff ff bf ff fe 00 7f ff ff ff bf ff fe 08 ................
90 7fffffffbffffe10: 7f ff ff ff bf ff fe 10 7f ff ff ff bf ff fe 18 ................
91 7fffffffbffffe20: 7f ff ff ff bf ff fe 20 7f ff ff ff bf ff fe 28 ................
92 7fffffffbffffe30: 7f ff ff ff bf ff fe 30 7f ff ff ff bf ff fe 38 .......0.......8
93 7fffffffbffffe40: 7f ff ff ff bf ff fe 40 7f ff ff ff bf ff fe 48 ...............H
94 7fffffffbffffe50: 7f ff ff ff bf ff fe 50 7f ff ff ff bf ff fe 58 .......P.......X
95 7fffffffbffffe60: 7f ff ff ff bf ff fe 60 7f ff ff ff bf ff fe 68 ...............h
96 7fffffffbffffe70: 7f ff ff ff bf ff fe 70 7f ff ff ff bf ff fe 78 .......p.......x
97 7fffffffbffffe80: 7f ff ff ff bf ff fe 80 7f ff ff ff bf ff fe 88 ................
98 7fffffffbffffe90: 7f ff ff ff bf ff fe 90 7f ff ff ff bf ff fe 98 ................
99 7fffffffbffffea0: 7f ff ff ff bf ff fe a0 7f ff ff ff bf ff fe a8 ................
100 7fffffffbffffeb0: 7f ff ff ff bf ff fe b0 7f ff ff ff bf ff fe b8 ................
101 7fffffffbffffec0: 7f ff ff ff bf ff fe c0 7f ff ff ff bf ff fe c8 ................
102 7fffffffbffffed0: 7f ff ff ff bf ff fe d0 7f ff ff ff bf ff fe d8 ................
103 7fffffffbffffee0: 7f ff ff ff bf ff fe e0 7f ff ff ff bf ff fe e8 ................
104 7fffffffbffffef0: 7f ff ff ff bf ff fe f0 7f ff ff ff bf ff fe f8 ................
105 7fffffffbfffff00: 7f ff ff ff bf ff ff 00 7f ff ff ff bf ff ff 08 ................
106 7fffffffbfffff10: 7f ff ff ff bf ff ff 10 7f ff ff ff bf ff ff 18 ................
107 7fffffffbfffff20: 7f ff ff ff bf ff ff 20 7f ff ff ff bf ff ff 28 ................
108 7fffffffbfffff30: 7f ff ff ff bf ff ff 30 7f ff ff ff bf ff ff 38 .......0.......8
109 7fffffffbfffff40: 7f ff ff ff bf ff ff 40 7f ff ff ff bf ff ff 48 ...............H
110 7fffffffbfffff50: 7f ff ff ff bf ff ff 50 7f ff ff ff bf ff ff 58 .......P.......X
111 7fffffffbfffff60: 7f ff ff ff bf ff ff 60 7f ff ff ff bf ff ff 68 ...............h
112 7fffffffbfffff70: 7f ff ff ff bf ff ff 70 7f ff ff ff bf ff ff 78 .......p.......x
113 7fffffffbfffff80: 7f ff ff ff bf ff ff 80 7f ff ff ff bf ff ff 88 ................
114 7fffffffbfffff90: 7f ff ff ff bf ff ff 90 7f ff ff ff bf ff ff 98 ................
115 7fffffffbfffffa0: 7f ff ff ff bf ff ff a0 7f ff ff ff bf ff ff a8 ................
116 7fffffffbfffffb0: 7f ff ff ff bf ff ff b0 7f ff ff ff bf ff ff b8 ................
117 7fffffffbfffffc0: 7f ff ff ff bf ff ff c0 7f ff ff ff bf ff ff c8 ................
118 7fffffffbfffffd0: 7f ff ff ff bf ff ff d0 7f ff ff ff bf ff ff d8 ................
119 7fffffffbfffffe0: 7f ff ff ff bf ff ff e0 7f ff ff ff bf ff ff e8 ................
120 7fffffffbffffff0: 7f ff ff ff bf ff ff f0 7f ff ff ff bf ff ff f8 ................" ]
121 then
122 echo "$0: unexpected pattern:"
123 cat pattern-largest-for-qemu.out
124 exit 1