ref: 1924e3b013b733435f33bbe47c78eea8cc052747
dir: /test/
#!/bin/rc fn fail{ >[1=2] echo $1 >[1=2]; exit $1 } ~ $1 '' || addr=$1 ~ $addr '' && { usage 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 127.0.0.1' >ctl || fail 'Could not write client ctl' y=`{grep connect ctl} ~ $y(2) 127.0.0.1 || 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 '^$addr >ctl || fail 'Could not connect to server' <>data >[1=0] { ~ `{wc -c info} 0 && fail 'Did not receive RIDE info' cat >/dev/null || fail 'Did not receive initial message' echo -n '["Execute",{"text":"⍳5\n","trace":0}]' || fail 'Could not send message' res='["AppendSessionOutput",{"result":"⍳5\n","type":14,"group":0}]' ~ `{cat} $res || fail 'Did not receive response' } cd .. } <clone { cd `{read} echo 'connect '^$addr >ctl >data { msg='["Execute",{"text":"⍳5\n","trace":0}]' echo -n $msg || fail 'Could not send message' } & tpid=$apid <data { cat >/dev/null || fail 'Could not receive message' } & rpid=$apid wait $tpid || fail $status wait $rpid || fail $status }