Blame SOURCES/parted-3.1-tests-rewrite-t6001-to-use-dev-mapper.patch

8dc857
From 7d4947fd094f1dda491473a57a9275971405684e Mon Sep 17 00:00:00 2001
8dc857
From: Fedora Ninjas <parted-owner@fedoraproject.org>
8dc857
Date: Wed, 17 Apr 2013 14:59:36 -0700
8dc857
Subject: [PATCH] tests: rewrite t6001 to use /dev/mapper
8dc857
8dc857
This test begain failing because using a private copy of /dev/mapper
8dc857
confuses the system. This fixes that and generally cleans up the test.
8dc857
8dc857
tests/t6001.sh: update to use /dev/mapper directly
8dc857
---
8dc857
 tests/t6001-psep.sh | 43 ++++++++++++++++++-------------------------
8dc857
 1 file changed, 18 insertions(+), 25 deletions(-)
8dc857
8dc857
diff --git a/tests/t6001-psep.sh b/tests/t6001-psep.sh
8dc857
index 1859ac9..0c1ab99 100644
8dc857
--- a/tests/t6001-psep.sh
8dc857
+++ b/tests/t6001-psep.sh
8dc857
@@ -1,4 +1,5 @@
8dc857
 #!/bin/sh
8dc857
+
8dc857
 # ensure that parted names partitions on dm disks correctly
8dc857
 
8dc857
 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
8dc857
@@ -19,10 +20,7 @@
8dc857
 . "${srcdir=.}/init.sh"; path_prepend_ ../parted
8dc857
 
8dc857
 require_root_
8dc857
-lvm_init_root_dir_
8dc857
-
8dc857
-test "x$ENABLE_DEVICE_MAPPER" = xyes \
8dc857
-  || skip_ "no device-mapper support"
8dc857
+(dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed"
8dc857
 
8dc857
 # Device maps names - should be random to not conflict with existing ones on
8dc857
 # the system
8dc857
@@ -41,25 +39,19 @@ cleanup_fn_() {
8dc857
     rm -f "$f1 $f2";
8dc857
 }
8dc857
 
8dc857
-# create a file of size N bytes
8dc857
-N=10M
8dc857
+loop_file_1=loop-file-1-$$
8dc857
+loop_file_2=loop-file-2-$$
8dc857
 
8dc857
-f1=$(pwd)/1; d1=$(loop_setup_ "$f1") \
8dc857
-  || skip_ "is this partition mounted with 'nodev'?"
8dc857
+d1=$(loop_setup_ $loop_file_1) || framework_failure
8dc857
+d1_size=$(blockdev --getsz $d1)
8dc857
+d2=$(loop_setup_ $loop_file_2) || framework_failure
8dc857
+d2_size=$(blockdev --getsz $d2)
8dc857
 
8dc857
-f2=$(pwd)/2 ;d2=$(loop_setup_ "$f2") \
8dc857
-  || skip_ "is this partition mounted with 'nodev'?"
8dc857
-
8dc857
-dmsetup_cmd="0 `blockdev --getsz $d1` linear $d1 0"
8dc857
-# setup: create a mapping
8dc857
-echo "$dmsetup_cmd" | dmsetup create "$linear_" || fail=1
8dc857
-dev="$DM_DEV_DIR/mapper/$linear_"
8dc857
+dmsetup create $linear_ --table "0 $d1_size linear $d1 0" || framework_failure
8dc857
+dev="/dev/mapper/$linear_"
8dc857
 
8dc857
 # Create msdos partition table
8dc857
-parted -s $dev mklabel msdos > out 2>&1 || fail=1
8dc857
-compare /dev/null out || fail=1
8dc857
-
8dc857
-parted -s $dev mkpart primary fat32 1m 5m > out 2>&1 || fail=1
8dc857
+parted -s $dev mklabel msdos mkpart primary fat32 1m 5m > out 2>&1 || fail=1
8dc857
 compare /dev/null out || fail=1
8dc857
 
8dc857
 #make sure device name is correct
8dc857
@@ -67,17 +59,18 @@ test -e ${dev}p1 || fail=1
8dc857
 
8dc857
 #repeat on name not ending in a digit
8dc857
 # setup: create a mapping
8dc857
-echo "$dmsetup_cmd" | dmsetup create "$linear2_" || fail=1
8dc857
-dev="$DM_DEV_DIR/mapper/$linear2_"
8dc857
+dmsetup create $linear2_ --table "0 $d2_size linear $d2 0" || framework_failure
8dc857
+dev="/dev/mapper/$linear2_"
8dc857
 
8dc857
 # Create msdos partition table
8dc857
-parted -s $dev mklabel msdos > out 2>&1 || fail=1
8dc857
-compare /dev/null out || fail=1
8dc857
-
8dc857
-parted -s $dev mkpart primary fat32 1m 5m > out 2>&1 || fail=1
8dc857
+parted -s $dev mklabel msdos mkpart primary fat32 1m 5m > out 2>&1 || fail=1
8dc857
 compare /dev/null out || fail=1
8dc857
 
8dc857
 #make sure device name is correct
8dc857
 test -e ${dev}1 || fail=1
8dc857
 
8dc857
+if [ -n "$fail" ]; then
8dc857
+    ls /dev/mapper
8dc857
+fi
8dc857
+
8dc857
 Exit $fail
8dc857
-- 
8dc857
1.8.1.4
8dc857