#!/bin/bash
#
# Test suite for lgc
#
# To execute: cd to the directory containing this file, then write ./test
#
# The test suite creates a temporary directory named 
# /tmp/lgc.test.XXXXXXXXXX (with the X's replaced by random characters)
#
# After successful completion, the temporary directory is deleted.
# In case of errors, the temporary directory must be deleted manually
#
# When developing new tests it may be useful to work in a specific rather
# than a random directory. To do so, create a directory named
# /tmp/lgc.test. Then the test suite uses that directory and does
# not delete it on successful completion.
#
# The test is divided in a number of classes:
#
# Many error messages occur during execution of the test suite.
# That is normal since, among other, it is the ability of lgc to catch
# errors which is tested.
#
# The test suite is successful if it ends writing
# "Testsuite succeeded"
#

# Untested messages:
# !"Could not unpack generated page"
# let P = if r tail then p else !"lgw:" :: lgc-string2mixed ( p )
# !"Malformed page found at " :: s [[ !"type" ]] :: !":" :: s [[ !"fetching" ]]
# !"Wrong page found at " :: s [[ !"type" ]] :: !":" :: s [[ !"fetching" ]]

DIV=--------------------------------------------------------------
echo
echo Test of lgc
echo
echo $DIV
DIR=/tmp/lgc.test
if [ -d $DIR ]
then
  echo "$DIR exists. Using that directory."
else
  DIR=`mktemp -d /tmp/lgc.test.XXXXXXXXXX` || exit 1
  echo Temporary directory: $DIR
fi

LGW_PATH="${DIR}/logiweb/:/page.lgr"
LGWAM0="env LGW_PATH=${LGW_PATH} ${PWD}/../lgwam"
LGWAM1="${LGWAM0} script"
LGC="${LGWAM1} ${PWD}/../lgc"
LGC0="$LGC -s conf/site.conf -r $DIR/logiweb/: -l $DIR/name/: +l $DIR/name/latest"
LGC1="$LGC0 --path --namepath"
LGC2="env HOME=$DIR $LGC -s conf/site.conf -r ~/logiweb/: -l ~/name/: -p ~/logiweb/:/vector.lgw -n ~/name/:/vector.lgw"
LGC3="$LGC0 -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/rack.lgr"

LGW_PATHX="${DIR}/logiweb/:/rack.lgr"
LGWAMX0="env LGW_PATH=${LGW_PATHX} ${PWD}/../lgwam"
LGWAMX1="${LGWAMX0} script"
LGCX="${LGWAMX1} $DIR/name/lgc/page/bin/lgc"
LGCX0="$LGCX -s conf/site.conf -r $DIR/logiwebx/: -l $DIR/namex/: +l $DIR/namex/latest"
LGCX3="$LGCX0 -n $DIR/namex/:/vector.lgw -p $DIR/logiwebx/:/rack.lgr"

#LGCY0="$LGCX -s conf/site.conf -r $DIR/logiweby/: -l $DIR/namey/:"
#LGCY0="$LGC -s conf/site.conf -r $DIR/logiweby/: -l $DIR/namey/:"
#LGCY1="$LGCY0 -n $DIR/nowhere/:/rack.lgr -p $DIR/nowhere/:/rack.lgr"

#LGCY1="$LGCY0 -n $DIR/namex/:/rack.lgr ++n $DIR/namex/:/vector.lgw"
#LGCY3="$LGCY1 -p $DIR/logiwebx/:/rack.lgr ++p $DIR/logiwebx/:/vector.lgw"



#--------------------------------------------------------------
# NEW TESTS (TESTS UNDER TEST)
#--------------------------------------------------------------



if (( 0 ))
then
echo $DIV
echo "New tests"
mkdir -p $DIR/stdout
mkdir -p $DIR/home



echo $DIV
if [ -d /tmp/lgc.test ]
then
  echo "Remove /tmp/lgc.test manually"
else
  echo Removing $DIR
  rm -r $DIR
fi
echo $DIV
echo
echo "New tests done"
echo
exit 0
fi



#--------------------------------------------------------------
# ORDINARY TESTS
#--------------------------------------------------------------



