#!/bin/bash # $HeadURL$ $LastChangedRevision$ PROGNAME=`basename $0` SANDPIT=`pwd` . $(ade-config ade_share_prefix)/include/adetestsupport.sh strip_variant_output() { sed -e "s@$SANDPIT/root/[0-9][0-9]*@BLANKED_BY_$PROGNAME@" } # WARNING: much of this code is reproduced in another test of fadscan. echo "creating base directories ..." mkdir $SANDPIT/{root,scans,elsewhere,etc,state,log} # Run test for ten seconds (should be enough time to trigger error) TEST_DURATION=10 END_TIME=$(($(date '+%s') + $TEST_DURATION)) echo "starting scan loop in background ..." { I=0 while [ $(date '+%s') -lt $END_TIME ]; do #echo "S: $I" find $SANDPIT/root | fadscan --log-dir=$SANDPIT/log --state-dir=$SANDPIT/state -i test - || true I=$(($I + 1)) # Normally we would say '| sort -u' to verify that at least one message appeared, but # we expect this message several times, so we use 'head -3' instead. done 2>&1 | strip_variant_output | head -3 # Can't report end of loop 'cos can't guarantee this loop finishes before the other one. #echo "done scanning loop" } & KILL_PIDS="$KILL_PIDS $!" echo "starting fiddling loop in background ..." { # make the removal of $OLD_I work touch $SANDPIT/root/0 OLD_I=0 I=1 while [ $(date '+%s') -lt $END_TIME ]; do #echo "F: $I" touch $SANDPIT/root/$I rm -f $SANDPIT/root/$OLD_I OLD_I=$I I=$(($I + 1)) done # clean up leftovers rm -f $SANDPIT/root/$I # Can't report end of loop 'cos can't guarantee this loop finishes before the other one. #echo "done fiddling loop" } & KILL_PIDS="$KILL_PIDS $!" # Ensure if user kills us that the backgrounded processes don't hang around and # start outputting shell-init errors 'cos their $PWD disappeared. trap "kill $KILL_PIDS; wait" 2 wait echo "all done"