#!/bin/bash

passed=0
total=0

for TESTCASE in d d.3gram binarize bin2; do 
    ../itg -configfile $TESTCASE.config > $TESTCASE.stdout 2> /dev/null
    if diff -b $TESTCASE.stdout $TESTCASE.stdout.gold ; then
	echo PASSED test $TESTCASE
	let passed=passed+1
    else
	echo FAILED test $TESTCASE
    fi
    let total=total+1
done

for TESTCASE in d d.3gram binarize bin2; do
    ../itg -configfile $TESTCASE.config -lazy_kbest 1 > $TESTCASE.lazykbest.stdout 2> /dev/null
    if diff -b $TESTCASE.lazykbest.stdout $TESTCASE.lazykbest.stdout.gold ; then
        echo PASSED test $TESTCASE using lazykbest
	let passed=passed+1
    else
        echo FAILED test $TESTCASE using lazykbest
    fi
    let total=total+1
done

for TESTCASE in d d.3gram binarize bin2; do 
    ../itg -configfile $TESTCASE.config -use_agenda 1 > $TESTCASE.agenda.stdout 2> /dev/null
    if diff -b $TESTCASE.agenda.stdout $TESTCASE.agenda.stdout.gold ; then
	echo PASSED test $TESTCASE with agenda
	let passed=passed+1
    else
	echo FAILED test $TESTCASE with agenda
    fi
    let total=total+1
done


for TESTCASE in d d.3gram binarize bin2; do
    ../itg -configfile $TESTCASE.config -use_agenda 1 -two_pass 1 > $TESTCASE.agenda.twopass.stdout 2> /dev/null
    if diff -b $TESTCASE.agenda.twopass.stdout $TESTCASE.agenda.twopass.stdout.gold ; then
        echo PASSED test $TESTCASE with agenda twopass
	let passed=passed+1
    else
        echo FAILED test $TESTCASE with agenda twopass
    fi
    let total=total+1
done


for TESTCASE in d d.3gram binarize bin2; do
    ../itg -configfile $TESTCASE.config -use_agenda 1 -two_pass 1 -cyk_first_pass 1 > $TESTCASE.agenda.cykfirstpass.stdout 2> /dev/null
    if diff -b $TESTCASE.agenda.cykfirstpass.stdout $TESTCASE.agenda.cykfirstpass.stdout.gold ; then
        echo PASSED test $TESTCASE with cyk first pass agenda second pass
	let passed=passed+1
    else
        echo FAILED test $TESTCASE with cyk first pass agenda second pass
    fi
    let total=total+1
done


#for TESTCASE in d d.3gram binarize bin2; do
#    ../itg -configfile $TESTCASE.config -use_agenda 1 -two_pass 1 -cyk_first_pass 1 -epass 1 > $TESTCASE.agenda.cykfirstpass.epass.stdout 2> /dev/null
#    if diff -b $TESTCASE.agenda.cykfirstpass.epass.stdout $TESTCASE.agenda.cykfirstpass.epass.stdout.gold ; then
#        echo PASSED test $TESTCASE with cyk first pass agenda second pass
#	let passed=passed+1
#    else
#        echo FAILED test $TESTCASE with cyk first pass agenda second pass
#    fi
#    let total=total+1
#done

echo "Passed $passed/$total tests"
