#/bin/csh
# @OPENGROUP_COPYRIGHT@
# COPYRIGHT NOTICE
# Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
# Copyright (c) 1996, 1997, 1998, 1999, 2000 The Open Group
# ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
# the full copyright text.
# 
# This software is subject to an open license. It may only be
# used on, with or for operating systems which are themselves open
# source systems. You must contact The Open Group for a license
# allowing distribution and sublicensing of this software on, with,
# or for operating systems which are not Open Source programs.
# 
# See http://www.opengroup.org/openmotif/license for full
# details of the license agreement. Any use, reproduction, or
# distribution of the program constitutes recipient's acceptance of
# this agreement.
# 
# EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
# PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
# WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
# OR FITNESS FOR A PARTICULAR PURPOSE
# 
# EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
# NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
# EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGES.
#
# HISTORY


#run validator into a listing file
#assumes you are running in ./tests/uil/validator and that uil
#compiler is build and located at ../../../../clients/uil/uil

if !(-e ../../../../clients/uil/uil) then
   echo "***ERROR!***"
   echo "Your uil compiler is missing."
   echo "Please build it in ../../../../clients/uil."
   exit (1)
endif

if !(-x ../../../../clients/uil/uil) then
   echo "***ERROR!***"
   echo "Your uil compiler is not executable."
   echo "Please change its permissions."
   exit (1)
endif

echo "Uil compiler in place at ../../../../clients/uil/uil."

if !(-w .) then
   echo "***ERROR!***"
   echo "This directory is unwriteable."
   echo "Please change the permissions."
   exit (1)
endif

#cleanup if need be
if (-e validator.uid) then
   rm validator.uid
endif
if (-e run.log) then
   rm run.log
endif
if (-e run.out) then
   rm run.out
endif
if (-e run.diff) then
   rm run.diff
endif

echo "Beginning test..."

../../../../clients/uil/uil -o validator.uid validator.uil -v run.out

set postCompileStatus = $status

#remove the Page/date headers which show up in every diff
#and other stuff which makes maintenance tedious

sed -e '/Page/d' -e '/^Module/d' -e 's///g' -e '/^$/d' -e 's/^ *[0-9]* *//'  run.out | sed -e '/(0)[ 	]*$/d' > run.log
diff -c validator.log run.log > run.diff

set diffStatus = $status

#report results
clear
echo " "
echo "*************RESULTS*************"
echo "***PART I: Exit Status***********"
echo "   PostCompileStatus expected is 1, actual is" $postCompileStatus
if ($postCompileStatus == 1) then
echo "   Part I PASSES"
else
echo "   Part I FAILS"
endif
if ($postCompileStatus > 4) then
echo "The status indicates a severe failure."
endif
echo "  "
echo "***PART II: Log Comparison*******"
if ($diffStatus == 0) then
   echo "   The run and source files are the same."
   echo "   Part II PASSES."
   echo "  "
else
   echo "   The run and source files are different."
   echo "   To determine the extent of the failure, check the differences"
   echo "     between run.log and validator.log, as shown in run.diff."
   echo "   It is possible that spurious file differences may have caused"
   echo "     the failure."
   echo "   In evaluating the results, remember each valid entry in validator.uil"
   echo "     should be compiled without error, and each INVALID entry should"
   echo "     have an error generated."
   echo "   Part II FAILS"
   echo " "
endif
echo "*************END OF TEST*********"
echo "   "
