#!/bin/csh -f
#
# ABCTEST - full PANACEA test
#

set System = `../../manager/system-id`
set BinDir = ../../dev/$System/bin
setenv SCHEME ../../dev/$System/scheme
set ERROR  = 0
set ABCError = FALSE

source ../../manager/env-$System

set FrontEnd = ""
set DPE = `which pact-dpe`
if ("$DPE" != "") then
   if (-e "$DPE[1]") then
      source $DPE
   endif
endif

echo ""
echo -n "                    Building PANACEA ABC Test ....."

touch st.rxx
rm -f tsrc1.src st.[rse]*

rm -f test.error
touch test.error
pact remove-sys >>& test.error
pact auto >>& test.error
if ($status != 0) then
   echo ""
   cat test.error
   echo "                         Can't build PANACEA ABC Test"
   set ERROR = 1
else
   echo " DONE"
   echo ""
   echo "                    PANACEA ABC Test ....."

   $FrontEnd s tsrc1 >>& test.error
   if ($status != 0) then
      echo "                    PANACEA S ..... FAILED"
      set ERROR    = 2
      set ABCError = "TRUE"
   else
      echo "                    PANACEA S ..... PASSED"
   endif

   if ($ABCError == "FALSE") then
      $FrontEnd a st.g >>& test.error
      if ($status != 0) then
         echo "                    PANACEA A ..... FAILED"
         set ERROR    = 3
         set ABCError = "TRUE"
      else
         echo "                    PANACEA A ..... PASSED"
      endif
   endif

   if ($ABCError == "FALSE") then
      $FrontEnd b st.r00 >>& test.error
      if ($status != 0) then
         echo "                    PANACEA B ..... FAILED"
         set ERROR    = 4
         set ABCError = "TRUE"
      else
         echo "                    PANACEA B ..... PASSED"
      endif
   endif

endif

if ($ERROR == 0) then
   pact remove-sys >>& /dev/null
endif

exit($ERROR)

