# Copyright (c) 2005 Sandia Corporation. Under the terms of Contract
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Governement
# retains certain rights in this software.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# 
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
# 
#     * Redistributions in binary form must reproduce the above
#       copyright notice, this list of conditions and the following
#       disclaimer in the documentation and/or other materials provided
#       with the distribution.  
# 
#     * Neither the name of Sandia Corporation nor the names of its
#       contributors may be used to endorse or promote products derived
#       from this software without specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# 

# 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 SUFFIX = ""
set BINDIR = /Users/gdsjaar/src/exodusii-sf/exodus/cbind/test
set SRCDIR = /Users/gdsjaar/src/exodusii-sf/exodus/cbind/test
set NCDUMP = /Users/gdsjaar/src/SEACAS.git/bin/ncdump
echo "************************************************************************"
echo "************************************************************************"
rm -f test.output
echo "testwt - single precision write test..."
echo "begin testwt" > test.output
${PREFIX} ${BINDIR}/testwt${SUFFIX} >> test.output
echo "end testwt" >> test.output
${NCDUMP} -d5,5 test.exo | grep -v version | diff - ${SRCDIR}/test.dmp | tee testwt.res

echo "testrd - single precision read test..."
echo "begin testrd" >> test.output
${PREFIX} ${BINDIR}/testrd${SUFFIX} | grep -v version | diff - ${SRCDIR}/testrd.dmp | tee testrd.res
echo "end testrd" >> test.output

echo "testrdv - single precision read test with varid..."
echo "begin testrdv" >> test.output
${PREFIX} ${BINDIR}/testrdv${SUFFIX} | grep -v version | diff - ${SRCDIR}/testrdv.dmp | tee testrdv.res
echo "end testrdv" >> test.output

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

echo "testcp_sd - single-to-double precision copy test..."
echo "begin testcp_sd" >> test.output
${PREFIX} ${BINDIR}/testcpd${SUFFIX} >> test.output
echo "end testcp_sd" >> test.output
${NCDUMP} -d5,5 testcpd.exo | grep -v version | diff - ${SRCDIR}/testcp_sd.dmp | tee testcp_sd.res

echo "testcp_ln - large model to normal model single precision copy test..."
echo "begin testcp_ln" >> test.output
${PREFIX} ${BINDIR}/testcp_ln${SUFFIX} >> test.output
echo "end testcp_ln" >> test.output
${NCDUMP} -d5,5 testcp.exo | grep -v version | diff - ${SRCDIR}/testcp_ln.dmp | tee testcp_ln.res

echo "testcp_nl - normal_model to large_model single precision copy test..."
echo "begin testcp_nl" >> test.output
${PREFIX} ${BINDIR}/testcp_nl${SUFFIX} >> test.output
echo "end testcp_nl" >> test.output
${NCDUMP} -d5,5 testcp_nl.exo | grep -v version | diff - ${SRCDIR}/testcp_nl.dmp | tee testcp_nl.res

echo "testwt_clb - single precision write test using concatenated puts..."
echo "begin testwt_clb" >> test.output
${PREFIX} ${BINDIR}/testwt_clb${SUFFIX} >> test.output
echo "end testwt_clb" >> test.output
${NCDUMP} -d5,5 test.exo | grep -v version | diff - ${SRCDIR}/test_clb.dmp | tee testwt_clb.res

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

echo "testrdd - double precision read test..."
echo "begin testrdd" >> test.output
${PREFIX} ${BINDIR}/testrdd${SUFFIX} | grep -v version | diff - ${SRCDIR}/testrdd.dmp | tee testrdd.res
echo "end testrdd" >> test.output

echo "testcp_dd - double-to-double precision copy test..."
echo "begin testcp_dd" >> test.output
${PREFIX} ${BINDIR}/testcpd${SUFFIX} >> test.output
echo "end testcp_dd" >> test.output
${NCDUMP} -d5,5 testcpd.exo | grep -v version | diff - ${SRCDIR}/testcp_dd.dmp | tee testcp_dd.res

