code: mafs

ref: eef0fe67ee4bb8c254f0f9e61c24ef5d34d05a4f
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 {
	test=$1
	debug=$"2
	echo 'service='^$test
	service=$test
	echo 'disk='^$service^/disk
	disk=$service^/disk
	echo 'debug='^$debug

	nblocks=()
	. $service^/params

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

	# start service
	if(~ $"debug '')
		mount -c <{disk/mafs -s -r mafs_^$service -h 10 $disk <[0=1]} /n/mafs_^$service
	if not # TODO below breaks auth negotiation. Something is writing to fd 1.
		mount -c <{disk/mafs $"debug -s -r mafs_^$service -h 10 $disk <[0=1]} /n/mafs_^$service
	echo service status: $status

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

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

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

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

	nblocks=()
	. $service^/params

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

	# start service
	if(~ $"debug '')
		disk/mafs -r mafs_^$service -h 10 $disk
	if not
		disk/mafs $"debug -r mafs_^$service -h 10 $disk
	echo service status: $status

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

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

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

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

if(~ $#* 0){
	chkreli.rc
	chkextents.rc
	for (t in test.*){
		rununi $t
		runmp $t
	}
}
if not {
	if(~ $"* reli){
		chkreli.rc
	}
	if(~ $"* extents){
		chkextents.rc
	}
	if not {
		rununi $*
		runmp $*
	}
}