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

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