#!/bin/csh

# Shut down the daemons
@ i = 0
foreach DEVICE (`cat /usr/tmp/TARGETS`)
    killall drand."$i" >& /dev/null
    @ i++
end
killall sio        >& /dev/null

# Parse and check the output files
foreach DEVICE (`cat /usr/tmp/TARGETS`)
   @ drerr = 0
   foreach errpattern (expected block DMA)
        cd /usr/tmp
        set Q = `grep $errpattern $DEVICE.ostest.out | wc | awk '{print $1}'`
        if ($Q != 0) then
            @ drerr = 1
        endif
   end
   if ($drerr != 0) then
        echo ERROR - diskrand $DEVICE failed `date`|tee -a /usr/tmp/diskrand.log        cat $DEVICE.ostest.out
        cp $DEVICE.ostest.out $DEVICE.ostest.bad
   endif
end
rm /usr/tmp/*.ostest.out >& /dev/null
rm /usr/tmp/*ostest >& /dev/null
rm /usr/tmp/drand.* >& /dev/null
rm /usr/tmp/TARGETS >& /dev/null

# Shut down the port blasters
killall blast
