#!/bin/sh -e

TOP_SRCDIR=`pwd`/`dirname $0`/..

CMD=`pwd`/"$1"

## Set up the test environment

ulimit -v 1048576 || true

## Run the tests

# Try to debug the libtool executable, if present
DIR=`dirname $CMD`
BASE=`basename $CMD`
if [ ! -z "$DEBUGGER" ] && [ -x $DIR/.libs/lt-$BASE ]
then
	echo "Running $DEBUGGER $DIR/.libs/lt-$BASE $ARGS"
	RES=0
	if ! $DEBUGGER $DIR/.libs/lt-$BASE $ARGS
	then
		RES=$?
		echo "Failed with result $RES"
	fi
else
	echo "Running $DEBUGGER $CMD $ARGS"
	RES=0
	if !  $DEBUGGER $CMD $ARGS
	then
		RES=$?
		echo "Failed with result $RES"
	fi
fi


if [ ! -z "$PAUSE" ]
then
	echo "Post-test inspection requested."
	echo "Exit this shell to cleanup the test environment."
	bash
fi

exit $RES
