[sheepdog] [PATCH] tests: add valgrind support to collie command
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Thu Sep 6 03:24:48 CEST 2012
This patch shows valgrind error messages of collie if they exist.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
tests/008 | 8 +-------
tests/011 | 2 +-
tests/check | 1 +
tests/common.config | 3 ++-
tests/common.rc | 23 +++++++++++++++++++++--
5 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/tests/008 b/tests/008
index 92af96a..fa18d20 100755
--- a/tests/008
+++ b/tests/008
@@ -45,13 +45,7 @@ for i in `seq 1 5`; do
done
echo wait for object recovery to finish
-while true; do
- if [ "$(pgrep collie)" ]; then
- sleep 1
- else
- break
- fi
-done
+_wait_for_collie
for i in `seq 0 4`; do
for port in `seq 0 7`; do
diff --git a/tests/011 b/tests/011
index 13df80f..9aeffa5 100755
--- a/tests/011
+++ b/tests/011
@@ -17,7 +17,7 @@ trap "_cleanup_devices; exit \$status" 0 1 2 3 15
_cleanup_devices()
{
- killall -9 collie >/dev/null 2>&1 || true
+ _kill_all_collies
_kill_all_sheeps
for i in 0 1 2; do
diff --git a/tests/check b/tests/check
index 8177362..897a0c3 100755
--- a/tests/check
+++ b/tests/check
@@ -287,6 +287,7 @@ fi
if $valgrind; then
export SHEEP=_valgrind_sheep
+ export COLLIE=_valgrind_collie
fi
# we need common.rc
diff --git a/tests/common.config b/tests/common.config
index b9f78ec..3b99621 100644
--- a/tests/common.config
+++ b/tests/common.config
@@ -76,7 +76,8 @@ export DRIVER=${DRIVER:-local}
export STORE=${STORE:-/tmp/sheepdog}
export SHEEP_PROG=${SHEEP_PROG:-../sheep/sheep}
export SHEEP=${SHEEP:-$SHEEP_PROG}
-export COLLIE=${COLLIE:-../collie/collie}
+export COLLIE_PROG=${COLLIE_PROG:-../collie/collie}
+export COLLIE=${COLLIE:-$COLLIE_PROG}
# make sure this script returns success
/bin/true
diff --git a/tests/common.rc b/tests/common.rc
index 166d392..de658ce 100644
--- a/tests/common.rc
+++ b/tests/common.rc
@@ -120,7 +120,7 @@ _die()
_cleanup()
{
- killall -9 collie >/dev/null 2>&1 || true
+ _kill_all_collies
_kill_all_sheeps
mkdir -p $STORE
@@ -136,7 +136,7 @@ _cleanup()
_wait_for_collie()
{
for ((;;)); do
- if [ "$(pgrep collie)" ]; then
+ if [ "$(pgrep -f "$COLLIE_PROG (cluster|vdi|node|debug)")" ]; then
sleep 1
else
break
@@ -190,6 +190,16 @@ _valgrind_sheep()
done
}
+_valgrind_collie()
+{
+ logfile=$(mktemp)
+ valgrind --log-file=$logfile --error-exitcode=99 $COLLIE_PROG "$@"
+ if [ $? == 99 ]; then
+ cat $logfile 1>&2
+ fi
+ rm $logfile
+}
+
_start_sheep()
{
# ensure that sheep is not running
@@ -214,6 +224,15 @@ _start_sheep()
fi
}
+_kill_all_collies()
+{
+ pkill -9 -f "$COLLIE_PROG (cluster|vdi|node|debug)"
+
+ while [ $? == 0 ]; do
+ pgrep -f "$COLLIE_PROG (cluster|vdi|node|debug)" > /dev/null
+ done
+}
+
_kill_all_sheeps()
{
pkill -9 -f "$SHEEP_PROG $STORE"
--
1.7.2.5
More information about the sheepdog
mailing list