Making cdf5 tests conditional on cdf5 support setting at configure time.

This commit is contained in:
Ward Fisher 2017-09-14 14:18:56 -06:00
parent f82bcf9d15
commit 1a56d3fdc8
5 changed files with 118 additions and 64 deletions

View File

@ -108,8 +108,8 @@ are set when opening a binary file on Windows. */
#cmakedefine DLL_NETCDF 1
/* if true, enable CDF5 Support */
#cmakedefine ENABLE_CDF5
#cmakedefine USE_CDF5
#cmakedefine ENABLE_CDF5 1
#cmakedefine USE_CDF5 1
/* if true, build DAP2 and DAP4 Client */
#cmakedefine ENABLE_DAP 1

View File

@ -104,10 +104,12 @@ NC_interpret_magic_number(char* magic, int* model, int* version, int use_paralle
} else if(magic[3] == '\002') {
*version = 2; /* netcdf classic version 2 */
*model = NC_FORMATX_NC3;
} else if(magic[3] == '\005') {
*version = 5; /* cdf5 (including pnetcdf) file */
#ifdef USE_CDF5
} else if(magic[3] == '\005') {
*version = 5; /* cdf5 (including pnetcdf) file */
*model = NC_FORMATX_NC3;
} else
#endif
} else
{status = NC_ENOTNC; goto done;}
} else
{status = NC_ENOTNC; goto done;}

View File

@ -1,10 +1,20 @@
#!/bin/sh
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
# This shell script runs the ncdump tests.
# get some config.h parameters
if test -f ${top_builddir}/config.h ; then
if fgrep -e '#define USE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
CDF5=1
else
CDF5=0
fi
else
echo "Cannot locate config.h"
exit 1
fi
echo ""
echo "*** Testing ncgen and ncdump with 64-bit offset format."
@ -20,6 +30,8 @@ ${NCDUMP} test1.nc > test2.cdl
cmp test1.cdl test2.cdl
echo "*** All ncgen and ncdump with 64-bit offset format tests passed!"
if [ "x$CDF5" == "x1" ]; then
echo ""
echo "*** Testing ncgen and ncdump with CDF5 format."
set -e
@ -33,5 +45,6 @@ echo "*** creating test2.cdl from test1.nc..."
${NCDUMP} test1.nc > test2.cdl
cmp test1.cdl test2.cdl
echo "*** All ncgen and ncdump with CDF5 format tests passed!"
fi
exit 0

View File

@ -1,8 +1,21 @@
#!/bin/sh
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
# This shell script runs the ncdump tests.
# get some config.h parameters
if test -f ${top_builddir}/config.h ; then
if fgrep -e '#define USE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
USE_CDF5=1
else
USE_CDF5=0
fi
else
echo "Cannot locate config.h"
exit 1
fi
# This shell script tests the output several previous tests.
ECODE=0
@ -28,17 +41,20 @@ echo "*** Fail: extended format for a 64-bit classic file"
ECODE=1
fi
echo "Test extended format output for a 64-bit CDF-5 classic file"
rm -f tmp
${NCGEN} -k5 -b -o ./test.nc $srcdir/ref_tst_small.cdl
${NCDUMP} -K test.nc >tmp
if ! grep -F '64-bit data mode=00000020' <tmp ; then
echo "*** Fail: extended format for a 64-bit CDF-5 classic file"
ECODE=1
# Only do following test if USE_CDF5 is true.
if [ "x$USE_CDF5" == "x1" ]; then
echo "Test extended format output for a 64-bit CDF-5 classic file"
rm -f tmp
${NCGEN} -k5 -b -o ./test.nc $srcdir/ref_tst_small.cdl
${NCDUMP} -K test.nc >tmp
if ! grep -F '64-bit data mode=00000020' <tmp ; then
echo "*** Fail: extended format for a 64-bit CDF-5 classic file"
ECODE=1
fi
fi
rm -f tmp test.nc
exit $ECODE

View File

