# Copyright(C) 1999-2020 National Technology & Engineering Solutions
# of Sandia, LLC (NTESS).  Under the terms of Contract DE-NA0003525 with
# NTESS, the U.S. Government retains certain rights in this software.
#
# See packages/seacas/LICENSE for details

# script to run all tests and compare them to saved dump files.
#
# To run the tests with valgrind checking, uncomment the next line and comment the
# following line. Can also define other prefixes if wanted.

#set PREFIX = "valgrind --tool=memcheck"
set PREFIX = ""
set SRCDIR = .
set NCDUMP = /Users/gdsjaar/src/SEACAS.git/bin/ncdump

# testwt - single precision write test
echo "************************************************************************"
echo "************************************************************************"
echo "testwt ..."
echo "begin testwt" > test.output
${PREFIX} ${SRCDIR}/testwt >> test.output
echo "end testwt" >> test.output
${NCDUMP} -d5,5 test.exo | grep -v version > test.dmp

# testrd - single precision read test
echo "testrd ..."
echo "testrd ... [Expect ex_create NOCLOBBER error from this test]"
${PREFIX} ${SRCDIR}/testrd | grep -v version > testrd.dmp

# testcp_ss - single-to-single precision copy test
echo "testcp_ss ..."
echo "begin testcp_ss" >> test.output
${PREFIX} ${SRCDIR}/testcp >> test.output
echo "end testcp_ss" >> test.output
${NCDUMP} -d5,5 testcp.exo | grep -v version > testcp_ss.dmp

# testcpln - single-to-single, large to normal copy test
echo "testcpln ..."
echo "begin testcpln" >> test.output
${PREFIX} ${SRCDIR}/testcpln >> test.output
echo "end testcpln" >> test.output
${NCDUMP} -d5,5 testcp.exo | grep -v version > testcpln.dmp

# testcpnl - single-to-single, normal to large copy test
echo "testcpnl ..."
echo "begin testcpnl" >> test.output
${PREFIX} ${SRCDIR}/testcpnl >> test.output
echo "end testcpnl" >> test.output
${NCDUMP} -d5,5 testcpnl.exo | grep -v version > testcpnl.dmp

# testwt1 - single precision write test with multiple side sets
echo "testwt1 ..."
echo "testwt1 ... [Expect WEDGE6 warning from this test]"
echo "begin testwt1" >> test.output
${PREFIX} ${SRCDIR}/testwt1 >> test.output
echo "end testwt1" >> test.output
${NCDUMP} -d5,5 test.exo | grep -v version > test1.dmp

# testrd1 - single precision read test with multiple side sets
echo "testrd1 ..."
echo "testrd1 ... [Expect failure locating elem var 1 for elem block 12]"
${PREFIX} ${SRCDIR}/testrd1 | grep -v version > testrd1.dmp

# testwtd - double precision write test
echo "testwtd ..."
echo "begin testwtd" >> test.output
${PREFIX} ${SRCDIR}/testwtd >> test.output
echo "end testwtd" >> test.output
${NCDUMP} -d5,5 test.exo | grep -v version > testd.dmp

# testrdd - double precision read test
echo "testrdd ..."
${PREFIX} ${SRCDIR}/testrdd | grep -v version > testrdd.dmp

# testwt2 - single precision write 2 files (simultaneously open) test
echo "testwt2 ..."
echo "begin testwt2" >> test.output
${PREFIX} ${SRCDIR}/testwt2 >> test.output |&grep -v "property name string"
echo "end testwt2" >> test.output
${NCDUMP} -d5,5 test.exo | grep -v version > test2-1.dmp
${NCDUMP} -d5,5 test2.exo | grep -v version > test2-2.dmp

echo "testwt_nsid ..."
echo "begin testwt_nsid" > test.output
${PREFIX} ${SRCDIR}/testwt_nsid >> test.output
echo "end testwt_nsid" >> test.output
${NCDUMP} -d5,5 test-nsided.exo | grep -v version > test-nsided.dmp

# testrd_nsid - single precision read test
echo "testrd_nsid ..."
${PREFIX} ${SRCDIR}/testrd_nsid | grep -v version > testrd_nsid.dmp

echo "************************************************************************"
echo "************************************************************************"

