diff options
author | Alan Conway <aconway@apache.org> | 2008-02-21 14:24:24 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2008-02-21 14:24:24 +0000 |
commit | e94f3d432e52caa93244bcbca57d58bee570041d (patch) | |
tree | 41de5e5b5b985c448c6592383598674490354f05 /qpid/cpp/examples | |
parent | a0551acfe22a99433db840b246a56edb48f6f06e (diff) | |
download | qpid-python-e94f3d432e52caa93244bcbca57d58bee570041d.tar.gz |
Fix verify script problem
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@629796 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/examples')
-rw-r--r-- | qpid/cpp/examples/Makefile.am | 8 | ||||
-rwxr-xr-x | qpid/cpp/examples/verify | 85 | ||||
-rwxr-xr-x | qpid/cpp/examples/verify_all | 15 |
3 files changed, 93 insertions, 15 deletions
diff --git a/qpid/cpp/examples/Makefile.am b/qpid/cpp/examples/Makefile.am index df7fe4dfc7..21363ea8e4 100644 --- a/qpid/cpp/examples/Makefile.am +++ b/qpid/cpp/examples/Makefile.am @@ -44,12 +44,6 @@ VERIFY_FILES= verify verify_all \ EXTRA_DIST=$(nobase_pkgdata_DATA) $(VERIFY_FILES) -force: - -VERIFY_SCRIPT=$(top_srcdir)/../bin/verify -verify: force - if [ -f $(VERIFY_SCRIPT) ] ; then cp $(VERIFY_SCRIPT) $@; fi - # Note: we don't use normal automake SUBDIRS because the example # makefiles don't understand all the recursive automake targets. @@ -67,7 +61,7 @@ all-local: # Verify the examples in the buid tree. check-local: all-local verify - $(srcdir)/verify_all $(abs_top_srcdir) $(abs_top_builddir) + $(srcdir)/verify_all $(abs_top_srcdir)/.. # TODO: # create a tarball for testing installed examples. diff --git a/qpid/cpp/examples/verify b/qpid/cpp/examples/verify new file mode 100755 index 0000000000..251097930e --- /dev/null +++ b/qpid/cpp/examples/verify @@ -0,0 +1,85 @@ +#!/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() { + 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 +} + +verify() { + FAIL= + if [ -d $1 ]; then dir=$1; script=verify; + else dir=`dirname $1`; script=`basename $1`; fi + cd $dir || return 1 + rm -f *.out + { source ./$script && diff -ac $script.out $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 + +for example in "$@"; do + echo "== $example " + if ( verify $example; ) then echo "PASS"; else echo "FAIL"; RET=1; fi + done +exit $RET diff --git a/qpid/cpp/examples/verify_all b/qpid/cpp/examples/verify_all index e6d75929b2..5501239021 100755 --- a/qpid/cpp/examples/verify_all +++ b/qpid/cpp/examples/verify_all @@ -2,20 +2,19 @@ # Verify all C++/python example combinations. # -src=$1 ; build=$2 - -verify=./verify -qpidd=$build/src/qpidd -cpp=$build/examples/examples -python=$src/../python +srcdir=$1 ; +verify=`dirname $0`/verify +qpidd=../src/qpidd +python=$srcdir/python trap "$qpidd -q" exit export QPID_PORT=`$qpidd -dp0 --data-dir ""` export PYTHON_EXAMPLES=$python/examples export PYTHONPATH=$python:$PYTHONPATH -export AMQP_SPEC=$src/../specs/amqp.0-10-preview.xml +export AMQP_SPEC=$srcdir/specs/amqp.0-10-preview.xml -find="find $cpp" +test -d $PYTHON_EXAMPLES || echo "Warning: not verifying python examples, $PYTHON_EXAMPLES not found" +find="find examples" test -d $PYTHON_EXAMPLES && find="$find $PYTHON_EXAMPLES" find="$find -name verify" test -d $PYTHON_EXAMPLES && \ |