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

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