#!/bin/bash
###SHELLPACK preamble unixbench-install 5.1.3
WEB_LOCATION=http://www.skynet.ie/~mel/mmtests-archive/unixbench
MIRROR_LOCATION="$WEBROOT/unixbench/"

###SHELLPACK parseargBegin
###SHELLPACK parseargEnd

rm -rf $SHELLPACK_SOURCES/unixbench-${VERSION}
###SHELLPACK sources_fetch UnixBench${VERSION}.tgz unixbench-${VERSION}-installed

###SHELLPACK build_start unixbench-${VERSION}-installed

TEMPFILE=`mktemp`
LINECOUNT=`wc -l $0 | awk '{print $1}'`
CSTART=`grep -n "BEGIN PATCH FILE" $0 | tail -1 | awk -F : '{print $1}'`
tail -$(($LINECOUNT-$CSTART)) $0 | grep -v "^###" > $TEMPFILE.patch

cat $TEMPFILE.patch | patch -p1
RETVAL=$?
rm $TEMPFILE $TEMPFILE.patch
if [ $RETVAL -ne 0 ]; then
	exit $SHELLPACK_ERROR
fi

###SHELLPACK make

echo unixbench installed successfully
exit $SHELLPACK_SUCCESS

==== BEGIN PATCH FILE ====
diff --git a/Run b/Run
index d615935..7322003 100755
--- a/Run
+++ b/Run
@@ -106,7 +106,7 @@ my $TESTDIR = getDir('UB_TESTDIR', $BASEDIR . "/testdir");
 
 # Configure the categories to which tests can belong.
 my $testCats = {
-    'system'    => { 'name' => "System Benchmarks", 'maxCopies' => 16 },
+    'system'    => { 'name' => "System Benchmarks", 'maxCopies' => 0 },
     '2d'        => { 'name' => "2D Graphics Benchmarks", 'maxCopies' => 1 },
     '3d'        => { 'name' => "3D Graphics Benchmarks", 'maxCopies' => 1 },
     'misc'      => { 'name' => "Non-Index Benchmarks", 'maxCopies' => 16 },
@@ -1329,7 +1329,7 @@ sub runTests {
         # If the benchmark doesn't want to run with this many copies, skip it.
         my $cat = $params->{'cat'};
         my $maxCopies = $testCats->{$cat}{'maxCopies'};
-        next if ($copies > $maxCopies);
+        next if ($maxCopies > 0 && $copies > $maxCopies);
 
         # Run the benchmark.
         my $bresult = runBenchmark($bench, $params, $verbose, $logFile, $copies);
