Skip to contentSkip to conversation

LVM2 ./WHATS_NEW test/Makefile.in test/lvm-uti ...

PATCH [email protected] 1 participant 1 message Oct 9, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: meyering at sourceware.org 2007-10-09 13:13:06

Modified files:
. : WHATS_NEW
test : Makefile.in lvm-utils.sh t-lvcreate-pvtags.sh
t-lvcreate-usage.sh test-lib.sh

Log message:
Run tests with LVM_SYSTEM_DIR pointing to private root and /dev dirs.

This makes the tests more reproducible and helps isolate them from any existing LVM set-up.
* test/Makefile.in (abs_builddir): Define. (init.sh): Emit definition of abs_builddir.
* test/lvm-utils.sh (unsafe_losetup_): Keep only the portable, iterative approach. (dmsetup_has_dm_devdir_support_): New function. (init_root_dir_): New function.
Invoke init_root_dir_ for all but the first test.
* test/test-lib.sh (this_test_): Adapt to test-name change. Invoke lvm-utils.sh much later (after tmpdir creation), and only if the current test is not being skipped. Remove useless abs_top_srcdir definition.
Rename t0->test_dir_rand_.
* test/t-lvcreate-pvtags.sh: Skip this test if the available version of dmsetup is not new enough.
Use global, $G_dev_, rather than hard-coded "/dev".
* test/t-lvcreate-usage.sh: Make --verbose output more useful.

Author: Jim Meyering <[email protected]>
Committer: Jim Meyering <[email protected]>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.716&r2=1.717
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/Makefile.in.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lvm-utils.sh.diff?cvsroot=lvm2&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvcreate-pvtags.sh.diff?cvsroot=lvm2&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvcreate-usage.sh.diff?cvsroot=lvm2&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/test-lib.sh.diff?cvsroot=lvm2&r1=1.2&r2=1.3

WHATS_NEW +1 -0
@@ -1,5 +1,6 @@
 Version 2.02.29 -
 ==================================
+  Tests are run with LVM_SYSTEM_DIR pointing to private root and /dev dirs.
   Fix a bug in lvm_dump.sh checks for lvm/dmsetup binaries.
   Fix underquotations in lvm_dump.sh.
   Refactor lvcreate stripe and mirror parameter validation.
test/Makefile.in +2 -0
@@ -21,6 +21,7 @@
 top_srcdir = @top_srcdir@
 top_builddir = @top_builddir@
 abs_srcdir = @abs_srcdir@
+abs_builddir = @abs_builddir@
 abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
 
@@ -32,6 +33,7 @@
 	echo 'abs_top_srcdir=$(abs_top_builddir)' >> $@-t
 	echo 'PATH=$(abs_top_builddir)/test/bin:$$PATH' >> $@-t
 	echo 'abs_srcdir=$(abs_srcdir)' >> $@-t
+	echo 'abs_builddir=$(abs_builddir)' >> $@-t
 	echo 'export PATH' >> $@-t
 	chmod a-w $@-t
 	mv $@-t $@
test/lvm-utils.sh +47 -11

76 lines not on this page · raw message

test/t-lvcreate-pvtags.sh +10 -3
@@ -14,6 +14,13 @@
 
 . ./test-lib.sh
 
+dmsetup_has_dm_devdir_support_ ||
+{
+  say "Your version of dmsetup lacks support for changing DM_DEVDIR."
+  say "Skipping this test"
+  exit 0
+}
+
 cleanup_()
 {
   test -n "$vg" && {
@@ -48,7 +55,7 @@
 done
 
 for n in $(seq 1 $nr_pvs); do
-  pvs="$pvs /dev/mapper/pv$n"
+  pvs="$pvs $G_dev_/mapper/pv$n"
 done
 
 test_expect_success \
@@ -66,7 +73,7 @@
 test_expect_failure 'too many stripes(4) for 3 PVs' \
   'lvcreate -l4 -i4 $vg @fast'
 test_expect_failure '2 stripes is too many with just one PV' \
-  'lvcreate -l2 -i2 $vg /dev/mapper/pv1'
+  'lvcreate -l2 -i2 $vg $G_dev_/mapper/pv1'
 
 test_expect_success 'lvcreate mirror' \
   'lvcreate -l1 -m1 $vg @fast'
@@ -77,6 +84,6 @@
 test_expect_failure 'lvcreate mirror (corelog, w/no free PVs)' \
   'lvcreate -l1 -m3 --corelog $vg @fast'
 test_expect_failure 'lvcreate mirror with a single PV arg' \
-  'lvcreate -l1 -m1 --corelog $vg /dev/mapper/pv1'
+  'lvcreate -l1 -m1 --corelog $vg $G_dev_/mapper/pv1'
 
 test_done
test/t-lvcreate-usage.sh +4 -3
@@ -30,15 +30,16 @@
   'set up temp files, loopback devices, PVs, and a VG' \
   'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") &&
    f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") &&
-   pvcreate $d1 $d2      &&
-   vg=$(this_test_)-test-vg-$$  &&
+   pvcreate $d1 $d2                       &&
+   vg=$(this_test_)-test-vg-$$            &&
    vgcreate $vg $d1 $d2'
 
 lv=lvcreate-usage-$$
 
 test_expect_success \
   'lvcreate rejects a negative stripesize' \
-  'lvcreate -L 64M -n $lv -i2 --stripesize -4 $vg 2>err; test $? = 3 &&
+  'lvcreate -L 64M -n $lv -i2 --stripesize -4 $vg 2>err;
+   status=$?; echo status=$?; test $status = 3 &&
    grep "^  Negative stripesize is invalid\$" err'
 
 test_expect_success \
test/test-lib.sh +8 -8
@@ -37,7 +37,7 @@
 	echo "* $*"
 }
 
-this_test_() { expr "./$0" : '.*/\(t[0-9]*\)-[^/]*$'; }
+this_test_() { expr "./$0" : '.*/t-\([^/]*\)\.sh$'; }
 
 test "${test_description}" != "" ||
 error "Test script did not set test_description."
@@ -193,8 +193,6 @@
 	esac
 }
 
-. lvm-utils.sh
-
 this_test=$(this_test_)
 
 skip_=0
@@ -208,8 +206,6 @@
     fi
 fi
 
-# Test the binaries we have just built.
-abs_top_srcdir=$(cd .. && pwd)
 pwd_=`pwd`
 
 test_dir_=${LVM_TEST_DIR-.}
@@ -239,16 +235,20 @@
 	esac
 done
 
-t0=$($abs_srcdir/mkdtemp $test_dir_ lvm-$this_test.XXXXXXXXXX) \
+test_dir_rand_=$($abs_srcdir/mkdtemp $test_dir_ lvm-$this_test.XXXXXXXXXX) \
     || error "failed to create temporary directory in $test_dir_"
 
 # Run each test from within a temporary sub-directory named after the
 # test itself, and arrange to remove it upon exception or normal exit.
-trap 'st=$?; cleanup_; d='"$t0"';
+trap 'st=$?; cleanup_; d='"$test_dir_rand_"';
     cd '"$test_dir_"' && chmod -R u+rwx "$d" && rm -rf "$d" && exit $st' 0
 trap '(exit $?); exit $?' 1 2 13 15
 
-cd $t0 || error "failed to cd to $t0"
+cd $test_dir_rand_ || error "failed to cd to $test_dir_rand_"
+
+if test $skip_ = 0; then
+  . $abs_srcdir/lvm-utils.sh || exit 1
+fi
 
 if ( diff --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then
   compare='diff -u'