#! /bin/sh

#
# CONFIGURATION SECTION
#
if [ -z "$PIC30_CD" ]; then
    echo "Environmental variable PIC30_CD must be set up.";
    exit 1;
fi

SCRIPT_PATH=$PIC30_CD/support/gld

#
# END CONFIGURATION
#

# process args
vflag=off
while [ $# -gt 0 ]
do
    case "$1" in
        -v)  vflag=on;;
    esac
    shift
done

grep -e "^  data .*ORIGIN.*LENGTH" $SCRIPT_PATH/p30f6010.gld > test.out
grep -e "^  data .*ORIGIN.*LENGTH" $SCRIPT_PATH/p30f6012.gld >> test.out
grep -e "^  data .*ORIGIN.*LENGTH" $SCRIPT_PATH/p30f6014.gld >> test.out

echo
echo `head -1 info.txt`

if [ $vflag = "on" ]; then
    diff -b -B test.out expect.out
else
    diff -b -B test.out expect.out > /dev/null
fi

if [ $? -ne 0 ]; then
    echo "ERRORs Detected!!"
    echo
    exit 199
fi

echo "All Tests Pass"
echo
exit 0
