Modified ncdap_test to allow a different method

to get TOPSRCDIR that avoids use of
TEST_ENVIRONMENT and makes automake and cmake
more consistent.

Basic assumption is that abs_top_srcdir (and
cmake equivalent) is known at 'make check' time,
so we can use -D flag to compile a program that
has the value of abs_top_srcdir embedded into it
as a constant.

We define two new files in ncdap_test:
1. t_srcdir.h -- provide a gettopsrcdir() function
   to return the topsrcdir value to the test program.
2. topsrcdir.c -- a program that calls gettopsrcdir()
   and prints its output (minus any newline) on stdout.
   This is used in .sh files to get topsrcdir.
This commit is contained in:
Dennis Heimbigner 2017-01-18 21:46:47 -07:00
parent 8a2e722373
commit 7be9506aac
25 changed files with 196 additions and 129 deletions

View File

@ -1,56 +1,23 @@
# Is netcdf-4 and/or DAP enabled?
#NC4=1
#DAP=1
NC4=1
DAP=1
# Is visual studio being used?
#VS=yes
CYGWIN=yes
VS=yes
#CYGWIN=yes
if test "x$VS" = x ; then
#CC=mpicc
CC=gcc
else
VSSTRING="Visual Studio 12 2013 Win64"
G="-G\"$VSSTRING\""
fi
export CC
if test "x$VS" != x -a "x$CYGWIN" != x ; then
ZLIB=cygz.dll; H5LIB=cyghdf5.dll; H5LIB_HL=cyghdf5_hl.dll; CURLLIB=cygcurl.dll
elif test "x$VS" = x -a "x$CYGWIN" != x ; then
ZLIB=libz.dll.a; H5LIB=libhdf5.dll.a; H5LIB_HL=libhdf5_hl.dll.a; CURLLIB=libcurl.dll.a
elif test "x$VS" = x -a "x$CYGWIN" == x ; then
ZLIB=libz.so; H5LIB=libhdf5.so; H5LIB_HL=libhdf5_hl.so; CURLLIB=libcurl.so
else
echo "cannot determine library names"
exit 1
fi
for p in /usr/bin /usr/local/bin /usr/local/lib /usr/lib ; do
if test -f $p/$ZLIB ; then ZP=$p; fi
if test -f $p/$H5LIB ; then HP=$p; fi
if test -f $p/$CURLLIB ; then CP=$p; fi
done
if test "x$ZP" = x ; then echo "Cannot find z lib" ; exit 1; fi
if test "x$HP" = x ; then echo "Cannot find hdf5 lib" ; exit 1; fi
if test "x$CP" = x ; then echo "Cannot find curl lib" ; exit 1; fi
if test "x$CYGWIN" != x -a "x$VS" != x; then
ZP=`cygpath -w "$ZP"`
HP=`cygpath -w "$HP"`
CP=`cygpath -w "$CP"`
fi
#if test "x$VS" != x ; then USR=c:/cygwin/usr; else USR=/usr; fi
ZLIB="-DZLIB_LIBRARY=${ZP}/$ZLIB -DZLIB_INCLUDE_DIR=${ZP}/include -DZLIB_INCLUDE_DIRS=${ZP}/include"
if test "x$NC4" = x1 ; then
HDF5="-DHDF5_LIB=${HP}/$H5LIB -DHDF5_HL_LIB=${HP}/$H5LIB_HL -DHDF5_INCLUDE_DIR=${HP}/include"
fi
if test "x$DAP" = x1 ; then
CURL="-DCURL_LIBRARY=${CP}/$CURLLIB -DCURL_INCLUDE_DIR=${CP}/include -DCURL_INCLUDE_DIRS=${CP}/include"
fi
#FLAGS="$FLAGS -DCMAKE_C_FLAGS='-Wall -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-parameter'"x2
FLAGS="-DCMAKE_PREFIX_PATH=c:/tools/nccmake"
if test "x$DAP" = x ; then
FLAGS="$FLAGS -DENABLE_DAP=false"
@ -60,16 +27,12 @@ FLAGS="$FLAGS -DENABLE_NETCDF_4=false"
fi
FLAGS="$FLAGS -DENABLE_CONVERSION_WARNINGS=false"
FLAGS="$FLAGS -DCMAKE_INSTALL_PREFIX=$USR/local"
#FLAGS="-DCMAKE_PREFIX_PATH=$PPATH"
#FLAGS="$FLAGS -DCMAKE_PREFIX_PATH=$PPATH"
FLAGS="$FLAGS -DENABLE_DAP_REMOTE_TESTS=true"
#FLAGS="$FLAGS -DENABLE_DAP_AUTH_TESTS=true"
rm -fr build
mkdir build
cd build
cmake $FLAGS ${ZLIB} ${HDF5} ${CURL} ..
cmake -GVisual\ Studio\ 14\ 2015 $FLAGS ${ZLIB} ${HDF5} ${CURL} ..
cmake --build .
CTEST_OUTPUT_ON_FAILURE=1 cmake --build . --target test

