#!/usr/bin/env bash

export LD_LIBRARY_PATH=/usr/local/lib
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk

make -s clean

using_java=`grep "JAVA=" ../../../config.log|sed 's/JAVA=//'`
if ( test "$using_java" = "''" ); then
## Could not test without java, but return pass to make check goes through
   echo '---running (java) attr script'
   echo "   PASSED"
   echo '---running (java) prover script'
   echo "   PASSED"
   exit 0
fi

echo '---running (java) attr script'
make run_attr 1>/dev/null 2>& 1
result=`grep "prover success" attr.log 2>/dev/null`
if [ "$result" = "" ]; then
   echo "   ERROR"
else   
   echo "   PASSED"
fi

echo '---running (java) prover script'
make run_prove 1>/dev/null 2>& 1
result=`grep "prover success" prover.log 2>/dev/null`
if [ "$result" = "" ]; then
   echo "   ERROR"
else   
   echo "   PASSED"
fi