rm -r -f $DIR/*
mkdir -p $DIR/stdout
mkdir -p $DIR/home



echo $DIV
echo "lgwam test"
../lgwam test || exit 1



echo $DIV
TST=nosource
echo $TST
$LGC0 | tee $DIR/stdout/$TST
grep -F -e 'No source file specified' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=help1
echo $TST
$LGC0 -h | tee $DIR/stdout/$TST
grep -F -e '--verbose    or  -v     Set verbosity' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '--path++x    or ++p x   Add x at end of path' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=help2
echo $TST
${LGC} --help | tee $DIR/stdout/$TST
grep -F -e '--verbose    or  -v     Set verbosity' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '--path++x    or ++p x   Add x at end of path' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=help3
echo $TST
$LGC0 -h yes | tee $DIR/stdout/$TST
grep -F -e '--verbose    or  -v     Set verbosity' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '--path++x    or ++p x   Add x at end of path' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=help4
echo $TST
${LGC} --help=yes | tee $DIR/stdout/$TST
grep -F -e '--verbose    or  -v     Set verbosity' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '--path++x    or ++p x   Add x at end of path' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=help5
echo $TST
$LGC0 -h no | tee $DIR/stdout/$TST
grep -F -e 'No source file specified' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=help6
echo $TST
${LGC} --help=no | tee $DIR/stdout/$TST
grep -F -e 'No source file specified' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=help7
echo $TST
${LGC} --help2=yes | tee $DIR/stdout/$TST
grep -F -e '--version               Print version' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '--license               Print license' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=help8
echo $TST
${LGC} -H | tee $DIR/stdout/$TST
grep -F -e '--version               Print version' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '--license               Print license' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=version
echo $TST
$LGC0 --version | tee $DIR/stdout/$TST
grep -F -e 'Logiweb compiler (lgc) version ' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=license
echo $TST
$LGC0 --license | tee $DIR/stdout/$TST
grep -F -e 'This program is free software; you can redistribute it and/or modify' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'it under the terms of the GNU General Public License as published by' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=option1
echo $TST
$LGC0 -o siteconfig | tee $DIR/stdout/$TST
grep -F -e 'conf/site.conf' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=option2
echo $TST
$LGC0 --option=siteconfig | tee $DIR/stdout/$TST
grep -F -e 'conf/site.conf' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=option3
echo $TST
$LGC0 --option=license | tee $DIR/stdout/$TST
grep -F -e 'no' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=option4
echo $TST
$LGC -s conf/nopath -o path | tee $DIR/stdout/$TST
diff -q /dev/null      $DIR/stdout/$TST || exit 1



echo $DIV
TST=option5
echo $TST
$LGC -s conf/three -o path | tee $DIR/stdout/$TST
diff -q conf/three.txt $DIR/stdout/$TST || exit 1



echo $DIV
TST=options
echo $TST
$LGC0 --options | tee $DIR/stdout/$TST
grep -F -e '  GRD-1972-06-30+1' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=siteconfig
echo $TST
$LGC -s conf/site1.conf -o userconfig  | tee $DIR/stdout/$TST
grep -F -e 'conf/user1.conf' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=userconfig1
echo $TST
$LGC0 -s conf/site1.conf -o path  | tee $DIR/stdout/$TST
grep -F -e 'usercache/:/rack.lgr' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=userconfig2
echo $TST
$LGC0 -o verbose  | tee $DIR/stdout/$TST
grep -F -e '3' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=verbosity
echo $TST
$LGC0 -v a | tee $DIR/stdout/$TST
grep -F -e 'Invalid verbosity' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=leap1
echo $TST
$LGC0 --leap+GRD-2008-1a-31+1 | tee $DIR/stdout/$TST
grep -F -e 'Invalid leap: GRD-2008-1a-31+1' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=leap2
echo $TST
$LGC0 --leap+GRD-2008-12-31@1 | tee $DIR/stdout/$TST
grep -F -e 'Invalid leap: GRD-2008-12-31@1' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=leap3
echo $TST
$LGC0 --leap+GRD-2008-11-31+1 | tee $DIR/stdout/$TST
grep -F -e 'Leap seconds must be stated in descending order' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=nosuchfile
echo $TST
$LGC0 foo/bar | tee $DIR/stdout/$TST
grep -F -e 'Reading   file:foo/bar' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:foo/bar.lgs' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Source file not found' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=dc4
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 5 character 2:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Illegal character: 0x14' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'd|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=withext1
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 5 character 2:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Illegal character: 0x14' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'd|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=withext1.lgs
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 5 character 2:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Illegal character: 0x14' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'd|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=withext2
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 5 character 2:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Illegal character: 0x14' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'd|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=withext2.lgs
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 5 character 2:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Illegal character: 0x14' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'd|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=longend
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 2 character 4:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'End of file in long comment' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'def|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '""{ghi' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=stringend
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 2 character 4:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'End of file in string' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'def|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '"ghi' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=stringesc
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 2 character 7:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Unknown escape in string: 0x43' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'def"gh|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '""Ci"' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=stringendhex
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 2 character 7:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'End of string in hex code' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'def"gh|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '""x12"' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=stringeofhex
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 2 character 4:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'End of file in string' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'def|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '"gh""x12' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=stringinvhex
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 2 character 11:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Invalid character in hex constant' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'def"gh""x1|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'G."' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=stringinvhex1
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 2 character 10:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Invalid character in hex constant' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'def"gh""x|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'G1."' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=stringoddhex
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 2 character 7:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Odd number of digits in hex code' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'def"gh|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '""x1."' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=pagezero
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 1 character 1:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'No page name found' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=pagetwo
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 3 character 4:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'More than one page name found' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'ghi|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '""Pjkl' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=pageempty
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 1 character 4:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Empty page name' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'abc|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '""P  ""ndef' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=pageempty1
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 1 character 4:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Empty page name' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'abc|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '""P abc "  ""ndef' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=pageesc
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 1 character 8:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Unknown escape in page: 0x43' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'abc""Pa|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '""Cb' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=refempty
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 1 character 4:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Empty reference' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'abc|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '""R  ""ndef' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=refempty1
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 1 character 4:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Empty reference' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'abc|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '""R abc "  ""ndef' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=refesc
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 1 character 8:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Unknown escape in reference: 0x43' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'abc""Ra|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '""Cb' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=refesc1
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 1 character 8:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Unknown escape in reference: 0x21' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'abc""Ra|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '""!b"de' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=defesc
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 1 character 8:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Unknown escape in definition: 0x43' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'abc""Da|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '""Cb' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=defillegal
echo $TST
$LGC0 lex/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 2 character 1:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Construct must contain at least one proper character' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'abc""D 1.2.3' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=charge1
echo $TST
$LGC0 parse/$TST | tee $DIR/stdout/$TST
grep -F -e 'Malformed charge' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '""D|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e ' 0.2.a' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=charge2
echo $TST
$LGC0 parse/$TST | tee $DIR/stdout/$TST
grep -F -e 'Line 5 character 4:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Charge refers to ambiguous construct' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '""D|' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=nobinary
echo $TST
$LGC0 include/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 2 character 4:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Could not find include file nofile' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'def|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '""#nofile"ghi' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=notext
echo $TST
$LGC0 include/$TST | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 2 character 4:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Could not find include file nofile' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'def|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '""$nofile"ghi' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=readref1
echo $TST
$LGC1 -n :.lgo/rack.lgr load/refbase | tee $DIR/stdout/$TST
grep -F -e 'Reading   file:load/refbase' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Fetching  base' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Could not load reference base' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=readref2
echo $TST
$LGC1 -v 4 -n :.lgo/rack.lgr ++n :.lgr load/refbase | tee $DIR/stdout/$TST
grep -F -e 'Fetching  base' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:base.lgo/rack.lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:base.lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Could not load reference base' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=nocolon
echo $TST
$LGC1 -v 4 -n :.lgo/rack.lgr ++n .lgr load/refbase | tee $DIR/stdout/$TST
grep -F -e 'Fetching  base' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:base.lgo/rack.lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Missing colon in path or namepath element .lgr' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=suffix1
echo $TST
$LGC1 -v 4 -n :.lgo/rack.lgr ++n :.lgx load/refbase | tee $DIR/stdout/$TST
grep -F -e 'Fetching  base' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:base.lgo/rack.lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Illegal suffix in path or namepath element :.lgx' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Only .lgw, .lgr, and .lgu are legal suffixes' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=suffix2
echo $TST
$LGC1 -v 4 -n :.lgo/rack.lgr ++n :lgr load/refbase | tee $DIR/stdout/$TST
grep -F -e 'Fetching  base' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:base.lgo/rack.lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Illegal suffix in path or namepath element :lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Only .lgw, .lgr, and .lgu are legal suffixes' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=url1
echo $TST
$LGC1 -v 4 -n :.lgo/rack.lgr ++n http:dom/:.lgr load/refbase | tee $DIR/stdout/$TST
grep -F -e 'Fetching  base' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:base.lgo/rack.lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Malformed url: http:dom/base.lgr' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=url2
echo $TST
$LGC1 -v 4 -n :.lgo/rack.lgr ++n http:/dom/:.lgr load/refbase | tee $DIR/stdout/$TST
grep -F -e 'Fetching  base' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:base.lgo/rack.lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Malformed url: http:/dom/base.lgr' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=url3
echo $TST
$LGC1 -v 4 -n :.lgo/rack.lgr ++n http:/dom/:.lgr load/refbase | tee $DIR/stdout/$TST
grep -F -e 'Fetching  base' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:base.lgo/rack.lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Malformed url: http:/dom/base.lgr' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=url4
echo $TST
$LGC1 -v 4 -n :.lgo/rack.lgr ++n http://dom:.lgr load/refbase | tee $DIR/stdout/$TST
grep -F -e 'Fetching  base' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:base.lgo/rack.lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Malformed url: http://dombase.lgr' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=url5
echo $TST
$LGC1 -v 4 -n :.lgo/rack.lgr ++n http://dom:8o8o/:.lgr load/refbase | tee $DIR/stdout/$TST
grep -F -e 'Fetching  base' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:base.lgo/rack.lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Malformed url: http://dom:8o8o/base.lgr' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=url6
echo $TST
$LGC1 -v 4 -n :.lgo/rack.lgr ++n http://dom:-1/:.lgr load/refbase | tee $DIR/stdout/$TST
grep -F -e 'Fetching  base' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:base.lgo/rack.lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Malformed url: http://dom:-1/base.lgr' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=url7
echo $TST
$LGC1 -v 4 -n :.lgo/rack.lgr ++n http://dom:65536/:.lgr load/refbase | tee $DIR/stdout/$TST
grep -F -e 'Fetching  base' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:base.lgo/rack.lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Malformed url: http://dom:65536/base.lgr' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=readhttp
echo $TST
echo We hope no-one listens at IANA reserved port 1024
$LGC1 -v 4 -n :.lgo/rack.lgr ++n http://127.0.0.1:1024/:.lgr load/refbase | tee $DIR/stdout/$TST
grep -F -e 'Fetching  base' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:base.lgo/rack.lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   http://127.0.0.1:1024/base.lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Could not load reference base' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=lgu1
echo $TST
$LGC1 -v 4 -n :.lgo/rack.lgr ++n load/:1.lgu load/refbase | tee $DIR/stdout/$TST
grep -F -e 'Fetching  base' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:base.lgo/rack.lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:load/base1.lgu' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Malformed lgu link: file:abc.lgw' \
                       $DIR/stdout/$TST || exit 1
grep -F -e "Such links must start with 'http:'" \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Source of link: file:load/base1.lgu' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=lgu2
echo $TST
$LGC1 -v 4 -n :.lgo/rack.lgr ++n load/:2.lgu load/refbase | tee $DIR/stdout/$TST
grep -F -e 'Fetching  base' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:base.lgo/rack.lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:load/base2.lgu' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Illegal suffix in lgu link: http://dom/base.lgx' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Only .lgw and .lgu are legal suffixes' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Source of link: file:load/base2.lgu' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=lgu3
echo $TST
$LGC1 -v 4 -n :.lgo/rack.lgr ++n load/:3.lgu load/refbase | tee $DIR/stdout/$TST
grep -F -e 'Fetching  base' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:base.lgo/rack.lgr' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:load/base3.lgu' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Malformed url: http:abc.lgw' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=nocolon2
echo $TST
$LGC1 -r abc vector/pagesym | tee $DIR/stdout/$TST
grep -F -e 'Missing colon in rendering option' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=pagesym
echo $TST
$LGC1 vector/$TST | tee $DIR/stdout/$TST
grep -F -e 'Reading   file:vector/pagesym' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Reading   file:vector/pagesym.lgs' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Parsing' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Codifying' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Rendering' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye' \
                       $DIR/stdout/$TST || exit 1
od -t x1 --width=1000 $DIR/logiweb/*/vector.lgw | \
grep "00 00 01$" || exit 1
od -t x1 --width=1000 $DIR/name/$TST/vector.lgw | \
grep "00 00 01$" || exit 1
od -t x1 --width=1000 $DIR/name/latest/vector.lgw | \
grep "00 00 01$" || exit 1
head -c 20 $DIR/name/latest/ref.lgp > $DIR/name/latest/ref.lgp1
echo >> $DIR/name/latest/ref.lgp1
xxd -g 11 -l 11 -u $DIR/name/latest/vector.lgw | tail --bytes=+12 | head -c 20 \
  > $DIR/name/latest/ref.lgp2