echo "testcp_ds - double-to-single precision copy test..."
echo "begin testcp_ds" >> test.output
${PREFIX} ${BINDIR}/testcp${SUFFIX} >> test.output
echo "end testcp_ds" >> test.output
${NCDUMP} -d5,5 testcp.exo | grep -v version | diff - ${SRCDIR}/testcp_ds.dmp | tee testcp_ds.res

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

echo "testrd1 - single precision read test of a file with several side sets..."
echo "testrd1 ... [Expect file create failure error, NOCLOBBER]"
echo "testrd1 ... [Expect failure locating elem var 1 for elem block 12]"
echo "begin testrd1" >> test.output
${PREFIX} ${BINDIR}/testrd1${SUFFIX} | grep -v version | diff - ${SRCDIR}/testrd1.dmp | tee testrd1.res
echo "end testrd1" >> test.output

echo "testwt_ss - write files to test side sets..."
echo "testwt_ss ... [Expect WEDGE6 warning from this test]"
echo "begin testwt_ss" >> test.output
${PREFIX} ${BINDIR}/testwt_ss${SUFFIX} >> test.output
echo "end testwt_ss" >> test.output
${NCDUMP} -d5,5 test.exo | grep -v version | diff - ${SRCDIR}/testwt_ss.dmp | tee testwt_ss.res

echo "testrd_ss - read test of a file with several side sets..."
echo "testrd_ss ... [Expect warning for NULL sidesets 30 and 31]"
echo "begin testrd_ss" >> test.output
${PREFIX} ${BINDIR}/testrd_ss${SUFFIX} | grep -v version | diff - ${SRCDIR}/testrd_ss.dmp | tee testrd_ss.res
echo "end testrd_ss" >> test.output

echo "testwt2 - single precision write 2 files (simultaneously open) test..."
echo "begin testwt2" >> test.output
${PREFIX} ${BINDIR}/testwt2${SUFFIX} >> test.output
echo "end testwt2" >> test.output
${NCDUMP} -d5,5 test.exo | grep -v version | diff - ${SRCDIR}/test2-1.dmp | tee testwt2-1.res
${NCDUMP} -d5,5 test2.exo | grep -v version | diff - ${SRCDIR}/test2-2.dmp | tee testwt2-2.res

echo "testrdwt - read from one and write to another (simutaneously open) file..."
echo "begin testrdwt" >> test.output
${PREFIX} ${BINDIR}/testrdwt${SUFFIX} >> test.output
echo "end testrdwt" >> test.output
${NCDUMP} -d5,5 test2.exo | grep -v version | diff - ${SRCDIR}/test2.dmp | tee testrdwt.res

echo "testwt_nc - write x y z components of coordinates separately..."
echo "begin testwt_nc" >> test.output
${PREFIX} ${BINDIR}/testwt_nc${SUFFIX} >> test.output
echo "end testwt_nc" >> test.output
${NCDUMP} -d5,5 test.exo | grep -v version | diff - ${SRCDIR}/test.dmp | tee testwt_nc.res

echo "testrd_nc - read x y z components of coordinates separately..."
echo "begin testrd_nc" >> test.output
${PREFIX} ${BINDIR}/testrd_nc${SUFFIX} | grep -v version | diff - ${SRCDIR}/testrd_nc.dmp | tee testrd_nc.res
echo "end testrd" >> test.output

echo "testwt-zeron - write file with zero nodes and elements..."
echo "begin testwt-zeron" >> test.output
${PREFIX} ${BINDIR}/testwt-zeron${SUFFIX} >> test.output
echo "end testwt-zeron" >> test.output
${NCDUMP} -d5,5 test.exo | grep -v version | diff - ${SRCDIR}/testwt-zeron.dmp | tee testwt-zeron.res

