shithub: ridefs

ref: 51e6ec12a2616a08679546084131f3f080168c4f
dir: /test/

View raw version
#!/bin/rc

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

./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'

ot=`{grep timeout ctl}
echo 'timeout 5000' >ctl ||
	fail 'Could not write ctl'

nt=`{grep timeout ctl}
~ $nt(2) 5000 ||
	fail 'Written and read ctl values differ'
echo timeout $ot(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'

	ot=`{grep timeout ctl}
	echo 'timeout 5000' >ctl ||
		fail 'Could not write client ctl'

	nt=`{grep timeout ctl}
	~ $nt(2) 5000 ||
		fail 'Written and read client ctl values differ'
	echo timeout $ot(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 192.168.11.17' >ctl ||
		fail 'Could not connect to server'

	<>io >[1=0] {
		~ `{wc -c rinfo} 0 &&
			fail 'Did not receive RIDE info'

		echo '["Execute",{"text":"      ⍳5\n","trace":0}]' ||
			fail 'Could not write message'
	}
	cd ..
}