merged ejh_test_null_vars_stride this time I mean it!

This commit is contained in:
Ed Hartnett 2019-01-03 06:36:58 -07:00
commit f8a33aace5
23 changed files with 134 additions and 22 deletions

View File

@ -1,7 +1,5 @@
#!/bin/sh
#Q=-q
# This shell gets some sample HDF4 files from the netCDF ftp site for
# testing. Then it runs program tst_interops3 on the test file to
# check that HDF4 reading works.
@ -11,6 +9,9 @@
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
# Uncomment for quiet wget operation.
#Q=-q
# Get a file from the ftp site; retry several times
getfile() {
FTPFILE="ftp://ftp.unidata.ucar.edu/pub/netcdf/sample_data/hdf4/$1.gz"
@ -18,7 +19,7 @@ getfile() {
for try in 1 2 3 4 ; do # try 4 times
# signal success/failure
if wget -c $Q --passive-ftp $FTPFILE ; then
if wget -c $Q --passive-ftp $FTPFILE || curl -O $FTPFILE ; then
return 0 # got it
fi
echo "wget failed: try $try"

View File

@ -40,10 +40,13 @@ extern "C" {
extern int
NC_HDF4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
void* parameters, NC_Dispatch*, NC*);
void *parameters, NC_Dispatch *, NC *);
extern int
NC_HDF4_close(int ncid);
NC_HDF4_abort(int ncid);
extern int
NC_HDF4_close(int ncid, void *ignore);
extern int
NC_HDF4_inq_format(int ncid, int *formatp);

View File

@ -699,10 +699,10 @@ NC_check_nulls(int ncid, int varid, const size_t *start, size_t **count,
{
int i;
if (!(*stride = malloc(varndims * sizeof(size_t))))
if (!(*stride = malloc(varndims * sizeof(ptrdiff_t))))
return NC_ENOMEM;
for (i = 0; i < varndims; i++)
*stride[i] = 1;
(*stride)[i] = 1;
}
return NC_NOERR;

View File

@ -24,7 +24,7 @@ NC_HDF4_open,
NC_RO_redef,
NC_RO__enddef,
NC_RO_sync,
NC_HDF4_close,
NC_HDF4_abort,
NC_HDF4_close,
NC_RO_set_fill,
NC_NOTNC3_inq_base_pe,

View File

@ -662,7 +662,7 @@ NC_HDF4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
}
/**
* @internal Close the HDF4 file.
* @internal Abort (close) the HDF4 file.
*
* @param ncid File ID.
*
@ -671,7 +671,23 @@ NC_HDF4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
* @author Ed Hartnett
*/
int
NC_HDF4_close(int ncid)
NC_HDF4_abort(int ncid)
{
return NC_HDF4_close(ncid, NULL);
}
/**
* @internal Close the HDF4 file.
*
* @param ncid File ID.
* @param ignore Ignore this pointer.
*
* @return ::NC_NOERR No error.
* @return ::NC_EBADID Bad ncid.
* @author Ed Hartnett
*/
int
NC_HDF4_close(int ncid, void *ignore)
{
NC_GRP_INFO_T *grp;
NC *nc;

View File

@ -20,6 +20,7 @@
* netCDF I/O.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>

View File

@ -26,6 +26,7 @@ See \ref copyright file for more info.
* Check the first new variable's begin to see whether it is less than
* the last variable's offset in the existing file.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <netcdf.h>

View File

@ -9,6 +9,7 @@ See \ref copyright file for more info.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <netcdf.h>

View File

@ -7,6 +7,7 @@
* Author: Wei-keng Liao.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -9,6 +9,7 @@ See \ref copyright file for more info.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <netcdf.h>

View File

@ -9,6 +9,7 @@ See \ref copyright file for more info.
*/
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>

View File

@ -9,6 +9,7 @@ See \ref copyright file for more info.
*/
#include <config.h>
#include <stdio.h>
#include <netcdf.h>

View File

@ -224,6 +224,81 @@ main(int argc, char **argv)
SUMMARIZE_ERR;
} /* next fill value method test */
} /* next fill val write test */
#define NDIM2 2
#define DIM1_NAME "dim1"
#define DIM2_NAME "dim2"
#define NTYPE 6
#define DATA_LEN 4
printf("*** testing handling of null strides with format %d... ",
format[f]);
{
char file_name[NC_MAX_NAME + 1];
char var_name[NC_MAX_NAME + 1];
int dimid[NDIM2];
int xtype[NTYPE] = {NC_BYTE, NC_CHAR, NC_SHORT, NC_INT, NC_FLOAT, NC_DOUBLE};
int type_size[NTYPE] = {1, 1, 2, 4, 4, 8};
int varid[NTYPE];
size_t start[NDIM2] = {0, 0};
size_t count[NDIM2] = {2, 2};
signed char data_byte[DATA_LEN] = {1, 2, 3, 4};
unsigned char data_char[DATA_LEN] = {1, 2, 3, 4};
short data_short[DATA_LEN] = {1, 2, 3, 4};
int data_int[DATA_LEN] = {1, 2, 3, 4};
float data_float[DATA_LEN] = {1, 2, 3, 4};
double data_double[DATA_LEN] = {1, 2, 3, 4};
void *data_ptr[NTYPE] = {data_byte, data_char, data_short, data_int, data_float, data_double};
int t;
/* Create the test file. */
sprintf(file_name, "%s_%d_null_strides.nc", FILE_NAME_BASE, format[f]);
if (nc_set_default_format(format[f], NULL)) ERR;
if (nc_create(file_name, 0, &ncid)) ERR;
if (nc_def_dim(ncid, DIM1_NAME, DIM_LEN, &dimid[0])) ERR;
if (nc_def_dim(ncid, DIM2_NAME, DIM_LEN, &dimid[1])) ERR;
for (t = 0; t < NTYPE; t++)
{
sprintf(var_name, "var_%d", xtype[t]);
if (nc_def_var(ncid, var_name, xtype[t], NDIM2, dimid, &varid[t])) ERR;
}
if (nc_enddef(ncid)) ERR;
/* Write some data. */
for (t = 0; t < NTYPE; t++)
{
if (nc_put_vars(ncid, varid[t], start, count, NULL, data_ptr[t])) ERR;
}
if (nc_close(ncid)) ERR;
/* Open the file and check data. */
{
int ndims, nvars, ngatts, unlimdimid;
if (nc_open(file_name, NC_NOWRITE, &ncid)) ERR;
if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR;
if (ndims != 2 || nvars != NTYPE || ngatts != 0 || unlimdimid != -1) ERR;
for (t = 0; t < NTYPE; t++)
{
nc_type my_type;
int var_ndims, natts;
int var_dimid[NDIM2];
void *data_in;
if (nc_inq_var(ncid, varid[t], NULL, &my_type, &var_ndims, var_dimid, &natts)) ERR;
if (my_type != xtype[t] || var_ndims != 2 || var_dimid[0] != dimid[0] ||
var_dimid[1] != dimid[1] || natts != 0) ERR;
if (!(data_in = malloc(DATA_LEN * type_size[t]))) ERR;
if (nc_get_vars(ncid, varid[t], start, count, NULL, data_in)) ERR;
if (memcmp(data_in, data_ptr[t], DATA_LEN * type_size[t])) ERR;
free(data_in);
}
if (nc_close(ncid)) ERR;
}
}
SUMMARIZE_ERR;
} /* next format */
}
FINAL_RESULTS;

