Browse code

When RAR is disabled, allow make check to succeed, and print only a warning (bb #1212)

* ChangeLog:

git-svn: trunk@4233

Török Edvin authored on 2008/10/08 04:35:41
Showing 5 changed files
... ...
@@ -1,3 +1,11 @@
1
+Tue Oct  7 22:52:06 EEST 2008 (edwin)
2
+-------------------------------------
3
+
4
+ * unit_tests/Makefile.am, unit_tests/Makefile.in,
5
+ unit_tests/check_clamd.sh, unit_tests/check_clamscan.sh: When RAR is
6
+ disabled, allow make check to succeed, and print only a warning (bb
7
+ #1212)
8
+
1 9
 Tue Oct  7 19:18:16 CEST 2008 (tk)
2 10
 ----------------------------------
3 11
   * shared/cfgparser.c, clamconf: gently deprecate obsolete options (bb#1213)
... ...
@@ -10,6 +10,10 @@ programs = check_clamav
10 10
 scripts = check_clamd.sh check_freshclam.sh check_sigtool.sh check_clamscan.sh\
11 11
 	 valgrind_tests.sh efence_tests.sh duma_tests.sh
12 12
 TESTS_ENVIRONMENT=export abs_srcdir=$(abs_srcdir) AWK=$(AWK);
13
+if ENABLE_UNRAR
14
+else
15
+TESTS_ENVIRONMENT += export unrar_disabled=1;
16
+endif
13 17
 TESTS = $(programs) $(scripts)
14 18
 check_PROGRAMS = $(programs)
15 19
 check_SCRIPTS = $(scripts)
... ...
@@ -32,6 +32,7 @@ POST_UNINSTALL = :
32 32
 build_triplet = @build@
33 33
 host_triplet = @host@
34 34
 target_triplet = @target@
35
+@ENABLE_UNRAR_FALSE@am__append_1 = export unrar_disabled=1;
35 36
 TESTS = $(am__EXEEXT_1) $(scripts)
36 37
 check_PROGRAMS = $(am__EXEEXT_1)
37 38
 subdir = unit_tests
... ...
@@ -233,7 +234,8 @@ programs = check_clamav
233 233
 scripts = check_clamd.sh check_freshclam.sh check_sigtool.sh check_clamscan.sh\
234 234
 	 valgrind_tests.sh efence_tests.sh duma_tests.sh
235 235
 
236
-TESTS_ENVIRONMENT = export abs_srcdir=$(abs_srcdir) AWK=$(AWK);
236
+TESTS_ENVIRONMENT = export abs_srcdir=$(abs_srcdir) AWK=$(AWK); \
237
+	$(am__append_1)
237 238
 check_SCRIPTS = $(scripts)
238 239
 @HAVE_LIBCHECK_FALSE@check_clamav_SOURCES = check_clamav_skip.c
239 240
 @HAVE_LIBCHECK_TRUE@check_clamav_SOURCES = check_clamav.c checks.h $(top_builddir)/libclamav/clamav.h\
... ...
@@ -39,6 +39,16 @@ error()
39 39
 	echo "***" >&2
40 40
 }
41 41
 
42
+scan_failed() {
43
+	if test "X$unrar_disabled" = "X1" && test `grep -v '\.rar' $1 | grep OK | wc -l` -eq 0
44
+	then
45
+		error "UNRAR is disabled, won't be able to detect unrar files!";
46
+	else
47
+		error  $2;
48
+		die 2;
49
+	fi
50
+}
51
+
42 52
 start_clamd()
43 53
 {
44 54
 	rm -f clamd-test.log
... ...
@@ -146,14 +156,12 @@ NFILES=`ls -1 $FILES | wc -l`
146 146
 NINFECTED=`grep "Infected files" clamdscan.log | cut -f2 -d:|sed -e 's/ //g'`
147 147
 NINFECTED_MULTI=`grep "Infected files" clamdscan-multiscan.log | cut -f2 -d:|sed -e 's/ //g'`
148 148
 if test "$NFILES" -ne "0$NINFECTED"; then
149
-	error "clamd did not detect all testfiles correctly!"
150 149
 	grep OK clamdscan.log
151
-	die 2
150
+	scan_failed clamdscan.log "clamd did not detect all testfiles correctly!"
152 151
 fi
153 152
 if test "$NFILES" -ne "0$NINFECTED_MULTI"; then
154
-	error "clamd did not detect all testfiles correctly in multiscan mode!"
155 153
 	grep OK clamdscan-multiscan.log
156
-	die 3
154
+	scan_failed clamdscan-multiscan.log "clamd did not detect all testfiles correctly in multiscan mode!"
157 155
 fi
158 156
 
159 157
 # Test HeuristicScanPrecedence off feature
... ...
@@ -1,9 +1,22 @@
1
-#!/bin/sh
1
+#!/bin/sh 
2 2
 CLAMSCAN_WRAPPER=${CLAMSCAN_WRAPPER-}
3 3
 die() {
4 4
 	rm -rf test-db
5 5
 	exit $1;
6 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
+
7 20
 mkdir test-db
8 21
 cat <<EOF >test-db/test.hdb
9 22
 aa15bcf478d165efd2065190eb473bcb:544:ClamAV-Test-File
... ...
@@ -18,9 +31,8 @@ fi
18 18
 NFILES=`ls -1 ../test/clam* | wc -l`
19 19
 NINFECTED=`grep "Infected files" clamscan.log | cut -f2 -d: |sed -e 's/ //g'`
20 20
 if test "$NFILES" -ne "0$NINFECTED"; then
21
-	echo "clamscan did not detect all testfiles correctly!" >&2;
22 21
 	grep OK clamscan.log >&2;
23
-	die 2;
22
+	scan_failed clamscan.log
24 23
 fi
25 24
 
26 25
 cat <<EOF >test-db/test.pdb