code: mafs

ref: 56bd332994102b4e194819abb5e087a8895452f9
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 -s -r $test $disk <[0=1]} /n/^$service
	if not # if auth negotiation breaks, something is writing to fd 1.
		mount -c <{disk/^$cmd $"debug -s -r $test $disk <[0=1]} /n/^$service
	echo service status: $status

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

	# 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 -r $test -h 10 $disk
	if not
		disk/^$cmd $"debug -r $test -h 10 $disk
	echo service status: $status

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

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

	# 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
	for (t in test.*){
#		rununi mfs $t
		rununi mafs $t
#		runmp mfs $t
#		runmp mafs $t
	}
}
if not {
	if(~ $"* reli){
		chkreli.rc
	}
	if(~ $"* extents){
		chkextents.rc
	}
	if not {
#		rununi mfs $*
		rununi mafs $*
#		runmp mfs $*
#		runmp mafs $*
	}
}