2011-01-05 03:16:18 +03:00
#!/bin/sh
2017-07-04 12:55:17 +03:00
# Copyright (C) 2011-2017 Red Hat, Inc.
2012-03-16 16:59:02 +04: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,
2016-01-21 13:49:46 +03:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2011-01-05 03:16:18 +03:00
. lib/paths
2012-03-16 16:59:02 +04:00
CMD = ${ 0 ##*/ }
test " $CMD " != lvm || unset CMD
2014-09-21 03:16:57 +04:00
# When needed to trace command from test suite use env var before program
# and run program directly via shell in test dir i.e.:
# sh shell/activate-mirror.sh
# 'LVM_GDB=1 lvcreate -l1 $vg'
# > run
test -z " $LVM_GDB " || exec gdb --readnow --args " $abs_top_builddir /tools/lvm " $CMD " $@ "
2012-03-16 16:59:02 +04:00
# Multiple level of LVM_VALGRIND support
# the higher level the more commands are traced
if test -n " $LVM_VALGRIND " ; then
2014-10-01 10:19:05 +04:00
RUN_DBG = " ${ VALGRIND :- valgrind } " ;
2012-03-16 16:59:02 +04:00
fi
2014-09-30 19:09:26 +04:00
if test -n " $LVM_STRACE " ; then
RUN_DBG = " strace $LVM_STRACE -o strace.log "
fi
case " $CMD " in
lvs| pvs| vgs| vgck| vgscan)
2017-07-04 12:55:17 +03:00
test " ${ LVM_DEBUG_LEVEL :- 0 } " -lt 2 && RUN_DBG = "" ; ;
2014-09-30 19:09:26 +04:00
pvcreate| pvremove| lvremove| vgcreate| vgremove)
2017-07-04 12:55:17 +03:00
test " ${ LVM_DEBUG_LEVEL :- 0 } " -lt 1 && RUN_DBG = "" ; ;
2014-09-30 19:09:26 +04:00
esac
2015-04-09 14:13:36 +03:00
# Capture parallel users of debug.log file
2015-05-01 14:26:07 +03:00
#test -z "$(fuser debug.log 2>/dev/null)" || {
# echo "TEST WARNING: \"debug.log\" is still in use while running $CMD $@" >&2
# fuser -v debug.log >&2
#}
2015-04-09 14:13:36 +03:00
2013-04-11 18:22:35 +04:00
# the exec is important, because otherwise fatal signals inside "not" go unnoticed
2014-09-30 19:08:34 +04:00
if test -n " $abs_top_builddir " ; then
exec $RUN_DBG " $abs_top_builddir /tools/lvm " $CMD " $@ "
else # we are testing the lvm on $PATH
2017-07-04 12:55:17 +03:00
PATH = $( echo " $PATH " | sed -e 's,[^:]*lvm2-testsuite[^:]*:,,g' )
2014-09-30 19:08:34 +04:00
exec $RUN_DBG lvm $CMD " $@ "
fi