pkill -9 a.out

for k in {0..10000}; do
	for i in {0..10}; do
		for j in {0..3}; do
			./a.out 1 file_${i} &
		done
	done
	sleep 1
	COUNT=0
	while [ $COUNT -eq 0 ]; do
		lctl set_param debug=0; lctl set_param debug=+dlmtrace; lctl set_param debug_mb=4000; lctl clear
		echo 1 > /proc/fs/lustre/ldlm/dump_namespaces ; lctl dk > /tmp/namespaces
		COUNT=`grep GROUP /tmp/namespaces | grep resource_dump | wc -l`
		echo count: $COUNT
		sleep 0.5
	done
	#COUNT=`expr $COUNT + 1`
	TEST=`expr $i + 1`
	echo $TEST
	if [ $COUNT -ne $TEST ]; then
		echo "count != expected, expected" `expr $i + 1`
		echo "remember to do pkill -9 a.out, processes are still running"
		exit
	fi
#echo "press enter to kill and start over"
#read
pkill -9 a.out
done
