Browse code

Use automake's parallel tests feature.

This simplifies the various clamd/clamscan tests a lot,
since the valgrind tests can now be parallelized by automake,
and we don't need to do that in the script itself.

Török Edvin authored on 2009/09/14 23:37:19
Showing 20 changed files
... ...
@@ -15,5 +15,4 @@ target.h
15 15
 config.log
16 16
 config.status
17 17
 libclamav.pc
18
-unit_tests/*
19 18
 autom4te.cache/*
... ...
@@ -29,7 +29,7 @@ pkgconfig_DATA = libclamav.pc
29 29
 # don't complain that configuration files and databases are not removed, this is intended
30 30
 distuninstallcheck_listfiles = find . -type f ! -name clamd.conf ! -name freshclam.conf ! -name daily.cvd ! -name main.cvd -print
31 31
 DISTCLEANFILES = target.h
32
-if DISTCHECK_ENABLE_FLAGS 
32
+if DISTCHECK_ENABLE_FLAGS
33 33
 DISTCHECK_CONFIGURE_FLAGS=--enable-milter --disable-clamav CFLAGS="-Wno-pointer-sign -Werror-implicit-function-declaration -Werror -Wextra -Wall -Wbad-function-cast -Wcast-align -Wendif-labels -Wfloat-equal -Wformat=2 -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wno-error=missing-prototypes -Wnested-externs -Wno-error=nested-externs -Wpointer-arith -Wstrict-prototypes -Wno-error=strict-prototypes -Wno-switch -Wno-switch-enum -Wundef -Wwrite-strings -Wstrict-overflow=1 -Winit-self -Wmissing-include-dirs -Wstrict-aliasing -Wdeclaration-after-statement -Waggregate-return -Wmissing-format-attribute -Wno-error=missing-format-attribute -Wno-error=type-limits -Wno-error=unused-value -Wno-error=unused-variable -Wcast-qual -Wno-error=cast-qual -Wno-error=sign-compare -Wshadow -Wno-error=shadow -Wno-error=uninitialized -fdiagnostics-show-option -Wno-unused-parameter -Wno-error=unreachable-code -Winvalid-pch -Wno-error=invalid-pch -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-all -Wstack-protector -Wno-error=aggregate-return"
34 34
 else
35 35
 DISTCHECK_CONFIGURE_FLAGS=--enable-milter --disable-clamav
... ...
@@ -384,7 +384,8 @@ DISTCLEANFILES = target.h
384 384
 @DISTCHECK_ENABLE_FLAGS_TRUE@	-D_FORTIFY_SOURCE=2 \
385 385
 @DISTCHECK_ENABLE_FLAGS_TRUE@	-fstack-protector-all \
386 386
 @DISTCHECK_ENABLE_FLAGS_TRUE@	-Wstack-protector \
387
-@DISTCHECK_ENABLE_FLAGS_TRUE@	-Wno-error=aggregate-return"
387
+@DISTCHECK_ENABLE_FLAGS_TRUE@	-Wno-error=aggregate-return" \
388
+@DISTCHECK_ENABLE_FLAGS_TRUE@	VERBOSE=1
388 389
 all: clamav-config.h
389 390
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
390 391
 
... ...
@@ -33,7 +33,7 @@ AC_CREATE_TARGET_H([target.h])
33 33
 
34 34
 dnl -Wall and -Werror here are NOT CFLAGS, they refer to automake warnings
35 35
 dnl enable stealth builds and psychedelic tests
36
-AM_INIT_AUTOMAKE([-Wall -Wportability -Wno-override -Werror std-options foreign dist-bzip2 no-define color-tests])
36
+AM_INIT_AUTOMAKE([1.11 -Wall -Wportability -Wno-override -Werror std-options foreign dist-bzip2 no-define color-tests parallel-tests tar-ustar])
37 37
 AM_SILENT_RULES([yes])
38 38
 
39 39
 dnl we told automake to not define these, since we want to include
... ...
@@ -1,14 +1,22 @@
1 1
 SPLIT_DIR=$(top_srcdir)/unit_tests/.split
2 2
 FILES = clam-phish-exe
3 3
 
4
-check_clamd.sh: $(FILES)
4
+check2_clamd.sh: $(FILES)
5
+check3_clamd.sh: $(FILES)
6
+check4_clamd.sh: $(FILES)
7
+check5_clamd_vg.sh: $(FILES)
8
+check6_clamd_vg.sh: $(FILES)
9
+check7_clamd_vg.sh: $(FILES)
10
+check8_clamd_hg.sh: $(FILES)
11
+check9_clamd_hg.sh: $(FILES)
12
+check10_clamd_hg.sh: $(FILES)
5 13
 
6 14
 $(FILES) :
7 15
 	cat $(SPLIT_DIR)/split.$@aa $(SPLIT_DIR)/split.$@ab > $@
8 16
 
9 17
 programs = check_clamav
10
-scripts = check_clamd.sh check_freshclam.sh check_sigtool.sh check_clamscan.sh\
11
-	 valgrind_tests.sh efence_tests.sh duma_tests.sh
18
+scripts = check_freshclam.sh check_sigtool.sh check1_clamscan.sh check2_clamd.sh check3_clamd.sh check4_clamd.sh\
19
+	  check5_clamd_vg.sh check6_clamd_vg.sh check7_clamd_hg.sh check8_clamd_hg.sh
12 20
 TESTS_ENVIRONMENT=export abs_srcdir=$(abs_srcdir) AWK=$(AWK);
13 21
 if ENABLE_UNRAR
14 22
 else
... ...
@@ -42,8 +50,8 @@ $(top_builddir)/test/clam.exe:
42 42
 quick-check:
43 43
 	VALGRIND=no LIBEFENCE=no LIBDUMA=no $(MAKE) check
44 44
 
45
-CLEANFILES=lcov.out *.gcno *.gcda *.log $(FILES) test-stderr.log clamscan.log valgrind-*.log duma.log duma2.log clamscan2.log
46
-EXTRA_DIST=.split $(srcdir)/*.ref input test-clamd.conf test-freshclam.conf valgrind.supp virusaction-test.sh $(scripts) preload_run.sh
45
+CLEANFILES=lcov.out *.gcno *.gcda *.log $(FILES) test-stderr.log clamscan.log accdenied
46
+EXTRA_DIST=.split $(srcdir)/*.ref input test-freshclam.conf valgrind.supp virusaction-test.sh $(scripts) preload_run.sh check_common.sh
47 47
 if ENABLE_COVERAGE
48 48
 LCOV_OUTPUT = lcov.out
49 49
 LCOV_HTML = lcov_html
... ...
@@ -133,6 +133,76 @@ test "X$(AM_COLOR_TESTS)" != Xno \
133 133
   blu=''; \
134 134
   std=''; \
135 135
 }
136
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
137
+am__vpath_adj = case $$p in \
138
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
139
+    *) f=$$p;; \
140
+  esac;
141
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
142
+am__install_max = 40
143
+am__nobase_strip_setup = \
144
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
145
+am__nobase_strip = \
146
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
147
+am__nobase_list = $(am__nobase_strip_setup); \
148
+  for p in $$list; do echo "$$p $$p"; done | \
149
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
150
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
151
+    if (++n[$$2] == $(am__install_max)) \
152
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
153
+    END { for (dir in files) print dir, files[dir] }'
154
+am__base_list = \
155
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
156
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
157
+# Restructured Text title and section.
158
+am__rst_title = sed 's/.*/   &   /;h;s/./=/g;p;x;p;g;p;s/.*//'
159
+am__rst_section = sed 'p;s/./=/g;p;g'
160
+# Put stdin (possibly several lines separated by ".  ") in a box.
161
+am__text_box = $(AWK) '{				\
162
+  n = split($$0, lines, "\\.  "); max = 0;		\
163
+  for (i = 1; i <= n; ++i)				\
164
+    if (max < length(lines[i]))				\
165
+      max = length(lines[i]);				\
166
+  for (i = 0; i < max; ++i) line = line "=";		\
167
+  print line;						\
168
+  for (i = 1; i <= n; ++i) if (lines[i]) print lines[i];\
169
+  print line;						\
170
+}'
171
+# Solaris 10 'make', and several other traditional 'make' implementations,
172
+# pass "-e" to $(SHELL).  This contradicts POSIX.  Work around the problem
173
+# by disabling -e (using the XSI extension "set +e") if it's set.
174
+am__sh_e_setup = case $$- in *e*) set +e;; esac
175
+# To be inserted before the command running the test.  Creates the
176
+# directory for the log if needed.  Stores in $dir the directory
177
+# containing $f, in $tst the test, in $log the log, and passes
178
+# TESTS_ENVIRONMENT.  Save and restore TERM around use of
179
+# TESTS_ENVIRONMENT, in case that unsets it.
180
+am__check_pre = \
181
+$(am__sh_e_setup);					\
182
+$(am__vpath_adj_setup) $(am__vpath_adj)			\
183
+srcdir=$(srcdir); export srcdir;			\
184
+rm -f $@-t;						\
185
+trap 'st=$$?; rm -f '\''$(abs_builddir)/$@-t'\''; (exit $$st); exit $$st' \
186
+  1 2 13 15;						\
187
+am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;		\
188
+test "x$$am__odir" = x. || $(MKDIR_P) "$$am__odir" || exit $$?;	\
189
+if test -f "./$$f"; then dir=./;			\
190
+elif test -f "$$f"; then dir=;				\
191
+else dir="$(srcdir)/"; fi;				\
192
+tst=$$dir$$f; log='$@'; __SAVED_TERM=$$TERM;		\
193
+$(TESTS_ENVIRONMENT)
194
+RECHECK_LOGS = $(TEST_LOGS)
195
+AM_RECURSIVE_TARGETS = check check-html recheck recheck-html
196
+TEST_SUITE_LOG = test-suite.log
197
+TEST_SUITE_HTML = $(TEST_SUITE_LOG:.log=.html)
198
+TEST_EXTENSIONS = @EXEEXT@ .test
199
+LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)
200
+am__test_logs1 = $(TESTS:=.log)
201
+am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
202
+TEST_LOGS = $(am__test_logs2:.test.log=.log)
203
+TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
204
+	$(TEST_LOG_FLAGS)
205
+TEST_LOGS_TMP = $(TEST_LOGS:.log=.log-t)
136 206
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
137 207
 ACLOCAL = @ACLOCAL@
