From 677884d1746fecc2675c4f9d3a8711b78bde0c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 25 Feb 2014 16:42:31 +0100 Subject: [PATCH] Add a few checks in ssl-opt.sh --- tests/ssl-opt.sh | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index f2879b0a6..971504947 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -38,6 +38,11 @@ fail() { FAILS=`echo $FAILS + 1 | bc` } +# is_polar +is_polar() { + echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null +} + # Usage: run_test name srv_args cli_args cli_exit [option [...]] # Options: -s pattern pattern that must be present in server output # -c pattern pattern that must be present in client output @@ -53,10 +58,34 @@ run_test() { sleep 1 $SHELL -c "$2" > cli_out 2>&1 CLI_EXIT=$? - echo SERVERQUIT | openssl s_client -no_ticket \ - -cert data_files/cli2.crt -key data_files/cli2.key \ - >/dev/null 2>&1 + if is_polar $2; then + echo SERVERQUIT | openssl s_client -no_ticket \ + -cert data_files/cli2.crt -key data_files/cli2.key \ + >/dev/null 2>&1 + else + kill $SRV_PID + fi wait $SRV_PID + + # check if the client and server went at least to the handshake stage + # (usefull to avoid tests with only negative assertions and non-zero + # expected client exit to incorrectly succeed in case of catastrophic + # failure) + if is_polar $1; then + if grep "Performing the SSL/TLS handshake" srv_out >/dev/null; then :; + else + fail "server failed to start" + return + fi + fi + if is_polar $2; then + if grep "Performing the SSL/TLS handshake" cli_out >/dev/null; then :; + else + fail "client failed to start" + return + fi + fi + shift 2 # check server exit code