#!/bin/bash
# A helper script that will ultimately fragment memory as part of a test
DIRNAME=`dirname $0`
export SCRIPTDIR=`cd "$DIRNAME" && pwd`
export MMTESTS_ROOT=$SCRIPTDIR/../../../../
. $MMTESTS_ROOT/shellpacks/common.sh
. $MMTESTS_ROOT/shellpacks/addon-setenv
SCRATCH=$SHELLPACK_DATA/fragment
mkdir -p $SCRATCH

COMMAND=$1
shift

# Global options must be specified first. All others are passed to the
# submodules
OTHER=
while [ $# -ge 1 ]; do
	case $1 in
	--method)
		METHOD=$2
		shift 2
		;;
	*)
		break
	esac
done

if [ "$METHOD" = "" ]; then
	die "Method must be specified with --method"
fi

if [ ! -e $SCRIPTDIR/../lib/$METHOD ]; then
	die "Method $METHOD does not exist in lib directory"
fi

. $SCRIPTDIR/../lib/$METHOD
