3 # Copyright (C) 2018-2019 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
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
37 requires sfdisk
--help
38 requires
test -r /dev
/urandom
39 requires qemu-img
--version
53 truncate
-s 1G
$d/disk
54 sfdisk
-X $label $d/disk
56 # Run nbdkit on each partition, copying data in and out.
57 for ((part
=1; part
<= $nrparts; ++part
)); do
58 # The smallest partition in any test is 1023 sectors. However
59 # to make things quicker only write a sector of random data.
60 dd if=/dev
/urandom of
=$d/rand bs
=512 count
=1
62 if [ "$part" != "$skip_extended" ]; then
64 --filter=partition
file $d/disk partition
=$part \
65 --run "qemu-img convert -n $d/rand \$nbd"
67 --filter=partition
file $d/disk partition
=$part \
68 --run "qemu-img convert \$nbd $d/out"
69 truncate
-s 512 $d/out
75 # Regular MBR with 1-4 primary partitions.
98 # MBR with 3 primary partitions and 2 logical partitions.
99 # Ignore partition 4 which is the extended partition.
100 do_test dos
6 4 <<'EOF'
109 # As above but the extended partition is 1.
110 do_test dos
6 1 <<'EOF'
119 # MBR also allows missing partitions. This disk has only partition 2.
120 # (Partition 1 must be ignored since it is missing.)
121 do_test dos
2 1 <<'EOF'
122 disk2: start=1024 size=1023 type=83
125 # Regular GPT with 1-6 partitions.
126 do_test gpt
1 <<'EOF'
130 do_test gpt
2 <<'EOF'
135 do_test gpt
3 <<'EOF'
141 do_test gpt
4 <<'EOF'
148 do_test gpt
5 <<'EOF'
156 do_test gpt
6 <<'EOF'