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
42 requires nbdcopy
--version
44 files
="partitioning1.out partitioning1-p1 partitioning1-p2 partitioning1-p3 partitioning1-p4 partitioning1-p5 partitioning1-p6"
46 cleanup_fn
rm -f $files
48 # Create some odd-sized partitions. These exist to test alignment and
50 $TRUNCATE -s 1 partitioning1-p1
51 $TRUNCATE -s 511 partitioning1-p2
52 $TRUNCATE -s 10M partitioning1-p3
53 $TRUNCATE -s 1023 partitioning1-p4
54 $TRUNCATE -s 1 partitioning1-p5
55 $TRUNCATE -s 511 partitioning1-p6
57 # Run nbdkit with partitioning plugin and partition filter.
58 nbdkit
-f -v -D partitioning.regions
=1 -U - \
61 mbr-id
=0x83 alignment
=512 \
63 mbr-id
=0x82 alignment
=$
((2048 * 512)) \
71 --run 'nbdcopy "$uri" partitioning1.out'
73 # Contents of partitioning1.out should be identical to file-data.
74 cmp file-data partitioning1.out
76 # Same test with > 4 MBR partitions.
77 # Note we select partition 6 because partition 4 is the extended partition.
78 nbdkit
-f -v -D partitioning.regions
=1 -U - \
90 --run 'nbdcopy "$uri" partitioning1.out'
92 cmp file-data partitioning1.out
95 nbdkit
-f -v -D partitioning.regions
=1 -U - \
102 type-guid
=A2A0D0EB-E5B9-3344-87C0-68B6B72699C7 \
104 type-guid
=AF3DC60F-8384-7247-8E79-3D69D8477DE4 \
109 --run 'nbdcopy "$uri" partitioning1.out'
111 cmp file-data partitioning1.out