|
|
9e7f5d |
From 1c5b0b263f08faa0649bf673a685d93ed9319bef Mon Sep 17 00:00:00 2001
|
|
|
9e7f5d |
From: "Brian C. Lane" <bcl@redhat.com>
|
|
|
9e7f5d |
Date: Wed, 4 Feb 2015 16:31:00 -0800
|
|
|
9e7f5d |
Subject: [PATCH 31/32] tests: Add a test for device-mapper partition sizes
|
|
|
9e7f5d |
(#1188431)
|
|
|
9e7f5d |
|
|
|
9e7f5d |
device-mapper uses 512b sector units, not device specific sector sizes.
|
|
|
9e7f5d |
This test ensures that the correct partition size is created, no matter
|
|
|
9e7f5d |
what the device's sector size is.
|
|
|
9e7f5d |
|
|
|
9e7f5d |
Related: rhbz#1188431
|
|
|
9e7f5d |
---
|
|
|
9e7f5d |
tests/Makefile.am | 1 +
|
|
|
9e7f5d |
tests/t6004-dm-512b-sectors.sh | 68 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
9e7f5d |
2 files changed, 69 insertions(+)
|
|
|
9e7f5d |
create mode 100644 tests/t6004-dm-512b-sectors.sh
|
|
|
9e7f5d |
|
|
|
9e7f5d |
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
|
|
9e7f5d |
index faa0f37..1cf859c 100644
|
|
|
9e7f5d |
--- a/tests/Makefile.am
|
|
|
9e7f5d |
+++ b/tests/Makefile.am
|
|
|
9e7f5d |
@@ -57,6 +57,7 @@ TESTS = \
|
|
|
9e7f5d |
t6001-psep.sh \
|
|
|
9e7f5d |
t6002-dm-many-partitions.sh \
|
|
|
9e7f5d |
t6003-dm-uuid.sh \
|
|
|
9e7f5d |
+ t6004-dm-512b-sectors.sh \
|
|
|
9e7f5d |
t6100-mdraid-partitions.sh \
|
|
|
9e7f5d |
t7000-scripting.sh \
|
|
|
9e7f5d |
t8000-loop.sh \
|
|
|
9e7f5d |
diff --git a/tests/t6004-dm-512b-sectors.sh b/tests/t6004-dm-512b-sectors.sh
|
|
|
9e7f5d |
new file mode 100644
|
|
|
9e7f5d |
index 0000000..31abba9
|
|
|
9e7f5d |
--- /dev/null
|
|
|
9e7f5d |
+++ b/tests/t6004-dm-512b-sectors.sh
|
|
|
9e7f5d |
@@ -0,0 +1,68 @@
|
|
|
9e7f5d |
+#!/bin/sh
|
|
|
9e7f5d |
+# device-mapper sector sizes are 512b, make sure partitions are the correct
|
|
|
9e7f5d |
+# size when using larger sector sizes and a linear dm table.
|
|
|
9e7f5d |
+
|
|
|
9e7f5d |
+# Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
9e7f5d |
+
|
|
|
9e7f5d |
+# This program is free software; you can redistribute it and/or modify
|
|
|
9e7f5d |
+# it under the terms of the GNU General Public License as published by
|
|
|
9e7f5d |
+# the Free Software Foundation; either version 3 of the License, or
|
|
|
9e7f5d |
+# (at your option) any later version.
|
|
|
9e7f5d |
+
|
|
|
9e7f5d |
+# This program is distributed in the hope that it will be useful,
|
|
|
9e7f5d |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
9e7f5d |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
9e7f5d |
+# GNU General Public License for more details.
|
|
|
9e7f5d |
+
|
|
|
9e7f5d |
+# You should have received a copy of the GNU General Public License
|
|
|
9e7f5d |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
9e7f5d |
+
|
|
|
9e7f5d |
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
|
|
|
9e7f5d |
+
|
|
|
9e7f5d |
+require_root_
|
|
|
9e7f5d |
+require_scsi_debug_module_
|
|
|
9e7f5d |
+
|
|
|
9e7f5d |
+grep '^#define USE_BLKID 1' "$CONFIG_HEADER" > /dev/null ||
|
|
|
9e7f5d |
+ skip_ 'this system lacks a new-enough libblkid'
|
|
|
9e7f5d |
+
|
|
|
9e7f5d |
+(dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed"
|
|
|
9e7f5d |
+
|
|
|
9e7f5d |
+# Device maps names - should be random to not conflict with existing ones on
|
|
|
9e7f5d |
+# the system
|
|
|
9e7f5d |
+linear_=plinear-$$test
|
|
|
9e7f5d |
+
|
|
|
9e7f5d |
+cleanup_fn_() {
|
|
|
9e7f5d |
+ i=0
|
|
|
9e7f5d |
+ udevadm settle
|
|
|
9e7f5d |
+ while [ $i -lt 10 ] ; do
|
|
|
9e7f5d |
+ [ -e "/dev/mapper/${linear_}1" ] && dmsetup remove ${linear_}1
|
|
|
9e7f5d |
+ sleep .2
|
|
|
9e7f5d |
+ [ -e "/dev/mapper/$linear_" ] && dmsetup remove $linear_
|
|
|
9e7f5d |
+ sleep .2
|
|
|
9e7f5d |
+ [ -e "/dev/mapper/${linear_}1" -o -e "/dev/mapper/$linear_" ] || i=10
|
|
|
9e7f5d |
+ i=$((i + 1))
|
|
|
9e7f5d |
+ done
|
|
|
9e7f5d |
+ udevadm settle
|
|
|
9e7f5d |
+}
|
|
|
9e7f5d |
+
|
|
|
9e7f5d |
+# Create a 500M device
|
|
|
9e7f5d |
+ss=$sector_size_
|
|
|
9e7f5d |
+scsi_debug_setup_ sector_size=$ss dev_size_mb=500 > dev-name ||
|
|
|
9e7f5d |
+ skip_ 'failed to create scsi_debug device'
|
|
|
9e7f5d |
+scsi_dev=$(cat dev-name)
|
|
|
9e7f5d |
+
|
|
|
9e7f5d |
+# Size of device, in 512b units
|
|
|
9e7f5d |
+scsi_dev_size=$(blockdev --getsz $scsi_dev) || framework_failure
|
|
|
9e7f5d |
+
|
|
|
9e7f5d |
+dmsetup create $linear_ --table "0 $scsi_dev_size linear $scsi_dev 0" || framework_failure
|
|
|
9e7f5d |
+dev="/dev/mapper/$linear_"
|
|
|
9e7f5d |
+
|
|
|
9e7f5d |
+# Create msdos partition table with a partition from 1MiB to 100MiB
|
|
|
9e7f5d |
+parted -s $dev mklabel msdos mkpart primary ext2 1MiB 101MiB > out 2>&1 || fail=1
|
|
|
9e7f5d |
+compare /dev/null out || fail=1
|
|
|
9e7f5d |
+
|
|
|
9e7f5d |
+# The size of the partition should be 100MiB, or 204800 512b sectors
|
|
|
9e7f5d |
+p1_size=$(blockdev --getsz ${dev}1) || framework_failure
|
|
|
9e7f5d |
+[ $p1_size == 204800 ] || fail=1
|
|
|
9e7f5d |
+
|
|
|
9e7f5d |
+Exit $fail
|
|
|
9e7f5d |
--
|
|
|
9e7f5d |
2.1.0
|
|
|
9e7f5d |
|