1#!/bin/sh 2# This shell script tests ncdump for netcdf-4 3# Ed Hartnett, Dennis Heimbigner, Ward Fisher 4 5if test "x$srcdir" = x ; then srcdir=`pwd`; fi 6. ../test_common.sh 7 8set -e 9 10# Remove the version information from _NCProperties 11cleanncprops() { 12 src="$1" 13 dst="$2" 14 rm -f $dst 15 cat $src \ 16 | sed -e 's/_SuperblockVersion = 1/_SuperblockVersion = 0/' \ 17 | sed -e 's/\(netcdflibversion\|netcdf\)=.*|/\1=NNNN|/' \ 18 | sed -e 's/\(hdf5libversion\|hdf5\)=.*"/\1=HHHH"/' \ 19 | grep -v '_NCProperties' \ 20 | cat >$dst 21} 22 23ERR() { 24 RES=$? 25 if [ $RES -ne 0 ]; then 26 echo "Error found: $RES" 27 exit $RES 28 fi 29} 30 31echo "" 32echo "*** Testing ncgen and ncdump for netCDF-4 format." 33${NCGEN} -k nc4 -b -o tst_netcdf4_c0_4.nc ${ncgenc04} ;ERR 34${NCDUMP} -n c1 tst_netcdf4_c0_4.nc | sed 's/e+0/e+/g' > tst_netcdf4_c1_4.cdl ; ERR 35diff -b tst_netcdf4_c1_4.cdl $srcdir/ref_ctest1_nc4.cdl ; ERR 36 37echo "*** Creating test output tst_netcdf4_c0.nc." 38${NCGEN} -k nc7 -b -o tst_netcdf4_c0.nc ${ncgenc0} ; ERR 39 40echo "*** Testing that program tst_h_rdc0 can read tst_netcdf4_c0.nc." 41${execdir}/tst_h_rdc0 ; ERR 42 43echo "*** Running tst_create_files.c to create test files." 44${execdir}/tst_create_files ; ERR 45echo "*** Testing tst_create_files output for netCDF-4 features." 46${NCDUMP} tst_solar_1.nc | sed 's/e+0/e+/g' > tst_solar_1.cdl ; ERR 47diff -b tst_solar_1.cdl $srcdir/ref_tst_solar_1.cdl ; ERR 48${NCDUMP} tst_solar_2.nc | sed 's/e+0/e+/g' > tst_solar_2.cdl ; ERR 49diff -b tst_solar_2.cdl $srcdir/ref_tst_solar_2.cdl ; ERR 50 51echo "*** Running tst_group_data.c to create test files." 52${execdir}/tst_group_data ; ERR 53${NCDUMP} tst_group_data.nc | sed 's/e+0/e+/g' > tst_group_data.cdl ; ERR 54diff -b tst_group_data.cdl $srcdir/ref_tst_group_data.cdl ; ERR 55 56echo "*** Testing -v option with absolute name and groups..." 57${NCDUMP} -v g2/g3/var tst_group_data.nc | sed 's/e+0/e+/g' > tst_group_data.cdl ; ERR 58diff -b tst_group_data.cdl $srcdir/ref_tst_group_data_v23.cdl ; ERR 59 60echo "*** Testing -v option with relative name and groups..." 61${NCDUMP} -v var,var2 tst_group_data.nc | sed 's/e+0/e+/g' > tst_group_data.cdl ; ERR 62diff -b tst_group_data.cdl $srcdir/ref_tst_group_data.cdl ; ERR 63 64echo "*** Running tst_enum_data.c to create test files." 65${execdir}/tst_enum_data ; ERR 66${NCDUMP} tst_enum_data.nc | sed 's/e+0/e+/g' > tst_enum_data.cdl ; ERR 67diff -b tst_enum_data.cdl $srcdir/ref_tst_enum_data.cdl ; ERR 68 69echo "*** Running tst_opaque_data.c to create test files." 70${execdir}/tst_opaque_data ; ERR 71${NCDUMP} tst_opaque_data.nc | sed 's/e+0/e+/g' > tst_opaque_data.cdl ; ERR 72diff -b tst_opaque_data.cdl $srcdir/ref_tst_opaque_data.cdl ; ERR 73 74if test "x$NC_VLEN_NOTEST" = x ; then 75echo "*** Running tst_vlen_data.c to create test files." 76${execdir}/tst_vlen_data ; ERR 77${NCDUMP} tst_vlen_data.nc | sed 's/e+0/e+/g' > tst_vlen_data.cdl ; ERR 78diff -b tst_vlen_data.cdl $srcdir/ref_tst_vlen_data.cdl ; ERR 79fi 80 81echo "*** Running tst_comp.c to create test files." 82${execdir}/tst_comp ; ERR 83${NCDUMP} tst_comp.nc | sed 's/e+0/e+/g' > tst_comp.cdl ; ERR 84diff -b tst_comp.cdl $srcdir/ref_tst_comp.cdl ; ERR 85 86echo "*** Running tst_nans.c to create test files." 87${execdir}/tst_nans ; ERR 88${NCDUMP} tst_nans.nc | sed 's/e+0/e+/g' > tst_nans.cdl ; ERR 89diff -b tst_nans.cdl $srcdir/ref_tst_nans.cdl ; ERR 90 91# Do unicode test only if it exists => BUILD_UTF8 is true 92if test -f ./tst_unicode -o -f ./tst_unicode.exe ; then 93 echo "*** dumping tst_unicode.nc to tst_unicode.cdl..." 94 ${execdir}/tst_unicode ; ERR 95${NCDUMP} tst_unicode.nc | sed 's/e+0/e+/g' > tst_unicode.cdl ; ERR 96 #echo "*** comparing tst_unicode.cdl with ref_tst_unicode.cdl..." 97 #diff -b tst_unicode.cdl $srcdir/ref_tst_unicode.cdl 98fi 99 100echo "*** Running tst_special_atts.c to create test files." 101${execdir}/tst_special_atts ; ERR 102${NCDUMP} -c -s tst_special_atts.nc > tst_special_atts.cdl ; ERR 103cleanncprops tst_special_atts.cdl tst_special_atts.tmp 104cleanncprops $srcdir/ref_tst_special_atts.cdl ref_tst_special_atts.tmp 105echo "*** comparing tst_special_atts.cdl with ref_tst_special_atts.cdl..." 106diff -b tst_special_atts.tmp ref_tst_special_atts.tmp ; ERR 107 108#echo "" 109#echo "*** Testing ncdump on file with corrupted header " 110#rm -f ./ignore_tst_netcdf4 111#if ${NCDUMP} ${srcdir}/ref_test_corrupt_magic.nc > ./ignore_tst_netcdf4 2>&1 ; then 112#echo "***Fail: ncdump should have failed on ref_test_corrupt_magic.nc" 113#else 114#echo "***XFail: ncdump properly failed on ref_test_corrupt_magic.nc" 115#fi 116#rm -fr ./ignore_tst_netcdf4 117 118# This should work, but does not. See github issue 982. 119#echo "*** creating tst_output_irish_rover.cdl from ref_tst_irish_rover.nc..." 120#${NCDUMP} ref_tst_irish_rover.nc > tst_output_irish_rover.cdl 121 122rm -f *.tmp 123echo "*** All ncgen and ncdump test output for netCDF-4 format passed!" 124exit 0 125