View File

@ -7,16 +7,15 @@
include $(top_srcdir)/lib_flags.am
LDADD = ${top_builddir}/liblib/libnetcdf.la
AM_CPPFLAGS += -I$(top_builddir)/liblib
AM_CPPFLAGS += -DTOPSRCDIR=${abs_top_srcdir} -I$(top_builddir)/liblib
# Set up the tests; do the .sh first, then .c
check_PROGRAMS =
TESTS =
TESTS_ENVIRONMENT=TOPSRCDIR=${abs_top_srcdir}
TESTS += tst_ncdap3.sh
t_dap3a_SOURCES = t_dap3a.c
t_dap3a_SOURCES = t_dap3a.c t_srcdir.h
test_cvt3_SOURCES = test_cvt.c
test_vara_SOURCES = test_vara.c
@ -33,6 +32,9 @@ if ENABLE_DAP_REMOTE_TESTS
check_PROGRAMS += nctestserver
nctestserver_SOURCES = nctestserver.c
check_PROGRAMS += topsrcdir
topsrcdir_SOURCES = topsrcdir.c
if BUILD_UTILITIES
TESTS += tst_remote3.sh tst_formatx.sh
endif

View File

@ -6,7 +6,13 @@
# will be executed in a different directory
# than the ontaining it; so capture the path to this script
# as the location of the source directory.
srcdir=`dirname $0`
topsrcdir=`topsrcdir`
if test "x$topsrcdir" != x ; then
srcdir="${topsrcdir}/ncdap_test"
else
srcdir=`dirname $0`
fi
cd $srcdir
srcdir=`pwd`
if [ `uname | cut -d "_" -f 1` = "MINGW32" ]; then
@ -20,8 +26,8 @@ if test ${tmp} = ${srcdir} ; then
srcdir=${tmp}
fi
echo "srcdir=${srcdir}"
# Also compute the build directory
#builddir=`pwd`/..
builddir=${srcdir}/..
echo "builddir=${builddir}"

View File

@ -3,6 +3,7 @@
#include <stdlib.h>
#include <string.h>
#include "netcdf.h"
#include "t_srcdir.h"
#undef GENERATE
@ -110,7 +111,7 @@ int main()
int ncid, varid;
int ncstat = NC_NOERR;
char* url;
char* topsrcdir;
const char* topsrcdir;
size_t len;
#ifndef USE_NETCDF4
int i,j;
@ -120,12 +121,8 @@ int main()
server downtime issues
*/
/* Assume that TESTS_ENVIRONMENT was set */
topsrcdir = getenv("TOPSRCDIR");
if(topsrcdir == NULL) {
fprintf(stderr,"*** FAIL: $abs_top_srcdir not defined: location= %s:%d\n",__FILE__,__LINE__);
exit(1);
}
topsrcdir = gettopsrcdir();
len = strlen("file://") + strlen(topsrcdir) + strlen("/ncdap_test/testdata3/test.02") + 1;
#ifdef DEBUG
len += strlen("[log][show=fetch]");

View File

@ -4,6 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include "netcdf.h"
#include "t_srcdir.h"
#undef GENERATE
@ -111,7 +112,7 @@ int main()
int ncid, varid;
int ncstat = NC_NOERR;
char* url;
char* topsrcdir;
const char* topsrcdir;
size_t len;
#ifndef USE_NETCDF4
int i,j;
@ -121,12 +122,8 @@ int main()
server downtime issues
*/
/* Assume that TESTS_ENVIRONMENT was set */
topsrcdir = getenv("TOPSRCDIR");
if(topsrcdir == NULL) {
fprintf(stderr,"$abs_top_srcdir not defined: using '../'");
topsrcdir = "..";
}
topsrcdir = gettopsrcdir();
len = strlen("file://") + strlen(topsrcdir) + strlen("/ncdap_test/testdata3/test.02") + 1;
#ifdef DEBUG
len += strlen("[log][show=fetch]");
@ -146,6 +143,7 @@ int main()
/* open file, get varid */
CHECK(nc_open(url, NC_NOWRITE, &ncid));
/* extract the string case for netcdf-3*/
#ifndef USE_NETCDF4
CHECK(nc_inq_varid(ncid, "s", &varid));

