1 From 8ab27474806687a2af7efb008b80b33615e6eb1d Mon Sep 17 00:00:00 2001
2 From: "Brian C. Lane" <bcl@redhat.com>
3 Date: Wed, 4 Feb 2015 16:31:00 -0800
4 Subject: [PATCH 09/11] tests: Add a test for device-mapper partition sizes
6 device-mapper uses 512b sector units, not device specific sector sizes.
7 This test ensures that the correct partition size is created, no matter
8 what the device's sector size is.
10 tests/Makefile.am | 1 +
11 tests/t6006-dm-512b-sectors.sh | 68 ++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 69 insertions(+)
13 create mode 100644 tests/t6006-dm-512b-sectors.sh
15 diff --git a/tests/Makefile.am b/tests/Makefile.am
16 index b726366..ce8391d 100644
17 --- a/tests/Makefile.am
18 +++ b/tests/Makefile.am
19 @@ -69,6 +69,7 @@ TESTS = \
21 t6004-dm-many-partitions.sh \
23 + t6006-dm-512b-sectors.sh \
24 t6100-mdraid-partitions.sh \
27 diff --git a/tests/t6006-dm-512b-sectors.sh b/tests/t6006-dm-512b-sectors.sh
29 index 0000000..31abba9
31 +++ b/tests/t6006-dm-512b-sectors.sh
34 +# device-mapper sector sizes are 512b, make sure partitions are the correct
35 +# size when using larger sector sizes and a linear dm table.
37 +# Copyright (C) 2015 Free Software Foundation, Inc.
39 +# This program is free software; you can redistribute it and/or modify
40 +# it under the terms of the GNU General Public License as published by
41 +# the Free Software Foundation; either version 3 of the License, or
42 +# (at your option) any later version.
44 +# This program is distributed in the hope that it will be useful,
45 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
46 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47 +# GNU General Public License for more details.
49 +# You should have received a copy of the GNU General Public License
50 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
52 +. "${srcdir=.}/init.sh"; path_prepend_ ../parted
55 +require_scsi_debug_module_
57 +grep '^#define USE_BLKID 1' "$CONFIG_HEADER" > /dev/null ||
58 + skip_ 'this system lacks a new-enough libblkid'
60 +(dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed"
62 +# Device maps names - should be random to not conflict with existing ones on
64 +linear_=plinear-$$test
69 + while [ $i -lt 10 ] ; do
70 + [ -e "/dev/mapper/${linear_}1" ] && dmsetup remove ${linear_}1
72 + [ -e "/dev/mapper/$linear_" ] && dmsetup remove $linear_
74 + [ -e "/dev/mapper/${linear_}1" -o -e "/dev/mapper/$linear_" ] || i=10
80 +# Create a 500M device
82 +scsi_debug_setup_ sector_size=$ss dev_size_mb=500 > dev-name ||
83 + skip_ 'failed to create scsi_debug device'
84 +scsi_dev=$(cat dev-name)
86 +# Size of device, in 512b units
87 +scsi_dev_size=$(blockdev --getsz $scsi_dev) || framework_failure
89 +dmsetup create $linear_ --table "0 $scsi_dev_size linear $scsi_dev 0" || framework_failure
90 +dev="/dev/mapper/$linear_"
92 +# Create msdos partition table with a partition from 1MiB to 100MiB
93 +parted -s $dev mklabel msdos mkpart primary ext2 1MiB 101MiB > out 2>&1 || fail=1
94 +compare /dev/null out || fail=1
96 +# The size of the partition should be 100MiB, or 204800 512b sectors
97 +p1_size=$(blockdev --getsz ${dev}1) || framework_failure
98 +[ $p1_size == 204800 ] || fail=1