netcdf-c/ncdump/tst_fileinfo.sh
Dennis Heimbigner 88a7a1753c Simplify libhdf5/nc5info.c to move to lazy parsing
re: https://github.com/Unidata/netcdf-c/issues/1352

When nc4info.c encounters an _NCProperties attribute
with a version number it does not recognize, it does not
show it correctly.

Solution chosen is to arrange so that accessing the attribute
returns the raw value of the Attribute from the file. This way,
even if the version is unrecognized, it will return something
usable.

The changes were primarily to never attempt to parse the value
of _NCProperties until actually required. Which since they
are currently not used means that parsing never occurs.

Also modified ncdump/tst_fileinfo.sh to include some extra testing

I tested the original failure by changing the value of NCPROPS to 3.
However, there is no way to test this at build time.

Misc. Changes
* Inlined the provenance info in the NC_FILE_INFO_T structure
* Centralized stuff from elsewhere into include/nc_provenance.h

Misc. Unrelated Changes
* Removed/turned off some misc debug output left on by accident
* Fix CPPFLAGS name error in libhdf5/Makefile.am
2019-03-09 20:35:57 -07:00

82 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
# Author: Dennis Heimbigner
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
set -e
echo ""
EXIT=0
NCF="./nc4_fileinfo.nc"
HDF="./hdf5_fileinfo.hdf"
NF="${top_srcdir}/ncdump/ref_tst_compounds4.nc"
NPV1="${top_srcdir}/ncdump/ref_provenance_v1.nc"
NPNCP="${top_srcdir}/ncdump/ref_no_ncproperty.nc"
# Create various files
${execdir}/tst_fileinfo
# Do a false negative test
rm -f ./tst_fileinfo.tmp
if $NCDUMP -s $NF | fgrep '_IsNetcdf4 = 0' > ./tst_fileinfo.tmp ; then
echo "Pass: False negative for file: $NF"
else
echo "FAIL: False negative for file: $NF"
EXIT=1
fi
rm -f ./tst_fileinfo.tmp
# Verify handling of a file with no _NCProperties attribute
rm -f ./tst_fileinfo.tmp
if $NCDUMP -s $NPNCP | fgrep '_NCProperties=' > ./tst_fileinfo.tmp ; then
echo "Fail: $NPNCP has _NCProperties attribute"
EXIT=1
else
echo "Pass: $NPNCP has no _NCProperties attribute"
fi
rm -f ./tst_fileinfo.tmp
if test -e $NCF ; then
# look at the _IsNetcdf4 flag
N_IS=`${NCDUMP} -s $NCF | fgrep '_IsNetcdf4' | tr -d ' ;'`
N_IS=`echo $N_IS | cut -d= -f2`
H_IS=`${NCDUMP} -s $HDF | fgrep '_IsNetcdf4' | tr -d ' ;'`
H_IS=`echo $H_IS | cut -d= -f2`
if test "x$N_IS" = 'x0' ;then
echo "FAIL: $NCF is marked as not netcdf-4"
EXIT=1
fi
if test "x$H_IS" = 'x1' ;then
echo "FAIL: $HDF is marked as netcdf-4"
EXIT=1
fi
else
echo "FAIL: tst_fileinfo: $NCF does not exist"
EXIT=1
fi
echo "PASS: $NCF is marked as netcdf-4"
# Test what happens when we read a file that used provenance version 1
rm -f ./tst_fileinfo.tmp ./tst_fileinfo2.tmp
$NCDUMP -hs $NPV1 >tst_fileinfo2.tmp
fgrep '_NCProperties' <tst_fileinfo2.tmp > ./tst_fileinfo.tmp
if ! XXX=`fgrep 'version=1' tst_fileinfo.tmp` ; then
echo "FAIL: $NPV1 is not marked as version=1"
EXIT=1
fi
echo "PASS: $NPV1 is marked as version=1"
rm -f $NCF
rm -f $HDF
rm -f tst_fileinfo.tmp tst_fileinfo2.tmp
if test "x$EXIT" = x0 ; then
echo "*** Pass all tests"
else
echo "*** FAIL one or more tests"
fi
exit $EXIT