shithub: ridefs

ref: 4626f9b20df8a86229a58a196eacd645e10ca690
dir: /test/

View raw version
#!/bin/rc

fn fail{ >[1=2] echo $1 >[1=2]; exit $1 }

argv0=$0
~ $rideaddr '' && {
	fail 'missing server address argument'
}

./6.out $* ||
	fail 'Crashed at startup'

cd /mnt/ride ||
	fail 'Not mounted'

ls . >/dev/null ||
	fail 'Mountpoint not readable'

cat ctl >/dev/null ||
	fail 'Could not read ctl'

x=`{grep debug ctl}
echo 'debug 1' >ctl ||
	fail 'Could not write ctl'

y=`{grep debug ctl}
~ $y(2) 1 ||
	fail 'Written and read ctl values differ'
echo debug $x(2) >ctl

cat clone >/dev/null ||
	fail 'Could not clone'

<clone {
	cd `{read} ||
		fail 'Could not cd to client'

	cat ctl >/dev/null ||
		fail 'Could not read client ctl'

	x=`{grep connect ctl}
	echo 'connect localhost' >ctl ||
		fail 'Could not write client ctl'
	y=`{grep connect ctl}
	~ $y(2) localhost ||
		fail 'Written and read client ctl values differ'
	echo umask $x(2) >ctl

	cd .. ||
		fail 'Could not cd out of client directory'
}

n=`{read clone}
ls -d $n >[2]/dev/null &&
	fail 'Did not clean up closed client'

<clone {
	cd `{read}
	echo 'connect '^$rideaddr >ctl

	echo >text ||
		fail 'Could not connect to server'

	>text {
		~ `{wc -c info} 0 &&
			fail 'Did not receive RIDE info'

		# expect events: prompt > response > prompt
		# XXX: >/dev/null and >/fd/1 mysteriously effect different text
		<event for(n in 0 1 2) x=`{read} & evpid=$apid
		echo '⍳5' ||
			fail 'Could not send message'

		wait $evpid
		tx='      ⍳5
0 1 2 3 4
      '
		~ `''{cat text} $tx ||
			fail 'Did not receive expected response'
	}
	cd ..
}