#!/bin/sh
if [ $# -lt 2 ]; then
  echo "Usage: $0 compiler test1 test2 ..."
  echo "called from make sure"
  echo "SGI compiler \"CC -LANG:std -w -I/usr/local/mpi/include -L/usr/local/mpi/lib32\""
  echo "Intel compiler \"icc -w\""
  echo "IBM compiler xlC or mpCC as appropriate"
  echo "Tru64 compiler cxx -D__USE_STD_IOSTREAM"
fi

CC=$1
export CC
shift

PATH=.:$PATH

passed=0
failed=0
for i in $*; do 
    echo -n "$i: "
    # absorb stdio to reduce chatter
    bash $i &> /dev/null
    if test $? -eq 0 ; then 
        passed=`expr $passed + 1`
        echo passed
    else
        failed=`expr $failed + 1`
        echo -e "\033[31mfailed\033[0m"
    fi
done

echo "$passed tests passed, $failed tests failed"
exit $failed
