Update Red Hat Copyright Notices
[nbdkit.git] / tests / test-partitioning1.sh
blob0ece7e13c297eb910376c11cf5170d0b1b7fc213
1 #!/usr/bin/env bash
2 # nbdkit
3 # Copyright Red Hat
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
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
31 # SUCH DAMAGE.
33 # Test the partitioning plugin.
35 # Test 1: check that partitioning + partition filter = identity
37 source ./functions.sh
38 set -e
39 set -x
41 requires_run
42 requires_nbdcopy
44 files="partitioning1.out partitioning1-p1 partitioning1-p2 partitioning1-p3 partitioning1-p4 partitioning1-p5 partitioning1-p6"
45 rm -f $files
46 cleanup_fn rm -f $files
48 # Create some odd-sized partitions. These exist to test alignment and
49 # padding.
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 - \
59 --filter=partition \
60 partitioning \
61 mbr-id=0x83 alignment=512 \
62 partitioning1-p1 \
63 mbr-id=0x82 alignment=$((2048 * 512)) \
64 partitioning1-p2 \
65 mbr-id=default \
66 file-data \
67 mbr-id=0x82 \
68 partitioning1-p3 \
69 partition-type=mbr \
70 partition=3 \
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 - \
79 --filter=partition \
80 partitioning \
81 partitioning1-p1 \
82 partitioning1-p2 \
83 partitioning1-p3 \
84 partitioning1-p4 \
85 file-data \
86 partitioning1-p5 \
87 partitioning1-p6 \
88 partition-type=mbr \
89 partition=6 \
90 --run 'nbdcopy "$uri" partitioning1.out'
92 cmp file-data partitioning1.out
94 # Same test with GPT.
95 nbdkit -f -v -D partitioning.regions=1 -U - \
96 --filter=partition \
97 partitioning \
98 partitioning1-p1 \
99 partitioning1-p2 \
100 partitioning1-p3 \
101 partitioning1-p4 \
102 type-guid=A2A0D0EB-E5B9-3344-87C0-68B6B72699C7 \
103 file-data \
104 type-guid=AF3DC60F-8384-7247-8E79-3D69D8477DE4 \
105 partitioning1-p5 \
106 partitioning1-p6 \
107 partition-type=gpt \
108 partition=5 \
109 --run 'nbdcopy "$uri" partitioning1.out'
111 cmp file-data partitioning1.out