From 81eff899b63a5cb94de177fa5679333b5c22902a Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Thu, 14 Nov 2013 00:02:28 +0000 Subject: QPID-5306: Improve test wrapper to avoid using getopt for long options Using getopt with long options is a gnu extension and so best avoided for portability reasons. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1541764 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/run_test | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'qpid/cpp/src/tests/run_test') diff --git a/qpid/cpp/src/tests/run_test b/qpid/cpp/src/tests/run_test index 6fe49f7975..acb1714b0e 100755 --- a/qpid/cpp/src/tests/run_test +++ b/qpid/cpp/src/tests/run_test @@ -31,13 +31,46 @@ # examination. # -working_dir='.' +wrapper="Qpid Test Wrapper" +function usage { + echo "Usage:" + echo " --working-dir DIR" + echo " --build-dir DIR" + echo " --source-dir DIR" + echo " --python - run python script" + echo " --boost-test - run boost unit test" + echo " --xml - XML output from tests" + echo " --start-broker - start/stop broker before/after test" + echo " --broker-options - use these extra options when starting broker" + echo " --help - print this message" + echo " -- - This is required to separate the wrapped command" + echo " from the test parameters" +} + +function illegal_option { + echo "$wrapper: $1 is not an accepted option" + usage >&2 +} -OPTS=$(getopt -n "Qpid Test Wrapper" -o '' -l working-dir:,build-dir:,source-dir:,python,boost-test,xml,start-broker,broker-options: -- "$@") || exit 1 -eval set -- $OPTS +function no_command { + echo "$wrapper: No wrapped command specified" + usage >&2 +} + +function ignored_argument { + echo "Ignored argument: $1" >&2 +} + +working_dir='.' while true; do case "$1" in + --) shift; break ;; + # Split up any parameters expressed as --blah=foo + # and process them next time round the loop + --*=*) option=${1%%=*}; param=${1#*=} + shift; + set -- "$option" "$param" "$@" ;; --working-dir) working_dir=$2; shift 2 ;; --build-dir) build_dir=$2; shift 2 ;; --source-dir) source_dir=$2; shift 2 ;; @@ -46,7 +79,10 @@ case "$1" in --xml) xml_output=yes; shift ;; --start-broker) start_broker=yes; shift ;; --broker-options) qpidd_extra_options=$2; shift 2 ;; - --) shift; break ;; + --help) usage; exit 0; ;; + --*) illegal_option "$1"; exit 1; ;; + '') no_command; exit 1; ;; + *) ignored_argument "$1"; shift; ;; esac done -- cgit v1.2.1