summaryrefslogtreecommitdiff
path: root/cpp/examples
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2008-02-08 15:01:30 +0000
committerAlan Conway <aconway@apache.org>2008-02-08 15:01:30 +0000
commit2b1f0e248873a041f7fe5bda724a0d7e13617372 (patch)
tree44d734f4c475a9eada3df0dd002e79de450e3ffa /cpp/examples
parent942b577d5047b3617d00a375235400e275bfe1ff (diff)
downloadqpid-python-2b1f0e248873a041f7fe5bda724a0d7e13617372.tar.gz
Refactored verify scripts, added verify for python Examples.
To verify an example: <qpid-trunk>/bin/verify <example-dir> See comments in bin/verify for more details. Changes: - Each example dir has its own verify script and verify.in. - Added sys.stdout.flush() to som python examples so verify can tell when they're ready. - Made python examples svn:executable. - C++ examples/Makefile.am runs python examples git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@619903 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/examples')
-rw-r--r--cpp/examples/Makefile.am20
-rw-r--r--cpp/examples/examples/direct/verify3
-rw-r--r--cpp/examples/examples/fanout/verify2
-rw-r--r--cpp/examples/examples/pub-sub/verify4
-rw-r--r--cpp/examples/examples/request-response/verify5
-rwxr-xr-xcpp/examples/verify90
6 files changed, 31 insertions, 93 deletions
diff --git a/cpp/examples/Makefile.am b/cpp/examples/Makefile.am
index 933a6de26a..f4882d2c7d 100644
--- a/cpp/examples/Makefile.am
+++ b/cpp/examples/Makefile.am
@@ -17,7 +17,11 @@ nobase_pkgdata_DATA= \
examples/direct/listener.cpp \
examples/direct/declare_queues.cpp
-VERIFY_SCRIPT=verify \
+VERIFY_SCRIPT= \
+ examples/request-response/verify \
+ examples/fanout/verify \
+ examples/pub-sub/verify \
+ examples/direct/verify \
examples/request-response/verify.in \
examples/fanout/verify.in \
examples/pub-sub/verify.in \
@@ -35,7 +39,17 @@ clean-local:
abs_top_builddir=@abs_top_builddir@
abs_top_srcdir=@abs_top_srcdir@
-VERIFY=$(abs_top_srcdir)/examples/verify
+VERIFY=$(top_srcdir)/../bin/verify
+PYTHON_EXAMPLES=$(top_srcdir)/../python/examples
+EXAMPLES= \
+ examples/pub-sub \
+ examples/fanout \
+ examples/direct \
+ examples/request-response \
+ $(PYTHON_EXAMPLES)/pubsub \
+ $(PYTHON_EXAMPLES)/fanout \
+ $(PYTHON_EXAMPLES)/direct \
+ $(PYTHON_EXAMPLES)/request-response
# Build the examples in the source tree.
all-local:
@@ -43,7 +57,7 @@ all-local:
# Verify the examples in the buid tree.
check-local: all-local
- cd examples && QPID_DATA_DIR= QPIDD=$(abs_top_builddir)/src/qpidd $(VERIFY)
+ QPID_DATA_DIR= QPIDD=$(top_builddir)/src/qpidd $(VERIFY) $(EXAMPLES)
# Build and verify the installed examples, then clean up to avoid rpmbuild warnings.
EXAMPLE_FLAGS=-I$(DESTDIR)$(includedir) -L$(DESTDIR)$(libdir) -Wl,-rpath,$(DESTDIR)$(libdir)
diff --git a/cpp/examples/examples/direct/verify b/cpp/examples/examples/direct/verify
new file mode 100644
index 0000000000..ac0464ef80
--- /dev/null
+++ b/cpp/examples/examples/direct/verify
@@ -0,0 +1,3 @@
+# See https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid/bin/verify
+clients ./declare_queues ./direct_producer ./listener
+outputs ./declare_queues.out ./direct_producer.out ./listener.out
diff --git a/cpp/examples/examples/fanout/verify b/cpp/examples/examples/fanout/verify
new file mode 100644
index 0000000000..9febd5777c
--- /dev/null
+++ b/cpp/examples/examples/fanout/verify
@@ -0,0 +1,2 @@
+clients ./declare_queues ./fanout_producer ./listener
+outputs ./declare_queues.out ./fanout_producer.out ./listener.out
diff --git a/cpp/examples/examples/pub-sub/verify b/cpp/examples/examples/pub-sub/verify
new file mode 100644
index 0000000000..3589a4c9da
--- /dev/null
+++ b/cpp/examples/examples/pub-sub/verify
@@ -0,0 +1,4 @@
+# See https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid/bin/verify
+background "Listening" ./topic_listener
+clients ./topic_publisher
+outputs ./topic_publisher.out "topic_listener.out | remove_uuid | sort"
diff --git a/cpp/examples/examples/request-response/verify b/cpp/examples/examples/request-response/verify
new file mode 100644
index 0000000000..a8c942b5e6
--- /dev/null
+++ b/cpp/examples/examples/request-response/verify
@@ -0,0 +1,5 @@
+# See https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid/bin/verify
+background "Waiting" ./server
+clients ./client
+kill %% # Must kill the server.
+outputs "./client.out | remove_uuid" " server.out | remove_uuid"
diff --git a/cpp/examples/verify b/cpp/examples/verify
deleted file mode 100755
index 9271d8d972..0000000000
--- a/cpp/examples/verify
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/bin/sh
-# Run from the installed examples/ dir with a full path to this script.
-# If $QPIDD is set, run a private QPIDD and use it.
-# If $QPID_HOST or $QPID_PORT are set, use them to connect.
-
-DIR=$PWD
-SRC=`dirname $0 | sed 's|^\([^/].*\)|'$PWD'/\1|'`/examples
-
-# Start private broker if QPIDD is set.
-if [ -n "$QPIDD" ] ; then
- export QPID_PORT=`$QPIDD -dp0` || { echo "Cannot start $QPIDD" ; exit 1; }
- trap "$QPIDD -q" EXIT
-fi
-
-cleanup() {
- test -n "$QPIDD" && $QPIDD -q # Private broker
- kill %% > /dev/null 2>&1 # Leftover background jobs
-}
-
-trap cleanup EXIT
-
-ARGS="${QPID_HOST:-localhost} $QPID_PORT"
-
-
-client() { "$@" $ARGS > $1.out; }
-clients() { for cmd in "$@"; do client $cmd; done; }
-
-waitfor() { until grep -a -l "$2" $1 >/dev/null 2>&1 ; do sleep 1 ; done ; }
-
-background() {
- pattern=$1; shift
- eval "$@ $ARGS > $1.out &"
- waitfor $1.out $pattern
-}
-
-outputs() {
- wait 2> /dev/null # Wait for all backgroud processes to complete
- for f in "$@"; do
- { echo "==== $f"; eval "cat $f"; } >> verify.out ;
- done
-}
-
-verify() {
- dir=$1
- func=`echo $dir | tr - _`
- cd $dir || return 1
- rm -f *.out
- { $func && diff -ac verify.out $SRC/$dir/verify.in ; } || return 1
- rm -f *.out
-}
-
-HEX="[a-fA-F0-9]"
-remove_uuid() {
- sed "s/$HEX\{8\}-$HEX\{4\}-$HEX\{4\}-$HEX\{4\}-$HEX\{12\}//g" $*
-}
-
-# Scripts for each example
-
-direct() {
- clients ./declare_queues ./direct_producer ./listener
- outputs ./declare_queues.out ./direct_producer.out ./listener.out
-}
-
-fanout() {
- clients ./declare_queues ./fanout_producer ./listener
- outputs ./declare_queues.out ./fanout_producer.out ./listener.out
-}
-
-pub_sub() {
- background "Listening" ./topic_listener
- clients ./topic_publisher
- outputs ./topic_publisher.out "topic_listener.out | remove_uuid | sort"
-}
-
-request_response() {
- background "Waiting" ./server
- clients ./client
- kill %% # Must kill the server.
- outputs "./client.out | remove_uuid" " server.out | remove_uuid"
-}
-
-# Main
-EXAMPLES=${*:-direct fanout pub-sub request-response}
-for ex in $EXAMPLES ; do
- if ( verify $ex; ) then echo "PASS: $ex"; else
- echo "FAIL: $ex"; RET=1; fi
-done
-
-exit $RET
-