Merge branch 'master' into cdf5-sync-master

This commit is contained in:
Ward Fisher 2015-11-09 13:45:11 -07:00
commit c1210f4020
7 changed files with 120 additions and 9 deletions

View File

@ -32,10 +32,21 @@ before_script:
- export PATH=$HOME/usr/bin:$PATH
- cd -
- mkdir build
- cd build
- cmake .. -DENABLE_DOXYGEN=ON -DENABLE_EXTRA_TESTS=ON -DENABLE_HDF4=ON -DCMAKE_PREFIX_PATH=$HOME/usr
- mkdir build-all
- mkdir build-min
- cd build-min
- cmake .. -DENABLE_NETCDF_4=OFF -DENABLE_DAP=OFF -DCMAKE_PREFIX_PATH=$HOME/usr-min
- cd ..
- cd build-all
- cmake .. -DENABLE_MMAP=ON -DENABLE_DOXYGEN=ON -DENABLE_EXTRA_TESTS=ON -DENABLE_HDF4=ON -DCMAKE_PREFIX_PATH=$HOME/usr
- cd ..
script:
- cd build-min
- make -j 4
- make test
- cd ../build-all
- make -j 4
- make test

View File

@ -931,6 +931,10 @@ nc_def_var_extra(int ncid, int varid, int *shuffle, int *deflate,
if ((retval = check_chunksizes(grp, var, chunksizes)))
return retval;
for (d = 0; d < var->ndims; d++) {
if(var->dim[d]->len > 0 && chunksizes[d] > var->dim[d]->len)
return NC_EBADCHUNK;
}
/* Set the chunksizes for this variable. */
for (d = 0; d < var->ndims; d++)

View File

@ -253,6 +253,44 @@ main(int argc, char **argv)
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
printf("**** testing that too large chunksizes fail...");
{
#define D_SMALL_LEN2 66
int stat = NC_NOERR;
int ncid;
int nvars, ndims, ngatts, unlimdimid;
int contig;
int ndims_in, natts_in, dimids_in;
int small_dimid, medium_dimid, large_dimid;
int small_varid;
char var_name_in[NC_MAX_NAME + 1];
size_t chunks[1], chunksize_in;
nc_type xtype_in;
/* Create a netcdf-4 file with three dimensions. */
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
if (nc_def_dim(ncid, D_SMALL, D_SMALL_LEN2, &small_dimid)) ERR;
/* Add one var. */
if (nc_def_var(ncid, V_SMALL, NC_INT64, NDIMS1, &small_dimid, &small_varid)) ERR;
/* Attempt to set too large chunksizes */
chunks[0] = D_SMALL_LEN2 + 1;
stat = nc_def_var_chunking(ncid, small_varid, NC_CHUNKED, chunks);
if(stat != NC_EBADCHUNK) {
printf("Return code is '%s', expected NC_BADCHUNK",nc_strerror(stat));
ERR;
}
/* try agains with proper chunksize */
chunks[0] = D_SMALL_LEN2;
stat = nc_def_var_chunking(ncid, small_varid, NC_CHUNKED, chunks);
if(stat != NC_NOERR) {
printf("Return code is '%s', expected NC_NOERR",nc_strerror(stat));
ERR;
}
if (nc_abort(ncid)) ERR;
}
SUMMARIZE_ERR;
FINAL_RESULTS;
}

View File

@ -110,8 +110,11 @@ ENDIF()
ENDIF(CMAKE_COMPILER_IS_GNUCC OR APPLE)
IF(BUILD_DISKLESS)
add_sh_test(ncdump tst_inmemory)
ENDIF()
add_sh_test(ncdump tst_inmemory_nc3)
IF(USE_NETCDF4)
add_sh_test(ncdump tst_inmemory_nc4)
ENDIF(USE_NETCDF4)
ENDIF(BUILD_DISKLESS)
###
# This test fails on Visual Studio builds with bash.

View File

@ -38,7 +38,10 @@ TESTS += tst_iter.sh
endif
if BUILD_DISKLESS
TESTS += tst_inmemory.sh
TESTS += tst_inmemory_nc3.sh
if USE_NETCDF4
TESTS += tst_inmemory_nc4.sh
endif
endif
if USE_NETCDF4
@ -133,7 +136,7 @@ ref_tst_mud4_chars.cdl \
ref_tst_ncf213.cdl tst_h_scalar.sh \
run_utf8_nc4_tests.sh \
tst_formatx3.sh tst_formatx4.sh ref_tst_utf8_4.cdl \
CMakeLists.txt XGetopt.c tst_bom.sh tst_inmemory.sh
CMakeLists.txt XGetopt.c tst_bom.sh tst_inmemory_nc3.sh tst_inmemory_nc4.sh
# CDL files and Expected results
SUBDIRS=cdl expected

54
ncdump/tst_inmemory_nc3.sh Executable file
View File

@ -0,0 +1,54 @@
#!/bin/sh
verbose=1
set -e
set -x
if test "x$builddir" = "x"; then builddir=`pwd`; fi
if test "x$srcdir" = "x"; then srcdir=`dirname $0`; fi
# Make buildir absolute
cd $builddir
builddir=`pwd`
# Make srcdir be absolute
cd $srcdir
srcdir=`pwd`
cd $builddir
# Setup
PASS=1
# Define the .cdl files to test
CLASSIC="small ref_tst_nans ref_tst_utf8"
EXTENDED="ref_nc_test_netcdf4 ref_tst_comp ref_tst_opaque_data"
rm -fr ./results
mkdir ./results
# Dump classic files two ways and compare
dotest() {
K=$1
for f in $2 ; do
echo "Testing ${f}"
${builddir}/../ncgen/ncgen -$K -o ./results/${f}.nc ${srcdir}/${f}.cdl
./ncdump ./results/${f}.nc > ./results/${f}.cdl
./ncdump -Xm ./results/${f}.nc > ./results/${f}.cdx
diff -w ./results/${f}.cdl ./results/${f}.cdx &> ./results/${f}.diff
if test -s ./results/${f}.diff ; then
echo "***FAIL: $f"
PASS=0
fi
done
}
dotest "3" "$CLASSIC"
# Cleanup
rm -fr results
if test "x$PASS" = x1 ; then
echo "*** PASS all tests"
CODE=0
else
CODE=1
fi
exit $CODE

View File

@ -59,5 +59,3 @@ else
CODE=1
fi
exit $CODE