summaryrefslogtreecommitdiff
path: root/qpid/cpp/examples/old_api/verify
diff options
context:
space:
mode:
authorRajith Muditha Attapattu <rajith@apache.org>2011-05-27 15:44:23 +0000
committerRajith Muditha Attapattu <rajith@apache.org>2011-05-27 15:44:23 +0000
commit66765100f4257159622cefe57bed50125a5ad017 (patch)
treea88ee23bb194eb91f0ebb2d9b23ff423e3ea8e37 /qpid/cpp/examples/old_api/verify
parent1aeaa7b16e5ce54f10c901d75c4d40f9f88b9db6 (diff)
parent88b98b2f4152ef59a671fad55a0d08338b6b78ca (diff)
downloadqpid-python-66765100f4257159622cefe57bed50125a5ad017.tar.gz
Creating a branch for experimenting with some ideas for JMS client.rajith_jms_client
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/rajith_jms_client@1128369 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/examples/old_api/verify')
-rwxr-xr-xqpid/cpp/examples/old_api/verify121
1 files changed, 121 insertions, 0 deletions
diff --git a/qpid/cpp/examples/old_api/verify b/qpid/cpp/examples/old_api/verify
new file mode 100755
index 0000000000..9a1ed078d6
--- /dev/null
+++ b/qpid/cpp/examples/old_api/verify
@@ -0,0 +1,121 @@
+#!/bin/sh
+
+#
+# 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.
+#
+
+export LC_ALL=C
+
+# 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.
+#
+
+QPID_DATA_DIR=
+QPID_NO_MODULE_DIR=1
+export QPID_DATA_DIR QPID_NO_MODULE_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() {
+ file=$1
+ while [ -f $file.out ]; do file="${file}X"; done
+ echo $file.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"
+}
+
+name() {
+ for x in $*; do name="$name `basename $x`"; done
+ echo $name;
+}
+
+outputs() {
+ wait 2> /dev/null # Wait for all backgroud processes to complete
+ rm -f $script.out
+ for f in "$@"; do
+ { echo "==== `name $f`"; eval "cat $f"; } >> $script.out || fail
+ done
+}
+
+normalize() { echo `cd $1 && pwd`; }
+
+verify() {
+ FAIL=
+ arg=$1
+ srcdir=$(normalize $2)
+ builddir=$(normalize $3)
+ if [ -d $arg ]; then dir=$(normalize $arg); script=verify;
+ else dir=$(normalize `dirname $arg`); script=`basename $arg`; fi
+
+ # if the example is in the "cpp" area, make sure we run from the build directory, not the source dir.
+ rundir=${dir/$srcdir\/cpp/$builddir/}
+ cd $rundir || return 1
+ rm -f *.out
+ { source $dir/$script && diff -ac $script.out $dir/$script.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\}==//g' $*
+}
+
+# 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
+
+topsrcdir=$1
+topbuilddir=$2
+shift 2
+
+for example in "$@"; do
+ echo "== $example"
+ if ( verify $example $topsrcdir $topbuilddir; ) then echo "PASS"; else echo "FAIL"; RET=1; fi
+ done
+exit $RET