Skip to content

Commit

Permalink
Merge pull request #680 from NetCDF-World-Domination-Council/ejh_ncfu…
Browse files Browse the repository at this point in the history
…nc_testing

improve parallel builds, fixed SEGFAULT for NULL parameter for nc_inq_format(), added testing, documentation
  • Loading branch information
WardF committed Nov 29, 2017
2 parents f480dfd + 3c5404c commit f69e031
Show file tree
Hide file tree
Showing 48 changed files with 1,187 additions and 1,275 deletions.
4 changes: 1 addition & 3 deletions h5_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SET(H5TESTS tst_h_files tst_h_files2 tst_h_files4 tst_h_atts tst_h_atts3 tst_h_atts4 tst_h_vars tst_h_vars2 tst_h_vars3 tst_h_grps tst_h_compounds tst_h_compounds2 tst_h_wrt_cmp tst_h_rd_cmp tst_h_vl tst_h_opaques tst_h_strings tst_h_strings1 tst_h_strings2 tst_h_ints tst_h_dimscales tst_h_dimscales1 tst_h_dimscales2 tst_h_dimscales3 tst_h_enums tst_h_dimscales4)
SET(H5TESTS tst_h_files tst_h_files2 tst_h_files4 tst_h_atts tst_h_atts3 tst_h_atts4 tst_h_vars tst_h_vars2 tst_h_vars3 tst_h_grps tst_h_compounds tst_h_compounds2 tst_h_wrt_cmp tst_h_vl tst_h_opaques tst_h_strings tst_h_strings1 tst_h_strings2 tst_h_ints tst_h_dimscales tst_h_dimscales1 tst_h_dimscales2 tst_h_dimscales3 tst_h_enums tst_h_dimscales4)

FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h5 ${CMAKE_CURRENT_SOURCE_DIR}/*.nc)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
Expand All @@ -12,5 +12,3 @@ FOREACH(CTEST ${H5TESTS})
)
ADD_TEST(${CTEST} ${EXECUTABLE_OUTPUT_PATH}/${CTEST})
ENDFOREACH()

SET_TESTS_PROPERTIES(tst_h_rd_cmp PROPERTIES DEPENDS tst_h_wrt_cmp)
4 changes: 3 additions & 1 deletion h5_test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# only use HDF5; these tests don't use netCDF at all.
#
# If one of these tests fails, then netCDF-4 will not work correctly.
# Ed Hartnett, Ward Fisher

# Set AM_CPPFLAGS and AM_LDFLAGS based on user choices.
include $(top_srcdir)/lib_flags.am
Expand Down Expand Up @@ -46,7 +47,8 @@ endif # USE_VALGRIND_TESTS
# We must include these files in the distribution.
EXTRA_DIST = run_par_tests.sh run_valgrind_tests.sh \
ref_tst_h_compounds.h5 ref_tst_h_compounds2.h5 run_par_tests.sh \
run_valgrind_tests.sh ref_tst_compounds.nc h5_err_macros.h CMakeLists.txt
run_valgrind_tests.sh ref_tst_compounds.nc h5_err_macros.h \
CMakeLists.txt

# Clean up test results.
CLEANFILES = tst_h_*.h5
2 changes: 1 addition & 1 deletion h5_test/tst_h_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ main()
printf("*** large file test for HDF5...");
{
hid_t fapl_id, fcpl_id, fileid, grpid, spaceid, datasetid;
hid_t dim1_dimscaleid, dim2_dimscaleid, plistid, datasetid2, file_spaceid;
hid_t dim1_dimscaleid, dim2_dimscaleid, plistid, file_spaceid;
hid_t mem_spaceid, xfer_plistid, native_typeid;
hsize_t *chunksize, dims[1], maxdims[1], *dimsize, *maxdimsize;
hsize_t fdims[MAX_DIMS], fmaxdims[MAX_DIMS];
Expand Down
62 changes: 0 additions & 62 deletions h5_test/tst_h_rd_cmp.c

This file was deleted.

45 changes: 37 additions & 8 deletions h5_test/tst_h_wrt_cmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
Copyright 2007 University Corporation for Atmospheric Research/Unidata
See COPYRIGHT file for conditions of use.
Test HDF5 compound types.
Test HDF5 compound types.
Ed Hartnett
*/

#include "h5_err_macros.h"
Expand All @@ -20,7 +21,7 @@ main()
hid_t datasetid;
hsize_t dims[1];
char dummy[] = " ";
struct s1
struct s1
{
unsigned char c1;
double d;
Expand All @@ -46,7 +47,7 @@ main()
/* Open file and create group. */
if ((access_plist = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR;
if (H5Pset_fclose_degree(access_plist, H5F_CLOSE_STRONG)) ERR;
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
access_plist)) < 0) ERR;

/* Create a simple compound type. */
Expand All @@ -60,11 +61,11 @@ main()
if ((spaceid = H5Screate_simple(1, dims, dims)) < 0) ERR;