echo "testrd - read test of file with zero nodes and elements..."
echo "begin testrd zero nodes" >> test.output
${PREFIX} ${BINDIR}/testrd${SUFFIX} | grep -v version | diff - ${SRCDIR}/testrd_zeron.dmp | tee testrd_zeron.res
echo "end testrd zero nodes" >> test.output

echo "testwt-zeroe - write file with zero elements..."
echo "begin testwt-zeroe" >> test.output
${PREFIX} ${BINDIR}/testwt-zeroe${SUFFIX} >> test.output
echo "end testwt-zeroe" >> test.output
${NCDUMP} -d5,5 test.exo | grep -v version | diff - ${SRCDIR}/testwt-zeroe.dmp | tee testwt-zeroe.res

echo "testrd - read test of file with zero elements..."
echo "begin testrd zero elements" >> test.output
${PREFIX} ${BINDIR}/testrd${SUFFIX} | grep -v version | diff - ${SRCDIR}/testrd_zeroe.dmp | tee testrd_zeroe.res
echo "end testrd zero elements" >> test.output

echo "testwt-one-attrib - read/write test of element attributes - read one at a time..."
echo "begin testwt-one-attrib - read attributes one at a time" >> test.output
${PREFIX} ${BINDIR}/testwt-one-attrib${SUFFIX} | tee testrd_zeroe.res
echo "end testwt-one-attrib - read attributes one at a time" >> test.output

echo "testwt-nsided - write file with nsided elements..."
echo "begin testwt-nsided" >> test.output
${PREFIX} ${BINDIR}/testwt-nsided${SUFFIX} >> test.output
echo "end testwt-nsided" >> test.output
${NCDUMP} -d5,5 test-nsided.exo | grep -v version | diff - ${SRCDIR}/testwt-nsided.dmp | tee testwt-nsided.res

echo "testrd-nsided - read file with nsided elements..."
echo "begin testrd-nsided" >> test.output
${PREFIX} ${BINDIR}/testrd-nsided${SUFFIX} | grep -v version | diff - ${SRCDIR}/testrd-nsided.dmp | tee testrd-nsided.res
echo "end testrd-nsided" >> test.output

echo "testwt-nfaced - write file with nfaced elements..."
echo "begin testwt-nfaced" >> test.output
${PREFIX} ${BINDIR}/testwt-nfaced${SUFFIX} >> test.output
echo "end testwt-nfaced" >> test.output
${NCDUMP} -d5,5 test-nfaced.exo | grep -v version | diff - ${SRCDIR}/testwt-nfaced.dmp | tee testwt-nfaced.res

echo "testrd-nfaced - read file with nfaced elements..."
echo "begin testrd-nfaced" >> test.output
${PREFIX} ${BINDIR}/testrd-nfaced${SUFFIX} | grep -v version | diff - ${SRCDIR}/testrd-nfaced.dmp | tee testrd-nfaced.res
echo "end testrd-nfaced" >> test.output

echo "testwt-long-name - write file with long (64-character) names..."
echo "begin testwt-long-name" >> test.output
${PREFIX} ${BINDIR}/testwt-long-name${SUFFIX} >> test.output
echo "end testwt-long-name" >> test.output
${NCDUMP} -d5,5 test.exo | grep -v version | diff - ${SRCDIR}/testwt-long-name.dmp | tee testwt-long-name.res

echo "testrd - read long name file truncating to 32 characters on read..."
echo "begin testrd (truncate)" >> test.output
${PREFIX} ${BINDIR}/testrd${SUFFIX} | grep -v version | diff - ${SRCDIR}/testrd-nm32.dmp | tee testrd-nm32.res
echo "end testrd (truncate)" >> test.output

echo "testrd-long-name - read long name file..."
echo "begin testrd-long-name" >> test.output
${PREFIX} ${BINDIR}/testrd-long-name${SUFFIX} | grep -v version | diff - ${SRCDIR}/testrd-long-name.dmp | tee testrd-long-name.res
echo "end testrd-long-name" >> test.output

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