#! /bin/sh
#
# Tests for mpicc, mpiCC, mpif77 (.F) and mpif90 (.F90)
#   -Dname=\"foo bar\"
#   -Dname='"foo bar"'
#   
STOPFILE=${MPITEST_STOPTEST:-"$HOME/.stopmpichtests"}
mpicc="../../../../bin/ampiCC"
mpiCC=""
mpif77=":"
mpif90="@MPIF90@"

# Create test files
trap 'rm -f a.out rtest* *.o' 0
cat >> rtest.c <<EOF
#include <stdio.h>
int main( int argc, char *argv[] )
{
    printf( testname );
    return 0;
}
EOF
cat >> rtest.f <<EOF
        program main
        print *, testname
        end
EOF
cat >> rtest.cc <<EOF
#include <iostream.h>
int main( int argc, char *argv[] )
{
    cout << testname;
    return 0;
}
EOF
outlog="/dev/null"

cmd=mpicc
if $mpicc -Dtestname=\"foo\" rtest.c > $outlog 2>&1 ; then
    :
else
    echo "Error with escaped double quotes in $cmd"
fi
if $mpicc -Dtestname='"foo bar"' rtest.c  > $outlog 2>&1 ; then 
    :
else
    echo "Error with double inside of single quotes in $cmd"
fi

# Run this test only if mpiCC is valid (
if [ "no" = "yes" ] ; then
    cmd=mpiCC
    if $mpiCC -Dtestname=\"foo\" rtest.cc  > $outlog 2>&1; then
        :
    else
        echo "Error with escaped double quotes in $cmd"
    fi
    if $mpiCC -Dtestname='"foo bar"' rtest.cc > $outlog 2>&1 ; then 
        :
    else
        echo "Error with double inside of single quotes in $cmd"
    fi
fi
#
# No tests for Fortran yet since we don't directly support .F or .F90.