echo >> $DIR/name/latest/ref.lgp2
diff $DIR/name/latest/ref.lgp1 $DIR/name/latest/ref.lgp2 || exit 1



echo $DIV
HDR="00 0a 01 09 01 08 01 07 01 06 02 05 02 04 00 03 00 02 00 01 00 00"
TST=tree1
RES="$HDR 02$"
echo $TST
$LGC1 vector/$TST | tee $DIR/stdout/$TST
od -t x1 --width=1000 $DIR/name/$TST/vector.lgw | \
grep "$RES" || exit 1



echo $DIV
TST=tree2
RES="$HDR 07 02 03$"
echo $TST
$LGC1 vector/$TST | tee $DIR/stdout/$TST
od -t x1 --width=1000 $DIR/name/$TST/vector.lgw | \
grep "$RES" || exit 1



echo $DIV
TST=tree3
RES="$HDR 07 06 02 03 06 04 05$"
echo $TST
$LGC1 vector/$TST | tee $DIR/stdout/$TST
od -t x1 --width=1000 $DIR/name/$TST/vector.lgw | \
grep "$RES" || exit 1



echo $DIV
TST=tree4
RES="$HDR 06 06 02 03 04$"
echo $TST
$LGC1 vector/$TST | tee $DIR/stdout/$TST
od -t x1 --width=1000 $DIR/name/$TST/vector.lgw | \
grep "$RES" || exit 1



echo $DIV
TST=tree5
RES="$HDR 07 02 07 03 04$"
echo $TST
$LGC1 vector/$TST | tee $DIR/stdout/$TST
od -t x1 --width=1000 $DIR/name/$TST/vector.lgw | \
grep "$RES" || exit 1



echo $DIV
TST=tree6
RES="$HDR 06 02 08 07 03 04$"
echo $TST
$LGC1 vector/$TST | tee $DIR/stdout/$TST
od -t x1 --width=1000 $DIR/name/$TST/vector.lgw | \
grep "$RES" || exit 1



echo $DIV
TST=tree7
RES="$HDR 06 09 07 02 03 04$"
echo $TST
$LGC1 vector/$TST | tee $DIR/stdout/$TST
od -t x1 --width=1000 $DIR/name/$TST/vector.lgw | \
grep "$RES" || exit 1



echo $DIV
TST=tree8
RES="$HDR 08 09 02$"
echo $TST
$LGC1 vector/$TST | tee $DIR/stdout/$TST
od -t x1 --width=1000 $DIR/name/$TST/vector.lgw | \
grep "$RES" || exit 1



echo $DIV
TST=tree9
RES="$HDR 0b 0a 02$"
echo $TST
$LGC1 vector/$TST | tee $DIR/stdout/$TST
od -t x1 --width=1000 $DIR/name/$TST/vector.lgw | \
grep "$RES" || exit 1



echo $DIV
TST=string
RES="$HDR 07 01 00 03 61 62 63$"
echo $TST
$LGC1 vector/$TST | tee $DIR/stdout/$TST
od -t x1 --width=1000 $DIR/name/$TST/vector.lgw | \
grep "$RES" || exit 1



echo $DIV
TST=noint1
echo $TST
$LGC1 parse/$TST | tee $DIR/stdout/$TST
grep -F -e 'Line 7 character 19:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Syntax error' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Cannot parse beyond this point' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Expected e.g. |' \
                       $DIR/stdout/$TST || exit 1
grep -F -e ') " ] "' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'x ( x ) x [ x ( x |' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '] x ) x' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=noint2
echo $TST
$LGC1 parse/$TST | tee $DIR/stdout/$TST
grep -F -e 'Line 7 character 10:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Syntax error' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Cannot parse beyond this point' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Expected e.g. end of file' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'x [ x ] x|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'yyy' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=ambig1
echo $TST
$LGC1 parse/$TST | tee $DIR/stdout/$TST
grep -F -e 'Ambiguous source text' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Could be at the end of construct " +' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Could be in the middle of construct " + "' \
                       $DIR/stdout/$TST || exit 1
grep -F -e '+ 1 + 2 + 3 +|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e ' + 4 + 5 + 6 +' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=ambig2
echo $TST
$LGC1 parse/$TST | tee $DIR/stdout/$TST
grep -F -e 'Use of ambiguous construct " + "' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Could be construct 2 of reference 0' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Could be construct 3 of reference 0' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'x +|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e ' x + x' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=proclaim1
echo $TST
$LGC1 codify/$TST | tee $DIR/stdout/$TST
grep -F -e 'Invalid proclamation:' \
		       $DIR/stdout/$TST || exit 1



echo $DIV
TST=proclaim2
echo $TST
$LGC1 codify/$TST | tee $DIR/stdout/$TST
grep -F -e 'Invalid proclamation:' \
		       $DIR/stdout/$TST || exit 1



echo $DIV
TST=html1
echo $TST
$LGC1 render/$TST | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of html1</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '<link rel="icon" href="logiweb.ico" type="image/x-icon"/>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '<title>Logiweb diagnose of html1</title>' \
		       $DIR/name/$TST/diagnose.html || exit 1
grep -F -e '<h3>The page is correct</h3>' \
		       $DIR/name/$TST/diagnose.html || exit 1
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1
grep -F -e '"";;01' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e '""P html1' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e 'proclaim " as " end proclaim' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e '<title>Logiweb extract of html1</title>' \
		       $DIR/name/$TST/extract.html || exit 1
grep -F -e '<p>define "charge" of x apply y as "2.4.8" end define</p>' \
		       $DIR/name/$TST/extract.html || exit 1
ls -l $DIR/name/$TST/logiweb.ico | grep -F -e ' 894 ' || exit 1
ls -l $DIR/name/$TST/logiweb.png | grep -F -e ' 559 ' || exit 1



echo $DIV
TST=html2
echo $TST
$LGC1 render/$TST | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of html2</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '<link rel="icon" href="logiweb.ico" type="image/x-icon"/>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '<title>Logiweb diagnose of html2</title>' \
		       $DIR/name/$TST/diagnose.html || exit 1
grep -F -e '<p>lambda x dot "abc"</p>' \
		       $DIR/name/$TST/diagnose.html || exit 1
grep -F -e 'lambda x dot "abc"' \
		       $DIR/name/$TST/diagnose.txt || exit 1
grep -F -e '"";;01' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e '""P html2' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e 'proclaim " as " end proclaim' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e '<title>Logiweb extract of html2</title>' \
		       $DIR/name/$TST/extract.html || exit 1
grep -F -e '<p><tt>Proclamed meaning: "lambda"</tt></p>' \
		       $DIR/name/$TST/extract.html || exit 1
ls -l $DIR/name/$TST/logiweb.ico | grep -F -e ' 894 ' || exit 1
ls -l $DIR/name/$TST/logiweb.png | grep -F -e ' 559 ' || exit 1



echo $DIV
TST=html3a
echo $TST
cp -f render/html3.lgs render/html3a.lgs
$LGC1 render/$TST | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of html1</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '<link rel="icon" href="logiweb.ico" type="image/x-icon"/>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '<title>Logiweb diagnose of html1</title>' \
		       $DIR/name/$TST/diagnose.html || exit 1
grep -F -e '<h3>The page is correct</h3>' \
		       $DIR/name/$TST/diagnose.html || exit 1
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1
grep -F -e '"";;01' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e '""P html1' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e 'proclaim " as " end proclaim' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e '<title>Logiweb extract of html1</title>' \
		       $DIR/name/$TST/extract.html || exit 1
