[NCF-282]/ HAD-595112

The code that tests if a path is a url is
faulting when the url does not end in a slash
(e.g. http://thredds-tests.ucar.edu).
The code that tests if a path is a url is
faulting when the url does not end in a slash
(e.g. http://thredds-tests.ucar.edu).
CF-273]/HZY-708311

Solution was to do a null pointer test.
Added a test (tst_misc).
This commit is contained in:
dmh 2014-01-20 16:11:45 -07:00
parent 6a6891b72b
commit dfc3749506
7 changed files with 56 additions and 4 deletions

11
.gitignore vendored
View File

@ -2,7 +2,18 @@ build
html
doxygen*.tmp
\#*.*\#
*.*~
*.o
*.lo
*.la
Makefile.in
stamp-h1
autom4te.cache
myhtml
CMakeLists.txt.user
scan-build
.deps
.libs
*.zip
*.gz
Makefile

2
cf
View File

@ -8,7 +8,7 @@ fi
HDF5=1
DAP=1
HDF4=1
#HDF4=1
#PNETCDF=1
#RPC=1

View File

@ -36,7 +36,7 @@ nc__testurl(const char* path, char** basenamep)
NCURI* uri;
int ok = ncuriparse(path,&uri);
if(ok) {
char* slash = strrchr(uri->file, '/');
char* slash = (uri->file == NULL ? NULL : strrchr(uri->file, '/'));
char* dot;
if(slash == NULL) slash = (char*)path; else slash++;
slash = nulldup(slash);

View File

@ -8,8 +8,8 @@ TOP="/home/dmh/mach/netcdf-c"
#TOP="/cygdrive/f/svn/trunk"
#TOP="/cygdrive/c/Users/dmh/svn/trunk"
F="http://ticket:ticket1@utmea.enea.it:8080/thredds/dodsC/UNIDATA_passwd/head_out.nc"
#F="http://ticket:ticket1@utmea.enea.it:8080/thredds/dodsC/UNIDATA_passwd/head_out.nc"
F="http://motherlode.ucar.edu"
#PROG=./ncd
PROG="$TOP/ncdump/ncdump"

View File

@ -42,6 +42,7 @@ IF(ENABLE_TESTS)
add_bin_test(ncdap test_partvar)
add_bin_test(ncdap test_varm3)
add_bin_test(ncdap t_auth)
add_bin_test(ncdap t_misc)
ENDIF()

View File

@ -38,18 +38,21 @@ test_varm3_SOURCES = test_varm3.c
t_dap3a_SOURCES = t_dap3a.c
test_nstride_cached_SOURCE = test_nstride_cached.c
t_auth_SOURCES = t_auth.c
t_misc_SOURCES = t_misc.c
TESTS += t_dap3a test_cvt3 test_vara test_partvar
TESTS += test_varm3
TESTS += t_dap3a
TESTS += test_nstride_cached
TESTS += t_auth
TESTS += t_misc
check_PROGRAMS += t_dap3a test_cvt3 test_vara test_partvar
check_PROGRAMS += test_varm3
check_PROGRAMS += t_dap3a
check_PROGRAMS += test_nstride_cached
check_PROGRAMS += t_auth
check_PROGRAMS += t_misc
endif #ENABLE_DAP_REMOTE_TESTS

37
ncdap_test/t_misc.c Normal file
View File

@ -0,0 +1,37 @@
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <netcdf.h>
#define URL1 "http://thredds-test.ucar.edu" /* test that no trailing / is ok */
static void
CHECK(int e, const char* msg)
{
if(e == NC_NOERR) return;
if(msg == NULL) msg = "Error";
printf("%s: %s\n", msg, nc_strerror(e));
exit(1);
}
static void
XFAIL(int e, const char* msg)
{
if(e == NC_NOERR) return;
if(msg == NULL) msg = "XFAIL";
printf("%s: %s\n", msg, nc_strerror(e));
}
int
main()
{
int ncid,retval;
printf("Testing: Misc. Tests \n");
retval = nc_open(URL1, 0, &ncid);
XFAIL(retval,"*** XFail : No trailing slash in url");
retval = nc_close(ncid);
return 0;
}