From 9dea8bd658a0cfea2dd32d4afa3db282c4cf8aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 26 Feb 2014 18:21:02 +0100 Subject: [PATCH] Minor compat.sh clean-up --- tests/compat.sh | 96 ++++++++++++++++++++++++------------------------ tests/ssl-opt.sh | 4 ++ 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/tests/compat.sh b/tests/compat.sh index ffb3b8252..f5cdc6cd1 100755 --- a/tests/compat.sh +++ b/tests/compat.sh @@ -14,55 +14,47 @@ OPENSSL=openssl FILTER="" VERBOSE="" -# Parse arguments -# -until [ -z "$1" ] -do - case "$1" in - -f|--filter) - # Filter ciphersuites - shift - FILTER=$1 - ;; - -m|--modes) - # Perform modes - shift - MODES=$1 - ;; - -t|--types) - # Key exchange types - shift - TYPES=$1 - ;; - -V|--verify) - # Verifiction modes - shift - VERIFIES=$1 - ;; - -v|--verbose) - # Set verbosity - shift - VERBOSE=1 - ;; - -h|--help) - # print help - echo "Usage: $0" - echo -e " -f|--filter\tFilter ciphersuites to test (Default: all)" - echo -e " -h|--help\t\tPrint this help." - echo -e " -m|--modes\tWhich modes to perform (Default: \"ssl3 tls1 tls1_1 tls1_2\")" - echo -e " -t|--types\tWhich key exchange type to perform (Default: \"ECDSA RSA PSK\")" - echo -e " -V|--verify\tWhich verification modes to perform (Default: \"NO YES\")" - echo -e " -v|--verbose\t\tSet verbose output." - exit 1 - ;; - *) - # print error - echo "Unknown argument: '$1'" - exit 1 - ;; - esac - shift -done +print_usage() { + echo "Usage: $0" + echo -e " -f|--filter\tFilter ciphersuites to test (Default: all)" + echo -e " -h|--help\t\tPrint this help." + echo -e " -m|--modes\tWhich modes to perform (Default: \"ssl3 tls1 tls1_1 tls1_2\")" + echo -e " -t|--types\tWhich key exchange type to perform (Default: \"ECDSA RSA PSK\")" + echo -e " -V|--verify\tWhich verification modes to perform (Default: \"NO YES\")" + echo -e " -v|--verbose\t\tSet verbose output." +} + +get_options() { + while [ $# -gt 0 ]; do + case "$1" in + -f|--filter) + shift; FILTER=$1 + ;; + -m|--modes) + shift; MODES=$1 + ;; + -t|--types) + shift; TYPES=$1 + ;; + -V|--verify) + shift; VERIFIES=$1 + ;; + -v|--verbose) + VERBOSE=1 + ;; + -h|--help) + print_usage + exit 0 + ;; + *) + echo "Unknown argument: '$1'" + print_usage + exit 1 + ;; + esac + shift + done +} log() { if [ "X" != "X$VERBOSE" ]; then @@ -553,6 +545,12 @@ run_client() { esac } +# +# MAIN +# + +get_options "$@" + killall -q openssl ssl_server ssl_server2 trap cleanup INT TERM HUP diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 3867eee84..a1e3f511f 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -221,6 +221,10 @@ cleanup() { exit 1 } +# +# MAIN +# + get_options "$@" killall -q openssl ssl_server ssl_server2