#!/bin/sh

domainname="`hostname -d 2>/dev/null`"
if [ "$domainname" = "" ]; then
        echo "retr_hostname: domain name query failed, you may have trouble running tests." 1>&2
fi

echo "Normalizing hostname in preparation for comparison"
outputname=${1}.out

cat $outputname |

sed -e 's@^.*newtape -c .*--@@' |
sed -e 's@^\(.*INDEX_\)'"$domainname"'\(_.*\)$@\1linux\.com\2@' |
sed -e 's@^\(SHAK_DOMAIN *:\).*$@\1linux.com@' |
sed -e 's@^\(SHAK_TAPEHOST *:\).*$@\1Penguin7@' |
sed -e 's@^\(00..:[^ ]* [^ ]* [^ ]* [^ ]* [^ ]*UTC. \)[^ ]*\( .*\)$@\1Penguin7\2@' |
sed -e 's@^\(shak.diff:latestheader:File [1-9].*__SHAK__.*__SHAK__[^:]*:[^:]*:\)[^ :]*:\(.*\)@\1'"Penguin7:"'\2@' |
sed -e 's@^\(--- START\).*@\1 date@' | sed -e 's@^\(--- FINISH\).*@\1 date@' |
sed -e 's@^\(File [1-9].*__SHAK__.*__SHAK__[^:]*:[^:]*:\)[^ :]*:\(.*\)@\1'"Penguin7:"'\2@' >${outputname}.norm
echo "*************** testtape output below ********************" >>${outputname}.norm
cat var/testtape-out.* >>${outputname}.norm


echo "If comparison is silent, no differences were found and"
echo "the tests will have passed."
echo "Comparing  test.baseline to ${outputname}.norm" 
sed -e 's@^.*newtape -c .*--@@' test.baseline | diff - ${outputname}.norm


