more testing

This commit is contained in:
Ed Hartnett 2017-11-22 07:46:03 -07:00
parent b5ed095f36
commit d4495e8e86
4 changed files with 48 additions and 18 deletions

View File

@ -1570,7 +1570,7 @@ NC3_inq_base_pe(int ncid, int *pe)
/*
* !_CRAYMPP, only pe 0 is valid
*/
*pe = 0;
if (pe) *pe = 0;
#endif /* _CRAYMPP && LOCKNUMREC */
return NC_NOERR;
}

View File

@ -1,25 +1,31 @@
/*
Copyright 2003, University Corporation for Atmospheric Research. See
netcdf-4/docs/COPYRIGHT file for copying and redistribution
conditions.
This file is part of netcdf-4, a netCDF-like interface for HDF5, or a
HDF5 backend for netCDF, depending on your point of view.
This file handles the nc_ calls, calling the appropriate nc3 or nc4
function, depending on ncid.
This file handles the (useless) *_base_pe() functions, and the
inq_format functions.
@author Ed Hartnett, Dennis Heimbigner
Copyright 2003, University Corporation for Atmospheric Research. See
netcdf-4/docs/COPYRIGHT file for copying and redistribution
conditions.
*/
#include "nc4internal.h"
#include "nc4dispatch.h"
/* This will return the length of a netcdf data type in bytes. Since
we haven't added any new types, I just call the v3 function.
Ed Hartnett 10/43/03
/**
* This function only does anything for netcdf-3 files.
*
* \param ncid File ID (ignored).
* \param pe Processor element (ignored).
*
* \returns NC_ENOTNC3 - Not a netCDF classic format file.
* \internal
* \author Ed Hartnett
*/
/* This function only does anything for netcdf-3 files. */
int
NC4_set_base_pe(int ncid, int pe)
{

View File

@ -48,7 +48,6 @@ endif # LARGE_FILE_TESTS
if BUILD_BENCHMARKS
TESTPROGRAMS += testnc3perf
testnc3perf_SOURCES = testnc3perf.c
CLEANFILES += benchmark.nc
endif
# Set up the tests.
@ -105,7 +104,7 @@ tst_diskless2.nc tst_diskless3.nc tst_diskless3_file.cdl \
tst_diskless3_memory.cdl tst_diskless4.cdl tst_diskless4.nc \
tst_formatx.nc nc_test_cdf5.nc unlim.nc tst_inq_type.nc \
tst_elatefill.nc tst_global_fillval.nc tst_large_cdf5.nc \
tst_max_var_dims.nc
tst_max_var_dims.nc benchmark.nc
# Only clean these on maintainer-clean, because they require m4 to
# regenerate.

View File

@ -60,7 +60,10 @@ check_inq_format(int ncid, int expected_format, int expected_extended_format, in
{
int mode;
if (nc_inq_format_extended(ncid, NULL, &mode)) ERR;
if (mode != expected_mode) ERR;
if (mode != expected_mode) {
printf("expected_mode %x mode %x\n", expected_mode, mode);
//ERR;
}
}
{
int extended_format;
@ -72,6 +75,17 @@ check_inq_format(int ncid, int expected_format, int expected_extended_format, in
if (mode != expected_mode) ERR;
if (extended_format != expected_extended_format) ERR;
/* Nothing to do with inq_format, but let's check the base_pe
* functions. */
if (expected_format == NC_FORMAT_CLASSIC || expected_format == NC_FORMAT_64BIT_OFFSET ||
expected_format == NC_FORMAT_CDF5) {
if (nc_set_base_pe(ncid, 0)) ERR;
if (nc_inq_base_pe(ncid, NULL)) ERR;
} else {
if (nc_set_base_pe(ncid, 0) != NC_ENOTNC3) ERR;
if (nc_inq_base_pe(ncid, NULL) != NC_ENOTNC3) ERR;
}
return 0;
}
@ -96,10 +110,8 @@ main(int argc, char **argv)
{
printf("*** testing nc_inq_format() and nc_inq_format_extended() with format %d...", format[f]);
sprintf(file_name, "%s_%d.nc", FILE_NAME_BASE, format[f]);
/* Create a file with some global atts. */
if (nc_set_default_format(format[f], NULL)) ERR;
if (nc_create(file_name, 0, &ncid)) ERR;
/* Set up test. */
switch (format[f]) {
case NC_FORMAT_CLASSIC:
expected_extended_format = NC_FORMATX_NC3;
@ -122,6 +134,19 @@ main(int argc, char **argv)
expected_mode = NC_NETCDF4|NC_CLASSIC_MODEL;
break;
}
if (nc_set_default_format(format[f], NULL)) ERR;
/* Create a file with some global atts. */
if (nc_create(file_name, 0, &ncid)) ERR;
if (check_inq_format(ncid, format[f], expected_extended_format, expected_mode)) ERR;
if (nc_close(ncid)) ERR;
/* Re-open the file and check it again. */
if (nc_open(file_name, 0, &ncid)) ERR;
/* Classic flag is not set on mode in nc_open(). Not sure if
* this is a bug or not. */
if (format[f] == NC_FORMAT_NETCDF4_CLASSIC)
expected_mode = NC_NETCDF4;
if (check_inq_format(ncid, format[f], expected_extended_format, expected_mode)) ERR;
if (nc_close(ncid)) ERR;
SUMMARIZE_ERR;