[sheepdog] [PATCH] tests: add valgrind support
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Wed Sep 5 09:58:46 CEST 2012
If you add '-valgrind' to command options, check script wraps all
sheep calls with valgrind. This makes it easier to debug problems and
detect memory leaks.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
tests/check | 12 ++++++++++++
tests/common.config | 3 ++-
tests/common.rc | 12 +++++++++---
3 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/tests/check b/tests/check
index 8965be0..8177362 100755
--- a/tests/check
+++ b/tests/check
@@ -62,6 +62,7 @@ sortme=false
expunge=true
have_test_arg=false
randomize=false
+valgrind=false
rm -f $tmp.list $tmp.tmp $tmp.sed
for r
@@ -136,6 +137,7 @@ common options
check options
-sheepdog test sheepdog
-corosync use corosync driver (default: local)
+ -valgrind use valgrind
-xdiff graphical mode diff
-n show me, do not run tests
-T output timestamps
@@ -154,6 +156,12 @@ testlist options
DRIVER="corosync"
xpand=false
;;
+
+ -valgrind)
+ valgrind=true
+ xpand=false
+ ;;
+
-g) # -g group ... pick from group file
group=true
xpand=false
@@ -277,6 +285,10 @@ then
list=`echo $list | awk -f randomize.awk`
fi
+if $valgrind; then
+ export SHEEP=_valgrind_sheep
+fi
+
# we need common.rc
if ! . ./common.rc
then
diff --git a/tests/common.config b/tests/common.config
index e9c8fb4..b9f78ec 100644
--- a/tests/common.config
+++ b/tests/common.config
@@ -74,7 +74,8 @@ export BC_PROG="`set_prog_path bc`"
export DRIVER=${DRIVER:-local}
export STORE=${STORE:-/tmp/sheepdog}
-export SHEEP=${SHEEP:-../sheep/sheep}
+export SHEEP_PROG=${SHEEP_PROG:-../sheep/sheep}
+export SHEEP=${SHEEP:-$SHEEP_PROG}
export COLLIE=${COLLIE:-../collie/collie}
# make sure this script returns success
diff --git a/tests/common.rc b/tests/common.rc
index 5faa6dd..d6590f9 100644
--- a/tests/common.rc
+++ b/tests/common.rc
@@ -146,7 +146,7 @@ _wait_for_collie()
_count_sheep_processes()
{
- pgrep -f "$SHEEP $STORE/" -l | awk '{ $1=""; print }' | sort | uniq | wc -l
+ pgrep -f "$SHEEP_PROG $STORE/" -l | awk '{ $1=""; print }' | sort | uniq | wc -l
}
# wait for all sheep to join completely
@@ -176,6 +176,12 @@ _wait_for_sheep()
done
}
+_valgrind_sheep()
+{
+ mkdir $1 > /dev/null 2>&1
+ sh -c "valgrind $SHEEP_PROG $@ -f -o > $1/sheep.log 2>&1 &"
+}
+
_start_sheep()
{
# ensure that sheep is not running
@@ -211,14 +217,14 @@ _kill_all_sheeps()
_kill_sheep()
{
- pkill -9 -f "$SHEEP $STORE/$1"
+ pkill -9 -f "$SHEEP_PROG $STORE/$1"
if [ $? != 0 ]; then
_die "cannot kill sheep $1"
fi
while [ $? == 0 ]; do
- pgrep -f "$SHEEP $STORE/$1" > /dev/null
+ pgrep -f "$SHEEP_PROG $STORE/$1" > /dev/null
done
}
--
1.7.2.5
More information about the sheepdog
mailing list