You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2007/04/02 22:27:22 UTC
svn commit: r524913 - in /incubator/qpid/trunk/qpid/cpp/src/tests:
.valgrind.supp .valgrindrc-default .vg-supp Makefile.am README
examples.Makefile examples.README run-unit-tests setup test_env
Author: aconway
Date: Mon Apr 2 13:27:21 2007
New Revision: 524913
URL: http://svn.apache.org/viewvc?view=rev&rev=524913
Log:
* src/tests/examples.README,examples.Makefile: out of date, removed.
* src/tests/README: details on running tests.
* cpp/README: Point to src/tests/README
* src/tests/ .valgrind.supp, .valgrindrc-default: moved valgrind options to file, easier to modify locally updated suppressions (see README)
* src/tests/test_env, run-unit-tests: more flexible test running (see README)
Added:
incubator/qpid/trunk/qpid/cpp/src/tests/.valgrind.supp
- copied, changed from r524780, incubator/qpid/trunk/qpid/cpp/src/tests/.vg-supp
incubator/qpid/trunk/qpid/cpp/src/tests/.valgrindrc-default
incubator/qpid/trunk/qpid/cpp/src/tests/README (with props)
incubator/qpid/trunk/qpid/cpp/src/tests/test_env
- copied, changed from r524780, incubator/qpid/trunk/qpid/cpp/src/tests/setup
Removed:
incubator/qpid/trunk/qpid/cpp/src/tests/.vg-supp
incubator/qpid/trunk/qpid/cpp/src/tests/examples.Makefile
incubator/qpid/trunk/qpid/cpp/src/tests/examples.README
incubator/qpid/trunk/qpid/cpp/src/tests/setup
Modified:
incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am
incubator/qpid/trunk/qpid/cpp/src/tests/run-unit-tests
Copied: incubator/qpid/trunk/qpid/cpp/src/tests/.valgrind.supp (from r524780, incubator/qpid/trunk/qpid/cpp/src/tests/.vg-supp)
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/.valgrind.supp?view=diff&rev=524913&p1=incubator/qpid/trunk/qpid/cpp/src/tests/.vg-supp&r1=524780&p2=incubator/qpid/trunk/qpid/cpp/src/tests/.valgrind.supp&r2=524913
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/.vg-supp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/.valgrind.supp Mon Apr 2 13:27:21 2007
@@ -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)
+}
Added: incubator/qpid/trunk/qpid/cpp/src/tests/.valgrindrc-default
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/.valgrindrc-default?view=auto&rev=524913
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/.valgrindrc-default (added)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/.valgrindrc-default Mon Apr 2 13:27:21 2007
@@ -0,0 +1,7 @@
+--gen-suppressions=all
+--full_leak_check=--leak-check=full
+--demangle=yes
+--suppressions=.valgrind.supp
+--num-callers=25
+--track-fds=yes
+
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am?view=diff&rev=524913&r1=524912&r2=524913
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am Mon Apr 2 13:27:21 2007
@@ -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 @@
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 @@
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 @@
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 @@
> $@-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.
Added: incubator/qpid/trunk/qpid/cpp/src/tests/README
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/README?view=auto&rev=524913
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/README (added)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/README Mon Apr 2 13:27:21 2007
@@ -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.
+
+
+
+
Propchange: incubator/qpid/trunk/qpid/cpp/src/tests/README
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/trunk/qpid/cpp/src/tests/README
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/run-unit-tests
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/run-unit-tests?view=diff&rev=524913&r1=524912&r2=524913
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/run-unit-tests (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/run-unit-tests Mon Apr 2 13:27:21 2007
@@ -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
Copied: incubator/qpid/trunk/qpid/cpp/src/tests/test_env (from r524780, incubator/qpid/trunk/qpid/cpp/src/tests/setup)
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/test_env?view=diff&rev=524913&p1=incubator/qpid/trunk/qpid/cpp/src/tests/setup&r1=524780&p2=incubator/qpid/trunk/qpid/cpp/src/tests/test_env&r2=524913
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/setup (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/test_env Mon Apr 2 13:27:21 2007
@@ -1,81 +1,43 @@
-# -*- sh -*-
+#!/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
-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" = ''
+# 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()
{
- local file=$1
- if test x$VALGRIND != x; then
- vg_error_check $file && vg_leak_check $file
- fi
+ # 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"