#!/bin/bash
#
# Copyright (c) 2008, 2009 Red Hat, Inc.
#
# This file is part of the Qpid async store library msgstore.so.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
# USA
#
# The GNU Lesser General Public License is available in the file COPYING.

if test -z ${QPID_DIR} ; then
    cat <<EOF

	===========  WARNING: PYTHON TESTS DISABLED ==============
	
	QPID_DIR not set.

	===========================================================

EOF
	exit
fi
  
. `dirname $0`/tests_env.sh

MODULENAME=python_tests

echo "Running Python tests in module ${MODULENAME}..."

case x$1 in
    xSHORT_TEST)
        DEFAULT_PYTHON_TESTS="*.client_persistence.ExchangeQueueTests.* *.flow_to_disk.SimpleMaxSizeCountTest.test_browse_recover *.flow_to_disk.SimpleMaxSizeCountTest.test_durable_browse_recover *.flow_to_disk.MultiDurableQueueDurableMsgBrowseRecoverTxPTxCTest.test_mixed_limit_2" ;;
    xLONG_TEST)
        DEFAULT_PYTHON_TESTS= ;;
    x)
        DEFAULT_PYTHON_TESTS="*.client_persistence.* *.flow_to_disk.SimpleMaxSizeCountTest.* *.flow_to_disk.MultiDurableQueue*.test_mixed_limit_1 *.flow_to_disk.MultiQueue*.test_mixed_limit_1 *.resize.SimpleTest.* *.federation.*" ;;
    *)
        DEFAULT_PYTHON_TESTS=$1
esac

PYTHON_TESTS=${PYTHON_TESTS:-${DEFAULT_PYTHON_TESTS}}

OUTDIR=${MODULENAME}.tmp
rm -rf $OUTDIR

# To debug a test, add the following options to the end of the following line:
# -v DEBUG -c qpid.messaging.io.ops [*.testName]
${PYTHON_DIR}/qpid-python-test -m ${MODULENAME} -I ${FAILING_PYTHON_TESTS} ${PYTHON_TESTS} -DOUTDIR=$OUTDIR #-v DEBUG
RETCODE=$?

if test x${RETCODE} != x0; then 
    exit 1;
fi
exit 0
