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