Modified a number of tests

to make use of remotetest.unidata.ucar.edu
optional. Purpose is purely for testing
new dts and thredds servers.
This commit is contained in:
dmh 2014-10-04 15:59:16 -06:00
parent c60b45394f
commit 1739c50622
15 changed files with 192 additions and 78 deletions

View File

@ -348,9 +348,9 @@ extern const char* NCDAP_urllookup(void* dapurl, const char* param);
# else
# define MSC_NCDISPATCH_EXTRA __declspec(dllimport)
# endif
MSC_NCDISPATCH_EXTRA extern const char* NC_findtestserver(const char*);
MSC_NCDISPATCH_EXTRA extern char* NC_findtestserver(const char*, const char**);
#else
extern const char* NC_findtestserver(const char*);
extern char* NC_findtestserver(const char*,const char**);
#endif
/* Ping a specific server */

View File

@ -1,6 +1,8 @@
#include "ncdispatch.h"
#include "ncuri.h"
#define MAXSERVERURL 4096
extern int NCSUBSTRATE_intialize(void);
/* Define vectors of zeros and ones for use with various nc_get_varX function*/
@ -26,11 +28,11 @@ static struct NCPROTOCOLLIST {
{NULL,NULL,0} /* Terminate search */
};
/* Define the server to ping in order;
/* Define the default servers to ping in order;
make the order attempt to optimize
against future changes.
*/
static const char* servers[] = {
static const char* default_servers[] = {
"http://remotetest.unidata.ucar.edu",
NULL
};
@ -56,26 +58,37 @@ NCDISPATCH_initialize(void)
}
/* search list of servers and return first that succeeds when
concatenated with the specified path part
concatenated with the specified path part.
Search list can be prefixed by the second argument.
*/
const char*
NC_findtestserver(const char* path)
char*
NC_findtestserver(const char* path, const char** servers)
{
#ifdef USE_DAP
#ifdef ENABLE_DAP_REMOTE_TESTS
/* NCDAP_ping is defined in libdap2/ncdap.c */
const char** svc;
int stat;
char* url = (char*)malloc(MAXSERVERURL);
if(path == NULL) path = "";
for(svc=servers;*svc != NULL;svc++) {
int stat;
char url[4096];
snprintf(url,sizeof(url),"%s%s%s",
*svc,
(path[0] == '/' ? "" : "/"),
path);
stat = NCDAP_ping(url);
if(stat == NC_NOERR)
return *svc;
if(strlen(path) > 0 && path[0] == '/')
path++;
if(servers != NULL) {
for(svc=servers;*svc != NULL;svc++) {
snprintf(url,MAXSERVERURL,"%s/%s",*svc,path);
stat = NCDAP_ping(url);
if(stat == NC_NOERR)
return url;
}
}
/* not found in user supplied list; try defaults */
for(svc=default_servers;*svc != NULL;svc++) {
snprintf(url,MAXSERVERURL,"%s/%s",*svc,path);
stat = NCDAP_ping(url);
if(stat == NC_NOERR)
return url;
}
#endif
#endif

View File

@ -4,7 +4,7 @@
#include <string.h>
#include <netcdf.h>
#define URL "http://remotetest.unidata.ucar.edu/dts/test.02"
#define URL "http://%s/dts/test.02"
#define VAR "i32"
#define ERRCODE 2
@ -21,8 +21,16 @@ main()
size_t start[1];
size_t count[1];
int ok = 1;
char url[1024];
if ((retval = nc_open(URL, 0, &ncid)))
{
char* evv = getenv("REMOTETESTSERVER");
if(evv == NULL)
evv = "remotetest.unidata.ucar.edu";
snprintf(url,sizeof(url),URL,evv);
}
if ((retval = nc_open(url, 0, &ncid)))
ERR(retval);
if ((retval = nc_inq_varid(ncid, VAR, &varid)))
ERR(retval);

View File

@ -65,7 +65,7 @@ NC4_def_grp(int parent_ncid, const char *name, int *new_ncid)
int
NC4_rename_grp(int grpid, const char *name)
{
NC_GRP_INFO_T *grp, *g;
NC_GRP_INFO_T *grp;
NC_HDF5_FILE_INFO_T *h5;
char norm_name[NC_MAX_NAME + 1];
int retval;

View File

@ -5,21 +5,39 @@
#include "netcdf.h"
#include "ncdispatch.h"
/**
Given a partial suffix path,
try to find a server for which
a request to that server + path
returns some kind of result.
This indicates that the server is up
and running.
Return the complete url for the server
plus the path.
*/
int
main(int argc, char** argv)
{
const char* url = NULL;
if(argc == 1) {
fprintf(stderr,"no path specified");
printf("%s","");
exit(1);
const char* path = NULL;
char* serverlist[64];
int nservers = 0;
if(argc == 1)
path = "";
else if(argc >= 2)
path = argv[1];
if(argc >= 3) {
int i;
for(i=2;i<argc;i++,nservers++)
serverlist[i-2] = argv[i];
serverlist[nservers] = NULL;
}
url = NC_findtestserver(argv[1]);
url = NC_findtestserver(path,(nservers==0?(const char**)NULL:(const char**)serverlist));
if(url == NULL)
url = "";
printf("%s",url);
fflush(stdout);
exit(0);
}

View File

@ -2,21 +2,31 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "netcdf.h"
#define USERPWD "tiggeUser:tigge"
#define URL1 "https://tiggeUser:tigge@%s/thredds/dodsC/restrict/testData.nc"
#define URL2 "https://%s/thredds/dodsC/restrict/testData.nc"
/* Embedded user:pwd */
static char* URL1 =
"http://tiggeUser:tigge@remotetest.unidata.ucar.edu/thredds/dodsC/restrict/testData.nc";
static char url1[1024];
/* user:pwd from .dodsrc*/
static char* URL2 =
"http://remotetest.unidata.ucar.edu/thredds/dodsC/restrict/testData.nc";
static char url2[1024];
/* Test redirect */
static char* URL3 =
static char* url3 =
"http://tiggeUser:tigge@thredds-test.ucar.edu/thredds/dodsC/restrict/testData.nc";
/* .dodsrc file */
static char* CONTENT = "HTTP.CREDENTIALS.USER=tiggeUser\nHTTP.CREDENTIALS.PASSWORD=tigge\n";
#ifdef DEBUG
static void
CHECK(int e, const char* msg)
{
@ -25,14 +35,33 @@ CHECK(int e, const char* msg)
printf("%s: %s\n", msg, nc_strerror(e));
exit(1);
}
#endif
int
main(int argc, char** argv)
{
int ncid,retval,pass;
char** url;
FILE* dodsrc;
char* envv;
envv = getenv("THREDDSTESTSERVER");
if(envv == NULL) {
envv = "remotetest.unidata.ucar.edu";
} else { /* walk past the schema and // */
char* p = strchr(envv,':');
if(p == NULL) {
fprintf(stderr,"URL has no schema: %s\n",url1);
exit(1);
}
envv = p+3;
}
snprintf(url1,sizeof(url1),URL1,envv);
snprintf(url2,sizeof(url2),URL2,envv);
printf("url1: %s\n",url1);
printf("url2: %s\n",url2);
fflush(stdout);
pass = 1; /* assume success */
dodsrc = fopen(".dodsrc","w");
@ -45,8 +74,8 @@ main(int argc, char** argv)
printf("Testing: Http Basic Authorization\n\n");
if(1) {
printf("Embedded user:pwd: %s\n",URL1);
retval = nc_open(URL1, 0, &ncid);
printf("Embedded user:pwd: %s\n",url1);
retval = nc_open(url1, 0, &ncid);
if(retval != NC_NOERR) {
pass = 0;
printf("*** FAIL: Embedded user:pwd\n");
@ -58,9 +87,9 @@ main(int argc, char** argv)
}
if(1) {
printf(".dodsrc user:pwd: %s\n",URL1);
printf(".dodsrc user:pwd: %s\n",url2);
retval = nc_open(URL2, 0, &ncid);
retval = nc_open(url2, 0, &ncid);
if(retval != NC_NOERR) {
pass = 0;
printf("*** FAIL: .dodsrc user:pwd\n");
@ -74,8 +103,8 @@ main(int argc, char** argv)
printf("Testing: Http Basic Redirect\n\n");
if(1) {
printf("Basic redirect: %s\n",URL3);
retval = nc_open(URL3, 0, &ncid);
printf("Basic redirect: %s\n",url3);
retval = nc_open(url3, 0, &ncid);
if(retval != NC_NOERR) {
printf("*** XFAIL: Basic redirect\n");
} else {

View File

@ -5,8 +5,10 @@
#include <netcdf.h>
#define URL1 "http://remotetest.unidata.ucar.edu" /* test that no trailing / is ok */
#define URL1 "http://%s" /* test that no trailing / is ok */
static char url1[1024];
#ifdef DEBUG
static void
CHECK(int e, const char* msg)
{
@ -15,6 +17,7 @@ CHECK(int e, const char* msg)
printf("%s: %s\n", msg, nc_strerror(e));
exit(1);
}
#endif
static void
XFAIL(int e, const char* msg)
@ -29,8 +32,15 @@ main()
{
int ncid,retval;
{
char* evv = getenv("DTSTESTSERVER");
if(evv == NULL)
evv = "remotetest.unidata.ucar.edu";
snprintf(url1,sizeof(url1),URL1,evv);
}
printf("Testing: Misc. Tests \n");
retval = nc_open(URL1, 0, &ncid);
retval = nc_open(url1, 0, &ncid);
XFAIL(retval,"*** XFail : No trailing slash in url");
retval = nc_close(ncid);
return 0;

View File

@ -52,6 +52,7 @@ incorrect data return
#include<stdio.h>
#include<string.h>
#include "netcdf.h"
#include "ncdispatch.h"
#define VERBOSE 1
@ -66,12 +67,14 @@ Float64 lon_rho[eta_rho = 336][xi_rho = 896];
Float64 lat_rho[eta_rho = 336][xi_rho = 896];
*/
static char* URL="https://remotetest.unidata.ucar.edu/thredds/dodsC/testdods/rtofs.nc";
#define URL "%s/thredds/dodsC/testdods/rtofs.nc"
#define VAR1 "Latitude"
#define VAR2 "Longitude"
#define XSIZE 850
#define YSIZE 712
static char url[1024];
int
main()
{
@ -81,13 +84,30 @@ main()
int i;
int ncstatus;
size_t start[5], count[5];
ptrdiff_t stride[5], tmp_ptrdiff_t;
ptrdiff_t stride[5];
int pass = 1;
int nelems = XSIZE*YSIZE;
int idim, ndim;
float *dat = (float*)malloc(sizeof(float)*nelems);
float sdat[10];
char* svc;
/* Find Test Server */
svc = getenv("THREDDSTESTSERVER");
if(svc != NULL) {
const char* testserver[2];
testserver[0] = svc;
testserver[1] = NULL;
svc = NC_findtestserver("dts",testserver);
} else
svc = NC_findtestserver("dts",NULL);
if(svc == NULL) {
fprintf(stderr,"Cannot locate test server\n");
exit(0);
}
snprintf(url,sizeof(url),URL,svc);
for (idim=0; idim<5; idim++) {
start[idim] = 0;
@ -99,13 +119,13 @@ main()
printf(" \n");
printf("********************\n");
printf("open URL %s\n",URL);
printf("open URL %s\n",url);
printf(" \n");
ncstatus = nc_open(URL, NC_NOWRITE, &ncid);
ncstatus = nc_open(url, NC_NOWRITE, &ncid);
if(ncstatus != NC_NOERR) {
fprintf(stderr,"Could not open: %s; server may be down; test ignored\n",URL);
fprintf(stderr,"Could not open: %s; server may be down; test ignored\n",url);
exit(0);
}
@ -216,7 +236,7 @@ main()
#endif
ncstatus = nc_close (ncid);
ncstatus = nc_open(URL, NC_NOWRITE, &ncid);
ncstatus = nc_open(url, NC_NOWRITE, &ncid);
/* ----------------------------------------------------- */
/* Read a subset of the data with strides */

View File

@ -21,7 +21,7 @@ variables:
*/
#define PARAMS ""
#define DTSTEST "/dts/ingrid"
#define DTSTEST "/ingrid"
#define VAR "v3H"
#define ISTA 35
#define IZ 44
@ -99,7 +99,15 @@ main()
const char* svc = NULL;
/* Find Test Server */
svc = NC_findtestserver("dts");
svc = getenv("DTSTESTSERVER");
if(svc != NULL) {
const char* dtstestserver[2];
dtstestserver[0] = svc;
dtstestserver[1] = NULL;
svc = NC_findtestserver("dts",dtstestserver);
} else
svc = NC_findtestserver("dts",NULL);
if(svc == NULL) {
fprintf(stderr,"Cannot locate test server\n");
exit(0);

View File

@ -26,7 +26,7 @@ variables:
double PolarGrid.Data\\ Fields.Spectra(Bands\:PolarGrid, YDim\:PolarGrid, XDim\:PolarGrid) ;
*/
#define DTSTEST "/dts/test.GridFile"
#define DTSTEST "/test.GridFile"
#define PARAMS ""
#define VAR "UTMGrid.Data Fields.Vegetation"
@ -88,7 +88,15 @@ main()
char url[4096];
/* Find Test Server */
svc = NC_findtestserver("dts");
svc = getenv("DTSTESTSERVER");
if(svc != NULL) {
const char* testserver[2];
testserver[0] = svc;
testserver[1] = NULL;
svc = NC_findtestserver("dts",testserver);
} else
svc = NC_findtestserver("dts",NULL);
if(svc == NULL) {
fprintf(stderr,"Cannot locate test server\n");
exit(1);

View File

@ -26,7 +26,7 @@ netcdf-4.1-beta2-snapshot2009091100
#undef DEBUG
#define TESTPATH "/thredds/dodsC/testdods/coads_climatology.nc"
#define TESTPATH "/dodsC/testdods/coads_climatology.nc"
#define VAR "SST"
static float expected_stride1[12] = {
@ -80,6 +80,7 @@ main()
int idim;
float dat[20];
char url[4096];
char* svc;
#ifdef STANDALONE
int ndim;
#endif
@ -90,16 +91,22 @@ main()
oc_logopen(NULL);
#endif
{
/* Find Test Server */
const char* svc = NC_findtestserver("thredds");
if(svc == NULL) {
fprintf(stderr,"Cannot locate test server\n");
exit(0);
}
strcpy(url,svc);
strcat(url,TESTPATH);
/* Find Test Server */
svc = getenv("THREDDSTESTSERVER");
if(svc != NULL) {
const char* testserver[2];
testserver[0] = svc;
testserver[1] = NULL;
svc = NC_findtestserver("thredds",testserver);
} else
svc = NC_findtestserver("thredds",NULL);
if(svc == NULL) {
fprintf(stderr,"Cannot locate test server\n");
exit(0);
}
strcpy(url,svc);
strcat(url,TESTPATH);
printf("*** Test: varm on URL: %s\n",url);
@ -253,5 +260,3 @@ main()
return fail;
}

View File

@ -8,12 +8,12 @@ echo "*** Testing extended file format output."
set -e
# Figure our dst server
SVC=`./nctestserver dts`
if test "x$SVC" = "x" ; then
echo "cannot locate test server"
DTS=`./nctestserver dts ${DTSTESTSERVER}`
if test "x$DTS" = "x" ; then
echo "cannot locate test server for dts"
exit
fi
URL="$SVC/dts/test.03"
URL="$DTS/test.03"
ECODE=0
echo "Test extended format output for a DAP2 file"

View File

@ -1,17 +1,16 @@
#!/bin/sh
#set -x
set -x
quiet=0
leakcheck=0
timing=0
# Figure our dst server
SVC=`./nctestserver dts`
if test "x$SVC" = "x" ; then
echo "cannot locate test server"
DTS=`./nctestserver dts ${DTSTESTSERVER}`
if test "x$DTS" = "x" ; then
echo "cannot locate test server for dts"
exit
fi
DTS="$SVC/dts"
PARAMS="[log]"
#PARAMS="${PARAMS}[show=fetch]"

View File

@ -6,7 +6,6 @@
# as the location of the source directory.
srcdir=`dirname $0`
# compute the build directory
builddir=`pwd`/..
# Hack for CYGWIN

View File

@ -734,9 +734,6 @@ unescape(
*p++ = (*t); t++;
}
}
if(s+yyleng <= p) {
int x = 0;
}
*p = '\0';
return (p - s);
}