summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2013-11-07 00:42:42 +0000
committerAndrew Stitcher <astitcher@apache.org>2013-11-07 00:42:42 +0000
commitfbed081eab315a178a392ccdd7e4eb3991dac8e7 (patch)
treeca1e7b15f8e38ff7aafafe49f62964ff3160cf02
parentded36a481812675a24a2705f0d28cc4f94f47526 (diff)
downloadqpid-python-fbed081eab315a178a392ccdd7e4eb3991dac8e7.tar.gz
QPID-5306: Improve c++ tests some more:
Add options to run_test script: --working-dir - run the test in this directory --build-dir - set the top of the build tree --source-dir - set the top of the source tree --python - run a python test --start-broker - start/stop broker before and after test --broker-options - allow non default broker options Remove a bunch of now obsolete testing related scripts git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1539510 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/src/tests/CMakeLists.txt34
-rw-r--r--qpid/cpp/src/tests/legacystore/CMakeLists.txt8
-rw-r--r--qpid/cpp/src/tests/legacystore/tests_env.sh260
-rwxr-xr-xqpid/cpp/src/tests/run_header_test6
-rwxr-xr-xqpid/cpp/src/tests/run_msg_group_tests9
-rwxr-xr-xqpid/cpp/src/tests/run_queue_flow_limit_tests29
-rwxr-xr-xqpid/cpp/src/tests/run_test89
-rwxr-xr-xqpid/cpp/src/tests/start_broker24
-rw-r--r--qpid/cpp/src/tests/start_broker.ps160
-rwxr-xr-xqpid/cpp/src/tests/stop_broker41
-rw-r--r--qpid/cpp/src/tests/stop_broker.ps156
-rw-r--r--qpid/cpp/src/tests/test_env.sh.in1
-rwxr-xr-xqpid/cpp/src/tests/test_wrap48
13 files changed, 96 insertions, 569 deletions
diff --git a/qpid/cpp/src/tests/CMakeLists.txt b/qpid/cpp/src/tests/CMakeLists.txt
index 4acd976a38..012f135c73 100644
--- a/qpid/cpp/src/tests/CMakeLists.txt
+++ b/qpid/cpp/src/tests/CMakeLists.txt
@@ -135,7 +135,8 @@ if (CMAKE_SYSTEM_NAME STREQUAL Windows)
set (shell "powershell")
endif (CMAKE_SYSTEM_NAME STREQUAL Windows)
-set(test_wrap ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_test${test_script_suffix})
+set(test_wrap ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_test${test_script_suffix} --build-dir=${CMAKE_BINARY_DIR})
+set(python_wrap ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_test${test_script_suffix} --build-dir=${CMAKE_BINARY_DIR} --python)
if (BUILD_TESTING_UNITTESTS)
@@ -225,7 +226,7 @@ target_link_libraries (unit_test
set_target_properties (unit_test PROPERTIES COMPILE_DEFINITIONS _IN_QPID_BROKER)
remember_location(unit_test)
-add_test (unit_test ${test_wrap} ${unit_test_LOCATION})
+add_test (unit_test ${test_wrap} -- ${unit_test_LOCATION})
endif (BUILD_TESTING_UNITTESTS)
@@ -319,33 +320,34 @@ if (BUILD_SASL)
add_test(ssl_test ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/ssl_test${test_script_suffix})
endif (BUILD_SSL)
endif (BUILD_SASL)
-add_test (start_broker ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/start_broker${test_script_suffix})
-add_test (qpid-client-test ${test_wrap} ${qpid-client-test_LOCATION})
-add_test (quick_perftest ${test_wrap} ${qpid-perftest_LOCATION} --summary --count 100)
-add_test (quick_topictest ${test_wrap} ${CMAKE_CURRENT_SOURCE_DIR}/quick_topictest${test_script_suffix})
-add_test (quick_txtest ${test_wrap} ${qpid-txtest_LOCATION} --queues 4 --tx-count 10 --quiet)
-add_test (msg_group_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_msg_group_tests${test_script_suffix})
+add_test (qpid-client-test ${test_wrap} --start-broker -- ${qpid-client-test_LOCATION})
+add_test (quick_perftest ${test_wrap} --start-broker -- ${qpid-perftest_LOCATION} --summary --count 100)
+add_test (quick_topictest ${test_wrap} --start-broker -- ${CMAKE_CURRENT_SOURCE_DIR}/quick_topictest${test_script_suffix})
+add_test (quick_txtest ${test_wrap} --start-broker -- ${qpid-txtest_LOCATION} --queues 4 --tx-count 10 --quiet)
+add_test (msg_group_tests ${test_wrap} --start-broker -- ${CMAKE_CURRENT_SOURCE_DIR}/run_msg_group_tests${test_script_suffix})
if (PYTHON_EXECUTABLE)
- add_test (run_header_test ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_header_test${test_script_suffix})
- add_test (python_tests ${test_wrap} ${CMAKE_CURRENT_SOURCE_DIR}/python_tests${test_script_suffix})
+ add_test (run_header_test ${test_wrap} --start-broker -- ${CMAKE_CURRENT_SOURCE_DIR}/run_header_test${test_script_suffix})
+ add_test (python_tests ${test_wrap} --start-broker -- ${CMAKE_CURRENT_SOURCE_DIR}/python_tests${test_script_suffix})
endif (PYTHON_EXECUTABLE)
-add_test (stop_broker ${test_wrap} ${CMAKE_CURRENT_SOURCE_DIR}/stop_broker${test_script_suffix})
if (NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
# paged queue not yet implemented for windows
add_test (paged_queue_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_paged_queue_tests${test_script_suffix})
endif (NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
if (PYTHON_EXECUTABLE)
- add_test (ha_tests ${test_wrap} ${CMAKE_CURRENT_SOURCE_DIR}/ha_tests.py)
- add_test (qpidd_qmfv2_tests ${test_wrap} ${CMAKE_CURRENT_SOURCE_DIR}/qpidd_qmfv2_tests.py)
+ add_test (ha_tests ${python_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/ha_tests.py)
+ add_test (qpidd_qmfv2_tests ${python_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/qpidd_qmfv2_tests.py)
if (BUILD_AMQP)
- add_test (interlink_tests ${test_wrap} ${CMAKE_CURRENT_SOURCE_DIR}/interlink_tests.py)
+ add_test (interlink_tests ${python_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/interlink_tests.py)
endif (BUILD_AMQP)
- add_test (swig_python_tests ${test_wrap} ${CMAKE_CURRENT_SOURCE_DIR}/swig_python_tests${test_script_suffix})
+ add_test (swig_python_tests ${test_wrap} -- ${CMAKE_CURRENT_SOURCE_DIR}/swig_python_tests${test_script_suffix})
endif (PYTHON_EXECUTABLE)
add_test (ipv6_test ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/ipv6_test${test_script_suffix})
add_test (federation_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_federation_tests${test_script_suffix})
add_test (federation_sys_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_federation_sys_tests${test_script_suffix})
-add_test (queue_flow_limit_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_queue_flow_limit_tests${test_script_suffix})
+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})
if (BUILD_ACL)
add_test (acl_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_acl_tests${test_script_suffix})
endif (BUILD_ACL)
diff --git a/qpid/cpp/src/tests/legacystore/CMakeLists.txt b/qpid/cpp/src/tests/legacystore/CMakeLists.txt
index 2067ab87cd..7df50d1398 100644
--- a/qpid/cpp/src/tests/legacystore/CMakeLists.txt
+++ b/qpid/cpp/src/tests/legacystore/CMakeLists.txt
@@ -28,6 +28,8 @@ endif (QPID_LINK_BOOST_DYNAMIC)
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
+set(test_wrap ${shell} ${CMAKE_SOURCE_DIR}/src/tests/run_test${test_script_suffix} --build-dir=${CMAKE_BINARY_DIR})
+
if (BUILD_TESTING_UNITTESTS)
# Like this to work with cmake 2.4 on Unix
@@ -50,7 +52,7 @@ target_link_libraries (legacystore_${theSourceFile}
set_target_properties (legacystore_${theSourceFile} PROPERTIES COMPILE_DEFINITIONS _IN_QPID_BROKER)
remember_location(legacystore_${theSourceFile})
-add_test (legacystore_${theSourceFile} ${test_wrap} ${legacystore_${theSourceFile}_LOCATION})
+add_test (legacystore_${theSourceFile} ${test_wrap} -- ${legacystore_${theSourceFile}_LOCATION})
ENDMACRO (define_legacystore_test)
define_legacystore_test (SimpleTest)
@@ -76,7 +78,7 @@ if ("${ARGV1}" STREQUAL "LONG")
set_target_properties(${testname} PROPERTIES COMPILE_DEFINITIONS LONG_TEST)
endif ()
remember_location(${testname})
-add_test (${testname} ${test_wrap} ${${testname}_LOCATION})
+add_test (${testname} ${test_wrap} -- ${${testname}_LOCATION})
unset (testname)
ENDMACRO (define_journal_test)
@@ -123,6 +125,8 @@ target_link_libraries (jtt__ut
${Boost_PROGRAM_OPTIONS_LIBRARY}
${clock_gettime_LIB} legacystore_shared)
+add_test(journal_jtt_ut ${test_wrap} --working-dir=${CMAKE_CURRENT_SOURCE_DIR}/jrnl/jtt -- ${CMAKE_CURRENT_BINARY_DIR}/jtt__ut)
+
endif (BUILD_TESTING_UNITTESTS)
#
diff --git a/qpid/cpp/src/tests/legacystore/tests_env.sh b/qpid/cpp/src/tests/legacystore/tests_env.sh
deleted file mode 100644
index 30d255b87c..0000000000
--- a/qpid/cpp/src/tests/legacystore/tests_env.sh
+++ /dev/null
@@ -1,260 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-# --- Function definitions ---
-
-
-func_check_required_env ()
-#-------------------------
-# Check that EITHER:
-# QPID_DIR is set (for running against svn QPID)
-# OR
-# QPID_PREFIX is set (for running against installed QPID
-# Will exit with error code 1 if neither of these is defined.
-# Params: None
-# Returns: 0 if env vars ok, 1 otherwise
-{
- if test -z "${QPID_DIR}" -a -z "${QPID_PREFIX}"; then
- # Try to find qpidd in the normal installed location
- if test -x /usr/sbin/qpidd; then
- QPID_PREFIX=/usr
- else
- echo "ERROR: Could not find installed Qpid"
- echo "Either of the following must be set in the environment for this script to run:"
- echo " QPID_DIR for running against a Qpid svn build"
- echo " QPID_PREFIX for running against an installed Qpid"
- return 1
- fi
- fi
- return 0
-}
-
-
-func_check_qpid_python ()
-#------------------------
-# Check that Qpid python environment is ok
-# Params: None
-# Returns: 0 if Python environment is ok; 1 otherwise
-{
- if ! python -c "import qpid" ; then
- cat <<EOF
-
- =========== WARNING: PYTHON TESTS DISABLED ==============
-
- Unable to load python qpid module - skipping python tests.
-
- PYTHONPATH=${PYTHONPATH}
-
- ===========================================================
-
-EOF
- return 1
- fi
- return 0
-}
-
-
-func_set_env ()
-#--------------
-# Set up the environment based on value of ${QPID_DIR}: if ${QPID_DIR} exists, assume a svn checkout,
-# otherwise set up for an installed or prefix test.
-# Params: None
-# Returns: Nothing
-{
- if test "${QPID_DIR}" -a -d "${QPID_DIR}" ; then
- # QPID_DIR is defined for source tree builds by the --with-qpid-checkout configure option.
- # QPID_BLD is defined as the build directory, either $QPID_DIR/cpp or separately specified with
- # the --with-qpid-build option for VPATH builds.
-
- # Check QPID_BLD is also set
- if test -z ${QPID_BLD}; then
- QPID_BLD="${QPID_DIR}/cpp"
- fi
-
- # Paths and dirs
- #if test -z ${abs_srcdir}; then
- # abs_srcdir=`pwd`
- #fi
- source $QPID_BLD/src/tests/test_env.sh
- # Override these two settings from test_env.sh:
- export RECEIVER_EXEC=$QPID_TEST_EXEC_DIR/qpid-receive
- export SENDER_EXEC=$QPID_TEST_EXEC_DIR/qpid-send
-
- echo "abs_srcdir=$abs_srcdir"
- export STORE_LIB="`pwd`/../lib/.libs/msgstore.so"
- export STORE_ENABLE=1
- export CLUSTER_LIB="${QPID_BLD}/src/.libs/cluster.so"
-
- PYTHON_DIR="${QPID_DIR}/python"
- export PYTHONPATH="${PYTHONPATH}":"${PYTHON_DIR}":"${QPID_DIR}/extras/qmf/src/py":"${QPID_DIR}/tools/src/py":"${QPID_DIR}/cpp/src/tests":"${abs_srcdir}"
-
- # Libraries
-
- # Executables
- export QPIDD_EXEC="${QPID_BLD}/src/qpidd"
-
- # Test data
-
- else
- # Set up the environment based on value of ${QPID_PREFIX} for testing against an installed qpid
- # Alternatively, make sure ${QPID_BIN_DIR}, ${QPID_SBIN_DIR}, ${QPID_LIB_DIR} and ${QPID_LIBEXEC_DIR} are set for
- # the installed location.
- if test "${QPID_PREFIX}" -a -d "${QPID_PREFIX}" ; then
- QPID_BIN_DIR=${QPID_PREFIX}/bin
- QPID_SBIN_DIR=${QPID_PREFIX}/sbin
- QPID_LIB_DIR=${QPID_PREFIX}/lib
- QPID_LIBEXEC_DIR=${QPID_PREFIX}/libexec
- fi
-
- # These four env vars must be set prior to calling this script
- func_checkpaths QPID_BIN_DIR QPID_SBIN_DIR QPID_LIB_DIR QPID_LIBEXEC_DIR
-
- # Paths and dirs
- export PYTHON_DIR="${QPID_BIN_DIR}"
- export PYTHONPATH="${PYTHONPATH}":"${QPID_LIB_DIR}/python":"${QPID_LIBEXEC_DIR}/qpid/tests":"${QPID_LIB_DIR}/python2.4"
-
-
- # Libraries
-
- # Executables
- export QPIDD_EXEC="${QPID_SBIN_DIR}/qpidd"
-
- # Test Data
-
- fi
-}
-
-
-func_mk_data_dir ()
-#------------------
-# Create a data dir at ${TMP_DATA_DIR} if not present, clear it otherwise.
-# Set TMP_DATA_DIR if it is not set.
-# Params: None
-# Returns: Nothing
-{
- if test -z "${TMP_DATA_DIR}"; then
- TMP_DATA_DIR=/tmp/python_tests
- echo "TMP_DATA_DIR not set; using ${TMP_DATA_DIR}"
- fi
-
- # Delete old test dirs if they exist
- if test -d "${TMP_DATA_DIR}" ; then
- rm -rf "${TMP_DATA_DIR}/*"
- fi
- mkdir -p "${TMP_DATA_DIR}"
- export TMP_DATA_DIR
-}
-
-
-func_checkvar ()
-#---------------
-# Check that an environment var is set (ie non-zero length)
-# Params: $1 - env var to be checked
-# Returns: 0 = env var is set (ie non-zero length)
-# 1 = env var is not set
-{
- local loc_VAR=$1
- if test -z ${!loc_VAR}; then
- echo "WARNING: environment variable ${loc_VAR} not set."
- return 1
- fi
- return 0
-}
-
-
-func_checkpaths ()
-#-----------------
-# Check a list of paths (each can contain ':'-separated sub-list) is set and valid (ie each path exists as a dir)
-# Params: $@ - List of path env vars to be checked
-# Returns: Nothing
-{
- local loc_PATHS=$@
- for path in ${loc_PATHS}; do
- func_checkvar ${path}
- if test $? == 0; then
- local temp_IFS=${IFS}
- IFS=":"
- local pl=${!path}
- for p in ${pl[@]}; do
- if test ! -d ${p}; then
- echo "WARNING: Directory ${p} in var ${path} not found."
- fi
- done
- IFS=${temp_IFS}
- fi
- done
-}
-
-
-func_checklibs ()
-#----------------
-# Check that a list of libs is set and valid (ie each lib exists as an executable file)
-# Params: $@ - List of lib values to be checked
-# Returns: Nothing
-{
- local loc_LIBS=$@
- for lib in ${loc_LIBS[@]}; do
- func_checkvar ${lib}
- if test $? == 0; then
- if test ! -x ${!lib}; then
- echo "WARNING: Library ${lib}=${!lib} not found."
- fi
- fi
- done
-}
-
-
-func_checkexecs ()
-#-----------------
-# Check that a list of executable is set and valid (ie each exec exists as an executable file)
-# Params: $@ - List of exec values to be checked
-# Returns: Nothing
-{
- local loc_EXECS=$@
- for exec in ${loc_EXECS[@]}; do
- func_checkvar ${exec}
- if test $? == 0; then
- if test ! -x ${!exec}; then
- echo "WARNING: Executable ${exec}=${!exec} not found or is not executable."
- fi
- fi
- done
-}
-
-
-#--- Start of script ---
-
-func_check_required_env || exit 1 # Cannot run, exit with error
-
-srcdir=`dirname $0`
-if test -z ${abs_srcdir}; then
- abs_srcdir=${srcdir}
-fi
-
-func_set_env
-func_check_qpid_python || exit 0 # A warning, not a failure.
-func_mk_data_dir
-
-# Check expected environment vars are set
-func_checkpaths PYTHON_DIR PYTHONPATH TMP_DATA_DIR
-func_checklibs STORE_LIB CLUSTER_LIB
-func_checkexecs QPIDD_EXEC QPID_CONFIG_EXEC QPID_ROUTE_EXEC SENDER_EXEC RECEIVER_EXEC
-
-FAILING_PYTHON_TESTS="${abs_srcdir}/failing_python_tests.txt"
-
diff --git a/qpid/cpp/src/tests/run_header_test b/qpid/cpp/src/tests/run_header_test
index 34008132cc..53b31026d5 100755
--- a/qpid/cpp/src/tests/run_header_test
+++ b/qpid/cpp/src/tests/run_header_test
@@ -23,15 +23,9 @@
# TODO: this should be expanded to cover a wider set of types and go
# in both directions
-srcdir=`dirname $0`
-source ./test_env.sh
-
-test -f qpidd.port && QPID_PORT=`cat qpidd.port`
-
if test -d ${PYTHON_DIR} ; then
./header_test -p $QPID_PORT
$srcdir/header_test.py "localhost" $QPID_PORT
else
echo "Skipping header test as python libs not found"
fi
-
diff --git a/qpid/cpp/src/tests/run_msg_group_tests b/qpid/cpp/src/tests/run_msg_group_tests
index 4e82759866..abbafe7592 100755
--- a/qpid/cpp/src/tests/run_msg_group_tests
+++ b/qpid/cpp/src/tests/run_msg_group_tests
@@ -20,17 +20,8 @@
#
#script to run a sequence of message group queue tests via make
-#setup path to find qpid-config and msg_group_test progs
-source ./test_env.sh
test -d $PYTHON_DIR || { echo "Skipping message group tests, no python dir."; exit 0; }
-export PATH=$PWD:$srcdir:$PYTHON_COMMANDS:$PATH
-
-#set port to connect to via env var
-test -s qpidd.port && QPID_PORT=`cat qpidd.port`
-
-#trap cleanup INT TERM QUIT
-
QUEUE_NAME="group-queue"
GROUP_KEY="My-Group-Id"
diff --git a/qpid/cpp/src/tests/run_queue_flow_limit_tests b/qpid/cpp/src/tests/run_queue_flow_limit_tests
index f6b5da97ea..4ba6f17dac 100755
--- a/qpid/cpp/src/tests/run_queue_flow_limit_tests
+++ b/qpid/cpp/src/tests/run_queue_flow_limit_tests
@@ -21,31 +21,4 @@
# Run tests against Queue producer flow control.
-source ./test_env.sh
-test -d $PYTHON_DIR || { echo "Skipping queue flow control tests, no python dir."; exit 0; }
-
-LOG_FILE=qpidd.log
-
-trap stop_broker INT TERM QUIT
-
-error() {
- echo $*
- exit 1;
-}
-
-#set -x
-
-rm -rf $LOG_FILE
-# Note: if you change the DEFAULT_THRESHOLDS, you will need to update queue_flow_limit_tests.py
-DEFAULT_THRESHOLDS="--default-flow-stop-threshold=80 --default-flow-resume-threshold=70"
-start_broker $DEFAULT_THRESHOLDS -t --log-to-stderr=no --log-to-stdout=no || error "Could not start broker"
-QPID_PORT=`cat qpidd.port`
-echo "Running Queue flow limit tests using broker on port $QPID_PORT"
-$QPID_PYTHON_TEST -m queue_flow_limit_tests $SKIPTESTS -b localhost:$QPID_PORT $@
-RETCODE=$?
-stop_broker || error "Could not stop broker"
-if test x$RETCODE != x0; then
- echo "FAIL queue flow limit tests"; exit 1;
-fi
-rm -rf $LOG_FILE
-
+$QPID_PYTHON_TEST -m queue_flow_limit_tests $SKIPTESTS -b localhost:$QPID_PORT
diff --git a/qpid/cpp/src/tests/run_test b/qpid/cpp/src/tests/run_test
index 16e7362d5a..12458e343f 100755
--- a/qpid/cpp/src/tests/run_test
+++ b/qpid/cpp/src/tests/run_test
@@ -31,19 +31,30 @@
# examination.
#
-srcdir=`dirname $0`
-source ./test_env.sh
-source $srcdir/vg_check
+working_dir='.'
-# Export variables from makefile.
-export srcdir
+OPTS=$(getopt -n "Qpid Test Wrapper" -o d:b:s:p -l working-dir:,build-dir:,source-dir:,python,start-broker,broker-options: -- "$@") || exit 1
+eval set -- $OPTS
-# Set QPID_PORT if qpidd.port exists.
-test -s qpidd.port && QPID_PORT=`cat qpidd.port`
-export QPID_PORT
+while true; do
+case "$1" in
+ -d|--working-dir) working_dir=$2; shift 2 ;;
+ -b|--build-dir) build_dir=$2; shift 2 ;;
+ -s|--source-dir) source_dir=$2; shift 2 ;;
+ -p|--python) run_python=yes; shift ;;
+ --start-broker) start_broker=yes; shift ;;
+ --broker-options) qpidd_extra_options=$2; shift 2 ;;
+ --) shift; break ;;
+esac
+done
+
+program=$1
+shift
+
+logfilebase=$(pwd -P)/$(basename $program)
+source $build_dir/src/tests/test_env.sh || (echo "Error: Couldn't read test_env.sh (build settings)" ; exit 1)
+source $srcdir/vg_check
-VG_LOG="`basename $1`.vglog"
-rm -f $VG_LOG*
# Use VALGRIND_OPTS="--gen-suppressions=all" to generated suppressions
VALGRIND_OPTS="$VALGRIND_OPTS
@@ -51,23 +62,63 @@ VALGRIND_OPTS="$VALGRIND_OPTS
--demangle=yes
--suppressions=$srcdir/.valgrind.supp
--num-callers=25
---log-file=$VG_LOG --
"
+
+# Set up environment for running a Qpid test
+if [ -n "$start_broker" ] ; then
+ qpidd_options="--auth=no --no-module-dir --daemon --port=0 --interface 127.0.0.1 --log-to-file $logfilebase-qpidd.log $qpidd_extra_options"
+ if [ -n "$VALGRIND" ] ; then
+ QPID_PORT=$($VALGRIND $VALGRIND_OPTS --log-file=$logfilebase-qpidd.vglog -- $QPIDD_EXEC $qpidd_options)
+ else
+ QPID_PORT=$($QPID_EXEC $qpidd_options)
+ fi
+elif [ -r qpidd.port ]; then
+ QPID_PORT=$(cat qpidd.port)
+fi
+export QPID_PORT
+QPID_LOG_TO_FILE="$logfilebase.log"
+export QPID_LOG_TO_FILE
+
+# Export variables from makefile.
+export srcdir
+
+VG_LOG="$logfilebase.vglog"
+rm -f $VG_LOG*
+
ERROR=0
-if [ ! -x $1 ] ; then
- echo "Cannot execute $1"
+if [ -n "$run_python" -a -n "$PYTHON" ] ; then
+ (cd $working_dir; $PYTHON $program "$@") || ERROR=1
+elif [ ! -x $program ] ; then
+ echo "Cannot execute $program"
ERROR=1
-elif file $1 | grep -q text; then
- # This is a shell script, just execute it.
- exec "$@"
-elif [ -n "$VALGRIND" ] ; then
+elif (file $program | grep -q ELF) && [ -n "$VALGRIND" ] ; then
# This is a real executable, valgrind it.
# Hide output unless there's an error.
- $VALGRIND $VALGRIND_OPTS "$@" 2>&1 || ERROR=1
+ (cd $working_dir; $VALGRIND $VALGRIND_OPTS --log-file=$VG_LOG -- $program "$@" 2>&1) || ERROR=1
vg_check $VG_LOG* || ERROR=1
else
- "$@" 2>&1 || ERROR=1
+ (cd $working_dir; $program "$@") || ERROR=1
fi
+# Check log
+if [ -r $QPID_LOG_TO_FILE ]; then
+egrep 'warning\|error\|critical' $QPID_LOG_TO_FILE && {
+ echo "WARNING: Suspicious broker log entries in $QPID_LOG_TO_FILE, above."
+}
+fi
+
+if [ -n "$start_broker" ] ; then
+ $QPIDD_EXEC --no-module-dir --quit || ERROR=1
+
+ # Check qpidd.log.
+ egrep 'warning\|error\|critical' $logfilebase-qpidd.log && {
+ echo "WARNING: Suspicious broker log entries in qpidd.log, above."
+ }
+
+ # Check valgrind log.
+ if test -n "$VALGRIND"; then
+ vg_check $logfilebase-qpidd.vglog || ERROR=1
+ fi
+fi
exit $ERROR
diff --git a/qpid/cpp/src/tests/start_broker b/qpid/cpp/src/tests/start_broker
deleted file mode 100755
index 6eea38e0f8..0000000000
--- a/qpid/cpp/src/tests/start_broker
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-# Start a test broker.
-srcdir=`dirname $0`
-exec $srcdir/run_test ../qpidd --auth=no --no-module-dir --daemon --port=0 --interface 127.0.0.1 --log-to-file qpidd.log "$@" > qpidd.port
diff --git a/qpid/cpp/src/tests/start_broker.ps1 b/qpid/cpp/src/tests/start_broker.ps1
deleted file mode 100644
index 6f4a140efd..0000000000
--- a/qpid/cpp/src/tests/start_broker.ps1
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-# Get the directory where this script resides.
-function Get-ScriptPath
- { Split-Path $myInvocation.ScriptName }
-
-# Start a test broker and capture it's port (from stdout) to qpidd.port
-# This script will exit immediately after spawning the broker process. To avoid
-# running more tests before the broker is initialized, wait for the qpidd.port
-# file to appear before exiting.
-if (Test-Path qpidd.port) {
- Remove-Item qpidd.port
-}
-
-# Test runs from the tests directory but the broker executable is one level
-# up, and most likely in a subdirectory from there based on what build type.
-# Look around for it before trying to start it.
-$subs = "Debug","Release","MinSizeRel","RelWithDebInfo"
-foreach ($sub in $subs) {
- $prog = "..\$sub\qpidd.exe"
- if (Test-Path $prog) {
- break
- }
-}
-if (!(Test-Path $prog)) {
- "Cannot locate qpidd.exe"
- exit 1
-}
-$cmdline = "$prog --auth=no --no-module-dir --port=0 --log-to-file qpidd.log $args | foreach { set-content qpidd.port `$_ }"
-$cmdblock = $executioncontext.invokecommand.NewScriptBlock($cmdline)
-$srcdir = Get-ScriptPath
-. $srcdir\background.ps1 $cmdblock
-
-$wait_time = 0
-while (!(Test-Path qpidd.port) -and ($wait_time -lt 30)) {
- Start-Sleep 2
- $wait_time += 2
-}
-if (Test-Path qpidd.port) {
- exit 0
-}
-"Time out waiting for broker to start"
-exit 1
diff --git a/qpid/cpp/src/tests/stop_broker b/qpid/cpp/src/tests/stop_broker
deleted file mode 100755
index b774e70225..0000000000
--- a/qpid/cpp/src/tests/stop_broker
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-# Stop the broker, check for errors.
-#
-QPID_PORT=`cat qpidd.port`
-export QPID_PORT
-rm -f qpidd.port
-
-../qpidd --no-module-dir --quit || ERROR=1
-
-# Check qpidd.log.
-egrep 'warning\|error\|critical' qpidd.log && {
- echo "WARNING: Suspicious broker log entries in qpidd.log, above."
-}
-
-# Check valgrind log.
-if test -n "$VALGRIND"; then
- . `dirname $0`/vg_check $VG_LOG*
- vg_check qpidd.vglog* || ERROR=1
-fi
-
-exit $ERROR
diff --git a/qpid/cpp/src/tests/stop_broker.ps1 b/qpid/cpp/src/tests/stop_broker.ps1
deleted file mode 100644
index 4fdeb26e2b..0000000000
--- a/qpid/cpp/src/tests/stop_broker.ps1
+++ /dev/null
@@ -1,56 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-# Stop the broker, check for errors.
-Get-Content -path qpidd.port -totalCount 1 | Set-Variable -name qpid_port
-Remove-Item qpidd.port
-
-# Test runs from the tests directory but the broker executable is one level
-# up, and most likely in a subdirectory from there based on what build type.
-# Look around for it before trying to start it.
-$subs = "Debug","Release","MinSizeRel","RelWithDebInfo"
-foreach ($sub in $subs) {
- $prog = "..\$sub\qpidd.exe"
- if (Test-Path $prog) {
- break
- }
-}
-if (!(Test-Path $prog)) {
- "Cannot locate qpidd.exe"
- exit 1
-}
-
-# Piping the output makes the script wait for qpidd to finish.
-Invoke-Expression "$prog --quit --port $qpid_port" | Write-Output
-$stopped = $?
-
-# Check qpidd.log.
-filter bad_stuff {
- $_ -match "( warning | error | critical )"
-}
-
-$qpidd_errors = $false
-Get-Content -path qpidd.log | where { bad_stuff } | Out-Default | Set-Variable -name qpidd_errors -value $true
-if ($qpidd_errors -eq $true) {
- "WARNING: Suspicious broker log entries in qpidd.log, above."
-}
-if ($stopped -eq $true) {
- exit 0
-}
-exit 1
diff --git a/qpid/cpp/src/tests/test_env.sh.in b/qpid/cpp/src/tests/test_env.sh.in
index 2247469cc3..a16812ca6c 100644
--- a/qpid/cpp/src/tests/test_env.sh.in
+++ b/qpid/cpp/src/tests/test_env.sh.in
@@ -36,6 +36,7 @@ if [ "$enable_valgrind" = "ON" ] ; then
export VALGRIND=@VALGRIND_EXECUTABLE@
fi
export SASL_PW=@SASLPASSWD2_EXECUTABLE@
+export PYTHON=@PYTHON_EXECUTABLE@
# Python paths and directories
export PYTHON_DIR=$builddir/python
diff --git a/qpid/cpp/src/tests/test_wrap b/qpid/cpp/src/tests/test_wrap
deleted file mode 100755
index dd43c5a2e2..0000000000
--- a/qpid/cpp/src/tests/test_wrap
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/sh
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-# Read the started broker port, set appropriate env vars
-# then run the program under test
-
-QPID_PORT=`cat qpidd.port`
-export QPID_PORT
-
-program=$1
-shift
-
-QPID_LOG_TO_FILE=`basename $program`.log
-export QPID_LOG_TO_FILE
-
-ERROR=0
-$program $* || ERROR=1
-
-# Check qpidd.log.
-egrep 'warning\|error\|critical' $QPID_LOG_TO_FILE && {
- echo "WARNING: Suspicious broker log entries in $QPID_LOG_TO_FILE, above."
-}
-
-# Check valgrind log.
-#if test -n "$VALGRIND"; then
-# . `dirname $0`/vg_check $VG_LOG*
-# vg_check qpidd.vglog* || ERROR=1
-#fi
-
-exit $ERROR