For target 'check-valgrind', add '-' before $(SHELL) so that even if
test case fails, the make continues executing and reports total errors.
The additional option --errors-for-leak-kinds=definite will consider
valgrind's definite memory leaks as errors and show at the last line of
valgrind.* as "ERROR SUMMARY: <N> errors". The patch grep this pattern
and sum the total number of errors.

To better understand the erros, add a new target 'check-valgrind-verbose',
which checks different valgrind's error patterns. Note: all the results
are from tests/testsuite.dir/<N>/valgrind.*, make sure this folder has no
stale files.

Signed-off-by: William Tu <u9012...@gmail.com>
---
 tests/automake.mk | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 47 insertions(+), 2 deletions(-)

diff --git a/tests/automake.mk b/tests/automake.mk
index 592f648..5d16664 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -184,17 +184,62 @@ $(valgrind_wrappers): tests/valgrind-wrapper.in
 CLEANFILES += $(valgrind_wrappers)
 EXTRA_DIST += tests/valgrind-wrapper.in
 
-VALGRIND = valgrind --log-file=valgrind.%p --leak-check=full \
+VALGRIND = valgrind --log-file=valgrind.%p --leak-check=full 
--errors-for-leak-kinds=definite \
        --suppressions=$(abs_top_srcdir)/tests/glibc.supp \
        --suppressions=$(abs_top_srcdir)/tests/openssl.supp --num-callers=20
 EXTRA_DIST += tests/glibc.supp tests/openssl.supp
 check-valgrind: all tests/atconfig tests/atlocal $(TESTSUITE) \
                 $(valgrind_wrappers) $(check_DATA)
-       $(SHELL) '$(TESTSUITE)' -C tests CHECK_VALGRIND=true 
VALGRIND='$(VALGRIND)' AUTOTEST_PATH='tests/valgrind:$(AUTOTEST_PATH)' -d 
$(TESTSUITEFLAGS)
+       -$(SHELL) '$(TESTSUITE)' -C tests CHECK_VALGRIND=true 
VALGRIND='$(VALGRIND)' AUTOTEST_PATH='tests/valgrind:$(AUTOTEST_PATH)' -d 
$(TESTSUITEFLAGS)
        @echo
        @echo 
'----------------------------------------------------------------------'
+       @echo Total errors: `find tests/testsuite.dir -name "valgrind.*" | 
xargs cat | \
+               sed -n 's/.*ERROR\ SUMMARY:\ \([0-9]*\)\ errors.*/.+\1/p' | bc 
| tail -1`
        @echo 'Valgrind output can be found in tests/testsuite.dir/*/valgrind.*'
        @echo 
'----------------------------------------------------------------------'
+
+# Valgrind error pattern, see:
+#     http://valgrind.org/docs/manual/mc-manual.html#mc-manual.errormsgs
+valgrind_def_leak='definitely lost in'
+valgrind_invalid_rw='Invalid \(write\|read\) of size'
+valgrind_invalid_free='\(Invalid\|Mismatched\) free'
+valgrind_uninit_jmp='Conditional jump or move depends on uninitialised value'
+valgrind_uninit_syscall='Syscall param write(buf) points to uninitialised'
+valgrind_overlap='Source and destination overlap in'
+
+check-valgrind-verbose: check-valgrind
+       @echo -n 'Check definitely memory leak... '
+       @if grep -r $(valgrind_def_leak) tests/testsuite.dir/* > /dev/null; \
+       then echo 'FAILED';     \
+       else echo 'ok';         \
+       fi
+       @echo -n 'Check invalid read/write... '
+       @if grep -r $(valgrind_invalid_rw) tests/testsuite.dir/* > /dev/null; \
+       then echo 'FAILED';     \
+       else echo 'ok';         \
+       fi
+       @echo -n 'Check invalid free... '
+       @if grep -r $(valgrind_invalid_free) tests/testsuite.dir/* > /dev/null; 
\
+       then echo 'FAILED';     \
+       else echo 'ok';         \
+       fi
+       @echo -n 'Check use of uninitialised values... '
+       @if grep -r $(valgrind_uninit_jmp) tests/testsuite.dir/* > /dev/null; \
+       then echo 'FAILED';     \
+       else echo 'ok';         \
+       fi
+       @echo -n 'Check use of uninitialised or unaddressable values in system 
calls... '
+       @if grep -r $(valgrind_uninit_syscall) tests/testsuite.dir/* > 
/dev/null; \
+       then echo 'FAILED';     \
+       else echo 'ok';         \
+       fi
+       @echo -n 'Check overlapping source and destination blocks... '
+       @if grep -r $(valgrind_overlap) tests/testsuite.dir/* > /dev/null; \
+       then echo 'FAILED';     \
+       else echo 'ok';         \
+       fi
+       @echo 
'----------------------------------------------------------------------'
+
 
 # OFTest support.
 
-- 
2.5.0

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to