3
# We don't look for 'still reachable' blocks, since clamd fork()s after loading
4
# the DB. The parent exits without freeing the memory (but they are freed
5
# anyway due to the exit).
6
# To test for DB load leaks, we issue a RELOAD command, which should cause
7
# leaks to be reported by valgrind if there are any.
10
test "x$VG" = "x1" || { echo "*** valgrind tests skipped by default, use 'make check VG=1' to activate"; exit 77; }
11
VALGRIND=`which ${VALGRIND-valgrind}`
12
test -n "$VALGRIND" || { echo "*** valgrind not found, skipping test"; exit 77; }
13
test -x "$VALGRIND" || { echo "*** valgrind not executable, skipping test"; exit 77; }
18
echo "*** Logfile $1 not found. Valgrind failed to run?"
20
NRUNS=`grep "ERROR SUMMARY" $1 | wc -l`
21
if test $NRUNS -eq `grep "ERROR SUMMARY: 0 errors" $1 | wc -l` && test `grep "FATAL:" $1|wc -l ` -eq 0; then
22
if test "$1" = "valgrind-race.log" ||
23
test $NRUNS -eq `grep "no leaks are possible" $1 | wc -l` ||
24
test `grep "lost:" $1 | grep -v "0 bytes" | wc -l` -eq 0; then
25
if test -z "$GENSUPP"; then
30
echo "*** Valgrind test FAILED, memory LEAKS detected ***"
31
grep "lost:" $1 | grep -v "0 bytes"
34
if test "$1" = "valgrind-race.log" ; then
35
echo "*** Valgrind test FAILED, DATA RACES detected ****"
37
echo "*** Valgrind test FAILED, memory ERRORS detected ****"
39
grep "ERROR SUMMARY" $1 | grep -v "0 errors"
42
# save current line in hold buffer
46
# get original line back and print
50
# store it in hold buffer
52
' <$1 | grep -Ev "Thread.+was created" | grep -v "Open"
55
echo "*** Please submit $1 to http://bugs.clamav.net"
59
if test "X$VALGRIND_GENSUPP" = "X1"; then
60
GENSUPP="--gen-suppressions=all"
65
VALGRIND_COMMON_FLAGS="-v --trace-children=yes --suppressions=$abs_srcdir/valgrind.supp $GENSUPP"
66
VALGRIND_FLAGS="$VALGRIND_COMMON_FLAGS --track-fds=yes --leak-check=full"
67
VALGRIND_FLAGS_RACE="$VALGRIND_COMMON_FLAGS --tool=helgrind"
68
export CK_DEFAULT_TIMEOUT=40
69
echo "--- Starting check_clamav under valgrind/memcheck"
70
rm -f valgrind-check.log valgrind-clamd.log valgrind-race.log
71
CK_FORK=no ../libtool --mode=execute $VALGRIND $VALGRIND_FLAGS ./check_clamav >valgrind-check.log 2>&1 &
74
echo "--- Starting clamd under valgrind/memcheck"
75
CLAMD_WRAPPER="$VALGRIND $VALGRIND_FLAGS" $abs_srcdir/check_clamd.sh >valgrind-clamd.log 2>&1 &
78
echo "--- Starting clamd under valgrind/helgrind"
79
CLAMD_TEST_UNIQ1=3 CLAMD_TEST_UNIQ2=4 CLAMD_WRAPPER="$VALGRIND $VALGRIND_FLAGS_RACE" $abs_srcdir/check_clamd.sh >valgrind-race.log 2>&1 &
82
wait $pid1 $pid2 $pid3
83
parse_valgrindlog valgrind-check.log
84
parse_valgrindlog valgrind-clamd.log
85
parse_valgrindlog valgrind-race.log
87
if test -f valgrind-check.log || test -f valgrind-race.log || test -f valgrind-clamd.log; then