View File

@ -8,10 +8,10 @@
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include <nc_tests.h>
#include "err_macros.h"
#include <netcdf.h>

View File

@ -9,6 +9,7 @@ See \ref copyright file for more info.
*/
#include <config.h>
#include <stdio.h>
#include <netcdf.h>

View File

@ -9,6 +9,7 @@
*/
#include <config.h>
#include <stdio.h> /* printf() */
#include <config.h>
#include <stdlib.h>

View File

@ -4,6 +4,7 @@
* $Id: util.c 2792 2014-10-27 06:02:59Z wkliao $
*********************************************************************/
#include <config.h>
#include <math.h> /* floor() */
#include "tests.h"

View File

@ -13,17 +13,15 @@ include $(top_srcdir)/lib_flags.am
# Un comment to use a more verbose test driver
#SH_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
TEST_EXTENSIONS = .sh
# Note which tests depend on other tests. necessary for make -j check
extradir =
TEST_EXTENSIONS = .sh
# Link to our assembled library.
AM_LDFLAGS += ${top_builddir}/liblib/libnetcdf.la
LDADD = ${top_builddir}/liblib/libnetcdf.la
# These are netCDF-4 C test programs which are built and run.
NC4_TESTS = tst_dims tst_dims2 tst_dims3 tst_files tst_files4 \
NC4_TESTS = tst_dims tst_dims2 tst_dims3 tst_files tst_files4 \
tst_vars tst_varms tst_unlim_vars tst_converts tst_converts2 tst_grps \
tst_grps2 tst_compounds tst_compounds2 tst_compounds3 tst_opaques \
tst_strings tst_strings2 tst_interops tst_interops4 tst_interops5 \
@ -42,7 +40,7 @@ NC4_TESTS += tst_h_strbug tst_h_refs
endif
# Build test programs plus programs used in test scripts.
check_PROGRAMS = $(NC4_TESTS) renamegroup tst_empty_vlen_unlim
check_PROGRAMS = $(NC4_TESTS) tst_empty_vlen_unlim
TESTS = $(NC4_TESTS) run_empty_vlen_test.sh
# Add these if large file tests are turned on.
@ -52,6 +50,7 @@ TESTS += tst_large tst_large2
endif
if BUILD_UTILITIES
check_PROGRAMS += renamegroup
TESTS += run_grp_rename.sh tst_misc.sh
endif
@ -108,6 +107,7 @@ endif
# Filter Tests (requires ncdump and ncgen)
if ENABLE_FILTER_TESTING
if BUILD_UTILITIES
extradir =
extra_PROGRAMS = test_filter test_filter_misc
TESTS += tst_filter.sh
endif

