ssl-opt.sh: cosmetics

This commit is contained in:
Manuel Pégourié-Gonnard 2014-02-21 09:20:14 +01:00
parent dbe1ee1988
commit f8bdbb5d62

View file

@ -12,13 +12,28 @@ PROGS_DIR='../programs/ssl'
SRV_CMD="$PROGS_DIR/ssl_server2" SRV_CMD="$PROGS_DIR/ssl_server2"
CLI_CMD="$PROGS_DIR/ssl_client2" CLI_CMD="$PROGS_DIR/ssl_client2"
# print_name <name>
print_name() {
echo -n "$1 "
LEN=`echo "$1" | wc -c`
LEN=`echo 72 - $LEN | bc`
for i in `seq 1 $LEN`; do echo -n '.'; done
echo -n ' '
}
# fail <message>
fail() {
echo "FAIL"
echo " $1"
}
# Usage: run_test name srv_args cli_args cli_exit [option [...]] # Usage: run_test name srv_args cli_args cli_exit [option [...]]
# Options: -s pattern pattern that must be present in server output # Options: -s pattern pattern that must be present in server output
# -c pattern pattern that must be present in client output # -c pattern pattern that must be present in client output
# -S pattern pattern that must be absent in server output # -S pattern pattern that must be absent in server output
# -C pattern pattern that must be absent in client output # -C pattern pattern that must be absent in client output
run_test() { run_test() {
echo -n "$1: " print_name "$1"
shift shift
# run the commands # run the commands
@ -31,11 +46,17 @@ run_test() {
wait $SRV_PID wait $SRV_PID
shift 2 shift 2
# check server exit code
if [ $? != 0 ]; then
fail "server fail"
return
fi
# check client exit code # check client exit code
if [ \( "$1" = 0 -a "$CLI_EXIT" != 0 \) -o \ if [ \( "$1" = 0 -a "$CLI_EXIT" != 0 \) -o \
\( "$1" != 0 -a "$CLI_EXIT" = 0 \) ] \( "$1" != 0 -a "$CLI_EXIT" = 0 \) ]
then then
echo "FAIL - client exit" fail "client exit"
return return
fi fi
shift shift
@ -46,28 +67,28 @@ run_test() {
case $1 in case $1 in
"-s") "-s")
if grep "$2" srv_out >/dev/null; then :; else if grep "$2" srv_out >/dev/null; then :; else
echo "FAIL - -s $2" fail "-s $2"
return return
fi fi
;; ;;
"-c") "-c")
if grep "$2" cli_out >/dev/null; then :; else if grep "$2" cli_out >/dev/null; then :; else
echo "FAIL - -c $2" fail "-c $2"
return return
fi fi
;; ;;
"-S") "-S")
if grep "$2" srv_out >/dev/null; then if grep "$2" srv_out >/dev/null; then
echo "FAIL - -S $2" fail "-S $2"
return return
fi fi
;; ;;
"-C") "-C")
if grep "$2" cli_out >/dev/null; then if grep "$2" cli_out >/dev/null; then
echo "FAIL - -C $2" fail "-C $2"
return return
fi fi
;; ;;