]> arthur.barton.de Git - ngircd-alex.git/blob - src/testsuite/wait-tests.sh
ngIRCd Release 27
[ngircd-alex.git] / src / testsuite / wait-tests.sh
1 #!/bin/sh
2 #
3 # ngIRCd Test Suite
4 # Copyright (c)2001-2024 Alexander Barton (alex@barton.de) and Contributors.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 # Please read the file COPYING, README and AUTHORS for more information.
11 #
12
13 [ "$1" -gt 0 ] 2>/dev/null && MAX="$1" || MAX=5
14
15 # detect source directory
16 [ -z "$srcdir" ] && srcdir=`dirname "$0"`
17 set -u
18
19 PS_FLAGS="-f"
20 ps $PS_FLAGS >/dev/null 2>&1
21 [ $? -ne 0 ] && PS_FLAGS="a"
22
23 # read in functions
24 . "${srcdir}/functions.inc"
25
26 msg=0
27 while true; do
28         count=`ps $PS_FLAGS | grep "expect " | wc -l`
29         count=`expr $count - 1`
30
31         [ $count -le $MAX ] && break
32
33         if [ $msg -lt 1 ]; then
34                 echo_n "      waiting for processes to settle: "
35                 msg=1
36         fi
37
38         # there are still clients connected. Wait ...
39         echo_n "$count>$MAX "
40         sleep 1
41 done
42
43 [ $msg -gt 0 ] && echo "done: $count"
44 exit 0