2013-06-10 13:28:47 +04:00
#!/usr/bin/env bash
2012-01-26 22:25:46 +04:00
# Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved.
2011-01-05 03:16:18 +03:00
#
# 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
. lib/utils
2012-03-16 16:59:02 +04:00
run_valgrind( ) {
2012-03-20 14:51:57 +04:00
# Execute script which may use $TESTNAME for creating individual
2012-03-16 16:59:02 +04:00
# log files for each execute command
2014-10-01 10:19:05 +04:00
exec " ${ VALGRIND :- valgrind } " " $@ "
2012-03-16 16:59:02 +04:00
}
2012-05-16 14:43:41 +04:00
expect_failure( ) {
echo "TEST EXPECT FAILURE"
}
2011-01-05 03:16:18 +03:00
prepare_clvmd( ) {
2014-09-30 19:09:26 +04:00
rm -f debug.log strace.log
2012-03-16 16:59:02 +04:00
test " ${ LVM_TEST_LOCKING :- 0 } " -ne 3 && return # not needed
2011-01-05 03:16:18 +03:00
if pgrep clvmd ; then
echo " Cannot use fake cluster locking with real clvmd ( $( pgrep clvmd) ) running. "
2012-03-16 16:59:02 +04:00
skip
2011-01-05 03:16:18 +03:00
fi
# skip if we don't have our own clvmd...
2015-04-13 15:19:54 +03:00
( which clvmd 2>/dev/null | grep -q " $abs_builddir " ) || skip
2014-01-08 16:52:05 +04:00
# lvs is executed from clvmd - use our version
export LVM_BINARY = $( which lvm)
2011-01-05 03:16:18 +03:00
2015-04-13 15:19:54 +03:00
test -e " $DM_DEV_DIR /control " || dmsetup table >/dev/null # create control node
2014-03-21 14:38:20 +04:00
# skip if singlenode is not compiled in
2015-04-13 15:19:54 +03:00
( clvmd --help 2>& 1 | grep "Available cluster managers" | grep -q "singlenode" ) || skip
2011-01-05 03:16:18 +03:00
2012-03-16 16:59:02 +04:00
# lvmconf "activation/monitoring = 1"
local run_valgrind =
2014-03-09 01:53:23 +04:00
test " ${ LVM_VALGRIND_CLVMD :- 0 } " -eq 0 || run_valgrind = "run_valgrind"
2014-03-21 14:38:20 +04:00
rm -f " $CLVMD_PIDFILE "
2015-04-13 17:30:17 +03:00
echo "<======== Starting CLVMD ========>"
2015-04-20 11:05:27 +03:00
LVM_LOG_FILE_EPOCH = CLVMD $run_valgrind clvmd -Isinglenode -d 1 -f &
2014-03-21 14:38:20 +04:00
echo $! > LOCAL_CLVMD
for i in $( seq 1 100) ; do
test $i -eq 100 && die "Startup of clvmd is too slow."
2015-04-20 11:05:27 +03:00
test -e " $CLVMD_PIDFILE " && break
2014-03-21 14:38:20 +04:00
sleep .2
done
2011-01-05 03:16:18 +03:00
}
prepare_dmeventd( ) {
2014-09-30 19:09:26 +04:00
rm -f debug.log strace.log
2011-01-05 03:16:18 +03:00
if pgrep dmeventd ; then
echo " Cannot test dmeventd with real dmeventd ( $( pgrep dmeventd) ) running. "
2012-03-16 16:59:02 +04:00
skip
2011-01-05 03:16:18 +03:00
fi
# skip if we don't have our own dmeventd...
2012-03-16 16:59:02 +04:00
( which dmeventd 2>/dev/null | grep " $abs_builddir " ) || skip
2011-01-05 03:16:18 +03:00
2012-03-16 16:59:02 +04:00
lvmconf "activation/monitoring = 1"
2011-01-07 16:04:17 +03:00
2014-03-09 02:19:26 +04:00
local run_valgrind =
test " ${ LVM_VALGRIND_DMEVENTD :- 0 } " -eq 0 || run_valgrind = "run_valgrind"
2015-04-20 11:05:27 +03:00
LVM_LOG_FILE_EPOCH = DMEVENTD $run_valgrind dmeventd -f " $@ " &
2012-03-16 16:59:02 +04:00
echo $! > LOCAL_DMEVENTD
2011-03-04 17:19:18 +03:00
# FIXME wait for pipe in /var/run instead
2014-03-14 14:12:46 +04:00
for i in $( seq 1 100) ; do
test $i -eq 100 && die "Startup of dmeventd is too slow."
test -e " ${ DMEVENTD_PIDFILE } " && break
sleep .2
done
2014-03-09 02:19:26 +04:00
echo ok
2011-01-05 03:16:18 +03:00
}
2011-08-31 15:31:57 +04:00
prepare_lvmetad( ) {
2015-04-12 22:42:26 +03:00
test $# -eq 0 && default_opts = "-l all"
2014-09-30 19:09:26 +04:00
rm -f debug.log strace.log
2011-08-31 15:31:57 +04:00
# skip if we don't have our own lvmetad...
2012-03-16 16:59:02 +04:00
( which lvmetad 2>/dev/null | grep " $abs_builddir " ) || skip
2011-08-31 15:31:57 +04:00
2015-04-08 23:44:16 +03:00
lvmconf "global/use_lvmetad = 1" \
"devices/md_component_detection = 0"
2011-08-31 15:31:57 +04:00
2012-09-10 09:42:39 +04:00
local run_valgrind =
2014-03-09 01:53:23 +04:00
test " ${ LVM_VALGRIND_LVMETAD :- 0 } " -eq 0 || run_valgrind = "run_valgrind"
2012-09-10 09:42:39 +04:00
2014-07-21 23:44:53 +04:00
kill_sleep_kill_ LOCAL_LVMETAD ${ LVM_VALGRIND_LVMETAD :- 0 }
2012-03-16 16:59:02 +04:00
echo "preparing lvmetad..."
2014-07-21 23:44:53 +04:00
$run_valgrind lvmetad -f " $@ " -s " $TESTDIR /lvmetad.socket " $default_opts " $@ " &
2012-03-16 16:59:02 +04:00
echo $! > LOCAL_LVMETAD
2012-10-08 22:25:14 +04:00
while ! test -e " $TESTDIR /lvmetad.socket " ; do echo -n .; sleep .1; done # wait for the socket
echo ok
2011-08-31 15:31:57 +04:00
}
2014-02-28 14:18:33 +04:00
lvmetad_talk( ) {
2014-03-03 00:48:28 +04:00
local use = nc
if type -p socat >& /dev/null; then
use = socat
elif echo | not nc -U " $TESTDIR /lvmetad.socket " ; then
echo "WARNING: Neither socat nor nc -U seems to be available." 1>& 2
echo "# failed to contact lvmetad"
return 1
fi
if test " $use " = nc ; then
nc -U " $TESTDIR /lvmetad.socket "
else
socat " unix-connect: $TESTDIR /lvmetad.socket " -
2014-03-03 22:01:30 +04:00
fi | tee -a lvmetad-talk.txt
2014-02-28 14:18:33 +04:00
}
lvmetad_dump( ) {
2014-03-21 14:38:20 +04:00
( echo 'request="dump"' ; echo '##' ) | lvmetad_talk " $@ "
2014-02-28 14:18:33 +04:00
}
2012-02-24 03:58:42 +04:00
notify_lvmetad( ) {
if test -e LOCAL_LVMETAD; then
2015-04-22 10:01:49 +03:00
# Ignore results here...
LVM_LOG_FILE_EPOCH = pvscan --cache " $@ " || true
rm -f debug.log
2012-02-24 03:58:42 +04:00
fi
}
2012-03-20 14:51:57 +04:00
teardown_devs_prefixed( ) {
local prefix = $1
local stray = ${ 2 :- 0 }
local IFS = $IFS_NL
local dm
2012-03-16 16:59:02 +04:00
2012-03-20 14:51:57 +04:00
# Resume suspended devices first
2012-03-28 15:10:08 +04:00
for dm in $( dm_info suspended,name | grep " ^Suspended:.* $prefix " ) ; do
2012-03-20 14:51:57 +04:00
echo " dmsetup resume \" ${ dm #Suspended : } \" "
2013-12-18 13:40:36 +04:00
dmsetup clear " ${ dm #Suspended : } "
2012-11-29 20:39:36 +04:00
dmsetup resume " ${ dm #Suspended : } " &
2012-03-20 14:51:57 +04:00
done
2011-06-29 22:14:08 +04:00
2012-11-29 20:39:36 +04:00
wait
2012-03-20 14:51:57 +04:00
local mounts = ( $( grep " $prefix " /proc/mounts | cut -d' ' -f1) )
if test ${# mounts [@] } -gt 0; then
test " $stray " -eq 0 || echo " Removing stray mounted devices containing $prefix : ${ mounts [@] } "
if umount -fl " ${ mounts [@] } " ; then
udev_wait
fi
fi
2012-03-16 16:59:02 +04:00
2012-03-20 14:51:57 +04:00
# Remove devices, start with closed (sorted by open count)
local remfail = no
local need_udev_wait = 0
init_udev_transaction
2012-03-28 15:10:08 +04:00
for dm in $( dm_info name --sort open | grep " $prefix " ) ; do
2014-06-05 14:09:02 +04:00
dmsetup remove " $dm " & >/dev/null || remfail = yes
2012-03-20 14:51:57 +04:00
need_udev_wait = 1
done
finish_udev_transaction
test $need_udev_wait -eq 0 || udev_wait
if test $remfail = yes; then
local num_devs
local num_remaining_devs = 999
2012-03-28 15:10:08 +04:00
while num_devs = $( dm_table | grep " $prefix " | wc -l) && \
2012-03-20 14:51:57 +04:00
test $num_devs -lt $num_remaining_devs -a $num_devs -ne 0; do
test " $stray " -eq 0 || echo " Removing $num_devs stray mapped devices with names beginning with $prefix : "
2012-03-28 15:10:08 +04:00
for dm in $( dm_info name --sort open | grep " $prefix " ) ; do
2014-06-05 14:09:02 +04:00
dmsetup remove -f " $dm " || true
2012-03-16 16:59:02 +04:00
done
2012-03-20 14:51:57 +04:00
num_remaining_devs = $num_devs
2012-03-16 16:59:02 +04:00
done
2012-03-20 14:51:57 +04:00
fi
}
teardown_devs( ) {
# Delete any remaining dm/udev semaphores
teardown_udev_cookies
test -z " $PREFIX " || {
rm -rf " $TESTDIR /dev/ $PREFIX " *
teardown_devs_prefixed " $PREFIX "
2011-01-05 03:16:18 +03:00
}
# NOTE: SCSI_DEBUG_DEV test must come before the LOOP test because
# prepare_scsi_debug_dev() also sets LOOP to short-circuit prepare_loop()
if test -f SCSI_DEBUG_DEV; then
2014-03-17 19:32:29 +04:00
test " ${ LVM_TEST_PARALLEL :- 0 } " -eq 1 || modprobe -r scsi_debug
2011-01-05 03:16:18 +03:00
else
2014-06-30 23:00:08 +04:00
test ! -f LOOP || losetup -d $( < LOOP) || true
test ! -f LOOPFILE || rm -f $( < LOOPFILE)
2011-01-05 03:16:18 +03:00
fi
rm -f DEVICES # devs is set in prepare_devs()
2015-02-17 17:53:24 +03:00
not diff LOOP BACKING_DEV >/dev/null 2>& 1 || rm -f BACKING_DEV
2011-01-05 03:16:18 +03:00
rm -f LOOP
2011-06-29 21:33:39 +04:00
2011-06-30 13:15:53 +04:00
# Attempt to remove any loop devices that failed to get torn down if earlier tests aborted
2014-03-17 19:32:29 +04:00
test " ${ LVM_TEST_PARALLEL :- 0 } " -eq 1 -o -z " $COMMON_PREFIX " || {
2012-03-20 14:51:57 +04:00
teardown_devs_prefixed " $COMMON_PREFIX " 1
local stray_loops = ( $( losetup -a | grep " $COMMON_PREFIX " | cut -d: -f1) )
test ${# stray_loops [@] } -eq 0 || {
echo " Removing stray loop devices containing $COMMON_PREFIX : ${ stray_loops [@] } "
2013-10-17 19:52:42 +04:00
for i in " ${ stray_loops [@] } " ; do losetup -d $i ; done
2012-03-20 14:51:57 +04:00
}
2011-06-30 13:15:53 +04:00
}
2014-06-16 15:37:22 +04:00
# Leave test when udev processed all removed devices
udev_wait
2011-01-05 03:16:18 +03:00
}
2014-03-10 01:55:11 +04:00
kill_sleep_kill_( ) {
2014-10-01 10:53:27 +04:00
pidfile = $1
slow = $2
if test -s $pidfile ; then
pid = $( < $pidfile )
2015-04-15 14:10:33 +03:00
kill -TERM $pid 2>/dev/null || return 0
2014-10-01 10:53:27 +04:00
if test $slow -eq 0 ; then sleep .1 ; else sleep 1 ; fi
kill -KILL $pid 2>/dev/null || true
wait = 0
while ps $pid > /dev/null && test $wait -le 10; do
sleep .5
wait = $(( $wait + 1 ))
done
2014-03-10 01:55:11 +04:00
fi
}
2015-04-03 11:41:33 +03:00
# $1 cmd line
# $2 optional parms for pgrep
add_to_kill_list( ) {
2015-04-14 14:29:19 +03:00
local p = $( pgrep ${ @ : 2 } -f " $1 " 2>/dev/null)
test -z " $p " || echo " $p : $1 " >> kill_list
2015-04-03 11:41:33 +03:00
}
2015-04-14 14:29:19 +03:00
kill_listed_processes( ) {
local tmp
local pid
local cmd
test -f kill_list || return 0
while read tmp; do
pid = ${ tmp %% : * }
cmd = ${ tmp ##* : }
2015-04-03 11:41:33 +03:00
for tmp in $( pgrep -f " $cmd " -d ' ' ) ; do
2015-04-14 14:29:19 +03:00
test " $tmp " = " $pid " && kill -9 " $tmp "
2015-04-03 11:41:33 +03:00
done
2015-04-14 14:29:19 +03:00
done < kill_list
rm -f kill_list
2015-04-03 11:41:33 +03:00
}
2011-01-05 03:16:18 +03:00
teardown( ) {
2012-03-16 16:59:02 +04:00
echo -n "## teardown..."
2014-03-10 01:55:11 +04:00
2015-04-14 14:29:19 +03:00
kill_listed_processes
2015-04-03 11:41:33 +03:00
2014-03-10 01:55:11 +04:00
kill_sleep_kill_ LOCAL_LVMETAD ${ LVM_VALGRIND_LVMETAD :- 0 }
2011-01-05 03:16:18 +03:00
2012-03-28 15:10:08 +04:00
dm_table | not egrep -q " $vg | $vg1 | $vg2 | $vg3 | $vg4 " || {
2012-03-23 13:41:20 +04:00
# Avoid activation of dmeventd if there is no pid
2012-03-28 15:10:08 +04:00
cfg = $( test -s LOCAL_DMEVENTD || echo "--config activation{monitoring=0}" )
2012-03-23 13:41:20 +04:00
vgremove -ff $cfg \
2014-09-30 19:09:26 +04:00
$vg $vg1 $vg2 $vg3 $vg4 & >/dev/null || rm -f debug.log strace.log
2012-03-23 13:41:20 +04:00
}
2014-03-10 01:55:11 +04:00
kill_sleep_kill_ LOCAL_CLVMD ${ LVM_VALGRIND_CLVMD :- 0 }
2012-03-16 16:59:02 +04:00
echo -n .
2011-01-05 03:16:18 +03:00
2014-03-09 02:19:26 +04:00
kill_sleep_kill_ LOCAL_DMEVENTD ${ LVM_VALGRIND_DMEVENTD :- 0 }
2011-01-05 03:16:18 +03:00
2012-03-16 16:59:02 +04:00
echo -n .
2011-01-05 03:16:18 +03:00
2012-03-16 16:59:02 +04:00
test -d " $DM_DEV_DIR /mapper " && teardown_devs
2011-01-05 03:16:18 +03:00
2012-03-16 16:59:02 +04:00
echo -n .
2011-01-05 03:16:18 +03:00
2012-03-16 16:59:02 +04:00
test -n " $TESTDIR " && {
cd " $TESTOLDPWD "
rm -rf " $TESTDIR " || echo BLA
}
2011-01-05 03:16:18 +03:00
2012-03-16 16:59:02 +04:00
echo "ok"
2011-01-05 03:16:18 +03:00
2014-03-17 19:32:29 +04:00
test " ${ LVM_TEST_PARALLEL :- 0 } " -eq 1 -o -n " $RUNNING_DMEVENTD " || not pgrep dmeventd #&>/dev/null
2011-01-05 03:16:18 +03:00
}
prepare_loop( ) {
2012-03-16 16:59:02 +04:00
local size = ${ 1 =32 }
2012-03-20 14:51:57 +04:00
local i
local slash
2011-01-05 03:16:18 +03:00
2014-06-30 23:00:08 +04:00
test -f LOOP && LOOP = $( < LOOP)
2012-03-16 16:59:02 +04:00
echo -n "## preparing loop device..."
2011-01-05 03:16:18 +03:00
# skip if prepare_scsi_debug_dev() was used
2012-03-16 16:59:02 +04:00
if test -f SCSI_DEBUG_DEV -a -f LOOP ; then
echo "(skipped)"
2011-01-05 03:16:18 +03:00
return 0
fi
test ! -e LOOP
test -n " $DM_DEV_DIR "
for i in 0 1 2 3 4 5 6 7; do
2012-03-16 16:59:02 +04:00
test -e " $DM_DEV_DIR /loop $i " || mknod " $DM_DEV_DIR /loop $i " b 7 $i
2011-01-05 03:16:18 +03:00
done
2012-03-16 16:59:02 +04:00
echo -n .
2011-01-05 03:16:18 +03:00
2012-03-16 16:59:02 +04:00
local LOOPFILE = " $PWD /test.img "
2015-03-26 17:01:54 +03:00
rm -f " $LOOPFILE "
dd if = /dev/zero of = " $LOOPFILE " bs = $(( 1024 * 1024 )) count = 0 seek = $(( $size + 1 )) 2> /dev/null
2012-03-16 16:59:02 +04:00
if LOOP = $( losetup -s -f " $LOOPFILE " 2>/dev/null) ; then
2011-01-05 03:16:18 +03:00
:
2012-03-16 16:59:02 +04:00
elif LOOP = $( losetup -f) && losetup " $LOOP " " $LOOPFILE " ; then
2011-01-05 03:16:18 +03:00
# no -s support
:
else
2012-03-16 16:59:02 +04:00
# no -f support
2011-01-05 03:16:18 +03:00
# 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
2012-03-16 16:59:02 +04:00
local dev = " $DM_DEV_DIR /loop $slash $i "
! losetup " $dev " >/dev/null 2>& 1 || continue
2011-01-05 03:16:18 +03:00
# got a free
losetup " $dev " " $LOOPFILE "
LOOP = $dev
break
done
2012-03-16 16:59:02 +04:00
test -z " $LOOP " || break
2011-01-05 03:16:18 +03:00
done
fi
test -n " $LOOP " # confirm or fail
2014-06-27 02:44:53 +04:00
BACKING_DEV = " $LOOP "
2012-03-16 16:59:02 +04:00
echo " $LOOP " > LOOP
2014-06-27 02:44:53 +04:00
echo " $LOOP " > BACKING_DEV
2012-03-16 16:59:02 +04:00
echo " ok ( $LOOP ) "
2011-01-05 03:16:18 +03:00
}
# A drop-in replacement for prepare_loop() that uses scsi_debug to create
# a ramdisk-based SCSI device upon which all LVM devices will be created
# - scripts must take care not to use a DEV_SIZE that will enduce OOM-killer
2012-03-16 16:59:02 +04:00
prepare_scsi_debug_dev( ) {
local DEV_SIZE = $1
local SCSI_DEBUG_PARAMS = ${ @ : 2 }
2015-04-07 15:56:16 +03:00
rm -f debug.log strace.log
2014-04-24 16:40:15 +04:00
test ! -f "SCSI_DEBUG_DEV" || return 0
2012-03-16 16:59:02 +04:00
test -z " $LOOP "
test -n " $DM_DEV_DIR "
# Skip test if scsi_debug module is unavailable or is already in use
modprobe --dry-run scsi_debug || skip
2014-04-24 16:40:15 +04:00
lsmod | not grep -q scsi_debug || skip
2012-03-16 16:59:02 +04:00
# Create the scsi_debug device and determine the new scsi device's name
# NOTE: it will _never_ make sense to pass num_tgts param;
# last param wins.. so num_tgts=1 is imposed
2015-04-07 15:56:16 +03:00
touch SCSI_DEBUG_DEV
2012-03-16 16:59:02 +04:00
modprobe scsi_debug dev_size_mb = $DEV_SIZE $SCSI_DEBUG_PARAMS num_tgts = 1 || skip
sleep 2 # allow for async Linux SCSI device registration
local DEBUG_DEV = " /dev/ $( grep -H scsi_debug /sys/block/*/device/model | cut -f4 -d /) "
test -b " $DEBUG_DEV " || return 1 # should not happen
# Create symlink to scsi_debug device in $DM_DEV_DIR
SCSI_DEBUG_DEV = " $DM_DEV_DIR / $( basename $DEBUG_DEV ) "
echo " $SCSI_DEBUG_DEV " > SCSI_DEBUG_DEV
2014-09-30 18:50:31 +04:00
echo " $SCSI_DEBUG_DEV " > BACKING_DEV
2012-03-16 16:59:02 +04:00
# Setting $LOOP provides means for prepare_devs() override
2014-09-30 18:50:31 +04:00
test " $DEBUG_DEV " = " $SCSI_DEBUG_DEV " || ln -snf " $DEBUG_DEV " " $SCSI_DEBUG_DEV "
2011-01-05 03:16:18 +03:00
}
2012-03-16 16:59:02 +04:00
cleanup_scsi_debug_dev( ) {
2012-03-16 23:08:09 +04:00
teardown_devs
2012-03-16 16:59:02 +04:00
rm -f SCSI_DEBUG_DEV LOOP
2011-01-05 03:16:18 +03:00
}
2014-06-27 02:44:53 +04:00
prepare_backing_dev( ) {
2015-04-03 15:22:29 +03:00
if test -f BACKING_DEV; then
2014-09-30 18:50:31 +04:00
BACKING_DEV = $( < BACKING_DEV)
elif test -b " $LVM_TEST_BACKING_DEVICE " ; then
2014-06-27 02:44:53 +04:00
BACKING_DEV = " $LVM_TEST_BACKING_DEVICE "
echo " $BACKING_DEV " > BACKING_DEV
else
prepare_loop " $@ "
fi
}
2011-01-05 03:16:18 +03:00
prepare_devs( ) {
2012-03-16 16:59:02 +04:00
local n = ${ 1 :- 3 }
local devsize = ${ 2 :- 34 }
local pvname = ${ 3 :- pv }
2015-03-26 17:01:54 +03:00
local shift = 0
2011-01-05 03:16:18 +03:00
2014-06-27 02:44:53 +04:00
prepare_backing_dev $(( $n * $devsize ))
2015-03-26 17:01:54 +03:00
# shift start of PV devices on /dev/loopXX by 1M
not diff LOOP BACKING_DEV >/dev/null 2>& 1 || shift = 2048
2012-03-16 16:59:02 +04:00
echo -n " ## preparing $n devices... "
2011-01-05 03:16:18 +03:00
2014-06-27 02:44:53 +04:00
local size = $(( $devsize * 2048 )) # sectors
2014-06-04 15:46:19 +04:00
local count = 0
2011-01-05 03:16:18 +03:00
init_udev_transaction
2012-03-16 16:59:02 +04:00
for i in $( seq 1 $n ) ; do
2011-01-05 03:16:18 +03:00
local name = " ${ PREFIX } $pvname $i "
local dev = " $DM_DEV_DIR /mapper/ $name "
2014-06-04 15:46:19 +04:00
DEVICES[ $count ] = $dev
count = $(( $count + 1 ))
2015-03-26 17:01:54 +03:00
echo 0 $size linear " $BACKING_DEV " $(( ( $i - 1 ) * $size + $shift )) > " $name .table "
2014-09-30 18:19:14 +04:00
if not dmsetup create -u " TEST- $name " " $name " " $name .table " &&
test -n " $LVM_TEST_BACKING_DEVICE " ;
then # maybe the backing device is too small for this test
LVM_TEST_BACKING_DEVICE =
2014-09-30 18:50:31 +04:00
rm -f BACKING_DEV
2014-09-30 18:19:14 +04:00
prepare_devs " $@ "
return $?
fi
2011-01-05 03:16:18 +03:00
done
finish_udev_transaction
2014-06-27 02:44:53 +04:00
# non-ephemeral devices need to be cleared between tests
test -f LOOP || for d in ${ DEVICES [@] } ; do
2015-02-12 15:30:39 +03:00
dd if = /dev/zero of = $d bs = 64K count = 1
2014-06-27 02:44:53 +04:00
done
2011-01-05 03:16:18 +03:00
#for i in `seq 1 $n`; do
# local name="${PREFIX}$pvname$i"
# dmsetup info -c $name
#done
#for i in `seq 1 $n`; do
# local name="${PREFIX}$pvname$i"
# dmsetup table $name
#done
2014-06-04 15:46:19 +04:00
printf "%s\n" " ${ DEVICES [@] } " > DEVICES
# ( IFS=$'\n'; echo "${DEVICES[*]}" ) >DEVICES
2012-03-16 16:59:02 +04:00
echo "ok"
2015-03-26 17:01:54 +03:00
for dev in " ${ DEVICES [@] } " ; do
notify_lvmetad " $dev "
done
2011-01-05 03:16:18 +03:00
}
2015-04-03 15:22:29 +03:00
common_dev_( ) {
local tgtype = $1
local name = ${ 2 ##*/ }
local offsets
local read_ms
local write_ms
case " $tgtype " in
delay)
read_ms = ${ 3 :- 0 }
write_ms = ${ 4 :- 0 }
offsets = ${ @ : 5 }
if test " $read_ms " -eq 0 -a " $write_ms " -eq 0 ; then
offsets =
else
2015-04-03 17:38:05 +03:00
test -z " ${ offsets [@] } " && offsets = "0:"
2015-04-03 15:22:29 +03:00
fi ; ;
error) offsets = ${ @ : 3 }
2015-04-03 17:38:05 +03:00
test -z " ${ offsets [@] } " && offsets = "0:" ; ;
2015-04-03 15:22:29 +03:00
esac
2013-08-30 16:50:58 +04:00
local pos
local size
local type
local pvdev
local offset
read pos size type pvdev offset < " $name .table "
2015-04-03 15:22:29 +03:00
for fromlen in ${ offsets [@] } ; do
from = ${ fromlen %% : * }
len = ${ fromlen ##* : }
test -n " $len " || len = $(( $size - $from ))
diff = $(( $from - $pos ))
if test $diff -gt 0 ; then
echo " $pos $diff $type $pvdev $(( $pos + $offset )) "
pos = $(( $pos + $diff ))
elif test $diff -lt 0 ; then
die "Position error"
fi
case " $tgtype " in
delay)
echo " $from $len delay $pvdev $(( $pos + $offset )) $read_ms $pvdev $(( $pos + $offset )) $write_ms " ; ;
error)
echo " $from $len error " ; ;
esac
pos = $(( $pos + $len ))
done > " $name .devtable "
diff = $(( $size - $pos ))
test " $diff " -gt 0 && echo " $pos $diff $type $pvdev $(( $pos + $offset )) " >>" $name .devtable "
2013-08-30 16:50:58 +04:00
init_udev_transaction
2015-04-03 15:22:29 +03:00
dmsetup load " $name " " $name .devtable "
2015-04-03 20:35:18 +03:00
# TODO: add support for resume without udev rescan
2013-08-30 16:50:58 +04:00
dmsetup resume " $name "
finish_udev_transaction
}
2015-04-03 15:22:29 +03:00
# Replace linear PV device with its 'delayed' version
# Could be used to more deterministicaly hit some problems.
# Parameters: {device path} [read delay ms] [write delay ms] [offset:size]...
# Original device is restored when both delay params are 0 (or missing).
# If the size is missing, the remaing portion of device is taken
# i.e. delay_dev "$dev1" 0 200 256:
delay_dev( ) {
target_at_least dm-delay 1 2 0 || skip
common_dev_ delay " $@ "
}
2011-01-05 03:16:18 +03:00
disable_dev( ) {
2012-03-20 14:51:57 +04:00
local dev
2014-05-26 16:37:45 +04:00
local silent
local error
local notify
while test -n " $1 " ; do
if test " $1 " = "--silent" ; then
silent = 1
shift
elif test " $1 " = "--error" ; then
error = 1
shift
else
break
fi
done
2012-03-20 14:51:57 +04:00
2013-08-14 17:57:52 +04:00
udev_wait
2011-01-05 03:16:18 +03:00
for dev in " $@ " ; do
2014-02-28 14:07:56 +04:00
maj = $(( $( stat -L --printf= 0x%t " $dev " ) ))
min = $(( $( stat -L --printf= 0x%T " $dev " ) ))
2012-03-16 16:59:02 +04:00
echo " Disabling device $dev ( $maj : $min ) "
2014-05-26 16:37:45 +04:00
notify = " $notify $maj : $min "
if test -n " $error " ; then
2015-04-08 23:43:52 +03:00
echo 0 10000000 error | dmsetup load " $dev "
dmsetup resume " $dev "
2014-05-26 16:37:45 +04:00
else
dmsetup remove -f " $dev " 2>/dev/null || true
fi
done
test -n " $silent " || for num in $notify ; do
notify_lvmetad --major $( echo $num | sed -e "s,:.*,," ) \
--minor $( echo $num | sed -e "s,.*:,," )
2014-05-21 13:40:34 +04:00
done
2011-01-05 03:16:18 +03:00
}
enable_dev( ) {
2012-03-20 14:51:57 +04:00
local dev
2014-05-26 16:37:45 +04:00
local silent
if test " $1 " = "--silent" ; then
silent = 1
shift
fi
2012-03-20 14:51:57 +04:00
2014-09-30 19:09:26 +04:00
rm -f debug.log strace.log
2011-01-05 03:16:18 +03:00
init_udev_transaction
for dev in " $@ " ; do
2012-03-16 16:59:02 +04:00
local name = $( echo " $dev " | sed -e 's,.*/,,' )
2013-12-17 16:55:19 +04:00
dmsetup create -u " TEST- $name " " $name " " $name .table " 2>/dev/null || \
2012-03-16 16:59:02 +04:00
dmsetup load " $name " " $name .table "
2011-10-23 19:43:10 +04:00
# using device name (since device path does not exists yes with udev)
2012-03-16 16:59:02 +04:00
dmsetup resume " $name "
2011-01-05 03:16:18 +03:00
done
finish_udev_transaction
2014-05-21 13:40:34 +04:00
2014-05-26 16:37:45 +04:00
test -n " $silent " || for dev in " $@ " ; do
2014-05-21 13:40:34 +04:00
notify_lvmetad " $dev "
done
2011-01-05 03:16:18 +03:00
}
2012-12-01 20:09:18 +04:00
#
# Convert device to device with errors
# Takes the list of pairs of error segment from:len
# Original device table is replace with multiple lines
# i.e. error_dev "$dev1" 8:32 96:8
error_dev( ) {
2015-04-03 15:22:29 +03:00
common_dev_ error " $@ "
2012-12-01 20:09:18 +04:00
}
2011-01-05 03:16:18 +03:00
backup_dev( ) {
2012-03-20 14:51:57 +04:00
local dev
2011-01-05 03:16:18 +03:00
for dev in " $@ " ; do
2012-03-16 16:59:02 +04:00
dd if = " $dev " of = " $dev .backup " bs = 1024
2011-01-05 03:16:18 +03:00
done
}
restore_dev( ) {
2012-03-20 14:51:57 +04:00
local dev
2011-01-05 03:16:18 +03:00
for dev in " $@ " ; do
2012-03-16 16:59:02 +04:00
test -e " $dev .backup " || \
die " Internal error: $dev not backed up, can't restore! "
dd of = " $dev " if = " $dev .backup " bs = 1024
2011-01-05 03:16:18 +03:00
done
}
prepare_pvs( ) {
prepare_devs " $@ "
2014-06-04 15:46:19 +04:00
pvcreate -ff " ${ DEVICES [@] } "
2011-01-05 03:16:18 +03:00
}
prepare_vg( ) {
teardown_devs
2015-03-06 15:29:35 +03:00
prepare_devs " $@ "
2014-06-04 15:46:19 +04:00
vgcreate -s 512K $vg " ${ DEVICES [@] } "
2011-01-05 03:16:18 +03:00
}
2013-05-27 04:03:00 +04:00
extend_filter( ) {
filter = $( grep ^devices/global_filter CONFIG_VALUES | tail -n 1)
for rx in " $@ " ; do
filter = $( echo $filter | sed -e " s:\[:[ \" $rx \", : " )
done
lvmconf " $filter "
}
extend_filter_LVMTEST( ) {
extend_filter " a| $DM_DEV_DIR /LVMTEST| "
}
2013-04-29 00:41:15 +04:00
hide_dev( ) {
filter = $( grep ^devices/global_filter CONFIG_VALUES | tail -n 1)
for dev in $@ ; do
filter = $( echo $filter | sed -e " s:\[:[ \"r| $dev |\", : " )
done
lvmconf " $filter "
}
unhide_dev( ) {
filter = $( grep ^devices/global_filter CONFIG_VALUES | tail -n 1)
for dev in $@ ; do
filter = $( echo $filter | sed -e " s:\"r| $dev |\", :: " )
done
lvmconf " $filter "
}
2013-09-16 13:02:58 +04:00
mkdev_md5sum( ) {
2014-09-30 19:09:26 +04:00
rm -f debug.log strace.log
2013-09-16 13:02:58 +04:00
mkfs.ext2 " $DM_DEV_DIR / $1 / $2 " || return 1
md5sum " $DM_DEV_DIR / $1 / $2 " > " md5. $1 - $2 "
}
2013-07-30 17:44:15 +04:00
generate_config( ) {
if test -n " $profile_name " ; then
config_values = PROFILE_VALUES_$profile_name
config = PROFILE_$profile_name
touch $config_values
else
config_values = CONFIG_VALUES
config = CONFIG
fi
2012-03-16 16:59:02 +04:00
LVM_TEST_LOCKING = ${ LVM_TEST_LOCKING :- 1 }
if test " $DM_DEV_DIR " = "/dev" ; then
LVM_VERIFY_UDEV = ${ LVM_VERIFY_UDEV :- 0 }
else
LVM_VERIFY_UDEV = ${ LVM_VERIFY_UDEV :- 1 }
fi
2014-06-30 23:00:08 +04:00
test -f " $config_values " || {
cat > " $config_values " <<-EOF
2011-01-05 03:16:18 +03:00
devices/dir = " $DM_DEV_DIR "
devices/scan = " $DM_DEV_DIR "
2013-05-27 02:53:03 +04:00
devices/filter = "a|.*|"
2014-02-22 03:24:46 +04:00
devices/global_filter = [ " a| $DM_DEV_DIR /mapper/.*pv[0-9_]* $| " , "r|.*|" ]
2011-01-05 03:16:18 +03:00
devices/cache_dir = " $TESTDIR /etc "
2015-04-21 14:27:40 +03:00
devices/sysfs_scan = 1
2011-01-05 03:16:18 +03:00
devices/default_data_alignment = 1
2012-03-16 16:57:28 +04:00
devices/md_component_detection = 0
2011-01-05 03:16:18 +03:00
log/syslog = 0
log/indent = 1
log/level = 9
log/file = " $TESTDIR /debug.log "
log/overwrite = 1
log/activation = 1
2012-03-16 16:59:02 +04:00
log/verbose = 0
activation/retry_deactivation = 1
2011-01-05 03:16:18 +03:00
backup/backup = 0
backup/archive = 0
global/abort_on_internal_errors = 1
2011-08-11 21:46:13 +04:00
global/detect_internal_vg_cache_corruption = 1
2011-01-05 03:16:18 +03:00
global/library_dir = " $TESTDIR /lib "
global/locking_dir = " $TESTDIR /var/lock/lvm "
global/locking_type= $LVM_TEST_LOCKING
global/si_unit_consistency = 1
global/fallback_to_local_locking = 0
2015-04-14 11:08:57 +03:00
global/cache_check_executable = " $LVM_TEST_CACHE_CHECK_CMD "
global/cache_dump_executable = " $LVM_TEST_CACHE_DUMP_CMD "
global/cache_repair_executable = " $LVM_TEST_CACHE_REPAIR_CMD "
global/thin_check_executable = " $LVM_TEST_THIN_CHECK_CMD "
global/thin_dump_executable = " $LVM_TEST_THIN_DUMP_CMD "
global/thin_repair_executable = " $LVM_TEST_THIN_REPAIR_CMD "
2011-07-01 18:09:19 +04:00
activation/checks = 1
2011-01-05 03:16:18 +03:00
activation/udev_sync = 1
2011-06-28 04:38:26 +04:00
activation/udev_rules = 1
2011-09-25 01:15:13 +04:00
activation/verify_udev_operations = $LVM_VERIFY_UDEV
2011-01-05 03:16:18 +03:00
activation/polling_interval = 0
activation/snapshot_autoextend_percent = 50
activation/snapshot_autoextend_threshold = 50
2011-01-07 16:04:17 +03:00
activation/monitoring = 0
2013-12-09 13:35:47 +04:00
allocation/wipe_signatures_when_zeroing_new_lvs = 0
2011-01-05 03:16:18 +03:00
EOF
2012-03-16 16:59:02 +04:00
}
2012-03-20 14:51:57 +04:00
local v
2012-03-16 16:59:02 +04:00
for v in " $@ " ; do
2014-06-30 23:00:08 +04:00
echo " $v "
done >> " $config_values "
2012-03-16 16:59:02 +04:00
2012-03-20 14:51:57 +04:00
local s
2014-06-30 23:00:08 +04:00
for s in $( cut -f1 -d/ " $config_values " | sort | uniq) ; do
echo " $s { "
2012-03-20 14:51:57 +04:00
local k
2014-06-30 23:00:08 +04:00
for k in $( grep ^" $s " / " $config_values " | cut -f1 -d= | sed -e 's, *$,,' | sort | uniq) ; do
grep " ^ $k " " $config_values " | tail -n 1 | sed -e " s,^ $s /, , "
2012-03-16 16:59:02 +04:00
done
2014-06-30 23:00:08 +04:00
echo "}"
echo
2015-04-13 17:30:17 +03:00
done | tee " $config " | sed -e "s,^,## LVMCONF: ,"
2013-07-30 17:44:15 +04:00
}
lvmconf( ) {
unset profile_name
generate_config " $@ "
2012-03-20 14:51:57 +04:00
mv -f CONFIG etc/lvm.conf
2011-01-05 03:16:18 +03:00
}
2013-07-30 17:44:15 +04:00
profileconf( ) {
profile_name = " $1 "
shift
generate_config " $@ "
test -d etc/profile || mkdir etc/profile
2014-06-30 23:00:08 +04:00
mv -f " PROFILE_ $profile_name " " etc/profile/ $profile_name .profile "
2013-07-30 17:44:15 +04:00
}
2014-04-01 17:51:46 +04:00
prepare_profiles( ) {
test -d etc/profile || mkdir etc/profile
for profile_name in $@ ; do
test -L " $abs_top_builddir /test/lib/ $profile_name .profile " || skip
cp " $abs_top_builddir /test/lib/ $profile_name .profile " " etc/profile/ $profile_name .profile "
done
}
2011-01-05 03:16:18 +03:00
apitest( ) {
2012-03-20 14:51:57 +04:00
local t = $1
2012-03-16 16:59:02 +04:00
shift
test -x " $abs_top_builddir /test/api/ $t .t " || skip
2014-09-30 19:09:26 +04:00
" $abs_top_builddir /test/api/ $t .t " " $@ " && rm -f debug.log strace.log
2011-01-05 03:16:18 +03:00
}
api( ) {
2012-03-16 16:59:02 +04:00
test -x " $abs_top_builddir /test/api/wrapper " || skip
2014-09-30 19:09:26 +04:00
" $abs_top_builddir /test/api/wrapper " " $@ " && rm -f debug.log strace.log
2011-01-05 03:16:18 +03:00
}
2014-03-17 19:32:42 +04:00
mirror_recovery_works( ) {
2014-06-30 23:00:08 +04:00
case " $( uname -r) " in
2014-03-17 19:32:42 +04:00
3.3.4-5.fc17.i686| 3.3.4-5.fc17.x86_64) return 1 ; ;
esac
2013-09-03 17:49:14 +04:00
}
2014-03-02 22:46:17 +04:00
raid456_replace_works( ) {
2013-09-20 20:33:29 +04:00
# The way kmem_cache aliasing is done in the kernel is broken.
# It causes RAID 4/5/6 tests to fail.
#
# The problem with kmem_cache* is this:
# *) Assume CONFIG_SLUB is set
# 1) kmem_cache_create(name="foo-a")
# - creates new kmem_cache structure
# 2) kmem_cache_create(name="foo-b")
# - If identical cache characteristics, it will be merged with the previously
# created cache associated with "foo-a". The cache's refcount will be
# incremented and an alias will be created via sysfs_slab_alias().
# 3) kmem_cache_destroy(<ptr>)
# - Attempting to destroy cache associated with "foo-a", but instead the
# refcount is simply decremented. I don't even think the sysfs aliases are
# ever removed...
# 4) kmem_cache_create(name="foo-a")
# - This FAILS because kmem_cache_sanity_check colides with the existing
# name ("foo-a") associated with the non-removed cache.
#
# This is a problem for RAID (specifically dm-raid) because the name used
# for the kmem_cache_create is ("raid%d-%p", level, mddev). If the cache
# persists for long enough, the memory address of an old mddev will be
# reused for a new mddev - causing an identical formulation of the cache
# name. Even though kmem_cache_destory had long ago been used to delete
# the old cache, the merging of caches has cause the name and cache of that
# old instance to be preserved and causes a colision (and thus failure) in
# kmem_cache_create(). I see this regularly in testing the following
# kernels:
2014-03-09 01:38:06 +04:00
#
# This seems to be finaly resolved with this patch:
# http://www.redhat.com/archives/dm-devel/2014-March/msg00008.html
# so we need to put here exlusion for kernes which do trace SLUB
#
2014-06-30 23:00:08 +04:00
case " $( uname -r) " in
2014-03-17 21:38:59 +04:00
3.6.*.fc18.i686*| 3.6.*.fc18.x86_64) return 1 ; ;
3.9.*.fc19.i686*| 3.9.*.fc19.x86_64) return 1 ; ;
2014-03-17 02:46:43 +04:00
3.1[ 0123] .*.fc18.i686*| 3.1[ 0123] .*.fc18.x86_64) return 1 ; ;
2014-05-26 17:58:09 +04:00
3.1[ 01234] .*.fc19.i686*| 3.1[ 01234] .*.fc19.x86_64) return 1 ; ;
2014-11-17 02:32:49 +03:00
3.1[ 123] .*.fc20.i686*| 3.1[ 123] .*.fc20.x86_64) return 1 ; ;
2014-03-25 23:13:25 +04:00
3.14.*.fc21.i686*| 3.14.*.fc21.x86_64) return 1 ; ;
2014-05-24 00:40:31 +04:00
3.15.*rc6*.fc21.i686*| 3.15.*rc6*.fc21.x86_64) return 1 ; ;
2014-07-23 02:29:32 +04:00
3.16.*rc4*.fc21.i686*| 3.16.*rc4*.fc21.x86_64) return 1 ; ;
2014-03-02 22:46:17 +04:00
esac
2013-09-20 20:33:29 +04:00
}
2011-01-28 19:10:21 +03:00
udev_wait( ) {
2011-03-02 02:44:07 +03:00
pgrep udev >/dev/null || return 0
2014-02-03 21:26:55 +04:00
which udevadm & >/dev/null || return 0
2011-01-28 19:10:21 +03:00
if test -n " $1 " ; then
2012-03-20 14:51:57 +04:00
udevadm settle --exit-if-exists= " $1 " || true
2011-01-28 19:10:21 +03:00
else
2012-03-20 14:51:57 +04:00
udevadm settle --timeout= 15 || true
2011-01-28 19:10:21 +03:00
fi
}
2012-07-24 23:17:54 +04:00
# wait_for_sync <VG/LV>
wait_for_sync( ) {
local i
2014-11-17 02:34:44 +03:00
for i in { 1..100} ; do
2012-07-24 23:17:54 +04:00
check in_sync $1 $2 && return
sleep .2
done
echo "Sync is taking too long - assume stuck"
return 1
}
2013-11-16 02:47:14 +04:00
# Check if tests are running on 64bit architecture
2014-03-21 14:38:20 +04:00
can_use_16T( ) {
2013-11-16 02:47:14 +04:00
test " $( getconf LONG_BIT) " -eq 64
}
2014-11-17 02:41:33 +03:00
# Check if major.minor.revision' string is 'at_least'
version_at_least( ) {
local major
local minor
local revision
IFS = . read -r major minor revision <<< " $1 "
shift
test -z " $1 " && return 0
test -n " $major " || return 1
test " $major " -gt " $1 " && return 0
test " $major " -eq " $1 " || return 1
test -z " $2 " && return 0
test -n " $minor " || return 1
test " $minor " -gt " $2 " && return 0
test " $minor " -eq " $2 " || return 1
test -z " $3 " && return 0
test " $revision " -ge " $3 " 2>/dev/null || return 1
}
2011-11-10 16:44:00 +04:00
#
# Check wheter kernel [dm module] target exist
# at least in expected version
#
# [dm-]target-name major minor revision
#
# i.e. dm_target_at_least dm-thin-pool 1 0
2014-03-21 14:38:20 +04:00
target_at_least( ) {
2014-09-30 19:09:26 +04:00
rm -f debug.log strace.log
2011-11-10 16:44:00 +04:00
case " $1 " in
2012-10-09 12:37:37 +04:00
dm-*) modprobe " $1 " || true ; ;
2011-11-10 16:44:00 +04:00
esac
2013-11-19 14:47:28 +04:00
if test " $1 " = dm-raid; then
case " $( uname -r) " in
3.12.0*) return 1 ; ;
esac
fi
2012-03-20 14:51:57 +04:00
local version = $( dmsetup targets 2>/dev/null | grep " ${ 1 ##dm- } " 2>/dev/null)
2011-11-10 16:44:00 +04:00
version = ${ version ##* v }
shift
2014-11-17 02:41:33 +03:00
version_at_least " $version " " $@ "
2011-11-10 16:44:00 +04:00
}
2014-03-21 14:38:20 +04:00
have_thin( ) {
2014-05-20 21:54:48 +04:00
test " $THIN " = shared -o " $THIN " = internal || return 1
target_at_least dm-thin-pool " $@ " || return 1
2012-10-10 16:57:02 +04:00
2015-04-15 12:51:00 +03:00
declare -a CONF
2012-10-15 15:18:32 +04:00
# disable thin_check if not present in system
2015-04-15 12:51:00 +03:00
if test -n " $LVM_TEST_THIN_CHECK_CMD " -a ! -x " $LVM_TEST_THIN_CHECK_CMD " ; then
CONF[ 0] = "global/thin_check_executable = \"\""
fi
if test -n " $LVM_TEST_THIN_DUMP_CMD " -a ! -x " $LVM_TEST_THIN_DUMP_CMD " ; then
CONF[ 1] = "global/thin_dump_executable = \"\""
fi
if test -n " $LVM_TEST_THIN_REPAIR_CMD " -a ! -x " $LVM_TEST_THIN_REPAIR_CMD " ; then
CONF[ 2] = "global/thin_repair_executable = \"\""
fi
if test ${# CONF [@] } -ne 0 ; then
echo " TEST WARNING: Reconfiguring ${ CONF [@] } "
lvmconf " ${ CONF [@] } "
fi
2012-10-15 15:18:32 +04:00
}
2014-05-20 21:54:48 +04:00
have_raid( ) {
test " $RAID " = shared -o " $RAID " = internal || return 1
target_at_least dm-raid " $@ "
}
have_cache( ) {
test " $CACHE " = shared -o " $CACHE " = internal || return 1
target_at_least dm-cache " $@ "
2014-11-17 02:41:33 +03:00
2015-04-15 12:51:00 +03:00
declare -a CONF
2015-04-14 11:08:57 +03:00
# disable cache_check if not present in system
2015-04-15 12:51:00 +03:00
if test -n " $LVM_TEST_CACHE_CHECK_CMD " -a ! -x " $LVM_TEST_CACHE_CHECK_CMD " ; then
CONF[ 0] = "global/cache_check_executable = \"\""
fi
if test -n " $LVM_TEST_CACHE_DUMP_CMD " -a ! -x " $LVM_TEST_CACHE_DUMP_CMD " ; then
CONF[ 1] = "global/cache_dump_executable = \"\""
fi
if test -n " $LVM_TEST_CACHE_REPAIR_CMD " -a ! -x " $LVM_TEST_CACHE_REPAIR_CMD " ; then
CONF[ 2] = "global/cache_repair_executable = \"\""
fi
if test ${# CONF [@] } -ne 0 ; then
echo " TEST WARNING: Reconfiguring ${ CONF [@] } "
lvmconf " ${ CONF [@] } "
fi
2014-11-17 02:41:33 +03:00
}
have_tool_at_least( ) {
local version = $( $1 -V 2>/dev/null)
version = ${ version %%-* }
shift
version_at_least " $version " " $@ "
2014-05-20 21:54:48 +04:00
}
2012-10-15 15:18:32 +04:00
# check if lvm shell is build-in (needs readline)
2014-03-21 14:38:20 +04:00
have_readline( ) {
2012-10-15 15:18:32 +04:00
echo version | lvm & >/dev/null
2012-10-10 02:20:22 +04:00
}
2014-03-21 14:38:20 +04:00
dmsetup_wrapped( ) {
2014-03-02 23:11:44 +04:00
udev_wait
dmsetup " $@ "
}
2015-03-27 16:24:16 +03:00
wait_pvmove_lv_ready( ) {
# given sleep .1 this is about 60 secs of waiting
2015-04-03 20:35:18 +03:00
local retries = ${ 2 :- 300 }
2015-03-27 16:24:16 +03:00
while : ; do
test $retries -le 0 && die "Waiting for pvmove LV to get activated has timed out"
2015-04-03 15:38:22 +03:00
dmsetup info -c -o tables_loaded $1 > out 2>/dev/null|| true;
not grep Live out >/dev/null || break
2015-03-27 16:24:16 +03:00
sleep .1
retries = $(( retries-1))
done
}
2015-03-26 17:01:54 +03:00
test -z " $LVM_TEST_AUX_TRACE " || set -x
2014-06-30 23:00:08 +04:00
test -f DEVICES && devs = $( < DEVICES)
2011-01-05 03:16:18 +03:00
2014-03-02 23:11:44 +04:00
if test " $1 " = dmsetup; then
shift
dmsetup_wrapped " $@ "
else
" $@ "
fi