#!/bin/sh
# Verify all C++/python example combinations.
#

verify=`dirname $0`/verify
topsrcdir=$1
qpidd=$2
exclude_regexp=$3
python=${QPID_PYTHON_DIR:-$topsrcdir/python}

trap "$qpidd -q" exit
QPID_PORT=`$qpidd -dp0 --no-module-dir --data-dir "" --auth no` || { echo "Can't run qpidd" ; exit 1; }
PYTHON_EXAMPLES=$python/examples
PYTHONPATH=$python:$PYTHONPATH
export QPID_PORT PYTHON_EXAMPLES PYTHONPATH

test -d $PYTHON_EXAMPLES || echo "WARNING: No python examples. $PYTHON_EXAMPLES not found."
find="find"
test -d $PYTHON_EXAMPLES && find="$find $PYTHON_EXAMPLES"
find="$find -mindepth 2 -name verify"
test -d $PYTHON_EXAMPLES && \
    find="$find -o -name verify_cpp_python -o -name verify_python_cpp"
all_examples=`$find`

if test -z "$exclude_regexp"; then
    run_examples=$all_examples
else
    for f in $all_examples; do
	{ cat $f | grep $exclude_regexp > /dev/null ; } || run_examples="$run_examples $f"
    done
fi
$verify $run_examples
