Browse code

add electric-fence/duma tests if available (bb #1092)

git-svn: trunk@4176

Török Edvin authored on 2008/09/15 18:57:02
Showing 7 changed files
... ...
@@ -7,7 +7,8 @@ $(FILES) :
7 7
 	cat $(SPLIT_DIR)/split.$@aa $(SPLIT_DIR)/split.$@ab > $@
8 8
 
9 9
 programs = check_clamav
10
-scripts = check_clamd.sh check_freshclam.sh check_sigtool.sh check_clamscan.sh valgrind_tests.sh
10
+scripts = check_clamd.sh check_freshclam.sh check_sigtool.sh check_clamscan.sh\
11
+	 valgrind_tests.sh efence_tests.sh duma_tests.sh
11 12
 TESTS = $(programs) $(scripts)
12 13
 check_PROGRAMS = $(programs)
13 14
 check_SCRIPTS = $(scripts)
... ...
@@ -26,8 +27,8 @@ check_clamscan.sh: $(top_builddir)/test/clam.exe
26 26
 $(top_builddir)/test/clam.exe:
27 27
 	(cd $(top_builddir)/test && $(MAKE))
28 28
 
29
-CLEANFILES=lcov.out *.gcno *.gcda *.log clamd-test.socket /tmp/clamd-test.log $(FILES) test-stderr.log clamscan.log valgrind-*.log clamdscan.log clamdscan-multiscan.log
30
-EXTRA_DIST=.split input test-clamd.conf test-freshclam.conf valgrind.supp virusaction-test.sh $(scripts)
29
+CLEANFILES=lcov.out *.gcno *.gcda *.log clamd-test.socket /tmp/clamd-test.log $(FILES) test-stderr.log clamscan.log valgrind-*.log clamdscan.log clamdscan-multiscan.log duma.log
30
+EXTRA_DIST=.split input test-clamd.conf test-freshclam.conf valgrind.supp virusaction-test.sh $(scripts)/preload_run.sh
31 31
 if ENABLE_COVERAGE
32 32
 LCOV_OUTPUT = lcov.out
33 33
 LCOV_HTML = lcov_html
... ...
@@ -228,13 +228,15 @@ top_srcdir = @top_srcdir@
228 228
 SPLIT_DIR = $(top_srcdir)/unit_tests/.split
229 229
 FILES = clam-phish-exe
230 230
 programs = check_clamav
231
-scripts = check_clamd.sh check_freshclam.sh check_sigtool.sh check_clamscan.sh valgrind_tests.sh
231
+scripts = check_clamd.sh check_freshclam.sh check_sigtool.sh check_clamscan.sh\
232
+	 valgrind_tests.sh efence_tests.sh duma_tests.sh
233
+
232 234
 check_SCRIPTS = $(scripts)
233 235
 @HAVE_LIBCHECK_FALSE@check_clamav_SOURCES = check_clamav_skip.c
234 236
 @HAVE_LIBCHECK_TRUE@check_clamav_SOURCES = check_clamav.c check_jsnorm.c check_str.c check_regex.c checks.h $(top_builddir)/libclamav/clamav.h check_disasm.c check_uniq.c check_matchers.c
235 237
 @HAVE_LIBCHECK_TRUE@check_clamav_CPPFLAGS = @CHECK_CPPFLAGS@ -DSRCDIR=\"$(abs_srcdir)\"
236 238
 @HAVE_LIBCHECK_TRUE@check_clamav_LDADD = $(top_builddir)/libclamav/libclamav.la @THREAD_LIBS@ @CHECK_LIBS@
237
-CLEANFILES = lcov.out *.gcno *.gcda *.log clamd-test.socket /tmp/clamd-test.log $(FILES) test-stderr.log clamscan.log valgrind.log clamdscan.log
239
+CLEANFILES = lcov.out *.gcno *.gcda *.log clamd-test.socket /tmp/clamd-test.log $(FILES) test-stderr.log clamscan.log valgrind-*.log clamdscan.log clamdscan-multiscan.log duma.log
238 240
 EXTRA_DIST = .split input test-clamd.conf test-freshclam.conf valgrind.supp virusaction-test.sh $(scripts)
239 241
 @ENABLE_COVERAGE_TRUE@LCOV_OUTPUT = lcov.out
240 242
 @ENABLE_COVERAGE_TRUE@LCOV_HTML = lcov_html
... ...
@@ -1,14 +1,20 @@
1
-#!/bin/sh  
1
+#!/bin/sh 
2 2
 CLAMD_WRAPPER=${CLAMD_WRAPPER-}
3 3
 killclamd() {
4 4
 	test -f /tmp/clamd-test.pid || return
5
-	pid=`cat /tmp/clamd-test.pid`
6
-	kill -0 $pid && kill $pid
5
+	pid=`cat /tmp/clamd-test.pid 2>/dev/null`
6
+	if test "X$pid" = "X"; then
7
+		# file can be removed between the 'test' and 'cat',
8
+		# it happened a few times for me
9
+		return
10
+	fi
11
+	kill -0 $pid 2>/dev/null || return
12
+	kill $pid
7 13
 	timeout=10
8
-	(sleep $timeout; kill -KILL $pid) &
14
+	(sleep $timeout && kill -0 $pid 2>/dev/null && kill -KILL $pid) &
9 15
 	sleeperpid=$!
10 16
 	wait $pid
11
-	kill -ALRM $sleeperpid 2>/dev/null
17
+	kill $sleeperpid 2>/dev/null
12 18
 	rm -f /tmp/clamd-test.pid
13 19
 }
14 20
 die() {
... ...
@@ -1,4 +1,5 @@
1 1
 #!/bin/sh
2
+CLAMSCAN_WRAPPER=${CLAMSCAN_WRAPPER-}
2 3
 die() {
3 4
 	rm -rf test-db
4 5
 	exit $1;
... ...
@@ -8,7 +9,7 @@ cat <<EOF >test-db/test.hdb
8 8
 aa15bcf478d165efd2065190eb473bcb:544:ClamAV-Test-File
9 9
 EOF
10 10
 rm -f clamscan.log
11
-../clamscan/clamscan --quiet -dtest-db/test.hdb ../test/clam* --log=clamscan.log
11
+../libtool --mode=execute $CLAMSCAN_WRAPPER ../clamscan/clamscan --quiet -dtest-db/test.hdb ../test/clam* --log=clamscan.log
12 12
 if test $? != 1; then
13 13
 	echo "Error running clamscan: $?" >&2;
14 14
 	grep OK clamscan.log >&2;
15 15
new file mode 100755
... ...
@@ -0,0 +1,35 @@
0
+#!/bin/sh
1
+# Run under duma
2
+for i in $LIBDUMA /usr/lib/libduma.so /usr/local/lib/libduma.so; do
3
+	if test -f "$i"; then
4
+		LIBDUMA="$i"
5
+		break;
6
+	fi
7
+done
8
+test -f "$LIBDUMA" || { echo "*** duma not found, skipping test"; exit 77;}
9
+DUMA_FILL=90
10
+DUMA_MALLOC_0_STRATEGY=1
11
+DUMA_OUTPUT_FILE=duma.log
12
+DUMA_DISABLE_BANNER=1
13
+LIBPRELOAD="$LIBDUMA"
14
+rm -f duma.log
15
+export DUMA_FILL DUMA_MALLOC_0_STRATEGY DUMA_OUTPUT_FILE DUMA_DISABLE_BANNER LIBPRELOAD
16
+echo "--- running clamd under duma to detect underruns"
17
+CLAMD_WRAPPER=$srcdir/preload_run.sh $srcdir/check_clamd.sh
18
+if test ! $?; then
19
+	echo "*** DUMA has detected errors"
20
+	cat duma.log
21
+	exit 3
22
+fi
23
+DUMA_PROTECT_BELOW=1
24
+export DUMA_PROTECT_BELOW
25
+echo "--- running clamd under duma to detect underruns"
26
+rm -f duma.log
27
+CLAMD_WRAPPER=$srcdir/preload_run.sh $srcdir/check_clamd.sh
28
+if test ! $?; then
29
+	echo "*** DUMA has detected errors"
30
+	cat duma.log
31
+	exit 3
32
+fi
33
+rm -f duma.log
34
+
0 35
new file mode 100755
... ...
@@ -0,0 +1,39 @@
0
+#!/bin/sh
1
+# Run under electric-fence
2
+for i in $LIBEFENCE /usr/lib/libefence.so /usr/local/lib/libefence.so /opt/csw/lib/libefence.so; do
3
+	if test -f "$i"; then
4
+		LIBEFENCE="$i"
5
+		break;
6
+	fi
7
+done
8
+test -f "$LIBEFENCE" || { echo "*** electric-fence not found, skipping test"; exit 77;}
9
+
10
+EF_FREE_WIPES=1
11
+LIBPRELOAD="$LIBEFENCE"
12
+export EF_FREE_WIPES LIBPRELOAD
13
+VALGRIND=`which ${VALGRIND-valgrind}`
14
+if test ! -n "$VALGRIND" -o ! -x "$VALGRIND"; then
15
+	# run check_clamav under efence only if we don't have valgrind installed
16
+	echo "--- Running check_clamav under electric-fence"
17
+	CK_FORK=no ../libtool --mode=execute $srcdir/preload_run.sh ./check_clamav
18
+	if test ! $?; then
19
+		echo "*** Electric-fence has detected errors"
20
+		exit 1
21
+	fi
22
+fi
23
+# we don't run clamd under electric-fence, it always crashes in free(),
24
+# probably doesn't work well with libpthread.
25
+echo "--- running clamscan under electric-fence to detect overruns"
26
+CLAMSCAN_WRAPPER=$srcdir/preload_run.sh $srcdir/check_clamscan.sh
27
+if test ! $?; then
28
+	echo "*** Electric-fence has detected errors"
29
+	exit 2
30
+fi
31
+EF_PROTECT_BELOW=1
32
+export EF_PROTECT_BELOW
33
+echo "--- running clamscan under electric-fence to detect underruns"
34
+CLAMSCAN_WRAPPER=$srcdir/preload_run.sh $srcdir/check_clamscan.sh
35
+if test ! $?; then
36
+	echo "*** Electric-fence has detected errors"
37
+	exit 3
38
+fi
0 39
new file mode 100755
... ...
@@ -0,0 +1,8 @@
0
+#!/bin/sh
1
+# Helper script to run a program under electric-fence / duma
2
+
3
+# prevent core dumps
4
+ulimit -c 0
5
+LD_PRELOAD=$LIBPRELOAD
6
+export LD_PRELOAD
7
+exec $@