code: mafs

ref: fb53d7e68bcb2108fb304c81dccb1d7ff50ffa1f
dir: /tests/regress.rc/

View raw version
#!/bin/rc

# tests
# check the contents of the blocks

# cd /mnt/term/home/j/local/plan9/custom/mafs/tests
# watch -e '\.[chsy]$' -e '\.rc' -e mkfile 'mk all tests'
# regress.rc test.2 -DDDDD # for running mafs with debug flags

fn rununi {
	cmd=$1
	test=$2
	debug=$"3
	echo 'cmd='^$cmd
	echo 'service='^$cmd^'_'^$test
	service=$cmd^'_'^$test
	echo 'disk='^$test^/disk
	disk=$test^/disk
	echo 'debug='^$debug

	nblocks=()
	. $test^/params

	# setup the service
	test -f $test^/setup.rc && $test^/setup.rc $disk $nblocks

	# start service
	if(~ $"debug '')
		mount -c <{disk/^$cmd $cmdparams -s -r $test $disk <[0=1]} /n/^$service
	if not # if auth negotiation breaks, something is writing to fd 1.
		mount -c <{disk/^$cmd $cmdparams $"debug -s -r $test $disk <[0=1]} /n/^$service
	echo service status: $status

	sleep 1
	test -f $test^/action.rc && $test^/action.rc $service $disk

	# tear it down
	test -f /n/^$service^/adm/ctl && {
		echo halt >> /n/^$service^/adm/ctl
	}
	unmount /n/^$service
	test -f /srv/^$test && rm /srv/^$test

	sleep 1
	test -f $test^/check.rc &&
		$test^/check.rc $test $disk $nblocks ||
		check.rc $test $disk $nblocks
}

fn runmp {
	cmd=$1
	test=$2
	debug=$"3
	echo 'cmd='^$cmd
	echo 'service='^$cmd^'_'^$test
	service=$cmd^'_'^$test
	echo 'disk='^$test^/disk
	disk=$test^/disk
	echo 'debug='^$debug

	nblocks=()
	. $test^/params

	# setup the service
	test -f $test^/setup.rc && $test^/setup.rc $disk $nblocks

	# start service
	if(~ $"debug '')
		disk/^$cmd $cmdparams -r $test $disk
	if not
		disk/^$cmd $cmdparams $"debug -r $test $disk
	echo service status: $status

	mount -c /srv/^$test /n/^$service

	sleep 1
	test -f $test^/action.rc && $test^/action.rc $service $disk

	# tear it down
	test -f /n/^$service^/adm/ctl && {
		echo halt >> /n/^$service^/adm/ctl
	}
	unmount /n/^$service
	test -f /srv/^$test && rm /srv/^$test

	sleep 1
	test -f $test^/check.rc &&
		$test^/check.rc $test $disk $nblocks ||
		check.rc $test $disk $nblocks
}

if(~ $#* 0){
	chkreli.rc
	chkextents.rc
	chkflush.rc
	chknlastdatablocks.rc
	for (t in test.*){
		rununi mafs $t
		runmp mafs $t
	}
}
if not {
	rununi mafs $*
	runmp mafs $*
}