#!/bin/rc # # Exec2fs Regression # echo '== Exec2fs Regression ==' # # Parameters # O=8. CMD=../$O #TESTDIR=.test/exec2fs TESTDIR=/tmp/testbed/exec2fs EXECLOG=$TESTDIR/exec2fs.log MPIPELOG=$TESTDIR/mpipefs.log ERRORLOG=$TESTDIR/error.log E_MNTPATH=$TESTDIR/E #M_MNTPATH=$TESTDIR/M M_MNTPATH=$E_MNTPATH # # Cleanup Previous Instances # fn cleanup { echo Cleaning up previous runs. rm -f $E_MNTPATH $M_MNTPATH rm -rf $TESTDIR } fn shutdown { echo Shutting down previous runs. # FIXME: should there be multiple mpipes? unmount /n/mpipetest > /dev/null >[2] /dev/null unmount $E_MNTPATH > /dev/null >[2] /dev/null unmount $M_MNTPATH > /dev/null >[2] /dev/null rm -f /srv/mpipe rm -f /srv/exec2fs rm -f /n/mpipetest unmount /proc > /dev/null >[2] /dev/null bind '#p' /proc } # # Startup mpipefs # fn startup_mpipe { echo Starting mpipefs.... if(~ $#* 0) { $CMD^mpipefs >[2] $MPIPELOG # $M_MNTPATH } if not { $CMD^mpipefs -v $1 >[2] $MPIPELOG # CHATTY } } # # Startup exec2fs # fn startup_exec2fs { echo Starting exec2fs. if(~ $#* 0) { $CMD^exec2fs -s exec2fs -E $CMD^execcmd -m $E_MNTPATH -L $TESTDIR -Z $M_MNTPATH >[2] $EXECLOG } if not { $CMD^exec2fs -v $1 -s exec2fs -E $CMD^execcmd -m $E_MNTPATH -L $TESTDIR -Z $M_MNTPATH >[2] $EXECLOG # CHATTY } } fn startup { startup_exec2fs $1 startup_mpipe $1 bind -bc . /$objtype/bin bind -bc .. /$objtype/bin } # Setup a test directory # fn testdir { mkdir -p $TESTDIR mkdir -p $E_MNTPATH $M_MNTPATH } fn myexecstdin { mypid=`{cat} #` echo -n exec /bin/cat >>[2] exec2fs.log >>[2] $ERRORLOG cat $TESTDIR/test > $M_MNTPATH/$mypid/stdin >>[2] $ERRORLOG cat $M_MNTPATH/$mypid/stdout > $TESTDIR/test1 >>[2] $ERRORLOG } fn myexecstdout { mypid=`{cat} #` echo -n exec /bin/cat $TESTDIR/test >>[2] $ERRORLOG cat $M_MNTPATH/$mypid/stdout > $TESTDIR/test1 >>[2] $ERRORLOG } fn stdout { echo -n Stdout Test.... # initialize files echo Hello Squidboy > $TESTDIR/test echo > $TESTDIR/test1 # execute test myexecstdout <>$E_MNTPATH/clone >[1=0] # verify results if(! cmp -s $TESTDIR/test $TESTDIR/test1) { echo FAILED! exit 'stdout: test failed' } echo Success! } fn stdin { echo -n Stdin Test.... # initialize files echo Hello Squidboy > $TESTDIR/test echo > $TESTDIR/test1 # execute test myexecstdin <>$E_MNTPATH/clone >[1=0] # verify results if(! cmp -s $TESTDIR/test $TESTDIR/test1) { echo FAILED! exit 'stdout: test failed' } echo Success! } # Setup rfork cleanup shutdown testdir startup $1 # Tests -- do it several times to verify that it does not die as before stdin stdout stdin stdout stdin stdout stdin stdout shutdown #cleanup