netcdf-c/ncdap_test/tst_ncdap.sh
Dennis Heimbigner 8072d1f6bb Modify DAP2 and DAP4 to optionally allow Fillvalue/Variable mismatch
re: issue https://github.com/Unidata/netcdf-c/issues/1151

Modify DAP2 and DAP4 code to handle case when _FillValue type is not
same as the parent variable type.

Specifically:
1. Define a parameter [fillmismatch] to allow this mismatch;
   default is to disallow.
2. If allowed, forcibly change the type of the _FillValue to match
   the parent variable.
3. If allowed Convert the values to match new type
4. Generate a log message
5. if not allowed, then fail

Implementing this required some changes to ncdap_test/dapcvt.c
Also added test cases.

Minor Unrelated Changes:
1. There were a number of warnings about e.g.
   assigning a const char* to a char*. Fix these
2. In nccopy.1, replace .NP with .IP "n"
   (re PR https://github.com/Unidata/netcdf-c/pull/1144)
3. fix minor error in ncdump/ocprint
2018-10-01 15:51:43 -06:00

121 lines
2.4 KiB
Bash
Executable File

#!/bin/sh
if test "x$SETX" != x ; then set -x ; fi
quiet=0
leakcheck=0
PARAMS="[log]"
#PARAMS="${PARAMS}[fetch=memory]"
#PARAMS="${PARAMS}[show=fetch]"
OCLOGFILE=/dev/null
# Capture arguments
srcdir="$1"
builddir="$2"
mode="$3"
# Locate the testdata and expected directory
testdata3="${srcdir}/testdata3"
expected3="${srcdir}/expected3"
TITLE="DAP to netCDF-3 translation"
EXPECTED="$expected3"
PARAMS="${PARAMS}[cache]"
# get the list of test files
. ${srcdir}/tst_ncdap_shared.sh
case "$mode" in
file*)
TESTURL="$FILEURL"
TESTSET="$FILETESTS"
;;
dds*)
TESTURL="[noprefetch]$FILEURL"
TESTSET="$DDSTESTS"
FLAGS="$FLAGS -h"
;;
remote*)
TESTURL="$REMOTEURL"
TITLE="Remote $TITLE"
TESTSET="$REMOTETESTS"
;;
esac
RESULTSDIR="./results_tst_ncdap"
#
if test "x$leakcheck" = "x1" ; then
VALGRIND="valgrind -q --error-exitcode=2 --leak-check=full"
fi
rm -fr ${RESULTSDIR}
mkdir "${RESULTSDIR}"
rm -f ./.dodsrc ./.ocrc ./.daprc
passcount=0
xfailcount=0
failcount=0
echo "*** Testing $TITLE "
echo " Base URL: ${TESTURL}"
echo " Client Parameters: ${PARAMS}"
cd ${RESULTSDIR}
for x in ${TESTSET} ; do
url="${PARAMS}${TESTURL}/$x"
if test "x$quiet" = "x0" ; then echo "*** Testing: ${x} ; url=$url" ; fi
# determine if this is an xfailtest
isxfail=0
for t in ${XFAILTESTS} ; do
if test "x${t}" = "x${x}" ; then isxfail=1; fi
done
ok=1
if ${VALGRIND} ${NCDUMP} ${FLAGS} "${url}" | sed 's/\\r//g' > ${x}.dmp ; then ok=$ok; else ok=0; fi
# compare with expected
if diff -w ${EXPECTED}/${x}.dmp ${x}.dmp ; then ok=$ok; else ok=0; fi
if test "$ok" = 1 ; then
status=0 # succeed
elif test "x$isxfail" = "x0" ; then
status=1 # fail
else
status=2 # xfail
fi
case "$status" in
0)
passcount=`expr $passcount + 1`
if test "x$quiet" = "x" ; then echo "*** SUCCEED: ${x}"; fi
;;
1)
failcount=`expr $failcount + 1`
echo "*** FAIL: ${x}"
;;
2)
xfailcount=`expr $xfailcount + 1`
echo "*** XFAIL : ${x}"
;;
esac
done
rm -f ./.dodsrc ./.ocrc ./.daprc
cd ..
echo "pwd=" `pwd`
totalcount=`expr $passcount + $failcount + $xfailcount`
okcount=`expr $passcount + $xfailcount`
rm -fr ${RESULTSDIR}
echo "*** PASSED: ${okcount}/${totalcount} ; ${xfailcount} expected failures ; ${failcount} unexpected failures"
#failcount=0
if test "$failcount" -gt 0
then
exit 1
else
exit 0
fi