View File

@ -2,7 +2,8 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <netcdf.h>
#include "netcdf.h"
#include "t_srcdir.h"
#define VAR "i32"
@ -20,15 +21,12 @@ main()
size_t start[1];
size_t count[1];
int ok = 1;
char* topsrcdir;
const char* topsrcdir;
char url[4096];
/* Assume that TESTS_ENVIRONMENT was set */
topsrcdir = getenv("TOPSRCDIR");
if(topsrcdir == NULL) {
fprintf(stderr,"*** FAIL: $abs_top_srcdir not defined: location= %s:%d\n",__FILE__,__LINE__);
exit(1);
}
topsrcdir = gettopsrcdir();
strcpy(url,"file://");
strcat(url,topsrcdir);
strcat(url,"/ncdap_test/testdata3/test.02");

View File

@ -3,7 +3,7 @@
#include <stdlib.h>
#include <string.h>
#include "netcdf.h"
#include "t_srcdir.h"
#undef GENERATE
@ -110,7 +110,7 @@ int main()
int ncid, varid;
int ncstat = NC_NOERR;
char* url;
char* topsrcdir;
const char* topsrcdir;
size_t len;
#ifndef USE_NETCDF4
int i,j;
@ -120,12 +120,8 @@ int main()
server downtime issues
*/
/* Assume that TESTS_ENVIRONMENT was set */
topsrcdir = getenv("TOPSRCDIR");
if(topsrcdir == NULL) {
fprintf(stderr,"*** FAIL: $abs_top_srcdir not defined: location= %s:%d\n",__FILE__,__LINE__);
exit(1);
}
topsrcdir = gettopsrcdir();
len = strlen("file://") + strlen(topsrcdir) + strlen("/ncdap_test/testdata3/test.02") + 1;
#ifdef DEBUG
len += strlen("[log][show=fetch]");

View File

@ -3,7 +3,7 @@
#include <stdlib.h>
#include <string.h>
#include "netcdf.h"
#include "t_srcdir.h"
#undef GENERATE
@ -110,7 +110,7 @@ int main()
int ncid, varid;
int ncstat = NC_NOERR;
char* url;
char* topsrcdir;
const char* topsrcdir;
size_t len;
#ifndef USE_NETCDF4
int i,j;
@ -121,11 +121,8 @@ int main()
*/
/* Assume that TESTS_ENVIRONMENT was set */
topsrcdir = getenv("TOPSRCDIR");
if(topsrcdir == NULL) {
fprintf(stderr,"*** FAIL: $abs_top_srcdir not defined: location= %s:%d\n",__FILE__,__LINE__);
exit(1);
}
topsrcdir = gettopsrcdir();
len = strlen("file://") + strlen(topsrcdir) + strlen("/ncdap_test/testdata3/test.02") + 1;
#ifdef DEBUG
len += strlen("[log][show=fetch]");

View File

@ -2,7 +2,8 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <netcdf.h>
#include "netcdf.h"
#include "t_srcdir.h"
#define VAR "i32"
@ -21,15 +22,11 @@ main()
size_t count[1];
int ok = 1;
char* topsrcdir;
const char* topsrcdir;
char url[4096];
/* Assume that TESTS_ENVIRONMENT was set */
topsrcdir = getenv("TOPSRCDIR");
if(topsrcdir == NULL) {
fprintf(stderr,"*** FAIL: $abs_top_srcdir not defined: location= %s:%d\n",__FILE__,__LINE__);
exit(1);
}
topsrcdir = gettopsrcdir();
strcpy(url,"file://");
strcat(url,topsrcdir);
strcat(url,"/ncdap_test/testdata3/test.02");

23
ncdap_test/t_srcdir.h Normal file
View File

