#!/bin/sh

#
#	Phoronix Test Suite
#	URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
#	Copyright (C) 2008 - 2009, Phoronix Media
#	Copyright (C) 2008 - 2009, Michael Larabel
#	phoronix-test-suite: The Phoronix Test Suite is an extensible open-source testing / benchmarking platform
#
#	This program is free software; you can redistribute it and/or modify
#	it under the terms of the GNU General Public License as published by
#	the Free Software Foundation; either version 3 of the License, or
#	(at your option) any later version.
#
#	This program 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 General Public License for more details.
#
#	You should have received a copy of the GNU General Public License
#	along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# Full path to root directory of the actual Phoronix Test Suite code
export PTS_DIR=`pwd`
CALL_DIR=`pwd`

if [ $PTS_DIR != `pwd` ]
then
	cd $PTS_DIR
fi

# Determine PHP binary location
if [ -x /usr/bin/php5 ] || [ -x /usr/local/bin/php5 ]
then
	export PHP_BIN="php5"
elif [ -x /usr/bin/php ] || [ -x /usr/local/bin/php ]
then
	export PHP_BIN="php"
elif [ -x /usr/php5/bin/php ]
then
	export PHP_BIN="/usr/php5/bin/php"
elif [ -x /usr/php/bin/php ]
then
	export PHP_BIN="/usr/php/bin/php"
else
	export PHP_BIN=""
fi

# Make sure PHP is installed
if [ "X$PHP_BIN" = "X" ]
then
	cat <<'EOT'

PHP 5.x CLI Must Be Installed To Run The Phoronix Test Suite.
Only PHP For The Command Line Is Needed, Not A Complete PHP Web Server Installation
The PHP CLI package is usually called php-cli or php5-cli. Also recommended is the PHP GD library (php-gd)
For support visit: http://www.phoronix-test-suite.com/

EOT
exit
fi

# Ensure the user is in the correct directory
if [ ! -f pts-core/phoronix-test-suite.php ]
then
	cat <<'EOT'

To run the Phoronix Test Suite locally you must first change directories to phoronix-test-suite/ 
or install the program using the install-sh script. For support visit: http://www.phoronix-test-suite.com/

EOT
exit
fi

# Check if being called from a Self Contained test profile
# export SCTP_FILE=`echo $CALL_DIR/$1 | sed 's:\./::g'`
# if [ -e $SCTP_FILE ]
# then
# 	export PTS_COMMAND="benchmark"
# 	$PHP_BIN pts-core/phoronix-test-suite.php benchmark $SCTP_FILE
# 	exit
# fi

# Command-specific conditions
case "$1" in
"test-module" | "debug-module")
	export PTS_IGNORE_MODULES=1
	;;
esac

# Run The Phoronix Test Suite
$PHP_BIN pts-core/phoronix-test-suite.php $@