grep -F -e '<p>define "charge" of x apply y as "2.4.8" end define</p>' \
		       $DIR/name/$TST/extract.html || exit 1
ls -l $DIR/name/$TST/logiweb.ico | grep -F -e ' 894 ' || exit 1
ls -l $DIR/name/$TST/logiweb.png | grep -F -e ' 559 ' || exit 1



echo $DIV
TST=html3b
echo $TST
cp -f render/html3a.lgs render/html3b.lgs
$LGC1 render/$TST | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of html1</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '<link rel="icon" href="logiweb.ico" type="image/x-icon"/>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '<title>Logiweb diagnose of html1</title>' \
		       $DIR/name/$TST/diagnose.html || exit 1
grep -F -e '<h3>The page is correct</h3>' \
		       $DIR/name/$TST/diagnose.html || exit 1
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1
grep -F -e '"";;01' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e '""P html1' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e 'proclaim " as " end proclaim' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e '<title>Logiweb extract of html1</title>' \
		       $DIR/name/$TST/extract.html || exit 1
grep -F -e '<p>define "charge" of x apply y as "2.4.8" end define</p>' \
		       $DIR/name/$TST/extract.html || exit 1
ls -l $DIR/name/$TST/logiweb.ico | grep -F -e ' 894 ' || exit 1
ls -l $DIR/name/$TST/logiweb.png | grep -F -e ' 559 ' || exit 1
diff render/html3a.lgs render/html3b.lgs || exit 1
rm -f render/html3a.lgs
rm -f render/html3b.lgs



echo $DIV
TST=html4a
echo $TST
cp -f render/html4.lgs render/html4a.lgs
$LGC1 render/$TST | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of html1</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '<link rel="icon" href="logiweb.ico" type="image/x-icon"/>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '<title>Logiweb diagnose of html1</title>' \
		       $DIR/name/$TST/diagnose.html || exit 1
grep -F -e '<h3>The page is correct</h3>' \
		       $DIR/name/$TST/diagnose.html || exit 1
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1
grep -F -e '"";;01B7A8BB6C5EA751A8802A83D284E1D1DA39AD4673DCAEC4F3DDCAB60806' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e '""P html1' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e 'proclaim " as " end proclaim' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e '<title>Logiweb extract of html1</title>' \
		       $DIR/name/$TST/extract.html || exit 1
grep -F -e '<p>define "charge" of x apply y as "2.4.8" end define</p>' \
		       $DIR/name/$TST/extract.html || exit 1
ls -l $DIR/name/$TST/logiweb.ico | grep -F -e ' 894 ' || exit 1
ls -l $DIR/name/$TST/logiweb.png | grep -F -e ' 559 ' || exit 1
rm -f render/html4a.lgs



echo $DIV
TST=diag1
echo $TST
B='<font color="blue">[</font>'
E='<font color="blue">]<wbr/></font>'
$LGC1 render/$TST | tee $DIR/stdout/$TST
grep -F -e '""[x + y""] + z' \
		       $DIR/name/$TST/diagnose.txt || exit 1
grep -F -e "<p>${B}x + y${E} + z</p>" \
		       $DIR/name/$TST/diagnose.html || exit 1



echo $DIV
TST=diag2
echo $TST
B='<font color="blue">[</font>'
E='<font color="blue">]<wbr/></font>'
$LGC1 render/$TST | tee $DIR/stdout/$TST
grep -F -e 'x :: ""[y :: z""]' \
		       $DIR/name/$TST/diagnose.txt || exit 1
grep -F -e "<p>x :: ${B}y :: z${E}</p>" \
		       $DIR/name/$TST/diagnose.html || exit 1



echo $DIV
TST=diag3
echo $TST
$LGC1 render/$TST | tee $DIR/stdout/$TST
grep -F -e '""[u + v""] :: ""[x + y""]' \
		       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=diag4
echo $TST
$LGC1 render/$TST | tee $DIR/stdout/$TST
grep -F -e '""[lambda u + v dot ""[w + x""]""] then y + z end' \
		       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=diag5
echo $TST
$LGC1 render/$TST | tee $DIR/stdout/$TST
grep -F -e 'if u + v then ""[""[w + x""] else y + z endif""]' \
		       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=diag6
echo $TST
$LGC1 render/$TST | tee $DIR/stdout/$TST
grep -F -e 'u + lambda v dot ""[x :: y""]' \
		       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=diag7
echo $TST
$LGC1 render/$TST | tee $DIR/stdout/$TST
grep -F -e '""[u :: v""] then x end + y' \
		       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=diag8
echo $TST
$LGC1 render/$TST | tee $DIR/stdout/$TST
grep -F -e '""["". + ""-""!a""!"""] + "<&>"' \
		       $DIR/name/$TST/diagnose.txt || exit 1
grep -F -e '<font color="blue">[</font>"". + ""-""!a""!"<font color="blue">]<wbr/></font> + "&lt;&amp;&gt;"' \
		       $DIR/name/$TST/diagnose.html || exit 1



echo $DIV
TST=diag9
echo $TST
$LGC1 render/$TST | tee $DIR/stdout/$TST
grep -F -e '""["". + ""-""!a""!"""] + "<&>"' \
		       $DIR/name/$TST/diagnose.txt || exit 1
grep -F -e '<font color="blue">[</font>"". + ""-""!a""!"<font color="blue">]<wbr/></font> + "&lt;&amp;&gt;"' \
		       $DIR/name/$TST/diagnose.html || exit 1
grep -F -e 'end{document}' \
		       $DIR/name/$TST/page/diagnose.tex || exit 1
grep -F -e 'linebreak [0]' \
		       $DIR/name/$TST/page/diagnose.tex || exit 1
grep -F -e 'end{document}' \
		       $DIR/name/$TST/page/page.tex || exit 1
grep -F -e 'Proclamations' \
		       $DIR/name/$TST/page/page.tex || exit 1
echo "Looking for $DIR/name/$TST/page/page.pdf"
[ -a $DIR/name/$TST/page/page.pdf ] || exit 1
echo "Looking for $DIR/name/$TST/page/diagnose.pdf"
[ -a $DIR/name/$TST/page/diagnose.pdf ] || exit 1



echo $DIV
TST=ref1
echo $TST "(1)"
$LGC1 bib/$TST | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of ref1</title>' \
		       $DIR/name/$TST/index.html || exit 1
ls -l $DIR/name/$TST/vector.lgw | grep -F -e ' 474 ' || exit 1
ls -l $DIR/name/$TST/rack.lgr | grep -F -e ' 3070 ' || exit 1



echo $DIV
TST=ref2
echo $TST "(1)"
$LGC1 bib/$TST -n $DIR/name/:/vector.lgw | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of ref2</title>' \
		       $DIR/name/$TST/index.html || exit 1
ls -l $DIR/name/$TST/vector.lgw | grep -F -e ' 387 ' || exit 1
ls -l $DIR/name/$TST/rack.lgr | grep -F -e ' 2393 ' || exit 1



echo $DIV
TST=ref3
echo $TST "(1)"
$LGC1 bib/$TST -n $DIR/name/:/rack.lgr | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of ref3</title>' \
		       $DIR/name/$TST/index.html || exit 1
ls -l $DIR/name/$TST/vector.lgw | grep -F -e ' 387 ' || exit 1
ls -l $DIR/name/$TST/rack.lgr | grep -F -e ' 2393 ' || exit 1



echo $DIV
TST=ref2a
echo $TST
$LGC1 bib/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of ref2a</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '"Hello World"' \
		       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=ref2b
echo $TST
$LGC1 bib/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/rack.lgr \
                       | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of ref2b</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '"Hello World"' \
		       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=ref2c
echo $TST
$LGC1 bib/$TST -n $DIR/name/:/rack.lgr -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of ref2c</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '"Hello World"' \
		       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=ref2d
echo $TST
$LGC1 bib/$TST -n $DIR/name/:/rack.lgr -p $DIR/logiweb/:/rack.lgr \
                       | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of ref2d</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '"Hello World"' \
		       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=ref2a1
echo $TST
$LGC1 bib/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of ref2a1</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '"Hello World"' \
		       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=ref2b1
echo $TST
$LGC1 bib/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/rack.lgr \
                       | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of ref2b1</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '"Hello World"' \
		       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=ref2c1
