diff options
author | Alan Conway <aconway@apache.org> | 2007-12-07 16:29:59 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2007-12-07 16:29:59 +0000 |
commit | c5d4127efa6689586687f8a2f19ec10e57f13f89 (patch) | |
tree | fdc7997e9ddf46b36b592024e85622ccc6765be1 /cpp | |
parent | aa29da990d23d017ecfa095eb0d3e8adf705b4b8 (diff) | |
download | qpid-python-c5d4127efa6689586687f8a2f19ec10e57f13f89.tar.gz |
examples/verify
- run installed examples and verify their output.
examples/examples/*/verify.in
- expected output of example, may be filtered/sorted for some examples.
examples/Makefile.am
- add verify to installcheck target.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@602140 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/examples/Makefile.am | 1 | ||||
-rw-r--r-- | cpp/examples/examples/direct/verify.in | 38 | ||||
-rw-r--r-- | cpp/examples/examples/fanout/verify.in | 19 | ||||
-rw-r--r-- | cpp/examples/examples/pub-sub/verify.in | 61 | ||||
-rw-r--r-- | cpp/examples/examples/request-response/verify.in | 21 | ||||
-rwxr-xr-x | cpp/examples/verify | 68 | ||||
-rwxr-xr-x | cpp/examples/verify_functions | 50 |
7 files changed, 208 insertions, 50 deletions
diff --git a/cpp/examples/Makefile.am b/cpp/examples/Makefile.am index 77b6c5d26a..8e7c88b996 100644 --- a/cpp/examples/Makefile.am +++ b/cpp/examples/Makefile.am @@ -31,4 +31,5 @@ EXAMPLE_FLAGS=-I$(DESTDIR)$(includedir) -L$(DESTDIR)$(libdir) -Wl,-rpath,$(DESTD EXAMPLE_DIR=$(DESTDIR)$(pkgdatadir)/examples installcheck-local: cd $(EXAMPLE_DIR) && $(MAKE) CXX="$(CXX)" CXXFLAGS="$(EXAMPLE_FLAGS)" all + cd ${EXAMPLE_DIR) && $(abs_srcdir)/verify cd $(EXAMPLE_DIR) && $(MAKE) clean diff --git a/cpp/examples/examples/direct/verify.in b/cpp/examples/examples/direct/verify.in new file mode 100644 index 0000000000..3d344071f2 --- /dev/null +++ b/cpp/examples/examples/direct/verify.in @@ -0,0 +1,38 @@ +==== ./direct_config_queues +==== +==== ./direct_publisher +==== +==== ./listener +Activating listener for: listener_destination +Message: Message 0 +Message: Message 1 +Message: Message 2 +Message: Message 3 +Message: Message 4 +Message: Message 5 +Message: Message 6 +Message: Message 7 +Message: Message 8 +Message: Message 9 +Message: That's all, folks! +Shutting down listener for listener_destination +==== +==== ./direct_persistent_config_queues +==== +==== ./direct_persistent_publisher +==== +==== ./listener +Activating listener for: listener_destination +Message: Message 0 +Message: Message 1 +Message: Message 2 +Message: Message 3 +Message: Message 4 +Message: Message 5 +Message: Message 6 +Message: Message 7 +Message: Message 8 +Message: Message 9 +Message: That's all, folks! +Shutting down listener for listener_destination +==== diff --git a/cpp/examples/examples/fanout/verify.in b/cpp/examples/examples/fanout/verify.in new file mode 100644 index 0000000000..ca3ae7c3b6 --- /dev/null +++ b/cpp/examples/examples/fanout/verify.in @@ -0,0 +1,19 @@ +==== ./fanout_config_queues +==== +==== ./fanout_publisher +==== +==== ./listener +Activating listener for: listener_destination +Message: Message 0 +Message: Message 1 +Message: Message 2 +Message: Message 3 +Message: Message 4 +Message: Message 5 +Message: Message 6 +Message: Message 7 +Message: Message 8 +Message: Message 9 +Message: That's all, folks! +Shutting down listener for listener_destination +==== diff --git a/cpp/examples/examples/pub-sub/verify.in b/cpp/examples/examples/pub-sub/verify.in new file mode 100644 index 0000000000..cc76bb0436 --- /dev/null +++ b/cpp/examples/examples/pub-sub/verify.in @@ -0,0 +1,61 @@ +==== ./topic_publisher +==== +==== remove_uuid topic_listener.out | sort +Declaring queue: europe +Declaring queue: news +Declaring queue: usa +Declaring queue: weather +Listening for messages ... +Message: Message 0 from europe +Message: Message 0 from europe +Message: Message 0 from news +Message: Message 0 from news +Message: Message 0 from usa +Message: Message 0 from usa +Message: Message 0 from weather +Message: Message 0 from weather +Message: Message 1 from europe +Message: Message 1 from europe +Message: Message 1 from news +Message: Message 1 from news +Message: Message 1 from usa +Message: Message 1 from usa +Message: Message 1 from weather +Message: Message 1 from weather +Message: Message 2 from europe +Message: Message 2 from europe +Message: Message 2 from news +Message: Message 2 from news +Message: Message 2 from usa +Message: Message 2 from usa +Message: Message 2 from weather +Message: Message 2 from weather +Message: Message 3 from europe +Message: Message 3 from europe +Message: Message 3 from news +Message: Message 3 from news +Message: Message 3 from usa +Message: Message 3 from usa +Message: Message 3 from weather +Message: Message 3 from weather +Message: Message 4 from europe +Message: Message 4 from europe +Message: Message 4 from news +Message: Message 4 from news +Message: Message 4 from usa +Message: Message 4 from usa +Message: Message 4 from weather +Message: Message 4 from weather +Message: That's all, folks! from europe +Message: That's all, folks! from news +Message: That's all, folks! from usa +Message: That's all, folks! from weather +Shutting down listener for europe +Shutting down listener for news +Shutting down listener for usa +Shutting down listener for weather +Subscribing to queue europe +Subscribing to queue news +Subscribing to queue usa +Subscribing to queue weather +==== diff --git a/cpp/examples/examples/request-response/verify.in b/cpp/examples/examples/request-response/verify.in new file mode 100644 index 0000000000..52034bdfd0 --- /dev/null +++ b/cpp/examples/examples/request-response/verify.in @@ -0,0 +1,21 @@ +==== ./client +Activating response queue listener for: client +Request: Twas brillig, and the slithy toves +Request: Did gire and gymble in the wabe. +Request: All mimsy were the borogroves, +Request: And the mome raths outgrabe. +Waiting for all responses to arrive ... +Response: TWAS BRILLIG, AND THE SLITHY TOVES +Response: DID GIRE AND GYMBLE IN THE WABE. +Response: ALL MIMSY WERE THE BOROGROVES, +Response: AND THE MOME RATHS OUTGRABE. +Shutting down listener for client +==== +==== remove_uuid server.out +Activating request queue listener for: request_queue +Waiting for requests +Request:: Twas brillig, and the slithy toves (client ) +Request:: Did gire and gymble in the wabe. (client ) +Request:: All mimsy were the borogroves, (client ) +Request:: And the mome raths outgrabe. (client ) +==== diff --git a/cpp/examples/verify b/cpp/examples/verify new file mode 100755 index 0000000000..d6d24fb5ce --- /dev/null +++ b/cpp/examples/verify @@ -0,0 +1,68 @@ +#!/bin/sh +# Run from the installed examples/ dir with a full path to this script. +# + +DIR=$PWD +SRC=`dirname $0`/examples + +# Utility functions + +run() { + echo ==== $*; eval "$*"; echo ====; +} + +waitfor() { until grep -a -l "$2" $1 >/dev/null ; do sleep 1 ; done ; } + +verify() { + ex=`basename $PWD` + diff -ac verify.out verify.in || { echo "FAIL: $ex " ; RET=1 ; return 1; } +} + +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() { + run ./direct_config_queues > verify.out + run ./direct_publisher >> verify.out + run ./listener >> verify.out + run ./direct_persistent_config_queues >> verify.out + run ./direct_persistent_publisher >> verify.out + run ./listener >> verify.out +} + +fanout() { + run ./fanout_config_queues > verify.out + run ./fanout_publisher >>verify.out + run ./listener >>verify.out +} + +pub_sub() { + ./topic_listener | tee topic_listener.out > topic_listener.wait & + waitfor topic_listener.wait "Listening" + run ./topic_publisher > verify.out + wait + run remove_uuid "topic_listener.out | sort" >> verify.out +} + +request_response() { + ./server | tee server.out > server.wait & + waitfor server.wait "Waiting" + run ./client | remove_uuid > verify.out + kill %% + wait 2> /dev/null + run remove_uuid server.out >> verify.out +} + +# Main +for ex in direct fanout pub-sub request-response; do + func=`echo $ex | tr - _` + cp $SRC/$ex/verify.in $ex + echo "Verifing $ex" + ( cd $ex && $func && verify && rm -f verify.in *.out *.wait) +done + +exit $RET diff --git a/cpp/examples/verify_functions b/cpp/examples/verify_functions deleted file mode 100755 index 15bf34f048..0000000000 --- a/cpp/examples/verify_functions +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh - -new_tag() { - for t in $TAGS; do - if test "$t" = "$1"; then - echo "Duplicate tag $t" 1>&2 ; exit 1 - fi - done - TAGS="$TAGS $tag" -} - -# Usage: run tag program args ... -# Runs 'program args ...' with output to tag.out and tag.err -run() { - tag=$1; shift - test -n "$*" || { echo "No command for tag: $tag" 1>&2; exit 1; } - new_tag $tag - rm -f $tag.out $tag.err $tag.diff - "$@" > $tag.out 2> $tag.err || echo "exit status $?" >> $tag.err & -} - -# Genereate error report -errors() { - for tag in "$@"; do - DIFF=`diff $tag.out $tag.expect 2>&1` || { - echo "==== $tag.out != $tag.expect ====" - echo $DIFF - } - test -s $tag.err && { - echo "==== $tag.err ====" - cat $tag.err - } - done -} - -# Wait for processes, verify output. -# Verifies tag.expect == tag.out and ! tag.err for each tag, -# creates errors.txt if there are any discrepancies. -# -verify() { - wait - rm -f errors.txt - ERRORS=`errors $TAGS` - if test -n "$ERRORS"; then - echo "$ERRORS" 1>&2 - return 1 - fi - return 0 -} - |