Also use unique names for temp files

This commit is contained in:
Manuel Pégourié-Gonnard 2014-05-28 23:06:50 +02:00
parent 8066b81a54
commit bc3b16c7e2
2 changed files with 51 additions and 38 deletions

View file

@ -757,8 +757,8 @@ start_server() {
SERVER_NAME=$1
log "$SERVER_CMD"
echo "$SERVER_CMD" > srv_out
$SERVER_CMD >> srv_out 2>&1 &
echo "$SERVER_CMD" > $SRV_OUT
$SERVER_CMD >> $SRV_OUT 2>&1 &
PROCESS_ID=$!
sleep 1
@ -787,19 +787,19 @@ stop_server() {
wait $PROCESS_ID 2>/dev/null
if [ "$MEMCHECK" -gt 0 ]; then
if is_polar "$SERVER_CMD" && has_mem_err srv_out; then
if is_polar "$SERVER_CMD" && has_mem_err $SRV_OUT; then
echo " ! Server had memory errors"
let "srvmem++"
return
fi
fi
rm -f srv_out
rm -f $SRV_OUT
}
# kill the running server (used when killed by signal)
cleanup() {
rm -f srv_out cli_out
rm -f $SRV_OUT $CLI_OUT
kill $PROCESS_ID
exit 1
}
@ -820,14 +820,14 @@ run_client() {
[Oo]pen*)
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
echo "$CLIENT_CMD" > $CLI_OUT
( echo -e 'GET HTTP/1.0'; echo; ) | $CLIENT_CMD >> $CLI_OUT 2>&1
EXIT=$?
if [ "$EXIT" == "0" ]; then
RESULT=0
else
if grep 'Cipher is (NONE)' cli_out >/dev/null; then
if grep 'Cipher is (NONE)' $CLI_OUT >/dev/null; then
RESULT=1
else
RESULT=2
@ -838,8 +838,8 @@ run_client() {
[Gg]nu*)
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
echo "$CLIENT_CMD" > $CLI_OUT
( echo -e 'GET HTTP/1.0'; echo; ) | $CLIENT_CMD >> $CLI_OUT 2>&1
EXIT=$?
if [ "$EXIT" == "0" ]; then
@ -848,8 +848,8 @@ run_client() {
RESULT=2
# interpret early failure, with a handshake_failure alert
# before the server hello, as "no ciphersuite in common"
if grep -F 'Received alert [40]: Handshake failed' cli_out; then
if grep -i 'SERVER HELLO .* was received' cli_out; then :
if grep -F 'Received alert [40]: Handshake failed' $CLI_OUT; then
if grep -i 'SERVER HELLO .* was received' $CLI_OUT; then :
else
RESULT=1
fi
@ -863,8 +863,8 @@ run_client() {
CLIENT_CMD="valgrind --leak-check=full $CLIENT_CMD"
fi
log "$CLIENT_CMD"
echo "$CLIENT_CMD" > cli_out
$CLIENT_CMD >> cli_out 2>&1
echo "$CLIENT_CMD" > $CLI_OUT
$CLIENT_CMD >> $CLI_OUT 2>&1
EXIT=$?
case $EXIT in
@ -874,7 +874,7 @@ run_client() {
esac
if [ "$MEMCHECK" -gt 0 ]; then
if is_polar "$CLIENT_CMD" && has_mem_err cli_out; then
if is_polar "$CLIENT_CMD" && has_mem_err $CLI_OUT; then
RESULT=2
fi
fi
@ -887,7 +887,7 @@ run_client() {
;;
esac
echo "EXIT: $EXIT" >> cli_out
echo "EXIT: $EXIT" >> $CLI_OUT
# report and count result
case $RESULT in
@ -900,14 +900,14 @@ run_client() {
;;
"2")
echo FAIL
cp srv_out c-srv-${tests}.log
cp cli_out c-cli-${tests}.log
cp $SRV_OUT c-srv-${tests}.log
cp $CLI_OUT c-cli-${tests}.log
echo " ! outputs saved to c-srv-${tests}.log, c-cli-${tests}.log"
let "failed++"
;;
esac
rm -f cli_out
rm -f $CLI_OUT
}
#
@ -956,6 +956,10 @@ done
PORT="0000$$"
PORT="1$(echo $PORT | tail -c 4)"
# Also pick a unique name for intermediate files
SRV_OUT="srv_out.$$"
CLI_OUT="cli_out.$$"
trap cleanup INT TERM HUP
for VERIFY in $VERIFIES; do

View file

@ -89,8 +89,8 @@ fail() {
echo "FAIL"
echo " ! $1"
cp srv_out o-srv-${TESTS}.log
cp cli_out o-cli-${TESTS}.log
cp $SRV_OUT o-srv-${TESTS}.log
cp $CLI_OUT o-cli-${TESTS}.log
echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log"
FAILS=`echo $FAILS + 1 | bc`
@ -142,14 +142,14 @@ run_test() {
fi
# run the commands
echo "$SRV_CMD" > srv_out
$SRV_CMD >> srv_out 2>&1 &
echo "$SRV_CMD" > $SRV_OUT
$SRV_CMD >> $SRV_OUT 2>&1 &
SRV_PID=$!
sleep 1
echo "$CLI_CMD" > cli_out
eval "$CLI_CMD" >> cli_out 2>&1
echo "$CLI_CMD" > $CLI_OUT
eval "$CLI_CMD" >> $CLI_OUT 2>&1
CLI_EXIT=$?
echo "EXIT: $CLI_EXIT" >> cli_out
echo "EXIT: $CLI_EXIT" >> $CLI_OUT
# psk is useful when server only has bad certs
if is_polar "$SRV_CMD"; then
@ -166,14 +166,14 @@ run_test() {
# expected client exit to incorrectly succeed in case of catastrophic
# failure)
if is_polar "$SRV_CMD"; then
if grep "Performing the SSL/TLS handshake" srv_out >/dev/null; 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 "$CLI_CMD"; then
if grep "Performing the SSL/TLS handshake" cli_out >/dev/null; then :;
if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
else
fail "client failed to start"
return
@ -199,28 +199,28 @@ run_test() {
do
case $1 in
"-s")
if grep "$2" srv_out >/dev/null; then :; else
if grep "$2" $SRV_OUT >/dev/null; then :; else
fail "-s $2"
return
fi
;;
"-c")
if grep "$2" cli_out >/dev/null; then :; else
if grep "$2" $CLI_OUT >/dev/null; then :; else
fail "-c $2"
return
fi
;;
"-S")
if grep "$2" srv_out >/dev/null; then
if grep "$2" $SRV_OUT >/dev/null; then
fail "-S $2"
return
fi
;;
"-C")
if grep "$2" cli_out >/dev/null; then
if grep "$2" $CLI_OUT >/dev/null; then
fail "-C $2"
return
fi
@ -235,11 +235,11 @@ run_test() {
# check valgrind's results
if [ "$MEMCHECK" -gt 0 ]; then
if is_polar "$SRV_CMD" && has_mem_err srv_out; then
if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
fail "Server has memory errors"
return
fi
if is_polar "$CLI_CMD" && has_mem_err cli_out; then
if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
fail "Client has memory errors"
return
fi
@ -247,11 +247,11 @@ run_test() {
# if we're here, everything is ok
echo "PASS"
rm -f srv_out cli_out
rm -f $SRV_OUT $CLI_OUT
}
cleanup() {
rm -f cli_out srv_out sess
rm -f $CLI_OUT $SRV_OUT $SESSION
kill $SRV_PID
exit 1
}
@ -286,6 +286,11 @@ P_CLI="$P_CLI server_port=$PORT"
O_SRV="$O_SRV -accept $PORT"
O_CLI="$O_CLI -connect localhost:$PORT"
# Also pick a unique name for intermediate files
SRV_OUT="srv_out.$$"
CLI_OUT="cli_out.$$"
SESSION="session.$$"
trap cleanup INT TERM HUP
# Test for SSLv2 ClientHello
@ -374,7 +379,9 @@ run_test "Session resume using tickets #4 (openssl server)" \
run_test "Session resume using tickets #5 (openssl client)" \
"$P_SRV debug_level=4 tickets=1" \
"($O_CLI -sess_out sess; $O_CLI -sess_in sess; rm -f sess)" \
"( $O_CLI -sess_out $SESSION; \
$O_CLI -sess_in $SESSION; \
rm -f $SESSION )" \
0 \
-s "found session ticket extension" \
-s "server hello, adding session ticket extension" \
@ -459,7 +466,9 @@ run_test "Session resume using cache #7 (no timeout)" \
run_test "Session resume using cache #8 (openssl client)" \
"$P_SRV debug_level=4 tickets=0" \
"($O_CLI -sess_out sess; $O_CLI -sess_in sess; rm -f sess)" \
"( $O_CLI -sess_out $SESSION; \
$O_CLI -sess_in $SESSION; \
rm -f $SESSION )" \
0 \
-s "found session ticket extension" \
-S "server hello, adding session ticket extension" \