mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Update testing scripts
Make the teardown really usable - it will try down to remove all the left devices even from previous test runs (the only missing piece is probably proper mdadm teardown) Add few more local vars Try to setup PATH and LD_LIBRARY_PATH just once. Try shorter sleeps.
This commit is contained in:
parent
758f674240
commit
ef199faeda
173
test/lib/aux.sh
173
test/lib/aux.sh
@ -12,7 +12,7 @@
|
|||||||
. lib/utils
|
. lib/utils
|
||||||
|
|
||||||
run_valgrind() {
|
run_valgrind() {
|
||||||
# Execute script which may use $TESTNAME for creating individal
|
# Execute script which may use $TESTNAME for creating individual
|
||||||
# log files for each execute command
|
# log files for each execute command
|
||||||
exec "${VALGRIND:-valg}" "$@"
|
exec "${VALGRIND:-valg}" "$@"
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ prepare_dmeventd() {
|
|||||||
echo $! > LOCAL_DMEVENTD
|
echo $! > LOCAL_DMEVENTD
|
||||||
|
|
||||||
# FIXME wait for pipe in /var/run instead
|
# FIXME wait for pipe in /var/run instead
|
||||||
sleep 1
|
sleep .3
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_lvmetad() {
|
prepare_lvmetad() {
|
||||||
@ -73,7 +73,7 @@ prepare_lvmetad() {
|
|||||||
lvmetad -f "$@" -s "$TESTDIR/lvmetad.socket" &
|
lvmetad -f "$@" -s "$TESTDIR/lvmetad.socket" &
|
||||||
echo $! > LOCAL_LVMETAD
|
echo $! > LOCAL_LVMETAD
|
||||||
|
|
||||||
sleep 1
|
sleep .3
|
||||||
}
|
}
|
||||||
|
|
||||||
notify_lvmetad() {
|
notify_lvmetad() {
|
||||||
@ -82,37 +82,63 @@ notify_lvmetad() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
teardown_devs() {
|
teardown_devs_prefixed() {
|
||||||
vgremove -ff $vg $vg1 $vg2 $vg3 $vg4 &>/dev/null || rm -f debug.log
|
local prefix=$1
|
||||||
|
local stray=${2:-0}
|
||||||
|
local IFS=$IFS_NL
|
||||||
|
local dm
|
||||||
|
|
||||||
|
# Resume suspended devices first
|
||||||
|
for dm in $(dmsetup info -c -o suspended,name --noheadings | grep "^Suspended:.*$prefix"); do
|
||||||
|
echo "dmsetup resume \"${dm#Suspended:}\""
|
||||||
|
dmsetup resume "${dm#Suspended:}" || true
|
||||||
|
done
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
if test "$stray" -eq 0; then
|
||||||
|
dmsetup table | not egrep -q "$vg|$vg1|$vg2|$vg3|$vg4" || \
|
||||||
|
vgremove -ff $vg $vg1 $vg2 $vg3 $vg4 &>/dev/null || rm -f debug.log
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove devices, start with closed (sorted by open count)
|
||||||
|
local remfail=no
|
||||||
|
local need_udev_wait=0
|
||||||
|
init_udev_transaction
|
||||||
|
for dm in $(dmsetup info -c -o name --sort open --noheadings | grep "$prefix"); do
|
||||||
|
dmsetup remove "$dm" &>/dev/null || remfail=yes
|
||||||
|
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
|
||||||
|
while num_devs=$(dmsetup table | grep "$prefix" | wc -l) && \
|
||||||
|
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: "
|
||||||
|
for dm in $(dmsetup info -c -o name --sort open --noheadings | grep "$prefix") ; do
|
||||||
|
dmsetup remove -f "$dm" || true
|
||||||
|
done
|
||||||
|
num_remaining_devs=$num_devs
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown_devs() {
|
||||||
# Delete any remaining dm/udev semaphores
|
# Delete any remaining dm/udev semaphores
|
||||||
teardown_udev_cookies
|
teardown_udev_cookies
|
||||||
|
|
||||||
test -z "$PREFIX" || {
|
test -z "$PREFIX" || {
|
||||||
rm -rf "$TESTDIR/dev/$PREFIX"*
|
rm -rf "$TESTDIR/dev/$PREFIX"*
|
||||||
|
teardown_devs_prefixed "$PREFIX"
|
||||||
# Try unmount opened devices first
|
|
||||||
for s in $(dmsetup info -c -o open,name --sort -open --noheading | grep "$PREFIX"); do
|
|
||||||
test "${s%%:*}" -gt 0 || break
|
|
||||||
umount -fl "$DM_DEV_DIR/mapper/${s#[0..9]*:}" &>/dev/null || true
|
|
||||||
done
|
|
||||||
|
|
||||||
# Remove devices, start with closed (sorted by open count)
|
|
||||||
init_udev_transaction
|
|
||||||
for s in $(dmsetup info -c -o name --sort open --noheading | grep "$PREFIX"); do
|
|
||||||
dmsetup remove "$s" &>/dev/null || true
|
|
||||||
done
|
|
||||||
finish_udev_transaction
|
|
||||||
udev_wait
|
|
||||||
|
|
||||||
# Brute force, and without udev transaction
|
|
||||||
while dmsetup table | grep -q "$PREFIX"; do
|
|
||||||
for s in $(dmsetup info -c -o name --sort open --noheading | grep "$PREFIX"); do
|
|
||||||
umount -fl "$DM_DEV_DIR/mapper/$s" &>/dev/null || true
|
|
||||||
dmsetup remove -f "$s" &>/dev/null || true
|
|
||||||
done
|
|
||||||
udev_wait
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# NOTE: SCSI_DEBUG_DEV test must come before the LOOP test because
|
# NOTE: SCSI_DEBUG_DEV test must come before the LOOP test because
|
||||||
@ -120,7 +146,7 @@ teardown_devs() {
|
|||||||
if test -f SCSI_DEBUG_DEV; then
|
if test -f SCSI_DEBUG_DEV; then
|
||||||
modprobe -r scsi_debug
|
modprobe -r scsi_debug
|
||||||
else
|
else
|
||||||
test ! -f LOOP || losetup -d $(cat LOOP)
|
test ! -f LOOP || losetup -d $(cat LOOP) || true
|
||||||
test ! -f LOOPFILE || rm -f $(cat LOOPFILE)
|
test ! -f LOOPFILE || rm -f $(cat LOOPFILE)
|
||||||
fi
|
fi
|
||||||
rm -f DEVICES # devs is set in prepare_devs()
|
rm -f DEVICES # devs is set in prepare_devs()
|
||||||
@ -128,44 +154,12 @@ teardown_devs() {
|
|||||||
|
|
||||||
# Attempt to remove any loop devices that failed to get torn down if earlier tests aborted
|
# Attempt to remove any loop devices that failed to get torn down if earlier tests aborted
|
||||||
test -z "$COMMON_PREFIX" || {
|
test -z "$COMMON_PREFIX" || {
|
||||||
# Resume any linears to be sure we do not deadlock
|
teardown_devs_prefixed "$COMMON_PREFIX" 1
|
||||||
STRAY_DEVS=$(dmsetup table | sed 's/:.*//' | grep "$COMMON_PREFIX" | cut -d' ' -f 1)
|
local stray_loops=( $(losetup -a | grep "$COMMON_PREFIX" | cut -d: -f1) )
|
||||||
for dm in $STRAY_DEVS ; do
|
test ${#stray_loops[@]} -eq 0 || {
|
||||||
# FIXME: only those really suspended
|
echo "Removing stray loop devices containing $COMMON_PREFIX: ${stray_loops[@]}"
|
||||||
echo "dmsetup resume \"$dm\""
|
losetup -d "${stray_loops[@]}"
|
||||||
dmsetup resume "$dm" || true
|
}
|
||||||
done
|
|
||||||
|
|
||||||
STRAY_MOUNTS=$(mount | grep "$COMMON_PREFIX" | cut -d' ' -f1)
|
|
||||||
if test -n "$STRAY_MOUNTS"; then
|
|
||||||
echo "Removing stray mounted devices containing $COMMON_PREFIX:"
|
|
||||||
mount | grep "$COMMON_PREFIX"
|
|
||||||
umount -fl "$STRAY_MOUNTS" || true
|
|
||||||
udev_wait
|
|
||||||
fi
|
|
||||||
|
|
||||||
init_udev_transaction
|
|
||||||
NUM_REMAINING_DEVS=999
|
|
||||||
while NUM_DEVS=$(dmsetup table | grep "^$COMMON_PREFIX" | wc -l) && \
|
|
||||||
test $NUM_DEVS -lt $NUM_REMAINING_DEVS -a $NUM_DEVS -ne 0; do
|
|
||||||
echo "Removing $NUM_DEVS stray mapped devices with names beginning with $COMMON_PREFIX:"
|
|
||||||
STRAY_DEVS=$(dmsetup table | sed 's/:.*//' | grep "$COMMON_PREFIX" | cut -d' ' -f 1)
|
|
||||||
dmsetup info -c | grep "^$COMMON_PREFIX"
|
|
||||||
for dm in $STRAY_DEVS ; do
|
|
||||||
echo "dmsetup remove -f \"$dm\""
|
|
||||||
dmsetup remove -f "$dm" || true
|
|
||||||
done
|
|
||||||
NUM_REMAINING_DEVS=$NUM_DEVS
|
|
||||||
done
|
|
||||||
finish_udev_transaction
|
|
||||||
udev_wait
|
|
||||||
|
|
||||||
STRAY_LOOPS=$(losetup -a | grep "$COMMON_PREFIX" | cut -d: -f1)
|
|
||||||
if test -n "$STRAY_LOOPS"; then
|
|
||||||
echo "Removing stray loop devices containing $COMMON_PREFIX:"
|
|
||||||
losetup -a | grep "$COMMON_PREFIX"
|
|
||||||
losetup -d "$STRAY_LOOPS" || true
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,6 +175,7 @@ teardown() {
|
|||||||
|
|
||||||
echo -n .
|
echo -n .
|
||||||
|
|
||||||
|
pgrep dmeventd || true
|
||||||
test -f LOCAL_DMEVENTD && kill -9 $(cat LOCAL_DMEVENTD) || true
|
test -f LOCAL_DMEVENTD && kill -9 $(cat LOCAL_DMEVENTD) || true
|
||||||
test -f LOCAL_LVMETAD && kill -9 $(cat LOCAL_LVMETAD) || true
|
test -f LOCAL_LVMETAD && kill -9 $(cat LOCAL_LVMETAD) || true
|
||||||
|
|
||||||
@ -201,13 +196,16 @@ teardown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
make_ioerror() {
|
make_ioerror() {
|
||||||
echo 0 10000000 error | dmsetup create -u TEST-ioerror ioerror
|
echo 0 10000000 error | dmsetup create -u ${PREFIX}-ioerror ioerror
|
||||||
ln -s "$DM_DEV_DIR/mapper/ioerror" "$DM_DEV_DIR/ioerror"
|
ln -s "$DM_DEV_DIR/mapper/ioerror" "$DM_DEV_DIR/ioerror"
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_loop() {
|
prepare_loop() {
|
||||||
local size=${1=32}
|
local size=${1=32}
|
||||||
|
local i
|
||||||
|
local slash
|
||||||
|
|
||||||
|
test -f LOOP && LOOP=$(cat LOOP)
|
||||||
echo -n "## preparing loop device..."
|
echo -n "## preparing loop device..."
|
||||||
|
|
||||||
# skip if prepare_scsi_debug_dev() was used
|
# skip if prepare_scsi_debug_dev() was used
|
||||||
@ -296,6 +294,7 @@ prepare_devs() {
|
|||||||
local n=${1:-3}
|
local n=${1:-3}
|
||||||
local devsize=${2:-34}
|
local devsize=${2:-34}
|
||||||
local pvname=${3:-pv}
|
local pvname=${3:-pv}
|
||||||
|
local loopsz
|
||||||
|
|
||||||
prepare_loop $(($n*$devsize))
|
prepare_loop $(($n*$devsize))
|
||||||
echo -n "## preparing $n devices..."
|
echo -n "## preparing $n devices..."
|
||||||
@ -331,6 +330,8 @@ prepare_devs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
disable_dev() {
|
disable_dev() {
|
||||||
|
local dev
|
||||||
|
|
||||||
init_udev_transaction
|
init_udev_transaction
|
||||||
for dev in "$@"; do
|
for dev in "$@"; do
|
||||||
maj=$(($(stat --printf=0x%t "$dev")))
|
maj=$(($(stat --printf=0x%t "$dev")))
|
||||||
@ -340,10 +341,11 @@ disable_dev() {
|
|||||||
notify_lvmetad --major "$maj" --minor "$min"
|
notify_lvmetad --major "$maj" --minor "$min"
|
||||||
done
|
done
|
||||||
finish_udev_transaction
|
finish_udev_transaction
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enable_dev() {
|
enable_dev() {
|
||||||
|
local dev
|
||||||
|
|
||||||
init_udev_transaction
|
init_udev_transaction
|
||||||
for dev in "$@"; do
|
for dev in "$@"; do
|
||||||
local name=$(echo "$dev" | sed -e 's,.*/,,')
|
local name=$(echo "$dev" | sed -e 's,.*/,,')
|
||||||
@ -357,12 +359,16 @@ enable_dev() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
backup_dev() {
|
backup_dev() {
|
||||||
|
local dev
|
||||||
|
|
||||||
for dev in "$@"; do
|
for dev in "$@"; do
|
||||||
dd if="$dev" of="$dev.backup" bs=1024
|
dd if="$dev" of="$dev.backup" bs=1024
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
restore_dev() {
|
restore_dev() {
|
||||||
|
local dev
|
||||||
|
|
||||||
for dev in "$@"; do
|
for dev in "$@"; do
|
||||||
test -e "$dev.backup" || \
|
test -e "$dev.backup" || \
|
||||||
die "Internal error: $dev not backed up, can't restore!"
|
die "Internal error: $dev not backed up, can't restore!"
|
||||||
@ -426,24 +432,27 @@ activation/monitoring = 0
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local v
|
||||||
for v in "$@"; do
|
for v in "$@"; do
|
||||||
echo "$v" >> CONFIG_VALUES
|
echo "$v" >> CONFIG_VALUES
|
||||||
done
|
done
|
||||||
|
|
||||||
rm -f CONFIG
|
rm -f CONFIG
|
||||||
|
local s
|
||||||
for s in $(cat CONFIG_VALUES | cut -f1 -d/ | sort | uniq); do
|
for s in $(cat CONFIG_VALUES | cut -f1 -d/ | sort | uniq); do
|
||||||
echo "$s {" >> CONFIG
|
echo "$s {" >> CONFIG
|
||||||
for k in $(grep ^$s/ CONFIG_VALUES | cut -f1 -d= | sed -e 's, *$,,' | sort | uniq); do
|
local k
|
||||||
|
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/, ," >> CONFIG
|
grep "^$k" CONFIG_VALUES | tail -n 1 | sed -e "s,^$s/, ," >> CONFIG
|
||||||
done
|
done
|
||||||
echo "}" >> CONFIG
|
echo "}" >> CONFIG
|
||||||
echo >> CONFIG
|
echo >> CONFIG
|
||||||
done
|
done
|
||||||
mv -f CONFIG $TESTDIR/etc/lvm.conf
|
mv -f CONFIG etc/lvm.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
apitest() {
|
apitest() {
|
||||||
t=$1
|
local t=$1
|
||||||
shift
|
shift
|
||||||
test -x "$abs_top_builddir/test/api/$t.t" || skip
|
test -x "$abs_top_builddir/test/api/$t.t" || skip
|
||||||
"$abs_top_builddir/test/api/$t.t" "$@" && rm -f debug.log
|
"$abs_top_builddir/test/api/$t.t" "$@" && rm -f debug.log
|
||||||
@ -458,9 +467,9 @@ udev_wait() {
|
|||||||
pgrep udev >/dev/null || return 0
|
pgrep udev >/dev/null || return 0
|
||||||
which udevadm >/dev/null || return 0
|
which udevadm >/dev/null || return 0
|
||||||
if test -n "$1" ; then
|
if test -n "$1" ; then
|
||||||
udevadm settle --exit-if-exists=$1
|
udevadm settle --exit-if-exists="$1" || true
|
||||||
else
|
else
|
||||||
udevadm settle --timeout=15
|
udevadm settle --timeout=15 || true
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,28 +486,28 @@ target_at_least()
|
|||||||
dm-*) modprobe "$1" ;;
|
dm-*) modprobe "$1" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
version=$(dmsetup targets 2>/dev/null | grep "${1##dm-} " 2>/dev/null)
|
local version=$(dmsetup targets 2>/dev/null | grep "${1##dm-} " 2>/dev/null)
|
||||||
version=${version##* v}
|
version=${version##* v}
|
||||||
shift
|
shift
|
||||||
major=$(echo "$version" | cut -d. -f1)
|
|
||||||
minor=$(echo "$version" | cut -d. -f2)
|
|
||||||
revision=$(echo "$version" | cut -d. -f3)
|
|
||||||
|
|
||||||
|
local major=$(echo "$version" | cut -d. -f1)
|
||||||
test -z "$1" && return 0
|
test -z "$1" && return 0
|
||||||
test -n "$major" || return 1
|
test -n "$major" || return 1
|
||||||
test "$major" -gt "$1" && return 0
|
test "$major" -gt "$1" && return 0
|
||||||
test "$major" -eq "$1" || return 1
|
test "$major" -eq "$1" || return 1
|
||||||
|
|
||||||
test -z "$2" && return 0
|
test -z "$2" && return 0
|
||||||
|
local minor=$(echo "$version" | cut -d. -f2)
|
||||||
test -n "$minor" || return 1
|
test -n "$minor" || return 1
|
||||||
test "$minor" -gt "$2" && return 0
|
test "$minor" -gt "$2" && return 0
|
||||||
test "$minor" -eq "$2" || return 1
|
test "$minor" -eq "$2" || return 1
|
||||||
test -z "$4" && return 0
|
|
||||||
test -n "$revision" || return 1
|
test -z "$3" && return 0
|
||||||
test "$revision" -eq "$3" || return 1
|
local revision=$(echo "$version" | cut -d. -f3)
|
||||||
|
test "$revision" -ge "$3" 2>/dev/null || return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
test -f DEVICES && devs=$(cat DEVICES)
|
test -f DEVICES && devs=$(cat DEVICES)
|
||||||
test -f LOOP && LOOP=$(cat LOOP)
|
|
||||||
|
|
||||||
unset LVM_VALGRIND
|
unset LVM_VALGRIND
|
||||||
"$@"
|
"$@"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Copyright (C) 2011 Red Hat, Inc. All rights reserved.
|
# Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved.
|
||||||
#
|
#
|
||||||
# This copyrighted material is made available to anyone wishing to use,
|
# This copyrighted material is made available to anyone wishing to use,
|
||||||
# modify, copy, or redistribute it subject to the terms and conditions
|
# modify, copy, or redistribute it subject to the terms and conditions
|
||||||
@ -17,7 +17,7 @@ TZ=UTC
|
|||||||
# Put script name into variable, so it can used in external scripts
|
# Put script name into variable, so it can used in external scripts
|
||||||
TESTNAME=${0##*/}
|
TESTNAME=${0##*/}
|
||||||
# Nice debug message
|
# Nice debug message
|
||||||
PS4=' ${BASH_SOURCE[0]##*/}:${LINENO}+ '
|
PS4='#${BASH_SOURCE[0]##*/}:${LINENO}+ '
|
||||||
export TESTNAME PS4
|
export TESTNAME PS4
|
||||||
|
|
||||||
unset CDPATH
|
unset CDPATH
|
||||||
@ -29,8 +29,8 @@ TESTOLDPWD=$(pwd)
|
|||||||
COMMON_PREFIX="LVMTEST"
|
COMMON_PREFIX="LVMTEST"
|
||||||
PREFIX="${COMMON_PREFIX}$$"
|
PREFIX="${COMMON_PREFIX}$$"
|
||||||
|
|
||||||
TESTDIR=$(mkdtemp "${LVM_TEST_DIR-$TESTOLDPWD}" "$PREFIX.XXXXXXXXXX") || \
|
TESTDIR=$(mkdtemp "${LVM_TEST_DIR:-$TESTOLDPWD}" "$PREFIX.XXXXXXXXXX") || \
|
||||||
die "failed to create temporary directory in ${LVM_TEST_DIR-$TESTOLDPWD}"
|
die "failed to create temporary directory in ${LVM_TEST_DIR:-$TESTOLDPWD}"
|
||||||
RUNNING_DMEVENTD=$(pgrep dmeventd) || true
|
RUNNING_DMEVENTD=$(pgrep dmeventd) || true
|
||||||
|
|
||||||
export TESTOLDPWD TESTDIR COMMON_PREFIX PREFIX RUNNING_DMEVENTD
|
export TESTOLDPWD TESTDIR COMMON_PREFIX PREFIX RUNNING_DMEVENTD
|
||||||
@ -57,9 +57,10 @@ cd "$TESTDIR"
|
|||||||
echo "$TESTNAME" >TESTNAME
|
echo "$TESTNAME" >TESTNAME
|
||||||
|
|
||||||
# Setting up symlink from $i to $TESTDIR/lib
|
# Setting up symlink from $i to $TESTDIR/lib
|
||||||
find "$abs_top_builddir/daemons/dmeventd/plugins/" -name \*.so \
|
find "$abs_top_builddir/daemons/dmeventd/plugins/" -name '*.so' \
|
||||||
-exec ln -s "{}" lib/ \;
|
-exec ln -s -t lib "{}" +
|
||||||
ln -s "$abs_top_builddir/test/lib/"* lib/
|
find "$abs_top_builddir/test/lib" ! \( -name '*.sh' -o -name '*.[cdo]' \
|
||||||
|
-o -name '*~' \) -exec ln -s -t lib "{}" +
|
||||||
|
|
||||||
# Set vars from utils now that we have TESTDIR/PREFIX/...
|
# Set vars from utils now that we have TESTDIR/PREFIX/...
|
||||||
prepare_test_vars
|
prepare_test_vars
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Copyright (C) 2011 Red Hat, Inc. All rights reserved.
|
# Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved.
|
||||||
#
|
#
|
||||||
# This copyrighted material is made available to anyone wishing to use,
|
# This copyrighted material is made available to anyone wishing to use,
|
||||||
# modify, copy, or redistribute it subject to the terms and conditions
|
# modify, copy, or redistribute it subject to the terms and conditions
|
||||||
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
MAX_TRIES=4
|
MAX_TRIES=4
|
||||||
|
IFS_NL='
|
||||||
|
'
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
echo "$@" >&2
|
echo "$@" >&2
|
||||||
@ -62,8 +64,7 @@ mkdtemp() {
|
|||||||
fail=0
|
fail=0
|
||||||
|
|
||||||
# First, try to use mktemp.
|
# First, try to use mktemp.
|
||||||
d=$(env -u TMPDIR mktemp -d -t -p "$destdir" "$template" 2>/dev/null) \
|
d=$(env -u TMPDIR mktemp -d -t -p "$destdir" "$template" 2>/dev/null) || fail=1
|
||||||
|| fail=1
|
|
||||||
|
|
||||||
# The resulting name must be in the specified directory.
|
# The resulting name must be in the specified directory.
|
||||||
case "$d" in "${destdir}"*);; *) fail=1;; esac
|
case "$d" in "${destdir}"*);; *) fail=1;; esac
|
||||||
@ -165,15 +166,15 @@ kernel_at_least() {
|
|||||||
local major=$(uname -r | cut -d. -f1)
|
local major=$(uname -r | cut -d. -f1)
|
||||||
local minor=$(uname -r | cut -d. -f2 | cut -d- -f1)
|
local minor=$(uname -r | cut -d. -f2 | cut -d- -f1)
|
||||||
|
|
||||||
test $major -gt $1 && return 0
|
test "$major" -gt "$1" && return 0
|
||||||
test $major -eq $1 || return 1
|
test "$major" -eq "$1" || return 1
|
||||||
test $minor -gt $2 && return 0
|
test "$minor" -gt "$2" && return 0
|
||||||
test $minor -eq $2 || return 1
|
test "$minor" -eq "$2" || return 1
|
||||||
test -z "$3" && return 0
|
test -z "$3" && return 0
|
||||||
|
|
||||||
local minor2=$(uname -r | cut -d. -f3 | cut -d- -f1)
|
local minor2=$(uname -r | cut -d. -f3 | cut -d- -f1)
|
||||||
test -z "$minor2" -a $3 -ne 0 && return 1
|
test -z "$minor2" -a "$3" -ne 0 && return 1
|
||||||
test $minor2 -ge $3 2>/dev/null || return 1
|
test "$minor2" -ge "$3" 2>/dev/null || return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_test_vars() {
|
prepare_test_vars() {
|
||||||
@ -189,13 +190,18 @@ prepare_test_vars() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
. lib/paths || die "you must run make first"
|
# check if $abs_top_builddir was already set via 'lib/paths'
|
||||||
|
test -n "${abs_top_builddir+varset}" || . lib/paths || die "you must run make first"
|
||||||
|
|
||||||
PATH="$abs_top_builddir/test/lib":$PATH
|
case "$PATH" in
|
||||||
for d in daemons/dmeventd/plugins/mirror daemons/dmeventd/plugins/snapshot \
|
*"$abs_top_builddir/test/lib"*) ;;
|
||||||
daemons/dmeventd/plugins/lvm2 daemons/dmeventd liblvm tools libdm; do
|
*)
|
||||||
LD_LIBRARY_PATH="$abs_top_builddir/$d":$LD_LIBRARY_PATH
|
PATH="$abs_top_builddir/test/lib":$PATH
|
||||||
done
|
for d in daemons/dmeventd/plugins/mirror daemons/dmeventd/plugins/snapshot \
|
||||||
export PATH LD_LIBRARY_PATH
|
daemons/dmeventd/plugins/lvm2 daemons/dmeventd liblvm tools libdm; do
|
||||||
|
LD_LIBRARY_PATH="$abs_top_builddir/$d":$LD_LIBRARY_PATH
|
||||||
|
done
|
||||||
|
export PATH LD_LIBRARY_PATH ;;
|
||||||
|
esac
|
||||||
|
|
||||||
test -z "$PREFIX" || prepare_test_vars
|
test -z "$PREFIX" || prepare_test_vars
|
||||||
|
Loading…
Reference in New Issue
Block a user