X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=tests%2Fcommon.sh;h=d2b3459cee64123b75e81d65f3b80123c50e6aff;hb=9fb20ff647d6d494d99184875d2c60586107d34c;hp=1ca15837a47bdc5864db80e59f7de479f437a41c;hpb=8c4e41d4ed8b3d8c3a39d3bef01feec98dc82161;p=tlsproxy%2Ftlsproxy.git diff --git a/tests/common.sh b/tests/common.sh index 1ca1583..d2b3459 100644 --- a/tests/common.sh +++ b/tests/common.sh @@ -46,6 +46,26 @@ client() { ./client ./proxy-ca.pem "$@" > tmp 2>&1 } +wait_for_ports() { + while :; do + sleep 1 + + # Check if each given port can be reached. + ready=1 + for port in "$@"; do + printf 'invalid request\r\n\r\n' \ + | nc localhost "$port" >/dev/null 2>&1 \ + || ready= + done + + if test -n "$ready"; then + break + fi + + echo "waiting for ports $* ..." + done +} + test_proxy_failure() { grep 'proxy failure' tmp >/dev/null \ || abort 'test_proxy_failure'