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
33 # Test the extentlist filter.
41 requires qemu-img
--version
42 requires qemu-img map
--help
44 out
=test-extentlist.out
45 input
=test-extentlist.
in
46 expected
=test-extentlist.expected
47 files
="$out $input $expected"
53 nbdkit
-v -D extentlist.lookup
=1 \
56 null size
=$1 extentlist
=$input \
57 --run 'qemu-img map -f raw --output=json $nbd' |
58 jq
-c '.[] | {start:.start, length:.length, data:.data, zero:.zero}' \
60 diff -u $out $expected
67 cat > $expected <<'EOF'
68 {"start":0,"length":0,"data":false,"zero":false}
71 cat > $expected <<'EOF'
72 {"start":0,"length":1048576,"data":false,"zero":true}
76 # Extent list covering 0-1M with data.
81 cat > $expected <<'EOF'
82 {"start":0,"length":0,"data":false,"zero":false}
85 cat > $expected <<'EOF'
86 {"start":0,"length":1048576,"data":true,"zero":false}
90 # Extent list covering 1-2M with data.
95 cat > $expected <<'EOF'
96 {"start":0,"length":0,"data":false,"zero":false}
99 cat > $expected <<'EOF'
100 {"start":0,"length":1048576,"data":false,"zero":true}
103 cat > $expected <<'EOF'
104 {"start":0,"length":1048576,"data":false,"zero":true}
105 {"start":1048576,"length":1048576,"data":true,"zero":false}
108 cat > $expected <<'EOF'
109 {"start":0,"length":1048576,"data":false,"zero":true}
110 {"start":1048576,"length":1048576,"data":true,"zero":false}
111 {"start":2097152,"length":1048576,"data":false,"zero":true}
115 # Extent list covering 1-2M with data, but in a more fragmented
116 # way than the above.
122 cat > $expected <<'EOF'
123 {"start":0,"length":0,"data":false,"zero":false}
126 cat > $expected <<'EOF'
127 {"start":0,"length":1048576,"data":false,"zero":true}
130 cat > $expected <<'EOF'
131 {"start":0,"length":1048576,"data":false,"zero":true}
132 {"start":1048576,"length":1048576,"data":true,"zero":false}
135 cat > $expected <<'EOF'
136 {"start":0,"length":1048576,"data":false,"zero":true}
137 {"start":1048576,"length":1048576,"data":true,"zero":false}
138 {"start":2097152,"length":1048576,"data":false,"zero":true}
142 # Adjacent data and holes.
149 cat > $expected <<'EOF'
150 {"start":0,"length":0,"data":false,"zero":false}
153 cat > $expected <<'EOF'
154 {"start":0,"length":1048576,"data":true,"zero":false}
157 cat > $expected <<'EOF'
158 {"start":0,"length":1048576,"data":true,"zero":false}
159 {"start":1048576,"length":1048576,"data":false,"zero":true}
162 cat > $expected <<'EOF'
163 {"start":0,"length":1048576,"data":true,"zero":false}
164 {"start":1048576,"length":1048576,"data":false,"zero":true}
165 {"start":2097152,"length":1048576,"data":true,"zero":false}
168 cat > $expected <<'EOF'
169 {"start":0,"length":1048576,"data":true,"zero":false}
170 {"start":1048576,"length":1048576,"data":false,"zero":true}
171 {"start":2097152,"length":1048576,"data":true,"zero":false}
172 {"start":3145728,"length":1048576,"data":false,"zero":true}
173 {"start":4194304,"length":1048576,"data":true,"zero":false}
174 {"start":5242880,"length":1048576,"data":false,"zero":true}