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

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