From ed5686d9810865100f6aae7d4c5bbdef04e9267a Mon Sep 17 00:00:00 2001 From: Petr Rockai Date: Wed, 7 Apr 2010 14:46:26 +0000 Subject: [PATCH] Refactor the test utilities, dropping the legacy test-lib.sh and curtailing lvm-utils.sh. Clears up lots of unused code, should have little observable impact (it does change test directory layout slightly). --- test/Makefile.in | 2 +- test/lvm-utils.sh | 92 ------------ test/t-000-basic.sh | 4 +- test/t-fsadm.sh | 6 +- test/t-lvcreate-operation.sh | 2 +- test/t-lvcreate-pvtags.sh | 2 +- test/t-mirror-basic.sh | 2 +- test/t-pvcreate-operation.sh | 6 +- test/t-pvmove-basic.sh | 2 +- test/t-read-ahead.sh | 2 +- test/t-snapshot-merge.sh | 2 +- test/t-topology-support.sh | 2 +- test/t-vgsplit-stacked.sh | 4 +- test/test-lib.sh | 272 ----------------------------------- test/test-utils.sh | 101 ++++++++----- 15 files changed, 85 insertions(+), 416 deletions(-) delete mode 100755 test/test-lib.sh diff --git a/test/Makefile.in b/test/Makefile.in index 6ea6224bc..90ce1f792 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -30,7 +30,7 @@ SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) SCRIPTS := $(wildcard $(srcdir)/t-*.sh) \ $(srcdir)/test-utils.sh \ - $(srcdir)/test-lib.sh + $(srcdir)/lvm-utils.sh ifeq ("@UDEV_SYNC@", "yes") dm_udev_synchronisation = 1 diff --git a/test/lvm-utils.sh b/test/lvm-utils.sh index 98bcb3c53..39d52fdfb 100644 --- a/test/lvm-utils.sh +++ b/test/lvm-utils.sh @@ -16,40 +16,6 @@ export LVM_SUPPRESS_FD_WARNINGS=1 ME=$(basename "$0") warn() { echo >&2 "$ME: $@"; } -unsafe_losetup_() -{ - f=$1 - - test -n "$G_dev_" \ - || error "Internal error: unsafe_losetup_ called before init_root_dir_" - - # Iterate through $G_dev_/loop{,/}{0,1,2,3,4,5,6,7,8,9} - for slash in '' /; do - for i in 0 1 2 3 4 5 6 7 8 9; do - dev=$G_dev_/loop$slash$i - losetup $dev > /dev/null 2>&1 && continue; - losetup "$dev" "$f" > /dev/null && { echo "$dev"; return 0; } - break - done - done - - return 1 -} - -loop_setup_() -{ - file=$1 - dd if=/dev/zero of="$file" bs=1M count=1 seek=1000 > /dev/null 2>&1 \ - || { warn "loop_setup_ failed: Unable to create tmp file $file"; return 1; } - - # NOTE: this requires a new enough version of losetup - dev=$(unsafe_losetup_ "$file" 2>/dev/null) \ - || { warn "loop_setup_ failed: Unable to create loopback device"; return 1; } - - echo "$dev" - return 0; -} - compare_two_fields_() { local cmd1=$1; @@ -176,61 +142,3 @@ dmsetup_has_dm_devdir_support_() test "$?:$out" = "1:Invalid DM_DEV_DIR envvar value." -o \ "$?:$out" = "1:Invalid DM_DEV_DIR environment variable value." } - -# set up private /dev and /etc -init_root_dir_() -{ - test -n "$test_dir_rand_" \ - || error "Internal error: called init_root_dir_ before" \ - "defining \$test_dir_rand_" - - # Define these two globals. - G_root_=$test_dir_rand_/root - G_dev_=$G_root_/dev - - export LVM_SYSTEM_DIR=$G_root_/etc - export DM_DEV_DIR=$G_dev_ - - # Only the first caller does anything. - mkdir -p $G_root_/etc $G_dev_ $G_dev_/mapper $G_root_/lib - for i in 0 1 2 3 4 5 6 7; do - mknod $G_root_/dev/loop$i b 7 $i - done - for i in $abs_top_builddir/daemons/dmeventd/plugins/*/*.so - do - # NOTE: This check is necessary because the loop above will give us the value - # "$abs_top_builddir/daemons/dmeventd/plugins/*/*.so" if no files ending in 'so' exist. - # This is the best way I could quickly determine to skip over this bogus value. - if [ -f $i ]; then - echo Setting up symlink from $i to $G_root_/lib - ln -s $i $G_root_/lib - fi - done - cat > $G_root_/etc/lvm.conf <<-EOF - devices { - dir = "$G_dev_" - scan = "$G_dev_" - filter = [ "a/loop/", "a/mirror/", "a/mapper/", "r/.*/" ] - cache_dir = "$G_root_/etc" - sysfs_scan = 0 - } - log { - verbose = $verboselevel - syslog = 0 - indent = 1 - } - backup { - backup = 0 - archive = 0 - } - global { - library_dir = "$G_root_/lib" - } - activation { - udev_sync = 1 - udev_rules = 1 - } -EOF -} - -init_root_dir_ diff --git a/test/t-000-basic.sh b/test/t-000-basic.sh index 8f212fe6d..195749e63 100755 --- a/test/t-000-basic.sh +++ b/test/t-000-basic.sh @@ -20,7 +20,7 @@ lvm pvmove --version|sed -n "1s/.*: *\([0-9][^ ]*\) .*/\1/p" > actual # ensure they are the same diff -u actual expected -mknod $G_root_/dev/null c 1 3 || +mknod $DM_DEV_DIR/null c 1 3 || error "Can't create nodes on filesystem" -echo >$G_root_/dev/null || +echo >$DM_DEV_DIR/null || error "Filesystem for tests does not allow using device nodes (check nodev)" diff --git a/test/t-fsadm.sh b/test/t-fsadm.sh index 421ec6b91..6cff7c544 100644 --- a/test/t-fsadm.sh +++ b/test/t-fsadm.sh @@ -19,7 +19,7 @@ vgcreate -cn $vg $devs # Test for block sizes != 1024 (rhbz #480022) lvcreate -n$lv1 -L 64M $vg -mke2fs -b4096 -j $G_dev_/$vg/$lv1 -e2fsck -f -y $G_dev_/$vg/$lv1 -fsadm --lvresize resize $G_dev_/$vg/$lv1 128M +mke2fs -b4096 -j $DM_DEV_DIR/$vg/$lv1 +e2fsck -f -y $DM_DEV_DIR/$vg/$lv1 +fsadm --lvresize resize $DM_DEV_DIR/$vg/$lv1 128M vgremove -ff $vg diff --git a/test/t-lvcreate-operation.sh b/test/t-lvcreate-operation.sh index 44d97b41b..8a31759b8 100644 --- a/test/t-lvcreate-operation.sh +++ b/test/t-lvcreate-operation.sh @@ -21,7 +21,7 @@ cleanup_lvs() { fi } -aux prepare_pvs 2 +prepare_pvs 2 aux pvcreate --metadatacopies 0 $dev1 aux vgcreate -c n $vg $devs diff --git a/test/t-lvcreate-pvtags.sh b/test/t-lvcreate-pvtags.sh index 718ac1386..b9a438061 100755 --- a/test/t-lvcreate-pvtags.sh +++ b/test/t-lvcreate-pvtags.sh @@ -24,7 +24,7 @@ lvcreate -l3 -i3 $vg @fast not lvcreate -l4 -i4 $vg @fast # 2 stripes is too many with just one PV -not lvcreate -l2 -i2 $vg $G_dev_/mapper/pv1 +not lvcreate -l2 -i2 $vg $DM_DEV_DIR/mapper/pv1 # lvcreate mirror lvcreate -l1 -m1 $vg @fast diff --git a/test/t-mirror-basic.sh b/test/t-mirror-basic.sh index 9c3efc445..7577d9c7a 100755 --- a/test/t-mirror-basic.sh +++ b/test/t-mirror-basic.sh @@ -21,7 +21,7 @@ dmsetup_has_dm_devdir_support_ || exit 200 lvdev_() { - echo "$G_dev_/$1/$2" + echo "$DM_DEV_DIR/$1/$2" } mimages_are_redundant_ () diff --git a/test/t-pvcreate-operation.sh b/test/t-pvcreate-operation.sh index 3bd2f7bd8..a9d1a4219 100755 --- a/test/t-pvcreate-operation.sh +++ b/test/t-pvcreate-operation.sh @@ -15,9 +15,9 @@ aux prepare_devs 4 for mdatype in 1 2 do # pvcreate (lvm$mdatype) refuses to overwrite an mounted filesystem (bz168330) - test ! -d $G_root_/mnt && mkdir $G_root_/mnt + test ! -d $TESTDIR/mnt && mkdir $TESTDIR/mnt if mke2fs $dev1; then - mount $dev1 $G_root_/mnt + mount $dev1 $TESTDIR/mnt not pvcreate -M$mdatype $dev1 2>err grep "Can't open $dev1 exclusively. Mounted filesystem?" err umount $dev1 @@ -89,7 +89,7 @@ done # pvcreate (lvm2) fails writing LVM label at sector 4 not pvcreate --labelsector 4 $dev1 -backupfile=mybackupfile-$(this_test_) +backupfile=$PREFIX.mybackupfile uuid1=freddy-fred-fred-fred-fred-fred-freddy uuid2=freddy-fred-fred-fred-fred-fred-fredie bogusuuid=fred diff --git a/test/t-pvmove-basic.sh b/test/t-pvmove-basic.sh index 5070b725e..f182c6340 100755 --- a/test/t-pvmove-basic.sh +++ b/test/t-pvmove-basic.sh @@ -20,7 +20,7 @@ dmsetup_has_dm_devdir_support_ || exit 200 # Utilities lvdev_() { - echo "$G_dev_/$1/$2" + echo "$DM_DEV_DIR/$1/$2" } lv_is_on_() { diff --git a/test/t-read-ahead.sh b/test/t-read-ahead.sh index bda12bf01..6130561a2 100755 --- a/test/t-read-ahead.sh +++ b/test/t-read-ahead.sh @@ -47,7 +47,7 @@ lvremove -ff "$vg" blockdev --setra 768 $dev1 vgscan lvcreate -n $lv -L4m $vg $dev1 -test $(blockdev --getra $G_dev_/$vg/$lv) -eq 768 +test $(blockdev --getra $DM_DEV_DIR/$vg/$lv) -eq 768 lvremove -ff $vg # Check default, active/inactive values for read_ahead / kernel_read_ahead diff --git a/test/t-snapshot-merge.sh b/test/t-snapshot-merge.sh index 9d953cffa..b7c0cb0e1 100755 --- a/test/t-snapshot-merge.sh +++ b/test/t-snapshot-merge.sh @@ -16,7 +16,7 @@ which mkfs.ext3 || exit 200 lvdev_() { - echo "$G_dev_/$1/$2" + echo "$DM_DEV_DIR/$1/$2" } snap_lv_name_() { diff --git a/test/t-topology-support.sh b/test/t-topology-support.sh index 27ea4f702..53a1a4421 100644 --- a/test/t-topology-support.sh +++ b/test/t-topology-support.sh @@ -31,7 +31,7 @@ check_logical_block_size() lvdev_() { - echo "$G_dev_/$1/$2" + echo "$DM_DEV_DIR/$1/$2" } test_snapshot_mount() diff --git a/test/t-vgsplit-stacked.sh b/test/t-vgsplit-stacked.sh index fb4e659ed..9df19b570 100644 --- a/test/t-vgsplit-stacked.sh +++ b/test/t-vgsplit-stacked.sh @@ -8,8 +8,8 @@ vgcreate $vg1 $dev1 $dev2 lvcreate -n $lv1 -l 100%FREE $vg1 #top VG -pvcreate $G_dev_/$vg1/$lv1 -vgcreate $vg $G_dev_/$vg1/$lv1 $dev3 +pvcreate $DM_DEV_DIR/$vg1/$lv1 +vgcreate $vg $DM_DEV_DIR/$vg1/$lv1 $dev3 vgchange -a n $vg vgchange -a n $vg1 diff --git a/test/test-lib.sh b/test/test-lib.sh deleted file mode 100755 index 4e6f485c1..000000000 --- a/test/test-lib.sh +++ /dev/null @@ -1,272 +0,0 @@ -#!/bin/sh -# Derived from git's t/test-lib.sh, which is Copyright (c) 2005 Junio C Hamano -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions -# of the GNU General Public License v.2. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -# For repeatability, reset the environment to known value. -LANG=C -LC_ALL=C -TZ=UTC -export LANG LC_ALL TZ - -. ./init.sh || { echo >&2 you must run make first; exit 1; } - -# Protect ourselves from common misconfiguration to export -# CDPATH into the environment -unset CDPATH - -# Each test should start with something like this, after copyright notices: -# -# test_description='Description of this test... -# This test checks if command xyzzy does the right thing... -# ' -# . ./test-lib.sh - -error () { - echo "* error: $*" - exit 1 -} - -say () { - echo "* $*" -} - -this_test_() { expr "./$0" : '.*/t-\([^/]*\)\.sh$'; } - -test "${test_description}" != "" || -error "Test script did not set test_description." - -verboselevel=0 -while test "$#" -ne 0 -do - case "$1" in - -d|--d|--de|--deb|--debu|--debug) - debug=t ;; - -i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate) - immediate=t ;; - -h|--h|--he|--hel|--help) - echo "$test_description" - exit 0 ;; - -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose) - verbose=t ;; - -vv|-vvv|-vvvv) - verboselevel=${#1} - verboselevel=$(($verboselevel - 1)) - verbose=t ;; - *) - echo "$0: unsupported option $1" - exit 0 ;; - esac - shift -done - -exec 5>&1 -if test "$verbose" = "t" -then - exec 4>&2 3>&1 -else - exec 4>/dev/null 3>/dev/null -fi - -test_failure=0 -test_count=0 - -trap 'echo >&5 "FATAL: Unexpected exit with code $?"; exit 1' exit - -# You are not expected to call test_ok_ and test_failure_ directly, use -# the text_expect_* functions instead. - -test_ok_ () { - test_count=$(expr "$test_count" + 1) - say " ok $test_count: $@" -} - -test_failure_ () { - test_count=$(expr "$test_count" + 1) - test_failure=$(expr "$test_failure" + 1); - say "FAIL $test_count: $1" - shift - echo "$@" | sed -e 's/^/ /' - test "$immediate" = "" || exit 1 -} - -test_debug () { - test "$debug" = "" || eval "$1" -} - -test_run_ () { - eval >&3 2>&4 "$1" - eval_ret="$?" - return 0 -} - -test_skip () { - this_test=$(this_test_) - this_test="$this_test.$(expr "$test_count" + 1)" - to_skip= - for skp in $SKIP_TESTS - do - case "$this_test" in - $skp) - to_skip=t - esac - done - case "$to_skip" in - t) - say >&3 "skipping test: $@" - test_count=$(expr "$test_count" + 1) - say "skip $test_count: $1" - : true - ;; - *) - false - ;; - esac -} - -test_expect_failure () { - test "$#" = 2 || - error "bug in the test script: not 2 parameters to test-expect-failure" - if ! test_skip "$@" - then - say >&3 "expecting failure: $2" - test_run_ "$2" - if [ "$?" = 0 -a "$eval_ret" != 0 -a "$eval_ret" -lt 129 ] - then - test_ok_ "$1" - else - test_failure_ "$@" - fi - fi - echo >&3 "" -} - -test_expect_success () { - test "$#" = 2 || - error "bug in the test script: not 2 parameters to test-expect-success" - if ! test_skip "$@" - then - say >&3 "expecting success: $2" - test_run_ "$2" - if [ "$?" = 0 -a "$eval_ret" = 0 ] - then - test_ok_ "$1" - else - test_failure_ "$@" - fi - fi - echo >&3 "" -} - -test_expect_code () { - test "$#" = 3 || - error "bug in the test script: not 3 parameters to test-expect-code" - if ! test_skip "$@" - then - say >&3 "expecting exit code $1: $3" - test_run_ "$3" - if [ "$?" = 0 -a "$eval_ret" = "$1" ] - then - test_ok_ "$2" - else - test_failure_ "$@" - fi - fi - echo >&3 "" -} - -test_done () { - case "$test_failure" in - 0) - # We could: - # cd .. && rm -fr trash - # but that means we forbid any tests that use their own - # subdirectory from calling test_done without coming back - # to where they started from. - # The Makefile provided will clean this test area so - # we will leave things as they are. - - say "passed all $test_count test(s)" - exit 0 ;; - - *) - say "failed $test_failure among $test_count test(s)" - exit 1 ;; - - esac -} - -this_test=$(this_test_) - -skip_=0 -# If $privileges_required_ is nonempty, non-root skips this test. -if test "$privileges_required_" != ''; then - uid=`id -u` || error 'failed to run "id -u"' - if test "$uid" != 0; then - SKIP_TESTS="$SKIP_TESTS $this_test" - say "you have insufficient privileges for test $this_test" - skip_=1 - fi -fi - -pwd_=`pwd` - -test_dir_=${LVM_TEST_DIR-.} -test "$test_dir_" = . && test_dir_=$pwd_ - -# This is a stub function that is run upon trap (upon regular exit and -# interrupt). Override it with a per-test function, e.g., to unmount -# a partition, or to undo any other global state changes. -cleanup_() { :; } - -for skp in $SKIP_TESTS -do - to_skip= - for skp in $SKIP_TESTS - do - case "$this_test" in - $skp) - to_skip=t - esac - done - case "$to_skip" in - t) - say >&3 "skipping test $this_test altogether" - say "skip all tests in $this_test" - trap - exit - test_done - esac -done - -test_dir_rand_=$($abs_srcdir/mkdtemp $test_dir_ lvm-$this_test.XXXXXXXXXX) \ - || error "failed to create temporary directory in $test_dir_" - -testlib_cleanup_() { - d="$test_dir_rand_"; - cd "$test_dir_" && chmod -R u+rwx "$d" && rm -rf "$d" -} - -# 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_; testlib_cleanup_; exit $st' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -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' -elif ( cmp --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then - compare='cmp -s' -else - compare=cmp -fi diff --git a/test/test-utils.sh b/test/test-utils.sh index 08e89c980..eb309744e 100644 --- a/test/test-utils.sh +++ b/test/test-utils.sh @@ -8,9 +8,6 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -test_description="foo" # silence test-lib for now -. ./test-lib.sh - aux() { # use just "$@" for verbose operation "$@" > /dev/null 2> /dev/null @@ -71,12 +68,30 @@ prepare_clvmd() { # skip if we don't have our own clvmd... (which clvmd | grep $abs_builddir) || exit 200 - trap 'aux teardown_' EXIT # don't forget to clean up + trap_teardown clvmd -Isinglenode -d 1 & LOCAL_CLVMD="$!" } +prepare_testroot() { + PWD="`pwd`" + PREFIX="LVMTEST$$" + + trap_teardown + TESTDIR=$($abs_srcdir/mkdtemp ${LVM_TEST_DIR-$(pwd)} $PREFIX.XXXXXXXXXX) \ + || { echo "failed to create temporary directory in $test_dir_"; exit 1; } + + export LVM_SYSTEM_DIR=$TESTDIR/etc + export DM_DEV_DIR=$TESTDIR/dev + mkdir $LVM_SYSTEM_DIR $DM_DEV_DIR $DM_DEV_DIR/mapper $TESTDIR/lib + + for i in `find $abs_top_builddir/daemons/dmeventd/plugins/ -name \*.so`; do + echo Setting up symlink from $i to $TESTDIR/lib + ln -s $i $TESTDIR/lib + done +} + teardown() { echo $LOOP echo $PREFIX @@ -84,12 +99,12 @@ teardown() { test -n "$LOCAL_CLVMD" && kill -9 "$LOCAL_CLVMD" test -n "$PREFIX" && { - rm -rf $G_root_/dev/$PREFIX* + rm -rf $TESTDIR/dev/$PREFIX* init_udev_transaction while dmsetup table | grep -q ^$PREFIX; do - for s in `dmsetup table | grep ^$PREFIX| awk '{ print substr($1,1,length($1)-1) }'`; do - dmsetup remove $s 2>/dev/null > /dev/null || true + for s in `dmsetup info -c -o name --noheading | grep ^$PREFIX`; do + dmsetup remove $s >& /dev/null || true done done finish_udev_transaction @@ -105,27 +120,35 @@ teardown() { test -n "$LOOPFILE" && rm -f $LOOPFILE fi unset devs # devs is set in prepare_devs() + + test -n "$TESTDIR" && { + cd $PWD + rm -rf $TESTDIR || echo BLA + } } -teardown_() { - teardown - cleanup_ # user-overridable cleanup - testlib_cleanup_ # call test-lib cleanup routine, too +trap_teardown() { + trap 'set +vex; STACKTRACE; set -vex' ERR + trap 'aux teardown' EXIT # don't forget to clean up } make_ioerror() { echo 0 10000000 error | dmsetup create ioerror - ln -s $G_dev_/mapper/ioerror $G_dev_/ioerror + ln -s $DM_DEV_DIR/mapper/ioerror $DM_DEV_DIR/ioerror } prepare_loop() { size=$1 test -n "$size" || size=32 - test -n "$LOOP" && return 0 - trap 'aux teardown_' EXIT # don't forget to clean up - trap 'set +vex; STACKTRACE; set -vex' ERR - #trap - ERR + test -z "$LOOP" + test -n "$DM_DEV_DIR" + + trap_teardown + + for i in 0 1 2 3 4 5 6 7; do + mknod $DM_DEV_DIR/loop$i b 7 $i + done LOOPFILE="$PWD/test.img" dd if=/dev/zero of="$LOOPFILE" bs=$((1024*1024)) count=1 seek=$(($size-1)) @@ -136,10 +159,10 @@ prepare_loop() { return 0 else # no -f support - # Iterate through $G_dev_/loop{,/}{0,1,2,3,4,5,6,7} + # Iterate through $DM_DEV_DIR/loop{,/}{0,1,2,3,4,5,6,7} for slash in '' /; do for i in 0 1 2 3 4 5 6 7; do - local dev=$G_dev_/loop$slash$i + local dev=$DM_DEV_DIR/loop$slash$i ! losetup $dev >/dev/null 2>&1 || continue # got a free losetup "$dev" "$LOOPFILE" @@ -174,8 +197,7 @@ prepare_scsi_debug_dev() local SCSI_DEBUG_PARAMS="$@" test -n "$SCSI_DEBUG_DEV" && return 0 - trap 'aux teardown_' EXIT # don't forget to clean up - trap 'set +vex; STACKTRACE; set -vex' ERR + trap_teardown # Skip test if awk isn't available (required for get_sd_devs_) which awk || exit 200 @@ -201,8 +223,8 @@ prepare_scsi_debug_dev() fi done if [ $FOUND -eq 0 ]; then - # Create symlink to scsi_debug device in $G_dev_ - SCSI_DEBUG_DEV=$G_dev_/$(basename $dev1) + # Create symlink to scsi_debug device in $DM_DEV_DIR + SCSI_DEBUG_DEV=$DM_DEV_DIR/$(basename $dev1) # Setting $LOOP provides means for prepare_devs() override LOOP=$SCSI_DEBUG_DEV ln -snf $dev1 $SCSI_DEBUG_DEV @@ -228,8 +250,6 @@ prepare_devs() { prepare_loop $(($n*$devsize)) - PREFIX="LVMTEST$$" - if ! loopsz=`blockdev --getsz $LOOP 2>/dev/null`; then loopsz=`blockdev --getsize $LOOP 2>/dev/null` fi @@ -239,7 +259,7 @@ prepare_devs() { init_udev_transaction for i in `seq 1 $n`; do local name="${PREFIX}$pvname$i" - local dev="$G_dev_/mapper/$name" + local dev="$DM_DEV_DIR/mapper/$name" eval "dev$i=$dev" devs="$devs $dev" echo 0 $size linear $LOOP $((($i-1)*$size)) > $name.table @@ -325,13 +345,13 @@ prepare_lvmconf() { filter='[ "a/dev\/mirror/", "a/dev\/mapper\/.*pv[0-9_]*$/", "r/.*/" ]' locktype= if test -n "$LVM_TEST_LOCKING"; then locktype="locking_type = $LVM_TEST_LOCKING"; fi - cat > $G_root_/etc/lvm.conf <<-EOF + cat > $TESTDIR/etc/lvm.conf <<-EOF $LVM_TEST_CONFIG devices { - dir = "$G_dev_" - scan = "$G_dev_" + dir = "$DM_DEV_DIR" + scan = "$DM_DEV_DIR" filter = $filter - cache_dir = "$G_root_/etc" + cache_dir = "$TESTDIR/etc" sysfs_scan = 0 } log { @@ -344,8 +364,8 @@ prepare_lvmconf() { } global { abort_on_internal_errors = 1 - library_dir = "$G_root_/lib" - locking_dir = "$G_root_/var/lock/lvm" + library_dir = "$TESTDIR/lib" + locking_dir = "$TESTDIR/var/lock/lvm" $locktype } activation { @@ -353,9 +373,22 @@ prepare_lvmconf() { udev_rules = 1 } EOF + cat $TESTDIR/etc/lvm.conf } -set -vexE -o pipefail -aux prepare_lvmconf -prepare_clvmd +prepare() { + prepare_testroot + prepare_lvmconf + prepare_clvmd + source ./lvm-utils.sh +} +LANG=C +LC_ALL=C +TZ=UTC +unset CDPATH + +. ./init.sh || { echo >&2 you must run make first; exit 1; } + +set -vexE -o pipefail +aux prepare