#!/bin/sh

. ./hw_vars

if [ "$SwapTotal" -eq 0 ]; then
	echo "No swap space. Please setup swap before running $0" >&2
	exit 1
fi

[ -n "$unit_size" ] || unit_size=$(( ((MemAvailable + SwapTotal) << 10) * 3 / 4))

testcase=$(basename $0)
if [ "${testcase%-mt}" != "$testcase" ]; then
	multi_task_option="-t"
else
	multi_task_option="-n"
fi

if [ "${testcase#*-rand}" != "$testcase" ]; then
	rand_seq_option="--random"
else
	rand_seq_option=""
fi

if [ "${testcase#*-r-}" != "$testcase" ]; then
	rw_option="--open-rw --touch-alloc --readonly"
else
	rw_option=""
fi

$USEMEM $multi_task_option $nr_task $rand_seq_option $rw_option $((unit_size / nr_task))
