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
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 partitioning plugin.
35 # Test 1: check that partitioning + partition filter = identity
41 requires qemu-img
--version
43 files
="partitioning1.out partitioning1-p1 partitioning1-p2 partitioning1-p3 partitioning1-p4 partitioning1-p5 partitioning1-p6"
45 cleanup_fn
rm -f $files
47 # Create some odd-sized partitions. These exist to test alignment and
49 truncate
-s 1 partitioning1-p1
50 truncate
-s 511 partitioning1-p2
51 truncate
-s 10M partitioning1-p3
52 truncate
-s 1023 partitioning1-p4
53 truncate
-s 1 partitioning1-p5
54 truncate
-s 511 partitioning1-p6
56 # Run nbdkit with partitioning plugin and partition filter.
57 nbdkit
-f -v -D partitioning.regions
=1 -U - \
60 mbr-id
=0x83 alignment
=512 \
62 mbr-id
=0x82 alignment
=$
((2048 * 512)) \
70 --run 'qemu-img convert $nbd partitioning1.out'
72 # Contents of partitioning1.out should be identical to file-data.
73 cmp file-data partitioning1.out
75 # Same test with > 4 MBR partitions.
76 # Note we select partition 6 because partition 4 is the extended partition.
77 nbdkit
-f -v -D partitioning.regions
=1 -U - \
89 --run 'qemu-img convert $nbd partitioning1.out'
91 cmp file-data partitioning1.out
94 nbdkit
-f -v -D partitioning.regions
=1 -U - \
101 type-guid
=A2A0D0EB-E5B9-3344-87C0-68B6B72699C7 \
103 type-guid
=AF3DC60F-8384-7247-8E79-3D69D8477DE4 \
108 --run 'qemu-img convert $nbd partitioning1.out'
110 cmp file-data partitioning1.out