/* Create a dataset of this compound type. */
if ((datasetid = H5Dcreate(fileid, VAR_NAME, typeid, spaceid,
if ((datasetid = H5Dcreate(fileid, VAR_NAME, typeid, spaceid,
H5P_DEFAULT)) < 0) ERR;

/* Write some data. */
if (H5Dwrite(datasetid, typeid, H5S_ALL, H5S_ALL, H5P_DEFAULT,
if (H5Dwrite(datasetid, typeid, H5S_ALL, H5S_ALL, H5P_DEFAULT,
data) < 0) ERR;

/* Release all resources. */
Expand All @@ -75,7 +76,7 @@ main()
}
SUMMARIZE_ERR;
printf("*** Checking packing of HDF5 compound types...");
{
{
/* Open file. */
if ((access_plist = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR;
if (H5Pset_fclose_degree(access_plist, H5F_CLOSE_STRONG)) ERR;
Expand All @@ -92,10 +93,38 @@ main()
/* Get type. */
if ((typeid = H5Dget_type(datasetid)) < 0) ERR;

/* if ((native_type = H5Tget_native_type(typeid, H5T_DIR_DEFAULT)) < 0) ERR;*/
/* Read the data. */
if (H5Dread(datasetid, typeid, H5S_ALL, H5S_ALL, H5P_DEFAULT,
data) < 0) ERR;

/* Check the data. */
for (i=0; i<DIM1_LEN; i++)
if (data[i].c1 != 126 || data[i].d != -9999999) ERR;

/* Release all resources. */
if (H5Fclose(fileid) < 0) ERR;
}
SUMMARIZE_ERR;
printf("*** Checking packing of HDF5 compound types...");
{
/* Open file. */
if ((access_plist = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR;
if (H5Pset_fclose_degree(access_plist, H5F_CLOSE_STRONG)) ERR;
if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDONLY, access_plist)) < 0) ERR;

/* Open dataset. */
if ((datasetid = H5Dopen1(fileid, VAR_NAME)) < 0) ERR;

/* Check space. */
if ((spaceid = H5Dget_space(datasetid)) < 0) ERR;
if (H5Sget_simple_extent_ndims(spaceid) != 1) ERR;
if (H5Sget_simple_extent_npoints(spaceid) != DIM1_LEN) ERR;

/* Get type. */
if ((typeid = H5Dget_type(datasetid)) < 0) ERR;

/* Read the data. */
if (H5Dread(datasetid, typeid, H5S_ALL, H5S_ALL, H5P_DEFAULT,
if (H5Dread(datasetid, typeid, H5S_ALL, H5S_ALL, H5P_DEFAULT,
data) < 0) ERR;

/* Check the data. */
Expand Down
29 changes: 6 additions & 23 deletions include/err_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Common includes, defines, etc., for test code in the libsrc4 and
nc_test4 directories.
Ed Hartnett, Russ Rew, Dennis Heimbigner
*/

#ifndef _ERR_MACROS_H
Expand All @@ -20,31 +22,19 @@
* generally cosists of several sets of tests. */
static int total_err = 0, err = 0;

#if 0
/* This is handy for print statements. */
static char *format_name[] = {"", "classic", "64-bit offset", "netCDF-4",
"netCDF-4 classic model"};
#endif

/* This macro prints an error message with line number and name of
* test program. */
#define ERR do { \
fflush(stdout); /* Make sure our stdout is synced with stderr. */ \
err++; \
fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \
__FILE__, __LINE__); \
fflush(stderr); \
return 2; \
} while (0)

/* This macro prints an error message with line number and name of
* test program, and then exits the program. */

#define ERR_RET do { \
fflush(stdout); /* Make sure our stdout is synced with stderr. */ \
fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \
__FILE__, __LINE__); \
return 2; \
} while (0)
/* Duplicate with different name. */
#define ERR_RET ERR

#define ERR_GOTO do { \
fflush(stdout); /* Make sure our stdout is synced with stderr. */ \
Expand All @@ -58,13 +48,12 @@ int ERR_report(int stat, const char* file, int line)
fflush(stdout);
fprintf(stderr, "Sorry! Unexpected result, %s, line: %d; status=%d\n",
file,line,stat);
fflush(stdout);
fflush(stderr);
return 1;
}

#define ERRSTAT(stat) {err+=ERR_report(stat,__FILE__,__LINE__);}


/* After a set of tests, report the number of errors, and increment
* total_err. */
#define SUMMARIZE_ERR do { \
Expand All @@ -78,12 +67,6 @@ int ERR_report(int stat, const char* file, int line)
printf("ok.\n"); \
} while (0)

/* If extra memory debugging is not in use (as it usually isn't),
* define away the nc_exit function, which may be in some tests. */
#ifndef EXTRA_MEM_DEBUG
#define nc_exit()
#endif

/* This macro prints out our total number of errors, if any, and exits
* with a 0 if there are not, or a 2 if there were errors. Make will
* stop if a non-zero value is returned from a test program. */
Expand Down
4 changes: 0 additions & 4 deletions libdap2/ncd2dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,6 @@ builddims(NCDAPCOMMON* dapcomm)
NCerror ncstat = NC_NOERR;
int dimid;
NClist* dimset = NULL;
NC* drno = dapcomm->controller;
NC* ncsub;
char* definename;

Expand Down Expand Up @@ -738,7 +737,6 @@ buildvars(NCDAPCOMMON* dapcomm)
NCerror ncstat = NC_NOERR;
int varid;
NClist* varnodes = dapcomm->cdf.ddsroot->tree->varnodes;
NC* drno = dapcomm->controller;
char* definename;

ASSERT((varnodes != NULL));
Expand Down Expand Up @@ -816,7 +814,6 @@ buildglobalattrs(NCDAPCOMMON* dapcomm, CDFnode* root)
char *nltxt, *p;
NCbytes* buf = NULL;
NClist* cdfnodes;
NC* drno = dapcomm->controller;

if(root->attributes != NULL) {
for(i=0;i<nclistlength(root->attributes);i++) {
Expand Down Expand Up @@ -895,7 +892,6 @@ buildattribute(NCDAPCOMMON* dapcomm, NCattribute* att, nc_type vartype, int vari
int i;
NCerror ncstat = NC_NOERR;
unsigned int nvalues = nclistlength(att->values);
NC* drno = dapcomm->controller;

/* If the type of the attribute is string, then we need*/
/* to convert to a single character string by concatenation.
Expand Down
Loading

0 comments on commit f69e031

Please sign in to comment.