Update Red Hat Copyright Notices
[nbdkit.git] / tests / test-partitioning5.sh
blob094f4008235f2b33ea58842172f1ca56e9e7b1c3
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 5: Create a filesystem and embed it in an MBR logical
36 # partition. libguestfs uses virtio-scsi so the practical limit here
37 # is about 15 partitions.
39 source ./functions.sh
40 set -e
41 set -x
43 requires guestfish --version
44 requires mke2fs -V
46 sock=$(mktemp -u /tmp/nbdkit-test-sock.XXXXXX)
47 files="partitioning5.pid $sock
48 partitioning5.fs
49 partitioning5.p1 partitioning5.p2 partitioning5.p3 partitioning5.p5 partitioning5.p6 partitioning5.p7 partitioning5.p8 partitioning5.p9 partitioning5.p10 partitioning5.p11 partitioning5.p13"
50 rm -f $files
51 cleanup_fn rm -f $files
53 # Create partitions before and after.
54 $TRUNCATE -s 1 partitioning5.p1
55 $TRUNCATE -s 10M partitioning5.p2
56 $TRUNCATE -s 512 partitioning5.p3
57 # partition 4 = extended partition
58 $TRUNCATE -s 1 partitioning5.p5
59 $TRUNCATE -s 512 partitioning5.p6
60 $TRUNCATE -s 1 partitioning5.p7
61 $TRUNCATE -s 1 partitioning5.p8
62 $TRUNCATE -s 10M partitioning5.p9
63 $TRUNCATE -s 512 partitioning5.p10
64 $TRUNCATE -s 1 partitioning5.p11
65 # partition 12 = naked filesystem
66 $TRUNCATE -s 10M partitioning5.p13
68 # Create the naked filesystem.
69 $TRUNCATE -s 20M partitioning5.fs
70 mke2fs -F -t ext2 partitioning5.fs
72 # Run nbdkit.
73 start_nbdkit -P partitioning5.pid -U $sock \
74 partitioning \
75 partitioning5.p1 partitioning5.p2 \
76 partitioning5.p3 \
77 partitioning5.p5 partitioning5.p6 \
78 partitioning5.p7 partitioning5.p8 \
79 partitioning5.p9 partitioning5.p10 \
80 partitioning5.p11 partitioning5.fs \
81 partitioning5.p13 \
82 partition-type=mbr
84 # Connect with guestfish and read/write stuff to partition 12.
85 guestfish --format=raw -a "nbd://?socket=$sock" <<'EOF'
86 run
87 mount /dev/sda12 /
88 touch /hello
89 fill-pattern "abc" 10000 /pattern
90 ll /
91 umount /dev/sda12
92 sync
93 EOF