netcdf-c/dap4_test/test_data.c
Dennis Heimbigner 65414eeaa4 Fix some protocol differences between netcdf-c and the Hyrax server.
re: Partly addresses issue https://github.com/Unidata/netcdf-c/issues/1712.

1. Turn on Hyrax Hack to accept Hyrax style attribute containers.
2. Support Url type as alias for String.
3. Accept the special attribute, "__DAP4_Checksum_CRC32",
   to control per-variable checksums.
4. Make _DAP4_xxx attributes be reserved and only accessible
   by name (ala _SuperBlock attribute).
5. Fix handling of checksums. There is a hack in the code
   that uses an extra flag in the chunk header to indicate
   that all variables have checksums. This violates the spec
   and will be removed once it is possible to regenerate the
   test cases.

Note that checksumming with the Hyrax test server has not
been tested. This, along with some other probable inconsistencies,
needs fixing when OPeNDAP and Unidata can agree on the proper
specification. Testing will be included.
2020-05-30 17:36:25 -06:00

65 lines
1.4 KiB
C

/*********************************************************************
* Copyright 2016, UCAR/Unidata
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
*********************************************************************/
/**
Test the netcdf-4 data building process.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include "netcdf.h"
#undef DEBUG
static void
fail(int code)
{
if(code != NC_NOERR)
fprintf(stderr,"***Fail: %s\n",nc_strerror(code));
exit((code==NC_NOERR?EXIT_SUCCESS:EXIT_FAILURE));
}
int
main(int argc, char** argv)
{
int ret = NC_NOERR;
char url[4096];
int ncid;
/* Skip cmd name */
argc++;
argv++;
if(argc < 2) {
fprintf(stderr, "too few arguments: t_dmrdata.c <infile> <outfile>\n");
fail(NC_NOERR);
}
/* build the url */
snprintf(url,sizeof(url),"file://%s#dap4&debug=copy",argv[0]);
if(argc >= 3) {
strlcat(url,"&substratename=",sizeof(url));
strlcat(url,argv[1],sizeof(url));
}
#ifdef DEBUG
strlcat(url,"&log",sizeof(url));
#endif
#ifdef DEBUG
fprintf(stderr,"test_data url=%s\n",url);
#endif
/* Use the open/close mechanism */
if((ret=nc_open(url,NC_NETCDF4,&ncid))) goto done;
if((ret=nc_close(ncid))) goto done;
done:
#ifdef DEBUG
fprintf(stderr,"code=%d %s\n",ret,nc_strerror(ret));
#endif
return (ret ? 1 : 0);
}