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
38 requires sfdisk
--help
39 requires
test -r /dev
/urandom
42 # RHEL 7 sfdisk didn't have the -X option, so skip the tests here.
43 if LANG
=C sfdisk
-X |
& grep -sq "invalid option"; then
44 echo "$0: skipping test because no sfdisk -X option"
60 truncate
-s 1G
$d/disk
61 sfdisk
-X $label $d/disk
63 # The smallest partition in any test is 1023 sectors. However
64 # to make things quicker only write a sector of random data.
65 dd if=/dev
/urandom of
=$d/rand bs
=512 count
=1
67 # Run nbdkit on each partition, copying data in and out.
68 for ((part
=1; part
<= $nrparts; ++part
)); do
69 if [ "$part" != "$ignored" ]; then
71 --filter=partition
file $d/disk partition
=$part \
72 --run "nbdcopy -C 1 $d/rand \$uri && nbdcopy -C 1 \$uri $d/out"
73 truncate
-s 512 $d/out
79 # Regular MBR with 1-4 primary partitions.
102 # MBR with 3 primary partitions and 2 logical partitions.
103 # Ignore partition 4 which is the extended partition.
104 do_test dos
6 4 <<'EOF'
113 # As above but the extended partition is 1.
114 do_test dos
6 1 <<'EOF'
123 # MBR also allows missing partitions. This disk has only partition 2.
124 # (Partition 1 must be ignored since it is missing.)
125 do_test dos
2 1 <<'EOF'
126 disk2: start=1024 size=1023 type=83
129 # Regular GPT with 1-6 partitions.
130 do_test gpt
1 <<'EOF'
134 do_test gpt
2 <<'EOF'
139 do_test gpt
3 <<'EOF'
145 do_test gpt
4 <<'EOF'
152 do_test gpt
5 <<'EOF'
160 do_test gpt
6 <<'EOF'