138 208
 AMTAR = @AMTAR@
... ...
@@ -294,8 +364,8 @@ top_srcdir = @top_srcdir@
294 294
 SPLIT_DIR = $(top_srcdir)/unit_tests/.split
295 295
 FILES = clam-phish-exe
296 296
 programs = check_clamav
297
-scripts = check_clamd.sh check_freshclam.sh check_sigtool.sh check_clamscan.sh\
298
-	 valgrind_tests.sh efence_tests.sh duma_tests.sh
297
+scripts = check_freshclam.sh check_sigtool.sh check1_clamscan.sh check2_clamd.sh check3_clamd.sh check4_clamd.sh\
298
+	  check5_clamd_vg.sh check6_clamd_vg.sh check7_clamd_hg.sh check8_clamd_hg.sh
299 299
 
300 300
 TESTS_ENVIRONMENT = export abs_srcdir=$(abs_srcdir) AWK=$(AWK); \
301 301
 	$(am__append_1)
... ...
@@ -312,8 +382,8 @@ check_SCRIPTS = $(scripts)
312 312
 @HAVE_LIBCHECK_TRUE@check_clamd_SOURCES = check_clamd.c checks_common.h
313 313
 @HAVE_LIBCHECK_TRUE@check_clamd_CPPFLAGS = -I$(top_srcdir) @CHECK_CPPFLAGS@ -DSRCDIR=\"$(abs_srcdir)\" -DBUILDDIR=\"$(abs_builddir)\"
314 314
 @HAVE_LIBCHECK_TRUE@check_clamd_LDADD = @CHECK_LIBS@ @CLAMD_LIBS@
315
-CLEANFILES = lcov.out *.gcno *.gcda *.log $(FILES) test-stderr.log clamscan.log valgrind-*.log duma.log duma2.log clamscan2.log
316
-EXTRA_DIST = .split $(srcdir)/*.ref input test-clamd.conf test-freshclam.conf valgrind.supp virusaction-test.sh $(scripts) preload_run.sh
315
+CLEANFILES = lcov.out *.gcno *.gcda *.log $(FILES) test-stderr.log clamscan.log accdenied
316
+EXTRA_DIST = .split $(srcdir)/*.ref input test-freshclam.conf valgrind.supp virusaction-test.sh $(scripts) preload_run.sh check_common.sh
317 317
 @ENABLE_COVERAGE_TRUE@LCOV_OUTPUT = lcov.out
318 318
 @ENABLE_COVERAGE_TRUE@LCOV_HTML = lcov_html
319 319
 @ENABLE_COVERAGE_TRUE@LCOV_LCOV = @LCOV@
... ...
@@ -323,7 +393,7 @@ EXTRA_DIST = .split $(srcdir)/*.ref input test-clamd.conf test-freshclam.conf va
323 323
 all: all-am
324 324
 
325 325
 .SUFFIXES:
326
-.SUFFIXES: .c .lo .o .obj
326
+.SUFFIXES: .c .html .lo .log .o .obj .test .test$(EXEEXT)
327 327
 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
328 328
 	@for dep in $?; do \
329 329
 	  case '$(am__configure_deps)' in \
... ...
@@ -663,97 +733,183 @@ GTAGS:
663 663
 distclean-tags:
664 664
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
665 665
 
666
-check-TESTS: $(TESTS)
667
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
668
-	srcdir=$(srcdir); export srcdir; \
669
-	list=' $(TESTS) '; \
670
-	$(am__tty_colors); \
671
-	if test -n "$$list"; then \
672
-	  for tst in $$list; do \
673
-	    if test -f ./$$tst; then dir=./; \
674
-	    elif test -f $$tst; then dir=; \
675
-	    else dir="$(srcdir)/"; fi; \
676
-	    if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
677
-	      all=`expr $$all + 1`; \
678
-	      case " $(XFAIL_TESTS) " in \
679
-	      *[\ \	]$$tst[\ \	]*) \
680
-		xpass=`expr $$xpass + 1`; \
681
-		failed=`expr $$failed + 1`; \
682
-		col=$$red; res=XPASS; \
683
-	      ;; \
684
-	      *) \
685
-		col=$$grn; res=PASS; \
686
-	      ;; \
687
-	      esac; \
688
-	    elif test $$? -ne 77; then \
689
-	      all=`expr $$all + 1`; \
690
-	      case " $(XFAIL_TESTS) " in \
691
-	      *[\ \	]$$tst[\ \	]*) \
692
-		xfail=`expr $$xfail + 1`; \
693
-		col=$$lgn; res=XFAIL; \
694
-	      ;; \
695
-	      *) \
696
-		failed=`expr $$failed + 1`; \
697
-		col=$$red; res=FAIL; \
698
-	      ;; \
699
-	      esac; \
700
-	    else \
701
-	      skip=`expr $$skip + 1`; \
702
-	      col=$$blu; res=SKIP; \
703
-	    fi; \
704
-	    echo "$${col}$$res$${std}: $$tst"; \
705
-	  done; \
706
-	  if test "$$all" -eq 1; then \
707
-	    tests="test"; \
708
-	    All=""; \
709
-	  else \
710
-	    tests="tests"; \
711
-	    All="All "; \
712
-	  fi; \
713
-	  if test "$$failed" -eq 0; then \
714
-	    if test "$$xfail" -eq 0; then \
715
-	      banner="$$All$$all $$tests passed"; \
716
-	    else \
717
-	      if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
718
-	      banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
719
-	    fi; \
720
-	  else \
721
-	    if test "$$xpass" -eq 0; then \
722
-	      banner="$$failed of $$all $$tests failed"; \
723
-	    else \
724
-	      if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
725
-	      banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
726
-	    fi; \
727
-	  fi; \
728
-	  dashes="$$banner"; \
729
-	  skipped=""; \
730
-	  if test "$$skip" -ne 0; then \
731
-	    if test "$$skip" -eq 1; then \
732
-	      skipped="($$skip test was not run)"; \
733
-	    else \
734
-	      skipped="($$skip tests were not run)"; \
735
-	    fi; \
736
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
737
-	      dashes="$$skipped"; \
738
-	  fi; \
739
-	  report=""; \
740
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
741
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
742
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
743
-	      dashes="$$report"; \
744
-	  fi; \
745
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
746
-	  if test "$$failed" -eq 0; then \
747
-	    echo "$$grn$$dashes"; \
748
-	  else \
749
-	    echo "$$red$$dashes"; \
750
-	  fi; \
751
-	  echo "$$banner"; \
752
-	  test -z "$$skipped" || echo "$$skipped"; \
753
-	  test -z "$$report" || echo "$$report"; \
754
-	  echo "$$dashes$$std"; \
755
-	  test "$$failed" -eq 0; \
756
-	else :; fi
666
+# To be appended to the command running the test.  Handle the stdout
667
+# and stderr redirection, and catch the exit status.
668
+am__check_post =					\
669
+>$@-t 2>&1;						\
670
+estatus=$$?;						\
671
+if test -n '$(DISABLE_HARD_ERRORS)'			\
672
+   && test $$estatus -eq 99; then			\
673
+  estatus=1;						\
674
+fi;							\
675
+TERM=$$__SAVED_TERM; export TERM;			\
676
+$(am__tty_colors);					\
677
+xfailed=PASS;						\
678
+case " $(XFAIL_TESTS) " in				\
679
+  *[\ \	]$$f[\ \	]* | *[\ \	]$$dir$$f[\ \	]*) \
680
+    xfailed=XFAIL;;					\
681
+esac;							\
682
+case $$estatus:$$xfailed in				\
683
+    0:XFAIL) col=$$red; res=XPASS;;			\
684
+    0:*)     col=$$grn; res=PASS ;;			\
685
+    77:*)    col=$$blu; res=SKIP ;;			\
686
+    99:*)    col=$$red; res=FAIL ;;			\
687
+    *:XFAIL) col=$$lgn; res=XFAIL;;			\
688
+    *:*)     col=$$red; res=FAIL ;;			\
689
+esac;							\
690
+echo "$${col}$$res$${std}: $$f";			\
691
+echo "$$res: $$f (exit: $$estatus)" |			\
692
+  $(am__rst_section) >$@;				\
693
+cat $@-t >>$@;						\
694
+rm -f $@-t
695
+
696
+$(TEST_SUITE_LOG): $(TEST_LOGS)
697
+	@$(am__sh_e_setup);						\
698
+	list='$(TEST_LOGS)';						\
699
+	results=`for f in $$list; do					\
700
+		   read line < $$f && echo "$$line" || echo FAIL;	\
701
+		 done`;							\
702
+	all=`echo "$$results" | sed '/^$$/d' | wc -l | sed -e 's/^[	 ]*//'`; \
703
+	fail=`echo "$$results" | grep -c '^FAIL'`;			\
704
+	pass=`echo "$$results" | grep -c '^PASS'`;			\
705
+	skip=`echo "$$results" | grep -c '^SKIP'`;			\
706
+	xfail=`echo "$$results" | grep -c '^XFAIL'`;			\
707
+	xpass=`echo "$$results" | grep -c '^XPASS'`;			\
708
+	failures=`expr $$fail + $$xpass`;				\
709
+	all=`expr $$all - $$skip`;					\
710
+	if test "$$all" -eq 1; then tests=test; All=;			\
711
+	else tests=tests; All="All "; fi;				\
712
+	case fail=$$fail:xpass=$$xpass:xfail=$$xfail in			\
713
+	  fail=0:xpass=0:xfail=0)					\
714
+	    msg="$$All$$all $$tests passed.  ";				\
715
+	    exit=true;;							\
716
+	  fail=0:xpass=0:xfail=*)					\
717
+	    msg="$$All$$all $$tests behaved as expected";		\
718
+	    if test "$$xfail" -eq 1; then xfailures=failure;		\
719
+	    else xfailures=failures; fi;				\
720
+	    msg="$$msg ($$xfail expected $$xfailures).  ";		\
721
+	    exit=true;;							\
722
+	  fail=*:xpass=0:xfail=*)					\
723
+	    msg="$$fail of $$all $$tests failed.  ";			\
724
+	    exit=false;;						\
725
+	  fail=*:xpass=*:xfail=*)					\
726
+	    msg="$$failures of $$all $$tests did not behave as expected"; \
727
+	    if test "$$xpass" -eq 1; then xpasses=pass;			\
728
+	    else xpasses=passes; fi;					\
729
+	    msg="$$msg ($$xpass unexpected $$xpasses).  ";		\
730
+	    exit=false;;						\
731
+	  *)								\
732
+	    echo >&2 "incorrect case"; exit 4;;				\
733
+	esac;								\
734
+	if test "$$skip" -ne 0; then					\
735
+	  if test "$$skip" -eq 1; then					\
736
+	    msg="$$msg($$skip test was not run).  ";			\
737
+	  else								\
738
+	    msg="$$msg($$skip tests were not run).  ";			\
739
+	  fi;								\
740
+	fi;								\
741
+	{								\
742
+	  echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" |	\
743
+	    $(am__rst_title);						\
744
+	  echo "$$msg";							\
745
+	  echo;								\
746
+	  echo ".. contents:: :depth: 2";				\
747
+	  echo;								\
748
+	  for f in $$list; do						\
749
+	    read line < $$f;						\
750
+	    case $$line in						\
751
+	      PASS:*|XFAIL:*);;						\
752
+	      *) echo; cat $$f;;					\
753
+	    esac;							\
754
+	  done;								\
755
+	} >$(TEST_SUITE_LOG).tmp;					\
756
+	mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG);			\
757
+	if test "$$failures" -ne 0; then				\
758
+	  msg="$${msg}See $(subdir)/$(TEST_SUITE_LOG).  ";		\
759
+	  if test -n "$(PACKAGE_BUGREPORT)"; then			\
760
+	    msg="$${msg}Please report to $(PACKAGE_BUGREPORT).  ";	\
761
+	  fi;								\
762
+	fi;								\
763
+	test x"$$VERBOSE" = x || $$exit || cat $(TEST_SUITE_LOG);	\
764
+	$(am__tty_colors);						\
765
+	if $$exit; then							\
766
+	  echo $(ECHO_N) "$$grn$(ECHO_C)";				\
767
+	 else								\
768
+	  echo $(ECHO_N) "$$red$(ECHO_C)";				\
769
+	fi;								\
770
+	echo "$$msg" | $(am__text_box);					\
771
+	echo $(ECHO_N) "$$std$(ECHO_C)";				\
772
+	$$exit
773
+
774
+# Run all the tests.
775
+check-TESTS:
776
+	@list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
777
+	@test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
778
+	@set_logs=; if test "X$(TEST_LOGS)" = X.log; then		\
779
+	  set_logs=TEST_LOGS=;						\
780
+	fi;								\
781
+	$(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) $$set_logs
782
+
783
+.log.html:
784
+	@list='$(RST2HTML) $$RST2HTML rst2html rst2html.py';		\
785
+	for r2h in $$list; do						\
786
+	  if ($$r2h --version) >/dev/null 2>&1; then			\
787
+	    R2H=$$r2h;							\
788
+	  fi;								\
789
+	done;								\
790
+	if test -z "$$R2H"; then					\
791
+	  echo >&2 "cannot find rst2html, cannot create $@";		\
792
+	  exit 2;							\
793
+	fi;								\
794
+	$$R2H $< >$@.tmp
795
+	@mv $@.tmp $@
796
+
797
+# Be sure to run check first, and then to convert the result.
798
+# Beware of concurrent executions.  Run "check" not "check-TESTS", as
799
+# check-SCRIPTS and other dependencies are rebuilt by the former only.
800
+# And expect check to fail.
801
+check-html:
802
+	@if $(MAKE) $(AM_MAKEFLAGS) check; then			\
803
+	  rv=0; else rv=$$?;					\
804
+	fi;							\
805
+	$(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_HTML) || exit 4;	\
806
+	exit $$rv
807
+recheck recheck-html:
808
+	@target=`echo $@ | sed 's,^re,,'`;				\
809
+	list='$(TEST_LOGS)';						\
810
+	list=`for f in $$list; do					\
811
+	        test -f $$f || continue;				\
812
+	        if read line < $$f; then				\
813
+	          case $$line in FAIL*|XPASS*) echo $$f;; esac;		\
814
+	        else echo $$f; fi;					\
815
+	      done | tr '\012\015' '  '`;				\
816
+	$(MAKE) $(AM_MAKEFLAGS) $$target AM_MAKEFLAGS='$(AM_MAKEFLAGS) TEST_LOGS="'"$$list"'"'
817
+check_clamav.log: check_clamav$(EXEEXT)
818
+	@p='check_clamav$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
819
+check_freshclam.sh.log: check_freshclam.sh
820
+	@p='check_freshclam.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
821
+check_sigtool.sh.log: check_sigtool.sh
822
+	@p='check_sigtool.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
823
+check1_clamscan.sh.log: check1_clamscan.sh
824
+	@p='check1_clamscan.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
825
+check2_clamd.sh.log: check2_clamd.sh
826
+	@p='check2_clamd.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
827
+check3_clamd.sh.log: check3_clamd.sh
828
+	@p='check3_clamd.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
829
+check4_clamd.sh.log: check4_clamd.sh
830
+	@p='check4_clamd.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
831
+check5_clamd_vg.sh.log: check5_clamd_vg.sh
832
+	@p='check5_clamd_vg.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
833
+check6_clamd_vg.sh.log: check6_clamd_vg.sh
834
+	@p='check6_clamd_vg.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
835
+check7_clamd_hg.sh.log: check7_clamd_hg.sh
836
+	@p='check7_clamd_hg.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
837
+check8_clamd_hg.sh.log: check8_clamd_hg.sh
838
+	@p='check8_clamd_hg.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
839
+.test.log:
840
+	@p='$<'; $(am__check_pre) $(TEST_LOG_COMPILE) "$$tst" $(am__check_post)
841
+@am__EXEEXT_TRUE@.test$(EXEEXT).log:
842
+@am__EXEEXT_TRUE@	@p='$<'; $(am__check_pre) $(TEST_LOG_COMPILE) "$$tst" $(am__check_post)
757 843
 
