tests: Add tests that just including the header works.
[nbdkit/ericb.git] / tests / test-partitioning5.sh
blobe868cbe651dc0a8e26ef370519657bf184e9ab20
1 #!/usr/bin/env bash
2 # nbdkit
3 # Copyright (C) 2018-2019 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
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 mke2fs -V
45 files="partitioning5.pid partitioning5.sock
46 partitioning5.fs
47 partitioning5.p1 partitioning5.p2 partitioning5.p3 partitioning5.p5 partitioning5.p6 partitioning5.p7 partitioning5.p8 partitioning5.p9 partitioning5.p10 partitioning5.p11 partitioning5.p13"
48 rm -f $files
49 cleanup_fn rm -f $files
51 # Create partitions before and after.
52 truncate -s 1 partitioning5.p1
53 truncate -s 10M partitioning5.p2
54 truncate -s 512 partitioning5.p3
55 # partition 4 = extended partition
56 truncate -s 1 partitioning5.p5
57 truncate -s 512 partitioning5.p6
58 truncate -s 1 partitioning5.p7
59 truncate -s 1 partitioning5.p8
60 truncate -s 10M partitioning5.p9
61 truncate -s 512 partitioning5.p10
62 truncate -s 1 partitioning5.p11
63 # partition 12 = naked filesystem
64 truncate -s 10M partitioning5.p13
66 # Create the naked filesystem.
67 truncate -s 20M partitioning5.fs
68 mke2fs -F -t ext2 partitioning5.fs
70 # Run nbdkit.
71 start_nbdkit -P partitioning5.pid -U partitioning5.sock \
72 partitioning \
73 partitioning5.p1 partitioning5.p2 \
74 partitioning5.p3 \
75 partitioning5.p5 partitioning5.p6 \
76 partitioning5.p7 partitioning5.p8 \
77 partitioning5.p9 partitioning5.p10 \
78 partitioning5.p11 partitioning5.fs \
79 partitioning5.p13 \
80 partition-type=mbr
82 # Connect with guestfish and read/write stuff to partition 12.
83 guestfish --format=raw -a "nbd://?socket=$PWD/partitioning5.sock" <<'EOF'
84 run
85 mount /dev/sda12 /
86 touch /hello
87 fill-pattern "abc" 10000 /pattern
88 ll /
89 umount /dev/sda12
90 sync
91 EOF