summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2009-11-30 19:34:36 +0000
committerAlan Conway <aconway@apache.org>2009-11-30 19:34:36 +0000
commit7a70ee7193a85ceb52cbfe3df2684e947cee9456 (patch)
tree3f8c78519d4169bc7c0ec8015a684879527a5350 /cpp/src
parentd3e2aeef6229259be003071988706c934677ff43 (diff)
downloadqpid-python-7a70ee7193a85ceb52cbfe3df2684e947cee9456.tar.gz
Clean up test environment variables, prepare for running more tests in cmake.
- consolidate test env vars in test_env.sh, also useful from command line. - generate test_env.sh with autoconf/cmake to cover library location differences. - Remove explicit mention of .libs, use $QPID_MODULE_DIR to load modules. - Fix run_test to run valgrind under cmake git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@885557 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/CMakeLists.txt8
-rw-r--r--cpp/src/tests/CMakeLists.txt15
-rw-r--r--cpp/src/tests/ClusterFailover.cpp2
-rw-r--r--cpp/src/tests/Makefile.am7
-rw-r--r--cpp/src/tests/PartialFailure.cpp4
-rw-r--r--cpp/src/tests/ReplicationTest.cpp3
-rw-r--r--cpp/src/tests/XmlClientSessionTest.cpp7
-rw-r--r--cpp/src/tests/cluster_test.cpp4
-rwxr-xr-xcpp/src/tests/clustered_replication_test7
-rwxr-xr-xcpp/src/tests/federated_cluster_test2
-rwxr-xr-xcpp/src/tests/federated_topic_test2
-rw-r--r--cpp/src/tests/python_env.sh26
-rwxr-xr-xcpp/src/tests/python_tests5
-rwxr-xr-xcpp/src/tests/reliable_replication_test15
-rwxr-xr-xcpp/src/tests/replication_test18
-rwxr-xr-xcpp/src/tests/run_acl_tests10
-rwxr-xr-xcpp/src/tests/run_cli_tests6
-rwxr-xr-xcpp/src/tests/run_cluster_tests7
-rwxr-xr-xcpp/src/tests/run_failover_soak5
-rwxr-xr-xcpp/src/tests/run_federation_tests8
-rwxr-xr-xcpp/src/tests/run_header_test5
-rwxr-xr-xcpp/src/tests/run_ring_queue_test4
-rwxr-xr-xcpp/src/tests/run_test14
-rwxr-xr-xcpp/src/tests/ssl_test6
-rwxr-xr-xcpp/src/tests/start_cluster3
-rw-r--r--cpp/src/tests/test_env.sh51
-rw-r--r--cpp/src/tests/test_env.sh.in76
-rw-r--r--cpp/src/tests/test_tools.h9
28 files changed, 166 insertions, 163 deletions
diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt
index 907dc0e71e..dc084662dd 100644
--- a/cpp/src/CMakeLists.txt
+++ b/cpp/src/CMakeLists.txt
@@ -324,6 +324,7 @@ if (BUILD_XML)
qpid/xml/XmlExchange.cpp
qpid/xml/XmlExchange.h
qpid/xml/XmlExchangePlugin.cpp)
+ set_target_properties (xml PROPERTIES PREFIX "")
target_link_libraries (xml xerces-c xqilla qpidbroker pthread)
if (CMAKE_COMPILER_IS_GNUCXX)
set_target_properties (xml PROPERTIES
@@ -356,6 +357,7 @@ if (BUILD_ACL)
qpid/acl/AclReader.h
)
add_library (acl MODULE ${acl_SOURCES})
+ set_target_properties (acl PROPERTIES PREFIX "")
target_link_libraries (acl qpidbroker ${Boost_PROGRAM_OPTIONS_LIBRARY})
if (CMAKE_COMPILER_IS_GNUCXX)
set_target_properties (acl PROPERTIES
@@ -873,8 +875,7 @@ add_library (replicating_listener MODULE
qpid/replication/ReplicatingEventListener.h
)
target_link_libraries (replicating_listener qpidbroker ${Boost_PROGRAM_OPTIONS_LIBRARY})
-set_target_properties (replicating_listener PROPERTIES
- PREFIX "")
+set_target_properties (replicating_listener PROPERTIES PREFIX "")
if (CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(replicating_listener PROPERTIES
LINK_FLAGS -Wl,--no-undefined)
@@ -893,8 +894,7 @@ add_library (replicating_exchange MODULE
qpid/replication/ReplicationExchange.h
)
target_link_libraries (replicating_exchange qpidbroker)
-set_target_properties (replicating_exchange PROPERTIES
- PREFIX "")
+set_target_properties (replicating_exchange PROPERTIES PREFIX "")
if (CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(replicating_exchange PROPERTIES
LINK_FLAGS -Wl,--no-undefined)
diff --git a/cpp/src/tests/CMakeLists.txt b/cpp/src/tests/CMakeLists.txt
index b1219aad74..fce9c3516a 100644
--- a/cpp/src/tests/CMakeLists.txt
+++ b/cpp/src/tests/CMakeLists.txt
@@ -28,6 +28,16 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
include (FindPythonInterp)
+# Create the environment scripts for tests
+set (abs_srcdir ${CMAKE_CURRENT_SOURCE_DIR})
+set (abs_builddir ${CMAKE_CURRENT_BINARY_DIR})
+set (abs_top_srcdir ${CMAKE_SOURCE_DIR})
+set (abs_top_builddir ${CMAKE_BINARY_DIR})
+set (builddir_lib_suffix "")
+configure_file (${CMAKE_CURRENT_SOURCE_DIR}/test_env.sh.in
+ ${CMAKE_CURRENT_BINARY_DIR}/test_env.sh)
+
+
# If valgrind is selected in the configuration step, set up the path to it
# for CTest.
if (ENABLE_VALGRIND)
@@ -158,9 +168,10 @@ target_link_libraries (unit_test
remember_location(unit_test)
add_library (shlibtest MODULE shlibtest.cpp)
-#libshlibtest_la_LDFLAGS = -module -rpath $(abs_builddir)
-#include cluster.mk
+# include(cluster.cmake)
+
+# FIXME aconway 2009-11-30: enable SSL
#if SSL
#include ssl.mk
#endif
diff --git a/cpp/src/tests/ClusterFailover.cpp b/cpp/src/tests/ClusterFailover.cpp
index f7d05d516b..6b1ef99807 100644
--- a/cpp/src/tests/ClusterFailover.cpp
+++ b/cpp/src/tests/ClusterFailover.cpp
@@ -54,7 +54,7 @@ const sys::Duration TIMEOUT=sys::TIME_SEC/4;
// Test re-connecting with same session name after a failure.
QPID_AUTO_TEST_CASE(testReconnectSameSessionName) {
ostringstream clusterLib;
- clusterLib << getLibPath("CLUSTER_LIB", "../.libs/cluster.so");
+ clusterLib << getLibPath("CLUSTER_LIB");
ClusterFixture::Args args = list_of<string>("--auth")("no")("--no-module-dir")("--no-data-dir")("--load-module")(clusterLib.str());
ClusterFixture cluster(2, args, -1);
Client c0(cluster[0], "foo");
diff --git a/cpp/src/tests/Makefile.am b/cpp/src/tests/Makefile.am
index 44e1574968..dc677c5862 100644
--- a/cpp/src/tests/Makefile.am
+++ b/cpp/src/tests/Makefile.am
@@ -23,6 +23,7 @@ PUBLIC_INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include # Use public
abs_builddir=@abs_builddir@
abs_srcdir=@abs_srcdir@
+
extra_libs =
lib_client = $(abs_builddir)/../libqpidclient.la
lib_common = $(abs_builddir)/../libqpidcommon.la
@@ -280,12 +281,7 @@ qpid_stream_LDADD=$(lib_client)
TESTS_ENVIRONMENT = \
VALGRIND=$(VALGRIND) \
LIBTOOL="$(LIBTOOL)" \
- srcdir=$(srcdir) \
- top_builddir=$(top_builddir) \
QPID_DATA_DIR= \
- ACL_LIB=../.libs/acl.so \
- CLUSTER_LIB=../.libs/cluster.so \
- TEST_STORE_LIB=.libs/test_store.so \
BOOST_TEST_SHOW_PROGRESS=yes \
$(srcdir)/run_test
@@ -332,7 +328,6 @@ LONG_TESTS+=start_broker fanout_perftest shared_perftest multiq_perftest topic_p
EXTRA_DIST+= \
CMakeLists.txt \
- python_env.sh \
fanout_perftest \
shared_perftest \
multiq_perftest \
diff --git a/cpp/src/tests/PartialFailure.cpp b/cpp/src/tests/PartialFailure.cpp
index 21c6c5c724..63ee28017a 100644
--- a/cpp/src/tests/PartialFailure.cpp
+++ b/cpp/src/tests/PartialFailure.cpp
@@ -53,8 +53,8 @@ static bool isLogOption(const std::string& s) { return boost::starts_with(s, "--
void updateArgs(ClusterFixture::Args& args, size_t index) {
ostringstream clusterLib, testStoreLib, storeName;
- clusterLib << getLibPath("CLUSTER_LIB", "../.libs/cluster.so");
- testStoreLib << getLibPath("TEST_STORE_LIB", ".libs/test_store.so");
+ clusterLib << getLibPath("CLUSTER_LIB");
+ testStoreLib << getLibPath("TEST_STORE_LIB");
storeName << "s" << index;
args.push_back("--auth");
args.push_back("no");
diff --git a/cpp/src/tests/ReplicationTest.cpp b/cpp/src/tests/ReplicationTest.cpp
index ed768f1306..3b289d1b4e 100644
--- a/cpp/src/tests/ReplicationTest.cpp
+++ b/cpp/src/tests/ReplicationTest.cpp
@@ -47,12 +47,13 @@ namespace tests {
QPID_AUTO_TEST_SUITE(ReplicationTestSuite)
+// FIXME aconway 2009-11-26: clean this up.
// The CMake-based build passes in the module suffix; if it's not there, this
// is a Linux/UNIX libtool-based build.
#if defined (QPID_MODULE_SUFFIX)
qpid::sys::Shlib plugin("replicating_listener" QPID_MODULE_SUFFIX);
#else
-qpid::sys::Shlib plugin("../.libs/replicating_listener.so");
+qpid::sys::Shlib plugin(getLibPath("REPLICATING_LISTENER_LIB"));
#endif
qpid::broker::Broker::Options getBrokerOpts(const std::vector<std::string>& args)
diff --git a/cpp/src/tests/XmlClientSessionTest.cpp b/cpp/src/tests/XmlClientSessionTest.cpp
index 46a4c826a3..b59abbf2cc 100644
--- a/cpp/src/tests/XmlClientSessionTest.cpp
+++ b/cpp/src/tests/XmlClientSessionTest.cpp
@@ -55,11 +55,8 @@ using std::string;
using std::cout;
using std::endl;
-#if defined (QPID_MODULE_SUFFIX)
- Shlib shlib("../xml" QPID_MODULE_SUFFIX);
-#else
- Shlib shlib("../.libs/xml.so");
-#endif
+
+Shlib shlib(getLibPath("XML_LIB"));
class SubscribedLocalQueue : public LocalQueue {
private:
diff --git a/cpp/src/tests/cluster_test.cpp b/cpp/src/tests/cluster_test.cpp
index 7ca58415dc..a2e18b8f78 100644
--- a/cpp/src/tests/cluster_test.cpp
+++ b/cpp/src/tests/cluster_test.cpp
@@ -72,7 +72,7 @@ bool durableFlag = std::getenv("STORE_LIB") != 0;
void prepareArgs(ClusterFixture::Args& args, const bool durableFlag = false) {
ostringstream clusterLib;
- clusterLib << getLibPath("CLUSTER_LIB", "../.libs/cluster.so");
+ clusterLib << getLibPath("CLUSTER_LIB");
args += "--auth", "no", "--no-module-dir", "--load-module", clusterLib.str();
if (durableFlag)
args += "--load-module", getLibPath("STORE_LIB"), "TMP_DATA_DIR";
@@ -227,7 +227,7 @@ QPID_AUTO_TEST_CASE(testAcl) {
char cwd[1024];
BOOST_CHECK(::getcwd(cwd, sizeof(cwd)));
ostringstream aclLib;
- aclLib << getLibPath("ACL_LIB", "../.libs/acl.so");
+ aclLib << getLibPath("ACL_LIB");
ClusterFixture::Args args;
prepareArgs(args, durableFlag);
args += "--log-enable=critical"; // Supress expected errors
diff --git a/cpp/src/tests/clustered_replication_test b/cpp/src/tests/clustered_replication_test
index 49d788f41e..c7719b8424 100755
--- a/cpp/src/tests/clustered_replication_test
+++ b/cpp/src/tests/clustered_replication_test
@@ -21,8 +21,7 @@
# Test reliability of the replication feature in the face of link
# failures:
-srcdir=`dirname $0`
-. $srcdir/python_env.sh
+source ./test_env.sh
trap stop_brokers INT EXIT
@@ -58,8 +57,8 @@ if test -d $PYTHON_DIR; then
DR_CLUSTER=DR_$(hostname)_$$
GENERAL_OPTS="--auth no --no-module-dir --no-data-dir --daemon --port 0 --log-to-stderr false"
- PRIMARY_OPTS="--load-module ../.libs/replicating_listener.so --create-replication-queue true --replication-queue REPLICATION_QUEUE --load-module ../.libs/cluster.so --cluster-name $PRIMARY_CLUSTER"
- DR_OPTS="--load-module ../.libs/replication_exchange.so --load-module ../.libs/cluster.so --cluster-name $DR_CLUSTER"
+ PRIMARY_OPTS="--load-module $QPID_MODULE_DIR/replicating_listener.so --create-replication-queue true --replication-queue REPLICATION_QUEUE --load-module $QPID_MODULE_DIR/cluster.so --cluster-name $PRIMARY_CLUSTER"
+ DR_OPTS="--load-module $QPID_MODULE_DIR/replication_exchange.so --load-module $QPID_MODULE_DIR/cluster.so --cluster-name $DR_CLUSTER"
rm -f repl*.tmp #cleanup any files left from previous run
diff --git a/cpp/src/tests/federated_cluster_test b/cpp/src/tests/federated_cluster_test
index 8b3ce3cb95..89bb711c3e 100755
--- a/cpp/src/tests/federated_cluster_test
+++ b/cpp/src/tests/federated_cluster_test
@@ -22,7 +22,7 @@
# Test reliability of the replication feature in the face of link
# failures:
srcdir=`dirname $0`
-. $srcdir/python_env.sh
+source ./test_env.sh
trap stop_brokers EXIT
diff --git a/cpp/src/tests/federated_topic_test b/cpp/src/tests/federated_topic_test
index dbe9a85e95..7d56f602e9 100755
--- a/cpp/src/tests/federated_topic_test
+++ b/cpp/src/tests/federated_topic_test
@@ -43,7 +43,7 @@ while getopts "s:m:b:" opt ; do
done
MY_DIR=$(dirname $(which $0))
-. $MY_DIR/python_env.sh
+source ./test_env.sh
trap stop_brokers EXIT
diff --git a/cpp/src/tests/python_env.sh b/cpp/src/tests/python_env.sh
deleted file mode 100644
index f5dca97a56..0000000000
--- a/cpp/src/tests/python_env.sh
+++ /dev/null
@@ -1,26 +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.
-#
-
-# Environment for python tests
-test -d python || { echo "WARNING: skipping `basename $0`, no python directory."; exit 0; }
-PYTHON_DIR=$PWD/python
-PYTHON_COMMANDS=$PYTHON_DIR/commands
-PYTHONPATH=$PYTHON_DIR
-export PYTHONPATH PYTHON_DIR
-
diff --git a/cpp/src/tests/python_tests b/cpp/src/tests/python_tests
index e2077ef7dc..b82123b5bd 100755
--- a/cpp/src/tests/python_tests
+++ b/cpp/src/tests/python_tests
@@ -20,10 +20,9 @@
#
# Run the python tests.
-. `dirname $0`/python_env.sh
+source ./test_env.sh
QPID_PORT=${QPID_PORT:-5672}
PYTHON_TESTS=${PYTHON_TESTS:-$*}
FAILING=${FAILING:-/dev/null}
-cd $PYTHON_DIR
-python commands/qpid-python-test -b localhost:$QPID_PORT -I $FAILING $PYTHON_TESTS || exit 1
+python $QPID_PYTHON_TEST -b localhost:$QPID_PORT -I $FAILING $PYTHON_TESTS || exit 1
diff --git a/cpp/src/tests/reliable_replication_test b/cpp/src/tests/reliable_replication_test
index db06259f0c..165ece82e0 100755
--- a/cpp/src/tests/reliable_replication_test
+++ b/cpp/src/tests/reliable_replication_test
@@ -21,8 +21,8 @@
# Test reliability of the replication feature in the face of link
# failures:
-MY_DIR=`dirname \`which $0\``
-. ${MY_DIR}/python_env.sh
+
+source ./test_env.sh
trap stop_brokers EXIT
@@ -39,19 +39,18 @@ stop_brokers() {
setup() {
rm -f replication-source.log replication-dest.log
- ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module ../.libs/replicating_listener.so --replication-queue replication --create-replication-queue true --log-enable trace+ --log-to-file replication-source.log --log-to-stderr 0 > qpidd-repl.port
+ ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module $QPID_MODULE_DIR/replicating_listener.so --replication-queue replication --create-replication-queue true --log-enable trace+ --log-to-file replication-source.log --log-to-stderr 0 > qpidd-repl.port
BROKER_A=`cat qpidd-repl.port`
- ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module ../.libs/replication_exchange.so --log-enable info+ --log-to-file replication-dest.log --log-to-stderr 0 > qpidd-repl.port
+ ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module $QPID_MODULE_DIR/replication_exchange.so --log-enable info+ --log-to-file replication-dest.log --log-to-stderr 0 > qpidd-repl.port
BROKER_B=`cat qpidd-repl.port`
- #../qpidd --port 5555 --no-data-dir --no-module-dir --auth no --load-module ../.libs/replicating_listener.so --replication-queue replication --create-replication-queue true --log-enable trace+ --log-to-file replication-source.log --log-to-stderr 0 &
+ #../qpidd --port 5555 --no-data-dir --no-module-dir --auth no --load-module $QPID_MODULE_DIR/replicating_listener.so --replication-queue replication --create-replication-queue true --log-enable trace+ --log-to-file replication-source.log --log-to-stderr 0 &
#BROKER_A=5555
- #../qpidd --port 6666 --no-data-dir --no-module-dir --auth no --load-module ../.libs/replication_exchange.so --log-enable info+ --log-to-file replication-dest.log --log-to-stderr 0 &
+ #../qpidd --port 6666 --no-data-dir --no-module-dir --auth no --load-module $QPID_MODULE_DIR/replication_exchange.so --log-enable info+ --log-to-file replication-dest.log --log-to-stderr 0 &
#BROKER_B=6666
echo "Testing replication from port $BROKER_A to port $BROKER_B"
- export PYTHONPATH=$PYTHON_DIR
$PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add exchange replication replication
$PYTHON_COMMANDS/qpid-route --ack 500 queue add "localhost:$BROKER_B" "localhost:$BROKER_A" replication replication
@@ -79,7 +78,7 @@ bounce_link() {
echo "Route re-established"
}
-if test -d ${PYTHON_DIR} && test -e ../.libs/replicating_listener.so && test -e ../.libs/replication_exchange.so ; then
+if test -d ${PYTHON_DIR} && test -e $QPID_MODULE_DIR/replicating_listener.so && test -e $QPID_MODULE_DIR/replication_exchange.so ; then
setup
for i in `seq 1 100000`; do echo Message $i; done > replicated.expected
send &
diff --git a/cpp/src/tests/replication_test b/cpp/src/tests/replication_test
index 000b4591da..e47aeb2b03 100755
--- a/cpp/src/tests/replication_test
+++ b/cpp/src/tests/replication_test
@@ -20,8 +20,8 @@
#
# Run a test of the replication feature
-MY_DIR=`dirname \`which $0\``
-. `dirname $0`/python_env.sh
+
+source ./test_env.sh
trap stop_brokers INT TERM QUIT
@@ -36,16 +36,14 @@ stop_brokers() {
fi
}
-if test -d ${PYTHON_DIR} && test -f ../.libs/replicating_listener.so && test -f ../.libs/replication_exchange.so; then
+if test -d ${PYTHON_DIR} && test -f $QPID_MODULE_DIR/replicating_listener.so && test -f $QPID_MODULE_DIR/replication_exchange.so; then
rm -f queue-*.repl replication-*.log #cleanup from any earlier runs
- ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module ../.libs/replicating_listener.so --replication-queue replication --create-replication-queue true --log-enable info+ --log-to-file replication-source.log --log-to-stderr 0 > qpidd.port
+ ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module $QPID_MODULE_DIR/replicating_listener.so --replication-queue replication --create-replication-queue true --log-enable info+ --log-to-file replication-source.log --log-to-stderr 0 > qpidd.port
BROKER_A=`cat qpidd.port`
- ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module ../.libs/replication_exchange.so --log-enable info+ --log-to-file replication-dest.log --log-to-stderr 0 > qpidd.port
+ ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module $QPID_MODULE_DIR/replication_exchange.so --log-enable info+ --log-to-file replication-dest.log --log-to-stderr 0 > qpidd.port
BROKER_B=`cat qpidd.port`
- PYTHONPATH=$PYTHON_DIR
- export PYTHONPATH
echo "Running replication test between localhost:$BROKER_A and localhost:$BROKER_B"
$PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add exchange replication replication
@@ -120,10 +118,10 @@ if test -d ${PYTHON_DIR} && test -f ../.libs/replicating_listener.so && test -f
# now check offsets working (enqueue based on position being set, not queue abs position)
- ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module ../.libs/replicating_listener.so --replication-queue replication --create-replication-queue true --log-enable info+ --log-to-file replication-source.log --log-to-stderr 0 > qpidd.port
+ ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module $QPID_MODULE_DIR/replicating_listener.so --replication-queue replication --create-replication-queue true --log-enable info+ --log-to-file replication-source.log --log-to-stderr 0 > qpidd.port
BROKER_A=`cat qpidd.port`
- ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module ../.libs/replication_exchange.so --log-enable info+ --log-to-file replication-dest.log --log-to-stderr 0 > qpidd.port
+ ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module $QPID_MODULE_DIR/replication_exchange.so --log-enable info+ --log-to-file replication-dest.log --log-to-stderr 0 > qpidd.port
BROKER_B=`cat qpidd.port`
$PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add exchange replication replication
@@ -151,7 +149,7 @@ if test -d ${PYTHON_DIR} && test -f ../.libs/replicating_listener.so && test -f
# now check offsets working
../qpidd -q --port $BROKER_B
unset BROKER_B
- ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module ../.libs/replication_exchange.so --log-enable info+ --log-to-file replication-dest.log --log-to-stderr 0 > qpidd.port
+ ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module $QPID_MODULE_DIR/replication_exchange.so --log-enable info+ --log-to-file replication-dest.log --log-to-stderr 0 > qpidd.port
BROKER_B=`cat qpidd.port`
$PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add queue queue-e
diff --git a/cpp/src/tests/run_acl_tests b/cpp/src/tests/run_acl_tests
index c67e2d421d..0cefff2958 100755
--- a/cpp/src/tests/run_acl_tests
+++ b/cpp/src/tests/run_acl_tests
@@ -20,13 +20,13 @@
#
# Run the acl tests. $srcdir is set by the Makefile.
-. `dirname $0`/python_env.sh
+source ./test_env.sh
DATA_DIR=`pwd`/data_dir
trap stop_brokers INT TERM QUIT
start_brokers() {
- ../qpidd --daemon --port 0 --no-module-dir --data-dir $DATA_DIR --load-module ../.libs/acl.so --acl-file policy.acl --auth no > qpidd.port
+ ../qpidd --daemon --port 0 --no-module-dir --data-dir $DATA_DIR --load-module $QPID_MODULE_DIR/acl.so --acl-file policy.acl --auth no > qpidd.port
LOCAL_PORT=`cat qpidd.port`
}
@@ -35,9 +35,9 @@ stop_brokers() {
}
test_loading_acl_from_absolute_path(){
- POLICY_FILE=$PWD/$srcdir/policy.acl
+ POLICY_FILE=$srcdir/policy.acl
rm -f temp.log
- PORT=`../qpidd --daemon --port 0 --no-module-dir --no-data-dir --auth no --load-module ../.libs/acl.so --acl-file $POLICY_FILE -t --log-to-file temp.log 2>/dev/null`
+ PORT=`../qpidd --daemon --port 0 --no-module-dir --no-data-dir --auth no --load-module $QPID_MODULE_DIR/acl.so --acl-file $POLICY_FILE -t --log-to-file temp.log 2>/dev/null`
ACL_FILE=`grep "notice Read ACL file" temp.log | sed 's/^.*Read ACL file //'`
../qpidd -q --port $PORT
if test "$ACL_FILE" != "\"$POLICY_FILE\""; then
@@ -55,7 +55,7 @@ if test -d ${PYTHON_DIR} ; then
echo "Running acl tests using brokers on ports $LOCAL_PORT"
PYTHONPATH=$PYTHON_DIR:$srcdir
export PYTHONPATH
- $PYTHON_COMMANDS/qpid-python-test -b localhost:$LOCAL_PORT -m acl || EXITCODE=1
+ $QPID_PYTHON_TEST -b localhost:$LOCAL_PORT -m acl || EXITCODE=1
stop_brokers || EXITCODE=1
test_loading_acl_from_absolute_path || EXITCODE=1
rm -rf $DATA_DIR
diff --git a/cpp/src/tests/run_cli_tests b/cpp/src/tests/run_cli_tests
index bb9605410c..d47bb70406 100755
--- a/cpp/src/tests/run_cli_tests
+++ b/cpp/src/tests/run_cli_tests
@@ -20,8 +20,8 @@
#
# Run the cli-utility tests.
-MY_DIR=`dirname \`which $0\``
-. `dirname $0`/python_env.sh
+
+source ./test_env.sh
CLI_DIR=$PYTHON_COMMANDS
trap stop_brokers INT TERM QUIT
@@ -41,8 +41,6 @@ stop_brokers() {
if test -d ${PYTHON_DIR} ; then
start_brokers
echo "Running CLI tests using brokers on ports $LOCAL_PORT $REMOTE_PORT"
- PYTHONPATH=${PYTHON_DIR}:${MY_DIR}
- export PYTHONPATH
$PYTHON_COMMANDS/qpid-python-test -m cli_tests -b localhost:$LOCAL_PORT -Dremote-port=$REMOTE_PORT -Dcli-dir=$CLI_DIR $@
RETCODE=$?
stop_brokers
diff --git a/cpp/src/tests/run_cluster_tests b/cpp/src/tests/run_cluster_tests
index b6c144bb05..997cddf1e2 100755
--- a/cpp/src/tests/run_cluster_tests
+++ b/cpp/src/tests/run_cluster_tests
@@ -19,15 +19,12 @@
# under the License.
#
-srcdir=$(dirname $0)
-. $srcdir/test_env.sh checkout $srcdir/../../.. ../.. || exit 1
-. $srcdir/ais_check
+source ./test_env.sh
+source $srcdir/ais_check
TEST_EXEC=$QPID_PYTHON_COMMANDS/qpid-python-test
test -x $TEST_EXEC || { echo Skipping test, $TEST_EXEC not found; exit 0; }
-PYTHONPATH=$srcdir:$PYTHONPATH
-
# Delete old cluster test data
OUTDIR=brokertest.tmp
rm -rf $OUTDIR
diff --git a/cpp/src/tests/run_failover_soak b/cpp/src/tests/run_failover_soak
index 082cd75449..9c53e6162c 100755
--- a/cpp/src/tests/run_failover_soak
+++ b/cpp/src/tests/run_failover_soak
@@ -19,11 +19,12 @@
# under the License.
#
-. `dirname $0`/ais_check
+source ./test_env.sh
+. $srcdir/ais_check
host=127.0.0.1
-MODULES=${MODULES:-../.libs}
+MODULES=${MODULES:-$QPID_MODULE_DIR}
MESSAGES=${MESSAGES:-1000000}
REPORT_FREQUENCY=${REPORT_FREQUENCY:-20000}
VERBOSITY=${VERBOSITY:-10}
diff --git a/cpp/src/tests/run_federation_tests b/cpp/src/tests/run_federation_tests
index 3fe4bccb13..4c3b53ede2 100755
--- a/cpp/src/tests/run_federation_tests
+++ b/cpp/src/tests/run_federation_tests
@@ -20,8 +20,8 @@
#
# Run the federation tests.
-MY_DIR=`dirname \`which $0\``
-. `dirname $0`/python_env.sh
+
+source ./test_env.sh
trap stop_brokers INT TERM QUIT
@@ -40,9 +40,7 @@ stop_brokers() {
if test -d ${PYTHON_DIR} ; then
start_brokers
echo "Running federation tests using brokers on ports $LOCAL_PORT $REMOTE_PORT"
- PYTHONPATH=${PYTHON_DIR}:${MY_DIR}
- export PYTHONPATH
- $PYTHON_COMMANDS/qpid-python-test -m federation -b localhost:$LOCAL_PORT -Dremote-port=$REMOTE_PORT $@
+ $QPID_PYTHON_TEST -m federation -b localhost:$LOCAL_PORT -Dremote-port=$REMOTE_PORT $@
RETCODE=$?
stop_brokers
if test x$RETCODE != x0; then
diff --git a/cpp/src/tests/run_header_test b/cpp/src/tests/run_header_test
index 1b5a3963db..07658343e7 100755
--- a/cpp/src/tests/run_header_test
+++ b/cpp/src/tests/run_header_test
@@ -24,13 +24,12 @@
# in both directions
srcdir=`dirname $0`
-. `dirname $0`/python_env.sh
+source ./test_env.sh
+
test -f qpidd.port && QPID_PORT=`cat qpidd.port`
if test -d ${PYTHON_DIR} ; then
./header_test -p $QPID_PORT
- PYTHONPATH=$PYTHON_DIR:$PYTHONPATH
- export PYTHONPATH
$srcdir/header_test.py "localhost" $QPID_PORT
else
echo "Skipping header test as python libs not found"
diff --git a/cpp/src/tests/run_ring_queue_test b/cpp/src/tests/run_ring_queue_test
index 9cd3775de1..7ca870841e 100755
--- a/cpp/src/tests/run_ring_queue_test
+++ b/cpp/src/tests/run_ring_queue_test
@@ -21,8 +21,8 @@
#script to run a sequence of ring queue tests via make
#setup path to find qpid-config and sender/receiver test progs
-srcdir=`dirname $0`
-. `dirname $0`/python_env.sh
+source ./test_env.sh
+
export PATH=$PWD:$srcdir:$PYTHON_COMMANDS:$PATH
#set port to connect to via env var
diff --git a/cpp/src/tests/run_test b/cpp/src/tests/run_test
index 130584ff9b..4b227621bc 100755
--- a/cpp/src/tests/run_test
+++ b/cpp/src/tests/run_test
@@ -32,7 +32,8 @@
#
srcdir=`dirname $0`
-. $srcdir/vg_check
+source ./test_env.sh
+source $srcdir/vg_check
# Export variables from makefile.
export srcdir
@@ -59,9 +60,6 @@ VALGRIND_OPTS="$VALGRIND_OPTS
--num-callers=25
--log-file=$VG_LOG --
"
-# FIXME aconway 2008-07-16: removed --trace-children=yes, problems with cluster tests forking
-# qpidd libtool script. Investigate & restore --trace-children if possible.
-
ERROR=0
if grep -l "^# Generated by .*libtool" "$1" >/dev/null 2>&1; then
# This is a libtool "executable". Valgrind it if VALGRIND specified.
@@ -69,9 +67,15 @@ if grep -l "^# Generated by .*libtool" "$1" >/dev/null 2>&1; then
# Hide output unless there's an error.
$LIBTOOL --mode=execute $VALGRIND "$@" 2>&1 || ERROR=1
test -n "$VALGRIND" && { vg_check $VG_LOG* || ERROR=1 ; }
-else
+elif file $1 | grep -q text; then
# This is a non-libtool shell script, just execute it.
exec "$@"
+else
+ # This is a real executable, valgrind it.
+ test -n "$VALGRIND" && VALGRIND="$VALGRIND $VALGRIND_OPTS"
+ # Hide output unless there's an error.
+ $VALGRIND "$@" 2>&1 || ERROR=1
+ test -n "$VALGRIND" && { vg_check $VG_LOG* || ERROR=1 ; }
fi
exit $ERROR
diff --git a/cpp/src/tests/ssl_test b/cpp/src/tests/ssl_test
index 31d1a07f2c..2ce1d0bb81 100755
--- a/cpp/src/tests/ssl_test
+++ b/cpp/src/tests/ssl_test
@@ -21,6 +21,8 @@
# Run a simple test over SSL
+source ./test_env.sh
+
CONFIG=$(dirname $0)/config.null
CERT_DIR=`pwd`/test_cert_db
CERT_PW_FILE=`pwd`/cert.password
@@ -45,7 +47,7 @@ delete_certs() {
}
start_broker() {
- PORT=`../qpidd --daemon --transport ssl --port 0 --ssl-port 0 --no-data-dir --no-module-dir --auth no --config $CONFIG --load-module ../.libs/ssl.so --ssl-cert-db $CERT_DIR --ssl-cert-password-file $CERT_PW_FILE --ssl-cert-name $TEST_HOSTNAME`
+ PORT=`../qpidd --daemon --transport ssl --port 0 --ssl-port 0 --no-data-dir --no-module-dir --auth no --config $CONFIG --load-module $QPID_MODULE_DIR/ssl.so --ssl-cert-db $CERT_DIR --ssl-cert-password-file $CERT_PW_FILE --ssl-cert-name $TEST_HOSTNAME`
}
stop_broker() {
@@ -74,7 +76,7 @@ create_certs || error "Could not create test certificate"
start_broker || error "Could not start broker"
echo "Running SSL test on port $PORT"
export QPID_NO_MODULE_DIR=1
-export QPID_LOAD_MODULE=../.libs/sslconnector.so
+export QPID_LOAD_MODULE=$QPID_MODULE_DIR/sslconnector.so
export QPID_SSL_CERT_DB=${CERT_DIR}
export QPID_SSL_CERT_PASSWORD_FILE=${CERT_PW_FILE}
./perftest --count ${COUNT} --port ${PORT} -P ssl -b $TEST_HOSTNAME --summary
diff --git a/cpp/src/tests/start_cluster b/cpp/src/tests/start_cluster
index dadb1ee743..90291acad4 100755
--- a/cpp/src/tests/start_cluster
+++ b/cpp/src/tests/start_cluster
@@ -23,13 +23,14 @@
#
# Execute command with the ais group set.
+source ./test_env.sh
. `dirname $0`/ais_check
rm -f cluster*.log cluster.ports qpidd.port
SIZE=${1:-3}; shift
CLUSTER=$HOSTNAME.$$
-OPTS="-d --no-module-dir --load-module ../.libs/cluster.so --cluster-name=$CLUSTER --auth=no --log-enable notice+ --log-enable debug+:cluster $@"
+OPTS="-d --no-module-dir --load-module $QPID_MODULE_DIR/cluster.so --cluster-name=$CLUSTER --auth=no --log-enable notice+ --log-enable debug+:cluster $@"
for (( i=0; i<SIZE; ++i )); do
DDIR=`mktemp -d /tmp/start_cluster.XXXXXXXXXX`
diff --git a/cpp/src/tests/test_env.sh b/cpp/src/tests/test_env.sh
deleted file mode 100644
index 46d8bbab16..0000000000
--- a/cpp/src/tests/test_env.sh
+++ /dev/null
@@ -1,51 +0,0 @@
-# Set up env var required by various tests.
-# If run without args, assume the current directory
-#
-# source test_env.sh checkout|install dir1 [ dir2 ]
-# checkout: dir1 is qpid dir of svn checkout, optional dir2 is cpp build directory
-# install: dir1 is the install prefix
-
-usage() { echo "Usage: $0 checkout|install dir1 [ dir2 ]"; return 1; }
-absdir() { echo `cd $1 && pwd`; }
-
-qpid_checkout_env() {
- QPID_ROOT=$(absdir $1)
- if [ -n $2 ]; then QPID_BUILD=$(absdir $2); else QPID_BUILD=$QPID_ROOT/cpp; fi
-
- export QPID_PYTHON_COMMANDS=$QPID_BUILD/src/tests/python/commands
- export PYTHONPATH=$QPID_BUILD/src/tests/python:$QPID_PYTHON_COMMANDS:$PYTHONPATH
- export QPIDD_EXEC=$QPID_BUILD/src/qpidd
- export QPID_TEST_EXEC_DIR=$QPID_BUILD/src/tests
- export QPID_MODULE_DIR=$QPID_BUILD/src/.libs/
-}
-
-qpid_install_env() {
- QPID_PREFIX=$(absdir $1)
-
- export QPID_PYTHON_COMMANDS=$QPID_PREFIX/bin
- export PYTHONPATH=$QPID_PREFIX/python:$QPID_PYTHON_COMMANDS:$PYTHONPATH
- export QPIDD_EXEC=$QPID_PREFIX/sbin/qpidd
- export QPID_TEST_EXEC_DIR=$QPID_PREFIX/libexec/qpid/tests
- if [ test -d $QPID_PREFIX/lib64/qpid ]; then export QPID_MODULE_DIR=$PREFIX/lib64/qpid;
- elif [ test -d $QPID_PREFIX/lib/qpid ]; then export QPID_MODULE_DIR=$PREFIX/lib/qpid;
- else echo "Can't find module directory $QPID_PREFIX/lib[64]/qpid";
- fi
-}
-
-test $# -ge 2 || { usage; return 1; }
-
-case $1 in
- checkout) qpid_checkout_env $2 $3 ;;
- install) qpid_install_env $2 ;;
- *) usage; return 1 ;;
-esac
-
-export QPID_CONFIG_EXEC=$QPID_PYTHON_COMMANDS/qpid-config
-export QPID_ROUTE_EXEC=$QPID_PYTHON_COMMANDS/qpid-route
-export QPID_CLUSTER_EXEC=$QPID_PYTHON_COMMANDS/qpid-cluster
-
-export RECEIVER_EXEC=$QPID_TEST_EXEC_DIR/receiver
-export SENDER_EXEC=$QPID_TEST_EXEC_DIR/sender
-
-test -f $QPID_MODULE_DIR/cluster.so && export CLUSTER_LIB=$QPID_MODULE_DIR/cluster.so
-test -f $QPID_MODULE_DIR/xml.so && export XML_LIB=$QPID_LIB_DIR/xml.so
diff --git a/cpp/src/tests/test_env.sh.in b/cpp/src/tests/test_env.sh.in
new file mode 100644
index 0000000000..602a5bedd9
--- /dev/null
+++ b/cpp/src/tests/test_env.sh.in
@@ -0,0 +1,76 @@
+#
+# 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.
+#
+
+absdir() { echo `cd $1 && pwd`; }
+
+# Environment variables substituted by configure/cmake.
+export srcdir=@abs_srcdir@
+export builddir=@abs_builddir@
+export top_srcdir=@abs_top_srcdir@
+export top_builddir=@abs_top_builddir@
+
+export QPID_MODULE_DIR=$top_builddir/src@builddir_lib_suffix@
+export QPID_TEST_MODULE_DIR=$builddir@builddir_lib_suffix@
+
+# Other paths and directories
+if test -d $builddir/python ; then
+ export PYTHON_DIR=$builddir/python
+ export QPID_PYTHON_TEST=$PYTHON_DIR/commands/qpid-python-test
+elif test -d $top_srcdir/../python ; then
+ export PYTHON_DIR=$top_srcdir/../python
+ export QPID_PYTHON_TEST=$PYTHON_DIR/qpid-python-test
+fi
+if test -d $PYTHON_DIR; then
+ export PYTHON_COMMANDS=$PYTHON_DIR/commands
+ export PYTHONPATH=$srcdir:$PYTHON_DIR:$PYTHON_COMMANDS:$PYTHONPATH
+fi
+
+export QPID_TEST_EXEC_DIR=$builddir
+
+# qpidd executable
+export QPIDD_EXEC=$top_builddir/src/qpidd
+
+# Executable python scripts
+export QPID_CONFIG_EXEC=$PYTHON_COMMANDS/qpid-config
+export QPID_ROUTE_EXEC=$PYTHON_COMMANDS/qpid-route
+export QPID_CLUSTER_EXEC=$PYTHON_COMMANDS/qpid-cluster
+
+# Test executables
+export RECEIVER_EXEC=$QPID_TEST_EXEC_DIR/receiver
+export SENDER_EXEC=$QPID_TEST_EXEC_DIR/sender
+
+# Modules
+export TEST_STORE_LIB=$QPID_TEST_MODULE_DIR/test_store.so
+export REPLICATING_LISTENER_LIB=$QPID_MODULE_DIR/replicating_listener.so
+export REPLICATION_EXCHANGE_LIB=$QPID_MODULE_DIR/replication_exchange.so
+
+# Optional modules, set only if present
+exportmodule() { test -f $QPID_MODULE_DIR/$2 && eval "export $1=$QPID_MODULE_DIR/$2"; }
+exportmodule ACL_LIB acl.so
+exportmodule CLUSTER_LIB cluster.so
+exportmodule SSL_CONNECTOR_LIB ssl_connector.so
+exportmodule SSL_LIB ssl.so
+exportmodule WATCHDOG_LIB watchdog.so
+exportmodule XML_LIB xml.so
+
+
+# Qpid options
+export QPID_NO_MODULE_DIR=1 # Don't accidentally load installed modules
+export QPID_DATA_DIR= # Default to no data dir, not ~/.qpidd
+
diff --git a/cpp/src/tests/test_tools.h b/cpp/src/tests/test_tools.h
index 4174751173..bb2509fd32 100644
--- a/cpp/src/tests/test_tools.h
+++ b/cpp/src/tests/test_tools.h
@@ -28,6 +28,8 @@
#include <vector>
#include <set>
#include <ostream>
+#include <sstream>
+#include <exception>
// Print a sequence
template <class T> std::ostream& seqPrint(std::ostream& o, const T& seq) {
@@ -106,8 +108,11 @@ inline std::string getLibPath(const char* envName, const char* defaultPath = 0)
const char* p = std::getenv(envName);
if (p != 0)
return p;
- if (defaultPath == 0)
- BOOST_FAIL("Environment variable " << envName << " not set.");
+ if (defaultPath == 0) {
+ std::ostringstream msg;
+ msg << "Environment variable " << envName << " not set.";
+ throw std::runtime_error(msg.str());
+ }
return defaultPath;
}