@ -0,0 +1,23 @@
#define XSTRINGIFY(s) #s
#define STRINGIFY(s) XSTRINGIFY(s)
static const char*
gettopsrcdir(void)
{
const char* topsrcdir;
#ifdef TOPSRCDIR
topsrcdir = STRINGIFY(TOPSRCDIR);
#else
static char wd[8192];
getwd(wd,sizeof(wd));
strcat(wd,SEP);
strcat(wd,"..");
topsrcdir = wd;
#endif
if(topsrcdir == NULL) {
fprintf(stderr,"*** FAIL: $abs_top_srcdir not defined\n");
exit(1);
}
fprintf(stderr,"topsrcdir=%s\n",topsrcdir);
return topsrcdir;
}

View File

@ -3,6 +3,7 @@
#include <stdlib.h>
#include <string.h>
#include "netcdf.h"
#include "t_srcdir.h"
#undef GENERATE
@ -110,7 +111,7 @@ int main()
int ncid, varid;
int ncstat = NC_NOERR;
char* url;
char* topsrcdir;
const char* topsrcdir;
size_t len;
#ifndef USE_NETCDF4
int i,j;
@ -120,12 +121,8 @@ int main()
server downtime issues
*/
/* Assume that TESTS_ENVIRONMENT was set */
topsrcdir = getenv("TOPSRCDIR");
if(topsrcdir == NULL) {
fprintf(stderr,"*** FAIL: $abs_top_srcdir not defined: location= %s:%d\n",__FILE__,__LINE__);
exit(1);
}
topsrcdir = gettopsrcdir();
len = strlen("file://") + strlen(topsrcdir) + strlen("/ncdap_test/testdata3/test.02") + 1;
#ifdef DEBUG
len += strlen("[log][show=fetch]");

View File

@ -1,7 +1,8 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <netcdf.h>
#include "netcdf.h"
#include "t_srcdir.h"
/* The DDS in netcdf classic form is as follows:
netcdf test {
@ -75,15 +76,11 @@ main()
int retval;
size_t start[RANK];
size_t count[RANK];
char* topsrcdir;
const char* topsrcdir;
char url[4096];
/* Assume that TESTS_ENVIRONMENT was set */
topsrcdir = getenv("TOPSRCDIR");
if(topsrcdir == NULL) {
fprintf(stderr,"*** FAIL: $abs_top_srcdir not defined: location= %s:%d\n",__FILE__,__LINE__);
exit(1);
}
topsrcdir = gettopsrcdir();
strcpy(url,"file://");
strcat(url,topsrcdir);
strcat(url,"/ncdap_test/testdata3/test.06");

View File

@ -16,13 +16,17 @@
# capture the build directory
# Do a hack to remove e.g. c: for CYGWIN
builddir=`pwd`/..
if test "x$TOPSRCDIR" != x ; then
srcdir="$TOPSRCDIR/ncdap_test"
topsrcdir=`topsrcdir`
if test "x$topsrcdir" != x ; then
srcdir="$topsrcdir/ncdap_test"
else
srcdir=`dirname $0`
srcdir=`dirname $0`
fi
# canonical
builddir=`pwd`/..
# canonical form
cd $srcdir
srcdir=`pwd`

23
ncdap_test/topsrcdir.c Normal file
View File

@ -0,0 +1,23 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define XSTRINGIFY(s) #s
#define STRINGIFY(s) XSTRINGIFY(s)
#ifdef _MSC_VER
static const char* SEP = "\\";
#else
static const char* SEP = "/";
#endif
int
main(int argc, char** argv)
{
#ifdef TOPSRCDIR
const char* topsrcdir = STRINGIFY(TOPSRCDIR);
printf("%s",topsrcdir);
#endif
return 0;
}

View File

@ -4,18 +4,25 @@
# will be executed in a different directory
# than the one containing it; so capture the path to this script
# as the location of the source directory.
srcdir=`dirname $0`
if test "x$topsrcdir" != x ; then
srcdir="$topsrcdir/ncdap_test"
else
srcdir=`dirname $0`
fi
cd $srcdir
srcdir=`pwd`
# compute the build directory
builddir=`pwd`/..
# Hack for CYGWIN
cd $srcdir
if [ `uname | cut -d "_" -f 1` = "MINGW32" ]; then
srcdir=`pwd | sed 's/\/c\//c:\//g'`
builddir="$srcdir"/..
fi
# compute the build directory
builddir=`pwd`/..
cd ${builddir}/ncdap_test
sh ${srcdir}/tst_remote.sh "$srcdir" "$builddir" "3" "" "long"

View File

