Author: astitcher Date: Thu Nov 14 00:02:28 2013 New Revision: 1541764 URL: http://svn.apache.org/r1541764 Log: 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.
Modified: qpid/trunk/qpid/cpp/src/tests/CMakeLists.txt qpid/trunk/qpid/cpp/src/tests/run_test Modified: qpid/trunk/qpid/cpp/src/tests/CMakeLists.txt URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/CMakeLists.txt?rev=1541764&r1=1541763&r2=1541764&view=diff ============================================================================== --- qpid/trunk/qpid/cpp/src/tests/CMakeLists.txt (original) +++ qpid/trunk/qpid/cpp/src/tests/CMakeLists.txt Thu Nov 14 00:02:28 2013 @@ -345,7 +345,7 @@ add_test (federation_sys_tests ${shell} add_test (queue_flow_limit_tests ${test_wrap} --start-broker "--broker-options=--default-flow-stop-threshold=80 --default-flow-resume-threshold=70 -t --log-to-stderr=no --log-to-stdout=no" - ${CMAKE_CURRENT_SOURCE_DIR}/run_queue_flow_limit_tests${test_script_suffix}) + -- ${CMAKE_CURRENT_SOURCE_DIR}/run_queue_flow_limit_tests${test_script_suffix}) if (BUILD_ACL) add_test (acl_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_acl_tests${test_script_suffix}) endif (BUILD_ACL) Modified: qpid/trunk/qpid/cpp/src/tests/run_test URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/run_test?rev=1541764&r1=1541763&r2=1541764&view=diff ============================================================================== --- qpid/trunk/qpid/cpp/src/tests/run_test (original) +++ qpid/trunk/qpid/cpp/src/tests/run_test Thu Nov 14 00:02:28 2013 @@ -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 --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org