#!/bin/sh

rm -rf localhost:8000
wget -q -r http://localhost:8000
# Give yaws some time to write out its report.log file
count=10
while [ $count -gt 0 ]; do
    if [ ! -f logs/report.log ]; then
        sleep 3
    else
        # log file written, now check it
        # count lines to work around grep exit status portability issues
        total=`cat logs/report.log | grep -v www/arg.yaws | \
            grep -v www/arg2.yaws | grep -v ^=ERROR | grep ERROR 2>&1 | wc -l`
        [ "$total" -eq 0 ] || exit 1
    fi
    count=`expr $count - 1`
done
exit 0
