diff options
author | Petr Rockai <prockai@redhat.com> | 2014-09-30 17:09:26 +0200 |
---|---|---|
committer | Petr Rockai <prockai@redhat.com> | 2014-11-18 19:02:08 +0100 |
commit | f63cc8ce1943dee125abf62401d53de054ce45e0 (patch) | |
tree | ca1f54d4b6eec4b9f8bb4fbd1b02eec39549e9c5 | |
parent | 8b3c90c84d2b0e2d234e806ef6e7801a69162b43 (diff) | |
download | lvm2-f63cc8ce1943dee125abf62401d53de054ce45e0.tar.gz |
test: Add support for running LVM commands in tests through strace.
-rw-r--r-- | test/lib/aux.sh | 18 | ||||
-rw-r--r-- | test/lib/lvm-wrapper.sh | 23 | ||||
-rw-r--r-- | test/lib/utils.sh | 1 |
3 files changed, 24 insertions, 18 deletions
diff --git a/test/lib/aux.sh b/test/lib/aux.sh index 8f18c7b91..aba30a72a 100644 --- a/test/lib/aux.sh +++ b/test/lib/aux.sh @@ -22,7 +22,7 @@ expect_failure() { } prepare_clvmd() { - rm -f debug.log + rm -f debug.log strace.log test "${LVM_TEST_LOCKING:-0}" -ne 3 && return # not needed if pgrep clvmd ; then @@ -53,7 +53,7 @@ prepare_clvmd() { } prepare_dmeventd() { - rm -f debug.log + rm -f debug.log strace.log if pgrep dmeventd ; then echo "Cannot test dmeventd with real dmeventd ($(pgrep dmeventd)) running." skip @@ -80,7 +80,7 @@ prepare_dmeventd() { prepare_lvmetad() { test $# -eq 0 && default_opts="-l wire,debug" - rm -f debug.log + rm -f debug.log strace.log # skip if we don't have our own lvmetad... (which lvmetad 2>/dev/null | grep "$abs_builddir") || skip @@ -226,7 +226,7 @@ teardown() { # Avoid activation of dmeventd if there is no pid cfg=$(test -s LOCAL_DMEVENTD || echo "--config activation{monitoring=0}") vgremove -ff $cfg \ - $vg $vg1 $vg2 $vg3 $vg4 &>/dev/null || rm -f debug.log + $vg $vg1 $vg2 $vg3 $vg4 &>/dev/null || rm -f debug.log strace.log } kill_sleep_kill_ LOCAL_CLVMD ${LVM_VALGRIND_CLVMD:-0} @@ -477,7 +477,7 @@ enable_dev() { shift fi - rm -f debug.log + rm -f debug.log strace.log init_udev_transaction for dev in "$@"; do local name=$(echo "$dev" | sed -e 's,.*/,,') @@ -600,7 +600,7 @@ unhide_dev() { } mkdev_md5sum() { - rm -f debug.log + rm -f debug.log strace.log mkfs.ext2 "$DM_DEV_DIR/$1/$2" || return 1 md5sum "$DM_DEV_DIR/$1/$2" > "md5.$1-$2" } @@ -703,12 +703,12 @@ apitest() { local t=$1 shift 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 strace.log } api() { test -x "$abs_top_builddir/test/api/wrapper" || skip - "$abs_top_builddir/test/api/wrapper" "$@" && rm -f debug.log + "$abs_top_builddir/test/api/wrapper" "$@" && rm -f debug.log strace.log } mirror_recovery_works() { @@ -819,7 +819,7 @@ version_at_least() { # # i.e. dm_target_at_least dm-thin-pool 1 0 target_at_least() { - rm -f debug.log + rm -f debug.log strace.log case "$1" in dm-*) modprobe "$1" || true ;; esac diff --git a/test/lib/lvm-wrapper.sh b/test/lib/lvm-wrapper.sh index 013bc1399..3eb0d99a9 100644 --- a/test/lib/lvm-wrapper.sh +++ b/test/lib/lvm-wrapper.sh @@ -24,17 +24,22 @@ test -z "$LVM_GDB" || exec gdb --readnow --args "$abs_top_builddir/tools/lvm" $C # Multiple level of LVM_VALGRIND support # the higher level the more commands are traced if test -n "$LVM_VALGRIND"; then - RUN_VALGRIND="aux run_valgrind"; - case "$CMD" in - lvs|pvs|vgs|vgck|vgscan) - test "$LVM_VALGRIND" -gt 2 || unset RUN_VALGRIND ;; - pvcreate|pvremove|lvremove|vgcreate|vgremove) - test "$LVM_VALGRIND" -gt 1 || unset RUN_VALGRIND ;; - *) - test "$LVM_VALGRIND" -gt 0 || unset RUN_VALGRIND ;; - esac + RUN_DBG="aux run_valgrind"; fi +if test -n "$LVM_STRACE"; then + RUN_DBG="strace $LVM_STRACE -o strace.log" +fi + +set -x + +case "$CMD" in + lvs|pvs|vgs|vgck|vgscan) + test ${LVM_DEBUG_LEVEL:-0} -lt 2 && RUN_DBG= ;; + pvcreate|pvremove|lvremove|vgcreate|vgremove) + test ${LVM_DEBUG_LEVEL:-0} -lt 1 && RUN_DBG= ;; +esac + # the exec is important, because otherwise fatal signals inside "not" go unnoticed if test -n "$abs_top_builddir"; then exec $RUN_DBG "$abs_top_builddir/tools/lvm" $CMD "$@" diff --git a/test/lib/utils.sh b/test/lib/utils.sh index 70f8ca558..0599f4d87 100644 --- a/test/lib/utils.sh +++ b/test/lib/utils.sh @@ -129,6 +129,7 @@ STACKTRACE() { test -z "$LVM_TEST_NODEBUG" -a -f debug.log && { sed -e "s,^,## DEBUG: ,;s,$top_srcdir/\?,," < debug.log + test -e strace.log && sed -e "s,^,## STRACE: ,;s,$top_srcdir/\?,," < strace.log } test -f SKIP_THIS_TEST && exit 200 |