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

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