summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen D. Huston <shuston@apache.org>2009-04-28 17:56:25 +0000
committerStephen D. Huston <shuston@apache.org>2009-04-28 17:56:25 +0000
commit9a9447d2c38e22ef4b7a3c280dcfae816003887b (patch)
tree38ef6f850b59d1b2975c5b3b2b249abaac0e8b98
parent7b38772fe85b436624912a02a47f450fea98fcf1 (diff)
downloadqpid-python-9a9447d2c38e22ef4b7a3c280dcfae816003887b.tar.gz
Add tests; revise checks for C++ headers to uuse C++, not C
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@769480 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/CMakeLists.txt5
-rw-r--r--qpid/cpp/src/CMakeLists.txt26
-rw-r--r--qpid/cpp/src/tests/CMakeLists.txt360
-rw-r--r--qpid/cpp/src/tests/Shlib.cpp28
4 files changed, 242 insertions, 177 deletions
diff --git a/qpid/cpp/CMakeLists.txt b/qpid/cpp/CMakeLists.txt
index e17a93a1f1..9d561943bf 100644
--- a/qpid/cpp/CMakeLists.txt
+++ b/qpid/cpp/CMakeLists.txt
@@ -20,9 +20,12 @@ project(qpidc)
cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
set (qpidc_version 0.5)
-# enable_testing()
+enable_testing()
# set(CMAKE_INCLUDE_CURRENT_DIR ON)
+# Emulate "make check" behavior of the autoconf world.
+add_custom_target(check COMMAND ${CMAKE_TEST_COMMAND})
+
add_subdirectory(managementgen)
# add_subdirectory(etc)
add_subdirectory(src)
diff --git a/qpid/cpp/src/CMakeLists.txt b/qpid/cpp/src/CMakeLists.txt
index 9d6d8a2f3b..e12de6f294 100644
--- a/qpid/cpp/src/CMakeLists.txt
+++ b/qpid/cpp/src/CMakeLists.txt
@@ -18,6 +18,7 @@
#
include(CheckFunctionExists)
+include(CheckIncludeFileCXX)
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(CheckSymbolExists)
@@ -128,19 +129,9 @@ if (ENABLE_WARNINGS AND CMAKE_COMPILER_IS_GNUCXX)
# The following warnings are deliberately omitted, they warn on valid code.
# -Wunreachable-code -Wpadded -Winline
# -Wshadow - warns about boost headers.
- add_definitions(-Werror
- -pedantic
- -Wall
- -Wextra
- -Wno-shadow
- -Wpointer-arith
- -Wcast-qual
- -Wcast-align
- -Wno-long-long
- -Wvolatile-register-var
- -Winvalid-pch
- -Wno-system-headers
- -Woverloaded-virtual)
+ set (WARNING_FLAGS
+ " -Werror -pedantic -Wall -Wextra -Wno-shadow -Wpointer-arith -Wcast-qual -Wcast-align -Wno-long-long -Wvolatile-register-var -Winvalid-pch -Wno-system-headers -Woverloaded-virtual")
+ set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}${WARNING_FLAGS})
endif (ENABLE_WARNINGS AND CMAKE_COMPILER_IS_GNUCXX)
# Expand a bit from the basic Find_Boost; be specific about what's needed.
@@ -200,8 +191,8 @@ endif (CMAKE_SYSTEM_NAME STREQUAL Windows)
option(QPID_HAS_XML "Build with XML Exchange" ${xml_default})
if (QPID_HAS_XML)
CHECK_LIBRARY_EXISTS (xerces-c _init "" HAVE_XERCES)
- CHECK_INCLUDE_FILES (xercesc/framework/MemBufInputSource.hpp HAVE_XERCES_H)
- CHECK_INCLUDE_FILES (xqilla/xqilla-simple.hpp HAVE_XQILLA_H)
+ CHECK_INCLUDE_FILE_CXX (xercesc/framework/MemBufInputSource.hpp HAVE_XERCES_H)
+ CHECK_INCLUDE_FILE_CXX (xqilla/xqilla-simple.hpp HAVE_XQILLA_H)
if (NOT HAVE_XERCES)
message(FATAL_ERROR "XML Exchange support requested but xerces-c library not found")
endif (NOT HAVE_XERCES)
@@ -644,4 +635,7 @@ add_definitions(-DHAVE_CONFIG_H)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config.h)
-# add_subdirectory(tests)
+# tests has EXCLUDE_FROM_ALL to avoid building and running tests during
+# "make all". Top-level CMakeLists has a "check" target that runs the tests
+# and all the tests are dependencies of "check" so they'll get built then.
+add_subdirectory(tests EXCLUDE_FROM_ALL)
diff --git a/qpid/cpp/src/tests/CMakeLists.txt b/qpid/cpp/src/tests/CMakeLists.txt
index 273231f0df..798242f18e 100644
--- a/qpid/cpp/src/tests/CMakeLists.txt
+++ b/qpid/cpp/src/tests/CMakeLists.txt
@@ -1,35 +1,25 @@
-
-########### install files ###############
-
-
-
-
-#original Makefile.am contents follow:
-
-##
-## 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.
-##
#
-#AM_CXXFLAGS = $(WARNING_CFLAGS) -DBOOST_TEST_DYN_LINK
-#INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../gen -I$(top_builddir)/src/gen
+# 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
#
-#abs_builddir=@abs_builddir@
-#extra_libs =
+# 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.
+#
+
+add_definitions(-DBOOST_TEST_DYN_LINK)
+include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
+
#lib_client = $(abs_builddir)/../libqpidclient.la
#lib_common = $(abs_builddir)/../libqpidcommon.la
#lib_broker = $(abs_builddir)/../libqpidbroker.la
@@ -45,157 +35,212 @@
#EXTRA_DIST=
#CLEANFILES=
#
-##
-## Unit test program
-##
-## Unit tests are built as a single program to reduce valgrind overhead
-## when running the tests. If you want to build a subset of the tests do
-## rm -f unit_test; make unit_test unit_test_OBJECTS="unit_test.o SelectedTest.o"
-##
#
+# Unit test program
+#
+# Unit tests are built as a single program to reduce valgrind overhead
+# when running the tests. If you want to build a subset of the tests do
+# rm -f unit_test; make unit_test unit_test_OBJECTS="unit_test.o SelectedTest.o"
+#
+set (qpid_test_boost_libs boost_unit_test_framework boost_regex)
#TESTS+=unit_test
#check_PROGRAMS+=unit_test
#unit_test_LDADD=-lboost_unit_test_framework -lboost_regex \
# $(lib_client) $(lib_broker) $(lib_console)
#
-#unit_test_SOURCES= unit_test.cpp unit_test.h \
-# BrokerFixture.h SocketProxy.h \
-# exception_test.cpp \
-# RefCounted.cpp \
-# SessionState.cpp Blob.cpp logging.cpp \
-# AsyncCompletion.cpp \
-# Url.cpp Uuid.cpp \
-# Shlib.cpp FieldValue.cpp FieldTable.cpp Array.cpp \
-# QueueOptionsTest.cpp \
-# InlineAllocator.cpp \
-# InlineVector.cpp \
-# ClientSessionTest.cpp \
-# SequenceSet.cpp \
-# StringUtils.cpp \
-# IncompleteMessageList.cpp \
-# RangeSet.cpp \
-# AtomicValue.cpp \
-# QueueTest.cpp \
-# AccumulatedAckTest.cpp \
-# DtxWorkRecordTest.cpp \
-# DeliveryRecordTest.cpp \
-# ExchangeTest.cpp \
-# HeadersExchangeTest.cpp \
-# MessageTest.cpp \
-# QueueRegistryTest.cpp \
-# QueuePolicyTest.cpp \
-# FramingTest.cpp \
-# HeaderTest.cpp \
-# SequenceNumberTest.cpp \
-# TimerTest.cpp \
-# TopicExchangeTest.cpp \
-# TxBufferTest.cpp \
-# TxPublishTest.cpp \
-# MessageBuilderTest.cpp \
-# ConnectionOptions.h \
-# ForkedBroker.h \
-# ManagementTest.cpp \
-# MessageReplayTracker.cpp \
-# ConsoleTest.cpp
-#
-#if HAVE_XML
-#unit_test_SOURCES+= XmlClientSessionTest.cpp
-#endif
-#
-#
-## Disabled till we move to amqp_0_10 codec.
-## amqp_0_10/serialize.cpp allSegmentTypes.h \
-## amqp_0_10/ProxyTemplate.cpp \
-## amqp_0_10/apply.cpp \
-## amqp_0_10/Map.cpp \
-## amqp_0_10/handlers.cpp
-#
-#
-#check_LTLIBRARIES += libshlibtest.la
+set(unit_tests_to_build
+ unit_test
+ exception_test
+ RefCounted
+ SessionState
+ logging
+ AsyncCompletion
+ Url
+ Uuid
+ Shlib
+ FieldValue
+ FieldTable
+ Array
+ QueueOptionsTest
+ InlineAllocator
+ InlineVector
+ ClientSessionTest
+ SequenceSet
+ StringUtils
+ IncompleteMessageList
+ RangeSet
+ AtomicValue
+ QueueTest
+ AccumulatedAckTest
+ DtxWorkRecordTest
+ DeliveryRecordTest
+ ExchangeTest
+ HeadersExchangeTest
+ MessageTest
+ QueueRegistryTest
+ QueuePolicyTest
+ FramingTest
+ HeaderTest
+ SequenceNumberTest
+ TimerTest
+ TopicExchangeTest
+ TxBufferTest
+ TxPublishTest
+ MessageBuilderTest
+ ManagementTest
+ MessageReplayTracker
+ ConsoleTest
+ QueueEvents
+ ProxyTest
+ RetryList
+ RateFlowcontrolTest
+ FrameDecoder
+ ReplicationTest
+ ClientMessageTest
+ PollableCondition
+ CACHE STRING "Which unit tests to build"
+ )
+if (QPID_HAS_XML)
+ set(unit_tests_to_build ${unit_tests_to_build} XmlClientSessionTest)
+endif (QPID_HAS_XML)
+mark_as_advanced(unit_tests_to_build)
+
+#message(DEBUG "unit_tests_to_build: ${unit_tests_to_build}")
+#string (REPLACE ";" ".cpp;"
+# unit_test_SOURCES
+# ${unit_tests_to_build})
+
+# Disabled till we move to amqp_0_10 codec.
+# amqp_0_10/serialize.cpp allSegmentTypes.h \
+# amqp_0_10/ProxyTemplate.cpp \
+# amqp_0_10/apply.cpp \
+# amqp_0_10/Map.cpp \
+# amqp_0_10/handlers.cpp
+
+add_executable (unit_test ${unit_tests_to_build})
+target_link_libraries (unit_test
+ ${qpid_test_boost_libs}
+ qpidclient qpidbroker qmfconsole)
+add_test (unit_test unit_test)
+add_dependencies (check unit_test)
+
+add_library (shlibtest MODULE shlibtest.cpp)
#libshlibtest_la_LDFLAGS = -module -rpath $(abs_builddir)
-#libshlibtest_la_SOURCES = shlibtest.cpp
-#
+
#include cluster.mk
#if SSL
#include ssl.mk
#endif
+
#
-##
-## Other test programs
-##
-#check_PROGRAMS+=perftest
-#perftest_SOURCES=perftest.cpp test_tools.h TestOptions.h ConnectionOptions.h
-#perftest_LDADD=$(lib_client)
+# Other test programs
#
-#check_PROGRAMS+=txtest
+add_executable (perftest perftest.cpp)
+target_link_libraries (perftest qpidclient)
+#perftest_SOURCES=perftest.cpp test_tools.h TestOptions.h ConnectionOptions.h
+add_test (perftest perftest)
+add_dependencies (check perftest)
+
+add_executable (txtest txtest.cpp)
+target_link_libraries (txtest qpidclient)
#txtest_SOURCES=txtest.cpp TestOptions.h ConnectionOptions.h
-#txtest_LDADD=$(lib_client)
-#
-#check_PROGRAMS+=latencytest
+add_test (txtest txtest)
+add_dependencies (check txtest)
+
+add_executable (latencytest latencytest.cpp)
+target_link_libraries (latencytest qpidclient)
#latencytest_SOURCES=latencytest.cpp TestOptions.h ConnectionOptions.h
-#latencytest_LDADD=$(lib_client)
-#
-#check_PROGRAMS+=echotest
+add_test (latencytest latencytest)
+add_dependencies (check latencytest)
+
+add_executable (echotest echotest.cpp)
+target_link_libraries (echotest qpidclient)
#echotest_SOURCES=echotest.cpp TestOptions.h ConnectionOptions.h
-#echotest_LDADD=$(lib_client)
-#
-#check_PROGRAMS+=client_test
+add_test (echotest echotest)
+add_dependencies (check echotest)
+
+add_executable (client_test client_test.cpp)
+target_link_libraries (client_test qpidclient)
#client_test_SOURCES=client_test.cpp TestOptions.h ConnectionOptions.h
-#client_test_LDADD=$(lib_client)
-#
-#check_PROGRAMS+=topic_listener
+add_test (client_test client_test)
+add_dependencies (check client_test)
+
+add_executable (topic_listener topic_listener.cpp)
+target_link_libraries (topic_listener qpidclient)
#topic_listener_SOURCES=topic_listener.cpp TestOptions.h ConnectionOptions.h
-#topic_listener_LDADD=$(lib_client)
-#
-#check_PROGRAMS+=topic_publisher
+add_test (topic_listener topic_listener)
+add_dependencies (check topic_listener)
+
+add_executable (topic_publisher topic_publisher.cpp)
+target_link_libraries (topic_publisher qpidclient)
#topic_publisher_SOURCES=topic_publisher.cpp TestOptions.h ConnectionOptions.h
-#topic_publisher_LDADD=$(lib_client)
-#
-#check_PROGRAMS+=publish
+add_test (topic_publisher topic_publisher)
+add_dependencies (check topic_publisher)
+
+add_executable (publish publish.cpp)
+target_link_libraries (publish qpidclient)
#publish_SOURCES=publish.cpp TestOptions.h ConnectionOptions.h
-#publish_LDADD=$(lib_client)
-#
-#check_PROGRAMS+=consume
+add_test (publish publish)
+add_dependencies (check publish)
+
+add_executable (consume consume.cpp)
+target_link_libraries (consume qpidclient)
#consume_SOURCES=consume.cpp TestOptions.h ConnectionOptions.h
-#consume_LDADD=$(lib_client)
-#
-#check_PROGRAMS+=header_test
+add_test (consume consume)
+add_dependencies (check consume)
+
+add_executable (header_test header_test.cpp)
+target_link_libraries (header_test qpidclient)
#header_test_SOURCES=header_test.cpp TestOptions.h ConnectionOptions.h
-#header_test_LDADD=$(lib_client)
-#
-#check_PROGRAMS+=failover_soak
+add_test (header_test header_test)
+add_dependencies (check header_test)
+
+add_executable (failover_soak failover_soak.cpp ForkedBroker.cpp)
+target_link_libraries (failover_soak qpidclient)
#failover_soak_SOURCES=failover_soak.cpp ForkedBroker.h
-#failover_soak_LDADD=$(lib_client)
-#
-#check_PROGRAMS+=declare_queues
-#declare_queues_SOURCES=declare_queues.cpp
-#declare_queues_LDADD=$(lib_client)
-#
-#check_PROGRAMS+=replaying_sender
-#replaying_sender_SOURCES=replaying_sender.cpp
-#replaying_sender_LDADD=$(lib_client)
-#
-#check_PROGRAMS+=resuming_receiver
-#resuming_receiver_SOURCES=resuming_receiver.cpp
-#resuming_receiver_LDADD=$(lib_client)
-#
-#check_PROGRAMS+=txshift
+add_test (failover_soak failover_soak)
+add_dependencies (check failover_soak)
+
+add_executable (declare_queues declare_queues.cpp)
+target_link_libraries (declare_queues qpidclient)
+add_test (declare_queues declare_queues)
+add_dependencies (check declare_queues)
+
+add_executable (replaying_sender replaying_sender.cpp)
+target_link_libraries (replaying_sender qpidclient)
+add_test (replaying_sender replaying_sender)
+add_dependencies (check replaying_sender)
+
+add_executable (resuming_receiver resuming_receiver.cpp)
+target_link_libraries (resuming_receiver qpidclient)
+add_test (resuming_receiver resuming_receiver)
+add_dependencies (check resuming_receiver)
+
+add_executable (txshift txshift.cpp)
+target_link_libraries (txshift qpidclient)
#txshift_SOURCES=txshift.cpp TestOptions.h ConnectionOptions.h
-#txshift_LDADD=$(lib_client)
-#
-#check_PROGRAMS+=txjob
+add_test (txshift txshift)
+add_dependencies (check txshift)
+
+add_executable (txjob txjob.cpp)
+target_link_libraries (txjob qpidclient)
#txjob_SOURCES=txjob.cpp TestOptions.h ConnectionOptions.h
-#txjob_LDADD=$(lib_client)
-#
-#check_PROGRAMS+=receiver
+add_test (txjob txjob)
+add_dependencies (check txjob)
+
+add_executable (receiver receiver.cpp)
+target_link_libraries (receiver qpidclient)
#receiver_SOURCES=receiver.cpp TestOptions.h ConnectionOptions.h
-#receiver_LDADD=$(lib_client)
-#
-#check_PROGRAMS+=sender
+add_test (receiver receiver)
+add_dependencies (check receiver)
+
+add_executable (sender sender.cpp)
+target_link_libraries (sender qpidclient)
#sender_SOURCES=sender.cpp TestOptions.h ConnectionOptions.h
-#sender_LDADD=$(lib_client)
-#
-#
+add_test (sender sender)
+add_dependencies (check sender)
+
+
#TESTS_ENVIRONMENT = VALGRIND=$(VALGRIND) srcdir=$(srcdir) QPID_DATA_DIR= BOOST_TEST_SHOW_PROGRESS=yes $(srcdir)/run_test
#
#system_tests = client_test quick_perftest quick_topictest run_header_test quick_txtest
@@ -220,11 +265,10 @@
# TestMessageStore.h \
# TxMocks.h \
# start_cluster stop_cluster restart_cluster
-#
-#check_LTLIBRARIES += libdlclose_noop.la
+
+add_library (dlclose_noop MODULE dlclose_noop.c)
#libdlclose_noop_la_LDFLAGS = -module -rpath $(abs_builddir)
-#libdlclose_noop_la_SOURCES = dlclose_noop.c
-#
+
#CLEANFILES+=valgrind.out *.log *.vglog* dummy_test $(unit_wrappers)
#
## FIXME aconway 2008-05-23: Disabled interop_runner because it uses
diff --git a/qpid/cpp/src/tests/Shlib.cpp b/qpid/cpp/src/tests/Shlib.cpp
index 426a052c9f..b75d8d919a 100644
--- a/qpid/cpp/src/tests/Shlib.cpp
+++ b/qpid/cpp/src/tests/Shlib.cpp
@@ -24,13 +24,37 @@
#include "unit_test.h"
+#ifndef WIN32
+# include <sys/stat.h>
+#endif
+
QPID_AUTO_TEST_SUITE(ShlibTestSuite)
using namespace qpid::sys;
typedef void (*CallMe)(int*);
+// Figure out the correct combination of tokens to use for a loadable
+// library.
+namespace {
+ const char *assemble_name (const char *base)
+ {
+ static char full_name[1024];
+# if defined (WIN32)
+ sprintf (full_name, "%s.dll", base);
+# else
+ // If we're in a libtool environment, use that; else look here.
+ struct stat s;
+ if (stat(".libs", &s) == 0)
+ sprintf (full_name, ".libs/lib%s.so", base);
+ else
+ sprintf (full_name, "./lib%s.so", base);
+# endif /* WIN32 */
+ return full_name;
+ }
+}
+
QPID_AUTO_TEST_CASE(testShlib) {
- Shlib sh(".libs/libshlibtest.so");
+ Shlib sh(assemble_name("shlibtest"));
// Double cast to avoid ISO warning.
CallMe callMe=sh.getSymbol<CallMe>("callMe");
BOOST_REQUIRE(callMe != 0);
@@ -48,7 +72,7 @@ QPID_AUTO_TEST_CASE(testShlib) {
QPID_AUTO_TEST_CASE(testAutoShlib) {
int unloaded = 0;
{
- AutoShlib sh(".libs/libshlibtest.so");
+ AutoShlib sh(assemble_name("shlibtest"));
CallMe callMe=sh.getSymbol<CallMe>("callMe");
BOOST_REQUIRE(callMe != 0);
callMe(&unloaded);