Fix failings of nc_test/run_inmemory.sh

re: issue https://github.com/Unidata/netcdf-c/issues/1233

Changes:

1. remove exit that was there for testing.
2. the program tst_open_mem must be netcdf-4 only.
3. fix some diff problems
   - Change dataset name for tst_inmemory4_create to tst_inmemory4
   - Modify tst_inmemory.c to reorder the variables (somewhat major rewrite)

Minor Unrelated Fixes:
1. fix comment problem in nc_provenance.h
2. Fix memory leak in tst_open_mem.c
3. fix ncdump/bindata.c to properly compile if netcdf4 is disabled.
4. minor changes to ncgen.l
This commit is contained in:
Dennis Heimbigner 2018-12-04 19:22:02 -07:00
parent 9aa821b6c2
commit 30d63bbaa5
8 changed files with 366 additions and 565 deletions

View File

@ -1,5 +1,6 @@
This directory contains various scripts for debugging by Dennis
Heimbigner @ Unidata.
DO NOT DELETE.
USE AT YOUR OWN PERIL.

View File

@ -97,7 +97,7 @@ NCLIB="${NCLIB}/build/liblib"
#G="-GUnix Makefiles"
#T="--trace-expand"
cmake "${G}" $FLAGS ..
if test "x$NOBUILD" == x ; then
if test "x$NOBUILD" = x ; then
make all
make test
fi

View File