echo $TST
$LGC1 bib/$TST -n $DIR/name/:/rack.lgr -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of ref2c1</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '"Hello World"' \
		       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=ref2d1
echo $TST
$LGC1 bib/$TST -n $DIR/name/:/rack.lgr -p $DIR/logiweb/:/rack.lgr \
                       | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of ref2d1</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '"Hello World"' \
		       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=ref2a2
echo $TST
$LGC1 bib/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of ref2a2</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '"Hello World"' \
		       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=ref2b2
echo $TST
$LGC1 bib/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/rack.lgr \
                       | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of ref2b2</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '"Hello World"' \
		       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=ref2c2
echo $TST
$LGC1 bib/$TST -n $DIR/name/:/rack.lgr -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of ref2c2</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '"Hello World"' \
		       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=ref2d2
echo $TST
$LGC1 bib/$TST -n $DIR/name/:/rack.lgr -p $DIR/logiweb/:/rack.lgr \
                       | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of ref2d2</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '"Hello World"' \
		       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=ref4a
echo $TST
cp -f bib/ref4.lgs bib/$TST.lgs
$LGC1 bib/$TST -n $DIR/name/:/vector.lgw --path \
                       | tee $DIR/stdout/$TST
grep -F -e '1st reading' $DIR/stdout/$TST || exit 1
grep -F -e '2nd reading' $DIR/stdout/$TST || exit 1
grep -F -e '3rd reading' $DIR/stdout/$TST || exit 1
grep -F -e '<title>Logiweb main menu of ref4</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '"";;011D31291E8F8386A16A9193299A8D9461B2B8117890ADBD8B9FD4B60806' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e '"";;011D31291E8F8386A16A9193299A8D9461B2B8117890ADBD8B9FD4B60806' \
		       bib/$TST.lgs || exit 1
ls -l $DIR/name/$TST/vector.lgw | grep -F -e ' 474 ' || exit 1
ls -l $DIR/name/$TST/rack.lgr | grep -F -e ' 3070 ' || exit 1
od -t x1 --width=16 $DIR/name/$TST/vector.lgw > $DIR/name/$TST/vector.od
diff -q bib/$TST.lgw.od $DIR/name/$TST/vector.od || exit 1
od -t x1 --width=16 $DIR/name/$TST/rack.lgr > $DIR/name/$TST/rack.od
diff -q bib/$TST.lgr.od $DIR/name/$TST/rack.od || exit 1
rm -f bib/$TST.lgs



echo $DIV
TST=ref5a
echo $TST
cp -f bib/ref5.lgs bib/$TST.lgs
$LGC1 bib/$TST -n $DIR/name/:/vector.lgw --path \
                       | tee $DIR/stdout/$TST
grep -c -F -e 'reading' $DIR/stdout/$TST | grep 5 || exit 1
grep -F -e '<title>Logiweb main menu of ref5</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '"";;01ED480112C0FB3DFB409B9170710AF6162F38C544B8FEB68C9FD4B60806' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e '"";;01ED480112C0FB3DFB409B9170710AF6162F38C544B8FEB68C9FD4B60806' \
		       bib/$TST.lgs || exit 1
ls -l $DIR/name/$TST/vector.lgw | grep -F -e ' 387 ' || exit 1
ls -l $DIR/name/$TST/rack.lgr | grep -F -e ' 2393 ' || exit 1
od -t x1 --width=16 $DIR/name/$TST/vector.lgw > $DIR/name/$TST/vector.od
diff -q bib/$TST.lgw.od $DIR/name/$TST/vector.od || exit 1
od -t x1 --width=16 $DIR/name/$TST/rack.lgr > $DIR/name/$TST/rack.od
diff -q bib/$TST.lgr.od $DIR/name/$TST/rack.od || exit 1
rm -f bib/$TST.lgs



echo $DIV
TST=ref5b
echo $TST
cp -f bib/ref5.lgs bib/$TST.lgs
$LGC1 bib/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/rack.lgr \
                       | tee $DIR/stdout/$TST
grep -c -F -e 'reading' $DIR/stdout/$TST | grep 0 || exit 1
grep -F -e '<title>Logiweb main menu of ref5</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '"";;01ED480112C0FB3DFB409B9170710AF6162F38C544B8FEB68C9FD4B60806' \
		       $DIR/name/$TST/source.lgs || exit 1
grep -F -e '"";;01ED480112C0FB3DFB409B9170710AF6162F38C544B8FEB68C9FD4B60806' \
		       bib/$TST.lgs || exit 1
ls -l $DIR/name/$TST/vector.lgw | grep -F -e ' 387 ' || exit 1
ls -l $DIR/name/$TST/rack.lgr | grep -F -e ' 2393 ' || exit 1
rm -f bib/$TST.lgs



echo $DIV
TST=autobase1
echo $TST
$LGC1 auto/$TST | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of autobase1</title>' \
		       $DIR/name/$TST/index.html || exit 1



echo $DIV
TST=auto1
RES="14 12 00 04 6e 61 6d 65 01 00 05 61 75 74 6f 31 0e$"
echo $TST
$LGC1 auto/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
od -t x1 --width=1000 $DIR/name/$TST/vector.lgw | grep "$RES" || exit 1
grep -F -e '<title>Logiweb main menu of auto1</title>' \
		       $DIR/name/$TST/index.html || exit 1
grep -F -e '<title>Logiweb extract of auto1</title>' \
		       $DIR/name/$TST/extract.html || exit 1
grep -F -e '<p>lgcdef "name" of auto1 as "auto1" enddef</p>' \
		       $DIR/name/$TST/extract.html || exit 1



echo $DIV
TST=auto2
RES="14 12 00 06 63 68 61 72 67 65 01 00 01 30 0e$"
echo $TST
$LGC1 auto/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
od -t x1 --width=1000 $DIR/name/$TST/vector.lgw | grep "$RES" || exit 1



echo $DIV
TST=auto3
RES="00 21 22 22 3b 3b 0a 22 22 50 20 61 75 74 6f 33 0a 22 22 52 20 61 75 74 6f 62 61 73 65 31 0a 22 22 53 0a$"
echo $TST
$LGC1 auto/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
od -t x1 --width=1000 $DIR/name/$TST/vector.lgw | grep "$RES" || exit 1



echo $DIV
TST=auto4
RES="00 21 22 22 3b 3b 0a 22 22 50 20 61 75 74 6f 34 0a 22 22 52 20 61 75 74 6f 62 61 73 65 31 0a 22 22 53 0a$"
echo $TST
$LGC1 auto/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
od -t x1 --width=1000 $DIR/name/$TST/vector.lgw | \
grep "$RES" || exit 1



echo $DIV
TST=auto5
echo $TST
$LGC1 auto/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
RES="09 12 03 01 00 05 61 75 74 6f 35 09"
od -t x1 --width=1000 $DIR/name/$TST/vector.lgw | grep "$RES" || exit 1
RES="09 12 05 01 00 01 30 09"
od -t x1 --width=1000 $DIR/name/$TST/vector.lgw | grep "$RES" || exit 1
RES='<title>Logiweb main menu of auto5</title>'
grep -F -e "$RES" $DIR/name/$TST/index.html || exit 1
RES='<title>Logiweb extract of auto5</title>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgcname of auto5 as "auto5" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgccharge of auto5 as "0" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='lgcdef lgcname of lgcvar lgclgcthen lgcvar as ""-""! lgclgcthen ""!" enddef'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='lgcdef lgccharge of lgcvar lgclgcthen lgcvar as "6" enddef'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1



echo $DIV
TST=autobase2
echo $TST
$LGC1 auto/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
RES='<title>Logiweb main menu of autobase2</title>'
grep -F -e "$RES" $DIR/name/$TST/index.html || exit 1
RES='<title>Logiweb extract of autobase2</title>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgcname of autobase2 as "autobase2" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgccharge of autobase2 as "0" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='lgcdef lgcname of lgcvar lgcthen lgcvar as ""-""! lgcthen ""!" enddef'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='lgcdef lgccharge of lgcvar lgcthen lgcvar as "6" enddef'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1



