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


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

1.1
date	2011.07.04.23.54.44;	author garga;	state Exp;
branches;
next	;


desc
@@


1.2
log
@Update to 20111104
@
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
@Update to 20110704
@
text
@@