758 844
 distdir: $(DISTFILES)
759 845
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
... ...
@@ -806,6 +962,10 @@ install-strip:
806 806
 	  `test -z '$(STRIP)' || \
807 807
 	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
808 808
 mostlyclean-generic:
809
+	-test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS)
810
+	-test -z "$(TEST_LOGS_TMP)" || rm -f $(TEST_LOGS_TMP)
811
+	-test -z "$(TEST_SUITE_HTML)" || rm -f $(TEST_SUITE_HTML)
812
+	-test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
809 813
 
810 814
 clean-generic:
811 815
 	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
... ...
@@ -889,24 +1049,33 @@ ps-am:
889 889
 
890 890
 uninstall-am:
891 891
 
892
-.MAKE: check-am install-am install-strip
893
-
894
-.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
895
-	clean-checkPROGRAMS clean-generic clean-libtool clean-local \
896
-	ctags distclean distclean-compile distclean-generic \
897
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
898
-	html-am info info-am install install-am install-data \
899
-	install-data-am install-dvi install-dvi-am install-exec \
900
-	install-exec-am install-html install-html-am install-info \
901
-	install-info-am install-man install-pdf install-pdf-am \
902
-	install-ps install-ps-am install-strip installcheck \
903
-	installcheck-am installdirs maintainer-clean \
892
+.MAKE: check-am check-html install-am install-strip recheck \
893
+	recheck-html
894
+
895
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am check-html \
896
+	clean clean-checkPROGRAMS clean-generic clean-libtool \
897
+	clean-local ctags distclean distclean-compile \
898
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
899
+	dvi-am html html-am info info-am install install-am \
900
+	install-data install-data-am install-dvi install-dvi-am \
901
+	install-exec install-exec-am install-html install-html-am \
902
+	install-info install-info-am install-man install-pdf \
903
+	install-pdf-am install-ps install-ps-am install-strip \
904
+	installcheck installcheck-am installdirs maintainer-clean \
904 905
 	maintainer-clean-generic mostlyclean mostlyclean-compile \
905 906
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
906
-	tags uninstall uninstall-am
907
-
908
-
909
-check_clamd.sh: $(FILES)
907
+	recheck recheck-html tags uninstall uninstall-am
908
+
909
+
910
+check2_clamd.sh: $(FILES)
911
+check3_clamd.sh: $(FILES)
912
+check4_clamd.sh: $(FILES)
913
+check5_clamd_vg.sh: $(FILES)
914
+check6_clamd_vg.sh: $(FILES)
915
+check7_clamd_vg.sh: $(FILES)
916
+check8_clamd_hg.sh: $(FILES)
917
+check9_clamd_hg.sh: $(FILES)
918
+check10_clamd_hg.sh: $(FILES)
910 919
 
911 920
 $(FILES) :
912 921
 	cat $(SPLIT_DIR)/split.$@aa $(SPLIT_DIR)/split.$@ab > $@
913 922
new file mode 100755
... ...
@@ -0,0 +1,3 @@
0
+#!/bin/sh
1
+. $abs_srcdir/check_common.sh
2
+test_clamscan 1
0 3
new file mode 100755
... ...
@@ -0,0 +1,3 @@
0
+#!/bin/sh
1
+. $srcdir/check_common.sh
2
+test_clamd1 2
0 3
new file mode 100755
... ...
@@ -0,0 +1,3 @@
0
+#!/bin/sh
1
+. $srcdir/check_common.sh
2
+test_clamd2 3
0 3
new file mode 100755
... ...
@@ -0,0 +1,3 @@
0
+#!/bin/sh 
1
+. $srcdir/check_common.sh
2
+test_clamd3 4
0 3
new file mode 100755
... ...
@@ -0,0 +1,5 @@
0
+#!/bin/sh
1
+. $srcdir/check_common.sh
2
+init_valgrind
3
+WRAPPER="$VALGRIND $VALGRIND_FLAGS" test_clamd1 5
4
+end_valgrind
0 5
new file mode 100755
... ...
@@ -0,0 +1,5 @@
0
+#!/bin/sh
1
+. $srcdir/check_common.sh
2
+init_valgrind
3
+WRAPPER="$VALGRIND $VALGRIND_FLAGS" test_clamd2 6
4
+end_valgrind
0 5
new file mode 100755
... ...
@@ -0,0 +1,5 @@
0
+#!/bin/sh
1
+. $srcdir/check_common.sh
2
+init_helgrind
3
+WRAPPER="$VALGRIND $VALGRIND_FLAGS_RACE" test_clamd1 7
4
+end_valgrind
0 5
new file mode 100755
... ...
@@ -0,0 +1,5 @@
0
+#!/bin/sh
1
+. $srcdir/check_common.sh
2
+init_helgrind
3
+WRAPPER="$VALGRIND $VALGRIND_FLAGS_RACE" test_clamd2 8
4
+end_valgrind
0 5
deleted file mode 100755
... ...
@@ -1,289 +0,0 @@
1
-#!/bin/sh 
2
-CLAMD_WRAPPER=${CLAMD_WRAPPER-}
3
-CLAMD_TEST_UNIQ1=${CLAMD_TEST_UNIQ1-1}
4
-CLAMD_TEST_UNIQ2=${CLAMD_TEST_UNIQ2-2}
5
-TOP="../.."
6
-LTEXEC="$TOP/libtool --mode=execute"
7
-killclamd() {
8
-	test -f clamd-test.pid || return
9
-	pid=`cat clamd-test.pid 2>/dev/null`
10
-	if test "X$pid" = "X"; then
11
-		# file can be removed between the 'test' and 'cat',
12
-		# it happened a few times for me
13
-		return
14
-	fi
15
-	kill -0 $pid 2>/dev/null || return
16
-	kill $pid
17
-	pippo=0
18
-	while kill -0 $pid 2>/dev/null; do
19
-		sleep 1
20
-		pippo=`expr $pippo + 1`
21
-		if test $pippo -gt 9; then
22
-			kill -KILL $pid
23
-			echo "Clamd didn't quit";
24
-			rm -f clamd-test.pid
25
-			exit 4;
26
-		fi
27
-	done
28
-	rm -f clamd-test.pid
29
-}
30
-
31
-die()
32
-{
33
-	killclamd
34
-	exit $1
35
-}
36
-
37
-error()
38
-{
39
-	echo >&2
40
-	echo "***" >&2
41
-	echo "*** $1" >&2
42
-	echo "***" >&2
43
-}
44
-
45
-scan_failed() {
46
-	if test "X$unrar_disabled" = "X1" && test `grep -v '\.rar' $1 | grep OK | wc -l` -eq 0
47
-	then
48
-		error "UNRAR is disabled, won't be able to detect unrar files!";
49
-	else
50
-		error  $2;
51
-		die 2;
52
-	fi
53
-}
54
-
55
-start_clamd()
56
-{
57
-	rm -f clamd-test.log ../clamd-test1.log ../clamd-test2.log
58
-	$LTEXEC $CLAMD_WRAPPER $TOP/clamd/clamd -c $1 --help >clamd-test.log 2>&1 || 
59
-		{ error "Failed to start clamd --help!"; cat clamd-test.log; die 1; }
60
-	grep "Clam AntiVirus Daemon" clamd-test.log >/dev/null ||
61
-		{ error "Wrong --help reply from clamd!"; die 1; }
62
-	$LTEXEC $CLAMD_WRAPPER $TOP/clamd/clamd -c $1 >clamd-test.log 2>&1 || 
63
-		{ error "Failed to start clamd!"; cat clamd-test.log; die 1; }
64
-}
65
-
66
-run_clamdscan_fileonly() {
67
-	rm -f clamdscan.log clamdscan-multiscan.log
68
-	$TOP/clamdscan/clamdscan --version --config-file=test-clamd.conf 2>&1|grep "^ClamAV" >/dev/null || 
69
-		{ error "clamdscan can't get version of clamd!"; die 1;}
70
-	$TOP/clamdscan/clamdscan --quiet --config-file=test-clamd.conf $* --log=clamdscan.log
71
-	if test $? = 2; then 
72
-		error "Failed to run clamdscan!"
73
-		cat clamdscan.log
74
-		die 1
75
-	fi
76
-	$TOP/clamdscan/clamdscan --quiet --config-file=test-clamd.conf $* -m --log=clamdscan-multiscan.log
77
-	if test $? = 2; then 
78
-		error "Failed to run clamdscan (multiscan)!"
79
-		cat clamdscan-multiscan.log
80
-		die 1
81
-	fi
82
-}
83
-
84
-run_clamdscan() {
85
-	run_clamdscan_fileonly $*
86
-	rm -f clamdscan-fdpass.log clamdscan-multiscan-fdpass.log
87
-	$TOP/clamdscan/clamdscan --quiet --config-file=test-clamd.conf $* --fdpass --log=clamdscan-fdpass.log
88
-	if test $? = 2; then 
89
-		error "Failed to run clamdscan (fdpass)!"
90
-		cat clamdscan-fdpass.log
91
-		die 1
92
-	fi
93
-	$TOP/clamdscan/clamdscan --quiet --config-file=test-clamd.conf $* -m --fdpass --log=clamdscan-multiscan-fdpass.log
94
-	if test $? = 2; then 
95
-		error "Failed to run clamdscan (fdpass + multiscan)!"
96
-		cat clamdscan-multiscan-fdpass.log
97
-		die 1
98
-	fi
99
-	$TOP/clamdscan/clamdscan --quiet --config-file=test-clamd.conf $* --stream --log=clamdscan-stream.log
100
-	if test $? = 2; then 
101
-		error "Failed to run clamdscan (instream)!"
102
-		cat clamdscan-stream.log
103
-		die 1
104
-	fi
105
-	$TOP/clamdscan/clamdscan --quiet --config-file=test-clamd.conf $* -m --stream --log=clamdscan-multiscan-stream.log
106
-	if test $? = 2; then 
107
-		error "Failed to run clamdscan (instream + multiscan)!"
108
-		cat clamdscan-multiscan-stream.log
109
-		die 1
110
-	fi
111
-}
112
-
113
-run_reload_test()
114
-{
115
-	rm -f reload-testfile
116
-	echo "ClamAV-RELOAD-Test" >reload-testfile
117
-	run_clamdscan reload-testfile
118
-	grep "ClamAV-RELOAD-TestFile" clamdscan.log >/dev/null 2>/dev/null;
119
-	if test $? -eq 0; then
120
-		# it is not supposed to detect until we actually put the
121
-		# signature there and reload!
122
-		error "RELOAD test failed!"
123
-		cat clamdscan.log
124
-		die 10
125
-	fi
126
-	echo "ClamAV-RELOAD-TestFile:0:0:436c616d41562d52454c4f41442d54657374" >test-db/new.ndb
127
-	$TOP/clamdscan/clamdscan --reload --config-file=test-clamd.conf
128
-	if test $? -ne 0; then
129
-		error "clamdscan says reload failed!"
130
-		die 11
131
-	fi
132
-	run_clamdscan reload-testfile
133
-	grep "ClamAV-RELOAD-TestFile" clamdscan.log >/dev/null 2>/dev/null;
134
-	failed=0
135
-	if test $? -ne 0; then
136
-		error "RELOAD test failed! (after reload)"
137
-		cat clamdscan.log
138
-		failed=1
139
-	fi
140
-	grep "ClamAV-RELOAD-TestFile" clamdscan-multiscan.log >/dev/null 2>/dev/null;
141
-	if test $? -ne 0; then
142
-		error "RELOAD test failed! (after reload, multiscan)"
143
-		cat clamdscan-multiscan.log
144
-		failed=1
145
-	fi
146
-	if test "$failed" = "1"; then
147
-		echo "RELOAD tests failed!"
148
-		die 12
149
-	fi
150
-	rm -f reload-testfile
151
-}
152
-
153
-run_clamdscan_fdpass() {
154
-	rm -f clamdscan.log
155
-	$TOP/clamdscan/clamdscan --quiet --fdpass --config-file=test-clamd.conf - <$1 --log=clamdscan.log
156
-	if test $? = 2; then
157
-		error "Failed to run clamdscan (fdpass)!"
158
-		cat clamdscan.log
159
-		die 14
160
-	fi
161
-}
162
-
163
-# We run multiple clamd tests in parallel, each in its own directory
164
-prepare_clamd()
165
-{
166
-	cd clamdtest$1 
167
-	# Set up test DBdir
168
-	rm -rf test-db
169
-	mkdir -p test-db
170
-	cat <<EOF >test-db/test.hdb
171
-aa15bcf478d165efd2065190eb473bcb:544:ClamAV-Test-File
172
-EOF
173
-	cp $abs_srcdir/input/daily.pdb test-db/
174
-	$AWK "{ sub(/X/,\"$1\"); sub(/CWD/,\"`pwd`\"); print }" $abs_srcdir/test-clamd.conf >test-clamd.conf
175
-}
176
-
177
-rm -rf clamdtest$CLAMD_TEST_UNIQ1 clamdtest$CLAMD_TEST_UNIQ2
178
-mkdir clamdtest$CLAMD_TEST_UNIQ1 clamdtest$CLAMD_TEST_UNIQ2 || 
179
-	{ echo "Unable to create temporary directories!"; exit 1; }
180
-
181
-# Prepare configuration for clamd #1 and #2
182
-(prepare_clamd $CLAMD_TEST_UNIQ1)
183
-(prepare_clamd $CLAMD_TEST_UNIQ2)
184
-# Add clamd #2 specific configuration
185
-echo "VirusEvent $abs_srcdir/virusaction-test.sh `pwd`/clamdtest$CLAMD_TEST_UNIQ2 \"Virus found: %v\"" >>clamdtest$CLAMD_TEST_UNIQ2/test-clamd.conf
186
-echo "HeuristicScanPrecedence yes" >>clamdtest$CLAMD_TEST_UNIQ2/test-clamd.conf
187
-grep -v LogFile clamdtest$CLAMD_TEST_UNIQ2/test-clamd.conf >tmp__
188
-mv tmp__ clamdtest$CLAMD_TEST_UNIQ2/test-clamd.conf
189
-
190
-# Start clamd #1 tests
191
-(cd clamdtest$CLAMD_TEST_UNIQ1 
192
-start_clamd test-clamd.conf
193
-
194
-# Test that all testfiles are detected
195
-FILES=$TOP/test/clam*
196
-run_clamdscan $FILES
197
-NFILES=`ls -1 $FILES | wc -l`
198
-NINFECTED=`grep "Infected files" clamdscan.log | cut -f2 -d:|sed -e 's/ //g'`
199
-NINFECTED_MULTI=`grep "Infected files" clamdscan-multiscan.log | cut -f2 -d:|sed -e 's/ //g'`
200
-NINFECTED_FDPASS=`grep "Infected files" clamdscan-fdpass.log | cut -f2 -d:|sed -e 's/ //g'`
201
-NINFECTED_MULTI_FDPASS=`grep "Infected files" clamdscan-multiscan-fdpass.log | cut -f2 -d:|sed -e 's/ //g'`
202
-NINFECTED_STREAM=`grep "Infected files" clamdscan-stream.log | cut -f2 -d:|sed -e 's/ //g'`
203
-NINFECTED_MULTI_STREAM=`grep "Infected files" clamdscan-multiscan-stream.log | cut -f2 -d:|sed -e 's/ //g'`
204
-if test "$NFILES" -ne "0$NINFECTED"; then
205
-	grep OK clamdscan.log
206
-	scan_failed clamdscan.log "clamd did not detect all testfiles correctly!"
207
-fi
208
-if test "$NFILES" -ne "0$NINFECTED_MULTI"; then
209
-	grep OK clamdscan-multiscan.log
210
-	scan_failed clamdscan-multiscan.log "clamd did not detect all testfiles correctly in multiscan mode!"
211
-fi
212
-if test "$NFILES" -ne "0$NINFECTED_FDPASS"; then
213
-	grep OK clamdscan-fdpass.log
214
-	scan_failed clamdscan-multiscan.log "clamd did not detect all testfiles correctly in fdpass mode!"
215
-fi
216
-if test "$NFILES" -ne "0$NINFECTED_MULTI_FDPASS"; then
217
-	grep OK clamdscan-multiscan-fdpass.log
218
-	scan_failed clamdscan-multiscan.log "clamd did not detect all testfiles correctly in fdpass+multiscan mode!"
219
-fi
220
-
221
-$TOP/unit_tests/check_clamd
222
-ecode=$?
223
-if test $ecode -ne 77 && test $ecode -ne 0; then
224
-    error "Failed clamd protocol test!"
225
-    die 1
226
-fi
227
-# Test HeuristicScanPrecedence off feature
228
-run_clamdscan ../clam-phish-exe
229
-grep "ClamAV-Test-File" clamdscan.log >/dev/null 2>/dev/null;
230
-if test $? -ne 0; then
231
-	error "HeuristicScanPrecedence off test failed!"
232
-	cat clamdscan.log
233
-	die 4
234
-fi
235
-die 0
236
-)&
237
-pid1=$!
238
-
239
-# Start clamd #2 tests
240
-(cd clamdtest$CLAMD_TEST_UNIQ2
241
-start_clamd test-clamd.conf
242
-
243
-# Test VirusEvent feature
244
-run_clamdscan_fileonly $TOP/test/clam.exe
245
-grep "Virus found: ClamAV-Test-File.UNOFFICIAL" test-clamd.log >/dev/null 2>/dev/null; 
246
-if test $? -ne 0; then
247
-	error "Virusaction test failed!" 
248
-	cat test-clamd.log
249
-	die 2
250
-fi
251
-
252
-# Test HeuristicScanPrecedence feature
253
-run_clamdscan ../clam-phish-exe
254
-grep "Phishing.Heuristics.Email.SpoofedDomain" clamdscan.log >/dev/null 2>/dev/null;
255
-if test $? -ne 0; then
256
-	error "HeuristicScanPrecedence on test failed!"
257
-	cat clamdscan.log
258
-	die 3
259
-fi
260
-
261
-if grep "^#define HAVE_FD_PASSING 1" $TOP/clamav-config.h >/dev/null; then
262
-	run_clamdscan_fdpass $TOP/test/clam.exe
263
-	grep "ClamAV-Test-File" clamdscan.log >/dev/null 2>/dev/null;
264
-	if test $? -ne 0; then
265
-		error "FDpassing test failed!"
266
-		cat clamdscan.log;
267
-		die 4
268
-	fi
269
-else
270
-	echo "*** No file descriptor passing support, skipping test"
271
-fi
272
-
273
-# Test RELOAD command
274
-run_reload_test
275
-
276
-die 0
277
-)&
278
-
279
-pid2=$!
280
-
281
-wait $pid1
282
-exitcode1=$?
283
-wait $pid2
284
-exitcode2=$?
285
-rm -rf clamdtest$CLAMD_TEST_UNIQ1 clamdtest$CLAMD_TEST_UNIQ2 test-db accdenied
286
-if (test $exitcode1 -ne 0 && test $exitcode1 -ne 127) || (test $exitcode2 -ne 0	&& test $exitcode2 -ne 127); then
287
-	exit 1
288
-fi
289
-exit 0
290 1
deleted file mode 100755
... ...
@@ -1,66 +0,0 @@
1
-#!/bin/sh 
2
-CLAMSCAN_WRAPPER=${CLAMSCAN_WRAPPER-}
3
-die() {
4
-	rm -rf test-db
5
-	exit $1;
6
-}
7
-
8
-scan_failed() {
9
-	if test "X$unrar_disabled" = "X1" && test `grep -v '\.rar' $1 | grep OK | wc -l` -eq 0
10
-	then
11
-		echo "***" >&2;
12
-		echo "*** UNRAR is disabled, won't be able to detect unrar files!" >&2;
13
-		echo "***" >&2;
14
-	else
15
-		echo "clamscan did not detect all testfiles correctly!" >&2;
16
-		die 2;
17
-	fi
18
-}
19
-
20
-mkdir test-db
21
-cat <<EOF >test-db/test.hdb
22
-aa15bcf478d165efd2065190eb473bcb:544:ClamAV-Test-File
23
-EOF
24
-rm -f clamscan.log
25
-../libtool --mode=execute $CLAMSCAN_WRAPPER ../clamscan/clamscan --quiet -dtest-db/test.hdb ../test/clam* --log=clamscan.log
26
-if test $? != 1; then
27
-	echo "Error running clamscan: $?" >&2;
28
-	grep OK clamscan.log >&2;
29
-	die 1;
30
-fi
31
-NFILES=`ls -1 ../test/clam* | wc -l`
32
-NINFECTED=`grep "Infected files" clamscan.log | cut -f2 -d: |sed -e 's/ //g'`
33
-if test "$NFILES" -ne "0$NINFECTED"; then
34
-	grep OK clamscan.log >&2;
35
-	scan_failed clamscan.log
36
-fi
37
-
38
-cat <<EOF >test-db/test.pdb
39
-H:example.com
40
-EOF
41
-rm -f clamscan2.log
42
-../clamscan/clamscan  -dtest-db $abs_srcdir/input/phish-test-* --log=clamscan2.log --quiet
43
-val=$?
44
-if test $val != 0; then
45
-	if test $val = 1; then
46
-		echo "clamscan detected a file it shouldn't" >&2
47
-		grep FOUND clamscan2.log
48
-		die 3;
49
-	fi
50
-	echo "Error running clamscan: $val" >&2;
51
-	die 3;
52
-fi
53
-
54
-rm -f clamscan2.log
55
-../clamscan/clamscan --phishing-ssl --phishing-cloak -dtest-db $abs_srcdir/input/phish-test-* --log=clamscan2.log --quiet
56
-val=$?
57
-if test $val != 1; then
58
-	echo "Error running clamscan: $val" >&2;
59
-	die 3;
60
-fi
61
-grep "phish-test-ssl: Phishing.Heuristics.Email.SSL-Spoof FOUND" clamscan2.log >/dev/null && grep "phish-test-cloak: Phishing.Heuristics.Email.Cloaked.Null FOUND" clamscan2.log >/dev/null
62
-if test $? -ne 0; then
63
-	echo "Error on ssl/cloak phishing test" >&2;
64
-	die 4;
65
-fi
66
-die 0;
67 1
new file mode 100644
... ...
@@ -0,0 +1,318 @@
0
+#!/bin/sh
1
+set -e
2
+
3
+WRAPPER=${WRAPPER-}
4
+TOP=`pwd`/..
5
+CLAMSCAN=$TOP/clamscan/clamscan
6
+CLAMD=$TOP/clamd/clamd
7
+CHECK_CLAMD=$TOP/unit_tests/check_clamd
8
+CLAMDSCAN=$TOP/clamdscan/clamdscan
9
+TESTFILES=$TOP/test/clam*
10
+NFILES=`ls -1 $TESTFILES | wc -l`
11
+
12
+killclamd() {
13
+    test -f clamd-test.pid &&
14
+    pid=`cat clamd-test.pid 2>/dev/null` &&
15
+    test -n "$pid" &&
16
+    kill -0 $pid 2>/dev/null &&
17
+    kill $pid 2>/dev/null &&
18
+    kill -0 $pid 2>/dev/null &&
19
+    sleep 1 &&
20
+    kill -0 $pid 2>/dev/null &&
21
+    sleep 9 &&
22
+    kill -0 $pid 2>/dev/null &&
23
+    kill -KILL $pid || true
24
+}
25
+
26
+error()
27
+{
28
+	echo >&2
29
+	echo "***" >&2
30
+	echo "*** $1" >&2
31
+	echo "***" >&2
32
+}
33
+
34
+die()
35
+{
36
+	error "$1"
37
+	test -f valgrind.log && cat valgrind.log || true
38
+	killclamd
39
+	exit 42
40
+}
41
+
42
+# Setup test directory to avoid temporary and output file clashes
43
+test_start() {
44
+    ulimit -t 120; ulimit -d 512000; ulimit -v 512000;
45
+    (cd test-$1 2>/dev/null && killclamd || true)
46
+    rm -rf test-$1
47
+    mkdir test-$1
48
+    cd test-$1
49
+    mkdir test-db
50
+    cat <<EOF >test-db/test.hdb
51
+aa15bcf478d165efd2065190eb473bcb:544:ClamAV-Test-File
52
+EOF
53
+    cat <<EOF >test-clamd.conf
54
+LogFile `pwd`/clamd-test.log
55
+LogFileMaxSize 0
56
+LogTime yes
57
+Debug yes
58
+LogClean yes
59
+LogVerbose yes
60
+PidFile `pwd`/clamd-test.pid
61
+DatabaseDirectory `pwd`/test-db
62
+LocalSocket clamd-test.socket
63
+TCPAddr 127.0.0.1
64
+# using different port here to avoid conflicts with system clamd daemon
65
+TCPSocket 331$1
66
+ExitOnOOM yes
67
+DetectPUA yes
68
+ScanPDF yes
69
+CommandReadTimeout 1
70
+MaxQueue 800
71
+MaxConnectionQueueLength 1024
72
+EOF
73
+}
74
+
75
+# arg1: expected exitcode
76
+test_run() {
77
+   expected=$1
78
+   shift
79
+   set +e
80
+   $TOP/libtool --mode=execute $WRAPPER $*
81
+   val=$?
82
+   if test $val -ne $expected; then
83
+       error "Failed to run $*, expected $expected exitcode, but was $val" >&2;
84
+       return 0;
85
+   fi
86
+   set -e
87
+   return 1;
88
+}
89
+
90
+# Run a test and return its exitcode
91
+test_run_check() {
92
+    set +e
93
+    $TOP/libtool --mode=execute $WRAPPER $*
94
+    val=$?
95
+    set -e
96
+    return $?;
97
+}
98
+
99
+# test successfully finished, remove test dir
100
+test_end() {
101
+    killclamd
102
+    cd ..
103
+    rm -rf test-$1
104
+}
105
+
106
+scan_failed() {
107
+    if test "X$unrar_disabled" = "X1" && test `grep -v '\.rar' $1 | grep OK | wc -l` -eq 0
108
+    then
109
+	error "UNRAR is disabled, won't be able to detect unrar files!"
110
+    else
111
+	cat $1
112
+    	die "$2";
113
+    fi
114
+}
115
+
116
+# ----------- valgrind wrapper 
117
+init_valgrind() {
118
+    test "x$VG" = "x1" || { echo "*** valgrind tests skipped by default, use 'make check VG=1' to activate"; exit 77; }
119
+    export VALGRIND=`which ${VALGRIND-valgrind}`
120
+    export VALGRIND_COMMON_FLAGS="-v --trace-children=yes --suppressions=$abs_srcdir/valgrind.supp --log-file=valgrind.log --error-exitcode=123 $GENSUPP"
121
+    export VALGRIND_FLAGS="$VALGRIND_COMMON_FLAGS --track-fds=yes --leak-check=full"
122
+    export VALGRIND_FLAGS_RACE="$VALGRIND_COMMON_FLAGS --tool=helgrind"
123
+    test -n "$VALGRIND" || { echo "*** valgrind not found, skipping test"; exit 77; }
124
+    test -x "$VALGRIND" || { echo "*** valgrind not executable, skipping test"; exit 77; }
125
+}
126
+
127
+init_helgrind() {
128
+    init_valgrind
129
+}
130
+
131
+end_valgrind() {
132
+    NRUNS=`grep -a "ERROR SUMMARY" valgrind.log | wc -l`
133
+    if test $NRUNS -ne `grep -a "ERROR SUMMARY: 0 errors" valgrind.log | wc -l` || 
134
+	test `grep -a "FATAL:" valgrind.log|wc -l` -ne 0; then
135
+	cat valgrind.log
136
+	die "Valgrind tests failed"
137
+    fi
138
+}
139
+
140
+# ----------- clamscan tests --------------------------------------------------------
141
+test_clamscan() {
142
+    test_start $1
143
+    if test_run 1 $CLAMSCAN --quiet -dtest-db/test.hdb $TESTFILES --log=clamscan.log; then
144
+	scan_failed clamscan.log "clamscan didn't detect all testfiles correctly"
145
+    fi
146
+    NINFECTED=`grep "Infected files" clamscan.log | cut -f2 -d: | sed -e 's/ //g'`
147
+    if test "$NFILES" -ne "0$NINFECTED"; then
148
+	scan_failed clamscan.log "clamscan didn't detect all testfiles correctly"
149
+    fi
150
+
151
+    cat <<EOF >test-db/test.pdb
152
+H:example.com
153
+EOF
154
+    if test_run 0 $CLAMSCAN --quiet -dtest-db $abs_srcdir/input/phish-test-* --log=clamscan2.log; then
155
+	cat clamscan2.log;
156
+	die "Failed to run clamscan (phish-test)";
157
+    fi
158
+
159
+    if test_run 1 $CLAMSCAN --quiet --phishing-ssl --phishing-cloak -dtest-db $abs_srcdir/input/phish-test-* --log=clamscan3.log; then
160
+	cat clamscan3.log;
161
+	die "Failed to run clamscan (phish-test2)";
162
+    fi
163
+
164
+    grep "phish-test-ssl: Phishing.Heuristics.Email.SSL-Spoof FOUND" clamscan3.log >/dev/null || die "phish-test1 failed";
165
+    grep "phish-test-cloak: Phishing.Heuristics.Email.Cloaked.Null FOUND" clamscan3.log >/dev/null || die "phish-test2 failed";
166
+    test_end $1
167
+}
168
+
169
+# ----------- clamd tests --------------------------------------------------------
170
+start_clamd()
171
+{
172
+    cp $abs_srcdir/input/daily.pdb test-db/daily.pdb
173
+    if test_run 0 $CLAMD -c test-clamd.conf --help >clamd-test.log; then
174
+	die "Failed to run clamd --help";
175
+    fi
176
+    grep "Clam AntiVirus Daemon" clamd-test.log >/dev/null || die "Wrong --help reply from clamd!";
177
+    if test_run 0 $CLAMD -c test-clamd.conf >clamd-test.log 2>&1; then
178
+	cat clamd-test.log
179
+	die "Failed to run clamd";
180
+    fi
181
+}
182
+
183
+run_clamdscan_fileonly() {
184
+    rm -f clamdscan.log clamdscan-multiscan.log
185
+    $CLAMDSCAN --version --config-file=test-clamd.conf | grep "^ClamAV" >/dev/null || die "clamdscan can't get version of clamd!";
186
+    set +e
187
+    $CLAMDSCAN --quiet --config-file=test-clamd.conf $* --log=clamdscan.log
188
+    if test $? = 2; then
189
+	die "Failed to run clamdscan!"
190
+    fi
191
+    $CLAMDSCAN --quiet --config-file=test-clamd.conf $* -m --log=clamdscan-multiscan.log
192
+    if test $? = 2; then
193
+	die "Failed to run clamdscan (multiscan)!"
194
+    fi
195
+    set -e
196
+}
197
+
198
+run_clamdscan() {
199
+    run_clamdscan_fileonly $*
200
+    rm -f clamdscan-fdpass.log clamdscan-multiscan-fdpass.log clamdscan-stream.log clamdscan-multiscan-stream.log
201
+    set +e
202
+    $CLAMDSCAN --quiet --config-file=test-clamd.conf $* --fdpass --log=clamdscan-fdpass.log
203
+    if test $? = 2; then 
204
+	die "Failed to run clamdscan (fdpass)!"
205
+    fi
206
+    $CLAMDSCAN --quiet --config-file=test-clamd.conf $* -m --fdpass --log=clamdscan-multiscan-fdpass.log
207
+    if test $? = 2; then 
208
+        die "Failed to run clamdscan (fdpass + multiscan)!"
209
+    fi
210
+    $CLAMDSCAN --quiet --config-file=test-clamd.conf $* --stream --log=clamdscan-stream.log
211
+    if test $? = 2; then 
212
+    	die "Failed to run clamdscan (instream)!"
213
+    fi
214
+    $CLAMDSCAN --quiet --config-file=test-clamd.conf $* -m --stream --log=clamdscan-multiscan-stream.log
215
+    if test $? = 2; then 
216
+	die "Failed to run clamdscan (instream + multiscan)!"
217
+    fi
218
+    set -e
219
+}
220
+
221
+run_reload_test()
222
+{
223
+	echo "ClamAV-RELOAD-Test" >reload-testfile
224
+	run_clamdscan reload-testfile
225
+	# it is not supposed to detect until we actually put the
226
+	# signature there and reload!
227
+	grep "ClamAV-RELOAD-TestFile" clamdscan.log >/dev/null 2>/dev/null && die "RELOAD test(1) failed!"
228
+	echo "ClamAV-RELOAD-TestFile:0:0:436c616d41562d52454c4f41442d54657374" >test-db/new.ndb
229
+	$CLAMDSCAN --reload --config-file=test-clamd.conf || die "clamdscan says reload failed!"
230
+	run_clamdscan reload-testfile
231
+	failed=0
232
+	grep "ClamAV-RELOAD-TestFile" clamdscan.log >/dev/null 2>/dev/null || die "RELOAD test failed! (after reload)"
233
+	grep "ClamAV-RELOAD-TestFile" clamdscan-multiscan.log >/dev/null 2>/dev/null || die "RELOAD test failed! (after reload, multiscan)"
234
+}
235
+
236
+run_clamdscan_fdpass() {
237
+    set +e
238
+    $CLAMDSCAN --quiet --fdpass --config-file=test-clamd.conf - <$1 --log=clamdscan.log
239
+    if test $? = 2; then
240
+    	die "Failed to run clamdscan (fdpass)!"
241
+    fi
242
+    set -e
243
+}
244
+
245
+test_clamd1() {
246
+    test_start $1
247
+    start_clamd
248
+    # Test that all testfiles are detected
249
+    run_clamdscan $TESTFILES
250
+    NINFECTED=`grep "Infected files" clamdscan.log | cut -f2 -d:|sed -e 's/ //g'`
251
+    NINFECTED_MULTI=`grep "Infected files" clamdscan-multiscan.log | cut -f2 -d:|sed -e 's/ //g'`
252
+    NINFECTED_FDPASS=`grep "Infected files" clamdscan-fdpass.log | cut -f2 -d:|sed -e 's/ //g'`
253
+    NINFECTED_MULTI_FDPASS=`grep "Infected files" clamdscan-multiscan-fdpass.log | cut -f2 -d:|sed -e 's/ //g'`
254
+    NINFECTED_STREAM=`grep "Infected files" clamdscan-stream.log | cut -f2 -d:|sed -e 's/ //g'`
255
+    NINFECTED_MULTI_STREAM=`grep "Infected files" clamdscan-multiscan-stream.log | cut -f2 -d:|sed -e 's/ //g'`
256
+    if test "$NFILES" -ne "0$NINFECTED"; then
257
+	scan_failed clamdscan.log "clamd did not detect all testfiles correctly!"
258
+    fi
259
+    if test "$NFILES" -ne "0$NINFECTED_MULTI"; then
260
+	scan_failed clamdscan-multiscan.log "clamd did not detect all testfiles correctly in multiscan mode!"
261
+    fi
262
+    if test "$NFILES" -ne "0$NINFECTED_FDPASS"; then
263
+	scan_failed clamdscan-multiscan.log "clamd did not detect all testfiles correctly in fdpass mode!"
264
+    fi
265
+    if test "$NFILES" -ne "0$NINFECTED_MULTI_FDPASS"; then
266
+	scan_failed clamdscan-multiscan.log "clamd did not detect all testfiles correctly in fdpass+multiscan mode!"
267
+    fi
268
+    # Test HeuristicScanPrecedence off feature
269
+    run_clamdscan ../clam-phish-exe
270
+    grep "ClamAV-Test-File" clamdscan.log >/dev/null 2>/dev/null;
271
+    if test $? -ne 0; then
272
+	cat clamdscan.log
273
+	die "HeuristicScanPrecedence off test failed!"
274
+    fi
275
+    test_end $1
276
+}
277
+
278
+test_clamd2() {
279
+    test_start $1
280
+    start_clamd
281
+    # Run clamd test suite
282
+    test_run_check $CHECK_CLAMD
283
+    val=$?
284
+
285
+    # Test RELOAD command
286
+    run_reload_test
287
+
288
+    test_end $1
289
+    exit $?
290
+}
291
+
292
+test_clamd3() {
293
+    test_start $1
294
+    echo "VirusEvent $abs_srcdir/virusaction-test.sh `pwd` \"Virus found: %v\"" >>test-clamd.conf
295
+    echo "HeuristicScanPrecedence yes" >>test-clamd.conf
296
+    start_clamd
297
+    # Test HeuristicScanPrecedence feature
298
+    run_clamdscan ../clam-phish-exe
299
+    grep "Phishing.Heuristics.Email.SpoofedDomain" clamdscan.log >/dev/null 2>/dev/null ||
300
+        { cat clamdscan.log; die "HeuristicScanPrecedence on test failed!"; }
301
+
302
+    if grep "^#define HAVE_FD_PASSING 1" $TOP/clamav-config.h >/dev/null; then
303
+	run_clamdscan_fdpass $TOP/test/clam.exe
304
+	grep "ClamAV-Test-File" clamdscan.log >/dev/null 2>/dev/null ||
305
+	{ cat clamdscan.log; die "FDpassing test failed!";}
306
+    else
307
+	echo "*** No file descriptor passing support, skipping test"
308
+    fi
309
+
310
+    # Test VirusEvent feature
311
+    run_clamdscan_fileonly $TOP/test/clam.exe
312
+    test -f test-clamd.log || sleep 1
313
+    grep "Virus found: ClamAV-Test-File.UNOFFICIAL" test-clamd.log >/dev/null 2>/dev/null ||
314
+	{ cat test-clamd.log || true; die "Virusaction test failed"; }
315
+
316
+    test_end $1
317
+}
0 318
deleted file mode 100644
... ...
@@ -1,19 +0,0 @@
1
-# script will fill in CWD and X
2
-LogFile CWD/../clamd-testX.log
3
-LogFileMaxSize 0
4
-LogTime yes
5
-Debug yes
6
-LogClean yes
7
-LogVerbose yes
8
-PidFile CWD/clamd-test.pid
9
-DatabaseDirectory CWD/test-db
10
-LocalSocket clamd-test.socket
11
-TCPAddr 127.0.0.1
12
-# using different port here to avoid conflicts with system clamd daemon
13
-TCPSocket 331X
14
-ExitOnOOM yes
15
-DetectPUA yes
16
-ScanPDF yes
17
-CommandReadTimeout 1
18
-MaxQueue 800
19
-MaxConnectionQueueLength 1024
... ...
@@ -1,343 +0,0 @@
1
-{
2
-	glibc-freeres-dbg
3
-	Memcheck:Free
4
-	fun:free
5
-	fun:free_mem
6
-	fun:__libc_freeres
7
-}
8
-{
9
-	glibc-freeres
10
-	Memcheck:Free
11
-	fun:free
12
-	obj:/lib*/libc-*.so
13
-	fun:__libc_freeres
14
-}
15
-{
16
-	glibc-etch1
17
-	Memcheck:Free
18
-	fun:*
19
-	fun:_dl_allocate_tls
20
-}
21
-{
22
-	glibc-etch2
23
-	Memcheck:Free
24
-	obj:/lib*/ld-*.so
25
-	obj:/lib*/ld-*.so
26
-}
27
-{
28
-       glibc-etch1
29
-       Memcheck:Free
30
-       fun:*
31
-       fun:_dl_allocate_tls
32
-}
33
-{
34
-       glibc-etch2
35
-       Memcheck:Addr8
36
-       obj:/lib*/ld-*.so
37
-       obj:/lib*/ld-*.so
38
-}
39
-{
40
-       glibc-etch2
41
-       Memcheck:Addr4
42
-       obj:/lib*/ld-*.so
43
-       obj:/lib*/ld-*.so
44
-}
45
-{
46
-	helgrind-glibc27-dbg01
47
-	Helgrind:Race
48
-	fun:mythread_wrapper
49
-	fun:start_thread
50
-}
51
-{
52
-	helgrind-glibc27-dbg02
53
-	Helgrind:Race
54
-	fun:pthread_mutex_*
55
-}
56
-{
57
-	helgrind-glibc27-dbg03
58
-	Helgrind:Race
59
-	fun:pthread_create*
60
-}
61
-{
62
-	helgrind-glibc27-dbg04
63
-	Helgrind:Race
64
-	fun:pthread_create*
65
-}
66
-{
67
-	helgrind-glibc27-dbg05
68
-	Helgrind:Race
69
-	fun:__deallocate_stack
70
-	fun:start_thread
71
-}
72
-{
73
-	helgrind-glibc27-dbg05
74
-	Helgrind:Race
75
-	fun:free_stacks
76
-	fun:__deallocate_stack
77
-	fun:start_thread
78
-}
79
-{
80
-	helgrind-glibc27-dbg06
81
-	Helgrind:Race
82
-	fun:*
83
-	obj:/usr/lib/debug/libpthread-*.so
84
-}
85
-{
86
-	helgrind-glibc27-dbg06
87
-	Helgrind:Race
88
-	fun:*
89
-	obj:/lib/libpthread-*.so
90
-}
91
-{
92
-	helgrind-glibc27-dbg08
93
-	Helgrind:Race
94
-	obj:/lib/ld-*.so
95
-}
96
-{
97
-	helgrind-glibc27-dbg09
98
-	Helgrind:Race
99
-	fun:*
100
-	fun:exit
101
-}
102
-{
103
-	helgrind-glibc27-dbg10
104
-	Helgrind:Race
105
-	fun:*
106
-	fun:*
107
-	fun:exit
108
-}
109
-{
110
-	helgrind-glibc27-dbg11
111
-	Helgrind:Race
112
-	fun:*
113
-	fun:*
114
-	fun:*
115
-	fun:exit
116
-}
117
-{
118
-	helgrind-glibc27-dbg12
119
-	Helgrind:Race
120
-	fun:*
121
-	fun:*
122
-	fun:*
123
-	fun:*
124
-	fun:exit
125
-}
126
-{
127
-	helgrind-glibc27-dbg13
128
-	Helgrind:Race
129
-	fun:*
130
-	fun:*
131
-	fun:ctime_r
132
-}
133
-{
134
-	helgrind-glibc27-dbg15
135
-	Helgrind:Race
136
-	fun:*
137
-	fun:*
138
-	fun:*
139
-	fun:ctime_r
140
-}
141
-{
142
-	helgrind-glibc27-dbg14
143
-	Helgrind:Race
144
-	fun:_IO_link_in
145
-	fun:_IO_file_init*
146
-}
147
-# libc has a gconv_lock, but valgrind doesn't know that because it uses lll_lock
148
-# instead of pthread_mutex_lock
149
-{
150
-	helgrind-glibc27-dbg15
151
-	Helgrind:Race
152
-	fun:__gconv_release_shlib
153
-}
154
-{
155
-	helgrind-glibc27-dbg16
156
-	Helgrind:Race
157
-	fun:__gconv_find_shlib
158
-}
159
-{
160
-	helgrind-glibc27-dbg17
161
-	Helgrind:Race
162
-	fun:exit
163
-}
164
-
165
-{
166
-# suppress false positives, see bb 1189
167
-   chm-etch-gcc41-fp
168
-   Memcheck:Cond
169
-   fun:cli_chm_open
170
-   fun:cli_scanmschm
171
-}
172
-{
173
-   glibc-etch
174
-   Memcheck:Leak
175
-   fun:*
176
-   fun:_dl_allocate_tls
177
-}
178
-{
179
-   glibc-suse
180
-   Memcheck:Leak
181
-   fun:*
182
-   obj:*
183
-   fun:_dl_allocate_tls
184
-}
185
-{
186
-   glibc-tls3
187
-   Memcheck:Leak
188
-   fun:*
189
-   fun:allocate_dtv
190
-   fun:_dl_allocate_tls
191
-}
192
-{
193
-   glibc-tls4
194
-   Memcheck:Leak
195
-   fun:allocate_dtv
196
-   fun:_dl_allocate_tls
197
-}
198
-# glibc uses IO_lock_lock, which uses lll_lock,
199
-# and valgrind doesn't know about it, so it thinks it is unlocked
200
-{
201
-   glibc-IOlock-fp
202
-   Helgrind:Race
203
-   fun:*
204
-   fun:*
205
-   fun:fputs
206
-}
207
-{
208
-   glibc-IOlock-fp
209
-   Helgrind:Race
210
-   fun:fputs
211
-}
212
-{
213
-  glibc-fork
214
-  Helgrind:Race
215
-  fun:fork
216
-}
217
-{
218
-  glibc-fork
219
-  Helgrind:Race
220
-  fun:*
221
-  fun:fork
222
-}
223
-{
224
-  glibc-freetcb
225
-  Helgrind:Race
226
-  fun:__free_tcb
227
-}
228
-{
229
-  glibc-2.5-strcpy_chk
230
-  Memcheck:Addr8
231
-  obj:/lib64/libc-2.5.so
232
-  fun:decodeLine
233
-}
234
-{
235
-  glibc-2.5-strcpy_chk
236
-  Memcheck:Cond
237
-  obj:/lib64/libc-2.5.so
238
-  fun:decodeLine
239
-}
240
-{
241
-  glibc-2.5-strcpy_chk
242
-  Memcheck:Cond
243
-  obj:/lib64/libc-2.5.so
244
-  fun:cli_mbox
245
-}
246
-{
247
-  glibc-2.8-lll
248
-  Helgrind:Race
249
-  fun:__lll_unlock_wake
250
-}
251
-{ 
252
-   glibc-freeres
253
-   Helgrind:Race
254
-   fun: *
255
-   fun: __libc_thread_freeres
256
-}
257
-{
258
-   glibc-poll
259
-   Helgrind:Race
260
-   fun: __libc_enable_asynccancel
261
-   fun: poll
262
-}
263
-{
264
-   glibc-poll
265
-   Helgrind:Race
266
-   fun: _setjmp
267
-   fun: clone
268
-}
269
-{
270
-   glibc-ubuntu-jaunty
271
-   Helgrind:Race
272
-   fun:__fprintf_chk
273
-}
274
-# no symbols in opensuse's libs :(
275
-{	
276
-   glibc-suse
277
-   Helgrind:Race
278
-   obj:/lib*/ld-*.so
279
-   obj:/lib*/ld-*.so
280
-   obj:/lib*/ld-*.so
281
-}
282
-{	
283
-   glibc-suse2
284
-   Helgrind:Race
285
-   obj:/lib*/ld-*.so
286
-   obj:/lib*/ld-*.so
287
-   obj:/lib*/ld-*.so
288
-   obj:/lib*/ld-*.so
289
-}
290
-{
291
-   glibc-suse4
292
-   Helgrind:Race
293
-   obj:/lib*/libc-*.so
294
-   obj:/lib*/libc-*.so
295
-   obj:/lib*/libc-*.so
296
-}
297
-{
298
-   glibc-suse3
299
-   Helgrind:Race
300
-   obj:*
301
-   fun:start_thread
302
-}
303
-{
304
-   helgrind-glibc2X-005-valgrind-3.4.0
305
-   Helgrind:Race
306
-   obj:/lib*/libpthread-2.*so*
307
-}
308
-{
309
-   debian-libc-dbg
310
-   Helgrind:Race
311
-   fun:__pthread_mutex_*
312
-}
313
-{
314
-    debian-libc-dbg
315
-    Helgrind:Race
316
-    fun:pthread_create@*
317
-}
318
-{
319
-    debian-libc-dbg
320
-    Helgrind:Race
321
-    fun:close
322
-}
323
-{
324
-    debian-libc-dbg
325
-    Helgrind:Race
326
-    obj:/usr/lib*/debug/libpthread-2.*so*
327
-}
328
-{
329
-    sighandler-no-mutex
330
-    Helgrind:Race
331
-    fun:sighandler_th
332
-}
333
-{
334
-    sighandler-no-mutex
335
-    Helgrind:Race
336
-    fun:recvloop_th
337
-}
338
-#{
339
-#	helgrind-glibc27-dbg18
340
-#	Helgrind:Race
341
-#	fun:__reclaim_stacks
342
-#	fun:fork
343
-#}
... ...
@@ -17,12 +17,13 @@ parse_valgrindlog()
17 17
 	if test ! -f $1; then
18 18
 		echo "*** Logfile $1 not found. Valgrind failed to run?"
19 19
 	fi
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
20
+	NRUNS=`grep -a "ERROR SUMMARY" $1 | wc -l`
21
+	if test $NRUNS -eq `grep -a "ERROR SUMMARY: 0 errors" $1 | wc -l` && test `grep -a "FATAL:" $1|wc -l ` -eq 0; then
22 22
 		if test "$1" = "valgrind-race.log" || 
23 23
 			test $NRUNS -eq `grep "no leaks are possible" $1 | wc -l` ||
24 24
 			test `grep "lost:" $1 | grep -v " 0 bytes" | wc -l` -eq 0; then 
25 25
 			if test -z "$GENSUPP"; then
26
+			        cp $1 /tmp
26 27
 				rm -f $1;
27 28
 			fi
28 29
 			return
... ...
@@ -62,24 +63,40 @@ else
62 62
 	GENSUPP=
63 63
 fi
64 64
 
65
-VALGRIND_COMMON_FLAGS="-v --trace-children=yes --suppressions=$abs_srcdir/valgrind.supp $GENSUPP"
65
+VALGRIND_COMMON_FLAGS="-v --trace-children=yes --suppressions=$abs_srcdir/valgrind.supp --error-exitcode=123 $GENSUPP"
66 66
 VALGRIND_FLAGS="$VALGRIND_COMMON_FLAGS --track-fds=yes --leak-check=full"
67 67
 VALGRIND_FLAGS_RACE="$VALGRIND_COMMON_FLAGS --tool=helgrind"
68 68
 export CK_DEFAULT_TIMEOUT=40
69 69
 echo "--- Starting check_clamav under valgrind/memcheck"
70 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 &
71
+CK_FORK=no ../libtool --mode=execute $VALGRIND $VALGRIND_FLAGS --log-file=valgrind-check.log ./check_clamav &
72 72
 pid1=$!
73 73
 
74 74
 echo "--- Starting clamd under valgrind/memcheck"
75
-CLAMD_WRAPPER="$VALGRIND $VALGRIND_FLAGS" $abs_srcdir/check_clamd.sh >valgrind-clamd.log 2>&1 &
75
+CLAMD_WRAPPER="$VALGRIND $VALGRIND_FLAGS --log-file=`pwd`/valgrind-clamd.log" $abs_srcdir/check_clamd.sh &
76 76
 pid2=$!
77 77
 
78 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 &
79
+CLAMD_TEST_UNIQ1=3 CLAMD_TEST_UNIQ2=4 CLAMD_WRAPPER="$VALGRIND $VALGRIND_FLAGS_RACE --log-file=`pwd`/valgrind-race.log" $abs_srcdir/check_clamd.sh &
80 80
 pid3=$!
81 81
 
82
-wait $pid1 $pid2 $pid3
82
+errors=0
83
+wait $pid1
84
+if test $? -ne 0; then
85
+    # don't rm logs
86
+    GENSUPP=1
87
+    errors=1
88
+fi
89
+wait $pid2
90
+if test $? -ne 0; then
91
+    GENSUPP=1
92
+    errors=1
93
+fi
94
+wait $pid3
95
+if test $? -ne 0; then
96
+    GENSUPP=1
97
+    errors=1
98
+fi
83 99
 parse_valgrindlog valgrind-check.log
84 100
 parse_valgrindlog valgrind-clamd.log
85 101
 parse_valgrindlog valgrind-race.log
... ...
@@ -87,4 +104,4 @@ parse_valgrindlog valgrind-race.log
87 87
 if test -f valgrind-check.log || test -f valgrind-race.log || test -f valgrind-clamd.log; then
88 88
 	exit 1;
89 89
 fi
90
-exit 0
90
+exit $errors