echo $DIV
TST=autobase3
echo $TST
$LGC1 auto/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
RES='<title>Logiweb main menu of autobase3</title>'
grep -F -e "$RES" $DIR/name/$TST/index.html || exit 1
RES='<title>Logiweb extract of autobase3</title>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgcname of autobase3 as "autobase3" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgccharge of autobase3 as "0" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgccharge of proclaim lgcvar as lgcvar end proclaim as "0" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgccharge of define lgcvar of lgcvar as lgcvar end define as "0" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgccharge of x as "2.4.6" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgccharge of y as "3" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgccharge of z as "2.-3.8" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgccharge of lgcend as "2" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgccharge of lgcvar as "2" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgccharge of lgcdef lgcvar of lgcvar as lgcvar enddef as "2" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgccharge of lgcname as "2" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgccharge of lgccharge as "3" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgccharge of lgcvar lgcthen lgcvar as "6" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1
RES='<p>lgcdef lgccharge of lgcvar[[ lgcvar ]]lgcvar as "6" enddef</p>'
grep -F -e "$RES" $DIR/name/$TST/extract.html || exit 1



echo $DIV
TST=tilde1
echo $TST

$LGC2 tilde/$TST | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of tilde1</title>' \
		       $DIR/name/$TST/index.html || exit 1



echo $DIV
TST=tilde2
echo $TST
$LGC2 tilde/$TST | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of tilde2</title>' \
		       $DIR/name/$TST/index.html || exit 1



echo $DIV
TST=tilde3
echo $TST
$LGC2 tilde/$TST | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of tilde3</title>' \
		       $DIR/name/$TST/index.html || exit 1



echo $DIV
TST=tilde4
echo $TST
$LGC2 tilde/$TST +p "~/logiweb/:/rack.lgr" | tee $DIR/stdout/$TST
grep -F -e '<title>Logiweb main menu of tilde3</title>' \
		       $DIR/name/$TST/index.html || exit 1



echo $DIV
TST=tilde5
echo $TST
cp -f conf/site1.conf $DIR/home/siteconf
env HOME=$DIR/home $LGC -s "~/siteconf" -o userconfig  | tee $DIR/stdout/$TST
grep -F -e 'conf/user1.conf' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=tilde6
echo $TST
cp -f conf/site1.conf $DIR/home/siteconf
env HOME=$DIR/home $LGC -s "~/siteconf" -o path  | tee $DIR/stdout/$TST
grep -F -e 'usercache/:/rack.lgr' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=tilde7
echo $TST
cp -f conf/user1.conf $DIR/home/userconf
env HOME=$DIR/home $LGC -s /dev/null -u "~/userconf" -o path  | \
                       tee $DIR/stdout/$TST
grep -F -e 'usercache/:/rack.lgr' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=tilde8
echo $TST
cp -f lex/dc4 $DIR/home/
env HOME=$DIR/home $LGC0 "~/dc4" | tee $DIR/stdout/$TST
grep -F -e '---' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Line 5 character 2:' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Illegal character: 0x14' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'd|' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST=eventbase
echo $TST
$LGC1 render/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
RES='<title>Logiweb main menu of eventbase</title>'
grep -F -e "$RES" $DIR/name/$TST/index.html || exit 1



echo $DIV
TST=event1
echo $TST
$LGC1 render/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
RES='<title>Logiweb main menu of event1</title>'
grep -F -e "$RES" $DIR/name/$TST/index.html || exit 1
RES='This is index.html'
grep -F -e "$RES" $DIR/name/$TST/page/index.html || exit 1



echo $DIV
TST=event2
echo $TST
$LGC1 render/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
RES='<title>Logiweb main menu of event2</title>'
grep -F -e "$RES" $DIR/name/$TST/index.html || exit 1
RES='Improper filename:'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1
RES='Empty filename'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1



echo $DIV
TST=event3
echo $TST
$LGC1 render/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
RES='<title>Logiweb main menu of event3</title>'
grep -F -e "$RES" $DIR/name/$TST/index.html || exit 1
RES='Improper filename: /etc/passwd'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1
RES='Relative filename starts with slash'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1



echo $DIV
TST=event4
echo $TST
$LGC1 render/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
RES='<title>Logiweb main menu of event4</title>'
grep -F -e "$RES" $DIR/name/$TST/index.html || exit 1
RES='Improper filename: .'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1
RES='Filename must be more than a dot'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1



echo $DIV
TST=event5
echo $TST
$LGC1 render/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
RES='<title>Logiweb main menu of event5</title>'
grep -F -e "$RES" $DIR/name/$TST/index.html || exit 1
RES='Improper filename: abc/'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1
RES='Filename ends with a slash'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1



echo $DIV
TST=event6
echo $TST
$LGC1 render/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
RES='<title>Logiweb main menu of event6</title>'
grep -F -e "$RES" $DIR/name/$TST/index.html || exit 1
RES='Improper filename: abc/.'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1
RES='Filename ends with slash-dot'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1



echo $DIV
TST=event7
echo $TST
$LGC1 render/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
RES='<title>Logiweb main menu of event7</title>'
grep -F -e "$RES" $DIR/name/$TST/index.html || exit 1
RES='Improper filename: abc//def'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1
RES='Filename contains two slashes in a row'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1



echo $DIV
TST=event8
echo $TST
$LGC1 render/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
RES='<title>Logiweb main menu of event8</title>'
grep -F -e "$RES" $DIR/name/$TST/index.html || exit 1
RES='Improper filename: abc%def'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1
RES='Filename must be constructed from letters (a to z and A to Z)'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1
RES='digits (0 to 9), hyphen (-), underscore (_), dot (.), and slash (/)'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1



echo $DIV
TST=event9
echo $TST
$LGC1 render/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
RES='<title>Logiweb main menu of event9</title>'
grep -F -e "$RES" $DIR/name/$TST/index.html || exit 1
RES='Improper filename: abc/../../def'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1
RES='Filename contains two dots in a row'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1



echo $DIV
TST=latex1
echo $TST
$LGC1 render/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
RES='<title>Logiweb main menu of latex1</title>'
grep -F -e "$RES" $DIR/name/$TST/index.html || exit 1
RES='\section{Test section}\label{TestSection}'
grep -F -e "$RES" $DIR/name/$TST/page/page.tex || exit 1
RES='Fairouz'
grep -F -e "$RES" $DIR/name/$TST/page/page.bbl || exit 1
RES='\indexentry{Logiweb}{1}'
grep -F -e "$RES" $DIR/name/$TST/page/page.idx || exit 1
RES='Logiweb'
grep -F -e "$RES" $DIR/name/$TST/page/page.ind || exit 1



echo $DIV
TST=latex2
echo $TST
$LGC1 render/$TST -n $DIR/name/:/vector.lgw -p $DIR/logiweb/:/vector.lgw \
                       | tee $DIR/stdout/$TST
RES='<title>Logiweb main menu of latex2</title>'
grep -F -e "$RES" $DIR/name/$TST/index.html || exit 1
RES='\section{Test section}\label{TestSection}'
grep -F -e "$RES" $DIR/name/$TST/page/page.tex || exit 1
RES='Error running latex page in /tmp/lgc.test'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1
RES='Error running bibtex page in /tmp/lgc.test'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1
RES='Error running dvipdfm page in /tmp/lgc.test'
grep -F -e "$RES" $DIR/stdout/$TST || exit 1



echo $DIV
TST=base
echo $TST "(1)"
$LGC3 ../$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/name/$TST/index.html || exit 1
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=check
echo $TST "(1)"
$LGC3 pages/$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/name/$TST/index.html || exit 1
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=Peano
echo $TST "(1)"
$LGC3 pages/$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/name/$TST/index.html || exit 1
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=combinations
echo $TST "(1)"
$LGC3 pages/$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/name/$TST/index.html || exit 1
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=multzero
echo $TST "(1)"
$LGC3 pages/$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/name/$TST/index.html || exit 1
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=test
echo $TST "(1)"
$LGC3 pages/$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/name/$TST/index.html || exit 1
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=testmachine
echo $TST "(1)"
$LGC3 pages/$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/name/$TST/index.html || exit 1
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=lgc
echo $TST "(1)"
( cd .. ; $LGC3 $TST.lgs )
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/name/$TST/index.html || exit 1
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1




echo $DIV
TST=lgc
echo help9
grep -F -e "siteconfig=/etc/logiweb/lgc.conf" ${PWD}/../lgc || exit 1
cp ${PWD}/../lgc $DIR/name/$TST/page/bin/lgc1
echo "help=true" >> $DIR/name/$TST/page/bin/lgc1
$LGWAM1 $DIR/name/$TST/page/bin/lgc1 | tee $DIR/stdout/help9
grep -F -e '--verbose    or  -v     Set verbosity' \
                       $DIR/stdout/help9 || exit 1
