#!/bin/sh
# - iterations

. $LKP_SRC/lib/unit.sh
. $LKP_SRC/lib/reproduce-log.sh

cd $BENCHMARK_ROOT/stutter || die "no $BENCHMARK_ROOT/stutter"

set_memtotal_bytes()
{
	local default_memory_bytes=$(to_byte "8G")
	local memory_bytes=$(to_byte $memory)
	# limit the memory to speed up the test
	if [ $memory_bytes -gt $default_memory_bytes ]; then
		memory_bytes=$default_memory_bytes
	fi
	log_eval export MEMTOTAL_BYTES=$memory_bytes
}

set_memtotal_bytes

log_eval export ITERATIONS=$iterations
log_eval export LOGDIR_RESULTS=$RESULT_ROOT/log_result

log_cmd mkdir -p $LOGDIR_RESULTS

[ -z "$mount_points" ] && exit
log_eval export TESTDISK_DIR="${mount_points%% *}"

log_cmd ./run.sh

# This case reuqires disk_size > (system memory * 2 * 2), but it seems lkp has
# not an existed filter to handle it, so here is to check whether there is a
# 'No space left on device' error
grep 'No space left on device' $LOGDIR_RESULTS/*.log && ret=1

if [ $ret -ne 0 ]; then
	echo "stutter: fail"
else
	echo "stutter: pass"
fi