View File

@ -12,6 +12,7 @@ See \ref copyright file for more info.
Open a netcdf-4 file with horrendously large metadata.
*/
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

View File

@ -11,8 +11,8 @@
$Id$
*/
#include <netcdf.h>
#include <config.h>
#include <netcdf.h>
#include <nc_tests.h>
#include "err_macros.h"
#include <string.h>

View File

@ -402,16 +402,16 @@ main(int argc, char **argv)
{
#define VAR_NAME "Britany"
#define NDIMS 2
#define NDIMS2 2
#define TEXT_LEN 15
#define D0_NAME "time"
#define D1_NAME "tl"
int ncid, nvars_in, varids_in[1];
int time_dimids[NDIMS], time_id;
size_t time_count[NDIMS], time_index[NDIMS] = {0, 0};
int time_dimids[NDIMS2], time_id;
size_t time_count[NDIMS2], time_index[NDIMS2] = {0, 0};
const char ttext[TEXT_LEN]="20051224.150000";
int nvars, ndims, ngatts, unlimdimid;
int ndims_in, natts_in, dimids_in[NDIMS];
int ndims_in, natts_in, dimids_in[NDIMS2];
char var_name_in[NC_MAX_NAME + 1];
nc_type xtype_in;
@ -420,7 +420,7 @@ main(int argc, char **argv)
if (nc_def_dim(ncid, D0_NAME, NC_UNLIMITED, &time_dimids[0])) ERR;
if (nc_def_dim(ncid, D1_NAME, TEXT_LEN, &time_dimids[1])) ERR;
if (nc_def_var(ncid, D0_NAME, NC_CHAR, NDIMS, time_dimids, &time_id)) ERR;
if (nc_def_var(ncid, D0_NAME, NC_CHAR, NDIMS2, time_dimids, &time_id)) ERR;
/* Write one time to the coordinate variable. */
time_count[0] = 1;

View File

@ -12,6 +12,7 @@ See \ref copyright file for more info.
See https://bugtracking.unidata.ucar.edu/browse/NCF-326
for more information.
*/
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <netcdf.h>

View File

@ -387,6 +387,7 @@ main(int argc, char **argv)
{
int ncid, dimid[NDIMS2], varid;
size_t start[NDIMS2] = {0, 0}, count[NDIMS2] = {NX, NY};
ptrdiff_t stride[NDIMS2] = {1, 1};
double double_data[NX * NY];
/* Create file with two dims, one 2D var. */
@ -400,6 +401,10 @@ main(int argc, char **argv)
if (nc_put_vara_double(ncid + MILLION, 0, start, count, double_data) != NC_EBADID) ERR;
if (nc_put_vara_double(ncid + TEST_VAL_42, 0, start, count, double_data) != NC_EBADID) ERR;
/* Write some data. */
if (nc_put_vars_double(ncid, varid, start, count, NULL, double_data)) ERR;
if (nc_put_vars_double(ncid, varid, start, count, stride, double_data)) ERR;
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;