@ -4,7 +4,13 @@
# will be executed in a different directory
# than the one containing it; so capture the path to this script
# as the location of the source directory.
srcdir=`dirname $0`
if test "x$topsrcdir" != x ; then
srcdir="$topsrcdir/ncdap_test"
else
srcdir=`dirname $0`
fi
cd $srcdir
srcdir=`pwd`
# compute the build directory

View File

@ -10,7 +10,13 @@ set -e
# than the one containing it; so capture the path to this script
# as the location of the source directory.
srcdir=`dirname $0`
if test "x$topsrcdir" != x ; then
srcdir="$topsrcdir/ncdap_test"
else
srcdir=`dirname $0`
fi
#set -x
# compute the build directory
# Do a hack to remove e.g. c: for MSYS

View File

@ -9,7 +9,13 @@ set -e
# will be executed in a different directory
# than the one containing it; so capture the path to this script
# as the location of the source directory.
srcdir=`dirname $0`
if test "x$topsrcdir" != x ; then
srcdir="$topsrcdir/ncdap_test"
else
srcdir=`dirname $0`
fi
cd $srcdir
srcdir=`pwd`

View File

@ -6,7 +6,13 @@ set -e
# will be executed in a different directory
# than the one containing it; so capture the path to this script
# as the location of the source directory.
srcdir=`dirname $0`
if test "x$topsrcdir" != x ; then
srcdir="$topsrcdir/ncdap_test"
else
srcdir=`dirname $0`
fi
cd $srcdir
srcdir=`pwd`
# compute the build directory

View File

@ -6,7 +6,13 @@ set -e
# will be executed in a different directory
# than the one containing it; so capture the path to this script
# as the location of the source directory.
srcdir=`dirname $0`
if test "x$topsrcdir" != x ; then
srcdir="$topsrcdir/ncdap_test"
else
srcdir=`dirname $0`
fi
cd $srcdir
srcdir=`pwd`
# compute the build directory

View File

@ -6,7 +6,12 @@ set -e
# will be executed in a different directory
# than the one containing it; so capture the path to this script
# as the location of the source directory.
srcdir=`dirname $0`
if test "x$topsrcdir" != x ; then
srcdir="$topsrcdir/ncdap_test"
else
srcdir=`dirname $0`
fi
# compute the build directory
builddir=`pwd`/..

View File

@ -6,7 +6,13 @@ set -e
# will be executed in a different directory
# than the one containing it; so capture the path to this script
# as the location of the source directory.
srcdir=`dirname $0`
if test "x$topsrcdir" != x ; then
srcdir="$topsrcdir/ncdap_test"
else
srcdir=`dirname $0`
fi
cd $srcdir
srcdir=`pwd`
# compute the build directory

View File

@ -6,7 +6,13 @@ set -e
# will be executed in a different directory
# than the one containing it; so capture the path to this script
# as the location of the source directory.
srcdir=`dirname $0`
if test "x$topsrcdir" != x ; then
srcdir="$topsrcdir/ncdap_test"
else
srcdir=`dirname $0`
fi
cd $srcdir
srcdir=`pwd`

View File

@ -6,7 +6,13 @@ set -e
# will be executed in a different directory
# than the one containing it; so capture the path to this script
# as the location of the source directory.
srcdir=`dirname $0`
if test "x$topsrcdir" != x ; then
srcdir="$topsrcdir/ncdap_test"
else
srcdir=`dirname $0`
fi
cd $srcdir
srcdir=`pwd`

View File

@ -86,6 +86,14 @@ IF(MSVC)
${CMAKE_CURRENT_BINARY_DIR})
SET_TARGET_PROPERTIES(tst_dimsizes PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
${CMAKE_CURRENT_BINARY_DIR})
SET_TARGET_PROPERTIES(tst_fileinfo PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR})
SET_TARGET_PROPERTIES(tst_fileinfo PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
${CMAKE_CURRENT_BINARY_DIR})
SET_TARGET_PROPERTIES(tst_fileinfo PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
${CMAKE_CURRENT_BINARY_DIR})
SET_TARGET_PROPERTIES(tst_fileinfo PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
${CMAKE_CURRENT_BINARY_DIR})
ENDIF()
@ -115,6 +123,7 @@ ENDIF()
add_sh_test(ncdump tst_formatx3)
add_sh_test(ncdump tst_bom)
add_sh_test(ncdump tst_dimsizes)
add_sh_test(ncdump tst_fileinfo)
# The following test script invokes
# gcc directly.