netcdf-c/ncdump/run_ncgen_nc4_tests.sh

66 lines
1.8 KiB
Bash
Raw Permalink Normal View History

2017-05-25 04:37:54 +08:00
#!/bin/sh
# This shell script runs the ncdump tests.
2017-11-19 05:20:04 +08:00
# Dennis Heimbigner
2017-05-25 04:37:54 +08:00
if test "x$srcdir" = x ; then srcdir="."; fi
. ../test_common.sh
##
# Function to test a netCDF CDL file.
2017-11-19 05:20:04 +08:00
# First generate binary nc. Then use ncdump to compare against
# original CDL file.
2017-05-25 04:37:54 +08:00
# Input: CDL file name, minus the suffix, output filename
# Other input: arguments.
#
# Example:
# $ validateNC compound_datasize_test -k nc4
##
validateNC() {
ORIGNAME=$1
BASENAME=tst_$1_run_ncgen_nc4_tests
2017-05-25 04:37:54 +08:00
INFILE=$top_srcdir/ncgen/$1.cdl
TMPFILE=tst_$2.cdl
shift
shift
ARGS=$@
echo "*** generating $BASENAME.nc ***"
${NCGEN} $ARGS -o $BASENAME.nc $INFILE
${NCDUMP} -n $ORIGNAME $BASENAME.nc | sed 's/e+0/e+/g' > $TMPFILE
2017-05-25 04:37:54 +08:00
echo "*** comparing binary against source CDL file *** "
diff -b -w $INFILE $TMPFILE
}
echo "*** Testing ncgen for netCDF-4."
set -e
echo "*** creating netCDF-4 file c0_4.nc from c0_4.cdl..."
validateNC "c0_4" "c0_4" -k nc4 -b -o c0_4.nc
echo "*** creating netCDF-4 classic model file c0_4c.nc from c0.cdl..."
validateNC "c0" "c0_4c" -k nc7 -b
echo "*** creating C code for CAM file ref_camrun.cdl..."
2017-11-19 05:20:04 +08:00
${NCGEN} -lc $top_srcdir/ncgen/ref_camrun.cdl > camrun.c
2017-05-25 04:37:54 +08:00
echo "*** test for jira NCF-199 bug"
validateNC "ncf199" "ncf199" -k nc4
Fix more memory leaks in netcdf-c library This is a follow up to PR https://github.com/Unidata/netcdf-c/pull/1173 Sorry that it is so big, but leak suppression can be complex. This PR fixes all remaining memory leaks -- as determined by -fsanitize=address, and with the exceptions noted below. Unfortunately. there remains a significant leak that I cannot solve. It involves vlens, and it is unclear if the leak is occurring in the netcdf-c library or the HDF5 library. I have added a check_PROGRAM to the ncdump directory to show the problem. The program is called tst_vlen_demo.c To exercise it, build the netcdf library with -fsanitize=address enabled. Then go into ncdump and do a "make clean check". This should build tst_vlen_demo without actually executing it. Then do the command "./tst_vlen_demo" to see the output of the memory checker. Note the the lost malloc is deep in the HDF5 library (in H5Tvlen.c). I am temporarily working around this error in the following way. 1. I modified several test scripts to not execute known vlen tests that fail as described above. 2. Added an environment variable called NC_VLEN_NOTEST. If set, then those specific tests are suppressed. This should mean that the --disable-utilities option to ./configure should not need to be set to get a memory leak clean build. This should allow for detection of any new leaks. Note: I used an environment variable rather than a ./configure option to control the vlen tests. This is because it is temporary (I hope) and because it is a bit tricky for shell scripts to access ./configure options. Finally, as before, this only been tested with netcdf-4 and hdf5 support.
2018-11-16 01:00:38 +08:00
if test "x$NC_VLEN_NOTEST" = x ; then
2017-05-25 04:37:54 +08:00
echo "*** creating binary files for github issue 323..."
echo "*** github issue 323 test 1"
validateNC "compound_datasize_test" "compound_datasize_test" -k nc4
Fix more memory leaks in netcdf-c library This is a follow up to PR https://github.com/Unidata/netcdf-c/pull/1173 Sorry that it is so big, but leak suppression can be complex. This PR fixes all remaining memory leaks -- as determined by -fsanitize=address, and with the exceptions noted below. Unfortunately. there remains a significant leak that I cannot solve. It involves vlens, and it is unclear if the leak is occurring in the netcdf-c library or the HDF5 library. I have added a check_PROGRAM to the ncdump directory to show the problem. The program is called tst_vlen_demo.c To exercise it, build the netcdf library with -fsanitize=address enabled. Then go into ncdump and do a "make clean check". This should build tst_vlen_demo without actually executing it. Then do the command "./tst_vlen_demo" to see the output of the memory checker. Note the the lost malloc is deep in the HDF5 library (in H5Tvlen.c). I am temporarily working around this error in the following way. 1. I modified several test scripts to not execute known vlen tests that fail as described above. 2. Added an environment variable called NC_VLEN_NOTEST. If set, then those specific tests are suppressed. This should mean that the --disable-utilities option to ./configure should not need to be set to get a memory leak clean build. This should allow for detection of any new leaks. Note: I used an environment variable rather than a ./configure option to control the vlen tests. This is because it is temporary (I hope) and because it is a bit tricky for shell scripts to access ./configure options. Finally, as before, this only been tested with netcdf-4 and hdf5 support.
2018-11-16 01:00:38 +08:00
fi
2017-05-25 04:37:54 +08:00
echo "*** github issue 323 test 2"
validateNC "compound_datasize_test2" "compound_datasize_test2" -k nc4
echo "*** Global Attribute with Enum type"
validateNC "tst_gattenum" "tst_gattenum" -k nc4
echo "*** Integer constant with just 'u' suffix"
validateNC "tst_usuffix" "tst_usuffix" -k nc4
echo "*** Test successful!"
exit 0