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