Blame SOURCES/0009-tests-Add-a-test-for-device-mapper-partition-sizes.patch

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