diff options
author | Petr Rockai <prockai@redhat.com> | 2011-01-05 00:16:18 +0000 |
---|---|---|
committer | Petr Rockai <prockai@redhat.com> | 2011-01-05 00:16:18 +0000 |
commit | 1b7c4b9bcec8fa6e279b56d91e79e4fcb8f6c01e (patch) | |
tree | fabbb05a955b0f5d8e8fd18b59a39c7f9b4b3cd8 /test/lib/utils.sh | |
parent | 63bd9ec3fff74d719f109b0f8a8e7bc8449e7fc8 (diff) | |
download | lvm2-1b7c4b9bcec8fa6e279b56d91e79e4fcb8f6c01e.tar.gz lvm2-1b7c4b9bcec8fa6e279b56d91e79e4fcb8f6c01e.tar.xz lvm2-1b7c4b9bcec8fa6e279b56d91e79e4fcb8f6c01e.zip |
Substantial rework of the functional test support code. Some new features:
- somewhat neater, more consistent and more readable output
- possible to set any lvm.conf value: aux lvmconf "section/key = value"
- LVM_TEST_NODEBUG to suppress the (lengthy) "## DEBUG" output
- back-substitution on test output ($TESTDIR/$PREFIX -> @TESTDIR@/@PREFIX@)
- support code moved from test/ to test/lib/ --> less clutter
Diffstat (limited to 'test/lib/utils.sh')
-rw-r--r-- | test/lib/utils.sh | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/test/lib/utils.sh b/test/lib/utils.sh new file mode 100644 index 00000000..96c35fce --- /dev/null +++ b/test/lib/utils.sh @@ -0,0 +1,80 @@ +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. +# +# 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 + +set -e + +STACKTRACE() { + trap - ERR; + i=0; + + while FUNC=${FUNCNAME[$i]}; test "$FUNC" != "main"; do + echo "## $i ${FUNC}() called from ${BASH_SOURCE[$i]}:${BASH_LINENO[$i]}" + i=$(($i + 1)); + done + + # Get backtraces from coredumps + if which gdb >& /dev/null; then + echo bt full > gdb_commands.txt + echo l >> gdb_commands.txt + echo quit >> gdb_commands.txt + for core in `ls core* 2>/dev/null`; do + bin=$(gdb -batch -c $core 2>&1 | grep "generated by" | \ + sed -e "s,.*generated by \`\([^ ']*\).*,\1,") + gdb -batch -c $core -x gdb_commands.txt `which $bin` + done + fi + + test -z "$LVM_TEST_NODEBUG" && test -f debug.log && { + sed -e "s,^,## DEBUG: ,;s,$top_srcdir/\?,," < debug.log + } + + test -f SKIP_THIS_TEST && exit 200 +} + +init_udev_transaction() { + if test "$DM_UDEV_SYNCHRONISATION" = 1; then + COOKIE=$(dmsetup udevcreatecookie) + # Cookie is not generated if udev is not running! + if test -n "$COOKIE"; then + export DM_UDEV_COOKIE=$COOKIE + fi + fi +} + +finish_udev_transaction() { + if test "$DM_UDEV_SYNCHRONISATION" = 1 -a -n "$DM_UDEV_COOKIE"; then + dmsetup udevreleasecookie + unset DM_UDEV_COOKIE + fi +} + +. lib/paths || { echo >&2 you must run make first; exit 1; } + +PATH=$abs_top_builddir/test/lib:$PATH +LIBDIRS="libdm tools liblvm daemons/dmeventd daemons/dmeventd/plugins/lvm2 \ + daemons/dmeventd/plugins/mirror daemons/dmeventd/plugins/snapshot" + +for d in $LIBDIRS; do + LD_LIBRARY_PATH=$abs_top_builddir/$d:$LD_LIBRARY_PATH +done +export LD_LIBRARY_PATH + +if test -n "$PREFIX"; then + vg=${PREFIX}vg + lv=LV + + for i in `seq 1 16`; do + name="${PREFIX}pv$i" + dev="$DM_DEV_DIR/mapper/$name" + eval "dev$i=$dev" + eval "lv$i=LV$i" + eval "vg$i=${PREFIX}vg$i" + done +fi |