@ -1,8 +1,20 @@
#!/bin/sh
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
# get some config.h parameters
if test -f ${top_builddir}/config.h ; then
if fgrep -e '#define USE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
HAVE_CDF5=1
else
HAVE_CDF5=0
fi
else
echo "Cannot locate config.h"
exit 1
fi
# It is unreasonable to test actual lengths of files
# (even netcdf-3 files).
#However, the files created in this script are used in later ones
@ -10,7 +22,7 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi
${NCGEN} -b ${srcdir}/small.cdl
${NCGEN} -b ${srcdir}/small2.cdl
# This shell script tests lengths of small netcdf files and tests
# This shell script tests lengths of small netcdf files and tests
# that rewriting a numeric value doesn't change file length
# $Id: tst_lengths.sh,v 1.10 2008/08/07 00:07:52 ed Exp $
@ -93,39 +105,44 @@ ${NCGEN} -b -k64-bit-offset -x ${srcdir}/small.cdl && ${execdir}/rewrite-scalar
# exit 1
#fi
echo "*** testing length of 64-bit data file"
${NCGEN} -b -k64-bit-data ${srcdir}/small.cdl
if test `wc -c < small.nc` != 104; then
exit 1
# The following tests only occur if we have CDF5.
if [ "x$HAVE_CDF5" == "x1" ]; then
echo "*** testing length of 64-bit data file"
${NCGEN} -b -k64-bit-data ${srcdir}/small.cdl
if test `wc -c < small.nc` != 104; then
exit 1
fi
echo "*** testing length of 64-bit data file"
${NCGEN} -b -5 ${srcdir}/small.cdl
if test `wc -c < small.nc` != 104; then
exit 1
fi
echo "*** testing length of 64-bit data file written with NOFILL"
${NCGEN} -b -5 -x ${srcdir}/small.cdl
#if test `wc -c < small.nc` != 104; then
# exit 1
#fi
echo "*** testing length of rewritten 64-bit data file"
${NCGEN} -b -5 ${srcdir}/small.cdl && ${execdir}/rewrite-scalar small.nc t
# Watch out, it appears that the CDF-5 files are being rounded up to next page size
# So, we need to truncate them wrt nul's in order to check size.
# Bad hack, but what else can I do?
if test `${execdir}/nctrunc <small.nc |wc -c` != 104; then
exit 1
fi
echo "*** testing length of rewritten 64-bit data file written with NOFILL"
${NCGEN} -b -5 -x ${srcdir}/small.cdl && ${execdir}/rewrite-scalar small.nc t
#if test `wc -c < small.nc` != 104; then
# exit 1
#fi
# End HAVE_CDF5 block.
fi
echo "*** testing length of 64-bit data file"
${NCGEN} -b -5 ${srcdir}/small.cdl
if test `wc -c < small.nc` != 104; then
exit 1
fi
echo "*** testing length of 64-bit data file written with NOFILL"
${NCGEN} -b -5 -x ${srcdir}/small.cdl
#if test `wc -c < small.nc` != 104; then
# exit 1
#fi
echo "*** testing length of rewritten 64-bit data file"
${NCGEN} -b -5 ${srcdir}/small.cdl && ${execdir}/rewrite-scalar small.nc t
# Watch out, it appears that the CDF-5 files are being rounded up to next page size
# So, we need to truncate them wrt nul's in order to check size.
# Bad hack, but what else can I do?
if test `${execdir}/nctrunc <small.nc |wc -c` != 104; then
exit 1
fi
echo "*** testing length of rewritten 64-bit data file written with NOFILL"
${NCGEN} -b -5 -x ${srcdir}/small.cdl && ${execdir}/rewrite-scalar small.nc t
#if test `wc -c < small.nc` != 104; then
# exit 1
#fi
# test with only one record variable of type byte or short, which need
# not be 4-byte aligned
echo "*** testing length of one-record-variable classic file"
@ -134,22 +151,28 @@ ${NCGEN} -b ${srcdir}/small2.cdl
# exit 1
#fi
echo "*** testing length of one-record-variable 64-bit data file"
${NCGEN} -b -5 ${srcdir}/small2.cdl
if test `wc -c < small2.nc` != 161; then
exit 1
fi
# The following tests only occur if we have CDF5.
if [ "x$HAVE_CDF5" == "x1" ]; then
echo "*** testing length of one-record-variable 64-bit data file"
${NCGEN} -b -5 ${srcdir}/small2.cdl
if test `wc -c < small2.nc` != 161; then
exit 1
fi
echo "*** testing length of one-record-variable 64-bit data file"
${NCGEN} -b -5 ${srcdir}/small2.cdl
if test `wc -c < small2.nc` != 161; then
exit 1
fi
echo "*** testing length of one-record-variable 64-bit data file written with NOFILL"
${NCGEN} -b -5 -x ${srcdir}/small2.cdl
if test `wc -c < small2.nc` != 161; then
exit 1
echo "*** testing length of one-record-variable 64-bit data file"
${NCGEN} -b -5 ${srcdir}/small2.cdl
if test `wc -c < small2.nc` != 161; then
exit 1
fi
echo "*** testing length of one-record-variable 64-bit data file written with NOFILL"
${NCGEN} -b -5 -x ${srcdir}/small2.cdl
if test `wc -c < small2.nc` != 161; then
exit 1
fi
#end HAVE_CDF5 block
fi
echo "*** testing length of one-record-variable classic file written with NOFILL"