diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/tests/Makefile.am | 5 | ||||
-rw-r--r-- | cpp/tests/client_test.cpp | 32 | ||||
-rwxr-xr-x | cpp/tests/kill_broker | 3 | ||||
-rwxr-xr-x | cpp/tests/python_tests | 12 | ||||
-rwxr-xr-x | cpp/tests/quick_topictest | 7 | ||||
-rwxr-xr-x | cpp/tests/run-system-tests | 42 | ||||
-rwxr-xr-x | cpp/tests/start_broker | 10 | ||||
-rw-r--r-- | cpp/tests/topic_listener.cpp | 2 | ||||
-rw-r--r-- | cpp/tests/topic_publisher.cpp | 8 | ||||
-rwxr-xr-x | cpp/tests/topictest | 20 |
10 files changed, 69 insertions, 72 deletions
diff --git a/cpp/tests/Makefile.am b/cpp/tests/Makefile.am index 5e4d5dcc02..5e3d289b0b 100644 --- a/cpp/tests/Makefile.am +++ b/cpp/tests/Makefile.am @@ -61,8 +61,9 @@ unit_tests = \ noinst_PROGRAMS = $(client_exe_tests) -TESTS = run-unit-tests run-system-tests -EXTRA_DIST += $(TESTS) +CLIENT_TESTS = client_test quick_topictest +TESTS = run-unit-tests start_broker $(CLIENT_TESTS) python_tests kill_broker +EXTRA_DIST += $(TESTS) topictest include gen.mk diff --git a/cpp/tests/client_test.cpp b/cpp/tests/client_test.cpp index 9534fdcecb..869cbd33e7 100644 --- a/cpp/tests/client_test.cpp +++ b/cpp/tests/client_test.cpp @@ -40,6 +40,8 @@ using namespace qpid::client; using namespace qpid::sys; using std::string; +bool verbose = false; + /** * A simple message listener implementation that prints out the * message content then notifies a montitor allowing the test to @@ -52,13 +54,15 @@ public: inline SimpleListener(Monitor* _monitor) : monitor(_monitor){} inline virtual void received(Message& msg){ - std::cout << "Received message " << msg.getData() << std::endl; + if (verbose) + std::cout << "Received message " << msg.getData() << std::endl; monitor->notify(); } }; int main(int argc, char**) { + verbose = argc > 1; try{ //Use a custom exchange Exchange exchange("MyExchange", Exchange::TOPIC_EXCHANGE); @@ -69,25 +73,25 @@ int main(int argc, char**) Connection con(argc > 1); string host("localhost"); con.open(host); - std::cout << "Opened connection." << std::endl; + if (verbose) std::cout << "Opened connection." << std::endl; //Create and open a channel on the connection through which //most functionality is exposed Channel channel; con.openChannel(&channel); - std::cout << "Opened channel." << std::endl; + if (verbose) std::cout << "Opened channel." << std::endl; //'declare' the exchange and the queue, which will create them //as they don't exist channel.declareExchange(exchange); - std::cout << "Declared exchange." << std::endl; + if (verbose) std::cout << "Declared exchange." << std::endl; channel.declareQueue(queue); - std::cout << "Declared queue." << std::endl; + if (verbose) std::cout << "Declared queue." << std::endl; //now bind the queue to the exchange qpid::framing::FieldTable args; channel.bind(exchange, queue, "MyTopic", args); - std::cout << "Bound queue to exchange." << std::endl; + if (verbose) std::cout << "Bound queue to exchange." << std::endl; //Set up a message listener to receive any messages that //arrive in our queue on the broker. We only expect one, and @@ -98,7 +102,7 @@ int main(int argc, char**) SimpleListener listener(&monitor); string tag("MyTag"); channel.consume(queue, tag, &listener); - std::cout << "Registered consumer." << std::endl; + if (verbose) std::cout << "Registered consumer." << std::endl; //we need to enable the message dispatching for this channel //and we want that to occur on another thread so we call @@ -111,7 +115,7 @@ int main(int argc, char**) string data("MyMessage"); msg.setData(data); channel.publish(msg, exchange, "MyTopic"); - std::cout << "Published message: " << data << std::endl; + if (verbose) std::cout << "Published message: " << data << std::endl; { Monitor::ScopedLock l(monitor); @@ -122,13 +126,15 @@ int main(int argc, char**) //close the channel & connection con.closeChannel(&channel); - std::cout << "Closed channel." << std::endl; + if (verbose) std::cout << "Closed channel." << std::endl; con.close(); - std::cout << "Closed connection." << std::endl; + if (verbose) std::cout << "Closed connection." << std::endl; }catch(qpid::QpidError error){ - std::cout << "Error [" << error.code << "] " << error.msg << " (" - << error.location.file << ":" << error.location.line - << ")" << std::endl; + if (verbose) std::cout + << "Error [" << error.code << "] " + << error.msg << " (" + << error.location.file << ":" << error.location.line + << ")" << std::endl; return 1; } return 0; diff --git a/cpp/tests/kill_broker b/cpp/tests/kill_broker new file mode 100755 index 0000000000..36818f976b --- /dev/null +++ b/cpp/tests/kill_broker @@ -0,0 +1,3 @@ +#!/bin/sh +PID=qpid.pid +if [ -f $PID ] ; then kill -9 `cat $PID` ; rm -f $PID ; fi diff --git a/cpp/tests/python_tests b/cpp/tests/python_tests new file mode 100755 index 0000000000..d41f8adb80 --- /dev/null +++ b/cpp/tests/python_tests @@ -0,0 +1,12 @@ +#!/bin/sh +# FIXME aconway 2007-01-09: Re-enable. +echo "*** WARNING: PYTHON TESTS DISABLED till branch is functioning on 0-9." +exit + +# Run the python tests. +if test -d ../../python ; then + cd ../../python && ./run-tests -v -I cpp_failing.txt +else + echo Warning: python tests not found. +fi + diff --git a/cpp/tests/quick_topictest b/cpp/tests/quick_topictest new file mode 100755 index 0000000000..e3b1f5fae9 --- /dev/null +++ b/cpp/tests/quick_topictest @@ -0,0 +1,7 @@ +#!/bin/sh +# Quick and quiet topic test for make check. +./topictest -s2 -m2 -b1 > topictest.log 2>&1 || { + echo See topictest.log. + exit 1 +} + diff --git a/cpp/tests/run-system-tests b/cpp/tests/run-system-tests deleted file mode 100755 index 7e3223debe..0000000000 --- a/cpp/tests/run-system-tests +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh - -set -e -log=`pwd`/qpidd.log -# Start the daemon, recording its PID. -../src/qpidd > $log 2>&1 & pid=$! - -# Arrange to kill the daemon upon any type of termination. -trap 'status=$?; kill $pid; rm -f test.out; exit $status' 0 -trap '(exit $?); exit $?' 1 2 13 15 - -# Run C++ client tests. -run_test() { - test="$*" - echo -n "Running: $test ... " - if $test >test.out 2>&1 ; then - echo " Passed" ; - else - echo " FAILED. Output:"; - cat test.out - FAILED=yes - fi - rm -f test.out -} - -run_test ./client_test -run_test `dirname $0`/topictest -s2 -m2 -b1 - -# FIXME aconway 2007-01-08: Re-enable python tests when the brach -# is functional again. -echo "WARNING: PYTHON TESTS DISABLED TILL BRANCH IS FUNCTIONAL" - -# Run the python tests. -# if test -d ../../python ; then -# cd ../../python && ./run-tests -v -I cpp_failing.txt -# else -# echo Warning: python tests not found. -# fi - -# TODO aconway 2006-12-13: run the other client tests. - -rm -f $log diff --git a/cpp/tests/start_broker b/cpp/tests/start_broker new file mode 100755 index 0000000000..6f67e7d8c5 --- /dev/null +++ b/cpp/tests/start_broker @@ -0,0 +1,10 @@ +#!/bin/sh +set -e + +LOG=`pwd`/qpidd.log +PID=`pwd`/qpidd.pid + +rm -rf $LOG $PID + +# Start the daemon, recording its PID. +../src/qpidd > $LOG 2>&1 & echo $! > $PID diff --git a/cpp/tests/topic_listener.cpp b/cpp/tests/topic_listener.cpp index 06c1765786..ec457c7f57 100644 --- a/cpp/tests/topic_listener.cpp +++ b/cpp/tests/topic_listener.cpp @@ -121,10 +121,12 @@ int main(int argc, char** argv){ channel.consume(control, tag, &listener, args.getAckMode()); channel.run(); connection.close(); + return 0; }catch(qpid::QpidError error){ std::cout << error.what() << std::endl; } } + return 1; } Listener::Listener(Channel* _channel, const std::string& _responseq, bool tx) : diff --git a/cpp/tests/topic_publisher.cpp b/cpp/tests/topic_publisher.cpp index 6d17b7034f..5761acc4aa 100644 --- a/cpp/tests/topic_publisher.cpp +++ b/cpp/tests/topic_publisher.cpp @@ -110,12 +110,12 @@ public: inline bool getHelp() const { return help; } }; -int main(int argc, char** argv){ +int main(int argc, char** argv) { Args args; args.parse(argc, argv); if(args.getHelp()){ args.usage(); - }else{ + } else { try{ Connection connection(args.getTrace()); connection.open(args.getHost(), args.getPort()); @@ -156,10 +156,12 @@ int main(int argc, char** argv){ } channel.close(); connection.close(); - }catch(qpid::QpidError error){ + return 0; + }catch(qpid::QpidError error) { std::cout << error.what() << std::endl; } } + return 1; } Publisher::Publisher(Channel* _channel, const std::string& _controlTopic, bool tx) : diff --git a/cpp/tests/topictest b/cpp/tests/topictest index d68a8c81da..b2c7e57b41 100755 --- a/cpp/tests/topictest +++ b/cpp/tests/topictest @@ -1,7 +1,10 @@ #!/bin/bash # Run the C++ topic test -# Defaults +# Clean up old log files +rm -f subscriber_*.log + +# Defaults values SUBSCRIBERS=10 MESSAGES=2000 BATCHES=10 @@ -19,13 +22,8 @@ while getopts "s:m:b:" opt ; do done subscribe() { - ID=$1 - echo "subscriber $ID" - ./topic_listener > subscriber.$ID 2>&1 || { - echo "SUBSCRIBER %ID FAILED: " ; - cat subscriber.$ID - } - rm subscriber.$ID + LOG="subscriber_$1.log" + ./topic_listener > $LOG 2>&1 && rm -f $LOG } publish() { @@ -35,7 +33,5 @@ publish() { for ((i=$SUBSCRIBERS ; i--; )); do subscribe $i & done -sleep 1 -STATS=~/bin/topictest.times -echo "---- topictest `date`" >> $STATS -publish | tee -a $STATS + +publish 2>&1 || exit 1 |