58 lines
858 B
Plaintext
58 lines
858 B
Plaintext
|
#!/usr/bin/env rc
|
||
|
# poor man portable expect
|
||
|
|
||
|
QPROMPT='10.0.2.15# '
|
||
|
INFILE=/tmp/runqemu.$pid.in
|
||
|
OUTFILE=/tmp/runqemu.$pid.out
|
||
|
|
||
|
cd $JEHANNE/arch/amd64/kern
|
||
|
echo -n > $INFILE
|
||
|
echo -n > $OUTFILE
|
||
|
|
||
|
@{tail -f $INFILE | $JEHANNE/hacking/QA.sh >> $OUTFILE} &
|
||
|
QPID=$apid
|
||
|
|
||
|
tail -f $OUTFILE &
|
||
|
TPID=$apid
|
||
|
|
||
|
ifs='
|
||
|
'
|
||
|
INPUT=`{cat}
|
||
|
|
||
|
fn descendants {
|
||
|
if( ! ~ 0 $#1 ) {
|
||
|
echo $1;
|
||
|
ps -o pid= --ppid $1|xargs -n 1 rc -c 'descendants $1'
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fn quit {
|
||
|
kill -2 `{descendants $QPID}
|
||
|
kill -2 $TPID
|
||
|
wait
|
||
|
rm $INFILE
|
||
|
rm $OUTFILE
|
||
|
exit $1
|
||
|
}
|
||
|
|
||
|
fn failOnError {
|
||
|
if( ! ~ 0 `{cat $OUTFILE | grep FAIL | wc -c}){
|
||
|
quit 1
|
||
|
}
|
||
|
}
|
||
|
|
||
|
for(cmd in $INPUT){
|
||
|
while( ~ 0 `{tail -n 1 $OUTFILE | sed -n '/'$QPROMPT'/p' | wc -c}){
|
||
|
sleep 2
|
||
|
}
|
||
|
failOnError
|
||
|
echo $cmd >> $INFILE
|
||
|
sleep 2
|
||
|
}
|
||
|
|
||
|
while( ~ 0 `{tail -n 1 $OUTFILE | sed -n '/'$QPROMPT'/p' | wc -c}){
|
||
|
sleep 2
|
||
|
}
|
||
|
failOnError
|
||
|
quit
|