@ -1,13 +1,12 @@
/* Copyright 2005-2018 University Corporation for Atmospheric
Research/Unidata. */
/**
/**
* @file
* @internal Contains information for creating provenance
* info and/or displaying provenance info.
*
* @author Dennis Heimbigner, Ward Fisher
*/
/**************************************************/
/**

View File

@ -16,7 +16,7 @@ CREATE3=tst_inmemory3_create
FILE4=tst_inmemory4
CREATE4=tst_inmemory4_create
# For tst_open_mem
# For tst_open_mem NETCDF4 only
OMEMFILE=f03tst_open_mem.nc
echo ""
@ -26,8 +26,9 @@ HASNC4=`${top_builddir}/nc-config --has-nc4`
# Execute the core of the inmemory tests
${execdir}/tst_inmemory
exit
if test "x$HASNC4" = xyes ; then
${execdir}/tst_open_mem ${srcdir}/${OMEMFILE}
fi
echo "**** Test ncdump of the resulting inmemory data"
${NCDUMP} -n "${FILE3}" ${FILE3}.nc > ${FILE3}.cdl
@ -36,8 +37,9 @@ diff -wb ${FILE3}.cdl ${CREATE3}.cdl
if test "x$HASNC4" = "xyes" ; then
${NCDUMP} ${FILE4}.nc > ${FILE4}.cdl
${NCDUMP} ${CREATE4}.nc > ${CREATE4}.cdl
${NCDUMP} -n ${FILE4} ${CREATE4}.nc > ${CREATE4}.cdl
diff -wb ${FILE4}.cdl ${CREATE4}.cdl
fi
# cleanup
rm -f ${FILE3}.nc ${FILE4}.nc ${CREATE3}.nc ${CREATE4}.nc

View File

@ -61,8 +61,8 @@ extern int H5Eprint1(FILE * stream);
#define NVARS0 3 /* # variables in define_metadata */
#define VAR0_NAME "nightlife"
#define VAR1_NAME "time"
#define VAR2_NAME "taxi_distance"
#define VAR1_NAME "taxi_distance"
#define VAR2_NAME "time"
/* Variable added by modify_file */
#define VAR3_NAME "miles"
@ -270,19 +270,19 @@ define_metadata(int ncid)
{
int stat = NC_NOERR;
int dimid[MAXDIMS], varid0, varid1, varid2;
short short_data[DIM1_LEN];
size_t start[1] = {0};
size_t count[1] = {DIM1_LEN};
int dimprod = (DIM0_LEN*DIM1_LEN);
int i;
float float_data;
int nightdata[DIM0_LEN*DIM1_LEN] ;
short taxi_distance[DIM1_LEN] ;
/* Create data to write */
float_data = FLOATVAL;
for (i = 0; i < DIM1_LEN; i++)
short_data[i] = i;
taxi_distance[i] = i;
for (i = 0; i < dimprod; i++)
nightdata[i] = (100*i);
@ -294,13 +294,13 @@ define_metadata(int ncid)
CHECK(nc_def_dim(ncid, DIM1_NAME, DIM1_LEN, &dimid[1]));
CHECK(nc_def_var(ncid, VAR0_NAME, NC_INT, 2, dimid, &varid0));
CHECK(nc_def_var(ncid, VAR1_NAME, NC_FLOAT, 0, NULL, &varid1));
CHECK(nc_def_var(ncid, VAR2_NAME, NC_SHORT, 1, &dimid[1], &varid2));
CHECK(nc_def_var(ncid, VAR1_NAME, NC_SHORT, 1, &dimid[1], &varid1));
CHECK(nc_def_var(ncid, VAR2_NAME, NC_FLOAT, 0, NULL, &varid2));
CHECK(nc_enddef(ncid));
CHECK(nc_put_vara_float(ncid, varid1, NULL, NULL, &float_data));
CHECK(nc_put_vara_short(ncid, varid2, start, count, short_data));
CHECK(nc_put_vara_short(ncid, varid1, start, count, taxi_distance));
CHECK(nc_put_var_float(ncid, varid2, &float_data));
{
size_t start[2] = {0,0};
@ -407,6 +407,7 @@ verify_file(int ncid, int modified, int extra)
float float_data_in;
int milesdata_in[MAXDIMLEN];
int expenses_in[MAXDIMLEN];
short taxi_distance_in[MAXDIMLEN];
int dimprod = DIM0_LEN * DIM1_LEN;
#ifdef USE_NETCDF4
int tmp;
@ -456,18 +457,23 @@ verify_file(int ncid, int modified, int extra)
if (strcmp(name_in, VAR0_NAME) || type_in != NC_INT || ndims_in != NDIMS0 ||
dimid_in[0] != 0 || dimid_in[1] != 1 || natts_in != 0) CHECK(NC_EINVAL);
CHECK(nc_inq_var(ncid, varid[1], name_in, &type_in, &ndims_in, dimid_in, &natts_in));
if (strcmp(name_in, VAR1_NAME) || type_in != NC_FLOAT || ndims_in != 0 ||
natts_in != 0) CHECK(NC_EINVAL);
if (strcmp(name_in, VAR1_NAME) || type_in != NC_SHORT || ndims_in != 1 || dimid_in[0] != 1 || natts_in != 0)
CHECK(NC_EINVAL);
CHECK(nc_inq_var(ncid, varid[2], name_in, &type_in, &ndims_in, dimid_in, &natts_in));
if (strcmp(name_in, VAR2_NAME) || type_in != NC_SHORT || ndims_in != 1 ||
dimid_in[0] != 1 || natts_in != 0) CHECK(NC_EINVAL);
if (strcmp(name_in, VAR2_NAME) || type_in != NC_FLOAT || ndims_in != 0 || natts_in != 0)
CHECK(NC_EINVAL);
CHECK(nc_get_var_int(ncid, varid[0], nightdata_in));
for(i=0;i<dimprod;i++) {
if(nightdata_in[i] != (100*i)) CHECK(NC_EINVAL);
}
CHECK(nc_get_vara_float(ncid, varid[1], NULL, NULL, &float_data_in));
CHECK(nc_get_var_short(ncid, varid[1], taxi_distance_in));
for(i=0;i<DIM1_LEN;i++) {
if(taxi_distance_in[i] != (i)) CHECK(NC_EINVAL);
}
CHECK(nc_get_var_float(ncid, varid[2], &float_data_in));
if (float_data_in != FLOATVAL) CHECK(NC_EINVAL);
if(modified) {

View File

@ -31,8 +31,12 @@ readfile(const char* path, NC_memio* memio)
#else
f = fopen(path,"r");
#endif
if(f == NULL)
{status = errno; goto done;}
if(f == NULL) {
fprintf(stderr,"cannot open file: %s\n",path);
fflush(stderr);
status = errno;
goto done;
}
/* get current filesize */
if(fseek(f,0,SEEK_END) < 0)
{status = errno; goto done;}
@ -56,6 +60,7 @@ readfile(const char* path, NC_memio* memio)
if(memio) {
memio->size = (size_t)filesize;
memio->memory = memory;
memory = NULL;
}
done:
if(status != NC_NOERR && memory != NULL)
@ -82,6 +87,8 @@ main(int argc, char** argv)
goto exit;
if((retval = nc_close(ncid)))
goto exit;
if(mem.memory)
free(mem.memory);
return 0;
exit:
fprintf(stderr,"retval=%d\n",retval);

View File

@ -431,13 +431,15 @@ Internal equivalent of ncaux_reclaim_data.
/* It is helpful to have a structure that contains memory and an offset */
typedef struct Reclaim {char* memory; ptrdiff_t offset;} Reclaim;
static ptrdiff_t read_alignment(ptrdiff_t offset, unsigned long alignment);
static int bin_reclaim_datar(Symbol* tsym, Reclaim* reclaim);
#ifdef USE_NETCDF4
static ptrdiff_t read_alignment(ptrdiff_t offset, unsigned long alignment);
static int bin_reclaim_usertype(Symbol* tsym, Reclaim* reclaim);
static int bin_reclaim_compound(Symbol* tsym, Reclaim* reclaim);
static int bin_reclaim_vlen(Symbol* tsym, Reclaim* reclaim);
static int bin_reclaim_enum(Symbol* tsym, Reclaim* reclaim);
static int bin_reclaim_opaque(Symbol* tsym, Reclaim* reclaim);
#endif
int
binary_reclaim_data(Symbol* tsym, void* memory, size_t count)
@ -493,6 +495,7 @@ bin_reclaim_datar(Symbol* tsym, Reclaim* reclaimer)
return stat;
}
#ifdef USE_NETCDF4
static int
bin_reclaim_usertype(Symbol* tsym, Reclaim* reclaimer)
{
@ -587,6 +590,7 @@ bin_reclaim_compound(Symbol* tsym, Reclaim* reclaimer)
done:
return stat;
}
#endif /*USE_NETCDF4*/
#endif /*ENABLE_BINARY*/

File diff suppressed because it is too large Load Diff