mirror of
				https://github.com/osmarks/ngircd.git
				synced 2025-10-31 05:52:59 +00:00 
			
		
		
		
	Fixed echo without newline for systems not understanding "echo -n"; added
new file "functions.inc" for functions usable by all test scripts.
This commit is contained in:
		
							
								
								
									
										28
									
								
								src/testsuite/functions.inc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/testsuite/functions.inc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| #!/bin/sh | ||||
| # | ||||
| # ngIRCd Test Suite | ||||
| # Copyright (c)2002-2004 by Alexander Barton (alex@barton.de) | ||||
| # | ||||
| # This program is free software; you can redistribute it and/or modify | ||||
| # it under the terms of the GNU General Public License as published by | ||||
| # the Free Software Foundation; either version 2 of the License, or | ||||
| # (at your option) any later version. | ||||
| # Please read the file COPYING, README and AUTHORS for more information. | ||||
| # | ||||
| # $Id: functions.inc,v 1.1 2004/09/06 22:04:06 alex Exp $ | ||||
| # | ||||
|  | ||||
| # test how to call echo to get output without newline | ||||
| echo -n | grep -- -n >/dev/null 2>&1 | ||||
| if [ $? -eq 0 ]; then | ||||
| 	ECHO_N=""; ECHO_C="\c" | ||||
| else | ||||
| 	ECHO_N="-n"; ECHO_C="" | ||||
| fi | ||||
|  | ||||
| echo_n() | ||||
| { | ||||
| 	echo $ECHO_N "$*$ECHO_C" | ||||
| } | ||||
|  | ||||
| # -eof- | ||||
| @@ -1,10 +1,13 @@ | ||||
| #!/bin/sh | ||||
| # ngIRCd Test Suite | ||||
| # $Id: start-server.sh,v 1.13 2004/09/04 19:14:46 alex Exp $ | ||||
| # $Id: start-server.sh,v 1.14 2004/09/06 22:04:06 alex Exp $ | ||||
|  | ||||
| [ -z "$srcdir" ] && srcdir=`dirname $0` | ||||
|  | ||||
| echo -n "      starting server ..." | ||||
| # read in functions | ||||
| . ${srcdir}/functions.inc | ||||
|  | ||||
| echo_n "      starting server ..." | ||||
|  | ||||
| # remove old logfiles | ||||
| rm -rf logs *.log | ||||
|   | ||||
| @@ -1,10 +1,13 @@ | ||||
| #!/bin/sh | ||||
| # ngIRCd Test Suite | ||||
| # $Id: stop-server.sh,v 1.12 2004/09/06 20:22:30 alex Exp $ | ||||
| # $Id: stop-server.sh,v 1.13 2004/09/06 22:04:06 alex Exp $ | ||||
|  | ||||
| [ -z "$srcdir" ] && srcdir=`dirname $0` | ||||
|  | ||||
| echo -n "      stopping server ..." | ||||
| # read in functions | ||||
| . ${srcdir}/functions.inc | ||||
|  | ||||
| echo_n "      stopping server ..." | ||||
|  | ||||
| # stop test-server ... | ||||
| pid=`./getpid.sh T-ngircd` | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
| # (at your option) any later version. | ||||
| # Please read the file COPYING, README and AUTHORS for more information. | ||||
| # | ||||
| # $Id: stress-server.sh,v 1.14 2004/09/04 19:14:46 alex Exp $ | ||||
| # $Id: stress-server.sh,v 1.15 2004/09/06 22:04:06 alex Exp $ | ||||
| # | ||||
|  | ||||
| # detect source directory | ||||
| @@ -38,6 +38,9 @@ fi | ||||
| # hello world! :-) | ||||
| echo "      stressing server with $CLIENTS clients (be patient!):" | ||||
|  | ||||
| # read in functions | ||||
| . ${srcdir}/functions.inc | ||||
|  | ||||
| # create scripts for expect(1) | ||||
| no=0 | ||||
| while [ ${no} -lt $CLIENTS ]; do | ||||
| @@ -57,7 +60,7 @@ while [ ${no} -lt $CLIENTS ]; do | ||||
|   [ $MAX -gt 0 ] && $srcdir/wait-tests.sh $MAX | ||||
| done | ||||
|  | ||||
| echo -n "      waiting for clients to complete: ." | ||||
| echo_n "      waiting for clients to complete: ." | ||||
| touch logs/check-idle.log | ||||
| while true; do | ||||
|   expect ${srcdir}/check-idle.e >> logs/check-idle.log; res=$? | ||||
| @@ -66,7 +69,7 @@ while true; do | ||||
|  | ||||
|   # there are still clients connected. Wait ... | ||||
|   sleep 3 | ||||
|   echo -n "." | ||||
|   echo_n "." | ||||
| done | ||||
|  | ||||
| [ $res -eq 0 ] && echo " ok." || echo " failure!" | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| #!/bin/sh | ||||
| # ngIRCd Test Suite | ||||
| # $Id: tests.sh,v 1.6 2004/09/04 19:14:46 alex Exp $ | ||||
| # $Id: tests.sh,v 1.7 2004/09/06 22:04:06 alex Exp $ | ||||
|  | ||||
| # detect source directory | ||||
| [ -z "$srcdir" ] && srcdir=`dirname $0` | ||||
| @@ -14,6 +14,9 @@ if [ ! -r "$test" ]; then | ||||
|   exit 1 | ||||
| fi | ||||
|  | ||||
| # read in functions | ||||
| . ${srcdir}/functions.inc | ||||
|  | ||||
| type expect > /dev/null 2>&1 | ||||
| if [ $? -ne 0 ]; then | ||||
|   echo "      ${name}: \"expect\" not found.";  exit 77 | ||||
| @@ -23,7 +26,7 @@ if [ $? -ne 0 ]; then | ||||
|   echo "      ${name}: \"telnet\" not found.";  exit 77 | ||||
| fi | ||||
|  | ||||
| echo -n "      running ${test} ..." | ||||
| echo_n "      running ${test} ..." | ||||
| expect ${srcdir}/${test}.e > logs/${test}.log 2>&1; r=$? | ||||
| [ $r -eq 0 ] && echo " ok." || echo " failure!" | ||||
|  | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
| # (at your option) any later version. | ||||
| # Please read the file COPYING, README and AUTHORS for more information. | ||||
| # | ||||
| # $Id: wait-tests.sh,v 1.3 2004/09/04 18:22:42 alex Exp $ | ||||
| # $Id: wait-tests.sh,v 1.4 2004/09/06 22:04:06 alex Exp $ | ||||
| # | ||||
|  | ||||
| [ "$1" -gt 0 ] 2> /dev/null && MAX="$1" || MAX=5 | ||||
| @@ -18,6 +18,9 @@ PS_FLAGS="-f" | ||||
| ps $PS_FLAGS >/dev/null 2>&1 | ||||
| [ $? -ne 0 ] && PS_FLAGS="a" | ||||
|  | ||||
| # read in functions | ||||
| . ${srcdir}/functions.inc | ||||
|  | ||||
| msg=0 | ||||
| while true; do | ||||
|   count=`ps $PS_FLAGS | grep "expect " | wc -l` | ||||
| @@ -26,12 +29,12 @@ while true; do | ||||
|   [ $count -le $MAX ] && break | ||||
|  | ||||
|   if [ $msg -lt 1 ]; then | ||||
|     echo -n "      waiting for processes to settle: " | ||||
|     echo_n "      waiting for processes to settle: " | ||||
|     msg=1 | ||||
|   fi | ||||
|  | ||||
|   # there are still clients connected. Wait ... | ||||
|   echo -n "$count>$MAX " | ||||
|   echo_n "$count>$MAX " | ||||
|   sleep 1 | ||||
| done | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Alexander Barton
					Alexander Barton