[sheepdog] [PATCH] tests: abort test on valgrind error

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Fri Sep 7 09:38:24 CEST 2012


This dumps a core file on a valgrind error to make fixing it much
easier.

It seems that valgrind complains about some corosync versions.  Feel
free to add a new section to valgrind.supp to suppress meaningless
errors.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 tests/common.rc     |   11 ++++++++---
 tests/valgrind.supp |   29 +++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 3 deletions(-)
 create mode 100644 tests/valgrind.supp

diff --git a/tests/common.rc b/tests/common.rc
index de658ce..06cefad 100644
--- a/tests/common.rc
+++ b/tests/common.rc
@@ -179,12 +179,17 @@ _wait_for_sheep()
 _valgrind_sheep()
 {
     mkdir $1 > /dev/null 2>&1
-    sh -c "valgrind $SHEEP_PROG $@ -f -o > $1/sheep.log 2>&1 &"
+
+    # Dump a core file and stop the script on the first valgrind error.
+    db_cmd="gdb -nw --ex \"generate-core-file $1/core\" %f %p > /dev/null; \
+            echo \"core dumped ($1/core)\"; kill \$PPID"
+    opts="--db-attach=yes --db-command='${db_cmd}' --suppressions=valgrind.supp"
+
+    sh -c "echo y | valgrind ${opts} $SHEEP_PROG $@ -f -o 2> $1/sheep.log &"
 
     # wait for sheep to start up
     while true; do
-        ls $1/lock > /dev/null 2>&1
-        if [ $? == 0 ]; then
+        if [ -a $1/lock ]; then
             break
         fi
     done
diff --git a/tests/valgrind.supp b/tests/valgrind.supp
new file mode 100644
index 0000000..dc1e68a
--- /dev/null
+++ b/tests/valgrind.supp
@@ -0,0 +1,29 @@
+{
+	corosync 2.0.1 and libqb 0.14.1
+	Memcheck:Param
+	socketcall.sendto(msg)
+	fun:send
+	fun:qb_ipc_us_send
+	fun:qb_ipcc_us_setup_connect
+	fun:qb_ipcc_connect
+	fun:corosync_cfg_initialize
+}
+{
+	corosync 1.4.1
+	Memcheck:Param
+	socketcall.sendmsg(msg.msg_iov[i])
+	fun:__sendmsg_nocancel
+	fun:coroipcc_service_connect
+	fun:cpg_model_initialize
+	fun:cpg_initialize
+	fun:corosync_init
+}
+{
+	corosync 1.4.1
+	Memcheck:Param
+	socketcall.sendmsg(msg.msg_iov[i])
+	fun:__sendmsg_nocancel
+	fun:coroipcc_service_connect
+	fun:corosync_cfg_initialize
+	fun:corosync_init
+}
-- 
1.7.2.5




More information about the sheepdog mailing list