Browse code

Fix valgrind tests.

Need to parse the correct valgrind.log when running multiple tests in parallel.

Török Edvin authored on 2010/09/28 19:46:33
Showing 7 changed files
... ...
@@ -2,4 +2,4 @@
2 2
 . $srcdir/check_common.sh
3 3
 init_valgrind
4 4
 WRAPPER="$VALGRIND $VALGRIND_FLAGS" test_clamd1 5
5
-end_valgrind
5
+end_valgrind 5
... ...
@@ -2,4 +2,4 @@
2 2
 . $srcdir/check_common.sh
3 3
 init_valgrind
4 4
 WRAPPER="$VALGRIND $VALGRIND_FLAGS" test_clamd2 6
5
-end_valgrind
5
+end_valgrind 6
... ...
@@ -3,4 +3,4 @@ exit 77
3 3
 . $srcdir/check_common.sh
4 4
 init_helgrind
5 5
 WRAPPER="$VALGRIND $VALGRIND_FLAGS_RACE" test_clamd1 7
6
-end_valgrind
6
+end_valgrind 7
... ...
@@ -2,4 +2,4 @@
2 2
 . $srcdir/check_common.sh
3 3
 init_helgrind
4 4
 WRAPPER="$VALGRIND $VALGRIND_FLAGS_RACE" test_clamd2 8
5
-end_valgrind
5
+end_valgrind 8
... ...
@@ -2,4 +2,4 @@
2 2
 . $srcdir/check_common.sh
3 3
 init_valgrind
4 4
 WRAPPER="$VALGRIND $VALGRIND_FLAGS" test_clamscan 9
5
-end_valgrind
5
+end_valgrind 9
... ...
@@ -107,6 +107,7 @@ test_run_check() {
107 107
 test_end() {
108 108
     killclamd
109 109
     cd ..
110
+    test -f test-$1/valgrind.log && mv -f test-$1/valgrind.log valgrind$1.log
110 111
     rm -rf test-$1
111 112
 }
112 113
 
... ...
@@ -137,10 +138,11 @@ init_helgrind() {
137 137
 }
138 138
 
139 139
 end_valgrind() {
140
-    NRUNS=`grep -a "ERROR SUMMARY" valgrind.log | wc -l`
141
-    if test $NRUNS -ne `grep -a "ERROR SUMMARY: 0 errors" valgrind.log | wc -l` || 
142
-	test `grep -a "FATAL:" valgrind.log|wc -l` -ne 0; then
143
-	cat valgrind.log
140
+    VLOG=valgrind$1.log
141
+    NRUNS=`grep -a "ERROR SUMMARY" $VLOG | wc -l`
142
+    if test $NRUNS -ne `grep -a "ERROR SUMMARY: 0 errors" $VLOG | wc -l` || 
143
+	test `grep -a "FATAL:" $VLOG|wc -l` -ne 0; then
144
+	cat $VLOG
144 145
 	die "Valgrind tests failed"
145 146
     fi
146 147
 }
... ...
@@ -365,7 +365,7 @@ static void do_phishing_test(const struct rtest *rtest)
365 365
 {
366 366
 	char *realurl;
367 367
 	cli_ctx ctx;
368
-	const char *virname;
368
+	const char *virname = NULL;
369 369
 	tag_arguments_t hrefs;
370 370
 	int rc;
371 371
 
... ...
@@ -417,8 +417,9 @@ static void do_phishing_test(const struct rtest *rtest)
417 417
 				fail_unless_fmt(ctx.found_possibly_unwanted,
418 418
 					"this should be blacklisted, realURL: %s, displayURL: %s",
419 419
 					rtest->realurl, rtest->displayurl);
420
-				fail_unless_fmt(!strstr((const char*)ctx.virname,"Blacklisted"),
421
-						"should be blacklisted, but is: %s\n", ctx.virname);
420
+				if (*ctx.virname)
421
+				    fail_unless_fmt(!strstr((const char*)*ctx.virname,"Blacklisted"),
422
+						    "should be blacklisted, but is: %s\n", ctx.virname);
422 423
 			}
423 424
 			break;
424 425
 	}