1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#! /bin/bash
declare -i TESTS=0
declare -i ERRORS=0
for TEST in *; do
if [ -d $TEST ]; then
[[ -f $TEST/forbidden ]] && if [ "$(egrep -f $TEST/regexps $TEST/forbidden | wc -l)" != "$(wc -l < $TEST/forbidden)" ]; then
echo "$TEST failed to match all forbidden cases"
ERRORS+=1
fi
[[ -f $TEST/allowed ]] && if [ "$(egrep -f $TEST/regexps $TEST/allowed | wc -l)" != "0" ]; then
echo "$TEST detected an allowed case as forbidden"
ERRORS+=1
fi
TESTS+=1
fi
done
if [ $ERRORS == 0 ]; then
echo "All $TESTS rules passed their tests"
else
echo "$ERRORS errors were found during the rule tests"
fi
exit $ERRORS
|