Blame SOURCES/parted-3.1-test-creating-20-device-mapper-partitions.patch

fc4a62
From 166491bd870df6877e04831c9da593e2f8e77ca8 Mon Sep 17 00:00:00 2001
fc4a62
From: "Brian C. Lane" <bcl@redhat.com>
fc4a62
Date: Thu, 19 Apr 2012 17:11:09 -0700
fc4a62
Subject: [PATCH] tests: test creating 20 device-mapper partitions (#803108)
fc4a62
fc4a62
* tests/t6002-dm-many-partitions.sh: Make sure > 17 partitions appear in
fc4a62
  device mapper.
fc4a62
---
fc4a62
 tests/Makefile.am                 |    1 +
fc4a62
 tests/t6002-dm-many-partitions.sh |   60 +++++++++++++++++++++++++++++++++++++
fc4a62
 2 files changed, 61 insertions(+), 0 deletions(-)
fc4a62
 create mode 100755 tests/t6002-dm-many-partitions.sh
fc4a62
fc4a62
diff --git a/tests/Makefile.am b/tests/Makefile.am
fc4a62
index 1b37fd9..57771be 100644
fc4a62
--- a/tests/Makefile.am
fc4a62
+++ b/tests/Makefile.am
fc4a62
@@ -55,6 +55,7 @@ TESTS = \
fc4a62
   t5000-tags.sh \
fc4a62
   t6000-dm.sh \
fc4a62
   t6001-psep.sh \
fc4a62
+  t6002-dm-many-partitions.sh \
fc4a62
   t6100-mdraid-partitions.sh \
fc4a62
   t7000-scripting.sh \
fc4a62
   t8000-loop.sh \
fc4a62
diff --git a/tests/t6002-dm-many-partitions.sh b/tests/t6002-dm-many-partitions.sh
fc4a62
new file mode 100755
fc4a62
index 0000000..4d08e72
fc4a62
--- /dev/null
fc4a62
+++ b/tests/t6002-dm-many-partitions.sh
fc4a62
@@ -0,0 +1,60 @@
fc4a62
+#!/bin/sh
fc4a62
+# device-mapper: create many partitions
fc4a62
+# This would not create partitions > 16 when using device-mapper
fc4a62
+
fc4a62
+# Copyright (C) 2012 Free Software Foundation, Inc.
fc4a62
+
fc4a62
+# This program is free software; you can redistribute it and/or modify
fc4a62
+# it under the terms of the GNU General Public License as published by
fc4a62
+# the Free Software Foundation; either version 3 of the License, or
fc4a62
+# (at your option) any later version.
fc4a62
+
fc4a62
+# This program is distributed in the hope that it will be useful,
fc4a62
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
fc4a62
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
fc4a62
+# GNU General Public License for more details.
fc4a62
+
fc4a62
+# You should have received a copy of the GNU General Public License
fc4a62
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
fc4a62
+
fc4a62
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
fc4a62
+
fc4a62
+require_root_
fc4a62
+(dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed"
fc4a62
+
fc4a62
+ss=$sector_size_
fc4a62
+ns=300
fc4a62
+n_partitions=20
fc4a62
+start_sector=34
fc4a62
+loop_file=loop-file-$$
fc4a62
+dm_name=dm-test-$$
fc4a62
+
fc4a62
+cleanup_() {
fc4a62
+    dmsetup remove $dm_name
fc4a62
+    test -n "$dev" && losetup -d "$dev"
fc4a62
+    rm -f $loop_file;
fc4a62
+}
fc4a62
+
fc4a62
+# create a file large enough to hold a GPT partition table
fc4a62
+dd if=/dev/null of=$loop_file bs=$ss seek=$ns || framework_failure
fc4a62
+dev=$(losetup --show -f $loop_file) || framework_failure
fc4a62
+dmsetup create $dm_name --table "0 $ns linear $dev 0" || framework_failure
fc4a62
+
fc4a62
+cmd=
fc4a62
+for ((i=1; i<=$n_partitions; i+=1)); do
fc4a62
+  s=$((start_sector + i - 1))
fc4a62
+  cmd="$cmd mkpart p$i ${s}s ${s}s"
fc4a62
+done
fc4a62
+parted -m -a min -s /dev/mapper/$dm_name mklabel gpt $cmd > /dev/null 2>&1 || fail=1
fc4a62
+
fc4a62
+# Make sure all the partitions appeared under /dev/mapper/
fc4a62
+for ((i=1; i<=$n_partitions; i+=1)); do
fc4a62
+    if [ ! -e "/dev/mapper/${dm_name}p$i" ]; then
fc4a62
+        fail=1
fc4a62
+        break
fc4a62
+    fi
fc4a62
+    # remove the partitions as we go, otherwise cleanup won't work.
fc4a62
+    dmsetup remove /dev/mapper/${dm_name}p$i
fc4a62
+done
fc4a62
+
fc4a62
+Exit $fail
fc4a62
-- 
fc4a62
1.7.7.6
fc4a62