netcdf-c/ncdap_test/Makefile.am
Dennis Heimbigner 231ae96c4b Add support for Zarr string type to NCZarr
* re: https://github.com/Unidata/netcdf-c/pull/2278
* re: https://github.com/Unidata/netcdf-c/issues/2485
* re: https://github.com/Unidata/netcdf-c/issues/2474

This PR subsumes PR https://github.com/Unidata/netcdf-c/pull/2278.
Actually is a bit an omnibus covering several issues.

## PR https://github.com/Unidata/netcdf-c/pull/2278
Add support for the Zarr string type.
Zarr strings are restricted currently to be of fixed size.
The primary issue to be addressed is to provide a way for user to
specify the size of the fixed length strings. This is handled by providing
the following new attributes special:
1. **_nczarr_default_maxstrlen** —
This is an attribute of the root group. It specifies the default
maximum string length for string types. If not specified, then
it has the value of 64 characters.
2. **_nczarr_maxstrlen** —
This is a per-variable attribute. It specifies the maximum
string length for the string type associated with the variable.
If not specified, then it is assigned the value of
**_nczarr_default_maxstrlen**.

This PR also requires some hacking to handle the existing netcdf-c NC_CHAR
type, which does not exist in zarr. The goal was to choose numpy types for
both the netcdf-c NC_STRING type and the netcdf-c NC_CHAR type such that
if a pure zarr implementation read them, it would still work and an
NC_CHAR type would be handled by zarr as a string of length 1.

For writing variables and NCZarr attributes, the type mapping is as follows:
* "|S1" for NC_CHAR.
* ">S1" for NC_STRING && MAXSTRLEN==1
* ">Sn" for NC_STRING && MAXSTRLEN==n

Note that it is a bit of a hack to use endianness, but it should be ok since for
string/char, the endianness has no meaning.

For reading attributes with pure zarr (i.e. with no nczarr
atribute types defined), they will always be interpreted as of
type NC_CHAR.

## Issue: https://github.com/Unidata/netcdf-c/issues/2474
This PR partly fixes this issue because it provided more
comprehensive support for Zarr attributes that are JSON valued expressions.
This PR still does not address the problem in that issue where the
_ARRAY_DIMENSION attribute is incorrectly set. Than can only be
fixed by the creator of the datasets.

## Issue: https://github.com/Unidata/netcdf-c/issues/2485
This PR also fixes the scalar failure shown in this issue.
It generally cleans up scalar handling.
It also adds a note to the documentation describing that
NCZarr supports scalars while Zarr does not and also how
scalar interoperability is achieved.

## Misc. Other Changes
1. Convert the nczarr special attributes and keys to be all lower case. So "_NCZARR_ATTR" now used "_nczarr_attr. Support back compatibility for the upper case names.
2. Cleanup my too-clever-by-half handling of scalars in libnczarr.
2022-08-27 20:21:13 -06:00

131 lines
3.4 KiB
Makefile

## This is a automake file, part of Unidata's netCDF package.
# Copyright 2018v, see the COPYRIGHT file for more information.
# This file builds and runs DAP tests.
# Put together AM_CPPFLAGS and AM_LDFLAGS.
include $(top_srcdir)/lib_flags.am
# Un comment to use a more verbose test driver
#SH_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#TESTS_ENVIRONMENT = export SETX=1;
# Note which tests depend on other tests. Necessary for make -j check.
TEST_EXTENSIONS = .sh
LDADD = ${top_builddir}/liblib/libnetcdf.la
AM_CPPFLAGS += -I$(top_srcdir)/liblib
AM_CPPFLAGS += -DTOPSRCDIR=${abs_top_srcdir}
AM_CPPFLAGS += -DTOPBINDIR=${abs_top_builddir}
# Set up the tests; do the .sh first, then .c
check_PROGRAMS =
TESTS =
t_dap3a_SOURCES = t_dap3a.c t_srcdir.h
test_cvt3_SOURCES = test_cvt.c t_srcdir.h
test_vara_SOURCES = test_vara.c t_srcdir.h
if ENABLE_DAP
check_PROGRAMS += t_dap3a test_cvt3 test_vara
TESTS += t_dap3a test_cvt3 test_vara
if BUILD_UTILITIES
TESTS += tst_ncdap3.sh
endif
# remote tests are optional
# because the server may be down or inaccessible
if ENABLE_DAP_REMOTE_TESTS
noinst_PROGRAMS = findtestserver pingurl
findtestserver_SOURCES = findtestserver.c
pingurl_SOURCES = pingurl.c
if BUILD_UTILITIES
TESTS += tst_ber.sh tst_remote3.sh tst_formatx.sh testurl.sh tst_fillmismatch.sh tst_zero_len_var.sh tst_encode.sh
endif
TESTS += test_partvar
if ENABLE_DAP_LONG_TESTS
TESTS += tst_longremote3.sh
tst_longremote3.log: tst_remote3.log
if ENABLE_EXTERNAL_SERVER_TESTS
test_manyurls_SOURCES = test_manyurls.c manyurls.h
check_PROGRAMS += test_manyurls
test_manyurls.log: tst_longremote3.log
TESTS += test_manyurls
endif
endif
test_partvar_SOURCES = test_partvar.c
t_misc_SOURCES = t_misc.c
#TESTS += t_ncf330
TESTS += t_misc
test_nstride_cached_SOURCES = test_nstride_cached.c
TESTS += test_nstride_cached
check_PROGRAMS += test_nstride_cached
test_varm3_SOURCES = test_varm3.c
TESTS += test_varm3
check_PROGRAMS += test_varm3
check_PROGRAMS += test_partvar
check_PROGRAMS += t_misc
check_PROGRAMS += t_ncf330
if ENABLE_DAP_AUTH_TESTS
TESTS += testauth.sh
endif
endif #ENABLE_DAP_REMOTE_TESTS
endif #ENABLE_DAP
# Need to add subdirs
SUBDIRS = testdata3 expected3 expectremote3
EXTRA_DIST = tst_ncdap3.sh \
tst_remote3.sh \
tst_longremote3.sh \
tst_zero_len_var.sh \
tst_filelists.sh tst_urls.sh tst_utils.sh \
t_dap.c CMakeLists.txt tst_formatx.sh testauth.sh testurl.sh \
t_ncf330.c tst_ber.sh tst_fillmismatch.sh tst_encode.sh \
findtestserver.c.in
CLEANFILES = test_varm3 test_cvt3 file_results/* remote_results/* datadds* t_dap3a test_nstride_cached *.exe tmp*.txt
# This should only be left behind if using parallel io
CLEANFILES += tmp_*
DISTCLEANFILES = findtestserver.c
# This rule are used if someone wants to rebuild t_dap3a.c
# Otherwise never invoked, but records how to do it.
t_dap3a.c: t_dap.c
echo "#define NETCDF3ONLY" > ./t_dap3a.c
cat t_dap.c >> t_dap3a.c
# One last thing
BUILT_SOURCES = .dodsrc
.dodsrc:
echo "#DODSRC" >.dodsrc
echo "HTTP.READ.BUFFERSIZE=max" >>.dodsrc
echo "HTTP.KEEPALIVE=60/60" >>.dodsrc
clean-local: clean-local-check
.PHONY: clean-local-check
clean-local-check:
-rm -rf results
-rm -f .dodsrc
# If valgrind is present, add valgrind targets.
@VALGRIND_CHECK_RULES@