summaryrefslogtreecommitdiff
path: root/qpid/bin
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
commit56be271a9b61a7baec92b81ba84b9e9e2c51255d (patch)
tree61bf333f8b68de7365590e54ef2e53c767d6c2d0 /qpid/bin
parentb70fba9bd0fbc69f6892d576a3c70f9ee7af563b (diff)
downloadqpid-python-56be271a9b61a7baec92b81ba84b9e9e2c51255d.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@619903 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/bin')
-rwxr-xr-xqpid/bin/verify74
1 files changed, 74 insertions, 0 deletions
diff --git a/qpid/bin/verify b/qpid/bin/verify
new file mode 100755
index 0000000000..fc86c3d896
--- /dev/null
+++ b/qpid/bin/verify
@@ -0,0 +1,74 @@
+#!/bin/sh
+# Driver script to verify installed examples (also used for build tests.)
+#
+# Usage: verify example_dir [ example_dir ...]
+# Where each example_dir must contain a verify sub-script to include.
+#
+# If $QPIDD is set, run a private QPIDD and use it.
+# If $QPID_HOST or $QPID_PORT are set, use them to connect.
+#
+
+export QPID_DATA_DIR=
+
+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"
+
+outfile() { echo $1.out; }
+
+fail() { test -n "$*" && echo $* 1>&2 ; FAIL=1; return 1; }
+
+client() { "$@" $ARGS > `outfile $*` || fail; }
+
+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
+ out=`outfile $*`
+ eval "$* $ARGS > $out &" || { fail; return 1; }
+ waitfor $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 || fail
+ done
+}
+
+verify() {
+ FAIL=
+ dir=$1
+ cd $dir || return 1
+ rm -f *.out
+ { source ./verify && diff -ac verify.out verify.in ; } || fail
+ test -z "$FAIL" && rm -f *.out
+ return $FAIL
+}
+
+HEX="[a-fA-F0-9]"
+remove_uuid() {
+ sed "s/$HEX\{8\}-$HEX\{4\}-$HEX\{4\}-$HEX\{4\}-$HEX\{12\}//g" $*
+}
+remove_uuid64() {
+ sed 's/[-A-Za-z0-9_]\{22\}==$//' $*
+}
+
+# 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
+
+for dir in "$@"; do
+ echo -n "$dir : "
+ if ( verify $dir; ) then echo "PASS"; else echo "FAIL"; RET=1; fi
+ done
+exit $RET