X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=tests%2Fcommon.sh;h=eb60743d89a21087bd6e1fff1e7b9699037f9099;hb=94b7d1f951f5707dfc47c3ab48c0889af8b0ed9d;hp=1ca15837a47bdc5864db80e59f7de479f437a41c;hpb=f7ca2cfdbb4390a1a44aa5ae863e55245024d8f7;p=tlsproxy%2Ftlsproxy.git diff --git a/tests/common.sh b/tests/common.sh index 1ca1583..eb60743 100644 --- a/tests/common.sh +++ b/tests/common.sh @@ -34,6 +34,9 @@ abort() { stop_servers exit 1 } +tlsproxy_setup() { + "$srcdir/../src/tlsproxy-setup" >/dev/null 2>/dev/null +} tlsproxy() { ../src/tlsproxy -d2 "$@" >tlsproxy-log 2>&1 & pid_tlsproxy=$! @@ -46,6 +49,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'