#! /bin/tcsh
#
# Test script for CSC 357 program 4, Winter 2007.
#


#
# Create output, expected-output, and diffs dirs if necessary.
#
if (! -e output) then
    mkdir output
endif

if (! -e expected-output) then
    mkdir expected-output
endif

if (! -e diffs) then
    mkdir diffs
endif


#
# Dynamically generate expected output by running UNIX find.
#
./run-find.csh /bin/find expected-output


#
# Run ./sfind.
#
./run-find.csh ./sfind output


#
# Compare results.
#
foreach f (expected-output/*)
    set g = $f:t
    if (! -e output/$g) then
	echo "sfind produced no output for $f"
    else
	diff output/$g $f > diffs/$g:r.diff
	if (-z diffs/$g:r.diff) then
	    rm diffs/$g:r.diff
	else
	    echo "sfind output/$g differs from $f"
	endif
    endif
end
