summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qpid/cpp/src/tests/.valgrind.supp (renamed from qpid/cpp/src/tests/.vg-supp)16
-rw-r--r--qpid/cpp/src/tests/.valgrindrc-default7
-rw-r--r--qpid/cpp/src/tests/Makefile.am45
-rw-r--r--qpid/cpp/src/tests/README71
-rw-r--r--qpid/cpp/src/tests/examples.Makefile66
-rw-r--r--qpid/cpp/src/tests/examples.README18
-rwxr-xr-xqpid/cpp/src/tests/run-unit-tests21
-rw-r--r--qpid/cpp/src/tests/setup81
-rw-r--r--qpid/cpp/src/tests/test_env43
9 files changed, 164 insertions, 204 deletions
diff --git a/qpid/cpp/src/tests/.vg-supp b/qpid/cpp/src/tests/.valgrind.supp
index b5abdf1385..dc66e78e16 100644
--- a/qpid/cpp/src/tests/.vg-supp
+++ b/qpid/cpp/src/tests/.valgrind.supp
@@ -16,3 +16,19 @@
obj:/usr/bin/DllPlugInTester
fun:(below main)
}
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:_Znwj
+ fun:_ZN4qpid6broker17ReferenceRegistry4openERKSs
+ fun:_ZN13ReferenceTestC1Ev
+ fun:_ZN7CppUnit25ConcretTestFixtureFactoryI13ReferenceTestE11makeFixtureEv
+ fun:_ZNK7CppUnit27TestSuiteBuilderContextBase15makeTestFixtureEv
+ fun:_ZN13ReferenceTest15addTestsToSuiteERN7CppUnit27TestSuiteBuilderContextBaseE
+ fun:_ZN7CppUnit16TestSuiteFactoryI13ReferenceTestE8makeTestEv
+ fun:_ZN7CppUnit19TestFactoryRegistry14addTestToSuiteEPNS_9TestSuiteE
+ fun:_ZN7CppUnit19TestFactoryRegistry8makeTestEv
+ obj:/usr/bin/DllPlugInTester
+ obj:/usr/bin/DllPlugInTester
+ fun:(below main)
+}
diff --git a/qpid/cpp/src/tests/.valgrindrc-default b/qpid/cpp/src/tests/.valgrindrc-default
new file mode 100644
index 0000000000..f498da8ab2
--- /dev/null
+++ b/qpid/cpp/src/tests/.valgrindrc-default
@@ -0,0 +1,7 @@
+--gen-suppressions=all
+--full_leak_check=--leak-check=full
+--demangle=yes
+--suppressions=.valgrind.supp
+--num-callers=25
+--track-fds=yes
+
diff --git a/qpid/cpp/src/tests/Makefile.am b/qpid/cpp/src/tests/Makefile.am
index 89f3cfb9f9..5a64667f65 100644
--- a/qpid/cpp/src/tests/Makefile.am
+++ b/qpid/cpp/src/tests/Makefile.am
@@ -1,10 +1,10 @@
AM_CXXFLAGS = $(WARNING_CFLAGS) $(CPPUNIT_CXXFLAGS)
-INCLUDES = \
- -I$(srcdir)/../gen \
+INCLUDES = \
+ -I$(srcdir)/../gen \
$(APR_CXXFLAGS)
# Unit tests
-broker_tests = \
+broker_unit_tests = \
AccumulatedAckTest \
BrokerChannelTest \
ConfigurationTest \
@@ -25,42 +25,38 @@ broker_tests = \
ValueTest \
MessageHandlerTest
-client_tests = \
+client_unit_tests = \
ClientChannelTest
-framing_tests = \
+framing_unit_tests = \
FieldTableTest \
FramingTest \
HeaderTest
-misc_tests = \
+misc_unit_tests = \
ProducerConsumerTest
-posix_tests = \
+posix_unit_tests = \
EventChannelTest \
EventChannelThreadsTest
unit_tests = \
- $(broker_tests) \
- $(client_tests) \
- $(framing_tests) \
- $(misc_tests)
+ $(broker_unit_tests) \
+ $(client_unit_tests) \
+ $(framing_unit_tests) \
+ $(misc_unit_tests)
-# Executable client tests
+# Executables for client tests
-client_exe_tests = \
+client_test_exe = \
client_test \
echo_service \
topic_listener \
topic_publisher
-noinst_PROGRAMS = $(client_exe_tests)
+noinst_PROGRAMS = $(client_test_exe)
-TESTS_ENVIRONMENT = \
- VALGRIND=$(VALGRIND) \
- abs_builddir='$(abs_builddir)' \
- PATH="$(abs_builddir)/../src$(PATH_SEPARATOR)$$PATH" \
- abs_srcdir='$(abs_srcdir)'
+TESTS_ENVIRONMENT = VALGRIND=$(VALGRIND) srcdir=$(srcdir)
CLIENT_TESTS = client_test quick_topictest
TESTS = run-unit-tests start_broker $(CLIENT_TESTS) python_tests kill_broker
@@ -68,11 +64,12 @@ TESTS = run-unit-tests start_broker $(CLIENT_TESTS) python_tests kill_broker
EXTRA_DIST = \
$(TESTS) \
.vg-supp \
+ .valgrindrc.default \
InProcessBroker.h \
MockChannel.h \
MockConnectionInputHandler.h \
qpid_test_plugin.h \
- setup \
+ test_env \
topicall \
topictest \
APRBaseTest.cpp
@@ -86,7 +83,6 @@ check_LTLIBRARIES += libdlclose_noop.la
libdlclose_noop_la_LDFLAGS = -module -rpath /home/aconway/svn/qpid/cpp/tests
libdlclose_noop_la_SOURCES = dlclose_noop.c
-
abs_builddir = @abs_builddir@
extra_libs = $(CPPUNIT_LIBS)
lib_client = $(abs_builddir)/../libqpidclient.la
@@ -112,6 +108,9 @@ gen.mk: Makefile.am
> $@-t
mv $@-t $@
-check: $(check_LTLIBRARIES) $(lib_common) $(lib_client) $(lib_broker)
+check: .valgrindrc $(check_LTLIBRARIES) $(lib_common) $(lib_client) $(lib_broker)
+
+# Create a copy so user can modify without risk of checking in their mods.
+.valgrindrc: .valgrindrc-default
+ cp .valgrindrc-default .valgrindrc
-# Rule to run unit tests from an individual test module.
diff --git a/qpid/cpp/src/tests/README b/qpid/cpp/src/tests/README
new file mode 100644
index 0000000000..d0552a2ddd
--- /dev/null
+++ b/qpid/cpp/src/tests/README
@@ -0,0 +1,71 @@
+= Running Qpid C++ tests =
+
+General philosophy is that "make check" run all tests by default, but
+developers can run tests selectively as explained below.
+
+== Valgrind ==
+
+By default we run tests under valgrind to detect memory errors if valgrind
+is present. ./configure --disable-valgrind will disable it.
+
+Default valgrind options are specified in .valgrindrc-default, which a
+checked-in file. The actual options used are in .valgrindrc which is a
+local file. Normally it is a copy of valgrindrc-default but you can
+modify at will.
+
+Supressed errors are listed in .valgrind.supp. If you want to change
+suppressions for local testing, just modify .valgrindrc to point to a
+different file. Do NOT add suppressions to .valgrindrc.supp unless
+they are known problems outside of Qpid that can't reasonably be
+worked around in Qpid.
+
+
+== Unit Tests ==
+
+Unit tests shared libraries containing CppUnit test plug-ins, run by
+the CppUnit DllPlugInTester program.
+
+run-unit-tests runs tests under valgrind, you can run it directly.
+Library names (without path or .so) and CppUnit test paths can be
+specified on the command line or in env var UNIT_TESTS. For example:
+
+Selected test classes:
+./run-unit-tests ValueTest ClientChannelTest
+
+Individual test method
+./run-unit-tests ValueTest :ValueTest::testStringValueEquals
+
+You can also Build and run selected tests via make:
+make check TESTS=run-unit-tests UNIT_TESTS=ClientChannelTest
+
+NOTE: If you use DllPlugInTester directly note that if foobar.so is in
+the current directory then this will fail with "can't load plugin":
+ # DllPluginTester foobar.so
+
+Instead you need to say:
+ # DllPluginTester ./foobar.so
+
+DllPluginTester uses dlopen() which only searches for shlibs
+in the standard places unless the filename contains a "/". In that
+case it just tries to open the filename.
+
+== System Tests ==
+
+System tests are self contained AMQP client executables or scripts.
+They are listed in the TESTS make variable, which can be over-ridden.
+
+The ./start_broker "test" launches the broker, ./kill_broker" kills it.
+Tests in between assume the broker is running.
+
+./run-python-tests: runs ../python/run_tests. This is the main set of
+system testss for the broker.
+
+Other C++ client test executables and scripts under client/test are
+system tests for the client.
+
+By setting TESTS in a make command you can run a different subset of tests
+against an already-running broker.
+
+
+
+
diff --git a/qpid/cpp/src/tests/examples.Makefile b/qpid/cpp/src/tests/examples.Makefile
deleted file mode 100644
index 45999f7852..0000000000
--- a/qpid/cpp/src/tests/examples.Makefile
+++ /dev/null
@@ -1,66 +0,0 @@
-#
-# XXX: Edit these locations to suit.
-#
-BOOST_LOCATION := $(HOME)/local/boost-1.33.1
-APR_LOCATION := $(HOME)/local/apr-1.2.7
-
-CXXFLAGS := -DNDEBUG -DUSE_APR -MMD -fpic
-
-#
-# Configure Boost.
-#
-BOOST_CFLAGS := -I$(BOOST_LOCATION)/include/boost-1_33_1
-CXXFLAGS := $(CXXFLAGS) $(BOOST_CFLAGS)
-
-#
-# Configure APR.
-#
-APR_CFLAGS := -I$(APR_LOCATION)/include/apr-1
-APR_LDFLAGS := $(shell $(APR_LOCATION)/bin/apr-1-config --libs) -L$(APR_LOCATION)/lib -lapr-1
-CXXFLAGS := $(CXXFLAGS) $(APR_CFLAGS)
-LDFLAGS := $(LDFLAGS) $(APR_LDFLAGS)
-
-#
-# Configure Qpid cpp client.
-#
-QPID_CLIENT_LDFLAGS := ../lib/libcommon.so ../lib/libclient.so
-includeDir := ../include
-QPID_CLIENT_CFLAGS := \
- -I$(includeDir)/gen \
- -I$(includeDir)/client \
- -I$(includeDir)/broker \
- -I$(includeDir)/common \
- -I$(includeDir)/common/sys \
- -I$(includeDir)/common/framing
-
-CXXFLAGS := $(CXXFLAGS) $(QPID_CLIENT_CFLAGS)
-LDFLAGS := $(LDFLAGS) $(QPID_CLIENT_LDFLAGS)
-
-CXX := g++
-
-#
-# Add rule to build examples.
-#
-.SUFFIX: .cpp
-%: %.cpp
- $(CXX) $(CXXFLAGS) $(LDFLAGS) $< -o $@
-
-#
-# Define targets.
-#
-
-EXAMPLES := client_test topic_listener topic_publisher echo_service
-
-cppFiles := $(wildcard *.cpp)
-programs = $(foreach cppFile, $(cppFiles), $(subst .cpp, ,$(cppFile)))
-
-.PHONY:
-all: $(programs)
-
-debug:
- @echo cppFiles = $(cppFiles)
- @echo programs = $(programs)
-
-.PHONY:
-clean:
- -rm $(EXAMPLES)
diff --git a/qpid/cpp/src/tests/examples.README b/qpid/cpp/src/tests/examples.README
deleted file mode 100644
index 65f908c249..0000000000
--- a/qpid/cpp/src/tests/examples.README
+++ /dev/null
@@ -1,18 +0,0 @@
-Building the examples
----------------------
-
-You had better edit the Makefile and provide the locations for APR and boost.
-
-Then just type 'make'.
-
-
-Running the examples
---------------------
-
-Before running the examples ensure that you have setup your LD_LIBRARY_PATH.
-
-Most of the examples take the following connection parameters for your
-AMQP broker:
-
- -host host
- -port port
diff --git a/qpid/cpp/src/tests/run-unit-tests b/qpid/cpp/src/tests/run-unit-tests
index f066a38205..a3113b14ee 100755
--- a/qpid/cpp/src/tests/run-unit-tests
+++ b/qpid/cpp/src/tests/run-unit-tests
@@ -11,27 +11,16 @@
#
# Build and run selected tests:
# make check TESTS=run-unit-tests UNIT_TESTS=ClientChannelTest
-#
-
-# Default VALGRIND from the path and $srcdir to . but
-# don't override values set by make.
-test -z "$VALGRIND" -a -z "$MAKEFLAGS" && VALGRIND=`which valgrind` 2>/dev/null
-test -z "$srcdir" && srcdir=.
+#
-rm -f valgrind.out
-vg_log=--log-file-exactly=valgrind.out
-source $srcdir/setup
for u in $* $UNIT_TESTS ; do
case $u in
:*) TEST_ARGS="$TEST_ARGS $u" ;; # A test path.
- *) TEST_ARGS="$TEST_ARGS $pwd/.libs/$u.so" ;; # A test library.
+ *) TEST_ARGS="$TEST_ARGS .libs/$u.so" ;; # A test library.
esac
done
-# If none specified, run all tests in .libs
-test -z "$TEST_ARGS" && TEST_ARGS="$pwd/.libs/*Test.so"
-fail=0
+test -z "$TEST_ARGS" && TEST_ARGS=".libs/*Test.so"
-$vg DllPlugInTester -c -b $TEST_ARGS || fail=1
-vg_check valgrind.out || fail=1
+test -z "$srcdir" && srcdir=.
+exec $srcdir/test_env DllPlugInTester -c -b $TEST_ARGS
-exit $fail
diff --git a/qpid/cpp/src/tests/setup b/qpid/cpp/src/tests/setup
deleted file mode 100644
index aaa3afd9b8..0000000000
--- a/qpid/cpp/src/tests/setup
+++ /dev/null
@@ -1,81 +0,0 @@
-# -*- sh -*-
-
-test "$VERBOSE" = yes && set -x
-
-pwd=`pwd`
-test -z "$abs_srcdir" && abs_srcdir=$pwd
-
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-pid=0
-test -z "$TEST_DEBUG" &&
-trap 's=$?;test $pid = 0||kill -2 $pid;cd "$pwd" && rm -rf $t0 && exit $s' 0
-test -z "$TEST_DEBUG" && trap '(exit $?); exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-gen_supp=--gen-suppressions=all
-# This option makes valgrind significantly slower.
-full_leak_check=--leak-check=full
-demangle=--demangle=yes
-
-vg_options="
- --suppressions=$abs_srcdir/.vg-supp
- --num-callers=25
- --track-fds=yes
- $demangle
- $full_leak_check
- $gen_supp
- $vg_log
- "
-# configure tests for the existence of valgrind.
-# If it's not available, then make $vg and vg_check no-ops.
-if test x$VALGRIND = x; then
- vg=
-else
- vg="libtool --mode=execute $VALGRIND `echo $vg_options` --"
- # Suppress dlclose or valgrind traces wont have test library symbols.
- vg="env LD_PRELOAD=$pwd/.libs/libdlclose_noop.so $vg"
-fi
-
-
-vg_leak_check()
-{
- local file=$1
- local fail
- # If we detect a leak, dump all output to stderr.
- grep -E '^==[0-9]+== +definitely lost: [^0]' $file \
- && { fail=1; cat $file 1>&2;
- echo "found memory leaks (see log file, $file); see above" 1>&2; }
- test "$fail" = ''
-}
-
-
-# Ensure 1) that there is an ERROR SUMMARY line, and
-# 2) that the number of errors is 0.
-# An offending line looks like this:
-# ==29302== ERROR SUMMARY: 4 errors from 2 contexts (suppressed: 16 from 5)
-vg_error_check()
-{
- local file=$1
- local fail
- # If we detect a leak, dump all output to stderr.
- grep -E '^==[0-9]+== ERROR SUMMARY:' $file > /dev/null \
- || { fail=1; cat $file 1>&2;
- echo "no valgrind ERROR SUMMARY line in $file" 1>&2; }
- if test "$fail" = ''; then
- grep -E '^==[0-9]+== ERROR SUMMARY: [^0] ' $file \
- && { fail=1; cat $file 1>&2;
- echo "valgrind reported errors in $file; see above" 1>&2; }
- fi
- test "$fail" = ''
-}
-
-vg_check()
-{
- local file=$1
- if test x$VALGRIND != x; then
- vg_error_check $file && vg_leak_check $file
- fi
-}
diff --git a/qpid/cpp/src/tests/test_env b/qpid/cpp/src/tests/test_env
new file mode 100644
index 0000000000..fdfc5f0369
--- /dev/null
+++ b/qpid/cpp/src/tests/test_env
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# Run a test under valgrind.
+#
+
+# Use VALGRIND if set, else look on path.
+test -z "$VALGRIND" && VALGRIND=`which valgrind 2>/dev/null`
+# No valgrind, just run the command
+test -z "$VALGRIND" && exec libtool --mode=execute "$@"
+
+test "$VERBOSE" = yes && set -x
+test -z "$vg_log" && vg_log=valgrind.out
+rm -f $vg_log
+
+# Dump log file, print a message and exit non-0.
+vg_failed() {
+ cat $vg_log 1>&2
+ echo $1 1>&2
+ exit 1
+}
+
+# Check for errors in valgrind output.
+vg_check()
+{
+ # Ensure there is an ERROR SUMMARY line.
+ grep -E '^==[0-9]+== ERROR SUMMARY:' $vg_log > /dev/null || \
+ vg_failed "No valgrind ERROR SUMMARY line in $$vg_failed."
+ # Ensure that the number of errors is 0.
+ grep -E '^==[0-9]+== ERROR SUMMARY: [^0] ' $vg_log > /dev/null && \
+ vg_failed "Valgrind reported errors in $vg_out; see above."
+ # Check for leaks.
+ grep -E '^==[0-9]+== +.* lost: [^0]' $vg_log && \
+ vg_failed "Found memory leaks (see log file, $vg_log); see above."
+ true
+}
+
+# libdlclose_noop prevents unloading symbols needed for valgrind output.
+preload=.libs/libdlclose_noop.so
+# Output to file, only display if there is an error.
+opts=--log-file-exactly=$vg_log
+
+LD_PRELOAD=$preload libtool --mode=execute $VALGRIND $opts -- "$@" || fail=1
+vg_check && test -z "$fail"