head	1.2;
access;
symbols;
locks; strict;
comment	@# @;


1.2
date	2011.07.26.22.24.21;	author garga;	state dead;
branches;
next	1.1;

1.1
date	2011.06.29.19.37.51;	author crees;	state Exp;
branches;
next	;


desc
@@


1.2
log
@- Update to 0.97.2

PR:		ports/159185 (based on)
Submitted by:	Michael Scheidell <scheidell@@secnap.net>
@
text
@$RANDOM is a bashism, it has been replaced with portable code.

Also, the randomly generated port is checked to make sure it's not already
in use.

--- unit_tests/check_common.sh.orig	2011-05-13 12:25:31.000000000 +0100
+++ unit_tests/check_common.sh	2011-06-28 19:12:00.683905036 +0100
@@@@ -58,9 +58,13 @@@@
 aa15bcf478d165efd2065190eb473bcb:544:ClamAV-Test-File
 EOF
     port=331$1
-    if test "x$RANDOM" != "x"; then
-	port=1`expr 100 + \( $RANDOM % 899 \)`$1
-    fi
+    tries=0
+    while nc -z localhost $port 2>/dev/null
+	do rand=` ( echo $$ ; time ps 2>&1 ; date ) | cksum | cut -f1 -d" " `
+	port=1`expr 100 + \( $rand % 899 \)`$1
+	[ $tries -gt 100 ] && echo Giving up, too many ports open && exit 1
+	tries=`expr $tries + 1`
+    done
     cat <<EOF >test-clamd.conf
 LogFile `pwd`/clamd-test.log
 LogFileMaxSize 0
@


1.1
log
@Remove bashism from the unit tests, and also check that chosen random port is
closed first to avoid intermittent failures when testing

Approved by:	rene (mentor), garga (maintainer, via IRC)
@
text
@@

