2016-05-04 11:17:06 +08:00
|
|
|
#!/bin/sh
|
2018-08-26 11:44:41 +08:00
|
|
|
# Author: Dennis Heimbigner
|
2016-05-04 11:17:06 +08:00
|
|
|
|
2018-04-18 04:23:52 +08:00
|
|
|
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
|
2017-03-09 08:01:10 +08:00
|
|
|
. ../test_common.sh
|
2016-05-04 11:17:06 +08:00
|
|
|
|
2017-03-09 08:01:10 +08:00
|
|
|
set -e
|
|
|
|
echo ""
|
2016-05-04 11:17:06 +08:00
|
|
|
|
|
|
|
EXIT=0
|
|
|
|
|
2018-08-26 11:44:41 +08:00
|
|
|
NCF="./nc4_fileinfo.nc"
|
|
|
|
HDF="./hdf5_fileinfo.hdf"
|
|
|
|
|
|
|
|
NF="${top_srcdir}/ncdump/ref_tst_compounds4.nc"
|
|
|
|
NPV1="${top_srcdir}/ncdump/ref_provenance_v1.nc"
|
2019-03-10 11:35:57 +08:00
|
|
|
NPNCP="${top_srcdir}/ncdump/ref_no_ncproperty.nc"
|
2018-08-26 11:44:41 +08:00
|
|
|
|
|
|
|
# Create various files
|
|
|
|
${execdir}/tst_fileinfo
|
2016-05-04 11:17:06 +08:00
|
|
|
|
2018-04-18 04:23:52 +08:00
|
|
|
# Do a false negative test
|
2018-08-26 11:44:41 +08:00
|
|
|
rm -f ./tst_fileinfo.tmp
|
|
|
|
if $NCDUMP -s $NF | fgrep '_IsNetcdf4 = 0' > ./tst_fileinfo.tmp ; then
|
2016-05-04 11:17:06 +08:00
|
|
|
echo "Pass: False negative for file: $NF"
|
|
|
|
else
|
|
|
|
echo "FAIL: False negative for file: $NF"
|
2018-08-26 11:44:41 +08:00
|
|
|
EXIT=1
|
2016-05-04 11:17:06 +08:00
|
|
|
fi
|
2019-03-10 11:35:57 +08:00
|
|
|
rm -f ./tst_fileinfo.tmp
|
2016-05-04 11:17:06 +08:00
|
|
|
|
2019-03-10 11:35:57 +08:00
|
|
|
# Verify handling of a file with no _NCProperties attribute
|
2018-08-26 11:44:41 +08:00
|
|
|
rm -f ./tst_fileinfo.tmp
|
2019-03-10 11:35:57 +08:00
|
|
|
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
|
|
|
|
|
2018-08-26 11:44:41 +08:00
|
|
|
if test -e $NCF ; then
|
2016-05-04 11:17:06 +08:00
|
|
|
# look at the _IsNetcdf4 flag
|
2017-03-09 08:01:10 +08:00
|
|
|
N_IS=`${NCDUMP} -s $NCF | fgrep '_IsNetcdf4' | tr -d ' ;'`
|
2016-05-04 11:17:06 +08:00
|
|
|
N_IS=`echo $N_IS | cut -d= -f2`
|
2017-03-09 08:01:10 +08:00
|
|
|
H_IS=`${NCDUMP} -s $HDF | fgrep '_IsNetcdf4' | tr -d ' ;'`
|
2016-05-04 11:17:06 +08:00
|
|
|
H_IS=`echo $H_IS | cut -d= -f2`
|
|
|
|
if test "x$N_IS" = 'x0' ;then
|
|
|
|
echo "FAIL: $NCF is marked as not netcdf-4"
|
2018-08-26 11:44:41 +08:00
|
|
|
EXIT=1
|
2016-05-04 11:17:06 +08:00
|
|
|
fi
|
|
|
|
if test "x$H_IS" = 'x1' ;then
|
|
|
|
echo "FAIL: $HDF is marked as netcdf-4"
|
2018-08-26 11:44:41 +08:00
|
|
|
EXIT=1
|
2016-05-04 11:17:06 +08:00
|
|
|
fi
|
|
|
|
else
|
2018-08-26 11:44:41 +08:00
|
|
|
echo "FAIL: tst_fileinfo: $NCF does not exist"
|
|
|
|
EXIT=1
|
|
|
|
fi
|
2019-03-10 11:35:57 +08:00
|
|
|
echo "PASS: $NCF is marked as netcdf-4"
|
2018-08-26 11:44:41 +08:00
|
|
|
|
|
|
|
# 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
|
2019-03-10 11:35:57 +08:00
|
|
|
if ! XXX=`fgrep 'version=1' tst_fileinfo.tmp` ; then
|
2018-08-26 11:44:41 +08:00
|
|
|
echo "FAIL: $NPV1 is not marked as version=1"
|
|
|
|
EXIT=1
|
2016-05-04 11:17:06 +08:00
|
|
|
fi
|
2019-03-10 11:35:57 +08:00
|
|
|
echo "PASS: $NPV1 is marked as version=1"
|
2016-05-04 11:17:06 +08:00
|
|
|
|
|
|
|
rm -f $NCF
|
|
|
|
rm -f $HDF
|
2019-01-21 01:02:31 +08:00
|
|
|
rm -f tst_fileinfo.tmp tst_fileinfo2.tmp
|
2016-05-04 11:17:06 +08:00
|
|
|
|
2018-08-26 11:44:41 +08:00
|
|
|
if test "x$EXIT" = x0 ; then
|
|
|
|
echo "*** Pass all tests"
|
2019-03-10 11:35:57 +08:00
|
|
|
else
|
|
|
|
echo "*** FAIL one or more tests"
|
2018-08-26 11:44:41 +08:00
|
|
|
fi
|
2016-05-04 11:17:06 +08:00
|
|
|
exit $EXIT
|