Add client timeout to ssl-opt.sh and compat.sh

This commit is contained in:
Manuel Pégourié-Gonnard 2014-08-30 22:41:47 +02:00
parent decaf0b182
commit c0f6a692fb
2 changed files with 50 additions and 9 deletions

View file

@ -806,6 +806,23 @@ cleanup() {
exit 1
}
# wait for client to terminate and set EXIT
# must be called right after starting the client
wait_client_done() {
CLI_PID=$!
( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
WATCHDOG_PID=$!
wait $CLI_PID
EXIT=$?
kill $WATCHDOG_PID
wait $WATCHDOG_PID
echo "EXIT: $EXIT" >> $CLI_OUT
}
# run_client <name> <cipher>
run_client() {
# announce what we're going to do
@ -823,8 +840,8 @@ run_client() {
CLIENT_CMD="$OPENSSL_CMD s_client $O_CLIENT_ARGS -cipher $2"
log "$CLIENT_CMD"
echo "$CLIENT_CMD" > $CLI_OUT
( echo -e 'GET HTTP/1.0'; echo; ) | $CLIENT_CMD >> $CLI_OUT 2>&1
EXIT=$?
( echo -e 'GET HTTP/1.0'; echo; ) | $CLIENT_CMD >> $CLI_OUT 2>&1 &
wait_client_done
if [ "$EXIT" == "0" ]; then
RESULT=0
@ -841,8 +858,8 @@ run_client() {
CLIENT_CMD="$GNUTLS_CLI $G_CLIENT_ARGS --priority $G_PRIO_MODE:$2 localhost"
log "$CLIENT_CMD"
echo "$CLIENT_CMD" > $CLI_OUT
( echo -e 'GET HTTP/1.0'; echo; ) | $CLIENT_CMD >> $CLI_OUT 2>&1
EXIT=$?
( echo -e 'GET HTTP/1.0'; echo; ) | $CLIENT_CMD >> $CLI_OUT 2>&1 &
wait_client_done
if [ "$EXIT" == "0" ]; then
RESULT=0
@ -866,8 +883,8 @@ run_client() {
fi
log "$CLIENT_CMD"
echo "$CLIENT_CMD" > $CLI_OUT
$CLIENT_CMD >> $CLI_OUT 2>&1
EXIT=$?
$CLIENT_CMD >> $CLI_OUT 2>&1 &
wait_client_done
case $EXIT in
"0") RESULT=0 ;;
@ -962,6 +979,13 @@ PORT="1$(echo $PORT | tail -c 5)"
SRV_OUT="srv_out.$$"
CLI_OUT="cli_out.$$"
# client timeout delay: be more patient with valgrind
if [ "$MEMCHECK" -gt 0 ]; then
DOG_DELAY=30
else
DOG_DELAY=10
fi
trap cleanup INT TERM HUP
for VERIFY in $VERIFIES; do

View file

@ -150,6 +150,23 @@ wait_server_start() {
fi
}
# wait for client to terminate and set CLI_EXIT
# must be called right after starting the client
wait_client_done() {
CLI_PID=$!
( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
WATCHDOG_PID=$!
wait $CLI_PID
CLI_EXIT=$?
kill $WATCHDOG_PID
wait $WATCHDOG_PID
echo "EXIT: $CLI_EXIT" >> $CLI_OUT
}
# Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]]
# Options: -s pattern pattern that must be present in server output
# -c pattern pattern that must be present in client output
@ -192,10 +209,10 @@ run_test() {
$SRV_CMD >> $SRV_OUT 2>&1 &
SRV_PID=$!
wait_server_start
echo "$CLI_CMD" > $CLI_OUT
eval "$CLI_CMD" >> $CLI_OUT 2>&1
CLI_EXIT=$?
echo "EXIT: $CLI_EXIT" >> $CLI_OUT
eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
wait_client_done
# kill the server
kill $SRV_PID