Blame SOURCES/parted-3.1-tests-Make-sure-dm-UUIDs-are-not-erased.patch

fc4a62
From cc96f793bb4fb088123a40fb9d802e7db1fdbffb Mon Sep 17 00:00:00 2001
fc4a62
From: Brian C. Lane <bcl@redhat.com>
fc4a62
Date: Tue, 7 Aug 2012 10:14:03 -0700
fc4a62
Subject: [PATCH] tests: Make sure dm UUIDs are not erased
fc4a62
fc4a62
* tests/t6003-dm-uuid.sh: Make sure dm UUIDs are not erased
fc4a62
---
fc4a62
 tests/Makefile.am      |    1 +
fc4a62
 tests/t6003-dm-uuid.sh |   59 ++++++++++++++++++++++++++++++++++++++++++++++++
fc4a62
 2 files changed, 60 insertions(+), 0 deletions(-)
fc4a62
 create mode 100755 tests/t6003-dm-uuid.sh
fc4a62
fc4a62
diff --git a/tests/Makefile.am b/tests/Makefile.am
fc4a62
index 57771be..98310f2 100644
fc4a62
--- a/tests/Makefile.am
fc4a62
+++ b/tests/Makefile.am
fc4a62
@@ -56,6 +56,7 @@ TESTS = \
fc4a62
   t6000-dm.sh \
fc4a62
   t6001-psep.sh \
fc4a62
   t6002-dm-many-partitions.sh \
fc4a62
+  t6003-dm-uuid.sh \
fc4a62
   t6100-mdraid-partitions.sh \
fc4a62
   t7000-scripting.sh \
fc4a62
   t8000-loop.sh \
fc4a62
diff --git a/tests/t6003-dm-uuid.sh b/tests/t6003-dm-uuid.sh
fc4a62
new file mode 100755
fc4a62
index 0000000..1751cb4
fc4a62
--- /dev/null
fc4a62
+++ b/tests/t6003-dm-uuid.sh
fc4a62
@@ -0,0 +1,59 @@
fc4a62
+#!/bin/sh
fc4a62
+# device-mapper: preserve uuid
fc4a62
+# The dm's partitions uuid would be removed when creating new partitions
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=3
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
+dmsetup rename $dm_name --setuuid f139317b-f98a-45d7-ab3b-9b4e0a336872 || 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 have UUIDs
fc4a62
+for ((i=1; i<=$n_partitions; i+=1)); do
fc4a62
+    dmsetup info /dev/mapper/${dm_name}p$i | grep UUID || fail=1
fc4a62
+
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