grep -F -e '--path++x    or ++p x   Add x at end of path' \
                       $DIR/stdout/help9 || exit 1

echo $DIV
TST=lgc
echo help10
grep -F -e "siteconfig=/etc/logiweb/lgc.conf" \
		       $DIR/name/$TST/page/bin/lgc || exit 1
cp $DIR/name/$TST/page/bin/lgc $DIR/name/$TST/page/bin/lgc2
echo "help=true" >> $DIR/name/$TST/page/bin/lgc2
$LGWAMX1 $DIR/name/$TST/page/bin/lgc2 | tee $DIR/stdout/help10
grep -F -e '--verbose    or  -v     Set verbosity' \
                       $DIR/stdout/help10 || exit 1
grep -F -e '--path++x    or ++p x   Add x at end of path' \
                       $DIR/stdout/help10 || exit 1



echo $DIV
TST=fail01
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
diff -q -b -           $DIR/name/$TST/diagnose.txt <<diag || exit 1
diagnose math ttst false end test end math end diagnose
diag



echo $DIV
TST=fail02
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
diff -q -b -           $DIR/name/$TST/diagnose.txt <<diag || exit 1
diagnose math ttst exception end test end math end diagnose
diag



echo $DIV
TST=fail03
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
diff -q -b -           $DIR/name/$TST/diagnose.txt <<diag || exit 1
diagnose math ftst true end test end math end diagnose
diag



echo $DIV
TST=fail04
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
diff -q -b -           $DIR/name/$TST/diagnose.txt <<diag || exit 1
diagnose math ftst exception end test end math end diagnose
diag



echo $DIV
TST=fail05
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
diff -q -b -           $DIR/name/$TST/diagnose.txt <<diag || exit 1
diagnose math etst exception ; true end test end math end diagnose
diag



echo $DIV
TST=fail06
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
diff -q -b -           $DIR/name/$TST/diagnose.txt <<diag || exit 1
diagnose math etst exception ; false end test end math end diagnose
diag



echo $DIV
TST=fail07
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
diff -q -b -           $DIR/name/$TST/diagnose.txt <<diag || exit 1
diagnose math etst exception ; 2 raise end test end math end diagnose
diag



echo $DIV
TST=unify
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "Line"            $DIR/name/$TST/diagnose.txt || exit 1
grep "L02"             $DIR/name/$TST/diagnose.txt || exit 1
grep "in proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "Unable to unify" $DIR/name/$TST/diagnose.txt || exit 1
grep "#x"              $DIR/name/$TST/diagnose.txt || exit 1
grep "with"            $DIR/name/$TST/diagnose.txt || exit 1
grep "#y"              $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=Init
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "Line"            $DIR/name/$TST/diagnose.txt || exit 1
grep "L01"             $DIR/name/$TST/diagnose.txt || exit 1
grep "in proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "Init-seqop used on non-meta term" \
                       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=Ponens
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "In proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "Ponens-seqop used on non-inference" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "#x"              $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=Probans
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "In proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "Probans-seqop used on non-endorsement" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "#x"              $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=Verify
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "In proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "Verify-seqop used on non-endorsement" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "#x"              $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=sidecond
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "Line"            $DIR/name/$TST/diagnose.txt || exit 1
grep "L08"             $DIR/name/$TST/diagnose.txt || exit 1
grep "in proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "Verify-seqop used on false condition" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "\ c . false"     $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=Curry
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "In proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "Curry-seqop used on unfit argument:" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "#x"              $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=Uncurry
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "In proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "Uncurry-seqop used on unfit argument:" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "#x"              $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=Deref
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "In proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "Deref-seqop used on undefined statement:" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "#x"              $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=Deref2
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "In proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "Deref-seqop applied to" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "teststatement"   $DIR/name/$TST/diagnose.txt || exit 1
grep "produced non-meta term:" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "#x = All #x : #x" \
                       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=at
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "In proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "At-seqop used on non-quantifier:" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "#x"              $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=at2
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "In proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "At-seqop used for non-free substitution. Attempt to instantiate" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "#x" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "with"            $DIR/name/$TST/diagnose.txt || exit 1
grep "#y"              $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=infer
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "In proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "Infer-seqop used on non-meta term:" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "#x = All #x : #x" \
                       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=endorse
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "In proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "Endorse-seqop used on non-meta term:" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "#x = All #x : #x" \
                       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=IdEst
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "In proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "IdEst-seqop used on non-matching result. Attempt to match" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "teststatement"   $DIR/name/$TST/diagnose.txt || exit 1
grep "with"            $DIR/name/$TST/diagnose.txt || exit 1
grep -F -e 'All #x : ""[#x = #y""]' \
                       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=All1
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "In proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "All-seqop catches variable" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "#x"              $DIR/name/$TST/diagnose.txt || exit 1
grep "which is free in the following premise" \
                       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=All2
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "In proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "All-seqop catches variable" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "#x"              $DIR/name/$TST/diagnose.txt || exit 1
grep "which is free in the following condition:" \
                       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=unknown
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "In proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "Unknown seqop in root of" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "2 + 3"           $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=malform
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "Malformed proof of" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=sidecond2
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "In proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "Unchecked sidecondition:" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "#x"              $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=nolemma
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "Proof of non-existent lemma:" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=wronglemma
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "The proof of"    $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "does not prove what the lemma says." \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "After macro expansion, the lemma says:" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep -F -e 'System S infer All #x : ""[#x = #x""]' \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "After macro, tactic, and sequent expansion, the proof concludes:" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "#x infer #x" \
                       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=aux1
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=ref1
echo $TST "(2)"
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=aux2
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
diff -q -b -           $DIR/name/$TST/diagnose.txt <<diag || exit 1
diagnose math ttst false end test end math end diagnose
diag



echo $DIV
TST=ref2
echo $TST "(2)"
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "Lemma"           $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma1"      $DIR/name/$TST/diagnose.txt || exit 1
grep "occurs on a page with a non-empty diagnose." \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "Avoid referencing that lemma." \
                       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=aux3
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=ref3
echo $TST "(2)"
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "Lemma"           $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma1"      $DIR/name/$TST/diagnose.txt || exit 1
grep "occurs on a page which has not been checked" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "by the present proof checker." \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "Avoid referencing that lemma." \
                       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=noproof
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "Lemma"           $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma1"      $DIR/name/$TST/diagnose.txt || exit 1
grep "has no proof. Avoid referencing that lemma." \
                       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=nocirc
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=circular
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "Circular proof. The vicious circle includes lemma" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=unify1
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "Line"            $DIR/name/$TST/diagnose.txt || exit 1
grep "L03"             $DIR/name/$TST/diagnose.txt || exit 1
grep "in proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "Incomplete unification. Uninstantiated variable:" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "#x"              $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=rule1
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "Line"            $DIR/name/$TST/diagnose.txt || exit 1
grep "L02"             $DIR/name/$TST/diagnose.txt || exit 1
grep "in proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "No locally assumed theory includes the following rule:" \
                       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=rule2
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "Line"            $DIR/name/$TST/diagnose.txt || exit 1
grep "L03"             $DIR/name/$TST/diagnose.txt || exit 1
grep "in proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "No locally assumed theory includes the following rule:" \
                       $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=plus1
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=noop
echo $TST
$LGC3 port/$TST
echo Checking          $DIR/name/$TST/diagnose.txt
grep "Line"            $DIR/name/$TST/diagnose.txt || exit 1
grep "L03"             $DIR/name/$TST/diagnose.txt || exit 1
grep "in proof of"     $DIR/name/$TST/diagnose.txt || exit 1
grep "testlemma"       $DIR/name/$TST/diagnose.txt || exit 1
grep "Unknown unitac operator in root of argumentation:" \
                       $DIR/name/$TST/diagnose.txt || exit 1
grep "2 + 3"           $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=unpacker
echo $TST
(cd port ; $LGC3 $TST )
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/name/$TST/index.html || exit 1
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=unpacked
echo $TST
(cd port ; $LGC3 $TST )
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/name/$TST/index.html || exit 1
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1



echo $DIV
TST=renderer
echo $TST
$LGC3 port/$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/name/$TST/index.html || exit 1
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1
grep -F -e "A Logiweb renderer" \
		       $DIR/name/$TST/page/index.html || exit 1
grep -F -e "[9] (./page.aux) )" \
		       $DIR/name/$TST/page/page.log || exit 1
grep -F -e "Output written on page.dvi (9 pages" \
		       $DIR/name/$TST/page/page.log || exit 1



echo $DIV
TST=rendered
echo $TST
$LGC3 port/$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/name/$TST/index.html || exit 1
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1
grep -F -e "A custom rendered page" \
		       $DIR/name/$TST/page/index.html || exit 1
grep -F -e "[3] (./page.aux) )" \
		       $DIR/name/$TST/page/page.log || exit 1
grep -F -e "Output written on page.dvi (3 pages" \
		       $DIR/name/$TST/page/page.log || exit 1



echo $DIV
TST=renderex
echo $TST
$LGC3 port/$TST | tee $DIR/stdout/$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/name/$TST/index.html || exit 1
diff -q /dev/null      $DIR/name/$TST/diagnose.txt || exit 1
grep -F -e 'Exception raised during user rendering, goodbye.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST="hello"
echo $TST
$LGWAMX1 $DIR/name/base/page/bin/$TST > $DIR/stdout/${TST}1
echo "Hello World" > $DIR/stdout/${TST}2
diff -q $DIR/stdout/${TST}1 $DIR/stdout/${TST}2 || exit 1



echo $DIV
TST="echo"
echo $TST
echo "abcq" | $LGWAMX1 $DIR/name/base/page/bin/$TST > $DIR/stdout/${TST}1
echo "abc" > $DIR/stdout/${TST}2
diff -q $DIR/stdout/${TST}1 $DIR/stdout/${TST}2 || exit 1



echo $DIV
TST=eecho
echo $TST
echo "abcq" | $LGWAMX1 $DIR/name/base/page/bin/$TST > $DIR/stdout/${TST}1
echo "aabbcc" > $DIR/stdout/${TST}2
diff -q $DIR/stdout/${TST}1 $DIR/stdout/${TST}2 || exit 1



echo $DIV
TST="test1"
echo $TST "(1)"
$LGWAMX1 $DIR/name/testmachine/page/bin/$TST > $DIR/stdout/${TST}1
echo "HelloWorld" > $DIR/stdout/${TST}2
diff -q $DIR/stdout/${TST}1 $DIR/stdout/${TST}2 || exit 1



echo $DIV
TST="test1"
echo $TST "(2)"
rm -r -f ${DIR}/.logiweb
env LGW_PATH="" HOME=${DIR} ${PWD}/../lgwam script \
$DIR/name/testmachine/page/bin/$TST > $DIR/stdout/${TST}21
grep -F -e "not found" $DIR/stdout/${TST}21 || exit 1



echo $DIV
TST="test1"
echo $TST "(3)"
mkdir ${DIR}/.logiweb
ln -s ${DIR}/logiweb ${DIR}/.logiweb/logiweb
env LGW_PATH="" HOME=${DIR} ${PWD}/../lgwam script \
$DIR/name/testmachine/page/bin/$TST > $DIR/stdout/${TST}31
echo "HelloWorld" > $DIR/stdout/${TST}32
diff -q $DIR/stdout/${TST}31 $DIR/stdout/${TST}32 || exit 1



echo $DIV
TST=lgciotest
echo $TST
$LGWAMX1 $DIR/name/base/page/bin/$TST > $DIR/stdout/$TST
grep -F -e 'fileRmdir testdir2' \
                       $DIR/stdout/$TST || exit 1
grep -F -e 'Test succeeded.' \
                       $DIR/stdout/$TST || exit 1



echo $DIV
TST="testrun"
echo $TST
$LGWAMX0 testrun $DIR/name/testmachine/page/bin/test1 || exit 1



echo $DIV
TST=base
echo $TST "(2)"
$LGCX3 ../$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/namex/$TST/index.html || exit 1
diff -q /dev/null      $DIR/namex/$TST/diagnose.txt || exit 1
diff -q -r -x *.pdf -x *.dvi -x *.log $DIR/name/$TST $DIR/namex/$TST || exit 1



echo $DIV
TST=check
echo $TST "(2)"
$LGCX3 pages/$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/namex/$TST/index.html || exit 1
diff -q /dev/null      $DIR/namex/$TST/diagnose.txt || exit 1
diff -q -r -x *.pdf -x *.dvi -x *.log $DIR/name/$TST $DIR/namex/$TST || exit 1



echo $DIV
TST=Peano
echo $TST "(2)"
$LGCX3 pages/$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/namex/$TST/index.html || exit 1
diff -q /dev/null      $DIR/namex/$TST/diagnose.txt || exit 1
diff -q -r -x *.pdf -x *.dvi -x *.log $DIR/name/$TST $DIR/namex/$TST || exit 1



echo $DIV
TST=combinations
echo $TST "(2)"
$LGCX3 pages/$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/namex/$TST/index.html || exit 1
diff -q /dev/null      $DIR/namex/$TST/diagnose.txt || exit 1
diff -q -r -x *.pdf -x *.dvi -x *.log $DIR/name/$TST $DIR/namex/$TST || exit 1



echo $DIV
TST=multzero
echo $TST "(2)"
$LGCX3 pages/$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/namex/$TST/index.html || exit 1
diff -q /dev/null      $DIR/namex/$TST/diagnose.txt || exit 1
diff -q -r -x *.pdf -x *.dvi -x *.log $DIR/name/$TST $DIR/namex/$TST || exit 1



echo $DIV
TST=test
echo $TST "(2)"
$LGCX3 pages/$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/namex/$TST/index.html || exit 1
diff -q /dev/null      $DIR/namex/$TST/diagnose.txt || exit 1
diff -q -r -x *.pdf -x *.dvi -x *.log $DIR/name/$TST $DIR/namex/$TST || exit 1



echo $DIV
TST=testmachine
echo $TST "(2)"
$LGCX3 pages/$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/namex/$TST/index.html || exit 1
diff -q /dev/null      $DIR/namex/$TST/diagnose.txt || exit 1
diff -q -r -x *.pdf -x *.dvi -x *.log $DIR/name/$TST $DIR/namex/$TST || exit 1



echo $DIV
TST=lgc
echo $TST "(2)"
( cd .. ; $LGCX3 $TST.lgs )
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/namex/$TST/index.html || exit 1
diff -q /dev/null      $DIR/namex/$TST/diagnose.txt || exit 1
diff -q -r -x *.pdf -x *.dvi -x *.log -x lgc1 -x lgc2 \
                       $DIR/name/$TST $DIR/namex/$TST || exit 1



rm -r -f $DIR/logiweby
rm -r -f $DIR/namey
echo $DIV
TST=testmachine
echo $TST "(3)"
$LGC   -s conf/site.conf \
       -r $DIR/logiweby/: \
       -l $DIR/namey/: \
       -n $DIR/nowhere/:/rack.lgr \
       -p $DIR/nowhere/:/rack.lgr \
       ++n $DIR/namex/:/rack.lgr \
       ++p $DIR/logiwebx/:/rack.lgr \
       pages/$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/namey/$TST/index.html || exit 1
diff -q /dev/null      $DIR/namey/$TST/diagnose.txt || exit 1
ls $DIR/logiweby | wc -l | grep '^5$' || exit 1



rm -r -f $DIR/logiwebz
rm -r -f $DIR/namez
echo $DIV
TST=testmachine
echo $TST "(4)"
$LGC   -s conf/site.conf \
       -r $DIR/logiwebz/: \
       -l $DIR/namez/: \
       -n $DIR/nowhere/:/rack.lgr \
       -p $DIR/nowhere/:/rack.lgr \
       ++n $DIR/namex/:/vector.lgw \
       ++p $DIR/logiwebx/:/vector.lgw \
       pages/$TST
grep -F -e "<title>Logiweb main menu of $TST</title>" \
		       $DIR/namez/$TST/index.html || exit 1
diff -q /dev/null      $DIR/namez/$TST/diagnose.txt || exit 1
ls $DIR/logiwebz | wc -l | grep '^5$' || exit 1



echo $DIV
if [ -d /tmp/lgc.test ]
then
  echo "Remove /tmp/lgc.test manually"
else
  echo Removing $DIR
  rm -r $DIR
fi

echo $DIV
echo
echo Testsuite succeeded
echo
