summaryrefslogtreecommitdiffstats
path: root/src/Makefile.am
blob: fb73bbf618007541759553e24811bb058c60a9b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#
# Copyright by The HDF Group.
# Copyright by the Board of Trustees of the University of Illinois.
# All rights reserved.
#
# This file is part of HDF5.  The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the files COPYING and Copyright.html.  COPYING can be found at the root
# of the source code distribution tree; Copyright.html can be found at the
# root level of an installed copy of the electronic HDF5 document set and
# is linked from the top-level documents page.  It can also be found at
# http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have
# access to either file, you may request a copy from help@hdfgroup.org.
##
## Makefile.am
## Run automake to generate a Makefile.in from this file.
#
# HDF5 Library Makefile(.in)
#

include $(top_srcdir)/config/commence.am
include $(top_srcdir)/config/lt_vers.am


# How to build H5detect for number format detection.
# Use -g to force no optimization since many compilers (e.g., Intel) takes
# a long time to compile it with any optimization on.  H5detect is used
# to generate H5Tinit.c once. So, optimization is not critical.
noinst_PROGRAMS = H5detect
H5detect_CFLAGS = -g

# Our main target, the HDF5 library
lib_LTLIBRARIES=libhdf5.la

# Add libtool numbers to the HDF5 library (from config/lt_vers.am)
libhdf5_la_LDFLAGS= -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE)

# H5Tinit.c is a generated file, and should be cleaned.
MOSTLYCLEANFILES=H5Tinit.c
# H5pubconf.h is generated by configure, and should be cleaned.
DISTCLEANFILES=H5pubconf.h

# library sources
libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
        H5A.c H5Abtree2.c H5Adense.c H5Adeprec.c H5Aint.c H5Atest.c \
        H5AC.c H5B.c H5Bcache.c H5Bdbg.c \
        H5B2.c H5B2cache.c H5B2dbg.c H5B2int.c H5B2stat.c H5B2test.c \
        H5C.c H5CS.c \
        H5D.c H5Dbtree.c H5Dchunk.c H5Dcompact.c H5Dcontig.c H5Ddbg.c \
        H5Ddeprec.c H5Defl.c H5Dfill.c H5Dint.c \
        H5Dio.c H5Dlayout.c \
        H5Dmpio.c H5Doh.c H5Dscatgath.c H5Dselect.c H5Dtest.c \
        H5E.c H5Edeprec.c H5Eint.c \
        H5EA.c H5EAcache.c H5EAdbg.c H5EAdblkpage.c H5EAdblock.c H5EAhdr.c \
        H5EAiblock.c H5EAint.c H5EAsblock.c H5EAstat.c H5EAtest.c \
        H5F.c H5Faccum.c H5Fdbg.c H5Ffake.c H5Fio.c H5Fmount.c H5Fmpi.c H5Fquery.c \
        H5Fsfile.c H5Fsuper.c H5Fsuper_cache.c H5Ftest.c \
        H5FA.c H5FAcache.c H5FAdbg.c H5FAdblock.c H5FAdblkpage.c H5FAhdr.c \
        H5FAstat.c H5FAtest.c \
        H5FD.c H5FDcore.c  \
        H5FDdirect.c H5FDfamily.c H5FDint.c H5FDlog.c H5FDmpi.c H5FDmpio.c \
        H5FDmpiposix.c H5FDmulti.c H5FDsec2.c H5FDspace.c H5FDstdio.c \
        H5FL.c H5FO.c H5FS.c H5FScache.c H5FSdbg.c H5FSsection.c H5FSstat.c H5FStest.c \
        H5G.c H5Gbtree2.c H5Gcache.c \
        H5Gcompact.c H5Gdense.c H5Gdeprec.c H5Gent.c \
        H5Gint.c H5Glink.c \
        H5Gloc.c H5Gname.c H5Gnode.c H5Gobj.c H5Goh.c H5Groot.c H5Gstab.c H5Gtest.c \
        H5Gtraverse.c \
        H5HF.c H5HFbtree2.c H5HFcache.c H5HFdbg.c H5HFdblock.c H5HFdtable.c \
        H5HFhdr.c H5HFhuge.c H5HFiblock.c H5HFiter.c H5HFman.c H5HFsection.c \
        H5HFspace.c H5HFstat.c H5HFtest.c H5HFtiny.c \
        H5HG.c H5HGcache.c H5HGdbg.c \
        H5HL.c H5HLcache.c H5HLdbg.c \
        H5HP.c H5I.c H5L.c H5Lexternal.c \
        H5MF.c H5MFaggr.c H5MFdbg.c H5MFsection.c \
        H5MM.c H5MP.c H5MPtest.c \
        H5O.c H5Oainfo.c H5Oalloc.c H5Oattr.c \
        H5Oattribute.c H5Obogus.c H5Obtreek.c H5Ocache.c \
        H5Ocont.c H5Ocopy.c H5Odbg.c H5Odrvinfo.c H5Odtype.c H5Oefl.c \
        H5Ofill.c H5Oginfo.c \
        H5Olayout.c \
        H5Olinfo.c H5Olink.c H5Omessage.c H5Omtime.c \
        H5Oname.c H5Onull.c H5Opline.c H5Orefcount.c \
        H5Osdspace.c H5Oshared.c H5Ostab.c \
        H5Oshmesg.c H5Otest.c H5Ounknown.c \
        H5P.c H5Pacpl.c H5Pdapl.c H5Pdcpl.c \
        H5Pdeprec.c H5Pdxpl.c H5Pfapl.c H5Pfcpl.c H5Pfmpl.c \
        H5Pgcpl.c H5Pint.c \
        H5Plapl.c H5Plcpl.c H5Pocpl.c H5Pocpypl.c H5Pstrcpl.c H5Ptest.c \
        H5R.c H5Rdeprec.c \
        H5RC.c \
        H5RS.c \
        H5S.c H5Sall.c H5Sdbg.c H5Shyper.c H5Smpio.c H5Snone.c H5Spoint.c \
        H5Sselect.c H5Stest.c H5SL.c H5SM.c H5SMbtree2.c \
        H5SMcache.c H5SMtest.c H5ST.c \
        H5T.c H5Tarray.c H5Tbit.c H5Tcommit.c H5Tcompound.c H5Tconv.c \
        H5Tcset.c H5Tdbg.c H5Tdeprec.c H5Tenum.c H5Tfields.c \
        H5Tfixed.c \
        H5Tfloat.c H5Tinit.c H5Tnative.c H5Toffset.c H5Toh.c \
        H5Topaque.c \
        H5Torder.c \
        H5Tpad.c H5Tprecis.c H5Tstrpad.c H5Tvisit.c H5Tvlen.c H5TS.c H5V.c H5WB.c H5Z.c  \
        H5Zdeflate.c H5Zfletcher32.c H5Znbit.c H5Zshuffle.c H5Zszip.c  \
        H5Zscaleoffset.c H5Ztrans.c


# Public headers
include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5version.h \
        H5Apublic.h H5ACpublic.h \
        H5Cpublic.h H5Dpublic.h \
        H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDdirect.h \
	H5FDfamily.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h              \
        H5FDmulti.h H5FDsec2.h  H5FDstdio.h \
        H5Gpublic.h  H5Ipublic.h H5Lpublic.h \
        H5MMpublic.h H5Opublic.h H5Ppublic.h H5Rpublic.h H5Spublic.h \
        H5Tpublic.h H5Zpublic.h

# install libhdf5.settings in lib directory
settingsdir=$(libdir)
settings_DATA=libhdf5.settings

# Number format detection
# The LD_LIBRARY_PATH setting is a kludge.
# Things should have been all set during H5detect making.
# Remove the generated .c file if errors occur unless HDF5_Make_Ignore
# is set to ignore the error.
H5Tinit.c: H5detect$(EXEEXT)
	LD_LIBRARY_PATH="$$LD_LIBRARY_PATH`echo $(LDFLAGS) |                  \
		sed -e 's/-L/:/g' -e 's/ //g'`"                               \
	$(RUNSERIAL) ./H5detect > H5Tinit.c  ||                               \
	    (test $$HDF5_Make_Ignore && echo "*** Error ignored") ||          \
	    ($(RM) $@ ; exit 1)

# Error header generation
#
# Actually, H5Einit.h, H5Eterm.h, H5Edefin.h and H5Epubgen.h all
# depend on H5err.txt, but the perl script generates them all, so just
# list one here.
$(top_srcdir)/src/H5Edefin.h: $(top_srcdir)/src/H5err.txt
	perl $(top_srcdir)/bin/make_err $?

# API version macro generation
$(top_srcdir)/src/H5version.h: $(top_srcdir)/src/H5vers.txt
	perl $(top_srcdir)/bin/make_vers $?

# Assignment overflow macro generation
$(top_srcdir)/src/H5overflow.h: $(top_srcdir)/src/H5overflow.txt
	perl $(top_srcdir)/bin/make_overflow $?

# Add TRACE macros to library source files.  This is done via the trace script
# in the hdf5/bin directory.  If the file contains HDF5 API macros, a "clean"
# version of the source file is saved with a tilde (~) after its name and
# tracing information is inserted.  trace should have no effect on files
# without HDF5 macros.
.PHONY: trace

trace: $(libhdf5_la_SOURCES)
	@for dep in $? dummy; do                                          \
	 if test $$dep != "dummy" -a -n "$(PERL)"; then                      \
	  case "$$dep" in                                                 \
	   *.c)                                                           \
	    $(TRACE) $$dep;                                               \
	    ;;                                                            \
	  esac;                                                           \
	 fi;                                                              \
	done

include $(top_srcdir)/config/conclude.am
re the COPYING.txt file for the windows binary package #----------------------------------------------------------------------------- -if (WIN32) +if (WIN32 OR MINGW) configure_file (${HDF5_SOURCE_DIR}/COPYING ${HDF5_BINARY_DIR}/COPYING.txt @ONLY) endif () @@ -212,7 +212,7 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED) ${HDF5_SOURCE_DIR}/release_docs/COPYING ${HDF5_SOURCE_DIR}/release_docs/RELEASE.txt ) - if (WIN32) + if (WIN32 OR MINGW) set (release_files ${release_files} ${HDF5_SOURCE_DIR}/release_docs/USING_HDF5_VS.txt @@ -226,7 +226,7 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED) ${HDF5_SOURCE_DIR}/release_docs/HISTORY-1_8.txt ${HDF5_SOURCE_DIR}/release_docs/INSTALL ) - if (WIN32) + if (WIN32 OR MINGW) set (release_files ${release_files} ${HDF5_SOURCE_DIR}/release_docs/INSTALL_Windows.txt @@ -294,7 +294,7 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) set (CPACK_PACKAGE_ICON "${HDF_RESOURCES_EXT_DIR}/hdf.bmp") set (CPACK_GENERATOR "TGZ") - if (WIN32) + if (WIN32 OR MINGW) set (CPACK_GENERATOR "ZIP") if (NSIS_EXECUTABLE) @@ -459,7 +459,7 @@ The HDF5 data model, file format, API, library, and tools are open and distribut if (HDF5_PACKAGE_EXTLIBS) if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") if (ZLIB_FOUND AND ZLIB_USE_EXTERNAL) - if (WIN32) + if (WIN32 OR MINGW) set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ZLIB_INCLUDE_DIR_GEN};ZLIB;ALL;/") else () set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ZLIB_INCLUDE_DIR_GEN};ZLIB;libraries;/") @@ -468,7 +468,7 @@ The HDF5 data model, file format, API, library, and tools are open and distribut endif () endif () if (SZIP_FOUND AND SZIP_USE_EXTERNAL) - if (WIN32) + if (WIN32 OR MINGW) set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${SZIP_INCLUDE_DIR_GEN};SZIP;ALL;/") else () set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${SZIP_INCLUDE_DIR_GEN};SZIP;libraries;/") diff --git a/CMakeLists.txt b/CMakeLists.txt index fc656c0..a62561f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -512,7 +512,7 @@ endif () # and we need to call the executable from inside the CMake configuration #----------------------------------------------------------------------------- set (EXE_EXT "") -if (WIN32) +if (WIN32 OR MINGW) set (EXE_EXT ".exe") add_definitions (-D_BIND_TO_CURRENT_VCLIBS_VERSION=1) add_definitions (-D_CRT_SECURE_NO_WARNINGS) @@ -688,7 +688,7 @@ endif () option (HDF5_ENABLE_THREADSAFE "Enable thread-safety" OFF) if (HDF5_ENABLE_THREADSAFE) # check for unsupported options - if (WIN32) + if (WIN32 OR MINGW) message (STATUS " **** thread-safety option not supported with static library **** ") message (STATUS " **** thread-safety option will not be used building static library **** ") endif () diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index b141a5e..38c46be 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -188,7 +188,7 @@ install ( COMPONENT cpplibraries ) -if (NOT WIN32) +if (NOT WIN32 AND NOT MINGW) set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER}) configure_file ( ${HDF_RESOURCES_DIR}/libh5cc.in diff --git a/config/cmake/CTestScript.cmake b/config/cmake/CTestScript.cmake index 0269ba8..a5527c3 100644 --- a/config/cmake/CTestScript.cmake +++ b/config/cmake/CTestScript.cmake @@ -72,7 +72,7 @@ set (CTEST_CMAKE_COMMAND "\"${CMAKE_COMMAND}\"") if (CTEST_USE_TAR_SOURCE) ## Uncompress source if tar or zip file provided ## -------------------------- - if (WIN32) + if (WIN32 AND NOT MINGW) message (STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}\\${CTEST_USE_TAR_SOURCE}.zip]") execute_process (COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}\\${CTEST_USE_TAR_SOURCE}.zip RESULT_VARIABLE rv) else () diff --git a/config/cmake/jrunTest.cmake b/config/cmake/jrunTest.cmake index 44ac15b..341c382 100644 --- a/config/cmake/jrunTest.cmake +++ b/config/cmake/jrunTest.cmake @@ -49,7 +49,7 @@ endif () message (STATUS "COMMAND: ${TEST_TESTER} -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=${LOG_LEVEL} -Djava.library.path=\"${TEST_LIBRARY_DIRECTORY}\" -cp \"${TEST_CLASSPATH}\" ${TEST_ARGS} ${TEST_PROGRAM} ${ARGN}") -if (WIN32 AND NOT MINGW) +if (WIN32 OR MINGW) set (ENV{PATH} "$ENV{PATH}\\;${TEST_LIBRARY_DIRECTORY}") else () set (ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:${TEST_LIBRARY_DIRECTORY}") @@ -124,7 +124,7 @@ message (STATUS "COMMAND Error: ${TEST_ERROR}") # compare output files to references unless this must be skipped if (NOT TEST_SKIP_COMPARE) if (EXISTS ${TEST_FOLDER}/${TEST_REFERENCE}) - if (WIN32 AND NOT MINGW) + if (WIN32 OR MINGW) file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}") endif () @@ -186,7 +186,7 @@ if (NOT TEST_SKIP_COMPARE) # now compare the .err file with the error reference, if supplied if (TEST_ERRREF) - if (WIN32 AND NOT MINGW) + if (WIN32 OR MINGW) file (READ ${TEST_FOLDER}/${TEST_ERRREF} TEST_STREAM) file (WRITE ${TEST_FOLDER}/${TEST_ERRREF} "${TEST_STREAM}") endif () diff --git a/config/cmake/scripts/CTestScript.cmake b/config/cmake/scripts/CTestScript.cmake index e1fe85a..dc3939e 100644 --- a/config/cmake/scripts/CTestScript.cmake +++ b/config/cmake/scripts/CTestScript.cmake @@ -69,7 +69,7 @@ set (CTEST_CMAKE_COMMAND "\"${CMAKE_COMMAND}\"") if (CTEST_USE_TAR_SOURCE) ## Uncompress source if tar file provided ## -------------------------- - if (WIN32) + if (WIN32 AND NOT MINGW) message (STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} x ${CTEST_DASHBOARD_ROOT}\\${CTEST_USE_TAR_SOURCE}.zip]") execute_process (COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}\\${CTEST_USE_TAR_SOURCE}.zip RESULT_VARIABLE rv) else () diff --git a/config/cmake/scripts/HDF5config.cmake b/config/cmake/scripts/HDF5config.cmake index 44ed531..e6c9619 100644 --- a/config/cmake/scripts/HDF5config.cmake +++ b/config/cmake/scripts/HDF5config.cmake @@ -90,7 +90,7 @@ endif () set (CTEST_BINARY_NAME "build") set (CTEST_DASHBOARD_ROOT "${CTEST_SCRIPT_DIRECTORY}") -if (WIN32) +if (WIN32 AND NOT MINGW) set (CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_SOURCE_NAME}") set (CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_BINARY_NAME}") else () @@ -104,7 +104,7 @@ if (NOT DEFINED HPC) if (NOT DEFINED BUILD_GENERATOR) message (FATAL_ERROR "BUILD_GENERATOR must be defined - Unix, VS2017, or VS201764, VS2015, VS201564, VS2013, VS201364") endif () - if (WIN32) + if (WIN32 AND NOT MINGW) set (SITE_OS_NAME "Windows") set (SITE_OS_VERSION "WIN7") if (BUILD_GENERATOR STREQUAL "VS201764") @@ -212,7 +212,7 @@ set (REPOSITORY_BRANCH "develop") ################################################################### -if (WIN32) +if (WIN32 AND NOT MINGW) set (BINFILEBASE "HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-win${SITE_OS_BITS}") include (${CTEST_SCRIPT_DIRECTORY}\\HDF5options.cmake) include (${CTEST_SCRIPT_DIRECTORY}\\CTestScript.cmake) diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index 8c00f52..c19c5dc 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -74,7 +74,7 @@ if (MINGW) set (${HDF_PREFIX}_HAVE_WINSOCK2_H 1) endif () -if (WIN32) +if (WIN32 AND NOT MINGW) if (NOT UNIX) set (WINDOWS 1) set (CMAKE_REQUIRED_FLAGS "/DWIN32_LEAN_AND_MEAN=1 /DNOGDI=1") diff --git a/config/cmake_ext_mod/HDFUseFortran.cmake b/config/cmake_ext_mod/HDFUseFortran.cmake index bed1fc1..bfb45fa 100644 --- a/config/cmake_ext_mod/HDFUseFortran.cmake +++ b/config/cmake_ext_mod/HDFUseFortran.cmake @@ -191,7 +191,7 @@ CHECK_FORTRAN_FEATURE(iso_c_binding # Add debug information (intel Fortran : JB) #----------------------------------------------------------------------------- if (CMAKE_Fortran_COMPILER MATCHES ifort) - if (WIN32) + if (WIN32 AND NOT MINGW) set (CMAKE_Fortran_FLAGS_DEBUG "/debug:full /dbglibs " CACHE "flags" STRING FORCE) set (CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG" CACHE "flags" STRING FORCE) endif () diff --git a/config/cmake_ext_mod/grepTest.cmake b/config/cmake_ext_mod/grepTest.cmake index 4b58639..dffbd8c 100644 --- a/config/cmake_ext_mod/grepTest.cmake +++ b/config/cmake_ext_mod/grepTest.cmake @@ -46,7 +46,7 @@ endif () message (STATUS "COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}") if (TEST_LIBRARY_DIRECTORY) - if (WIN32 AND NOT MINGW) + if (WIN32 OR MINGW) set (ENV{PATH} "$ENV{PATH};${TEST_LIBRARY_DIRECTORY}") else () set (ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:${TEST_LIBRARY_DIRECTORY}") @@ -98,7 +98,7 @@ if (TEST_ERRREF) #always compare output file to reference unless this must be skipped if (NOT TEST_SKIP_COMPARE) if (EXISTS ${TEST_FOLDER}/${TEST_REFERENCE}) - if (WIN32 AND NOT MINGW) + if (WIN32 OR MINGW) file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}") endif () diff --git a/config/cmake_ext_mod/runTest.cmake b/config/cmake_ext_mod/runTest.cmake index c9508f3..184ec27 100644 --- a/config/cmake_ext_mod/runTest.cmake +++ b/config/cmake_ext_mod/runTest.cmake @@ -38,7 +38,7 @@ endif () message (STATUS "COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}") if (TEST_LIBRARY_DIRECTORY) - if (WIN32 AND NOT MINGW) + if (WIN32 OR MINGW) set (ENV{PATH} "$ENV{PATH};${TEST_LIBRARY_DIRECTORY}") else () set (ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:${TEST_LIBRARY_DIRECTORY}") @@ -186,7 +186,7 @@ endif () # compare output files to references unless this must be skipped if (NOT TEST_SKIP_COMPARE) if (EXISTS ${TEST_FOLDER}/${TEST_REFERENCE}) - if (WIN32 AND NOT MINGW) + if (WIN32 OR MINGW) file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}") endif () @@ -248,7 +248,7 @@ if (NOT TEST_SKIP_COMPARE) # now compare the .err file with the error reference, if supplied if (TEST_ERRREF) - if (WIN32 AND NOT MINGW) + if (WIN32 OR MINGW) file (READ ${TEST_FOLDER}/${TEST_ERRREF} TEST_STREAM) file (WRITE ${TEST_FOLDER}/${TEST_ERRREF} "${TEST_STREAM}") endif () diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index 315dc85..4077180 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -494,7 +494,7 @@ install ( COMPONENT fortlibraries ) -if (NOT WIN32) +if (NOT WIN32 AND NOT MINGW) set (_PKG_CONFIG_COMPILER ${CMAKE_Fortran_COMPILER}) configure_file ( ${HDF_RESOURCES_DIR}/libh5cc.in diff --git a/hl/c++/src/CMakeLists.txt b/hl/c++/src/CMakeLists.txt index 1911d62..9964160 100644 --- a/hl/c++/src/CMakeLists.txt +++ b/hl/c++/src/CMakeLists.txt @@ -108,7 +108,7 @@ install ( COMPONENT hlcpplibraries ) -if (NOT WIN32) +if (NOT WIN32 AND NOT MINGW) set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER}) configure_file ( ${HDF_RESOURCES_DIR}/libh5cc.in diff --git a/hl/src/CMakeLists.txt b/hl/src/CMakeLists.txt index 3cce7e4..9bce694 100644 --- a/hl/src/CMakeLists.txt +++ b/hl/src/CMakeLists.txt @@ -132,7 +132,7 @@ install ( COMPONENT hllibraries ) -if (NOT WIN32) +if (NOT WIN32 AND NOT MINGW) set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER}) configure_file ( ${HDF_RESOURCES_DIR}/libh5cc.in diff --git a/java/examples/datasets/CMakeLists.txt b/java/examples/datasets/CMakeLists.txt index 9e5c45c..328c4b1 100644 --- a/java/examples/datasets/CMakeLists.txt +++ b/java/examples/datasets/CMakeLists.txt @@ -39,7 +39,7 @@ set (HDF_JAVA_SZIP_EXAMPLES set (${HDF_JAVA_EXAMPLES} ${HDF_JAVA_EXAMPLES} ${HDF_JAVA_SZIP_EXAMPLES}) endif (H5_HAVE_FILTER_SZIP) -if (WIN32) +if (WIN32 OR MINGW) set (CMAKE_JAVA_INCLUDE_FLAG_SEP ";") else () set (CMAKE_JAVA_INCLUDE_FLAG_SEP ":") diff --git a/java/examples/datatypes/CMakeLists.txt b/java/examples/datatypes/CMakeLists.txt index c939985..18a99b8 100644 --- a/java/examples/datatypes/CMakeLists.txt +++ b/java/examples/datatypes/CMakeLists.txt @@ -24,7 +24,7 @@ set (HDF_JAVA_EXAMPLES H5Ex_T_VLString ) -if (WIN32) +if (WIN32 OR MINGW) set (CMAKE_JAVA_INCLUDE_FLAG_SEP ";") else () set (CMAKE_JAVA_INCLUDE_FLAG_SEP ":") diff --git a/java/examples/groups/CMakeLists.txt b/java/examples/groups/CMakeLists.txt index 489dab3..8b16ffd 100644 --- a/java/examples/groups/CMakeLists.txt +++ b/java/examples/groups/CMakeLists.txt @@ -13,7 +13,7 @@ set (HDF_JAVA_EXAMPLES H5Ex_G_Visit ) -if (WIN32) +if (WIN32 OR MINGW) set (CMAKE_JAVA_INCLUDE_FLAG_SEP ";") else () set (CMAKE_JAVA_INCLUDE_FLAG_SEP ":") diff --git a/java/examples/intro/CMakeLists.txt b/java/examples/intro/CMakeLists.txt index 1801749..86b6296 100644 --- a/java/examples/intro/CMakeLists.txt +++ b/java/examples/intro/CMakeLists.txt @@ -13,7 +13,7 @@ set (HDF_JAVA_EXAMPLES H5_ReadWrite ) -if (WIN32) +if (WIN32 OR MINGW) set (CMAKE_JAVA_INCLUDE_FLAG_SEP ";") else () set (CMAKE_JAVA_INCLUDE_FLAG_SEP ":") diff --git a/java/test/CMakeLists.txt b/java/test/CMakeLists.txt index 05bfd8d..a210ca9 100644 --- a/java/test/CMakeLists.txt +++ b/java/test/CMakeLists.txt @@ -82,7 +82,7 @@ HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/h5ex_g_iterate.orig" "${PROJECT_BINARY_ add_custom_target(${HDF5_JAVA_TEST_LIB_TARGET}_files ALL COMMENT "Copying files needed by ${HDF5_JAVA_TEST_LIB_TARGET} tests" DEPENDS ${${HDF5_JAVA_TEST_LIB_TARGET}_files_list}) -if (WIN32) +if (WIN32 OR MINGW) set (CMAKE_JAVA_INCLUDE_FLAG_SEP ";") else () set (CMAKE_JAVA_INCLUDE_FLAG_SEP ":") diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index 3d986d2..b138f14 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -885,7 +885,7 @@ endif () ### F I L T E R P L U G I N T E S T S ############################################################################## if (BUILD_SHARED_LIBS) - if (WIN32) + if (WIN32 OR MINGW) set (CMAKE_SEP "\;") set (BIN_REL_PATH "../../") else () @@ -982,7 +982,7 @@ endif () ### V O L P L U G I N T E S T S ############################################################################## if (BUILD_SHARED_LIBS) - if (WIN32) + if (WIN32 OR MINGW) set (CMAKE_SEP "\;") set (BIN_REL_PATH "../../") else () diff --git a/test/flushrefreshTest.cmake b/test/flushrefreshTest.cmake index 73210ef..926efba 100644 --- a/test/flushrefreshTest.cmake +++ b/test/flushrefreshTest.cmake @@ -41,7 +41,7 @@ endif () message (STATUS "COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}") if (TEST_LIBRARY_DIRECTORY) - if (WIN32 AND NOT MINGW) + if (WIN32 OR MINGW) set (ENV{PATH} "$ENV{PATH};${TEST_LIBRARY_DIRECTORY}") else () set (ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:${TEST_LIBRARY_DIRECTORY}") diff --git a/tools/src/misc/CMakeLists.txt b/tools/src/misc/CMakeLists.txt index 7c3d7f0..6b41d7f 100644 --- a/tools/src/misc/CMakeLists.txt +++ b/tools/src/misc/CMakeLists.txt @@ -78,13 +78,6 @@ if (BUILD_SHARED_LIBS) ) endif () -#----------------------------------------------------------------------------- -# Generate the h5cc file containing settings needed to compile programs -#----------------------------------------------------------------------------- -#if (NOT WIN32) -# configure_file (${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5cc.in ${HDF5_BINARY_DIR}/h5cc @ONLY) -#endif () - ############################################################################## ############################################################################## ### I N S T A L L A T I O N ### diff --git a/tools/test/h5dump/CMakeTests.cmake b/tools/test/h5dump/CMakeTests.cmake index 070e98e..db47111 100644 --- a/tools/test/h5dump/CMakeTests.cmake +++ b/tools/test/h5dump/CMakeTests.cmake @@ -362,7 +362,7 @@ endforeach () foreach (tst_exp_file ${HDF5_REFERENCE_EXP_FILES}) - if (WIN32) + if (WIN32 OR MINGW) file (READ ${HDF5_TOOLS_DIR}/testfiles/${tst_exp_file} TEST_STREAM) file (WRITE ${PROJECT_BINARY_DIR}/testfiles/std/${tst_exp_file} "${TEST_STREAM}") else () @@ -388,7 +388,7 @@ # -------------------------------------------------------------------- HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/tbin1.ddl" "${PROJECT_BINARY_DIR}/testfiles/std/tbin1LE.ddl" "h5dump_std_files") - if (WIN32) + if (WIN32 OR MINGW) file (READ ${HDF5_TOOLS_DIR}/testfiles/tbinregR.exp TEST_STREAM) file (WRITE ${PROJECT_BINARY_DIR}/testfiles/std/tbinregR.exp "${TEST_STREAM}") else () -- cgit v0.12 From 6b775a9d45b827427d09bf9a26c1b384c45f1f95 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Sat, 13 Jul 2019 09:58:26 -0500 Subject: HDFFV-10845 defines already set --- config/cmake_ext_mod/ConfigureChecks.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index c19c5dc..7369350 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -70,7 +70,6 @@ if (MINGW) set (${HDF_PREFIX}_HAVE_MINGW 1) set (WINDOWS 1) # MinGW tries to imitate Windows set (CMAKE_REQUIRED_FLAGS "-DWIN32_LEAN_AND_MEAN=1 -DNOGDI=1") - set (HDF_EXTRA_C_FLAGS "-DWIN32_LEAN_AND_MEAN=1 -DNOGDI=1") set (${HDF_PREFIX}_HAVE_WINSOCK2_H 1) endif () @@ -78,7 +77,6 @@ if (WIN32 AND NOT MINGW) if (NOT UNIX) set (WINDOWS 1) set (CMAKE_REQUIRED_FLAGS "/DWIN32_LEAN_AND_MEAN=1 /DNOGDI=1") - set (HDF_EXTRA_C_FLAGS "/DWIN32_LEAN_AND_MEAN=1 /DNOGDI=1") if (MSVC) set (${HDF_PREFIX}_HAVE_VISUAL_STUDIO 1) endif () -- cgit v0.12 From 0efee3ddbada2d08803bfba5a4622d60238cdc35 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Sat, 13 Jul 2019 10:11:49 -0500 Subject: Must include from system --- config/cmake_ext_mod/FindSZIP.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/cmake_ext_mod/FindSZIP.cmake b/config/cmake_ext_mod/FindSZIP.cmake index b84d768..2303d6d 100644 --- a/config/cmake_ext_mod/FindSZIP.cmake +++ b/config/cmake_ext_mod/FindSZIP.cmake @@ -73,7 +73,7 @@ if(SZIP_INCLUDE_DIR AND EXISTS "${SZIP_INCLUDE_DIR}/SZconfig.h") unset(szip_version_str) endif() -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +include(FindPackageHandleStandardArgs) find_package_handle_standard_args(SZIP REQUIRED_VARS SZIP_LIBRARY SZIP_INCLUDE_DIR VERSION_VAR SZIP_VERSION) -- cgit v0.12 From 5b258e186b84d36a465740413573fbac8c00a360 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Sat, 13 Jul 2019 18:29:52 -0500 Subject: Correct install syntax --- fortran/src/CMakeLists.txt | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index 4077180..1dc0896 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -356,18 +356,32 @@ install ( ${HDF5_F90_SRC_SOURCE_DIR}/H5f90.h ${HDF5_F90_SRC_SOURCE_DIR}/H5f90i.h ${HDF5_F90_SRC_SOURCE_DIR}/H5f90proto.h - if (NOT ONLY_SHARED_LIBS) - ${HDF5_F90_BINARY_DIR}/static/H5f90i_gen.h - ${HDF5_F90_BINARY_DIR}/static/H5fortran_types.F90 - else () - ${HDF5_F90_BINARY_DIR}/shared/H5f90i_gen.h - ${HDF5_F90_BINARY_DIR}/shared/H5fortran_types.F90 - endif () DESTINATION ${HDF5_INSTALL_INCLUDE_DIR} COMPONENT fortheaders ) +if (NOT ONLY_SHARED_LIBS) + install ( + FILES + ${HDF5_F90_BINARY_DIR}/static/H5f90i_gen.h + ${HDF5_F90_BINARY_DIR}/static/H5fortran_types.F90 + DESTINATION + ${HDF5_INSTALL_INCLUDE_DIR} + COMPONENT + fortheaders + ) +else () + install ( + FILES + ${HDF5_F90_BINARY_DIR}/shared/H5f90i_gen.h + ${HDF5_F90_BINARY_DIR}/shared/H5fortran_types.F90 + DESTINATION + ${HDF5_INSTALL_INCLUDE_DIR} + COMPONENT + fortheaders + ) +endif () if (NOT ONLY_SHARED_LIBS) set (mod_files -- cgit v0.12 From ac5680ce8db5452d3705e6530a087ff927cc8687 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Sun, 14 Jul 2019 17:25:26 -0500 Subject: HDFFV-10845 add_custom_command requires emulator --- config/cmake_ext_mod/ConfigureChecks.cmake | 4 ++-- fortran/src/CMakeLists.txt | 8 ++++---- fortran/test/CMakeLists.txt | 4 ++-- hl/fortran/src/CMakeLists.txt | 4 ++-- src/CMakeLists.txt | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index 7369350..b05fbc8 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -96,7 +96,7 @@ if (WINDOWS) if (NOT MINGW) set (${HDF_PREFIX}_HAVE_GETHOSTNAME 1) endif () - if (NOT UNIX AND NOT CYGWIN AND NOT MINGW) + if (NOT UNIX AND NOT CYGWIN) set (${HDF_PREFIX}_HAVE_GETCONSOLESCREENBUFFERINFO 1) endif () set (${HDF_PREFIX}_HAVE_FUNCTION 1) @@ -474,7 +474,7 @@ if (NOT WINDOWS) CHECK_FUNCTION_EXISTS (_getvideoconfig ${HDF_PREFIX}_HAVE__GETVIDEOCONFIG) CHECK_FUNCTION_EXISTS (gettextinfo ${HDF_PREFIX}_HAVE_GETTEXTINFO) CHECK_FUNCTION_EXISTS (_scrsize ${HDF_PREFIX}_HAVE__SCRSIZE) - if (NOT CYGWIN AND NOT MINGW) + if (NOT CYGWIN) CHECK_FUNCTION_EXISTS (GetConsoleScreenBufferInfo ${HDF_PREFIX}_HAVE_GETCONSOLESCREENBUFFERINFO) endif () CHECK_SYMBOL_EXISTS (TIOCGWINSZ "sys/ioctl.h" ${HDF_PREFIX}_HAVE_TIOCGWINSZ) diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index 1dc0896..0ec14ab 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -84,7 +84,7 @@ if (NOT ONLY_SHARED_LIBS) add_custom_command ( OUTPUT ${HDF5_F90_BINARY_DIR}/static/H5f90i_gen.h ${HDF5_F90_BINARY_DIR}/static/H5fortran_types.F90 - COMMAND $ + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR}/static DEPENDS H5match_types ) @@ -95,7 +95,7 @@ if (BUILD_SHARED_LIBS) add_custom_command ( OUTPUT ${HDF5_F90_BINARY_DIR}/shared/H5f90i_gen.h ${HDF5_F90_BINARY_DIR}/shared/H5fortran_types.F90 - COMMAND $ + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR}/shared DEPENDS H5match_types ) @@ -183,7 +183,7 @@ set (f90_F_GEN_SOURCES if (NOT ONLY_SHARED_LIBS) add_custom_command ( OUTPUT ${HDF5_F90_BINARY_DIR}/static/H5_gen.F90 - COMMAND $ + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR}/static DEPENDS ${f90_F_GEN_SOURCES} COMMENT "Generating the H5_gen.F90 file" @@ -197,7 +197,7 @@ endif () if (BUILD_SHARED_LIBS) add_custom_command ( OUTPUT ${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 - COMMAND $ + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR}/shared DEPENDS ${f90_F_GEN_SOURCES} COMMENT "Generating the H5_gen.F90 shared file" diff --git a/fortran/test/CMakeLists.txt b/fortran/test/CMakeLists.txt index 9c68860..4efd8a8 100644 --- a/fortran/test/CMakeLists.txt +++ b/fortran/test/CMakeLists.txt @@ -83,7 +83,7 @@ endif () if (NOT BUILD_SHARED_LIBS) add_custom_command ( OUTPUT ${HDF5_FORTRAN_TESTS_BINARY_DIR}/static/tf_gen.F90 - COMMAND $ + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_FORTRAN_TESTS_BINARY_DIR}/static DEPENDS H5_test_buildiface COMMENT "Generating the tf_gen.F90 file" @@ -95,7 +95,7 @@ if (NOT BUILD_SHARED_LIBS) else () add_custom_command ( OUTPUT ${HDF5_FORTRAN_TESTS_BINARY_DIR}/shared/tf_gen.F90 - COMMAND $ + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_FORTRAN_TESTS_BINARY_DIR}/shared DEPENDS H5_test_buildiface COMMENT "Generating the tf_gen.F90 shared file" diff --git a/hl/fortran/src/CMakeLists.txt b/hl/fortran/src/CMakeLists.txt index b63b5c6..e532fff 100644 --- a/hl/fortran/src/CMakeLists.txt +++ b/hl/fortran/src/CMakeLists.txt @@ -105,7 +105,7 @@ set (HDF5_HL_F90_F_BASE_SOURCES if (NOT ONLY_SHARED_LIBS) add_custom_command ( OUTPUT ${HDF5_HL_F90_BINARY_DIR}/static/H5LTff_gen.F90 ${HDF5_HL_F90_BINARY_DIR}/static/H5TBff_gen.F90 - COMMAND $ + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_HL_F90_BINARY_DIR}/static DEPENDS ${HDF5_HL_F90_F_BASE_SOURCES} COMMENT "Generating the H5LTff_gen.F90, H5TBff_gen.F90 files" @@ -122,7 +122,7 @@ endif () if (BUILD_SHARED_LIBS) add_custom_command ( OUTPUT ${HDF5_HL_F90_BINARY_DIR}/shared/H5LTff_gen.F90 ${HDF5_HL_F90_BINARY_DIR}/shared/H5TBff_gen.F90 - COMMAND $ + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_HL_F90_BINARY_DIR}/shared DEPENDS ${HDF5_HL_F90_F_BASE_SOURCES} COMMENT "Generating the H5LTff_gen.F90, H5TBff_gen.F90 shared files" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b6c3351..4106515 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1014,7 +1014,7 @@ if (NOT EXISTS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c) add_custom_command ( OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 - COMMAND $ + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ARGS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c COMMAND ${CMAKE_COMMAND} ARGS -E touch ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 @@ -1070,7 +1070,7 @@ target_link_libraries (H5make_libsettings add_custom_command ( OUTPUT ${HDF5_BINARY_DIR}/H5lib_settings.c ${HDF5_BINARY_DIR}/gen_SRCS.stamp2 - COMMAND $ + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ARGS ${HDF5_BINARY_DIR}/H5lib_settings.c COMMAND ${CMAKE_COMMAND} ARGS -E touch ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp2 -- cgit v0.12 From f724e867272b5316dc95c2ff90f32a10975dc850 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 15 Jul 2019 09:44:14 -0500 Subject: HDFFV-10845 use of TARGETFILE disables auto emulator --- c++/examples/CMakeTests.cmake | 6 ++-- c++/test/CMakeTests.cmake | 3 +- c++/test/CMakeVFDTests.cmake | 1 + config/cmake/userblockTest.cmake | 8 ++--- config/cmake/vfdTest.cmake | 4 +-- config/cmake/volTest.cmake | 4 +-- config/cmake_ext_mod/grepTest.cmake | 4 +-- config/cmake_ext_mod/runTest.cmake | 6 ++-- examples/CMakeTests.cmake | 3 +- fortran/examples/CMakeTests.cmake | 6 ++-- fortran/test/CMakeTests.cmake | 16 +++++---- hl/c++/examples/CMakeTests.cmake | 3 +- hl/c++/test/CMakeTests.cmake | 3 +- hl/examples/CMakeTests.cmake | 3 +- hl/fortran/examples/CMakeTests.cmake | 3 +- hl/fortran/test/CMakeTests.cmake | 3 +- hl/test/CMakeTests.cmake | 3 +- hl/tools/gif2h5/CMakeLists.txt | 2 +- hl/tools/gif2h5/CMakeTests.cmake | 10 +++--- hl/tools/h5watch/CMakeTests.cmake | 5 ++- test/CMakePassthroughVOLTests.cmake | 5 +++ test/CMakeTests.cmake | 52 +++++++++++++++++----------- test/CMakeVFDTests.cmake | 5 +++ test/flushrefreshTest.cmake | 4 +-- testpar/CMakeVFDTests.cmake | 1 + tools/test/h5copy/CMakeLists.txt | 2 +- tools/test/h5copy/CMakeTests.cmake | 29 ++++++++++------ tools/test/h5diff/CMakeLists.txt | 2 +- tools/test/h5diff/CMakeTests.cmake | 5 ++- tools/test/h5dump/CMakeLists.txt | 2 +- tools/test/h5dump/CMakeTests.cmake | 27 ++++++++++----- tools/test/h5dump/CMakeTestsPBITS.cmake | 3 +- tools/test/h5dump/CMakeTestsVDS.cmake | 9 +++-- tools/test/h5dump/CMakeTestsXML.cmake | 3 +- tools/test/h5format_convert/CMakeLists.txt | 2 +- tools/test/h5format_convert/CMakeTests.cmake | 12 +++++-- tools/test/h5import/CMakeTests.cmake | 15 ++++++-- tools/test/h5jam/CMakeLists.txt | 2 +- tools/test/h5jam/CMakeTests.cmake | 21 +++++++---- tools/test/h5ls/CMakeTests.cmake | 7 ++-- tools/test/h5ls/CMakeTestsVDS.cmake | 6 ++-- tools/test/h5repack/CMakeTests.cmake | 47 +++++++++++++++---------- tools/test/h5repack/CMakeVFDTests.cmake | 1 + tools/test/h5stat/CMakeLists.txt | 2 +- tools/test/h5stat/CMakeTests.cmake | 6 ++-- tools/test/misc/CMakeLists.txt | 4 +-- tools/test/misc/CMakeTestsClear.cmake | 18 ++++++---- tools/test/misc/CMakeTestsMkgrp.cmake | 6 ++-- tools/test/misc/CMakeTestsRepart.cmake | 10 +++--- tools/test/perform/CMakeTests.cmake | 23 +++++++----- 50 files changed, 277 insertions(+), 150 deletions(-) diff --git a/c++/examples/CMakeTests.cmake b/c++/examples/CMakeTests.cmake index 58bdb68..6a2190c 100644 --- a/c++/examples/CMakeTests.cmake +++ b/c++/examples/CMakeTests.cmake @@ -33,9 +33,10 @@ foreach (example ${examples}) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME CPP_ex_${example} COMMAND $) + add_test (NAME CPP_ex_${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME CPP_ex_${example} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -73,9 +74,10 @@ foreach (example ${tutr_examples}) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME CPP_ex_${example} COMMAND $) + add_test (NAME CPP_ex_${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME CPP_ex_${example} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" diff --git a/c++/test/CMakeTests.cmake b/c++/test/CMakeTests.cmake index 02bff3e..a25dc6b 100644 --- a/c++/test/CMakeTests.cmake +++ b/c++/test/CMakeTests.cmake @@ -32,9 +32,10 @@ add_test ( ) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME CPP_testhdf5 COMMAND $) + add_test (NAME CPP_testhdf5 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME CPP_testhdf5 COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" diff --git a/c++/test/CMakeVFDTests.cmake b/c++/test/CMakeVFDTests.cmake index 6a8ce2c..c979ff1 100644 --- a/c++/test/CMakeVFDTests.cmake +++ b/c++/test/CMakeVFDTests.cmake @@ -46,6 +46,7 @@ add_test ( NAME CPP_VFD-${vfdname}-cpp_testhdf5 COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" diff --git a/config/cmake/userblockTest.cmake b/config/cmake/userblockTest.cmake index 0e9d01b..c9fc36f 100644 --- a/config/cmake/userblockTest.cmake +++ b/config/cmake/userblockTest.cmake @@ -55,7 +55,7 @@ if (TEST_CHECKUB STREQUAL "YES") # of the user block #s2=`$JAM_BIN/tellub $origfile` EXECUTE_PROCESS ( - COMMAND ${TEST_PROGRAM} ${TEST_OFILE} + COMMAND ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_OFILE} WORKING_DIRECTORY ${TEST_FOLDER} RESULT_VARIABLE TEST_RESULT OUTPUT_FILE ${TEST_HFILE}.len.txt @@ -73,7 +73,7 @@ if (TEST_CHECKUB STREQUAL "YES") if (TEST_O_STRING_LEN) #$JAM_BIN/getub -c $s2 $origfile > $cmpfile EXECUTE_PROCESS ( - COMMAND ${TEST_GET_PROGRAM} -c ${TEST_O_STRING_LEN} ${TEST_OFILE} + COMMAND ${TEST_EMULATOR} ${TEST_GET_PROGRAM} -c ${TEST_O_STRING_LEN} ${TEST_OFILE} WORKING_DIRECTORY ${TEST_FOLDER} RESULT_VARIABLE TEST_RESULT OUTPUT_FILE ${TEST_HFILE}-ub.cmp @@ -91,7 +91,7 @@ if (TEST_CHECKUB STREQUAL "YES") #$JAM_BIN/getub -c $size $hfile > $tfile EXECUTE_PROCESS ( - COMMAND ${TEST_GET_PROGRAM} -c ${TEST_STRING_SIZE} ${TEST_HFILE} + COMMAND ${TEST_EMULATOR} ${TEST_GET_PROGRAM} -c ${TEST_STRING_SIZE} ${TEST_HFILE} WORKING_DIRECTORY ${TEST_FOLDER} RESULT_VARIABLE TEST_RESULT OUTPUT_FILE ${TEST_HFILE}.cmp @@ -115,7 +115,7 @@ else () # call 'ubsize' to get the size of the user block #ubsize=`$JAM_BIN/tellub $hfile` EXECUTE_PROCESS ( - COMMAND ${TEST_PROGRAM} ${TEST_HFILE} + COMMAND ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_HFILE} WORKING_DIRECTORY ${TEST_FOLDER} RESULT_VARIABLE TEST_H_STRING_LEN OUTPUT_VARIABLE TEST_OUT diff --git a/config/cmake/vfdTest.cmake b/config/cmake/vfdTest.cmake index 8e186e9..3556d07 100644 --- a/config/cmake/vfdTest.cmake +++ b/config/cmake/vfdTest.cmake @@ -36,13 +36,13 @@ endif () # set (ERROR_APPEND 1) #endif () -message (STATUS "USING ${TEST_VFD} ON COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}") +message (STATUS "USING ${TEST_VFD} ON COMMAND: ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS}") set (ENV{HDF5_DRIVER} "${TEST_VFD}") # run the test program, capture the stdout/stderr and the result var execute_process ( - COMMAND ${TEST_PROGRAM} ${TEST_ARGS} + COMMAND ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS} WORKING_DIRECTORY ${TEST_FOLDER} RESULT_VARIABLE TEST_RESULT OUTPUT_FILE ${TEST_OUTPUT}_${TEST_VFD}.out diff --git a/config/cmake/volTest.cmake b/config/cmake/volTest.cmake index a9dd756..6554f00 100644 --- a/config/cmake/volTest.cmake +++ b/config/cmake/volTest.cmake @@ -36,13 +36,13 @@ endif () # set (ERROR_APPEND 1) #endif () -message (STATUS "USING ${TEST_VOL} ON COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}") +message (STATUS "USING ${TEST_VOL} ON COMMAND: ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS}") set (ENV{HDF5_VOL_CONNECTOR} "${TEST_VOL}") # run the test program, capture the stdout/stderr and the result var execute_process ( - COMMAND ${TEST_PROGRAM} ${TEST_ARGS} + COMMAND ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS} WORKING_DIRECTORY ${TEST_FOLDER} RESULT_VARIABLE TEST_RESULT OUTPUT_FILE ${TEST_OUTPUT}.out diff --git a/config/cmake_ext_mod/grepTest.cmake b/config/cmake_ext_mod/grepTest.cmake index dffbd8c..2a30336 100644 --- a/config/cmake_ext_mod/grepTest.cmake +++ b/config/cmake_ext_mod/grepTest.cmake @@ -43,7 +43,7 @@ if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.err) file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}.err) endif () -message (STATUS "COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}") +message (STATUS "COMMAND: ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS}") if (TEST_LIBRARY_DIRECTORY) if (WIN32 OR MINGW) @@ -60,7 +60,7 @@ endif () # run the test program, capture the stdout/stderr and the result var execute_process ( - COMMAND ${TEST_PROGRAM} ${TEST_ARGS} + COMMAND ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS} WORKING_DIRECTORY ${TEST_FOLDER} RESULT_VARIABLE TEST_RESULT OUTPUT_FILE ${TEST_OUTPUT} diff --git a/config/cmake_ext_mod/runTest.cmake b/config/cmake_ext_mod/runTest.cmake index 184ec27..3953c27 100644 --- a/config/cmake_ext_mod/runTest.cmake +++ b/config/cmake_ext_mod/runTest.cmake @@ -35,7 +35,7 @@ if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.err) file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}.err) endif () -message (STATUS "COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}") +message (STATUS "COMMAND: ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS}") if (TEST_LIBRARY_DIRECTORY) if (WIN32 OR MINGW) @@ -53,7 +53,7 @@ endif () if (NOT TEST_INPUT) # run the test program, capture the stdout/stderr and the result var execute_process ( - COMMAND ${TEST_PROGRAM} ${TEST_ARGS} + COMMAND ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS} WORKING_DIRECTORY ${TEST_FOLDER} RESULT_VARIABLE TEST_RESULT OUTPUT_FILE ${TEST_OUTPUT} @@ -64,7 +64,7 @@ if (NOT TEST_INPUT) else () # run the test program with stdin, capture the stdout/stderr and the result var execute_process ( - COMMAND ${TEST_PROGRAM} ${TEST_ARGS} + COMMAND ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS} WORKING_DIRECTORY ${TEST_FOLDER} RESULT_VARIABLE TEST_RESULT INPUT_FILE ${TEST_INPUT} diff --git a/examples/CMakeTests.cmake b/examples/CMakeTests.cmake index 6cab7dd..69ace97 100644 --- a/examples/CMakeTests.cmake +++ b/examples/CMakeTests.cmake @@ -77,9 +77,10 @@ foreach (example ${examples}) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME EXAMPLES-${example} COMMAND $) + add_test (NAME EXAMPLES-${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME EXAMPLES-${example} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" diff --git a/fortran/examples/CMakeTests.cmake b/fortran/examples/CMakeTests.cmake index 1ad606c..221e5cc 100644 --- a/fortran/examples/CMakeTests.cmake +++ b/fortran/examples/CMakeTests.cmake @@ -47,9 +47,10 @@ foreach (example ${examples}) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME f90_ex_${example} COMMAND $) + add_test (NAME f90_ex_${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME f90_ex_${example} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -68,9 +69,10 @@ endforeach () foreach (example ${F2003_examples}) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME f03_ex_${example} COMMAND $) + add_test (NAME f03_ex_${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME f03_ex_${example} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" diff --git a/fortran/test/CMakeTests.cmake b/fortran/test/CMakeTests.cmake index 20fb7e3..c93b4a2 100644 --- a/fortran/test/CMakeTests.cmake +++ b/fortran/test/CMakeTests.cmake @@ -65,9 +65,10 @@ endif () set (last_test "FORTRAN_testhdf5-clear-objects") if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME FORTRAN_testhdf5_fortran COMMAND $) + add_test (NAME FORTRAN_testhdf5_fortran COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME FORTRAN_testhdf5_fortran COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -85,9 +86,10 @@ set_tests_properties (FORTRAN_testhdf5_fortran PROPERTIES DEPENDS FORTRAN_testhd #-- Adding test for testhdf5_fortran_1_8 if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME FORTRAN_testhdf5_fortran_1_8 COMMAND $) + add_test (NAME FORTRAN_testhdf5_fortran_1_8 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME FORTRAN_testhdf5_fortran_1_8 COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -105,9 +107,10 @@ set_tests_properties (FORTRAN_testhdf5_fortran_1_8 PROPERTIES DEPENDS FORTRAN_te #-- Adding test for fortranlib_test_F03 if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME FORTRAN_fortranlib_test_F03 COMMAND $) + add_test (NAME FORTRAN_fortranlib_test_F03 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME FORTRAN_fortranlib_test_F03 COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -125,9 +128,10 @@ endif () #-- Adding test for vol_connector if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME FORTRAN_vol_connector COMMAND $) + add_test (NAME FORTRAN_vol_connector COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME FORTRAN_vol_connector COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -142,9 +146,9 @@ else () endif () #-- Adding test for fflush1 -add_test (NAME FORTRAN_fflush1 COMMAND $) +add_test (NAME FORTRAN_fflush1 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) set_tests_properties (FORTRAN_fflush1 PROPERTIES DEPENDS FORTRAN_testhdf5-clear-objects) #-- Adding test for fflush2 -add_test (NAME FORTRAN_fflush2 COMMAND $) +add_test (NAME FORTRAN_fflush2 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) set_tests_properties (FORTRAN_fflush2 PROPERTIES DEPENDS FORTRAN_fflush1) diff --git a/hl/c++/examples/CMakeTests.cmake b/hl/c++/examples/CMakeTests.cmake index 103ec2b..a7acc63 100644 --- a/hl/c++/examples/CMakeTests.cmake +++ b/hl/c++/examples/CMakeTests.cmake @@ -24,9 +24,10 @@ add_test ( ) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME HL_CPP_ex_ptExampleFL COMMAND $) + add_test (NAME HL_CPP_ex_ptExampleFL COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME HL_CPP_ex_ptExampleFL COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" diff --git a/hl/c++/test/CMakeTests.cmake b/hl/c++/test/CMakeTests.cmake index 785abca..f85ef85 100644 --- a/hl/c++/test/CMakeTests.cmake +++ b/hl/c++/test/CMakeTests.cmake @@ -17,9 +17,10 @@ ############################################################################## if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME HL_CPP_ptableTest COMMAND $) + add_test (NAME HL_CPP_ptableTest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME HL_CPP_ptableTest COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" diff --git a/hl/examples/CMakeTests.cmake b/hl/examples/CMakeTests.cmake index c1fd6c2..407c61c 100644 --- a/hl/examples/CMakeTests.cmake +++ b/hl/examples/CMakeTests.cmake @@ -58,9 +58,10 @@ add_custom_target(hl_ex_ex_ds1_files ALL COMMENT "Copying files needed by hl_ex_ foreach (example ${examples}) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME HL_ex_${example} COMMAND $) + add_test (NAME HL_ex_${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME HL_ex_${example} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" diff --git a/hl/fortran/examples/CMakeTests.cmake b/hl/fortran/examples/CMakeTests.cmake index 91cb56b..d3a9d0c 100644 --- a/hl/fortran/examples/CMakeTests.cmake +++ b/hl/fortran/examples/CMakeTests.cmake @@ -28,9 +28,10 @@ add_test ( foreach (example ${examples}) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME HL_FORTRAN_f90_ex_${example} COMMAND $) + add_test (NAME HL_FORTRAN_f90_ex_${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME HL_FORTRAN_f90_ex_${example} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" diff --git a/hl/fortran/test/CMakeTests.cmake b/hl/fortran/test/CMakeTests.cmake index 2137d1a..0b81573 100644 --- a/hl/fortran/test/CMakeTests.cmake +++ b/hl/fortran/test/CMakeTests.cmake @@ -30,9 +30,10 @@ set (test_CLEANFILES macro (ADD_H5_FORTRAN_TEST file) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME HL_FORTRAN_f90_${file} COMMAND $) + add_test (NAME HL_FORTRAN_f90_${file} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME HL_FORTRAN_f90_${file} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" diff --git a/hl/test/CMakeTests.cmake b/hl/test/CMakeTests.cmake index 477a165..be90206 100644 --- a/hl/test/CMakeTests.cmake +++ b/hl/test/CMakeTests.cmake @@ -48,9 +48,10 @@ add_custom_target(hl_test_files ALL COMMENT "Copying files needed by hl_test tes # -------------------------------------------------------------------- macro (HL_ADD_TEST hl_name) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME HL_${hl_name} COMMAND $) + add_test (NAME HL_${hl_name} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME HL_${hl_name} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" diff --git a/hl/tools/gif2h5/CMakeLists.txt b/hl/tools/gif2h5/CMakeLists.txt index 14a5f5f..3cd913f 100644 --- a/hl/tools/gif2h5/CMakeLists.txt +++ b/hl/tools/gif2h5/CMakeLists.txt @@ -80,7 +80,7 @@ if (BUILD_TESTING) target_link_libraries (hl_h52gifgentest PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (hl_h52gifgentest PROPERTIES FOLDER generator/tools/hl) -# add_test (NAME hl_h52gifgentest COMMAND $) +# add_test (NAME hl_h52gifgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) endif () include (CMakeTests.cmake) diff --git a/hl/tools/gif2h5/CMakeTests.cmake b/hl/tools/gif2h5/CMakeTests.cmake index 1cc989c..ab14864 100644 --- a/hl/tools/gif2h5/CMakeTests.cmake +++ b/hl/tools/gif2h5/CMakeTests.cmake @@ -44,19 +44,19 @@ add_test ( image24.gif ) -add_test (NAME HL_TOOLS_gif2h5 COMMAND $ testfiles/image1.gif image1.h5) +add_test (NAME HL_TOOLS_gif2h5 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ testfiles/image1.gif image1.h5) set_tests_properties (HL_TOOLS_gif2h5 PROPERTIES DEPENDS HL_TOOLS-clear-objects) -add_test (NAME HL_TOOLS_h52gif COMMAND $ testfiles/h52giftst.h5 image1.gif -i image) +add_test (NAME HL_TOOLS_h52gif COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ testfiles/h52giftst.h5 image1.gif -i image) set_tests_properties (HL_TOOLS_h52gif PROPERTIES DEPENDS HL_TOOLS-clear-objects) -add_test (NAME HL_TOOLS_h52gif_none COMMAND $ testfiles/h52giftst.h5 image.gif -i nosuch_image) +add_test (NAME HL_TOOLS_h52gif_none COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ testfiles/h52giftst.h5 image.gif -i nosuch_image) set_tests_properties (HL_TOOLS_h52gif_none PROPERTIES WILL_FAIL "true") set_tests_properties (HL_TOOLS_h52gif_none PROPERTIES DEPENDS HL_TOOLS-clear-objects) -#add_test (NAME HL_TOOLS_h52gifpal COMMAND $ testfiles/h52giftst.h5 image.gif -i palette) +#add_test (NAME HL_TOOLS_h52gifpal COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ testfiles/h52giftst.h5 image.gif -i palette) #set_tests_properties (HL_TOOLS_h52gifpal PROPERTIES WILL_FAIL "true") -add_test (NAME HL_TOOLS_h52gif24bits COMMAND $ testfiles/ex_image2.h5 image24.gif -i image24bitpixel) +add_test (NAME HL_TOOLS_h52gif24bits COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ testfiles/ex_image2.h5 image24.gif -i image24bitpixel) set_tests_properties (HL_TOOLS_h52gif24bits PROPERTIES WILL_FAIL "true") set_tests_properties (HL_TOOLS_h52gif24bits PROPERTIES DEPENDS HL_TOOLS-clear-objects) diff --git a/hl/tools/h5watch/CMakeTests.cmake b/hl/tools/h5watch/CMakeTests.cmake index fba8484..e563be4 100644 --- a/hl/tools/h5watch/CMakeTests.cmake +++ b/hl/tools/h5watch/CMakeTests.cmake @@ -79,6 +79,7 @@ add_custom_target(H5WATCH_files ALL COMMENT "Copying files needed by H5WATCH tes add_test ( NAME H5WATCH_ARGS-h5watch-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -97,6 +98,7 @@ add_custom_target(H5WATCH_files ALL COMMENT "Copying files needed by H5WATCH tes add_test ( NAME H5WATCH_ARGS-h5watch-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -122,6 +124,7 @@ add_custom_target(H5WATCH_files ALL COMMENT "Copying files needed by H5WATCH tes add_test ( NAME H5WATCH-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -177,7 +180,7 @@ if (NOT SWMR_INCOMPAT) # # ################################################################################################# # create the output files to be used. - add_test (NAME H5WATCH-h5watchgentest COMMAND $) + add_test (NAME H5WATCH-h5watchgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) set_tests_properties (H5WATCH-h5watchgentest PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") set_tests_properties (H5WATCH-h5watchgentest PROPERTIES DEPENDS "H5WATCH-clearall-objects") set (last_test "H5WATCH-h5watchgentest") diff --git a/test/CMakePassthroughVOLTests.cmake b/test/CMakePassthroughVOLTests.cmake index 24a0201..9863147 100644 --- a/test/CMakePassthroughVOLTests.cmake +++ b/test/CMakePassthroughVOLTests.cmake @@ -99,6 +99,7 @@ add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HD ) add_test (NAME VOL-${volname}-${voltest} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VOL:STRING=${volinfo}" @@ -127,6 +128,7 @@ add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HD ) add_test (NAME VOL-${volname}-${voltest} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VOL:STRING=${volinfo}" @@ -151,6 +153,7 @@ add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HD ) add_test (NAME VOL-${volname}-${voltest} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VOL:STRING=${volinfo}" @@ -178,6 +181,7 @@ add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HD ) add_test (NAME VOL-${volname}-${voltest} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VOL:STRING=${volinfo}" @@ -221,6 +225,7 @@ add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HD ) add_test (NAME VOL-${volname}-fheap COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VOL:STRING=${volinfo}" diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index b138f14..8537c46 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -206,25 +206,25 @@ add_test (NAME H5TEST-clear-testhdf5-objects ) set_tests_properties (H5TEST-clear-testhdf5-objects PROPERTIES FIXTURES_SETUP clear_testhdf5) -add_test (NAME H5TEST-testhdf5-base COMMAND $ -x heap -x file -x select) +add_test (NAME H5TEST-testhdf5-base COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -x heap -x file -x select) set_tests_properties (H5TEST-testhdf5-base PROPERTIES FIXTURES_REQUIRED clear_testhdf5 ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) -add_test (NAME H5TEST-testhdf5-heap COMMAND $ -o heap) +add_test (NAME H5TEST-testhdf5-heap COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -o heap) set_tests_properties (H5TEST-testhdf5-heap PROPERTIES FIXTURES_REQUIRED clear_testhdf5 ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) -add_test (NAME H5TEST-testhdf5-file COMMAND $ -o file) +add_test (NAME H5TEST-testhdf5-file COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -o file) set_tests_properties (H5TEST-testhdf5-file PROPERTIES FIXTURES_REQUIRED clear_testhdf5 ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) -add_test (NAME H5TEST-testhdf5-select COMMAND $ -o select) +add_test (NAME H5TEST-testhdf5-select COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -o select) set_tests_properties (H5TEST-testhdf5-select PROPERTIES FIXTURES_REQUIRED clear_testhdf5 ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" @@ -472,7 +472,7 @@ set (H5TEST_SEPARATE_TESTS foreach (h5_test ${H5_TESTS}) if (NOT h5_test IN_LIST H5TEST_SEPARATE_TESTS) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5TEST-${h5_test} COMMAND $) + add_test (NAME H5TEST-${h5_test} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) set_tests_properties (H5TEST-${h5_test} PROPERTIES FIXTURES_REQUIRED clear_objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" @@ -485,6 +485,7 @@ foreach (h5_test ${H5_TESTS}) ) else () add_test (NAME H5TEST-${h5_test} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -521,9 +522,10 @@ if (NOT CYGWIN) ) set_tests_properties (H5TEST-clear-cache-objects PROPERTIES FIXTURES_SETUP cache_clear_objects) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5TEST-cache COMMAND $) + add_test (NAME H5TEST-cache COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME H5TEST-cache COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -553,7 +555,7 @@ if (TEST_CACHE_IMAGE) ${HDF5_TEST_BINARY_DIR}/H5TEST ) set_tests_properties (H5TEST-clear-cache_image-objects PROPERTIES FIXTURES_SETUP cache_image_clear_objects) - add_test (NAME H5TEST-cache_image COMMAND $) + add_test (NAME H5TEST-cache_image COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) set_tests_properties (H5TEST-cache_image PROPERTIES FIXTURES_REQUIRED cache_image_clear_objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5TestExpress=${HDF_TEST_EXPRESS}" @@ -581,9 +583,10 @@ add_test ( ) set_tests_properties (H5TEST-clear-external_env-objects PROPERTIES FIXTURES_SETUP external_env_clear_objects) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5TEST-external_env COMMAND $) + add_test (NAME H5TEST-external_env COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME H5TEST-external_env COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_ENV_VAR:STRING=HDF5_EXTFILE_PREFIX" @@ -617,9 +620,10 @@ add_test ( ) set_tests_properties (H5TEST-clear-vds_env-objects PROPERTIES FIXTURES_SETUP vds_env_clear_objects) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5TEST-vds_env COMMAND $) + add_test (NAME H5TEST-vds_env COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME H5TEST-vds_env COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_ENV_VAR:STRING=HDF5_VDS_PREFIX" @@ -654,9 +658,10 @@ add_test (NAME H5TEST-clear-flush-objects ${HDF5_TEST_BINARY_DIR}/H5TEST ) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5TEST-flush1 COMMAND $) + add_test (NAME H5TEST-flush1 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME H5TEST-flush1 COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -672,9 +677,10 @@ set_tests_properties (H5TEST-flush1 PROPERTIES WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5TEST-flush2 COMMAND $) + add_test (NAME H5TEST-flush2 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME H5TEST-flush2 COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -687,17 +693,17 @@ endif () set_tests_properties (H5TEST-flush2 PROPERTIES DEPENDS H5TEST-flush1) #-- Adding test for tcheck_version -add_test (NAME H5TEST-tcheck_version-major COMMAND $ "-tM") +add_test (NAME H5TEST-tcheck_version-major COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ "-tM") set_tests_properties (H5TEST-tcheck_version-major PROPERTIES WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST WILL_FAIL "true" ) -add_test (NAME H5TEST-tcheck_version-minor COMMAND $ "-tm") +add_test (NAME H5TEST-tcheck_version-minor COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ "-tm") set_tests_properties (H5TEST-tcheck_version-minor PROPERTIES WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST WILL_FAIL "true" ) -add_test (NAME H5TEST-tcheck_version-release COMMAND $ "-tr") +add_test (NAME H5TEST-tcheck_version-release COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ "-tr") set_tests_properties (H5TEST-tcheck_version-release PROPERTIES WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST WILL_FAIL "true" @@ -745,7 +751,7 @@ add_test ( ${HDF5_TEST_BINARY_DIR}/H5TEST ) set_tests_properties (H5TEST-clear-filenotclosed-objects PROPERTIES FIXTURES_SETUP filenotclosed_clear_objects) -add_test (NAME H5TEST-filenotclosed COMMAND $) +add_test (NAME H5TEST-filenotclosed COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) set_tests_properties (H5TEST-filenotclosed PROPERTIES FIXTURES_REQUIRED filenotclosed_clear_objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" @@ -762,7 +768,7 @@ add_test ( ${HDF5_TEST_BINARY_DIR}/H5TEST ) set_tests_properties (H5TEST-clear-del_many_dense_attrs-objects PROPERTIES FIXTURES_SETUP del_many_dense_attrs_clear_objects) -add_test (NAME H5TEST-del_many_dense_attrs COMMAND $) +add_test (NAME H5TEST-del_many_dense_attrs COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) set_tests_properties (H5TEST-del_many_dense_attrs PROPERTIES FIXTURES_REQUIRED del_many_dense_attrs_clear_objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" @@ -781,6 +787,7 @@ if (HDF5_ENABLE_DEPRECATED_SYMBOLS) ) set_tests_properties (H5TEST-clear-err_compat-objects PROPERTIES FIXTURES_SETUP err_compat_clear_objects) add_test (NAME H5TEST-err_compat COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -816,6 +823,7 @@ if (HDF5_USE_16_API_DEFAULT) set_property(TEST H5TEST-error_test PROPERTY DISABLED) else () add_test (NAME H5TEST-error_test COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -847,9 +855,10 @@ add_test (NAME H5TEST-clear-links_env-objects ) set_tests_properties (H5TEST-clear-links_env-objects PROPERTIES FIXTURES_SETUP links_env_clear_objects) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5TEST-links_env COMMAND $) + add_test (NAME H5TEST-links_env COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME H5TEST-links_env COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" #-D "TEST_ENV_VAR:STRING=HDF5_EXT_PREFIX" @@ -893,7 +902,7 @@ if (BUILD_SHARED_LIBS) set (BIN_REL_PATH "../") endif () - add_test (NAME H5PLUGIN-filter_plugin COMMAND $) + add_test (NAME H5PLUGIN-filter_plugin COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) set_tests_properties (H5PLUGIN-filter_plugin PROPERTIES ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/filter_plugin_dir1${CMAKE_SEP}${CMAKE_BINARY_DIR}/filter_plugin_dir2;srcdir=${HDF5_TEST_BINARY_DIR}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR} @@ -902,7 +911,7 @@ if (BUILD_SHARED_LIBS) ############################################################################## # HDFFV-9655 relative plugin test disabled # -# add_test (NAME H5PLUGIN-pluginRelative COMMAND $) +# add_test (NAME H5PLUGIN-pluginRelative COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) # set_tests_properties (H5PLUGIN-pluginRelative PROPERTIES # ENVIRONMENT "HDF5_PLUGIN_PATH=@/${BIN_REL_PATH}testdir1${CMAKE_SEP}@/${BIN_REL_PATH}testdir2;srcdir=${HDF5_TEST_BINARY_DIR}" # WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR} @@ -923,7 +932,7 @@ if (ENABLE_EXTENDED_TESTS) # testswmr.sh: swmr* # testvdsswmr.sh: vds_swmr* -# add_test (NAME H5Test-swmr_check_compat_vfd COMMAND $) +# add_test (NAME H5Test-swmr_check_compat_vfd COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) #-- Adding test for flushrefresh file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST/flushrefresh_test") @@ -940,6 +949,7 @@ if (ENABLE_EXTENDED_TESTS) ) set_tests_properties (H5TEST-clear-testflushrefresh-objects PROPERTIES FIXTURES_SETUP testflushrefresh_clear_objects) add_test (NAME H5TEST-testflushrefresh COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS1:STRING=flushrefresh_VERIFICATION_START" -D "TEST_ARGS2:STRING=flushrefresh_VERIFICATION_DONE" @@ -990,7 +1000,7 @@ if (BUILD_SHARED_LIBS) set (BIN_REL_PATH "../") endif () - add_test (NAME H5PLUGIN-vol_plugin COMMAND $) + add_test (NAME H5PLUGIN-vol_plugin COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) set_tests_properties (H5PLUGIN-vol_plugin PROPERTIES ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/null_vol_plugin_dir;srcdir=${HDF5_TEST_BINARY_DIR}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR} diff --git a/test/CMakeVFDTests.cmake b/test/CMakeVFDTests.cmake index 0ddce92..2767bdc 100644 --- a/test/CMakeVFDTests.cmake +++ b/test/CMakeVFDTests.cmake @@ -102,6 +102,7 @@ add_custom_target(HDF5_VFDTEST_LIB_files ALL COMMENT "Copying files needed by HD ) add_test (NAME VFD-${vfdname}-${vfdtest} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" @@ -130,6 +131,7 @@ add_custom_target(HDF5_VFDTEST_LIB_files ALL COMMENT "Copying files needed by HD ) add_test (NAME VFD-${vfdname}-${vfdtest} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" @@ -154,6 +156,7 @@ add_custom_target(HDF5_VFDTEST_LIB_files ALL COMMENT "Copying files needed by HD ) add_test (NAME VFD-${vfdname}-${vfdtest} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" @@ -180,6 +183,7 @@ add_custom_target(HDF5_VFDTEST_LIB_files ALL COMMENT "Copying files needed by HD ) add_test (NAME VFD-${vfdname}-${vfdtest} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" @@ -222,6 +226,7 @@ add_custom_target(HDF5_VFDTEST_LIB_files ALL COMMENT "Copying files needed by HD ) add_test (NAME VFD-${vfdname}-fheap COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" diff --git a/test/flushrefreshTest.cmake b/test/flushrefreshTest.cmake index 926efba..01faad5 100644 --- a/test/flushrefreshTest.cmake +++ b/test/flushrefreshTest.cmake @@ -90,7 +90,7 @@ while (verification_done LESS "1") else () message (STATUS "execute: ${TEST_PROGRAM} ${param1} ${param2}") execute_process ( - COMMAND ${TEST_PROGRAM} ${param1} ${param2} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} ${TEST_PROGRAM} ${param1} ${param2} RESULT_VARIABLE TEST_RESULT OUTPUT_FILE ${TEST_OUTPUT} ERROR_FILE ${TEST_OUTPUT}.err @@ -133,7 +133,7 @@ while (verification_done LESS "2") else () message (STATUS "execute: ${TEST_PROGRAM} ${param1}") execute_process ( - COMMAND ${TEST_PROGRAM} ${param1} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} ${TEST_PROGRAM} ${param1} RESULT_VARIABLE TEST_RESULT OUTPUT_FILE ${TEST_OUTPUT} ERROR_FILE ${TEST_OUTPUT}.err diff --git a/testpar/CMakeVFDTests.cmake b/testpar/CMakeVFDTests.cmake index 7333c6d..6f974af 100644 --- a/testpar/CMakeVFDTests.cmake +++ b/testpar/CMakeVFDTests.cmake @@ -50,6 +50,7 @@ endforeach () add_test ( NAME MPI_TEST_VFD-${vfdname}-${h5_test} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" diff --git a/tools/test/h5copy/CMakeLists.txt b/tools/test/h5copy/CMakeLists.txt index ecf371f..1130ea7 100644 --- a/tools/test/h5copy/CMakeLists.txt +++ b/tools/test/h5copy/CMakeLists.txt @@ -11,7 +11,7 @@ if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) target_link_libraries (h5copygentest PRIVATE ${HDF5_LIB_TARGET}) set_target_properties (h5copygentest PROPERTIES FOLDER generator/tools) - #add_test (NAME h5copygentest COMMAND $) + #add_test (NAME h5copygentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) endif () #----------------------------------------------------------------------------- diff --git a/tools/test/h5copy/CMakeTests.cmake b/tools/test/h5copy/CMakeTests.cmake index df56f1a..3fabdf6 100644 --- a/tools/test/h5copy/CMakeTests.cmake +++ b/tools/test/h5copy/CMakeTests.cmake @@ -73,7 +73,7 @@ add_test ( NAME H5COPY_F-${testname} - COMMAND $ -f ${fparam} -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -f ${fparam} -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN} ) if (HDF5_ENABLE_USING_MEMCHECKER) if (last_test) @@ -87,7 +87,7 @@ if (NOT ${resultcode} EQUAL 2) add_test ( NAME H5COPY_F-${testname}-DIFF - COMMAND $ -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) set_tests_properties (H5COPY_F-${testname}-DIFF PROPERTIES DEPENDS H5COPY_F-${testname}) if (${resultcode} EQUAL 1) @@ -109,7 +109,7 @@ add_test ( NAME H5COPY-${testname} - COMMAND $ -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN} ) if (HDF5_ENABLE_USING_MEMCHECKER) if (last_test) @@ -123,7 +123,7 @@ if (NOT ${resultcode} EQUAL 2) add_test ( NAME H5COPY-${testname}-DIFF - COMMAND $ -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) set_tests_properties (H5COPY-${testname}-DIFF PROPERTIES DEPENDS H5COPY-${testname}) if (${resultcode} EQUAL 1) @@ -155,7 +155,7 @@ add_test ( NAME H5COPY-${testname}-prefill - COMMAND $ -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 -v -s ${psparam} -d ${pdparam} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 -v -s ${psparam} -d ${pdparam} ) if (HDF5_ENABLE_USING_MEMCHECKER) if (last_test) @@ -167,14 +167,14 @@ add_test ( NAME H5COPY-${testname} - COMMAND $ -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN} ) set_tests_properties (H5COPY-${testname} PROPERTIES DEPENDS H5COPY-${testname}-prefill) # resultcode=2 will cause the test to skip the diff test if (NOT ${resultcode} EQUAL 2) add_test ( NAME H5COPY-${testname}-DIFF - COMMAND $ -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) set_tests_properties (H5COPY-${testname}-DIFF PROPERTIES DEPENDS H5COPY-${testname}) if (${resultcode} EQUAL 1) @@ -196,7 +196,7 @@ add_test ( NAME H5COPY_SAME-${testname}-prefill - COMMAND $ -i ./testfiles/${pfile} -o ./testfiles/${testname}.out.h5 -v -s ${psparam} -d ${pdparam} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -i ./testfiles/${pfile} -o ./testfiles/${testname}.out.h5 -v -s ${psparam} -d ${pdparam} ) if (HDF5_ENABLE_USING_MEMCHECKER) if (last_test) @@ -208,14 +208,14 @@ add_test ( NAME H5COPY_SAME-${testname} - COMMAND $ -i ./testfiles/${testname}.out.h5 -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -i ./testfiles/${testname}.out.h5 -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN} ) set_tests_properties (H5COPY_SAME-${testname} PROPERTIES DEPENDS H5COPY_SAME-${testname}-prefill) # resultcode=2 will cause the test to skip the diff test if (NOT ${resultcode} EQUAL 2) add_test ( NAME H5COPY_SAME-${testname}-DIFF - COMMAND $ -v ./testfiles/${testname}.out.h5 ./testfiles/${testname}.out.h5 ${srcname} ${dstname} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -v ./testfiles/${testname}.out.h5 ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) set_tests_properties (H5COPY_SAME-${testname}-DIFF PROPERTIES DEPENDS H5COPY_SAME-${testname}) if (${resultcode} EQUAL 1) @@ -231,7 +231,7 @@ macro (ADD_H5_CMP_TEST testname resultcode infile vparam sparam srcname dparam dstname) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5COPY-CMP-${testname} COMMAND $ -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN}) + add_test (NAME H5COPY-CMP-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN}) if (${resultcode} EQUAL 1) set_tests_properties (H5COPY-CMP-${testname} PROPERTIES WILL_FAIL "true") endif () @@ -251,6 +251,7 @@ add_test ( NAME H5COPY-CMP-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS=-i;./testfiles/${infile};-o;./testfiles/${testname}.out.h5;${vparam};${sparam};${srcname};${dparam};${dstname}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -282,6 +283,7 @@ add_test ( NAME H5COPY_UD-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-v;-i;./testfiles/${infile};-o;./testfiles/${testname}.out.h5;${sparam};${srcname};${dparam};${dstname}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -298,6 +300,7 @@ add_test ( NAME H5COPY_UD-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-v;-i;./testfiles/${infile};-o;./testfiles/${testname}.out.h5;${sparam};${srcname};${dparam};${dstname}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -315,6 +318,7 @@ add_test ( NAME H5COPY_UD-${testname}-DIFF COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-v;./testfiles/${cmpfile};./testfiles/${testname}.out.h5;${srcname};${dstname}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -348,6 +352,7 @@ add_test ( NAME H5COPY_UD_ERR-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-v;--enable-error-stack;-i;./testfiles/${infile};-o;./testfiles/${testname}_ERR.out.h5;${sparam};${srcname};${dparam};${dstname}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -365,6 +370,7 @@ add_test ( NAME H5COPY_UD_ERR-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-v;--enable-error-stack;-i;./testfiles/${infile};-o;./testfiles/${testname}_ERR.out.h5;${sparam};${srcname};${dparam};${dstname}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -383,6 +389,7 @@ add_test ( NAME H5COPY_UD_ERR-${testname}-DIFF COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-v;./testfiles/${cmpfile};./testfiles/${testname}_ERR.out.h5;${srcname};${dstname}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" diff --git a/tools/test/h5diff/CMakeLists.txt b/tools/test/h5diff/CMakeLists.txt index 0a874ec..cb4397f 100644 --- a/tools/test/h5diff/CMakeLists.txt +++ b/tools/test/h5diff/CMakeLists.txt @@ -11,7 +11,7 @@ if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) target_link_libraries (h5diffgentest PRIVATE ${HDF5_LIB_TARGET}) set_target_properties (h5diffgentest PROPERTIES FOLDER generator/tools) - #add_test (NAME h5diffgentest COMMAND $) + #add_test (NAME h5diffgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) endif () #----------------------------------------------------------------------------- diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake index 604c8a5..c7734a6 100644 --- a/tools/test/h5diff/CMakeTests.cmake +++ b/tools/test/h5diff/CMakeTests.cmake @@ -358,7 +358,7 @@ macro (ADD_H5_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DIFF-${resultfile} COMMAND $ ${ARGN}) + add_test (NAME H5DIFF-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) set_tests_properties (H5DIFF-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") if (${resultcode}) set_tests_properties (H5DIFF-${resultfile} PROPERTIES WILL_FAIL "true") @@ -381,6 +381,7 @@ add_test ( NAME H5DIFF-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -454,6 +455,7 @@ add_test ( NAME H5DIFF_UD-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -470,6 +472,7 @@ add_test ( NAME H5DIFF_UD-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" diff --git a/tools/test/h5dump/CMakeLists.txt b/tools/test/h5dump/CMakeLists.txt index 1672774..38f4118 100644 --- a/tools/test/h5dump/CMakeLists.txt +++ b/tools/test/h5dump/CMakeLists.txt @@ -40,7 +40,7 @@ if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) target_link_libraries (h5dumpgentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (h5dumpgentest PROPERTIES FOLDER generator/tools) - #add_test (NAME h5dumpgentest COMMAND $) + #add_test (NAME h5dumpgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) endif () include (CMakeTests.cmake) diff --git a/tools/test/h5dump/CMakeTests.cmake b/tools/test/h5dump/CMakeTests.cmake index db47111..c151c9a 100644 --- a/tools/test/h5dump/CMakeTests.cmake +++ b/tools/test/h5dump/CMakeTests.cmake @@ -411,7 +411,7 @@ macro (ADD_HELP_TEST testname resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${testname} COMMAND $ ${ARGN}) + add_test (NAME H5DUMP-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) set_tests_properties (H5DUMP-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") if (last_test) set_tests_properties (H5DUMP-${testname} PROPERTIES DEPENDS ${last_test}) @@ -432,6 +432,7 @@ add_test ( NAME H5DUMP-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" @@ -461,7 +462,7 @@ macro (ADD_H5_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND $ ${ARGN}) + add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") if (${resultcode}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") @@ -482,6 +483,7 @@ add_test ( NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" @@ -497,7 +499,7 @@ macro (ADD_H5_TEST_N resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-N-${resultfile} COMMAND $ ${ARGN}) + add_test (NAME H5DUMP-N-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) set_tests_properties (H5DUMP-N-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") if (${resultcode}) set_tests_properties (H5DUMP-N-${resultfile} PROPERTIES WILL_FAIL "true") @@ -518,6 +520,7 @@ add_test ( NAME H5DUMP-N-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" @@ -533,7 +536,7 @@ macro (ADD_H5_TEST_EXPORT resultfile targetfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND $ ${ARGN} ${resultfile}.txt ${targetfile}) + add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${resultfile}.txt ${targetfile}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") if (${resultcode}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") @@ -554,6 +557,7 @@ add_test ( NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN};${resultfile}.txt;${targetfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" @@ -576,7 +580,7 @@ macro (ADD_H5_TEST_EXPORT_DDL resultfile targetfile resultcode ddlfile) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND $ --ddl=${ddlfile}.txt ${ARGN} ${resultfile}.txt ${targetfile}) + add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ --ddl=${ddlfile}.txt ${ARGN} ${resultfile}.txt ${targetfile}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") if (${resultcode}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") @@ -598,6 +602,7 @@ add_test ( NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=--ddl=${ddlfile}.txt;${ARGN};${resultfile}.txt;${targetfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" @@ -634,7 +639,7 @@ set_tests_properties (H5DUMP-output-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") add_test ( NAME H5DUMP-output-${resultfile} - COMMAND $ ${ARGN} ${resultfile}.txt ${targetfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${resultfile}.txt ${targetfile} ) set_tests_properties (H5DUMP-output-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") set_tests_properties (H5DUMP-output-${resultfile} PROPERTIES DEPENDS H5DUMP-output-${resultfile}-clear-objects) @@ -662,6 +667,7 @@ add_test ( NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" @@ -689,6 +695,7 @@ add_test ( NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" @@ -715,6 +722,7 @@ add_test ( NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" @@ -742,6 +750,7 @@ add_test ( NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" @@ -772,6 +781,7 @@ add_test ( NAME H5DUMP-IMPORT-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN};-o;${resultfile}.bin;${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" @@ -781,10 +791,10 @@ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5DUMP-IMPORT-${resultfile} PROPERTIES DEPENDS "H5DUMP-IMPORT-${resultfile}-clear-objects") - add_test (NAME H5DUMP-IMPORT-h5import-${resultfile} COMMAND $ ${resultfile}.bin -c ${conffile}.out -o ${resultfile}.h5) + add_test (NAME H5DUMP-IMPORT-h5import-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${resultfile}.bin -c ${conffile}.out -o ${resultfile}.h5) set_tests_properties (H5DUMP-IMPORT-h5import-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") set_tests_properties (H5DUMP-IMPORT-h5import-${resultfile} PROPERTIES DEPENDS H5DUMP-IMPORT-${resultfile}) - add_test (NAME H5DUMP-IMPORT-h5diff-${resultfile} COMMAND $ ${testfile} ${resultfile}.h5 /integer /integer) + add_test (NAME H5DUMP-IMPORT-h5diff-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${testfile} ${resultfile}.h5 /integer /integer) set_tests_properties (H5DUMP-IMPORT-h5diff-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") set_tests_properties (H5DUMP-IMPORT-h5diff-${resultfile} PROPERTIES DEPENDS H5DUMP-IMPORT-h5import-${resultfile}) endif () @@ -804,6 +814,7 @@ add_test ( NAME H5DUMP_UD-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" diff --git a/tools/test/h5dump/CMakeTestsPBITS.cmake b/tools/test/h5dump/CMakeTestsPBITS.cmake index feb5c68..57c1ad7 100644 --- a/tools/test/h5dump/CMakeTestsPBITS.cmake +++ b/tools/test/h5dump/CMakeTestsPBITS.cmake @@ -128,7 +128,7 @@ macro (ADD_H5_PBITS_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND $ ${ARGN}) + add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/pbits") if (${resultcode}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") @@ -149,6 +149,7 @@ add_test ( NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/pbits" diff --git a/tools/test/h5dump/CMakeTestsVDS.cmake b/tools/test/h5dump/CMakeTestsVDS.cmake index c557ba4..454d9ef 100644 --- a/tools/test/h5dump/CMakeTestsVDS.cmake +++ b/tools/test/h5dump/CMakeTestsVDS.cmake @@ -124,7 +124,7 @@ macro (ADD_H5_VDS_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND $ ${ARGN}) + add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds") if (${resultcode}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") @@ -145,6 +145,7 @@ add_test ( NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/vds" @@ -160,7 +161,7 @@ macro (ADD_H5_VDS_PREFIX_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP_PREFIX-${resultfile} COMMAND $ ${ARGN}) + add_test (NAME H5DUMP_PREFIX-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) set_tests_properties (H5DUMP_PREFIX-${resultfile} PROPERTIES ENVIRONMENT "HDF5_VDS_PREFIX=${PROJECT_BINARY_DIR}/testfiles/vds/" WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds/prefix" @@ -184,6 +185,7 @@ add_test ( NAME H5DUMP_PREFIX-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/vds/prefix" @@ -201,7 +203,7 @@ macro (ADD_H5_VDS_LAYOUT resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND $ -p ${ARGN}) + add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -p ${ARGN}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds") if (${resultcode}) set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") @@ -222,6 +224,7 @@ add_test ( NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-p;${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/vds" diff --git a/tools/test/h5dump/CMakeTestsXML.cmake b/tools/test/h5dump/CMakeTestsXML.cmake index a883b86..c4e3f7b 100644 --- a/tools/test/h5dump/CMakeTestsXML.cmake +++ b/tools/test/h5dump/CMakeTestsXML.cmake @@ -182,7 +182,7 @@ macro (ADD_XML_H5_TEST resultfile resultcode) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP_XML-${resultfile} COMMAND $ --xml ${ARGN}) + add_test (NAME H5DUMP_XML-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ --xml ${ARGN}) set_tests_properties (H5DUMP_XML-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/xml") if (${resultcode}) set_tests_properties (H5DUMP_XML-${resultfile} PROPERTIES WILL_FAIL "true") @@ -203,6 +203,7 @@ add_test ( NAME H5DUMP_XML-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=--xml;${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/xml" diff --git a/tools/test/h5format_convert/CMakeLists.txt b/tools/test/h5format_convert/CMakeLists.txt index 019252f..55d5623 100644 --- a/tools/test/h5format_convert/CMakeLists.txt +++ b/tools/test/h5format_convert/CMakeLists.txt @@ -22,7 +22,7 @@ if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) target_link_libraries (h5fc_gentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (h5fc_gentest PROPERTIES FOLDER generator/tools) - #add_test (NAME h5fc_gentest COMMAND $) + #add_test (NAME h5fc_gentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) endif () include (CMakeTests.cmake) diff --git a/tools/test/h5format_convert/CMakeTests.cmake b/tools/test/h5format_convert/CMakeTests.cmake index e1abc48..6e13664 100644 --- a/tools/test/h5format_convert/CMakeTests.cmake +++ b/tools/test/h5format_convert/CMakeTests.cmake @@ -127,6 +127,7 @@ add_test ( NAME H5FC-${testname}-${testfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS=${ARGN};outtmp.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -142,6 +143,7 @@ add_test ( NAME H5FC-${testname}-NA COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -179,6 +181,7 @@ add_test ( NAME H5FC-${testname}-${testfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS=${ARGN};outtmp.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -215,6 +218,7 @@ add_test ( NAME H5FC-${testname}-${testfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS=${ARGN};outtmp.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -252,6 +256,7 @@ add_test ( NAME H5FC-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS=${ARGN};./testfiles/tmp.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -270,7 +275,7 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5FC_CHECK_IDX-${testname} - COMMAND "$" "./testfiles/tmp.h5" "${ARGN}" + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ./testfiles/tmp.h5 ${ARGN} ) set_tests_properties (H5FC_CHECK_IDX-${testname} PROPERTIES DEPENDS "H5FC-${dependtest}") endif () @@ -299,6 +304,7 @@ add_test ( NAME H5FC-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS=-d;${ARGN};./testfiles/chktmp.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -310,7 +316,7 @@ set_tests_properties (H5FC-${testname} PROPERTIES DEPENDS "H5FC-${testname}-tmpfile") add_test ( NAME H5FC_CHECK_IDX-${testname} - COMMAND "$" "./testfiles/chktmp.h5" "${ARGN}" + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ./testfiles/chktmp.h5 ${ARGN} ) set_tests_properties (H5FC_CHECK_IDX-${testname} PROPERTIES DEPENDS "H5FC-${testname}") set (last_test "H5FC_CHECK_IDX-${testname}") @@ -342,6 +348,7 @@ add_test ( NAME H5FC-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS=${ARGN};./testfiles/dmptmp.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -354,6 +361,7 @@ add_test ( NAME H5FC_CHECK_DUMP-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-BH;./testfiles/dmptmp.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" diff --git a/tools/test/h5import/CMakeTests.cmake b/tools/test/h5import/CMakeTests.cmake index 9d36276..4aaee68 100644 --- a/tools/test/h5import/CMakeTests.cmake +++ b/tools/test/h5import/CMakeTests.cmake @@ -105,7 +105,7 @@ macro (ADD_H5_TEST testname importfile conffile testfile) # If using memchecker skip macro based tests if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5IMPORT-${testname} COMMAND $ ${importfile} -c ${conffile} -o ${testfile}) + add_test (NAME H5IMPORT-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${importfile} -c ${conffile} -o ${testfile}) if (last_test) set_tests_properties (H5IMPORT-${testname} PROPERTIES DEPENDS H5IMPORT-h5importtest) endif () @@ -123,12 +123,13 @@ ) set_tests_properties (H5IMPORT-${testname}-clear-objects PROPERTIES DEPENDS H5IMPORT-h5importtest) - add_test (NAME H5IMPORT-${testname} COMMAND $ ${importfile} -c ${conffile} -o ${testfile}) + add_test (NAME H5IMPORT-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${importfile} -c ${conffile} -o ${testfile}) set_tests_properties (H5IMPORT-${testname} PROPERTIES DEPENDS H5IMPORT-${testname}-clear-objects) add_test ( NAME H5IMPORT-${testname}-H5DMP COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -142,6 +143,7 @@ add_test ( NAME H5IMPORT-${testname}-H5DMP_CMP COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=testfiles/${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -177,6 +179,7 @@ add_test ( NAME H5IMPORT-DUMP-${testname}-H5DMP COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-p;-d;${datasetname};-o;d${testfile}.bin;-b;NATIVE;testfiles/${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -189,6 +192,7 @@ add_test ( NAME H5IMPORT-DUMP-${testname}-H5DMP COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-p;-d;${datasetname};-o;d${testfile}.bin;-y;--width=1;testfiles/${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -203,6 +207,7 @@ add_test ( NAME H5IMPORT-DUMP-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=d${testfile}.bin;-c;d${testfile}.dmp;-o;d${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -216,6 +221,7 @@ add_test ( NAME H5IMPORT-DUMP-${testname}-H5DFF COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-r;d${testfile};testfiles/${testfile};${datasetname};${datasetname}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -250,6 +256,7 @@ add_test ( NAME H5IMPORT_SUB-DUMP-${testname}-H5DMP COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-p;-d;${datasetname};${ARGN};-o;${testname}.bin;-b;NATIVE;testfiles/${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -263,6 +270,7 @@ add_test ( NAME H5IMPORT_SUB-DUMP-${testname}-H5IMP COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${testname}.bin;-c;${testname}.dmp;-o;d-${testname}.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -275,6 +283,7 @@ add_test ( NAME H5IMPORT_SUB-DUMP-${testname}-CMP COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-p;d-${testname}.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -511,7 +520,7 @@ endif () set (last_test "H5IMPORT-clear-objects") - add_test (NAME H5IMPORT-h5importtest COMMAND $) + add_test (NAME H5IMPORT-h5importtest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) set_tests_properties (H5IMPORT-h5importtest PROPERTIES DEPENDS H5IMPORT-h5importtest-clear-objects) # ----- TESTING "ASCII I32 rank 3 - Output BE " ; diff --git a/tools/test/h5jam/CMakeLists.txt b/tools/test/h5jam/CMakeLists.txt index 585a8a1..6fdf7b0 100644 --- a/tools/test/h5jam/CMakeLists.txt +++ b/tools/test/h5jam/CMakeLists.txt @@ -11,7 +11,7 @@ if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) target_link_libraries (h5jamgentest PRIVATE ${HDF5_LIB_TARGET}) set_target_properties (h5jamgentest PROPERTIES FOLDER generator/tools) - #add_test (NAME h5jamgentest COMMAND $) + #add_test (NAME h5jamgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) endif () add_executable (getub ${HDF5_TOOLS_TEST_H5JAM_SOURCE_DIR}/getub.c) diff --git a/tools/test/h5jam/CMakeTests.cmake b/tools/test/h5jam/CMakeTests.cmake index 84af48b..d930a1e 100644 --- a/tools/test/h5jam/CMakeTests.cmake +++ b/tools/test/h5jam/CMakeTests.cmake @@ -60,7 +60,7 @@ macro (TEST_H5JAM_OUTPUT expectfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5JAM-${expectfile} COMMAND $ ${ARGN}) + add_test (NAME H5JAM-${expectfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) if (${resultcode}) set_tests_properties (H5JAM-${expectfile} PROPERTIES WILL_FAIL "true") endif () @@ -75,6 +75,7 @@ add_test ( NAME H5JAM-${expectfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -96,7 +97,7 @@ macro (TEST_H5UNJAM_OUTPUT expectfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5JAM-UNJAM-${expectfile} COMMAND $ ${ARGN}) + add_test (NAME H5JAM-UNJAM-${expectfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) if (${resultcode}) set_tests_properties (H5JAM-UNJAM-${expectfile} PROPERTIES WILL_FAIL "true") endif () @@ -111,6 +112,7 @@ add_test ( NAME H5JAM-UNJAM-${expectfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -139,6 +141,7 @@ add_test ( NAME H5JAM-${testname}-CHECKFILE-H5DMP COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=testfiles/${expected}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -152,6 +155,7 @@ add_test ( NAME H5JAM-${testname}-CHECKFILE-H5DMP_CMP COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${actual}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -187,7 +191,7 @@ COMMAND ${CMAKE_COMMAND} -E remove ${ufile} ) set_tests_properties (H5JAM-${testname}-UNJAM_D-clear-objects PROPERTIES DEPENDS H5JAM-${testname}-UNJAM-clear-objects) - add_test (NAME H5JAM-${testname}-UNJAM COMMAND $ -i ${infile} -u ${ufile} -o ${outfile}) + add_test (NAME H5JAM-${testname}-UNJAM COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -i ${infile} -u ${ufile} -o ${outfile}) set_tests_properties (H5JAM-${testname}-UNJAM PROPERTIES DEPENDS H5JAM-${testname}-UNJAM_D-clear-objects) set (compare_test ${ufile}) else () @@ -195,6 +199,7 @@ add_test ( NAME H5JAM-${testname}-UNJAM COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-i;${infile};-o;${outfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -206,7 +211,7 @@ set_tests_properties (H5JAM-${testname}-UNJAM PROPERTIES DEPENDS H5JAM-${testname}-UNJAM-clear-objects) set (compare_test "${outfile}.ufile.txt") else () - add_test (NAME H5JAM-${testname}-UNJAM COMMAND $ -i ${infile} -o ${outfile}) + add_test (NAME H5JAM-${testname}-UNJAM COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -i ${infile} -o ${outfile}) set_tests_properties (H5JAM-${testname}-UNJAM PROPERTIES DEPENDS H5JAM-${testname}-UNJAM-clear-objects) set (compare_test "") endif () @@ -224,6 +229,7 @@ add_test ( NAME H5JAM-${testname}-UNJAM-CHECK_UB_1 COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_GET_PROGRAM=$" -D "TEST_CHECKUB=YES" @@ -240,6 +246,7 @@ add_test ( NAME H5JAM-${testname}-UNJAM-CHECK_NOUB COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_GET_PROGRAM=$" -D "TEST_CHECKUB=NO" @@ -267,7 +274,7 @@ COMMAND ${CMAKE_COMMAND} -E remove ${outfile} ${infile}.cpy.h5 ) endif () - add_test (NAME H5JAM-${testname} COMMAND $ -u testfiles/${jamfile} -i testfiles/${infile} -o ${outfile} ${ARGN}) + add_test (NAME H5JAM-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -u testfiles/${jamfile} -i testfiles/${infile} -o ${outfile} ${ARGN}) if (NOT HDF5_ENABLE_USING_MEMCHECKER) set_tests_properties (H5JAM-${testname} PROPERTIES DEPENDS H5JAM-${testname}-clear-objects) set (compare_test ${outfile}) @@ -288,6 +295,7 @@ add_test ( NAME H5JAM-${testname}-CHECK_UB_1 COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_GET_PROGRAM=$" -D "TEST_CHECKUB=YES" @@ -322,7 +330,7 @@ ) set_tests_properties (H5JAM-${testname}_NONE_COPY PROPERTIES DEPENDS H5JAM-${testname}_NONE-SETUP) - add_test (NAME H5JAM-${testname}_NONE COMMAND $ -u testfiles/${jamfile} -i ${chkfile} ${ARGN}) + add_test (NAME H5JAM-${testname}_NONE COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -u testfiles/${jamfile} -i ${chkfile} ${ARGN}) set_tests_properties (H5JAM-${testname}_NONE PROPERTIES DEPENDS H5JAM-${testname}_NONE_COPY) set (compare_test ${chkfile}) @@ -343,6 +351,7 @@ add_test ( NAME H5JAM-${testname}_NONE-CHECK_UB_1 COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_GET_PROGRAM=$" -D "TEST_CHECKUB=YES" diff --git a/tools/test/h5ls/CMakeTests.cmake b/tools/test/h5ls/CMakeTests.cmake index cd62297..9110f01 100644 --- a/tools/test/h5ls/CMakeTests.cmake +++ b/tools/test/h5ls/CMakeTests.cmake @@ -143,7 +143,7 @@ macro (ADD_H5_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5LS-${resultfile} COMMAND $ ${ARGN}) + add_test (NAME H5LS-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) set_tests_properties (H5LS-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") if (${resultcode} EQUAL 1) set_tests_properties (H5LS-${resultfile} PROPERTIES WILL_FAIL "true") @@ -163,6 +163,7 @@ add_test ( NAME H5LS-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -178,7 +179,7 @@ macro (ADD_H5_ERR_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5LS-${resultfile} COMMAND $ ${ARGN}) + add_test (NAME H5LS-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) set_tests_properties (H5LS-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") if (${resultcode} EQUAL 1) set_tests_properties (H5LS-${resultfile} PROPERTIES WILL_FAIL "true") @@ -198,6 +199,7 @@ add_test ( NAME H5LS-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -224,6 +226,7 @@ add_test ( NAME H5LS_UD-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" diff --git a/tools/test/h5ls/CMakeTestsVDS.cmake b/tools/test/h5ls/CMakeTestsVDS.cmake index 04fb306..b975d4a 100644 --- a/tools/test/h5ls/CMakeTestsVDS.cmake +++ b/tools/test/h5ls/CMakeTestsVDS.cmake @@ -89,7 +89,7 @@ macro (ADD_H5_VDS_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5LS-${resultfile} COMMAND $ ${ARGN}) + add_test (NAME H5LS-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) set_tests_properties (H5LS-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds") if (${resultcode} EQUAL 1) set_tests_properties (H5LS-${resultfile} PROPERTIES WILL_FAIL "true") @@ -109,6 +109,7 @@ add_test ( NAME H5LS-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/vds" @@ -124,7 +125,7 @@ macro (ADD_H5_VDS_PREFIX_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5LS_PREFIX-${resultfile} COMMAND $ ${ARGN}) + add_test (NAME H5LS_PREFIX-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) set_tests_properties (H5LS_PREFIX-${resultfile} PROPERTIES ENVIRONMENT "HDF5_VDS_PREFIX=\${ORIGIN}" WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" @@ -147,6 +148,7 @@ add_test ( NAME H5LS_PREFIX-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index 50be28a..d1e9c7a 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -166,7 +166,7 @@ macro (ADD_HELP_TEST testname resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5REPACK-h5repack-${testname} COMMAND $ ${ARGN}) + add_test (NAME H5REPACK-h5repack-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) set_tests_properties (H5REPACK-h5repack-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") if (last_test) set_tests_properties (H5REPACK-h5repack-${testname} PROPERTIES DEPENDS ${last_test}) @@ -186,6 +186,7 @@ add_test ( NAME H5REPACK-h5repack-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -219,12 +220,12 @@ endif () add_test ( NAME H5REPACK_OLD-${testname} - COMMAND $ ${ARGN} -i ${PROJECT_BINARY_DIR}/testfiles/${testfile} -o ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} -i ${PROJECT_BINARY_DIR}/testfiles/${testfile} -o ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) set_tests_properties (H5REPACK_OLD-${testname} PROPERTIES DEPENDS H5REPACK_OLD-${testname}-clear-objects) add_test ( NAME H5REPACK_OLD-${testname}_DFF - COMMAND $ ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) set_tests_properties (H5REPACK_OLD-${testname}_DFF PROPERTIES DEPENDS H5REPACK_OLD-${testname}) endif () @@ -251,12 +252,12 @@ endif () add_test ( NAME H5REPACK-${testname} - COMMAND $ --enable-error-stack ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ --enable-error-stack ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) set_tests_properties (H5REPACK-${testname} PROPERTIES DEPENDS H5REPACK-${testname}-clear-objects) add_test ( NAME H5REPACK-${testname}_DFF - COMMAND $ --enable-error-stack ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ --enable-error-stack ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) set_tests_properties (H5REPACK-${testname}_DFF PROPERTIES DEPENDS H5REPACK-${testname}) endif () @@ -276,7 +277,7 @@ if (HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5REPACK_CMP-${testname} - COMMAND $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile} ) if (last_test) set_tests_properties (H5REPACK_CMP-${testname} PROPERTIES DEPENDS ${last_test}) @@ -296,6 +297,7 @@ add_test ( NAME H5REPACK_CMP-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN};${resultfile};out-${testname}.${resultfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -324,7 +326,7 @@ if (HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5REPACK_MASK-${testname} - COMMAND $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile} ) if (last_test) set_tests_properties (H5REPACK_MASK-${testname} PROPERTIES DEPENDS ${last_test}) @@ -344,6 +346,7 @@ add_test ( NAME H5REPACK_MASK-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN};${resultfile};out-${testname}.${resultfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -382,13 +385,14 @@ endif () add_test ( NAME H5REPACK_DMP-${testname} - COMMAND $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile} ) set_tests_properties (H5REPACK_DMP-${testname} PROPERTIES DEPENDS H5REPACK_DMP-${testname}-clear-objects) if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5REPACK_DMP-h5dump-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-q;creation_order;-pH;out-${testname}.${resultfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -425,13 +429,14 @@ endif () add_test ( NAME H5REPACK_STAT-${testname} - COMMAND $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${statarg}.${resultfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${statarg}.${resultfile} ) set_tests_properties (H5REPACK_STAT-${testname} PROPERTIES DEPENDS H5REPACK_STAT-${testname}-clear-objects) if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5REPACK_STAT-h5stat-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-S;-s;out-${statarg}.${resultfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -469,18 +474,19 @@ endif () add_test ( NAME H5REPACK_VERIFY_LAYOUT-${testname} - COMMAND $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname} PROPERTIES DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}-clear-objects) add_test ( NAME H5REPACK_VERIFY_LAYOUT-${testname}_DFF - COMMAND $ ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}_DFF PROPERTIES DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}) if (NOT ${resultcode}) add_test ( NAME H5REPACK_VERIFY_LAYOUT-${testname}_DMP COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-d;${testdset};-pH;out-${testname}.${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -504,6 +510,7 @@ add_test ( NAME H5REPACK_VERIFY_LAYOUT-${testname}_DMP COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-pH;out-${testname}.${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -544,13 +551,14 @@ endif () add_test ( NAME H5REPACK_VERIFY_LAYOUT_VDS-${testname} - COMMAND $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) set_tests_properties (H5REPACK_VERIFY_LAYOUT_VDS-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") set_tests_properties (H5REPACK_VERIFY_LAYOUT_VDS-${testname} PROPERTIES DEPENDS H5REPACK_VERIFY_LAYOUT_VDS-${testname}-clear-objects) add_test ( NAME H5REPACK_VERIFY_LAYOUT_VDS-${testname}_DMP COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-d;${testdset};-p;out-${testname}.${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -581,12 +589,13 @@ endif () add_test ( NAME H5REPACK_VERIFY_SUPERBLOCK-${testname} - COMMAND $ -j;${lowbound};-k;${highbound} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -j;${lowbound};-k;${highbound} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) set_tests_properties (H5REPACK_VERIFY_SUPERBLOCK-${testname} PROPERTIES DEPENDS H5REPACK_VERIFY_SUPERBLOCK-${testname}-clear-objects) add_test ( NAME H5REPACK_VERIFY_SUPERBLOCK-${testname}_DMP COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-H;-B;out-${testname}.${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -612,7 +621,7 @@ endif () add_test ( NAME ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname} - COMMAND $ -j;${lowbound};-k;${highbound} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -j;${lowbound};-k;${highbound} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) set_tests_properties ( ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname} PROPERTIES @@ -635,12 +644,12 @@ endif () add_test ( NAME H5REPACK_META-${testname}_N - COMMAND $ ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}_N.${testname}.h5 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}_N.${testname}.h5 ) set_tests_properties (H5REPACK_META-${testname}_N PROPERTIES DEPENDS H5REPACK_META-${testname}_N-clear-objects) add_test ( NAME H5REPACK_META-${testname}_M - COMMAND $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}_M.${testname}.h5 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}_M.${testname}.h5 ) set_tests_properties (H5REPACK_META-${testname}_M PROPERTIES DEPENDS H5REPACK_META-${testname}_N) @@ -668,6 +677,7 @@ add_test ( NAME H5REPACK_UD-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN};${resultfile};out-${testname}.${resultfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -684,6 +694,7 @@ add_test ( NAME H5REPACK_UD-${testname}-h5dump COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-pH;out-${testname}.${resultfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -916,7 +927,7 @@ ADD_HELP_TEST(help 0 -h) - add_test (NAME H5REPACK-testh5repack_detect_szip COMMAND $) + add_test (NAME H5REPACK-testh5repack_detect_szip COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) if (HDF5_ENABLE_SZIP_SUPPORT) if (HDF5_ENABLE_SZIP_ENCODING) set (passRegex "yes") @@ -931,7 +942,7 @@ endif () set_tests_properties (H5REPACK-testh5repack_detect_szip PROPERTIES DEPENDS H5REPACK-clearall-objects) - add_test (NAME H5REPACK-h5repacktest COMMAND $) + add_test (NAME H5REPACK-h5repacktest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) set_tests_properties (H5REPACK-h5repacktest PROPERTIES DEPENDS H5REPACK-testh5repack_detect_szip) set (last_test "H5REPACK-h5repacktest") diff --git a/tools/test/h5repack/CMakeVFDTests.cmake b/tools/test/h5repack/CMakeVFDTests.cmake index e100e3c..7761c17 100644 --- a/tools/test/h5repack/CMakeVFDTests.cmake +++ b/tools/test/h5repack/CMakeVFDTests.cmake @@ -39,6 +39,7 @@ add_test ( NAME H5REPACK-VFD-${vfdname}-h5repacktest COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" diff --git a/tools/test/h5stat/CMakeLists.txt b/tools/test/h5stat/CMakeLists.txt index f3bd20b..5c17fd5 100644 --- a/tools/test/h5stat/CMakeLists.txt +++ b/tools/test/h5stat/CMakeLists.txt @@ -11,7 +11,7 @@ if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) target_link_libraries (h5stat_gentest PRIVATE ${HDF5_LIB_TARGET}) set_target_properties (h5stat_gentest PROPERTIES FOLDER generator/tools) - #add_test (NAME h5stat_gentest COMMAND $) + #add_test (NAME h5stat_gentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) endif () include (CMakeTests.cmake) diff --git a/tools/test/h5stat/CMakeTests.cmake b/tools/test/h5stat/CMakeTests.cmake index 63886d0..7d0e3f9 100644 --- a/tools/test/h5stat/CMakeTests.cmake +++ b/tools/test/h5stat/CMakeTests.cmake @@ -102,7 +102,7 @@ macro (ADD_H5_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5STAT-${resultfile} COMMAND $ ${ARGN}) + add_test (NAME H5STAT-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) if (${resultcode}) set_tests_properties (H5STAT-${resultfile} PROPERTIES WILL_FAIL "true") endif () @@ -123,6 +123,7 @@ add_test ( NAME H5STAT-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" @@ -138,7 +139,7 @@ macro (ADD_H5_ERR_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5STAT-${resultfile} COMMAND $ ${ARGN}) + add_test (NAME H5STAT-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) if (${resultcode}) set_tests_properties (H5STAT-${resultfile} PROPERTIES WILL_FAIL "true") endif () @@ -159,6 +160,7 @@ add_test ( NAME H5STAT-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" diff --git a/tools/test/misc/CMakeLists.txt b/tools/test/misc/CMakeLists.txt index f5e3ea3..a250222 100644 --- a/tools/test/misc/CMakeLists.txt +++ b/tools/test/misc/CMakeLists.txt @@ -15,7 +15,7 @@ if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) target_link_libraries (h5repart_gentest PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET}) endif () set_target_properties (h5repart_gentest PROPERTIES FOLDER generator/tools) - #add_test (NAME h5repart_gentest COMMAND $) + #add_test (NAME h5repart_gentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) add_executable (h5clear_gentest ${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/h5clear_gentest.c) target_include_directories (h5clear_gentest PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") @@ -27,7 +27,7 @@ if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) target_link_libraries (h5clear_gentest PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET}) endif () set_target_properties (h5clear_gentest PROPERTIES FOLDER tools) - #add_test (NAME H5CLEAR-h5clear_gentest COMMAND $) + #add_test (NAME H5CLEAR-h5clear_gentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) add_subdirectory (vds) diff --git a/tools/test/misc/CMakeTestsClear.cmake b/tools/test/misc/CMakeTestsClear.cmake index c7b2fe9..99650e6 100644 --- a/tools/test/misc/CMakeTestsClear.cmake +++ b/tools/test/misc/CMakeTestsClear.cmake @@ -106,6 +106,7 @@ add_test ( NAME H5CLEAR_CMP-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -134,6 +135,7 @@ add_test ( NAME H5CLEAR_CMP-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -171,6 +173,7 @@ add_test ( NAME H5CLEAR_CMP-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN};${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -207,6 +210,7 @@ add_test ( NAME H5CLEAR_CMP-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN};${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -225,7 +229,7 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5CLEAR_RET-${testname} - COMMAND $ ${ARGN} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ) set_tests_properties (H5CLEAR_RET-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") set_tests_properties (H5CLEAR_RET-${testname} PROPERTIES WILL_FAIL "${resultcode}") @@ -261,6 +265,7 @@ add_test ( NAME H5CLEAR_FILESIZE_CMP-${testname}_before_size COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=--filesize;${testname}.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -273,12 +278,12 @@ if (NOT ${incr_size} MATCHES "NONE") add_test ( NAME H5CLEAR_FILESIZE_INCR-${testname} - COMMAND $ --increment=${incr_size} ${testname}.h5 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ --increment=${incr_size} ${testname}.h5 ) else () add_test ( NAME H5CLEAR_FILESIZE_INCR-${testname} - COMMAND $ --increment ${testname}.h5 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ --increment ${testname}.h5 ) endif () set_tests_properties (H5CLEAR_FILESIZE_INCR-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") @@ -287,6 +292,7 @@ add_test ( NAME H5CLEAR_FILESIZE_CMP-${testname}_after_size COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=--filesize;${testname}.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -315,7 +321,7 @@ # Initial file open fails OR # File open succeeds because the library does not check status_flags for file with < v3 superblock - add_test (NAME H5CLEAR-clr_open_chk-${testname}_${resultcode} COMMAND $ ${testfile}.h5) + add_test (NAME H5CLEAR-clr_open_chk-${testname}_${resultcode} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${testfile}.h5) set_tests_properties (H5CLEAR-clr_open_chk-${testname}_${resultcode} PROPERTIES WILL_FAIL "${resultcode}") set_tests_properties (H5CLEAR-clr_open_chk-${testname}_${resultcode} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") if (last_test) @@ -323,10 +329,10 @@ endif () # After "h5clear" the file, the subsequent file open succeeds - add_test (NAME H5CLEAR-h5clr-${testname} COMMAND $ -s ${testfile}.h5) + add_test (NAME H5CLEAR-h5clr-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -s ${testfile}.h5) set_tests_properties (H5CLEAR-h5clr-${testname} PROPERTIES DEPENDS H5CLEAR-clr_open_chk-${testname}_${resultcode}) set_tests_properties (H5CLEAR-h5clr-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - add_test (NAME H5CLEAR-clr_open_chk-${testname} COMMAND $ ${testfile}.h5) + add_test (NAME H5CLEAR-clr_open_chk-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${testfile}.h5) set_tests_properties (H5CLEAR-clr_open_chk-${testname} PROPERTIES DEPENDS H5CLEAR-h5clr-${testname}) set_tests_properties (H5CLEAR-clr_open_chk-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") set (last_test "H5CLEAR-clr_open_chk-${testname}") diff --git a/tools/test/misc/CMakeTestsMkgrp.cmake b/tools/test/misc/CMakeTestsMkgrp.cmake index db1f805..37d87ca 100644 --- a/tools/test/misc/CMakeTestsMkgrp.cmake +++ b/tools/test/misc/CMakeTestsMkgrp.cmake @@ -75,7 +75,7 @@ add_test ( NAME H5MKGRP-${resultfile} - COMMAND $ ${resultoption} ${resultfile}.h5 ${ARGN} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${resultoption} ${resultfile}.h5 ${ARGN} ) set_tests_properties (H5MKGRP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") if (HDF5_ENABLE_USING_MEMCHECKER) @@ -87,6 +87,7 @@ add_test ( NAME H5MKGRP-${resultfile}-h5ls COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=-v;-r;${resultfile}.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -102,7 +103,7 @@ macro (ADD_H5_CMP resultfile resultcode) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5MKGRP_CMP-${resultfile} COMMAND $ ${ARGN}) + add_test (NAME H5MKGRP_CMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) else () add_test ( NAME H5MKGRP_CMP-${resultfile}-clear-objects @@ -116,6 +117,7 @@ add_test ( NAME H5MKGRP_CMP-${resultfile} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" diff --git a/tools/test/misc/CMakeTestsRepart.cmake b/tools/test/misc/CMakeTestsRepart.cmake index 53949a2..24b6004 100644 --- a/tools/test/misc/CMakeTestsRepart.cmake +++ b/tools/test/misc/CMakeTestsRepart.cmake @@ -80,31 +80,31 @@ set_tests_properties (H5REPART-clearall-objects PROPERTIES FIXTURES_SETUP clear_testrepart) # repartition family member size to 20,000 bytes. - add_test (NAME H5REPART-h5repart_20K COMMAND $ -m 20000 family_file%05d.h5 fst_family%05d.h5) + add_test (NAME H5REPART-h5repart_20K COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -m 20000 family_file%05d.h5 fst_family%05d.h5) set_tests_properties (H5REPART-h5repart_20K PROPERTIES FIXTURES_REQUIRED clear_testrepart ) # repartition family member size to 5 KB. - add_test (NAME H5REPART-h5repart_5K COMMAND $ -m 5k family_file%05d.h5 scd_family%05d.h5) + add_test (NAME H5REPART-h5repart_5K COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -m 5k family_file%05d.h5 scd_family%05d.h5) set_tests_properties (H5REPART-h5repart_5K PROPERTIES FIXTURES_REQUIRED clear_testrepart ) # convert family file to sec2 file of 20,000 bytes - add_test (NAME H5REPART-h5repart_single COMMAND $ -m 20000 -family_to_single family_file%05d.h5 family_to_single.h5) + add_test (NAME H5REPART-h5repart_single COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -m 20000 -family_to_single family_file%05d.h5 family_to_single.h5) set_tests_properties (H5REPART-h5repart_single PROPERTIES FIXTURES_REQUIRED clear_testrepart ) # convert family file to sec2 file of 20,000 bytes (old argument) - add_test (NAME H5REPART-h5repart_sec2 COMMAND $ -m 20000 -family_to_sec2 family_file%05d.h5 family_to_sec2.h5) + add_test (NAME H5REPART-h5repart_sec2 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -m 20000 -family_to_sec2 family_file%05d.h5 family_to_sec2.h5) set_tests_properties (H5REPART-h5repart_sec2 PROPERTIES FIXTURES_REQUIRED clear_testrepart ) # test the output files repartitioned above. - add_test (NAME H5REPART-h5repart_test COMMAND $) + add_test (NAME H5REPART-h5repart_test COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) set_tests_properties (H5REPART-h5repart_test PROPERTIES DEPENDS "H5REPART-h5repart_20K;H5REPART-h5repart_5K;H5REPART-h5repart_single;H5REPART-h5repart_sec2" ) diff --git a/tools/test/perform/CMakeTests.cmake b/tools/test/perform/CMakeTests.cmake index 20e7f59..f0eb65f 100644 --- a/tools/test/perform/CMakeTests.cmake +++ b/tools/test/perform/CMakeTests.cmake @@ -53,9 +53,10 @@ add_test ( ) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PERFORM_h5perf_serial COMMAND $) + add_test (NAME PERFORM_h5perf_serial COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME PERFORM_h5perf_serial COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -70,13 +71,14 @@ set_tests_properties (PERFORM_h5perf_serial PROPERTIES TIMEOUT ${CTEST_VERY_LONG set_tests_properties (PERFORM_h5perf_serial PROPERTIES DEPENDS "PERFORM_h5perform-clearall-objects") if (HDF5_BUILD_PERFORM_STANDALONE) - add_test (NAME PERFORM_h5perf_serial_alone COMMAND $) + add_test (NAME PERFORM_h5perf_serial_alone COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) endif () if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PERFORM_chunk COMMAND $) + add_test (NAME PERFORM_chunk COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME PERFORM_chunk COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -90,9 +92,10 @@ endif () set_tests_properties (PERFORM_chunk PROPERTIES DEPENDS "PERFORM_h5perform-clearall-objects") if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PERFORM_iopipe COMMAND $) + add_test (NAME PERFORM_iopipe COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME PERFORM_iopipe COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -106,9 +109,10 @@ endif () set_tests_properties (PERFORM_iopipe PROPERTIES DEPENDS "PERFORM_h5perform-clearall-objects") if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PERFORM_overhead COMMAND $) + add_test (NAME PERFORM_overhead COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME PERFORM_overhead COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -122,9 +126,10 @@ endif () set_tests_properties (PERFORM_overhead PROPERTIES DEPENDS "PERFORM_h5perform-clearall-objects") if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PERFORM_perf_meta COMMAND $) + add_test (NAME PERFORM_perf_meta COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () add_test (NAME PERFORM_perf_meta COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -138,9 +143,10 @@ endif () set_tests_properties (PERFORM_perf_meta PROPERTIES DEPENDS "PERFORM_h5perform-clearall-objects") if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PERFORM_zip_perf_help COMMAND $ "-h") + add_test (NAME PERFORM_zip_perf_help COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ "-h") else () add_test (NAME PERFORM_zip_perf_help COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -154,9 +160,10 @@ endif () set_tests_properties (PERFORM_zip_perf_help PROPERTIES DEPENDS "PERFORM_h5perform-clearall-objects") if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PERFORM_zip_perf COMMAND $ tfilters.h5) + add_test (NAME PERFORM_zip_perf COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ tfilters.h5) else () add_test (NAME PERFORM_zip_perf COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" -- cgit v0.12 From 0eb050d481d611e8dc634f9a80582402a734aed4 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 15 Jul 2019 15:00:57 -0500 Subject: HDFFV-10845 mingw needs special windows reference files --- tools/test/h5diff/CMakeTests.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake index c7734a6..3feac0a 100644 --- a/tools/test/h5diff/CMakeTests.cmake +++ b/tools/test/h5diff/CMakeTests.cmake @@ -324,7 +324,7 @@ # # Overwrite system dependent files (Windows) and not VS2015 # - if (WIN32 AND MSVC_VERSION LESS 1900) + if (MINGW OR WIN32 AND MSVC_VERSION LESS 1900) foreach (h5_tstfiles ${LIST_WIN_TEST_FILES}) get_filename_component(fname "${h5_tstfiles}" NAME) HDFTEST_COPY_FILE("${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/${h5_tstfiles}w.txt" "${PROJECT_BINARY_DIR}/testfiles/${fname}.txt" "h5diff_files") -- cgit v0.12 From 95d3b41af07dd1e7532d0a6b453315ee2e3e5968 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 15 Jul 2019 16:17:41 -0500 Subject: HDFFV-10845 separate test used by copy windows files --- tools/test/h5diff/CMakeTests.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake index 3feac0a..4e5b2ef 100644 --- a/tools/test/h5diff/CMakeTests.cmake +++ b/tools/test/h5diff/CMakeTests.cmake @@ -324,7 +324,14 @@ # # Overwrite system dependent files (Windows) and not VS2015 # - if (MINGW OR WIN32 AND MSVC_VERSION LESS 1900) + set (COPY_WINDOWS_FILES false) + if (MINGW) + set (COPY_WINDOWS_FILES true) + endif () + if (WIN32 AND MSVC_VERSION LESS 1900) + set (COPY_WINDOWS_FILES true) + endif () + if (COPY_WINDOWS_FILES) foreach (h5_tstfiles ${LIST_WIN_TEST_FILES}) get_filename_component(fname "${h5_tstfiles}" NAME) HDFTEST_COPY_FILE("${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/${h5_tstfiles}w.txt" "${PROJECT_BINARY_DIR}/testfiles/${fname}.txt" "h5diff_files") -- cgit v0.12 From 3ea746014a7e905b6a6d668bcc4c6305e76b5ec2 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 15 Jul 2019 16:36:44 -0500 Subject: HDFFV-10845 copy files with windows EOL --- config/cmake/jrunTest.cmake | 12 ++++++++---- config/cmake_ext_mod/grepTest.cmake | 6 ++++-- config/cmake_ext_mod/runTest.cmake | 12 ++++++++---- tools/test/h5dump/CMakeTests.cmake | 10 ++++++---- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/config/cmake/jrunTest.cmake b/config/cmake/jrunTest.cmake index 341c382..fa687f5 100644 --- a/config/cmake/jrunTest.cmake +++ b/config/cmake/jrunTest.cmake @@ -125,8 +125,10 @@ message (STATUS "COMMAND Error: ${TEST_ERROR}") if (NOT TEST_SKIP_COMPARE) if (EXISTS ${TEST_FOLDER}/${TEST_REFERENCE}) if (WIN32 OR MINGW) - file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) - file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}") + configure_file(${TEST_FOLDER}/${TEST_REFERENCE} ${TEST_FOLDER}/${TEST_REFERENCE}.tmp NEWLINE_STYLE CRLF) + file(RENAME ${TEST_FOLDER}/${TEST_REFERENCE}.tmp ${TEST_FOLDER}/${TEST_REFERENCE}) + #file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) + #file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}") endif () if (NOT TEST_SORT_COMPARE) @@ -187,8 +189,10 @@ if (NOT TEST_SKIP_COMPARE) # now compare the .err file with the error reference, if supplied if (TEST_ERRREF) if (WIN32 OR MINGW) - file (READ ${TEST_FOLDER}/${TEST_ERRREF} TEST_STREAM) - file (WRITE ${TEST_FOLDER}/${TEST_ERRREF} "${TEST_STREAM}") + configure_file(${TEST_FOLDER}/${TEST_ERRREF} ${TEST_FOLDER}/${TEST_ERRREF}.tmp NEWLINE_STYLE CRLF) + file(RENAME ${TEST_FOLDER}/${TEST_ERRREF}.tmp ${TEST_FOLDER}/${TEST_ERRREF}) + #file (READ ${TEST_FOLDER}/${TEST_ERRREF} TEST_STREAM) + #file (WRITE ${TEST_FOLDER}/${TEST_ERRREF} "${TEST_STREAM}") endif () # now compare the error output with the error reference diff --git a/config/cmake_ext_mod/grepTest.cmake b/config/cmake_ext_mod/grepTest.cmake index 2a30336..ab00e70 100644 --- a/config/cmake_ext_mod/grepTest.cmake +++ b/config/cmake_ext_mod/grepTest.cmake @@ -99,8 +99,10 @@ if (TEST_ERRREF) if (NOT TEST_SKIP_COMPARE) if (EXISTS ${TEST_FOLDER}/${TEST_REFERENCE}) if (WIN32 OR MINGW) - file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) - file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}") + configure_file(${TEST_FOLDER}/${TEST_REFERENCE} ${TEST_FOLDER}/${TEST_REFERENCE}.tmp NEWLINE_STYLE CRLF) + file(RENAME ${TEST_FOLDER}/${TEST_REFERENCE}.tmp ${TEST_FOLDER}/${TEST_REFERENCE}) + #file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) + #file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}") endif () if (NOT TEST_SORT_COMPARE) # now compare the output with the reference diff --git a/config/cmake_ext_mod/runTest.cmake b/config/cmake_ext_mod/runTest.cmake index 3953c27..a904855 100644 --- a/config/cmake_ext_mod/runTest.cmake +++ b/config/cmake_ext_mod/runTest.cmake @@ -187,8 +187,10 @@ endif () if (NOT TEST_SKIP_COMPARE) if (EXISTS ${TEST_FOLDER}/${TEST_REFERENCE}) if (WIN32 OR MINGW) - file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) - file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}") + configure_file(${TEST_FOLDER}/${TEST_REFERENCE} ${TEST_FOLDER}/${TEST_REFERENCE}.tmp NEWLINE_STYLE CRLF) + file(RENAME ${TEST_FOLDER}/${TEST_REFERENCE}.tmp ${TEST_FOLDER}/${TEST_REFERENCE}) + #file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) + #file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}") endif () if (NOT TEST_SORT_COMPARE) @@ -249,8 +251,10 @@ if (NOT TEST_SKIP_COMPARE) # now compare the .err file with the error reference, if supplied if (TEST_ERRREF) if (WIN32 OR MINGW) - file (READ ${TEST_FOLDER}/${TEST_ERRREF} TEST_STREAM) - file (WRITE ${TEST_FOLDER}/${TEST_ERRREF} "${TEST_STREAM}") + configure_file(${TEST_FOLDER}/${TEST_ERRREF} ${TEST_FOLDER}/${TEST_ERRREF}.tmp NEWLINE_STYLE CRLF) + file(RENAME ${TEST_FOLDER}/${TEST_ERRREF}.tmp ${TEST_FOLDER}/${TEST_ERRREF}) + #file (READ ${TEST_FOLDER}/${TEST_ERRREF} TEST_STREAM) + #file (WRITE ${TEST_FOLDER}/${TEST_ERRREF} "${TEST_STREAM}") endif () # now compare the error output with the error reference diff --git a/tools/test/h5dump/CMakeTests.cmake b/tools/test/h5dump/CMakeTests.cmake index c151c9a..458c6b0 100644 --- a/tools/test/h5dump/CMakeTests.cmake +++ b/tools/test/h5dump/CMakeTests.cmake @@ -363,8 +363,9 @@ foreach (tst_exp_file ${HDF5_REFERENCE_EXP_FILES}) if (WIN32 OR MINGW) - file (READ ${HDF5_TOOLS_DIR}/testfiles/${tst_exp_file} TEST_STREAM) - file (WRITE ${PROJECT_BINARY_DIR}/testfiles/std/${tst_exp_file} "${TEST_STREAM}") + configure_file(${HDF5_TOOLS_DIR}/testfiles/${tst_exp_file} ${PROJECT_BINARY_DIR}/testfiles/std/${tst_exp_file} NEWLINE_STYLE CRLF) + #file (READ ${HDF5_TOOLS_DIR}/testfiles/${tst_exp_file} TEST_STREAM) + #file (WRITE ${PROJECT_BINARY_DIR}/testfiles/std/${tst_exp_file} "${TEST_STREAM}") else () HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${tst_exp_file}" "${PROJECT_BINARY_DIR}/testfiles/std/${tst_exp_file}" "h5dump_std_files") endif () @@ -389,8 +390,9 @@ HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/tbin1.ddl" "${PROJECT_BINARY_DIR}/testfiles/std/tbin1LE.ddl" "h5dump_std_files") if (WIN32 OR MINGW) - file (READ ${HDF5_TOOLS_DIR}/testfiles/tbinregR.exp TEST_STREAM) - file (WRITE ${PROJECT_BINARY_DIR}/testfiles/std/tbinregR.exp "${TEST_STREAM}") + configure_file(${HDF5_TOOLS_DIR}/testfiles/tbinregR.exp ${PROJECT_BINARY_DIR}/testfiles/std/tbinregR.exp NEWLINE_STYLE CRLF) + #file (READ ${HDF5_TOOLS_DIR}/testfiles/tbinregR.exp TEST_STREAM) + #file (WRITE ${PROJECT_BINARY_DIR}/testfiles/std/tbinregR.exp "${TEST_STREAM}") else () HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/tbinregR.exp" "${PROJECT_BINARY_DIR}/testfiles/std/tbinregR.exp" "h5dump_std_files") endif () -- cgit v0.12 From 741ef0aaefb64ead937d86c5e30c9fbc97f69597 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 16 Jul 2019 11:38:10 -0500 Subject: HDFFV-10845 skip test if CMake command doesn't support ignore EOL --- CMakeLists.txt | 6 ++++++ tools/test/h5dump/CMakeTests.cmake | 24 ++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a62561f..95d24bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,12 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) ) endif () +# CMake version 3.14 added option --ignore-eol to compare files +# cmake -E compare_files --ignore-eol file1 file2 +#if(CMAKE_VERSION VERSION_LESS "3.14.0" AND WIN32) +# MESSAGE(FATAL_ERROR "Windows builds requires a minimum of CMake 3.14") +#endif() + #----------------------------------------------------------------------------- # Instructions for use : Sub-Project Build # diff --git a/tools/test/h5dump/CMakeTests.cmake b/tools/test/h5dump/CMakeTests.cmake index 458c6b0..e8e9d07 100644 --- a/tools/test/h5dump/CMakeTests.cmake +++ b/tools/test/h5dump/CMakeTests.cmake @@ -362,13 +362,7 @@ endforeach () foreach (tst_exp_file ${HDF5_REFERENCE_EXP_FILES}) - if (WIN32 OR MINGW) - configure_file(${HDF5_TOOLS_DIR}/testfiles/${tst_exp_file} ${PROJECT_BINARY_DIR}/testfiles/std/${tst_exp_file} NEWLINE_STYLE CRLF) - #file (READ ${HDF5_TOOLS_DIR}/testfiles/${tst_exp_file} TEST_STREAM) - #file (WRITE ${PROJECT_BINARY_DIR}/testfiles/std/${tst_exp_file} "${TEST_STREAM}") - else () - HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${tst_exp_file}" "${PROJECT_BINARY_DIR}/testfiles/std/${tst_exp_file}" "h5dump_std_files") - endif () + HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${tst_exp_file}" "${PROJECT_BINARY_DIR}/testfiles/std/${tst_exp_file}" "h5dump_std_files") endforeach () foreach (tst_other_file ${HDF5_REFERENCE_FILES}) @@ -569,13 +563,15 @@ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") - add_test ( - NAME H5DUMP-${resultfile}-output-cmp - COMMAND ${CMAKE_COMMAND} - -E compare_files ${resultfile}.txt ${resultfile}.exp - ) - set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES DEPENDS H5DUMP-${resultfile}) + if(NOT CMAKE_VERSION VERSION_LESS "3.14.0") + add_test ( + NAME H5DUMP-${resultfile}-output-cmp + COMMAND ${CMAKE_COMMAND} + -E compare_files --ignore-eol ${resultfile}.txt ${resultfile}.exp + ) + set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") + set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES DEPENDS H5DUMP-${resultfile}) + endif () endif () endmacro () -- cgit v0.12 From ac8a1f02ab5cb260f23acbe865090033a0183303 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 16 Jul 2019 16:12:15 -0500 Subject: Add missing target root path, check other export macro --- config/cmake/CTestScript.cmake | 5 +++++ config/toolchain/mingw64.cmake | 2 +- tools/test/h5dump/CMakeTests.cmake | 46 +++++++++++++++++++++----------------- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/config/cmake/CTestScript.cmake b/config/cmake/CTestScript.cmake index a5527c3..e819e58 100644 --- a/config/cmake/CTestScript.cmake +++ b/config/cmake/CTestScript.cmake @@ -101,6 +101,11 @@ endif () include (ProcessorCount) ProcessorCount (N) if (NOT N EQUAL 0) + if (MAX_PROC_COUNT) + if (N GREATER MAX_PROC_COUNT) + set (N ${MAX_PROC_COUNT}) + endif () + endif () if (NOT WIN32) set (CTEST_BUILD_FLAGS -j${N}) endif () diff --git a/config/toolchain/mingw64.cmake b/config/toolchain/mingw64.cmake index ad0fb85..721c39a 100644 --- a/config/toolchain/mingw64.cmake +++ b/config/toolchain/mingw64.cmake @@ -3,7 +3,7 @@ set (CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) set (CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) set (CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) set (CMAKE_Fortran_COMPILER x86_64-w64-mingw32-gfortran) -set (CMAKE_FIND_ROOT_PATH ) +set (CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/tools/test/h5dump/CMakeTests.cmake b/tools/test/h5dump/CMakeTests.cmake index e8e9d07..7a3fdd6 100644 --- a/tools/test/h5dump/CMakeTests.cmake +++ b/tools/test/h5dump/CMakeTests.cmake @@ -610,20 +610,22 @@ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") - add_test ( - NAME H5DUMP-${resultfile}-output-cmp - COMMAND ${CMAKE_COMMAND} - -E compare_files ${resultfile}.txt ${resultfile}.exp - ) - set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES DEPENDS H5DUMP-${resultfile}) - add_test ( - NAME H5DUMP-${resultfile}-output-cmp-ddl - COMMAND ${CMAKE_COMMAND} - -E compare_files ${ddlfile}.txt ${ddlfile}.exp - ) - set_tests_properties (H5DUMP-${resultfile}-output-cmp-ddl PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - set_tests_properties (H5DUMP-${resultfile}-output-cmp-ddl PROPERTIES DEPENDS H5DUMP-${resultfile}-output-cmp) + if(NOT CMAKE_VERSION VERSION_LESS "3.14.0") + add_test ( + NAME H5DUMP-${resultfile}-output-cmp + COMMAND ${CMAKE_COMMAND} + -E compare_files --ignore-eol ${resultfile}.txt ${resultfile}.exp + ) + set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") + set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES DEPENDS H5DUMP-${resultfile}) + add_test ( + NAME H5DUMP-${resultfile}-output-cmp-ddl + COMMAND ${CMAKE_COMMAND} + -E compare_files --ignore-eol ${ddlfile}.txt ${ddlfile}.exp + ) + set_tests_properties (H5DUMP-${resultfile}-output-cmp-ddl PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") + set_tests_properties (H5DUMP-${resultfile}-output-cmp-ddl PROPERTIES DEPENDS H5DUMP-${resultfile}-output-cmp) + endif () endif () endmacro () @@ -641,13 +643,15 @@ ) set_tests_properties (H5DUMP-output-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") set_tests_properties (H5DUMP-output-${resultfile} PROPERTIES DEPENDS H5DUMP-output-${resultfile}-clear-objects) - add_test ( - NAME H5DUMP-output-cmp-${resultfile} - COMMAND ${CMAKE_COMMAND} - -E compare_files ${resultfile}.txt ${resultfile}.exp - ) - set_tests_properties (H5DUMP-output-cmp-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - set_tests_properties (H5DUMP-output-cmp-${resultfile} PROPERTIES DEPENDS H5DUMP-output-${resultfile}) + if(NOT CMAKE_VERSION VERSION_LESS "3.14.0") + add_test ( + NAME H5DUMP-output-cmp-${resultfile} + COMMAND ${CMAKE_COMMAND} + -E compare_files --ignore-eol ${resultfile}.txt ${resultfile}.exp + ) + set_tests_properties (H5DUMP-output-cmp-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") + set_tests_properties (H5DUMP-output-cmp-${resultfile} PROPERTIES DEPENDS H5DUMP-output-${resultfile}) + endif () endif () endmacro () -- cgit v0.12 From 0a9180c0746618d08396d57f3fa5c94aa45e5b65 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 17 Jul 2019 16:08:43 -0500 Subject: HDFFV-10845 update mingw cmake changes --- c++/src/CMakeLists.txt | 5 ++++- config/cmake_ext_mod/ConfigureChecks.cmake | 5 ++--- config/cmake_ext_mod/HDFMacros.cmake | 10 ++++++++-- release_docs/README_HDF5_CMake | 6 +++--- release_docs/RELEASE.txt | 8 ++++---- src/H5win32defs.h | 12 +++++------- testpar/CMakeVFDTests.cmake | 2 +- 7 files changed, 27 insertions(+), 21 deletions(-) diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index 38c46be..4e668d6 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -112,7 +112,10 @@ if (BUILD_SHARED_LIBS) PRIVATE $<$:MPICH_SKIP_MPICXX;MPICH_IGNORE_CXX_SEEK># Parallel/MPI, prevent spurious cpp/cxx warnings ) TARGET_C_PROPERTIES (${HDF5_CPP_LIBSH_TARGET} SHARED) - target_link_libraries (${HDF5_CPP_LIBSH_TARGET} PUBLIC ${HDF5_LIBSH_TARGET}) + target_link_libraries (${HDF5_CPP_LIBSH_TARGET} + PUBLIC ${HDF5_LIBSH_TARGET} + PRIVATE $<$:-static -static-libgcc -static-libstdc++ -dynamic> + ) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_CPP_LIBSH_TARGET}") H5_SET_LIB_OPTIONS (${HDF5_CPP_LIBSH_TARGET} ${HDF5_CPP_LIB_NAME} SHARED "CXX") set_target_properties (${HDF5_CPP_LIBSH_TARGET} PROPERTIES FOLDER libraries/cpp) diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index b05fbc8..8b68a9f 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -21,9 +21,6 @@ include (CheckTypeSize) include (CheckVariableExists) include (TestBigEndian) -set (HDF_EXTRA_C_FLAGS) -set (HDF_EXTRA_FLAGS) - #----------------------------------------------------------------------------- # APPLE/Darwin setup #----------------------------------------------------------------------------- @@ -264,6 +261,8 @@ HDF_FUNCTION_TEST (STDC_HEADERS) # The linux-lfs option is deprecated. set (LINUX_LFS 0) +set (HDF_EXTRA_C_FLAGS) +set (HDF_EXTRA_FLAGS) if (NOT WINDOWS) # Might want to check explicitly for Linux and possibly Cygwin # instead of checking for not Solaris or Darwin. diff --git a/config/cmake_ext_mod/HDFMacros.cmake b/config/cmake_ext_mod/HDFMacros.cmake index d145607..e1b79d8 100644 --- a/config/cmake_ext_mod/HDFMacros.cmake +++ b/config/cmake_ext_mod/HDFMacros.cmake @@ -86,7 +86,7 @@ macro (INSTALL_TARGET_PDB libtarget targetdestination targetcomponent) ${targetfilename} DESTINATION ${targetdestination} - CONFIGURATIONS $ + CONFIGURATIONS Debug RelWithDebInfo COMPONENT ${targetcomponent} OPTIONAL ) @@ -101,7 +101,7 @@ macro (INSTALL_PROGRAM_PDB progtarget targetdestination targetcomponent) $ DESTINATION ${targetdestination} - CONFIGURATIONS $ + CONFIGURATIONS Debug RelWithDebInfo COMPONENT ${targetcomponent} OPTIONAL ) @@ -128,6 +128,12 @@ macro (HDF_SET_LIB_OPTIONS libtarget libname libtype) endif () endif () + set_target_properties (${libtarget} + PROPERTIES + OUTPUT_NAME + ${LIB_RELEASE_NAME} + ) + if (${libtype} MATCHES "STATIC") if (WIN32) set_target_properties (${libtarget} diff --git a/release_docs/README_HDF5_CMake b/release_docs/README_HDF5_CMake index a2e7dce..1b02f0c 100644 --- a/release_docs/README_HDF5_CMake +++ b/release_docs/README_HDF5_CMake @@ -6,16 +6,16 @@ This tar file contains CTestScript.cmake HDF5config.cmake CMake scripts for building HDF5 HDF5options.cmake - hdf5-1.11.4 HDF5 1.11.4 source + hdf5-1.11.6 HDF5 1.11.6 source SZip.tar.gz source for building SZIP ZLib.tar.gz source for building ZLIB For more information about building HDF5 with CMake, see USING_HDF5_CMake.txt in -hdf5-1.11.4/release_docs, or +hdf5-1.11.6/release_docs, or https://portal.hdfgroup.org/display/support/Building+HDF5+with+CMake. For more information about building HDF5 with CMake on HPC machines, including -cross compiling on Cray XC40, see README_HPC in hdf5-1.11.4/release_docs. +cross compiling on Cray XC40, see README_HPC in hdf5-1.11.6/release_docs. diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 707adce..a64abc8 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -50,10 +50,10 @@ New Features ------------- - Windows PDB files are always installed - There are configuration settings for Windows, that may not generate - PDB files. As such the install utility will break because those files - are not found. Add an optional variable that can be set to not install - PDB files. + There are build configuration or flag settings for Windows that may not + generate PDB files. If those files are not generated then the install + utility will fail because those PDB files are not found. An optional + variable, DISABLE_PDB_FILES, was added to not install PDB files. (ADB - 2019/07/17, HDFFV-100424) diff --git a/src/H5win32defs.h b/src/H5win32defs.h index d439379..29533dd 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -69,13 +69,6 @@ typedef __int64 h5_stat_size_t; #define HDtzset() _tzset() #define HDunlink(S) _unlink(S) #define HDwrite(F,M,Z) _write(F,M,Z) -#if (_MSC_VER < 1800) -/* va_copy() does not exist on pre-2013 Visual Studio. Since va_lists are - * just pointers into the stack in those CRTs, the usual work-around - * is to just define the operation as a pointer copy. - */ -#define HDva_copy(D,S) ((D) = (S)) -#endif /* MSC_VER < 1800 */ #ifdef H5_HAVE_VISUAL_STUDIO @@ -86,6 +79,11 @@ typedef __int64 h5_stat_size_t; #ifndef H5_HAVE_STRTOULL #define HDstrtoull(S,R,N) _strtoui64(S,R,N) #endif /* H5_HAVE_STRTOULL */ + /* va_copy() does not exist on pre-2013 Visual Studio. Since va_lists are + * just pointers into the stack in those CRTs, the usual work-around + * is to just define the operation as a pointer copy. + */ + #define HDva_copy(D,S) ((D) = (S)) #endif /* MSC_VER < 1800 */ /* diff --git a/testpar/CMakeVFDTests.cmake b/testpar/CMakeVFDTests.cmake index 6f974af..1c0f2e8 100644 --- a/testpar/CMakeVFDTests.cmake +++ b/testpar/CMakeVFDTests.cmake @@ -50,7 +50,7 @@ endforeach () add_test ( NAME MPI_TEST_VFD-${vfdname}-${h5_test} COMMAND "${CMAKE_COMMAND}" - -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" -- cgit v0.12 From 0f2c1b8126075b2a1652644e5f529f83b771a52c Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 18 Jul 2019 01:48:16 -0500 Subject: Moved the -std=f2008 option to gfortran 9 for now. --- config/gnu-fflags | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/gnu-fflags b/config/gnu-fflags index 3a47787..d054980 100644 --- a/config/gnu-fflags +++ b/config/gnu-fflags @@ -52,7 +52,10 @@ if test "X-gfortran" = "X-$f9x_vendor"; then F9XSUFFIXFLAG="" FSEARCH_DIRS="" - H5_FCFLAGS="$H5_FCFLAGS -std=f2008" + if test $f9x_vers_major -ge 9; then + H5_FCFLAGS="$H5_FCFLAGS -std=f2008" + fi + ############################### # Architecture-specific flags # -- cgit v0.12 From 17474a232fa0bd2a7fb8da8e9e97d9050cbc0443 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 18 Jul 2019 09:21:00 -0500 Subject: HDFFV-10845 quote multiple strings in cmake link command --- c++/src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index 4e668d6..0871123 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -114,7 +114,7 @@ if (BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (${HDF5_CPP_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_CPP_LIBSH_TARGET} PUBLIC ${HDF5_LIBSH_TARGET} - PRIVATE $<$:-static -static-libgcc -static-libstdc++ -dynamic> + PRIVATE "$<$:-static -static-libgcc -static-libstdc++ -dynamic>" ) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_CPP_LIBSH_TARGET}") H5_SET_LIB_OPTIONS (${HDF5_CPP_LIBSH_TARGET} ${HDF5_CPP_LIB_NAME} SHARED "CXX") -- cgit v0.12 From bdfb553c4c5783f757524f436ae8043e061dd765 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 18 Jul 2019 10:45:42 -0500 Subject: HDFFV-1045 gcc static must be link flags --- c++/src/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index 0871123..f3db4f2 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -114,8 +114,12 @@ if (BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (${HDF5_CPP_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_CPP_LIBSH_TARGET} PUBLIC ${HDF5_LIBSH_TARGET} - PRIVATE "$<$:-static -static-libgcc -static-libstdc++ -dynamic>" ) + if (MINGW) + target_link_options (${HDF5_CPP_LIBSH_TARGET} + PUBLIC "-static -static-libgcc -static-libstdc++ -dynamic>" + ) + endif () set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_CPP_LIBSH_TARGET}") H5_SET_LIB_OPTIONS (${HDF5_CPP_LIBSH_TARGET} ${HDF5_CPP_LIB_NAME} SHARED "CXX") set_target_properties (${HDF5_CPP_LIBSH_TARGET} PROPERTIES FOLDER libraries/cpp) -- cgit v0.12 From 5b97d67d432d110e1c9ff5821e4ceec9e8ab4bf0 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 18 Jul 2019 11:37:34 -0500 Subject: CMake generator expr cannot be used in get_property cmd --- config/cmake_ext_mod/HDFMacros.cmake | 25 ++++++++++++++++--------- java/test/CMakeLists.txt | 5 +++-- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/config/cmake_ext_mod/HDFMacros.cmake b/config/cmake_ext_mod/HDFMacros.cmake index e1b79d8..972896d 100644 --- a/config/cmake_ext_mod/HDFMacros.cmake +++ b/config/cmake_ext_mod/HDFMacros.cmake @@ -110,21 +110,16 @@ endmacro () #------------------------------------------------------------------------------- macro (HDF_SET_LIB_OPTIONS libtarget libname libtype) - if (WIN32) - set (LIB_DEBUG_SUFFIX "_D") - else () - set (LIB_DEBUG_SUFFIX "_debug") - endif () if (${libtype} MATCHES "SHARED") set (LIB_RELEASE_NAME "${libname}") - set (LIB_DEBUG_NAME "${libname}${LIB_DEBUG_SUFFIX}") + set (LIB_DEBUG_NAME "${libname}${CMAKE_DEBUG_POSTFIX}") else () - if (WIN32) + if (WIN32 AND NOT MINGW) set (LIB_RELEASE_NAME "lib${libname}") - set (LIB_DEBUG_NAME "lib${libname}${LIB_DEBUG_SUFFIX}") + set (LIB_DEBUG_NAME "lib${libname}${CMAKE_DEBUG_POSTFIX}") else () set (LIB_RELEASE_NAME "${libname}") - set (LIB_DEBUG_NAME "${libname}${LIB_DEBUG_SUFFIX}") + set (LIB_DEBUG_NAME "${libname}${CMAKE_DEBUG_POSTFIX}") endif () endif () @@ -132,7 +127,19 @@ macro (HDF_SET_LIB_OPTIONS libtarget libname libtype) PROPERTIES OUTPUT_NAME ${LIB_RELEASE_NAME} + OUTPUT_NAME_DEBUG + ${LIB_DEBUG_NAME} + OUTPUT_NAME_RELEASE + ${LIB_RELEASE_NAME} + OUTPUT_NAME_MINSIZEREL + ${LIB_RELEASE_NAME} + OUTPUT_NAME_RELWITHDEBINFO + ${LIB_RELEASE_NAME} ) + #get_property (target_name TARGET ${libtarget} PROPERTY OUTPUT_NAME) + #get_property (target_name_debug TARGET ${libtarget} PROPERTY OUTPUT_NAME_DEBUG) + #get_property (target_name_rwdi TARGET ${libtarget} PROPERTY OUTPUT_NAME_RELWITHDEBINFO) + #message (STATUS "${target_name} : ${target_name_debug} : ${target_name_rwdi}") if (${libtype} MATCHES "STATIC") if (WIN32) diff --git a/java/test/CMakeLists.txt b/java/test/CMakeLists.txt index a210ca9..7910ea2 100644 --- a/java/test/CMakeLists.txt +++ b/java/test/CMakeLists.txt @@ -88,8 +88,9 @@ else () set (CMAKE_JAVA_INCLUDE_FLAG_SEP ":") endif () -get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY $,OUTPUT_NAME_DEBUG,OUTPUT_NAME_RELWITHDEBINFO>) -set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=${target_name};") +get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME) +get_property (target_name_debug TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME_DEBUG) +set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$,${target_name_debug},${target_name}>;") foreach (test_file ${HDF5_JAVA_TEST_SOURCES}) -- cgit v0.12 From 179d0b5af07c565faf694a06a2b4d699dd42e2e5 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 18 Jul 2019 12:00:19 -0500 Subject: Correct OUTPUT_NAME usage --- c++/examples/CMakeTests.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/c++/examples/CMakeTests.cmake b/c++/examples/CMakeTests.cmake index 6a2190c..b7d7497 100644 --- a/c++/examples/CMakeTests.cmake +++ b/c++/examples/CMakeTests.cmake @@ -26,6 +26,7 @@ SDSextendible.h5 Select.h5 ) + set_tests_properties (CPP_ex-clear-objects PROPERTIES FIXTURES_SETUP clear_cppex) if (last_test) set_tests_properties (CPP_ex-clear-objects PROPERTIES DEPENDS ${last_test}) endif () -- cgit v0.12 From 5984530f3f25fc236dd263fd134340a0a88abb64 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 18 Jul 2019 12:07:32 -0500 Subject: Fix typo --- c++/src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index f3db4f2..e93d089 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -117,7 +117,7 @@ if (BUILD_SHARED_LIBS) ) if (MINGW) target_link_options (${HDF5_CPP_LIBSH_TARGET} - PUBLIC "-static -static-libgcc -static-libstdc++ -dynamic>" + PUBLIC "-static -static-libgcc -static-libstdc++ -dynamic" ) endif () set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_CPP_LIBSH_TARGET}") -- cgit v0.12 From 5654ba57f131d14eaf76d09e8ca1299e03ee1358 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 18 Jul 2019 12:55:02 -0500 Subject: Correct syntax --- c++/src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index e93d089..bb244e8 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -117,7 +117,7 @@ if (BUILD_SHARED_LIBS) ) if (MINGW) target_link_options (${HDF5_CPP_LIBSH_TARGET} - PUBLIC "-static -static-libgcc -static-libstdc++ -dynamic" + PUBLIC -static-libgcc -static-libstdc++ ) endif () set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_CPP_LIBSH_TARGET}") -- cgit v0.12 From 4d3f52ac97ea922cefda857c971fbd3608d8994c Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 18 Jul 2019 13:03:07 -0500 Subject: Correct java load library name access --- java/examples/datasets/CMakeLists.txt | 5 +++-- java/examples/datatypes/CMakeLists.txt | 5 +++-- java/examples/groups/CMakeLists.txt | 5 +++-- java/examples/intro/CMakeLists.txt | 5 +++-- java/test/CMakeLists.txt | 2 -- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/java/examples/datasets/CMakeLists.txt b/java/examples/datasets/CMakeLists.txt index 328c4b1..83343fc 100644 --- a/java/examples/datasets/CMakeLists.txt +++ b/java/examples/datasets/CMakeLists.txt @@ -72,8 +72,9 @@ foreach (HDFJAVA_JAR ${CMAKE_JAVA_INCLUDE_PATH}) endforeach () macro (ADD_H5_TEST resultfile resultcode) - get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY $,OUTPUT_NAME_DEBUG,OUTPUT_NAME_RELWITHDEBINFO>) - set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=${target_name};") + get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME) + get_property (target_name_debug TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME_DEBUG) + set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$,${target_name_debug},${target_name}>;") add_test ( NAME JAVA_datasets-${resultfile} COMMAND "${CMAKE_COMMAND}" diff --git a/java/examples/datatypes/CMakeLists.txt b/java/examples/datatypes/CMakeLists.txt index 18a99b8..701fe2a 100644 --- a/java/examples/datatypes/CMakeLists.txt +++ b/java/examples/datatypes/CMakeLists.txt @@ -57,8 +57,9 @@ foreach (HDFJAVA_JAR ${CMAKE_JAVA_INCLUDE_PATH}) endforeach () MACRO (ADD_H5_TEST resultfile resultcode) - get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY $,OUTPUT_NAME_DEBUG,OUTPUT_NAME_RELWITHDEBINFO>) - set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=${target_name};") + get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME) + get_property (target_name_debug TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME_DEBUG) + set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$,${target_name_debug},${target_name}>;") add_test ( NAME JAVA_datatypes-${resultfile} COMMAND "${CMAKE_COMMAND}" diff --git a/java/examples/groups/CMakeLists.txt b/java/examples/groups/CMakeLists.txt index 8b16ffd..f0693ba 100644 --- a/java/examples/groups/CMakeLists.txt +++ b/java/examples/groups/CMakeLists.txt @@ -56,8 +56,9 @@ endforeach () add_custom_target(H5Ex_G_Visit_files ALL COMMENT "Copying files needed by H5Ex_G_Visit tests" DEPENDS ${H5Ex_G_Visit_files_list}) macro (ADD_H5_TEST resultfile resultcode) - get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY $,OUTPUT_NAME_DEBUG,OUTPUT_NAME_RELWITHDEBINFO>) - set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=${target_name};") + get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME) + get_property (target_name_debug TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME_DEBUG) + set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$,${target_name_debug},${target_name}>;") add_test ( NAME JAVA_groups-${resultfile} COMMAND "${CMAKE_COMMAND}" diff --git a/java/examples/intro/CMakeLists.txt b/java/examples/intro/CMakeLists.txt index 86b6296..a4f0cdd 100644 --- a/java/examples/intro/CMakeLists.txt +++ b/java/examples/intro/CMakeLists.txt @@ -58,8 +58,9 @@ foreach (example ${HDF_JAVA_OBJECT_EXAMPLES}) endforeach () MACRO (ADD_H5_TEST resultfile resultcode) - get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY $,OUTPUT_NAME_DEBUG,OUTPUT_NAME_RELWITHDEBINFO>) - set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=${target_name};") + get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME) + get_property (target_name_debug TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME_DEBUG) + set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$,${target_name_debug},${target_name}>;") add_test ( NAME JAVA_intro-${resultfile} COMMAND "${CMAKE_COMMAND}" diff --git a/java/test/CMakeLists.txt b/java/test/CMakeLists.txt index 7910ea2..d677b5f 100644 --- a/java/test/CMakeLists.txt +++ b/java/test/CMakeLists.txt @@ -93,7 +93,6 @@ get_property (target_name_debug TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTP set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$,${target_name_debug},${target_name}>;") foreach (test_file ${HDF5_JAVA_TEST_SOURCES}) - set (CMAKE_JAVA_CLASSPATH ".") foreach (CMAKE_INCLUDE_PATH ${CMAKE_JAVA_INCLUDE_PATH}) set (CMAKE_JAVA_CLASSPATH "${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${CMAKE_INCLUDE_PATH}") @@ -125,7 +124,6 @@ foreach (test_file ${HDF5_JAVA_TEST_SOURCES}) -D "TEST_REFERENCE=JUnit-${test_file}.txt" -P "${HDF_RESOURCES_DIR}/jrunTest.cmake" ) - set_tests_properties (JUnit-${test_file} PROPERTIES ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/testdir2" DEPENDS "JUnit-${test_file}-clearall-objects" -- cgit v0.12 From 367f7ed0e338ccf1a698ab0af4bb7ea702fd2d60 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 18 Jul 2019 16:27:06 -0500 Subject: HDFFV-10845 make flags private --- c++/examples/CMakeLists.txt | 10 ++++++++++ c++/src/CMakeLists.txt | 2 +- c++/test/CMakeLists.txt | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/c++/examples/CMakeLists.txt b/c++/examples/CMakeLists.txt index 2088019..58d85c1 100644 --- a/c++/examples/CMakeLists.txt +++ b/c++/examples/CMakeLists.txt @@ -41,6 +41,11 @@ foreach (example ${examples}) else () TARGET_C_PROPERTIES (cpp_ex_${example} SHARED) target_link_libraries (cpp_ex_${example} PRIVATE ${HDF5_CPP_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + if (MINGW) + target_link_options (${HDF5_CPP_LIBSH_TARGET} + PRIVATE -static-libgcc -static-libstdc++ + ) + endif () endif () set_target_properties (cpp_ex_${example} PROPERTIES FOLDER examples/cpp) endforeach () @@ -54,6 +59,11 @@ foreach (example ${tutr_examples}) else () TARGET_C_PROPERTIES (cpp_ex_${example} SHARED) target_link_libraries (cpp_ex_${example} PRIVATE ${HDF5_CPP_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + if (MINGW) + target_link_options (${HDF5_CPP_LIBSH_TARGET} + PRIVATE -static-libgcc -static-libstdc++ + ) + endif () endif () set_target_properties (cpp_ex_${example} PROPERTIES FOLDER examples/cpp) endforeach () diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index bb244e8..2a92ed2 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -117,7 +117,7 @@ if (BUILD_SHARED_LIBS) ) if (MINGW) target_link_options (${HDF5_CPP_LIBSH_TARGET} - PUBLIC -static-libgcc -static-libstdc++ + PRIVATE -static-libgcc -static-libstdc++ ) endif () set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_CPP_LIBSH_TARGET}") diff --git a/c++/test/CMakeLists.txt b/c++/test/CMakeLists.txt index 95ca9b1..75efc3b 100644 --- a/c++/test/CMakeLists.txt +++ b/c++/test/CMakeLists.txt @@ -48,6 +48,11 @@ if (NOT BUILD_SHARED_LIBS) else () TARGET_C_PROPERTIES (cpp_testhdf5 SHARED) target_link_libraries (cpp_testhdf5 PRIVATE ${HDF5_CPP_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET}) + if (MINGW) + target_link_options (${HDF5_CPP_LIBSH_TARGET} + PRIVATE -static-libgcc -static-libstdc++ + ) + endif () endif () set_target_properties (cpp_testhdf5 PROPERTIES FOLDER test/cpp) -- cgit v0.12 From 5a3147b660c4e37f6a5cb71f4884e7f7e43a8782 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 18 Jul 2019 23:40:52 -0700 Subject: First stab at gfortran versions. Tested on gfortran 7-9 so far. --- config/gnu-fflags | 75 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 16 deletions(-) diff --git a/config/gnu-fflags b/config/gnu-fflags index d054980..90a3656 100644 --- a/config/gnu-fflags +++ b/config/gnu-fflags @@ -52,8 +52,14 @@ if test "X-gfortran" = "X-$f9x_vendor"; then F9XSUFFIXFLAG="" FSEARCH_DIRS="" - if test $f9x_vers_major -ge 9; then + # Need Fortran 2008 support for storage_size() in gcc 4.6 on + # (2008ts in some versions) + if test $f9x_vers_major -ge 8; then H5_FCFLAGS="$H5_FCFLAGS -std=f2008" + elif test $f9x_vers_major -ge 5 -o $f9x_vers_major -eq 4 -a $f9x_vers_minor -ge 6; then + H5_FCFLAGS="$H5_FCFLAGS -std=f2008ts" + else + H5_FCFLAGS="$H5_FCFLAGS -std=f2003" fi @@ -81,8 +87,7 @@ if test "X-gfortran" = "X-$f9x_vendor"; then # Debug # ######### - # Need to figure out an appropriate version for the switch. - if test $f9x_vers_major -ge 9; then + if test $f9x_vers_major -ge 5 -o $f9x_vers_major -eq 4 -a $f9x_vers_minor -ge 5; then DEBUG_FCFLAGS="-fcheck=all" else DEBUG_FCFLAGS="-fbounds-check" @@ -105,8 +110,13 @@ if test "X-gfortran" = "X-$f9x_vendor"; then # Optimization # ################ - HIGH_OPT_FCFLAGS="-O2" - DEBUG_OPT_FCFLAGS="-O0" + if test $f9x_vers_major -le 4; then + HIGH_OPT_CFLAGS="-O3" + DEBUG_OPT_CFLAGS= + else + HIGH_OPT_CFLAGS="-O3" + DEBUG_OPT_CFLAGS="-Og" + fi NO_OPT_FCFLAGS="-O0" ############ @@ -118,24 +128,57 @@ if test "X-gfortran" = "X-$f9x_vendor"; then ########### H5_FCFLAGS="$H5_FCFLAGS -pedantic -Wall -Wextra -Wunderflow -Wimplicit-interface -Wsurprising" - - # Turn off warnings for passing non-ANSI types to BIND(). - # We pass a lot of hid_t, etc. types so this generates a LOT of spurious warnings. - H5_FCFLAGS="$H5_FCFLAGS -Wno-c-binding-type" + H5_FCFLAGS="$H5_FCFLAGS -Waliasing -Wcharacter-truncation -Wimplicit-procedure" ############################# # Version-specific warnings # ############################# - # gcc 9 - # Move to other versions (9 is just the current version) - if test $f9x_vers_major -ge 9; then - H5_FCFLAGS="$H5_FCFLAGS -Waliasing -Warray-temporaries -Wcharacter-truncation" - H5_FCFLAGS="$H5_FCFLAGS -Wconversion-extra -Wfrontend-loop-interchange -Wimplicit-procedure" - H5_FCFLAGS="$H5_FCFLAGS -Winteger-division -Wintrinsics-std -Wreal-q-constant" - H5_FCFLAGS="$H5_FCFLAGS -Wuse-without-only -Wrealloc-lhs -Wrealloc-lhs-all" + # gfortran 4.3 (nothing new) + + # gfortran 4.4 + if test $f9x_vers_major -ge 5 -o $f9x_vers_major -eq 4 -a $f9x_vers_minor -ge 4; then + H5_FCFLAGS="$H5_FCFLAGS -Warray-temporaries -Wintrinsics-std" + fi + + # gfortran 4.5 (nothing new) + + # gfortran 4.6 (nothing new) + + # gfortran 4.7 + if test $f9x_vers_major -ge 5 -o $f9x_vers_major -eq 4 -a $f9x_vers_minor -ge 7; then + H5_FCFLAGS="$H5_FCFLAGS -Wreal-q-constant -Wfunction-elimination" + fi + + # gfortran 4.8 + if test $f9x_vers_major -ge 5 -o $f9x_vers_major -eq 4 -a $f9x_vers_minor -ge 8; then + H5_FCFLAGS="$H5_FCFLAGS -Wrealloc-lhs -Wrealloc-lhs-all" + # Turn off warnings for passing non-ANSI types to BIND(). + # We pass a lot of hid_t, etc. types so this generates a LOT of spurious warnings. + H5_FCFLAGS="$H5_FCFLAGS -Wno-c-binding-type" + fi + + # gfortran 4.9 (nothing new) + + # gfortran 5 + if test $f9x_vers_major -ge 5; then + H5_FCFLAGS="$H5_FCFLAGS -Wuse-without-only" + fi + + # gfortran 6 + if test $f9x_vers_major -ge 6; then + H5_FCFLAGS="$H5_FCFLAGS -Winteger-division" fi + # gfortran 7 (nothing new) + + # gfortran 8 + if test $f9x_vers_major -ge 8; then + H5_FCFLAGS="$H5_FCFLAGS -Wfrontend-loop-interchange" + fi + + # gfortran 9 (nothing new) + ################# # Flags are set # ################# -- cgit v0.12 From 7d291d059da6287f769951c4854c566da0b93ce8 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 19 Jul 2019 02:48:00 -0500 Subject: Parallel Fortran tests now use the MPI module instead of including mpif.h. --- fortran/testpar/hyper.f90 | 3 ++- fortran/testpar/mdset.f90 | 3 ++- fortran/testpar/ptest.f90 | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fortran/testpar/hyper.f90 b/fortran/testpar/hyper.f90 index 22f641d..c07636f 100644 --- a/fortran/testpar/hyper.f90 +++ b/fortran/testpar/hyper.f90 @@ -18,9 +18,10 @@ SUBROUTINE hyper(length,do_collective,do_chunk, mpi_size, mpi_rank, nerrors) USE HDF5 + USE MPI USE TH5_MISC + IMPLICIT NONE - INCLUDE 'mpif.h' INTEGER, INTENT(in) :: length ! array length LOGICAL, INTENT(in) :: do_collective ! use collective I/O diff --git a/fortran/testpar/mdset.f90 b/fortran/testpar/mdset.f90 index 70d2939..3de61c3 100644 --- a/fortran/testpar/mdset.f90 +++ b/fortran/testpar/mdset.f90 @@ -18,9 +18,10 @@ SUBROUTINE multiple_dset_write(length, do_collective, do_chunk, mpi_size, mpi_rank, nerrors) USE HDF5 + USE MPI USE TH5_MISC + IMPLICIT NONE - INCLUDE 'mpif.h' INTEGER, INTENT(in) :: length ! array length LOGICAL, INTENT(in) :: do_collective ! use collective I/O diff --git a/fortran/testpar/ptest.f90 b/fortran/testpar/ptest.f90 index 14ac3b2..3b07f21 100644 --- a/fortran/testpar/ptest.f90 +++ b/fortran/testpar/ptest.f90 @@ -16,7 +16,7 @@ ! PROGRAM parallel_test - USE hdf5 + USE HDF5 USE MPI USE TH5_MISC -- cgit v0.12 From 19327521770a5a61ecb7cf62415b37ce1f82328c Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Sun, 21 Jul 2019 14:19:23 -0500 Subject: HDFFV-10845 Windows drive can only goto Z --- test/links.c | 1896 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 950 insertions(+), 946 deletions(-) diff --git a/test/links.c b/test/links.c index 2658101..69ec665 100644 --- a/test/links.c +++ b/test/links.c @@ -15,28 +15,28 @@ * Programmer: Robb Matzke * Friday, April 10, 1998 * - * Purpose: Tests hard, soft (symbolic) & external links. + * Purpose: Tests hard, soft (symbolic) & external links. */ /* * This file needs to access private information from the H5FD package. * This file also needs to access the file driver testing code. */ -#define H5FD_FRIEND /*suppress error about including H5FDpkg */ +#define H5FD_FRIEND /*suppress error about including H5FDpkg */ #define H5FD_TESTING /* * This file needs to access private information from the H5G package. * This file also needs to access the group testing code. */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ #define H5G_TESTING #include "h5test.h" #include "H5srcdir.h" #include "H5FDpkg.h" /* File drivers */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ /* File for external link test. Created with gen_udlinks.c */ @@ -62,55 +62,55 @@ const char *FILENAME[] = { "links6", /* 9 */ "links7", /* 10 */ "links8", /* 11 */ - "extlinks0", /* 12: main files */ - TMPDIR "extlinks0", /* 13: */ - "extlinks1", /* 14: target files */ - TMPDIR "extlinks1", /* 15: */ - "extlinks2", /* 16: */ - TMPDIR "extlinks2", /* 17: */ - "extlinks3", /* 18: */ - TMPDIR "extlinks3", /* 19: */ - "extlinks4", /* 20: */ - TMPDIR "extlinks4", /* 21: */ - "extlinks5", /* 22: */ - TMPDIR "extlinks6", /* 23: */ - "extlinks7", /* 24: */ - TMPDIR "extlinks7", /* 25: */ - TMPDIR "extlinks8", /* 26: */ - "extlinks9", /* 27: */ - TMPDIR "extlinks9", /* 28: */ - "extlinks10", /* 29: */ /* TESTS for windows */ + "extlinks0", /* 12: main files */ + TMPDIR "extlinks0", /* 13: */ + "extlinks1", /* 14: target files */ + TMPDIR "extlinks1", /* 15: */ + "extlinks2", /* 16: */ + TMPDIR "extlinks2", /* 17: */ + "extlinks3", /* 18: */ + TMPDIR "extlinks3", /* 19: */ + "extlinks4", /* 20: */ + TMPDIR "extlinks4", /* 21: */ + "extlinks5", /* 22: */ + TMPDIR "extlinks6", /* 23: */ + "extlinks7", /* 24: */ + TMPDIR "extlinks7", /* 25: */ + TMPDIR "extlinks8", /* 26: */ + "extlinks9", /* 27: */ + TMPDIR "extlinks9", /* 28: */ + "extlinks10", /* 29: */ /* TESTS for windows */ TMPDIR "extlinks10",/* 30: */ TMPDIR "extlinks11",/* 31: */ TMPDIR "extlinks12",/* 32: */ - "extlinks13", /* 33: */ + "extlinks13", /* 33: */ TMPDIR "extlinks13",/* 34: */ TMPDIR "extlinks14",/* 35: */ TMPDIR "extlinks15",/* 36: */ - "extlinks16A", /* 37: */ /* TESTS for H5P_set_elink_fapl */ - "extlinks16B", /* 38: */ - "extlinks17", /* 39: */ - "extlinks18A", /* 40: */ - "extlinks18B", /* 41: */ - "extlinks19A", /* 42: */ - "extlinks19B", /* 43: */ - "extlinks20", /* 44: */ - "extlinks21A", /* 45: Files for symlink() tests*/ + "extlinks16A", /* 37: */ /* TESTS for H5P_set_elink_fapl */ + "extlinks16B", /* 38: */ + "extlinks17", /* 39: */ + "extlinks18A", /* 40: */ + "extlinks18B", /* 41: */ + "extlinks19A", /* 42: */ + "extlinks19B", /* 43: */ + "extlinks20", /* 44: */ + "extlinks21A", /* 45: Files for symlink() tests*/ TMPDIR2 "extlinks21B",/* 46: */ TMPDIR2 "extlinks21C",/* 47: */ - "extlinks21C", /* 48: (same as #47, only without the TMPDIR2 prefix) */ + "extlinks21C", /* 48: (same as #47, only without the TMPDIR2 prefix) */ TMPDIR "extlinks21D",/* 49: */ TMPDIR "extlinks21E",/* 50: */ - "extlinks21E", /* 51: (same as #50, only without the TMPDIR prefix) */ + "extlinks21E", /* 51: (same as #50, only without the TMPDIR prefix) */ NULL }; -#define FAMILY_SIZE 1024 +#define FAMILY_SIZE 1024 #define CORE_INCREMENT 1024 -#define NUM40 40 +#define NUM40 40 /* do not do check_all_closed() for "ext*" files and "tmp/ext*" */ -#define EXTSTOP 12 +#define EXTSTOP 12 #define LINK_BUF_SIZE 1024 #define NAME_BUF_SIZE 1024 @@ -318,7 +318,7 @@ typedef struct { static hid_t dcpl_g; /* for [un]minimized dataset object headers */ - + /*------------------------------------------------------------------------- * Function: fix_ext_filename * @@ -340,17 +340,17 @@ fix_ext_filename(char *path_name, char *cwd, const char *file_name) HDstrcat(path_name, file_name); } - + /*------------------------------------------------------------------------- - * Function: mklinks + * Function: mklinks * - * Purpose: Build a file with assorted links. + * Purpose: Build a file with assorted links. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, August 14, 1998 * * Modifications: @@ -360,9 +360,9 @@ fix_ext_filename(char *path_name, char *cwd, const char *file_name) static int mklinks(hid_t fapl, hbool_t new_format) { - hid_t file, scalar, grp, d1; - hsize_t size[1] = {1}; - char filename[NAME_BUF_SIZE]; + hid_t file, scalar, grp, d1; + hsize_t size[1] = {1}; + char filename[NAME_BUF_SIZE]; if(new_format) TESTING("link creation (w/new group format)") @@ -405,7 +405,7 @@ mklinks(hid_t fapl, hbool_t new_format) return -1; } - + /*------------------------------------------------------------------------- * Function: new_links * @@ -425,11 +425,11 @@ mklinks(hid_t fapl, hbool_t new_format) static int new_links(hid_t fapl, hbool_t new_format) { - hid_t file_a, file_b=(-1); - hid_t grp1_a=(-1), grp1_b=(-1), grp2_a=(-1), grp2_b=(-1); - hid_t scalar=(-1); - hid_t dset1=(-1), dset2=(-1); - char filename[NAME_BUF_SIZE]; + hid_t file_a, file_b=(-1); + hid_t grp1_a=(-1), grp1_b=(-1), grp2_a=(-1), grp2_b=(-1); + hid_t scalar=(-1); + hid_t dset1=(-1), dset2=(-1); + char filename[NAME_BUF_SIZE]; hsize_t size[1] = {1}; if(new_format) @@ -492,31 +492,31 @@ new_links(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Sclose(scalar); - H5Dclose(dset1); - H5Dclose(dset2); - H5Gclose(grp1_a); - H5Gclose(grp2_a); - H5Gclose(grp1_b); - H5Gclose(grp2_b); - H5Fclose(file_a); - H5Fclose(file_b); + H5Sclose(scalar); + H5Dclose(dset1); + H5Dclose(dset2); + H5Gclose(grp1_a); + H5Gclose(grp2_a); + H5Gclose(grp1_b); + H5Gclose(grp2_b); + H5Fclose(file_a); + H5Fclose(file_b); } H5E_END_TRY; return -1; } - + /*------------------------------------------------------------------------- - * Function: cklinks + * Function: cklinks * - * Purpose: Open the file created in the first step and check that the - * links look correct. + * Purpose: Open the file created in the first step and check that the + * links look correct. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, August 14, 1998 * * Modifications: @@ -526,12 +526,12 @@ new_links(hid_t fapl, hbool_t new_format) static int cklinks(hid_t fapl, hbool_t new_format) { - hid_t file; - H5O_info_t oinfo1, oinfo2; - H5L_info_t linfo2; - char linkval[LINK_BUF_SIZE]; - char filename[NAME_BUF_SIZE]; - herr_t status; + hid_t file; + H5O_info_t oinfo1, oinfo2; + H5L_info_t linfo2; + char linkval[LINK_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; + herr_t status; if(new_format) TESTING("link queries (w/new group format)") @@ -546,15 +546,15 @@ cklinks(hid_t fapl, hbool_t new_format) if(H5Oget_info_by_name2(file, "d1", &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5Oget_info_by_name2(file, "grp1/hard", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5O_TYPE_DATASET != oinfo2.type) { - H5_FAILED(); - HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); - TEST_ERROR + H5_FAILED(); + HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); + TEST_ERROR } /* end if */ if(H5F_addr_ne(oinfo1.addr, oinfo2.addr)) { - H5_FAILED(); - HDputs(" Hard link test failed. Link seems not to point to the "); - HDputs(" expected file location."); - TEST_ERROR + H5_FAILED(); + HDputs(" Hard link test failed. Link seems not to point to the "); + HDputs(" expected file location."); + TEST_ERROR } /* end if */ if(H5Lexists(file, "/", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR if(H5Lexists(file, "d1", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR @@ -565,91 +565,91 @@ cklinks(hid_t fapl, hbool_t new_format) status = H5Lexists(file, "no_grp1/hard", H5P_DEFAULT); } H5E_END_TRY; if(status >= 0) { - H5_FAILED(); - HDputs(" H5Lexists() should have failed for a path with missing components."); - TEST_ERROR + H5_FAILED(); + HDputs(" H5Lexists() should have failed for a path with missing components."); + TEST_ERROR } /* end if */ H5E_BEGIN_TRY { status = H5Lexists(file, "/no_grp1/hard", H5P_DEFAULT); } H5E_END_TRY; if(status >= 0) { - H5_FAILED(); - HDputs(" H5Lexists() should have failed for a path with missing components."); - TEST_ERROR + H5_FAILED(); + HDputs(" H5Lexists() should have failed for a path with missing components."); + TEST_ERROR } /* end if */ /* Symbolic link */ if(H5Oget_info_by_name2(file, "grp1/soft", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5O_TYPE_DATASET != oinfo2.type) { - H5_FAILED(); - HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); - TEST_ERROR + H5_FAILED(); + HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); + TEST_ERROR } /* end if */ if(H5F_addr_ne(oinfo1.addr, oinfo2.addr)) { - H5_FAILED(); - HDputs(" Soft link test failed. Link seems not to point to the "); - HDputs(" expected file location."); - TEST_ERROR + H5_FAILED(); + HDputs(" Soft link test failed. Link seems not to point to the "); + HDputs(" expected file location."); + TEST_ERROR } /* end if */ if(H5Lget_val(file, "grp1/soft", linkval, sizeof linkval, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(HDstrcmp(linkval, "/d1")) { - H5_FAILED(); - HDputs(" Soft link test failed. Wrong link value"); - TEST_ERROR + H5_FAILED(); + HDputs(" Soft link test failed. Wrong link value"); + TEST_ERROR } /* end if */ if(H5Lexists(file, "grp1/soft", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR /* Dangling link */ H5E_BEGIN_TRY { - status = H5Oget_info_by_name2(file, "grp1/dangle", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT); + status = H5Oget_info_by_name2(file, "grp1/dangle", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT); } H5E_END_TRY; if(status >= 0) { - H5_FAILED(); - HDputs(" H5Oget_info_by_name() should have failed for a dangling link."); - TEST_ERROR + H5_FAILED(); + HDputs(" H5Oget_info_by_name() should have failed for a dangling link."); + TEST_ERROR } /* end if */ if(H5Lget_info(file, "grp1/dangle", &linfo2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5L_TYPE_SOFT != linfo2.type) { - H5_FAILED(); - HDprintf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); - TEST_ERROR + H5_FAILED(); + HDprintf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); + TEST_ERROR } /* end if */ if(H5Lget_val(file, "grp1/dangle", linkval, sizeof linkval, H5P_DEFAULT) < 0) { - H5_FAILED(); - HDprintf(" %d: Can't retrieve link value\n", __LINE__); - TEST_ERROR + H5_FAILED(); + HDprintf(" %d: Can't retrieve link value\n", __LINE__); + TEST_ERROR } /* end if */ if(HDstrcmp(linkval, "foobar")) { - H5_FAILED(); - HDputs(" Dangling link test failed. Wrong link value"); - TEST_ERROR + H5_FAILED(); + HDputs(" Dangling link test failed. Wrong link value"); + TEST_ERROR } /* end if */ if(H5Lexists(file, "grp1/dangle", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR /* Recursive link */ H5E_BEGIN_TRY { - status = H5Oget_info_by_name2(file, "grp1/recursive", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT); + status = H5Oget_info_by_name2(file, "grp1/recursive", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT); } H5E_END_TRY; if(status >= 0) { - H5_FAILED(); - HDputs(" H5Oget_info_by_name() should have failed for a recursive link."); - TEST_ERROR + H5_FAILED(); + HDputs(" H5Oget_info_by_name() should have failed for a recursive link."); + TEST_ERROR } /* end if */ if(H5Lget_info(file, "grp1/recursive", &linfo2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5L_TYPE_SOFT != linfo2.type) { - H5_FAILED(); - HDprintf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); - TEST_ERROR + H5_FAILED(); + HDprintf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); + TEST_ERROR } /* end if */ if(H5Lget_val(file, "grp1/recursive", linkval, sizeof linkval, H5P_DEFAULT) < 0) { - H5_FAILED(); - HDprintf(" %d: Can't retrieve link value\n", __LINE__); - TEST_ERROR + H5_FAILED(); + HDprintf(" %d: Can't retrieve link value\n", __LINE__); + TEST_ERROR } /* end if */ if(HDstrcmp(linkval, "/grp1/recursive")) { - H5_FAILED(); - HDputs(" Recursive link test failed. Wrong link value"); - TEST_ERROR + H5_FAILED(); + HDputs(" Recursive link test failed. Wrong link value"); + TEST_ERROR } /* end if */ /* Non-existent link */ @@ -665,7 +665,7 @@ error: return -1; } - + /*------------------------------------------------------------------------- * Function: ck_new_links * @@ -684,9 +684,9 @@ error: static int ck_new_links(hid_t fapl, hbool_t new_format) { - hid_t file; - H5O_info_t oi_dset, oi_hard1, oi_hard2; - char filename[NAME_BUF_SIZE]; + hid_t file; + H5O_info_t oi_dset, oi_hard1, oi_hard2; + char filename[NAME_BUF_SIZE]; if(new_format) TESTING("new link queries (w/new group format)") @@ -699,23 +699,23 @@ ck_new_links(hid_t fapl, hbool_t new_format) /* Get hard link info */ if(H5Oget_info_by_name2(file, "/grp1/dataset2", &oi_dset, H5O_INFO_BASIC, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR if(H5Oget_info_by_name2(file, "/grp1/hard1", &oi_hard1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR if(H5Oget_info_by_name2(file, "/grp2/hard2", &oi_hard2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR /* Check hard links */ if(H5O_TYPE_DATASET != oi_hard1.type || H5O_TYPE_DATASET != oi_hard2.type) { - H5_FAILED(); - HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); - TEST_ERROR + H5_FAILED(); + HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); + TEST_ERROR } if(H5F_addr_ne(oi_dset.addr, oi_hard1.addr) || H5F_addr_ne(oi_dset.addr, oi_hard2.addr)) { - H5_FAILED(); - HDputs(" Hard link test failed. Link seems not to point to the "); - HDputs(" expected file location."); - TEST_ERROR + H5_FAILED(); + HDputs(" Hard link test failed. Link seems not to point to the "); + HDputs(" expected file location."); + TEST_ERROR } /* Cleanup */ @@ -728,7 +728,7 @@ error: return -1; } - + /*------------------------------------------------------------------------- * Function: long_links * @@ -748,12 +748,12 @@ error: static int long_links(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ - hid_t gid2 = (-1); /* Datatype ID */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group ID */ + hid_t gid2 = (-1); /* Datatype ID */ char *objname = NULL; /* Name of object [Long] */ size_t u; /* Local index variable */ - char filename[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; if(new_format) TESTING("long names for objects & links (w/new group format)") @@ -796,15 +796,15 @@ long_links(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid2); - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid2); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; HDfree(objname); return -1; } - + /*------------------------------------------------------------------------- * Function: toomany * @@ -824,10 +824,10 @@ long_links(hid_t fapl, hbool_t new_format) static int toomany(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1), gid2 = (-1); /* Group IDs */ char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; if(new_format) TESTING("too many links (w/new group format)") @@ -917,9 +917,9 @@ toomany(hid_t fapl, hbool_t new_format) gid = H5Gopen2(fid, "soft17", H5P_DEFAULT); } H5E_END_TRY; if(gid >= 0) { - H5_FAILED(); - HDputs(" Should have failed for sequence of too many nested links."); - TEST_ERROR + H5_FAILED(); + HDputs(" Should have failed for sequence of too many nested links."); + TEST_ERROR } /* end if */ /* Open object through lesser soft link */ @@ -944,14 +944,14 @@ toomany(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose(gid2); - H5Gclose(gid); - H5Fclose(fid); + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(fid); } H5E_END_TRY; return -1; } /* end toomany() */ - + /*------------------------------------------------------------------------- * Function: test_lcpl * @@ -1111,7 +1111,7 @@ error: return 1; } /* end test_lcpl() */ - + /*------------------------------------------------------------------------- * Function: test_move * @@ -1131,9 +1131,9 @@ error: static int test_move(hid_t fapl, hbool_t new_format) { - hid_t file_a, file_b=(-1); - hid_t grp_1=(-1), grp_2=(-1), grp_move=(-1), moved_grp=(-1); - char filename[1024]; + hid_t file_a, file_b=(-1); + hid_t grp_1=(-1), grp_2=(-1), grp_move=(-1), moved_grp=(-1); + char filename[1024]; if(new_format) TESTING("H5Lmove (w/new group format)") @@ -1155,9 +1155,9 @@ test_move(hid_t fapl, hbool_t new_format) /* Create hard, soft and external links. */ if(H5Lcreate_hard(grp_1, "group_move", H5L_SAME_LOC, "hard", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR if(H5Lcreate_soft("/group1/group_move", grp_2, "soft", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR if(H5Lcreate_external("filename", "pathname", grp_2, "ext", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -1188,11 +1188,11 @@ test_move(hid_t fapl, hbool_t new_format) /* Move a group across groups in the same file while renaming it. */ if(H5Lmove(grp_1, "group_move", grp_2, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR /* Open the group just moved to the new location. */ if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if( H5Gclose(moved_grp) < 0) TEST_ERROR @@ -1201,38 +1201,38 @@ test_move(hid_t fapl, hbool_t new_format) moved_grp = H5Gopen2(grp_1, "group_move", H5P_DEFAULT); } H5E_END_TRY; if(moved_grp >= 0) { - H5_FAILED(); - HDputs(" Group still in original location?"); - TEST_ERROR + H5_FAILED(); + HDputs(" Group still in original location?"); + TEST_ERROR } /* end if */ /* Use H5Lmove to rename a group without moving it. */ if(H5Lmove(grp_2, "group_new_name", H5L_SAME_LOC, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR /* Open the group. */ if((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Use H5Lmove to move a group without renaming it. */ if(H5Lmove(grp_2, "group_newer_name", grp_1, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR /* Open the group . */ if((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Move the group while giving long paths. */ if(H5Lmove(file_a, "/group1/group_newer_name", grp_2, "/group2/group_newest_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR /* Open the group just moved to the new location. */ if((moved_grp = H5Gopen2(grp_2, "group_newest_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Gclose(moved_grp) < 0) TEST_ERROR @@ -1261,17 +1261,17 @@ test_move(hid_t fapl, hbool_t new_format) error: H5_FAILED(); H5E_BEGIN_TRY { - H5Gclose(grp_1); - H5Gclose(grp_2); - H5Gclose(grp_move); + H5Gclose(grp_1); + H5Gclose(grp_2); + H5Gclose(grp_move); H5Gclose(moved_grp); - H5Fclose(file_a); - H5Fclose(file_b); + H5Fclose(file_a); + H5Fclose(file_b); } H5E_END_TRY; return 1; } - + /*------------------------------------------------------------------------- * Function: test_copy * @@ -1291,9 +1291,9 @@ test_move(hid_t fapl, hbool_t new_format) static int test_copy(hid_t fapl, hbool_t new_format) { - hid_t file_a, file_b=(-1); - hid_t grp_1=(-1), grp_2=(-1), grp_move=(-1), moved_grp=(-1); - char filename[1024]; + hid_t file_a, file_b=(-1); + hid_t grp_1=(-1), grp_2=(-1), grp_move=(-1), moved_grp=(-1); + char filename[1024]; if(new_format) TESTING("H5Lcopy (w/new group format)") @@ -1315,9 +1315,9 @@ test_copy(hid_t fapl, hbool_t new_format) /* Create hard, soft and external links. */ if(H5Lcreate_hard(grp_1, "group_copy", H5L_SAME_LOC, "hard", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR if(H5Lcreate_soft("/group1/group_copy", grp_2, "soft", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR if(H5Lcreate_external("filename", "pathname", grp_2, "ext", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -1348,75 +1348,75 @@ test_copy(hid_t fapl, hbool_t new_format) /* Move a group across groups in the same file while renaming it. */ if(H5Lcopy(grp_1, "group_copy", grp_2, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR /* Open the group just moved to the new location. */ if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Verify that the group is also in the original location */ if((moved_grp = H5Gopen2(grp_1, "group_copy", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Use H5Lcopy to create a group in the same location with a different name. */ if(H5Lcopy(grp_2, "group_new_name", H5L_SAME_LOC, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR /* Open the group. */ if((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Verify that the group is also in the original location */ if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Use H5Lcopy to copy to a different location with the same name. */ if(H5Lcopy(grp_2, "group_newer_name", grp_1, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR /* Open the group . */ if((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Verify that the group is still in the previous location */ if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Copy the group while giving long paths. */ if(H5Lcopy(file_a, "/group1/group_newer_name", grp_2, "/group2/group_newest_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR /* Open the group just moved to the new location. */ if((moved_grp = H5Gopen2(grp_2, "group_newest_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Verify that the group is still in all previous original locations */ if((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Gclose(moved_grp) < 0) TEST_ERROR if((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Gclose(moved_grp) < 0) TEST_ERROR if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Gclose(moved_grp) < 0) TEST_ERROR if((moved_grp = H5Gopen2(grp_1, "group_copy", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Gclose(moved_grp) < 0) TEST_ERROR @@ -1432,17 +1432,17 @@ test_copy(hid_t fapl, hbool_t new_format) error: H5_FAILED(); H5E_BEGIN_TRY { - H5Gclose(grp_1); - H5Gclose(grp_2); - H5Gclose(grp_move); + H5Gclose(grp_1); + H5Gclose(grp_2); + H5Gclose(grp_move); H5Gclose(moved_grp); - H5Fclose(file_a); - H5Fclose(file_b); + H5Fclose(file_a); + H5Fclose(file_b); } H5E_END_TRY; return 1; } - + /*------------------------------------------------------------------------- * Function: test_move_preserves * @@ -1608,16 +1608,16 @@ test_move_preserves(hid_t fapl_id, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Pclose(fcpl_id); - H5Pclose(lcpl_id); - H5Pclose(lcpl2_id); + H5Pclose(fcpl_id); + H5Pclose(lcpl_id); + H5Pclose(lcpl2_id); H5Gclose(group_id); H5Fclose(file_id); } H5E_END_TRY; return 1; } /* end test_move_preserves() */ - + /*------------------------------------------------------------------------- * Function: test_deprec * @@ -1640,7 +1640,7 @@ test_deprec(hid_t fapl, hbool_t new_format) hid_t file_id = -1; hid_t group1_id = -1; hid_t group2_id = -1; - H5G_stat_t sb_hard1, sb_hard2, sb_soft1, sb_soft2; + H5G_stat_t sb_hard1, sb_hard2, sb_soft1, sb_soft2; H5G_obj_t obj_type; /* Object type */ hsize_t num_objs; /* Number of objects in a group */ char filename[1024]; @@ -1768,7 +1768,7 @@ error: } /* end test_deprec() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - + /*------------------------------------------------------------------------- * Function: external_link_root * @@ -1788,14 +1788,14 @@ error: static int external_link_root(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - H5L_info_t linfo; /* Link information */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + H5L_info_t linfo; /* Link information */ char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE]; - char filename2[NAME_BUF_SIZE]; - const char *file; /* File from external link */ - const char *path; /* Path from external link */ + char filename1[NAME_BUF_SIZE]; + char filename2[NAME_BUF_SIZE]; + const char *file; /* File from external link */ + const char *path; /* Path from external link */ if(new_format) TESTING("external link to root (w/new group format)") @@ -1824,21 +1824,21 @@ external_link_root(hid_t fapl, hbool_t new_format) /* Check information for external link */ if(H5Lget_info(fid, "ext_link", &linfo, H5P_DEFAULT) < 0) goto error; if(H5L_TYPE_EXTERNAL != linfo.type) { - H5_FAILED(); - HDputs(" Unexpected object type - should have been an external link"); - goto error; + H5_FAILED(); + HDputs(" Unexpected object type - should have been an external link"); + goto error; } if(H5Lget_val(fid, "ext_link", objname, sizeof(objname), H5P_DEFAULT) < 0) TEST_ERROR if(H5Lunpack_elink_val(objname, linfo.u.val_size, NULL, &file, &path) < 0) TEST_ERROR if(HDstrcmp(file, filename1)) { - H5_FAILED(); - HDputs(" External link file name incorrect"); - goto error; + H5_FAILED(); + HDputs(" External link file name incorrect"); + goto error; } if(HDstrcmp(path, "/")) { - H5_FAILED(); - HDputs(" External link path incorrect"); - goto error; + H5_FAILED(); + HDputs(" External link path incorrect"); + goto error; } /* Create external link to object in first file */ @@ -1848,21 +1848,21 @@ external_link_root(hid_t fapl, hbool_t new_format) /* Check information for external link */ if(H5Lget_info(fid, "ext_link", &linfo, H5P_DEFAULT) < 0) goto error; if(H5L_TYPE_EXTERNAL != linfo.type) { - H5_FAILED(); - HDputs(" Unexpected object type - should have been an external link"); - goto error; + H5_FAILED(); + HDputs(" Unexpected object type - should have been an external link"); + goto error; } if(H5Lget_val(fid, "ext_link", objname, sizeof(objname), H5P_DEFAULT) < 0) TEST_ERROR if(H5Lunpack_elink_val(objname, linfo.u.val_size, NULL, &file, &path) < 0) TEST_ERROR if(HDstrcmp(file, filename1)) { - H5_FAILED(); - HDputs(" External link file name incorrect"); - goto error; + H5_FAILED(); + HDputs(" External link file name incorrect"); + goto error; } if(HDstrcmp(path, "/")) { - H5_FAILED(); - HDputs(" External link path incorrect"); - goto error; + H5_FAILED(); + HDputs(" External link path incorrect"); + goto error; } /* Close and re-open file to ensure that data is written to disk */ @@ -1945,14 +1945,14 @@ external_link_root(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid2); - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid2); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_root() */ - + /*------------------------------------------------------------------------- * Function: external_link_path * @@ -1973,11 +1973,11 @@ external_link_root(hid_t fapl, hbool_t new_format) static int external_link_path(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1), gid2 = (-1); /* Group IDs */ char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE]; - char filename2[NAME_BUF_SIZE]; + char filename1[NAME_BUF_SIZE]; + char filename2[NAME_BUF_SIZE]; if(new_format) TESTING("external link to object on path (w/new group format)") @@ -2053,14 +2053,14 @@ external_link_path(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid2); - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid2); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_path() */ - + /*------------------------------------------------------------------------- * Function: external_link_mult * @@ -2081,13 +2081,13 @@ external_link_path(hid_t fapl, hbool_t new_format) static int external_link_mult(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1), fid2 = (-1); /* File IDs */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + hid_t fid = (-1), fid2 = (-1); /* File IDs */ + hid_t gid = (-1), gid2 = (-1); /* Group IDs */ char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - filename4[NAME_BUF_SIZE]; /* Names of files to externally link across */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + filename4[NAME_BUF_SIZE]; /* Names of files to externally link across */ if(new_format) TESTING("external links across multiple files (w/new group format)") @@ -2217,14 +2217,14 @@ external_link_mult(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid2); - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid2); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_mult() */ - + /*------------------------------------------------------------------------- * Function: external_link_self * @@ -2244,13 +2244,13 @@ external_link_mult(hid_t fapl, hbool_t new_format) static int external_link_self(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - hid_t lcpl_id = (-1); /* Link Creation Property List ID */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + hid_t lcpl_id = (-1); /* Link Creation Property List ID */ char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE]; - char filename2[NAME_BUF_SIZE]; - char filename3[NAME_BUF_SIZE]; + char filename1[NAME_BUF_SIZE]; + char filename2[NAME_BUF_SIZE]; + char filename3[NAME_BUF_SIZE]; if(new_format) TESTING("external link to self (w/new group format)") @@ -2365,15 +2365,15 @@ external_link_self(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose(gid2); - H5Gclose(gid); - H5Pclose(lcpl_id); - H5Fclose(fid); + H5Gclose(gid2); + H5Gclose(gid); + H5Pclose(lcpl_id); + H5Fclose(fid); } H5E_END_TRY; return -1; } /* end external_link_self() */ - + /*------------------------------------------------------------------------- * Function: external_link_pingpong * @@ -2401,11 +2401,11 @@ external_link_self(hid_t fapl, hbool_t new_format) static int external_link_pingpong(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1), gid2 = (-1); /* Group IDs */ char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ if(new_format) TESTING("external links back and forth (w/new group format)") @@ -2488,14 +2488,14 @@ external_link_pingpong(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose(gid2); - H5Gclose(gid); - H5Fclose(fid); + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(fid); } H5E_END_TRY; return -1; } /* end external_link_pingpong() */ - + /*------------------------------------------------------------------------- * Function: external_link_toomany * @@ -2536,11 +2536,11 @@ external_link_pingpong(hid_t fapl, hbool_t new_format) static int external_link_toomany(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1), gid2 = (-1); /* Group IDs */ char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ if(new_format) TESTING("too many external links (w/new group format)") @@ -2603,9 +2603,9 @@ external_link_toomany(hid_t fapl, hbool_t new_format) gid = H5Gopen2(fid, "link1", H5P_DEFAULT); } H5E_END_TRY; if (gid >= 0) { - H5_FAILED(); - HDprintf("%d: Should have failed for sequence of too many nested links.", __LINE__); - goto error; + H5_FAILED(); + HDprintf("%d: Should have failed for sequence of too many nested links.", __LINE__); + goto error; } /* Open object through external link */ @@ -2632,14 +2632,14 @@ external_link_toomany(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid2); - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid2); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_toomany() */ - + /*------------------------------------------------------------------------- * Function: external_link_dangling * @@ -2660,12 +2660,12 @@ external_link_toomany(hid_t fapl, hbool_t new_format) static int external_link_dangling(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ hid_t rid = (-1); /* Root Group ID */ hid_t status = (-1); /* Status */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ if(new_format) TESTING("dangling external links (w/new group format)") @@ -2704,9 +2704,9 @@ external_link_dangling(hid_t fapl, hbool_t new_format) gid = H5Gopen2(fid, "no_file", H5P_DEFAULT); } H5E_END_TRY; if (gid >= 0) { - H5_FAILED(); - HDputs(" Should have failed for sequence of too many nested links."); - goto error; + H5_FAILED(); + HDputs(" Should have failed for sequence of too many nested links."); + goto error; } /* Open object through dangling object external link */ @@ -2714,9 +2714,9 @@ external_link_dangling(hid_t fapl, hbool_t new_format) gid = H5Gopen2(fid, "no_object", H5P_DEFAULT); } H5E_END_TRY; if (gid >= 0) { - H5_FAILED(); - HDputs(" Should have failed for sequence of too many nested links."); - goto error; + H5_FAILED(); + HDputs(" Should have failed for sequence of too many nested links."); + goto error; } /* Try to get name of object by index through dangling file external link */ @@ -2740,22 +2740,22 @@ external_link_dangling(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_dangling() */ - + /*------------------------------------------------------------------------- * Function: external_link_prefix * * Purpose: 1. target link: "extlinks2" - * 2. main file: "extlinks0" - * 3. target file: "tmp/extlinks2" - * 4. Set up external link prefix via H5Pset_elink_prefix() to be "tmp" - * Should be able to access the target file in tmp directory via the prefix set - * by H5Pset_elink_prefix() + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks2" + * 4. Set up external link prefix via H5Pset_elink_prefix() to be "tmp" + * Should be able to access the target file in tmp directory via the prefix set + * by H5Pset_elink_prefix() * * * Return: Success: 0 @@ -2771,12 +2771,12 @@ external_link_dangling(hid_t fapl, hbool_t new_format) static int external_link_prefix(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - hid_t gapl_id = (-1); - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE]; + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + hid_t gapl_id = (-1); + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE]; if(new_format) TESTING("external links via H5Pset_elink_prefix()(w/new group format)") @@ -2790,7 +2790,7 @@ external_link_prefix(hid_t fapl, hbool_t new_format) /* create tmp directory and get current working directory path */ if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) - TEST_ERROR + TEST_ERROR /* set up name for target file: "tmp/extlinks2" */ h5_fixname(FILENAME[17], fapl, filename3, sizeof filename3); @@ -2821,9 +2821,9 @@ external_link_prefix(hid_t fapl, hbool_t new_format) /* should be able to find the target file from pathnames set via H5Pset_elink_prefix() */ if (gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in tmp directory."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in tmp directory."); + goto error; } /* closing for main file */ @@ -2835,20 +2835,20 @@ external_link_prefix(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_prefix() */ - + /*------------------------------------------------------------------------- * Function: external_link_abs_mainpath: test 3 * * Purpose: 1. target link: "extlinks3" - * 2. main file: Linux:"/CWD/tmp/extlinks0"; Windows: ":/CWD/tmp/extlinks0" - * 3. target file: "tmp/extlinks3" - * Should be able to access the target file via the main file's absolute path + * 2. main file: Linux:"/CWD/tmp/extlinks0"; Windows: ":/CWD/tmp/extlinks0" + * 3. target file: "tmp/extlinks3" + * Should be able to access the target file via the main file's absolute path * * Return: Success: 0 * Failure: -1 @@ -2863,13 +2863,13 @@ external_link_prefix(hid_t fapl, hbool_t new_format) static int external_link_abs_mainpath(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; if(new_format) TESTING("external links via main file's absolute path (w/new group format)") @@ -2887,7 +2887,7 @@ external_link_abs_mainpath(hid_t fapl, hbool_t new_format) /* * set up name for main file: - * Linux: "/CWD/tmp/extlinks0" + * Linux: "/CWD/tmp/extlinks0" * Window: ":/CWD/tmp/extlinks0" */ fix_ext_filename(tmpname, cwdpath, FILENAME[13]); @@ -2915,9 +2915,9 @@ external_link_abs_mainpath(hid_t fapl, hbool_t new_format) /* should be able to find the target file from absolute path set for main file */ if(gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in tmp directory."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in tmp directory."); + goto error; } /* closing for main file */ @@ -2929,20 +2929,20 @@ external_link_abs_mainpath(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_abs_mainpath() */ - + /*------------------------------------------------------------------------- * Function: external_link_rel_mainpath: test 4 * - * Purpose: 1. target link: "extlinks4" - * 2. main file: "tmp/extlinks0" - * 3. target file: "tmp/extlinks4" - * Should be able to access the target file via the main file's CWD+relative path + * Purpose: 1. target link: "extlinks4" + * 2. main file: "tmp/extlinks0" + * 3. target file: "tmp/extlinks4" + * Should be able to access the target file via the main file's CWD+relative path * * Return: Success: 0 * Failure: -1 @@ -2957,11 +2957,11 @@ external_link_abs_mainpath(hid_t fapl, hbool_t new_format) static int external_link_rel_mainpath(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE]; + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE]; if(new_format) TESTING("external links via main file's CWD + relative path(w/new group format)") @@ -3001,9 +3001,9 @@ external_link_rel_mainpath(hid_t fapl, hbool_t new_format) /* should be able to find the target file from the main file's relative pathname */ if (gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in current working directory"); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in current working directory"); + goto error; } /* closing for main file */ @@ -3015,19 +3015,19 @@ external_link_rel_mainpath(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_rel_mainpath() */ - + /*------------------------------------------------------------------------- * Function: external_link_cwd: test 5 * * Purpose: 1. target link: "extlinks5" - * 2. main file: Linux:"/CWD/tmp/extlinks0"; Window: ":/CWD/tmp/extlinks0" - * 2. target file: "extlinks5" - * Should be able to access the target file in the current working directory + * 2. main file: Linux:"/CWD/tmp/extlinks0"; Window: ":/CWD/tmp/extlinks0" + * 2. target file: "extlinks5" + * Should be able to access the target file in the current working directory * * * Return: Success: 0 @@ -3043,11 +3043,11 @@ external_link_rel_mainpath(hid_t fapl, hbool_t new_format) static int external_link_cwd(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], cwdpath[NAME_BUF_SIZE]; @@ -3065,7 +3065,7 @@ external_link_cwd(hid_t fapl, hbool_t new_format) /* * set up name for main file: - * Linux: "/CWD/tmp/extlinks0" + * Linux: "/CWD/tmp/extlinks0" * Windows: ":/CWD/tmp/extlinks0" */ fix_ext_filename(tmpname, cwdpath, FILENAME[13]); @@ -3093,9 +3093,9 @@ external_link_cwd(hid_t fapl, hbool_t new_format) /* should be able to find the target file from the current working directory */ if(gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in current working directory"); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in current working directory"); + goto error; } /* closing for main file */ @@ -3107,21 +3107,21 @@ external_link_cwd(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_cwd() */ - + /*------------------------------------------------------------------------- * Function: external_link_abstar: test 6 * * Purpose: 1. target link: Linux:"/CWD/tmp/extlinks6"; Windows:":/CWD/tmp/extlinks6" - * 2. main file: "extlinks0" - * 3. target file: "tmp/extlinks6" - * Should be able to access the target file's absolute path + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks6" + * Should be able to access the target file's absolute path * * Return: Success: 0 * Failure: -1 @@ -3136,12 +3136,12 @@ external_link_cwd(hid_t fapl, hbool_t new_format) static int external_link_abstar(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], cwdpath[NAME_BUF_SIZE]; if(new_format) @@ -3159,7 +3159,7 @@ external_link_abstar(hid_t fapl, hbool_t new_format) /* * set up name for external linked target file: * Linux: "/CWD/tmp/extlinks6" - * Windows: ":/CWD/tmp/extlinks6" + * Windows: ":/CWD/tmp/extlinks6" */ fix_ext_filename(tmpname, cwdpath, FILENAME[23]); h5_fixname(tmpname, fapl, filename2, sizeof filename2); @@ -3189,9 +3189,9 @@ external_link_abstar(hid_t fapl, hbool_t new_format) /* should be able to find the target file with abolute path */ if(gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in tmp directory."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in tmp directory."); + goto error; } /* closing for main file */ @@ -3203,8 +3203,8 @@ external_link_abstar(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_abstar() */ @@ -3213,9 +3213,9 @@ external_link_abstar(hid_t fapl, hbool_t new_format) * Function: external_link_abstar_cur: test 7 * * Purpose: 1. target link: Linux: "/CWD/tmp/extlinks7"; Windows: ":/CWD/tmp/extlinks7" - * 2. main file: "extlinks0" - * 3. target file: "extlinks7" - * Should be able to access the target file via the main file's CWD. + * 2. main file: "extlinks0" + * 3. target file: "extlinks7" + * Should be able to access the target file via the main file's CWD. * * Return: Success: 0 * Failure: -1 @@ -3230,13 +3230,13 @@ external_link_abstar(hid_t fapl, hbool_t new_format) static int external_link_abstar_cur(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; if(new_format) TESTING("external links via main file's CWD (w/new group format)") @@ -3256,7 +3256,7 @@ external_link_abstar_cur(hid_t fapl, hbool_t new_format) /* * set up name for external linked target file: * Linux: "/CWD/tmp/extlinks7" - * Windows: ":/CWD/tmp/extlinks7" + * Windows: ":/CWD/tmp/extlinks7" */ fix_ext_filename(tmpname, cwdpath, FILENAME[25]); h5_fixname(tmpname, fapl, filename2, sizeof filename2); @@ -3283,9 +3283,9 @@ external_link_abstar_cur(hid_t fapl, hbool_t new_format) /* should be able to find the target file from main file's current working directory */ if (gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in current working directory."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in current working directory."); + goto error; } /* closing for main file */ @@ -3297,20 +3297,20 @@ external_link_abstar_cur(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_abstar_cur() */ - + /*------------------------------------------------------------------------- * Function: external_link_reltar: test 8 * * Purpose: 1. target link: Linux:"tmp/extlinks8" - * 2. main file: "extlinks0" - * 3. target file: "tmp/extlinks8" - * Should be able to access the target file via the main file's CWD+ target's relative path + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks8" + * Should be able to access the target file via the main file's CWD+ target's relative path * * Return: Success: 0 * Failure: -1 @@ -3325,10 +3325,10 @@ external_link_abstar_cur(hid_t fapl, hbool_t new_format) static int external_link_reltar(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE]; if(new_format) TESTING("external links via main file's CWD + target's relative path(w/new group format)") @@ -3363,9 +3363,9 @@ external_link_reltar(hid_t fapl, hbool_t new_format) /* Open object through external link */ if((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) { - H5_FAILED(); - HDputs(" Should have found the file in tmp directory."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in tmp directory."); + goto error; } /* end if */ /* closing for main file */ @@ -3377,22 +3377,22 @@ external_link_reltar(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_reltar() */ - + /*------------------------------------------------------------------------- * Function: external_link_chdir: test 9 * * Purpose: - * 1. target link: "extlinks9" - * 2. main file: "extlinks0" - * 3. target file" "tmp/extlinks9" - * 3. chdir "tmp" - * Should be able to access the target file in current working directory + * 1. target link: "extlinks9" + * 2. main file: "extlinks0" + * 3. target file" "tmp/extlinks9" + * 3. chdir "tmp" + * Should be able to access the target file in current working directory * * Return: Success: 0 * Failure: -1 @@ -3407,11 +3407,11 @@ external_link_reltar(hid_t fapl, hbool_t new_format) static int external_link_chdir(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE]; + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE]; if(new_format) TESTING("external links via chdir and found in current working directory (w/new group format)") @@ -3460,9 +3460,9 @@ external_link_chdir(hid_t fapl, hbool_t new_format) * main file's current working directory + pathname of external linked targetfile */ if (gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in tmp directory."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in tmp directory."); + goto error; } /* closing for main file */ @@ -3474,28 +3474,28 @@ external_link_chdir(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_chdir() */ - + /*------------------------------------------------------------------------- * Function: external_set_elink_fapl1: test 10 * * Purpose: To verify that the external linked target file with physical layout - * different from the parent can be successfully opened. - * - * 1. target link: "extlinks16" - * 2. target file: "extlinks16" - * 3. main file: Linux:"/CWD/tmp/extlinks0"; Window: ":/CWD/tmp/extlinks0" - * 4. Create target file A to be a "family" file: extlinks16A - * 4. Create target file B to be a "multi" file: extlinks16B - * 5. Create external link from main file to target file A: ext_linkA->extlinks16A:/A - * 5. Create external link from main file to target file B: ext_linkB->extlinks16B:/B - * 6. Should succeed in opening the target object: ext_extA - * 6. Should succeed in opening the target object: ext_extB + * different from the parent can be successfully opened. + * + * 1. target link: "extlinks16" + * 2. target file: "extlinks16" + * 3. main file: Linux:"/CWD/tmp/extlinks0"; Window: ":/CWD/tmp/extlinks0" + * 4. Create target file A to be a "family" file: extlinks16A + * 4. Create target file B to be a "multi" file: extlinks16B + * 5. Create external link from main file to target file A: ext_linkA->extlinks16A:/A + * 5. Create external link from main file to target file B: ext_linkB->extlinks16B:/B + * 6. Should succeed in opening the target object: ext_extA + * 6. Should succeed in opening the target object: ext_extB * * Return: Success: 0 * Failure: -1 @@ -3510,22 +3510,22 @@ external_link_chdir(hid_t fapl, hbool_t new_format) static int external_set_elink_fapl1(hid_t fapl, hbool_t new_format) { - hid_t fid=(-1); - hid_t fidA=(-1), fidB=(-1); - hid_t gidA=(-1), gidB=(-1); - hid_t oidA=(-1), oidB=(-1); - char filename1[NAME_BUF_SIZE], - filename2A[NAME_BUF_SIZE], - filename2B[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], + hid_t fid=(-1); + hid_t fidA=(-1), fidB=(-1); + hid_t gidA=(-1), gidB=(-1); + hid_t oidA=(-1), oidB=(-1); + char filename1[NAME_BUF_SIZE], + filename2A[NAME_BUF_SIZE], + filename2B[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], cwdpath[NAME_BUF_SIZE]; - hid_t fam_fapl=-1, multi_fapl=-1; - hid_t lapl_idA=-1, lapl_idB=-1; - H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; + hid_t fam_fapl=-1, multi_fapl=-1; + hid_t lapl_idA=-1, lapl_idB=-1; + H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; + hid_t memb_fapl[H5FD_MEM_NTYPES]; char sv[H5FD_MEM_NTYPES][64]; - const char *memb_name[H5FD_MEM_NTYPES]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; + const char *memb_name[H5FD_MEM_NTYPES]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; if(new_format) TESTING("H5Pset/get_elink_fapl() with different physical layouts (w/new group format)") @@ -3533,11 +3533,11 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) TESTING("H5Pset/get_elink_fapl() with different physical layouts") if((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) - TEST_ERROR + TEST_ERROR /* * set up name for main file: - * Linux: "/CWD/tmp/extlinks0" + * Linux: "/CWD/tmp/extlinks0" * Windows: ":/CWD/tmp/extlinks0" */ fix_ext_filename(tmpname, cwdpath, FILENAME[13]); @@ -3560,8 +3560,8 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) HDmemset(sv, 0, sizeof sv); for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { - memb_map[mt] = H5FD_MEM_SUPER; - memb_fapl[mt] = H5P_DEFAULT; + memb_map[mt] = H5FD_MEM_SUPER; + memb_fapl[mt] = H5P_DEFAULT; } /* end for */ memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; @@ -3621,10 +3621,10 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) /* Create external link to target file A:/A */ if(H5Lcreate_external(filename2A, "/A", fid, "ext_linkA", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR /* Create external link to target file B:/B */ if(H5Lcreate_external(filename2B, "/B", fid, "ext_linkB", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + TEST_ERROR /* Set file access property list for link access to use the family driver */ if((lapl_idA = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR @@ -3635,9 +3635,9 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) /* should succeed in opening the target object A in the current working directory */ if (oidA < 0) { - H5_FAILED(); - HDputs(" Should succeed in opening family target file A in current working directory"); - goto error; + H5_FAILED(); + HDputs(" Should succeed in opening family target file A in current working directory"); + goto error; } /* Set file access property list for link access to use the multi driver */ @@ -3649,9 +3649,9 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) /* should succeed in opening the target object B in the current working directory */ if (oidB < 0) { - H5_FAILED(); - HDputs(" Should succeed in opening multi target file B in current working directory"); - goto error; + H5_FAILED(); + HDputs(" Should succeed in opening multi target file B in current working directory"); + goto error; } /* closing */ @@ -3668,38 +3668,38 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Pclose (lapl_idA); - H5Pclose (lapl_idB); - H5Pclose (fam_fapl); - H5Pclose (multi_fapl); - H5Gclose (gidA); - H5Gclose (gidB); - H5Oclose (oidA); - H5Oclose (oidB); - H5Fclose (fid); + H5Pclose (lapl_idA); + H5Pclose (lapl_idB); + H5Pclose (fam_fapl); + H5Pclose (multi_fapl); + H5Gclose (gidA); + H5Gclose (gidB); + H5Oclose (oidA); + H5Oclose (oidB); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_set_elink_fapl1() */ - + /*------------------------------------------------------------------------- * Function: external_set_elink_fapl2: test 11 * * Purpose: To verify that processing done to the external linked target object is - * correctly handled when the parent and target files have the same - * physical layout but different access methods. - * - * 1. target link: "extlinks17" - * 2. target file: "extlinks17" - * 3. main file: Linux:"/CWD/tmp/extlinks0"; Window: ":/CWD/tmp/extlinks0" - * 4. Create target file to be a "core" file:/A/Dataset - * 5. Create external link from main file to target file:ext_link->target file:/A/Dataset - * 6. Set the file access property list of the link access to use "core" file without - * backing store - * 6. Should succeed in opening the target dataset: ext_link - * 7. Write data to the target dataset - * 8. On closing, the file size of target should be the same as before since - * it is opened without backing store. + * correctly handled when the parent and target files have the same + * physical layout but different access methods. + * + * 1. target link: "extlinks17" + * 2. target file: "extlinks17" + * 3. main file: Linux:"/CWD/tmp/extlinks0"; Window: ":/CWD/tmp/extlinks0" + * 4. Create target file to be a "core" file:/A/Dataset + * 5. Create external link from main file to target file:ext_link->target file:/A/Dataset + * 6. Set the file access property list of the link access to use "core" file without + * backing store + * 6. Should succeed in opening the target dataset: ext_link + * 7. Write data to the target dataset + * 8. On closing, the file size of target should be the same as before since + * it is opened without backing store. * * Return: Success: 0 * Failure: -1 @@ -3714,17 +3714,17 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) static int external_set_elink_fapl2(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ hid_t core_fapl = -1, space = -1, dset = -1, did = -1, dapl_id = -1, dcpl = -1; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], cwdpath[NAME_BUF_SIZE]; hsize_t dims[2]; - int points[NUM40][NUM40]; - h5_stat_size_t filesize, new_filesize; - int i, j, n; + int points[NUM40][NUM40]; + h5_stat_size_t filesize, new_filesize; + int i, j, n; if(new_format) TESTING("H5Pset/get_elink_fapl() with same physical layout (w/new group format)") @@ -3736,7 +3736,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* * set up name for main file: - * Linux: "/CWD/tmp/extlinks0" + * Linux: "/CWD/tmp/extlinks0" * Windows: ":/CWD/tmp/extlinks0" */ fix_ext_filename(tmpname, cwdpath, FILENAME[13]); @@ -3769,7 +3769,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* create "Dataset" in group "A" of target file */ if((dset = H5Dcreate2(gid, "Dataset", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - TEST_ERROR + TEST_ERROR /* closing for target file */ if(H5Pclose(dcpl) < 0) TEST_ERROR @@ -3829,39 +3829,39 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Pclose(dcpl); - H5Sclose(space); - H5Dclose(dset); - H5Pclose(core_fapl); - H5Pclose(dapl_id); - H5Dclose(did); - H5Gclose(gid); - H5Fclose(fid); + H5Pclose(dcpl); + H5Sclose(space); + H5Dclose(dset); + H5Pclose(core_fapl); + H5Pclose(dapl_id); + H5Dclose(did); + H5Gclose(gid); + H5Fclose(fid); } H5E_END_TRY; return -1; } /* end external_set_elink_fapl2() */ - + /*------------------------------------------------------------------------- * Function: external_set_elink_fapl3: test 12 * * Purpose: To verify that the file access property list for link access is - * set and closed correctly. - * - * 1. Create fapl for core driver - * 2. Create fapl for stdio driver - * 3. Set link access's fapl to use stdio driver - * 4. Verify that link access's fapl is the stdio driver - * 5. Reset the link access' fapl to use core driver - * 6. H5Pcopy() the link access - * 7. Get the fapl property value of the original link access - * 8. Close the original link access - * 9. H5Pclose() fapl should fail since closing in step #8 should also close its fapl - * 10. Verify that the copied link access's fapl is the core driver - * 11. Get the fapl property value of the copied link access - * 12. H5Premove() the fapl property from the copied link access - * 13. H5Pclose() fapl set in the copied link access should fail since the - * removal in #12 should also close its fapl + * set and closed correctly. + * + * 1. Create fapl for core driver + * 2. Create fapl for stdio driver + * 3. Set link access's fapl to use stdio driver + * 4. Verify that link access's fapl is the stdio driver + * 5. Reset the link access' fapl to use core driver + * 6. H5Pcopy() the link access + * 7. Get the fapl property value of the original link access + * 8. Close the original link access + * 9. H5Pclose() fapl should fail since closing in step #8 should also close its fapl + * 10. Verify that the copied link access's fapl is the core driver + * 11. Get the fapl property value of the copied link access + * 12. H5Premove() the fapl property from the copied link access + * 13. H5Pclose() fapl set in the copied link access should fail since the + * removal in #12 should also close its fapl * * Return: Success: 0 * Failure: -1 @@ -3877,7 +3877,7 @@ static int external_set_elink_fapl3(hbool_t new_format) { hid_t core_fapl = -1, stdio_fapl = -1; - hid_t lapl_id = -1, new_lapl_id = -1, l_fapl = -1, out_fapl; + hid_t lapl_id = -1, new_lapl_id = -1, l_fapl = -1, out_fapl; if(new_format) TESTING("H5Pset/get_fapl() (w/new group format)") @@ -3945,7 +3945,7 @@ external_set_elink_fapl3(hbool_t new_format) return -1; } /* end external_set_elink_fapl3() */ - + /*------------------------------------------------------------------------- * Function: external_set_elink_acc_flags * @@ -4166,7 +4166,7 @@ external_set_elink_acc_flags(const char *env_h5_drvr, hid_t fapl, hbool_t new_fo return -1; } /* end external_set_elink_acc_flags() */ - + /*------------------------------------------------------------------------- * Function: external_set_elink_cb * @@ -4242,7 +4242,7 @@ external_set_elink_cb(hid_t fapl, hbool_t new_format) op_data.target_file = filename2; /* Core file driver has issues when used as the member file driver for a family file */ /* Family file driver cannot be used with family or multi drivers for member files */ - /* Also disable parallel member drivers, because H5F_HAS_FEATURE(H5FD_FEAT_HAS_MPI) + /* Also disable parallel member drivers, because H5F_HAS_FEATURE(H5FD_FEAT_HAS_MPI) would report FALSE, causing problems */ base_driver = H5Pget_driver(fapl); op_data.base_fapl = (base_driver == H5FD_FAMILY || base_driver == H5FD_MULTI @@ -4333,7 +4333,7 @@ external_set_elink_cb(hid_t fapl, hbool_t new_format) return -1; } /* end external_set_elink_cb() */ - + /*------------------------------------------------------------------------- * Function: external_reset_register * @@ -4394,17 +4394,17 @@ external_reset_register(void) return -1; } /* end external_reset_register() */ - + #ifdef H5_HAVE_WINDOW_PATH /*------------------------------------------------------------------------- * Function: external_link_win1 * * Purpose: - * 1. target link: "/CWD/tmp/extlinks10" - * 2. main file: "extlinks0" - * 3. target file: "extlinks10" - * Should be able to find the target file via main file's current drive/rel path + * 1. target link: "/CWD/tmp/extlinks10" + * 2. main file: "extlinks0" + * 3. target file: "extlinks10" + * Should be able to find the target file via main file's current drive/rel path * * Return: Success: 0 * Failure: -1 @@ -4419,12 +4419,12 @@ external_reset_register(void) static int external_link_win1(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], cwdpath[NAME_BUF_SIZE]; if(new_format) @@ -4469,9 +4469,9 @@ external_link_win1(hid_t fapl, hbool_t new_format) /* should be able to find the target file via main file's CWD*/ if(gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in CWD."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in CWD."); + goto error; } /* closing for main file */ @@ -4483,21 +4483,21 @@ external_link_win1(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_win1() */ - + /*------------------------------------------------------------------------- * Function: external_link_win2 * * Purpose: - * 1. target link: "/CWD/tmp/extlinks11" - * 2. main file: "extlinks0" - * 3. target file: "tmp/extlinks11" - * Should be able to access the target file directly (rel drive/abs path) + * 1. target link: "/CWD/tmp/extlinks11" + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks11" + * Should be able to access the target file directly (rel drive/abs path) * * Return: Success: 0 * Failure: -1 @@ -4512,12 +4512,12 @@ external_link_win1(hid_t fapl, hbool_t new_format) static int external_link_win2(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], cwdpath[NAME_BUF_SIZE]; if(new_format) @@ -4563,9 +4563,9 @@ external_link_win2(hid_t fapl, hbool_t new_format) /* should be able to find the target file directly */ if(gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in tmp."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in tmp."); + goto error; } /* closing for main file */ @@ -4577,21 +4577,21 @@ external_link_win2(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_win2() */ - + /*------------------------------------------------------------------------- * Function: external_link_win3 * * Purpose: - * 1. target link: ":tmp/extlinks12" - * 2. main file: "extlinks0" - * 3. target file: "tmp/extlinks12" - * Should be able to access the target file directly (abs drive/rel path) + * 1. target link: ":tmp/extlinks12" + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks12" + * Should be able to access the target file directly (abs drive/rel path) * * Return: Success: 0 * Failure: -1 @@ -4606,13 +4606,13 @@ external_link_win2(hid_t fapl, hbool_t new_format) static int external_link_win3(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - int drive=0; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE]; + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + int drive=0; + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE]; if(new_format) TESTING("external links via target's abs drive/rel path directly (windows)(w/new group format)") @@ -4656,9 +4656,9 @@ external_link_win3(hid_t fapl, hbool_t new_format) /* should be able to find the target file directly */ if (gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in tmp."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in tmp."); + goto error; } /* closing for main file */ @@ -4670,20 +4670,20 @@ external_link_win3(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_win3() */ - + /*------------------------------------------------------------------------- * Function: external_link_win4 * * Purpose: - * 1. target link: ":extlinks13" - * 2. main file: ":tmp/extlinks0" - * 3. target file: tmp/extlinks13 - * Should be able to access the target file via main file's abs drive/rel path + * 1. target link: ":extlinks13" + * 2. main file: ":tmp/extlinks0" + * 3. target file: tmp/extlinks13 + * Should be able to access the target file via main file's abs drive/rel path * * Return: Success: 0 * Failure: -1 @@ -4698,13 +4698,13 @@ external_link_win3(hid_t fapl, hbool_t new_format) static int external_link_win4(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - int drive=0; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE]; + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + int drive=0; + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE]; if(new_format) TESTING("external links via main file's abs drive/rel path (windows)(w/new group format)") @@ -4745,9 +4745,9 @@ external_link_win4(hid_t fapl, hbool_t new_format) /* should be able to find the target file via main file's absolute drive/relative path */ if (gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in CWD."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in CWD."); + goto error; } /* closing for main file */ @@ -4759,21 +4759,21 @@ external_link_win4(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_win4() */ - + /*------------------------------------------------------------------------- * Function: external_link_win5 * * Purpose: - * 1. target link: ":tmp/extlinks14" - * 2. main file: "/CWD/extlinks0" - * 3. target file: "tmp/extlinks14" - * Should be able to access the target file via main file's relative drive/absolute path + * 1. target link: ":tmp/extlinks14" + * 2. main file: "/CWD/extlinks0" + * 3. target file: "tmp/extlinks14" + * Should be able to access the target file via main file's relative drive/absolute path * * Return: Success: 0 * Failure: -1 @@ -4788,13 +4788,13 @@ external_link_win4(hid_t fapl, hbool_t new_format) static int external_link_win5(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - int drive=0; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + int drive=0; + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], cwdpath[NAME_BUF_SIZE]; if(new_format) @@ -4813,6 +4813,8 @@ external_link_win5(hid_t fapl, hbool_t new_format) h5_fixname(tmpname, fapl, filename1, sizeof filename1); /* set up name for target link: ":tmp/extlinks14" */ + if (drive >= 26) + drive -= 2; /* account for drive Z HDsnprintf(tmpname, sizeof(tmpname), "%c:%s", ((drive+1)+'A'-1), FILENAME[35]); h5_fixname(tmpname, fapl, filename2, sizeof filename2); @@ -4841,9 +4843,9 @@ external_link_win5(hid_t fapl, hbool_t new_format) /* should be able to find the target file via main file's rel drive/abs path */ if(gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in CWD."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in CWD."); + goto error; } /* closing for main file */ @@ -4855,21 +4857,21 @@ external_link_win5(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_win5() */ - + /*------------------------------------------------------------------------- * Function: external_link_win6 * * Purpose: - * 1. target link: ":tmp/extlinks15" - * 2. main file: "extlinks0" - * 3. target file: "tmp/extlinks15" - * Should be able to access the target file via target's current drive/rel path + * 1. target link: ":tmp/extlinks15" + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks15" + * Should be able to access the target file via target's current drive/rel path * * Return: Success: 0 * Failure: -1 @@ -4884,13 +4886,13 @@ external_link_win5(hid_t fapl, hbool_t new_format) static int external_link_win6(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - int drive=0; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE]; + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + int drive=0; + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE]; if(new_format) TESTING("external links via target's current drive/rel path (windows)(w/new group format)") @@ -4901,6 +4903,8 @@ external_link_win6(hid_t fapl, hbool_t new_format) if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR drive = HDgetdrive(); + if (drive >= 26) + drive -= 2; /* account for drive Z /* set up name for main file: "extlinks0" */ h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); @@ -4934,9 +4938,9 @@ external_link_win6(hid_t fapl, hbool_t new_format) /* should be able to find the target file via target file's rel path in current drive */ if (gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in tmp."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in tmp."); + goto error; } /* closing for main file */ @@ -4948,13 +4952,13 @@ external_link_win6(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_win6() */ - + /*------------------------------------------------------------------------- * Function: external_link_win7 * @@ -5041,7 +5045,7 @@ external_link_win7(hid_t fapl, hbool_t new_format) return -1; } /* end external_link_win7() */ - + /*------------------------------------------------------------------------- * Function: external_link_win8 * @@ -5133,7 +5137,7 @@ external_link_win8(hid_t fapl, hbool_t new_format) return -1; } /* end external_link_win8() */ - + /*------------------------------------------------------------------------- * Function: external_link_win9 * @@ -5222,7 +5226,7 @@ external_link_win9(hid_t fapl, hbool_t new_format) #endif /* H5_HAVE_WINDOW_PATH */ - + /*------------------------------------------------------------------------- * Function: external_link_recursive * @@ -5241,9 +5245,9 @@ external_link_win9(hid_t fapl, hbool_t new_format) static int external_link_recursive(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char filename1[NAME_BUF_SIZE]; /* Names of files to externally link across */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE]; /* Names of files to externally link across */ if(new_format) TESTING("recursive external links (w/new group format)") @@ -5271,9 +5275,9 @@ external_link_recursive(hid_t fapl, hbool_t new_format) gid = H5Gopen2(fid, "recursive", H5P_DEFAULT); } H5E_END_TRY; if (gid >= 0) { - H5_FAILED(); - HDputs(" Should have failed for recursive external links."); - goto error; + H5_FAILED(); + HDputs(" Should have failed for recursive external links."); + goto error; } /* Close first file */ @@ -5285,13 +5289,13 @@ external_link_recursive(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end external_link_recursive() */ - + /*------------------------------------------------------------------------- * Function: external_link_query * @@ -5311,14 +5315,14 @@ external_link_recursive(hid_t fapl, hbool_t new_format) static int external_link_query(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ const char *file_name; /* Name of the file the external link points to */ const char *object_name; /* Name of the object the external link points to */ - H5O_info_t oi; /* Object information */ + H5O_info_t oi; /* Object information */ H5L_info_t li; /* Link information */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], /* Names of files to externally link across */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], /* Names of files to externally link across */ query_buf[NAME_BUF_SIZE]; /* Buffer to hold query result */ if(new_format) @@ -5341,9 +5345,9 @@ external_link_query(hid_t fapl, hbool_t new_format) if(H5Lget_info(fid, "src", &li, H5P_DEFAULT) < 0) TEST_ERROR if(li.u.val_size != (1 + (HDstrlen(filename2) + 1) + (HDstrlen("/dst") + 1))) TEST_ERROR if (H5L_TYPE_EXTERNAL != li.type) { - H5_FAILED(); - HDputs(" Unexpected link class - should have been an external link"); - goto error; + H5_FAILED(); + HDputs(" Unexpected link class - should have been an external link"); + goto error; } /* Close file */ @@ -5367,9 +5371,9 @@ external_link_query(hid_t fapl, hbool_t new_format) if(H5Lget_info(fid, "src", &li, H5P_DEFAULT) < 0) TEST_ERROR if(li.u.val_size != (1 + (HDstrlen(filename2) + 1) + (HDstrlen("/dst") + 1))) TEST_ERROR if(H5L_TYPE_EXTERNAL != li.type) { - H5_FAILED(); - HDputs(" Unexpected link class - should have been an external link"); - goto error; + H5_FAILED(); + HDputs(" Unexpected link class - should have been an external link"); + goto error; } /* Get information for external link. It should be two strings right after each other */ @@ -5385,9 +5389,9 @@ external_link_query(hid_t fapl, hbool_t new_format) /* Query information about object that external link points to */ if(H5Oget_info_by_name2(fid, "src", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5O_TYPE_GROUP != oi.type) { - H5_FAILED(); - HDputs(" Unexpected object type - should have been a group"); - goto error; + H5_FAILED(); + HDputs(" Unexpected object type - should have been a group"); + goto error; } /* Close first file */ @@ -5415,13 +5419,13 @@ external_link_query(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose(gid); - H5Fclose(fid); + H5Gclose(gid); + H5Fclose(fid); } H5E_END_TRY; return -1; } /* end external_link_query() */ - + /*------------------------------------------------------------------------- * Function: external_link_unlink_compact * @@ -5438,10 +5442,10 @@ error: static int external_link_unlink_compact(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ if(new_format) TESTING("unlinking external link in compact group (w/new group format)") @@ -5500,14 +5504,14 @@ external_link_unlink_compact(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose(gid2); - H5Gclose(gid); - H5Fclose(fid); + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(fid); } H5E_END_TRY; return -1; } /* end external_link_unlink_compact() */ - + /*------------------------------------------------------------------------- * Function: external_link_unlink_dense * @@ -5524,13 +5528,13 @@ error: static int external_link_unlink_dense(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ + hid_t fid = (-1); /* File ID */ hid_t gcpl = (-1); /* Group creation property list ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + hid_t gid = (-1), gid2 = (-1); /* Group IDs */ char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ - unsigned nmsgs; /* Number of messages in group's header */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + unsigned nmsgs; /* Number of messages in group's header */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ unsigned u; /* Local index variable */ @@ -5646,14 +5650,14 @@ external_link_unlink_dense(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose(gid2); - H5Gclose(gid); - H5Fclose(fid); + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(fid); } H5E_END_TRY; return -1; } /* end external_link_unlink_dense() */ - + /*------------------------------------------------------------------------- * Function: external_link_move * @@ -5670,11 +5674,11 @@ error: static int external_link_move(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1), gid2 = (-1); /* Group IDs */ char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ if(new_format) TESTING("move external link (w/new group format)") @@ -5837,14 +5841,14 @@ external_link_move(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose(gid2); - H5Gclose(gid); - H5Fclose(fid); + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(fid); } H5E_END_TRY; return -1; } /* end external_link_move() */ - + /*------------------------------------------------------------------------- * Function: external_link_ride * @@ -5862,13 +5866,13 @@ error: static int external_link_ride(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ + hid_t fid = (-1); /* File ID */ hid_t gcpl = (-1); /* Group creation property list ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + hid_t gid = (-1), gid2 = (-1); /* Group IDs */ char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ - unsigned nmsgs; /* Number of messages in group's header */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + unsigned nmsgs; /* Number of messages in group's header */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ unsigned u; /* Local index variable */ @@ -6023,14 +6027,14 @@ external_link_ride(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { H5Pclose(gcpl); - H5Gclose(gid2); - H5Gclose(gid); - H5Fclose(fid); + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(fid); } H5E_END_TRY; return -1; } /* end external_link_ride() */ - + /*------------------------------------------------------------------------- * Function: external_link_closing * @@ -6052,11 +6056,11 @@ external_link_closing(hid_t fapl, hbool_t new_format) hid_t gid=(-1), tid=(-1), tid2=(-1), sid=(-1), did=(-1); hid_t lcpl_id=(-1); hsize_t dims[2]; - char filename1[NAME_BUF_SIZE], + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - filename4[NAME_BUF_SIZE], /* Names of files to externally link across */ - buf[NAME_BUF_SIZE]; /* misc. buffer */ + filename3[NAME_BUF_SIZE], + filename4[NAME_BUF_SIZE], /* Names of files to externally link across */ + buf[NAME_BUF_SIZE]; /* misc. buffer */ H5L_info_t li; H5O_info_t oi; hobj_ref_t obj_ref; @@ -6263,7 +6267,7 @@ error: return -1; } /* external_link_closing() */ - + /*------------------------------------------------------------------------- * Function: ext_link_endian * @@ -6282,8 +6286,8 @@ error: static int external_link_endian(hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1), gid2 = (-1); /* Group IDs */ hid_t lapl_id = (-1); /* Prop List ID */ const char *pathbuf = H5_get_srcdir(); /* Path to the files */ const char *namebuf; @@ -6331,14 +6335,14 @@ external_link_endian(hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose(gid2); - H5Gclose(gid); - H5Fclose(fid); + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(fid); } H5E_END_TRY; return -1; } - + /*------------------------------------------------------------------------- * Function: external_link_strong * @@ -6360,7 +6364,7 @@ external_link_strong(hid_t fapl, hbool_t new_format) hid_t fid1 = (-1), fid2 = (-1); /* File ID */ hid_t gid1 = (-1), gid2 = (-1); /* Group IDs */ char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; if(new_format) @@ -6423,7 +6427,7 @@ error: return -1; } /* end external_link_strong() */ - + /*------------------------------------------------------------------------- * Function: external_symlink * @@ -6444,17 +6448,17 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) #ifdef H5_HAVE_SYMLINK hid_t file1 = -1, file2 = -1, file3 = -1, file4 = -1, file5 = -1; hid_t group2 = -1, group3 = -1, group4 = -1, group5 = -1; - char filename1[NAME_BUF_SIZE], - filename2a[NAME_BUF_SIZE], - filename2b[NAME_BUF_SIZE], - filename3a[NAME_BUF_SIZE], - filename3b[NAME_BUF_SIZE], - filename4a[NAME_BUF_SIZE], - filename4b[NAME_BUF_SIZE], - filename5a[NAME_BUF_SIZE], - filename5b[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; + char filename1[NAME_BUF_SIZE], + filename2a[NAME_BUF_SIZE], + filename2b[NAME_BUF_SIZE], + filename3a[NAME_BUF_SIZE], + filename3b[NAME_BUF_SIZE], + filename4a[NAME_BUF_SIZE], + filename4b[NAME_BUF_SIZE], + filename5a[NAME_BUF_SIZE], + filename5b[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; hbool_t have_posix_compat_vfd; /* Whether VFD used is compatible w/POSIX I/O calls */ #endif /* H5_HAVE_SYMLINK */ @@ -6612,8 +6616,8 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) PASSED(); } /* end if */ else { - SKIPPED(); - HDputs(" Current VFD doesn't support POSIX I/O calls"); + SKIPPED(); + HDputs(" Current VFD doesn't support POSIX I/O calls"); } /* end else */ return 0; @@ -6639,7 +6643,7 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) #endif /* H5_HAVE_SYMLINK */ } /* end external_symlink() */ - + /*------------------------------------------------------------------------- * Function: external_copy_invalid_object * @@ -6712,7 +6716,7 @@ error: return -1; } /* end external_copy_invalid_object */ - + /*------------------------------------------------------------------------- * Function: external_dont_fail_to_source * @@ -6776,7 +6780,7 @@ error: return -1; } /* end external_dont_fail_to_source */ - + /*------------------------------------------------------------------------- * Function: external_file_cache * @@ -7169,7 +7173,7 @@ error: return -1; } /* end external_file_cache */ - + /*------------------------------------------------------------------------- * Function: external_open_twice * @@ -7405,7 +7409,7 @@ error: return -1; } /* end external_open_twice() */ - + /*------------------------------------------------------------------------- * Function: external_link_with_committed_datatype * @@ -7428,24 +7432,24 @@ error: static int external_link_with_committed_datatype(hid_t fapl, hbool_t new_format) { - hid_t fid1 = -1, fid2 = -1; /* File IDs */ - hid_t gid1 = -1, gid2 = -1; /* Group IDs */ - hid_t tid = -1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t sid2 = -1; /* Dataspace ID */ - hid_t aid = -1; /* Attribute ID */ - hid_t atid = -1; /* Attribute's datatype ID */ - hid_t did = -1; /* Dataset ID */ - hid_t dtid = -1; /* Dataset's datatype ID */ - hid_t dcpl = -1; /* Dataset creation property list */ - int wdata = 99; /* Attribute data written */ - int wbuf[60]; /* Data buffer for writing */ - int rbuf[60]; /* Data buffer for reading */ - int i; /* Local index variable */ - char filename1[NAME_BUF_SIZE]; /* File name for main file */ - char filename2[NAME_BUF_SIZE]; /* File name for target file */ - hsize_t dims[2] = {5, 12}; /* Dimension sizes */ - hsize_t chunks[2] = {3, 7}; /* Chunk sizes */ + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t gid1 = -1, gid2 = -1; /* Group IDs */ + hid_t tid = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t sid2 = -1; /* Dataspace ID */ + hid_t aid = -1; /* Attribute ID */ + hid_t atid = -1; /* Attribute's datatype ID */ + hid_t did = -1; /* Dataset ID */ + hid_t dtid = -1; /* Dataset's datatype ID */ + hid_t dcpl = -1; /* Dataset creation property list */ + int wdata = 99; /* Attribute data written */ + int wbuf[60]; /* Data buffer for writing */ + int rbuf[60]; /* Data buffer for reading */ + int i; /* Local index variable */ + char filename1[NAME_BUF_SIZE]; /* File name for main file */ + char filename2[NAME_BUF_SIZE]; /* File name for target file */ + hsize_t dims[2] = {5, 12}; /* Dimension sizes */ + hsize_t chunks[2] = {3, 7}; /* Chunk sizes */ if(new_format) TESTING("attach committed datatype to external group's attribute/dataset(w/new group format)") @@ -7530,8 +7534,8 @@ external_link_with_committed_datatype(hid_t fapl, hbool_t new_format) /* Initialize data buffers */ for(i = 0; i < 60; i++) { - wbuf[i] = i; - rbuf[i] = 0; + wbuf[i] = i; + rbuf[i] = 0; } /* Create a dataset with the committed datatype in the group */ @@ -7677,13 +7681,13 @@ error: H5Aclose(atid); H5Aclose(dtid); - H5Pclose(dcpl); + H5Pclose(dcpl); } H5E_END_TRY return -1; } /* end external_link_with_committed_datatype() */ - + /*------------------------------------------------------------------------- * Function: ud_hard_links * @@ -7873,12 +7877,12 @@ const H5L_class_t UD_hard_class[1] = {{ static int ud_hard_links(hid_t fapl) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1), gid2 = (-1); /* Group IDs */ H5L_info_t li; /* Link information */ char objname[NAME_BUF_SIZE]; /* Object name */ h5_stat_size_t empty_size; /* Size of an empty file */ - char filename[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; TESTING("user-defined hard link (w/new group format)") @@ -7950,9 +7954,9 @@ ud_hard_links(hid_t fapl) /* UD hard links have no query function, thus return a "link length" of 0 */ if(li.u.val_size != 0) TEST_ERROR if(UD_HARD_TYPE != li.type) { - H5_FAILED(); - HDputs(" Unexpected link class - should have been a UD hard link"); - goto error; + H5_FAILED(); + HDputs(" Unexpected link class - should have been a UD hard link"); + goto error; } /* end if */ /* Unlink the group pointed to by the UD link. It shouldn't be @@ -7983,14 +7987,14 @@ ud_hard_links(hid_t fapl) error: H5E_BEGIN_TRY { - H5Gclose(gid2); - H5Gclose(gid); - H5Fclose(fid); + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(fid); } H5E_END_TRY; return -1; } /* end ud_hard_links() */ - + /*------------------------------------------------------------------------- * Function: UD_rereg_traverse * @@ -8040,11 +8044,11 @@ const H5L_class_t UD_rereg_class[1] = {{ static int ud_link_reregister(hid_t fapl) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - H5L_info_t li; /* Link information */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + H5L_info_t li; /* Link information */ char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; h5_stat_size_t empty_size; /* Size of an empty file */ TESTING("registering a new class for existing UD links (w/new group format)") @@ -8169,14 +8173,14 @@ ud_link_reregister(hid_t fapl) error: H5E_BEGIN_TRY { - H5Gclose(gid2); - H5Gclose(gid); - H5Fclose(fid); + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(fid); } H5E_END_TRY; return -1; } /* end ud_link_reregister() */ - + /*------------------------------------------------------------------------- * Function: ud_callbacks * @@ -8313,12 +8317,12 @@ const H5L_class_t UD_cb_class[1] = {{ static int ud_callbacks(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group ID */ hid_t lcpl = (-1); /* Link Creation PL */ H5L_info_t li; /* Link information */ char ud_target_name[] = UD_CB_TARGET; /* Link target name */ - char filename[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; char query_buf[NAME_BUF_SIZE]; if(new_format) @@ -8426,14 +8430,14 @@ ud_callbacks(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Pclose (lcpl); - H5Gclose (gid); - H5Fclose (fid); + H5Pclose (lcpl); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end ud_callbacks() */ - + /*------------------------------------------------------------------------- * Function: lapl_udata * @@ -8485,12 +8489,12 @@ const H5L_class_t UD_plist_class[1] = {{ static int lapl_udata(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1), gid2 = (-1); /* Group IDs */ hid_t plist_id = (-1); /* Property List ID */ - char group_a_name[NAME_BUF_SIZE]; - char group_b_name[NAME_BUF_SIZE]; - char filename[NAME_BUF_SIZE]; + char group_a_name[NAME_BUF_SIZE]; + char group_b_name[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; if(new_format) TESTING("user data passed through lapl (w/new group format)") @@ -8565,15 +8569,15 @@ lapl_udata(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Pclose (plist_id); - H5Gclose (gid); - H5Gclose (gid2); - H5Fclose (fid); + H5Pclose (plist_id); + H5Gclose (gid); + H5Gclose (gid2); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end lapl_udata() */ - + /*------------------------------------------------------------------------- * Function: ud_link_errors * @@ -8783,10 +8787,10 @@ const H5L_class_t UD_error4_class[1] = {{ static int ud_link_errors(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char group_name[NAME_BUF_SIZE]; - char filename[NAME_BUF_SIZE]; + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char group_name[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; char query_buf[NAME_BUF_SIZE]; H5L_info_t li; /* Link information */ @@ -8900,13 +8904,13 @@ ud_link_errors(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end ud_link_errors() */ - + /*------------------------------------------------------------------------- * Function: lapl_nlinks * @@ -8927,15 +8931,15 @@ error: static int lapl_nlinks(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - hid_t plist = (-1); /* lapl ID */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + hid_t plist = (-1); /* lapl ID */ hid_t tid = (-1), sid = (-1), did = (-1); /* Other IDs */ hid_t gapl = (-1), dapl = (-1), tapl = (-1); /* Other property lists */ char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; size_t nlinks; /* nlinks for H5Pset_nlinks */ - hsize_t dims[2]; + hsize_t dims[2]; if(new_format) TESTING("adjusting nlinks with LAPL (w/new group format)") @@ -9129,21 +9133,21 @@ lapl_nlinks(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Pclose(gapl); - H5Pclose(dapl); - H5Pclose(tapl); - H5Dclose(did); - H5Sclose(sid); - H5Tclose(tid); - H5Gclose(gid2); - H5Gclose(gid); - H5Pclose(plist); - H5Fclose(fid); + H5Pclose(gapl); + H5Pclose(dapl); + H5Pclose(tapl); + H5Dclose(did); + H5Sclose(sid); + H5Tclose(tid); + H5Gclose(gid2); + H5Gclose(gid); + H5Pclose(plist); + H5Fclose(fid); } H5E_END_TRY; return -1; } /* end lapl_nlinks() */ - + /*------------------------------------------------------------------------- * Function: linkinfo * @@ -9160,12 +9164,12 @@ lapl_nlinks(hid_t fapl, hbool_t new_format) static int linkinfo(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group ID */ hid_t tid = (-1); /* Type ID */ hid_t sid = (-1), did = -(1); /* Dataspace and dataset IDs */ H5L_info_t li; /* Link information */ - char filename[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; if(new_format) TESTING("link type field in H5Lget_info (w/new group format)") @@ -9222,15 +9226,15 @@ linkinfo(hid_t fapl, hbool_t new_format) error: H5E_BEGIN_TRY { - H5Tclose (tid); - H5Dclose (did); - H5Gclose (gid); - H5Fclose (fid); + H5Tclose (tid); + H5Dclose (did); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } /* end linkinfo() */ - + /*------------------------------------------------------------------------- * Function: check_all_closed * @@ -9285,7 +9289,7 @@ error: } /* end check_all_closed() */ - + /*------------------------------------------------------------------------- * Function: build_visit_file * @@ -9385,7 +9389,7 @@ error: return -1; } /* end build_visit_file() */ - + /*------------------------------------------------------------------------- * Function: visit_link_cb * @@ -9415,7 +9419,7 @@ visit_link_cb(hid_t H5_ATTR_UNUSED group_id, const char *name, const H5L_info_t return(H5_ITER_CONT); } /* end visit_link_cb() */ - + /*------------------------------------------------------------------------- * Function: link_visit * @@ -9485,7 +9489,7 @@ error: return -1; } /* end link_visit() */ - + /*------------------------------------------------------------------------- * Function: link_visit_by_name * @@ -9563,7 +9567,7 @@ error: return -1; } /* end link_visit_by_name() */ - + /*------------------------------------------------------------------------- * Function: visit_obj_cb * @@ -9593,7 +9597,7 @@ visit_obj_cb(hid_t H5_ATTR_UNUSED group_id, const char *name, const H5O_info_t * return(H5_ITER_CONT); } /* end visit_obj_cb() */ - + /*------------------------------------------------------------------------- * Function: obj_visit * @@ -9663,7 +9667,7 @@ error: return -1; } /* end obj_visit() */ - + /*------------------------------------------------------------------------- * Function: obj_visit_by_name * @@ -9742,7 +9746,7 @@ error: return -1; } /* end obj_visit_by_name() */ - + /*------------------------------------------------------------------------- * Function: visit_obj_stop_cb * @@ -9767,7 +9771,7 @@ visit_obj_stop_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UNUSED *name return(H5_ITER_STOP); } /* end visit_obj_stop_cb() */ - + /*------------------------------------------------------------------------- * Function: obj_visit_stop * @@ -9826,7 +9830,7 @@ error: return -1; } /* end obj_visit_stop() */ - + /*------------------------------------------------------------------------- * Function: link_filters * @@ -9918,7 +9922,7 @@ link_filters(hid_t fapl, hbool_t new_format) int nfilters = 0; H5Z_class2_t filter_class; char name_out[24]; - char filename[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; htri_t tri_ret; herr_t status; @@ -10206,7 +10210,7 @@ error: return -1; } /* end link_filters() */ - + /*------------------------------------------------------------------------- * Function: obj_exists * @@ -10494,7 +10498,7 @@ error: return -1; } /* end obj_exists() */ - + /*------------------------------------------------------------------------- * Function: corder_create_empty * @@ -10511,10 +10515,10 @@ error: static int corder_create_empty(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ - unsigned crt_order_flags; /* Status of creation order info for GCPL */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1); /* Group ID */ + hid_t gcpl_id = (-1); /* Group creation property list ID */ + unsigned crt_order_flags; /* Status of creation order info for GCPL */ herr_t ret; /* Generic return value */ char filename[NAME_BUF_SIZE];/* File name */ @@ -10536,9 +10540,9 @@ corder_create_empty(hid_t fapl) ret = H5Pset_link_creation_order(gcpl_id, H5P_CRT_ORDER_INDEXED); } H5E_END_TRY; if(ret > 0) { - H5_FAILED(); - HDputs(" H5Pset_link_create_order() should have failed for a creation order index with no tracking."); - TEST_ERROR + H5_FAILED(); + HDputs(" H5Pset_link_create_order() should have failed for a creation order index with no tracking."); + TEST_ERROR } /* end if */ /* Set creation order tracking & indexing on group */ @@ -10601,7 +10605,7 @@ error: return -1; } /* end corder_create_empty() */ - + /*------------------------------------------------------------------------- * Function: corder_create_compact * @@ -10619,12 +10623,12 @@ error: static int corder_create_compact(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ + hid_t gcpl_id = (-1); /* Group creation property list ID */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ - unsigned nlinks; /* Number of link messages in group's header */ + unsigned nlinks; /* Number of link messages in group's header */ char objname[NAME_BUF_SIZE]; /* Object name */ char filename[NAME_BUF_SIZE];/* File name */ unsigned u; /* Local index variable */ @@ -10719,7 +10723,7 @@ error: return -1; } /* end corder_create_compact() */ - + /*------------------------------------------------------------------------- * Function: corder_create_dense * @@ -10737,12 +10741,12 @@ error: static int corder_create_dense(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ + hid_t gcpl_id = (-1); /* Group creation property list ID */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ - unsigned nlinks; /* Number of link messages in group's header */ + unsigned nlinks; /* Number of link messages in group's header */ hsize_t name_count; /* # of records in name index */ hsize_t corder_count; /* # of records in creation order index */ char objname[NAME_BUF_SIZE]; /* Object name */ @@ -10852,7 +10856,7 @@ error: return -1; } /* end corder_create_dense() */ - + /*------------------------------------------------------------------------- * Function: corder_transition * @@ -10870,12 +10874,12 @@ error: static int corder_transition(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ + hid_t gcpl_id = (-1); /* Group creation property list ID */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ - unsigned nlinks; /* Number of link messages in group's header */ + unsigned nlinks; /* Number of link messages in group's header */ hsize_t name_count; /* # of records in name index */ hsize_t corder_count; /* # of records in creation order index */ h5_stat_size_t empty_size; /* Size of empty file */ @@ -11081,7 +11085,7 @@ error: return -1; } /* end corder_transition() */ - + /*------------------------------------------------------------------------- * Function: corder_delete * @@ -11100,9 +11104,9 @@ error: static int corder_delete(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ + hid_t gcpl_id = (-1); /* Group creation property list ID */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ hsize_t name_count; /* # of records in name index */ @@ -11122,7 +11126,7 @@ corder_delete(hid_t fapl) /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - /* Creating file with latest format will enable paged aggregation with persistent fs */ + /* Creating file with latest format will enable paged aggregation with persistent fs */ if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ @@ -11210,14 +11214,14 @@ error: return -1; } /* end corder_delete() */ - + /*------------------------------------------------------------------------- * Function: link_info_by_idx_check * * Purpose: Support routine for link_info_by_idx, to verify the link * info is correct for a link * - * Note: This routine assumes that the links have been inserted in the + * Note: This routine assumes that the links have been inserted in the * group in alphabetical order. * * Return: Success: 0 @@ -11369,7 +11373,7 @@ error: return(-1); } /* end link_info_by_idx_check() */ - + /*------------------------------------------------------------------------- * Function: link_info_by_idx * @@ -11387,9 +11391,9 @@ error: static int link_info_by_idx(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1); /* Group ID */ + hid_t gcpl_id = (-1); /* Group creation property list ID */ unsigned hard_link; /* Create hard or soft link? */ unsigned use_index; /* Use index on creation order values */ unsigned max_compact; /* Maximum # of links to store in group compactly */ @@ -11453,7 +11457,7 @@ link_info_by_idx(hid_t fapl) /* Check for creating hard or soft link */ if(hard_link) { - hid_t group_id2; /* Group ID */ + hid_t group_id2; /* Group ID */ /* Create hard link, with group object */ if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -11495,7 +11499,7 @@ link_info_by_idx(hid_t fapl) /* Check for creating hard or soft link */ if(hard_link) { - hid_t group_id2; /* Group ID */ + hid_t group_id2; /* Group ID */ /* Create hard link, with group object */ if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -11554,7 +11558,7 @@ error: return -1; } /* end link_info_by_idx() */ - + /*------------------------------------------------------------------------- * Function: link_info_by_idx_old * @@ -11572,8 +11576,8 @@ error: static int link_info_by_idx_old(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ unsigned hard_link; /* Create hard or soft link? */ H5L_info_t linfo; /* Link info struct */ char objname[NAME_BUF_SIZE]; /* Object name */ @@ -11721,7 +11725,7 @@ error: return -1; } /* end link_info_by_idx_old() */ - + /*------------------------------------------------------------------------- * Function: delete_by_idx * @@ -11739,9 +11743,9 @@ error: static int delete_by_idx(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1); /* Group ID */ + hid_t gcpl_id = (-1); /* Group creation property list ID */ H5_index_t idx_type; /* Type of index to operate on */ H5_iter_order_t order; /* Order within in the index */ unsigned use_index; /* Use index on creation order values */ @@ -11824,7 +11828,7 @@ delete_by_idx(hid_t fapl) /* Create several links, up to limit of compact form */ for(u = 0; u < max_compact; u++) { - hid_t group_id2; /* Group ID */ + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); @@ -11879,7 +11883,7 @@ delete_by_idx(hid_t fapl) /* Create more links, to push group into dense form */ for(u = 0; u < (max_compact * 2); u++) { - hid_t group_id2; /* Group ID */ + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); @@ -11946,7 +11950,7 @@ delete_by_idx(hid_t fapl) /* Create more links, to push group into dense form */ for(u = 0; u < (max_compact * 2); u++) { - hid_t group_id2; /* Group ID */ + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); @@ -12047,7 +12051,7 @@ error: return -1; } /* end delete_by_idx() */ - + /*------------------------------------------------------------------------- * Function: delete_by_idx_old * @@ -12065,8 +12069,8 @@ error: static int delete_by_idx_old(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ H5L_info_t linfo; /* Link info struct */ H5_iter_order_t order; /* Order within in the index */ char objname[NAME_BUF_SIZE]; /* Object name */ @@ -12272,7 +12276,7 @@ error: return -1; } /* end delete_by_idx_old() */ - + /*------------------------------------------------------------------------- * Function: link_iterate_cb * @@ -12349,7 +12353,7 @@ link_iterate_cb(hid_t group_id, const char *link_name, const H5L_info_t *info, } /* end link_iterate_cb() */ #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: group_iterate_cb * @@ -12371,7 +12375,7 @@ group_iterate_cb(hid_t group_id, const char *link_name, void *_op_data) } /* end group_iterate_cb() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - + /*------------------------------------------------------------------------- * Function: link_iterate_fail_cb * @@ -12393,7 +12397,7 @@ link_iterate_fail_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UNUSED *l return(H5_ITER_ERROR); } /* end link_iterate_fail_cb() */ - + /*------------------------------------------------------------------------- * Function: link_iterate_check * @@ -12554,7 +12558,7 @@ error: return(-1); } /* end link_iterate_check() */ - + /*------------------------------------------------------------------------- * Function: link_iterate * @@ -12572,9 +12576,9 @@ error: static int link_iterate(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1); /* Group ID */ + hid_t gcpl_id = (-1); /* Group creation property list ID */ H5_index_t idx_type; /* Type of index to operate on */ H5_iter_order_t order; /* Order within in the index */ unsigned use_index; /* Use index on creation order values */ @@ -12666,7 +12670,7 @@ link_iterate(hid_t fapl) /* Create several links, up to limit of compact form */ for(u = 0; u < max_compact; u++) { - hid_t group_id2; /* Group ID */ + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); @@ -12692,7 +12696,7 @@ link_iterate(hid_t fapl) /* Create more links, to push group into dense form */ for(; u < (max_compact * 2); u++) { - hid_t group_id2; /* Group ID */ + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); @@ -12750,7 +12754,7 @@ error: return -1; } /* end link_iterate() */ - + /*------------------------------------------------------------------------- * Function: link_iterate_old_cb * @@ -12821,7 +12825,7 @@ link_iterate_old_cb(hid_t group_id, const char *link_name, const H5L_info_t *inf } /* end link_iterate_old_cb() */ #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: group_iterate_old_cb * @@ -12843,7 +12847,7 @@ group_iterate_old_cb(hid_t group_id, const char *link_name, void *_op_data) } /* end group_iterate_old_cb() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - + /*------------------------------------------------------------------------- * Function: link_iterate_old_check * @@ -13018,7 +13022,7 @@ error: return(-1); } /* end link_iterate_old_check() */ - + /*------------------------------------------------------------------------- * Function: link_iterate_old * @@ -13035,8 +13039,8 @@ error: static int link_iterate_old(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1); /* Group ID */ H5_iter_order_t order; /* Order within in the index */ char objname[NAME_BUF_SIZE]; /* Object name */ char filename[NAME_BUF_SIZE];/* File name */ @@ -13079,7 +13083,7 @@ link_iterate_old(hid_t fapl) /* Create several links */ for(u = 0; u < CORDER_NLINKS; u++) { - hid_t group_id2; /* Group ID */ + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); @@ -13139,7 +13143,7 @@ error: return -1; } /* end link_iterate_old() */ - + /*------------------------------------------------------------------------- * Function: open_by_idx_check * @@ -13238,7 +13242,7 @@ error: return(-1); } /* end open_by_idx_check() */ - + /*------------------------------------------------------------------------- * Function: open_by_idx * @@ -13256,11 +13260,11 @@ error: static int open_by_idx(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t mount_file_id = (-1); /* File ID for file to mount */ - hid_t group_id = (-1); /* Group ID */ - hid_t soft_group_id = (-1); /* Group ID for soft links */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ + hid_t file_id = (-1); /* File ID */ + hid_t mount_file_id = (-1); /* File ID for file to mount */ + hid_t group_id = (-1); /* Group ID */ + hid_t soft_group_id = (-1); /* Group ID for soft links */ + hid_t gcpl_id = (-1); /* Group creation property list ID */ H5_index_t idx_type; /* Type of index to operate on */ H5_iter_order_t order; /* Order within in the index */ unsigned use_index; /* Use index on creation order values */ @@ -13360,7 +13364,7 @@ open_by_idx(hid_t fapl) /* Create several links, up to limit of compact form */ for(u = 0; u < max_compact; u++) { - hid_t group_id2; /* Group ID */ + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); @@ -13395,7 +13399,7 @@ open_by_idx(hid_t fapl) /* Create more links, to push group into dense form */ for(; u < (max_compact * 2); u++) { - hid_t group_id2; /* Group ID */ + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); @@ -13468,7 +13472,7 @@ error: return -1; } /* end open_by_idx() */ - + /*------------------------------------------------------------------------- * Function: open_by_idx_old * @@ -13486,10 +13490,10 @@ error: static int open_by_idx_old(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t mount_file_id = (-1); /* File ID for file to mount */ - hid_t group_id = (-1); /* Group ID */ - hid_t soft_group_id = (-1); /* Group ID for soft links */ + hid_t file_id = (-1); /* File ID */ + hid_t mount_file_id = (-1); /* File ID for file to mount */ + hid_t group_id = (-1); /* Group ID */ + hid_t soft_group_id = (-1); /* Group ID for soft links */ H5_iter_order_t order; /* Order within in the index */ H5O_info_t oi; /* Buffer for querying object's info */ char filename[NAME_BUF_SIZE];/* File name */ @@ -13537,7 +13541,7 @@ open_by_idx_old(hid_t fapl) /* Create several links */ for(u = 0; u < CORDER_NLINKS; u++) { - hid_t group_id2; /* Group ID */ + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); @@ -13603,7 +13607,7 @@ error: return -1; } /* end open_by_idx_old() */ - + /*------------------------------------------------------------------------- * Function: object_info_check * @@ -13674,7 +13678,7 @@ error: return(-1); } /* end object_info_check() */ - + /*------------------------------------------------------------------------- * Function: object_info * @@ -13692,10 +13696,10 @@ error: static int object_info(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t soft_group_id = (-1); /* Group ID for soft links */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1); /* Group ID */ + hid_t soft_group_id = (-1); /* Group ID for soft links */ + hid_t gcpl_id = (-1); /* Group creation property list ID */ hid_t space_id = (-1); /* Dataspace ID (for attributes) */ H5_index_t idx_type; /* Type of index to operate on */ H5_iter_order_t order; /* Order within in the index */ @@ -13795,7 +13799,7 @@ object_info(hid_t fapl) /* Create several links, up to limit of compact form */ for(u = 0; u < max_compact; u++) { - hid_t group_id2; /* Group ID */ + hid_t group_id2; /* Group ID */ hid_t attr_id; /* Attribute ID */ /* Make name for link */ @@ -13843,7 +13847,7 @@ object_info(hid_t fapl) /* Create more links, to push group into dense form */ for(; u < (max_compact * 2); u++) { - hid_t group_id2; /* Group ID */ + hid_t group_id2; /* Group ID */ hid_t attr_id; /* Attribute ID */ /* Make name for link */ @@ -13925,7 +13929,7 @@ error: return -1; } /* end object_info() */ - + /*------------------------------------------------------------------------- * Function: object_info_old * @@ -13942,9 +13946,9 @@ error: static int object_info_old(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t soft_group_id = (-1); /* Group ID for soft links */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1); /* Group ID */ + hid_t soft_group_id = (-1); /* Group ID for soft links */ hid_t space_id = (-1); /* Dataspace ID (for attributes) */ H5_iter_order_t order; /* Order within in the index */ H5O_info_t oinfo; /* Buffer for querying object's info */ @@ -13992,7 +13996,7 @@ object_info_old(hid_t fapl) /* Create several links */ for(u = 0; u < CORDER_NLINKS; u++) { - hid_t group_id2; /* Group ID */ + hid_t group_id2; /* Group ID */ hid_t attr_id; /* Attribute ID */ /* Make name for link */ @@ -14071,7 +14075,7 @@ error: return -1; } /* end object_info_old() */ - + /*------------------------------------------------------------------------- * Function: group_info * @@ -14089,10 +14093,10 @@ error: static int group_info(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t soft_group_id = (-1); /* Group ID for soft links */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1); /* Group ID */ + hid_t soft_group_id = (-1); /* Group ID for soft links */ + hid_t gcpl_id = (-1); /* Group creation property list ID */ H5_index_t idx_type; /* Type of index to operate on */ H5_iter_order_t order; /* Order within in the index */ unsigned use_index; /* Use index on creation order values */ @@ -14184,7 +14188,7 @@ group_info(hid_t fapl) /* Create several links, up to limit of compact form */ for(u = 0; u < max_compact; u++) { - hid_t group_id2, group_id3; /* Group IDs */ + hid_t group_id2, group_id3; /* Group IDs */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); @@ -14325,7 +14329,7 @@ group_info(hid_t fapl) /* Create more links, to push group into dense form */ for(; u < (max_compact * 2); u++) { - hid_t group_id2, group_id3; /* Group IDs */ + hid_t group_id2, group_id3; /* Group IDs */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); @@ -14493,7 +14497,7 @@ error: return -1; } /* end group_info() */ - + /*------------------------------------------------------------------------- * Function: group_info_old * @@ -14511,9 +14515,9 @@ error: static int group_info_old(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t soft_group_id = (-1); /* Group ID for soft links */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1); /* Group ID */ + hid_t soft_group_id = (-1); /* Group ID for soft links */ H5_iter_order_t order; /* Order within in the index */ H5G_info_t grp_info; /* Buffer for querying object's info */ char filename[NAME_BUF_SIZE];/* File name */ @@ -14555,7 +14559,7 @@ group_info_old(hid_t fapl) /* Create several links */ for(u = 0; u < CORDER_NLINKS; u++) { - hid_t group_id2, group_id3; /* Group IDs */ + hid_t group_id2, group_id3; /* Group IDs */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); @@ -14723,7 +14727,7 @@ error: return -1; } /* end group_info_old() */ - + /*------------------------------------------------------------------------- * Function: timestamps * @@ -14741,11 +14745,11 @@ error: static int timestamps(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t group_id2 = (-1); /* Group ID */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ - hid_t gcpl_id2 = (-1); /* Group creation property list ID */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1); /* Group ID */ + hid_t group_id2 = (-1); /* Group ID */ + hid_t gcpl_id = (-1); /* Group creation property list ID */ + hid_t gcpl_id2 = (-1); /* Group creation property list ID */ H5O_info_t oinfo, oinfo2; /* Object info for groups created */ char filename[NAME_BUF_SIZE];/* File name */ hbool_t track_times; /* The object timestamp setting */ @@ -14886,17 +14890,17 @@ error: return -1; } /* end timestamps() */ - + /*------------------------------------------------------------------------- - * Function: main + * Function: main * - * Purpose: Test links + * Purpose: Test links * - * Return: Success: exit(EXIT_SUCCESS) + * Return: Success: exit(EXIT_SUCCESS) * - * Failure: exit(EXIT_FAILURE) + * Failure: exit(EXIT_FAILURE) * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, August 14, 1998 * *------------------------------------------------------------------------- @@ -14904,8 +14908,8 @@ error: int main(void) { - hid_t fapl, fapl2; /* File access property lists */ - int nerrors = 0; + hid_t fapl, fapl2; /* File access property lists */ + int nerrors = 0; unsigned new_format; /* Whether to use the new format or not */ unsigned minimize_dset_oh; unsigned efc; /* Whether to use the external file cache */ @@ -15035,7 +15039,7 @@ main(void) nerrors += external_copy_invalid_object(my_fapl, new_format) < 0 ? 1 : 0; nerrors += external_dont_fail_to_source(my_fapl, new_format) < 0 ? 1 : 0; nerrors += external_open_twice(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_with_committed_datatype(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_with_committed_datatype(my_fapl, new_format) < 0 ? 1 : 0; } /* with/without external file cache */ /* These tests assume that external links are a form of UD links, -- cgit v0.12 From 9877da0a6f8ec843926f11468c39121b81b40402 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Sun, 21 Jul 2019 16:46:47 -0500 Subject: HDFFV-10845 fix comment syntax --- test/links.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/links.c b/test/links.c index 69ec665..594e77e 100644 --- a/test/links.c +++ b/test/links.c @@ -4814,7 +4814,7 @@ external_link_win5(hid_t fapl, hbool_t new_format) /* set up name for target link: ":tmp/extlinks14" */ if (drive >= 26) - drive -= 2; /* account for drive Z + drive -= 2; /* account for drive Z */ HDsnprintf(tmpname, sizeof(tmpname), "%c:%s", ((drive+1)+'A'-1), FILENAME[35]); h5_fixname(tmpname, fapl, filename2, sizeof filename2); @@ -4904,7 +4904,7 @@ external_link_win6(hid_t fapl, hbool_t new_format) TEST_ERROR drive = HDgetdrive(); if (drive >= 26) - drive -= 2; /* account for drive Z + drive -= 2; /* account for drive Z */ /* set up name for main file: "extlinks0" */ h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); -- cgit v0.12 From 64733980e5f595ab6e267405284a4461261644ea Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 22 Jul 2019 14:23:05 -0500 Subject: HDFFV-10845 Allow mingw to find functionality --- config/cmake/ConfigureChecks.cmake | 2 +- config/cmake_ext_mod/ConfigureChecks.cmake | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index c1abeed..3bd0553 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -102,7 +102,7 @@ endif () CHECK_FUNCTION_EXISTS (difftime ${HDF_PREFIX}_HAVE_DIFFTIME) # Find the library containing clock_gettime() -if (NOT WINDOWS) +if (MINGW OR NOT WINDOWS) CHECK_FUNCTION_EXISTS (clock_gettime CLOCK_GETTIME_IN_LIBC) CHECK_LIBRARY_EXISTS (rt clock_gettime "" CLOCK_GETTIME_IN_LIBRT) CHECK_LIBRARY_EXISTS (posix4 clock_gettime "" CLOCK_GETTIME_IN_LIBPOSIX4) diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index 8b68a9f..abc88ed 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -92,16 +92,16 @@ if (WINDOWS) set (${HDF_PREFIX}_HAVE_LONGJMP 1) if (NOT MINGW) set (${HDF_PREFIX}_HAVE_GETHOSTNAME 1) + set (${HDF_PREFIX}_HAVE_FUNCTION 1) endif () if (NOT UNIX AND NOT CYGWIN) set (${HDF_PREFIX}_HAVE_GETCONSOLESCREENBUFFERINFO 1) + set (${HDF_PREFIX}_GETTIMEOFDAY_GIVES_TZ 1) + set (${HDF_PREFIX}_HAVE_TIMEZONE 1) + set (${HDF_PREFIX}_HAVE_GETTIMEOFDAY 1) + set (${HDF_PREFIX}_HAVE_LIBWS2_32 1) + set (${HDF_PREFIX}_HAVE_LIBWSOCK32 1) endif () - set (${HDF_PREFIX}_HAVE_FUNCTION 1) - set (${HDF_PREFIX}_GETTIMEOFDAY_GIVES_TZ 1) - set (${HDF_PREFIX}_HAVE_TIMEZONE 1) - set (${HDF_PREFIX}_HAVE_GETTIMEOFDAY 1) - set (${HDF_PREFIX}_HAVE_LIBWS2_32 1) - set (${HDF_PREFIX}_HAVE_LIBWSOCK32 1) endif () # ---------------------------------------------------------------------- @@ -187,7 +187,7 @@ endif () #----------------------------------------------------------------------------- # Check for the math library "m" #----------------------------------------------------------------------------- -if (NOT WINDOWS) +if (MINGW OR NOT WINDOWS) CHECK_LIBRARY_EXISTS_CONCAT ("m" ceil ${HDF_PREFIX}_HAVE_LIBM) CHECK_LIBRARY_EXISTS_CONCAT ("dl" dlopen ${HDF_PREFIX}_HAVE_LIBDL) CHECK_LIBRARY_EXISTS_CONCAT ("ws2_32" WSAStartup ${HDF_PREFIX}_HAVE_LIBWS2_32) @@ -263,7 +263,7 @@ set (LINUX_LFS 0) set (HDF_EXTRA_C_FLAGS) set (HDF_EXTRA_FLAGS) -if (NOT WINDOWS) +if (MINGW OR NOT WINDOWS) # Might want to check explicitly for Linux and possibly Cygwin # instead of checking for not Solaris or Darwin. if (NOT ${HDF_PREFIX}_HAVE_SOLARIS AND NOT ${HDF_PREFIX}_HAVE_DARWIN) @@ -323,7 +323,7 @@ endif () #----------------------------------------------------------------------------- # Check for HAVE_OFF64_T functionality #----------------------------------------------------------------------------- -if (NOT WINDOWS OR MINGW) +if (MINGW OR NOT WINDOWS) HDF_FUNCTION_TEST (HAVE_OFF64_T) if (${HDF_PREFIX}_HAVE_OFF64_T) CHECK_FUNCTION_EXISTS (lseek64 ${HDF_PREFIX}_HAVE_LSEEK64) @@ -402,7 +402,7 @@ if (NOT APPLE) if (NOT ${HDF_PREFIX}_SIZEOF_SSIZE_T) set (${HDF_PREFIX}_SIZEOF_SSIZE_T 0) endif () - if (NOT WINDOWS) + if (MINGW OR NOT WINDOWS) HDF_CHECK_TYPE_SIZE (ptrdiff_t ${HDF_PREFIX}_SIZEOF_PTRDIFF_T) endif () endif () @@ -426,7 +426,7 @@ else () HDF_CHECK_TYPE_SIZE (_Bool ${HDF_PREFIX}_SIZEOF_BOOL) endif () -if (NOT WINDOWS) +if (MINGW OR NOT WINDOWS) #----------------------------------------------------------------------------- # Check if the dev_t type is a scalar type #----------------------------------------------------------------------------- @@ -534,7 +534,7 @@ CHECK_FUNCTION_EXISTS (vasprintf ${HDF_PREFIX}_HAVE_VASPRINTF) CHECK_FUNCTION_EXISTS (waitpid ${HDF_PREFIX}_HAVE_WAITPID) CHECK_FUNCTION_EXISTS (vsnprintf ${HDF_PREFIX}_HAVE_VSNPRINTF) -if (NOT WINDOWS) +if (MINGW OR NOT WINDOWS) if (${HDF_PREFIX}_HAVE_VSNPRINTF) HDF_FUNCTION_TEST (VSNPRINTF_WORKS) endif () @@ -555,7 +555,7 @@ endif () #----------------------------------------------------------------------------- # Check a bunch of other functions #----------------------------------------------------------------------------- -if (NOT WINDOWS) +if (MINGW OR NOT WINDOWS) foreach (other_test HAVE_ATTRIBUTE HAVE_C99_FUNC -- cgit v0.12 From fbc06ff9b8e12f542814d6e5dc08c19680a5429d Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 22 Jul 2019 16:23:38 -0500 Subject: Use generator expr to get correct name --- java/examples/datasets/CMakeLists.txt | 56 ++++++++++++------------------- java/examples/datatypes/CMakeLists.txt | 53 +++++++++++------------------ java/examples/groups/CMakeLists.txt | 61 ++++++++++++---------------------- java/examples/intro/CMakeLists.txt | 55 ++++++++++++------------------ java/test/CMakeLists.txt | 6 ++-- 5 files changed, 86 insertions(+), 145 deletions(-) diff --git a/java/examples/datasets/CMakeLists.txt b/java/examples/datasets/CMakeLists.txt index 83343fc..c64e02e 100644 --- a/java/examples/datasets/CMakeLists.txt +++ b/java/examples/datasets/CMakeLists.txt @@ -71,61 +71,47 @@ foreach (HDFJAVA_JAR ${CMAKE_JAVA_INCLUDE_PATH}) set (CMAKE_JAVA_CLASSPATH "${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${HDFJAVA_JAR}") endforeach () -macro (ADD_H5_TEST resultfile resultcode) +if (BUILD_TESTING) get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME) - get_property (target_name_debug TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME_DEBUG) - set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$,${target_name_debug},${target_name}>;") - add_test ( - NAME JAVA_datasets-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_TESTER=${CMAKE_Java_RUNTIME};${CMAKE_Java_RUNTIME_FLAGS}" - -D "TEST_CLASSPATH:STRING=${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${${resultfile}_JAR_FILE}" - -D "TEST_ARGS:STRING=${CMD_ARGS}${ARGN}" - -D "TEST_PROGRAM=examples.datasets.${resultfile}" - -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}" - -D "TEST_FOLDER=${HDFJAVA_EXAMPLES_BINARY_DIR}" - -D "TEST_OUTPUT=datasets/${resultfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=datasets/${resultfile}.txt" - -P "${HDF_RESOURCES_DIR}/jrunTest.cmake" - ) - if (last_test) - set_tests_properties (JAVA_datasets-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "JAVA_datasets-${resultfile}") -endmacro () + set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=${target_name}$<$:${CMAKE_DEBUG_POSTFIX}>;") -if (BUILD_TESTING) foreach (example ${HDF_JAVA_EXAMPLES}) if (example STREQUAL "H5Ex_D_External") add_test ( NAME JAVA_datasets-${example}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove + COMMAND ${CMAKE_COMMAND} -E remove ${HDFJAVA_EXAMPLES_BINARY_DIR}/${example}.h5 ${HDFJAVA_EXAMPLES_BINARY_DIR}/${example}.data ) else () add_test ( NAME JAVA_datasets-${example}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${HDFJAVA_EXAMPLES_BINARY_DIR}/${example}.h5 + COMMAND ${CMAKE_COMMAND} -E remove ${HDFJAVA_EXAMPLES_BINARY_DIR}/${example}.h5 ) endif () - if (last_test) - set_tests_properties (JAVA_datasets-${example}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () + add_test ( NAME JAVA_datasets-${example}-copy-objects - COMMAND ${CMAKE_COMMAND} - -E copy_if_different + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${HDFJAVA_EXAMPLES_SOURCE_DIR}/testfiles/examples.datasets.${example}.txt ${HDFJAVA_EXAMPLES_DATASETS_BINARY_DIR}/${example}.txt ) set_tests_properties (JAVA_datasets-${example}-copy-objects PROPERTIES DEPENDS JAVA_datasets-${example}-clear-objects) - set (last_test "JAVA_datasets-${example}-copy-objects") - ADD_H5_TEST (${example} 0) + add_test ( + NAME JAVA_datasets-${example} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_TESTER=${CMAKE_Java_RUNTIME};${CMAKE_Java_RUNTIME_FLAGS}" + -D "TEST_CLASSPATH:STRING=${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${${example}_JAR_FILE}" + -D "TEST_ARGS:STRING=${CMD_ARGS}" + -D "TEST_PROGRAM=examples.datasets.${example}" + -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}" + -D "TEST_FOLDER=${HDFJAVA_EXAMPLES_BINARY_DIR}" + -D "TEST_OUTPUT=datasets/${example}.out" + -D "TEST_EXPECT=0" + -D "TEST_REFERENCE=datasets/${example}.txt" + -P "${HDF_RESOURCES_DIR}/jrunTest.cmake" + ) + set_tests_properties (JAVA_datasets-${example} PROPERTIES DEPENDS JAVA_datasets-${example}-copy-objects) endforeach () endif () diff --git a/java/examples/datatypes/CMakeLists.txt b/java/examples/datatypes/CMakeLists.txt index 701fe2a..70648e4 100644 --- a/java/examples/datatypes/CMakeLists.txt +++ b/java/examples/datatypes/CMakeLists.txt @@ -56,50 +56,37 @@ foreach (HDFJAVA_JAR ${CMAKE_JAVA_INCLUDE_PATH}) set (CMAKE_JAVA_CLASSPATH "${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${HDFJAVA_JAR}") endforeach () -MACRO (ADD_H5_TEST resultfile resultcode) +if (BUILD_TESTING) get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME) - get_property (target_name_debug TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME_DEBUG) - set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$,${target_name_debug},${target_name}>;") - add_test ( - NAME JAVA_datatypes-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_TESTER=${CMAKE_Java_RUNTIME};${CMAKE_Java_RUNTIME_FLAGS}" - -D "TEST_PROGRAM=examples.datatypes.${resultfile}" - -D "TEST_ARGS:STRING=${CMD_ARGS}${ARGN}" - -D "TEST_CLASSPATH:STRING=${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${${resultfile}_JAR_FILE}" - -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}" - -D "TEST_FOLDER=${HDFJAVA_EXAMPLES_BINARY_DIR}" - -D "TEST_OUTPUT=datatypes/${resultfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=datatypes/${resultfile}.txt" - -P "${HDF_RESOURCES_DIR}/jrunTest.cmake" - ) - if (last_test) - set_tests_properties (JAVA_datatypes-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "JAVA_datatypes-${resultfile}") -ENDMACRO () + set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=${target_name}$<$:${CMAKE_DEBUG_POSTFIX}>;") -if (BUILD_TESTING) foreach (example ${HDF_JAVA_EXAMPLES}) add_test ( NAME JAVA_datatypes-${example}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${HDFJAVA_EXAMPLES_BINARY_DIR}/${example}.h5 + COMMAND ${CMAKE_COMMAND} -E remove ${HDFJAVA_EXAMPLES_BINARY_DIR}/${example}.h5 ) - if (last_test) - set_tests_properties (JAVA_datatypes-${example}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () + add_test ( NAME JAVA_datatypes-${example}-copy-objects - COMMAND ${CMAKE_COMMAND} - -E copy_if_different + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${HDFJAVA_EXAMPLES_SOURCE_DIR}/testfiles/examples.datatypes.${example}.txt ${HDFJAVA_EXAMPLES_DATATYPES_BINARY_DIR}/${example}.txt ) set_tests_properties (JAVA_datatypes-${example}-copy-objects PROPERTIES DEPENDS JAVA_datatypes-${example}-clear-objects) - set (last_test "JAVA_datatypes-${example}-copy-objects") - ADD_H5_TEST (${example} 0) + add_test ( + NAME JAVA_datatypes-${example} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_TESTER=${CMAKE_Java_RUNTIME};${CMAKE_Java_RUNTIME_FLAGS}" + -D "TEST_PROGRAM=examples.datatypes.${example}" + -D "TEST_ARGS:STRING=${CMD_ARGS}" + -D "TEST_CLASSPATH:STRING=${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${${example}_JAR_FILE}" + -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}" + -D "TEST_FOLDER=${HDFJAVA_EXAMPLES_BINARY_DIR}" + -D "TEST_OUTPUT=datatypes/${example}.out" + -D "TEST_EXPECT=0" + -D "TEST_REFERENCE=datatypes/${example}.txt" + -P "${HDF_RESOURCES_DIR}/jrunTest.cmake" + ) + set_tests_properties (JAVA_datatypes-${example} PROPERTIES DEPENDS JAVA_datatypes-${example}-copy-objects) endforeach () endif () diff --git a/java/examples/groups/CMakeLists.txt b/java/examples/groups/CMakeLists.txt index f0693ba..e1ad108 100644 --- a/java/examples/groups/CMakeLists.txt +++ b/java/examples/groups/CMakeLists.txt @@ -55,65 +55,48 @@ foreach (h5_file ${HDF_JAVA_TEST_FILES}) endforeach () add_custom_target(H5Ex_G_Visit_files ALL COMMENT "Copying files needed by H5Ex_G_Visit tests" DEPENDS ${H5Ex_G_Visit_files_list}) -macro (ADD_H5_TEST resultfile resultcode) +if (BUILD_TESTING) get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME) - get_property (target_name_debug TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME_DEBUG) - set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$,${target_name_debug},${target_name}>;") - add_test ( - NAME JAVA_groups-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_TESTER=${CMAKE_Java_RUNTIME};${CMAKE_Java_RUNTIME_FLAGS}" - -D "TEST_PROGRAM=examples.groups.${resultfile}" - -D "TEST_ARGS:STRING=${CMD_ARGS}${ARGN}" - -D "TEST_CLASSPATH:STRING=${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${${resultfile}_JAR_FILE}" - -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}" - -D "TEST_FOLDER=${HDFJAVA_EXAMPLES_BINARY_DIR}" - -D "TEST_OUTPUT=groups/${resultfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=groups/${resultfile}.txt" - -P "${HDF_RESOURCES_DIR}/jrunTest.cmake" - ) - if (last_test) - set_tests_properties (JAVA_groups-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "JAVA_groups-${resultfile}") -endmacro () + set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=${target_name}$<$:${CMAKE_DEBUG_POSTFIX}>;") -if (BUILD_TESTING) foreach (example ${HDF_JAVA_EXAMPLES}) if (NOT example STREQUAL "H5Ex_G_Iterate" AND NOT example STREQUAL "H5Ex_G_Visit") if (example STREQUAL "H5Ex_G_Compact") add_test ( NAME JAVA_groups-${example}-clear-h5s - COMMAND ${CMAKE_COMMAND} - -E remove + COMMAND ${CMAKE_COMMAND} -E remove ${HDFJAVA_EXAMPLES_BINARY_DIR}/${example}1.h5 ${HDFJAVA_EXAMPLES_BINARY_DIR}/${example}2.h5 ) else () add_test ( NAME JAVA_groups-${example}-clear-h5s - COMMAND ${CMAKE_COMMAND} - -E remove - ${HDFJAVA_EXAMPLES_BINARY_DIR}/${example}.h5 + COMMAND ${CMAKE_COMMAND} -E remove ${HDFJAVA_EXAMPLES_BINARY_DIR}/${example}.h5 ) endif () - if (last_test) - set_tests_properties (JAVA_groups-${example}-clear-h5s PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "JAVA_groups-${example}-clear-h5s") endif () + add_test ( NAME JAVA_groups-${example}-copy-objects - COMMAND ${CMAKE_COMMAND} - -E copy_if_different + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${HDFJAVA_EXAMPLES_SOURCE_DIR}/testfiles/examples.groups.${example}.txt ${HDFJAVA_EXAMPLES_GROUPS_BINARY_DIR}/${example}.txt ) - if (last_test) - set_tests_properties (JAVA_groups-${example}-copy-objects PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "JAVA_groups-${example}-copy-objects") - ADD_H5_TEST (${example} 0) + set_tests_properties (JAVA_groups-${example}-copy-objects PROPERTIES DEPENDS JAVA_groups-${example}-clear-h5s) + add_test ( + NAME JAVA_groups-${example} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_TESTER=${CMAKE_Java_RUNTIME};${CMAKE_Java_RUNTIME_FLAGS}" + -D "TEST_PROGRAM=examples.groups.${example}" + -D "TEST_ARGS:STRING=${CMD_ARGS}" + -D "TEST_CLASSPATH:STRING=${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${${example}_JAR_FILE}" + -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}" + -D "TEST_FOLDER=${HDFJAVA_EXAMPLES_BINARY_DIR}" + -D "TEST_OUTPUT=groups/${example}.out" + -D "TEST_EXPECT=0" + -D "TEST_REFERENCE=groups/${example}.txt" + -P "${HDF_RESOURCES_DIR}/jrunTest.cmake" + ) + set_tests_properties (JAVA_groups-${example} PROPERTIES DEPENDS JAVA_groups-${example}-copy-objects) endforeach () endif () diff --git a/java/examples/intro/CMakeLists.txt b/java/examples/intro/CMakeLists.txt index a4f0cdd..e60af88 100644 --- a/java/examples/intro/CMakeLists.txt +++ b/java/examples/intro/CMakeLists.txt @@ -57,52 +57,39 @@ foreach (example ${HDF_JAVA_OBJECT_EXAMPLES}) add_dependencies (${example} ${HDFJAVA_H5_LIB_TARGET}) endforeach () -MACRO (ADD_H5_TEST resultfile resultcode) - get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME) - get_property (target_name_debug TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME_DEBUG) - set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$,${target_name_debug},${target_name}>;") - add_test ( - NAME JAVA_intro-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_TESTER=${CMAKE_Java_RUNTIME};${CMAKE_Java_RUNTIME_FLAGS}" - -D "TEST_PROGRAM=examples.intro.${resultfile}" - -D "TEST_ARGS:STRING=${CMD_ARGS}${ARGN}" - -D "TEST_CLASSPATH:STRING=${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${${resultfile}_JAR_FILE}" - -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}" - -D "TEST_FOLDER=${HDFJAVA_EXAMPLES_BINARY_DIR}" - -D "TEST_OUTPUT=intro/${resultfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=intro/${resultfile}.txt" - -P "${HDF_RESOURCES_DIR}/jrunTest.cmake" - ) - if (last_test) - set_tests_properties (JAVA_intro-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "JAVA_intro-${resultfile}") -ENDMACRO () - if (BUILD_TESTING) + get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME) + set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=${target_name}$<$:${CMAKE_DEBUG_POSTFIX}>;") foreach (example ${HDF_JAVA_EXAMPLES}) add_test ( NAME JAVA_intro-${example}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${HDFJAVA_EXAMPLES_BINARY_DIR}/${example}.h5 + COMMAND ${CMAKE_COMMAND} -E remove ${HDFJAVA_EXAMPLES_BINARY_DIR}/${example}.h5 ) - if (last_test) - set_tests_properties (JAVA_intro-${example}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () + add_test ( NAME JAVA_intro-${example}-copy-objects - COMMAND ${CMAKE_COMMAND} - -E copy_if_different + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${HDFJAVA_EXAMPLES_SOURCE_DIR}/testfiles/examples.intro.${example}.txt ${HDFJAVA_EXAMPLES_INTRO_BINARY_DIR}/${example}.txt ) set_tests_properties (JAVA_intro-${example}-copy-objects PROPERTIES DEPENDS JAVA_intro-${example}-clear-objects) - set (last_test "JAVA_intro-${example}-copy-objects") - ADD_H5_TEST (${example} 0) + + add_test ( + NAME JAVA_intro-${example} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_TESTER=${CMAKE_Java_RUNTIME};${CMAKE_Java_RUNTIME_FLAGS}" + -D "TEST_PROGRAM=examples.intro.${example}" + -D "TEST_ARGS:STRING=${CMD_ARGS}" + -D "TEST_CLASSPATH:STRING=${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${${example}_JAR_FILE}" + -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}" + -D "TEST_FOLDER=${HDFJAVA_EXAMPLES_BINARY_DIR}" + -D "TEST_OUTPUT=intro/${example}.out" + -D "TEST_EXPECT=0" + -D "TEST_REFERENCE=intro/${example}.txt" + -P "${HDF_RESOURCES_DIR}/jrunTest.cmake" + ) + set_tests_properties (JAVA_intro-${example} PROPERTIES DEPENDS JAVA_intro-${example}-copy-objects) endforeach () endif () diff --git a/java/test/CMakeLists.txt b/java/test/CMakeLists.txt index d677b5f..3298a47 100644 --- a/java/test/CMakeLists.txt +++ b/java/test/CMakeLists.txt @@ -89,8 +89,7 @@ else () endif () get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME) -get_property (target_name_debug TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME_DEBUG) -set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=$,${target_name_debug},${target_name}>;") +set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=${target_name}$<$:${CMAKE_DEBUG_POSTFIX}>;") foreach (test_file ${HDF5_JAVA_TEST_SOURCES}) set (CMAKE_JAVA_CLASSPATH ".") @@ -101,8 +100,7 @@ foreach (test_file ${HDF5_JAVA_TEST_SOURCES}) add_test ( NAME JUnit-${test_file}-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove + COMMAND ${CMAKE_COMMAND} -E remove JUnit-${test_file}.out JUnit-${test_file}.out.err ) -- cgit v0.12 From b9332d6a138b6812e0729b450f993bc9bb9b22de Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 22 Jul 2019 17:13:56 -0500 Subject: Correct format of drive check --- test/links.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/links.c b/test/links.c index 594e77e..b7eb6af 100644 --- a/test/links.c +++ b/test/links.c @@ -4805,6 +4805,10 @@ external_link_win5(hid_t fapl, hbool_t new_format) if(NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) TEST_ERROR drive = HDgetdrive(); + if (drive >= 26) + drive -= 1; /* account for drive Z */ + else + drive += 1; /* set up name for main file: "/CWD/extlinks0" */ HDstrcpy(tmpname, &cwdpath[2]); /* stripped the drive letter to make it rel drive but absolute path */ @@ -4813,9 +4817,7 @@ external_link_win5(hid_t fapl, hbool_t new_format) h5_fixname(tmpname, fapl, filename1, sizeof filename1); /* set up name for target link: ":tmp/extlinks14" */ - if (drive >= 26) - drive -= 2; /* account for drive Z */ - HDsnprintf(tmpname, sizeof(tmpname), "%c:%s", ((drive+1)+'A'-1), FILENAME[35]); + HDsnprintf(tmpname, sizeof(tmpname), "%c:%s", (drive+'A'-1), FILENAME[35]); h5_fixname(tmpname, fapl, filename2, sizeof filename2); /* set up name for target file: "tmp/extlinks14" */ @@ -4904,13 +4906,15 @@ external_link_win6(hid_t fapl, hbool_t new_format) TEST_ERROR drive = HDgetdrive(); if (drive >= 26) - drive -= 2; /* account for drive Z */ + drive -= 1; /* account for drive Z */ + else + drive += 1; /* set up name for main file: "extlinks0" */ h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); /* set up name for target link: ":tmp/extlinks15" */ - HDsnprintf(tmpname, sizeof(tmpname), "%c:%s", ((drive+1)+'A'-1), FILENAME[36]); + HDsnprintf(tmpname, sizeof(tmpname), "%c:%s", (drive+'A'-1), FILENAME[36]); h5_fixname(tmpname, fapl, filename2, sizeof filename2); /* set up name for target file: "tmp/extlinks15" */ -- cgit v0.12 From e19b0302cc38d1850ada7a00431511343cddc8a6 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 23 Jul 2019 16:21:07 -0500 Subject: HDFFV-10845 update note --- release_docs/RELEASE.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index a64abc8..fe40021 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -57,12 +57,16 @@ New Features (ADB - 2019/07/17, HDFFV-100424) - - Add mingw support with toolchain file + - Add mingw CMake support with a toolchain file There has been a number of mingw issues that has been linked under HDFFV-10845. It has been decided to implement the CMake cross-compiling technique of toolchain files. We will use a linux platform with the mingw - compiler stack for testing. + compiler stack for testing. Only the C language is fully supported, and + the error tests are skipped. The C++ language works for static but shared + builds has a shared library issue with the mingw Standard Exception Handling + library, which is not available on Windows. Fortran has a common cross-compile + problem with the fortran configure tests. (ADB - 2019/07/12, HDFFV-10845, HDFFV-10595) -- cgit v0.12 From 6a932198aa9c3da1d23fe4c4bdee05891bc2e38b Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 23 Jul 2019 16:24:56 -0500 Subject: HDFFV-10529 Update CMake tests to use test fixtures --- c++/examples/CMakeTests.cmake | 135 ++++---- c++/test/CMakeVFDTests.cmake | 3 +- config/cmake/CTestCustom.cmake | 180 ++-------- config/cmake/HDF5UseFortran.cmake | 3 +- config/cmake_ext_mod/HDFMacros.cmake | 4 +- examples/CMakeTests.cmake | 189 ++++++----- fortran/examples/CMakeTests.cmake | 52 ++- fortran/test/CMakeTests.cmake | 47 ++- hl/c++/examples/CMakeTests.cmake | 1 + hl/c++/test/CMakeTests.cmake | 6 + hl/examples/CMakeTests.cmake | 60 ++-- hl/fortran/examples/CMakeTests.cmake | 10 +- hl/fortran/test/CMakeTests.cmake | 21 +- hl/test/CMakeTests.cmake | 85 +++-- hl/tools/gif2h5/CMakeTests.cmake | 26 +- hl/tools/h5watch/CMakeTests.cmake | 27 +- test/CMakePassthroughVOLTests.cmake | 40 --- test/CMakeTests.cmake | 166 ++++------ test/CMakeVFDTests.cmake | 40 --- testpar/CMakeTests.cmake | 19 +- testpar/CMakeVFDTests.cmake | 8 - tools/test/h5copy/CMakeTests.cmake | 43 +-- tools/test/h5diff/CMakeTests.cmake | 42 +-- tools/test/h5dump/CMakeTests.cmake | 469 +-------------------------- tools/test/h5dump/CMakeTestsPBITS.cmake | 130 -------- tools/test/h5dump/CMakeTestsVDS.cmake | 78 ----- tools/test/h5dump/CMakeTestsXML.cmake | 158 --------- tools/test/h5format_convert/CMakeTests.cmake | 113 +------ tools/test/h5import/CMakeTests.cmake | 220 +++---------- tools/test/h5jam/CMakeTests.cmake | 37 +-- tools/test/h5ls/CMakeTests.cmake | 154 --------- tools/test/h5ls/CMakeTestsVDS.cmake | 62 ---- tools/test/h5repack/CMakeTests.cmake | 366 +++++++++------------ tools/test/h5repack/CMakeVFDTests.cmake | 4 - tools/test/h5stat/CMakeTests.cmake | 35 +- tools/test/misc/CMakeTestsClear.cmake | 295 ++++++++--------- tools/test/misc/CMakeTestsMkgrp.cmake | 108 ++---- tools/test/misc/CMakeTestsRepart.cmake | 25 +- tools/test/perform/CMakeTests.cmake | 30 +- 39 files changed, 895 insertions(+), 2596 deletions(-) diff --git a/c++/examples/CMakeTests.cmake b/c++/examples/CMakeTests.cmake index b7d7497..bbe3433 100644 --- a/c++/examples/CMakeTests.cmake +++ b/c++/examples/CMakeTests.cmake @@ -16,84 +16,79 @@ ############################################################################## ############################################################################## # Remove any output file left over from previous test run - add_test ( - NAME CPP_ex-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - Group.h5 - SDS.h5 - SDScompound.h5 - SDSextendible.h5 - Select.h5 - ) - set_tests_properties (CPP_ex-clear-objects PROPERTIES FIXTURES_SETUP clear_cppex) +add_test ( + NAME CPP_ex-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + Group.h5 + SDS.h5 + SDScompound.h5 + SDSextendible.h5 + Select.h5 +) +set_tests_properties (CPP_ex-clear-objects PROPERTIES FIXTURES_SETUP clear_cppex) + +foreach (example ${examples}) + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME CPP_ex_${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) + else () + add_test (NAME CPP_ex_${example} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_EXPECT=0" + -D "TEST_SKIP_COMPARE=TRUE" + -D "TEST_OUTPUT=cpp_ex_${example}.txt" + #-D "TEST_REFERENCE=cpp_ex_${example}.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + endif () + set_tests_properties (CPP_ex_${example} PROPERTIES FIXTURES_REQUIRED clear_cppex) if (last_test) - set_tests_properties (CPP_ex-clear-objects PROPERTIES DEPENDS ${last_test}) + set_tests_properties (CPP_ex_${example} PROPERTIES DEPENDS ${last_test}) endif () - set (last_test "CPP_ex-clear-objects") - - foreach (example ${examples}) - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME CPP_ex_${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - else () - add_test (NAME CPP_ex_${example} COMMAND "${CMAKE_COMMAND}" - -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=" - -D "TEST_EXPECT=0" - -D "TEST_SKIP_COMPARE=TRUE" - -D "TEST_OUTPUT=cpp_ex_${example}.txt" - #-D "TEST_REFERENCE=cpp_ex_${example}.out" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - endif () - if (last_test) - set_tests_properties (CPP_ex_${example} PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "CPP_ex_${example}") - endforeach () + set (last_test "CPP_ex_${example}") +endforeach () #the following dependencies are handled by the order of the files # SET_TESTS_PROPERTIES(CPP_ex_readdata PROPERTIES DEPENDS CPP_ex_create) # SET_TESTS_PROPERTIES(CPP_ex_chunks PROPERTIES DEPENDS CPP_ex_extend_ds) - add_test ( - NAME CPP_ex_tutr-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - h5tutr_cmprss.h5 - h5tutr_dset.h5 - h5tutr_extend.h5 - h5tutr_group.h5 - h5tutr_groups.h5 - h5tutr_subset.h5 - ) +add_test ( + NAME CPP_ex_tutr-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + h5tutr_cmprss.h5 + h5tutr_dset.h5 + h5tutr_extend.h5 + h5tutr_group.h5 + h5tutr_groups.h5 + h5tutr_subset.h5 +) +set_tests_properties (CPP_ex_tutr-clear-objects PROPERTIES FIXTURES_SETUP clear_cppex_tutr) + +foreach (example ${tutr_examples}) + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME CPP_ex_${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) + else () + add_test (NAME CPP_ex_${example} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_EXPECT=0" + -D "TEST_SKIP_COMPARE=TRUE" + -D "TEST_OUTPUT=cpp_ex_${example}.txt" + #-D "TEST_REFERENCE=cpp_ex_${example}.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + endif () + set_tests_properties (CPP_ex_${example} PROPERTIES FIXTURES_REQUIRED clear_cppex_tutr) if (last_test) - set_tests_properties (CPP_ex_tutr-clear-objects PROPERTIES DEPENDS ${last_test}) + set_tests_properties (CPP_ex_${example} PROPERTIES DEPENDS ${last_test}) endif () - set (last_test "CPP_ex_tutr-clear-objects") - - foreach (example ${tutr_examples}) - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME CPP_ex_${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - else () - add_test (NAME CPP_ex_${example} COMMAND "${CMAKE_COMMAND}" - -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=" - -D "TEST_EXPECT=0" - -D "TEST_SKIP_COMPARE=TRUE" - -D "TEST_OUTPUT=cpp_ex_${example}.txt" - #-D "TEST_REFERENCE=cpp_ex_${example}.out" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - endif () - if (last_test) - set_tests_properties (CPP_ex_${example} PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "CPP_ex_${example}") - endforeach () + set (last_test "CPP_ex_${example}") +endforeach () #the following dependencies are handled by the order of the files # SET_TESTS_PROPERTIES(CPP_ex_h5tutr_crtatt PROPERTIES DEPENDS CPP_ex_h5tutr_crtdat) # SET_TESTS_PROPERTIES(CPP_ex_h5tutr_rdwt PROPERTIES DEPENDS CPP_ex_h5tutr_crtdat) diff --git a/c++/test/CMakeVFDTests.cmake b/c++/test/CMakeVFDTests.cmake index c979ff1..b26165a 100644 --- a/c++/test/CMakeVFDTests.cmake +++ b/c++/test/CMakeVFDTests.cmake @@ -42,6 +42,7 @@ tattr_scalar.h5 tfattrs.h5 titerate.h5 + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${vfdname} ) add_test ( NAME CPP_VFD-${vfdname}-cpp_testhdf5 @@ -51,7 +52,7 @@ -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=cpp_testhdf5" + -D "TEST_OUTPUT=${vfdname}-cpp_testhdf5.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) diff --git a/config/cmake/CTestCustom.cmake b/config/cmake/CTestCustom.cmake index 6db0f6f..a05f906 100644 --- a/config/cmake/CTestCustom.cmake +++ b/config/cmake/CTestCustom.cmake @@ -42,25 +42,31 @@ set (CTEST_CUSTOM_MEMCHECK_IGNORE H5TEST-testlibinfo #uses grepTest.cmake ######### H5TEST-clear-objects - H5TEST-clear-cache-objects - H5TEST-clear-cache_api-objects - H5TEST-clear-cache_image-objects - H5TEST-clear-cache_tagging-objects - H5TEST-clear-del_many_dense_attrs-objects - H5TEST-clear-err_compat-objects - H5TEST-clear-error_test-objects - H5TEST-clear-filenotclosed-objects - H5TEST-clear-flush-objects - H5TEST-clear-links_env-objects - H5TEST-clear-testflushrefresh-objects - H5TEST-clear-testhdf5-objects - H5TEST-clear-ttsafe-objects + H5TEST-cache-clear-objects + H5TEST-cache_image-clear-objects + H5TEST-del_many_dense_attrs-clear-objects + H5TEST-external_env-clear-objects + H5TEST-filenotclosed-clear-objects + H5TEST-flush-clear-objects + H5TEST-links_env-clear-objects + H5TEST-testflushrefresh-clear-objects + H5TEST-testhdf5-clear-objects + H5TEST-vds_env-clear-objects PERFORM_h5perform-clear-objects - HL_TOOLS-clear-objects HL_test-clear-objects HL_FORTRAN_test-clear-objects FORTRAN_testhdf5-clear-objects + FORTRAN_flush1-clear-objects CPP_testhdf5-clear-objects + ######### examples ######### + EXAMPLES-clear-objects + CPP_ex-clear-objects + CPP_ex_tutr-clear-objects + HL_ex-clear-objects + f90_ex-clear-objects + HL_CPP_ptableTest-clear-objects + HL_CPP_ex_ptExampleFL-clear-objects + HL_FORTRAN_f90_ex-clear-objects ######### tools/h5clear ######### H5CLEAR-clearall-objects H5CLEAR-copy_h5clear_fsm_persist_equal.h5 @@ -89,10 +95,6 @@ set (CTEST_CUSTOM_MEMCHECK_IGNORE ######### tools/h5diff ######### H5DIFF-clearall-objects ######### tools/h5dump ######### - H5DUMP-clearall-objects - H5DUMP_PACKED_BITS-clearall-objects - H5DUMP-XML-clearall-objects - H5DUMP_VDS-clearall-objects H5DUMP-t128bit_float #uses grepTest.cmake ######### tools/h5format_convert ######### H5FC-clearall-objects @@ -100,136 +102,6 @@ set (CTEST_CUSTOM_MEMCHECK_IGNORE H5IMPORT-h5importtest-clear-objects H5IMPORT-clear-objects ######### tools/h5jam ######### - H5JAM-SETUP-N_twithub_u10_c-clear-objects - H5JAM-SETUP-N_twithub_u10_c - H5JAM-N_twithub_u10_c-clear-objects - H5JAM-NONE_COPY-N_twithub_u10_c - H5JAM-CHECKFILE-N_twithub_u10_c-clear-objects - H5JAM-SETUP-N_twithub_u511_c-clear-objects - H5JAM-SETUP-N_twithub_u511_c - H5JAM-N_twithub_u511_c-clear-objects - H5JAM-NONE_COPY-N_twithub_u511_c - H5JAM-CHECKFILE-N_twithub_u511_c-clear-objects - H5JAM-SETUP-N_twithub_u512_c-clear-objects - H5JAM-SETUP-N_twithub_u512_c - H5JAM-N_twithub_u512_c-clear-objects - H5JAM-NONE_COPY-N_twithub_u512_c - H5JAM-CHECKFILE-N_twithub_u512_c-clear-objects - H5JAM-SETUP-N_twithub_u513_c-clear-objects - H5JAM-SETUP-N_twithub_u513_c - H5JAM-N_twithub_u513_c-clear-objects - H5JAM-NONE_COPY-N_twithub_u513_c - H5JAM-CHECKFILE-N_twithub_u513_c-clear-objects - H5JAM-SETUP-N_twithub513_u10_c-clear-objects - H5JAM-SETUP-N_twithub513_u10_c - H5JAM-N_twithub513_u10_c-clear-objects - H5JAM-NONE_COPY-N_twithub513_u10_c - H5JAM-CHECKFILE-N_twithub513_u10_c-clear-objects - H5JAM-SETUP-N_twithub513_u511_c-clear-objects - H5JAM-SETUP-N_twithub513_u511_c - H5JAM-N_twithub513_u511_c-clear-objects - H5JAM-NONE_COPY-N_twithub513_u511_c - H5JAM-CHECKFILE-N_twithub513_u511_c-clear-objects - H5JAM-SETUP-N_twithub513_u512_c-clear-objects - H5JAM-SETUP-N_twithub513_u512_c - H5JAM-N_twithub513_u512_c-clear-objects - H5JAM-NONE_COPY-N_twithub513_u512_c - H5JAM-CHECKFILE-N_twithub513_u512_c-clear-objects - H5JAM-SETUP-N_twithub513_u513_c-clear-objects - H5JAM-SETUP-N_twithub513_u513_c - H5JAM-N_twithub513_u513_c-clear-objects - H5JAM-NONE_COPY-N_twithub513_u513_c - H5JAM-CHECKFILE-N_twithub513_u513_c-clear-objects - H5JAM-CHECKFILE-twithub_u10_c-clear-objects - H5JAM-twithub_u511_c-clear-objects - H5JAM-CHECKFILE-twithub_u511_c-clear-objects - H5JAM-twithub_u512_c-clear-objects - H5JAM-CHECKFILE-twithub_u512_c-clear-objects - H5JAM-twithub_u513_c-clear-objects - H5JAM-CHECKFILE-twithub_u513_c-clear-objects - H5JAM-twithub513_u10_c-clear-objects - H5JAM-CHECKFILE-twithub513_u10_c-clear-objects - H5JAM-twithub513_u511_c-clear-objects - H5JAM-CHECKFILE-twithub513_u511_c-clear-objects - H5JAM-twithub513_u512_c-clear-objects - H5JAM-CHECKFILE-twithub513_u512_c-clear-objects - H5JAM-twithub513_u513_c-clear-objects - H5JAM-CHECKFILE-twithub513_u513_c-clear-objects - H5JAM-SETUP-twithub_tall-clear-objects - H5JAM-SETUP-twithub_tall - H5JAM-UNJAM-twithub_tall-clear-objects - H5JAM-UNJAM_D-twithub_tall-clear-objects - H5JAM-CHECKFILE-twithub_tall-clear-objects - H5JAM-SETUP-twithub513_tall-clear-objects - H5JAM-SETUP-twithub513_tall - H5JAM-UNJAM-twithub513_tall-clear-objects - H5JAM-UNJAM_D-twithub513_tall-clear-objects - H5JAM-CHECKFILE-twithub513_tall-clear-objects - H5JAM-SETUP-N_twithub_tall-clear-objects - H5JAM-SETUP-N_twithub_tall - H5JAM-UNJAM-N_twithub_tall-clear-objects - H5JAM-UNJAM_D-N_twithub_tall-clear-objects - H5JAM-CHECKFILE-N_twithub_tall-clear-objects - H5JAM-SETUP-N_twithub513_tall-clear-objects - H5JAM-SETUP-N_twithub513_tall - H5JAM-UNJAM-N_twithub513_tall-clear-objects - H5JAM-UNJAM_D-N_twithub513_tall-clear-objects - H5JAM-CHECKFILE-N_twithub513_tall-clear-objects - H5JAM-SETUP-D_twithub_tall-clear-objects - H5JAM-SETUP-D_twithub_tall - H5JAM-UNJAM-D_twithub_tall-clear-objects - H5JAM-UNJAM_D-D_twithub_tall-clear-objects - H5JAM-CHECKFILE-D_twithub_tall-clear-objects - H5JAM-SETUP-D_twithub513_tall-clear-objects - H5JAM-SETUP-D_twithub513_tall - H5JAM-UNJAM-D_twithub513_tall-clear-objects - H5JAM-UNJAM_D-D_twithub513_tall-clear-objects - H5JAM-CHECKFILE-D_twithub513_tall-clear-objects - H5JAM-CHECKFILE-ta_u513-clear-objects - H5JAM-twithub_u10-clear-objects - H5JAM-CHECKFILE-twithub_u10-clear-objects - H5JAM-twithub_u511-clear-objects - H5JAM-CHECKFILE-twithub_u511-clear-objects - H5JAM-twithub_u512-clear-objects - H5JAM-CHECKFILE-twithub_u512-clear-objects - H5JAM-twithub_u513-clear-objects - H5JAM-CHECKFILE-twithub_u513-clear-objects - H5JAM-twithub513_u10-clear-objects - H5JAM-CHECKFILE-twithub513_u10-clear-objects - H5JAM-twithub513_u511-clear-objects - H5JAM-CHECKFILE-twithub513_u511-clear-objects - H5JAM-twithub513_u512-clear-objects - H5JAM-CHECKFILE-twithub513_u512-clear-objects - H5JAM-twithub513_u513-clear-objects - H5JAM-CHECKFILE-twithub513_u513-clear-objects - H5JAM-twithub_u10_c-clear-objects - H5JAM-tall_u10-clear-objects - H5JAM-CHECKFILE-tall_u10-clear-objects - H5JAM-tall_u511-clear-objects - H5JAM-CHECKFILE-tall_u511-clear-objects - H5JAM-tall_u512-clear-objects - H5JAM-CHECKFILE-tall_u512-clear-objects - H5JAM-tall_u513-clear-objects - H5JAM-CHECKFILE-tall_u513-clear-objects - H5JAM-SETUP-ta_u10-clear-objects - H5JAM-SETUP-ta_u10 - H5JAM-ta_u10-clear-objects - H5JAM-NONE_COPY-ta_u10 - H5JAM-CHECKFILE-ta_u10-clear-objects - H5JAM-SETUP-ta_u511-clear-objects - H5JAM-SETUP-ta_u511 - H5JAM-ta_u511-clear-objects - H5JAM-NONE_COPY-ta_u511 - H5JAM-CHECKFILE-ta_u511-clear-objects - H5JAM-SETUP-ta_u512-clear-objects - H5JAM-SETUP-ta_u512 - H5JAM-ta_u512-clear-objects - H5JAM-NONE_COPY-ta_u512 - H5JAM-CHECKFILE-ta_u512-clear-objects - H5JAM-SETUP-ta_u513-clear-objects - H5JAM-SETUP-ta_u513 - H5JAM-ta_u513-clear-objects - H5JAM-NONE_COPY-ta_u513 ######### tools/h5ls ######### H5LS-clearall-objects H5LS_VDS-clearall-objects @@ -286,7 +158,6 @@ set (CTEST_CUSTOM_MEMCHECK_IGNORE H5REPACK-HDFFV-7840-clear-objects H5REPACK_META-meta_long_N-clear-objects H5REPACK_META-meta_short_N-clear-objects - H5REPACK_OLD-old_style_layout_short_switches-clear-objects H5REPACK_STAT-GS_AGGR-clear-objects H5REPACK_STAT-S_AGGR-clear-objects H5REPACK_STAT-SP_NONE-clear-objects @@ -331,14 +202,7 @@ set (CTEST_CUSTOM_MEMCHECK_IGNORE H5MKGRP-clearall-objects ######### tools/perform ######### PERFORM_h5perform-clearall-objects - ######### hl/tools/h5watch ######### + ######### hl/tools ######### + HL_TOOLS-clear-objects H5WATCH-clearall-objects - ######### examples ######### - EXAMPLES-clear-objects - CPP_ex-clear-objects - CPP_ex_tutr-clear-objects - HL_ex-clear-objects - f90_ex-clear-objects - HL_CPP_ex_ptExampleFL-clear-objects - HL_FORTRAN_f90_ex-clear-objects ) diff --git a/config/cmake/HDF5UseFortran.cmake b/config/cmake/HDF5UseFortran.cmake index 279e077..2d3d371 100644 --- a/config/cmake/HDF5UseFortran.cmake +++ b/config/cmake/HDF5UseFortran.cmake @@ -14,7 +14,8 @@ # This file provides functions for HDF5 specific Fortran support. # #------------------------------------------------------------------------------- -ENABLE_LANGUAGE (Fortran) +enable_language (Fortran) + set (HDF_PREFIX "H5") include (CheckFortranFunctionExists) diff --git a/config/cmake_ext_mod/HDFMacros.cmake b/config/cmake_ext_mod/HDFMacros.cmake index 972896d..e320c07 100644 --- a/config/cmake_ext_mod/HDFMacros.cmake +++ b/config/cmake_ext_mod/HDFMacros.cmake @@ -127,8 +127,8 @@ macro (HDF_SET_LIB_OPTIONS libtarget libname libtype) PROPERTIES OUTPUT_NAME ${LIB_RELEASE_NAME} - OUTPUT_NAME_DEBUG - ${LIB_DEBUG_NAME} +# OUTPUT_NAME_DEBUG +# ${LIB_DEBUG_NAME} OUTPUT_NAME_RELEASE ${LIB_RELEASE_NAME} OUTPUT_NAME_MINSIZEREL diff --git a/examples/CMakeTests.cmake b/examples/CMakeTests.cmake index 69ace97..ea3b2c5 100644 --- a/examples/CMakeTests.cmake +++ b/examples/CMakeTests.cmake @@ -15,106 +15,103 @@ ### T E S T I N G ### ############################################################################## ############################################################################## - file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/red ${PROJECT_BINARY_DIR}/blue ${PROJECT_BINARY_DIR}/u2w) +file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/red ${PROJECT_BINARY_DIR}/blue ${PROJECT_BINARY_DIR}/u2w) - set (test_CLEANFILES - Attributes.h5 - btrees_file.h5 - cmprss.h5 - default_file.h5 - dset.h5 - extend.h5 - extlink_prefix_source.h5 - extlink_source.h5 - extlink_target.h5 - group.h5 - groups.h5 - hard_link.h5 - mount1.h5 - mount2.h5 - one_index_file.h5 - only_dspaces_and_attrs_file.h5 - only_huge_mesgs_file.h5 - REF_REG.h5 - refere.h5 - SDS.h5 - SDScompound.h5 - SDSextendible.h5 - Select.h5 - separate_indexes_file.h5 - small_lists_file.h5 - soft_link.h5 - subset.h5 - unix2win.h5 - blue/prefix_target.h5 - red/prefix_target.h5 - u2w/u2w_target.h5 - vds.h5 - vds-exc.h5 - vds-excalibur.h5 - vds-exclim.h5 - vds-percival.h5 - vds-percival-unlim.h5 - vds-percival-unlim-maxmin.h5 - a.h5 - b.h5 - c.h5 - d.h5 - vds-simpleIO.h5 - vds-eiger.h5 - ) +set (test_ex_CLEANFILES + Attributes.h5 + btrees_file.h5 + cmprss.h5 + default_file.h5 + dset.h5 + extend.h5 + extlink_prefix_source.h5 + extlink_source.h5 + extlink_target.h5 + group.h5 + groups.h5 + hard_link.h5 + mount1.h5 + mount2.h5 + one_index_file.h5 + only_dspaces_and_attrs_file.h5 + only_huge_mesgs_file.h5 + REF_REG.h5 + refere.h5 + SDS.h5 + SDScompound.h5 + SDSextendible.h5 + Select.h5 + separate_indexes_file.h5 + small_lists_file.h5 + soft_link.h5 + subset.h5 + unix2win.h5 + blue/prefix_target.h5 + red/prefix_target.h5 + u2w/u2w_target.h5 + vds.h5 + vds-exc.h5 + vds-excalibur.h5 + vds-exclim.h5 + vds-percival.h5 + vds-percival-unlim.h5 + vds-percival-unlim-maxmin.h5 + a.h5 + b.h5 + c.h5 + d.h5 + vds-simpleIO.h5 + vds-eiger.h5 +) - # Remove any output file left over from previous test run - add_test ( - NAME EXAMPLES-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove ${test_CLEANFILES} - ) +# Remove any output file left over from previous test run +add_test ( + NAME EXAMPLES-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove ${test_ex_CLEANFILES} +) +set_tests_properties (EXAMPLES-clear-objects PROPERTIES FIXTURES_SETUP clear_EXAMPLES) + +foreach (example ${examples}) + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME EXAMPLES-${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) + else () + add_test (NAME EXAMPLES-${example} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_EXPECT=0" + -D "TEST_SKIP_COMPARE=TRUE" + -D "TEST_OUTPUT=${example}.txt" + #-D "TEST_REFERENCE=${example}.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + endif () + set_tests_properties (EXAMPLES-${example} PROPERTIES FIXTURES_REQUIRED clear_EXAMPLES) if (last_test) - set_tests_properties (EXAMPLES-clear-objects PROPERTIES DEPENDS ${last_test}) + set_tests_properties (EXAMPLES-${example} PROPERTIES DEPENDS ${last_test}) endif () - set (last_test "EXAMPLES-clear-objects") - - foreach (example ${examples}) - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME EXAMPLES-${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - else () - add_test (NAME EXAMPLES-${example} COMMAND "${CMAKE_COMMAND}" - -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=" - -D "TEST_EXPECT=0" - -D "TEST_SKIP_COMPARE=TRUE" - -D "TEST_OUTPUT=${example}.txt" - #-D "TEST_REFERENCE=${example}.out" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - endif () - if (last_test) - set_tests_properties (EXAMPLES-${example} PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "EXAMPLES-${example}") - endforeach () + set (last_test "EXAMPLES-${example}") +endforeach () ### Windows pops up a modal permission dialog on this test - if (H5_HAVE_PARALLEL AND NOT WIN32) - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME MPI_TEST_EXAMPLES-ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) - else () - add_test (NAME MPI_TEST_EXAMPLES-ph5example COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=${MPIEXEC_EXECUTABLE};${MPIEXEC_NUMPROC_FLAG};${MPIEXEC_MAX_NUMPROCS};${MPIEXEC_PREFLAGS};$;${MPIEXEC_POSTFLAGS}" - -D "TEST_ARGS:STRING=" - -D "TEST_EXPECT=0" - -D "TEST_OUTPUT=ph5example.out" - -D "TEST_REFERENCE:STRING=PHDF5 tests finished with no errors" - -D "TEST_FILTER:STRING=PHDF5 tests finished with no errors" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_EXT_DIR}/grepTest.cmake" - ) - endif () - if (last_test) - set_tests_properties (MPI_TEST_EXAMPLES-ph5example PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "MPI_TEST_EXAMPLES-ph5example") +if (H5_HAVE_PARALLEL AND NOT WIN32) + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME MPI_TEST_EXAMPLES-ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) + else () + add_test (NAME MPI_TEST_EXAMPLES-ph5example COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=${MPIEXEC_EXECUTABLE};${MPIEXEC_NUMPROC_FLAG};${MPIEXEC_MAX_NUMPROCS};${MPIEXEC_PREFLAGS};$;${MPIEXEC_POSTFLAGS}" + -D "TEST_ARGS:STRING=" + -D "TEST_EXPECT=0" + -D "TEST_OUTPUT=ph5example.out" + -D "TEST_REFERENCE:STRING=PHDF5 tests finished with no errors" + -D "TEST_FILTER:STRING=PHDF5 tests finished with no errors" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -P "${HDF_RESOURCES_EXT_DIR}/grepTest.cmake" + ) + endif () + if (last_test) + set_tests_properties (MPI_TEST_EXAMPLES-ph5example PROPERTIES DEPENDS ${last_test}) endif () + set (last_test "MPI_TEST_EXAMPLES-ph5example") +endif () diff --git a/fortran/examples/CMakeTests.cmake b/fortran/examples/CMakeTests.cmake index 221e5cc..5e7dfa8 100644 --- a/fortran/examples/CMakeTests.cmake +++ b/fortran/examples/CMakeTests.cmake @@ -16,34 +16,30 @@ ############################################################################## ############################################################################## - set (test_CLEANFILES - compound.h5 - copy1.h5 - copy2.h5 - dsetf.h5 - extend.h5 - FORTRAN.h5 - groupf.h5 - groupsf.h5 - h5_cmprss.h5 - mount1.h5 - mount2.h5 - sdsf.h5 - subset.h5 - SDScompound.h5 - test.h5 - ) +set (test_ex_fortran_CLEANFILES + compound.h5 + copy1.h5 + copy2.h5 + dsetf.h5 + extend.h5 + FORTRAN.h5 + groupf.h5 + groupsf.h5 + h5_cmprss.h5 + mount1.h5 + mount2.h5 + sdsf.h5 + subset.h5 + SDScompound.h5 + test.h5 +) - # Remove any output file left over from previous test run - add_test ( - NAME f90_ex-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove ${test_CLEANFILES} - ) - if (last_test) - set_tests_properties (f90_ex-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "f90_ex-clear-objects") +# Remove any output file left over from previous test run +add_test ( + NAME f90_ex-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove ${test_ex_fortran_CLEANFILES} +) +set_tests_properties (f90_ex-clear-objects PROPERTIES FIXTURES_SETUP clear_f90_ex) foreach (example ${examples}) if (HDF5_ENABLE_USING_MEMCHECKER) @@ -61,6 +57,7 @@ foreach (example ${examples}) -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () + set_tests_properties (f90_ex_${example} PROPERTIES FIXTURES_REQUIRED clear_f90_ex) if (last_test) set_tests_properties (f90_ex_${example} PROPERTIES DEPENDS ${last_test}) endif () @@ -83,6 +80,7 @@ foreach (example ${F2003_examples}) -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () + set_tests_properties (f03_ex_${example} PROPERTIES FIXTURES_REQUIRED clear_f90_ex) if (last_test) set_tests_properties (f03_ex_${example} PROPERTIES DEPENDS ${last_test}) endif () diff --git a/fortran/test/CMakeTests.cmake b/fortran/test/CMakeTests.cmake index c93b4a2..df5c76c 100644 --- a/fortran/test/CMakeTests.cmake +++ b/fortran/test/CMakeTests.cmake @@ -16,7 +16,7 @@ ############################################################################## ############################################################################## -set (test_CLEANFILES +set (testhdf5_fortran_CLEANFILES a.h5 b.h5 c.h5 @@ -55,14 +55,9 @@ set (test_CLEANFILES # Remove any output file left over from previous test run add_test ( NAME FORTRAN_testhdf5-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${test_CLEANFILES} + COMMAND ${CMAKE_COMMAND} -E remove ${testhdf5_fortran_CLEANFILES} ) -if (last_test) - set_tests_properties (FORTRAN_testhdf5-clear-objects PROPERTIES DEPENDS ${last_test}) -endif () -set (last_test "FORTRAN_testhdf5-clear-objects") +set_tests_properties (FORTRAN_testhdf5-clear-objects PROPERTIES FIXTURES_SETUP clear_testhdf5_fortran) if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME FORTRAN_testhdf5_fortran COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) @@ -82,7 +77,9 @@ else () ) endif () #set_tests_properties (FORTRAN_testhdf5_fortran PROPERTIES PASS_REGULAR_EXPRESSION "[ ]*0 error.s") -set_tests_properties (FORTRAN_testhdf5_fortran PROPERTIES DEPENDS FORTRAN_testhdf5-clear-objects) +set_tests_properties (FORTRAN_testhdf5_fortran PROPERTIES + FIXTURES_REQUIRED clear_testhdf5_fortran +) #-- Adding test for testhdf5_fortran_1_8 if (HDF5_ENABLE_USING_MEMCHECKER) @@ -103,7 +100,10 @@ else () ) endif () #set_tests_properties (FORTRAN_testhdf5_fortran_1_8 PROPERTIES PASS_REGULAR_EXPRESSION "[ ]*0 error.s") -set_tests_properties (FORTRAN_testhdf5_fortran_1_8 PROPERTIES DEPENDS FORTRAN_testhdf5_fortran) +set_tests_properties (FORTRAN_testhdf5_fortran_1_8 PROPERTIES + DEPENDS FORTRAN_testhdf5_fortran + FIXTURES_REQUIRED clear_testhdf5_fortran +) #-- Adding test for fortranlib_test_F03 if (HDF5_ENABLE_USING_MEMCHECKER) @@ -124,7 +124,10 @@ else () ) endif () # set_tests_properties (FORTRAN_fortranlib_test_F03 PROPERTIES PASS_REGULAR_EXPRESSION "[ ]*0 error.s") - set_tests_properties (FORTRAN_fortranlib_test_F03 PROPERTIES DEPENDS FORTRAN_testhdf5_fortran_1_8) +set_tests_properties (FORTRAN_fortranlib_test_F03 PROPERTIES + DEPENDS FORTRAN_testhdf5_fortran_1_8 + FIXTURES_REQUIRED clear_testhdf5_fortran +) #-- Adding test for vol_connector if (HDF5_ENABLE_USING_MEMCHECKER) @@ -146,9 +149,23 @@ else () endif () #-- Adding test for fflush1 -add_test (NAME FORTRAN_fflush1 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) -set_tests_properties (FORTRAN_fflush1 PROPERTIES DEPENDS FORTRAN_testhdf5-clear-objects) +add_test ( + NAME FORTRAN_flush1-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove flush.h5 +) +add_test ( + NAME FORTRAN_fflush1 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ +) +set_tests_properties (FORTRAN_fflush1 PROPERTIES + DEPENDS FORTRAN_flush1-clear-objects +) #-- Adding test for fflush2 -add_test (NAME FORTRAN_fflush2 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) -set_tests_properties (FORTRAN_fflush2 PROPERTIES DEPENDS FORTRAN_fflush1) +add_test ( + NAME FORTRAN_fflush2 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ +) +set_tests_properties (FORTRAN_fflush2 PROPERTIES + DEPENDS FORTRAN_fflush1 +) diff --git a/hl/c++/examples/CMakeTests.cmake b/hl/c++/examples/CMakeTests.cmake index a7acc63..7bc614b 100644 --- a/hl/c++/examples/CMakeTests.cmake +++ b/hl/c++/examples/CMakeTests.cmake @@ -21,6 +21,7 @@ add_test ( COMMAND ${CMAKE_COMMAND} -E remove PTcppexampleFL.h5 + ptExampleFL.txt ) if (HDF5_ENABLE_USING_MEMCHECKER) diff --git a/hl/c++/test/CMakeTests.cmake b/hl/c++/test/CMakeTests.cmake index f85ef85..3d0f93a 100644 --- a/hl/c++/test/CMakeTests.cmake +++ b/hl/c++/test/CMakeTests.cmake @@ -16,6 +16,11 @@ ############################################################################## ############################################################################## +add_test ( + NAME HL_CPP_ptableTest-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove ${example}.txt +) if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME HL_CPP_ptableTest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () @@ -31,3 +36,4 @@ else () -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () +set_tests_properties (HL_CPP_ptableTest PROPERTIES DEPENDS HL_CPP_ptableTest-clear-objects) diff --git a/hl/examples/CMakeTests.cmake b/hl/examples/CMakeTests.cmake index 407c61c..d0f9018 100644 --- a/hl/examples/CMakeTests.cmake +++ b/hl/examples/CMakeTests.cmake @@ -26,35 +26,32 @@ foreach (h5_file ${HDF5_TEST_FILES}) endforeach () add_custom_target(hl_ex_ex_ds1_files ALL COMMENT "Copying files needed by hl_ex_ex_ds1 tests" DEPENDS ${hl_ex_ex_ds1_files_list}) - # Remove any output file left over from previous test run - add_test ( - NAME HL_ex-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ex_lite1.h5 - ex_lite2.h5 - ex_lite3.h5 - packet_table_FLexample.h5 - ex_image1.h5 - ex_image2.h5 - ex_table_01.h5 - ex_table_02.h5 - ex_table_03.h5 - ex_table_04.h5 - ex_table_05.h5 - ex_table_06.h5 - ex_table_07.h5 - ex_table_08.h5 - ex_table_09.h5 - ex_table_10.h5 - ex_table_11.h5 - ex_table_12.h5 - ex_ds1.h5 - ) - if (last_test) - set_tests_properties (HL_ex-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "HL_ex-clear-objects") +# Remove any output file left over from previous test run +add_test ( + NAME HL_ex-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ex_lite1.h5 + ex_lite2.h5 + ex_lite3.h5 + packet_table_FLexample.h5 + ex_image1.h5 + ex_image2.h5 + ex_table_01.h5 + ex_table_02.h5 + ex_table_03.h5 + ex_table_04.h5 + ex_table_05.h5 + ex_table_06.h5 + ex_table_07.h5 + ex_table_08.h5 + ex_table_09.h5 + ex_table_10.h5 + ex_table_11.h5 + ex_table_12.h5 + ex_ds1.h5 +) +set_tests_properties (HL_ex-clear-objects PROPERTIES FIXTURES_SETUP clear_HL_ex) foreach (example ${examples}) if (HDF5_ENABLE_USING_MEMCHECKER) @@ -73,7 +70,10 @@ foreach (example ${examples}) ) endif () if (last_test) - set_tests_properties (HL_ex_${example} PROPERTIES DEPENDS ${last_test}) + set_tests_properties (HL_ex_${example} PROPERTIES + DEPENDS ${last_test} + FIXTURES_REQUIRED clear_HL_ex + ) endif () set (last_test "HL_ex_${example}") endforeach () diff --git a/hl/fortran/examples/CMakeTests.cmake b/hl/fortran/examples/CMakeTests.cmake index d3a9d0c..b8f40d0 100644 --- a/hl/fortran/examples/CMakeTests.cmake +++ b/hl/fortran/examples/CMakeTests.cmake @@ -21,10 +21,10 @@ add_test ( NAME HL_FORTRAN_f90_ex-clear-objects COMMAND ${CMAKE_COMMAND} -E remove - ex_ds1.h5 - exlite.h5 + ex_ds1.h5 + exlite.h5 ) - +set_tests_properties (HL_FORTRAN_f90_ex-clear-objects PROPERTIES FIXTURES_SETUP clear_HL_FORTRAN_f90_ex) foreach (example ${examples}) if (HDF5_ENABLE_USING_MEMCHECKER) @@ -42,5 +42,7 @@ foreach (example ${examples}) -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () - set_tests_properties (HL_FORTRAN_f90_ex_${example} PROPERTIES DEPENDS HL_FORTRAN_f90_ex-clear-objects) + set_tests_properties (HL_FORTRAN_f90_ex_${example} PROPERTIES + FIXTURES_REQUIRED clear_HL_FORTRAN_f90_ex + ) endforeach () diff --git a/hl/fortran/test/CMakeTests.cmake b/hl/fortran/test/CMakeTests.cmake index 0b81573..0760b92 100644 --- a/hl/fortran/test/CMakeTests.cmake +++ b/hl/fortran/test/CMakeTests.cmake @@ -16,7 +16,7 @@ ############################################################################## ############################################################################## -set (test_CLEANFILES +set (test_hl_fortran_CLEANFILES dsetf1.h5 dsetf2.h5 dsetf3.h5 @@ -28,6 +28,14 @@ set (test_CLEANFILES tstds.h5 ) +# Remove any output file left over from previous test run +add_test ( + NAME HL_FORTRAN_test-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove ${test_hl_fortran_CLEANFILES} +) +set_tests_properties (HL_FORTRAN_test-clear-objects PROPERTIES FIXTURES_SETUP clear_HL_FORTRAN_test) + macro (ADD_H5_FORTRAN_TEST file) if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME HL_FORTRAN_f90_${file} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) @@ -44,16 +52,11 @@ macro (ADD_H5_FORTRAN_TEST file) -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () - set_tests_properties (HL_FORTRAN_f90_${file} PROPERTIES DEPENDS HL_FORTRAN_test-clear-objects) + set_tests_properties (HL_FORTRAN_f90_${file} PROPERTIES + FIXTURES_REQUIRED clear_HL_FORTRAN_test + ) endmacro () -# Remove any output file left over from previous test run -add_test ( - NAME HL_FORTRAN_test-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove ${test_CLEANFILES} -) - foreach (h5_test ${H5_TESTS}) ADD_H5_FORTRAN_TEST(${h5_test}) endforeach () diff --git a/hl/test/CMakeTests.cmake b/hl/test/CMakeTests.cmake index be90206..716a3d7 100644 --- a/hl/test/CMakeTests.cmake +++ b/hl/test/CMakeTests.cmake @@ -43,6 +43,44 @@ foreach (h5_file ${HL_REFERENCE_TEST_FILES}) endforeach () add_custom_target(hl_test_files ALL COMMENT "Copying files needed by hl_test tests" DEPENDS ${hl_test_files_list}) +# Remove any output file left over from previous test run +set (test_hl_CLEANFILES + combine_tables1.h5 + combine_tables2.h5 + file_img1.h5 + file_img2.h5 + test_append.h5 + h5do_compat.h5 + test_detach.h5 + test_ds1.h5 + test_ds2.h5 + test_ds3.h5 + test_ds4.h5 + test_ds5.h5 + test_ds6.h5 + test_ds7.h5 + test_ds8.h5 + test_ds9.h5 + test_ds10.h5 + test_image1.h5 + test_image2.h5 + test_image3.h5 + test_lite1.h5 + test_lite2.h5 + test_lite3.h5 + test_lite4.h5 + test_packet_compress.h5 + test_packet_table.h5 + test_packet_table_vlen.h5 + testfl_packet_table_vlen.h5 + test_table.h5 +) +add_test ( + NAME HL_test-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove ${test_hl_CLEANFILES} +) +set_tests_properties (HL_test-clear-objects PROPERTIES FIXTURES_SETUP clear_test_hl) + # -------------------------------------------------------------------- # Macro used to add a unit test # -------------------------------------------------------------------- @@ -62,54 +100,13 @@ macro (HL_ADD_TEST hl_name) -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () - if (last_test) - set_tests_properties (HL_${hl_name} PROPERTIES DEPENDS ${last_test} + set_tests_properties (HL_${hl_name} PROPERTIES + FIXTURES_REQUIRED clear_test_hl ENVIRONMENT "srcdir=${HDF5_HL_TEST_BINARY_DIR}" WORKING_DIRECTORY ${HDF5_HL_TEST_BINARY_DIR} - ) - endif () + ) endmacro () -# Remove any output file left over from previous test run -add_test ( - NAME HL_test-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - combine_tables1.h5 - combine_tables2.h5 - file_img1.h5 - file_img2.h5 - test_append.h5 - h5do_compat.h5 - test_detach.h5 - test_ds1.h5 - test_ds2.h5 - test_ds3.h5 - test_ds4.h5 - test_ds5.h5 - test_ds6.h5 - test_ds7.h5 - test_ds8.h5 - test_ds9.h5 - test_ds10.h5 - test_image1.h5 - test_image2.h5 - test_image3.h5 - test_lite1.h5 - test_lite2.h5 - test_lite3.h5 - test_lite4.h5 - test_packet_compress.h5 - test_packet_table.h5 - test_packet_table_vlen.h5 - testfl_packet_table_vlen.h5 - test_table.h5 -) -if (last_test) - set_tests_properties (HL_test-clear-objects PROPERTIES DEPENDS ${last_test}) -endif () -set (last_test "HL_test-clear-objects") - HL_add_test (test_lite ) HL_add_test (test_image) HL_add_test (test_file_image) diff --git a/hl/tools/gif2h5/CMakeTests.cmake b/hl/tools/gif2h5/CMakeTests.cmake index ab14864..8537d7c 100644 --- a/hl/tools/gif2h5/CMakeTests.cmake +++ b/hl/tools/gif2h5/CMakeTests.cmake @@ -43,20 +43,32 @@ add_test ( image.gif image24.gif ) +set_tests_properties (HL_TOOLS-clear-objects PROPERTIES FIXTURES_SETUP clear_tools_hl) add_test (NAME HL_TOOLS_gif2h5 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ testfiles/image1.gif image1.h5) -set_tests_properties (HL_TOOLS_gif2h5 PROPERTIES DEPENDS HL_TOOLS-clear-objects) +set_tests_properties (HL_TOOLS_gif2h5 PROPERTIES + FIXTURES_REQUIRED clear_tools_hl +) add_test (NAME HL_TOOLS_h52gif COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ testfiles/h52giftst.h5 image1.gif -i image) -set_tests_properties (HL_TOOLS_h52gif PROPERTIES DEPENDS HL_TOOLS-clear-objects) +set_tests_properties (HL_TOOLS_h52gif PROPERTIES + FIXTURES_REQUIRED clear_tools_hl +) add_test (NAME HL_TOOLS_h52gif_none COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ testfiles/h52giftst.h5 image.gif -i nosuch_image) -set_tests_properties (HL_TOOLS_h52gif_none PROPERTIES WILL_FAIL "true") -set_tests_properties (HL_TOOLS_h52gif_none PROPERTIES DEPENDS HL_TOOLS-clear-objects) +set_tests_properties (HL_TOOLS_h52gif_none PROPERTIES + WILL_FAIL "true" + FIXTURES_REQUIRED clear_tools_hl +) #add_test (NAME HL_TOOLS_h52gifpal COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ testfiles/h52giftst.h5 image.gif -i palette) -#set_tests_properties (HL_TOOLS_h52gifpal PROPERTIES WILL_FAIL "true") +#set_tests_properties (HL_TOOLS_h52gifpal PROPERTIES +# WILL_FAIL "true" +# FIXTURES_REQUIRED clear_tools_hl +#) add_test (NAME HL_TOOLS_h52gif24bits COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ testfiles/ex_image2.h5 image24.gif -i image24bitpixel) -set_tests_properties (HL_TOOLS_h52gif24bits PROPERTIES WILL_FAIL "true") -set_tests_properties (HL_TOOLS_h52gif24bits PROPERTIES DEPENDS HL_TOOLS-clear-objects) +set_tests_properties (HL_TOOLS_h52gif24bits PROPERTIES + WILL_FAIL "true" + FIXTURES_REQUIRED clear_tools_hl +) diff --git a/hl/tools/h5watch/CMakeTests.cmake b/hl/tools/h5watch/CMakeTests.cmake index e563be4..0424140 100644 --- a/hl/tools/h5watch/CMakeTests.cmake +++ b/hl/tools/h5watch/CMakeTests.cmake @@ -88,7 +88,10 @@ add_custom_target(H5WATCH_files ALL COMMENT "Copying files needed by H5WATCH tes -D "TEST_REFERENCE=${resultfile}.ddl" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5WATCH_ARGS-h5watch-${resultfile} PROPERTIES DEPENDS ${last_test}) + set_tests_properties (H5WATCH_ARGS-h5watch-${resultfile} PROPERTIES + DEPENDS ${last_test} + FIXTURES_REQUIRED gen_test_watch + ) set (last_test "H5WATCH_ARGS-h5watch-${resultfile}") endif () endmacro () @@ -108,7 +111,10 @@ add_custom_target(H5WATCH_files ALL COMMENT "Copying files needed by H5WATCH tes -D "TEST_ERRREF=${resultfile}.err" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5WATCH_ARGS-h5watch-${resultfile} PROPERTIES DEPENDS ${last_test}) + set_tests_properties (H5WATCH_ARGS-h5watch-${resultfile} PROPERTIES + DEPENDS ${last_test} + FIXTURES_REQUIRED gen_test_watch + ) set (last_test "H5WATCH_ARGS-h5watch-${resultfile}") endif () endmacro () @@ -133,7 +139,11 @@ add_custom_target(H5WATCH_files ALL COMMENT "Copying files needed by H5WATCH tes -D "TEST_REFERENCE=${resultfile}.txt" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5WATCH-${resultfile} PROPERTIES DEPENDS H5WATCH-${resultfile}-clear-objects) + set_tests_properties (H5WATCH-${resultfile} PROPERTIES + DEPENDS H5WATCH-${resultfile}-clear-objects + FIXTURES_REQUIRED gen_test_watch + ) + set (last_test "H5WATCH-${resultfile}") endif () endmacro () @@ -151,9 +161,7 @@ if (NOT SWMR_INCOMPAT) # Remove any output file left over from previous test run add_test ( NAME H5WATCH-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - WATCH.h5 + COMMAND ${CMAKE_COMMAND} -E remove WATCH.h5 ) if (last_test) set_tests_properties (H5WATCH-clearall-objects PROPERTIES DEPENDS ${last_test}) @@ -181,8 +189,11 @@ if (NOT SWMR_INCOMPAT) ################################################################################################# # create the output files to be used. add_test (NAME H5WATCH-h5watchgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - set_tests_properties (H5WATCH-h5watchgentest PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - set_tests_properties (H5WATCH-h5watchgentest PROPERTIES DEPENDS "H5WATCH-clearall-objects") + set_tests_properties (H5WATCH-h5watchgentest PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + DEPENDS "H5WATCH-clearall-objects" + ) + set_tests_properties (H5WATCH-h5watchgentest PROPERTIES FIXTURES_SETUP gen_test_watch) set (last_test "H5WATCH-h5watchgentest") # Test on --help options diff --git a/test/CMakePassthroughVOLTests.cmake b/test/CMakePassthroughVOLTests.cmake index 9863147..e1b1f92 100644 --- a/test/CMakePassthroughVOLTests.cmake +++ b/test/CMakePassthroughVOLTests.cmake @@ -90,13 +90,6 @@ add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HD if ("${voltest}" STREQUAL "flush1" OR "${voltest}" STREQUAL "flush2") if ("${volname}" STREQUAL "multi" OR "${volname}" STREQUAL "split") if (NOT BUILD_SHARED_LIBS AND NOT ${HDF_CFG_NAME} MATCHES "Debug") - add_test ( - NAME VOL-${volname}-${voltest}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${volname}/${volname}-${voltest}.out - ${volname}/${volname}-${voltest}.out.err - ) add_test (NAME VOL-${volname}-${voltest} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -109,7 +102,6 @@ add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HD -P "${HDF_RESOURCES_DIR}/volTest.cmake" ) set_tests_properties (VOL-${volname}-${voltest} PROPERTIES - DEPENDS VOL-${volname}-${voltest}-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} ) @@ -119,13 +111,6 @@ add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HD ) endif () else () - add_test ( - NAME VOL-${volname}-${voltest}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${volname}/${volname}-${voltest}.out - ${volname}/${volname}-${voltest}.out.err - ) add_test (NAME VOL-${volname}-${voltest} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -138,19 +123,11 @@ add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HD -P "${HDF_RESOURCES_DIR}/volTest.cmake" ) set_tests_properties (VOL-${volname}-${voltest} PROPERTIES - DEPENDS VOL-${volname}-${voltest}-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} ) endif () else () - add_test ( - NAME VOL-${volname}-${voltest}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${volname}/${volname}-${voltest}.out - ${volname}/${volname}-${voltest}.out.err - ) add_test (NAME VOL-${volname}-${voltest} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -163,7 +140,6 @@ add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HD -P "${HDF_RESOURCES_DIR}/volTest.cmake" ) set_tests_properties (VOL-${volname}-${voltest} PROPERTIES - DEPENDS VOL-${volname}-${voltest}-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname};HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} ) @@ -172,13 +148,6 @@ add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HD macro (DO_VOL_TEST voltest volname volinfo resultcode) #message(STATUS "${voltest}-${volname} with ${volinfo}") - add_test ( - NAME VOL-${volname}-${voltest}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${volname}/${volname}-${voltest}.out - ${volname}/${volname}-${voltest}.out.err - ) add_test (NAME VOL-${volname}-${voltest} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -191,7 +160,6 @@ add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HD -P "${HDF_RESOURCES_DIR}/volTest.cmake" ) set_tests_properties (VOL-${volname}-${voltest} PROPERTIES - DEPENDS VOL-${volname}-${voltest}-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} ) @@ -216,13 +184,6 @@ add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HD set_tests_properties (VOL-${volname}-cache PROPERTIES TIMEOUT ${CTEST_VERY_LONG_TIMEOUT}) endif () if (HDF5_TEST_FHEAP_PASSTHROUGH_VOL) - add_test ( - NAME VOL-${volname}-fheap-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${volname}/${volname}-fheap.out - ${volname}/${volname}-fheap.out.err - ) add_test (NAME VOL-${volname}-fheap COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -235,7 +196,6 @@ add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HD -P "${HDF_RESOURCES_DIR}/volTest.cmake" ) set_tests_properties (VOL-${volname}-fheap PROPERTIES - DEPENDS VOL-${volname}-fheap-clear-objects TIMEOUT ${CTEST_VERY_LONG_TIMEOUT} ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname};HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index 8537c46..49fabd8 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -198,13 +198,12 @@ set (testhdf5_CLEANFILES ) # Remove any output file left over from previous test run -add_test (NAME H5TEST-clear-testhdf5-objects - COMMAND ${CMAKE_COMMAND} - -E remove ${testhdf5_CLEANFILES} - WORKING_DIRECTORY - ${HDF5_TEST_BINARY_DIR}/H5TEST +add_test ( + NAME H5TEST-testhdf5-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove ${testhdf5_CLEANFILES} + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) -set_tests_properties (H5TEST-clear-testhdf5-objects PROPERTIES FIXTURES_SETUP clear_testhdf5) +set_tests_properties (H5TEST-testhdf5-clear-objects PROPERTIES FIXTURES_SETUP clear_testhdf5) add_test (NAME H5TEST-testhdf5-base COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -x heap -x file -x select) set_tests_properties (H5TEST-testhdf5-base PROPERTIES @@ -451,14 +450,12 @@ set (test_CLEANFILES ) # Remove any output file left over from previous test run -add_test (NAME H5TEST-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${test_CLEANFILES} - WORKING_DIRECTORY - ${HDF5_TEST_BINARY_DIR}/H5TEST +add_test ( + NAME H5TEST-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove ${test_CLEANFILES} + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) -set_tests_properties (H5TEST-clear-objects PROPERTIES FIXTURES_SETUP clear_objects) +set_tests_properties (H5TEST-clear-objects PROPERTIES FIXTURES_SETUP clear_H5TEST) set (H5TEST_SEPARATE_TESTS testhdf5 @@ -498,7 +495,7 @@ foreach (h5_test ${H5_TESTS}) ) endif () set_tests_properties (H5TEST-${h5_test} PROPERTIES - FIXTURES_REQUIRED clear_objects + FIXTURES_REQUIRED clear_H5TEST ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) @@ -513,14 +510,12 @@ set_tests_properties (H5TEST-objcopy PROPERTIES TIMEOUT ${CTEST_VERY_LONG_TIMEOU #-- Adding test for cache if (NOT CYGWIN) - add_test (NAME H5TEST-clear-cache-objects - COMMAND ${CMAKE_COMMAND} - -E remove - cache_test.h5 - WORKING_DIRECTORY - ${HDF5_TEST_BINARY_DIR}/H5TEST + add_test ( + NAME H5TEST-cache-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove cache_test.h5 + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) - set_tests_properties (H5TEST-clear-cache-objects PROPERTIES FIXTURES_SETUP cache_clear_objects) + set_tests_properties (H5TEST-cache-clear-objects PROPERTIES FIXTURES_SETUP clear_cache) if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME H5TEST-cache COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () @@ -537,7 +532,7 @@ if (NOT CYGWIN) ) endif () set_tests_properties (H5TEST-cache PROPERTIES - FIXTURES_REQUIRED cache_clear_objects + FIXTURES_REQUIRED clear_cache ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) @@ -547,17 +542,14 @@ endif () if (TEST_CACHE_IMAGE) #-- Adding test for cache_image add_test ( - NAME H5TEST-clear-cache_image-objects - COMMAND ${CMAKE_COMMAND} - -E remove - cache_image_test.h5 - WORKING_DIRECTORY - ${HDF5_TEST_BINARY_DIR}/H5TEST + NAME H5TEST-cache_image-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove cache_image_test.h5 + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) - set_tests_properties (H5TEST-clear-cache_image-objects PROPERTIES FIXTURES_SETUP cache_image_clear_objects) - add_test (NAME H5TEST-cache_image COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) + set_tests_properties (H5TEST-cache_image-clear-objects PROPERTIES FIXTURES_SETUP clear_cache_image) + add_test (NAME H5TEST_cache_image COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) set_tests_properties (H5TEST-cache_image PROPERTIES - FIXTURES_REQUIRED cache_image_clear_objects + FIXTURES_REQUIRED clear_cache_image ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) @@ -565,9 +557,8 @@ endif () #-- Adding test for external_env add_test ( - NAME H5TEST-clear-external_env-objects - COMMAND ${CMAKE_COMMAND} - -E remove + NAME H5TEST-external_env-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove extern_1r.raw extern_2r.raw extern_3r.raw @@ -576,12 +567,10 @@ add_test ( extern_2w.raw extern_3w.raw extern_4w.raw - external_env.txt - external_env.out WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) -set_tests_properties (H5TEST-clear-external_env-objects PROPERTIES FIXTURES_SETUP external_env_clear_objects) +set_tests_properties (H5TEST-external_env-clear-objects PROPERTIES FIXTURES_SETUP clear_external_env) if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME H5TEST-external_env COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () @@ -600,25 +589,22 @@ else () ) endif () set_tests_properties (H5TEST-external_env PROPERTIES - FIXTURES_REQUIRED external_env_clear_objects + FIXTURES_REQUIRED clear_external_env ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) #-- Adding test for vds_env add_test ( - NAME H5TEST-clear-vds_env-objects - COMMAND ${CMAKE_COMMAND} - -E remove + NAME H5TEST-vds_env-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove vds_virt_0.h5 vds_virt_3.h5 vds_src_2.h5 - vds_env.txt - vds_env.out WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) -set_tests_properties (H5TEST-clear-vds_env-objects PROPERTIES FIXTURES_SETUP vds_env_clear_objects) +set_tests_properties (H5TEST-vds_env-clear-objects PROPERTIES FIXTURES_SETUP clear_vds_env) if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME H5TEST-vds_env COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () @@ -637,15 +623,14 @@ else () ) endif () set_tests_properties (H5TEST-vds_env PROPERTIES - FIXTURES_REQUIRED vds_env_clear_objects + FIXTURES_REQUIRED clear_vds_env ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) #-- Adding test for flush1/2 -add_test (NAME H5TEST-clear-flush-objects - COMMAND ${CMAKE_COMMAND} - -E remove +add_test (NAME H5TEST-flush-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove flush.h5 flush-swmr.h5 noflush.h5 @@ -657,6 +642,7 @@ add_test (NAME H5TEST-clear-flush-objects WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) +set_tests_properties (H5TEST-flush-clear-objects PROPERTIES FIXTURES_SETUP clear_flush) if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME H5TEST-flush1 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () @@ -672,7 +658,7 @@ else () ) endif () set_tests_properties (H5TEST-flush1 PROPERTIES - DEPENDS H5TEST-clear-flush-objects + FIXTURES_REQUIRED clear_flush ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) @@ -690,7 +676,10 @@ else () -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () -set_tests_properties (H5TEST-flush2 PROPERTIES DEPENDS H5TEST-flush1) +set_tests_properties (H5TEST-flush2 PROPERTIES + FIXTURES_REQUIRED clear_flush + DEPENDS H5TEST-flush1 +) #-- Adding test for tcheck_version add_test (NAME H5TEST-tcheck_version-major COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ "-tM") @@ -743,49 +732,34 @@ set_tests_properties (H5TEST-tcheck_version-release PROPERTIES #-- Adding test for filenotclosed add_test ( - NAME H5TEST-clear-filenotclosed-objects - COMMAND ${CMAKE_COMMAND} - -E remove - filenotclosed.h5 - WORKING_DIRECTORY - ${HDF5_TEST_BINARY_DIR}/H5TEST + NAME H5TEST-filenotclosed-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove filenotclosed.h5 + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) -set_tests_properties (H5TEST-clear-filenotclosed-objects PROPERTIES FIXTURES_SETUP filenotclosed_clear_objects) +set_tests_properties (H5TEST-filenotclosed-clear-objects PROPERTIES FIXTURES_SETUP clear_filenotclosed) add_test (NAME H5TEST-filenotclosed COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) set_tests_properties (H5TEST-filenotclosed PROPERTIES - FIXTURES_REQUIRED filenotclosed_clear_objects + FIXTURES_REQUIRED clear_filenotclosed ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) #-- Adding test for del_many_dense_attrs add_test ( - NAME H5TEST-clear-del_many_dense_attrs-objects - COMMAND ${CMAKE_COMMAND} - -E remove - del_many_dense_attrs.h5 - WORKING_DIRECTORY - ${HDF5_TEST_BINARY_DIR}/H5TEST + NAME H5TEST-del_many_dense_attrs-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove del_many_dense_attrs.h5 + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) -set_tests_properties (H5TEST-clear-del_many_dense_attrs-objects PROPERTIES FIXTURES_SETUP del_many_dense_attrs_clear_objects) +set_tests_properties (H5TEST-del_many_dense_attrs-clear-objects PROPERTIES FIXTURES_SETUP clear_del_many_dense_attrs) add_test (NAME H5TEST-del_many_dense_attrs COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) set_tests_properties (H5TEST-del_many_dense_attrs PROPERTIES - FIXTURES_REQUIRED del_many_dense_attrs_clear_objects + FIXTURES_REQUIRED clear_del_many_dense_attrs ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) #-- Adding test for err_compat -if (HDF5_ENABLE_DEPRECATED_SYMBOLS) - add_test (NAME H5TEST-clear-err_compat-objects - COMMAND ${CMAKE_COMMAND} - -E remove - err_compat.txt - err_compat.txt.err - WORKING_DIRECTORY - ${HDF5_TEST_BINARY_DIR}/H5TEST - ) - set_tests_properties (H5TEST-clear-err_compat-objects PROPERTIES FIXTURES_SETUP err_compat_clear_objects) +if (HDF5_ENABLE_DEPRECATED_SYMBOLS AND NOT MINGW) add_test (NAME H5TEST-err_compat COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" @@ -799,23 +773,13 @@ if (HDF5_ENABLE_DEPRECATED_SYMBOLS) -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5TEST-err_compat PROPERTIES - FIXTURES_REQUIRED err_compat_clear_objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) endif () #-- Adding test for error_test -add_test (NAME H5TEST-clear-error_test-objects - COMMAND ${CMAKE_COMMAND} - -E remove - error_test.txt - error_test.txt.err - WORKING_DIRECTORY - ${HDF5_TEST_BINARY_DIR}/H5TEST -) -set_tests_properties (H5TEST-clear-error_test-objects PROPERTIES FIXTURES_SETUP error_test_clear_objects) -if (HDF5_USE_16_API_DEFAULT) +if (HDF5_USE_16_API_DEFAULT OR MINGW) add_test ( NAME H5TEST-error_test COMMAND ${CMAKE_COMMAND} -E echo "SKIP $" @@ -835,25 +799,21 @@ else () -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5TEST-error_test PROPERTIES - FIXTURES_REQUIRED error_test_clear_objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5_PLUGIN_PRELOAD=::" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) endif () #-- Adding test for links_env -add_test (NAME H5TEST-clear-links_env-objects - COMMAND ${CMAKE_COMMAND} - -E remove - links_env.txt - links_env.txt.err +add_test (NAME H5TEST-links_env-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove extlinks_env0.h5 extlinks_env1.h5 tmp/extlinks_env1.h5 WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) -set_tests_properties (H5TEST-clear-links_env-objects PROPERTIES FIXTURES_SETUP links_env_clear_objects) +set_tests_properties (H5TEST-links_env-clear-objects PROPERTIES FIXTURES_SETUP clear_links_env) if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME H5TEST-links_env COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) else () @@ -871,7 +831,7 @@ else () ) endif () set_tests_properties (H5TEST-links_env PROPERTIES - FIXTURES_REQUIRED links_env_clear_objects + FIXTURES_REQUIRED clear_links_env ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5_EXT_PREFIX=.:tmp" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) @@ -938,16 +898,12 @@ if (ENABLE_EXTENDED_TESTS) file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST/flushrefresh_test") find_package (Perl) if (PERL_FOUND) - add_test (NAME H5TEST-clear-testflushrefresh-objects - COMMAND ${CMAKE_COMMAND} - -E remove - flushrefresh.txt - flushrefresh.txt.err - flushrefresh.h5 - WORKING_DIRECTORY - ${HDF5_TEST_BINARY_DIR}/H5TEST/flushrefresh_test + add_test ( + NAME H5TEST-testflushrefresh-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove flushrefresh.h5 + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST/flushrefresh_test ) - set_tests_properties (H5TEST-clear-testflushrefresh-objects PROPERTIES FIXTURES_SETUP testflushrefresh_clear_objects) + set_tests_properties (H5TEST-testflushrefresh-clear-objects PROPERTIES FIXTURES_SETUP clear_testflushrefresh) add_test (NAME H5TEST-testflushrefresh COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" @@ -963,7 +919,7 @@ if (ENABLE_EXTENDED_TESTS) -P "${HDF5_TEST_SOURCE_DIR}/flushrefreshTest.cmake" ) set_tests_properties (H5TEST-testflushrefresh PROPERTIES - FIXTURES_REQUIRED testflushrefresh_clear_objects + FIXTURES_REQUIRED clear_testflushrefresh ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST/flushrefresh_test" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST/flushrefresh_test ) diff --git a/test/CMakeVFDTests.cmake b/test/CMakeVFDTests.cmake index 2767bdc..cf938f5 100644 --- a/test/CMakeVFDTests.cmake +++ b/test/CMakeVFDTests.cmake @@ -93,13 +93,6 @@ add_custom_target(HDF5_VFDTEST_LIB_files ALL COMMENT "Copying files needed by HD if ("${vfdtest}" STREQUAL "flush1" OR "${vfdtest}" STREQUAL "flush2") if ("${vfdname}" STREQUAL "multi" OR "${vfdname}" STREQUAL "split") if (NOT BUILD_SHARED_LIBS AND NOT HDF_CFG_NAME MATCHES "Debug") - add_test ( - NAME VFD-${vfdname}-${vfdtest}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${vfdname}/${vfdname}-${vfdtest}.out - ${vfdname}/${vfdname}-${vfdtest}.out.err - ) add_test (NAME VFD-${vfdname}-${vfdtest} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -112,7 +105,6 @@ add_custom_target(HDF5_VFDTEST_LIB_files ALL COMMENT "Copying files needed by HD -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-${vfdtest} PROPERTIES - DEPENDS VFD-${vfdname}-${vfdtest}-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) @@ -122,13 +114,6 @@ add_custom_target(HDF5_VFDTEST_LIB_files ALL COMMENT "Copying files needed by HD ) endif () else () - add_test ( - NAME VFD-${vfdname}-${vfdtest}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${vfdname}/${vfdname}-${vfdtest}.out - ${vfdname}/${vfdname}-${vfdtest}.out.err - ) add_test (NAME VFD-${vfdname}-${vfdtest} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -141,19 +126,11 @@ add_custom_target(HDF5_VFDTEST_LIB_files ALL COMMENT "Copying files needed by HD -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-${vfdtest} PROPERTIES - DEPENDS VFD-${vfdname}-${vfdtest}-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) endif () else () - add_test ( - NAME VFD-${vfdname}-${vfdtest}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${vfdname}/${vfdname}-${vfdtest}.out - ${vfdname}/${vfdname}-${vfdtest}.out.err - ) add_test (NAME VFD-${vfdname}-${vfdtest} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -166,7 +143,6 @@ add_custom_target(HDF5_VFDTEST_LIB_files ALL COMMENT "Copying files needed by HD -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-${vfdtest} PROPERTIES - DEPENDS VFD-${vfdname}-${vfdtest}-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname};HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) @@ -174,13 +150,6 @@ add_custom_target(HDF5_VFDTEST_LIB_files ALL COMMENT "Copying files needed by HD endmacro () macro (DO_VFD_TEST vfdtest vfdname resultcode) - add_test ( - NAME VFD-${vfdname}-${vfdtest}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${vfdname}/${vfdname}-${vfdtest}.out - ${vfdname}/${vfdname}-${vfdtest}.out.err - ) add_test (NAME VFD-${vfdname}-${vfdtest} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -193,7 +162,6 @@ add_custom_target(HDF5_VFDTEST_LIB_files ALL COMMENT "Copying files needed by HD -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-${vfdtest} PROPERTIES - DEPENDS VFD-${vfdname}-${vfdtest}-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) @@ -217,13 +185,6 @@ add_custom_target(HDF5_VFDTEST_LIB_files ALL COMMENT "Copying files needed by HD set_tests_properties (VFD-${vfdname}-cache PROPERTIES TIMEOUT ${CTEST_VERY_LONG_TIMEOUT}) endif () if (HDF5_TEST_FHEAP_VFD) - add_test ( - NAME VFD-${vfdname}-fheap-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${vfdname}/${vfdname}-fheap.out - ${vfdname}/${vfdname}-fheap.out.err - ) add_test (NAME VFD-${vfdname}-fheap COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -236,7 +197,6 @@ add_custom_target(HDF5_VFDTEST_LIB_files ALL COMMENT "Copying files needed by HD -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-fheap PROPERTIES - DEPENDS VFD-${vfdname}-fheap-clear-objects TIMEOUT ${CTEST_VERY_LONG_TIMEOUT} ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname};HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} diff --git a/testpar/CMakeTests.cmake b/testpar/CMakeTests.cmake index 0702d13..ad244b5 100644 --- a/testpar/CMakeTests.cmake +++ b/testpar/CMakeTests.cmake @@ -16,11 +16,10 @@ ############################################################################## ############################################################################## # Remove any output file left over from previous test run -add_test (NAME MPI_TEST-clear-testphdf5-objects - COMMAND ${CMAKE_COMMAND} - -E remove ParaTest.h5 - WORKING_DIRECTORY - ${HDF5_TEST_PAR_BINARY_DIR} +add_test ( + NAME MPI_TEST-clear-testphdf5-objects + COMMAND ${CMAKE_COMMAND} -E remove ParaTest.h5 + WORKING_DIRECTORY ${HDF5_TEST_PAR_BINARY_DIR} ) set_tests_properties (MPI_TEST-clear-testphdf5-objects PROPERTIES FIXTURES_SETUP par_clear_testphdf5) @@ -93,12 +92,10 @@ set (test_par_CLEANFILES ) # Remove any output file left over from previous test run -add_test (NAME MPI_TEST-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${test_par_CLEANFILES} - WORKING_DIRECTORY - ${HDF5_TEST_PAR_BINARY_DIR} +add_test ( + NAME MPI_TEST-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove ${test_par_CLEANFILES} + WORKING_DIRECTORY ${HDF5_TEST_PAR_BINARY_DIR} ) set_tests_properties (MPI_TEST-clear-objects PROPERTIES FIXTURES_SETUP par_clear_objects) diff --git a/testpar/CMakeVFDTests.cmake b/testpar/CMakeVFDTests.cmake index 1c0f2e8..7db99de 100644 --- a/testpar/CMakeVFDTests.cmake +++ b/testpar/CMakeVFDTests.cmake @@ -41,13 +41,6 @@ endforeach () if (NOT HDF5_ENABLE_USING_MEMCHECKER) foreach (h5_test ${H5P_VFD_TESTS}) add_test ( - NAME MPI_TEST_VFD-${vfdname}-${h5_test}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${vfdname}/${vfdname}-${h5_test}.out - ${vfdname}/${vfdname}-${h5_test}.out.err - ) - add_test ( NAME MPI_TEST_VFD-${vfdname}-${h5_test} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -60,7 +53,6 @@ endforeach () -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (MPI_TEST_VFD-${vfdname}-${h5_test} PROPERTIES - DEPENDS MPI_TEST_VFD-${vfdname}-${h5_test}-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_PAR_BINARY_DIR}/${vfdname}" WORKING_DIRECTORY ${HDF5_TEST_PAR_BINARY_DIR}/${vfdname} ) diff --git a/tools/test/h5copy/CMakeTests.cmake b/tools/test/h5copy/CMakeTests.cmake index 3fabdf6..b0d1615 100644 --- a/tools/test/h5copy/CMakeTests.cmake +++ b/tools/test/h5copy/CMakeTests.cmake @@ -65,9 +65,7 @@ # Remove any output file left over from previous test run add_test ( NAME H5COPY_F-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ./testfiles/${testname}.out.h5 + COMMAND ${CMAKE_COMMAND} -E remove ./testfiles/${testname}.out.h5 ) endif () @@ -101,9 +99,7 @@ # Remove any output file left over from previous test run add_test ( NAME H5COPY-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ./testfiles/${testname}.out.h5 + COMMAND ${CMAKE_COMMAND} -E remove ./testfiles/${testname}.out.h5 ) endif () @@ -147,9 +143,7 @@ # Remove any output file left over from previous test run add_test ( NAME H5COPY-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ./testfiles/${testname}.out.h5 + COMMAND ${CMAKE_COMMAND} -E remove ./testfiles/${testname}.out.h5 ) endif () @@ -188,9 +182,7 @@ # Remove any output file left over from previous test run add_test ( NAME H5COPY_SAME-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ./testfiles/${testname}.out.h5 + COMMAND ${CMAKE_COMMAND} -E remove ./testfiles/${testname}.out.h5 ) endif () @@ -242,11 +234,7 @@ # Remove any output file left over from previous test run add_test ( NAME H5COPY-CMP-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ./testfiles/${testname}.out.h5 - ./testfiles/${testname}.out.out - ./testfiles/${testname}.out.out.err + COMMAND ${CMAKE_COMMAND} -E remove ./testfiles/${testname}.out.h5 ) add_test ( NAME H5COPY-CMP-${testname} @@ -271,13 +259,7 @@ # Remove any output file left over from previous test run add_test ( NAME H5COPY_UD-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${testname}.out.h5 - testfiles/${infile}.out - testfiles/${infile}.out.err - testfiles/${testname}.out.h5.out - testfiles/${testname}.out.h5.out.err + COMMAND ${CMAKE_COMMAND} -E remove testfiles/${testname}.out.h5 ) if (${resultcode} EQUAL 2) add_test ( @@ -340,13 +322,7 @@ # Remove any output file left over from previous test run add_test ( NAME H5COPY_UD_ERR-${testname}-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${testname}_ERR.out.h5 - testfiles/${infile}_ERR.out - testfiles/${infile}_ERR.out.err - testfiles/${testname}_ERR.out.h5.out - testfiles/${testname}_ERR.out.h5.out.err + COMMAND ${CMAKE_COMMAND} -E remove testfiles/${testname}_ERR.out.h5 ) if (${resultcode} EQUAL 2) add_test ( @@ -424,8 +400,7 @@ # Remove any output file left over from previous test run add_test ( NAME H5COPY-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove + COMMAND ${CMAKE_COMMAND} -E remove simple.out.h5 chunk.out.h5 compact.out.h5 @@ -458,8 +433,6 @@ samefile1.out.h5 samefile2.out.h5 h5copy_misc1.out.h5 - h5copy_misc1.out.out - h5copy_misc1.out.out.err ) set_tests_properties (H5COPY-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") if (last_test) diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake index 4e5b2ef..93dfd72 100644 --- a/tools/test/h5diff/CMakeTests.cmake +++ b/tools/test/h5diff/CMakeTests.cmake @@ -374,17 +374,6 @@ set_tests_properties (H5DIFF-${resultfile} PROPERTIES DEPENDS ${last_test}) endif () else () - # Remove any output file left over from previous test run - add_test ( - NAME H5DIFF-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${resultfile}.out - testfiles/${resultfile}.out.err - ) - if (last_test) - set_tests_properties (H5DIFF-${resultfile}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5DIFF-${resultfile} COMMAND "${CMAKE_COMMAND}" @@ -398,7 +387,9 @@ -D "TEST_APPEND=EXIT CODE:" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5DIFF-${resultfile} PROPERTIES DEPENDS H5DIFF-${resultfile}-clear-objects) + if (last_test) + set_tests_properties (H5DIFF-${resultfile} PROPERTIES DEPENDS ${last_test}) + endif () endif () if (H5_HAVE_PARALLEL) ADD_PH5_TEST (${resultfile} ${resultcode} ${ARGN}) @@ -417,17 +408,6 @@ set_tests_properties (MPI_TEST_H5DIFF-${resultfile} PROPERTIES DEPENDS ${last_test}) endif () else () - # Remove any output file left over from previous test run - add_test ( - NAME MPI_TEST_H5DIFF-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - PAR/testfiles/${resultfile}.out - PAR/testfiles/${resultfile}.out.err - ) - if (last_test) - set_tests_properties (MPI_TEST_H5DIFF-${resultfile}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME MPI_TEST_H5DIFF-${resultfile} COMMAND "${CMAKE_COMMAND}" @@ -443,21 +423,15 @@ -D "TEST_SORT_COMPARE=TRUE" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (MPI_TEST_H5DIFF-${resultfile} PROPERTIES DEPENDS MPI_TEST_H5DIFF-${resultfile}-clear-objects) + if (last_test) + set_tests_properties (MPI_TEST_H5DIFF-${resultfile} PROPERTIES DEPENDS ${last_test}) + endif () set (last_test "PH5DIFF-${resultfile}") endif () endmacro () macro (ADD_H5_UD_TEST testname resultcode resultfile) if (NOT HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5DIFF_UD-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${resultfile}.out - testfiles/${resultfile}.out.err - ) if (${resultcode} EQUAL 2) add_test ( NAME H5DIFF_UD-${testname} @@ -493,7 +467,9 @@ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () - set_tests_properties (H5DIFF_UD-${testname} PROPERTIES DEPENDS H5DIFF_UD-${testname}-clear-objects) + if (last_test) + set_tests_properties (H5DIFF_UD-${testname} PROPERTIES DEPENDS ${last_test}) + endif () endif () endmacro () diff --git a/tools/test/h5dump/CMakeTests.cmake b/tools/test/h5dump/CMakeTests.cmake index 7a3fdd6..84016f9 100644 --- a/tools/test/h5dump/CMakeTests.cmake +++ b/tools/test/h5dump/CMakeTests.cmake @@ -414,17 +414,6 @@ endif () set (last_test "H5DUMP-${testname}") else () - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/std/h5dump-${testname}.out - testfiles/std/h5dump-${testname}.out.err - ) - if (last_test) - set_tests_properties (H5DUMP-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5DUMP-${testname} COMMAND "${CMAKE_COMMAND}" @@ -437,7 +426,9 @@ -D "TEST_REFERENCE=h5dump-${testname}.txt" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5DUMP-${testname} PROPERTIES DEPENDS H5DUMP-${testname}-clear-objects) + if (last_test) + set_tests_properties (H5DUMP-${testname} PROPERTIES DEPENDS ${last_test}) + endif () endif () endmacro () @@ -469,11 +460,7 @@ else () add_test ( NAME H5DUMP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.bin - ${resultfile}.out - ${resultfile}.out.err + COMMAND ${CMAKE_COMMAND} -E remove ${resultfile}.bin ) set_tests_properties (H5DUMP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") add_test ( @@ -506,11 +493,7 @@ else () add_test ( NAME H5DUMP-N-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}-N.bin - ${resultfile}-N.out - ${resultfile}-N.out.err + COMMAND ${CMAKE_COMMAND} -E remove ${resultfile}-N.bin ) set_tests_properties (H5DUMP-N-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") add_test ( @@ -543,11 +526,7 @@ else () add_test ( NAME H5DUMP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.txt - ${resultfile}.out - ${resultfile}.out.err + COMMAND ${CMAKE_COMMAND} -E remove ${resultfile}.txt ) set_tests_properties (H5DUMP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") add_test ( @@ -566,8 +545,7 @@ if(NOT CMAKE_VERSION VERSION_LESS "3.14.0") add_test ( NAME H5DUMP-${resultfile}-output-cmp - COMMAND ${CMAKE_COMMAND} - -E compare_files --ignore-eol ${resultfile}.txt ${resultfile}.exp + COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${resultfile}.txt ${resultfile}.exp ) set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES DEPENDS H5DUMP-${resultfile}) @@ -589,12 +567,9 @@ else () add_test ( NAME H5DUMP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove + COMMAND ${CMAKE_COMMAND} -E remove ${ddlfile}.txt ${resultfile}.txt - ${resultfile}.out - ${resultfile}.out.err ) set_tests_properties (H5DUMP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") add_test ( @@ -613,15 +588,13 @@ if(NOT CMAKE_VERSION VERSION_LESS "3.14.0") add_test ( NAME H5DUMP-${resultfile}-output-cmp - COMMAND ${CMAKE_COMMAND} - -E compare_files --ignore-eol ${resultfile}.txt ${resultfile}.exp + COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${resultfile}.txt ${resultfile}.exp ) set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES DEPENDS H5DUMP-${resultfile}) add_test ( NAME H5DUMP-${resultfile}-output-cmp-ddl - COMMAND ${CMAKE_COMMAND} - -E compare_files --ignore-eol ${ddlfile}.txt ${ddlfile}.exp + COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${ddlfile}.txt ${ddlfile}.exp ) set_tests_properties (H5DUMP-${resultfile}-output-cmp-ddl PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") set_tests_properties (H5DUMP-${resultfile}-output-cmp-ddl PROPERTIES DEPENDS H5DUMP-${resultfile}-output-cmp) @@ -633,8 +606,7 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5DUMP-output-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove ${resultfile}.txt + COMMAND ${CMAKE_COMMAND} -E remove ${resultfile}.txt ) set_tests_properties (H5DUMP-output-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") add_test ( @@ -646,8 +618,7 @@ if(NOT CMAKE_VERSION VERSION_LESS "3.14.0") add_test ( NAME H5DUMP-output-cmp-${resultfile} - COMMAND ${CMAKE_COMMAND} - -E compare_files --ignore-eol ${resultfile}.txt ${resultfile}.exp + COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${resultfile}.txt ${resultfile}.exp ) set_tests_properties (H5DUMP-output-cmp-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") set_tests_properties (H5DUMP-output-cmp-${resultfile} PROPERTIES DEPENDS H5DUMP-output-${resultfile}) @@ -657,15 +628,6 @@ macro (ADD_H5_MASK_TEST resultfile resultcode) if (NOT HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.out - ${resultfile}.out.err - ) - set_tests_properties (H5DUMP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") add_test ( NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" @@ -679,21 +641,11 @@ -D "TEST_MASK_ERROR=true" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") endif () endmacro () macro (ADD_H5_GREP_TEST resultfile resultcode result_check) if (NOT HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.out - ${resultfile}.out.err - ) - set_tests_properties (H5DUMP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") add_test ( NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" @@ -706,21 +658,11 @@ -D "TEST_REFERENCE=${result_check}" -P "${HDF_RESOURCES_EXT_DIR}/grepTest.cmake" ) - set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") endif () endmacro () macro (ADD_H5ERR_MASK_TEST resultfile resultcode result_errcheck) if (NOT HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.out - ${resultfile}.out.err - ) - set_tests_properties (H5DUMP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") add_test ( NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" @@ -734,21 +676,11 @@ -D "TEST_ERRREF=${result_errcheck}" -P "${HDF_RESOURCES_EXT_DIR}/grepTest.cmake" ) - set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") endif () endmacro () macro (ADD_H5ERR_MASK_ENV_TEST resultfile resultcode result_errcheck envvar envval) if (NOT HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.out - ${resultfile}.out.err - ) - set_tests_properties (H5DUMP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") add_test ( NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" @@ -764,7 +696,6 @@ -D "TEST_ENV_VALUE:STRING=${envval}" -P "${HDF_RESOURCES_EXT_DIR}/grepTest.cmake" ) - set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") endif () endmacro () @@ -773,11 +704,9 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5DUMP-IMPORT-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove + COMMAND ${CMAKE_COMMAND} -E remove ${resultfile}.bin ${resultfile}.h5 - ${conffile}.out ) set_tests_properties (H5DUMP-IMPORT-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") add_test ( @@ -804,15 +733,6 @@ macro (ADD_H5_UD_TEST testname resultcode resultfile) if (NOT HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP_UD-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.out - ${resultfile}.out.err - ) - set_tests_properties (H5DUMP_UD-${testname}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") add_test ( NAME H5DUMP_UD-${testname} COMMAND "${CMAKE_COMMAND}" @@ -828,7 +748,6 @@ -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5DUMP_UD-${testname} PROPERTIES DEPENDS H5DUMP_UD-${testname}-clear-objects) endif () endmacro () @@ -838,368 +757,6 @@ ############################################################################## ############################################################################## - if (HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - h5dump-help.out - charsets.out - charsets.out.err - file_space.out - file_space.out.err - filter_fail.out - filter_fail.out.err - non_existing.out - non_existing.out.err - packedbits.out - packedbits.out.err - tall-1.out - tall-1.out.err - tall-2.out - tall-2.out.err - tall-2A.out - tall-2A.out.err - tall-2A0.out - tall-2A0.out.err - tall-2B.out - tall-2B.out.err - tall-3.out - tall-3.out.err - tall-4s.out - tall-4s.out.err - tall-5s.out - tall-5s.out.err - tall-6.txt - tall-6.out - tall-6.out.err - tall-7.out - tall-7.out.err - tall-7N.out - tall-7N.out.err - tallfilters.out - tallfilters.out.err - tarray1.out - tarray1.out.err - tarray1_big.out - tarray1_big.out.err - tarray2.out - tarray2.out.err - tarray3.out - tarray3.out.err - tarray4.out - tarray4.out.err - tarray5.out - tarray5.out.err - tarray6.out - tarray6.out.err - tarray7.out - tarray7.out.err - tarray8.out - tarray8.out.err - tattr-1.out - tattr-1.out.err - tattr-2.out - tattr-2.out.err - tattr-3.out - tattr-3.out.err - tattr-4_be.out - tattr-4_be.out.err - tattrcontents1.out - tattrcontents1.out.err - tattrcontents2.out - tattrcontents2.out.err - tattrintsize.out - tattrintsize.out.err - tattrreg.out - tattrreg.out.err - tattrregR.out - tattrregR.out.err - tbin1LE.bin - tbinregR.txt - tbinregR.out - tbinregR.out.err - tbigdims.out - tbigdims.out.err - tbitnopaque_be.out - tbitnopaque_be.out.err - tbitnopaque_le.out - tbitnopaque_le.out.err - tboot1.out - tboot1.out.err - tboot2.out - tboot2.out.err - tboot2A.out - tboot2A.out.err - tboot2B.out - tboot2B.out.err - tchar1.out - tchar1.out.err - tchunked.out - tchunked.out.err - tcmpdattrintsize.out - tcmpdattrintsize.out.err - tcmpdintarray.out - tcmpdintarray.out.err - tcmpdints.out - tcmpdints.out.err - tcmpdintsize.out - tcmpdintsize.out.err - tcomp-1.out - tcomp-1.out.err - tcomp-2.out - tcomp-2.out.err - tcomp-3.out - tcomp-3.out.err - tcomp-4.out - tcomp-4.out.err - tcompact.out - tcompact.out.err - tcompound_complex.out - tcompound_complex.out.err - tcontents.out - tcontents.out.err - tcontiguos.out - tcontiguos.out.err - tdatareg.out - tdatareg.out.err - tdataregR.out - tdataregR.out.err - tdeflate.out - tdeflate.out.err - tdset-1.out - tdset-1.out.err - tdset-2.out - tdset-2.out.err - tdset-3s.out - tdset-3s.out.err - tempty.out - tempty.out.err - texternal.out - texternal.out.err - textlinksrc.out - textlinksrc.out.err - textlinkfar.out - textlinkfar.out.err - textlink.out - textlink.out.err - tfamily.out - tfamily.out.err - tfill.out - tfill.out.err - tfletcher32.out - tfletcher32.out.err - tfpformat.out - tfpformat.out.err - tgroup-1.out - tgroup-1.out.err - tgroup-2.out - tgroup-2.out.err - tgrp_comments.out - tgrp_comments.out.err - tgrpnullspace.out - tgrpnullspace.out.err - thlink-1.out - thlink-1.out.err - thlink-2.out - thlink-2.out.err - thlink-3.out - thlink-3.out.err - thlink-4.out - thlink-4.out.err - thlink-5.out - thlink-5.out.err - thyperslab.out - thyperslab.out.err - tindicesno.out - tindicesno.out.err - tindicessub1.out - tindicessub1.out.err - tindicessub2.out - tindicessub2.out.err - tindicessub3.out - tindicessub3.out.err - tindicessub4.out - tindicessub4.out.err - texceedsubstart.out - texceedsubstart.out.err - texceedsubcount.out - texceedsubcount.out.err - texceedsubstride.out - texceedsubstride.out.err - texceedsubblock.out - texceedsubblock.out.err - tindicesyes.out - tindicesyes.out.err - tints4dims.out - tints4dims.out.err - tints4dimsBlock2.out - tints4dimsBlock2.out.err - tints4dimsBlockEq.out - tints4dimsBlockEq.out.err - tints4dimsCount2.out - tints4dimsCount2.out.err - tints4dimsCountEq.out - tints4dimsCountEq.out.err - tints4dimsStride2.out - tints4dimsStride2.out.err - tintsattrs.out - tintsattrs.out.err - tintsnodata.out - tintsnodata.out.err - tlarge_objname.out - tlarge_objname.out.err - tldouble.out - tldouble.out.err - tlonglinks.out - tlonglinks.out.err - tloop-1.out - tloop-1.out.err - tmulti.out - tmulti.out.err - tmultifile.out - tmultifile.out.err -# tqmarkfile.out -# tqmarkfile.out.err -# tstarfile.out -# tstarfile.out.err - tnamed_dtype_attr.out - tnamed_dtype_attr.out.err - tnbit.out - tnbit.out.err - tnestcomp-1.out - tnestcomp-1.out.err - tnestedcmpddt.out - tnestedcmpddt.out.err - tnoattrdata.out - tnoattrdata.out.err - tnoattrddl.out - tnoattrddl.out.err - tnodata.out - tnodata.out.err - tnoddl.out - tnoddl.out.err - tnoddlfile.out - tnoddlfile.out.err - tno-subset.out - tno-subset.out.err - tnullspace.out - tnullspace.out.err - tordergr1.out - tordergr1.out.err - tordergr2.out - tordergr2.out.err - tordergr3.out - tordergr3.out.err - tordergr4.out - tordergr4.out.err - tordergr5.out - tordergr5.out.err - torderattr1.out - torderattr1.out.err - torderattr2.out - torderattr2.out.err - torderattr3.out - torderattr3.out.err - torderattr4.out - torderattr4.out.err - tordercontents1.out - tordercontents1.out.err - tordercontents2.out - tordercontents2.out.err - torderlinks1.out - torderlinks1.out.err - torderlinks2.out - torderlinks2.out.err - tperror.out - tperror.out.err - trawdatafile.out - trawdatafile.out.err - trawdatafile.txt - trawssetfile.out - trawssetfile.out.err - trawssetfile.txt - treadfilter.out - treadfilter.out.err - treadintfilter.out - treadintfilter.out.err - treference.out - treference.out.err - tsaf.out - tsaf.out.err - tscalarattrintsize.out - tscalarattrintsize.out.err - tscalarintattrsize.out - tscalarintattrsize.out.err - tscalarintsize.out - tscalarintsize.out.err - tscalarstring.out - tscalarstring.out.err - tscaleoffset.out - tscaleoffset.out.err - tshuffle.out - tshuffle.out.err - tslink-1.out - tslink-1.out.err - tslink-2.out - tslink-2.out.err - tslink-D.out - tslink-D.out.err - tsplit_file.out - tsplit_file.out.err - tstr-1.out - tstr-1.out.err - tstr-2.out - tstr-2.out.err - tstr2bin2.txt - tstr2bin6.txt - tstring.out - tstring.out.err - tstring2.out - tstring2.out.err - tstringe.out - tstringe.out.err - tszip.out - tszip.out.err - tudlink-1.out - tudlink-1.out.err - tudlink-2.out - tudlink-2.out.err - tuserfilter.out - tuserfilter.out.err - tvldtypes1.out - tvldtypes1.out.err - tvldtypes2.out - tvldtypes2.out.err - tvldtypes3.out - tvldtypes3.out.err - tvldtypes4.out - tvldtypes4.out.err - tvldtypes5.out - tvldtypes5.out.err - tvlenstr_array.out - tvlenstr_array.out.err - tvlstr.out - tvlstr.out.err - tvms.out - tvms.out.err - twidedisplay.out - twidedisplay.out.err - twithddl.txt - twithddlfile.out - twithddlfile.out.err - twithddlfile.txt - zerodim.out - zerodim.out.err - ) - set_tests_properties (H5DUMP-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - if (last_test) - set_tests_properties (H5DUMP-clearall-objects PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5DUMP-clearall-objects") - endif () - ADD_HELP_TEST(help 0 -h) # test data output redirection diff --git a/tools/test/h5dump/CMakeTestsPBITS.cmake b/tools/test/h5dump/CMakeTestsPBITS.cmake index 57c1ad7..a6be9ae 100644 --- a/tools/test/h5dump/CMakeTestsPBITS.cmake +++ b/tools/test/h5dump/CMakeTestsPBITS.cmake @@ -137,15 +137,6 @@ set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS ${last_pbits_test}) endif () else () - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.out - ${resultfile}.out.err - ) - set_tests_properties (H5DUMP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/pbits") add_test ( NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" @@ -158,7 +149,6 @@ -D "TEST_REFERENCE=${resultfile}.ddl" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS H5DUMP-${resultfile}-clear-objects) endif () endmacro () @@ -168,126 +158,6 @@ ############################################################################## ############################################################################## - if (HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP_PACKED_BITS-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - tnofilename-with-packed-bits.out - tnofilename-with-packed-bits.out.err - tpbitsArray.out - tpbitsArray.out.err - tpbitsCompound.out - tpbitsCompound.out.err - tpbitsIncomplete.out - tpbitsIncomplete.out.err - tpbitsLengthExceeded.out - tpbitsLengthExceeded.out.err - tpbitsCharLengthExceeded.out - tpbitsCharLengthExceeded.out.err - tpbitsIntLengthExceeded.out - tpbitsIntLengthExceeded.out.err - tpbitsLongLengthExceeded.out - tpbitsLongLengthExceeded.out.err - tpbitsLengthPositive.out - tpbitsLengthPositive.out.err - tpbitsMax.out - tpbitsMax.out.err - tpbitsMaxExceeded.out - tpbitsMaxExceeded.out.err - tpbitsOffsetExceeded.out - tpbitsOffsetExceeded.out.err - tpbitsCharOffsetExceeded.out - tpbitsCharOffsetExceeded.out.err - tpbitsIntOffsetExceeded.out - tpbitsIntOffsetExceeded.out.err - tpbitsLongOffsetExceeded.out - tpbitsLongOffsetExceeded.out.err - tpbitsOffsetNegative.out - tpbitsOffsetNegative.out.err - tpbitsOverlapped.out - tpbitsOverlapped.out.err - tpbitsSigned.out - tpbitsSigned.out.err - tpbitsUnsigned.out - tpbitsUnsigned.out.err - tpbitsSignedInt.out - tpbitsSignedInt.out.err - tpbitsUnsignedInt.out - tpbitsUnsignedInt.out.err - tpbitsSignedLong.out - tpbitsSignedLong.out.err - tpbitsUnsignedLong.out - tpbitsUnsignedLong.out.err - tpbitsSignedLongLong.out - tpbitsSignedLongLong.out.err - tpbitsUnsignedLongLong.out - tpbitsUnsignedLongLong.out.err - tpbitsSignedWhole.out - tpbitsSignedWhole.out.err - tpbitsUnsignedWhole.out - tpbitsUnsignedWhole.out.err - tpbitsSignedIntWhole.out - tpbitsSignedIntWhole.out.err - tpbitsUnsignedIntWhole.out - tpbitsUnsignedIntWhole.out.err - tpbitsSignedLongWhole.out - tpbitsSignedLongWhole.out.err - tpbitsUnsignedLongWhole.out - tpbitsUnsignedLongWhole.out.err - tpbitsSignedLongLongWhole.out - tpbitsSignedLongLongWhole.out.err - tpbitsUnsignedLongLongWhole.out - tpbitsUnsignedLongLongWhole.out.err - tpbitsSignedLongLongWhole1.out - tpbitsSignedLongLongWhole1.out.err - tpbitsUnsignedLongLongWhole1.out - tpbitsUnsignedLongLongWhole1.out.err - tpbitsSignedLongLongWhole63.out - tpbitsSignedLongLongWhole63.out.err - tpbitsUnsignedLongLongWhole63.out - tpbitsUnsignedLongLongWhole63.out.err - tpbitsSigned4.out - tpbitsSigned4.out.err - tpbitsUnsigned4.out - tpbitsUnsigned4.out.err - tpbitsSignedInt8.out - tpbitsSignedInt8.out.err - tpbitsUnsignedInt8.out - tpbitsUnsignedInt8.out.err - tpbitsSignedLong16.out - tpbitsSignedLong16.out.err - tpbitsUnsignedLong16.out - tpbitsUnsignedLong16.out.err - tpbitsSignedLongLong32.out - tpbitsSignedLongLong32.out.err - tpbitsUnsignedLongLong32.out - tpbitsUnsignedLongLong32.out.err - tpbitsSigned2.out - tpbitsSigned2.out.err - tpbitsUnsigned2.out - tpbitsUnsigned2.out.err - tpbitsSignedInt4.out - tpbitsSignedInt4.out.err - tpbitsUnsignedInt4.out - tpbitsUnsignedInt4.out.err - tpbitsSignedLong8.out - tpbitsSignedLong8.out.err - tpbitsUnsignedLong8.out - tpbitsUnsignedLong8.out.err - tpbitsSignedLongLong16.out - tpbitsSignedLongLong16.out.err - tpbitsUnsignedLongLong16.out - tpbitsUnsignedLongLong16.out.err - ) - set_tests_properties (H5DUMP_PACKED_BITS-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/pbits") - if (last_pbits_test) - set_tests_properties (H5DUMP_PACKED_BITS-clearall-objects PROPERTIES DEPENDS ${last_pbits_test}) - endif () - set (last_pbits_test "H5DUMP_PACKED_BITS-clearall-objects") - endif () - # test failure handling # Missing file name ADD_H5_PBITS_TEST (tnofilename-with-packed-bits 1 --enable-error-stack) diff --git a/tools/test/h5dump/CMakeTestsVDS.cmake b/tools/test/h5dump/CMakeTestsVDS.cmake index 454d9ef..036609c 100644 --- a/tools/test/h5dump/CMakeTestsVDS.cmake +++ b/tools/test/h5dump/CMakeTestsVDS.cmake @@ -133,15 +133,6 @@ set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS ${last_VDS_test}) endif () else () - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.out - ${resultfile}.out.err - ) - set_tests_properties (H5DUMP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds") add_test ( NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" @@ -154,7 +145,6 @@ -D "TEST_REFERENCE=${resultfile}.ddl" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS H5DUMP-${resultfile}-clear-objects) endif () endmacro () @@ -173,15 +163,6 @@ set_tests_properties (H5DUMP_PREFIX-${resultfile} PROPERTIES DEPENDS ${last_VDS_test}) endif () else () - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP_PREFIX-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.out - ${resultfile}.out.err - ) - set_tests_properties (H5DUMP_PREFIX-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds/prefix") add_test ( NAME H5DUMP_PREFIX-${resultfile} COMMAND "${CMAKE_COMMAND}" @@ -196,7 +177,6 @@ -D "TEST_ENV_VALUE=${PROJECT_BINARY_DIR}/testfiles/vds/" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5DUMP_PREFIX-${resultfile} PROPERTIES DEPENDS H5DUMP_PREFIX-${resultfile}-clear-objects) endif () endmacro () @@ -212,15 +192,6 @@ set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS ${last_VDS_test}) endif () else () - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.out - ${resultfile}.out.err - ) - set_tests_properties (H5DUMP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds") add_test ( NAME H5DUMP-${resultfile} COMMAND "${CMAKE_COMMAND}" @@ -233,7 +204,6 @@ -D "TEST_REFERENCE=${resultfile}.ddl" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") endif () endmacro () @@ -243,54 +213,6 @@ ############################################################################## ############################################################################## - if (HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP_VDS-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - tvds-1.out - tvds-1.out.err - tvds-2.out - tvds-2.out.err - tvds-3_1.out - tvds-3_1.out.err - tvds-3_2.out - tvds-3_2.out.err - tvds-4.out - tvds-4.out.err - tvds-5.out - tvds-5.out.err - vds-first.out - vds-first.out.err - vds-gap1.out - vds-gap1.out.err - vds-gap2.out - vds-gap2.out.err - tvds_layout-1.out - tvds_layout-1.out.err - tvds_layout-2.out - tvds_layout-2.out.err - tvds_layout-3_1.out - tvds_layout-3_1.out.err - tvds_layout-3_2.out - tvds_layout-3_2.out.err - tvds_layout-4.out - tvds_layout-4.out.err - tvds_layout-5.out - tvds_layout-5.out.err - vds_layout-eiger.out - vds_layout-eiger.out.err - vds_layout-maxmin.out - vds_layout-maxmin.out.err - ) - set_tests_properties (H5DUMP_VDS-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds") - if (last_vds_test) - set_tests_properties (H5DUMP_VDS-clearall-objects PROPERTIES DEPENDS ${last_vds_test}) - endif () - set (last_VDS_test "H5DUMP_VDS-clearall-objects") - endif () - # See which filters are usable (and skip tests for filters we # don't have). Do this by searching H5pubconf.h to see which # filters are defined. diff --git a/tools/test/h5dump/CMakeTestsXML.cmake b/tools/test/h5dump/CMakeTestsXML.cmake index c4e3f7b..6d73cb1 100644 --- a/tools/test/h5dump/CMakeTestsXML.cmake +++ b/tools/test/h5dump/CMakeTestsXML.cmake @@ -191,15 +191,6 @@ set_tests_properties (H5DUMP_XML-${resultfile} PROPERTIES DEPENDS ${last_xml_test}) endif () else () - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP_XML-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.out - ${resultfile}.out.err - ) - set_tests_properties (H5DUMP_XML-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/xml") add_test ( NAME H5DUMP_XML-${resultfile} COMMAND "${CMAKE_COMMAND}" @@ -212,7 +203,6 @@ -D "TEST_REFERENCE=${resultfile}.xml" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5DUMP_XML-${resultfile} PROPERTIES DEPENDS H5DUMP_XML-${resultfile}-clear-objects) endif () endmacro () @@ -222,154 +212,6 @@ ############################################################################## ############################################################################## - if (HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP-XML-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - tall.h5.out - tall.h5.out.err - tall-2A.h5.out - tall-2A.h5.out.err - tarray1.h5.out - tarray1.h5.out.err - tarray2.h5.out - tarray2.h5.out.err - tarray3.h5.out - tarray3.h5.out.err - tarray6.h5.out - tarray6.h5.out.err - tarray7.h5.out - tarray7.h5.out.err - tattr.h5.out - tattr.h5.out.err - tbitfields_be.h5.out - tbitfields_be.h5.out.err - tbitfields_le.h5.out - tbitfields_le.h5.out.err - tcompound.h5.out - tcompound.h5.out.err - tcompound2.h5.out - tcompound2.h5.out.err - tcompound_complex.h5.out - tcompound_complex.h5.out.err - tdatareg.h5.out - tdatareg.h5.out.err - tdset.h5.out - tdset.h5.out.err - tdset2.h5.out - tdset2.h5.out.err - tempty-dtd-2.h5.out - tempty-dtd-2.h5.out.err - tempty-dtd-uri.h5.out - tempty-dtd-uri.h5.out.err - tempty-dtd.h5.out - tempty-dtd.h5.out.err - tempty-nons-2.h5.out - tempty-nons-2.h5.out.err - tempty-nons-uri.h5.out - tempty-nons-uri.h5.out.err - tempty-nons.h5.out - tempty-nons.h5.out.err - tempty-ns-2.h5.out - tempty-ns-2.h5.out.err - tempty-ns.h5.out - tempty-ns.h5.out.err - tempty.h5.out - tempty.h5.out.err - tenum.h5.out - tenum.h5.out.err - test35.nc.out - test35.nc.out.err - textlink.h5.out - textlink.h5.out.err - tfpformat.h5.out - tfpformat.h5.out.err - tgroup.h5.out - tgroup.h5.out.err - thlink.h5.out - thlink.h5.out.err - tloop.h5.out - tloop.h5.out.err - tloop2.h5.out - tloop2.h5.out.err - tmany.h5.out - tmany.h5.out.err - tname-amp.h5.out - tname-amp.h5.out.err - tname-apos.h5.out - tname-apos.h5.out.err - tname-gt.h5.out - tname-gt.h5.out.err - tname-lt.h5.out - tname-lt.h5.out.err - tname-quot.h5.out - tname-quot.h5.out.err - tname-sp.h5.out - tname-sp.h5.out.err - tnamed_dtype_attr.h5.out - tnamed_dtype_attr.h5.out.err - tnestedcomp.h5.out - tnestedcomp.h5.out.err - tnodata.h5.out - tnodata.h5.out.err - tnoname.h5.out - tnoname.h5.out.err - tnullspace.h5.out - tnullspace.h5.out.err - tobjref.h5.out - tobjref.h5.out.err - topaque.h5.out - topaque.h5.out.err - torderattr1.h5.out - torderattr1.h5.out.err - torderattr2.h5.out - torderattr2.h5.out.err - torderattr3.h5.out - torderattr3.h5.out.err - torderattr4.h5.out - torderattr4.h5.out.err - tref-escapes-at.h5.out - tref-escapes-at.h5.out.err - tref-escapes.h5.out - tref-escapes.h5.out.err - tref.h5.out - tref.h5.out.err - tsaf.h5.out - tsaf.h5.out.err - tslink.h5.out - tslink.h5.out.err - tstr.h5.out - tstr.h5.out.err - tstr2.h5.out - tstr2.h5.out.err - tstring.h5.out - tstring.h5.out.err - tstring-at.h5.out - tstring-at.h5.out.err - tudlink.h5.out - tudlink.h5.out.err - tvldtypes1.h5.out - tvldtypes1.h5.out.err - tvldtypes2.h5.out - tvldtypes2.h5.out.err - tvldtypes3.h5.out - tvldtypes3.h5.out.err - tvldtypes4.h5.out - tvldtypes4.h5.out.err - tvldtypes5.h5.out - tvldtypes5.h5.out.err - tvlstr.h5.out - tvlstr.h5.out.err - ) - set_tests_properties (H5DUMP-XML-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/xml") - if (last_xml_test) - set_tests_properties (H5DUMP-XML-clearall-objects PROPERTIES DEPENDS ${last_xml_test}) - endif () - set (last_test "H5DUMP-XML-clearall-objects") - endif () - ########## test XML ADD_XML_H5_TEST (tall.h5 0 tall.h5) ADD_XML_H5_TEST (tattr.h5 0 tattr.h5) diff --git a/tools/test/h5format_convert/CMakeTests.cmake b/tools/test/h5format_convert/CMakeTests.cmake index 6e13664..398866c 100644 --- a/tools/test/h5format_convert/CMakeTests.cmake +++ b/tools/test/h5format_convert/CMakeTests.cmake @@ -108,11 +108,7 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5FC-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ./testfiles/outtmp.h5 - ./testfiles/${testname}.out - ./testfiles/${testname}.out.err + COMMAND ${CMAKE_COMMAND} -E remove ./testfiles/outtmp.h5 ) if (last_test) set_tests_properties (H5FC-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) @@ -120,8 +116,7 @@ if (${testfile}) add_test ( NAME H5FC-${testname}-${testfile}-tmpfile - COMMAND ${CMAKE_COMMAND} - -E copy_if_different ${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/testfiles/${testfile} ./testfiles/outtmp.h5 + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/testfiles/${testfile} ./testfiles/outtmp.h5 ) set_tests_properties (H5FC-${testname}-${testfile}-tmpfile PROPERTIES DEPENDS "H5FC-${testname}-clear-objects") add_test ( @@ -163,19 +158,14 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5FC-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ./testfiles/outtmp.h5 - ./testfiles/${testname}.out - ./testfiles/${testname}.out.err + COMMAND ${CMAKE_COMMAND} -E remove ./testfiles/outtmp.h5 ) if (last_test) set_tests_properties (H5FC-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) endif () add_test ( NAME H5FC-${testname}-${testfile}-tmpfile - COMMAND ${CMAKE_COMMAND} - -E copy_if_different ${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/testfiles/${testfile} ./testfiles/outtmp.h5 + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/testfiles/${testfile} ./testfiles/outtmp.h5 ) set_tests_properties (H5FC-${testname}-${testfile}-tmpfile PROPERTIES DEPENDS "H5FC-${testname}-clear-objects") add_test ( @@ -200,19 +190,14 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5FC-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ./testfiles/outtmp.h5 - ./testfiles/${testname}.out - ./testfiles/${testname}.out.err + COMMAND ${CMAKE_COMMAND} -E remove ./testfiles/outtmp.h5 ) if (last_test) set_tests_properties (H5FC-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) endif () add_test ( NAME H5FC-${testname}-${testfile}-tmpfile - COMMAND ${CMAKE_COMMAND} - -E copy_if_different ${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/testfiles/${testfile} ./testfiles/outtmp.h5 + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/testfiles/${testfile} ./testfiles/outtmp.h5 ) set_tests_properties (H5FC-${testname}-${testfile}-tmpfile PROPERTIES DEPENDS "H5FC-${testname}-clear-objects") add_test ( @@ -238,19 +223,14 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5FC-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ./testfiles/tmp.h5 - ./testfiles/${testname}.out - ./testfiles/${testname}.out.err + COMMAND ${CMAKE_COMMAND} -E remove ./testfiles/tmp.h5 ) if (last_test) set_tests_properties (H5FC-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) endif () add_test ( NAME H5FC-${testname}-tmpfile - COMMAND ${CMAKE_COMMAND} - -E copy_if_different ${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/testfiles/${testfile} testfiles/tmp.h5 + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/testfiles/${testfile} testfiles/tmp.h5 ) set_tests_properties (H5FC-${testname}-tmpfile PROPERTIES DEPENDS "H5FC-${testname}-clear-objects") add_test ( @@ -286,19 +266,14 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5FC-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ./testfiles/chktmp.h5 - ./testfiles/${testname}.out - ./testfiles/${testname}.out.err + COMMAND ${CMAKE_COMMAND} -E remove ./testfiles/chktmp.h5 ) if (last_test) set_tests_properties (H5FC-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) endif () add_test ( NAME H5FC-${testname}-tmpfile - COMMAND ${CMAKE_COMMAND} - -E copy_if_different ${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/testfiles/${testfile} testfiles/chktmp.h5 + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/testfiles/${testfile} testfiles/chktmp.h5 ) set_tests_properties (H5FC-${testname}-tmpfile PROPERTIES DEPENDS "H5FC-${testname}-clear-objects") add_test ( @@ -324,25 +299,18 @@ endmacro () macro (ADD_H5_H5DUMP_CHECK testname) - # If using memchecker add tests without using scripts + # If using memchecker skip tests if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5FC-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ./testfiles/dmptmp.h5 - ./testfiles/${testname}.out - ./testfiles/${testname}.out.err - ./testfiles/${testname}_chk.out - ./testfiles/${testname}_chk.out.err + COMMAND ${CMAKE_COMMAND} -E remove ./testfiles/dmptmp.h5 ) if (last_test) set_tests_properties (H5FC-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) endif () add_test ( NAME H5FC-${testname}-tmpfile - COMMAND ${CMAKE_COMMAND} - -E copy_if_different ${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/testfiles/${testname}.h5 testfiles/dmptmp.h5 + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/testfiles/${testname}.h5 testfiles/dmptmp.h5 ) set_tests_properties (H5FC-${testname}-tmpfile PROPERTIES DEPENDS "H5FC-${testname}-clear-objects") add_test ( @@ -385,60 +353,7 @@ # Remove any output file left over from previous test run add_test ( NAME H5FC-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - h5fc_help.out - h5fc_help.out.err - h5fc_nooption.out - h5fc_nooption.out.err - h5fc_nonexistfile.out - h5fc_nonexistfile.out.err - h5fc_d_file.out - h5fc_d_file.out.err - h5fc_d_file-d.out - h5fc_d_file-d.out.err - h5fc_dname.out - h5fc_dname.out.err - h5fc_nonexistdset_file.out - h5fc_nonexistdset_file.out.err - h5fc_v_non_chunked.out - h5fc_v_non_chunked.out.err - h5fc_v_bt1.out - h5fc_v_bt1.out.err - h5fc_v_ndata_bt1.out - h5fc_v_ndata_bt1.out.err - h5fc_v_all.out - h5fc_v_all.out.err - h5fc_v_n_1d.out - h5fc_v_n_1d.out.err - h5fc_v_n_all.out - h5fc_v_n_all.out.err - h5fc_ext1_i.out - h5fc_ext1_i.out.err - h5fc_ext1_s.out - h5fc_ext1_s.out.err - h5fc_ext1_f.out - h5fc_ext1_f.out.err - h5fc_ext2_if.out - h5fc_ext2_if.out.err - h5fc_ext2_is.out - h5fc_ext2_is.out.err - h5fc_ext2_sf.out - h5fc_ext2_sf.out.err - h5fc_ext3_isf.out - h5fc_ext3_isf.out.err - old_h5fc_ext1_i.out - old_h5fc_ext1_i.out.err - old_h5fc_ext1_s.out - old_h5fc_ext1_s.out.err - old_h5fc_ext1_f.out - old_h5fc_ext1_f.out.err - old_h5fc_ext2_if.out - old_h5fc_ext2_is.out.err - old_h5fc_ext2_is.out - old_h5fc_ext2_sf.out.err - old_h5fc_ext3_isf.out - old_h5fc_ext3_isf.out.err + COMMAND ${CMAKE_COMMAND} -E remove outtmp.h5 tmp.h5 chktmp.h5 diff --git a/tools/test/h5import/CMakeTests.cmake b/tools/test/h5import/CMakeTests.cmake index 4aaee68..22ab848 100644 --- a/tools/test/h5import/CMakeTests.cmake +++ b/tools/test/h5import/CMakeTests.cmake @@ -106,25 +106,22 @@ # If using memchecker skip macro based tests if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME H5IMPORT-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${importfile} -c ${conffile} -o ${testfile}) - if (last_test) - set_tests_properties (H5IMPORT-${testname} PROPERTIES DEPENDS H5IMPORT-h5importtest) - endif () + set_tests_properties (H5IMPORT-${testname} PROPERTIES + FIXTURES_REQUIRED set_h5importtest + ) else () add_test ( NAME H5IMPORT-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${testfile} - ${testfile}.new - ${testfile}.new.err - ${testfile}.out - ${testfile}.out.err - ${testfile} + COMMAND ${CMAKE_COMMAND} -E remove ${testfile} + ) + set_tests_properties (H5IMPORT-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED set_h5importtest ) - set_tests_properties (H5IMPORT-${testname}-clear-objects PROPERTIES DEPENDS H5IMPORT-h5importtest) add_test (NAME H5IMPORT-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${importfile} -c ${conffile} -o ${testfile}) - set_tests_properties (H5IMPORT-${testname} PROPERTIES DEPENDS H5IMPORT-${testname}-clear-objects) + set_tests_properties (H5IMPORT-${testname} PROPERTIES + DEPENDS H5IMPORT-${testname}-clear-objects + ) add_test ( NAME H5IMPORT-${testname}-H5DMP @@ -139,7 +136,9 @@ -D "TEST_SKIP_COMPARE=TRUE" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5IMPORT-${testname}-H5DMP PROPERTIES DEPENDS H5IMPORT-${testname}) + set_tests_properties (H5IMPORT-${testname}-H5DMP PROPERTIES + DEPENDS H5IMPORT-${testname} + ) add_test ( NAME H5IMPORT-${testname}-H5DMP_CMP COMMAND "${CMAKE_COMMAND}" @@ -153,7 +152,9 @@ -D "TEST_REFERENCE=${testfile}.new" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5IMPORT-${testname}-H5DMP_CMP PROPERTIES DEPENDS H5IMPORT-${testname}-H5DMP) + set_tests_properties (H5IMPORT-${testname}-H5DMP_CMP PROPERTIES + DEPENDS H5IMPORT-${testname}-H5DMP + ) endif () endmacro () @@ -162,18 +163,13 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5IMPORT-DUMP-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove + COMMAND ${CMAKE_COMMAND} -E remove d${testfile} d${testfile}.bin - d${testfile}.dmp - d${testfile}.dmp.err - d${testfile}.imp - d${testfile}.imp.err - d${testfile}.dff - d${testfile}.dff.err ) - set_tests_properties (H5IMPORT-DUMP-${testname}-clear-objects PROPERTIES DEPENDS H5IMPORT-h5importtest) + set_tests_properties (H5IMPORT-DUMP-${testname}-clear-objects PROPERTIES + DEPENDS H5IMPORT-${testname}-H5DMP_CMP + ) if ("${ARGN}" STREQUAL "BINARY") add_test ( @@ -202,7 +198,9 @@ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () - set_tests_properties (H5IMPORT-DUMP-${testname}-H5DMP PROPERTIES DEPENDS "H5IMPORT-DUMP-${testname}-clear-objects") + set_tests_properties (H5IMPORT-DUMP-${testname}-H5DMP PROPERTIES + DEPENDS "H5IMPORT-DUMP-${testname}-clear-objects" + ) add_test ( NAME H5IMPORT-DUMP-${testname} @@ -216,7 +214,9 @@ -D "TEST_SKIP_COMPARE=TRUE" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5IMPORT-DUMP-${testname} PROPERTIES DEPENDS "H5IMPORT-DUMP-${testname}-H5DMP") + set_tests_properties (H5IMPORT-DUMP-${testname} PROPERTIES + DEPENDS "H5IMPORT-DUMP-${testname}-H5DMP" + ) add_test ( NAME H5IMPORT-DUMP-${testname}-H5DFF @@ -231,7 +231,9 @@ -D "TEST_REFERENCE=testfiles/d${testfile}.txt" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5IMPORT-DUMP-${testname}-H5DFF PROPERTIES DEPENDS "H5IMPORT-DUMP-${testname}") + set_tests_properties (H5IMPORT-DUMP-${testname}-H5DFF PROPERTIES + DEPENDS "H5IMPORT-DUMP-${testname}" + ) endif () endmacro () @@ -240,18 +242,13 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5IMPORT_SUB-DUMP-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - d-${testname}.dmp - d-${testname}.dmp.err + COMMAND ${CMAKE_COMMAND} -E remove d-${testname}.h5 - ${testname}.dmp - ${testname}.dmp.err - ${testname}.imp - ${testname}.imp.err ${testname}.bin ) - set_tests_properties (H5IMPORT_SUB-DUMP-${testname}-clear-objects PROPERTIES DEPENDS H5IMPORT-h5importtest) + set_tests_properties (H5IMPORT_SUB-DUMP-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED set_h5importtest + ) add_test ( NAME H5IMPORT_SUB-DUMP-${testname}-H5DMP @@ -265,7 +262,9 @@ -D "TEST_SKIP_COMPARE=TRUE" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5IMPORT_SUB-DUMP-${testname}-H5DMP PROPERTIES DEPENDS "H5IMPORT_SUB-DUMP-${testname}-clear-objects") + set_tests_properties (H5IMPORT_SUB-DUMP-${testname}-H5DMP PROPERTIES + DEPENDS "H5IMPORT_SUB-DUMP-${testname}-clear-objects" + ) add_test ( NAME H5IMPORT_SUB-DUMP-${testname}-H5IMP @@ -279,7 +278,9 @@ -D "TEST_SKIP_COMPARE=TRUE" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5IMPORT_SUB-DUMP-${testname}-H5IMP PROPERTIES DEPENDS "H5IMPORT_SUB-DUMP-${testname}-H5DMP") + set_tests_properties (H5IMPORT_SUB-DUMP-${testname}-H5IMP PROPERTIES + DEPENDS "H5IMPORT_SUB-DUMP-${testname}-H5DMP" + ) add_test ( NAME H5IMPORT_SUB-DUMP-${testname}-CMP COMMAND "${CMAKE_COMMAND}" @@ -292,7 +293,9 @@ -D "TEST_REFERENCE=testfiles/${testname}.ddl" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5IMPORT_SUB-DUMP-${testname}-CMP PROPERTIES DEPENDS "H5IMPORT_SUB-DUMP-${testname}-H5IMP") + set_tests_properties (H5IMPORT_SUB-DUMP-${testname}-CMP PROPERTIES + DEPENDS "H5IMPORT_SUB-DUMP-${testname}-H5IMP" + ) endif () endmacro () @@ -323,8 +326,7 @@ # Remove any output file left over from previous test run add_test ( NAME H5IMPORT-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove + COMMAND ${CMAKE_COMMAND} -E remove binfp64.bin binin8.bin binin8w.bin @@ -333,164 +335,40 @@ binuin16.bin binuin32.bin txtin32.h5 - txtin32.h5.new - txtin32.h5.new.err - txtin32.h5.out - txtin32.h5.out.err txtin16.h5 - txtin16.h5.new - txtin16.h5.new.err - txtin16.h5.out - txtin16.h5.out.err txtin8.h5 - txtin8.h5.new - txtin8.h5.new.err - txtin8.h5.out - txtin8.h5.out.err txtuin16.h5 - txtuin16.h5.new - txtuin16.h5.new.err - txtuin16.h5.out - txtuin16.h5.out.err txtuin32.h5 - txtuin32.h5.new - txtuin32.h5.new.err - txtuin32.h5.out - txtuin32.h5.out.err txtfp32.h5 - txtfp32.h5.new - txtfp32.h5.new.err - txtfp32.h5.out - txtfp32.h5.out.err txtfp64.h5 - txtfp64.h5.new - txtfp64.h5.new.err - txtfp64.h5.out - txtfp64.h5.out.err binfp64.h5 - binfp64.h5.new - binfp64.h5.new.err - binfp64.h5.out - binfp64.h5.out.err binin8.h5 - binin8.h5.new - binin8.h5.new.err - binin8.h5.out - binin8.h5.out.err binin8w.h5 - binin8w.h5.new - binin8w.h5.new.err - binin8w.h5.out - binin8w.h5.out.err binin16.h5 - binin16.h5.new - binin16.h5.new.err - binin16.h5.out - binin16.h5.out.err binin32.h5 - binin32.h5.new - binin32.h5.new.err - binin32.h5.out - binin32.h5.out.err binuin16.h5 - binuin16.h5.new - binuin16.h5.new.err - binuin16.h5.out - binuin16.h5.out.err binuin32.h5 - binuin32.h5.new - binuin32.h5.new.err - binuin32.h5.out - binuin32.h5.out.err txtstr.h5 - txtstr.h5.new - txtstr.h5.new.err - txtstr.h5.out - txtstr.h5.out.err textpfe.h5 - textpfe.h5.new - textpfe.h5.new.err - textpfe.h5.out - textpfe.h5.out.err dbinfp64.h5 dbinfp64.h5.bin - dbinfp64.h5.imp - dbinfp64.h5.imp.err - dbinfp64.h5.dmp - dbinfp64.h5.dmp.err - dbinfp64.h5.dff - dbinfp64.h5.dff.err dbinin8.h5 dbinin8.h5.bin - dbinin8.h5.imp - dbinin8.h5.imp.err - dbinin8.h5.dmp - dbinin8.h5.dmp.err - dbinin8.h5.dff - dbinin8.h5.dff.err dbinin8w.h5 dbinin8w.h5.bin - dbinin8w.h5.imp - dbinin8w.h5.imp.err - dbinin8w.h5.dmp - dbinin8w.h5.dmp.err - dbinin8w.h5.dff - dbinin8w.h5.dff.err dbinin16.h5 dbinin16.h5.bin - dbinin16.h5.imp - dbinin16.h5.imp.err - dbinin16.h5.dmp - dbinin16.h5.dmp.err - dbinin16.h5.dff - dbinin16.h5.dff.err dbinin32.h5 dbinin32.h5.bin - dbinin32.h5.imp - dbinin32.h5.imp.err - dbinin32.h5.dmp - dbinin32.h5.dmp.err - dbinin32.h5.dff - dbinin32.h5.dff.err dbinuin16.h5 dbinuin16.h5.bin - dbinuin16.h5.imp - dbinuin16.h5.imp.err - dbinuin16.h5.dmp - dbinuin16.h5.dmp.err - dbinuin16.h5.dff - dbinuin16.h5.dff.err dbinuin32.h5 dbinuin32.h5.bin - dbinuin32.h5.imp - dbinuin32.h5.imp.err - dbinuin32.h5.dmp - dbinuin32.h5.dmp.err - dbinuin32.h5.dff - dbinuin32.h5.dff.err dtxtstr.h5 dtxtstr.h5.bin - dtxtstr.h5.imp - dtxtstr.h5.imp.err - dtxtstr.h5.dmp - dtxtstr.h5.dmp.err - dtxtstr.h5.dff - dtxtstr.h5.dff.err - tall_fp32.dmp - tall_fp32.dmp.err tall_fp32.bin - tall_fp32.imp - tall_fp32.imp.err - d-tall_fp32.dmp - d-tall_fp32.dmp.err d-tall_fp32.h5 - tall_i32.dmp - tall_i32.dmp.err tall_i32.bin - tall_i32.imp - tall_i32.imp.err - d-tall_i32.dmp - d-tall_i32.dmp.err d-tall_i32.h5 ) set (last_test "H5IMPORT-clear-objects") @@ -498,8 +376,7 @@ add_test ( NAME H5IMPORT-h5importtest-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove + COMMAND ${CMAKE_COMMAND} -E remove binfp64.bin binfp64.conf binin8.bin @@ -515,13 +392,12 @@ binuin32.bin binuin32.conf ) - if (last_test) - set_tests_properties (H5IMPORT-h5importtest-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5IMPORT-clear-objects") add_test (NAME H5IMPORT-h5importtest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - set_tests_properties (H5IMPORT-h5importtest PROPERTIES DEPENDS H5IMPORT-h5importtest-clear-objects) + set_tests_properties (H5IMPORT-h5importtest PROPERTIES + FIXTURES_SETUP set_h5importtest + DEPENDS H5IMPORT-h5importtest-clear-objects + ) # ----- TESTING "ASCII I32 rank 3 - Output BE " ; ADD_H5_TEST (ASCII_I32 testfiles/txtin32.txt testfiles/txtin32.conf txtin32.h5) diff --git a/tools/test/h5jam/CMakeTests.cmake b/tools/test/h5jam/CMakeTests.cmake index d930a1e..f108afc 100644 --- a/tools/test/h5jam/CMakeTests.cmake +++ b/tools/test/h5jam/CMakeTests.cmake @@ -66,13 +66,6 @@ endif () else () add_test ( - NAME H5JAM-${expectfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${expectfile}.out - ${expectfile}.out.err - ) - add_test ( NAME H5JAM-${expectfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -86,7 +79,6 @@ -D "TEST_REFERENCE=testfiles/${expectfile}.txt" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5JAM-${expectfile} PROPERTIES DEPENDS "H5JAM-${expectfile}-clear-objects") endif () endmacro () @@ -103,13 +95,6 @@ endif () else () add_test ( - NAME H5JAM-UNJAM-${expectfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${expectfile}.out - ${expectfile}.out.err - ) - add_test ( NAME H5JAM-UNJAM-${expectfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -121,7 +106,6 @@ -D "TEST_REFERENCE=testfiles/${expectfile}.txt" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5JAM-UNJAM-${expectfile} PROPERTIES DEPENDS "H5JAM-UNJAM-${expectfile}-clear-objects") endif () endmacro () @@ -129,16 +113,6 @@ # If using memchecker add tests without using scripts if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5JAM-${testname}-CHECKFILE-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${actual}.new - ${actual}.new.err - ${actual}.out - ${actual}.out.err - ) - set_tests_properties (H5JAM-${testname}-CHECKFILE-clear-objects PROPERTIES DEPENDS ${testdepends}) - add_test ( NAME H5JAM-${testname}-CHECKFILE-H5DMP COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -151,7 +125,7 @@ -D "TEST_SKIP_COMPARE=TRUE" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5JAM-${testname}-CHECKFILE-H5DMP PROPERTIES DEPENDS H5JAM-${testname}-CHECKFILE-clear-objects) + set_tests_properties (H5JAM-${testname}-CHECKFILE-H5DMP PROPERTIES DEPENDS ${testdepends}) add_test ( NAME H5JAM-${testname}-CHECKFILE-H5DMP_CMP COMMAND "${CMAKE_COMMAND}" @@ -219,8 +193,7 @@ if (${compare_test}) add_test ( NAME H5JAM-${testname}-UNJAM-CHECK_UB_1-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove + COMMAND ${CMAKE_COMMAND} -E remove ${infile}.len.txt ${infile}.cmp ${infile}-ub.cmp @@ -285,8 +258,7 @@ add_test ( NAME H5JAM-${testname}-CHECK_UB_1-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove + COMMAND ${CMAKE_COMMAND} -E remove ${compare_test}.len.txt ${compare_test}.cmp ${compare_test}-ub.cmp @@ -341,8 +313,7 @@ add_test ( NAME H5JAM-${testname}_NONE-CHECK_UB_1-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove + COMMAND ${CMAKE_COMMAND} -E remove ${compare_test}.len.txt ${compare_test}.cmp ${compare_test}-ub.cmp diff --git a/tools/test/h5ls/CMakeTests.cmake b/tools/test/h5ls/CMakeTests.cmake index 9110f01..2f3f3ab 100644 --- a/tools/test/h5ls/CMakeTests.cmake +++ b/tools/test/h5ls/CMakeTests.cmake @@ -148,19 +148,9 @@ if (${resultcode} EQUAL 1) set_tests_properties (H5LS-${resultfile} PROPERTIES WILL_FAIL "true") endif () - if (last_test) - set_tests_properties (H5LS-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif () else () # Remove any output file left over from previous test run add_test ( - NAME H5LS-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${resultfile}.out - testfiles/${resultfile}.out.err - ) - add_test ( NAME H5LS-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -172,7 +162,6 @@ -D "TEST_REFERENCE=${resultfile}.ls" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5LS-${resultfile} PROPERTIES DEPENDS H5LS-${resultfile}-clear-objects) endif () endmacro () @@ -184,18 +173,7 @@ if (${resultcode} EQUAL 1) set_tests_properties (H5LS-${resultfile} PROPERTIES WILL_FAIL "true") endif () - if (last_test) - set_tests_properties (H5LS-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif () else () - # Remove any output file left over from previous test run - add_test ( - NAME H5LS-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${resultfile}.out - testfiles/${resultfile}.out.err - ) add_test ( NAME H5LS-${resultfile} COMMAND "${CMAKE_COMMAND}" @@ -209,20 +187,11 @@ -D "TEST_ERRREF=${resultfile}.err" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5LS-${resultfile} PROPERTIES DEPENDS H5LS-${resultfile}-clear-objects) endif () endmacro () macro (ADD_H5_UD_TEST testname resultcode resultfile) if (NOT HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5LS_UD-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${resultfile}.out - testfiles/${resultfile}.out.err - ) add_test ( NAME H5LS_UD-${testname} COMMAND "${CMAKE_COMMAND}" @@ -238,7 +207,6 @@ -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5LS_UD-${testname} PROPERTIES DEPENDS H5LS_UD-${testname}-clear-objects) endif () endmacro () @@ -248,128 +216,6 @@ ############################################################################## ############################################################################## - if (HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5LS-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - help-1.out - help-1.out.err - help-2.out - help-2.out.err - help-3.out - help-3.out.err - nosuchfile.out - nosuchfile.out.err - tall-1.out - tall-1.out.err - tall-2.out - tall-2.out.err - tarray1.out - tarray1.out.err - tattr2.out - tattr2.out.err - tcomp-1.out - tcomp-1.out.err - tdataregbe.out - tdataregbe.out.err - tdataregle.out - tdataregle.out.err - tdset-1.out - tdset-1.out.err - tempty.out - tempty.out.err - textlink-1.out - textlink-1.out.err - textlinksrc-1.out - textlinksrc-1.out.err - textlinksrc-2.out - textlinksrc-2.out.err - textlinksrc-3.out - textlinksrc-3.out.err - textlinksrc-4.out - textlinksrc-4.out.err - textlinksrc-5.out - textlinksrc-5.out.err - textlinksrc-6.out - textlinksrc-6.out.err - textlinksrc-7.out - textlinksrc-7.out.err - textlinksrc-1-old.out - textlinksrc-1-old.out.err - textlinksrc-2-old.out - textlinksrc-2-old.out.err - textlinksrc-3-old.out - textlinksrc-3-old.out.err - textlinksrc-6-old.out - textlinksrc-6-old.out.err - textlinksrc-7-old.out - textlinksrc-7-old.out.err - tgrp_comments.out - tgrp_comments.out.err - tgrpnullspace.out - tgrpnullspace.out.err - tsoftlinks-1.out - tsoftlinks-1.out.err - tsoftlinks-2.out - tsoftlinks-2.out.err - tsoftlinks-3.out - tsoftlinks-3.out.err - tsoftlinks-4.out - tsoftlinks-4.out.err - tsoftlinks-5.out - tsoftlinks-5.out.err - textlinksrc-nodangle-1.out - textlinksrc-nodangle-1.out.err - textlinksrc-nodangle-2.out - textlinksrc-nodangle-2.out.err - tsoftlinks-nodangle-1.out - tsoftlinks-nodangle-1.out.err - thlinks-nodangle-1.out - thlinks-nodangle-1.out.err - tgroup.out - tgroup.out.err - tgroup-1.out - tgroup-1.out.err - tgroup-2.out - tgroup-2.out.err - tgroup-3.out - tgroup-3.out.err - thlink-1.out - thlink-1.out.err - tloop-1.out - tloop-1.out.err - tnestcomp-1.out - tnestcomp-1.out.err - tnestcomp-2.out - tnestcomp-2.out.err - tnestcomp-3.out - tnestcomp-3.out.err - tnestcomp-4.out - tnestcomp-4.out.err - tsaf.out - tsaf.out.err - tslink-1.out - tslink-1.out.err - tstr-1.out - tstr-1.out.err - tudlink-1.out - tudlink-1.out.err - tvldtypes1.out - tvldtypes1.out.err - tvldtypes2le.out - tvldtypes2le.out.err - tvldtypes2be.out - tvldtypes2be.out.err - ) - set_tests_properties (H5LS-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (last_test) - set_tests_properties (H5LS-clearall-objects PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5LS-clearall-objects") - endif () - # See which filters are usable (and skip tests for filters we # don't have). Do this by searching H5pubconf.h to see which # filters are defined. diff --git a/tools/test/h5ls/CMakeTestsVDS.cmake b/tools/test/h5ls/CMakeTestsVDS.cmake index b975d4a..cf5b6d7 100644 --- a/tools/test/h5ls/CMakeTestsVDS.cmake +++ b/tools/test/h5ls/CMakeTestsVDS.cmake @@ -94,19 +94,8 @@ if (${resultcode} EQUAL 1) set_tests_properties (H5LS-${resultfile} PROPERTIES WILL_FAIL "true") endif () - if (last_test) - set_tests_properties (H5LS-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif () else () add_test ( - NAME H5LS-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.out - ${resultfile}.out.err - ) - set_tests_properties (H5LS-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds") - add_test ( NAME H5LS-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -118,7 +107,6 @@ -D "TEST_REFERENCE=${resultfile}.ls" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5LS-${resultfile} PROPERTIES DEPENDS H5LS-${resultfile}-clear-objects) endif () endmacro () @@ -133,19 +121,8 @@ if (${resultcode} EQUAL 1) set_tests_properties (H5LS_PREFIX-${resultfile} PROPERTIES WILL_FAIL "true") endif () - if (last_test) - set_tests_properties (H5LS_PREFIX-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif () else () add_test ( - NAME H5LS_PREFIX-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.out - ${resultfile}.out.err - ) - set_tests_properties (H5LS_PREFIX-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds/prefix") - add_test ( NAME H5LS_PREFIX-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -159,7 +136,6 @@ -D "TEST_ENV_VALUE=\${ORIGIN}" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5LS_PREFIX-${resultfile} PROPERTIES DEPENDS H5LS_PREFIX-${resultfile}-clear-objects) endif () endmacro () @@ -169,44 +145,6 @@ ############################################################################## ############################################################################## - if (HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5LS_VDS-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - tvds-1.out - tvds-1.out.err - tvds-2.out - tvds-2.out.err - tvds-3_1.out - tvds-3_1.out.err - tvds-3_2.out - tvds-3_2.out.err - tvds-4.out - tvds-4.out.err - tvds-5.out - tvds-5.out.err - tvds_layout-1.out - tvds_layout-1.out.err - tvds_layout-2.out - tvds_layout-2.out.err - tvds_layout-3_1.out - tvds_layout-3_1.out.err - tvds_layout-3_2.out - tvds_layout-3_2.out.err - tvds_layout-4.out - tvds_layout-4.out.err - tvds_layout-5.out - tvds_layout-5.out.err - ) - set_tests_properties (H5LS_VDS-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds") - if (last_test) - set_tests_properties (H5LS_VDS-clearall-objects PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5LS_VDS-clearall-objects") - endif () - ADD_H5_VDS_TEST (tvds-1 0 -w80 -v -S 1_vds.h5) ADD_H5_VDS_TEST (tvds-2 0 -w80 -v -S 2_vds.h5) ADD_H5_VDS_TEST (tvds-3_1 0 -w80 -v -S 3_1_vds.h5) diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index d1e9c7a..cd20f77 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -167,22 +167,10 @@ # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME H5REPACK-h5repack-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) - set_tests_properties (H5REPACK-h5repack-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (last_test) - set_tests_properties (H5REPACK-h5repack-${testname} PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5REPACK-h5repack-${testname}") - else () - add_test ( - NAME H5REPACK-h5repack-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/h5repack-${testname}.out - testfiles/h5repack-${testname}.out.err + set_tests_properties (H5REPACK-h5repack-${testname} PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" ) - if (last_test) - set_tests_properties (H5REPACK-h5repack-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () + else () add_test ( NAME H5REPACK-h5repack-${testname} COMMAND "${CMAKE_COMMAND}" @@ -195,39 +183,43 @@ -D "TEST_REFERENCE=h5repack-${testname}.txt" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5REPACK-h5repack-${testname} PROPERTIES DEPENDS H5REPACK-h5repack-${testname}-clear-objects) endif () + set_tests_properties (H5REPACK-h5repack-${testname} PROPERTIES + FIXTURES_REQUIRED clear_h5repack + ) endmacro () macro (ADD_H5_TEST_OLD testname testtype testfile) - if ("${testtype}" STREQUAL "SKIP") - if (NOT HDF5_ENABLE_USING_MEMCHECKER) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + if ("${testtype}" STREQUAL "SKIP") add_test ( NAME H5REPACK_OLD-${testname} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} -i ${PROJECT_BINARY_DIR}/testfiles/${testfile} -o ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile}" ) set_property(TEST H5REPACK_OLD-${testname} PROPERTY DISABLED) + else () + add_test ( + NAME H5REPACK_OLD-${testname}-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${testfile} + ) + set_tests_properties (H5REPACK_OLD-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack + ) + add_test ( + NAME H5REPACK_OLD-${testname} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} -i ${PROJECT_BINARY_DIR}/testfiles/${testfile} -o ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + ) + set_tests_properties (H5REPACK_OLD-${testname} PROPERTIES + DEPENDS H5REPACK_OLD-${testname}-clear-objects + ) + add_test ( + NAME H5REPACK_OLD-${testname}_DFF + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + ) + set_tests_properties (H5REPACK_OLD-${testname}_DFF PROPERTIES + DEPENDS H5REPACK_OLD-${testname} + ) endif () - else () - add_test ( - NAME H5REPACK_OLD-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${testname}.${testfile} - ) - if (last_test) - set_tests_properties (H5REPACK_OLD-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () - add_test ( - NAME H5REPACK_OLD-${testname} - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} -i ${PROJECT_BINARY_DIR}/testfiles/${testfile} -o ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} - ) - set_tests_properties (H5REPACK_OLD-${testname} PROPERTIES DEPENDS H5REPACK_OLD-${testname}-clear-objects) - add_test ( - NAME H5REPACK_OLD-${testname}_DFF - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} - ) - set_tests_properties (H5REPACK_OLD-${testname}_DFF PROPERTIES DEPENDS H5REPACK_OLD-${testname}) endif () endmacro () @@ -243,23 +235,25 @@ else () add_test ( NAME H5REPACK-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${testfile} + ) + set_tests_properties (H5REPACK-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack ) - if (last_test) - set_tests_properties (H5REPACK-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5REPACK-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ --enable-error-stack ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) - set_tests_properties (H5REPACK-${testname} PROPERTIES DEPENDS H5REPACK-${testname}-clear-objects) + set_tests_properties (H5REPACK-${testname} PROPERTIES + DEPENDS H5REPACK-${testname}-clear-objects + ) add_test ( NAME H5REPACK-${testname}_DFF COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ --enable-error-stack ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) - set_tests_properties (H5REPACK-${testname}_DFF PROPERTIES DEPENDS H5REPACK-${testname}) + set_tests_properties (H5REPACK-${testname}_DFF PROPERTIES + DEPENDS H5REPACK-${testname} + ) endif () endmacro () @@ -279,21 +273,14 @@ NAME H5REPACK_CMP-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile} ) - if (last_test) - set_tests_properties (H5REPACK_CMP-${testname} PROPERTIES DEPENDS ${last_test}) - endif () else () add_test ( NAME H5REPACK_CMP-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${testname}.${resultfile} - testfiles/${resultfile}-${testname}.out - testfiles/${resultfile}-${testname}.out.err + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${resultfile} + ) + set_tests_properties (H5REPACK_CMP-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack ) - if (last_test) - set_tests_properties (H5REPACK_CMP-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5REPACK_CMP-${testname} COMMAND "${CMAKE_COMMAND}" @@ -307,7 +294,9 @@ -D "TEST_REFERENCE=${resultfile}-${testname}.tst" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5REPACK_CMP-${testname} PROPERTIES DEPENDS H5REPACK_CMP-${testname}-clear-objects) + set_tests_properties (H5REPACK_CMP-${testname} PROPERTIES + DEPENDS H5REPACK_CMP-${testname}-clear-objects + ) endif () endif () endmacro () @@ -328,21 +317,17 @@ NAME H5REPACK_MASK-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile} ) - if (last_test) - set_tests_properties (H5REPACK_MASK-${testname} PROPERTIES DEPENDS ${last_test}) - endif () + set_tests_properties (H5REPACK_MASK-${testname} PROPERTIES + FIXTURES_REQUIRED clear_h5repack + ) else (HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5REPACK_MASK-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${testname}.${resultfile} - testfiles/${resultfile}-${testname}.out - testfiles/${resultfile}-${testname}.out.err + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${resultfile} + ) + set_tests_properties (H5REPACK_MASK-${testname}-clear-objects PROPERTIES DEPENDS ${last_test} + FIXTURES_REQUIRED clear_h5repack ) - if (last_test) - set_tests_properties (H5REPACK_MASK-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5REPACK_MASK-${testname} COMMAND "${CMAKE_COMMAND}" @@ -374,20 +359,18 @@ else () add_test ( NAME H5REPACK_DMP-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${testname}.${resultfile} - testfiles/${resultfile}-${testname}.out - testfiles/${resultfile}-${testname}.out.err + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${resultfile} + ) + set_tests_properties (H5REPACK_DMP-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack ) - if (last_test) - set_tests_properties (H5REPACK_DMP-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5REPACK_DMP-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile} ) - set_tests_properties (H5REPACK_DMP-${testname} PROPERTIES DEPENDS H5REPACK_DMP-${testname}-clear-objects) + set_tests_properties (H5REPACK_DMP-${testname} PROPERTIES + DEPENDS H5REPACK_DMP-${testname}-clear-objects + ) if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5REPACK_DMP-h5dump-${testname} @@ -401,7 +384,9 @@ -D "TEST_REFERENCE=${testname}.${resultfile}.ddl" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5REPACK_DMP-h5dump-${testname} PROPERTIES DEPENDS "H5REPACK_DMP-${testname}") + set_tests_properties (H5REPACK_DMP-h5dump-${testname} PROPERTIES + DEPENDS "H5REPACK_DMP-${testname}" + ) endif () endif () endmacro () @@ -418,20 +403,18 @@ else () add_test ( NAME H5REPACK_STAT-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${statarg}.${resultfile} - testfiles/${resultfile}-${testname}.out - testfiles/${resultfile}-${testname}.out.err + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${statarg}.${resultfile} + ) + set_tests_properties (H5REPACK_STAT-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack ) - if (last_test) - set_tests_properties (H5REPACK_STAT-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5REPACK_STAT-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${statarg}.${resultfile} ) - set_tests_properties (H5REPACK_STAT-${testname} PROPERTIES DEPENDS H5REPACK_STAT-${testname}-clear-objects) + set_tests_properties (H5REPACK_STAT-${testname} PROPERTIES + DEPENDS H5REPACK_STAT-${testname}-clear-objects + ) if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5REPACK_STAT-h5stat-${testname} @@ -445,7 +428,9 @@ -D "TEST_REFERENCE=${statarg}.${resultfile}.ddl" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5REPACK_STAT-h5stat-${testname} PROPERTIES DEPENDS "H5REPACK_STAT-${testname}") + set_tests_properties (H5REPACK_STAT-h5stat-${testname} PROPERTIES + DEPENDS "H5REPACK_STAT-${testname}" + ) endif () endif () endmacro () @@ -463,25 +448,25 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5REPACK_VERIFY_LAYOUT-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${testname}.${testfile} - testfiles/${testfile}-${testname}-v.out - testfiles/${testfile}-${testname}-v.out.err + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${testfile} + ) + set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack ) - if (last_test) - set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5REPACK_VERIFY_LAYOUT-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) - set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname} PROPERTIES DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}-clear-objects) + set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname} PROPERTIES + DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}-clear-objects + ) add_test ( NAME H5REPACK_VERIFY_LAYOUT-${testname}_DFF COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) - set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}_DFF PROPERTIES DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}) + set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}_DFF PROPERTIES + DEPENDS H5REPACK_VERIFY_LAYOUT-${testname} + ) if (NOT ${resultcode}) add_test ( NAME H5REPACK_VERIFY_LAYOUT-${testname}_DMP @@ -496,7 +481,9 @@ -D "TEST_REFERENCE=${testfilter}" -P "${HDF_RESOURCES_EXT_DIR}/grepTest.cmake" ) - set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}_DMP PROPERTIES DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}_DFF) + set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}_DMP PROPERTIES + DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}_DFF + ) else () if ("${testfilter}" STREQUAL "CHUNKED") set (nottestfilter "(CONTIGUOUS|COMPACT)") @@ -520,7 +507,9 @@ -D "TEST_REFERENCE=${testfilter}" -P "${HDF_RESOURCES_EXT_DIR}/grepTest.cmake" ) - set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}_DMP PROPERTIES DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}_DFF) + set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}_DMP PROPERTIES + DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}_DFF + ) endif () endif () endif () @@ -540,21 +529,19 @@ # Remove any output file left over from previous test run add_test ( NAME H5REPACK_VERIFY_LAYOUT_VDS-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${testname}.${testfile} - testfiles/${testfile}-${testname}-v.out - testfiles/${testfile}-${testname}-v.out.err + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${testfile} + ) + set_tests_properties (H5REPACK_VERIFY_LAYOUT_VDS-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack ) - if (last_test) - set_tests_properties (H5REPACK_VERIFY_LAYOUT_VDS-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5REPACK_VERIFY_LAYOUT_VDS-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) - set_tests_properties (H5REPACK_VERIFY_LAYOUT_VDS-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - set_tests_properties (H5REPACK_VERIFY_LAYOUT_VDS-${testname} PROPERTIES DEPENDS H5REPACK_VERIFY_LAYOUT_VDS-${testname}-clear-objects) + set_tests_properties (H5REPACK_VERIFY_LAYOUT_VDS-${testname} PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + DEPENDS H5REPACK_VERIFY_LAYOUT_VDS-${testname}-clear-objects + ) add_test ( NAME H5REPACK_VERIFY_LAYOUT_VDS-${testname}_DMP COMMAND "${CMAKE_COMMAND}" @@ -567,8 +554,10 @@ -D "TEST_REFERENCE=${testfile}-${testname}-v.ddl" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5REPACK_VERIFY_LAYOUT_VDS-${testname}_DMP PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - set_tests_properties (H5REPACK_VERIFY_LAYOUT_VDS-${testname}_DMP PROPERTIES DEPENDS H5REPACK_VERIFY_LAYOUT_VDS-${testname}) + set_tests_properties (H5REPACK_VERIFY_LAYOUT_VDS-${testname}_DMP PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + DEPENDS H5REPACK_VERIFY_LAYOUT_VDS-${testname} + ) endif () endif () endmacro () @@ -578,20 +567,18 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5REPACK_VERIFY_SUPERBLOCK-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${testname}.${testfile} - testfiles/${testfile}-${testname}-v.out - testfiles/${testfile}-${testname}-v.out.err + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${testfile} + ) + set_tests_properties (H5REPACK_VERIFY_SUPERBLOCK-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack ) - if (last_test) - set_tests_properties (H5REPACK_VERIFY_SUPERBLOCK-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5REPACK_VERIFY_SUPERBLOCK-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -j;${lowbound};-k;${highbound} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) - set_tests_properties (H5REPACK_VERIFY_SUPERBLOCK-${testname} PROPERTIES DEPENDS H5REPACK_VERIFY_SUPERBLOCK-${testname}-clear-objects) + set_tests_properties (H5REPACK_VERIFY_SUPERBLOCK-${testname} PROPERTIES + DEPENDS H5REPACK_VERIFY_SUPERBLOCK-${testname}-clear-objects + ) add_test ( NAME H5REPACK_VERIFY_SUPERBLOCK-${testname}_DMP COMMAND "${CMAKE_COMMAND}" @@ -605,28 +592,27 @@ -D "TEST_REFERENCE=SUPERBLOCK_VERSION ${superblock}" -P "${HDF_RESOURCES_EXT_DIR}/grepTest.cmake" ) - set_tests_properties (H5REPACK_VERIFY_SUPERBLOCK-${testname}_DMP PROPERTIES DEPENDS H5REPACK_VERIFY_SUPERBLOCK-${testname}) + set_tests_properties (H5REPACK_VERIFY_SUPERBLOCK-${testname}_DMP PROPERTIES + DEPENDS H5REPACK_VERIFY_SUPERBLOCK-${testname} + ) endif () endmacro () macro (ADD_H5_VERIFY_INVALIDBOUNDS testname resultcode lowbound highbound) add_test ( NAME ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${testfile} + ) + set_tests_properties (ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack ) - if (last_test) - set_tests_properties (ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -j;${lowbound};-k;${highbound} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) - set_tests_properties ( - ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname} PROPERTIES - DEPENDS ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname}-clear-objects - WILL_FAIL "true" + set_tests_properties (ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname} PROPERTIES + DEPENDS ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname}-clear-objects + WILL_FAIL "true" ) endmacro () @@ -634,28 +620,33 @@ # Remove any output file left over from previous test run add_test ( NAME H5REPACK_META-${testname}_N-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}_N.${testname}.h5 testfiles/out-${testname}_M.${testname}.h5 ) - if (last_test) - set_tests_properties (H5REPACK_META-${testname}_N-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () + set_tests_properties (H5REPACK_META-${testname}_N-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack + ) add_test ( NAME H5REPACK_META-${testname}_N COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}_N.${testname}.h5 ) - set_tests_properties (H5REPACK_META-${testname}_N PROPERTIES DEPENDS H5REPACK_META-${testname}_N-clear-objects) + set_tests_properties (H5REPACK_META-${testname}_N PROPERTIES + DEPENDS H5REPACK_META-${testname}_N-clear-objects + ) add_test ( NAME H5REPACK_META-${testname}_M COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}_M.${testname}.h5 ) - set_tests_properties (H5REPACK_META-${testname}_M PROPERTIES DEPENDS H5REPACK_META-${testname}_N) + set_tests_properties (H5REPACK_META-${testname}_M PROPERTIES + DEPENDS H5REPACK_META-${testname}_N + ) add_test (NAME H5REPACK_META-${testname} COMMAND ${CMAKE_COMMAND} -E compare_files ${PROJECT_BINARY_DIR}/testfiles/out-${testname}_N.${testname}.h5 ${PROJECT_BINARY_DIR}/testfiles/out-${testname}_M.${testname}.h5) - set_tests_properties (H5REPACK_META-${testname} PROPERTIES WILL_FAIL "true") - set_tests_properties (H5REPACK_META-${testname} PROPERTIES DEPENDS H5REPACK_META-${testname}_M) + set_tests_properties (H5REPACK_META-${testname} PROPERTIES + WILL_FAIL "true" + DEPENDS H5REPACK_META-${testname}_M + ) endmacro () macro (ADD_H5_UD_TEST testname resultcode resultfile) @@ -663,17 +654,11 @@ # Remove any output file left over from previous test run add_test ( NAME H5REPACK_UD-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${testname}.${resultfile} - testfiles/${testname}.${resultfile}.out - testfiles/${testname}.${resultfile}.out.err - testfiles/${resultfile}-${testname}.out - testfiles/${resultfile}-${testname}.out.err + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${resultfile} + ) + set_tests_properties (H5REPACK_UD-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack ) - if (last_test) - set_tests_properties (H5REPACK_UD-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5REPACK_UD-${testname} COMMAND "${CMAKE_COMMAND}" @@ -690,7 +675,9 @@ -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5REPACK_UD-${testname} PROPERTIES DEPENDS H5REPACK_UD-${testname}-clear-objects) + set_tests_properties (H5REPACK_UD-${testname} PROPERTIES + DEPENDS H5REPACK_UD-${testname}-clear-objects + ) add_test ( NAME H5REPACK_UD-${testname}-h5dump COMMAND "${CMAKE_COMMAND}" @@ -706,7 +693,9 @@ -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5REPACK_UD-${testname}-h5dump PROPERTIES DEPENDS "H5REPACK_UD-${testname}") + set_tests_properties (H5REPACK_UD-${testname}-h5dump PROPERTIES + DEPENDS "H5REPACK_UD-${testname}" + ) endif () endmacro () @@ -750,67 +739,6 @@ if (HDF5_ENABLE_USING_MEMCHECKER) # Remove any output file left over from previous test run set (LIST_TO_CLEAR - h5dump-help.out - h5repack_layout.h5-chunk_18x13-v.out - h5repack_layout.h5-chunk_18x13-v.out.err - h5repack_layout.h5-chunk_20x10-v.out - h5repack_layout.h5-chunk_20x10-v.out.err - h5repack_layout.h5-chunk_compa-v.out - h5repack_layout.h5-chunk_compa-v.out.err - h5repack_layout.h5-chunk_conti-v.out - h5repack_layout.h5-chunk_conti-v.out.err - h5repack_layout.h5-compa-v.out - h5repack_layout.h5-compa-v.out.err - h5repack_layout.h5-conti-v.out - h5repack_layout.h5-conti-v.out.err - h5repack_layout.h5-deflate_limit.out - h5repack_layout.h5-deflate_limit.out.err - h5repack_layout.h5-dset2_chunk_20x10-v.out - h5repack_layout.h5-dset2_chunk_20x10-v.out.err - h5repack_layout.h5-dset2_chunk_20x10-errstk.out - h5repack_layout.h5-dset2_chunk_20x10-errstk.out.err - h5repack_layout.h5-dset2_compa-v.out - h5repack_layout.h5-dset2_compa-v.out.err - h5repack_layout.h5-dset2_conti-v.out - h5repack_layout.h5-dset2_conti-v.out.err - h5repack_layout.h5-dset_compa_chunk-v.out - h5repack_layout.h5-dset_compa_chunk-v.out.err - h5repack_layout.h5-dset_compa_compa-v.out - h5repack_layout.h5-dset_compa_compa-v.out.err - h5repack_layout.h5-dset_compa_conti-v.out - h5repack_layout.h5-dset_compa_conti-v.out.err - h5repack_layout.h5-dset_conti_chunk-v.out - h5repack_layout.h5-dset_conti_chunk-v.out.err - h5repack_layout.h5-dset_conti_compa-v.out - h5repack_layout.h5-dset_conti_compa-v.out.err - h5repack_layout.h5-dset_conti_conti-v.out - h5repack_layout.h5-dset_conti_conti-v.out.err - h5repack_layout.h5-layout_long_switches-v.out - h5repack_layout.h5-layout_long_switches-v.out.err - h5repack_layout.h5-layout_short_switches-v.out - h5repack_layout.h5-layout_short_switches-v.out.err - h5repack_layout.h5-plugin_test.out - h5repack_layout.h5-plugin_test.out.err - h5repack_layout2.h5-contig_small_compa-v.out - h5repack_layout2.h5-contig_small_compa-v.out.err - h5repack_layout2.h5-contig_small_fixed_compa-v.out - h5repack_layout2.h5-contig_small_fixed_compa-v.out.err - h5repack_layout3.h5-ckdim_biger-v.out - h5repack_layout3.h5-ckdim_biger-v.out.err - h5repack_layout3.h5-ckdim_smaller-v.out - h5repack_layout3.h5-ckdim_smaller-v.out.err - h5repack_layout3.h5-chunk2chunk-v.out - h5repack_layout3.h5-chunk2chunk-v.out.err - h5repack_layout3.h5-chunk2compa-v.out - h5repack_layout3.h5-chunk2compa-v.out.err - h5repack_layout3.h5-chunk2conti-v.out - h5repack_layout3.h5-chunk2conti-v.out.err - h5repack_layout3.h5-error1-v.out - h5repack_layout3.h5-error1-v.out.err - h5repack_layout3.h5-error2-v.out - h5repack_layout3.h5-error2-v.out.err - h5repack_layout3.h5-error3-v.out - h5repack_layout3.h5-error3-v.out.err out-family.tfamily%05d.h5 out-HDFFV-7840.h5diff_attr1.h5 out-attr.h5repack_attr.h5 @@ -919,10 +847,10 @@ NAME H5REPACK-clearall-objects COMMAND ${CMAKE_COMMAND} -E remove ${LIST_TO_CLEAR} ) - set_tests_properties (H5REPACK-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (last_test) - set_tests_properties (H5REPACK-clearall-objects PROPERTIES DEPENDS ${last_test}) - endif () + set_tests_properties (H5REPACK-clearall-objects PROPERTIES + FIXTURES_SETUP clear_h5repack + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + ) endif () ADD_HELP_TEST(help 0 -h) diff --git a/tools/test/h5repack/CMakeVFDTests.cmake b/tools/test/h5repack/CMakeVFDTests.cmake index 7761c17..f88f147 100644 --- a/tools/test/h5repack/CMakeVFDTests.cmake +++ b/tools/test/h5repack/CMakeVFDTests.cmake @@ -48,10 +48,6 @@ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) - if (last_test) - set_tests_properties (H5REPACK-VFD-${vfdname}-h5repacktest PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5REPACK-VFD-${vfdname}-h5repacktest") endmacro () ############################################################################## diff --git a/tools/test/h5stat/CMakeTests.cmake b/tools/test/h5stat/CMakeTests.cmake index 7d0e3f9..9674a77 100644 --- a/tools/test/h5stat/CMakeTests.cmake +++ b/tools/test/h5stat/CMakeTests.cmake @@ -106,21 +106,8 @@ if (${resultcode}) set_tests_properties (H5STAT-${resultfile} PROPERTIES WILL_FAIL "true") endif () - if (last_test) - set_tests_properties (H5STAT-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif () else (HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5STAT-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.out - ${resultfile}.out.err - ) - if (last_test) - set_tests_properties (H5STAT-${resultfile}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () - add_test ( NAME H5STAT-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -132,7 +119,6 @@ -D "TEST_REFERENCE=${resultfile}.ddl" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5STAT-${resultfile} PROPERTIES DEPENDS H5STAT-${resultfile}-clear-objects) endif () endmacro () @@ -143,21 +129,8 @@ if (${resultcode}) set_tests_properties (H5STAT-${resultfile} PROPERTIES WILL_FAIL "true") endif () - if (last_test) - set_tests_properties (H5STAT-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif () else (HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5STAT-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.out - ${resultfile}.out.err - ) - if (last_test) - set_tests_properties (H5STAT-${resultfile}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () - add_test ( NAME H5STAT-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -170,7 +143,6 @@ -D "TEST_ERRREF=${resultfile}.err" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5STAT-${resultfile} PROPERTIES DEPENDS H5STAT-${resultfile}-clear-objects) endif () endmacro () @@ -187,13 +159,8 @@ endforeach () add_test ( NAME H5STAT-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove ${CLEAR_LIST} + COMMAND ${CMAKE_COMMAND} -E remove ${CLEAR_LIST} ) - if (last_test) - set_tests_properties (H5STAT-clearall-objects PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5STAT-clearall-objects") endif () # Test for help flag diff --git a/tools/test/misc/CMakeTestsClear.cmake b/tools/test/misc/CMakeTestsClear.cmake index 99650e6..a2c494d 100644 --- a/tools/test/misc/CMakeTestsClear.cmake +++ b/tools/test/misc/CMakeTestsClear.cmake @@ -94,16 +94,6 @@ macro (ADD_H5_CMP testname resultfile resultcode) if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5CLEAR_CMP-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${testname}.out - testfiles/${testname}.out.err - ) - if (last_test) - set_tests_properties (H5CLEAR_CMP-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () - add_test ( NAME H5CLEAR_CMP-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -115,24 +105,12 @@ -D "TEST_REFERENCE=${resultfile}.ddl" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5CLEAR_CMP-${testname} PROPERTIES DEPENDS H5CLEAR_CMP-${testname}-clear-objects) - set (last_test "H5CLEAR_CMP-${testname}") endif () endmacro () macro (ADD_H5_ERR_CMP testname resultfile resultcode) if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5CLEAR_CMP-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${testname}.out - testfiles/${testname}.out.err - ) - if (last_test) - set_tests_properties (H5CLEAR_CMP-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () - add_test ( NAME H5CLEAR_CMP-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -145,8 +123,6 @@ -D "TEST_ERRREF=${resultfile}.err" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5CLEAR_CMP-${testname} PROPERTIES DEPENDS H5CLEAR_CMP-${testname}-clear-objects) - set (last_test "H5CLEAR_CMP-${testname}") endif () endmacro () @@ -154,22 +130,16 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5CLEAR_CMP-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${testname}.out - testfiles/${testname}.out.err - testfiles/${testfile} - ) - if (last_test) - set_tests_properties (H5CLEAR_CMP-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () + COMMAND ${CMAKE_COMMAND} -E remove testfiles/${testfile} + ) add_test ( NAME H5CLEAR_CMP-copy_${testname} - COMMAND ${CMAKE_COMMAND} - -E copy_if_different + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/testfiles/${testfile}" "${PROJECT_BINARY_DIR}/testfiles/${testfile}" ) - set_tests_properties (H5CLEAR_CMP-copy_${testname} PROPERTIES DEPENDS H5CLEAR_CMP-${testname}-clear-objects) + set_tests_properties (H5CLEAR_CMP-copy_${testname} PROPERTIES + DEPENDS H5CLEAR_CMP-${testname}-clear-objects + ) add_test ( NAME H5CLEAR_CMP-${testname} COMMAND "${CMAKE_COMMAND}" @@ -182,8 +152,9 @@ -D "TEST_REFERENCE=${resultfile}.ddl" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5CLEAR_CMP-${testname} PROPERTIES DEPENDS H5CLEAR_CMP-copy_${testname}) - set (last_test "H5CLEAR_CMP-${testname}") + set_tests_properties (H5CLEAR_CMP-${testname} PROPERTIES + DEPENDS H5CLEAR_CMP-copy_${testname} + ) endif () endmacro () @@ -191,22 +162,16 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5CLEAR_CMP-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${testname}.out - testfiles/${testname}.out.err - testfiles/${testfile} - ) - if (last_test) - set_tests_properties (H5CLEAR_CMP-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () + COMMAND ${CMAKE_COMMAND} -E remove testfiles/${testfile} + ) add_test ( NAME H5CLEAR_CMP-copy_${testname} - COMMAND ${CMAKE_COMMAND} - -E copy_if_different + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/testfiles/${testfile}" "${PROJECT_BINARY_DIR}/testfiles/${testfile}" ) - set_tests_properties (H5CLEAR_CMP-copy_${testname} PROPERTIES DEPENDS H5CLEAR_CMP-${testname}-clear-objects) + set_tests_properties (H5CLEAR_CMP-copy_${testname} PROPERTIES + DEPENDS H5CLEAR_CMP-${testname}-clear-objects + ) add_test ( NAME H5CLEAR_CMP-${testname} COMMAND "${CMAKE_COMMAND}" @@ -220,8 +185,9 @@ -D "TEST_ERRREF=${resultfile}.err" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5CLEAR_CMP-${testname} PROPERTIES DEPENDS H5CLEAR_CMP-copy_${testname}) - set (last_test "H5CLEAR_CMP-${testname}") + set_tests_properties (H5CLEAR_CMP-${testname} PROPERTIES + DEPENDS H5CLEAR_CMP-copy_${testname} + ) endif () endmacro () @@ -231,12 +197,10 @@ NAME H5CLEAR_RET-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ) - set_tests_properties (H5CLEAR_RET-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - set_tests_properties (H5CLEAR_RET-${testname} PROPERTIES WILL_FAIL "${resultcode}") - if (last_test) - set_tests_properties (H5CLEAR_RET-${testname} PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5CLEAR_RET-${testname}") + set_tests_properties (H5CLEAR_RET-${testname} PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + WILL_FAIL "${resultcode}" + ) endif () endmacro () @@ -244,24 +208,16 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5CLEAR_FILESIZE_TEST-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${testname}_before_size.out - testfiles/${testname}_before_size.out.err - testfiles/${testname}_after_size.out - testfiles/${testname}_after_size.out.err - testfiles/${testname}.h5 - ) - if (last_test) - set_tests_properties (H5CLEAR_FILESIZE_TEST-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () + COMMAND ${CMAKE_COMMAND} -E remove testfiles/${testname}.h5 + ) add_test ( NAME H5CLEAR_FILESIZE_TEST-copy_${testname} - COMMAND ${CMAKE_COMMAND} - -E copy_if_different + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/testfiles/${testname}.h5" "${PROJECT_BINARY_DIR}/testfiles/${testname}.h5" ) - set_tests_properties (H5CLEAR_FILESIZE_TEST-copy_${testname} PROPERTIES DEPENDS H5CLEAR_FILESIZE_TEST-${testname}-clear-objects) + set_tests_properties (H5CLEAR_FILESIZE_TEST-copy_${testname} PROPERTIES + DEPENDS H5CLEAR_FILESIZE_TEST-${testname}-clear-objects + ) add_test ( NAME H5CLEAR_FILESIZE_CMP-${testname}_before_size COMMAND "${CMAKE_COMMAND}" @@ -274,7 +230,9 @@ -D "TEST_REFERENCE=${resultfile}_before_size.ddl" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5CLEAR_FILESIZE_CMP-${testname}_before_size PROPERTIES DEPENDS H5CLEAR_FILESIZE_TEST-copy_${testname}) + set_tests_properties (H5CLEAR_FILESIZE_CMP-${testname}_before_size PROPERTIES + DEPENDS H5CLEAR_FILESIZE_TEST-copy_${testname} + ) if (NOT ${incr_size} MATCHES "NONE") add_test ( NAME H5CLEAR_FILESIZE_INCR-${testname} @@ -286,9 +244,11 @@ COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ --increment ${testname}.h5 ) endif () - set_tests_properties (H5CLEAR_FILESIZE_INCR-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - set_tests_properties (H5CLEAR_FILESIZE_INCR-${testname} PROPERTIES WILL_FAIL "${resultcode}") - set_tests_properties (H5CLEAR_FILESIZE_INCR-${testname} PROPERTIES DEPENDS H5CLEAR_FILESIZE_CMP-${testname}_before_size) + set_tests_properties (H5CLEAR_FILESIZE_INCR-${testname} PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + WILL_FAIL "${resultcode}" + DEPENDS H5CLEAR_FILESIZE_CMP-${testname}_before_size + ) add_test ( NAME H5CLEAR_FILESIZE_CMP-${testname}_after_size COMMAND "${CMAKE_COMMAND}" @@ -297,12 +257,75 @@ -D "TEST_ARGS:STRING=--filesize;${testname}.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${testname}_after_size.out" + -D "TEST_EXPECT=0" + -D "TEST_REFERENCE=${resultfile}_after_size.ddl" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5CLEAR_FILESIZE_CMP-${testname}_after_size PROPERTIES + DEPENDS H5CLEAR_FILESIZE_INCR-${testname} + ) + endif () + endmacro () + + macro (ADD_H5_FILESIZE_FAIL_TEST testname resultcode resultfile incr_size) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5CLEAR_FILESIZE_FAIL_TEST-${testname}-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove testfiles/${testname}.h5 + ) + add_test ( + NAME H5CLEAR_FILESIZE_FAIL_TEST-copy_${testname} + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${PROJECT_SOURCE_DIR}/testfiles/${testname}.h5" "${PROJECT_BINARY_DIR}/testfiles/${testname}.h5" + ) + set_tests_properties (H5CLEAR_FILESIZE_FAIL_TEST-copy_${testname} PROPERTIES + DEPENDS H5CLEAR_FILESIZE_FAIL_TEST-${testname}-clear-objects + ) + add_test ( + NAME H5CLEAR_FILESIZE_FAIL_CMP-${testname}_before_size + COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=--filesize;${testname}.h5" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${testname}_before_size.out" -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}.mty" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5CLEAR_FILESIZE_FAIL_CMP-${testname}_before_size PROPERTIES + DEPENDS H5CLEAR_FILESIZE_FAIL_TEST-copy_${testname} + ) + if (NOT ${incr_size} MATCHES "NONE") + add_test ( + NAME H5CLEAR_FILESIZE_FAIL_INCR-${testname} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -s --increment=${incr_size} ${testname}.h5 + ) + else () + add_test ( + NAME H5CLEAR_FILESIZE_FAIL_INCR-${testname} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -s --increment ${testname}.h5 + ) + endif () + set_tests_properties (H5CLEAR_FILESIZE_FAIL_INCR-${testname} PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + DEPENDS H5CLEAR_FILESIZE_FAIL_CMP-${testname}_before_size + ) + add_test ( + NAME H5CLEAR_FILESIZE_FAIL_CMP-${testname}_after_size + COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=--filesize;${testname}.h5" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${testname}_after_size.out" + -D "TEST_EXPECT=0" -D "TEST_REFERENCE=${resultfile}_after_size.ddl" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5CLEAR_FILESIZE_CMP-${testname}_after_size PROPERTIES DEPENDS H5CLEAR_FILESIZE_INCR-${testname}) - set (last_test "H5CLEAR_FILESIZE_CMP-${testname}_after_size") + set_tests_properties (H5CLEAR_FILESIZE_FAIL_CMP-${testname}_after_size PROPERTIES + DEPENDS H5CLEAR_FILESIZE_FAIL_INCR-${testname} + ) endif () endmacro () @@ -310,32 +333,39 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5CLEAR-clr_open_chk-copy_${testname}.h5 - COMMAND ${CMAKE_COMMAND} - -E copy_if_different + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/testfiles/${testfile}.h5" "${PROJECT_BINARY_DIR}/testfiles/${testfile}.h5" ) - if (last_test) - set_tests_properties (H5CLEAR-clr_open_chk-copy_${testname}.h5 PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5CLEAR-clr_open_chk-copy_${testname}.h5") # Initial file open fails OR # File open succeeds because the library does not check status_flags for file with < v3 superblock - add_test (NAME H5CLEAR-clr_open_chk-${testname}_${resultcode} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${testfile}.h5) - set_tests_properties (H5CLEAR-clr_open_chk-${testname}_${resultcode} PROPERTIES WILL_FAIL "${resultcode}") - set_tests_properties (H5CLEAR-clr_open_chk-${testname}_${resultcode} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (last_test) - set_tests_properties (H5CLEAR-clr_open_chk-${testname}_${resultcode} PROPERTIES DEPENDS ${last_test}) - endif () + add_test ( + NAME H5CLEAR-clr_open_chk-${testname}_${resultcode} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${testfile}.h5 + ) + set_tests_properties (H5CLEAR-clr_open_chk-${testname}_${resultcode} PROPERTIES + WILL_FAIL "${resultcode}" + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + DEPENDS H5CLEAR-clr_open_chk-copy_${testname}.h5 + ) # After "h5clear" the file, the subsequent file open succeeds - add_test (NAME H5CLEAR-h5clr-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -s ${testfile}.h5) - set_tests_properties (H5CLEAR-h5clr-${testname} PROPERTIES DEPENDS H5CLEAR-clr_open_chk-${testname}_${resultcode}) - set_tests_properties (H5CLEAR-h5clr-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - add_test (NAME H5CLEAR-clr_open_chk-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${testfile}.h5) - set_tests_properties (H5CLEAR-clr_open_chk-${testname} PROPERTIES DEPENDS H5CLEAR-h5clr-${testname}) - set_tests_properties (H5CLEAR-clr_open_chk-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - set (last_test "H5CLEAR-clr_open_chk-${testname}") + add_test ( + NAME H5CLEAR-h5clr-${testname} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -s ${testfile}.h5 + ) + set_tests_properties (H5CLEAR-h5clr-${testname} PROPERTIES + DEPENDS H5CLEAR-clr_open_chk-${testname}_${resultcode} + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + ) + add_test ( + NAME H5CLEAR-clr_open_chk-${testname} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${testfile}.h5 + ) + set_tests_properties (H5CLEAR-clr_open_chk-${testname} PROPERTIES + DEPENDS H5CLEAR-h5clr-${testname} + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + ) endif () endmacro () @@ -347,73 +377,6 @@ # # # -# The following are tests to verify the status_flags field is cleared properly: -if (HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5CLEAR-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - h5clear_log_v3.h5 - h5clear_mdc_image.h5 - h5clear_sec2_v0.h5 - h5clear_sec2_v2.h5 - h5clear_sec2_v3.h5 - orig_h5clear_sec2_v0.h5 - orig_h5clear_sec2_v2.h5 - orig_h5clear_sec2_v3.h5 - latest_h5clear_log_v3.h5 - latest_h5clear_sec2_v3.h5 - mod_h5clear_mdc_image.h5 - mod_h5clear_mdc_image2.h5 - ${HDF5_TEST_FILES} - ) - if (last_test) - set_tests_properties (H5CLEAR-clearall-objects PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5CLEAR-clearall-objects") - - foreach (h5_file ${HDF5_TEST_FILES} ${HDF5_SEC2_TEST_FILES}) - add_test ( - NAME H5CLEAR-copy_${h5_file} - COMMAND ${CMAKE_COMMAND} - -E copy_if_different - "${PROJECT_SOURCE_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/testfiles/${h5_file}" - ) - if (last_test) - set_tests_properties (H5CLEAR-copy_${h5_file} PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5CLEAR-copy_${h5_file}") - endforeach () - # make second copy of h5clear_sec2.h5 - foreach (h5_file ${HDF5_SEC2_TEST_FILES}) - add_test ( - NAME H5CLEAR-copy_orig_${h5_file} - COMMAND ${CMAKE_COMMAND} - -E copy_if_different - "${PROJECT_SOURCE_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/testfiles/orig_${h5_file}" - ) - if (last_test) - set_tests_properties (H5CLEAR-copy_orig_${h5_file} PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5CLEAR-copy_orig_${h5_file}") - endforeach () - # make second copy of mod_h5clear_mdc_image.h5 - add_test ( - NAME H5CLEAR-copy_mod_h5clr_mdc_image2.h5 - COMMAND ${CMAKE_COMMAND} - -E copy_if_different - "${PROJECT_SOURCE_DIR}/testfiles/mod_h5clear_mdc_image.h5" "${PROJECT_BINARY_DIR}/testfiles/mod_h5clear_mdc_image2.h5" - ) - if (last_test) - set_tests_properties (H5CLEAR-copy_mod_h5clr_mdc_image2.h5 PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5CLEAR-copy_mod_h5clr_mdc_image2.h5") -endif() - -# -# -# # The following are tests to verify the expected output from h5clear # "h5clear -h" # "h5clear" (no options, no file) @@ -487,9 +450,7 @@ endif() # "h5clear -s --increment=0 h5clear_status_noclose.h5" (clear status_flag, EOA = MAX(EOA, EOF) + 0) # (no output, check exit code) # "h5clear --filesize h5clear_status_noclose.h5" (print EOA/EOF after the last action) - ADD_H5_ERR_CMP_WITH_COPY (h5clr_open_fail_nc_s 1 h5clear_open_fail h5clear_status_noclose.h5 "--filesize") - ADD_H5_RETTEST (h5clr_mdc_image_nc "false" "-s" "--increment=0" h5clear_status_noclose.h5) - ADD_H5_CMP (h5clr_no_mdc_image_nc_m h5clear_status_noclose_after_size 0 "--filesize" h5clear_status_noclose.h5) + ADD_H5_FILESIZE_FAIL_TEST (h5clear_status_noclose 1 h5clear_status_noclose 0) # # (2) h5clear_fsm_persist_noclose.h5 # "h5clear --filesize h5clear_fsm_persist_noclose.h5" (print EOA/EOF before the next action) diff --git a/tools/test/misc/CMakeTestsMkgrp.cmake b/tools/test/misc/CMakeTestsMkgrp.cmake index 37d87ca..11fa3f2 100644 --- a/tools/test/misc/CMakeTestsMkgrp.cmake +++ b/tools/test/misc/CMakeTestsMkgrp.cmake @@ -61,29 +61,22 @@ endif () macro (ADD_H5_TEST resultfile resultcode resultoption) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5MKGRP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.h5 - ${resultfile}.out - ${resultfile}.out.err - ) - set_tests_properties (H5MKGRP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - endif () - + add_test ( + NAME H5MKGRP-${resultfile}-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove ${resultfile}.h5 + ) + set_tests_properties (H5MKGRP-${resultfile}-clear-objects PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + ) add_test ( NAME H5MKGRP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${resultoption} ${resultfile}.h5 ${ARGN} ) - set_tests_properties (H5MKGRP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (HDF5_ENABLE_USING_MEMCHECKER) - if (last_test) - set_tests_properties (H5MKGRP-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif () - else () - set_tests_properties (H5MKGRP-${resultfile} PROPERTIES DEPENDS H5MKGRP-${resultfile}-clear-objects) + set_tests_properties (H5MKGRP-${resultfile} PROPERTIES + DEPENDS H5MKGRP-${resultfile}-clear-objects + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + ) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5MKGRP-${resultfile}-h5ls COMMAND "${CMAKE_COMMAND}" @@ -107,13 +100,11 @@ else () add_test ( NAME H5MKGRP_CMP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.h5 - ${resultfile}.out - ${resultfile}.out.err + COMMAND ${CMAKE_COMMAND} -E remove ${resultfile}.h5 + ) + set_tests_properties (H5MKGRP_CMP-${resultfile}-clear-objects PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" ) - set_tests_properties (H5MKGRP_CMP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") add_test ( NAME H5MKGRP_CMP-${resultfile} COMMAND "${CMAKE_COMMAND}" @@ -126,7 +117,9 @@ -D "TEST_REFERENCE=${resultfile}.txt" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5MKGRP_CMP-${resultfile} PROPERTIES DEPENDS H5MKGRP_CMP-${resultfile}-clear-objects) + set_tests_properties (H5MKGRP_CMP-${resultfile} PROPERTIES + DEPENDS H5MKGRP_CMP-${resultfile}-clear-objects + ) endif () endmacro () @@ -138,54 +131,23 @@ if (HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5MKGRP-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - h5mkgrp_help.out - h5mkgrp_help.out.err - h5mkgrp_version.out - h5mkgrp_version.out.err - h5mkgrp_single.h5 - h5mkgrp_single.out - h5mkgrp_single.out.err - h5mkgrp_single_v.h5 - h5mkgrp_single_v.out - h5mkgrp_single_v.out.err - h5mkgrp_single_p.h5 - h5mkgrp_single_p.out - h5mkgrp_single_p.out.err - h5mkgrp_single_l.h5 - h5mkgrp_single_l.out - h5mkgrp_single_l.out.err - h5mkgrp_several.h5 - h5mkgrp_several.out - h5mkgrp_several.out.err - h5mkgrp_several_v.h5 - h5mkgrp_several_v.out - h5mkgrp_several_v.out.err - h5mkgrp_several_p.h5 - h5mkgrp_several_p.out - h5mkgrp_several_p.out.err - h5mkgrp_several_l.h5 - h5mkgrp_several_l.out - h5mkgrp_several_l.out.err - h5mkgrp_nested_p.h5 - h5mkgrp_nested_p.out - h5mkgrp_nested_p.out.err - h5mkgrp_nested_lp.h5 - h5mkgrp_nested_lp.out - h5mkgrp_nested_lp.out.err - h5mkgrp_nested_mult_p.h5 - h5mkgrp_nested_mult_p.out - h5mkgrp_nested_mult_p.out.err - h5mkgrp_nested_mult_lp.h5 - h5mkgrp_nested_mult_lp.out - h5mkgrp_nested_mult_lp.out.err + COMMAND ${CMAKE_COMMAND} -E remove + h5mkgrp_single.h5 + h5mkgrp_single_v.h5 + h5mkgrp_single_p.h5 + h5mkgrp_single_l.h5 + h5mkgrp_several.h5 + h5mkgrp_several_v.h5 + h5mkgrp_several_p.h5 + h5mkgrp_several_l.h5 + h5mkgrp_nested_p.h5 + h5mkgrp_nested_lp.h5 + h5mkgrp_nested_mult_p.h5 + h5mkgrp_nested_mult_lp.h5 + ) + set_tests_properties (H5MKGRP-clearall-objects PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" ) - set_tests_properties (H5MKGRP-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (last_test) - set_tests_properties (H5MKGRP-clearall-objects PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5MKGRP-clearall-objects") endif () # Check that help & version is displayed properly diff --git a/tools/test/misc/CMakeTestsRepart.cmake b/tools/test/misc/CMakeTestsRepart.cmake index 24b6004..fa49c53 100644 --- a/tools/test/misc/CMakeTestsRepart.cmake +++ b/tools/test/misc/CMakeTestsRepart.cmake @@ -80,31 +80,46 @@ set_tests_properties (H5REPART-clearall-objects PROPERTIES FIXTURES_SETUP clear_testrepart) # repartition family member size to 20,000 bytes. - add_test (NAME H5REPART-h5repart_20K COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -m 20000 family_file%05d.h5 fst_family%05d.h5) + add_test ( + NAME H5REPART-h5repart_20K + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -m 20000 family_file%05d.h5 fst_family%05d.h5 + ) set_tests_properties (H5REPART-h5repart_20K PROPERTIES FIXTURES_REQUIRED clear_testrepart ) # repartition family member size to 5 KB. - add_test (NAME H5REPART-h5repart_5K COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -m 5k family_file%05d.h5 scd_family%05d.h5) + add_test ( + NAME H5REPART-h5repart_5K + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -m 5k family_file%05d.h5 scd_family%05d.h5 + ) set_tests_properties (H5REPART-h5repart_5K PROPERTIES FIXTURES_REQUIRED clear_testrepart ) # convert family file to sec2 file of 20,000 bytes - add_test (NAME H5REPART-h5repart_single COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -m 20000 -family_to_single family_file%05d.h5 family_to_single.h5) + add_test ( + NAME H5REPART-h5repart_single + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -m 20000 -family_to_single family_file%05d.h5 family_to_single.h5 + ) set_tests_properties (H5REPART-h5repart_single PROPERTIES FIXTURES_REQUIRED clear_testrepart ) # convert family file to sec2 file of 20,000 bytes (old argument) - add_test (NAME H5REPART-h5repart_sec2 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -m 20000 -family_to_sec2 family_file%05d.h5 family_to_sec2.h5) + add_test ( + NAME H5REPART-h5repart_sec2 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -m 20000 -family_to_sec2 family_file%05d.h5 family_to_sec2.h5 + ) set_tests_properties (H5REPART-h5repart_sec2 PROPERTIES FIXTURES_REQUIRED clear_testrepart ) # test the output files repartitioned above. - add_test (NAME H5REPART-h5repart_test COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) + add_test ( + NAME H5REPART-h5repart_test + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ + ) set_tests_properties (H5REPART-h5repart_test PROPERTIES DEPENDS "H5REPART-h5repart_20K;H5REPART-h5repart_5K;H5REPART-h5repart_single;H5REPART-h5repart_sec2" ) diff --git a/tools/test/perform/CMakeTests.cmake b/tools/test/perform/CMakeTests.cmake index f0eb65f..f0ae416 100644 --- a/tools/test/perform/CMakeTests.cmake +++ b/tools/test/perform/CMakeTests.cmake @@ -67,8 +67,10 @@ else () -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () -set_tests_properties (PERFORM_h5perf_serial PROPERTIES TIMEOUT ${CTEST_VERY_LONG_TIMEOUT}) -set_tests_properties (PERFORM_h5perf_serial PROPERTIES DEPENDS "PERFORM_h5perform-clearall-objects") +set_tests_properties (PERFORM_h5perf_serial PROPERTIES + TIMEOUT ${CTEST_VERY_LONG_TIMEOUT} + DEPENDS "PERFORM_h5perform-clearall-objects" +) if (HDF5_BUILD_PERFORM_STANDALONE) add_test (NAME PERFORM_h5perf_serial_alone COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) @@ -89,7 +91,9 @@ else () -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () -set_tests_properties (PERFORM_chunk PROPERTIES DEPENDS "PERFORM_h5perform-clearall-objects") +set_tests_properties (PERFORM_chunk PROPERTIES + DEPENDS "PERFORM_h5perform-clearall-objects" +) if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME PERFORM_iopipe COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) @@ -106,7 +110,9 @@ else () -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () -set_tests_properties (PERFORM_iopipe PROPERTIES DEPENDS "PERFORM_h5perform-clearall-objects") +set_tests_properties (PERFORM_iopipe PROPERTIES + DEPENDS "PERFORM_h5perform-clearall-objects" +) if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME PERFORM_overhead COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) @@ -123,7 +129,9 @@ else () -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () -set_tests_properties (PERFORM_overhead PROPERTIES DEPENDS "PERFORM_h5perform-clearall-objects") +set_tests_properties (PERFORM_overhead PROPERTIES + DEPENDS "PERFORM_h5perform-clearall-objects" +) if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME PERFORM_perf_meta COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) @@ -140,7 +148,9 @@ else () -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () -set_tests_properties (PERFORM_perf_meta PROPERTIES DEPENDS "PERFORM_h5perform-clearall-objects") +set_tests_properties (PERFORM_perf_meta PROPERTIES + DEPENDS "PERFORM_h5perform-clearall-objects" +) if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME PERFORM_zip_perf_help COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ "-h") @@ -157,7 +167,9 @@ else () -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () -set_tests_properties (PERFORM_zip_perf_help PROPERTIES DEPENDS "PERFORM_h5perform-clearall-objects") +set_tests_properties (PERFORM_zip_perf_help PROPERTIES + DEPENDS "PERFORM_h5perform-clearall-objects" +) if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME PERFORM_zip_perf COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ tfilters.h5) @@ -174,7 +186,9 @@ else () -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () -set_tests_properties (PERFORM_zip_perf PROPERTIES DEPENDS "PERFORM_zip_perf_help;PERFORM_h5perform-clearall-objects") +set_tests_properties (PERFORM_zip_perf PROPERTIES + DEPENDS "PERFORM_zip_perf_help;PERFORM_h5perform-clearall-objects" +) if (H5_HAVE_PARALLEL) if (UNIX) -- cgit v0.12 From f723e0e7f19b778d9c865982fda5f76cc2f875e0 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 23 Jul 2019 16:28:54 -0500 Subject: HDFFV-10529 add note --- release_docs/RELEASE.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index fe40021..b4fa11c 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -48,6 +48,14 @@ New Features Configuration: ------------- + - Update CMake tests to use FIXTURES + + CMake test fixtures allow setup/cleanup tests and other dependency + requirements as properties for tests. This is more flexible for + modern CMake code. + + (ADB - 2019/07/23, HDFFV-10529) + - Windows PDB files are always installed There are build configuration or flag settings for Windows that may not @@ -55,7 +63,7 @@ New Features utility will fail because those PDB files are not found. An optional variable, DISABLE_PDB_FILES, was added to not install PDB files. - (ADB - 2019/07/17, HDFFV-100424) + (ADB - 2019/07/17, HDFFV-10424) - Add mingw CMake support with a toolchain file -- cgit v0.12 From 8008294578b5a133907d7ab1dd20e34735c54535 Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Thu, 25 Jul 2019 11:36:37 -0500 Subject: Squashed commit of the following: Merge changes from update_merged_S3_HDFS branch into develop. commit d5034315aea88629929ac0c9c59ebfafd5f21a31 Merge: 9c48823 d3fdcd8 Author: Larry Knox Date: Thu Jul 25 08:24:53 2019 -0500 Merge branch 'develop' into update_merged_S3_HDFS --- CMakeLists.txt | 21 + MANIFEST | 22 + bin/trace | 2 + config/cmake/ConfigureChecks.cmake | 15 + config/cmake/FindHDFS.cmake | 70 + config/cmake/H5pubconf.h.in | 31 + config/cmake/libhdf5.settings.cmake.in | 2 + configure.ac | 125 + java/examples/groups/JavaGroupExample.sh.in | 2 + java/src/Makefile.am | 2 + java/src/hdf/hdf5lib/CMakeLists.txt | 2 + java/src/hdf/hdf5lib/H5.java | 10 + java/src/hdf/hdf5lib/HDF5Constants.java | 6 + java/src/hdf/hdf5lib/structs/H5FD_hdfs_fapl_t.java | 102 + java/src/hdf/hdf5lib/structs/H5FD_ros3_fapl_t.java | 121 + java/src/jni/h5Constants.c | 4 + java/test/CMakeLists.txt | 14 + java/test/Makefile.am | 2 + java/test/TestAll.java | 1 + java/test/TestH5Pfapl.java | 4 + java/test/TestH5Pfaplhdfs.java | 393 ++ java/test/TestH5Pfapls3.java | 406 +++ java/test/junit.sh.in | 48 + java/test/testfiles/JUnit-TestH5Pfaplhdfs.txt | 9 + java/test/testfiles/JUnit-TestH5Pfapls3.txt | 10 + src/CMakeLists.txt | 7 + src/H5FDhdfs.c | 2070 +++++++++++ src/H5FDhdfs.h | 122 + src/H5FDros3.c | 1847 ++++++++++ src/H5FDros3.h | 105 + src/H5FDs3comms.c | 3770 ++++++++++++++++++++ src/H5FDs3comms.h | 634 ++++ src/Makefile.am | 8 +- src/hdf5.h | 18 +- src/libhdf5.settings.in | 2 + test/CMakeLists.txt | 3 + test/CMakeVFDTests.cmake | 1 + test/Makefile.am | 16 +- test/hdfs.c | 1836 ++++++++++ test/ros3.c | 2020 +++++++++++ test/s3comms.c | 2813 +++++++++++++++ test/vfd.c | 167 +- tools/CMakeLists.txt | 7 + tools/lib/h5tools_utils.c | 517 ++- tools/lib/h5tools_utils.h | 10 + tools/libtest/CMakeLists.txt | 21 + tools/libtest/CMakeTests.cmake | 49 + tools/libtest/Makefile.am | 34 + tools/libtest/h5tools_utils.c | 1296 +++++++ tools/src/h5dump/h5dump.c | 330 +- tools/src/h5ls/h5ls.c | 321 +- tools/src/h5stat/h5stat.c | 251 +- tools/test/h5stat/testfiles/h5stat_help1.ddl | 10 + tools/test/h5stat/testfiles/h5stat_help2.ddl | 10 + tools/test/h5stat/testfiles/h5stat_nofile.ddl | 10 + tools/testfiles/h5dump-help.txt | 10 + tools/testfiles/help-1.ls | 9 + tools/testfiles/help-2.ls | 9 + tools/testfiles/help-3.ls | 9 + .../pbits/tnofilename-with-packed-bits.ddl | 10 + tools/testfiles/pbits/tpbitsIncomplete.ddl | 10 + tools/testfiles/pbits/tpbitsLengthExceeded.ddl | 10 + tools/testfiles/pbits/tpbitsLengthPositive.ddl | 10 + tools/testfiles/pbits/tpbitsMaxExceeded.ddl | 10 + tools/testfiles/pbits/tpbitsOffsetExceeded.ddl | 10 + tools/testfiles/pbits/tpbitsOffsetNegative.ddl | 10 + tools/testfiles/textlinksrc-nodangle-1.ls | 9 + tools/testfiles/tgroup-1.ls | 9 + 68 files changed, 19629 insertions(+), 225 deletions(-) create mode 100644 config/cmake/FindHDFS.cmake create mode 100644 java/src/hdf/hdf5lib/structs/H5FD_hdfs_fapl_t.java create mode 100644 java/src/hdf/hdf5lib/structs/H5FD_ros3_fapl_t.java create mode 100644 java/test/TestH5Pfaplhdfs.java create mode 100644 java/test/TestH5Pfapls3.java create mode 100644 java/test/testfiles/JUnit-TestH5Pfaplhdfs.txt create mode 100644 java/test/testfiles/JUnit-TestH5Pfapls3.txt create mode 100644 src/H5FDhdfs.c create mode 100644 src/H5FDhdfs.h create mode 100644 src/H5FDros3.c create mode 100644 src/H5FDros3.h create mode 100644 src/H5FDs3comms.c create mode 100644 src/H5FDs3comms.h create mode 100644 test/hdfs.c create mode 100644 test/ros3.c create mode 100644 test/s3comms.c create mode 100644 tools/libtest/CMakeLists.txt create mode 100644 tools/libtest/CMakeTests.cmake create mode 100644 tools/libtest/Makefile.am create mode 100644 tools/libtest/h5tools_utils.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 95d24bb..dc6a94f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -574,6 +574,27 @@ include (${HDF_RESOURCES_DIR}/HDFCompilerFlags.cmake) set (CMAKE_MODULE_PATH ${HDF_RESOURCES_DIR} ${HDF_RESOURCES_EXT_DIR} ${CMAKE_MODULE_PATH}) #----------------------------------------------------------------------------- +# Option to Enable HDFS +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_HDFS "Enable HDFS" OFF) +if (HDF5_ENABLE_HDFS) + find_package(JNI REQUIRED) + if (JNI_FOUND) + set (H5_HAVE_LIBJVM 1) + endif () + find_package(HDFS REQUIRED) + if (HDFS_FOUND) + set (H5_HAVE_LIBHDFS 1) + set (H5_HAVE_HDFS_H 1) + if (NOT MSVC) + list (APPEND LINK_LIBS -pthread) + endif () + else () + message (FATAL_ERROR "Set to use libhdfs library, but could not find or use libhdfs. Please verify that the path to HADOOP_HOME is valid, and/or reconfigure without HDF5_ENABLE_HDFS") + endif () +endif () + +#----------------------------------------------------------------------------- # Option to Enable MPI Parallel #----------------------------------------------------------------------------- option (HDF5_ENABLE_PARALLEL "Enable parallel build (requires MPI)" OFF) diff --git a/MANIFEST b/MANIFEST index 8403d60..02feb72 100644 --- a/MANIFEST +++ b/MANIFEST @@ -636,6 +636,8 @@ ./src/H5FDdrvr_module.h ./src/H5FDfamily.c ./src/H5FDfamily.h +./src/H5FDhdfs.c +./src/H5FDhdfs.h ./src/H5FDint.c ./src/H5FDlog.c ./src/H5FDlog.h @@ -646,9 +648,13 @@ ./src/H5FDmpio.h ./src/H5FDmulti.c ./src/H5FDmulti.h +./src/H5FDros3.c +./src/H5FDros3.h ./src/H5FDpkg.h ./src/H5FDprivate.h ./src/H5FDpublic.h +./src/H5FDs3comms.h +./src/H5FDs3comms.c ./src/H5FDsec2.c ./src/H5FDsec2.h ./src/H5FDspace.c @@ -1069,6 +1075,7 @@ ./test/h5fc_ext_none.h5 ./test/h5test.c ./test/h5test.h +./test/hdfs.c ./test/hyperslab.c ./test/istore.c ./test/le_data.h5 @@ -1094,7 +1101,9 @@ ./test/paged_nopersist.h5 ./test/paged_persist.h5 ./test/reserved.c +./test/ros3.c ./test/pool.c +./test/s3comms.c ./test/set_extent.c # ====distribute this for now. See HDFFV-8236==== ./test/space_overflow.c @@ -1546,6 +1555,9 @@ ./tools/lib/io_timer.c ./tools/lib/io_timer.h +./tools/libtest/Makefile.am +./tools/libtest/h5tools_utils.c + ./tools/src/misc/Makefile.am ./tools/src/misc/h5clear.c ./tools/src/misc/h5debug.c @@ -3015,6 +3027,8 @@ ./java/src/hdf/hdf5lib/structs/H5AC_cache_config_t.java ./java/src/hdf/hdf5lib/structs/H5E_error2_t.java ./java/src/hdf/hdf5lib/structs/H5F_info2_t.java +./java/src/hdf/hdf5lib/structs/H5FD_hdfs_fapl_t.java +./java/src/hdf/hdf5lib/structs/H5FD_ros3_fapl_t.java ./java/src/hdf/hdf5lib/structs/H5G_info_t.java ./java/src/hdf/hdf5lib/structs/H5L_info_t.java ./java/src/hdf/hdf5lib/structs/H5O_hdr_info_t.java @@ -3178,6 +3192,8 @@ ./java/test/testfiles/JUnit-TestH5P.txt ./java/test/testfiles/JUnit-TestH5PData.txt ./java/test/testfiles/JUnit-TestH5Pfapl.txt +./java/test/testfiles/JUnit-TestH5Pfaplhdfs.txt +./java/test/testfiles/JUnit-TestH5Pfapls3.txt ./java/test/testfiles/JUnit-TestH5Plist.txt ./java/test/testfiles/JUnit-TestH5Pvirtual.txt ./java/test/testfiles/JUnit-TestH5PL.txt @@ -3216,6 +3232,8 @@ ./java/test/TestH5P.java ./java/test/TestH5PData.java ./java/test/TestH5Pfapl.java +./java/test/TestH5Pfaplhdfs.java +./java/test/TestH5Pfapls3.java ./java/test/TestH5Plist.java ./java/test/TestH5Pvirtual.java ./java/test/TestH5PL.java @@ -3249,6 +3267,7 @@ ./config/cmake/ConfigureChecks.cmake ./config/cmake/CPack.Info.plist.in ./config/cmake/CTestCustom.cmake +./config/cmake/FindHDFS.cmake ./config/cmake/H5cxx_config.h.in ./config/cmake/H5pubconf.h.in ./config/cmake/hdf5-config.cmake.in @@ -3358,6 +3377,8 @@ ./testpar/CMakeVFDTests.cmake ./tools/CMakeLists.txt ./tools/lib/CMakeLists.txt +./tools/libtest/CMakeLists.txt +./tools/libtest/CMakeTests.cmake ./tools/src/CMakeLists.txt ./tools/test/CMakeLists.txt ./tools/src/h5copy/CMakeLists.txt @@ -3478,6 +3499,7 @@ ./testpar/Makefile.in ./tools/Makefile.in ./tools/lib/Makefile.in +./tools/libtest/Makefile.in ./tools/src/Makefile.in ./tools/src/h5copy/Makefile.in ./tools/src/h5diff/Makefile.in diff --git a/bin/trace b/bin/trace index 50660fe..241c69c 100755 --- a/bin/trace +++ b/bin/trace @@ -139,6 +139,8 @@ $Source = ""; "H5FD_t" => "x", "H5FD_class_t" => "x", "H5FD_stream_fapl_t" => "x", + "H5FD_ros3_fapl_t" => "x", + "H5FD_hdfs_fapl_t" => "x", "H5FD_file_image_callbacks_t" => "x", "H5G_iterate_t" => "x", "H5G_info_t" => "x", diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index 3bd0553..f295a1c 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -155,6 +155,21 @@ if (NOT WINDOWS) endif () #----------------------------------------------------------------------------- +# Check if ROS3 driver works +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_ROS3_VFD "Build the ROS3 Virtual File Driver" OFF) + if (HDF5_ENABLE_ROS3_VFD) + find_package(CURL REQUIRED) + find_package(OpenSSL REQUIRED) + if (${CURL_FOUND} AND ${OPENSSL_FOUND}) + set (${HDF_PREFIX}_HAVE_ROS3_VFD 1) + list (APPEND LINK_LIBS ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES}) + else () + message (STATUS "The Read-Only S3 VFD was requested but cannot be built.\nPlease check that openssl and cURL are available on your\nsystem, and/or re-configure without option HDF5_ENABLE_ROS3_VFD.") + endif () +endif () + +#----------------------------------------------------------------------------- # Check if C has __float128 extension #----------------------------------------------------------------------------- diff --git a/config/cmake/FindHDFS.cmake b/config/cmake/FindHDFS.cmake new file mode 100644 index 0000000..e401a94 --- /dev/null +++ b/config/cmake/FindHDFS.cmake @@ -0,0 +1,70 @@ + +# DerivedFrom: https://github.com/cloudera/Impala/blob/cdh5-trunk/cmake_modules/FindHDFS.cmake +# - Find HDFS (hdfs.h and libhdfs.so) +# This module defines +# Hadoop_VERSION, version string of ant if found +# HDFS_INCLUDE_DIR, directory containing hdfs.h +# HDFS_LIBRARIES, location of libhdfs.so +# HDFS_FOUND, whether HDFS is found. + +exec_program($ENV{HADOOP_HOME}/bin/hadoop ARGS version OUTPUT_VARIABLE Hadoop_VERSION + RETURN_VALUE Hadoop_RETURN) + +# currently only looking in HADOOP_HOME +find_path(HDFS_INCLUDE_DIR hdfs.h PATHS + $ENV{HADOOP_HOME}/include/ + # make sure we don't accidentally pick up a different version + NO_DEFAULT_PATH +) + +if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8") + set(arch_hint "x64") +elseif ("$ENV{LIB}" MATCHES "(amd64|ia64)") + set(arch_hint "x64") +else () + set(arch_hint "x86") +endif() + +message(STATUS "Architecture: ${arch_hint}") + +if ("${arch_hint}" STREQUAL "x64") + set(HDFS_LIB_PATHS $ENV{HADOOP_HOME}/lib/native) +else () + set(HDFS_LIB_PATHS $ENV{HADOOP_HOME}/lib/native) +endif () + +message(STATUS "HDFS_LIB_PATHS: ${HDFS_LIB_PATHS}") + +find_library(HDFS_LIB NAMES hdfs PATHS + ${HDFS_LIB_PATHS} + # make sure we don't accidentally pick up a different version + NO_DEFAULT_PATH +) + +if (HDFS_LIB) + set(HDFS_FOUND TRUE) + set(HDFS_LIBRARIES ${HDFS_LIB}) + set(HDFS_STATIC_LIB ${HDFS_LIB_PATHS}/${CMAKE_STATIC_LIBRARY_PREFIX}hdfs${CMAKE_STATIC_LIBRARY_SUFFIX}) + + add_library(hdfs_static STATIC IMPORTED) + set_target_properties(hdfs_static PROPERTIES IMPORTED_LOCATION ${HDFS_STATIC_LIB}) +else () + set(HDFS_FOUND FALSE) +endif () + +if (HDFS_FOUND) + if (NOT HDFS_FIND_QUIETLY) + message(STATUS "${Hadoop_VERSION}") + message(STATUS "HDFS_INCLUDE_DIR: ${HDFS_INCLUDE_DIR}") + message(STATUS "HDFS_LIBRARIES: ${HDFS_LIBRARIES}") + message(STATUS "hdfs_static: ${HDFS_STATIC_LIB}") + endif () +else () + message(FATAL_ERROR "HDFS includes and libraries NOT found." + "(${HDFS_INCLUDE_DIR}, ${HDFS_LIB})") +endif () + +mark_as_advanced( + HDFS_LIBRARIES + HDFS_INCLUDE_DIR +) diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 9e7b8b7..cb05974 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -110,6 +110,9 @@ /* Define if the function stack tracing code is to be compiled in */ #cmakedefine H5_HAVE_CODESTACK @H5_HAVE_CODESTACK@ +/* Define to 1 if you have the header file. */ +#cmakedefine H5_HAVE_CURL_H @H5_HAVE_CURL_H@ + /* Define if Darwin or Mac OS X */ #cmakedefine H5_HAVE_DARWIN @H5_HAVE_DARWIN@ @@ -185,6 +188,9 @@ /* Define to 1 if you have the `gettimeofday' function. */ #cmakedefine H5_HAVE_GETTIMEOFDAY @H5_HAVE_GETTIMEOFDAY@ +/* Define to 1 if you have the header file. */ +#cmakedefine H5_HAVE_HDFS_H @H5_HAVE_HDFS_H@ + /* Define if the compiler understands inline */ #cmakedefine H5_HAVE_INLINE @H5_HAVE_INLINE@ @@ -201,12 +207,24 @@ /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_IO_H @H5_HAVE_IO_H@ +/* Define to 1 if you have the `crypto' library (-lcrypto). */ +#cmakedefine H5_HAVE_LIBCRYPTO @H5_HAVE_LIBCRYPTO@ + +/* Define to 1 if you have the `curl' library (-lcurl). */ +#cmakedefine H5_HAVE_LIBCURL @H5_HAVE_LIBCURL@ + /* Define to 1 if you have the `dl' library (-ldl). */ #cmakedefine H5_HAVE_LIBDL @H5_HAVE_LIBDL@ /* Define to 1 if you have the `dmalloc' library (-ldmalloc). */ #cmakedefine H5_HAVE_LIBDMALLOC @H5_HAVE_LIBDMALLOC@ +/* Proceed to build with libhdfs */ +#cmakedefine H5_HAVE_LIBHDFS @H5_HAVE_LIBHDFS@ + +/* Define to 1 if you have the `jvm' library (-ljvm). */ +#cmakedefine H5_HAVE_LIBJVM @H5_HAVE_LIBJVM@ + /* Define to 1 if you have the `m' library (-lm). */ #cmakedefine H5_HAVE_LIBM @H5_HAVE_LIBM@ @@ -264,6 +282,15 @@ /* Define if MPI_Info_c2f and MPI_Info_f2c exists */ #cmakedefine H5_HAVE_MPI_MULTI_LANG_Info @H5_HAVE_MPI_MULTI_LANG_Info@ +/* Define to 1 if you have the header file. */ +#cmakedefine H5_HAVE_OPENSSL_EVP_H @H5_HAVE_OPENSSL_EVP_H@ + +/* Define to 1 if you have the header file. */ +#cmakedefine H5_HAVE_OPENSSL_HMAC_H @H5_HAVE_OPENSSL_HMAC_H@ + +/* Define to 1 if you have the header file. */ +#cmakedefine H5_HAVE_OPENSSL_SHA_H @H5_HAVE_OPENSSL_SHA_H@ + /* Define if we have parallel support */ #cmakedefine H5_HAVE_PARALLEL @H5_HAVE_PARALLEL@ @@ -282,6 +309,10 @@ /* Define to 1 if you have the `rand_r' function. */ #cmakedefine H5_HAVE_RAND_R @H5_HAVE_RAND_R@ +/* Define whether the Read-Only S3 virtual file driver (VFD) should be + compiled */ +#cmakedefine H5_HAVE_ROS3_VFD @H5_HAVE_ROS3_VFD@ + /* Define to 1 if you have the `round' function. */ #cmakedefine H5_HAVE_ROUND @H5_HAVE_ROUND@ diff --git a/config/cmake/libhdf5.settings.cmake.in b/config/cmake/libhdf5.settings.cmake.in index 2117f3b..3451545 100644 --- a/config/cmake/libhdf5.settings.cmake.in +++ b/config/cmake/libhdf5.settings.cmake.in @@ -76,6 +76,8 @@ Parallel Filtered Dataset Writes: @PARALLEL_FILTERED_WRITES@ I/O filters (external): @EXTERNAL_FILTERS@ MPE: @H5_HAVE_LIBLMPE@ Direct VFD: @H5_HAVE_DIRECT@ + (Read-Only) S3 VFD: @H5_HAVE_ROS3_VFD@ + (Read-Only) HDFS VFD: @H5_HAVE_LIBHDFS@ dmalloc: @H5_HAVE_LIBDMALLOC@ Packages w/ extra debug output: @INTERNAL_DEBUG_OUTPUT@ API Tracing: @HDF5_ENABLE_TRACE@ diff --git a/configure.ac b/configure.ac index d1d209f..3d6ab10 100644 --- a/configure.ac +++ b/configure.ac @@ -2809,6 +2809,130 @@ fi AM_CONDITIONAL([DIRECT_VFD_CONDITIONAL], [test "X$DIRECT_VFD" = "Xyes"]) ## ---------------------------------------------------------------------- +## Check if Read-Only S3 virtual file driver is enabled by --enable-ros3-vfd +## +AC_SUBST([ROS3_VFD]) + +## Default is no Read-Only S3 VFD +ROS3_VFD=no + +AC_ARG_ENABLE([ros3-vfd], + [AS_HELP_STRING([--enable-ros3-vfd], + [Build the Read-Only S3 virtual file driver (VFD). + [default=no]])], + [ROS3_VFD=$enableval], [ROS3_VFD=no]) + +if test "X$ROS3_VFD" = "Xyes"; then + AC_CHECK_HEADERS([curl/curl.h],, [unset ROS3_VFD]) + AC_CHECK_HEADERS([openssl/evp.h],, [unset ROS3_VFD]) + AC_CHECK_HEADERS([openssl/hmac.h],, [unset ROS3_VFD]) + AC_CHECK_HEADERS([openssl/sha.h],, [unset ROS3_VFD]) + if test "X$ROS3_VFD" = "Xyes"; then + AC_CHECK_LIB([curl], [curl_global_init],, [unset ROS3_VFD]) + AC_CHECK_LIB([crypto], [EVP_sha256],, [unset ROS3_VFD]) + fi + + AC_MSG_CHECKING([if the Read-Only S3 virtual file driver (VFD) is enabled]) + if test "X$ROS3_VFD" = "Xyes"; then + AC_DEFINE([HAVE_ROS3_VFD], [1], + [Define whether the Read-Only S3 virtual file driver (VFD) should be compiled]) + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + ROS3_VFD=no + AC_MSG_ERROR([The Read-Only S3 VFD was requested but cannot be built. + Please check that openssl and cURL are available on your + system, and/or re-configure without option + --enable-ros3-vfd.]) + fi +else + AC_MSG_CHECKING([if the Read-Only S3 virtual file driver (VFD) is enabled]) + AC_MSG_RESULT([no]) + ROS3_VFD=no + +fi +## ---------------------------------------------------------------------- +## Is libhdfs (Hadoop Distributed File System) present? +## It might be specified with the `--with-libhdfs' command-line switch. +## If found, enables the HDFS VFD. +## +AC_SUBST([HAVE_LIBHDFS]) +AC_ARG_WITH([libhdfs], + [AS_HELP_STRING([--with-libhdfs=DIR], + [Provide libhdfs library to enable HDFS virtual file driver (VFD) [default=no]])],, + [withval=no]) + +case $withval in + no) + HAVE_LIBHDFS="no" + AC_MSG_CHECKING([for libhdfs]) + AC_MSG_RESULT([suppressed]) + ;; + *) + HAVE_LIBHDFS="yes" + case "$withval" in + *,*) + libhdfs_inc="`echo $withval |cut -f1 -d,`" + libhdfs_lib="`echo $withval |cut -f2 -d, -s`" + ;; + yes) + libhdfs_inc="$HADOOP_HOME/include" + libhdfs_lib="$HADOOP_HOME/lib" + ;; + *) + if test -n "$withval"; then + libhdfs_inc="$withval/include" + libhdfs_lib="$withval/lib" + fi + ;; + esac + + if test -n "$libhdfs_inc"; then + CPPFLAGS="$CPPFLAGS -I$libhdfs_inc" + AM_CPPFLAGS="$AM_CPPFLAGS -I$libhdfs_inc" + fi + AC_CHECK_HEADERS([hdfs.h],, + [unset HAVE_LIBHDFS]) + + if test "x$HAVE_LIBHDFS" = "xyes"; then + dnl Check for '-ljvm' needed by libhdfs + JNI_LDFLAGS="" + if test $JAVA_HOME != "" + then + JNI_LDFLAGS="-L$JAVA_HOME/jre/lib/$OS_ARCH -L$JAVA_HOME/jre/lib/$OS_ARCH/server" + fi + ldflags_bak=$LDFLAGS + LDFLAGS="$LDFLAGS $JNI_LDFLAGS" + AC_CHECK_LIB([jvm], [JNI_GetCreatedJavaVMs]) + LDFLAGS=$ldflags_bak + AC_SUBST([JNI_LDFLAGS]) + if test -n "$libhdfs_lib"; then + ## Hadoop distribution hides libraries down one level in 'lib/native' + libhdfs_lib="$libhdfs_lib/native" + LDFLAGS="$LDFLAGS -L$libhdfs_lib $JNI_LDFLAGS" + AM_LDFLAGS="$AM_LDFLAGS -L$libhdfs_lib $JNI_LDFLAGS" + fi + AC_CHECK_LIB([hdfs], [hdfsConnect],, + [unset HAVE_LIBHDFS]) + fi + + if test -z "$HAVE_LIBHDFS"; then + AC_MSG_ERROR([Set to use libhdfs library, but could not find or use + libhdfs. Please verify that the path to HADOOP_HOME is + valid, and/or reconfigure without --with-libhdfs.]) + fi + ;; +esac + +if test "x$HAVE_LIBHDFS" = "xyes"; then + AC_DEFINE([HAVE_LIBHDFS], [1], + [Proceed to build with libhdfs]) +fi + +## Checkpoint the cache +AC_CACHE_SAVE + +## ---------------------------------------------------------------------- ## Enable custom plugin default path for library. It requires SHARED support. ## AC_MSG_CHECKING([for custom plugin default path definition]) @@ -3537,6 +3661,7 @@ AC_CONFIG_FILES([src/libhdf5.settings testpar/testpflush.sh tools/Makefile tools/lib/Makefile + tools/libtest/Makefile tools/src/Makefile tools/src/h5dump/Makefile tools/src/h5import/Makefile diff --git a/java/examples/groups/JavaGroupExample.sh.in b/java/examples/groups/JavaGroupExample.sh.in index 9d4673f..3ba512a 100644 --- a/java/examples/groups/JavaGroupExample.sh.in +++ b/java/examples/groups/JavaGroupExample.sh.in @@ -64,6 +64,8 @@ $HDFTEST_HOME/h5ex_g_iterate.h5 $HDFTEST_HOME/h5ex_g_visit.h5 " LIST_DATA_FILES=" +$HDFTEST_HOME/h5ex_g_iterate.h5 +$HDFTEST_HOME/h5ex_g_visit.h5 $HDFTEST_HOME/../testfiles/examples.groups.H5Ex_G_Create.txt $HDFTEST_HOME/../testfiles/examples.groups.H5Ex_G_Iterate.txt $HDFTEST_HOME/../testfiles/examples.groups.H5Ex_G_Compact.txt diff --git a/java/src/Makefile.am b/java/src/Makefile.am index bd55c39..fcdeae9 100644 --- a/java/src/Makefile.am +++ b/java/src/Makefile.am @@ -98,6 +98,8 @@ hdf5_java_JAVA = \ ${pkgpath}/structs/H5A_info_t.java \ ${pkgpath}/structs/H5E_error2_t.java \ ${pkgpath}/structs/H5F_info2_t.java \ + ${pkgpath}/structs/H5FD_hdfs_fapl_t.java \ + ${pkgpath}/structs/H5FD_ros3_fapl_t.java \ ${pkgpath}/structs/H5G_info_t.java \ ${pkgpath}/structs/H5L_info_t.java \ ${pkgpath}/structs/H5O_info_t.java \ diff --git a/java/src/hdf/hdf5lib/CMakeLists.txt b/java/src/hdf/hdf5lib/CMakeLists.txt index c171ea8..be8f60a 100644 --- a/java/src/hdf/hdf5lib/CMakeLists.txt +++ b/java/src/hdf/hdf5lib/CMakeLists.txt @@ -73,6 +73,8 @@ set (HDF5_JAVA_HDF_HDF5_STRUCTS_SOURCES structs/H5AC_cache_config_t.java structs/H5E_error2_t.java structs/H5F_info2_t.java + structs/H5FD_ros3_fapl_t.java + structs/H5FD_hdfs_fapl_t.java structs/H5G_info_t.java structs/H5L_info_t.java structs/H5O_hdr_info_t.java diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index a1a8ede..481ca8c 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -50,6 +50,8 @@ import hdf.hdf5lib.structs.H5AC_cache_config_t; import hdf.hdf5lib.structs.H5A_info_t; import hdf.hdf5lib.structs.H5E_error2_t; import hdf.hdf5lib.structs.H5F_info2_t; +import hdf.hdf5lib.structs.H5FD_hdfs_fapl_t; +import hdf.hdf5lib.structs.H5FD_ros3_fapl_t; import hdf.hdf5lib.structs.H5G_info_t; import hdf.hdf5lib.structs.H5L_info_t; import hdf.hdf5lib.structs.H5O_info_t; @@ -7796,6 +7798,10 @@ public class H5 implements java.io.Serializable { public synchronized static native int H5Pset_fapl_family(long fapl_id, long memb_size, long memb_fapl_id) throws HDF5LibraryException, NullPointerException; + public synchronized static native int H5Pset_fapl_hdfs(long fapl_id, H5FD_hdfs_fapl_t fapl_conf) throws HDF5LibraryException, NullPointerException; + + public synchronized static native H5FD_hdfs_fapl_t H5Pget_fapl_hdfs(long fapl_id) throws HDF5LibraryException, NullPointerException; + /** * H5Pget_fapl_multi Sets up use of the multi I/O driver. * @@ -7880,6 +7886,10 @@ public class H5 implements java.io.Serializable { public synchronized static native int H5Pset_fapl_windows(long fapl_id) throws HDF5LibraryException, NullPointerException; + public synchronized static native int H5Pset_fapl_ros3(long fapl_id, H5FD_ros3_fapl_t fapl_conf) throws HDF5LibraryException, NullPointerException; + + public synchronized static native H5FD_ros3_fapl_t H5Pget_fapl_ros3(long fapl_id) throws HDF5LibraryException, NullPointerException; + // /////// unimplemented //////// // Generic property list routines // diff --git a/java/src/hdf/hdf5lib/HDF5Constants.java b/java/src/hdf/hdf5lib/HDF5Constants.java index cb5ed22..2e80f2e 100644 --- a/java/src/hdf/hdf5lib/HDF5Constants.java +++ b/java/src/hdf/hdf5lib/HDF5Constants.java @@ -246,6 +246,8 @@ public class HDF5Constants { public static final long H5FD_SEC2 = H5FD_SEC2(); public static final long H5FD_STDIO = H5FD_STDIO(); public static final long H5FD_WINDOWS = H5FD_WINDOWS(); + public static final long H5FD_ROS3 = H5FD_ROS3(); + public static final long H5FD_HDFS = H5FD_HDFS(); public static final int H5FD_LOG_LOC_READ = H5FD_LOG_LOC_READ(); public static final int H5FD_LOG_LOC_WRITE = H5FD_LOG_LOC_WRITE(); public static final int H5FD_LOG_LOC_SEEK = H5FD_LOG_LOC_SEEK(); @@ -1111,6 +1113,10 @@ public class HDF5Constants { private static native final long H5FD_WINDOWS(); + private static native final long H5FD_ROS3(); + + private static native final long H5FD_HDFS(); + private static native final int H5FD_LOG_LOC_READ(); private static native final int H5FD_LOG_LOC_WRITE(); diff --git a/java/src/hdf/hdf5lib/structs/H5FD_hdfs_fapl_t.java b/java/src/hdf/hdf5lib/structs/H5FD_hdfs_fapl_t.java new file mode 100644 index 0000000..f56a038 --- /dev/null +++ b/java/src/hdf/hdf5lib/structs/H5FD_hdfs_fapl_t.java @@ -0,0 +1,102 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Read-Only HDFS Virtual File Driver (VFD) * + * Copyright (c) 2018, The HDF Group. * + * * + * All rights reserved. * + * * + * NOTICE: * + * All information contained herein is, and remains, the property of The HDF * + * Group. The intellectual and technical concepts contained herein are * + * proprietary to The HDF Group. Dissemination of this information or * + * reproduction of this material is strictly forbidden unless prior written * + * permission is obtained from The HDF Group. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package hdf.hdf5lib.structs; + +import java.io.Serializable; + +/* + * Java representation of the HDFS VFD file access property list (fapl) + * structure. + * + * Used for the access of files hosted on the Hadoop Distributed File System. + */ + +@SuppressWarnings("serial") // mute default serialUID warnings until someone knowledgeable comes along or something breaks horribly +public class H5FD_hdfs_fapl_t implements Serializable { + + private long version; + private String namenode_name; + private String user_name; + private String kerberos_ticket_cache; + private int namenode_port; + private int stream_buffer_size; + + /** + * Create a fapl_t structure with the specified components. + */ + public H5FD_hdfs_fapl_t( + String namenode_name, + int namenode_port, + String user_name, + String kerberos_ticket_cache, + int stream_buffer_size) + { + this.version = 1; + this.namenode_name = namenode_name; + this.namenode_port = namenode_port; + this.user_name = user_name; + this.kerberos_ticket_cache = kerberos_ticket_cache; + this.stream_buffer_size = stream_buffer_size; + } + + @Override + public boolean equals(Object o) { + if (o == null) + return false; + if (!(o instanceof H5FD_hdfs_fapl_t)) + return false; + + H5FD_hdfs_fapl_t other = (H5FD_hdfs_fapl_t)o; + if (this.version != other.version) + return false; + if (!this.namenode_name.equals(other.namenode_name)) + return false; + if (this.namenode_port != other.namenode_port) + return false; + if (!this.user_name.equals(other.user_name)) + return false; + if (!this.kerberos_ticket_cache.equals(other.kerberos_ticket_cache)) + return false; + if (this.stream_buffer_size != other.stream_buffer_size) + return false; + return true; + } + + @Override + public int hashCode() { + /* this is a _very bad_ hash algorithm for purposes of hashing! */ + /* implemented to satisfy the "contract" regarding equality */ + int k = (int)this.version; + k += this.namenode_name.length(); + k += this.user_name.length(); + k += this.kerberos_ticket_cache.length(); + k += namenode_port; + k += stream_buffer_size; + return k; + } + + @Override + public String toString() { + return "H5FD_hdfs_fapl_t (Version: " + this.version + ") {" + + "\n namenode_name: '" + this.namenode_name + + "'\n namenode_port: " + this.namenode_port + + "\n user_name: '" + this.user_name + + "'\n kerberos_ticket_cache: '" + this.kerberos_ticket_cache + + "'\n stream_buffer_size: " + this.stream_buffer_size + + "\n}\n"; + } +} + + diff --git a/java/src/hdf/hdf5lib/structs/H5FD_ros3_fapl_t.java b/java/src/hdf/hdf5lib/structs/H5FD_ros3_fapl_t.java new file mode 100644 index 0000000..6b086c3 --- /dev/null +++ b/java/src/hdf/hdf5lib/structs/H5FD_ros3_fapl_t.java @@ -0,0 +1,121 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Read-Only S3 Virtual File Driver (VFD) * + * Copyright (c) 2017-2018, The HDF Group. * + * * + * All rights reserved. * + * * + * NOTICE: * + * All information contained herein is, and remains, the property of The HDF * + * Group. The intellectual and technical concepts contained herein are * + * proprietary to The HDF Group. Dissemination of this information or * + * reproduction of this material is strictly forbidden unless prior written * + * permission is obtained from The HDF Group. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package hdf.hdf5lib.structs; + +import java.io.Serializable; + +/* + * Java representation of the ROS3 VFD file access property list (fapl) + * structure. + * + * Used for the access of files hosted remotely on S3 by Amazon. + * + * For simplicity, implemented assuming that all ROS3 fapls have components: + * - version + * - aws_region + * - secret_id + * - secret_key + * + * Future implementations may be created to enable different fapl "shapes" + * depending on provided version. + * + * proposed: + * + * H5FD_ros3_fapl_t (super class, has only version field) + * H5FD_ros3_fapl_v1_t (extends super with Version 1 components) + * H5FD_ros3_fapl_v2_t (extends super with Version 2 components) + * and so on, for each version + * + * "super" is passed around, and is version-checked and re-cast as + * appropriate + */ + +@SuppressWarnings("serial") // mute default serialUID warnings until someone knowledgeable comes along or something breaks horribly +public class H5FD_ros3_fapl_t implements Serializable { + + private long version; + private String aws_region; + private String secret_id; + private String secret_key; + + /** + * Create a "default" fapl_t structure, for anonymous access. + */ + public H5FD_ros3_fapl_t () { + /* H5FD_ros3_fapl_t("", "", ""); */ /* defer */ + this.version = 1; + this.aws_region = ""; + this.secret_id = ""; + this.secret_key = ""; + } + + /** + * Create a fapl_t structure with the specified components. + * If all are the empty string, is anonymous (non-authenticating). + * Region and ID must both be supplied for authentication. + * + * @param region "aws region" for authenticating request + * @param id "secret id" or "access id" for authenticating request + * @param key "secret key" or "access key" for authenticating request + */ + public H5FD_ros3_fapl_t (String region, String id, String key) { + this.version = 1; /* must equal H5FD__CURR_ROS3_FAPL_T_VERSION */ + /* as found in H5FDros3.h */ + this.aws_region = region; + this.secret_id = id; + this.secret_key = key; + } + + @Override + public boolean equals(Object o) { + if (o == null) + return false; + if (!(o instanceof H5FD_ros3_fapl_t)) + return false; + + H5FD_ros3_fapl_t other = (H5FD_ros3_fapl_t)o; + if (this.version != other.version) + return false; + if (!this.aws_region.equals(other.aws_region)) + return false; + if (!this.secret_key.equals(other.secret_key)) + return false; + if (!this.secret_id.equals(other.secret_id)) + return false; + return true; + } + + @Override + public int hashCode() { + /* this is a _very bad_ hash algorithm for purposes of hashing! */ + /* implemented to satisfy the "contract" regarding equality */ + int k = (int)this.version; + k += this.aws_region.length(); + k += this.secret_id.length(); + k += this.secret_key.length(); + return k; + } + + @Override + public String toString() { + return "H5FD_ros3_fapl_t (Version:" + this.version + ") {" + + "\n aws_region : " + this.aws_region + + "\n secret_id : " + this.secret_id + + "\n secret_key : " + this.secret_key + + "\n}\n"; + } +} + + diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c index b9e320f..ac55a13 100644 --- a/java/src/jni/h5Constants.c +++ b/java/src/jni/h5Constants.c @@ -453,6 +453,8 @@ Java_hdf_hdf5lib_HDF5Constants_H5FD_1DIRECT(JNIEnv *env, jclass cls) { JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1FAMILY(JNIEnv *env, jclass cls) { return H5FD_FAMILY; } JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5FD_1HDFS(JNIEnv *env, jclass cls) { return H5FD_HDFS; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG(JNIEnv *env, jclass cls) { return H5FD_LOG; } JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MPIO(JNIEnv *env, jclass cls) { return H5FD_MPIO; } @@ -461,6 +463,8 @@ Java_hdf_hdf5lib_HDF5Constants_H5FD_1MULTI(JNIEnv *env, jclass cls) { return H5F JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1SEC2(JNIEnv *env, jclass cls) { return H5FD_SEC2; } JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5FD_1ROS3(JNIEnv *env, jclass cls) { return H5FD_ROS3; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1STDIO(JNIEnv *env, jclass cls) { return H5FD_STDIO; } JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1WINDOWS(JNIEnv *env, jclass cls) { diff --git a/java/test/CMakeLists.txt b/java/test/CMakeLists.txt index 3298a47..dfb6e72 100644 --- a/java/test/CMakeLists.txt +++ b/java/test/CMakeLists.txt @@ -51,6 +51,20 @@ if (NOT HDF5_ENABLE_DEBUG_APIS) ) endif () +if (HDF5_ENABLE_ROS3_VFD) + set (HDF5_JAVA_TEST_SOURCES + ${HDF5_JAVA_TEST_SOURCES} + TestH5Pfapls3 + ) +endif () + +if (HDF5_ENABLE_HDFS) + set (HDF5_JAVA_TEST_SOURCES + ${HDF5_JAVA_TEST_SOURCES} + TestH5Pfaplhdfs + ) +endif () + set (CMAKE_JAVA_INCLUDE_PATH "${HDF5_JAVA_LIB_DIR}/junit.jar;${HDF5_JAVA_LIB_DIR}/hamcrest-core.jar;${HDF5_JAVA_JARS};${HDF5_JAVA_LOGGING_JAR};${HDF5_JAVA_LOGGING_SIMPLE_JAR}") foreach (test_file ${HDF5_JAVA_TEST_SOURCES}) diff --git a/java/test/Makefile.am b/java/test/Makefile.am index af99d92..c375938 100644 --- a/java/test/Makefile.am +++ b/java/test/Makefile.am @@ -61,6 +61,8 @@ noinst_JAVA = \ TestH5P.java \ TestH5PData.java \ TestH5Pfapl.java \ + TestH5Pfaplhdfs.java \ + TestH5Pfapls3.java \ TestH5Pvirtual.java \ TestH5Plist.java \ TestH5A.java \ diff --git a/java/test/TestAll.java b/java/test/TestAll.java index 13cb597..c7c206c 100644 --- a/java/test/TestAll.java +++ b/java/test/TestAll.java @@ -27,6 +27,7 @@ import org.junit.runners.Suite; TestH5Lparams.class, TestH5Lbasic.class, TestH5Lcreate.class, TestH5R.class, TestH5P.class, TestH5PData.class, TestH5Pfapl.class, TestH5Pvirtual.class, TestH5Plist.class, + TestH5Pfapls3.class, TestH5Pfaplhdfs.class, TestH5A.class, TestH5Oparams.class, TestH5Obasic.class, TestH5Ocopy.class, TestH5Ocreate.class, TestH5PL.class, TestH5Z.class diff --git a/java/test/TestH5Pfapl.java b/java/test/TestH5Pfapl.java index 10a79dd..81a7ecb 100644 --- a/java/test/TestH5Pfapl.java +++ b/java/test/TestH5Pfapl.java @@ -15,6 +15,7 @@ package test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -28,6 +29,8 @@ import hdf.hdf5lib.exceptions.HDF5Exception; import hdf.hdf5lib.exceptions.HDF5LibraryException; import hdf.hdf5lib.exceptions.HDF5PropertyListInterfaceException; import hdf.hdf5lib.structs.H5AC_cache_config_t; +import hdf.hdf5lib.structs.H5FD_hdfs_fapl_t; +import hdf.hdf5lib.structs.H5FD_ros3_fapl_t; import org.junit.After; import org.junit.Before; @@ -1398,4 +1401,5 @@ public class TestH5Pfapl { fail("H5P_evict_on_close: " + err); } } + } diff --git a/java/test/TestH5Pfaplhdfs.java b/java/test/TestH5Pfaplhdfs.java new file mode 100644 index 0000000..2b0a808 --- /dev/null +++ b/java/test/TestH5Pfaplhdfs.java @@ -0,0 +1,393 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.File; +import java.text.DecimalFormat; +import java.text.NumberFormat; + +import hdf.hdf5lib.H5; +import hdf.hdf5lib.HDF5Constants; +import hdf.hdf5lib.exceptions.HDF5Exception; +import hdf.hdf5lib.exceptions.HDF5LibraryException; +import hdf.hdf5lib.exceptions.HDF5PropertyListInterfaceException; +import hdf.hdf5lib.structs.H5AC_cache_config_t; +import hdf.hdf5lib.structs.H5FD_hdfs_fapl_t; +import hdf.hdf5lib.structs.H5FD_ros3_fapl_t; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; + +public class TestH5Pfaplhdfs { + @Rule public TestName testname = new TestName(); + + private static final String H5_FILE = "testPf.h5"; + private static final String H5_LOG_FILE = "testPf.log"; + private static final String H5_FAMILY_FILE = "testPf%05d"; + private static final String H5_MULTI_FILE = "testPfmulti"; + private static char MULTI_LETTERS[] = {'X','s','b','r','g','l','o'}; + private static final int DIM_X = 4; + private static final int DIM_Y = 6; + private static final int DIMF_X = 12; + private static final int DIMF_Y = 18; + long H5fid = -1; + long H5dsid = -1; + long H5did = -1; + long H5Fdsid = -1; + long H5Fdid = -1; + long[] H5dims = { DIM_X, DIM_Y }; + long fapl_id = -1; + long plapl_id = -1; + long dapl_id = -1; + long plist_id = -1; + long btplist_id = -1; + long[] H5Fdims = { DIMF_X, DIMF_Y }; + double windchillF[][] = + {{36.0, 31.0, 25.0, 19.0, 13.0, 7.0, 1.0, -5.0, -11.0, -16.0, -22.0, -28.0, -34.0, -40.0, -46.0, -52.0, -57.0, -63.0}, + {34.0, 27.0, 21.0, 15.0, 9.0, 3.0, -4.0, -10.0, -16.0, -22.0, -28.0, -35.0, -41.0, -47.0, -53.0, -59.0, -66.0, -72.0}, + {32.0, 25.0, 19.0, 13.0, 6.0, 0.0, -7.0, -13.0, -19.0, -26.0, -32.0, -39.0, -45.0, -51.0, -58.0, -64.0, -71.0, -77.0}, + {30.0, 24.0, 17.0, 11.0, 4.0, -2.0, -9.0, -15.0, -22.0, -29.0, -35.0, -42.0, -48.0, -55.0, -61.0, -68.0, -74.0, -81.0}, + {29.0, 23.0, 16.0, 9.0, 3.0, -4.0, -11.0, -17.0, -24.0, -31.0, -37.0, -44.0, -51.0, -58.0, -64.0, -71.0, -78.0, -84.0}, + {28.0, 22.0, 15.0, 8.0, 1.0, -5.0, -12.0, -19.0, -26.0, -33.0, -39.0, -46.0, -53.0, -60.0, -67.0, -73.0, -80.0, -87.0}, + {28.0, 21.0, 14.0, 7.0, 0.0, -7.0, -14.0, -21.0, -27.0, -34.0, -41.0, -48.0, -55.0, -62.0, -69.0, -76.0, -82.0, -89.0}, + {27.0, 20.0, 13.0, 6.0, -1.0, -8.0, -15.0, -22.0, -29.0, -36.0, -43.0, -50.0, -57.0, -64.0, -71.0, -78.0, -84.0, -91.0}, + {26.0, 19.0, 12.0, 5.0, -2.0, -9.0, -16.0, -23.0, -30.0, -37.0, -44.0, -51.0, -58.0, -65.0, -72.0, -79.0, -86.0, -93.0}, + {26.0, 19.0, 12.0, 4.0, -3.0, -10.0, -17.0, -24.0, -31.0, -38.0, -45.0, -52.0, -60.0, -67.0, -74.0, -81.0, -88.0, -95.0}, + {25.0, 18.0, 11.0, 4.0, -3.0, -11.0, -18.0, -25.0, -32.0, -39.0, -46.0, -54.0, -61.0, -68.0, -75.0, -82.0, -89.0, -97.0}, + {25.0, 17.0, 10.0, 3.0, -4.0, -11.0, -19.0, -26.0, -33.0, -40.0, -48.0, -55.0, -62.0, -69.0, -76.0, -84.0, -91.0, -98.0} + }; + + private final void _deleteFile(String filename) { + File file = null; + try { + file = new File(filename); + } + catch (Throwable err) {} + + if (file.exists()) { + try {file.delete();} catch (SecurityException e) {} + } + } + + private final void _deleteLogFile() { + File file = null; + try { + file = new File(H5_LOG_FILE); + } + catch (Throwable err) {} + + if (file.exists()) { + try {file.delete();} catch (SecurityException e) {} + } + } + + private final void _deleteFamilyFile() { + File file = null; + for(int indx = 0; ;indx++) { + java.text.DecimalFormat myFormat = new java.text.DecimalFormat("00000"); + try { + file = new File("test"+myFormat.format(new Integer(indx))+".h5"); + } + catch (Throwable err) {} + + if (file.exists()) { + try {file.delete();} catch (SecurityException e) {} + } + else + return; + } + } + + private final void _deleteMultiFile() { + File file = null; + for(int indx = 1;indx<7;indx++) { + try { + file = new File(H5_MULTI_FILE+"-"+MULTI_LETTERS[indx]+".h5"); + } + catch (Throwable err) {} + + if (file.exists()) { + try {file.delete();} catch (SecurityException e) {} + } + } + } + + private final long _createDataset(long fid, long dsid, String name, long dapl) { + long did = -1; + try { + did = H5.H5Dcreate(fid, name, HDF5Constants.H5T_STD_I32BE, dsid, + HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, dapl); + } + catch (Throwable err) { + err.printStackTrace(); + fail("H5.H5Dcreate: " + err); + } + assertTrue("TestH5Pfapl._createDataset: ", did > 0); + + return did; + } + + private final void _createFloatDataset() { + try { + H5Fdsid = H5.H5Screate_simple(2, H5Fdims, null); + H5Fdid = H5.H5Dcreate(H5fid, "dsfloat", HDF5Constants.H5T_NATIVE_FLOAT, H5Fdsid, + HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); + } + catch (Throwable err) { + err.printStackTrace(); + fail("H5.H5Dcreate: " + err); + } + assertTrue("TestH5Pfapl._createFloatDataset: ", H5Fdid > 0); + + try { + H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); + } + catch (Throwable err) { + err.printStackTrace(); + } + } + + private final void _createH5multiFileDS() { + try { + H5did = _createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT); + } + catch (Throwable err) { + err.printStackTrace(); + fail("TestH5Pfapl.createH5file: " + err); + } + assertTrue("TestH5Pfapl.createH5file: _createDataset: ", H5did > 0); + + try { + H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); + } + catch (Throwable err) { + err.printStackTrace(); + } + } + + private final void _createH5File(long fapl) { + try { + H5fid = H5.H5Fcreate(H5_FILE, HDF5Constants.H5F_ACC_TRUNC, + HDF5Constants.H5P_DEFAULT, fapl); + H5dsid = H5.H5Screate_simple(2, H5dims, null); + H5did = _createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT); + } + catch (Throwable err) { + err.printStackTrace(); + fail("TestH5Pfapl.createH5file: " + err); + } + assertTrue("TestH5Pfapl.createH5file: H5.H5Fcreate: ", H5fid > 0); + assertTrue("TestH5Pfapl.createH5file: H5.H5Screate_simple: ", H5dsid > 0); + assertTrue("TestH5Pfapl.createH5file: _createDataset: ", H5did > 0); + + try { + H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); + } + catch (Throwable err) { + err.printStackTrace(); + } + } + + private final void _createH5familyFile(long fapl) { + try { + H5fid = H5.H5Fcreate(H5_FAMILY_FILE+".h5", HDF5Constants.H5F_ACC_TRUNC, + HDF5Constants.H5P_DEFAULT, fapl); + H5dsid = H5.H5Screate_simple(2, H5dims, null); + H5did = _createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT); + } + catch (Throwable err) { + err.printStackTrace(); + fail("TestH5Pfapl.createH5file: " + err); + } + assertTrue("TestH5Pfapl.createH5file: H5.H5Fcreate: ", H5fid > 0); + assertTrue("TestH5Pfapl.createH5file: H5.H5Screate_simple: ", H5dsid > 0); + assertTrue("TestH5Pfapl.createH5file: _createDataset: ", H5did > 0); + + try { + H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); + } + catch (Throwable err) { + err.printStackTrace(); + } + } + + private final void _createH5multiFile(long fapl) { + try { + H5fid = H5.H5Fcreate(H5_MULTI_FILE, HDF5Constants.H5F_ACC_TRUNC, + HDF5Constants.H5P_DEFAULT, fapl); + H5dsid = H5.H5Screate_simple(2, H5dims, null); + } + catch (Throwable err) { + err.printStackTrace(); + fail("TestH5Pfapl.createH5file: " + err); + } + assertTrue("TestH5Pfapl.createH5file: H5.H5Fcreate: ", H5fid > 0); + assertTrue("TestH5Pfapl.createH5file: H5.H5Screate_simple: ", H5dsid > 0); + + try { + H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); + } + catch (Throwable err) { + err.printStackTrace(); + } + } + + public void deleteH5file() { + _deleteFile(H5_FILE); + } + + public void deleteH5familyfile() { + _deleteFamilyFile(); + } + + public void deleteH5multifile() { + _deleteMultiFile(); + } + + @Before + public void createFileAccess() + throws NullPointerException, HDF5Exception { + assertTrue("H5 open ids is 0",H5.getOpenIDCount()==0); + System.out.print(testname.getMethodName()); + + try { + fapl_id = H5.H5Pcreate(HDF5Constants.H5P_FILE_ACCESS); + } + catch (Throwable err) { + err.printStackTrace(); + fail("TestH5Pfapl.createFileAccess: " + err); + } + assertTrue(fapl_id > 0); + try { + plapl_id = H5.H5Pcreate(HDF5Constants.H5P_LINK_ACCESS); + } + catch (Throwable err) { + err.printStackTrace(); + fail("TestH5Pfapl.createFileAccess: " + err); + } + assertTrue(plapl_id > 0); + try { + plist_id = H5.H5Pcreate(HDF5Constants.H5P_DATASET_XFER); + btplist_id = H5.H5Pcreate(HDF5Constants.H5P_DATASET_XFER); + dapl_id = H5.H5Pcreate(HDF5Constants.H5P_DATASET_ACCESS); + } + catch (Throwable err) { + err.printStackTrace(); + fail("TestH5Pfapl.createFileAccess: " + err); + } + assertTrue(plist_id > 0); + assertTrue(btplist_id > 0); + assertTrue(dapl_id > 0); + } + + @After + public void deleteFileAccess() throws HDF5LibraryException { + if (fapl_id > 0) + try {H5.H5Pclose(fapl_id);} catch (Exception ex) {} + if (plapl_id > 0) + try {H5.H5Pclose(plapl_id);} catch (Exception ex) {} + if (dapl_id > 0) + try {H5.H5Pclose(dapl_id);} catch (Exception ex) {} + if (plist_id > 0) + try {H5.H5Pclose(plist_id);} catch (Exception ex) {} + if (btplist_id > 0) + try {H5.H5Pclose(btplist_id);} catch (Exception ex) {} + + if (H5Fdsid > 0) + try {H5.H5Sclose(H5Fdsid);} catch (Exception ex) {} + if (H5Fdid > 0) + try {H5.H5Dclose(H5Fdid);} catch (Exception ex) {} + if (H5dsid > 0) + try {H5.H5Sclose(H5dsid);} catch (Exception ex) {} + if (H5did > 0) + try {H5.H5Dclose(H5did);} catch (Exception ex) {} + if (H5fid > 0) + try {H5.H5Fclose(H5fid);} catch (Exception ex) {} + System.out.println(); + } + + @Test + public void testHDFS_fapl() + throws Exception + { + if (HDF5Constants.H5FD_HDFS < 0) + throw new HDF5LibraryException("skip"); + + String nodename = "blues"; + int nodeport = 12345; + String username = "sparticus"; + String kerbcache = "/dev/null"; + int streamsize = 1024; + + final H5FD_hdfs_fapl_t config = new H5FD_hdfs_fapl_t( + nodename, + nodeport, + username, + kerbcache, + streamsize + ); + assertTrue("setting fapl should succeed", + -1 < H5.H5Pset_fapl_hdfs(fapl_id, config)); + + assertEquals("driver types should match", + HDF5Constants.H5FD_HDFS, + H5.H5Pget_driver(fapl_id)); + + H5FD_hdfs_fapl_t copy = H5.H5Pget_fapl_hdfs(fapl_id); + assertEquals("fapl contents should match", + new H5FD_hdfs_fapl_t( + nodename, + nodeport, + username, + kerbcache, + streamsize), + copy); + } + + @Test(expected = HDF5LibraryException.class) + public void testH5Pget_fapl_hdfs_invalid_fapl_id() + throws Exception + { + if (HDF5Constants.H5FD_HDFS < 0) + throw new HDF5LibraryException("skip"); + H5FD_hdfs_fapl_t fails = H5.H5Pget_fapl_hdfs(-1); + } + + @Test(expected = HDF5LibraryException.class) + public void testH5Pget_fapl_hdfs_fapl_id_of_wrong_driver_type() + throws Exception + { + if (HDF5Constants.H5FD_HDFS < 0) + throw new HDF5LibraryException("skip"); + if (HDF5Constants.H5FD_SEC2 < 0 ) + throw new HDF5LibraryException("skip"); + /* TODO: for now, test against a sec2 fapl only */ + + H5.H5Pset_fapl_sec2(fapl_id); + assertEquals("fapl_id was not set properly", + HDF5Constants.H5FD_SEC2, + H5.H5Pget_driver(fapl_id)); + H5FD_hdfs_fapl_t fails = H5.H5Pget_fapl_hdfs(fapl_id); + } + +} diff --git a/java/test/TestH5Pfapls3.java b/java/test/TestH5Pfapls3.java new file mode 100644 index 0000000..3107bc8 --- /dev/null +++ b/java/test/TestH5Pfapls3.java @@ -0,0 +1,406 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.File; +import java.text.DecimalFormat; +import java.text.NumberFormat; + +import hdf.hdf5lib.H5; +import hdf.hdf5lib.HDF5Constants; +import hdf.hdf5lib.exceptions.HDF5Exception; +import hdf.hdf5lib.exceptions.HDF5LibraryException; +import hdf.hdf5lib.exceptions.HDF5PropertyListInterfaceException; +import hdf.hdf5lib.structs.H5AC_cache_config_t; +import hdf.hdf5lib.structs.H5FD_hdfs_fapl_t; +import hdf.hdf5lib.structs.H5FD_ros3_fapl_t; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; + +public class TestH5Pfapls3 { + @Rule public TestName testname = new TestName(); + + private static final String H5_FILE = "testPf.h5"; + private static final String H5_LOG_FILE = "testPf.log"; + private static final String H5_FAMILY_FILE = "testPf%05d"; + private static final String H5_MULTI_FILE = "testPfmulti"; + private static char MULTI_LETTERS[] = {'X','s','b','r','g','l','o'}; + private static final int DIM_X = 4; + private static final int DIM_Y = 6; + private static final int DIMF_X = 12; + private static final int DIMF_Y = 18; + long H5fid = -1; + long H5dsid = -1; + long H5did = -1; + long H5Fdsid = -1; + long H5Fdid = -1; + long[] H5dims = { DIM_X, DIM_Y }; + long fapl_id = -1; + long plapl_id = -1; + long dapl_id = -1; + long plist_id = -1; + long btplist_id = -1; + long[] H5Fdims = { DIMF_X, DIMF_Y }; + double windchillF[][] = + {{36.0, 31.0, 25.0, 19.0, 13.0, 7.0, 1.0, -5.0, -11.0, -16.0, -22.0, -28.0, -34.0, -40.0, -46.0, -52.0, -57.0, -63.0}, + {34.0, 27.0, 21.0, 15.0, 9.0, 3.0, -4.0, -10.0, -16.0, -22.0, -28.0, -35.0, -41.0, -47.0, -53.0, -59.0, -66.0, -72.0}, + {32.0, 25.0, 19.0, 13.0, 6.0, 0.0, -7.0, -13.0, -19.0, -26.0, -32.0, -39.0, -45.0, -51.0, -58.0, -64.0, -71.0, -77.0}, + {30.0, 24.0, 17.0, 11.0, 4.0, -2.0, -9.0, -15.0, -22.0, -29.0, -35.0, -42.0, -48.0, -55.0, -61.0, -68.0, -74.0, -81.0}, + {29.0, 23.0, 16.0, 9.0, 3.0, -4.0, -11.0, -17.0, -24.0, -31.0, -37.0, -44.0, -51.0, -58.0, -64.0, -71.0, -78.0, -84.0}, + {28.0, 22.0, 15.0, 8.0, 1.0, -5.0, -12.0, -19.0, -26.0, -33.0, -39.0, -46.0, -53.0, -60.0, -67.0, -73.0, -80.0, -87.0}, + {28.0, 21.0, 14.0, 7.0, 0.0, -7.0, -14.0, -21.0, -27.0, -34.0, -41.0, -48.0, -55.0, -62.0, -69.0, -76.0, -82.0, -89.0}, + {27.0, 20.0, 13.0, 6.0, -1.0, -8.0, -15.0, -22.0, -29.0, -36.0, -43.0, -50.0, -57.0, -64.0, -71.0, -78.0, -84.0, -91.0}, + {26.0, 19.0, 12.0, 5.0, -2.0, -9.0, -16.0, -23.0, -30.0, -37.0, -44.0, -51.0, -58.0, -65.0, -72.0, -79.0, -86.0, -93.0}, + {26.0, 19.0, 12.0, 4.0, -3.0, -10.0, -17.0, -24.0, -31.0, -38.0, -45.0, -52.0, -60.0, -67.0, -74.0, -81.0, -88.0, -95.0}, + {25.0, 18.0, 11.0, 4.0, -3.0, -11.0, -18.0, -25.0, -32.0, -39.0, -46.0, -54.0, -61.0, -68.0, -75.0, -82.0, -89.0, -97.0}, + {25.0, 17.0, 10.0, 3.0, -4.0, -11.0, -19.0, -26.0, -33.0, -40.0, -48.0, -55.0, -62.0, -69.0, -76.0, -84.0, -91.0, -98.0} + }; + + private final void _deleteFile(String filename) { + File file = null; + try { + file = new File(filename); + } + catch (Throwable err) {} + + if (file.exists()) { + try {file.delete();} catch (SecurityException e) {} + } + } + + private final void _deleteLogFile() { + File file = null; + try { + file = new File(H5_LOG_FILE); + } + catch (Throwable err) {} + + if (file.exists()) { + try {file.delete();} catch (SecurityException e) {} + } + } + + private final void _deleteFamilyFile() { + File file = null; + for(int indx = 0; ;indx++) { + java.text.DecimalFormat myFormat = new java.text.DecimalFormat("00000"); + try { + file = new File("test"+myFormat.format(new Integer(indx))+".h5"); + } + catch (Throwable err) {} + + if (file.exists()) { + try {file.delete();} catch (SecurityException e) {} + } + else + return; + } + } + + private final void _deleteMultiFile() { + File file = null; + for(int indx = 1;indx<7;indx++) { + try { + file = new File(H5_MULTI_FILE+"-"+MULTI_LETTERS[indx]+".h5"); + } + catch (Throwable err) {} + + if (file.exists()) { + try {file.delete();} catch (SecurityException e) {} + } + } + } + + private final long _createDataset(long fid, long dsid, String name, long dapl) { + long did = -1; + try { + did = H5.H5Dcreate(fid, name, HDF5Constants.H5T_STD_I32BE, dsid, + HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, dapl); + } + catch (Throwable err) { + err.printStackTrace(); + fail("H5.H5Dcreate: " + err); + } + assertTrue("TestH5Pfapl._createDataset: ", did > 0); + + return did; + } + + private final void _createFloatDataset() { + try { + H5Fdsid = H5.H5Screate_simple(2, H5Fdims, null); + H5Fdid = H5.H5Dcreate(H5fid, "dsfloat", HDF5Constants.H5T_NATIVE_FLOAT, H5Fdsid, + HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); + } + catch (Throwable err) { + err.printStackTrace(); + fail("H5.H5Dcreate: " + err); + } + assertTrue("TestH5Pfapl._createFloatDataset: ", H5Fdid > 0); + + try { + H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); + } + catch (Throwable err) { + err.printStackTrace(); + } + } + + private final void _createH5multiFileDS() { + try { + H5did = _createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT); + } + catch (Throwable err) { + err.printStackTrace(); + fail("TestH5Pfapl.createH5file: " + err); + } + assertTrue("TestH5Pfapl.createH5file: _createDataset: ", H5did > 0); + + try { + H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); + } + catch (Throwable err) { + err.printStackTrace(); + } + } + + private final void _createH5File(long fapl) { + try { + H5fid = H5.H5Fcreate(H5_FILE, HDF5Constants.H5F_ACC_TRUNC, + HDF5Constants.H5P_DEFAULT, fapl); + H5dsid = H5.H5Screate_simple(2, H5dims, null); + H5did = _createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT); + } + catch (Throwable err) { + err.printStackTrace(); + fail("TestH5Pfapl.createH5file: " + err); + } + assertTrue("TestH5Pfapl.createH5file: H5.H5Fcreate: ", H5fid > 0); + assertTrue("TestH5Pfapl.createH5file: H5.H5Screate_simple: ", H5dsid > 0); + assertTrue("TestH5Pfapl.createH5file: _createDataset: ", H5did > 0); + + try { + H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); + } + catch (Throwable err) { + err.printStackTrace(); + } + } + + private final void _createH5familyFile(long fapl) { + try { + H5fid = H5.H5Fcreate(H5_FAMILY_FILE+".h5", HDF5Constants.H5F_ACC_TRUNC, + HDF5Constants.H5P_DEFAULT, fapl); + H5dsid = H5.H5Screate_simple(2, H5dims, null); + H5did = _createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT); + } + catch (Throwable err) { + err.printStackTrace(); + fail("TestH5Pfapl.createH5file: " + err); + } + assertTrue("TestH5Pfapl.createH5file: H5.H5Fcreate: ", H5fid > 0); + assertTrue("TestH5Pfapl.createH5file: H5.H5Screate_simple: ", H5dsid > 0); + assertTrue("TestH5Pfapl.createH5file: _createDataset: ", H5did > 0); + + try { + H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); + } + catch (Throwable err) { + err.printStackTrace(); + } + } + + private final void _createH5multiFile(long fapl) { + try { + H5fid = H5.H5Fcreate(H5_MULTI_FILE, HDF5Constants.H5F_ACC_TRUNC, + HDF5Constants.H5P_DEFAULT, fapl); + H5dsid = H5.H5Screate_simple(2, H5dims, null); + } + catch (Throwable err) { + err.printStackTrace(); + fail("TestH5Pfapl.createH5file: " + err); + } + assertTrue("TestH5Pfapl.createH5file: H5.H5Fcreate: ", H5fid > 0); + assertTrue("TestH5Pfapl.createH5file: H5.H5Screate_simple: ", H5dsid > 0); + + try { + H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); + } + catch (Throwable err) { + err.printStackTrace(); + } + } + + public void deleteH5file() { + _deleteFile(H5_FILE); + } + + public void deleteH5familyfile() { + _deleteFamilyFile(); + } + + public void deleteH5multifile() { + _deleteMultiFile(); + } + + @Before + public void createFileAccess() + throws NullPointerException, HDF5Exception { + assertTrue("H5 open ids is 0",H5.getOpenIDCount()==0); + System.out.print(testname.getMethodName()); + + try { + fapl_id = H5.H5Pcreate(HDF5Constants.H5P_FILE_ACCESS); + } + catch (Throwable err) { + err.printStackTrace(); + fail("TestH5Pfapl.createFileAccess: " + err); + } + assertTrue(fapl_id > 0); + try { + plapl_id = H5.H5Pcreate(HDF5Constants.H5P_LINK_ACCESS); + } + catch (Throwable err) { + err.printStackTrace(); + fail("TestH5Pfapl.createFileAccess: " + err); + } + assertTrue(plapl_id > 0); + try { + plist_id = H5.H5Pcreate(HDF5Constants.H5P_DATASET_XFER); + btplist_id = H5.H5Pcreate(HDF5Constants.H5P_DATASET_XFER); + dapl_id = H5.H5Pcreate(HDF5Constants.H5P_DATASET_ACCESS); + } + catch (Throwable err) { + err.printStackTrace(); + fail("TestH5Pfapl.createFileAccess: " + err); + } + assertTrue(plist_id > 0); + assertTrue(btplist_id > 0); + assertTrue(dapl_id > 0); + } + + @After + public void deleteFileAccess() throws HDF5LibraryException { + if (fapl_id > 0) + try {H5.H5Pclose(fapl_id);} catch (Exception ex) {} + if (plapl_id > 0) + try {H5.H5Pclose(plapl_id);} catch (Exception ex) {} + if (dapl_id > 0) + try {H5.H5Pclose(dapl_id);} catch (Exception ex) {} + if (plist_id > 0) + try {H5.H5Pclose(plist_id);} catch (Exception ex) {} + if (btplist_id > 0) + try {H5.H5Pclose(btplist_id);} catch (Exception ex) {} + + if (H5Fdsid > 0) + try {H5.H5Sclose(H5Fdsid);} catch (Exception ex) {} + if (H5Fdid > 0) + try {H5.H5Dclose(H5Fdid);} catch (Exception ex) {} + if (H5dsid > 0) + try {H5.H5Sclose(H5dsid);} catch (Exception ex) {} + if (H5did > 0) + try {H5.H5Dclose(H5did);} catch (Exception ex) {} + if (H5fid > 0) + try {H5.H5Fclose(H5fid);} catch (Exception ex) {} + System.out.println(); + } + + @Test + public void testH5Pset_fapl_ros3() + throws Exception + { + if (HDF5Constants.H5FD_ROS3 < 0) + return; + + final H5FD_ros3_fapl_t config = new H5FD_ros3_fapl_t(); + assertEquals("Default fapl has unexpected contents", + new H5FD_ros3_fapl_t("", "", ""), + config); + + H5.H5Pset_fapl_ros3(fapl_id, config); + + assertEquals("driver types don't match", + HDF5Constants.H5FD_ROS3, + H5.H5Pget_driver(fapl_id)); + + /* get_fapl_ros3 can throw exception in error cases */ + H5FD_ros3_fapl_t copy = H5.H5Pget_fapl_ros3(fapl_id); + assertEquals("contents of fapl set and get don't match", + new H5FD_ros3_fapl_t("", "", ""), + copy); + } + + @Test(expected = HDF5LibraryException.class) + public void testH5Pget_fapl_ros3_invalid_fapl_id() + throws Exception + { + if (HDF5Constants.H5FD_ROS3 < 0) + throw new HDF5LibraryException("skip"); + H5FD_ros3_fapl_t fails = H5.H5Pget_fapl_ros3(-1); + } + + @Test(expected = HDF5LibraryException.class) + public void testH5Pget_fapl_ros3_fapl_id_of_wrong_driver_type() + throws Exception + { + if (HDF5Constants.H5FD_ROS3 < 0) + throw new HDF5LibraryException("skip"); + if (HDF5Constants.H5FD_SEC2 < 0 ) + throw new HDF5LibraryException("skip"); + /* TODO: for now, test against a sec2 fapl only */ + + H5.H5Pset_fapl_sec2(fapl_id); + assertEquals("fapl_id was not set properly", + HDF5Constants.H5FD_SEC2, + H5.H5Pget_driver(fapl_id)); + H5FD_ros3_fapl_t fails = H5.H5Pget_fapl_ros3(fapl_id); + } + + @Test + public void testH5Pset_fapl_ros3_specified() + throws Exception + { + if (HDF5Constants.H5FD_ROS3 < 0) + return; + + String region = "us-east-1"; + String acc_id = "my_access_id"; + String acc_key = "my_access_key"; + + final H5FD_ros3_fapl_t config = new H5FD_ros3_fapl_t( + region, + acc_id, + acc_key); + H5.H5Pset_fapl_ros3(fapl_id, config); + assertEquals("driver types don't match", + HDF5Constants.H5FD_ROS3, + H5.H5Pget_driver(fapl_id)); + + H5FD_ros3_fapl_t copy = H5.H5Pget_fapl_ros3(fapl_id); + assertEquals("contents of fapl set and get don't match", + new H5FD_ros3_fapl_t(region, acc_id, acc_key), + copy); + } + +} diff --git a/java/test/junit.sh.in b/java/test/junit.sh.in index 7fb1bae..008c89c 100644 --- a/java/test/junit.sh.in +++ b/java/test/junit.sh.in @@ -18,6 +18,8 @@ srcdir=@srcdir@ USE_FILTER_SZIP="@USE_FILTER_SZIP@" USE_FILTER_DEFLATE="@USE_FILTER_DEFLATE@" +USE_ROS3_VFD="@HAVE_ROS3_VFD@" +USE_HDFS_VFD="@HAVE_LIBHDFS@" TESTNAME=JUnitInterface EXIT_SUCCESS=0 @@ -93,6 +95,8 @@ $HDFTEST_HOME/testfiles/JUnit-TestH5R.txt $HDFTEST_HOME/testfiles/JUnit-TestH5P.txt $HDFTEST_HOME/testfiles/JUnit-TestH5PData.txt $HDFTEST_HOME/testfiles/JUnit-TestH5Pfapl.txt +$HDFTEST_HOME/testfiles/JUnit-TestH5Pfapls3.txt +$HDFTEST_HOME/testfiles/JUnit-TestH5Pfaplhdfs.txt $HDFTEST_HOME/testfiles/JUnit-TestH5Pvirtual.txt $HDFTEST_HOME/testfiles/JUnit-TestH5Plist.txt $HDFTEST_HOME/testfiles/JUnit-TestH5A.txt @@ -1096,6 +1100,50 @@ if test $USE_FILTER_SZIP = "yes"; then test yes = "$verbose" && $DIFF JUnit-TestH5Giterate.txt JUnit-TestH5Giterate.out |sed 's/^/ /' fi fi +if test $ROS3_VFD = "yes"; then + echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Pfapls3" + TESTING JUnit-TestH5Pfapls3 + ($RUNSERIAL $JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Pfapls3 > JUnit-TestH5Pfapls3.ext) + + # Extract file name, line number, version and thread IDs because they may be different + sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \ + -e 's/line [0-9]*/line (number)/' \ + -e 's/Time: [0-9]*\.[0-9]*/Time: XXXX/' \ + -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \ + -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ + JUnit-TestH5Pfapls3.ext > JUnit-TestH5Pfapls3.out + + if diff JUnit-TestH5Pfapls3.out JUnit-TestH5Pfapls3.txt > /dev/null; then + echo " PASSED JUnit-TestH5Pfapls3" + else + echo "**FAILED** JUnit-TestH5Pfapls3" + echo " Expected result differs from actual result" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Pfapls3.txt JUnit-TestH5Pfapls3.out |sed 's/^/ /' + fi +fi +if test $HAVE_LIBHDFS = "yes"; then + echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Pfaplhdfs" + TESTING JUnit-TestH5Pfaplhdfs + ($RUNSERIAL $JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Pfaplhdfs > JUnit-TestH5Pfaplhdfs.ext) + + # Extract file name, line number, version and thread IDs because they may be different + sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \ + -e 's/line [0-9]*/line (number)/' \ + -e 's/Time: [0-9]*\.[0-9]*/Time: XXXX/' \ + -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \ + -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ + JUnit-TestH5Pfaplhdfs.ext > JUnit-TestH5Pfaplhdfs.out + + if diff JUnit-TestH5Pfaplhdfs.out JUnit-TestH5Pfaplhdfs.txt > /dev/null; then + echo " PASSED JUnit-TestH5Pfaplhdfs" + else + echo "**FAILED** JUnit-TestH5Pfaplhdfs" + echo " Expected result differs from actual result" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Pfaplhdfs.txt JUnit-TestH5Pfaplhdfs.out |sed 's/^/ /' + fi +fi # Clean up temporary files/directories diff --git a/java/test/testfiles/JUnit-TestH5Pfaplhdfs.txt b/java/test/testfiles/JUnit-TestH5Pfaplhdfs.txt new file mode 100644 index 0000000..47a00a4 --- /dev/null +++ b/java/test/testfiles/JUnit-TestH5Pfaplhdfs.txt @@ -0,0 +1,9 @@ +JUnit version 4.11 +.testH5Pget_fapl_hdfs_invalid_fapl_id +.testH5Pget_fapl_hdfs_fapl_id_of_wrong_driver_type +.testHDFS_fapl + +Time: XXXX + +OK (3 tests) + diff --git a/java/test/testfiles/JUnit-TestH5Pfapls3.txt b/java/test/testfiles/JUnit-TestH5Pfapls3.txt new file mode 100644 index 0000000..3f46342 --- /dev/null +++ b/java/test/testfiles/JUnit-TestH5Pfapls3.txt @@ -0,0 +1,10 @@ +JUnit version 4.11 +.testH5Pset_fapl_ros3_specified +.testH5Pset_fapl_ros3 +.testH5Pget_fapl_ros3_invalid_fapl_id +.testH5Pget_fapl_ros3_fapl_id_of_wrong_driver_type + +Time: XXXX + +OK (4 tests) + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4106515..2b693bd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -227,11 +227,14 @@ set (H5FD_SOURCES ${HDF5_SRC_DIR}/H5FDcore.c ${HDF5_SRC_DIR}/H5FDdirect.c ${HDF5_SRC_DIR}/H5FDfamily.c + ${HDF5_SRC_DIR}/H5FDhdfs.c ${HDF5_SRC_DIR}/H5FDint.c ${HDF5_SRC_DIR}/H5FDlog.c ${HDF5_SRC_DIR}/H5FDmpi.c ${HDF5_SRC_DIR}/H5FDmpio.c ${HDF5_SRC_DIR}/H5FDmulti.c + ${HDF5_SRC_DIR}/H5FDros3.c + ${HDF5_SRC_DIR}/H5FDs3comms.c ${HDF5_SRC_DIR}/H5FDsec2.c ${HDF5_SRC_DIR}/H5FDspace.c ${HDF5_SRC_DIR}/H5FDstdio.c @@ -243,11 +246,14 @@ set (H5FD_HDRS ${HDF5_SRC_DIR}/H5FDcore.h ${HDF5_SRC_DIR}/H5FDdirect.h ${HDF5_SRC_DIR}/H5FDfamily.h + ${HDF5_SRC_DIR}/H5FDhdfs.h ${HDF5_SRC_DIR}/H5FDlog.h ${HDF5_SRC_DIR}/H5FDmpi.h ${HDF5_SRC_DIR}/H5FDmpio.h ${HDF5_SRC_DIR}/H5FDmulti.h ${HDF5_SRC_DIR}/H5FDpublic.h + ${HDF5_SRC_DIR}/H5FDros3.h + ${HDF5_SRC_DIR}/H5FDs3comms.c ${HDF5_SRC_DIR}/H5FDsec2.h ${HDF5_SRC_DIR}/H5FDstdio.h ${HDF5_SRC_DIR}/H5FDwindows.h @@ -1142,6 +1148,7 @@ if (BUILD_SHARED_LIBS) add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} ${shared_gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS}) target_include_directories (${HDF5_LIBSH_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" + PUBLIC "$<$:${HDFS_INCLUDE_DIR}>" INTERFACE "$/include>" ) target_compile_definitions(${HDF5_LIBSH_TARGET} diff --git a/src/H5FDhdfs.c b/src/H5FDhdfs.c new file mode 100644 index 0000000..e3e11b2 --- /dev/null +++ b/src/H5FDhdfs.c @@ -0,0 +1,2070 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Read-Only HDFS Virtual File Driver (VFD) * + * Copyright (c) 2018, The HDF Group. * + * * + * All rights reserved. * + * * + * NOTICE: * + * All information contained herein is, and remains, the property of The HDF * + * Group. The intellectual and technical concepts contained herein are * + * proprietary to The HDF Group. Dissemination of this information or * + * reproduction of this material is strictly forbidden unless prior written * + * permission is obtained from The HDF Group. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Jacob Smith + * 2018-04-23 + * + * Purpose: Provide read-only access to files on the Hadoop Distributed + * File System (HDFS). + */ + +/* This source code file is part of the H5FD driver module */ +#include "H5FDdrvr_module.h" + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDhdfs.h" /* hdfs file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ + +#ifdef H5_HAVE_LIBHDFS +#include "hdfs.h" +#endif + +/* toggle function call prints: 1 turns on */ +#define HDFS_DEBUG 0 + +/* toggle stats collection and reporting */ +#define HDFS_STATS 0 + +/* The driver identification number, initialized at runtime */ +static hid_t H5FD_HDFS_g = 0; + +#if HDFS_STATS + +/* arbitrarily large value, such that any reasonable size read will be "less" + * than this value and set a true minimum + * not 0 because that may be a valid recorded minimum in degenerate cases + */ +#define HDFS_STATS_STARTING_MIN 0xfffffffful + +/* Configuration definitions for stats collection and breakdown + * + * 2^10 = 1024 + * Reads up to 1024 bytes (1 kB) fall in bin 0 + * 2^(10+(1*16)) = 2^26 = 64MB + * Reads of 64MB or greater fall in "overflow" bin[BIN_COUNT] + */ +#define HDFS_STATS_BASE 2 +#define HDFS_STATS_INTERVAL 1 +#define HDFS_STATS_START_POWER 10 +#define HDFS_STATS_BIN_COUNT 16 /* MUST BE GREATER THAN 0 */ + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Calculate `BASE ^ (START_POWER + (INTERVAL * bin_i))` + * Stores result at `(unsigned long long *) out_ptr`. + * Used in computing boundaries between stats bins. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + */ +#define HDFS_STATS_POW(bin_i, out_ptr) { \ + unsigned long long donotshadowresult = 1; \ + unsigned donotshadowindex = 0; \ + for (donotshadowindex = 0; \ + donotshadowindex < (((bin_i) * HDFS_STATS_INTERVAL) + \ + HDFS_STATS_START_POWER); \ + donotshadowindex++) \ + { \ + donotshadowresult *= HDFS_STATS_BASE; \ + } \ + *(out_ptr) = donotshadowresult; \ +} + +/* array to hold pre-computed boundaries for stats bins */ +static unsigned long long hdfs_stats_boundaries[HDFS_STATS_BIN_COUNT]; + + +/*************************************************************************** + * + * Structure: hdfs_statsbin + * + * Purpose: + * + * Structure for storing per-file hdfs VFD usage statistics. + * + * + * + * `count` (unsigned long long) + * + * Number of reads with size in this bin's range. + * + * `bytes` (unsigned long long) + * + * Total number of bytes read through this bin. + * + * `min` (unsigned long long) + * + * Smallest read size in this bin. + * + * `max` (unsigned long long) + * + * Largest read size in this bin. + * + * + * + * Programmer: Jacob Smith + * + * Changes: None + * + ***************************************************************************/ +typedef struct { + unsigned long long count; + unsigned long long bytes; + unsigned long long min; + unsigned long long max; +} hdfs_statsbin; + +#endif /* HDFS_STATS */ + +/* "unique" identifier for `hdfs_t` structures. + * Randomly generated by unweighted dice rolls. + */ +#define HDFS_HDFST_MAGIC 0x1AD5DE84 + + +/*************************************************************************** + * + * Structure: hdfs_t + * + * Purpose: + * + * Contain/retain information associated with a file hosted on Hadoop + * Distributed File System (HDFS). Instantiated and populated via + * `H5FD_hdfs_handle_open()` and cleaned up via `H5FD_hdfs_handle_close()`. + * + * + * + * `magic` (unisgned long) + * + * Number to indicate that this structure is of the promised + * type and should still be valid; should be HDFS_HDFST_MAGIC throughout + * the lifespan of the structure. Upon deletion of the structure, the + * programmer should set magic to anything but HDFS_HDFST_MAGIC, to + * indicate that the structure is to no longer be trusted. + * + * `filesystem` (hdfsFS) + * + * A libhdfs file system handle. + * + * `fileinfo` (hdfsFileInfo*) + * + * A pointer to a libhdfs file info structure. + * + * `file` (hdfsFile) + * + * A libhdfs file handle. + * + * + * + * Programmer: Jacob Smith + * May 2018 + * + * Changes: None + * + *************************************************************************** + */ +typedef struct { + unsigned long magic; +#ifdef H5_HAVE_LIBHDFS + hdfsFS filesystem; + hdfsFileInfo *fileinfo; + hdfsFile file; +#endif +} hdfs_t; + +#ifdef H5_HAVE_LIBHDFS + +/*-------------------------------------------------------------------------- + * Function: H5FD_hdfs_handle_open + * + * Purpose: Create a HDFS file handle, 'opening' the target file. + * + * Return: Success: Pointer to HDFS container/handle of opened file. + * Failure: NULL + * + * Programmer: Gerd Herber + * May 2018 + * + * Changes: None. + *-------------------------------------------------------------------------- + */ +static hdfs_t * +H5FD_hdfs_handle_open( + const char *path, + const char *namenode_name, + const int32_t namenode_port, + const char *user_name, + const char *kerberos_ticket_cache, + const int32_t stream_buffer_size) +{ + struct hdfsBuilder *builder = NULL; + hdfs_t *handle = NULL; + hdfs_t *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT + +#if HDFS_DEBUG + HDfprintf(stdout, "called H5FD_hdfs_handle_open.\n"); +#endif + + if (path == NULL || path[0] == '\0') { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "path cannot be null.\n") + } + if (namenode_name == NULL /* || namenode_name[0] == '\0' */ ) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "namenode name cannot be null.\n") + } + if (namenode_port < 0 || namenode_port > 65535) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "namenode port must be non-negative and <= 65535.\n") + } + if (stream_buffer_size < 0) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "buffer size must non-negative.\n") + } + + handle = (hdfs_t *)H5MM_malloc(sizeof(hdfs_t)); + if (handle == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, + "could not malloc space for handle.\n") + } + + handle->magic = (unsigned long)HDFS_HDFST_MAGIC; + handle->filesystem = NULL; /* TODO: not a pointer; NULL may cause bug */ + handle->fileinfo = NULL; + handle->file = NULL; /* TODO: not a pointer; NULL may cause bug */ + + builder = hdfsNewBuilder(); + if (!builder) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "(hdfs) failed to create builder") + } + hdfsBuilderSetNameNode(builder, namenode_name); + hdfsBuilderSetNameNodePort(builder, (tPort)namenode_port); + if (user_name != NULL && user_name[0] != '\0') { + hdfsBuilderSetUserName(builder, user_name); + } + if (kerberos_ticket_cache != NULL && kerberos_ticket_cache[0] != '\0') { + hdfsBuilderSetKerbTicketCachePath(builder, kerberos_ticket_cache); + } + /* Call to `hdfsBuilderConnect` releases builder, regardless of success. */ + handle->filesystem = hdfsBuilderConnect(builder); + if (!handle->filesystem) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "(hdfs) could not connect to default namenode") + } + handle->fileinfo = hdfsGetPathInfo(handle->filesystem, path); + if (!handle->fileinfo) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "hdfsGetPathInfo failed") + } + handle->file = hdfsOpenFile( + handle->filesystem, + path, + O_RDONLY, + stream_buffer_size, + 0, + 0); + if (!handle->file) { + HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, + "(hdfs) could not open") + } + + ret_value = handle; + +done: + if (ret_value == NULL && handle != NULL) { + /* error; clean up */ + HDassert(handle->magic == HDFS_HDFST_MAGIC); + handle->magic++; + if (handle->file != NULL) { + if (FAIL == (hdfsCloseFile(handle->filesystem, handle->file))) { + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, + "unable to close hdfs file handle") + } + } + if (handle->fileinfo != NULL) { + hdfsFreeFileInfo(handle->fileinfo, 1); + } + if (handle->filesystem != NULL) { + if (FAIL == (hdfsDisconnect(handle->filesystem))) { + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, + "unable to disconnect from hdfs") + } + } + H5MM_xfree(handle); + } + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_hdfs_handle_open() */ + + +/*-------------------------------------------------------------------------- + * Function: H5FD_hdfs_handle_close + * + * Purpose: 'Close' an HDFS file container/handle, releasing underlying + * resources. + * + * Return: Success: `SUCCEED` (0) + * Failure: `FAIL` (-1) + * + * Programmer: Gerd Herber + * May 2018 + * + * Changes: None. + *-------------------------------------------------------------------------- + */ +static herr_t +H5FD_hdfs_handle_close(hdfs_t *handle) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + +#if HDFS_DEBUG + HDfprintf(stdout, "called H5FD_hdfs_close.\n"); +#endif + + if (handle == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "handle cannot be null.\n") + } + if (handle->magic != HDFS_HDFST_MAGIC) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "handle has invalid magic.\n") + } + + handle->magic++; + if (handle->file != NULL) { + if (FAIL == (hdfsCloseFile(handle->filesystem, handle->file))) { + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, + "unable to close hdfs file handle") + } + } + if (handle->fileinfo != NULL) { + hdfsFreeFileInfo(handle->fileinfo, 1); + } + if (handle->filesystem != NULL) { + if (FAIL == (hdfsDisconnect(handle->filesystem))) { + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, + "unable to disconnect hdfs file system") + } + } + + H5MM_xfree(handle); + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_hdfs_close() */ +#endif /* H5_HAVE_LIBHDFS */ + + +/*************************************************************************** + * + * Structure: H5FD_hdfs_t + * + * Purpose: + * + * H5FD_hdfs_t is a structure used to store all information needed to + * maintain R/O access to a single HDF5 file in an HDFS file system. + * This structure is created when such a file is "opened" and + * discarded when it is "closed". + * + * + * `pub` (H5FD_t) + * + * Instance of H5FD_t which contains all fields common to all VFDs. + * It must be the first item in this structure, since at higher levels, + * this structure will be treated as an instance of H5FD_t. + * + * `fa` (H5FD_hdfs_fapl_t) + * + * Instance of `H5FD_hdfs_fapl_t` containing the HDFS configuration data + * needed to "open" the HDF5 file. + * + * `eoa` (haddr_t) + * + * End of addressed space in file. After open, it should always + * equal the file size. + * + * `hdfs_handle` (hdfs_t *) + * + * Instance of HDFS Request handle associated with the target resource. + * Responsible for communicating with remote host and presenting file + * contents as indistinguishable from a file on the local filesystem. + * + * *** present only if HDFS_SATS is flagged to enable stats collection *** + * + * `meta` (hdfs_statsbin[]) + * `raw` (hdfs_statsbin[]) + * + * Only present if hdfs stats collection is enabled. + * + * Arrays of `hdfs_statsbin` structures to record raw- and metadata reads. + * + * Records count and size of reads performed by the VFD, and is used to + * print formatted usage statistics to stdout upon VFD shutdown. + * + * Reads of each raw- and metadata type are recorded in an individual bin + * determined by the size of the read. The last bin of each type is + * reserved for "big" reads, with no defined upper bound. + * + * *** end HDFS_STATS *** + * + * + * + * Programmer: Jacob Smith + * + * Changes: None. + * + *************************************************************************** + */ +typedef struct H5FD_hdfs_t { + H5FD_t pub; + H5FD_hdfs_fapl_t fa; + haddr_t eoa; +#ifdef H5_HAVE_LIBHDFS + hdfs_t *hdfs_handle; +#endif +#if HDFS_STATS + hdfs_statsbin meta[HDFS_STATS_BIN_COUNT + 1]; + hdfs_statsbin raw[HDFS_STATS_BIN_COUNT + 1]; +#endif +} H5FD_hdfs_t; + +/* + * These macros check for overflow of various quantities. These macros + * assume that HDoff_t is signed and haddr_t and size_t are unsigned. + * + * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' + * is too large to be represented by the second argument + * of the file seek function. + * + */ +#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) + +/* Prototypes */ +static herr_t H5FD_hdfs_term(void); +static void *H5FD_hdfs_fapl_get(H5FD_t *_file); +static void *H5FD_hdfs_fapl_copy(const void *_old_fa); +static herr_t H5FD_hdfs_fapl_free(void *_fa); +static H5FD_t *H5FD_hdfs_open(const char *name, unsigned flags, hid_t fapl_id, + haddr_t maxaddr); +static herr_t H5FD_hdfs_close(H5FD_t *_file); +static int H5FD_hdfs_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD_hdfs_query(const H5FD_t *_f1, unsigned long *flags); +static haddr_t H5FD_hdfs_get_eoa(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD_hdfs_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static haddr_t H5FD_hdfs_get_eof(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD_hdfs_get_handle(H5FD_t *_file, hid_t fapl, + void** file_handle); +static herr_t H5FD_hdfs_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, + haddr_t addr, size_t size, void *buf); +static herr_t H5FD_hdfs_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, + haddr_t addr, size_t size, const void *buf); +static herr_t H5FD_hdfs_truncate(H5FD_t *_file, hid_t dxpl_id, + hbool_t closing); +static herr_t H5FD_hdfs_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD_hdfs_unlock(H5FD_t *_file); +static herr_t H5FD_hdfs_validate_config(const H5FD_hdfs_fapl_t * fa); + +static const H5FD_class_t H5FD_hdfs_g = { + "hdfs", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_hdfs_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + sizeof(H5FD_hdfs_fapl_t), /* fapl_size */ + H5FD_hdfs_fapl_get, /* fapl_get */ + H5FD_hdfs_fapl_copy, /* fapl_copy */ + H5FD_hdfs_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD_hdfs_open, /* open */ + H5FD_hdfs_close, /* close */ + H5FD_hdfs_cmp, /* cmp */ + H5FD_hdfs_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD_hdfs_get_eoa, /* get_eoa */ + H5FD_hdfs_set_eoa, /* set_eoa */ + H5FD_hdfs_get_eof, /* get_eof */ + H5FD_hdfs_get_handle, /* get_handle */ + H5FD_hdfs_read, /* read */ + H5FD_hdfs_write, /* write */ + NULL, /* flush */ + H5FD_hdfs_truncate, /* truncate */ + H5FD_hdfs_lock, /* lock */ + H5FD_hdfs_unlock, /* unlock */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ +}; + +/* Declare a free list to manage the H5FD_hdfs_t struct */ +H5FL_DEFINE_STATIC(H5FD_hdfs_t); + + +/*------------------------------------------------------------------------- + * Function: H5FD__init_package + * + * Purpose: Initializes any interface-specific data or routines. + * + * Return: Non-negative on success/Negative on failure + * + * Changes: Rename as appropriate for hdfs vfd. + * Jacob Smith 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD__init_package(void) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + if (H5FD_hdfs_init() < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, + "unable to initialize hdfs VFD") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD__init_package() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_hdfs_init + * + * Purpose: Initialize this driver by registering the driver with the + * library. + * + * Return: Success: The driver ID for the hdfs driver. + * Failure: Negative + * + * Programmer: Robb Matzke + * Thursday, July 29, 1999 + * + * Changes: Rename as appropriate for hdfs vfd. + * Jacob Smith 2018 + * + *------------------------------------------------------------------------- + */ +hid_t +H5FD_hdfs_init(void) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + +#if HDFS_DEBUG + HDfprintf(stdout, "H5FD_hdfs_init() called.\n"); +#endif + + if (H5I_VFL != H5I_get_type(H5FD_HDFS_g)) { + H5FD_HDFS_g = H5FD_register( + &H5FD_hdfs_g, + sizeof(H5FD_class_t), + FALSE); + } + +#if HDFS_STATS + /* pre-compute statsbin boundaries + */ + for (unsigned bin_i = 0; bin_i < HDFS_STATS_BIN_COUNT; bin_i++) { + unsigned long long value = 0; + HDFS_STATS_POW(bin_i, &value) + hdfs_stats_boundaries[bin_i] = value; + } +#endif + + ret_value = H5FD_HDFS_g; + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* end H5FD_hdfs_init() */ + + +/*--------------------------------------------------------------------------- + * Function: H5FD_hdfs_term + * + * Purpose: Shut down the VFD + * + * Returns: SUCCEED (Can't fail) + * + * Programmer: Quincey Koziol + * Friday, Jan 30, 2004 + * + * Changes: Rename as appropriate for hdfs vfd. + * Jacob Smith 2018 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5FD_hdfs_term(void) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + +#if HDFS_DEBUG + HDfprintf(stdout, "H5FD_hdfs_term() called.\n"); +#endif + + /* Reset VFL ID */ + H5FD_HDFS_g = 0; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FD_hdfs_term() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_fapl_hdfs + * + * Purpose: Modify the file access property list to use the H5FD_HDFS + * driver defined in this source file. All driver specfic + * properties are passed in as a pointer to a suitably + * initialized instance of H5FD_hdfs_fapl_t + * + * Return: SUCCEED/FAIL + * + * Programmer: John Mainzer + * 9/10/17 + * + * Changes: Rename as appropriate for hdfs vfd. + * Jacob Smith 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_fapl_hdfs(hid_t fapl_id, + H5FD_hdfs_fapl_t *fa) +{ + H5P_genplist_t *plist = NULL; /* Property list pointer */ + herr_t ret_value = FAIL; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*x", fapl_id, fa); + + HDassert(fa != NULL); + +#if HDFS_DEBUG + HDfprintf(stdout, "H5Pset_fapl_hdfs() called.\n"); +#endif + + plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); + if (plist == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, \ + "not a file access property list") + } + + if (FAIL == H5FD_hdfs_validate_config(fa)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "invalid hdfs config") + } + + ret_value = H5P_set_driver(plist, H5FD_HDFS, (void *)fa); + +done: + FUNC_LEAVE_API(ret_value) + +} /* H5Pset_fapl_hdfs() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_hdfs_validate_config() + * + * Purpose: Test to see if the supplied instance of H5FD_hdfs_fapl_t + * contains internally consistant data. Return SUCCEED if so, + * and FAIL otherwise. + * + * Note the difference between internally consistant and + * correct. As we will have to try to access the target + * object to determine whether the supplied data is correct, + * we will settle for internal consistancy at this point + * + * Return: SUCCEED if instance of H5FD_hdfs_fapl_t contains internally + * consistant data, FAIL otherwise. + * + * Programmer: Jacob Smith + * 9/10/17 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_hdfs_validate_config(const H5FD_hdfs_fapl_t * fa) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(fa != NULL); + + if ( fa->version != H5FD__CURR_HDFS_FAPL_T_VERSION ) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "Unknown H5FD_hdfs_fapl_t version"); + } + + if ( fa->namenode_port > 65535 ) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "Invalid namenode port number"); + } + if ( fa->namenode_port < 0 ) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "Invalid namenode port number"); + } + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_hdfs_validate_config() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pget_fapl_hdfs + * + * Purpose: Returns information about the hdfs file access property + * list though the function arguments. + * + * Return: Success: Non-negative + * + * Failure: Negative + * + * Programmer: John Mainzer + * 9/10/17 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_fapl_hdfs(hid_t fapl_id, + H5FD_hdfs_fapl_t *fa_out) +{ + const H5FD_hdfs_fapl_t *fa = NULL; + H5P_genplist_t *plist = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*x", fapl_id, fa_out); + +#if HDFS_DEBUG + HDfprintf(stdout, "H5Pget_fapl_hdfs() called.\n"); +#endif + + if (fa_out == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "fa_out is NULL") + } + plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); + if (plist == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access list") + } + if (H5FD_HDFS != H5P_peek_driver(plist)) { + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, + "incorrect VFL driver") + } + + fa = (const H5FD_hdfs_fapl_t *)H5P_peek_driver_info(plist); + if (fa == NULL) { + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, + "bad VFL driver info") + } + + /* Copy the hdfs fapl data out */ + HDmemcpy(fa_out, fa, sizeof(H5FD_hdfs_fapl_t)); + +done: + FUNC_LEAVE_API(ret_value) + +} /* H5Pget_fapl_hdfs() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_hdfs_fapl_get + * + * Purpose: Gets a file access property list which could be used to + * create an identical file. + * + * Return: Success: Ptr to new file access property list value. + * + * Failure: NULL + * + * Programmer: John Mainzer + * 9/8/17 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void * +H5FD_hdfs_fapl_get(H5FD_t *_file) +{ + H5FD_hdfs_t *file = (H5FD_hdfs_t*)_file; + H5FD_hdfs_fapl_t *fa = NULL; + void *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT + + fa = (H5FD_hdfs_fapl_t *)H5MM_calloc(sizeof(H5FD_hdfs_fapl_t)); + if (fa == NULL) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed") + } + + /* Copy the fields of the structure */ + HDmemcpy(fa, &(file->fa), sizeof(H5FD_hdfs_fapl_t)); + + ret_value = fa; + +done: + if (ret_value == NULL && fa != NULL) { + H5MM_xfree(fa); /* clean up on error */ + } + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_hdfs_fapl_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_hdfs_fapl_copy + * + * Purpose: Copies the hdfs-specific file access properties. + * + * Return: Success: Ptr to a new property list + * + * Failure: NULL + * + * Programmer: John Mainzer + * 9/8/17 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void * +H5FD_hdfs_fapl_copy(const void *_old_fa) +{ + const H5FD_hdfs_fapl_t *old_fa = (const H5FD_hdfs_fapl_t*)_old_fa; + H5FD_hdfs_fapl_t *new_fa = NULL; + void *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT + + new_fa = (H5FD_hdfs_fapl_t *)H5MM_malloc(sizeof(H5FD_hdfs_fapl_t)); + if (new_fa == NULL) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed") + } + + HDmemcpy(new_fa, old_fa, sizeof(H5FD_hdfs_fapl_t)); + ret_value = new_fa; + +done: + if (ret_value == NULL && new_fa != NULL) { + H5MM_xfree(new_fa); /* clean up on error */ + } + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_hdfs_fapl_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_hdfs_fapl_free + * + * Purpose: Frees the hdfs-specific file access properties. + * + * Return: SUCCEED (cannot fail) + * + * Programmer: John Mainzer + * 9/8/17 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_hdfs_fapl_free(void *_fa) +{ + H5FD_hdfs_fapl_t *fa = (H5FD_hdfs_fapl_t*)_fa; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(fa != NULL); /* sanity check */ + + H5MM_xfree(fa); + + FUNC_LEAVE_NOAPI(SUCCEED) + +} /* H5FD_hdfs_fapl_free() */ + +#if HDFS_STATS + +/*---------------------------------------------------------------------------- + * + * Function: hdfs_reset_stats() + * + * Purpose: + * + * Reset the stats collection elements in this virtual file structure. + * + * Clears any set data in stats bins; initializes/zeroes values. + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - FAILURE: `FAIL` + * - Occurs if the file is invalid somehow + * + * Programmer: Jacob Smith + * 2017-12-08 + * + * Changes: None. + * + *---------------------------------------------------------------------------- + */ +static herr_t +hdfs_reset_stats(H5FD_hdfs_t *file) +{ + unsigned i = 0; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + +#if HDFS_DEBUG + HDprintf("hdfs_reset_stats() called\n"); +#endif + + if (file == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "file was null") + } + + for (i = 0; i <= HDFS_STATS_BIN_COUNT; i++) { + file->raw[i].bytes = 0; + file->raw[i].count = 0; + file->raw[i].min = (unsigned long long)HDFS_STATS_STARTING_MIN; + file->raw[i].max = 0; + + file->meta[i].bytes = 0; + file->meta[i].count = 0; + file->meta[i].min = (unsigned long long)HDFS_STATS_STARTING_MIN; + file->meta[i].max = 0; + } + +done: + FUNC_LEAVE_NOAPI(ret_value); + +} /* hdfs_reset_stats */ +#endif /* HDFS_STATS */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_hdfs_open() + * + * Purpose: + * + * Create and/or opens a file as an HDF5 file. + * + * Any flag except H5F_ACC_RDONLY will cause an error. + * + * Return: + * + * Success: A pointer to a new file data structure. + * The public fields will be initialized by the caller, which is + * always H5FD_open(). + * + * Failure: NULL + * + * Programmer: Jacob Smith + * 2017-11-02 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static H5FD_t * +H5FD_hdfs_open( + const char *path, + unsigned flags, + hid_t fapl_id, + haddr_t maxaddr) +{ + H5FD_t *ret_value = NULL; +#ifdef H5_HAVE_LIBHDFS + H5FD_hdfs_t *file = NULL; + hdfs_t *handle = NULL; + H5FD_hdfs_fapl_t fa; +#endif + + FUNC_ENTER_NOAPI_NOINIT + +#ifndef H5_HAVE_LIBHDFS + HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, + "Illegal open of unsupported virtual file (hdfs)"); +#else +#if HDFS_DEBUG + HDfprintf(stdout, "H5FD_hdfs_open() called.\n"); +#endif /* HDFS_DEBUG */ + + /* Sanity check on file offsets */ + HDcompile_assert(sizeof(HDoff_t) >= sizeof(size_t)); + + /* Check arguments */ + if (!path || !*path) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "invalid file name") + } + if (0 == maxaddr || HADDR_UNDEF == maxaddr) { + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, + "bogus maxaddr") + } + if (ADDR_OVERFLOW(maxaddr)) { + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, + "bogus maxaddr") + } + if (flags != H5F_ACC_RDONLY) { + HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, NULL, + "only Read-Only access allowed") + } + if (fapl_id == H5P_DEFAULT || fapl_id == H5P_FILE_ACCESS_DEFAULT) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "fapl cannot be H5P_DEFAULT") + } + if (FAIL == H5Pget_fapl_hdfs(fapl_id, &fa)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "can't get property list") + } + + handle = H5FD_hdfs_handle_open( + path, + fa.namenode_name, + fa.namenode_port, + fa.user_name, + fa.kerberos_ticket_cache, + fa.stream_buffer_size); + + if (handle == NULL) { + HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, + "could not open") + } + + HDassert(handle->magic == HDFS_HDFST_MAGIC); + + /* create new file struct + */ + file = H5FL_CALLOC(H5FD_hdfs_t); + if (file == NULL) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "unable to allocate file struct") + } + file->hdfs_handle = handle; + HDmemcpy(&(file->fa), &fa, sizeof(H5FD_hdfs_fapl_t)); + +#if HDFS_STATS + if (FAIL == hdfs_reset_stats(file)) { + HGOTO_ERROR(H5E_INTERNAL, H5E_UNINITIALIZED, NULL, + "unable to reset file statistics") + } +#endif /* HDFS_STATS */ + + ret_value = (H5FD_t*)file; +#endif /* H5_HAVE_LIBHDFS */ + +done: +#ifdef H5_HAVE_LIBHDFS + if (ret_value == NULL) { + if (handle != NULL) { + if (FAIL == H5FD_hdfs_handle_close(handle)) { + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, + "unable to close HDFS file handle") + } + } + if (file != NULL) { + file = H5FL_FREE(H5FD_hdfs_t, file); + } + } /* if null return value (error) */ +#endif /* H5_HAVE_LIBHDFS */ + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_hdfs_open() */ + +#if HDFS_STATS + +/*---------------------------------------------------------------------------- + * + * Function: hdfs_fprint_stats() + * + * Purpose: + * + * Tabulate and pretty-print statistics for this virtual file. + * + * Should be called upon file close. + * + * Shows number of reads and bytes read, broken down by + * "raw" (H5FD_MEM_DRAW) + * or "meta" (any other flag) + * + * Prints filename and listing of total number of reads and bytes read, + * both as a grand total and separate meta- and rawdata reads. + * + * If any reads were done, prints out two tables: + * + * 1. overview of raw- and metadata reads + * - min (smallest size read) + * - average of size read + * - k,M,G suffixes by powers of 1024 (2^10) + * - max (largest size read) + * 2. tabulation of "bins", sepraring reads into exponentially-larger + * ranges of size. + * - columns for number of reads, total bytes, and average size, with + * separate sub-colums for raw- and metadata reads. + * - each row represents one bin, identified by the top of its range + * + * Bin ranges can be modified with pound-defines at the top of this file. + * + * Bins without any reads in their bounds are not printed. + * + * An "overflow" bin is also present, to catch "big" reads. + * + * Output for all bins (and range ceiling and average size report) + * is divied by powers of 1024. By corollary, four digits before the decimal + * is valid. + * + * - 41080 bytes is represented by 40.177k, not 41.080k + * - 1004.831M represents approx. 1052642000 bytes + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - FAILURE: `FAIL` + * - occurs if the file passed in is invalid + * - TODO: if stream is invalid? how can we check this? + * + * Programmer: Jacob Smith + * + * Changes: None. + * + *---------------------------------------------------------------------------- + */ +static herr_t +hdfs_fprint_stats( + FILE *stream, + const H5FD_hdfs_t *file) +{ + herr_t ret_value = SUCCEED; + parsed_url_t *purl = NULL; + unsigned i = 0; + unsigned long count_meta = 0; + unsigned long count_raw = 0; + double average_meta = 0.0; + double average_raw = 0.0; + unsigned long long min_meta = (unsigned long long)HDFS_STATS_STARTING_MIN; + unsigned long long min_raw = (unsigned long long)HDFS_STATS_STARTING_MIN; + unsigned long long max_meta = 0; + unsigned long long max_raw = 0; + unsigned long long bytes_raw = 0; + unsigned long long bytes_meta = 0; + double re_dub = 0.0; /* re-usable double variable */ + unsigned suffix_i = 0; + const char suffixes[] = { ' ', 'K', 'M', 'G', 'T', 'P' }; + + FUNC_ENTER_NOAPI_NOINIT + + if (stream == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "file stream cannot be null" ) + } + if (file == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "file cannot be null") + } + if (file->hdfs_handle == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "hdfs handle cannot be null") + } + if (file->hdfs_handle->magic != HDFS_HDFST_MAGIC) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "hdfs handle has invalid magic") + } + + /* TODO: See what libhdfs exposes to us. */ + +#if 0 + if (file->s3r_handle->purl == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "parsed url structure cannot be null") + } + purl = file->s3r_handle->purl; + + /****************** + * PRINT FILENAME * + ******************/ + + HDfprintf(stream, "stats for %s://%s", purl->scheme, purl->host); + if (purl->port != NULL && purl->port[0] != '\0') { + HDfprintf(stream, ":%s", purl->port); + } + if (purl->query != NULL && purl->query[0] != '\0') { + if (purl->path != NULL && purl->path[0] != '\0') { + HDfprintf(stream, "/%s", purl->path); + } else { + HDfprintf(stream, "/"); + } + HDfprintf(stream, "?%s", purl->query); + } else if (purl->path != NULL && purl->path[0] != '\0') { + HDfprintf(stream, "/%s", purl->path); + } + HDfprintf(stream, "\n"); +#endif + + /******************* + * AGGREGATE STATS * + *******************/ + + for (i = 0; i <= HDFS_STATS_BIN_COUNT; i++) { + const hdfs_statsbin *r = &file->raw[i]; + const hdfs_statsbin *m = &file->meta[i]; + + if (m->min < min_meta) min_meta = m->min; + if (r->min < min_raw) min_raw = r->min; + if (m->max > max_meta) max_meta = m->max; + if (r->max > max_raw) max_raw = r->max; + + count_raw += r->count; + count_meta += m->count; + bytes_raw += r->bytes; + bytes_meta += m->bytes; + } + if (count_raw > 0) average_raw = (double)bytes_raw / (double)count_raw; + if (count_meta > 0) average_meta = (double)bytes_meta / (double)count_meta; + + /****************** + * PRINT OVERVIEW * + ******************/ + + HDfprintf(stream, "TOTAL READS: %llu (%llu meta, %llu raw)\n", + count_raw + count_meta, count_meta, count_raw); + HDfprintf(stream, "TOTAL BYTES: %llu (%llu meta, %llu raw)\n", + bytes_raw + bytes_meta, bytes_meta, bytes_raw); + + if (count_raw + count_meta == 0) { + goto done; + } + + /************************* + * PRINT AGGREGATE STATS * + *************************/ + + HDfprintf(stream, "SIZES meta raw\n"); + HDfprintf(stream, " min "); + if (count_meta == 0) { + HDfprintf(stream, " 0.000 "); + } else { + re_dub = (double)min_meta; + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) { + re_dub /= 1024.0; + } + HDassert(suffix_i < sizeof(suffixes)); + HDfprintf(stream, "%8.3lf%c ", re_dub, suffixes[suffix_i]); + } + + if (count_raw == 0) { + HDfprintf(stream, " 0.000 \n"); + } else { + re_dub = (double)min_raw; + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) { + re_dub /= 1024.0; + } + HDassert(suffix_i < sizeof(suffixes)); + HDfprintf(stream, "%8.3lf%c\n", re_dub, suffixes[suffix_i]); + } + + HDfprintf(stream, " avg "); + re_dub = (double)average_meta; + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) { + re_dub /= 1024.0; + } + HDassert(suffix_i < sizeof(suffixes)); + HDfprintf(stream, "%8.3lf%c ", re_dub, suffixes[suffix_i]); + + re_dub = (double)average_raw; + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) { + re_dub /= 1024.0; + } + HDassert(suffix_i < sizeof(suffixes)); + HDfprintf(stream, "%8.3lf%c\n", re_dub, suffixes[suffix_i]); + + HDfprintf(stream, " max "); + re_dub = (double)max_meta; + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) { + re_dub /= 1024.0; + } + HDassert(suffix_i < sizeof(suffixes)); + HDfprintf(stream, "%8.3lf%c ", re_dub, suffixes[suffix_i]); + + re_dub = (double)max_raw; + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) { + re_dub /= 1024.0; + } + HDassert(suffix_i < sizeof(suffixes)); + HDfprintf(stream, "%8.3lf%c\n", re_dub, suffixes[suffix_i]); + + /****************************** + * PRINT INDIVIDUAL BIN STATS * + ******************************/ + + HDfprintf(stream, + "BINS # of reads total bytes average size\n"); + HDfprintf(stream, + " up-to meta raw meta raw meta raw\n"); + + for (i = 0; i <= HDFS_STATS_BIN_COUNT; i++) { + const hdfs_statsbin *m; + const hdfs_statsbin *r; + unsigned long long range_end = 0; + char bm_suffix = ' '; /* bytes-meta */ + double bm_val = 0.0; + char br_suffix = ' '; /* bytes-raw */ + double br_val = 0.0; + char am_suffix = ' '; /* average-meta */ + double am_val = 0.0; + char ar_suffix = ' '; /* average-raw */ + double ar_val = 0.0; + + m = &file->meta[i]; + r = &file->raw[i]; + if (r->count == 0 && m->count == 0) { + continue; + } + + range_end = hdfs_stats_boundaries[i]; + + if (i == HDFS_STATS_BIN_COUNT) { + range_end = hdfs_stats_boundaries[i-1]; + HDfprintf(stream, ">"); + } else { + HDfprintf(stream, " "); + } + + bm_val = (double)m->bytes; + for (suffix_i = 0; bm_val >= 1024.0; suffix_i++) { + bm_val /= 1024.0; + } + HDassert(suffix_i < sizeof(suffixes)); + bm_suffix = suffixes[suffix_i]; + + br_val = (double)r->bytes; + for (suffix_i = 0; br_val >= 1024.0; suffix_i++) { + br_val /= 1024.0; + } + HDassert(suffix_i < sizeof(suffixes)); + br_suffix = suffixes[suffix_i]; + + if (m->count > 0) { + am_val = (double)(m->bytes) / (double)(m->count); + } + for (suffix_i = 0; am_val >= 1024.0; suffix_i++) { + am_val /= 1024.0; + } + HDassert(suffix_i < sizeof(suffixes)); + am_suffix = suffixes[suffix_i]; + + if (r->count > 0) { + ar_val = (double)(r->bytes) / (double)(r->count); + } + for (suffix_i = 0; ar_val >= 1024.0; suffix_i++) { + ar_val /= 1024.0; + } + HDassert(suffix_i < sizeof(suffixes)); + ar_suffix = suffixes[suffix_i]; + + re_dub = (double)range_end; + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) { + re_dub /= 1024.0; + } + HDassert(suffix_i < sizeof(suffixes)); + + HDfprintf( + stream, + " %8.3f%c %7d %7d %8.3f%c %8.3f%c %8.3f%c %8.3f%c\n", + re_dub, suffixes[suffix_i], /* bin ceiling */ + m->count, /* metadata reads */ + r->count, /* rawdata reads */ + bm_val, bm_suffix, /* metadata bytes */ + br_val, br_suffix, /* rawdata bytes */ + am_val, am_suffix, /* metadata average */ + ar_val, ar_suffix); /* rawdata average */ + fflush(stream); + } + +done: + FUNC_LEAVE_NOAPI(ret_value); + +} /* hdfs_fprint_stats */ +#endif /* HDFS_STATS */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_hdfs_close() + * + * Purpose: + * + * Close an HDF5 file. + * + * Return: + * + * SUCCEED/FAIL + * + * Programmer: Jacob Smith + * 2017-11-02 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_hdfs_close(H5FD_t *_file) +{ + herr_t ret_value = SUCCEED; +#ifdef H5_HAVE_LIBHDFS + H5FD_hdfs_t *file = (H5FD_hdfs_t *)_file; +#endif + + FUNC_ENTER_NOAPI_NOINIT + +#ifndef H5_HAVE_LIBHDFS + HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, + "Illegal close of unsupported Virtual File (hdfs)") +#else +#if HDFS_DEBUG + HDfprintf(stdout, "H5FD_hdfs_close() called.\n"); +#endif + + /* Sanity checks + */ + HDassert(file != NULL); + HDassert(file->hdfs_handle != NULL); + HDassert(file->hdfs_handle->magic == HDFS_HDFST_MAGIC); + + /* Close the underlying request handle + */ + if (file->hdfs_handle != NULL) { + if (FAIL == H5FD_hdfs_handle_close(file->hdfs_handle)) { + HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, + "unable to close HDFS file handle") + } + } + +#if HDFS_STATS + /* TODO: mechanism to re-target stats printout */ + if (FAIL == hdfs_fprint_stats(stdout, file)) { + HGOTO_ERROR(H5E_INTERNAL, H5E_ERROR, FAIL, + "problem while writing file statistics") + } +#endif /* HDFS_STATS */ + + /* Release the file info + */ + file = H5FL_FREE(H5FD_hdfs_t, file); +#endif /* H5_HAVE_LIBHDFS */ + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* end H5FD_hdfs_close() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_hdfs_cmp() + * + * Purpose: + * + * Compares two files using this driver by their HDFS-provided file info, + * field-by-field. + * + * Return: + * + Equivalent: 0 + * + Not Equivalent: -1 + * + * Programmer: Gerd Herber + * May 2018 + * + * Changes: + * + * + Replace `if (ret_value == 0)` chain with `HGOTO_DONE` jumps. + * Jacob Smith 17 May 2018 + * + *------------------------------------------------------------------------- + */ +static int +H5FD_hdfs_cmp(const H5FD_t *_f1, + const H5FD_t *_f2) +{ + int ret_value = 0; +#ifdef H5_HAVE_LIBHDFS + const H5FD_hdfs_t *f1 = (const H5FD_hdfs_t *)_f1; + const H5FD_hdfs_t *f2 = (const H5FD_hdfs_t *)_f2; + hdfsFileInfo *finfo1 = NULL; + hdfsFileInfo *finfo2 = NULL; +#endif /* H5_HAVE_LIBHDFS */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + +#ifdef H5_HAVE_LIBHDFS +#if HDFS_DEBUG + HDfprintf(stdout, "H5FD_hdfs_cmp() called.\n"); +#endif /* HDFS_DEBUG */ + + HDassert(f1->hdfs_handle != NULL); + HDassert(f2->hdfs_handle != NULL); + HDassert(f1->hdfs_handle->magic == HDFS_HDFST_MAGIC); + HDassert(f2->hdfs_handle->magic == HDFS_HDFST_MAGIC); + + finfo1 = f1->hdfs_handle->fileinfo; + finfo2 = f2->hdfs_handle->fileinfo; + HDassert(finfo1 != NULL); + HDassert(finfo2 != NULL); + + if (finfo1->mKind != finfo2->mKind) HGOTO_DONE(-1); + if (finfo1->mName != finfo2->mName) HGOTO_DONE(-1); + if (finfo1->mLastMod != finfo2->mLastMod) HGOTO_DONE(-1); + if (finfo1->mSize != finfo2->mSize) HGOTO_DONE(-1); + if (finfo1->mReplication != finfo2->mReplication) HGOTO_DONE(-1); + if (finfo1->mBlockSize != finfo2->mBlockSize) HGOTO_DONE(-1); + if (strcmp(finfo1->mOwner, finfo2->mOwner)) HGOTO_DONE(-1); + if (strcmp(finfo1->mGroup, finfo2->mGroup)) HGOTO_DONE(-1); + if (finfo1->mPermissions != finfo2->mPermissions) HGOTO_DONE(-1); + if (finfo1->mLastAccess != finfo2->mLastAccess) HGOTO_DONE(-1); +#endif /* H5_HAVE_LIBHDFS */ + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_hdfs_cmp() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_hdfs_query + * + * Purpose: Set the flags that this VFL driver is capable of supporting. + * (listed in H5FDpublic.h) + * + * Note that since the HDFS VFD is read only, most flags + * are irrelevant. + * + * The term "set" is highly misleading... + * stores/copies the supported flags in the out-pointer `flags`. + * + * Return: SUCCEED (Can't fail) + * + * Programmer: John Mainzer + * 9/11/17 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_hdfs_query( + const H5FD_t H5_ATTR_UNUSED *_file, + unsigned long *flags) /* out variable */ +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + +#if HDFS_DEBUG + HDfprintf(stdout, "H5FD_hdfs_query() called.\n"); +#endif + + if (flags) { + *flags = 0; + *flags |= H5FD_FEAT_DATA_SIEVE; + } + + FUNC_LEAVE_NOAPI(SUCCEED) + +} /* H5FD_hdfs_query() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_hdfs_get_eoa() + * + * Purpose: + * + * Gets the end-of-address marker for the file. The EOA marker + * is the first address past the last byte allocated in the + * format address space. + * + * Return: + * + * The end-of-address marker. + * + * Programmer: Jacob Smith + * 2017-11-02 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static haddr_t +H5FD_hdfs_get_eoa( + const H5FD_t *_file, + H5FD_mem_t H5_ATTR_UNUSED type) +{ +#ifdef H5_HAVE_LIBHDFS + const H5FD_hdfs_t *file = (const H5FD_hdfs_t *)_file; +#endif /* H5_HAVE_LIBHDFS */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + +#if HDFS_DEBUG + HDfprintf(stdout, "H5FD_hdfs_get_eoa() called.\n"); +#endif + +#ifdef H5_HAVE_LIBHDFS + FUNC_LEAVE_NOAPI(file->eoa) +#else + FUNC_LEAVE_NOAPI(0) +#endif /* H5_HAVE_LIBHDFS */ + +} /* end H5FD_hdfs_get_eoa() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_hdfs_set_eoa() + * + * Purpose: + * + * Set the end-of-address marker for the file. + * + * Return: + * + * SUCCEED (can't fail) + * + * Programmer: Jacob Smith + * 2017-11-03 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_hdfs_set_eoa( + H5FD_t *_file, + H5FD_mem_t H5_ATTR_UNUSED type, + haddr_t addr) +{ +#ifdef H5_HAVE_LIBHDFS + H5FD_hdfs_t *file = (H5FD_hdfs_t *)_file; +#endif /* H5_HAVE_LIBHDFS */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + +#if HDFS_DEBUG + HDfprintf(stdout, "H5FD_hdfs_set_eoa() called.\n"); +#endif + +#ifdef H5_HAVE_LIBHDFS + file->eoa = addr; + + FUNC_LEAVE_NOAPI(SUCCEED) +#else + FUNC_LEAVE_NOAPI(FAIL) +#endif /* H5_HAVE_LIBHDFS */ + +} /* H5FD_hdfs_set_eoa() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_hdfs_get_eof() + * + * Purpose: + * + * Returns the end-of-file marker. + * + * Return: + * + * EOF: the first address past the end of the "file", either the + * filesystem file or the HDF5 file. + * + * Programmer: Jacob Smith + * 2017-11-02 + * + *------------------------------------------------------------------------- + */ +static haddr_t +H5FD_hdfs_get_eof( + const H5FD_t *_file, + H5FD_mem_t H5_ATTR_UNUSED type) +{ +#ifdef H5_HAVE_LIBHDFS + const H5FD_hdfs_t *file = (const H5FD_hdfs_t *)_file; +#endif /* H5_HAVE_LIBHDFS */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + +#if HDFS_DEBUG + HDfprintf(stdout, "H5FD_hdfs_get_eof() called.\n"); +#endif + +#ifdef H5_HAVE_LIBHDFS + HDassert(file->hdfs_handle != NULL); + HDassert(file->hdfs_handle->magic == HDFS_HDFST_MAGIC); + + FUNC_LEAVE_NOAPI((size_t) file->hdfs_handle->fileinfo->mSize) +#else + FUNC_LEAVE_NOAPI((size_t)0) +#endif /* H5_HAVE_LIBHDFS */ + +} /* end H5FD_hdfs_get_eof() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_hdfs_get_handle() + * + * Purpose: + * + * Returns the HDFS handle (hdfs_t) of hdfs file driver. + * + * Returns: + * + * SUCCEED/FAIL + * + * Programmer: Jacob Smith + * 2017-11-02 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_hdfs_get_handle( + H5FD_t *_file, + hid_t H5_ATTR_UNUSED fapl, + void **file_handle) +{ + herr_t ret_value = SUCCEED; +#ifdef H5_HAVE_LIBHDFS + H5FD_hdfs_t *file = (H5FD_hdfs_t *)_file; +#endif + + FUNC_ENTER_NOAPI_NOINIT + +#if HDFS_DEBUG + HDfprintf(stdout, "H5FD_hdfs_get_handle() called.\n"); +#endif /* HDFS_DEBUG */ + +#ifdef H5_HAVE_LIBHDFS + if (!file_handle) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "file handle not valid") + } + + *file_handle = file->hdfs_handle; +#else + HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, + "Illegal get-handle of unsupported virtual file (hdfs)"); +#endif /* H5_HAVE_LIBHDFS */ + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* end H5FD_hdfs_get_handle() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_hdfs_read() + * + * Purpose: + * + * Reads SIZE bytes of data from FILE beginning at address ADDR + * into buffer BUF according to data transfer properties in DXPL_ID. + * + * Return: + * + * Success: `SUCCEED` + * - Result is stored in caller-supplied buffer BUF. + * Failure: `FAIL` + * - Unable to complete read. + * - Contents of buffer `buf` are undefined. + * + * Programmer: Jacob Smith + * 2017-11-?? + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_hdfs_read( + H5FD_t *_file, + H5FD_mem_t H5_ATTR_UNUSED type, + hid_t H5_ATTR_UNUSED dxpl_id, + haddr_t addr, /* start offset */ + size_t size, /* length of read */ + void *buf) /* out */ +{ + herr_t ret_value = SUCCEED; +#if H5_HAVE_LIBHDFS + H5FD_hdfs_t *file = (H5FD_hdfs_t *)_file; + size_t filesize = 0; +#endif /* H5_HAVE_LIBHDFS */ +#if HDFS_STATS + /* working variables for storing stats */ + hdfs_statsbin *bin = NULL; + unsigned bin_i = 0; +#endif /* HDFS_STATS */ + + FUNC_ENTER_NOAPI_NOINIT + +#if HDFS_DEBUG + HDfprintf(stdout, "H5FD_hdfs_read() called.\n"); +#endif /* HDFS_DEBUG */ + +#ifndef H5_HAVE_LIBHDFS + HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, + "Illegal get-handle of unsupported virtual file (hdfs)"); +#else + HDassert(file != NULL); + HDassert(file->hdfs_handle != NULL); + HDassert(file->hdfs_handle->magic == HDFS_HDFST_MAGIC); + HDassert(buf != NULL); + + filesize = (size_t) file->hdfs_handle->fileinfo->mSize; + + if ((addr > filesize) || ((addr + size) > filesize)) { + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, + "range exceeds file address") + } + + if (FAIL == hdfsPread( + file->hdfs_handle->filesystem, + file->hdfs_handle->file, + (tOffset)addr, + buf, + (tSize)size)) + { + HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, + "unable to execute read") + } + +#if HDFS_STATS + + /* Find which "bin" this read fits in. Can be "overflow" bin. + */ + for (bin_i = 0; bin_i < HDFS_STATS_BIN_COUNT; bin_i++) { + if ((unsigned long long)size < hdfs_stats_boundaries[bin_i]) { + break; + } + } + bin = (type == H5FD_MEM_DRAW) + ? &file->raw[bin_i] + : &file->meta[bin_i]; + + /* Store collected stats in appropriate bin + */ + if (bin->count == 0) { + bin->min = size; + bin->max = size; + } else { + if (size < bin->min) bin->min = size; + if (size > bin->max) bin->max = size; + } + bin->count++; + bin->bytes += (unsigned long long)size; + +#endif /* HDFS_STATS */ +#endif /* H5_HAVE_LIBHDFS */ + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* end H5FD_hdfs_read() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_hdfs_write() + * + * Purpose: + * + * Write bytes to file. + * UNSUPPORTED IN READ-ONLY HDFS VFD. + * + * Return: + * + * FAIL (Not possible with Read-Only S3 file.) + * + * Programmer: Jacob Smith + * 2017-10-23 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_hdfs_write( + H5FD_t H5_ATTR_UNUSED *_file, + H5FD_mem_t H5_ATTR_UNUSED type, + hid_t H5_ATTR_UNUSED dxpl_id, + haddr_t H5_ATTR_UNUSED addr, + size_t H5_ATTR_UNUSED size, + const void H5_ATTR_UNUSED *buf) +{ + herr_t ret_value = FAIL; + + FUNC_ENTER_NOAPI_NOINIT + +#if HDFS_DEBUG + HDfprintf(stdout, "H5FD_hdfs_write() called.\n"); +#endif + + HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, + "cannot write to read-only file.") + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_hdfs_write() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_hdfs_truncate() + * + * Purpose: + * + * Makes sure that the true file size is the same (or larger) + * than the end-of-address. + * + * NOT POSSIBLE ON READ-ONLY S3 FILES. + * + * Return: + * + * FAIL (Not possible on Read-Only S3 files.) + * + * Programmer: Jacob Smith + * 2017-10-23 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_hdfs_truncate( + H5FD_t H5_ATTR_UNUSED *_file, + hid_t H5_ATTR_UNUSED dxpl_id, + hbool_t H5_ATTR_UNUSED closing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + +#if HDFS_DEBUG + HDfprintf(stdout, "H5FD_hdfs_truncate() called.\n"); +#endif + + HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, + "cannot truncate read-only file.") + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* end H5FD_hdfs_truncate() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_hdfs_lock() + * + * Purpose: + * + * Place an advisory lock on a file. + * No effect on Read-Only S3 file. + * + * Suggestion: remove lock/unlock from class + * > would result in error at H5FD_[un]lock() (H5FD.c) + * + * Return: + * + * SUCCEED (No-op always succeeds) + * + * Programmer: Jacob Smith + * 2017-11-03 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_hdfs_lock( + H5FD_t H5_ATTR_UNUSED *_file, + hbool_t H5_ATTR_UNUSED rw) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_LEAVE_NOAPI(SUCCEED) + +} /* end H5FD_hdfs_lock() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_hdfs_unlock() + * + * Purpose: + * + * Remove the existing lock on the file. + * No effect on Read-Only S3 file. + * + * Return: + * + * SUCCEED (No-op always succeeds) + * + * Programmer: Jacob Smith + * 2017-11-03 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_hdfs_unlock(H5FD_t H5_ATTR_UNUSED *_file) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_LEAVE_NOAPI(SUCCEED) + +} /* end H5FD_hdfs_unlock() */ + diff --git a/src/H5FDhdfs.h b/src/H5FDhdfs.h new file mode 100644 index 0000000..3d4128d --- /dev/null +++ b/src/H5FDhdfs.h @@ -0,0 +1,122 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Read-Only HDFS Virtual File Driver (VFD) * + * Copyright (c) 2018, The HDF Group. * + * * + * All rights reserved. * + * * + * NOTICE: * + * All information contained herein is, and remains, the property of The HDF * + * Group. The intellectual and technical concepts contained herein are * + * proprietary to The HDF Group. Dissemination of this information or * + * reproduction of this material is strictly forbidden unless prior written * + * permission is obtained from The HDF Group. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Jacob Smith + * 2018-04-23 + * + * Purpose: The public header file for the hdfs driver. + */ + +#ifndef H5FDhdfs_H +#define H5FDhdfs_H + +#define H5FD_HDFS (H5FD_hdfs_init()) + +#ifdef __cplusplus +extern "C" { +#endif + +/**************************************************************************** + * + * Structure: H5FD_hdfs_fapl_t + * + * Purpose: + * + * H5FD_hdfs_fapl_t is a public structure that is used to pass + * configuration information to the appropriate HDFS VFD via the FAPL. + * A pointer to an instance of this structure is a parameter to + * H5Pset_fapl_hdfs() and H5Pget_fapl_hdfs(). + * + * + * + * `version` (int32_t) + * + * Version number of the `H5FD_hdfs_fapl_t` structure. Any instance passed + * to the above calls must have a recognized version number, or an error + * will be flagged. + * + * This field should be set to `H5FD__CURR_HDFS_FAPL_T_VERSION`. + * + * `namenode_name` (const char[]) + * + * Name of "Name Node" to access as the HDFS server. + * + * Must not be longer than `H5FD__HDFS_NODE_NAME_SPACE`. + * + * TBD: Can be NULL. + * + * `namenode_port` (int32_t) TBD + * + * Port number to use to connect with Name Node. + * + * TBD: If 0, uses a default port. + * + * `kerberos_ticket_cache` (const char[]) + * + * Path to the location of the Kerberos authentication cache. + * + * Must not be longer than `H5FD__HDFS_KERB_CACHE_PATH_SPACE`. + * + * TBD: Can be NULL. + * + * `user_name` (const char[]) + * + * Username to use when accessing file. + * + * Must not be longer than `H5FD__HDFS_USER_NAME_SPACE`. + * + * TBD: Can be NULL. + * + * `stream_buffer_size` (int32_t) + * + * Size (in bytes) of the file read stream buffer. + * + * TBD: If -1, relies on a default value. + * + * + * + * Programmer: Jacob Smith + * 2018-04-23 + * + * Changes: None + * + ****************************************************************************/ + +#define H5FD__CURR_HDFS_FAPL_T_VERSION 1 + +#define H5FD__HDFS_NODE_NAME_SPACE 128 +#define H5FD__HDFS_USER_NAME_SPACE 128 +#define H5FD__HDFS_KERB_CACHE_PATH_SPACE 128 + +typedef struct H5FD_hdfs_fapl_t { + int32_t version; + char namenode_name[H5FD__HDFS_NODE_NAME_SPACE + 1]; + int32_t namenode_port; + char user_name[H5FD__HDFS_USER_NAME_SPACE + 1]; + char kerberos_ticket_cache[H5FD__HDFS_KERB_CACHE_PATH_SPACE + 1]; + int32_t stream_buffer_size; +} H5FD_hdfs_fapl_t; + +H5_DLL hid_t H5FD_hdfs_init(void); +H5_DLL herr_t H5Pget_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa_out); +H5_DLL herr_t H5Pset_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa); + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef H5FDhdfs_H */ + + diff --git a/src/H5FDros3.c b/src/H5FDros3.c new file mode 100644 index 0000000..8bf0420 --- /dev/null +++ b/src/H5FDros3.c @@ -0,0 +1,1847 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Read-Only S3 Virtual File Driver (VFD) * + * Copyright (c) 2017-2018, The HDF Group. * + * * + * All rights reserved. * + * * + * NOTICE: * + * All information contained herein is, and remains, the property of The HDF * + * Group. The intellectual and technical concepts contained herein are * + * proprietary to The HDF Group. Dissemination of this information or * + * reproduction of this material is strictly forbidden unless prior written * + * permission is obtained from The HDF Group. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Jacob Smith + * 2017-10-13 + * + * Purpose: + * + * Provide read-only access to files hosted on Amazon's S3 service. + * Relies on "s3comms" utility layer to implement the AWS REST API. + */ + +/* This source code file is part of the H5FD driver module */ +#include "H5FDdrvr_module.h" + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDros3.h" /* ros3 file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5FDs3comms.h" /* S3 Communications */ + +/* toggle function call prints: 1 turns on + */ +#define ROS3_DEBUG 0 + +/* toggle stats collection and reporting + */ +#define ROS3_STATS 0 + +/* The driver identification number, initialized at runtime + */ +static hid_t H5FD_ROS3_g = 0; + +#if ROS3_STATS + +/* arbitrarily large value, such that any reasonable size read will be "less" + * than this value and set a true minimum + * not 0 because that may be a valid recorded minimum in degenerate cases + */ +#define ROS3_STATS_STARTING_MIN 0xfffffffful + +/* Configuration definitions for stats collection and breakdown + * + * 2^10 = 1024 + * Reads up to 1024 bytes (1 kB) fall in bin 0 + * 2^(10+(1*16)) = 2^26 = 64MB + * Reads of 64MB or greater fall in "overflow" bin[BIN_COUNT] + */ +#define ROS3_STATS_BASE 2 +#define ROS3_STATS_INTERVAL 1 +#define ROS3_STATS_START_POWER 10 +#define ROS3_STATS_BIN_COUNT 16 /* MUST BE GREATER THAN 0 */ + + +/* + * Calculate `BASE ^ (START_POWER + (INTERVAL * bin_i))` + * Stores result at `(unsigned long long *) out_ptr`. + * Used in computing boundaries between stats bins. + */ +#define ROS3_STATS_POW(bin_i, out_ptr) { \ + unsigned long long donotshadowresult = 1; \ + unsigned donotshadowindex = 0; \ + for (donotshadowindex = 0; \ + donotshadowindex < (((bin_i) * ROS3_STATS_INTERVAL) + \ + ROS3_STATS_START_POWER); \ + donotshadowindex++) \ + { \ + donotshadowresult *= ROS3_STATS_BASE; \ + } \ + *(out_ptr) = donotshadowresult; \ +} + +/* array to hold pre-computed boundaries for stats bins + */ +static unsigned long long ros3_stats_boundaries[ROS3_STATS_BIN_COUNT]; + +/*************************************************************************** + * + * Structure: ros3_statsbin + * + * Purpose: + * + * Structure for storing per-file ros3 VFD usage statistics. + * + * + * + * `count` (unsigned long long) + * + * Number of reads with size in this bin's range. + * + * `bytes` (unsigned long long) + * + * Total number of bytes read through this bin. + * + * `min` (unsigned long long) + * + * Smallest read size in this bin. + * + * `max` (unsigned long long) + * + * Largest read size in this bin. + * + * + * + * Programmer: Jacob Smith + * + * Changes: None + * + ***************************************************************************/ +typedef struct { + unsigned long long count; + unsigned long long bytes; + unsigned long long min; + unsigned long long max; +} ros3_statsbin; + +#endif /* ROS3_STATS */ + +/*************************************************************************** + * + * Structure: H5FD_ros3_t + * + * Purpose: + * + * H5FD_ros3_t is a structure used to store all information needed to + * maintain R/O access to a single HDF5 file that has been stored as a + * S3 object. This structure is created when such a file is "opened" and + * discarded when it is "closed". + * + * Presents an S3 object as a file to the HDF5 library. + * + * + * + * `pub` (H5FD_t) + * + * Instance of H5FD_t which contains all fields common to all VFDs. + * It must be the first item in this structure, since at higher levels, + * this structure will be treated as an instance of H5FD_t. + * + * `fa` (H5FD_ros3_fapl_t) + * + * Instance of `H5FD_ros3_fapl_t` containing the S3 configuration data + * needed to "open" the HDF5 file. + * + * `eoa` (haddr_t) + * + * End of addressed space in file. After open, it should always + * equal the file size. + * + * `s3r_handle` (s3r_t *) + * + * Instance of S3 Request handle associated with the target resource. + * Responsible for communicating with remote host and presenting file + * contents as indistinguishable from a file on the local filesystem. + * + * *** present only if ROS3_SATS is flagged to enable stats collection *** + * + * `meta` (ros3_statsbin[]) + * `raw` (ros3_statsbin[]) + * + * Only present if ros3 stats collection is enabled. + * + * Arrays of `ros3_statsbin` structures to record raw- and metadata reads. + * + * Records count and size of reads performed by the VFD, and is used to + * print formatted usage statistics to stdout upon VFD shutdown. + * + * Reads of each raw- and metadata type are recorded in an individual bin + * determined by the size of the read. The last bin of each type is + * reserved for "big" reads, with no defined upper bound. + * + * *** end ROS3_STATS *** + * + * + * + * Programmer: Jacob Smith + * + * Changes: None. + * + ***************************************************************************/ +typedef struct H5FD_ros3_t { + H5FD_t pub; + H5FD_ros3_fapl_t fa; + haddr_t eoa; + s3r_t *s3r_handle; +#if ROS3_STATS + ros3_statsbin meta[ROS3_STATS_BIN_COUNT + 1]; + ros3_statsbin raw[ROS3_STATS_BIN_COUNT + 1]; +#endif +} H5FD_ros3_t; + +/* + * These macros check for overflow of various quantities. These macros + * assume that HDoff_t is signed and haddr_t and size_t are unsigned. + * + * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' + * is too large to be represented by the second argument + * of the file seek function. + * + */ +#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) + +/* Prototypes */ +static herr_t H5FD_ros3_term(void); +static void *H5FD_ros3_fapl_get(H5FD_t *_file); +static void *H5FD_ros3_fapl_copy(const void *_old_fa); +static herr_t H5FD_ros3_fapl_free(void *_fa); +static H5FD_t *H5FD_ros3_open(const char *name, unsigned flags, hid_t fapl_id, + haddr_t maxaddr); +static herr_t H5FD_ros3_close(H5FD_t *_file); +static int H5FD_ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD_ros3_query(const H5FD_t *_f1, unsigned long *flags); +static haddr_t H5FD_ros3_get_eoa(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD_ros3_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static haddr_t H5FD_ros3_get_eof(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD_ros3_get_handle(H5FD_t *_file, hid_t fapl, + void** file_handle); +static herr_t H5FD_ros3_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, + haddr_t addr, size_t size, void *buf); +static herr_t H5FD_ros3_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, + haddr_t addr, size_t size, const void *buf); +static herr_t H5FD_ros3_truncate(H5FD_t *_file, hid_t dxpl_id, + hbool_t closing); +static herr_t H5FD_ros3_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD_ros3_unlock(H5FD_t *_file); +static herr_t H5FD_ros3_validate_config(const H5FD_ros3_fapl_t * fa); + +static const H5FD_class_t H5FD_ros3_g = { + "ros3", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_ros3_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + sizeof(H5FD_ros3_fapl_t), /* fapl_size */ + H5FD_ros3_fapl_get, /* fapl_get */ + H5FD_ros3_fapl_copy, /* fapl_copy */ + H5FD_ros3_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD_ros3_open, /* open */ + H5FD_ros3_close, /* close */ + H5FD_ros3_cmp, /* cmp */ + H5FD_ros3_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD_ros3_get_eoa, /* get_eoa */ + H5FD_ros3_set_eoa, /* set_eoa */ + H5FD_ros3_get_eof, /* get_eof */ + H5FD_ros3_get_handle, /* get_handle */ + H5FD_ros3_read, /* read */ + H5FD_ros3_write, /* write */ + NULL, /* flush */ + H5FD_ros3_truncate, /* truncate */ + H5FD_ros3_lock, /* lock */ + H5FD_ros3_unlock, /* unlock */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ +}; + +/* Declare a free list to manage the H5FD_ros3_t struct */ +H5FL_DEFINE_STATIC(H5FD_ros3_t); + + +/*------------------------------------------------------------------------- + * Function: H5FD__init_package + * + * Purpose: Initializes any interface-specific data or routines. + * + * Return: Non-negative on success/Negative on failure + * + * Changes: Rename as appropriate for ros3 vfd. + * Jacob Smith 2017 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD__init_package(void) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + if (H5FD_ros3_init() < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, + "unable to initialize ros3 VFD") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD__init_package() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_ros3_init + * + * Purpose: Initialize this driver by registering the driver with the + * library. + * + * Return: Success: The driver ID for the ros3 driver. + * Failure: Negative + * + * Programmer: Robb Matzke + * Thursday, July 29, 1999 + * + * Changes: Rename as appropriate for ros3 vfd. + * Jacob Smith 2017 + * + *------------------------------------------------------------------------- + */ +hid_t +H5FD_ros3_init(void) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + +#if ROS3_DEBUG + HDfprintf(stdout, "H5FD_ros3_init() called.\n"); +#endif + + if (H5I_VFL != H5I_get_type(H5FD_ROS3_g)) + H5FD_ROS3_g = H5FD_register(&H5FD_ros3_g, sizeof(H5FD_class_t), FALSE); + +#if ROS3_STATS + /* pre-compute statsbin boundaries + */ + for (unsigned bin_i = 0; bin_i < ROS3_STATS_BIN_COUNT; bin_i++) { + unsigned long long value = 0; + ROS3_STATS_POW(bin_i, &value) + ros3_stats_boundaries[bin_i] = value; + } +#endif + + /* Set return value */ + ret_value = H5FD_ROS3_g; + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* end H5FD_ros3_init() */ + + +/*--------------------------------------------------------------------------- + * Function: H5FD_ros3_term + * + * Purpose: Shut down the VFD + * + * Returns: SUCCEED (Can't fail) + * + * Programmer: Quincey Koziol + * Friday, Jan 30, 2004 + * + * Changes: Rename as appropriate for ros3 vfd. + * Jacob Smith 2017 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5FD_ros3_term(void) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + +#if ROS3_DEBUG + HDfprintf(stdout, "H5FD_ros3_term() called.\n"); +#endif + + /* Reset VFL ID */ + H5FD_ROS3_g = 0; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FD_ros3_term() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_fapl_ros3 + * + * Purpose: Modify the file access property list to use the H5FD_ROS3 + * driver defined in this source file. All driver specfic + * properties are passed in as a pointer to a suitably + * initialized instance of H5FD_ros3_fapl_t + * + * Return: SUCCEED/FAIL + * + * Programmer: John Mainzer + * 9/10/17 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_fapl_ros3(hid_t fapl_id, + H5FD_ros3_fapl_t *fa) +{ + H5P_genplist_t *plist = NULL; /* Property list pointer */ + herr_t ret_value = FAIL; + + + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*x", fapl_id, fa); + + HDassert(fa != NULL); + +#if ROS3_DEBUG + HDfprintf(stdout, "H5Pset_fapl_ros3() called.\n"); +#endif + + plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); + if (plist == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, \ + "not a file access property list") + } + + if (FAIL == H5FD_ros3_validate_config(fa)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid ros3 config") + + ret_value = H5P_set_driver(plist, H5FD_ROS3, (void *)fa); + +done: + + FUNC_LEAVE_API(ret_value) + +} /* H5Pset_fapl_ros3() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_ros3_validate_config() + * + * Purpose: Test to see if the supplied instance of H5FD_ros3_fapl_t + * contains internally consistant data. Return SUCCEED if so, + * and FAIL otherwise. + * + * Note the difference between internally consistant and + * correct. As we will have to try to access the target + * object to determine whether the supplied data is correct, + * we will settle for internal consistancy at this point + * + * Return: SUCCEED if instance of H5FD_ros3_fapl_t contains internally + * consistant data, FAIL otherwise. + * + * Programmer: Jacob Smith + * 9/10/17 + * + * Changes: Add checks for authenticate flag requring populated + * `aws_region` and `secret_id` strings. + * -- Jacob Smith 2017-11-01 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_ros3_validate_config(const H5FD_ros3_fapl_t * fa) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(fa != NULL); + + if ( fa->version != H5FD__CURR_ROS3_FAPL_T_VERSION ) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "Unknown H5FD_ros3_fapl_t version"); + } + + /* if set to authenticate, region and id cannot be empty strings + */ + if (fa->authenticate == TRUE) { + if ((fa->aws_region[0] == '\0') || + (fa->secret_id[0] == '\0')) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "Inconsistent authentication information"); + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_ros3_validate_config() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pget_fapl_ros3 + * + * Purpose: Returns information about the ros3 file access property + * list though the function arguments. + * + * Return: Success: Non-negative + * + * Failure: Negative + * + * Programmer: John Mainzer + * 9/10/17 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_fapl_ros3(hid_t fapl_id, + H5FD_ros3_fapl_t *fa_out) +{ + const H5FD_ros3_fapl_t *fa; + H5P_genplist_t *plist = NULL; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*x", fapl_id, fa_out); + +#if ROS3_DEBUG + HDfprintf(stdout, "H5Pget_fapl_ros3() called.\n"); +#endif + + if (fa_out == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fa_out is NULL") + + plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); + if (plist == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") + } + + if (H5FD_ROS3 != H5P_peek_driver(plist)) { + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") + } + + fa = (const H5FD_ros3_fapl_t *)H5P_peek_driver_info(plist); + if (fa == NULL) { + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") + } + + /* Copy the ros3 fapl data out */ + HDmemcpy(fa_out, fa, sizeof(H5FD_ros3_fapl_t)); + +done: + FUNC_LEAVE_API(ret_value) + +} /* H5Pget_fapl_ros3() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_ros3_fapl_get + * + * Purpose: Gets a file access property list which could be used to + * create an identical file. + * + * Return: Success: Ptr to new file access property list value. + * + * Failure: NULL + * + * Programmer: John Mainzer + * 9/8/17 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void * +H5FD_ros3_fapl_get(H5FD_t *_file) +{ + H5FD_ros3_t *file = (H5FD_ros3_t*)_file; + H5FD_ros3_fapl_t *fa = NULL; + void *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT + + fa = (H5FD_ros3_fapl_t *)H5MM_calloc(sizeof(H5FD_ros3_fapl_t)); + if (fa == NULL) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed") + } + + /* Copy the fields of the structure */ + HDmemcpy(fa, &(file->fa), sizeof(H5FD_ros3_fapl_t)); + + /* Set return value */ + ret_value = fa; + +done: + if (ret_value == NULL) { + if (fa != NULL) + H5MM_xfree(fa); + } + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_ros3_fapl_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_ros3_fapl_copy + * + * Purpose: Copies the ros3-specific file access properties. + * + * Return: Success: Ptr to a new property list + * + * Failure: NULL + * + * Programmer: John Mainzer + * 9/8/17 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void * +H5FD_ros3_fapl_copy(const void *_old_fa) +{ + const H5FD_ros3_fapl_t *old_fa = (const H5FD_ros3_fapl_t*)_old_fa; + H5FD_ros3_fapl_t *new_fa = NULL; + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + new_fa = (H5FD_ros3_fapl_t *)H5MM_malloc(sizeof(H5FD_ros3_fapl_t)); + if (new_fa == NULL) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed"); + } + + HDmemcpy(new_fa, old_fa, sizeof(H5FD_ros3_fapl_t)); + ret_value = new_fa; + +done: + if (ret_value == NULL) { + if (new_fa != NULL) + H5MM_xfree(new_fa); + } + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_ros3_fapl_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_ros3_fapl_free + * + * Purpose: Frees the ros3-specific file access properties. + * + * Return: SUCCEED (cannot fail) + * + * Programmer: John Mainzer + * 9/8/17 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_ros3_fapl_free(void *_fa) +{ + H5FD_ros3_fapl_t *fa = (H5FD_ros3_fapl_t*)_fa; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(fa != NULL); /* sanity check */ + + H5MM_xfree(fa); + + FUNC_LEAVE_NOAPI(SUCCEED) + +} /* H5FD_ros3_fapl_free() */ + +#if ROS3_STATS + +/*---------------------------------------------------------------------------- + * + * Function: ros3_reset_stats() + * + * Purpose: + * + * Reset the stats collection elements in this virtual file structure. + * + * Clears any set data in stats bins; initializes/zeroes values. + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - FAILURE: `FAIL` + * - Occurs if the file is invalid somehow + * + * Programmer: Jacob Smith + * 2017-12-08 + * + * Changes: None. + * + *---------------------------------------------------------------------------- + */ +static herr_t +ros3_reset_stats(H5FD_ros3_t *file) +{ + unsigned i = 0; + herr_t ret_value = SUCCEED; + + + FUNC_ENTER_NOAPI_NOINIT + +#if ROS3_DEBUG + HDprintf("ros3_reset_stats() called\n"); +#endif + + if (file == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "file was null"); + } + + for (i = 0; i <= ROS3_STATS_BIN_COUNT; i++) { + file->raw[i].bytes = 0; + file->raw[i].count = 0; + file->raw[i].min = (unsigned long long)ROS3_STATS_STARTING_MIN; + file->raw[i].max = 0; + + file->meta[i].bytes = 0; + file->meta[i].count = 0; + file->meta[i].min = (unsigned long long)ROS3_STATS_STARTING_MIN; + file->meta[i].max = 0; + } + +done: + FUNC_LEAVE_NOAPI(ret_value); + +} /* ros3_reset_stats */ +#endif /* ROS3_STATS */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_ros3_open() + * + * Purpose: + * + * Create and/or opens a file as an HDF5 file. + * + * Any flag except H5F_ACC_RDONLY will cause an error. + * + * Name (as received from `H5FD_open()`) must conform to web url: + * NAME :: HTTP "://" DOMAIN [PORT] ["/" [URI] [QUERY] ] + * HTTP :: "http" [ "s" ] + * DOMAIN :: e.g., "mybucket.host.org" + * PORT :: ":" (e.g., ":9000" ) + * URI :: (e.g., "path/to/resource.hd5" ) + * QUERY :: "?" (e.g., "arg1=param1&arg2=param2") + * + * Return: + * + * Success: A pointer to a new file data structure. + * The public fields will be initialized by the caller, which is + * always H5FD_open(). + * + * Failure: NULL + * + * Programmer: Jacob Smith + * 2017-11-02 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static H5FD_t * +H5FD_ros3_open(const char *url, + unsigned flags, + hid_t fapl_id, + haddr_t maxaddr) +{ +#ifdef H5_HAVE_ROS3_VFD + H5FD_ros3_t *file = NULL; + struct tm *now = NULL; + char iso8601now[ISO8601_SIZE]; + unsigned char signing_key[SHA256_DIGEST_LENGTH]; + s3r_t *handle = NULL; + H5FD_ros3_fapl_t fa; +#endif + H5FD_t *ret_value = NULL; + + + + FUNC_ENTER_NOAPI_NOINIT +#ifdef H5_HAVE_ROS3_VFD + +#if ROS3_DEBUG + HDfprintf(stdout, "H5FD_ros3_open() called.\n"); +#endif + + + /* Sanity check on file offsets */ + HDcompile_assert(sizeof(HDoff_t) >= sizeof(size_t)); + + /* Check arguments */ + if (!url || !*url) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") + if (0 == maxaddr || HADDR_UNDEF == maxaddr) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") + if (ADDR_OVERFLOW(maxaddr)) + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") + if (flags != H5F_ACC_RDONLY) + HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, NULL, + "only Read-Only access allowed") + + if (FAIL == H5Pget_fapl_ros3(fapl_id, &fa)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't get property list") + } + + if (CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "unable to initialize curl global (placeholder flags)") + } + + /* open file; procedure depends on whether or not the fapl instructs to + * authenticate requests or not. + */ + if (fa.authenticate == TRUE) { + /* compute signing key (part of AWS/S3 REST API) + * can be re-used by user/key for 7 days after creation. + * find way to re-use/share + */ + now = gmnow(); + HDassert( now != NULL ); + if (ISO8601NOW(iso8601now, now) != (ISO8601_SIZE - 1)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "problem while writing iso8601 timestamp") + } + if (FAIL == H5FD_s3comms_signing_key(signing_key, + (const char *)fa.secret_key, + (const char *)fa.aws_region, + (const char *)iso8601now) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "problem while computing signing key") + } + + handle = H5FD_s3comms_s3r_open( + url, + (const char *)fa.aws_region, + (const char *)fa.secret_id, + (const unsigned char *)signing_key); + } else { + handle = H5FD_s3comms_s3r_open(url, NULL, NULL, NULL); + } /* if/else should authenticate */ + + if (handle == NULL) { + /* If we want to check CURL's say on the matter in a controlled + * fashion, this is the place to do it, but would need to make a + * few minor changes to s3comms `s3r_t` and `s3r_read()`. + */ + HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "could not open"); + } + + /* create new file struct + */ + file = H5FL_CALLOC(H5FD_ros3_t); + if (file == NULL) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "unable to allocate file struct") + } + + file->s3r_handle = handle; + HDmemcpy(&(file->fa), &fa, sizeof(H5FD_ros3_fapl_t)); + +#if ROS3_STATS + if (FAIL == ros3_reset_stats(file)) { + HGOTO_ERROR(H5E_INTERNAL, H5E_UNINITIALIZED, NULL, + "unable to reset file statistics") + } +#endif /* ROS3_STATS */ + + ret_value = (H5FD_t*)file; + +done: + if (ret_value == NULL) { + if (handle != NULL) { + if (FAIL == H5FD_s3comms_s3r_close(handle)) { + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, + "unable to close s3 file handle") + } + } + if (file != NULL) { + file = H5FL_FREE(H5FD_ros3_t, file); + } + curl_global_cleanup(); /* early cleanup because open failed */ + } /* if null return value (error) */ +#endif /* H5_HAVE_ROS3_VFD */ + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_ros3_open() */ + +#if ROS3_STATS + +/*---------------------------------------------------------------------------- + * + * Function: ros3_fprint_stats() + * + * Purpose: + * + * Tabulate and pretty-print statistics for this virtual file. + * + * Should be called upon file close. + * + * Shows number of reads and bytes read, broken down by + * "raw" (H5FD_MEM_DRAW) + * or "meta" (any other flag) + * + * Prints filename and listing of total number of reads and bytes read, + * both as a grand total and separate meta- and rawdata reads. + * + * If any reads were done, prints out two tables: + * + * 1. overview of raw- and metadata reads + * - min (smallest size read) + * - average of size read + * - k,M,G suffixes by powers of 1024 (2^10) + * - max (largest size read) + * 2. tabulation of "bins", sepraring reads into exponentially-larger + * ranges of size. + * - columns for number of reads, total bytes, and average size, with + * separate sub-colums for raw- and metadata reads. + * - each row represents one bin, identified by the top of its range + * + * Bin ranges can be modified with pound-defines at the top of this file. + * + * Bins without any reads in their bounds are not printed. + * + * An "overflow" bin is also present, to catch "big" reads. + * + * Output for all bins (and range ceiling and average size report) + * is divied by powers of 1024. By corollary, four digits before the decimal + * is valid. + * + * - 41080 bytes is represented by 40.177k, not 41.080k + * - 1004.831M represents approx. 1052642000 bytes + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - FAILURE: `FAIL` + * - occurs if the file passed in is invalid + * - TODO: if stream is invalid? how can we check this? + * + * Programmer: Jacob Smith + * + * Changes: None. + * + *---------------------------------------------------------------------------- + */ +static herr_t +ros3_fprint_stats(FILE *stream, + const H5FD_ros3_t *file) +{ + herr_t ret_value = SUCCEED; + parsed_url_t *purl = NULL; + unsigned i = 0; + unsigned long count_meta = 0; + unsigned long count_raw = 0; + double average_meta = 0.0; + double average_raw = 0.0; + unsigned long long min_meta = (unsigned long long)ROS3_STATS_STARTING_MIN; + unsigned long long min_raw = (unsigned long long)ROS3_STATS_STARTING_MIN; + unsigned long long max_meta = 0; + unsigned long long max_raw = 0; + unsigned long long bytes_raw = 0; + unsigned long long bytes_meta = 0; + double re_dub = 0.0; /* re-usable double variable */ + unsigned suffix_i = 0; + const char suffixes[] = { ' ', 'K', 'M', 'G', 'T', 'P' }; + + + + FUNC_ENTER_NOAPI_NOINIT + + if (stream == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "file stream cannot be null" ); + } + if (file == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "file cannot be null"); + } + if (file->s3r_handle == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "s3 request handle cannot be null"); + } + if (file->s3r_handle->purl == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "parsed url structure cannot be null"); + } + purl = file->s3r_handle->purl; + + /****************** + * PRINT FILENAME * + ******************/ + + HDfprintf(stream, "stats for %s://%s", purl->scheme, purl->host); + if (purl->port != NULL && purl->port[0] != '\0') + HDfprintf(stream, ":%s", purl->port); + if (purl->query != NULL && purl->query[0] != '\0') { + if (purl->path != NULL && purl->path[0] != '\0') + HDfprintf(stream, "/%s", purl->path); + else + HDfprintf(stream, "/"); + HDfprintf(stream, "?%s", purl->query); + } else if (purl->path != NULL && purl->path[0] != '\0') { + HDfprintf(stream, "/%s", purl->path); + } + HDfprintf(stream, "\n"); + + /******************* + * AGGREGATE STATS * + *******************/ + + for (i = 0; i <= ROS3_STATS_BIN_COUNT; i++) { + const ros3_statsbin *r = &file->raw[i]; + const ros3_statsbin *m = &file->meta[i]; + + if (m->min < min_meta) min_meta = m->min; + if (r->min < min_raw) min_raw = r->min; + if (m->max > max_meta) max_meta = m->max; + if (r->max > max_raw) max_raw = r->max; + + count_raw += r->count; + count_meta += m->count; + bytes_raw += r->bytes; + bytes_meta += m->bytes; + } + if (count_raw > 0) + average_raw = (double)bytes_raw / (double)count_raw; + if (count_meta > 0) + average_meta = (double)bytes_meta / (double)count_meta; + + /****************** + * PRINT OVERVIEW * + ******************/ + + HDfprintf(stream, "TOTAL READS: %llu (%llu meta, %llu raw)\n", + count_raw + count_meta, count_meta, count_raw); + HDfprintf(stream, "TOTAL BYTES: %llu (%llu meta, %llu raw)\n", + bytes_raw + bytes_meta, bytes_meta, bytes_raw); + + if (count_raw + count_meta == 0) + goto done; + + /************************* + * PRINT AGGREGATE STATS * + *************************/ + + HDfprintf(stream, "SIZES meta raw\n"); + HDfprintf(stream, " min "); + if (count_meta == 0) { + HDfprintf(stream, " 0.000 "); + } else { + re_dub = (double)min_meta; + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) + re_dub /= 1024.0; + HDassert(suffix_i < sizeof(suffixes)); + HDfprintf(stream, "%8.3lf%c ", re_dub, suffixes[suffix_i]); + } + + if (count_raw == 0) { + HDfprintf(stream, " 0.000 \n"); + } else { + re_dub = (double)min_raw; + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) + re_dub /= 1024.0; + HDassert(suffix_i < sizeof(suffixes)); + HDfprintf(stream, "%8.3lf%c\n", re_dub, suffixes[suffix_i]); + } + + HDfprintf(stream, " avg "); + re_dub = (double)average_meta; + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) + re_dub /= 1024.0; + HDassert(suffix_i < sizeof(suffixes)); + HDfprintf(stream, "%8.3lf%c ", re_dub, suffixes[suffix_i]); + + re_dub = (double)average_raw; + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) + re_dub /= 1024.0; + HDassert(suffix_i < sizeof(suffixes)); + HDfprintf(stream, "%8.3lf%c\n", re_dub, suffixes[suffix_i]); + + HDfprintf(stream, " max "); + re_dub = (double)max_meta; + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) + re_dub /= 1024.0; + HDassert(suffix_i < sizeof(suffixes)); + HDfprintf(stream, "%8.3lf%c ", re_dub, suffixes[suffix_i]); + + re_dub = (double)max_raw; + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) + re_dub /= 1024.0; + HDassert(suffix_i < sizeof(suffixes)); + HDfprintf(stream, "%8.3lf%c\n", re_dub, suffixes[suffix_i]); + + /****************************** + * PRINT INDIVIDUAL BIN STATS * + ******************************/ + + HDfprintf(stream, + "BINS # of reads total bytes average size\n"); + HDfprintf(stream, + " up-to meta raw meta raw meta raw\n"); + + for (i = 0; i <= ROS3_STATS_BIN_COUNT; i++) { + const ros3_statsbin *m; + const ros3_statsbin *r; + unsigned long long range_end = 0; + char bm_suffix = ' '; /* bytes-meta */ + double bm_val = 0.0; + char br_suffix = ' '; /* bytes-raw */ + double br_val = 0.0; + char am_suffix = ' '; /* average-meta */ + double am_val = 0.0; + char ar_suffix = ' '; /* average-raw */ + double ar_val = 0.0; + + m = &file->meta[i]; + r = &file->raw[i]; + if (r->count == 0 && m->count == 0) + continue; + + range_end = ros3_stats_boundaries[i]; + + if (i == ROS3_STATS_BIN_COUNT) { + range_end = ros3_stats_boundaries[i-1]; + HDfprintf(stream, ">"); + } else { + HDfprintf(stream, " "); + } + + bm_val = (double)m->bytes; + for (suffix_i = 0; bm_val >= 1024.0; suffix_i++) + bm_val /= 1024.0; + HDassert(suffix_i < sizeof(suffixes)); + bm_suffix = suffixes[suffix_i]; + + br_val = (double)r->bytes; + for (suffix_i = 0; br_val >= 1024.0; suffix_i++) + br_val /= 1024.0; + HDassert(suffix_i < sizeof(suffixes)); + br_suffix = suffixes[suffix_i]; + + if (m->count > 0) + am_val = (double)(m->bytes) / (double)(m->count); + for (suffix_i = 0; am_val >= 1024.0; suffix_i++) + am_val /= 1024.0; + HDassert(suffix_i < sizeof(suffixes)); + am_suffix = suffixes[suffix_i]; + + if (r->count > 0) + ar_val = (double)(r->bytes) / (double)(r->count); + for (suffix_i = 0; ar_val >= 1024.0; suffix_i++) + ar_val /= 1024.0; + HDassert(suffix_i < sizeof(suffixes)); + ar_suffix = suffixes[suffix_i]; + + re_dub = (double)range_end; + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) + re_dub /= 1024.0; + HDassert(suffix_i < sizeof(suffixes)); + + HDfprintf(stream, + " %8.3f%c %7d %7d %8.3f%c %8.3f%c %8.3f%c %8.3f%c\n", + re_dub, suffixes[suffix_i], /* bin ceiling */ + m->count, /* metadata reads */ + r->count, /* rawdata reads */ + bm_val, bm_suffix, /* metadata bytes */ + br_val, br_suffix, /* rawdata bytes */ + am_val, am_suffix, /* metadata average */ + ar_val, ar_suffix); /* rawdata average */ + + fflush(stream); + } + +done: + FUNC_LEAVE_NOAPI(ret_value); + +} /* ros3_fprint_stats */ +#endif /* ROS3_STATS */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_ros3_close() + * + * Purpose: + * + * Close an HDF5 file. + * + * Return: + * + * SUCCEED/FAIL + * + * Programmer: Jacob Smith + * 2017-11-02 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_ros3_close(H5FD_t *_file) +{ +#ifdef H5_HAVE_ROS3_VFD + H5FD_ros3_t *file = (H5FD_ros3_t *)_file; + herr_t ret_value = SUCCEED; +#else + herr_t ret_value = FAIL; +#endif + + + + FUNC_ENTER_NOAPI_NOINIT +#ifdef H5_HAVE_ROS3_VFD + +#if ROS3_DEBUG + HDfprintf(stdout, "H5FD_ros3_close() called.\n"); +#endif + + /* Sanity checks + */ + HDassert(file != NULL); + HDassert(file->s3r_handle != NULL); + + /* Close the underlying request handle + */ + if (FAIL == H5FD_s3comms_s3r_close(file->s3r_handle)) { + HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, + "unable to close S3 request handle") + } + +#if ROS3_STATS + /* TODO: mechanism to re-target stats printout */ + if (FAIL == ros3_fprint_stats(stdout, file)) { + HGOTO_ERROR(H5E_INTERNAL, H5E_ERROR, FAIL, + "problem while writing file statistics") + } +#endif /* ROS3_STATS */ + + /* Release the file info + */ + file = H5FL_FREE(H5FD_ros3_t, file); + +done: + curl_global_cleanup(); /* cleanup to answer init on open */ +#endif /* H5_HAVE_ROS3_VFD */ + + FUNC_LEAVE_NOAPI(ret_value) + +} /* end H5FD_ros3_close() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_ros3_cmp() + * + * Purpose: + * + * Compares two files belonging to this driver using an arbitrary + * (but consistent) ordering: + * + * + url scheme + * + url host + * + url port + * + url path + * + url query + * + fapl aws_region + * + fapl secret_id + * + fapl secret_key + * + * tl;dr -> check URL, check crentials + * + * Return: + * + * - Equivalent: 0 + * - Not Equivalent: -1 + * + * Programmer: Jacob Smith + * 2017-11-06 + * + * Changes: + * + * + Change from strcmp-like return values (-1, 0, 1) to instead return + * binary equivalence (0) or inequality (-1). + * + Replace "if still equal then check this" waterfall with GOTO jumps. + * Jacob Smith 2018-05-17 + * + *------------------------------------------------------------------------- + */ +static int +H5FD_ros3_cmp(const H5FD_t *_f1, + const H5FD_t *_f2) +{ +#ifdef H5_HAVE_ROS3_VFD + const H5FD_ros3_t *f1 = (const H5FD_ros3_t *)_f1; + const H5FD_ros3_t *f2 = (const H5FD_ros3_t *)_f2; + const parsed_url_t *purl1 = NULL; + const parsed_url_t *purl2 = NULL; +#endif + int ret_value = 0; + + + + FUNC_ENTER_NOAPI_NOINIT_NOERR +#ifdef H5_HAVE_ROS3_VFD + +#if ROS3_DEBUG + HDfprintf(stdout, "H5FD_ros3_cmp() called.\n"); +#endif + + HDassert(f1->s3r_handle != NULL); + HDassert(f2->s3r_handle != NULL); + + purl1 = (const parsed_url_t *)f1->s3r_handle->purl; + purl2 = (const parsed_url_t *)f2->s3r_handle->purl; + HDassert(purl1 != NULL); + HDassert(purl2 != NULL); + HDassert(purl1->scheme != NULL); + HDassert(purl2->scheme != NULL); + HDassert(purl1->host != NULL); + HDassert(purl2->host != NULL); + + /* URL: SCHEME */ + if (strcmp(purl1->scheme, purl2->scheme)) HGOTO_DONE(-1); + + /* URL: HOST */ + if (strcmp(purl1->host, purl2->host)) HGOTO_DONE(-1); + + /* URL: PORT */ + if (purl1->port && purl2->port) { + if (strcmp(purl1->port, purl2->port)) HGOTO_DONE(-1); + } else if (purl1->port) { + HGOTO_DONE(-1); + } else if (purl2->port) { + HGOTO_DONE(-1); + } + + /* URL: PATH */ + if (purl1->path && purl2->path) { + if (strcmp(purl1->path, purl2->path)) HGOTO_DONE(-1); + } else if (purl1->path && !purl2->path) { + HGOTO_DONE(-1); + } else if (purl2->path && !purl1->path) { + HGOTO_DONE(-1); + } + + /* URL: QUERY */ + if (purl1->query && purl2->query) { + if (strcmp(purl1->query, purl2->query)) HGOTO_DONE(-1); + } else if (purl1->query && !purl2->query) { + HGOTO_DONE(-1); + } else if (purl2->query && !purl1->query) { + HGOTO_DONE(-1); + } + + /* FAPL: AWS_REGION */ + if (f1->fa.aws_region[0] != '\0' && f1->fa.aws_region[0] != '\0') { + if (strcmp(f1->fa.aws_region, f2->fa.aws_region)) HGOTO_DONE(-1); + } else if (f1->fa.aws_region[0] != '\0') { + HGOTO_DONE(-1); + } else if (f2->fa.aws_region[0] != '\0') { + HGOTO_DONE(-1); + } + + /* FAPL: SECRET_ID */ + if (f1->fa.secret_id[0] != '\0' && f1->fa.secret_id[0] != '\0') { + if (strcmp(f1->fa.secret_id, f2->fa.secret_id)) HGOTO_DONE(-1); + } else if (f1->fa.secret_id[0] != '\0') { + HGOTO_DONE(-1); + } else if (f2->fa.secret_id[0] != '\0') { + HGOTO_DONE(-1); + } + + /* FAPL: SECRET_KEY */ + if (f1->fa.secret_key[0] != '\0' && f1->fa.secret_key[0] != '\0') { + if (strcmp(f1->fa.secret_key, f2->fa.secret_key)) HGOTO_DONE(-1); + } else if (f1->fa.secret_key[0] != '\0') { + HGOTO_DONE(-1); + } else if (f2->fa.secret_key[0] != '\0') { + HGOTO_DONE(-1); + } +#endif /* H5_HAVE_ROS3_VFD */ + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_ros3_cmp() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_ros3_query + * + * Purpose: Set the flags that this VFL driver is capable of supporting. + * (listed in H5FDpublic.h) + * + * Note that since the ROS3 VFD is read only, most flags + * are irrelevant. + * + * The term "set" is highly misleading... + * stores/copies the supported flags in the out-pointer `flags`. + * + * Return: SUCCEED (Can't fail) + * + * Programmer: John Mainzer + * 9/11/17 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_ros3_query(const H5FD_t H5_ATTR_UNUSED *_file, + unsigned long *flags /* out */) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + +#if ROS3_DEBUG + HDfprintf(stdout, "H5FD_ros3_query() called.\n"); +#endif + + /* Set the VFL feature flags that this driver supports */ + if (flags) { + *flags = 0; + /* OK to perform data sieving for faster raw data reads & writes */ + *flags |= H5FD_FEAT_DATA_SIEVE; + } /* end if */ + + FUNC_LEAVE_NOAPI(SUCCEED) + +} /* H5FD_ros3_query() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_ros3_get_eoa() + * + * Purpose: + * + * Gets the end-of-address marker for the file. The EOA marker + * is the first address past the last byte allocated in the + * format address space. + * + * Return: + * + * The end-of-address marker. + * + * Programmer: Jacob Smith + * 2017-11-02 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static haddr_t +H5FD_ros3_get_eoa(const H5FD_t *_file, + H5FD_mem_t H5_ATTR_UNUSED type) +{ + const H5FD_ros3_t *file = (const H5FD_ros3_t *)_file; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + +#if ROS3_DEBUG + HDfprintf(stdout, "H5FD_ros3_get_eoa() called.\n"); +#endif + + FUNC_LEAVE_NOAPI(file->eoa) + +} /* end H5FD_ros3_get_eoa() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_ros3_set_eoa() + * + * Purpose: + * + * Set the end-of-address marker for the file. + * + * Return: + * + * SUCCEED (can't fail) + * + * Programmer: Jacob Smith + * 2017-11-03 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_ros3_set_eoa(H5FD_t *_file, + H5FD_mem_t H5_ATTR_UNUSED type, + haddr_t addr) +{ + H5FD_ros3_t *file = (H5FD_ros3_t *)_file; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + +#if ROS3_DEBUG + HDfprintf(stdout, "H5FD_ros3_set_eoa() called.\n"); +#endif + + file->eoa = addr; + + FUNC_LEAVE_NOAPI(SUCCEED) + +} /* H5FD_ros3_set_eoa() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_ros3_get_eof() + * + * Purpose: + * + * Returns the end-of-file marker. + * + * Return: + * + * EOF: the first address past the end of the "file", either the + * filesystem file or the HDF5 file. + * + * Programmer: Jacob Smith + * 2017-11-02 + * + *------------------------------------------------------------------------- + */ +static haddr_t +H5FD_ros3_get_eof(const H5FD_t *_file, + H5FD_mem_t H5_ATTR_UNUSED type) +{ + const H5FD_ros3_t *file = (const H5FD_ros3_t *)_file; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + +#if ROS3_DEBUG + HDfprintf(stdout, "H5FD_ros3_get_eof() called.\n"); +#endif + + FUNC_LEAVE_NOAPI(H5FD_s3comms_s3r_get_filesize(file->s3r_handle)) + +} /* end H5FD_ros3_get_eof() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_ros3_get_handle() + * + * Purpose: + * + * Returns the S3 Request handle (s3r_t) of ros3 file driver. + * + * Returns: + * + * SUCCEED/FAIL + * + * Programmer: Jacob Smith + * 2017-11-02 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_ros3_get_handle(H5FD_t *_file, + hid_t H5_ATTR_UNUSED fapl, + void **file_handle) +{ + H5FD_ros3_t *file = (H5FD_ros3_t *)_file; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + +#if ROS3_DEBUG + HDfprintf(stdout, "H5FD_ros3_get_handle() called.\n"); +#endif + + if(!file_handle) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") + + *file_handle = file->s3r_handle; + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* end H5FD_ros3_get_handle() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_ros3_read() + * + * Purpose: + * + * Reads SIZE bytes of data from FILE beginning at address ADDR + * into buffer BUF according to data transfer properties in DXPL_ID. + * + * Return: + * + * Success: `SUCCEED` + * - Result is stored in caller-supplied buffer BUF. + * Failure: `FAIL` + * - Unable to complete read. + * - Contents of buffer `buf` are undefined. + * + * Programmer: Jacob Smith + * 2017-11-?? + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_ros3_read(H5FD_t *_file, + H5FD_mem_t H5_ATTR_UNUSED type, + hid_t H5_ATTR_UNUSED dxpl_id, + haddr_t addr, /* start offset */ + size_t size, /* length of read */ + void *buf) /* out */ +{ + H5FD_ros3_t *file = (H5FD_ros3_t *)_file; + size_t filesize = 0; + herr_t ret_value = SUCCEED; /* Return value */ +#if ROS3_STATS + /* working variables for storing stats */ + ros3_statsbin *bin = NULL; + unsigned bin_i = 0; +#endif /* ROS3_STATS */ + + + FUNC_ENTER_NOAPI_NOINIT + +#if ROS3_DEBUG + HDfprintf(stdout, "H5FD_ros3_read() called.\n"); +#endif + + HDassert(file != NULL); + HDassert(file->s3r_handle != NULL); + HDassert(buf != NULL); + + filesize = H5FD_s3comms_s3r_get_filesize(file->s3r_handle); + + if ((addr > filesize) || ((addr + size) > filesize)) { + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "range exceeds file address") + } + + if (FAIL == H5FD_s3comms_s3r_read(file->s3r_handle, addr, size, buf) ) { + HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "unable to execute read") + } + +#if ROS3_STATS + + /* Find which "bin" this read fits in. Can be "overflow" bin. + */ + for (bin_i = 0; bin_i < ROS3_STATS_BIN_COUNT; bin_i++) { + if ((unsigned long long)size < ros3_stats_boundaries[bin_i]) + break; + } + bin = (type == H5FD_MEM_DRAW) + ? &file->raw[bin_i] + : &file->meta[bin_i]; + + /* Store collected stats in appropriate bin + */ + if (bin->count == 0) { + bin->min = size; + bin->max = size; + } else { + if (size < bin->min) + bin->min = size; + if (size > bin->max) + bin->max = size; + } + bin->count++; + bin->bytes += (unsigned long long)size; + +#endif /* ROS3_STATS */ + + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* end H5FD_ros3_read() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_ros3_write() + * + * Purpose: + * + * Write bytes to file. + * UNSUPPORTED IN READ-ONLY ROS3 VFD. + * + * Return: + * + * FAIL (Not possible with Read-Only S3 file.) + * + * Programmer: Jacob Smith + * 2017-10-23 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_ros3_write(H5FD_t H5_ATTR_UNUSED *_file, + H5FD_mem_t H5_ATTR_UNUSED type, + hid_t H5_ATTR_UNUSED dxpl_id, + haddr_t H5_ATTR_UNUSED addr, + size_t H5_ATTR_UNUSED size, + const void H5_ATTR_UNUSED *buf) +{ + herr_t ret_value = FAIL; + + FUNC_ENTER_NOAPI_NOINIT + +#if ROS3_DEBUG + HDfprintf(stdout, "H5FD_ros3_write() called.\n"); +#endif + + HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, + "cannot write to read-only file.") + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_ros3_write() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_ros3_truncate() + * + * Purpose: + * + * Makes sure that the true file size is the same (or larger) + * than the end-of-address. + * + * NOT POSSIBLE ON READ-ONLY S3 FILES. + * + * Return: + * + * FAIL (Not possible on Read-Only S3 files.) + * + * Programmer: Jacob Smith + * 2017-10-23 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_ros3_truncate(H5FD_t H5_ATTR_UNUSED *_file, + hid_t H5_ATTR_UNUSED dxpl_id, + hbool_t H5_ATTR_UNUSED closing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + +#if ROS3_DEBUG + HDfprintf(stdout, "H5FD_ros3_truncate() called.\n"); +#endif + + HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, + "cannot truncate read-only file.") + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* end H5FD_ros3_truncate() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_ros3_lock() + * + * Purpose: + * + * Place an advisory lock on a file. + * No effect on Read-Only S3 file. + * + * Suggestion: remove lock/unlock from class + * > would result in error at H5FD_[un]lock() (H5FD.c) + * + * Return: + * + * SUCCEED (No-op always succeeds) + * + * Programmer: Jacob Smith + * 2017-11-03 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_ros3_lock(H5FD_t H5_ATTR_UNUSED *_file, + hbool_t H5_ATTR_UNUSED rw) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_LEAVE_NOAPI(SUCCEED) + +} /* end H5FD_ros3_lock() */ + + +/*------------------------------------------------------------------------- + * + * Function: H5FD_ros3_unlock() + * + * Purpose: + * + * Remove the existing lock on the file. + * No effect on Read-Only S3 file. + * + * Return: + * + * SUCCEED (No-op always succeeds) + * + * Programmer: Jacob Smith + * 2017-11-03 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_ros3_unlock(H5FD_t H5_ATTR_UNUSED *_file) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_LEAVE_NOAPI(SUCCEED) + +} /* end H5FD_ros3_unlock() */ + + diff --git a/src/H5FDros3.h b/src/H5FDros3.h new file mode 100644 index 0000000..49e757c --- /dev/null +++ b/src/H5FDros3.h @@ -0,0 +1,105 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Read-Only S3 Virtual File Driver (VFD) * + * Copyright (c) 2017-2018, The HDF Group. * + * * + * All rights reserved. * + * * + * NOTICE: * + * All information contained herein is, and remains, the property of The HDF * + * Group. The intellectual and technical concepts contained herein are * + * proprietary to The HDF Group. Dissemination of this information or * + * reproduction of this material is strictly forbidden unless prior written * + * permission is obtained from The HDF Group. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: John Mainzer + * 2017-10-10 + * + * Purpose: The public header file for the ros3 driver. + */ +#ifndef H5FDros3_H +#define H5FDros3_H + +#define H5FD_ROS3 (H5FD_ros3_init()) + +#ifdef __cplusplus +extern "C" { +#endif + +/**************************************************************************** + * + * Structure: H5FD_ros3_fapl_t + * + * Purpose: + * + * H5FD_ros3_fapl_t is a public structure that is used to pass S3 + * authentication data to the appropriate S3 VFD via the FAPL. A pointer + * to an instance of this structure is a parameter to H5Pset_fapl_ros3() + * and H5Pget_fapl_ros3(). + * + * + * + * `version` (int32_t) + * + * Version number of the H5FD_ros3_fapl_t structure. Any instance passed + * to the above calls must have a recognized version number, or an error + * will be flagged. + * + * This field should be set to H5FD__CURR_ROS3_FAPL_T_VERSION. + * + * `authenticate` (hbool_t) + * + * Flag TRUE or FALSE whether or not requests are to be authenticated + * with the AWS4 algorithm. + * If TRUE, `aws_region`, `secret_id`, and `secret_key` must be populated. + * If FALSE, those three components are unused. + * + * `aws_region` (char[]) + * + * String: name of the AWS "region" of the host, e.g. "us-east-1". + * + * `secret_id` (char[]) + * + * String: "Access ID" for the resource. + * + * `secret_key` (char[]) + * + * String: "Secret Access Key" associated with the ID and resource. + * + * + * + * Programmer: John Mainzer + * + * Changes: + * + * - Add documentation of fields (except `version`) + * --- Jacob Smith 2017-12-04 + * + ****************************************************************************/ + +#define H5FD__CURR_ROS3_FAPL_T_VERSION 1 + +#define H5FD__ROS3_MAX_REGION_LEN 32 +#define H5FD__ROS3_MAX_SECRET_ID_LEN 128 +#define H5FD__ROS3_MAX_SECRET_KEY_LEN 128 + +typedef struct H5FD_ros3_fapl_t { + int32_t version; + hbool_t authenticate; + char aws_region[H5FD__ROS3_MAX_REGION_LEN + 1]; + char secret_id[H5FD__ROS3_MAX_SECRET_ID_LEN + 1]; + char secret_key[H5FD__ROS3_MAX_SECRET_KEY_LEN + 1]; +} H5FD_ros3_fapl_t; + +H5_DLL hid_t H5FD_ros3_init(void); +H5_DLL herr_t H5Pget_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t * fa_out); +H5_DLL herr_t H5Pset_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t * fa); + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef H5FDros3_H */ + + diff --git a/src/H5FDs3comms.c b/src/H5FDs3comms.c new file mode 100644 index 0000000..7caeacb --- /dev/null +++ b/src/H5FDs3comms.c @@ -0,0 +1,3770 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Read-Only S3 Virtual File Driver (VFD) * + * Copyright (c) 2017-2018, The HDF Group. * + * * + * All rights reserved. * + * * + * NOTICE: * + * All information contained herein is, and remains, the property of The HDF * + * Group. The intellectual and technical concepts contained herein are * + * proprietary to The HDF Group. Dissemination of this information or * + * reproduction of this material is strictly forbidden unless prior written * + * permission is obtained from The HDF Group. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/***************************************************************************** + * Source for S3 Communications module + * + * ***NOT A FILE DRIVER*** + * + * Provide functions and structures required for interfacing with Amazon + * Simple Storage Service (S3). + * + * Provide S3 object access as if it were a local file. + * + * Connect to remote host, send and receive HTTP requests and responses + * as part of the AWS REST API, authenticating requests as appropriate. + * + * Programmer: Jacob Smith + * 2017-11-30 + * + *****************************************************************************/ + +/****************/ +/* Module Setup */ +/****************/ + +/***********/ +/* Headers */ +/***********/ + +#include "H5private.h" /* generic functions */ +#include "H5Eprivate.h" /* error handling */ +#include "H5MMprivate.h" /* memory management */ +#include "H5FDs3comms.h" /* S3 Communications */ + +/****************/ +/* Local Macros */ +/****************/ + +/* toggle debugging (enable with 1) + */ +#define S3COMMS_DEBUG 0 + +/* manipulate verbosity of CURL output + * operates separately from S3COMMS_DEBUG + * + * 0 -> no explicit curl output + * 1 -> on error, print failure info to stderr + * 2 -> in addition to above, print information for all performs; sets all + * curl handles with CURLOPT_VERBOSE + */ +#define S3COMMS_CURL_VERBOSITY 0 + +/* size to allocate for "bytes=[-]" HTTP Range value + */ +#define S3COMMS_MAX_RANGE_STRING_SIZE 128 + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Structures */ +/********************/ + +/* struct s3r_datastruct + * Structure passed to curl write callback + * pointer to data region and record of bytes written (offset) + */ +struct s3r_datastruct { + unsigned long magic; + char *data; + size_t size; +}; +#define S3COMMS_CALLBACK_DATASTRUCT_MAGIC 0x28c2b2ul + +/********************/ +/* Local Prototypes */ +/********************/ + +size_t curlwritecallback(char *ptr, + size_t size, + size_t nmemb, + void *userdata); + +herr_t H5FD_s3comms_s3r_getsize(s3r_t *handle); + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*************/ +/* Functions */ +/*************/ + + +/*---------------------------------------------------------------------------- + * + * Function: curlwritecallback() + * + * Purpose: + * + * Function called by CURL to write received data. + * + * Writes bytes to `userdata`. + * + * Internally manages number of bytes processed. + * + * Return: + * + * - Number of bytes processed. + * - Should equal number of bytes passed to callback. + * - Failure will result in curl error: CURLE_WRITE_ERROR. + * + * Programmer: Jacob Smith + * 2017-08-17 + * + * Changes: None. + * + *---------------------------------------------------------------------------- + */ +size_t +curlwritecallback(char *ptr, + size_t size, + size_t nmemb, + void *userdata) +{ + struct s3r_datastruct *sds = (struct s3r_datastruct *)userdata; + size_t product = (size * nmemb); + size_t written = 0; + + if (sds->magic != S3COMMS_CALLBACK_DATASTRUCT_MAGIC) + return written; + + if (size > 0) { + HDmemcpy(&(sds->data[sds->size]), ptr, product); + sds->size += product; + written = product; + } + + return written; + +} /* curlwritecallback */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_hrb_node_set() + * + * Purpose: + * + * Create, insert, modify, and remove elements in a field node list. + * + * `name` cannot be null; will return FAIL and list will be unaltered. + * + * Entries are accessed via the lowercase representation of their name: + * "Host", "host", and "hOSt" would all access the same node, + * but name's case is relevant in HTTP request output. + * + * List pointer `L` must always point to either of : + * - header node with lowest alphabetical order (by lowername) + * - NULL, if list is empty + * + * Types of operations: + * + * - CREATE + * - If `L` is NULL and `name` and `value` are not NULL, + * a new node is created at `L`, starting a list. + * - MODIFY + * - If a node is found with a matching lowercase name and `value` + * is not NULL, the existing name, value, and cat values are released + * and replaced with the new data. + * - No modifications are made to the list pointers. + * - REMOVE + * - If `value` is NULL, will attempt to remove node with matching + * lowercase name. + * - If no match found, returns FAIL and list is not modified. + * - When removing a node, all its resources is released. + * - If removing the last node in the list, list pointer is set to NULL. + * - INSERT + * - If no nodes exists with matching lowercase name and `value` + * is not NULL, a new node is created, inserted into list + * alphabetically by lowercase name. + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - List was successfully modified + * - FAILURE: `FAIL` + * - Unable to perform operation + * - Forbidden (attempting to remove absent node, e.g.) + * - Internal error + * + * Programmer: Jacob Smith + * 2017-09-22 + * + * Changes: + * + * - Change return value to herr_t + * - Change list pointer to pointer-to-pointer-to-node + * - Change to use singly-linked list (from twin doubly-linked lists) + * with modification to hrb_node_t + * --- Jake Smith 2017-01-17 + * + *---------------------------------------------------------------------------- + */ +herr_t +H5FD_s3comms_hrb_node_set(hrb_node_t **L, + const char *name, + const char *value) +{ + size_t i = 0; + char *valuecpy = NULL; + char *namecpy = NULL; + size_t namelen = 0; + char *lowername = NULL; + char *nvcat = NULL; + hrb_node_t *node_ptr = NULL; + hrb_node_t *new_node = NULL; + hbool_t is_looking = TRUE; + herr_t ret_value = SUCCEED; + + + + FUNC_ENTER_NOAPI_NOINIT + +#if S3COMMS_DEBUG + HDfprintf(stdout, "called H5FD_s3comms_hrb_node_set.\n"); + HDprintf("NAME: %s\n", name); + HDprintf("VALUE: %s\n", value); + HDprintf("LIST:\n->"); + for (node_ptr = (*L); node_ptr != NULL; node_ptr = node_ptr->next) + HDfprintf(stdout, "{%s}\n->", node_ptr->cat); + HDprintf("(null)\n"); + fflush(stdout); + node_ptr = NULL; +#endif + + if (name == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to operate on null name.\n"); + } + namelen = HDstrlen(name); + + /*********************** + * PREPARE ALL STRINGS * + **********************/ + + /* copy and lowercase name + */ + lowername = (char *)H5MM_malloc(sizeof(char) * (namelen + 1)); + if (lowername == NULL) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "cannot make space for lowercase name copy.\n"); + } + for (i = 0; i < namelen; i++) { + lowername[i] = (char)tolower((int)name[i]); + } + lowername[namelen] = 0; + + /* If value supplied, copy name, value, and concatenated "name: value". + * If NULL, we will be removing a node or doing nothing, so no need for + * copies + */ + if (value != NULL) { + size_t valuelen = HDstrlen(value); + size_t catlen = namelen + valuelen + 2; /* HDstrlen(": ") -> +2 */ + int sprint_ret = 0; + + namecpy = (char *)H5MM_malloc(sizeof(char) * (namelen + 1)); + if (namecpy == NULL) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "cannot make space for name copy.\n"); + } + HDmemcpy(namecpy, name, namelen + 1); + + valuecpy = (char *)H5MM_malloc(sizeof(char) * (valuelen + 1)); + if (valuecpy == NULL) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "cannot make space for value copy.\n"); + } + HDmemcpy(valuecpy, value, valuelen + 1); + + nvcat = (char *)H5MM_malloc(sizeof(char) * (catlen + 1)); + if (nvcat == NULL) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "cannot make space for concatenated string.\n"); + } + sprint_ret = HDsnprintf(nvcat, (catlen + 1), "%s: %s", name, value); + if (sprint_ret <= 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "error while concatenating `%s: %s", name, value); + HDassert( catlen == (size_t)sprint_ret ); + + /* create new_node, should we need it + */ + new_node = (hrb_node_t *)H5MM_malloc(sizeof(hrb_node_t)); + if (new_node == NULL) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "cannot make space for new set.\n"); + } + + new_node->magic = S3COMMS_HRB_NODE_MAGIC; + new_node->name = NULL; + new_node->value = NULL; + new_node->cat = NULL; + new_node->lowername = NULL; + new_node->next = NULL; + } + + /*************** + * ACT ON LIST * + ***************/ + + if (*L == NULL) { + if (value == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "trying to remove node from empty list"); + } else { +#if S3COMMS_DEBUG +HDprintf("CREATE NEW\n"); fflush(stdout); +#endif + /******************* + * CREATE NEW LIST * + *******************/ + + new_node->cat = nvcat; + new_node->name = namecpy; + new_node->lowername = lowername; + new_node->value = valuecpy; + + *L = new_node; + goto done; /* bypass further seeking */ + } + } + + /* sanity-check pointer passed in + */ + HDassert( (*L) != NULL ); + HDassert( (*L)->magic == S3COMMS_HRB_NODE_MAGIC ); + node_ptr = (*L); + + /* Check whether to modify/remove first node in list + */ + if (strcmp(lowername, node_ptr->lowername) == 0) { + + is_looking = FALSE; + + if (value == NULL) { +#if S3COMMS_DEBUG +HDprintf("REMOVE HEAD\n"); fflush(stdout); +#endif + /*************** + * REMOVE HEAD * + ***************/ + + *L = node_ptr->next; + +#if S3COMMS_DEBUG +HDprintf("FREEING CAT (node)\n"); fflush(stdout); +#endif + H5MM_xfree(node_ptr->cat); +#if S3COMMS_DEBUG +HDprintf("FREEING LOWERNAME (node)\n"); fflush(stdout); +#endif + H5MM_xfree(node_ptr->lowername); +#if S3COMMS_DEBUG +HDprintf("FREEING NAME (node)\n"); fflush(stdout); +#endif + H5MM_xfree(node_ptr->name); +#if S3COMMS_DEBUG +HDprintf("FREEING VALUE (node)\n"); fflush(stdout); +#endif + H5MM_xfree(node_ptr->value); +#if S3COMMS_DEBUG +HDprintf("MAGIC OK? %s\n", + (node_ptr->magic == S3COMMS_HRB_NODE_MAGIC) ? "YES" : "NO"); +fflush(stdout); +#endif + HDassert( node_ptr->magic == S3COMMS_HRB_NODE_MAGIC ); + node_ptr->magic += 1ul; +#if S3COMMS_DEBUG +HDprintf("FREEING POINTER\n"); fflush(stdout); +#endif + H5MM_xfree(node_ptr); + +#if S3COMMS_DEBUG +HDprintf("FREEING WORKING LOWERNAME\n"); fflush(stdout); +#endif + H5MM_xfree(lowername); lowername = NULL; + } else { +#if S3COMMS_DEBUG +HDprintf("MODIFY HEAD\n"); fflush(stdout); +#endif + /*************** + * MODIFY HEAD * + ***************/ + + H5MM_xfree(node_ptr->cat); + H5MM_xfree(node_ptr->name); + H5MM_xfree(node_ptr->value); + + node_ptr->name = namecpy; + node_ptr->value = valuecpy; + node_ptr->cat = nvcat; + + H5MM_xfree(lowername); + lowername = NULL; + new_node->magic += 1ul; + H5MM_xfree(new_node); + new_node = NULL; + } + } else if (strcmp(lowername, node_ptr->lowername) < 0) { + + is_looking = FALSE; + + if (value == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "trying to remove a node 'before' head"); + } else { +#if S3COMMS_DEBUG +HDprintf("PREPEND NEW HEAD\n"); fflush(stdout); +#endif + /******************* + * INSERT NEW HEAD * + *******************/ + + new_node->name = namecpy; + new_node->value = valuecpy; + new_node->lowername = lowername; + new_node->cat = nvcat; + new_node->next = node_ptr; + *L = new_node; + } + } + + /*************** + * SEARCH LIST * + ***************/ + + while (is_looking) { + if (node_ptr->next == NULL) { + + is_looking = FALSE; + + if (value == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "trying to remove absent node"); + } else { +#if S3COMMS_DEBUG +HDprintf("APPEND A NODE\n"); fflush(stdout); +#endif + /******************* + * APPEND NEW NODE * + *******************/ + + HDassert( strcmp(lowername, node_ptr->lowername) > 0 ); + new_node->name = namecpy; + new_node->value = valuecpy; + new_node->lowername = lowername; + new_node->cat = nvcat; + node_ptr->next = new_node; + } + } else if (strcmp(lowername, node_ptr->next->lowername) < 0) { + + is_looking = FALSE; + + if (value == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "trying to remove absent node"); + } else { +#if S3COMMS_DEBUG +HDprintf("INSERT A NODE\n"); fflush(stdout); +#endif + /******************* + * INSERT NEW NODE * + *******************/ + + HDassert( strcmp(lowername, node_ptr->lowername) > 0 ); + new_node->name = namecpy; + new_node->value = valuecpy; + new_node->lowername = lowername; + new_node->cat = nvcat; + new_node->next = node_ptr->next; + node_ptr->next = new_node; + } + } else if (strcmp(lowername, node_ptr->next->lowername) == 0) { + + is_looking = FALSE; + + if (value == NULL) { + /***************** + * REMOVE A NODE * + *****************/ + + hrb_node_t *tmp = node_ptr->next; + node_ptr->next = tmp->next; + +#if S3COMMS_DEBUG +HDprintf("REMOVE A NODE\n"); fflush(stdout); +#endif + H5MM_xfree(tmp->cat); + H5MM_xfree(tmp->lowername); + H5MM_xfree(tmp->name); + H5MM_xfree(tmp->value); + + HDassert( tmp->magic == S3COMMS_HRB_NODE_MAGIC ); + tmp->magic += 1ul; + H5MM_xfree(tmp); + + H5MM_xfree(lowername); + lowername = NULL; + } else { +#if S3COMMS_DEBUG +HDprintf("MODIFY A NODE\n"); fflush(stdout); +#endif + /***************** + * MODIFY A NODE * + *****************/ + + node_ptr = node_ptr->next; + H5MM_xfree(node_ptr->name); + H5MM_xfree(node_ptr->value); + H5MM_xfree(node_ptr->cat); + + HDassert( new_node->magic == S3COMMS_HRB_NODE_MAGIC ); + new_node->magic += 1ul; + H5MM_xfree(new_node); + H5MM_xfree(lowername); + new_node = NULL; + lowername = NULL; + + node_ptr->name = namecpy; + node_ptr->value = valuecpy; + node_ptr->cat = nvcat; + } + } else { + /**************** + * KEEP LOOKING * + ****************/ + + node_ptr = node_ptr->next; + } + } + +done: + if (ret_value == FAIL) { + /* clean up + */ + if (nvcat != NULL) H5MM_xfree(nvcat); + if (namecpy != NULL) H5MM_xfree(namecpy); + if (lowername != NULL) H5MM_xfree(lowername); + if (valuecpy != NULL) H5MM_xfree(valuecpy); + if (new_node != NULL) { + HDassert( new_node->magic == S3COMMS_HRB_NODE_MAGIC ); + new_node->magic += 1ul; + H5MM_xfree(new_node); + } + } + + FUNC_LEAVE_NOAPI(ret_value); + +} /* H5FD_s3comms_hrb_node_set */ + + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_hrb_destroy() + * + * Purpose: + * + * Destroy and free resources _directly_ associated with an HTTP Buffer. + * + * Takes a pointer to pointer to the buffer structure. + * This allows for the pointer itself to be NULLed from within the call. + * + * If buffer or buffer pointer is NULL, there is no effect. + * + * Headers list at `first_header` is not touched. + * + * - Programmer should re-use or destroy `first_header` pointer + * (hrb_node_t *) as suits their purposes. + * - Recommend fetching prior to destroy() + * e.g., `reuse_node = hrb_to_die->first_header; destroy(hrb_to_die);` + * or maintaining an external reference. + * - Destroy node/list separately as appropriate + * - Failure to account for this will result in a memory leak. + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - successfully released buffer resources + * - if `buf` is NULL or `*buf` is NULL, no effect + * - FAILURE: `FAIL` + * - `buf->magic != S3COMMS_HRB_MAGIC` + * + * Programmer: Jacob Smith + * 2017-07-21 + * + * Changes: + * + * - Conditional free() of `hrb_node_t` pointer properties based on + * `which_free` property. + * --- Jacob Smith 2017-08-08 + * + * - Integrate with HDF5. + * - Returns herr_t instead of nothing. + * --- Jacob Smith 2017-09-21 + * + * - Change argument to from *buf to **buf, to null pointer within call + * --- Jacob Smith 2017-20-05 + * + *---------------------------------------------------------------------------- + */ +herr_t +H5FD_s3comms_hrb_destroy(hrb_t **_buf) +{ + hrb_t *buf = NULL; + herr_t ret_value = SUCCEED; + + + + FUNC_ENTER_NOAPI_NOINIT + +#if S3COMMS_DEBUG + HDfprintf(stdout, "called H5FD_s3comms_hrb_destroy.\n"); +#endif + + if (_buf != NULL && *_buf != NULL) { + buf = *_buf; + if (buf->magic != S3COMMS_HRB_MAGIC) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "pointer's magic does not match.\n"); + } + + H5MM_xfree(buf->verb); + H5MM_xfree(buf->version); + H5MM_xfree(buf->resource); + buf->magic += 1ul; + H5MM_xfree(buf); + *_buf = NULL; + } + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_s3comms_hrb_destroy */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_hrb_init_request() + * + * Purpose: + * + * Create a new HTTP Request Buffer + * + * All non-null arguments should be null-terminated strings. + * + * If `verb` is NULL, defaults to "GET". + * If `http_version` is NULL, defaults to "HTTP/1.1". + * + * `resource` cannot be NULL; should be string beginning with slash + * character ('/'). + * + * All strings are copied into the structure, making them safe from + * modification in source strings. + * + * Return: + * + * - SUCCESS: pointer to new `hrb_t` + * - FAILURE: `NULL` + * + * Programmer: Jacob Smith + * 2017-07-21 + * + * Changes: + * + * - Update struct membership for newer 'generic' `hrb_t` format. + * --- Jacob Smith, 2017-07-24 + * + * - Rename from `hrb_new()` to `hrb_request()` + * --- Jacob Smith, 2017-07-25 + * + * - Integrate with HDF5. + * - Rename from 'hrb_request()` to `H5FD_s3comms_hrb_init_request()`. + * - Remove `host` from input parameters. + * - Host, as with all other fields, must now be added through the + * add-field functions. + * - Add `version` (HTTP version string, e.g. "HTTP/1.1") to parameters. + * --- Jacob Smith 2017-09-20 + * + * - Update to use linked-list `hrb_node_t` headers in structure. + * --- Jacob Smith 2017-10-05 + * + *---------------------------------------------------------------------------- + */ +hrb_t * +H5FD_s3comms_hrb_init_request(const char *_verb, + const char *_resource, + const char *_http_version) +{ + hrb_t *request = NULL; + char *res = NULL; + size_t reslen = 0; + hrb_t *ret_value = NULL; + char *verb = NULL; + size_t verblen = 0; + char *vrsn = NULL; + size_t vrsnlen = 0; + + + + FUNC_ENTER_NOAPI_NOINIT + +#if S3COMMS_DEBUG + HDfprintf(stdout, "called H5FD_s3comms_hrb_init_request.\n"); +#endif + + if (_resource == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "resource string cannot be null.\n"); + } + + /* populate valid NULLs with defaults + */ + if (_verb == NULL) + _verb = "GET"; + + if (_http_version == NULL) + _http_version = "HTTP/1.1"; + + /* malloc space for and prepare structure + */ + request = (hrb_t *)H5MM_malloc(sizeof(hrb_t)); + if (request == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, + "no space for request structure"); + } + request->magic = S3COMMS_HRB_MAGIC; + request->body = NULL; + request->body_len = 0; + request->first_header = NULL; + + + + /* malloc and copy strings for the structure + */ + if (_resource[0] == '/') { + reslen = HDstrlen(_resource) + 1; + res = (char *)H5MM_malloc(sizeof(char) * reslen); + if (res == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, + "no space for resource string"); + } + HDstrncpy(res, _resource, reslen); + } else { + int sprint_ret = 0; + reslen = HDstrlen(_resource) + 2; + res = (char *)H5MM_malloc(sizeof(char) * reslen); + if (res == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, + "no space for resource string"); + } + sprint_ret = HDsnprintf(res, reslen, "/%s", _resource); + if (sprint_ret <= 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "errro while appending resource string %s", _resource); + HDassert( (reslen - 1) == (size_t)sprint_ret ); + } /* start resource string with '/' */ + + verblen = HDstrlen(_verb) + 1; + verb = (char *)H5MM_malloc(sizeof(char) * verblen); + if (verb == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "no space for verb string"); + } + HDstrncpy(verb, _verb, verblen); + + vrsnlen = HDstrlen(_http_version) + 1; + vrsn = (char *)H5MM_malloc(sizeof(char) * vrsnlen); + if (vrsn == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "no space for http-version string"); + } + HDstrncpy(vrsn, _http_version, vrsnlen); + + + + /* place new copies into structure + */ + request->resource = res; + request->verb = verb; + request->version = vrsn; + + ret_value = request; + +done: + + /* if there is an error, clean up after ourselves + */ + if (ret_value == NULL) { + if (request != NULL) H5MM_xfree(request); + if (vrsn != NULL) H5MM_xfree(vrsn); + if (verb != NULL) H5MM_xfree(verb); + if (res != NULL) H5MM_xfree(res); + } + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_s3comms_hrb_init_request */ + + + +/**************************************************************************** + * S3R FUNCTIONS + ****************************************************************************/ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_s3r_close() + * + * Purpose: + * + * Close communications through given S3 Request Handle (`s3r_t`) + * and clean up associated resources. + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - FAILURE: `FAIL` + * - fails if handle is null or has invalid magic number + * + * + * Programmer: Jacob Smith + * 2017-08-31 + * + * Changes: + * + * - Remove all messiness related to the now-gone "setopt" utility + * as it no longer exists in the handle. + * - Return type to `void`. + * --- Jacob Smith 2017-09-01 + * + * - Incorporate into HDF environment. + * - Rename from `s3r_close()` to `H5FD_s3comms_s3r_close()`. + * --- Jacob Smith 2017-10-06 + * + * - Change separate host, resource, port info to `parsed_url_t` struct ptr. + * --- Jacob Smith 2017-11-01 + * + *---------------------------------------------------------------------------- + */ +herr_t +H5FD_s3comms_s3r_close(s3r_t *handle) +{ + herr_t ret_value = SUCCEED; + + + + FUNC_ENTER_NOAPI_NOINIT + +#ifdef H5_HAVE_ROS3_VFD +#if S3COMMS_DEBUG + HDfprintf(stdout, "called H5FD_s3comms_s3r_close.\n"); +#endif + + if (handle == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "handle cannot be null.\n"); + } + if (handle->magic != S3COMMS_S3R_MAGIC) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "handle has invalid magic.\n"); + } + + curl_easy_cleanup(handle->curlhandle); + + H5MM_xfree(handle->secret_id); + H5MM_xfree(handle->region); + H5MM_xfree(handle->signing_key); + + HDassert( handle->httpverb != NULL ); + H5MM_xfree(handle->httpverb); + + if (FAIL == H5FD_s3comms_free_purl(handle->purl)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to release parsed url structure") + } + + H5MM_xfree(handle); + +#endif /* H5_HAVE_ROS3_VFD */ + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_s3comms_s3r_close */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_s3r_get_filesize() + * + * Purpose: + * + * Retrieve the filesize of an open request handle. + * + * Wrapper "getter" to hide implementation details. + * + * + * Return: + * + * - SUCCESS: size of file, in bytes, if handle is valid. + * - FAILURE: 0, if handle is NULL or undefined. + * + * Programmer: Jacob Smith 2017-01-14 + * + * Changes: None + * + *---------------------------------------------------------------------------- + */ +size_t +H5FD_s3comms_s3r_get_filesize(s3r_t *handle) { + + size_t ret_value = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + +#ifdef H5_HAVE_ROS3_VFD + if (handle != NULL) + ret_value = handle->filesize; +#endif /* H5_HAVE_ROS3_VFD */ + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_s3comms_s3r_get_filesize */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_s3r_getsize() + * + * Purpose: + * + * Get the number of bytes of handle's target resource. + * + * Sets handle and curlhandle with to enact an HTTP HEAD request on file, + * and parses received headers to extract "Content-Length" from response + * headers, storing file size at `handle->filesize`. + * + * Critical step in opening (initiating) an `s3r_t` handle. + * + * Wraps `s3r_read()`. + * Sets curlhandle to write headers to a temporary buffer (using extant + * write callback) and provides no buffer for body. + * + * Upon exit, unsets HTTP HEAD settings from curl handle, returning to + * initial state. In event of error, curl handle state is undefined and is + * not to be trusted. + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - FAILURE: `FAIL` + * + * Programmer: Jacob Smith + * 2017-08-23 + * + * Changes: + * + * - Update to revised `s3r_t` format and life cycle. + * --- Jacob Smith 2017-09-01 + * + * - Conditional change to static header buffer and structure. + * --- Jacob Smith 2017-09-05 + * + * - Incorporate into HDF environment. + * - Rename from `s3r_getsize()` to `H5FD_s3comms_s3r_getsize()`. + * --- Jacob Smith 2017-10-06 + * + *---------------------------------------------------------------------------- + */ +herr_t +H5FD_s3comms_s3r_getsize(s3r_t *handle) +{ +#ifdef H5_HAVE_ROS3_VFD + unsigned long int content_length = 0; + CURL *curlh = NULL; + char *end = NULL; + char *headerresponse = NULL; + herr_t ret_value = SUCCEED; + struct s3r_datastruct sds = { + S3COMMS_CALLBACK_DATASTRUCT_MAGIC, + NULL, + 0 }; + char *start = NULL; +#else + herr_t ret_value = FAIL; +#endif /* H5_HAVE_ROS3_VFD */ + + + + FUNC_ENTER_NOAPI_NOINIT + +#ifdef H5_HAVE_ROS3_VFD + +#if S3COMMS_DEBUG + HDfprintf(stdout, "called H5FD_s3comms_s3r_getsize.\n"); +#endif + + if (handle == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "handle cannot be null.\n"); + } + if (handle->magic != S3COMMS_S3R_MAGIC) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "handle has invalid magic.\n"); + } + if (handle->curlhandle == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "handle has bad (null) curlhandle.\n") + } + + /******************** + * PREPARE FOR HEAD * + ********************/ + + curlh = handle->curlhandle; + + if ( CURLE_OK != + curl_easy_setopt(curlh, + CURLOPT_NOBODY, + 1L) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "error while setting CURL option (CURLOPT_NOBODY). " + "(placeholder flags)"); + } + + if ( CURLE_OK != + curl_easy_setopt(curlh, + CURLOPT_HEADERDATA, + &sds) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "error while setting CURL option (CURLOPT_HEADERDATA). " + "(placeholder flags)"); + } + + HDassert( handle->httpverb == NULL ); + handle->httpverb = (char *)H5MM_malloc(sizeof(char) * 16); + if (handle->httpverb == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, + "unable to allocate space for S3 request HTTP verb"); + } + HDmemcpy(handle->httpverb, "HEAD", 5); + + headerresponse = (char *)H5MM_malloc(sizeof(char) * CURL_MAX_HTTP_HEADER); + if (headerresponse == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, + "unable to allocate space for curl header response"); + } + sds.data = headerresponse; + + /******************* + * PERFORM REQUEST * + *******************/ + + /* these parameters fetch the entire file, + * but, with a NULL destination and NOBODY and HEADERDATA supplied above, + * only http metadata will be sent by server and recorded by s3comms + */ + if (FAIL == + H5FD_s3comms_s3r_read(handle, 0, 0, NULL) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "problem in reading during getsize.\n"); + } + + if (sds.size > CURL_MAX_HTTP_HEADER) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "HTTP metadata buffer overrun\n"); + } else if (sds.size == 0) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "No HTTP metadata\n"); +#if S3COMMS_DEBUG + } else { + HDfprintf(stderr, "GETSIZE: OK\n"); +#endif + } + + + /****************** + * PARSE RESPONSE * + ******************/ + + start = strstr(headerresponse, + "\r\nContent-Length: "); + if (start == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "could not find \"Content-Length\" in response.\n"); + } + + /* move "start" to beginning of value in line; find end of line + */ + start = start + HDstrlen("\r\nContent-Length: "); + end = strstr(start, "\r\n"); + if (end == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "could not find end of content length line"); + } + + /* place null terminator at end of numbers + */ + *end = '\0'; + + content_length = strtoul((const char *)start, + NULL, + 0); + if (content_length == 0 || + content_length == ULONG_MAX || + errno == ERANGE) /* errno set by strtoul */ + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "could not convert found \"Content-Length\" response (\"%s\")", + start); /* range is null-terminated, remember */ + } + + handle->filesize = (size_t)content_length; + + /********************** + * UNDO HEAD SETTINGS * + **********************/ + + if ( CURLE_OK != + curl_easy_setopt(curlh, + CURLOPT_NOBODY, + 0) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "error while setting CURL option (CURLOPT_NOBODY). " + "(placeholder flags)"); + } + + if ( CURLE_OK != + curl_easy_setopt(curlh, + CURLOPT_HEADERDATA, + 0) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "error while setting CURL option (CURLOPT_HEADERDATA). " + "(placeholder flags)"); + } + +done: + H5MM_xfree(headerresponse); + sds.magic += 1; /* set to bad magic */ + +#endif /* H5_HAVE_ROS3_VFD */ + + FUNC_LEAVE_NOAPI(ret_value); + +} /* H5FD_s3comms_s3r_getsize */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_s3r_open() + * + * Purpose: + * + * Logically 'open' a file hosted on S3. + * + * - create new Request Handle + * - copy supplied url + * - copy authentication info if supplied + * - create CURL handle + * - fetch size of file + * - connect with server and execute HEAD request + * - return request handle ready for reads + * + * To use 'default' port to connect, `port` should be 0. + * + * To prevent AWS4 authentication, pass null pointer to `region`, `id`, + * and `signing_key`. + * + * Uses `H5FD_s3comms_parse_url()` to validate and parse url input. + * + * Return: + * + * - SUCCESS: Pointer to new request handle. + * - FAILURE: NULL + * - occurs if: + * - authentication strings are inconsistent + * - must _all_ be null, or have at least `region` and `id` + * - url is NULL (no filename) + * - unable to parse url (malformed?) + * - error while performing `getsize()` + * + * Programmer: Jacob Smith + * 2017-09-01 + * + * Changes: + * + * - Incorporate into HDF environment. + * - Rename from `s3r_open()` to `H5FD_s3comms_s3r_open()`. + * --- Jacob Smith 2017-10-06 + * + * - Remove port number from signature. + * - Name (`url`) must be complete url with http scheme and optional port + * number in string. + * - e.g., "http://bucket.aws.com:9000/myfile.dat?query=param" + * - Internal storage of host, resource, and port information moved into + * `parsed_url_t` struct pointer. + * --- Jacob Smith 2017-11-01 + * + *---------------------------------------------------------------------------- + */ +s3r_t * +H5FD_s3comms_s3r_open(const char *url, + const char *region, + const char *id, + const unsigned char *signing_key) +{ +#ifdef H5_HAVE_ROS3_VFD + size_t tmplen = 0; + CURL *curlh = NULL; + s3r_t *handle = NULL; + parsed_url_t *purl = NULL; +#endif + s3r_t *ret_value = NULL; + + + + FUNC_ENTER_NOAPI_NOINIT + +#ifdef H5_HAVE_ROS3_VFD + +#if S3COMMS_DEBUG + HDfprintf(stdout, "called H5FD_s3comms_s3r_open.\n"); +#endif + + + + if (url == NULL || url[0] == '\0') { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "url cannot be null.\n"); + } + + if (FAIL == H5FD_s3comms_parse_url(url, &purl)) { + /* probably a malformed url, but could be internal error */ + HGOTO_ERROR(H5E_ARGS, H5E_CANTCREATE, NULL, + "unable to create parsed url structure"); + } + HDassert( purl != NULL ); /* if above passes, this must be true */ + HDassert( purl->magic == S3COMMS_PARSED_URL_MAGIC ); + + handle = (s3r_t *)H5MM_malloc(sizeof(s3r_t)); + if (handle == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, + "could not malloc space for handle.\n"); + } + + handle->magic = S3COMMS_S3R_MAGIC; + handle->purl = purl; + handle->filesize = 0; + handle->region = NULL; + handle->secret_id = NULL; + handle->signing_key = NULL; + handle->httpverb = NULL; + + /************************************* + * RECORD AUTHENTICATION INFORMATION * + *************************************/ + + if ((region != NULL && *region != '\0') || + (id != NULL && *id != '\0') || + (signing_key != NULL && *signing_key != '\0')) + { + /* if one exists, all three must exist + */ + if (region == NULL || region[0] == '\0') { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "region cannot be null.\n"); + } + if (id == NULL || id[0] == '\0') { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "secret id cannot be null.\n"); + } + if (signing_key == NULL || signing_key[0] == '\0') { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "signing key cannot be null.\n"); + } + + /* copy strings + */ + tmplen = HDstrlen(region) + 1; + handle->region = (char *)H5MM_malloc(sizeof(char) * tmplen); + if (handle->region == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "could not malloc space for handle region copy.\n"); + } + HDmemcpy(handle->region, region, tmplen); + + tmplen = HDstrlen(id) + 1; + handle->secret_id = (char *)H5MM_malloc(sizeof(char) * tmplen); + if (handle->secret_id == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "could not malloc space for handle ID copy.\n"); + } + HDmemcpy(handle->secret_id, id, tmplen); + + tmplen = SHA256_DIGEST_LENGTH; + handle->signing_key = + (unsigned char *)H5MM_malloc(sizeof(unsigned char) * tmplen); + if (handle->signing_key == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "could not malloc space for handle key copy.\n"); + } + HDmemcpy(handle->signing_key, signing_key, tmplen); + } /* if authentication information provided */ + + /************************ + * INITIATE CURL HANDLE * + ************************/ + + curlh = curl_easy_init(); + + if (curlh == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "problem creating curl easy handle!\n"); + } + + if ( CURLE_OK != + curl_easy_setopt(curlh, + CURLOPT_HTTPGET, + 1L) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "error while setting CURL option (CURLOPT_HTTPGET). " + "(placeholder flags)"); + } + + if ( CURLE_OK != + curl_easy_setopt(curlh, + CURLOPT_HTTP_VERSION, + CURL_HTTP_VERSION_1_1) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "error while setting CURL option (CURLOPT_HTTP_VERSION). " + "(placeholder flags)"); + } + + if ( CURLE_OK != + curl_easy_setopt(curlh, + CURLOPT_FAILONERROR, + 1L) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "error while setting CURL option (CURLOPT_FAILONERROR). " + "(placeholder flags)"); + } + + if ( CURLE_OK != + curl_easy_setopt(curlh, + CURLOPT_WRITEFUNCTION, + curlwritecallback) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "error while setting CURL option (CURLOPT_WRITEFUNCTION). " + "(placeholder flags)"); + } + + if ( CURLE_OK != + curl_easy_setopt(curlh, + CURLOPT_URL, + url) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "error while setting CURL option (CURLOPT_URL). " + "(placeholder flags)"); + } + +#if S3COMMS_CURL_VERBOSITY > 1 + /* CURL will print (to stdout) information for each operation + */ + curl_easy_setopt(curlh, CURLOPT_VERBOSE, 1L); +#endif + + handle->curlhandle = curlh; + + /******************* + * OPEN CONNECTION * + * * * * * * * * * * + * GET FILE SIZE * + *******************/ + + if (FAIL == + H5FD_s3comms_s3r_getsize(handle) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "problem in H5FD_s3comms_s3r_getsize.\n"); + } + + /********************* + * FINAL PREPARATION * + *********************/ + + HDassert( handle->httpverb != NULL ); + HDmemcpy(handle->httpverb, "GET", 4); + + ret_value = handle; +#endif /* H5_HAVE_ROS3_VFD */ + +done: + if (ret_value == NULL) { +#ifdef H5_HAVE_ROS3_VFD + if (curlh != NULL) { + curl_easy_cleanup(curlh); + } + if (FAIL == H5FD_s3comms_free_purl(purl)) { + HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "unable to free parsed url structure") + } + if (handle != NULL) { + H5MM_xfree(handle->region); + H5MM_xfree(handle->secret_id); + H5MM_xfree(handle->signing_key); + if (handle->httpverb != NULL) { + H5MM_xfree(handle->httpverb); + } + H5MM_xfree(handle); + } +#endif /* H5_HAVE_ROS3_VFD */ + } + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_s3comms_s3r_open */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_s3r_read() + * + * Purpose: + * + * Read file pointed to by request handle, writing specified + * `offset` .. `offset + len` bytes to buffer `dest`. + * + * If `len` is 0, reads entirety of file starting at `offset`. + * If `offset` and `len` are both 0, reads entire file. + * + * If `offset` or `offset+len` is greater than the file size, read is + * aborted and returns `FAIL`. + * + * Uses configured "curl easy handle" to perform request. + * + * In event of error, buffer should remain unaltered. + * + * If handle is set to authorize a request, creates a new (temporary) + * HTTP Request object (hrb_t) for generating requisite headers, + * which is then translated to a `curl slist` and set in the curl handle + * for the request. + * + * `dest` _may_ be NULL, but no body data will be recorded. + * + * - In general practice, NULL should never be passed in as `dest`. + * - NULL `dest` passed in by internal function `s3r_getsize()`, in + * conjunction with CURLOPT_NOBODY to preempt transmission of file data + * from server. + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - FAILURE: `FAIL` + * + * Programmer: Jacob Smith + * 2017-08-22 + * + * Changes: + * + * - Revise structure to prevent unnecessary hrb_t element creation. + * - Rename tmprstr -> rangebytesstr to reflect purpose. + * - Insert needed `free()`s, particularly for `sds`. + * --- Jacob Smith 2017-08-23 + * + * - Revise heavily to accept buffer, range as parameters. + * - Utilize modified s3r_t format. + * --- Jacob Smith 2017-08-31 + * + * - Incorporate into HDF library. + * - Rename from `s3r_read()` to `H5FD_s3comms_s3r_read()`. + * - Return `herr_t` succeed/fail instead of S3code. + * - Update to use revised `hrb_t` and `hrb_node_t` structures. + * --- Jacob Smith 2017-10-06 + * + * - Update to use `parsed_url_t *purl` in handle. + * --- Jacob Smith 2017-11-01 + * + * - Better define behavior upon read past EOF + * --- Jacob Smith 2017-01-19 + * + *---------------------------------------------------------------------------- + */ +herr_t +H5FD_s3comms_s3r_read(s3r_t *handle, + haddr_t offset, + size_t len, + void *dest) +{ +#ifdef H5_HAVE_ROS3_VFD + CURL *curlh = NULL; + CURLcode p_status = CURLE_OK; + struct curl_slist *curlheaders = NULL; + hrb_node_t *headers = NULL; + hrb_node_t *node = NULL; + struct tm *now = NULL; + char *rangebytesstr = NULL; + hrb_t *request = NULL; + int ret = 0; /* working variable to check */ + /* return value of HDsnprintf */ + struct s3r_datastruct *sds = NULL; + herr_t ret_value = SUCCEED; +#else + herr_t ret_value = FAIL; +#endif /* H5_HAVE_ROS3_VFD */ + + + + FUNC_ENTER_NOAPI_NOINIT + +#ifdef H5_HAVE_ROS3_VFD + +#if S3COMMS_DEBUG + HDfprintf(stdout, "called H5FD_s3comms_s3r_read.\n"); +#endif + + /************************************** + * ABSOLUTELY NECESSARY SANITY-CHECKS * + **************************************/ + + if (handle == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "handle cannot be null.\n"); + } + if (handle->magic != S3COMMS_S3R_MAGIC) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "handle has invalid magic.\n"); + } + if (handle->curlhandle == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "handle has bad (null) curlhandle.\n") + } + if (handle->purl == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "handle has bad (null) url.\n") + } + HDassert( handle->purl->magic == S3COMMS_PARSED_URL_MAGIC ); + if (offset > handle->filesize || (len + offset) > handle->filesize) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to read past EoF") + } + + curlh = handle->curlhandle; + + /********************* + * PREPARE WRITEDATA * + *********************/ + + if (dest != NULL) { + sds = (struct s3r_datastruct *)H5MM_malloc( + sizeof(struct s3r_datastruct)); + if (sds == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, + "could not malloc destination datastructure.\n"); + } + + sds->magic = S3COMMS_CALLBACK_DATASTRUCT_MAGIC; + sds->data = (char *)dest; + sds->size = 0; + if (CURLE_OK != + curl_easy_setopt(curlh, + CURLOPT_WRITEDATA, + sds) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, + "error while setting CURL option (CURLOPT_WRITEDATA). " + "(placeholder flags)"); + } + } + + /********************* + * FORMAT HTTP RANGE * + *********************/ + + if (len > 0) { + rangebytesstr = (char *)H5MM_malloc(sizeof(char) * \ + S3COMMS_MAX_RANGE_STRING_SIZE ); + if (rangebytesstr == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, + "could not malloc range format string.\n"); + } + ret = HDsnprintf(rangebytesstr, + (S3COMMS_MAX_RANGE_STRING_SIZE), + "bytes="H5_PRINTF_HADDR_FMT"-"H5_PRINTF_HADDR_FMT, + offset, + offset + len - 1); + if (ret == 0 || ret >= S3COMMS_MAX_RANGE_STRING_SIZE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to format HTTP Range value"); + } else if (offset > 0) { + rangebytesstr = (char *)H5MM_malloc(sizeof(char) * \ + S3COMMS_MAX_RANGE_STRING_SIZE); + if (rangebytesstr == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, + "could not malloc range format string.\n"); + } + ret = HDsnprintf(rangebytesstr, + (S3COMMS_MAX_RANGE_STRING_SIZE), + "bytes="H5_PRINTF_HADDR_FMT"-", + offset); + if (ret == 0 || ret >= S3COMMS_MAX_RANGE_STRING_SIZE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to format HTTP Range value"); + } + + /******************* + * COMPILE REQUEST * + *******************/ + + if (handle->signing_key == NULL) { + /* Do not authenticate. + */ + if (rangebytesstr != NULL) { + /* Pass in range directly + */ + char *bytesrange_ptr = NULL; /* pointer past "bytes=" portion */ + + bytesrange_ptr = strchr(rangebytesstr, '='); + HDassert( bytesrange_ptr != NULL ); + bytesrange_ptr++; /* move to first char past '=' */ + HDassert( *bytesrange_ptr != '\0' ); + + if (CURLE_OK != + curl_easy_setopt(curlh, + CURLOPT_RANGE, + bytesrange_ptr) ) + { + HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, + "error while setting CURL option (CURLOPT_RANGE). "); + } + } + } else { + /* authenticate request + */ + char authorization[512]; + /* 512 := approximate max length... + * 67 + * + 8 + * + 64 + * + 128 + * + 20 + * + 128 + */ + char buffer1[512]; /* -> Canonical Request -> Signature */ + char buffer2[256]; /* -> String To Sign -> Credential */ + char iso8601now[ISO8601_SIZE]; + char signed_headers[48]; + /* should be large enough for nominal listing: + * "host;range;x-amz-content-sha256;x-amz-date" + * + '\0', with "range;" possibly absent + */ + + /* zero start of strings */ + authorization[0] = 0; + buffer1[0] = 0; + buffer2[0] = 0; + iso8601now[0] = 0; + signed_headers[0] = 0; + + /**** VERIFY INFORMATION EXISTS ****/ + + if (handle->region == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "handle must have non-null region.\n"); + } + if (handle->secret_id == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "handle must have non-null secret_id.\n"); + } + if (handle->signing_key == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "handle must have non-null signing_key.\n"); + } + if (handle->httpverb == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "handle must have non-null httpverb.\n"); + } + if (handle->purl->host == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "handle must have non-null host.\n"); + } + if (handle->purl->path == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "handle must have non-null resource.\n"); + } + + /**** CREATE HTTP REQUEST STRUCTURE (hrb_t) ****/ + + request = H5FD_s3comms_hrb_init_request( + (const char *)handle->httpverb, + (const char *)handle->purl->path, + "HTTP/1.1"); + if (request == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "could not allocate hrb_t request.\n"); + } + HDassert( request->magic == S3COMMS_HRB_MAGIC ); + + now = gmnow(); + if (ISO8601NOW(iso8601now, now) != (ISO8601_SIZE - 1)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "could not format ISO8601 time.\n"); + } + + if (FAIL == + H5FD_s3comms_hrb_node_set( + &headers, + "x-amz-date", + (const char *)iso8601now) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to set x-amz-date header") + } + if (headers == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "problem building headers list. " + "(placeholder flags)\n"); + } + HDassert( headers->magic == S3COMMS_HRB_NODE_MAGIC ); + + if (FAIL == + H5FD_s3comms_hrb_node_set( + &headers, + "x-amz-content-sha256", + (const char *)EMPTY_SHA256) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to set x-amz-content-sha256 header") + } + if (headers == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "problem building headers list. " + "(placeholder flags)\n"); + } + HDassert( headers->magic == S3COMMS_HRB_NODE_MAGIC ); + + if (rangebytesstr != NULL) { + if (FAIL == + H5FD_s3comms_hrb_node_set( + &headers, + "Range", + (const char *)rangebytesstr) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to set range header") + } + if (headers == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "problem building headers list. " + "(placeholder flags)\n"); + } + HDassert( headers->magic == S3COMMS_HRB_NODE_MAGIC ); + } + + if (FAIL == + H5FD_s3comms_hrb_node_set( + &headers, + "Host", + (const char *)handle->purl->host) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to set host header") + } + if (headers == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "problem building headers list. " + "(placeholder flags)\n"); + } + HDassert( headers->magic == S3COMMS_HRB_NODE_MAGIC ); + + request->first_header = headers; + + /**** COMPUTE AUTHORIZATION ****/ + + if (FAIL == /* buffer1 -> canonical request */ + H5FD_s3comms_aws_canonical_request(buffer1, + signed_headers, + request) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "(placeholder flags)\n"); + } + if ( FAIL == /* buffer2->string-to-sign */ + H5FD_s3comms_tostringtosign(buffer2, + buffer1, + iso8601now, + handle->region) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "(placeholder flags)\n"); + } + if (FAIL == /* buffer1 -> signature */ + H5FD_s3comms_HMAC_SHA256(handle->signing_key, + SHA256_DIGEST_LENGTH, + buffer2, + HDstrlen(buffer2), + buffer1) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "(placeholder flags)\n"); + } + + iso8601now[8] = 0; /* trim to yyyyMMDD */ + ret = S3COMMS_FORMAT_CREDENTIAL(buffer2, + handle->secret_id, + iso8601now, + handle->region, + "s3"); + if (ret == 0 || ret >= S3COMMS_MAX_CREDENTIAL_SIZE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to format aws4 credential string"); + + ret = HDsnprintf(authorization, + 512, + "AWS4-HMAC-SHA256 Credential=%s,SignedHeaders=%s,Signature=%s", + buffer2, + signed_headers, + buffer1); + if (ret == 0 || ret >= 512) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to format aws4 authorization string"); + + /* append authorization header to http request buffer + */ + if (FAIL == + H5FD_s3comms_hrb_node_set( + &headers, + "Authorization", + (const char *)authorization) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to set Authorization header") + } + if (headers == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "problem building headers list. " + "(placeholder flags)\n"); + } + + /* update hrb's "first header" pointer + */ + request->first_header = headers; + + /**** SET CURLHANDLE HTTP HEADERS FROM GENERATED DATA ****/ + + node = request->first_header; + while (node != NULL) { + HDassert( node->magic == S3COMMS_HRB_NODE_MAGIC ); + curlheaders = curl_slist_append(curlheaders, + (const char *)node->cat); + if (curlheaders == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "could not append header to curl slist. " + "(placeholder flags)\n"); + } + node = node->next; + } + + /* sanity-check + */ + if (curlheaders == NULL) { + /* above loop was probably never run */ + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "curlheaders was never populated.\n"); + } + + /* finally, set http headers in curl handle + */ + if (CURLE_OK != + curl_easy_setopt(curlh, + CURLOPT_HTTPHEADER, + curlheaders) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "error while setting CURL option " + "(CURLOPT_HTTPHEADER). (placeholder flags)"); + } + + } /* if should authenticate (info provided) */ + + /******************* + * PERFORM REQUEST * + *******************/ + +#if S3COMMS_CURL_VERBOSITY > 0 + /* In event of error, print detailed information to stderr + * This is not the default behavior. + */ + { + long int httpcode = 0; + char curlerrbuf[CURL_ERROR_SIZE]; + curlerrbuf[0] = '\0'; + + if (CURLE_OK != + curl_easy_setopt(curlh, CURLOPT_ERRORBUFFER, curlerrbuf) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "problem setting error buffer") + } + + p_status = curl_easy_perform(curlh); + + if (p_status != CURLE_OK) { + if (CURLE_OK != + curl_easy_getinfo(curlh, CURLINFO_RESPONSE_CODE, &httpcode) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "problem getting response code") + } + HDfprintf(stderr, "CURL ERROR CODE: %d\nHTTP CODE: %d\n", + p_status, httpcode); + HDfprintf(stderr, "%s\n", curl_easy_strerror(p_status)); + HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, FAIL, + "problem while performing request.\n"); + } + if (CURLE_OK != + curl_easy_setopt(curlh, CURLOPT_ERRORBUFFER, NULL) ) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "problem unsetting error buffer") + } + } /* verbose error reporting */ +#else + p_status = curl_easy_perform(curlh); + + if (p_status != CURLE_OK) { + HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, FAIL, + "curl cannot perform request\n") + } +#endif + +#if S3COMMS_DEBUG + if (dest != NULL) { + HDfprintf(stderr, "len: %d\n", (int)len); + HDfprintf(stderr, "CHECKING FOR BUFFER OVERFLOW\n"); + if (sds == NULL) { + HDfprintf(stderr, "sds is NULL!\n"); + } else { + HDfprintf(stderr, "sds: 0x%lx\n", (long long)sds); + HDfprintf(stderr, "sds->size: %d\n", (int)sds->size); + if (len > sds->size) { + HDfprintf(stderr, "buffer overwrite\n"); + } + } + } else { + HDfprintf(stderr, "performed on entire file\n"); + } +#endif + +done: + /* clean any malloc'd resources + */ + if (curlheaders != NULL) { + curl_slist_free_all(curlheaders); + curlheaders = NULL; + } + if (rangebytesstr != NULL) { + H5MM_xfree(rangebytesstr); + rangebytesstr = NULL; + } + if (sds != NULL) { + H5MM_xfree(sds); + sds = NULL; + } + if (request != NULL) { + while (headers != NULL) + if (FAIL == + H5FD_s3comms_hrb_node_set(&headers, headers->name, NULL)) + { + HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "cannot release header node") + } + HDassert( NULL == headers ); + if (FAIL == H5FD_s3comms_hrb_destroy(&request)) { + HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "cannot release header request structure") + } + HDassert( NULL == request ); + } + + if (curlh != NULL) { + /* clear any Range */ + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_RANGE, NULL) ) + HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "cannot unset CURLOPT_RANGE") + + /* clear headers */ + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HTTPHEADER, NULL) ) + HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "cannot unset CURLOPT_HTTPHEADER") + } + +#endif /* H5_HAVE_ROS3_VFD */ + + FUNC_LEAVE_NOAPI(ret_value); + +} /* H5FD_s3comms_s3r_read */ + + + +/**************************************************************************** + * MISCELLANEOUS FUNCTIONS + ****************************************************************************/ + + +/*---------------------------------------------------------------------------- + * + * Function: gmnow() + * + * Purpose: + * + * Get the output of `time.h`'s `gmtime()` call while minimizing setup + * clutter where important. + * + * Return: + * + * Pointer to resulting `struct tm`,as created by gmtime(time_t * T). + * + * Programmer: Jacob Smith + * 2017-07-12 + * + * Changes: None. + * + *---------------------------------------------------------------------------- + */ +struct tm * +gmnow(void) +{ + time_t now; + time_t *now_ptr = &now; + struct tm *ret_value = NULL; + + /* Doctor assert, checks against error in time() */ + if ( (time_t)(-1) != time(now_ptr) ) + ret_value = gmtime(now_ptr); + + HDassert( ret_value != NULL ); + + return ret_value; + +} /* gmnow */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_aws_canonical_request() + * + * Purpose: + * + * Compose AWS "Canonical Request" (and signed headers string) + * as defined in the REST API documentation. + * + * Both destination strings are null-terminated. + * + * Destination string arguments must be provided with adequate space. + * + * Canonical Request format: + * + * "\n" + * "\n" + * "\n" + * "\n" (`lowercase(name)`":"`trim(value)`) + * "\n" + * ... (headers sorted by name) + * "\n" + * "\n" + * "\n" (`lowercase(header 1 name)`";"`header 2 name`;...) + * ("e3b0c4429...", e.g.) + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - writes canonical request to respective `...dest` strings + * - FAILURE: `FAIL` + * - one or more input argument was NULL + * - internal error + * + * Programmer: Jacob Smith + * 2017-10-04 + * + * Changes: None. + * + *---------------------------------------------------------------------------- + */ +herr_t +H5FD_s3comms_aws_canonical_request(char *canonical_request_dest, + char *signed_headers_dest, + hrb_t *http_request) +{ + hrb_node_t *node = NULL; + const char *query_params = ""; /* unused at present */ + herr_t ret_value = SUCCEED; + int ret = 0; /* return value of HDsnprintf */ + size_t len = 0; /* working string length variable */ + char tmpstr[256]; + + /* "query params" refers to the optional element in the URL, e.g. + * http://bucket.aws.com/myfile.txt?max-keys=2&prefix=J + * ^-----------------^ + * + * Not handled/implemented as of 2017-10-xx. + * Element introduced as empty placeholder and reminder. + * Further research to be done if this is ever relevant for the + * VFD use-cases. + */ + + + + FUNC_ENTER_NOAPI_NOINIT + +#if S3COMMS_DEBUG + HDfprintf(stdout, "called H5FD_s3comms_aws_canonical_request.\n"); +#endif + + if (http_request == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "hrb object cannot be null.\n"); + } + HDassert( http_request->magic == S3COMMS_HRB_MAGIC ); + + if (canonical_request_dest == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "canonical request destination cannot be null.\n"); + } + + if (signed_headers_dest == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "signed headers destination cannot be null.\n"); + } + + /* HTTP verb, resource path, and query string lines + */ + len = (HDstrlen(http_request->verb) + + HDstrlen(http_request->resource) + + HDstrlen(query_params) + + 3 ); + ret = HDsnprintf(canonical_request_dest, + len + 1, + "%s\n%s\n%s\n", + http_request->verb, + http_request->resource, + query_params); + if (ret == 0 || (size_t)ret > len) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to compose canonical request first line"); + + /* write in canonical headers, building signed headers concurrently + */ + node = http_request->first_header; /* assumed at first sorted */ + while (node != NULL) { + size_t join_len = 0; /* string len of joined header-value */ + + HDassert( node->magic == S3COMMS_HRB_NODE_MAGIC ); + + len = HDstrlen(node->lowername); + join_len = HDstrlen(node->value) + len + 2; /* +2 <- ":\n" */ + ret = HDsnprintf(tmpstr, + join_len + 1, /* +1 for null terminator */ + "%s:%s\n", + node->lowername, + node->value); + if (ret == 0 || (size_t)ret > join_len) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to concatenate HTTP header %s:%s", + node->lowername, + node->value); + strcat(canonical_request_dest, tmpstr); + + len += 1; /* semicolon */ + ret = HDsnprintf(tmpstr, + len + 1, + "%s;", + node->lowername); + if (ret == 0 || (size_t)ret > len) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to append signed header %s", + node->lowername); + strcat(signed_headers_dest, tmpstr); + + node = node->next; + } + + /* remove tailing ';' from signed headers sequence + */ + signed_headers_dest[HDstrlen(signed_headers_dest) - 1] = '\0'; + + /* append signed headers and payload hash + * NOTE: at present, no HTTP body is handled, per the nature of + * requests/range-gets + */ + strcat(canonical_request_dest, "\n"); + strcat(canonical_request_dest, signed_headers_dest); + strcat(canonical_request_dest, "\n"); + strcat(canonical_request_dest, EMPTY_SHA256); + +done: + FUNC_LEAVE_NOAPI(ret_value); + +} /* H5FD_s3comms_aws_canonical_request */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_bytes_to_hex() + * + * Purpose: + * + * Produce human-readable hex string [0-9A-F] from sequence of bytes. + * + * For each byte (char), writes two-character hexadecimal representation. + * + * No null-terminator appended. + * + * Assumes `dest` is allocated to enough size (msg_len * 2). + * + * Fails if either `dest` or `msg` are null. + * + * `msg_len` message length of 0 has no effect. + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - hex string written to `dest` (not null-terminated) + * - FAILURE: `FAIL` + * - `dest == NULL` + * - `msg == NULL` + * + * Programmer: Jacob Smith + * 2017-07-12 + * + * Changes: + * + * - Integrate into HDF. + * - Rename from hex() to H5FD_s3comms_bytes_to_hex. + * - Change return type from `void` to `herr_t`. + * --- Jacob Smtih 2017-09-14 + * + * - Add bool parameter `lowercase` to configure upper/lowercase output + * of a-f hex characters. + * --- Jacob Smith 2017-09-19 + * + * - Change bool type to `hbool_t` + * --- Jacob Smtih 2017-10-11 + * + *---------------------------------------------------------------------------- + */ +herr_t +H5FD_s3comms_bytes_to_hex(char *dest, + const unsigned char *msg, + size_t msg_len, + hbool_t lowercase) +{ + size_t i = 0; + herr_t ret_value = SUCCEED; + + + + FUNC_ENTER_NOAPI_NOINIT + +#if S3COMMS_DEBUG + HDfprintf(stdout, "called H5FD_s3comms_bytes_to_hex.\n"); +#endif + + if (dest == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "hex destination cannot be null.\n") + } + if (msg == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "bytes sequence cannot be null.\n") + } + + for (i = 0; i < msg_len; i++) { + int chars_written = + HDsnprintf(&(dest[i * 2]), + 3, /* 'X', 'X', '\n' */ + (lowercase == TRUE) ? "%02x" + : "%02X", + msg[i]); + if (chars_written != 2) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "problem while writing hex chars for %c", + msg[i]); + } + +done: + FUNC_LEAVE_NOAPI(ret_value); + +} /* H5FD_s3comms_bytes_to_hex */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_free_purl() + * + * Purpose: + * + * Release resources from a parsed_url_t pointer. + * + * If pointer is null, nothing happens. + * + * Return: + * + * `SUCCEED` (never fails) + * + * Programmer: Jacob Smith + * 2017-11-01 + * + * Changes: None. + * + *---------------------------------------------------------------------------- + */ +herr_t +H5FD_s3comms_free_purl(parsed_url_t *purl) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + +#if S3COMMS_DEBUG + HDprintf("called H5FD_s3comms_free_purl.\n"); +#endif + + if (purl != NULL) { + HDassert( purl->magic == S3COMMS_PARSED_URL_MAGIC ); + if (purl->scheme != NULL) H5MM_xfree(purl->scheme); + if (purl->host != NULL) H5MM_xfree(purl->host); + if (purl->port != NULL) H5MM_xfree(purl->port); + if (purl->path != NULL) H5MM_xfree(purl->path); + if (purl->query != NULL) H5MM_xfree(purl->query); + purl->magic += 1ul; + H5MM_xfree(purl); + } + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5FD_s3comms_free_purl */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_HMAC_SHA256() + * + * Purpose: + * + * Generate Hash-based Message Authentication Checksum using the SHA-256 + * hashing algorithm. + * + * Given a key, message, and respective lengths (to accommodate null + * characters in either), generate _hex string_ of authentication checksum + * and write to `dest`. + * + * `dest` must be at least `SHA256_DIGEST_LENGTH * 2` characters in size. + * Not enforceable by this function. + * `dest` will _not_ be null-terminated by this function. + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - hex string written to `dest` (not null-terminated) + * - FAILURE: `FAIL` + * - `dest == NULL` + * - error while generating hex string output + * + * Programmer: Jacob Smith + * 2017-07-?? + * + * Changes: + * + * - Integrate with HDF5. + * - Rename from `HMAC_SHA256` to `H5FD_s3comms_HMAC_SHA256`. + * - Rename output parameter from `md` to `dest`. + * - Return `herr_t` type instead of `void`. + * - Call `H5FD_s3comms_bytes_to_hex` to generate hex cleartext for output. + * --- Jacob Smith 2017-09-19 + * + * - Use static char array instead of malloc'ing `md` + * --- Jacob Smith 2017-10-10 + * + *---------------------------------------------------------------------------- + */ +herr_t +H5FD_s3comms_HMAC_SHA256(const unsigned char *key, + size_t key_len, + const char *msg, + size_t msg_len, + char *dest) +{ +#ifdef H5_HAVE_ROS3_VFD + unsigned char md[SHA256_DIGEST_LENGTH]; + unsigned int md_len = SHA256_DIGEST_LENGTH; + herr_t ret_value = SUCCEED; +#else + herr_t ret_value = FAIL; +#endif /* H5_HAVE_ROS3_VFD */ + + + + FUNC_ENTER_NOAPI_NOINIT + +#ifdef H5_HAVE_ROS3_VFD + +#if S3COMMS_DEBUG + HDfprintf(stdout, "called H5FD_s3comms_HMAC_SHA256.\n"); +#endif + + if (dest == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "destination cannot be null."); + } + + HMAC(EVP_sha256(), + key, + (int)key_len, + (const unsigned char *)msg, + msg_len, + md, + &md_len); + + if (FAIL == + H5FD_s3comms_bytes_to_hex(dest, + (const unsigned char *)md, + (size_t)md_len, + true)) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "could not convert to hex string."); + } + +#endif /* H5_HAVE_ROS3_VFD */ + +done: + FUNC_LEAVE_NOAPI(ret_value); + +} /* H5FD_s3comms_HMAC_SHA256 */ + + +/*----------------------------------------------------------------------------- + * + * Function: H5FD__s3comms_load_aws_creds_from_file() + * + * Purpose: + * + * Extract AWS configuration information from a target file. + * + * Given a file and a profile name, e.g. "ros3_vfd_test", attempt to locate + * that region in the file. If not found, returns in error and output + * pointers are not modified. + * + * If the profile label is found, attempts to locate and parse configuration + * data, stopping at the first line where: + * + reached end of file + * + line does not start with a recognized setting name + * + * Following AWS documentation, looks for any of: + * + aws_access_key_id + * + aws_secret_access_key + * + region + * + * To be valid, the setting must begin the line with one of the keywords, + * followed immediately by an equals sign '=', and have some data before + * newline at end of line. + * + `spam=eggs` would be INVALID because name is unrecognized + * + `region = us-east-2` would be INVALID because of spaces + * + `region=` would be INVALID because no data. + * + * Upon successful parsing of a setting line, will store the result in the + * corresponding output pointer. If the output pointer is NULL, will skip + * any matching setting line while parsing -- useful to prevent overwrite + * when reading from multiple files. + * + * Return: + * + * + SUCCESS: `SUCCEED` + * + no error. settings may or may not have been loaded. + * + FAILURE: `FAIL` + * + internal error occurred. + * + -1 :: unable to format profile label + * + -2 :: profile name/label not found in file + * + -3 :: some other error + * + * Programmer: Jacob Smith + * 2018-02-27 + * + * Changes: None + * + *----------------------------------------------------------------------------- + */ +static herr_t +H5FD__s3comms_load_aws_creds_from_file( + FILE *file, + const char *profile_name, + char *key_id, + char *access_key, + char *aws_region) +{ + char profile_line[32]; + char buffer[128]; + const char *setting_names[] = { + "region", + "aws_access_key_id", + "aws_secret_access_key", + }; + char * const setting_pointers[] = { + aws_region, + key_id, + access_key, + }; + unsigned setting_count = 3; + herr_t ret_value = SUCCEED; + unsigned buffer_i = 0; + unsigned setting_i = 0; + int found_setting = 0; + char *line_buffer = &(buffer[0]); + + FUNC_ENTER_NOAPI_NOINIT + +#if S3COMMS_DEBUG + HDfprintf(stdout, "called load_aws_creds_from_file.\n"); +#endif + + /* format target line for start of profile */ + if (32 < HDsnprintf(profile_line, 32, "[%s]", profile_name)) + HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, + "unable to format profile label") + + /* look for start of profile */ + do { + /* clear buffer */ + for (buffer_i=0; buffer_i < 128; buffer_i++) buffer[buffer_i] = 0; + + line_buffer = fgets(line_buffer, 128, file); + if (line_buffer == NULL) /* reached end of file */ + goto done; + } while (strncmp(line_buffer, profile_line, HDstrlen(profile_line))); + + /* extract credentials from lines */ + do { + size_t setting_name_len = 0; + const char *setting_name = NULL; + char line_prefix[128]; + + /* clear buffer */ + for (buffer_i=0; buffer_i < 128; buffer_i++) buffer[buffer_i] = 0; + + /* collect a line from file */ + line_buffer = fgets(line_buffer, 128, file); + if (line_buffer == NULL) + goto done; /* end of file */ + + /* loop over names to see if line looks like assignment */ + for (setting_i = 0; setting_i < setting_count; setting_i++) { + setting_name = setting_names[setting_i]; + setting_name_len = HDstrlen(setting_name); + if (128 < HDsnprintf( + line_prefix, + setting_name_len+2, + "%s=", + setting_name)) + HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, + "unable to format line prefix") + + /* found a matching name? */ + if (!strncmp(line_buffer, line_prefix, setting_name_len + 1)) { + found_setting = 1; + + /* skip NULL destination buffer */ + if (setting_pointers[setting_i] == NULL) + break; + + /* advance to end fo name in string */ + do { + line_buffer++; + } while (*line_buffer != 0 && *line_buffer != '='); + + if (*line_buffer == 0 || *(line_buffer+1) == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "incomplete assignment in file") + line_buffer++; /* was pointing at '='; advance */ + + /* copy line buffer into out pointer */ + strcpy(setting_pointers[setting_i], (const char *)line_buffer); + + /* "trim" tailing whitespace by replacing with null terminator*/ + buffer_i = 0; + while (!isspace(setting_pointers[setting_i][buffer_i])) + buffer_i++; + setting_pointers[setting_i][buffer_i] = '\0'; + + break; /* have read setting; don't compare with others */ + } + } + } while (found_setting); + +done: + FUNC_LEAVE_NOAPI(ret_value); + +} /* H5FD__s3comms_load_aws_creds_from_file */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_load_aws_profile() + * + * Purpose : + * + * Read aws profile elements from standard location on system and store + * settings in memory. + * + * Looks for both `~/.aws/config` and `~/.aws/credentials`, the standard + * files for AWS tools. If a file exists (can be opened), looks for the + * given profile name and reads the settings into the relevant buffer. + * + * Any setting duplicated in both files will be set to that from + * `credentials`. + * + * Settings are stored in the supplied buffers as null-terminated strings. + * + * Return: + * + * + SUCCESS: `SUCCEED` (0) + * + no error occurred and all settings were populated + * + FAILURE: `FAIL` (-1) + * + internal error occurred + * + unable to locate profile + * + region, key id, and secret key were not all found and set + * + * Programmer: Jacob Smith + * 2018-02-27 + * + * Changes: None + * + *---------------------------------------------------------------------------- + */ +herr_t +H5FD_s3comms_load_aws_profile(const char *profile_name, + char *key_id_out, + char *secret_access_key_out, + char *aws_region_out) +{ + herr_t ret_value = SUCCEED; + FILE *credfile = NULL; + char awspath[117]; + char filepath[128]; + + FUNC_ENTER_NOAPI_NOINIT + +#if S3COMMS_DEBUG + HDfprintf(stdout, "called H5FD_s3comms_load_aws_profile.\n"); +#endif + + /* TODO: Windows and other path gotchas */ + if (117 < HDsnprintf(awspath, 117, "%s/.aws/", getenv("HOME"))) + HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, + "unable to format home-aws path") + if (128 < HDsnprintf(filepath, 128, "%s%s", awspath, "credentials")) + HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, + "unable to format credentials path") + + credfile = fopen(filepath, "r"); + if (credfile != NULL) { + if (FAIL == H5FD__s3comms_load_aws_creds_from_file( + credfile, + profile_name, + key_id_out, + secret_access_key_out, + aws_region_out)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to load from aws credentials") + if (EOF == fclose(credfile)) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, + "unable to close credentials file") + credfile = NULL; + } + + if (128 < HDsnprintf(filepath, 128, "%s%s", awspath, "config")) + HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, + "unable to format config path") + credfile = fopen(filepath, "r"); + if (credfile != NULL) { + if (FAIL == H5FD__s3comms_load_aws_creds_from_file( + credfile, + profile_name, + (*key_id_out == 0) ? key_id_out : NULL, + (*secret_access_key_out == 0) ? secret_access_key_out : NULL, + (*aws_region_out == 0) ? aws_region_out : NULL)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to load from aws config") + if (EOF == fclose(credfile)) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, + "unable to close config file") + credfile = NULL; + } + + /* fail if not all three settings were loaded */ + if (*key_id_out == 0 || + *secret_access_key_out == 0 || + *aws_region_out == 0) + { + ret_value = FAIL; + } + +done: + if (credfile != NULL) { + if (EOF == fclose(credfile)) + HDONE_ERROR(H5E_ARGS, H5E_ARGS, FAIL, + "problem error-closing aws configuration file") + } + + FUNC_LEAVE_NOAPI(ret_value); + +} /* H5FD_s3comms_load_aws_profile */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_nlowercase() + * + * Purpose: + * + * From string starting at `s`, write `len` characters to `dest`, + * converting all to lowercase. + * + * Behavior is undefined if `s` is NULL or `len` overruns the allocated + * space of either `s` or `dest`. + * + * Provided as convenience. + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - upon completion, `dest` is populated + * - FAILURE: `FAIL` + * - `dest == NULL` + * + * Programmer: Jacob Smith + * 2017-09-18 + * + * Changes: None. + * + *---------------------------------------------------------------------------- + */ +herr_t +H5FD_s3comms_nlowercase(char *dest, + const char *s, + size_t len) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + +#if S3COMMS_DEBUG + HDfprintf(stdout, "called H5FD_s3comms_nlowercase.\n"); +#endif + + if (dest == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "destination cannot be null.\n"); + } + + if (len > 0) { + HDmemcpy(dest, s, len); + do { + len--; + dest[len] = (char)tolower( (int)dest[len] ); + } while (len > 0); + } + +done: + FUNC_LEAVE_NOAPI(ret_value); + +} /* H5FD_s3comms_nlowercase */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_parse_url() + * + * Purpose: + * + * Parse URL-like string and stuff URL components into + * `parsed_url` structure, if possible. + * + * Expects null-terminated string of format: + * SCHEME "://" HOST [":" PORT ] ["/" [ PATH ] ] ["?" QUERY] + * where SCHEME :: "[a-zA-Z/.-]+" + * PORT :: "[0-9]" + * + * Stores resulting structure in argument pointer `purl`, if successful, + * creating and populating new `parsed_url_t` structure pointer. + * Empty or absent elements are NULL in new purl structure. + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - `purl` pointer is populated + * - FAILURE: `FAIL` + * - unable to parse + * - `purl` is unaltered (probably NULL) + * + * Programmer: Jacob Smith + * 2017-10-30 + * + * Changes: None. + * + *---------------------------------------------------------------------------- + */ +herr_t +H5FD_s3comms_parse_url(const char *str, + parsed_url_t **_purl) +{ + parsed_url_t *purl = NULL; /* pointer to new structure */ + const char *tmpstr = NULL; /* working pointer in string */ + const char *curstr = str; /* "start" pointer in string */ + long int len = 0; /* substring length */ + long int urllen = 0; /* length of passed-in url string */ + unsigned int i = 0; + herr_t ret_value = FAIL; + + + + FUNC_ENTER_NOAPI_NOINIT; + +#if S3COMMS_DEBUG + HDprintf("called H5FD_s3comms_parse_url.\n"); +#endif + + if (str == NULL || *str == '\0') { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "invalid url string"); + } + + urllen = (long int)HDstrlen(str); + + purl = (parsed_url_t *)H5MM_malloc(sizeof(parsed_url_t)); + if (purl == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, + "can't allocate space for parsed_url_t"); + } + purl->magic = S3COMMS_PARSED_URL_MAGIC; + purl->scheme = NULL; + purl->host = NULL; + purl->port = NULL; + purl->path = NULL; + purl->query = NULL; + + /*************** + * READ SCHEME * + ***************/ + + tmpstr = strchr(curstr, ':'); + if (tmpstr == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "invalid SCHEME construction: probably not URL"); + } + len = tmpstr - curstr; + HDassert( (0 <= len) && (len < urllen) ); + + /* check for restrictions + */ + for (i = 0; i < len; i++) { + /* scheme = [a-zA-Z+-.]+ (terminated by ":") */ + if (!isalpha(curstr[i]) && + '+' != curstr[i] && + '-' != curstr[i] && + '.' != curstr[i]) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "invalid SCHEME construction"); + } + } + /* copy lowercased scheme to structure + */ + purl->scheme = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); + if (purl->scheme == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, + "can't allocate space for SCHEME"); + } + (void)HDstrncpy(purl->scheme, curstr, (size_t)len); + purl->scheme[len] = '\0'; + for ( i = 0; i < len; i++ ) { + purl->scheme[i] = (char)tolower(purl->scheme[i]); + } + + /* Skip "://" */ + tmpstr += 3; + curstr = tmpstr; + + /************* + * READ HOST * + *************/ + + if (*curstr == '[') { + /* IPv6 */ + while (']' != *tmpstr) { + if (tmpstr == 0) { /* end of string reached! */ + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "reached end of URL: incomplete IPv6 HOST"); + } + tmpstr++; + } + tmpstr++; + } else { + while (0 != *tmpstr) { + if (':' == *tmpstr || + '/' == *tmpstr || + '?' == *tmpstr) + { + break; + } + tmpstr++; + } + } /* if IPv4 or IPv6 */ + len = tmpstr - curstr; + if (len == 0) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "HOST substring cannot be empty"); + } else if (len > urllen) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "problem with length of HOST substring"); + } + + /* copy host + */ + purl->host = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); + if (purl->host == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, + "can't allocate space for HOST"); + } + (void)HDstrncpy(purl->host, curstr, (size_t)len); + purl->host[len] = 0; + + /************* + * READ PORT * + *************/ + + if (':' == *tmpstr) { + tmpstr += 1; /* advance past ':' */ + curstr = tmpstr; + while ((0 != *tmpstr) && ('/' != *tmpstr) && ('?' != *tmpstr)) { + tmpstr++; + } + len = tmpstr - curstr; + if (len == 0) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "PORT element cannot be empty"); + } else if (len > urllen) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "problem with length of PORT substring"); + } + for (i = 0; i < len; i ++) { + if (!isdigit(curstr[i])) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "PORT is not a decimal string"); + } + } + + /* copy port + */ + purl->port = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); + if (purl->port == NULL) { /* cannot malloc */ + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, + "can't allocate space for PORT"); + } + (void)HDstrncpy(purl->port, curstr, (size_t)len); + purl->port[len] = 0; + } /* if PORT element */ + + /************* + * READ PATH * + *************/ + + if ('/' == *tmpstr) { + /* advance past '/' */ + tmpstr += 1; + curstr = tmpstr; + + /* seek end of PATH + */ + while ((0 != *tmpstr) && ('?' != *tmpstr)) { + tmpstr++; + } + len = tmpstr - curstr; + if (len > urllen) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "problem with length of PATH substring"); + } + if (len > 0) { + purl->path = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); + if (purl->path == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, + "can't allocate space for PATH"); + } /* cannot malloc path pointer */ + (void)HDstrncpy(purl->path, curstr, (size_t)len); + purl->path[len] = 0; + } + } /* if PATH element */ + + /************** + * READ QUERY * + **************/ + + if ('?' == *tmpstr) { + tmpstr += 1; + curstr = tmpstr; + while (0 != *tmpstr) { + tmpstr++; + } + len = tmpstr - curstr; + if (len == 0) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "QUERY cannot be empty"); + } else if (len > urllen) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "problem with length of QUERY substring"); + } + purl->query = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); + if (purl->query == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, + "can't allocate space for QUERY"); + } /* cannot malloc path pointer */ + (void)HDstrncpy(purl->query, curstr, (size_t)len); + purl->query[len] = 0; + } /* if QUERY exists */ + + + + *_purl = purl; + ret_value = SUCCEED; + +done: + if (ret_value == FAIL) { + H5FD_s3comms_free_purl(purl); + } + FUNC_LEAVE_NOAPI(ret_value); + +} /* H5FD_s3comms_parse_url */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_percent_encode_char() + * + * Purpose: + * + * "Percent-encode" utf-8 character `c`, e.g., + * '$' -> "%24" + * '¢' -> "%C2%A2" + * + * `c` cannot be null. + * + * Does not (currently) accept multi-byte characters... + * limit to (?) u+00ff, well below upper bound for two-byte utf-8 encoding + * (u+0080..u+07ff). + * + * Writes output to `repr`. + * `repr` cannot be null. + * Assumes adequate space i `repr`... + * >>> char[4] or [7] for most characters, + * >>> [13] as theoretical maximum. + * + * Representation `repr` is null-terminated. + * + * Stores length of representation (without null terminator) at pointer + * `repr_len`. + * + * Return : SUCCEED/FAIL + * + * - SUCCESS: `SUCCEED` + * - percent-encoded representation written to `repr` + * - 'repr' is null-terminated + * - FAILURE: `FAIL` + * - `c` or `repr` was NULL + * + * Programmer: Jacob Smith + * + * Changes: + * + * - Integrate into HDF. + * - Rename from `hexutf8` to `H5FD_s3comms_percent_encode_char`. + * --- Jacob Smith 2017-09-15 + * + *---------------------------------------------------------------------------- + */ +herr_t +H5FD_s3comms_percent_encode_char(char *repr, + const unsigned char c, + size_t *repr_len) +{ + unsigned int acc = 0; + unsigned int i = 0; + unsigned int k = 0; + unsigned int stack[4] = {0, 0, 0, 0}; + unsigned int stack_size = 0; + int chars_written = 0; + herr_t ret_value = SUCCEED; +#if S3COMMS_DEBUG + unsigned char s[2] = {c, 0}; + unsigned char hex[3] = {0, 0, 0}; +#endif + + + + FUNC_ENTER_NOAPI_NOINIT + +#if S3COMMS_DEBUG + HDfprintf(stdout, "called H5FD_s3comms_percent_encode_char.\n"); +#endif + + if (repr == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination `repr`.\n") + } + +#if S3COMMS_DEBUG + H5FD_s3comms_bytes_to_hex((char *)hex, s, 1, FALSE); + HDfprintf(stdout, " CHAR: \'%s\'\n", s); + HDfprintf(stdout, " CHAR-HEX: \"%s\"\n", hex); +#endif + + if (c <= (unsigned char)0x7f) { + /* character represented in a single "byte" + * and single percent-code + */ +#if S3COMMS_DEBUG + HDfprintf(stdout, " SINGLE-BYTE\n"); +#endif + *repr_len = 3; + chars_written = HDsnprintf(repr, 4, "%%%02X", c); + if (chars_written != 3) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "cannot write char %c", + c); + } else { + /* multi-byte, multi-percent representation + */ +#if S3COMMS_DEBUG + HDfprintf(stdout, " MULTI-BYTE\n"); +#endif + stack_size = 0; + k = (unsigned int)c; + *repr_len = 0; + do { + /* push number onto stack in six-bit slices + */ + acc = k; + acc >>= 6; /* cull least */ + acc <<= 6; /* six bits */ + stack[stack_size++] = k - acc; /* max six-bit number */ + k = acc >> 6; + } while (k > 0); + + /* now have "stack" of two to four six-bit numbers + * to be put into UTF-8 byte fields + */ + +#if S3COMMS_DEBUG + HDfprintf(stdout, " STACK:\n {\n"); + for (i = 0; i < stack_size; i++) { + H5FD_s3comms_bytes_to_hex((char *)hex, + (unsigned char *)(&stack[i]), + 1, + FALSE); + hex[2] = 0; + HDfprintf(stdout, " %s,\n", hex); + } + HDfprintf(stdout, " }\n"); +#endif + + /**************** + * leading byte * + ****************/ + + /* prepend 11[1[1]]0 to first byte */ + /* 110xxxxx, 1110xxxx, or 11110xxx */ + acc = 0xC0; /* 2^7 + 2^6 -> 11000000 */ + acc += (stack_size > 2) ? 0x20 : 0; + acc += (stack_size > 3) ? 0x10 : 0; + stack_size -= 1; + chars_written = HDsnprintf(repr, 4, "%%%02X", acc + stack[stack_size]); + if (chars_written != 3) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "cannot write char %c", + c); + *repr_len += 3; + + /************************ + * continuation byte(s) * + ************************/ + + /* 10xxxxxx */ + for (i = 0; i < stack_size; i++) { + chars_written = HDsnprintf(&repr[i*3 + 3], + 4, + "%%%02X", + 128 + stack[stack_size - 1 - i]); + if (chars_written != 3) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "cannot write char %c", + c); + *repr_len += 3; + } + } + *(repr + *repr_len) = '\0'; + +done: + FUNC_LEAVE_NOAPI(ret_value); + +} /* H5FD_s3comms_percent_encode_char */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_signing_key() + * + * Purpose: + * + * Create AWS4 "Signing Key" from secret key, AWS region, and timestamp. + * + * Sequentially runs HMAC_SHA256 on strings in specified order, + * generating re-usable checksum (according to documentation, valid for + * 7 days from time given). + * + * `secret` is `access key id` for targeted service/bucket/resource. + * + * `iso8601now` must conform to format, yyyyMMDD'T'hhmmss'Z' + * e.g. "19690720T201740Z". + * + * `region` should be one of AWS service region names, e.g. "us-east-1". + * + * Hard-coded "service" algorithm requirement to "s3". + * + * Inputs must be null-terminated strings. + * + * Writes to `md` the raw byte data, length of `SHA256_DIGEST_LENGTH`. + * Programmer must ensure that `md` is appropriately allocated. + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - raw byte data of signing key written to `md` + * - FAILURE: `FAIL` + * - if any input arguments was NULL + * + * Programmer: Jacob Smith + * 2017-07-13 + * + * Changes: + * + * - Integrate into HDF5. + * - Return herr_t type. + * --- Jacob Smith 2017-09-18 + * + * - NULL check and fail of input parameters. + * --- Jacob Smith 2017-10-10 + * + *---------------------------------------------------------------------------- + */ +herr_t +H5FD_s3comms_signing_key(unsigned char *md, + const char *secret, + const char *region, + const char *iso8601now) +{ +#ifdef H5_HAVE_ROS3_VFD + char *AWS4_secret = NULL; + size_t AWS4_secret_len = 0; + unsigned char datekey[SHA256_DIGEST_LENGTH]; + unsigned char dateregionkey[SHA256_DIGEST_LENGTH]; + unsigned char dateregionservicekey[SHA256_DIGEST_LENGTH]; + int ret = 0; /* return value of HDsnprintf */ + herr_t ret_value = SUCCEED; +#else + herr_t ret_value = SUCCEED; +#endif /* H5_HAVE_ROS3_VFD */ + + + + FUNC_ENTER_NOAPI_NOINIT + +#ifdef H5_HAVE_ROS3_VFD + +#if S3COMMS_DEBUG + HDfprintf(stdout, "called H5FD_s3comms_signing_key.\n"); +#endif + + if (md == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "Destination `md` cannot be NULL.\n") + } + if (secret == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "`secret` cannot be NULL.\n") + } + if (region == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "`region` cannot be NULL.\n") + } + if (iso8601now == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "`iso8601now` cannot be NULL.\n") + } + + AWS4_secret_len = 4 + HDstrlen(secret) + 1; + AWS4_secret = (char*)H5MM_malloc(sizeof(char *) * AWS4_secret_len); + if (AWS4_secret == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "Could not allocate space.\n") + } + + /* prepend "AWS4" to start of the secret key + */ + ret = HDsnprintf(AWS4_secret, AWS4_secret_len,"%s%s", "AWS4", secret); + if ((size_t)ret != (AWS4_secret_len - 1)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "problem writing AWS4+secret `%s`", + secret); + + /* hash_func, key, len(key), msg, len(msg), digest_dest, digest_len_dest + * we know digest length, so ignore via NULL + */ + HMAC(EVP_sha256(), + (const unsigned char *)AWS4_secret, + (int)HDstrlen(AWS4_secret), + (const unsigned char*)iso8601now, + 8, /* 8 --> length of 8 --> "yyyyMMDD" */ + datekey, + NULL); + HMAC(EVP_sha256(), + (const unsigned char *)datekey, + SHA256_DIGEST_LENGTH, + (const unsigned char *)region, + HDstrlen(region), + dateregionkey, + NULL); + HMAC(EVP_sha256(), + (const unsigned char *)dateregionkey, + SHA256_DIGEST_LENGTH, + (const unsigned char *)"s3", + 2, + dateregionservicekey, + NULL); + HMAC(EVP_sha256(), + (const unsigned char *)dateregionservicekey, + SHA256_DIGEST_LENGTH, + (const unsigned char *)"aws4_request", + 12, + md, + NULL); + +done: + H5MM_xfree(AWS4_secret); + +#endif /* H5_HAVE_ROS3_VFD */ + + FUNC_LEAVE_NOAPI(ret_value); + +} /* H5FD_s3comms_signing_key */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_tostringtosign() + * + * Purpose: + * + * Get AWS "String to Sign" from Canonical Request, timestamp, + * and AWS "region". + * + * Common between single request and "chunked upload", + * conforms to: + * "AWS4-HMAC-SHA256\n" + + * + "\n" + // yyyyMMDD'T'hhmmss'Z' + * + "/" + + "/s3/aws4-request\n" + + * hex(SHA256()) + * + * Inputs `creq` (canonical request string), `now` (ISO8601 format), + * and `region` (s3 region designator string) must all be + * null-terminated strings. + * + * Result is written to `dest` with null-terminator. + * It is left to programmer to ensure `dest` has adequate space. + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - "string to sign" written to `dest` and null-terminated + * - FAILURE: `FAIL` + * - if any of the inputs are NULL + * - if an error is encountered while computing checksum + * + * Programmer: Jacob Smith + * 2017-07-?? + * + * Changes: + * + * - Integrate with HDF5. + * - Rename from `tostringtosign` to `H5FD_s3comms_tostringtosign`. + * - Return `herr_t` instead of characters written. + * - Use HDF-friendly bytes-to-hex function (`H5FD_s3comms_bytes_to_hex`) + * instead of general-purpose, deprecated `hex()`. + * - Adjust casts to openssl's `SHA256`. + * - Input strings are now `const`. + * --- Jacob Smith 2017-09-19 + * + *---------------------------------------------------------------------------- + */ +herr_t +H5FD_s3comms_tostringtosign(char *dest, + const char *req, + const char *now, + const char *region) +{ +#ifdef H5_HAVE_ROS3_VFD + unsigned char checksum[SHA256_DIGEST_LENGTH * 2 + 1]; + size_t d = 0; + char day[9]; + char hexsum[SHA256_DIGEST_LENGTH * 2 + 1]; + size_t i = 0; + int ret = 0; /* HDsnprintf return value */ + herr_t ret_value = SUCCEED; + char tmp[128]; +#else + herr_t ret_value = FAIL; +#endif /* H5_HAVE_ROS3_VFD */ + + + FUNC_ENTER_NOAPI_NOINIT + +#ifdef H5_HAVE_ROS3_VFD + +#if S3COMMS_DEBUG + HDfprintf(stdout, "called H5FD_s3comms_tostringtosign.\n"); +#endif + + if (dest == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "destination buffer cannot be null.\n") + } + if (req == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "canonical request cannot be null.\n") + } + if (now == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "Timestring cannot be NULL.\n") + } + if (region == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "Region cannot be NULL.\n") + } + + + + for (i = 0; i < 128; i++) { + tmp[i] = '\0'; + } + for (i = 0; i < SHA256_DIGEST_LENGTH * 2 + 1; i++) { + checksum[i] = '\0'; + hexsum[i] = '\0'; + } + HDstrncpy(day, now, 8); + day[8] = '\0'; + ret = HDsnprintf(tmp, 127, "%s/%s/s3/aws4_request", day, region); + if (ret <= 0 || ret >= 127) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "problem adding day and region to string") + + + + HDmemcpy((dest + d), "AWS4-HMAC-SHA256\n", 17); + d = 17; + + HDmemcpy((dest+d), now, HDstrlen(now)); + d += HDstrlen(now); + dest[d++] = '\n'; + + HDmemcpy((dest + d), tmp, HDstrlen(tmp)); + d += HDstrlen(tmp); + dest[d++] = '\n'; + + SHA256((const unsigned char *)req, + HDstrlen(req), + checksum); + + if (FAIL == + H5FD_s3comms_bytes_to_hex(hexsum, + (const unsigned char *)checksum, + SHA256_DIGEST_LENGTH, + true)) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "could not create hex string"); + } + + for (i = 0; i < SHA256_DIGEST_LENGTH * 2; i++) { + dest[d++] = hexsum[i]; + } + + dest[d] = '\0'; + +#endif /* H5_HAVE_ROS3_VFD */ + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5ros3_tostringtosign */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_trim() + * + * Purpose: + * + * Remove all whitespace characters from start and end of a string `s` + * of length `s_len`, writing trimmed string copy to `dest`. + * Stores number of characters remaining at `n_written`. + * + * Destination for trimmed copy `dest` cannot be null. + * `dest` must have adequate space allocated for trimmed copy. + * If inadequate space, behavior is undefined, possibly resulting + * in segfault or overwrite of other data. + * + * If `s` is NULL or all whitespace, `dest` is untouched and `n_written` + * is set to 0. + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - FAILURE: `FAIL` + * - `dest == NULL` + * + * Programmer: Jacob Smith + * 2017-09-18 + * + * Changes: + * + * - Rename from `trim()` to `H5FD_s3comms_trim()`. + * - Incorporate into HDF5. + * - Returns `herr_t` type. + * --- Jacob Smith 2017-??-?? + * + *---------------------------------------------------------------------------- + */ +herr_t +H5FD_s3comms_trim(char *dest, + char *s, + size_t s_len, + size_t *n_written) +{ + herr_t ret_value = SUCCEED; + + + + FUNC_ENTER_NOAPI_NOINIT + +#if S3COMMS_DEBUG + HDfprintf(stdout, "called H5FD_s3comms_trim.\n"); +#endif + + if (dest == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "destination cannot be null.") + } + if (s == NULL) { + s_len = 0; + } + + + + if (s_len > 0) { + /* Find first non-whitespace character from start; + * reduce total length per character. + */ + while ((s_len > 0) && + isspace((unsigned char)s[0]) && s_len > 0) + { + s++; + s_len--; + } + + /* Find first non-whitespace character from tail; + * reduce length per-character. + * If length is 0 already, there is no non-whitespace character. + */ + if (s_len > 0) { + do { + s_len--; + } while( isspace((unsigned char)s[s_len]) ); + s_len++; + + /* write output into dest + */ + HDmemcpy(dest, s, s_len); + } + } + + *n_written = s_len; + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_s3comms_trim */ + + +/*---------------------------------------------------------------------------- + * + * Function: H5FD_s3comms_uriencode() + * + * Purpose: + * + * URIencode (percent-encode) every byte except "[a-zA-Z0-9]-._~". + * + * For each character in source string `_s` from `s[0]` to `s[s_len-1]`, + * writes to `dest` either the raw character or its percent-encoded + * equivalent. + * + * See `H5FD_s3comms_bytes_to_hex` for information on percent-encoding. + * + * Space (' ') character encoded as "%20" (not "+") + * + * Forward-slash ('/') encoded as "%2F" only when `encode_slash == true`. + * + * Records number of characters written at `n_written`. + * + * Assumes that `dest` has been allocated with enough space. + * + * Neither `dest` nor `s` can be NULL. + * + * `s_len == 0` will have no effect. + * + * Return: + * + * - SUCCESS: `SUCCEED` + * - FAILURE: `FAIL` + * - source strings `s` or destination `dest` are NULL + * - error while attempting to percent-encode a character + * + * Programmer: Jacob Smith + * 2017-07-?? + * + * Changes: + * + * - Integrate to HDF environment. + * - Rename from `uriencode` to `H5FD_s3comms_uriencode`. + * - Change return from characters written to herr_t; + * move to i/o parameter `n_written`. + * - No longer append null-terminator to string; + * programmer may append or not as appropriate upon return. + * --- Jacob Smith 2017-09-15 + * + *---------------------------------------------------------------------------- + */ +herr_t +H5FD_s3comms_uriencode(char *dest, + const char *s, + size_t s_len, + hbool_t encode_slash, + size_t *n_written) +{ + char c = 0; + size_t dest_off = 0; + char hex_buffer[13]; + size_t hex_off = 0; + size_t hex_len = 0; + herr_t ret_value = SUCCEED; + size_t s_off = 0; + + + + FUNC_ENTER_NOAPI_NOINIT + +#if S3COMMS_DEBUG + HDfprintf(stdout, "H5FD_s3comms_uriencode called.\n"); +#endif + + if (s == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "source string cannot be NULL"); + if (dest == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "destination cannot be NULL"); + + /* Write characters to destination, converting to percent-encoded + * "hex-utf-8" strings if necessary. + * e.g., '$' -> "%24" + */ + for (s_off = 0; s_off < s_len; s_off++) { + c = s[s_off]; + if (isalnum(c) || + c == '.' || + c == '-' || + c == '_' || + c == '~' || + (c == '/' && encode_slash == FALSE)) + { + dest[dest_off++] = c; + } else { + hex_off = 0; + if (FAIL == + H5FD_s3comms_percent_encode_char(hex_buffer, + (const unsigned char)c, + &hex_len)) + { + hex_buffer[0] = c; + hex_buffer[1] = 0; + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to percent-encode character \'%s\' " + "at %d in \"%s\"", hex_buffer, (int)s_off, s); + } + + for (hex_off = 0; hex_off < hex_len; hex_off++) { + dest[dest_off++] = hex_buffer[hex_off]; + } + } + } + + if (dest_off < s_len) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "buffer overflow"); + + *n_written = dest_off; + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD_s3comms_uriencode */ + + diff --git a/src/H5FDs3comms.h b/src/H5FDs3comms.h new file mode 100644 index 0000000..0524c46 --- /dev/null +++ b/src/H5FDs3comms.h @@ -0,0 +1,634 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Read-Only S3 Virtual File Driver (VFD) * + * Copyright (c) 2017-2018, The HDF Group. * + * * + * All rights reserved. * + * * + * NOTICE: * + * All information contained herein is, and remains, the property of The HDF * + * Group. The intellectual and technical concepts contained herein are * + * proprietary to The HDF Group. Dissemination of this information or * + * reproduction of this material is strictly forbidden unless prior written * + * permission is obtained from The HDF Group. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/***************************************************************************** + * + * This is the header for the S3 Communications module + * + * ***NOT A FILE DRIVER*** + * + * Purpose: + * + * - Provide structures and functions related to communicating with + * Amazon S3 (Simple Storage Service). + * - Abstract away the REST API (HTTP, + * networked communications) behind a series of uniform function calls. + * - Handle AWS4 authentication, if appropriate. + * - Fail predictably in event of errors. + * - Eventually, support more S3 operations, such as creating, writing to, + * and removing Objects remotely. + * + * translates: + * `read(some_file, bytes_offset, bytes_length, &dest_buffer);` + * to: + * ``` + * GET myfile HTTP/1.1 + * Host: somewhere.me + * Range: bytes=4096-5115 + * ``` + * and places received bytes from HTTP response... + * ``` + * HTTP/1.1 206 Partial-Content + * Content-Range: 4096-5115/63239 + * + * + * ``` + * ...in destination buffer. + * + * TODO: put documentation in a consistent place and point to it from here. + * + * Programmer: Jacob Smith + * 2017-11-30 + * + *****************************************************************************/ + +#include +#include +#include +#include +#include + +#ifdef H5_HAVE_ROS3_VFD +#include +#include +#include +#include +#endif /* ifdef H5_HAVE_ROS3_VFD */ + +/***************** + * PUBLIC MACROS * + *****************/ + +/* hexadecimal string of pre-computed sha256 checksum of the empty string + * hex(sha256sum("")) + */ +#define EMPTY_SHA256 \ +"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + +/* string length (plus null terminator) + * example ISO8601-format string: "20170713T145903Z" (YYYYmmdd'T'HHMMSS'_') + */ +#define ISO8601_SIZE 17 + +/* string length (plus null terminator) + * example RFC7231-format string: "Fri, 30 Jun 2017 20:41:55 GMT" + */ +#define RFC7231_SIZE 30 + +/*--------------------------------------------------------------------------- + * + * Macro: ISO8601NOW() + * + * Purpose: + * + * write "YYYYmmdd'T'HHMMSS'Z'" (less single-quotes) to dest + * e.g., "20170630T204155Z" + * + * wrapper for strftime() + * + * It is left to the programmer to check return value of + * ISO8601NOW (should equal ISO8601_SIZE - 1). + * + * Programmer: Jacob Smith + * 2017-07-?? + * + *--------------------------------------------------------------------------- + */ +#define ISO8601NOW(dest, now_gm) \ +strftime((dest), ISO8601_SIZE, "%Y%m%dT%H%M%SZ", (now_gm)) + +/*--------------------------------------------------------------------------- + * + * Macro: RFC7231NOW() + * + * Purpose: + * + * write "Day, dd Mmm YYYY HH:MM:SS GMT" to dest + * e.g., "Fri, 30 Jun 2017 20:41:55 GMT" + * + * wrapper for strftime() + * + * It is left to the programmer to check return value of + * RFC7231NOW (should equal RFC7231_SIZE - 1). + * + * Programmer: Jacob Smith + * 2017-07-?? + * + *--------------------------------------------------------------------------- + */ +#define RFC7231NOW(dest, now_gm) \ +strftime((dest), RFC7231_SIZE, "%a, %d %b %Y %H:%M:%S GMT", (now_gm)) + + +/* Reasonable maximum length of a credential string. + * Provided for error-checking S3COMMS_FORMAT_CREDENTIAL (below). + * 17 <- "////aws4_request\0" + * 2 < "s3" (service) + * 8 <- "YYYYmmdd" (date) + * 128 <- (access_id) + * 155 :: sum + */ +#define S3COMMS_MAX_CREDENTIAL_SIZE 155 + + +/*--------------------------------------------------------------------------- + * + * Macro: H5FD_S3COMMS_FORMAT_CREDENTIAL() + * + * Purpose: + * + * Format "S3 Credential" string from inputs, for AWS4. + * + * Wrapper for HDsnprintf(). + * + * _HAS NO ERROR-CHECKING FACILITIES_ + * It is left to programmer to ensure that return value confers success. + * e.g., + * ``` + * assert( S3COMMS_MAX_CREDENTIAL_SIZE >= + * S3COMMS_FORMAT_CREDENTIAL(...) ); + * ``` + * + * "////aws4_request" + * assuming that `dest` has adequate space. + * + * ALL inputs must be null-terminated strings. + * + * `access` should be the user's access key ID. + * `date` must be of format "YYYYmmdd". + * `region` should be relevant AWS region, i.e. "us-east-1". + * `service` should be "s3". + * + * Programmer: Jacob Smith + * 2017-09-19 + * + * Changes: None. + * + *--------------------------------------------------------------------------- + */ +#define S3COMMS_FORMAT_CREDENTIAL(dest, access, iso8601_date, region, service) \ +HDsnprintf((dest), S3COMMS_MAX_CREDENTIAL_SIZE, \ + "%s/%s/%s/%s/aws4_request", \ + (access), (iso8601_date), (region), (service)) + +/********************* + * PUBLIC STRUCTURES * + *********************/ + + +/*---------------------------------------------------------------------------- + * + * Structure: hrb_node_t + * + * HTTP Header Field Node + * + * + * + * Maintain a ordered (linked) list of HTTP Header fields. + * + * Provides efficient access and manipulation of a logical sequence of + * HTTP header fields, of particular use when composing an + * "S3 Canonical Request" for authentication. + * + * - The creation of a Canoncial Request involves: + * - convert field names to lower case + * - sort by this lower-case name + * - convert ": " name-value separator in HTTP string to ":" + * - get sorted lowercase names without field or separator + * + * As HTTP headers allow headers in any order (excepting the case of multiple + * headers with the same name), the list ordering can be optimized for Canonical + * Request creation, suggesting alphabtical order. For more expedient insertion + * and removal of elements in the list, linked list seems preferable to a + * dynamically-expanding array. The usually-smaller number of entries (5 or + * fewer) makes performance overhead of traversing the list trivial. + * + * The above requirements of creating at Canonical Request suggests a reasonable + * trade-off of speed for space with the option to compute elements as needed + * or to have the various elements prepared and stored in the structure + * (e.g. name, value, lowername, concatenated name:value) + * The structure currently is implemented to pre-compute. + * + * At all times, the "first" node of the list should be the least, + * alphabetically. For all nodes, the `next` node should be either NULL or + * of greater alphabetical value. + * + * Each node contains its own header field information, plus a pointer to the + * next node. + * + * It is not allowed to have multiple nodes with the same _lowercase_ `name`s + * in the same list + * (i.e., name is case-insensitive for access and modification.) + * + * All data (`name`, `value`, `lowername`, and `cat`) are null-terminated + * strings allocated specifically for their node. + * + * + * + * `magic` (unsigned long) + * + * "unique" idenfier number for the structure type + * + * `name` (char *) + * + * Case-meaningful name of the HTTP field. + * Given case is how it is supplied to networking code. + * e.g., "Range" + * + * `lowername` (char *) + * + * Lowercase copy of name. + * e.g., "range" + * + * `value` (char *) + * + * Case-meaningful value of HTTP field. + * e.g., "bytes=0-9" + * + * `cat` (char *) + * + * Concatenated, null-terminated string of HTTP header line, + * as the field would appear in an HTTP request. + * e.g., "Range: bytes=0-9" + * + * `next` (hrb_node_t *) + * + * Pointers to next node in the list, or NULL sentinel as end of list. + * Next node must have a greater `lowername` as determined by strcmp(). + * + * + * + * Programmer: Jacob Smith + * 2017-09-22 + * + * Changes: + * + * - Change from twin doubly-linked lists to singly-linked list. + * --- Jake Smith 2017-01-17 + * + *---------------------------------------------------------------------------- + */ +typedef struct hrb_node_t { + unsigned long magic; + char *name; + char *value; + char *cat; + char *lowername; + struct hrb_node_t *next; +} hrb_node_t; +#define S3COMMS_HRB_NODE_MAGIC 0x7F5757UL + + +/*---------------------------------------------------------------------------- + * + * Structure: hrb_t + * + * HTTP Request Buffer structure + * + * + * + * Logically represent an HTTP request + * + * GET /myplace/myfile.h5 HTTP/1.1 + * Host: over.rainbow.oz + * Date: Fri, 01 Dec 2017 12:35:04 CST + * + * + * + * ...with fast, efficient access to and modification of primary and field + * elements. + * + * Structure for building HTTP requests while hiding much of the string + * processing required "under the hood." + * + * Information about the request target -- the first line -- and the body text, + * if any, are managed directly with this structure. All header fields, e.g., + * "Host" and "Date" above, are created with a linked list of `hrb_node_t` and + * included in the request by a pointer to the head of the list. + * + * + * + * `magic` (unsigned long) + * + * "Magic" number confirming that this is an hrb_t structure and + * what operations are valid for it. + * + * Must be S3COMMS_HRB_MAGIC to be valid. + * + * `body` (char *) : + * + * Pointer to start of HTTP body. + * + * Can be NULL, in which case it is treated as the empty string, "". + * + * `body_len` (size_t) : + * + * Number of bytes (characters) in `body`. 0 if empty or NULL `body`. + * + * `first_header` (hrb_node_t *) : + * + * Pointer to first SORTED header node, if any. + * It is left to the programmer to ensure that this node and associated + * list is destroyed when done. + * + * `resource` (char *) : + * + * Pointer to resource URL string, e.g., "/folder/page.xhtml". + * + * `verb` (char *) : + * + * Pointer to HTTP verb string, e.g., "GET". + * + * `version` (char *) : + * + * Pointer to HTTP version string, e.g., "HTTP/1.1". + * + * + * + * Programmer: Jacob Smith + * + *---------------------------------------------------------------------------- + */ +typedef struct { + unsigned long magic; + char *body; + size_t body_len; + hrb_node_t *first_header; + char *resource; + char *verb; + char *version; +} hrb_t; +#define S3COMMS_HRB_MAGIC 0x6DCC84UL + + +/*---------------------------------------------------------------------------- + * + * Structure: parsed_url_t + * + * + * Represent a URL with easily-accessed pointers to logical elements within. + * These elements (components) are stored as null-terminated strings (or just + * NULLs). These components should be allocated for the structure, making the + * data as safe as possible from modification. If a component is NULL, it is + * either implicit in or absent from the URL. + * + * "http://mybucket.s3.amazonaws.com:8080/somefile.h5?param=value&arg=value" + * ^--^ ^-----------------------^ ^--^ ^---------^ ^-------------------^ + * Scheme Host Port Resource Query/-ies + * + * + * + * `magic` (unsigned long) + * + * Structure identification and validation identifier. + * Identifies as `parsed_url_t` type. + * + * `scheme` (char *) + * + * String representing which protocol is to be expected. + * _Must_ be present. + * "http", "https", "ftp", e.g. + * + * `host` (char *) + * + * String of host, either domain name, IPv4, or IPv6 format. + * _Must_ be present. + * "over.rainbow.oz", "192.168.0.1", "[0000:0000:0000:0001]" + * + * `port` (char *) + * + * String representation of specified port. Must resolve to a valid unsigned + * integer. + * "9000", "80" + * + * `path` (char *) + * + * Path to resource on host. If not specified, assumes root "/". + * "lollipop_guild.wav", "characters/witches/white.dat" + * + * `query` (char *) + * + * Single string of all query parameters in url (if any). + * "arg1=value1&arg2=value2" + * + * + * + * Programmer: Jacob Smith + * + *---------------------------------------------------------------------------- + */ +typedef struct { + unsigned long magic; + char *scheme; /* required */ + char *host; /* required */ + char *port; + char *path; + char *query; +} parsed_url_t; +#define S3COMMS_PARSED_URL_MAGIC 0x21D0DFUL + + +/*---------------------------------------------------------------------------- + * + * Structure: s3r_t + * + * + * + * S3 request structure "handle". + * + * Holds persistent information for Amazon S3 requests. + * + * Instantiated through `H5FD_s3comms_s3r_open()`, copies data into self. + * + * Intended to be re-used for operations on a remote object. + * + * Cleaned up through `H5FD_s3comms_s3r_close()`. + * + * _DO NOT_ share handle between threads: curl easy handle `curlhandle` has + * undefined behavior if called to perform in multiple threads. + * + * + * + * `magic` (unsigned long) + * + * "magic" number identifying this structure as unique type. + * MUST equal `S3R_MAGIC` to be valid. + * + * `curlhandle` (CURL) + * + * Pointer to the curl_easy handle generated for the request. + * + * `httpverb` (char *) + * + * Pointer to NULL-terminated string. HTTP verb, + * e.g. "GET", "HEAD", "PUT", etc. + * + * Default is NULL, resulting in a "GET" request. + * + * `purl` (parsed_url_t *) + * + * Pointer to structure holding the elements of URL for file open. + * + * e.g., "http://bucket.aws.com:8080/myfile.dat?q1=v1&q2=v2" + * parsed into... + * { scheme: "http" + * host: "bucket.aws.com" + * port: "8080" + * path: "myfile.dat" + * query: "q1=v1&q2=v2" + * } + * + * Cannot be NULL. + * + * `region` (char *) + * + * Pointer to NULL-terminated string, specifying S3 "region", + * e.g., "us-east-1". + * + * Required to authenticate. + * + * `secret_id` (char *) + * + * Pointer to NULL-terminated string for "secret" access id to S3 resource. + * + * Requred to authenticate. + * + * `signing_key` (unsigned char *) + * + * Pointer to `SHA256_DIGEST_LENGTH`-long string for "re-usable" signing + * key, generated via + * `HMAC-SHA256(HMAC-SHA256(HMAC-SHA256(HMAC-SHA256("AWS4", + * ""), ""), "aws4_request")` + * which may be re-used for several (up to seven (7)) days from creation? + * Computed once upon file open. + * + * Requred to authenticate. + * + * + * + * Programmer: Jacob Smith + * + *---------------------------------------------------------------------------- + */ +typedef struct { + unsigned long magic; +#ifdef H5_HAVE_ROS3_VFD + CURL *curlhandle; + size_t filesize; + char *httpverb; + parsed_url_t *purl; + char *region; + char *secret_id; + unsigned char *signing_key; +#endif /* ifdef H5_HAVE_ROS3_VFD */ +} s3r_t; +#define S3COMMS_S3R_MAGIC 0x44d8d79 + +/******************************************* + * DECLARATION OF HTTP FIELD LIST ROUTINES * + *******************************************/ + +herr_t H5FD_s3comms_hrb_node_set(hrb_node_t **L, + const char *name, + const char *value); + +/*********************************************** + * DECLARATION OF HTTP REQUEST BUFFER ROUTINES * + ***********************************************/ + +herr_t H5FD_s3comms_hrb_destroy(hrb_t **buf); + +hrb_t * H5FD_s3comms_hrb_init_request(const char *verb, + const char *resource, + const char *host); + +/************************************* + * DECLARATION OF S3REQUEST ROUTINES * + *************************************/ + +H5_DLL herr_t H5FD_s3comms_s3r_close(s3r_t *handle); + +H5_DLL size_t H5FD_s3comms_s3r_get_filesize(s3r_t *handle); + +H5_DLL s3r_t * H5FD_s3comms_s3r_open(const char url[], + const char region[], + const char id[], + const unsigned char signing_key[]); + +H5_DLL herr_t H5FD_s3comms_s3r_read(s3r_t *handle, + haddr_t offset, + size_t len, + void *dest); + +/********************************* + * DECLARATION OF OTHER ROUTINES * + *********************************/ + +H5_DLL struct tm * gmnow(void); + +herr_t H5FD_s3comms_aws_canonical_request(char *canonical_request_dest, + char *signed_headers_dest, + hrb_t *http_request); + +H5_DLL herr_t H5FD_s3comms_bytes_to_hex(char *dest, + const unsigned char *msg, + size_t msg_len, + hbool_t lowercase); + +herr_t H5FD_s3comms_free_purl(parsed_url_t *purl); + +herr_t H5FD_s3comms_HMAC_SHA256(const unsigned char *key, + size_t key_len, + const char *msg, + size_t msg_len, + char *dest); + +herr_t H5FD_s3comms_load_aws_profile(const char *name, + char *key_id_out, + char *secret_access_key_out, + char *aws_region_out); + +herr_t H5FD_s3comms_nlowercase(char *dest, + const char *s, + size_t len); + +herr_t H5FD_s3comms_parse_url(const char *str, + parsed_url_t **purl); + +herr_t H5FD_s3comms_percent_encode_char(char *repr, + const unsigned char c, + size_t *repr_len); + +H5_DLL herr_t H5FD_s3comms_signing_key(unsigned char *md, + const char *secret, + const char *region, + const char *iso8601now); + +herr_t H5FD_s3comms_tostringtosign(char *dest, + const char *req_str, + const char *now, + const char *region); + +H5_DLL herr_t H5FD_s3comms_trim(char *dest, + char *s, + size_t s_len, + size_t *n_written); + +H5_DLL herr_t H5FD_s3comms_uriencode(char *dest, + const char *s, + size_t s_len, + hbool_t encode_slash, + size_t *n_written); + + diff --git a/src/Makefile.am b/src/Makefile.am index 0eaae1a..f737d5d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -63,8 +63,8 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5FA.c H5FAcache.c H5FAdbg.c H5FAdblock.c H5FAdblkpage.c H5FAhdr.c \ H5FAint.c H5FAstat.c H5FAtest.c \ H5FD.c H5FDcore.c \ - H5FDfamily.c H5FDint.c H5FDlog.c \ - H5FDmulti.c H5FDsec2.c H5FDspace.c H5FDstdio.c H5FDtest.c \ + H5FDfamily.c H5FDhdfs.c H5FDint.c H5FDlog.c H5FDs3comms.c \ + H5FDmulti.c H5FDros3.c H5FDsec2.c H5FDspace.c H5FDstdio.c H5FDtest.c \ H5FL.c H5FO.c H5FS.c H5FScache.c H5FSdbg.c H5FSint.c H5FSsection.c \ H5FSstat.c H5FStest.c \ H5G.c H5Gbtree2.c H5Gcache.c \ @@ -138,8 +138,8 @@ include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5vers H5Cpublic.h H5Dpublic.h \ H5Epubgen.h H5Epublic.h H5ESpublic.h H5Fpublic.h \ H5FDpublic.h H5FDcore.h H5FDdirect.h \ - H5FDfamily.h H5FDlog.h H5FDmpi.h H5FDmpio.h \ - H5FDmulti.h H5FDsec2.h H5FDstdio.h H5FDwindows.h \ + H5FDfamily.h H5FDhdfs.h H5FDlog.h H5FDmpi.h H5FDmpio.h \ + H5FDmulti.h H5FDros3.h H5FDsec2.h H5FDstdio.h H5FDwindows.h \ H5Gpublic.h H5Ipublic.h H5Lpublic.h \ H5MMpublic.h H5Opublic.h H5Ppublic.h \ H5PLextern.h H5PLpublic.h \ diff --git a/src/hdf5.h b/src/hdf5.h index c12037f..2201e9e 100644 --- a/src/hdf5.h +++ b/src/hdf5.h @@ -40,16 +40,18 @@ #include "H5Zpublic.h" /* Data filters */ /* Predefined file drivers */ -#include "H5FDcore.h" /* Files stored entirely in memory */ -#include "H5FDdirect.h" /* Linux direct I/O */ -#include "H5FDfamily.h" /* File families */ +#include "H5FDcore.h" /* Files stored entirely in memory */ +#include "H5FDdirect.h" /* Linux direct I/O */ +#include "H5FDfamily.h" /* File families */ +#include "H5FDhdfs.h" /* Hadoop HDFS */ #include "H5FDlog.h" /* sec2 driver with I/O logging (for debugging) */ -#include "H5FDmpi.h" /* MPI-based file drivers */ -#include "H5FDmulti.h" /* Usage-partitioned file family */ -#include "H5FDsec2.h" /* POSIX unbuffered file I/O */ -#include "H5FDstdio.h" /* Standard C buffered I/O */ +#include "H5FDmpi.h" /* MPI-based file drivers */ +#include "H5FDmulti.h" /* Usage-partitioned file family */ +#include "H5FDros3.h" /* R/O S3 "file" I/O */ +#include "H5FDsec2.h" /* POSIX unbuffered file I/O */ +#include "H5FDstdio.h" /* Standard C buffered I/O */ #ifdef H5_HAVE_WINDOWS -#include "H5FDwindows.h" /* Win32 I/O */ +#include "H5FDwindows.h" /* Win32 I/O */ #endif /* Virtual object layer (VOL) connectors */ diff --git a/src/libhdf5.settings.in b/src/libhdf5.settings.in index f856ebc..baa99ea 100644 --- a/src/libhdf5.settings.in +++ b/src/libhdf5.settings.in @@ -79,6 +79,8 @@ Parallel Filtered Dataset Writes: @PARALLEL_FILTERED_WRITES@ I/O filters (external): @EXTERNAL_FILTERS@ MPE: @MPE@ Direct VFD: @DIRECT_VFD@ + (Read-Only) S3 VFD: @ROS3_VFD@ + (Read-Only) HDFS VFD: @HAVE_LIBHDFS@ dmalloc: @HAVE_DMALLOC@ Packages w/ extra debug output: @INTERNAL_DEBUG_OUTPUT@ API tracing: @TRACE_API@ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8333c78..cbd1901 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -267,6 +267,9 @@ set (H5_TESTS enc_dec_plist_cross_platform getname vfd + ros3 + s3comms + hdfs ntypes dangle dtransform diff --git a/test/CMakeVFDTests.cmake b/test/CMakeVFDTests.cmake index 2767bdc..7f661a5 100644 --- a/test/CMakeVFDTests.cmake +++ b/test/CMakeVFDTests.cmake @@ -18,6 +18,7 @@ # included from CMakeTEsts.cmake set (VFD_LIST + hdfs sec2 stdio core diff --git a/test/Makefile.am b/test/Makefile.am index 1b82aa4..dbee9c2 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -59,11 +59,11 @@ TEST_PROG= testhdf5 \ stab gheap evict_on_close farray earray btree2 fheap \ pool accum hyperslab istore bittests dt_arith page_buffer \ dtypes dsets cmpd_dset filter_fail extend direct_chunk external efc \ - objcopy links unlink twriteorder big mtime fillval mount \ - flush1 flush2 app_ref enum set_extent ttsafe enc_dec_plist \ - enc_dec_plist_cross_platform getname vfd ntypes dangle dtransform \ - reserved cross_read freespace mf vds file_image unregister \ - cache_logging cork swmr vol + objcopy links unlink twriteorder big mtime fillval mount flush1 \ + flush2 app_ref enum set_extent ttsafe enc_dec_plist \ + enc_dec_plist_cross_platform getname vfd ros3 s3comms hdfs ntypes \ + dangle dtransform reserved cross_read freespace mf vds file_image \ + unregister cache_logging cork swmr vol # List programs to be built when testing here. # error_test and err_compat are built at the same time as the other tests, but executed by testerror.sh. @@ -145,7 +145,7 @@ ttsafe_SOURCES=ttsafe.c ttsafe_dcreate.c ttsafe_error.c ttsafe_cancel.c \ ttsafe_acreate.c cache_image_SOURCES=cache_image.c genall5.c -VFD_LIST = sec2 stdio core core_paged split multi family +VFD_LIST = hdfs sec2 stdio core core_paged split multi family if DIRECT_VFD_CONDITIONAL VFD_LIST += direct endif @@ -201,8 +201,8 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ unlink_chunked.h5 btree2.h5 btree2_tmp.h5 objcopy_src.h5 objcopy_dst.h5 \ objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 farray_tmp.h5 \ - earray.h5 earray_tmp.h5 efc[0-5].h5 log_vfd_out.log \ - new_multi_file_v16-r.h5 new_multi_file_v16-s.h5 \ + earray.h5 earray_tmp.h5 efc[0-5].h5 log_vfd_out.log log_ros3_out.log \ + log_s3comms_out.log new_multi_file_v16-r.h5 new_multi_file_v16-s.h5 \ split_get_file_image_test-m.h5 split_get_file_image_test-r.h5 \ file_image_core_test.h5.copy unregister_filter_1.h5 unregister_filter_2.h5 \ vds_virt.h5 vds_dapl.h5 vds_src_[0-1].h5 \ diff --git a/test/hdfs.c b/test/hdfs.c new file mode 100644 index 0000000..11b9918 --- /dev/null +++ b/test/hdfs.c @@ -0,0 +1,1836 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Read-Only HDFS Virtual File Driver (VFD) * + * Copyright (c) 2018, The HDF Group. * + * * + * All rights reserved. * + * * + * NOTICE: * + * All information contained herein is, and remains, the property of The HDF * + * Group. The intellectual and technical concepts contained herein are * + * proprietary to The HDF Group. Dissemination of this information or * + * reproduction of this material is strictly forbidden unless prior written * + * permission is obtained from The HDF Group. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: + * + * Verify behavior for Read-Only HDFS VFD. + * + * Demonstrates basic use cases and fapl interaction. + * + * Programmer: Jacob Smith + * 2018-04-23 + */ + +#include "h5test.h" /* testing utilities */ +#include "H5FDhdfs.h" /* this file driver's utilities */ + + +#define HDFS_TEST_DEBUG 0 +#define HDFS_TEST_MAX_BUF_SIZE 256 +#if 0 +#define S3_TEST_MAX_URL_SIZE 256 +#endif /* s3comms relic */ + +/***************************************************************************** + * + * FILE-LOCAL TESTING MACROS + * + * Purpose: + * + * 1) Upon test failure, goto-jump to single-location teardown in test + * function. E.g., `error:` (consistency with HDF corpus) or + * `failed:` (reflects purpose). + * >>> using "error", in part because `H5E_BEGIN_TRY` expects it. + * 2) Increase clarity and reduce overhead found with `TEST_ERROR`. + * e.g., "if(somefunction(arg, arg2) < 0) TEST_ERROR:" + * requires reading of entire line to know whether this if/call is + * part of the test setup, test operation, or a test unto itself. + * 3) Provide testing macros with optional user-supplied failure message; + * if not supplied (NULL), generate comparison output in the spirit of + * test-driven development. E.g., "expected 5 but was -3" + * User messages clarify test's purpose in code, encouraging description + * without relying on comments. + * 4) Configurable expected-actual order in generated comparison strings. + * Some prefer `VERIFY(expected, actual)`, others + * `VERIFY(actual, expected)`. Provide preprocessor ifdef switch + * to satifsy both parties, assuming one paradigm per test file. + * (One could #undef and redefine the flag through the file as desired, + * but _why_.) + * + * Provided as courtesy, per consideration for inclusion in the library + * proper. + * + * Macros: + * + * JSVERIFY_EXP_ACT - ifdef flag, configures comparison order + * FAIL_IF() - check condition + * FAIL_UNLESS() - check _not_ condition + * JSVERIFY() - long-int equality check; prints reason/comparison + * JSVERIFY_NOT() - long-int inequality check; prints + * JSVERIFY_STR() - string equality check; prints + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *****************************************************************************/ + + +/*---------------------------------------------------------------------------- + * + * ifdef flag: JSVERIFY_EXP_ACT + * + * JSVERIFY macros accept arguments as (EXPECTED, ACTUAL[, reason]) + * default, if this is undefined, is (ACTUAL, EXPECTED[, reason]) + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_EXP_ACT 1L + + +/*---------------------------------------------------------------------------- + * + * Macro: JSFAILED_AT() + * + * Purpose: + * + * Preface a test failure by printing "*FAILED*" and location to stdout + * Similar to `H5_FAILED(); AT();` from h5test.h + * + * *FAILED* at somefile.c:12 in function_name()... + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSFAILED_AT() { \ + HDprintf("*FAILED* at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: FAIL_IF() + * + * Purpose: + * + * Make tests more accessible and less cluttered than + * `if (thing == otherthing()) TEST_ERROR` + * paradigm. + * + * The following lines are roughly equivalent: + * + * `if (myfunc() < 0) TEST_ERROR;` (as seen elsewhere in HDF tests) + * `FAIL_IF(myfunc() < 0)` + * + * Prints a generic "FAILED AT" line to stdout and jumps to `error`, + * similar to `TEST_ERROR` in h5test.h + * + * Programmer: Jacob Smith + * 2017-10-23 + * + *---------------------------------------------------------------------------- + */ +#define FAIL_IF(condition) \ +if (condition) { \ + JSFAILED_AT() \ + goto error; \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: FAIL_UNLESS() + * + * Purpose: + * + * TEST_ERROR wrapper to reduce cognitive overhead from "negative tests", + * e.g., "a != b". + * + * Opposite of FAIL_IF; fails if the given condition is _not_ true. + * + * `FAIL_IF( 5 != my_op() )` + * is equivalent to + * `FAIL_UNLESS( 5 == my_op() )` + * However, `JSVERIFY(5, my_op(), "bad return")` may be even clearer. + * (see JSVERIFY) + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#if 0 /* UNUSED */ +#define FAIL_UNLESS(condition) \ +if (!(condition)) { \ + JSFAILED_AT() \ + goto error; \ +} +#endif /* UNUSED */ + + +/*---------------------------------------------------------------------------- + * + * Macro: JSERR_LONG() + * + * Purpose: + * + * Print an failure message for long-int arguments. + * ERROR-AT printed first. + * If `reason` is given, it is printed on own line and newlined after + * else, prints "expected/actual" aligned on own lines. + * + * *FAILED* at myfile.c:488 in somefunc()... + * forest must be made of trees. + * + * or + * + * *FAILED* at myfile.c:488 in somefunc()... + * ! Expected 425 + * ! Actual 3 + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSERR_LONG(expected, actual, reason) { \ + JSFAILED_AT() \ + if (reason!= NULL) { \ + HDprintf("%s\n", (reason)); \ + } else { \ + HDprintf(" ! Expected %ld\n ! Actual %ld\n", \ + (long)(expected), (long)(actual)); \ + } \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: JSERR_STR() + * + * Purpose: + * + * Print an failure message for string arguments. + * ERROR-AT printed first. + * If `reason` is given, it is printed on own line and newlined after + * else, prints "expected/actual" aligned on own lines. + * + * *FAILED* at myfile.c:421 in myfunc()... + * Blue and Red strings don't match! + * + * or + * + * *FAILED* at myfile.c:421 in myfunc()... + * !!! Expected: + * this is my expected + * string + * !!! Actual: + * not what I expected at all + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSERR_STR(expected, actual, reason) { \ + JSFAILED_AT() \ + if ((reason) != NULL) { \ + HDprintf("%s\n", (reason)); \ + } else { \ + HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", \ + (expected), (actual)); \ + } \ +} + + + +#ifdef JSVERIFY_EXP_ACT + + +/*---------------------------------------------------------------------------- + * + * Macro: JSVERIFY() + * + * Purpose: + * + * Verify that two long integers are equal. + * If unequal, print failure message + * (with `reason`, if not NULL; expected/actual if NULL) + * and jump to `error` at end of function + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY(expected, actual, reason) \ +if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ +} /* JSVERIFY */ + + +/*---------------------------------------------------------------------------- + * + * Macro: JSVERIFY_NOT() + * + * Purpose: + * + * Verify that two long integers are _not_ equal. + * If equal, print failure message + * (with `reason`, if not NULL; expected/actual if NULL) + * and jump to `error` at end of function + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_NOT(expected, actual, reason) \ +if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ +} /* JSVERIFY_NOT */ + + +/*---------------------------------------------------------------------------- + * + * Macro: JSVERIFY_STR() + * + * Purpose: + * + * Verify that two strings are equal. + * If unequal, print failure message + * (with `reason`, if not NULL; expected/actual if NULL) + * and jump to `error` at end of function + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_STR(expected, actual, reason) \ +if (strcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ +} /* JSVERIFY_STR */ + + +#else +/* JSVERIFY_EXP_ACT not defined + * + * Repeats macros above, but with actual/expected parameters reversed. + */ + + +/*---------------------------------------------------------------------------- + * Macro: JSVERIFY() + * See: JSVERIFY documentation above. + * Programmer: Jacob Smith + * 2017-10-14 + *---------------------------------------------------------------------------- + */ +#define JSVERIFY(actual, expected, reason) \ +if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)); \ + goto error; \ +} /* JSVERIFY */ + + +/*---------------------------------------------------------------------------- + * Macro: JSVERIFY_NOT() + * See: JSVERIFY_NOT documentation above. + * Programmer: Jacob Smith + * 2017-10-14 + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_NOT(actual, expected, reason) \ +if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ +} /* JSVERIFY_NOT */ + + +/*---------------------------------------------------------------------------- + * Macro: JSVERIFY_STR() + * See: JSVERIFY_STR documentation above. + * Programmer: Jacob Smith + * 2017-10-14 + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_STR(actual, expected, reason) \ +if (strcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ +} /* JSVERIFY_STR */ + +#endif /* ifdef/else JSVERIFY_EXP_ACT */ + +/******************************** + * OTHER MACROS AND DEFINITIONS * + ********************************/ + +/* copied from src/hdfs.c + */ +#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) +#define MAX_HDFS_NAMENODE_NAME 128 + +/******************************* + * FILE-LOCAL GLOBAL VARIABLES * + *******************************/ +static const char filename_missing[] = "/tmp/missing.txt"; +static const char filename_bard[] = "/tmp/t8.shakespeare.txt"; +static const char filename_raven[] = "/tmp/Poe_Raven.txt"; +static const char filename_example_h5[] = "/tmp/t.h5"; +static H5FD_hdfs_fapl_t default_fa = { + 1, /* fa version */ + "localhost", /* namenode name */ + 0, /* namenode port */ + "", /* user name */ + "", /* kerberos path */ + 1024, /* buffer size */ +}; + +/****************** + * TEST FUNCTIONS * + ******************/ + + +/*--------------------------------------------------------------------------- + * + * Function: test_fapl_config_validation() + * + * Purpose: + * + * Test data consistency of fapl configuration. + * Tests `H5FD_hdfs_validate_config` indirectly through `H5Pset_fapl_hdfs`. + * + * Return: + * + * PASSED : 0 + * FAILED : 1 + * + * Programmer: Jacob Smith + * 2018-04-25 + * + * Changes: None. + * + *--------------------------------------------------------------------------- + */ +static int +test_fapl_config_validation(void) +{ + /********************* + * test-local macros * + *********************/ + + /************************* + * test-local structures * + *************************/ + + struct testcase { + const char *msg; + herr_t expected; + H5FD_hdfs_fapl_t config; + }; + + /************************ + * test-local variables * + ************************/ + + hid_t fapl_id = -1; /* file access property list ID */ + H5FD_hdfs_fapl_t config; + H5FD_hdfs_fapl_t fa_fetch; + herr_t success = SUCCEED; + unsigned int i = 0; + unsigned int ncases = 6; /* should equal number of cases */ + struct testcase *case_ptr = NULL; /* dumb work-around for possible */ + /* dynamic cases creation because */ + /* of compiler warnings Wlarger-than */ + struct testcase cases_arr[] = { + { "default config fapl", + SUCCEED, + { 1, /* version */ + "localhost", /* namenode_name */ + 0, /* namenode_port number */ + "some_user", /* user_name */ + "", /* kerberos_ticket_cache path */ + -1, /* stream_buffer_size */ + }, + }, + { "invalid version number (2)", + FAIL, + { 2, /* version */ + "localhost", /* namenode_name */ + 0, /* namenode_port number */ + "some_user", /* user_name */ + "", /* kerberos_ticket_cache path */ + -1, /* stream_buffer_size */ + }, + }, + { "invalid version number (0)", + FAIL, + { 0, /* version */ + "localhost", /* namenode_name */ + 0, /* namenode_port number */ + "some_user", /* user_name */ + "", /* kerberos_ticket_cache path */ + -1, /* stream_buffer_size */ + }, + }, + { "nonsense kerberos path still ok?", + SUCCEED, + { 1, /* version */ + "localhost", /* namenode_name */ + 0, /* namenode_port number */ + "some_user", /* user_name */ + "pathToSomewhere", /* kerberos_ticket_cache path */ + -1, /* stream_buffer_size */ + }, + }, + { "namenode port number too high", + FAIL, + { 1, /* version */ + "localhost", /* namenode_name */ + 88000, /* namenode_port number */ + "some_user", /* user_name */ + "", /* kerberos_ticket_cache path */ + -1, /* stream_buffer_size */ + }, + }, + { "negative namenode port number", + FAIL, + { 1, /* version */ + "localhost", /* namenode_name */ + -1, /* namenode_port number */ + "some_user", /* user_name */ + "", /* kerberos_ticket_cache path */ + -1, /* stream_buffer_size */ + }, + }, + }; + + TESTING("HDFS fapl configuration validation"); + + /********* + * TESTS * + *********/ + + for (i = 0; i < ncases; i++) { + + /*--------------- + * per-test setup + *--------------- + */ + case_ptr = &cases_arr[i]; + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( fapl_id < 0 ) /* sanity-check */ + + /*----------------------------------- + * Actually test -- set fapl. + * Mute stack trace in failure cases. + *----------------------------------- + */ + H5E_BEGIN_TRY { + /* `H5FD_hdfs_validate_config(...)` is static/private + * to src/hdfs.c and cannot (and should not?) be tested directly? + * Instead, validate config through public api. + */ + success = H5Pset_fapl_hdfs(fapl_id, &case_ptr->config); + } H5E_END_TRY; + + JSVERIFY( case_ptr->expected, success, case_ptr->msg ) + + /* Make sure we can get back what we put in. + * Only valid if the fapl configuration does not result in error. + */ + if (success == SUCCEED) { + config = case_ptr->config; + JSVERIFY( SUCCEED, + H5Pget_fapl_hdfs(fapl_id, &fa_fetch), + "unable to get fapl" ) + JSVERIFY( H5FD__CURR_HDFS_FAPL_T_VERSION, + fa_fetch.version, + "invalid version number" ) + JSVERIFY( config.version, + fa_fetch.version, + "version number mismatch" ) + JSVERIFY( config.namenode_port, + fa_fetch.namenode_port, + "namenode port mismatch" ) + JSVERIFY( config.stream_buffer_size, + fa_fetch.stream_buffer_size, + "streambuffer size mismatch" ) + JSVERIFY_STR( config.namenode_name, + fa_fetch.namenode_name, + NULL ) + JSVERIFY_STR( config.user_name, + fa_fetch.user_name, + NULL ) + JSVERIFY_STR( config.kerberos_ticket_cache, + fa_fetch.kerberos_ticket_cache, + NULL ) + } + + /*----------------------------- + * per-test sanitation/teardown + *----------------------------- + */ + FAIL_IF( FAIL == H5Pclose(fapl_id) ) + fapl_id = -1; + + } /* for each test case */ + + PASSED(); + return 0; + +error: + /*********** + * CLEANUP * + ***********/ + + if (fapl_id < 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + } + return 1; + +} /* test_fapl_config_validation */ + + +/*------------------------------------------------------------------------- + * + * Function: test_hdfs_fapl() + * + * Purpose: Tests the file handle interface for the HDFS driver. + * + * For now, test only fapl & flags. Extend as the + * work on the VFD continues. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Jacob Smith + * 2018-04-25 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ +static int +test_hdfs_fapl(void) +{ + /************************ + * test-local variables * + ************************/ + + hid_t fapl_id = -1; /* file access property list ID */ + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ + H5FD_hdfs_fapl_t hdfs_fa_0 = { + 1, /* version*/ + "", /* node name */ + 9000, /* node port */ + "", /* username */ + "", /* kerb cache path */ + 1024, /* stream buffer size */ + }; + + TESTING("HDFS fapl "); + + /* Set property list and file name for HDFS driver. + */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( fapl_id < 0 ) + + FAIL_IF( FAIL == H5Pset_fapl_hdfs(fapl_id, &hdfs_fa_0) ) + + driver_id = H5Pget_driver(fapl_id); + FAIL_IF( driver_id < 0 ) + + /**************** + * Check that the VFD feature flags are correct + * SPEC MAY CHANGE + ******************/ + + FAIL_IF( H5FDdriver_query(driver_id, &driver_flags) < 0 ) + + JSVERIFY_NOT( 0, (driver_flags & H5FD_FEAT_DATA_SIEVE), + "bit(s) in `driver_flags` must align with " + "H5FD_FEAT_DATA_SIEVE" ) + + JSVERIFY( H5FD_FEAT_DATA_SIEVE, driver_flags, + "H5FD_FEAT_DATA_SIEVE should be the only supported flag") + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + + return 1; + +} /* test_hdfs_fapl() */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_vfd_open() + * + * Purpose: + * + * Demonstrate/specify VFD-level "Open" failure cases + * + * Return: + * + * PASSED : 0 + * FAILED : 1 + * + * Programmer: Jacob Smith + * 2018-06-07 + * + *--------------------------------------------------------------------------- + */ +static int +test_vfd_open(void) +{ + /********************* + * test-local macros * + *********************/ + +/* selectors for which fapl to use in testcase */ +#define FAPL_H5P_DEFAULT -2 +#define FAPL_UNCONFIGURED -3 /* H5P_FILE_ACCESS */ +#define FAPL_HDFS -4 + +#ifdef H5_HAVE_LIBHDFS + /************************* + * test-local structures * + *************************/ + + struct test_condition { + const char *message; + const char *url; + unsigned flags; + int which_fapl; + haddr_t maxaddr; + hbool_t might_use_other_driver; + }; + + /************************ + * test-local variables * + ************************/ + + struct test_condition failing_conditions[] = { + { "default property list (H5P_DEFAULT) is invalid", + filename_bard, + H5F_ACC_RDONLY, + FAPL_H5P_DEFAULT, + MAXADDR, + TRUE, + }, + { "generic file access property list is invalid", + filename_bard, + H5F_ACC_RDONLY, + FAPL_UNCONFIGURED, + MAXADDR, + TRUE, + }, + { "filename cannot be null", + NULL, + H5F_ACC_RDONLY, + FAPL_HDFS, + MAXADDR, + FALSE, + }, + { "filename cannot be empty", + "", + H5F_ACC_RDONLY, + FAPL_HDFS, + MAXADDR, + FALSE, + }, + { "file at filename must exist", + filename_missing, + H5F_ACC_RDONLY, + FAPL_HDFS, + MAXADDR, + FALSE, + }, + { "read-write flag not supported", + filename_bard, + H5F_ACC_RDWR, + FAPL_HDFS, + MAXADDR, + FALSE, + }, + { "truncate flag not supported", + filename_bard, + H5F_ACC_TRUNC, + FAPL_HDFS, + MAXADDR, + FALSE, + }, + { "create flag not supported", + filename_bard, + H5F_ACC_CREAT, + FAPL_HDFS, + MAXADDR, + FALSE, + }, + { "EXCL flag not supported", + filename_bard, + H5F_ACC_EXCL, + FAPL_HDFS, + MAXADDR, + FALSE, + }, + { "maxaddr cannot be 0 (caught in `H5FD_open()`)", + filename_bard, + H5F_ACC_RDONLY, + FAPL_HDFS, + 0, + FALSE, + }, + }; +#endif /* H5_HAVE_LIBHDFS */ + H5FD_t *fd = NULL; + hid_t fapl_hdfs = -1; + hid_t fapl_unconfigured = -1; + unsigned i = 0; + unsigned failing_conditions_count = 10; + + TESTING("HDFS VFD-level open"); + +#ifndef H5_HAVE_LIBHDFS + SKIPPED(); + puts(" HDFS VFD is not enabled"); + fflush(stdout); + return 0; +#else + fapl_unconfigured = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( fapl_unconfigured < 0 ) + + fapl_hdfs = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( fapl_hdfs < 0 ) + FAIL_IF( FAIL == H5Pset_fapl_hdfs(fapl_hdfs, &default_fa) ) + + /********* + * TESTS * + *********/ + + /* all the test cases that will _not_ open + */ + for (i = 0; i < failing_conditions_count; i++) { + struct test_condition T = failing_conditions[i]; + hid_t fapl_id = H5P_DEFAULT; + + fd = NULL; + + if (T.which_fapl == FAPL_UNCONFIGURED) + fapl_id = fapl_unconfigured; + else if (T.which_fapl == FAPL_HDFS) + fapl_id = fapl_hdfs; + +#if HDFS_TEST_DEBUG + HDfprintf(stderr, "testing: %s\n", T.message); +#endif /* HDFS_TEST_DEBUG */ + + H5E_BEGIN_TRY { + fd = H5FDopen(T.url, T.flags, fapl_id, T.maxaddr); + } H5E_END_TRY; + if (NULL != fd) { + if (TRUE == T.might_use_other_driver && + H5FD_HDFS != fd->driver_id) + { + HDfprintf(stderr, "\n!!!!! WARNING !!!!!\n" \ + " Successful open of file on local system " \ + "with non-HDFS VFD.\n"); + JSVERIFY(SUCCEED, H5FDclose(fd), + "unable to close errant open"); + fd = NULL; + } else { + JSVERIFY(1, 0, T.message); /* print message and fail */ + } + } + } + + FAIL_IF( NULL != fd ) /* sanity check */ + +#if HDFS_TEST_DEBUG + HDfprintf(stderr, "nominal open\n"); +#endif /* HDFS_TEST_DEBUG */ + + /* finally, show that a file can be opened + */ + fd = H5FDopen( + filename_bard, + H5F_ACC_RDONLY, + fapl_hdfs, + MAXADDR); + FAIL_IF( NULL == fd ) + + /************ + * TEARDOWN * + ************/ + +#if HDFS_TEST_DEBUG + HDfprintf(stderr, "teardown...\n"); +#endif /* HDFS_TEST_DEBUG */ + + FAIL_IF( FAIL == H5FDclose(fd) ) + fd = NULL; + + FAIL_IF( FAIL == H5Pclose(fapl_hdfs) ) + fapl_hdfs = -1; + + FAIL_IF( FAIL == H5Pclose(fapl_unconfigured) ) + fapl_unconfigured = -1; + + PASSED(); + return 0; +#endif /* H5_HAVE_LIBHDFS */ + +error: + /*********** + * CLEANUP * + ***********/ + + if (fd) + (void)H5FDclose(fd); + H5E_BEGIN_TRY { + if (fapl_hdfs >= 0) + (void)H5Pclose(fapl_hdfs); + if (fapl_unconfigured >= 0) + (void)H5Pclose(fapl_unconfigured); + } H5E_END_TRY; + + return 1; + +#undef FAPL_H5P_DEFAULT +#undef FAPL_UNCONFIGURED +#undef FAPL_HDFS + +} /* test_vfd_open */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_eof_eoa() + * + * Purpose: + * + * Demonstrate behavior of get_eof, get_eoa, and set_eoa. + * + * Return: + * + * PASSED : 0 + * FAILED : 1 + * + * Programmer: Jacob Smith + * 2018-06-07 + * + *--------------------------------------------------------------------------- + */ +static int +test_eof_eoa(void) +{ + /********************* + * test-local macros * + *********************/ + + /************************* + * test-local structures * + *************************/ + + /************************ + * test-local variables * + ************************/ + + H5FD_t *fd_shakespeare = NULL; + hid_t fapl_id = -1; + + TESTING("HDFS eof/eoa gets and sets"); + +#ifndef H5_HAVE_LIBHDFS + SKIPPED(); + puts(" HDFS VFD is not enabled"); + fflush(stdout); + return 0; +#else + /********* + * SETUP * + *********/ + + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( 0 > fapl_id ) + FAIL_IF( FAIL == H5Pset_fapl_hdfs(fapl_id, &default_fa) ) + + fd_shakespeare = H5FDopen( + filename_bard, + H5F_ACC_RDONLY, + fapl_id, + HADDR_UNDEF); + FAIL_IF( NULL == fd_shakespeare ) + + /********* + * TESTS * + *********/ + + /* verify as found + */ + JSVERIFY( 5458199, H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), NULL ) + JSVERIFY( H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), + H5FDget_eof(fd_shakespeare, H5FD_MEM_DRAW), + "mismatch between DEFAULT and RAW memory types" ) + JSVERIFY( 0, + H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), + "EoA should be unset by H5FDopen" ) + + /* set EoA below EoF + */ + JSVERIFY( SUCCEED, + H5FDset_eoa(fd_shakespeare, H5FD_MEM_DEFAULT, 44442202), + "unable to set EoA (lower)" ) + JSVERIFY( 5458199, + H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), + "EoF changed" ) + JSVERIFY( 44442202, + H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), + "EoA unchanged" ) + + /* set EoA above EoF + */ + JSVERIFY( SUCCEED, + H5FDset_eoa(fd_shakespeare, H5FD_MEM_DEFAULT, 6789012), + "unable to set EoA (higher)" ) + JSVERIFY( 5458199, + H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), + "EoF changed" ) + JSVERIFY( 6789012, + H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), + "EoA unchanged" ) + + /************ + * TEARDOWN * + ************/ + + FAIL_IF( FAIL == H5FDclose(fd_shakespeare) ) + fd_shakespeare = NULL; + + FAIL_IF( FAIL == H5Pclose(fapl_id) ) + fapl_id = -1; + + PASSED(); + return 0; +#endif /* H5_HAVE_LIBHDFS */ + +error: + /*********** + * CLEANUP * + ***********/ + + if (fd_shakespeare != NULL) { + (void)H5FDclose(fd_shakespeare); + } + if (fapl_id >= 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + } + + return 1; + +} /* test_eof_eoa */ + + +/*----------------------------------------------------------------------------- + * + * Function: test_H5FDread_without_eoa_set_fails() + * + * Purpose: + * + * Demonstrate a not-obvious constraint by the library, preventing + * file read before EoA is set + * + * Programmer: Jacob Smith + * 2018-06-08 + * + *----------------------------------------------------------------------------- + */ +static int +test_H5FDread_without_eoa_set_fails(void) +{ +#ifdef H5_HAVE_LIBHDFS + char buffer[HDFS_TEST_MAX_BUF_SIZE]; + unsigned int i = 0; +#endif /* H5_HAVE_LIBHDFS */ + H5FD_t *file_shakespeare = NULL; + hid_t fapl_id = -1; + + TESTING("HDFS VFD read-eoa temporal coupling library limitation"); + +#ifndef H5_HAVE_LIBHDFS + SKIPPED(); + puts(" HDFS VFD is not enabled"); + fflush(stdout); + return 0; +#else + /********* + * SETUP * + *********/ + + /* create HDFS fapl + */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( fapl_id < 0 ) + FAIL_IF( FAIL == H5Pset_fapl_hdfs(fapl_id, &default_fa) ) + + file_shakespeare = H5FDopen( + filename_bard, + H5F_ACC_RDONLY, + fapl_id, + MAXADDR); + FAIL_IF( NULL == file_shakespeare ) + + JSVERIFY( 0, H5FDget_eoa(file_shakespeare, H5FD_MEM_DEFAULT), + "EoA should remain unset by H5FDopen" ) + + /* zero buffer contents */ + for (i = 0; i < HDFS_TEST_MAX_BUF_SIZE; i++) { + buffer[i] = 0; + } + + /******** + * TEST * + ********/ + + H5E_BEGIN_TRY { /* mute stack trace on expected failure */ + JSVERIFY( FAIL, + H5FDread(file_shakespeare, + H5FD_MEM_DRAW, + H5P_DEFAULT, + 1200699, + 102, + buffer), + "cannot read before eoa is set" ) + } H5E_END_TRY; + for (i = 0; i < HDFS_TEST_MAX_BUF_SIZE; i++) { + JSVERIFY( 0, (unsigned)buffer[i], "buffer was modified by write!" ) + } + + /************ + * TEARDOWN * + ************/ + + FAIL_IF( FAIL == H5FDclose(file_shakespeare) ) + file_shakespeare = NULL; + + FAIL_IF( FAIL == H5Pclose(fapl_id) ) + fapl_id = -1; + + PASSED(); + return 0; +#endif /* H5_HAVE_LIBHDFS */ + +error: + /*********** + * CLEANUP * + ***********/ + + if (file_shakespeare) { + (void)H5FDclose(file_shakespeare); + } + if (fapl_id >= 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + } + + return 1; + +} /* test_H5FDread_without_eoa_set_fails */ + + + +/*--------------------------------------------------------------------------- + * + * Function: test_read() + * + * Purpose: + * + * Return: + * + * PASSED : 0 + * FAILED : 1 + * + * Programmer: Jacob Smith + * 2018-06-08 + * + *--------------------------------------------------------------------------- + */ +static int +test_read(void) +{ + /********************* + * test-local macros * + *********************/ + +#ifdef H5_HAVE_LIBHDFS + /************************* + * test-local structures * + *************************/ + struct testcase { + const char *message; /* purpose of test case */ + haddr_t eoa_set; /* set file EOA to this prior to read */ + size_t addr; /* offset of read in file */ + size_t len; /* length of read in file */ + herr_t success; /* expected return value of read function */ + const char *expected; /* expected contents of buffer; failure ignores */ + }; + + /************************ + * test-local variables * + ************************/ + struct testcase cases[] = { + { "successful range-get", + 6464, + 5691, + 32, /* fancy quotes are three bytes each(?) */ + SUCCEED, + "Quoth the Raven “Nevermore.”", + }, + { "read past EOA fails (EOA < EOF < addr)", + 3000, + 4000, + 100, + FAIL, + NULL, + }, + { "read overlapping EOA fails (EOA < addr < EOF < (addr+len))", + 3000, + 8000, + 100, + FAIL, + NULL, + }, + { "read past EOA/EOF fails ((EOA==EOF) < addr)", + 6464, + 7000, + 100, + FAIL, + NULL, + }, + { "read overlapping EOA/EOF fails (addr < (EOA==EOF) < (addr+len))", + 6464, + 6400, + 100, + FAIL, + NULL, + }, + { "read between EOF and EOA fails (EOF < addr < (addr+len) < EOA)", + 8000, + 7000, + 100, + FAIL, + NULL, + }, + }; + unsigned testcase_count = 6; + unsigned test_i = 0; + struct testcase test; + herr_t open_return = FAIL; + char buffer[HDFS_TEST_MAX_BUF_SIZE]; + unsigned int i = 0; +#endif /* H5_HAVE_LIBHDFS */ + H5FD_t *file_raven = NULL; + hid_t fapl_id = -1; + + TESTING("HDFS VFD read/range-gets"); + +#ifndef H5_HAVE_LIBHDFS + SKIPPED(); + puts(" HDFS VFD is not enabled"); + fflush(stdout); + return 0; +#else + /********* + * SETUP * + *********/ + + /* create HDFS fapl + */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( fapl_id < 0 ) + FAIL_IF( FAIL == H5Pset_fapl_hdfs(fapl_id, &default_fa) ) + + /* zero buffer contents */ + for (i = 0; i < HDFS_TEST_MAX_BUF_SIZE; i++) { + buffer[i] = 0; + } + + /* open file + */ + file_raven = H5FDopen( + filename_raven, + H5F_ACC_RDONLY, + fapl_id, + HADDR_UNDEF); /* Demonstrate success with "automatic" value */ + FAIL_IF( NULL == file_raven ) + + JSVERIFY( 6464, H5FDget_eof(file_raven, H5FD_MEM_DEFAULT), NULL ) + + /********* + * TESTS * + *********/ + + for (test_i = 0; test_i < testcase_count; test_i++) { + + /* -------------- * + * per-test setup * + * -------------- */ + + test = cases[test_i]; + open_return = FAIL; + + FAIL_IF( HDFS_TEST_MAX_BUF_SIZE < test.len ) /* buffer too small! */ + + FAIL_IF( FAIL == + H5FDset_eoa( file_raven, H5FD_MEM_DEFAULT, test.eoa_set) ) + + /* zero buffer contents */ + for (i = 0; i < HDFS_TEST_MAX_BUF_SIZE; i++) { + buffer[i] = 0; + } + + /* ------------ * + * conduct test * + * ------------ */ + + H5E_BEGIN_TRY { + open_return = H5FDread( + file_raven, + H5FD_MEM_DRAW, + H5P_DEFAULT, + test.addr, + test.len, + buffer); + } H5E_END_TRY; + + JSVERIFY( test.success, + open_return, + test.message ) + + if (open_return == SUCCEED) { + JSVERIFY_STR( test.expected, buffer, NULL ) + } + + } /* for each testcase */ + + /************ + * TEARDOWN * + ************/ + + FAIL_IF( FAIL == H5FDclose(file_raven) ) + file_raven = NULL; + + FAIL_IF( FAIL == H5Pclose(fapl_id) ) + fapl_id = -1; + + PASSED(); + return 0; +#endif /* H5_HAVE_LIBHDFS */ + +error: + /*********** + * CLEANUP * + ***********/ + + if (file_raven != 0) + (void)H5FDclose(file_raven); + if (fapl_id >= 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + } + + return 1; + +} /* test_read */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_noops_and_autofails() + * + * Purpose: + * + * Demonstrate the unavailable and do-nothing routines unique to + * Read-Only VFD. + * + * Return: + * + * PASSED : 0 + * FAILED : 1 + * + * Programmer: Jacob Smith + * 2017-11-06 + * + * Changes: + * + modify from S3VFD codebase to HDFS; Minor changes, mostly. + * + Jacob Smith 2018-06-08 + * + *--------------------------------------------------------------------------- + */ +static int +test_noops_and_autofails(void) +{ + /********************* + * test-local macros * + *********************/ + + /************************* + * test-local structures * + *************************/ + + /************************ + * test-local variables * + ************************/ + + hid_t fapl_id = -1; + H5FD_t *file = NULL; + const char data[36] = "The Force shall be with you, always"; + + TESTING("HDFS VFD always-fail and no-op routines"); + + /********* + * SETUP * + *********/ + +#ifndef H5_HAVE_LIBHDFS + SKIPPED(); + puts(" HDFS VFD is not enabled"); + fflush(stdout); + return 0; +#else + /* create HDFS fapl + */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( fapl_id < 0 ) + FAIL_IF( FAIL == H5Pset_fapl_hdfs(fapl_id, &default_fa) ) + + /* open file + */ + file = H5FDopen( + filename_bard, + H5F_ACC_RDONLY, + fapl_id, + HADDR_UNDEF); + FAIL_IF( NULL == file ) + + /********* + * TESTS * + *********/ + + /* auto-fail calls to write and truncate + */ + H5E_BEGIN_TRY { + JSVERIFY( FAIL, + H5FDwrite(file, H5FD_MEM_DRAW, H5P_DEFAULT, 1000, 35, data), + "write must fail" ) + } H5E_END_TRY; + + H5E_BEGIN_TRY { + JSVERIFY( FAIL, + H5FDtruncate(file, H5P_DEFAULT, FALSE), + "truncate must fail" ) + } H5E_END_TRY; + + H5E_BEGIN_TRY { + JSVERIFY( FAIL, + H5FDtruncate(file, H5P_DEFAULT, TRUE), + "truncate must fail (closing)" ) + } H5E_END_TRY; + + /* no-op calls to `lock()` and `unlock()` + */ + JSVERIFY( SUCCEED, + H5FDlock(file, TRUE), + "lock always succeeds; has no effect" ) + JSVERIFY( SUCCEED, + H5FDlock(file, FALSE), + NULL ) + JSVERIFY( SUCCEED, + H5FDunlock(file), + NULL ) + /* Lock/unlock with null file or similar error crashes tests. + * HDassert in calling heirarchy, `H5FD[un]lock()` and `H5FD_[un]lock()` + */ + + /************ + * TEARDOWN * + ************/ + + FAIL_IF( FAIL == H5FDclose(file) ) + file = NULL; + + FAIL_IF( FAIL == H5Pclose(fapl_id) ) + fapl_id = -1; + + PASSED(); + return 0; +#endif /* H5_HAVE_LIBHDFS */ + +error: + /*********** + * CLEANUP * + ***********/ + + if (fapl_id >= 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + } + if (file != NULL) { + (void)H5FDclose(file); + } + + return 1; + +} /* test_noops_and_autofails*/ + + +/*--------------------------------------------------------------------------- + * + * Function: test_cmp() + * + * Purpose: + * + * Verify "file comparison" behavior. + * + * Return: + * + * PASSED : 0 + * FAILED : 1 + * + * Programmer: Jacob Smith + * 2017-11-06 + * + *--------------------------------------------------------------------------- + */ +static int +test_cmp(void) +{ +#if 0 + /********************* + * test-local macros * + *********************/ + + /************************* + * test-local structures * + *************************/ + + /************************ + * test-local variables * + ************************/ + + H5FD_t *fd_raven = NULL; + H5FD_t *fd_shakes = NULL; + H5FD_t *fd_raven_2 = NULL; + hbool_t curl_ready = FALSE; + hid_t fapl_id = -1; + + + + TESTING("HDFS cmp (comparison)"); + + if (s3_test_credentials_loaded == 0) { + SKIPPED(); + puts(" s3 credentials are not loaded"); + fflush(stdout); + return 0; + } + + /********* + * SETUP * + *********/ + + FAIL_IF( CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT) ) + curl_ready = TRUE; + + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( 0 > fapl_id ) + JSVERIFY( SUCCEED, H5Pset_fapl_hdfs(fapl_id, &restricted_access_fa), NULL ) + + fd_raven = H5FDopen( + url_text_public, + H5F_ACC_RDONLY, + fapl_id, + HADDR_UNDEF); + FAIL_IF( NULL == fd_raven ) + + fd_shakes = H5FDopen( + url_text_restricted, + H5F_ACC_RDONLY, + fapl_id, + HADDR_UNDEF); + FAIL_IF( NULL == fd_shakes ) + + fd_raven_2 = H5FDopen( + url_text_public, + H5F_ACC_RDONLY, + fapl_id, + HADDR_UNDEF); + FAIL_IF( NULL == fd_raven_2 ) + + /********* + * TESTS * + *********/ + + JSVERIFY( 0, H5FDcmp(fd_raven, fd_raven_2), NULL ) + JSVERIFY( -1, H5FDcmp(fd_raven, fd_shakes), NULL ) + JSVERIFY( 1, H5FDcmp(fd_shakes, fd_raven_2), NULL ) + + /************ + * TEARDOWN * + ************/ + + FAIL_IF( FAIL == H5FDclose(fd_raven) ) + fd_raven = NULL; + FAIL_IF( FAIL == H5FDclose(fd_shakes) ) + fd_shakes = NULL; + FAIL_IF( FAIL == H5FDclose(fd_raven_2) ) + fd_raven_2 = NULL; + FAIL_IF( FAIL == H5Pclose(fapl_id) ) + fapl_id = -1; + + curl_global_cleanup(); + curl_ready = FALSE; + + PASSED(); + return 0; + +error: + /*********** + * CLEANUP * + ***********/ + + if (fd_raven != NULL) (void)H5FDclose(fd_raven); + if (fd_raven_2 != NULL) (void)H5FDclose(fd_raven_2); + if (fd_shakes != NULL) (void)H5FDclose(fd_shakes); + if (TRUE == curl_ready) curl_global_cleanup(); + if (fapl_id >= 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + } + +#else + /* + JSFAILED_AT() + HDprintf("TODO\n"); + return 1; + */ + + TESTING("HDFS cmp (comparison)"); + SKIPPED(); + HDfprintf( + stderr, + " TODO: Distinct valid fapls to open the same file.\n"); + + return 0; +#endif /* s3comms relic */ + +} /* test_cmp */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_H5F_integration() + * + * Purpose: + * + * Demonstrate H5F (File interface) behavior with files on HDFS. + * + * Return: + * + * PASSED : 0 + * FAILED : 1 + * + * Programmer: Jacob Smith + * 2017-11-07 + * + * Changes: + * + modify from S3VFD codebase to HDFS; Minor changes, mostly. + * + Jacob Smith 2018-06-08 + * + *--------------------------------------------------------------------------- + */ +static int +test_H5F_integration(void) +{ + /********************* + * test-local macros * + *********************/ + + /************************* + * test-local structures * + *************************/ + + /************************ + * test-local variables * + ************************/ + + hid_t file = -1; + hid_t fapl_id = -1; + + TESTING("HDFS file access through HD5F library (H5F API)"); + + /********* + * SETUP * + *********/ + +#ifndef H5_HAVE_LIBHDFS + SKIPPED(); + puts(" HDFS VFD is not enabled"); + fflush(stdout); + return 0; +#else + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( 0 > fapl_id ) + FAIL_IF( FAIL == H5Pset_fapl_hdfs(fapl_id, &default_fa) ) + + /********* + * TESTS * + *********/ + + /* Read-Write Open access is not allowed with this file driver. + */ + H5E_BEGIN_TRY { + FAIL_IF( 0 <= H5Fopen( + filename_example_h5, + H5F_ACC_RDWR, + fapl_id) ) + } H5E_END_TRY; + + /* H5Fcreate() is not allowed with this file driver. + */ + H5E_BEGIN_TRY { + FAIL_IF( 0 <= H5Fcreate( + filename_missing, + H5F_ACC_RDONLY, + H5P_DEFAULT, + fapl_id) ) + } H5E_END_TRY; + + /* Successful open. + */ + file = H5Fopen( + filename_example_h5, + H5F_ACC_RDONLY, + fapl_id); + FAIL_IF( file < 0 ) + + /************ + * TEARDOWN * + ************/ + + FAIL_IF( FAIL == H5Fclose(file) ) + file = -1; + + FAIL_IF( FAIL == H5Pclose(fapl_id) ) + fapl_id = -1; + + PASSED(); + return 0; +#endif /* H5_HAVE_LIBHDFS */ + +error: + /*********** + * CLEANUP * + ***********/ + +#if HDFS_TEST_DEBUG + HDprintf("\nerror!"); fflush(stdout); +#endif /* HDFS_TEST_DEBUG */ + + if (fapl_id >= 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + } + if (file > 0) { + (void)H5Fclose(file); + } + + return 1; + +} /* test_H5F_integration */ + + +/*------------------------------------------------------------------------- + * + * Function: main + * + * Purpose: Tests the basic features of Virtual File Drivers + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Jacob Smith + * 2017-10-23 + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + int nerrors = 0; + + /****************** + * commence tests * + ******************/ + + static char hdfs_namenode_name[MAX_HDFS_NAMENODE_NAME] = ""; + const char *hdfs_namenode_name_env = NULL; + + hdfs_namenode_name_env = HDgetenv("HDFS_TEST_NAMENODE_NAME"); + if (hdfs_namenode_name_env == NULL || hdfs_namenode_name_env[0] == '\0') { + HDstrncpy(hdfs_namenode_name, "localhost", 9); + } else { + HDstrncpy(default_fa.namenode_name, hdfs_namenode_name_env, MAX_HDFS_NAMENODE_NAME); + } + + h5_reset(); + + HDprintf("Testing hdfs VFD functionality.\n"); + + nerrors += test_fapl_config_validation(); + nerrors += test_hdfs_fapl(); + nerrors += test_vfd_open(); + nerrors += test_eof_eoa(); + nerrors += test_H5FDread_without_eoa_set_fails(); + nerrors += test_read(); + nerrors += test_noops_and_autofails(); + nerrors += test_cmp(); + nerrors += test_H5F_integration(); + + if (nerrors > 0) { + HDprintf("***** %d hdfs TEST%s FAILED! *****\n", + nerrors, + nerrors > 1 ? "S" : ""); + nerrors = 1; + } else { + HDprintf("All hdfs tests passed.\n"); + } + return nerrors; /* 0 if no errors, 1 if any errors */ + +} /* main() */ + + diff --git a/test/ros3.c b/test/ros3.c new file mode 100644 index 0000000..51c1a89 --- /dev/null +++ b/test/ros3.c @@ -0,0 +1,2020 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Read-Only S3 Virtual File Driver (VFD) * + * Copyright (c) 2017-2018, The HDF Group. * + * * + * All rights reserved. * + * * + * NOTICE: * + * All information contained herein is, and remains, the property of The HDF * + * Group. The intellectual and technical concepts contained herein are * + * proprietary to The HDF Group. Dissemination of this information or * + * reproduction of this material is strictly forbidden unless prior written * + * permission is obtained from The HDF Group. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: + * + * Verify behavior for Read-Only S3 VFD + * at the VFL (virtual file layer) level. + * + * Demonstrates basic use cases and fapl/dxpl interaction. + * + * Programmer: Jacob Smith + * 2017-10-11 + */ + +#include "h5test.h" + +#include "H5FDprivate.h" /* Virtual File Driver utilities */ +#include "H5FDros3.h" /* this file driver's utilities */ +#include "H5FDs3comms.h" /* for loading of credentials */ + + + +/***************************************************************************** + * + * FILE-LOCAL TESTING MACROS + * + * Purpose: + * + * 1) Upon test failure, goto-jump to single-location teardown in test + * function. E.g., `error:` (consistency with HDF corpus) or + * `failed:` (reflects purpose). + * >>> using "error", in part because `H5E_BEGIN_TRY` expects it. + * 2) Increase clarity and reduce overhead found with `TEST_ERROR`. + * e.g., "if(somefunction(arg, arg2) < 0) TEST_ERROR:" + * requires reading of entire line to know whether this if/call is + * part of the test setup, test operation, or a test unto itself. + * 3) Provide testing macros with optional user-supplied failure message; + * if not supplied (NULL), generate comparison output in the spirit of + * test-driven development. E.g., "expected 5 but was -3" + * User messages clarify test's purpose in code, encouraging description + * without relying on comments. + * 4) Configurable expected-actual order in generated comparison strings. + * Some prefer `VERIFY(expected, actual)`, others + * `VERIFY(actual, expected)`. Provide preprocessor ifdef switch + * to satifsy both parties, assuming one paradigm per test file. + * (One could #undef and redefine the flag through the file as desired, + * but _why_.) + * + * Provided as courtesy, per consideration for inclusion in the library + * proper. + * + * Macros: + * + * JSVERIFY_EXP_ACT - ifdef flag, configures comparison order + * FAIL_IF() - check condition + * FAIL_UNLESS() - check _not_ condition + * JSVERIFY() - long-int equality check; prints reason/comparison + * JSVERIFY_NOT() - long-int inequality check; prints + * JSVERIFY_STR() - string equality check; prints + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *****************************************************************************/ + + +/*---------------------------------------------------------------------------- + * + * ifdef flag: JSVERIFY_EXP_ACT + * + * JSVERIFY macros accept arguments as (EXPECTED, ACTUAL[, reason]) + * default, if this is undefined, is (ACTUAL, EXPECTED[, reason]) + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_EXP_ACT 1L + + +/*---------------------------------------------------------------------------- + * + * Macro: JSFAILED_AT() + * + * Purpose: + * + * Preface a test failure by printing "*FAILED*" and location to stdout + * Similar to `H5_FAILED(); AT();` from h5test.h + * + * *FAILED* at somefile.c:12 in function_name()... + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSFAILED_AT() { \ + HDprintf("*FAILED* at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: FAIL_IF() + * + * Purpose: + * + * Make tests more accessible and less cluttered than + * `if (thing == otherthing()) TEST_ERROR` + * paradigm. + * + * The following lines are roughly equivalent: + * + * `if (myfunc() < 0) TEST_ERROR;` (as seen elsewhere in HDF tests) + * `FAIL_IF(myfunc() < 0)` + * + * Prints a generic "FAILED AT" line to stdout and jumps to `error`, + * similar to `TEST_ERROR` in h5test.h + * + * Programmer: Jacob Smith + * 2017-10-23 + * + *---------------------------------------------------------------------------- + */ +#define FAIL_IF(condition) \ +if (condition) { \ + JSFAILED_AT() \ + goto error; \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: FAIL_UNLESS() + * + * Purpose: + * + * TEST_ERROR wrapper to reduce cognitive overhead from "negative tests", + * e.g., "a != b". + * + * Opposite of FAIL_IF; fails if the given condition is _not_ true. + * + * `FAIL_IF( 5 != my_op() )` + * is equivalent to + * `FAIL_UNLESS( 5 == my_op() )` + * However, `JSVERIFY(5, my_op(), "bad return")` may be even clearer. + * (see JSVERIFY) + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#if 0 /* UNUSED */ +#define FAIL_UNLESS(condition) \ +if (!(condition)) { \ + JSFAILED_AT() \ + goto error; \ +} +#endif + + +/*---------------------------------------------------------------------------- + * + * Macro: JSERR_LONG() + * + * Purpose: + * + * Print an failure message for long-int arguments. + * ERROR-AT printed first. + * If `reason` is given, it is printed on own line and newlined after + * else, prints "expected/actual" aligned on own lines. + * + * *FAILED* at myfile.c:488 in somefunc()... + * forest must be made of trees. + * + * or + * + * *FAILED* at myfile.c:488 in somefunc()... + * ! Expected 425 + * ! Actual 3 + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSERR_LONG(expected, actual, reason) { \ + JSFAILED_AT() \ + if (reason!= NULL) { \ + HDprintf("%s\n", (reason)); \ + } else { \ + HDprintf(" ! Expected %ld\n ! Actual %ld\n", \ + (long)(expected), (long)(actual)); \ + } \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: JSERR_STR() + * + * Purpose: + * + * Print an failure message for string arguments. + * ERROR-AT printed first. + * If `reason` is given, it is printed on own line and newlined after + * else, prints "expected/actual" aligned on own lines. + * + * *FAILED* at myfile.c:421 in myfunc()... + * Blue and Red strings don't match! + * + * or + * + * *FAILED* at myfile.c:421 in myfunc()... + * !!! Expected: + * this is my expected + * string + * !!! Actual: + * not what I expected at all + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSERR_STR(expected, actual, reason) { \ + JSFAILED_AT() \ + if ((reason) != NULL) { \ + HDprintf("%s\n", (reason)); \ + } else { \ + HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", \ + (expected), (actual)); \ + } \ +} + + + +#ifdef JSVERIFY_EXP_ACT + + +/*---------------------------------------------------------------------------- + * + * Macro: JSVERIFY() + * + * Purpose: + * + * Verify that two long integers are equal. + * If unequal, print failure message + * (with `reason`, if not NULL; expected/actual if NULL) + * and jump to `error` at end of function + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY(expected, actual, reason) \ +if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ +} /* JSVERIFY */ + + +/*---------------------------------------------------------------------------- + * + * Macro: JSVERIFY_NOT() + * + * Purpose: + * + * Verify that two long integers are _not_ equal. + * If equal, print failure message + * (with `reason`, if not NULL; expected/actual if NULL) + * and jump to `error` at end of function + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_NOT(expected, actual, reason) \ +if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ +} /* JSVERIFY_NOT */ + + +/*---------------------------------------------------------------------------- + * + * Macro: JSVERIFY_STR() + * + * Purpose: + * + * Verify that two strings are equal. + * If unequal, print failure message + * (with `reason`, if not NULL; expected/actual if NULL) + * and jump to `error` at end of function + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_STR(expected, actual, reason) \ +if (strcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ +} /* JSVERIFY_STR */ + + +#else +/* JSVERIFY_EXP_ACT not defined + * + * Repeats macros above, but with actual/expected parameters reversed. + */ + + +/*---------------------------------------------------------------------------- + * Macro: JSVERIFY() + * See: JSVERIFY documentation above. + * Programmer: Jacob Smith + * 2017-10-14 + *---------------------------------------------------------------------------- + */ +#define JSVERIFY(actual, expected, reason) \ +if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)); \ + goto error; \ +} /* JSVERIFY */ + + +/*---------------------------------------------------------------------------- + * Macro: JSVERIFY_NOT() + * See: JSVERIFY_NOT documentation above. + * Programmer: Jacob Smith + * 2017-10-14 + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_NOT(actual, expected, reason) \ +if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ +} /* JSVERIFY_NOT */ + + +/*---------------------------------------------------------------------------- + * Macro: JSVERIFY_STR() + * See: JSVERIFY_STR documentation above. + * Programmer: Jacob Smith + * 2017-10-14 + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_STR(actual, expected, reason) \ +if (strcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ +} /* JSVERIFY_STR */ + +#endif /* ifdef/else JSVERIFY_EXP_ACT */ + +/******************************** + * OTHER MACROS AND DEFINITIONS * + ********************************/ + +/* copied from src/ros3.c + */ +#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) + +#ifdef H5_HAVE_ROS3_VFD +#define S3_TEST_PROFILE_NAME "ros3_vfd_test" + +#define S3_TEST_MAX_URL_SIZE 256 + +#define S3_TEST_RESOURCE_TEXT_RESTRICTED "t8.shakespeare.txt" +#define S3_TEST_RESOURCE_TEXT_PUBLIC "Poe_Raven.txt" +#define S3_TEST_RESOURCE_H5_PUBLIC "GMODO-SVM01.h5" +#define S3_TEST_RESOURCE_MISSING "missing.csv" + +static char url_text_restricted[S3_TEST_MAX_URL_SIZE] = ""; +static char url_text_public[S3_TEST_MAX_URL_SIZE] = ""; +static char url_h5_public[S3_TEST_MAX_URL_SIZE] = ""; +static char url_missing[S3_TEST_MAX_URL_SIZE] = ""; +static char s3_test_bucket_url[S3_TEST_MAX_URL_SIZE] = ""; +static hbool_t s3_test_bucket_defined = FALSE; + +/* Global variables for aws test profile. + * An attempt is made to read ~/.aws/credentials and ~/.aws/config upon test + * startup -- if unable to open either file or cannot load region, id, and key, + * tests connecting with S3 will not be run + */ +static int s3_test_credentials_loaded = 0; +static char s3_test_aws_region[16]; +static char s3_test_aws_access_key_id[64]; +static char s3_test_aws_secret_access_key[128]; + +H5FD_ros3_fapl_t restricted_access_fa = { + H5FD__CURR_ROS3_FAPL_T_VERSION, /* fapl version */ + TRUE, /* authenticate */ + "", /* aws region */ + "", /* access key id */ + ""}; /* secret access key */ + +H5FD_ros3_fapl_t anonymous_fa = { + H5FD__CURR_ROS3_FAPL_T_VERSION, + FALSE, "", "", "" }; +#endif /* H5_HAVE_ROS3_VFD */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_fapl_config_validation() + * + * Purpose: + * + * Test data consistency of fapl configuration. + * Tests `H5FD_ros3_validate_config` indirectly through `H5Pset_fapl_ros3`. + * + * Return: + * + * PASSED : 0 + * FAILED : 1 + * + * Programmer: Jacob Smith + * 2017-10-23 + * + * Changes: None. + * + *--------------------------------------------------------------------------- + */ +static int +test_fapl_config_validation(void) +{ + /********************* + * test-local macros * + *********************/ + + /************************* + * test-local structures * + *************************/ + + struct testcase { + const char *msg; + herr_t expected; + H5FD_ros3_fapl_t config; + }; + + /************************ + * test-local variables * + ************************/ + +#ifdef H5_HAVE_ROS3_VFD + hid_t fapl_id = -1; /* file access property list ID */ + H5FD_ros3_fapl_t config; + H5FD_ros3_fapl_t fa_fetch; + herr_t success = SUCCEED; + unsigned int i = 0; + unsigned int ncases = 8; /* should equal number of cases */ + struct testcase *case_ptr = NULL; /* dumb work-around for possible */ + /* dynamic cases creation because */ + /* of compiler warnings Wlarger-than */ + struct testcase cases_arr[] = { + { "non-authenticating config allows empties.\n", + SUCCEED, + { H5FD__CURR_ROS3_FAPL_T_VERSION, /* version */ + FALSE, /* authenticate */ + "", /* aws_region */ + "", /* secret_id */ + "", /* secret_key */ + }, + }, + { "authenticating config asks for populated strings.\n", + FAIL, + { H5FD__CURR_ROS3_FAPL_T_VERSION, + TRUE, + "", + "", + "", + }, + }, + { "populated strings; key is the empty string?\n", + SUCCEED, + { H5FD__CURR_ROS3_FAPL_T_VERSION, + TRUE, + "region", + "me", + "", + }, + }, + { "id cannot be empty.\n", + FAIL, + { H5FD__CURR_ROS3_FAPL_T_VERSION, + TRUE, + "", + "me", + "", + }, + }, + { "region cannot be empty.\n", + FAIL, + { H5FD__CURR_ROS3_FAPL_T_VERSION, + TRUE, + "where", + "", + "", + }, + }, + { "all strings populated.\n", + SUCCEED, + { H5FD__CURR_ROS3_FAPL_T_VERSION, + TRUE, + "where", + "who", + "thisIsA GREAT seeeecrit", + }, + }, + { "incorrect version should fail\n", + FAIL, + { 12345, + FALSE, + "", + "", + "", + }, + }, + { "non-authenticating config cares not for (de)population" + "of strings.\n", + SUCCEED, + { H5FD__CURR_ROS3_FAPL_T_VERSION, + FALSE, + "someregion", + "someid", + "somekey", + }, + }, + }; + +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("ROS3 fapl configuration validation"); + + /********* + * TESTS * + *********/ + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD not enabled"); + fflush(stdout); + return 0; +#else + + if (FALSE == s3_test_bucket_defined) { + SKIPPED(); + puts(" environment variable HDF5_ROS3_TEST_BUCKET_URL not defined"); + fflush(stdout); + return 0; + } + + for (i = 0; i < ncases; i++) { + + /*--------------- + * per-test setup + *--------------- + */ + case_ptr = &cases_arr[i]; + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( fapl_id < 0 ) /* sanity-check */ + + /*----------------------------------- + * Actually test. + * Mute stack trace in failure cases. + *----------------------------------- + */ + H5E_BEGIN_TRY { + /* `H5FD_ros3_validate_config(...)` is static/private + * to src/ros3.c and cannot (and should not?) be tested directly? + * Instead, validate config through public api. + */ + success = H5Pset_fapl_ros3(fapl_id, &case_ptr->config); + } H5E_END_TRY; + + JSVERIFY( case_ptr->expected, success, case_ptr->msg ) + + /* Make sure we can get back what we put in. + * Only valid if the fapl configuration does not result in error. + */ + if (success == SUCCEED) { + config = case_ptr->config; + JSVERIFY( SUCCEED, + H5Pget_fapl_ros3(fapl_id, &fa_fetch), + "unable to get fapl" ) + + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, + fa_fetch.version, + "invalid version number" ) + JSVERIFY( config.version, + fa_fetch.version, + "version number mismatch" ) + JSVERIFY( config.authenticate, + fa_fetch.authenticate, + "authentication flag mismatch" ) + JSVERIFY_STR( config.aws_region, + fa_fetch.aws_region, + NULL ) + JSVERIFY_STR( config.secret_id, + fa_fetch.secret_id, + NULL ) + JSVERIFY_STR( config.secret_key, + fa_fetch.secret_key, + NULL ) + } + + /*----------------------------- + * per-test sanitation/teardown + *----------------------------- + */ + FAIL_IF( FAIL == H5Pclose(fapl_id) ) + fapl_id = -1; + + } /* for each test case */ + + PASSED(); + return 0; + +error: + /*********** + * CLEANUP * + ***********/ + + if (fapl_id < 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + } + return 1; +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_fapl_config_validation */ + + +/*------------------------------------------------------------------------- + * + * Function: test_ros3_fapl() + * + * Purpose: Tests the file handle interface for the ROS3 driver + * + * As the ROS3 driver is 1) read only, 2) requires access + * to an S3 server (minio for now), this test is quite + * different from the other tests. + * + * For now, test only fapl & flags. Extend as the + * work on the VFD continues. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: John Mainzer + * 7/12/17 + * + * Changes: Test only fapl and flags. + * Jacob Smith 2017 + * + *------------------------------------------------------------------------- + */ +static int +test_ros3_fapl(void) +{ + /************************ + * test-local variables * + ************************/ + +#ifdef H5_HAVE_ROS3_VFD + hid_t fapl_id = -1; /* file access property list ID */ + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ + H5FD_ros3_fapl_t ros3_fa_0 = { + H5FD__CURR_ROS3_FAPL_T_VERSION, /* version */ + FALSE, /* authenticate */ + "", /* aws_region */ + "", /* secret_id */ + "plugh", /* secret_key */ + }; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("ROS3 fapl "); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD not enabled"); + fflush(stdout); + return 0; +#else + /* Set property list and file name for ROS3 driver. + */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( fapl_id < 0 ) + + FAIL_IF( FAIL == H5Pset_fapl_ros3(fapl_id, &ros3_fa_0) ) + + driver_id = H5Pget_driver(fapl_id); + FAIL_IF( driver_id < 0 ) + + /**************** + * Check that the VFD feature flags are correct + * SPEC MAY CHANGE + ******************/ + + FAIL_IF( H5FDdriver_query(driver_id, &driver_flags) < 0 ) + + JSVERIFY_NOT( 0, (driver_flags & H5FD_FEAT_DATA_SIEVE), + "bit(s) in `driver_flags` must align with " + "H5FD_FEAT_DATA_SIEVE" ) + + JSVERIFY( H5FD_FEAT_DATA_SIEVE, driver_flags, + "H5FD_FEAT_DATA_SIEVE should be the only supported flag") + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + + return 1; +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_ros3_fapl() */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_vfd_open() + * + * Purpose: + * + * Demonstrate/specify VFD-level "Open" failure cases + * + * Return: + * + * PASSED : 0 + * FAILED : 1 + * + * Programmer: Jacob Smith + * 1027-11-03 + * + *--------------------------------------------------------------------------- + */ +static int +test_vfd_open(void) +{ + /********************* + * test-local macros * + *********************/ + +#ifdef H5_HAVE_ROS3_VFD + +#define FAPL_H5P_DEFAULT -2 +#define FAPL_FILE_ACCESS -3 +#define FAPL_ROS3_ANON -4 + + /************************* + * test-local structures * + *************************/ + + struct test_condition { + const char *message; + const char *url; + unsigned flags; + int which_fapl; + haddr_t maxaddr; + }; + + /************************ + * test-local variables * + ************************/ + + struct test_condition tests[] = { + { "default property list (H5P_DEFAULT) is invalid", + url_text_public, + H5F_ACC_RDONLY, + FAPL_H5P_DEFAULT, + MAXADDR, + }, + { "generic file access property list is invalid", + url_text_public, + H5F_ACC_RDONLY, + FAPL_FILE_ACCESS, + MAXADDR, + }, + { "filename cannot be null", + NULL, + H5F_ACC_RDONLY, + FAPL_ROS3_ANON, + MAXADDR, + }, + { "filename cannot be empty", + "", + H5F_ACC_RDONLY, + FAPL_ROS3_ANON, + MAXADDR, + }, + { "filename must exist", + url_missing, + H5F_ACC_RDONLY, + FAPL_ROS3_ANON, + MAXADDR, + }, + { "read-write flag not supported", + url_text_public, + H5F_ACC_RDWR, + FAPL_ROS3_ANON, + MAXADDR, + }, + { "truncate flag not supported", + url_text_public, + H5F_ACC_TRUNC, + FAPL_ROS3_ANON, + MAXADDR, + }, + { "create flag not supported", + url_text_public, + H5F_ACC_CREAT, + FAPL_ROS3_ANON, + MAXADDR, + }, + { "EXCL flag not supported", + url_text_public, + H5F_ACC_EXCL, + FAPL_ROS3_ANON, + MAXADDR, + }, + { "maxaddr cannot be 0 (caught in `H5FD_open()`)", + url_text_public, + H5F_ACC_RDONLY, + FAPL_ROS3_ANON, + 0, + }, + }; + H5FD_t *fd = NULL; + hbool_t curl_ready = FALSE; + hid_t fapl_id = -1; + hid_t fapl_file_access = -1; + unsigned i = 0; + unsigned tests_count = 10; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("ROS3 VFD-level open"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD not enabled"); + fflush(stdout); + return 0; +#else + + if (FALSE == s3_test_bucket_defined) { + SKIPPED(); + puts(" environment variable HDF5_ROS3_TEST_BUCKET_URL not defined"); + fflush(stdout); + return 0; + } + + FAIL_IF( CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT) ) + curl_ready = TRUE; + + fapl_file_access = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( fapl_file_access < 0 ) + + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( fapl_id < 0 ) + FAIL_IF( FAIL == H5Pset_fapl_ros3(fapl_id, &anonymous_fa) ) + + /********* + * TESTS * + *********/ + + /* all the test cases that will _not_ open + */ + for (i = 0; i < tests_count; i++) { + struct test_condition T = tests[i]; + hid_t _fapl_id = H5P_DEFAULT; + + fd = NULL; + + if (T.which_fapl == FAPL_FILE_ACCESS) + _fapl_id = fapl_file_access; + else if (T.which_fapl == FAPL_ROS3_ANON) + _fapl_id = fapl_id; + + H5E_BEGIN_TRY { + fd = H5FDopen(T.url, T.flags, _fapl_id, T.maxaddr); + } H5E_END_TRY; + if (NULL != fd) + JSVERIFY(1, 0, T.message); /* wrapper to print message and fail */ + } + + FAIL_IF( NULL != fd ) + + /* finally, show that a file can be opened + */ + fd = H5FDopen( + url_text_public, + H5F_ACC_RDONLY, + fapl_id, + MAXADDR); + FAIL_IF( NULL == fd ) + + /************ + * TEARDOWN * + ************/ + + FAIL_IF( FAIL == H5FDclose(fd) ) + fd = NULL; + + FAIL_IF( FAIL == H5Pclose(fapl_id) ) + fapl_id = -1; + + FAIL_IF( FAIL == H5Pclose(fapl_file_access) ) + fapl_file_access = -1; + + curl_global_cleanup(); + curl_ready = FALSE; + + PASSED(); + return 0; + +error: + /*********** + * CLEANUP * + ***********/ + + if (fd) { + (void)H5FDclose(fd); + } + if (fapl_id >= 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + } + if (fapl_file_access >= 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_file_access); + } H5E_END_TRY; + } + if (curl_ready == TRUE) { + curl_global_cleanup(); + } + + return 1; + +#undef FAPL_FILE_ACCESS +#undef FAPL_H5P_DEFAULT +#undef FAPL_ROS3_ANON + +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_vfd_open */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_eof_eoa() + * + * Purpose: + * + * Demonstrate behavior of get_eof, get_eoa, and set_eoa. + * + * Return: + * + * PASSED : 0 + * FAILED : 1 + * + * Programmer: Jacob Smith + * 2017-11-08 + * + *--------------------------------------------------------------------------- + */ +static int +test_eof_eoa(void) +{ + /********************* + * test-local macros * + *********************/ + + /************************* + * test-local structures * + *************************/ + + /************************ + * test-local variables * + ************************/ + +#ifdef H5_HAVE_ROS3_VFD + H5FD_t *fd_shakespeare = NULL; + hbool_t curl_ready = FALSE; + hid_t fapl_id = -1; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("ROS3 eof/eoa gets and sets"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD not enabled"); + fflush(stdout); + return 0; +#else + if (s3_test_credentials_loaded == 0) { + SKIPPED(); + puts(" s3 credentials are not loaded"); + fflush(stdout); + return 0; + } + + if (FALSE == s3_test_bucket_defined) { + SKIPPED(); + puts(" environment variable HDF5_ROS3_TEST_BUCKET_URL not defined"); + fflush(stdout); + return 0; + } + + /********* + * SETUP * + *********/ + + FAIL_IF( CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT) ) + curl_ready = TRUE; + + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( 0 > fapl_id ) + FAIL_IF( FAIL == H5Pset_fapl_ros3(fapl_id, &restricted_access_fa) ) + + fd_shakespeare = H5FDopen( + url_text_restricted, + H5F_ACC_RDONLY, + fapl_id, + HADDR_UNDEF); + FAIL_IF( NULL == fd_shakespeare ) + + /********* + * TESTS * + *********/ + + /* verify as found + */ + JSVERIFY( 5458199, H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), NULL ) + JSVERIFY( H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), + H5FDget_eof(fd_shakespeare, H5FD_MEM_DRAW), + "mismatch between DEFAULT and RAW memory types" ) + JSVERIFY( 0, + H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), + "EoA should be unset by H5FDopen" ) + + /* set EoA below EoF + */ + JSVERIFY( SUCCEED, + H5FDset_eoa(fd_shakespeare, H5FD_MEM_DEFAULT, 44442202), + "unable to set EoA (lower)" ) + JSVERIFY( 5458199, + H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), + "EoF changed" ) + JSVERIFY( 44442202, + H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), + "EoA unchanged" ) + + /* set EoA above EoF + */ + JSVERIFY( SUCCEED, + H5FDset_eoa(fd_shakespeare, H5FD_MEM_DEFAULT, 6789012), + "unable to set EoA (higher)" ) + JSVERIFY( 5458199, + H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), + "EoF changed" ) + JSVERIFY( 6789012, + H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), + "EoA unchanged" ) + + /************ + * TEARDOWN * + ************/ + + FAIL_IF( FAIL == H5FDclose(fd_shakespeare) ) + + FAIL_IF( FAIL == H5Pclose(fapl_id) ) + fapl_id = -1; + + curl_global_cleanup(); + curl_ready = FALSE; + + PASSED(); + return 0; + +error: + /*********** + * CLEANUP * + ***********/ + + if (fd_shakespeare) (void)H5FDclose(fd_shakespeare); + if (TRUE == curl_ready) curl_global_cleanup(); + if (fapl_id >= 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + } + + return 1; +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_eof_eoa */ + + +/*----------------------------------------------------------------------------- + * + * Function: test_H5FDread_without_eoa_set_fails() + * + * Purpose: + * + * Demonstrate a not-obvious constraint by the library, preventing + * file read before EoA is set + * + * Programmer: Jacob Smith + * 2018-01-26 + * + *----------------------------------------------------------------------------- + */ +static int +test_H5FDread_without_eoa_set_fails(void) +{ +#ifdef H5_HAVE_ROS3_VFD + char buffer[256]; + unsigned int i = 0; + H5FD_t *file_shakespeare = NULL; + hid_t fapl_id = -1; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("ROS3 VFD read-eoa temporal coupling library limitation "); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD not enabled"); + fflush(stdout); + return 0; +#else + if (s3_test_credentials_loaded == 0) { + SKIPPED(); + puts(" s3 credentials are not loaded"); + fflush(stdout); + return 0; + } + + if (FALSE == s3_test_bucket_defined) { + SKIPPED(); + puts(" environment variable HDF5_ROS3_TEST_BUCKET_URL not defined"); + fflush(stdout); + return 0; + } + + /********* + * SETUP * + *********/ + + /* create ROS3 fapl + */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( fapl_id < 0 ) + FAIL_IF( FAIL == H5Pset_fapl_ros3(fapl_id, &restricted_access_fa) ) + + file_shakespeare = H5FDopen( + url_text_restricted, + H5F_ACC_RDONLY, + fapl_id, + MAXADDR); + FAIL_IF( NULL == file_shakespeare ) + + JSVERIFY( 0, H5FDget_eoa(file_shakespeare, H5FD_MEM_DEFAULT), + "EoA should remain unset by H5FDopen" ) + + for (i = 0; i < 256; i++) + buffer[i] = 0; /* zero buffer contents */ + + /******** + * TEST * + ********/ + + H5E_BEGIN_TRY { /* mute stack trace on expected failure */ + JSVERIFY( FAIL, + H5FDread(file_shakespeare, + H5FD_MEM_DRAW, + H5P_DEFAULT, + 1200699, + 102, + buffer), + "cannot read before eoa is set" ) + } H5E_END_TRY; + JSVERIFY_STR( "", buffer, "buffer should remain untouched" ) + + /************ + * TEARDOWN * + ************/ + + FAIL_IF( FAIL == H5FDclose(file_shakespeare) ) + file_shakespeare = NULL; + + FAIL_IF( FAIL == H5Pclose(fapl_id) ) + fapl_id = -1; + + PASSED(); + return 0; + +error: + /*********** + * CLEANUP * + ***********/ + + if (file_shakespeare) { (void)H5FDclose(file_shakespeare); } + if (fapl_id >= 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + } + + return 1; + +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_H5FDread_without_eoa_set_fails */ + + + +/*--------------------------------------------------------------------------- + * + * Function: test_read() + * + * Purpose: + * + * Return: + * + * PASSED : 0 + * FAILED : 1 + * + * Programmer: Jacob Smith + * 2017-11-06 + * + *--------------------------------------------------------------------------- + */ +static int +test_read(void) +{ + /********************* + * test-local macros * + *********************/ + + /************************* + * test-local structures * + *************************/ + struct testcase { + const char *message; /* purpose of test case */ + haddr_t eoa_set; /* set file EOA to this prior to read */ + size_t addr; /* offset of read in file */ + size_t len; /* length of read in file */ + herr_t success; /* expected return value of read function */ + const char *expected; /* expected contents of buffer; failure ignores */ + }; + + /************************ + * test-local variables * + ************************/ +#ifdef H5_HAVE_ROS3_VFD + struct testcase cases[] = { + { "successful range-get", + 6464, + 5691, + 32, /* fancy quotes are three bytes each(?) */ + SUCCEED, + "Quoth the Raven “Nevermore.”", + }, + { "read past EOA fails (EOA < EOF < addr)", + 3000, + 4000, + 100, + FAIL, + NULL, + }, + { "read overlapping EOA fails (EOA < addr < EOF < (addr+len))", + 3000, + 8000, + 100, + FAIL, + NULL, + }, + { "read past EOA/EOF fails ((EOA==EOF) < addr)", + 6464, + 7000, + 100, + FAIL, + NULL, + }, + { "read overlapping EOA/EOF fails (addr < (EOA==EOF) < (addr+len))", + 6464, + 6400, + 100, + FAIL, + NULL, + }, + { "read between EOF and EOA fails (EOF < addr < (addr+len) < EOA)", + 8000, + 7000, + 100, + FAIL, + NULL, + }, + }; + unsigned testcase_count = 6; + unsigned test_i = 0; + struct testcase test; + herr_t open_return = FAIL; + char buffer[S3_TEST_MAX_URL_SIZE]; + unsigned int i = 0; + H5FD_t *file_raven = NULL; + hid_t fapl_id = -1; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("ROS3 VFD read/range-gets"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD not enabled"); + fflush(stdout); + return 0; +#else + if (s3_test_credentials_loaded == 0) { + SKIPPED(); + puts(" s3 credentials are not loaded"); + fflush(stdout); + return 0; + } + + if (FALSE == s3_test_bucket_defined) { + SKIPPED(); + puts(" environment variable HDF5_ROS3_TEST_BUCKET_URL not defined"); + fflush(stdout); + return 0; + } + + /********* + * SETUP * + *********/ + + /* create ROS3 fapl + */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( fapl_id < 0 ) + FAIL_IF( FAIL == H5Pset_fapl_ros3(fapl_id, &restricted_access_fa) ) + + /* open file + */ + file_raven = H5FDopen( /* will open with "authenticating" fapl */ + url_text_public, /* TODO: check return state: anon access of restricted says OK? (not NULL) */ + H5F_ACC_RDONLY, + fapl_id, + HADDR_UNDEF); /* Demonstrate success with "automatic" value */ + FAIL_IF( NULL == file_raven ) + + JSVERIFY( 6464, H5FDget_eof(file_raven, H5FD_MEM_DEFAULT), NULL ) + + /********* + * TESTS * + *********/ + + for (test_i = 0; test_i < testcase_count; test_i++) { + + /* -------------- * + * per-test setup * + * -------------- */ + + test = cases[test_i]; + open_return = FAIL; + + FAIL_IF( S3_TEST_MAX_URL_SIZE < test.len ) /* buffer too small! */ + + FAIL_IF( FAIL == + H5FD_set_eoa( file_raven, H5FD_MEM_DEFAULT, test.eoa_set) ) + + for (i = 0; i < S3_TEST_MAX_URL_SIZE; i++) /* zero buffer contents */ + buffer[i] = 0; + + /* ------------ * + * conduct test * + * ------------ */ + + H5E_BEGIN_TRY { + open_return = H5FDread( + file_raven, + H5FD_MEM_DRAW, + H5P_DEFAULT, + test.addr, + test.len, + buffer); + } H5E_END_TRY; + + JSVERIFY( test.success, + open_return, + test.message ) + if (open_return == SUCCEED) + JSVERIFY_STR( test.expected, buffer, NULL ) + + } /* for each testcase */ + + /************ + * TEARDOWN * + ************/ + + FAIL_IF( FAIL == H5FDclose(file_raven) ) + file_raven = NULL; + + FAIL_IF( FAIL == H5Pclose(fapl_id) ) + fapl_id = -1; + + PASSED(); + return 0; + +error: + /*********** + * CLEANUP * + ***********/ + + if (file_raven) + (void)H5FDclose(file_raven); + if (fapl_id >= 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + } + + return 1; + +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_read */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_noops_and_autofails() + * + * Purpose: + * + * Demonstrate the unavailable and do-nothing routines unique to + * Read-Only VFD. + * + * Return: + * + * PASSED : 0 + * FAILED : 1 + * + * Programmer: Jacob Smith + * 2017-11-06 + * + *--------------------------------------------------------------------------- + */ +static int +test_noops_and_autofails(void) +{ + /********************* + * test-local macros * + *********************/ + + /************************* + * test-local structures * + *************************/ + + /************************ + * test-local variables * + ************************/ + +#ifdef H5_HAVE_ROS3_VFD + hbool_t curl_ready = FALSE; + hid_t fapl_id = -1; + H5FD_t *file = NULL; + const char data[36] = "The Force shall be with you, always"; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("ROS3 VFD always-fail and no-op routines"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD not enabled"); + fflush(stdout); + return 0; +#else + + if (FALSE == s3_test_bucket_defined) { + SKIPPED(); + puts(" environment variable HDF5_ROS3_TEST_BUCKET_URL not defined"); + fflush(stdout); + return 0; + } + + /********* + * SETUP * + *********/ + + FAIL_IF( CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT) ) + curl_ready = TRUE; + + /* create ROS3 fapl + */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( fapl_id < 0 ) + JSVERIFY( SUCCEED, H5Pset_fapl_ros3(fapl_id, &anonymous_fa), NULL ) + + /* open file + */ + file = H5FDopen( + url_text_public, + H5F_ACC_RDONLY, + fapl_id, + HADDR_UNDEF); + FAIL_IF( NULL == file ) + + /********* + * TESTS * + *********/ + + /* auto-fail calls to write and truncate + */ + H5E_BEGIN_TRY { + JSVERIFY( FAIL, + H5FDwrite(file, H5FD_MEM_DRAW, H5P_DEFAULT, 1000, 35, data), + "write must fail" ) + } H5E_END_TRY; + + H5E_BEGIN_TRY { + JSVERIFY( FAIL, + H5FDtruncate(file, H5P_DEFAULT, FALSE), + "truncate must fail" ) + } H5E_END_TRY; + + H5E_BEGIN_TRY { + JSVERIFY( FAIL, + H5FDtruncate(file, H5P_DEFAULT, TRUE), + "truncate must fail (closing)" ) + } H5E_END_TRY; + + /* no-op calls to `lock()` and `unlock()` + */ + JSVERIFY( SUCCEED, + H5FDlock(file, TRUE), + "lock always succeeds; has no effect" ) + JSVERIFY( SUCCEED, + H5FDlock(file, FALSE), + NULL ) + JSVERIFY( SUCCEED, + H5FDunlock(file), + NULL ) + /* Lock/unlock with null file or similar error crashes tests. + * HDassert in calling heirarchy, `H5FD[un]lock()` and `H5FD_[un]lock()` + */ + + /************ + * TEARDOWN * + ************/ + + FAIL_IF( FAIL == H5FDclose(file) ) + file = NULL; + + FAIL_IF( FAIL == H5Pclose(fapl_id) ) + fapl_id = -1; + + curl_global_cleanup(); + curl_ready = FALSE; + + PASSED(); + return 0; + +error: + /*********** + * CLEANUP * + ***********/ + + if (fapl_id >= 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + } + if (file) { (void)H5FDclose(file); } + if (curl_ready == TRUE) { curl_global_cleanup(); } + + return 1; + +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_noops_and_autofails*/ + + +/*--------------------------------------------------------------------------- + * + * Function: test_cmp() + * + * Purpose: + * + * Verify "file comparison" behavior. + * + * Return: + * + * PASSED : 0 + * FAILED : 1 + * + * Programmer: Jacob Smith + * 2017-11-06 + * + *--------------------------------------------------------------------------- + */ +static int +test_cmp(void) +{ + /********************* + * test-local macros * + *********************/ + + /************************* + * test-local structures * + *************************/ + + /************************ + * test-local variables * + ************************/ + +#ifdef H5_HAVE_ROS3_VFD + H5FD_t *fd_raven = NULL; + H5FD_t *fd_shakes = NULL; + H5FD_t *fd_raven_2 = NULL; + hbool_t curl_ready = FALSE; + hid_t fapl_id = -1; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("ROS3 cmp (comparison)"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD not enabled"); + fflush(stdout); + return 0; +#else + if (s3_test_credentials_loaded == 0) { + SKIPPED(); + puts(" s3 credentials are not loaded"); + fflush(stdout); + return 0; + } + + if (FALSE == s3_test_bucket_defined) { + SKIPPED(); + puts(" environment variable HDF5_ROS3_TEST_BUCKET_URL not defined"); + fflush(stdout); + return 0; + } + + /********* + * SETUP * + *********/ + + FAIL_IF( CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT) ) + curl_ready = TRUE; + + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( 0 > fapl_id ) + JSVERIFY( SUCCEED, H5Pset_fapl_ros3(fapl_id, &restricted_access_fa), NULL ) + + fd_raven = H5FDopen( + url_text_public, + H5F_ACC_RDONLY, + fapl_id, + HADDR_UNDEF); + FAIL_IF( NULL == fd_raven ) + + fd_shakes = H5FDopen( + url_text_restricted, + H5F_ACC_RDONLY, + fapl_id, + HADDR_UNDEF); + FAIL_IF( NULL == fd_shakes ) + + fd_raven_2 = H5FDopen( + url_text_public, + H5F_ACC_RDONLY, + fapl_id, + HADDR_UNDEF); + FAIL_IF( NULL == fd_raven_2 ) + + /********* + * TESTS * + *********/ + + JSVERIFY( 0, H5FDcmp(fd_raven, fd_raven_2), NULL ) + JSVERIFY( -1, H5FDcmp(fd_raven, fd_shakes), NULL ) + JSVERIFY( -1, H5FDcmp(fd_shakes, fd_raven_2), NULL ) + + /************ + * TEARDOWN * + ************/ + + FAIL_IF( FAIL == H5FDclose(fd_raven) ) + fd_raven = NULL; + FAIL_IF( FAIL == H5FDclose(fd_shakes) ) + fd_shakes = NULL; + FAIL_IF( FAIL == H5FDclose(fd_raven_2) ) + fd_raven_2 = NULL; + FAIL_IF( FAIL == H5Pclose(fapl_id) ) + fapl_id = -1; + + curl_global_cleanup(); + curl_ready = FALSE; + + PASSED(); + return 0; + +error: + /*********** + * CLEANUP * + ***********/ + + if (fd_raven != NULL) (void)H5FDclose(fd_raven); + if (fd_raven_2 != NULL) (void)H5FDclose(fd_raven_2); + if (fd_shakes != NULL) (void)H5FDclose(fd_shakes); + if (TRUE == curl_ready) curl_global_cleanup(); + if (fapl_id >= 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + } + + return 1; +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_cmp */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_H5F_integration() + * + * Purpose: + * + * Demonstrate S3 file-open through H5F API. + * + * Return: + * + * PASSED : 0 + * FAILED : 1 + * + * Programmer: Jacob Smith + * 2017-11-07 + * + *--------------------------------------------------------------------------- + */ +static int +test_H5F_integration(void) +{ + /********************* + * test-local macros * + *********************/ + + /************************* + * test-local structures * + *************************/ + + /************************ + * test-local variables * + ************************/ + +#ifdef H5_HAVE_ROS3_VFD + hid_t file = -1; + hid_t fapl_id = -1; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("S3 file access through HD5F library (H5F API)"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD not enabled"); + fflush(stdout); + return 0; +#else + if (s3_test_credentials_loaded == 0) { + SKIPPED(); + puts(" s3 credentials are not loaded"); + fflush(stdout); + return 0; + } + + if (FALSE == s3_test_bucket_defined) { + SKIPPED(); + puts(" environment variable HDF5_ROS3_TEST_BUCKET_URL not defined"); + fflush(stdout); + return 0; + } + + /********* + * SETUP * + *********/ + + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( 0 > fapl_id ) + FAIL_IF( FAIL == H5Pset_fapl_ros3(fapl_id, &restricted_access_fa) ) + + /********* + * TESTS * + *********/ + + /* Read-Write Open access is not allowed with this file driver. + */ + H5E_BEGIN_TRY { + FAIL_IF( 0 <= H5Fopen( + url_h5_public, + H5F_ACC_RDWR, + fapl_id) ) + } H5E_END_TRY; + + /* H5Fcreate() is not allowed with this file driver. + */ + H5E_BEGIN_TRY { + FAIL_IF( 0 <= H5Fcreate( + url_missing, + H5F_ACC_RDONLY, + H5P_DEFAULT, + fapl_id) ) + } H5E_END_TRY; + + /* Successful open. + */ + file = H5Fopen( + url_h5_public, + H5F_ACC_RDONLY, + fapl_id); + FAIL_IF( file < 0 ) + + /************ + * TEARDOWN * + ************/ + + FAIL_IF( FAIL == H5Fclose(file) ) + file = -1; + + FAIL_IF( FAIL == H5Pclose(fapl_id) ) + fapl_id = -1; + + PASSED(); + return 0; + +error: + /*********** + * CLEANUP * + ***********/ +HDprintf("\nerror!"); fflush(stdout); + + if (fapl_id >= 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + } + if (file > 0) + (void)H5Fclose(file); + + return 1; +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_H5F_integration */ + + + + +/*------------------------------------------------------------------------- + * + * Function: main + * + * Purpose: Tests the basic features of Virtual File Drivers + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Jacob Smith + * 2017-10-23 + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + int nerrors = 0; + +#ifdef H5_HAVE_ROS3_VFD + const char *bucket_url_env = NULL; + + /************************ + * initialize test urls * + ************************/ + + bucket_url_env = HDgetenv("HDF5_ROS3_TEST_BUCKET_URL"); + if (bucket_url_env == NULL || bucket_url_env[0] == '\0') { + HDprintf("WARNING: S3 bucket url is not defined in enviornment " \ + "variable 'HDF5_ROS3_TEST_BUCKET_URL'!\n"); + } else { + HDstrncpy(s3_test_bucket_url, bucket_url_env, S3_TEST_MAX_URL_SIZE); + s3_test_bucket_defined = TRUE; + } + + if (S3_TEST_MAX_URL_SIZE < snprintf( + url_text_restricted, + (size_t)S3_TEST_MAX_URL_SIZE, + "%s/%s", + (const char *)s3_test_bucket_url, + (const char *)S3_TEST_RESOURCE_TEXT_RESTRICTED)) + { + HDprintf("* ros3 setup failed (text_restricted) ! *\n"); + return 1; + } + if (S3_TEST_MAX_URL_SIZE < HDsnprintf( + url_text_public, + (size_t)S3_TEST_MAX_URL_SIZE, + "%s/%s", + (const char *)s3_test_bucket_url, + (const char *)S3_TEST_RESOURCE_TEXT_PUBLIC)) + { + HDprintf("* ros3 setup failed (text_public) ! *\n"); + return 1; + } + if (S3_TEST_MAX_URL_SIZE < HDsnprintf( + url_h5_public, + (size_t)S3_TEST_MAX_URL_SIZE, + "%s/%s", + (const char *)s3_test_bucket_url, + (const char *)S3_TEST_RESOURCE_H5_PUBLIC)) + { + HDprintf("* ros3 setup failed (h5_public) ! *\n"); + return 1; + } + if (S3_TEST_MAX_URL_SIZE < HDsnprintf( + url_missing, + S3_TEST_MAX_URL_SIZE, + "%s/%s", + (const char *)s3_test_bucket_url, + (const char *)S3_TEST_RESOURCE_MISSING)) + { + HDprintf("* ros3 setup failed (missing) ! *\n"); + return 1; + } + + /************************************** + * load credentials and prepare fapls * + **************************************/ + + /* "clear" profile data strings */ + s3_test_aws_access_key_id[0] = '\0'; + s3_test_aws_secret_access_key[0] = '\0'; + s3_test_aws_region[0] = '\0'; + + /* attempt to load test credentials + * if unable, certain tests will be skipped + */ + if (SUCCEED == H5FD_s3comms_load_aws_profile( + S3_TEST_PROFILE_NAME, + s3_test_aws_access_key_id, + s3_test_aws_secret_access_key, + s3_test_aws_region)) + { + s3_test_credentials_loaded = 1; + HDstrncpy(restricted_access_fa.aws_region, + (const char *)s3_test_aws_region, + H5FD__ROS3_MAX_REGION_LEN); + HDstrncpy(restricted_access_fa.secret_id, + (const char *)s3_test_aws_access_key_id, + H5FD__ROS3_MAX_SECRET_ID_LEN); + HDstrncpy(restricted_access_fa.secret_key, + (const char *)s3_test_aws_secret_access_key, + H5FD__ROS3_MAX_SECRET_KEY_LEN); + } +#endif /* H5_HAVE_ROS3_VFD */ + + /****************** + * commence tests * + ******************/ + + h5_reset(); + + HDprintf("Testing ros3 VFD functionality.\n"); + + nerrors += test_fapl_config_validation(); + nerrors += test_ros3_fapl(); + nerrors += test_vfd_open(); + nerrors += test_eof_eoa(); + nerrors += test_H5FDread_without_eoa_set_fails(); + nerrors += test_read(); + nerrors += test_noops_and_autofails(); + nerrors += test_cmp(); + nerrors += test_H5F_integration(); + + if (nerrors > 0) { + HDprintf("***** %d ros3 TEST%s FAILED! *****\n", + nerrors, + nerrors > 1 ? "S" : ""); + nerrors = 1; + } else { + HDprintf("All ros3 tests passed.\n"); + } + return nerrors; /* 0 if no errors, 1 if any errors */ + +} /* main() */ + + diff --git a/test/s3comms.c b/test/s3comms.c new file mode 100644 index 0000000..71d93c2 --- /dev/null +++ b/test/s3comms.c @@ -0,0 +1,2813 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Read-Only S3 Virtual File Driver (VFD) * + * Copyright (c) 2017-2018, The HDF Group. * + * * + * All rights reserved. * + * * + * NOTICE: * + * All information contained herein is, and remains, the property of The HDF * + * Group. The intellectual and technical concepts contained herein are * + * proprietary to The HDF Group. Dissemination of this information or * + * reproduction of this material is strictly forbidden unless prior written * + * permission is obtained from The HDF Group. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Unit tests for the S3 Communications (s3comms) module. + * + * Programmer: Jacob Smith + * 2017-10-11 + */ + +#include "h5test.h" +#include "H5FDs3comms.h" +#include "H5MMprivate.h" /* memory management */ + +/***************************************************************************** + * + * FILE-LOCAL TESTING MACROS + * + * Purpose: + * + * 1) Upon test failure, goto-jump to single-location teardown in test + * function. E.g., `error:` (consistency with HDF corpus) or + * `failed:` (reflects purpose). + * >>> using "error", in part because `H5E_BEGIN_TRY` expects it. + * 2) Increase clarity and reduce overhead found with `TEST_ERROR`. + * e.g., "if(somefunction(arg, arg2) < 0) TEST_ERROR:" + * requires reading of entire line to know whether this if/call is + * part of the test setup, test operation, or a test unto itself. + * 3) Provide testing macros with optional user-supplied failure message; + * if not supplied (NULL), generate comparison output in the spirit of + * test-driven development. E.g., "expected 5 but was -3" + * User messages clarify test's purpose in code, encouraging description + * without relying on comments. + * 4) Configurable expected-actual order in generated comparison strings. + * Some prefer `VERIFY(expected, actual)`, others + * `VERIFY(actual, expected)`. Provide preprocessor ifdef switch + * to satifsy both parties, assuming one paradigm per test file. + * (One could #undef and redefine the flag through the file as desired, + * but _why_.) + * Provided as courtesy, per consideration for inclusion in the library + * proper. + * + * Macros: + * + * JSVERIFY_EXP_ACT - ifdef flag, configures comparison order + * FAIL_IF() - check condition + * FAIL_UNLESS() - check _not_ condition + * JSVERIFY() - long-int equality check; prints reason/comparison + * JSVERIFY_NOT() - long-int inequality check; prints + * JSVERIFY_STR() - string equality check; prints + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *****************************************************************************/ + + +/*---------------------------------------------------------------------------- + * + * ifdef flag: JSVERIFY_EXP_ACT + * + * JSVERIFY macros accept arguments as (EXPECTED, ACTUAL[, reason]) + * default, if this is undefined, is (ACTUAL, EXPECTED[, reason]) + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_EXP_ACT 1L + + +/*---------------------------------------------------------------------------- + * + * Macro: JSFAILED_AT() + * + * Purpose: + * + * Preface a test failure by printing "*FAILED*" and location to stdout + * Similar to `H5_FAILED(); AT();` from h5test.h + * + * *FAILED* at somefile.c:12 in function_name()... + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSFAILED_AT() { \ + HDprintf("*FAILED* at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: FAIL_IF() + * + * Purpose: + * + * Make tests more accessible and less cluttered than + * `if (thing == otherthing()) TEST_ERROR` + * paradigm. + * + * The following lines are roughly equivalent: + * + * `if (myfunc() < 0) TEST_ERROR;` (as seen elsewhere in HDF tests) + * `FAIL_IF(myfunc() < 0)` + * + * Prints a generic "FAILED AT" line to stdout and jumps to `error`, + * similar to `TEST_ERROR` in h5test.h + * + * Programmer: Jacob Smith + * 2017-10-23 + * + *---------------------------------------------------------------------------- + */ +#define FAIL_IF(condition) \ +if (condition) { \ + JSFAILED_AT() \ + goto error; \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: FAIL_UNLESS() + * + * Purpose: + * + * TEST_ERROR wrapper to reduce cognitive overhead from "negative tests", + * e.g., "a != b". + * + * Opposite of FAIL_IF; fails if the given condition is _not_ true. + * + * `FAIL_IF( 5 != my_op() )` + * is equivalent to + * `FAIL_UNLESS( 5 == my_op() )` + * However, `JSVERIFY(5, my_op(), "bad return")` may be even clearer. + * (see JSVERIFY) + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define FAIL_UNLESS(condition) \ +if (!(condition)) { \ + JSFAILED_AT() \ + goto error; \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: JSERR_LONG() + * + * Purpose: + * + * Print an failure message for long-int arguments. + * ERROR-AT printed first. + * If `reason` is given, it is printed on own line and newlined after + * else, prints "expected/actual" aligned on own lines. + * + * *FAILED* at myfile.c:488 in somefunc()... + * forest must be made of trees. + * + * or + * + * *FAILED* at myfile.c:488 in somefunc()... + * ! Expected 425 + * ! Actual 3 + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSERR_LONG(expected, actual, reason) { \ + JSFAILED_AT() \ + if (reason!= NULL) { \ + HDprintf("%s\n", (reason)); \ + } else { \ + HDprintf(" ! Expected %ld\n ! Actual %ld\n", \ + (long)(expected), (long)(actual)); \ + } \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: JSERR_STR() + * + * Purpose: + * + * Print an failure message for string arguments. + * ERROR-AT printed first. + * If `reason` is given, it is printed on own line and newlined after + * else, prints "expected/actual" aligned on own lines. + * + * *FAILED* at myfile.c:421 in myfunc()... + * Blue and Red strings don't match! + * + * or + * + * *FAILED* at myfile.c:421 in myfunc()... + * !!! Expected: + * this is my expected + * string + * !!! Actual: + * not what I expected at all + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSERR_STR(expected, actual, reason) { \ + JSFAILED_AT() \ + if ((reason) != NULL) { \ + HDprintf("%s\n", (reason)); \ + } else { \ + HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", \ + (expected), (actual)); \ + } \ +} + +#ifdef JSVERIFY_EXP_ACT +/* VERIFY rountines with paramter order (, [, ]) + */ + + +/*---------------------------------------------------------------------------- + * + * Macro: JSVERIFY() + * + * Purpose: + * + * Verify that two long integers are equal. + * If unequal, print failure message + * (with `reason`, if not NULL; expected/actual if NULL) + * and jump to `error` at end of function + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY(expected, actual, reason) \ +if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ +} /* JSVERIFY */ + +#if 0 /* UNUSED */ + +/*---------------------------------------------------------------------------- + * + * Macro: JSVERIFY_NOT() + * + * Purpose: + * + * Verify that two long integers are _not_ equal. + * If equal, print failure message + * (with `reason`, if not NULL; expected/actual if NULL) + * and jump to `error` at end of function + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_NOT(expected, actual, reason) \ +if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ +} /* JSVERIFY_NOT */ +#endif /* JSVERIFY_NOT unused */ + + +/*---------------------------------------------------------------------------- + * + * Macro: JSVERIFY_STR() + * + * Purpose: + * + * Verify that two strings are equal. + * If unequal, print failure message + * (with `reason`, if not NULL; expected/actual if NULL) + * and jump to `error` at end of function + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_STR(expected, actual, reason) \ +if (strcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ +} /* JSVERIFY_STR */ + + +#else +/* JSVERIFY_EXP_ACT not defined + * + * Repeats macros above, but with actual/expected parameters reversed. + */ + + +/*---------------------------------------------------------------------------- + * Macro: JSVERIFY() + * See: JSVERIFY documentation above. + * Programmer: Jacob Smith + * 2017-10-14 + *---------------------------------------------------------------------------- + */ +#define JSVERIFY(actual, expected, reason) \ +if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)); \ + goto error; \ +} /* JSVERIFY */ + +#if 0 /* UNUSED */ + +/*---------------------------------------------------------------------------- + * Macro: JSVERIFY_NOT() + * See: JSVERIFY_NOT documentation above. + * Programmer: Jacob Smith + * 2017-10-14 + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_NOT(actual, expected, reason) \ +if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ +} /* JSVERIFY_NOT */ +#endif /* JSVERIFY_NOT unused */ + + +/*---------------------------------------------------------------------------- + * Macro: JSVERIFY_STR() + * See: JSVERIFY_STR documentation above. + * Programmer: Jacob Smith + * 2017-10-14 + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_STR(actual, expected, reason) \ +if (strcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ +} /* JSVERIFY_STR */ + +#endif /* ifdef/else JSVERIFY_EXP_ACT */ + + +#ifdef H5_HAVE_ROS3_VFD + +#define S3_TEST_PROFILE_NAME "ros3_vfd_test" + +#define S3_TEST_RESOURCE_TEXT_RESTRICTED "t8.shakespeare.txt" +#define S3_TEST_RESOURCE_TEXT_PUBLIC "Poe_Raven.txt" +#define S3_TEST_RESOURCE_MISSING "missing.csv" + +#define S3_TEST_RUN_TIMEOUT 0 /* run tests that might hang */ +#define S3_TEST_MAX_URL_SIZE 256 /* char array size */ + +/* Global variables for aws test profile. + * An attempt is made to read ~/.aws/credentials and ~/.aws/config upon test + * startup -- if unable to open either file or cannot load region, id, and key, + * tests connecting with S3 will not be run + */ +static int s3_test_credentials_loaded = 0; +static char s3_test_aws_region[16] = ""; +static char s3_test_aws_access_key_id[64] = ""; +static char s3_test_aws_secret_access_key[128] = ""; +static char s3_test_bucket_url[S3_TEST_MAX_URL_SIZE] = ""; +static hbool_t s3_test_bucket_defined = FALSE; + +#endif /* H5_HAVE_ROS3_VFD */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_macro_format_credential() + * + * Purpose: + * + * Demonstrate that the macro `S3COMMS_FORMAT_CREDENTIAL` + * performs as expected. + * + * Programmer: Jacob Smith + * 2017-09-19 + * + *---------------------------------------------------------------------------- + */ +static herr_t +test_macro_format_credential(void) +{ + /************************ + * test-local variables * + ************************/ + +#ifdef H5_HAVE_ROS3_VFD + char dest[256]; + const char access[] = "AKIAIOSFODNN7EXAMPLE"; + const char date[] = "20130524"; + const char region[] = "us-east-1"; + const char service[] = "s3"; + const char expected[] = + "AKIAIOSFODNN7EXAMPLE/20130524/us-east-1/s3/aws4_request"; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("test_macro_format_credential"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD is not enabled"); + fflush(stdout); + return 0; +#else + FAIL_IF( S3COMMS_MAX_CREDENTIAL_SIZE < + S3COMMS_FORMAT_CREDENTIAL(dest, access, date, region, service) ) + + JSVERIFY_STR( expected, dest, NULL ) + + PASSED(); + return 0; +#endif /* H5_HAVE_ROS3_VFD */ + +error: + return -1; + +} /* test_macro_format_credential */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_aws_canonical_request() + * + * Purpose: + * + * Demonstrate the construction of a Canoncial Request (and Signed Headers) + * + * Elided / not yet implemented: + * Query strings + * request "body" + * + * Programmer: Jacob Smith + * 2017-10-04 + * + *--------------------------------------------------------------------------- + */ +static herr_t +test_aws_canonical_request(void) +{ + /************************* + * test-local structures * + *************************/ + +#ifdef H5_HAVE_ROS3_VFD + struct header { + const char *name; + const char *value; + }; + + struct testcase { + const char *exp_request; + const char *exp_headers; + const char *verb; + const char *resource; + unsigned int listsize; + struct header list[5]; + }; + + /************************ + * test-local variables * + ************************/ + + struct testcase cases[] = { + { "GET\n/some/path.file\n\nhost:somebucket.someserver.somedomain\nrange:bytes=150-244\n\nhost;range\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "host;range", + "GET", + "/some/path.file", + 2, + { {"Range", "bytes=150-244"}, + {"Host", "somebucket.someserver.somedomain"}, + }, + }, + { "HEAD\n/bucketpath/myfile.dat\n\nhost:place.domain\nx-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\nx-amz-date:19411207T150803Z\n\nhost;x-amz-content-sha256;x-amz-date\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "host;x-amz-content-sha256;x-amz-date", + "HEAD", + "/bucketpath/myfile.dat", + 3, + { {"x-amz-content-sha256", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}, + {"host", "place.domain"}, + {"x-amz-date", "19411207T150803Z"}, + } + }, + { "PUT\n/\n\n\n\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "", + "PUT", + "/", + 0, + {{"",""},}, /* unused; satisfies compiler */ + }, + }; /* struct testcase cases[] */ + struct testcase *C = NULL; + char cr_dest[512]; /* canonical request */ + hrb_t *hrb = NULL; /* http request buffer object */ + unsigned int i = 0; /* looping/indexing */ + unsigned int j = 0; /* looping/indexing */ + hrb_node_t *node = NULL; /* http headers list pointer */ + unsigned int n_cases = 3; + char sh_dest[64]; /* signed headers */ +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("test_aws_canonical_request"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD is not enabled"); + fflush(stdout); + return 0; +#else + for (i = 0; i < n_cases; i++) { + /* pre-test bookkeeping + */ + C = &cases[i]; + for (j = 0; j < 256; j++) { cr_dest[j] = 0; } /* zero request buffer */ + for (j = 0; j < 64; j++) { sh_dest[j] = 0; } /* zero headers buffer */ + + /* create HTTP request object with given verb, resource/path + */ + hrb = H5FD_s3comms_hrb_init_request(C->verb, + C->resource, + "HTTP/1.1"); + HDassert(hrb->body == NULL); + + /* Create headers list from test case input + */ + for (j = 0; j < C->listsize; j++) { + FAIL_IF( FAIL == + H5FD_s3comms_hrb_node_set( + &node, + C->list[j].name, + C->list[j].value)); + } + + hrb->first_header = node; + + /* test + */ + JSVERIFY( SUCCEED, + H5FD_s3comms_aws_canonical_request(cr_dest, sh_dest, hrb), + " unable to compose canonical request" ) + JSVERIFY_STR( C->exp_headers, sh_dest, NULL ) + JSVERIFY_STR( C->exp_request, cr_dest, NULL ) + + /* tear-down + */ + while (node != NULL) + FAIL_IF( FAIL == + H5FD_s3comms_hrb_node_set(&node, node->name, NULL)); + HDassert(NULL == node); + FAIL_IF( FAIL == H5FD_s3comms_hrb_destroy(&hrb)); + HDassert(NULL == hrb); + + } /* for each test case */ + + /*************** + * ERROR CASES * + ***************/ + + /* malformed hrb and/or node-list + */ + JSVERIFY( FAIL, H5FD_s3comms_aws_canonical_request(cr_dest, sh_dest, NULL), + "http request object cannot be null" ) + + hrb = H5FD_s3comms_hrb_init_request("GET", "/", "HTTP/1.1"); + JSVERIFY( FAIL, H5FD_s3comms_aws_canonical_request(NULL, sh_dest, hrb), + "canonical request destination cannot be NULL" ) + + JSVERIFY( FAIL, H5FD_s3comms_aws_canonical_request(cr_dest, NULL, hrb), + "signed headers destination cannot be null" ) + + FAIL_IF( FAIL == H5FD_s3comms_hrb_destroy(&hrb) ) + HDassert( NULL == hrb ); + + PASSED(); + return 0; + +error: + + if (node != NULL) { + while (node != NULL) + (void)H5FD_s3comms_hrb_node_set(&node, node->name, NULL); + HDassert( node == NULL ); + } + if (hrb != NULL) + (void)H5FD_s3comms_hrb_destroy(&hrb); + + return -1; +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_aws_canonical_request */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_bytes_to_hex + * + * Purpose: + * + * Define and verify behavior of `H5FD_s3comms_bytes_to_hex()`. + * + * Return: + * + * Success: 0 + * Failure: -1 + * + * Programmer: Jacob Smith + * 2017-09-14 + * + *--------------------------------------------------------------------------- + */ +static herr_t +test_bytes_to_hex(void) +{ + /************************* + * test-local structures * + *************************/ + + struct testcase { + const char exp[17]; /* in size * 2 + 1 for null terminator */ + const unsigned char in[8]; + size_t size; + hbool_t lower; + }; + + /************************ + * test-local variables * + ************************/ + + struct testcase cases[] = { + { "52F3000C9A", + {82,243,0,12,154}, + 5, + FALSE, + }, + { "009a0cf3005200", /* lowercase alphas */ + {0,154,12,243,0,82,0}, + 7, + TRUE, + }, + { "", + {17,63,26,56}, + 0, + FALSE, /* irrelevant */ + }, + }; + int i = 0; + int n_cases = 3; + char out[17]; + int out_off = 0; + + + + TESTING("bytes-to-hex"); + + for (i = 0; i < n_cases; i++) { + for (out_off = 0; out_off < 17; out_off++) { + out[out_off] = 0; + } + + JSVERIFY( SUCCEED, + H5FD_s3comms_bytes_to_hex(out, + cases[i].in, + cases[i].size, + cases[i].lower), + NULL ) + + JSVERIFY_STR(cases[i].exp, out, NULL) + } + + /* dest cannot be null + */ + JSVERIFY( FAIL, + H5FD_s3comms_bytes_to_hex( + NULL, + (const unsigned char *)"nada", + 5, + FALSE), + "destination cannot be null" ) + + PASSED(); + return 0; + +error: + return -1; + +} /* test_bytes_to_hex */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_hrb_init_request() + * + * Purpose: + * + * Define and verify behavior of `H5FD_s3comms_hrb_init_request()` + * + * Programmer: Jacob Smith + * 2017-09-20 + * + *--------------------------------------------------------------------------- + */ +static herr_t +test_hrb_init_request(void) +{ +#ifdef H5_HAVE_ROS3_VFD + /********************* + * test-local macros * + *********************/ + + /************************* + * test-local structures * + *************************/ + + struct testcase { + const char msg[64]; + const char *verb; + const char *resource; + const char *exp_res; + const char *version; + hbool_t ret_null; + }; + + /************************ + * test-local variables * + ************************/ + + struct testcase cases[] = { + { "get HTTP request just as we provided", + "GET", + "/path/to/some/file", + "/path/to/some/file", + "HTTP/1.1", + FALSE, + }, + { "null verb substitues to GET", + NULL, + "/MYPATH/MYFILE.tiff", + "/MYPATH/MYFILE.tiff", + "HTTP/1.1", + FALSE, + }, + { "demonstrate non-GET verb", + "HEAD", + "/MYPATH/MYFILE.tiff", + "/MYPATH/MYFILE.tiff", + "HTTP/1.1", + FALSE, + }, + { "slash prepented to resource path, if necessary", + NULL, + "MYPATH/MYFILE.tiff", + "/MYPATH/MYFILE.tiff", + NULL, + FALSE, + }, + { "null resource path causes problem", + "GET", + NULL, + NULL, + NULL, + TRUE, + }, + }; + struct testcase *C = NULL; + unsigned int i = 0; + unsigned int ncases = 5; + hrb_t *req = NULL; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("hrb_init_request"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD is not enabled"); + fflush(stdout); + return 0; +#else + for (i = 0; i < ncases; i++) { + C = &cases[i]; + req = H5FD_s3comms_hrb_init_request(C->verb, + C->resource, + C->version); + if (cases[i].ret_null == TRUE) { + FAIL_IF( req != NULL ); + } else { + FAIL_IF( req == NULL ); + JSVERIFY( S3COMMS_HRB_MAGIC, req->magic, NULL ) + if (C->verb == NULL) { + JSVERIFY_STR( "GET", req->verb, NULL ) + } else { + JSVERIFY_STR( req->verb, C->verb, NULL ) + } + JSVERIFY_STR( "HTTP/1.1", req->version, NULL ) + JSVERIFY_STR( C->exp_res, req->resource, NULL ) + FAIL_IF( req->first_header != NULL ); + FAIL_IF( req->body != NULL ); + JSVERIFY( 0, req->body_len, NULL ) + JSVERIFY( SUCCEED, H5FD_s3comms_hrb_destroy(&req), + "unable to destroy hrb_t" ) + FAIL_IF( NULL != req ); /* should annull pointer as well as free */ + } + + } /* for each testcase */ + + PASSED(); + return 0; + +error: + (void)H5FD_s3comms_hrb_destroy(&req); + + return -1; +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_hrb_init_request */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_hrb_node_set() + * + * Purpose: + * + * Test operations on hrb_node_t structure + * + * Programmer: Jacob Smith + * 2017-09-22 + * + *--------------------------------------------------------------------------- + */ +static herr_t +test_hrb_node_set(void) +{ +#ifdef H5_HAVE_ROS3_VFD + /************************* + * test-local structures * + *************************/ + + /* bundle of name/value representing an hrb_node_t + */ + typedef struct node_mock_t { + const char *name; + const char *value; + } node_mock_t; + + /* bundle for a testcase + * + * `message` + * purpose of the testcase + * + * `delta` + * container for name and value strings to pass into node-set function + * to to modify the list. + * + * `returned` + * expected return value of node-set function + * + * `given` + * `expected` + * string arrays representing the state of the list before and after + * modification. The number of strings must be even, with each name + * paired to a value. `NULL` terminates the list, with `{NULL}` + * representing the empty list. + */ + typedef struct testcase { + const char *message; + node_mock_t delta; + herr_t returned; + const char *given[11]; /* name/value pairs in array; NULL sentinel */ + const char *expected[11]; + } testcase; + + /************************ + * test-local variables * + ************************/ + + testcase cases[] = { + { "cannot remove node from null list", + { "Host", NULL }, + FAIL, + {NULL}, + {NULL}, + }, + { "cannot create list with NULL field name", + { NULL, "somevalue" }, + FAIL, + {NULL}, + {NULL}, + }, + { "create a new list", + { "Host", "somevalue" }, + SUCCEED, + {NULL}, + { "Host", "somevalue", + NULL, + }, + }, + { "insert new node at head list", + { "Host", "somevalue" }, + SUCCEED, + { "Range", "bytes=20-40", + NULL, + }, + { "Host", "somevalue", + "Range", "bytes=20-40", + NULL, + }, + }, + { "append new node at list end", + { "x-amz-date", "somevalue" }, + SUCCEED, + { "Range", "bytes=20-40", + NULL, + }, + { "Range", "bytes=20-40", + "x-amz-date", "somevalue", + NULL, + }, + }, + { "insert new node inside list", + { "Intermediary", "somevalue" }, + SUCCEED, + { "Host", "somehost" , + "Range", "bytes=20-40", + NULL, + }, + { "Host", "somehost", + "Intermediary", "somevalue", + "Range", "bytes=20-40", + NULL, + }, + }, + { "modify node", + { "Range", "bytes=40-80" }, + SUCCEED, + { "Host", "somehost", + "Range", "bytes=20-40", + NULL, + }, + { "Host", "somehost", + "Range", "bytes=40-80", + NULL, + }, + }, + { "modify node with new case", + { "RANGE", "bytes=40-80" }, + SUCCEED, + { "Host", "somehost", + "Range", "bytes=20-40", + NULL, + }, + { "Host", "somehost", + "RANGE", "bytes=40-80", + NULL, + }, + }, + { "cannot add node with no name", + { NULL, "bytes=40-80" }, + FAIL, + { "Host", "somehost", + NULL, + }, + { "Host", "somehost", + NULL, + }, + }, + { "add node with 'empty' name", + { "", "bytes=40-80" }, + SUCCEED, + { "Host", "somehost", + NULL, + }, + { "", "bytes=40-80", + "Host", "somehost", + NULL, + }, + }, + { "remove node from end of list", + { "Host", NULL }, + SUCCEED, + { "Date", "Thr, 25 Jan 2018", + "Host", "somehost", + NULL, + }, + { "Date", "Thr, 25 Jan 2018", + NULL, + }, + }, + { "remove node from middle of list", + { "Host", NULL }, + SUCCEED, + { "Date", "Thr, 25 Jan 2018", + "Host", "somehost", + "Range", "bytes=20-40", + NULL, + }, + { "Date", "Thr, 25 Jan 2018", + "Range", "bytes=20-40", + NULL, + }, + }, + { "remove node from start of list", + { "Date", NULL }, + SUCCEED, + { "Date", "Thr, 25 Jan 2018", + "Host", "somehost", + "Range", "bytes=20-40", + NULL, + }, + { "Host", "somehost", + "Range", "bytes=20-40", + NULL, + }, + }, + { "remove only node in list", + { "Date", NULL }, + SUCCEED, + { "Date", "Thr, 25 Jan 2018", + NULL, + }, + { NULL, + }, + }, + { "attempt to remove absent node fails", + { "Host", NULL }, + FAIL, + { "Date", "Thr, 25 Jan 2018", + "Range", "bytes=20-40", + NULL, + }, + { "Date", "Thr, 25 Jan 2018", + "Range", "bytes=20-40", + NULL, + }, + }, + { "removal is case-insensitive", + { "hOsT", NULL }, + SUCCEED, + { "Date", "Thr, 25 Jan 2018", + "Host", "somehost", + "Range", "bytes=20-40", + NULL, + }, + { "Date", "Thr, 25 Jan 2018", + "Range", "bytes=20-40", + NULL, + }, + }, + }; + unsigned testcases_count = 16; + unsigned test_i = 0; + + hrb_node_t *list = NULL; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("test_hrb_node_t"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD is not enabled"); + fflush(stdout); + return 0; +#else + for (test_i = 0; test_i < testcases_count; test_i++) { + const hrb_node_t *node = NULL; + const testcase *test = &(cases[test_i]); + unsigned mock_i = 0; + + /********* + * SETUP * + *********/ + + for (mock_i = 0; test->given[mock_i] != NULL; mock_i += 2) { + const char *name = test->given[mock_i]; + const char *valu = test->given[mock_i+1]; + + FAIL_IF( SUCCEED != + H5FD_s3comms_hrb_node_set(&list, name, valu) ) + } + /******** + * TEST * + ********/ + + /* perform modification on list + */ + JSVERIFY( test->returned, + H5FD_s3comms_hrb_node_set(&list, + test->delta.name, + test->delta.value), + test->message ) + + + /* verify resulting list + */ + node = list; + mock_i = 0; + while (test->expected[mock_i] != NULL && node != NULL) { + const char *name = test->expected[mock_i]; + const char *valu = test->expected[mock_i+1]; + + JSVERIFY_STR( name, node->name, NULL ) + JSVERIFY_STR( valu, node->value, NULL ) + + mock_i += 2; + node = node->next; + } + FAIL_IF( test->expected[mock_i] != NULL ) + FAIL_IF( node != NULL ) + + /************ + * TEARDOWN * + ************/ + + while (list != NULL) { + FAIL_IF( SUCCEED != + H5FD_s3comms_hrb_node_set(&list, list->name, NULL) ) + } + } + + PASSED(); + return 0; + +error: + while (list != NULL) + (void)H5FD_s3comms_hrb_node_set(&list, list->name, NULL); + + return -1; +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_hrb_node_t */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_HMAC_SHA256() + * + * Purpose: + * + * Define and verify behavior of `H5FD_s3comms_HMAC_SHA256()` + * + * Programmer: Jacob Smith + * 2017-09-19 + * + *--------------------------------------------------------------------------- + */ +static herr_t +test_HMAC_SHA256(void) +{ + + /************************* + * test-local structures * + *************************/ + +#ifdef H5_HAVE_ROS3_VFD + struct testcase { + herr_t ret; /* SUCCEED/FAIL expected from call */ + const unsigned char key[SHA256_DIGEST_LENGTH]; + size_t key_len; + const char *msg; + size_t msg_len; + const char *exp; /* not used if ret == FAIL */ + size_t dest_size; /* if 0, `dest` is not malloc'd */ + }; + + /************************ + * test-local variables * + ************************/ + + struct testcase cases[] = { + { SUCCEED, + { 0xdb, 0xb8, 0x93, 0xac, 0xc0, 0x10, 0x96, 0x49, + 0x18, 0xf1, 0xfd, 0x43, 0x3a, 0xdd, 0x87, 0xc7, + 0x0e, 0x8b, 0x0d, 0xb6, 0xbe, 0x30, 0xc1, 0xfb, + 0xea, 0xfe, 0xfa, 0x5e, 0xc6, 0xba, 0x83, 0x78, + }, + SHA256_DIGEST_LENGTH, + "AWS4-HMAC-SHA256\n20130524T000000Z\n20130524/us-east-1/s3/aws4_request\n7344ae5b7ee6c3e7e6b0fe0640412a37625d1fbfff95c48bbb2dc43964946972", + HDstrlen("AWS4-HMAC-SHA256\n20130524T000000Z\n20130524/us-east-1/s3/aws4_request\n7344ae5b7ee6c3e7e6b0fe0640412a37625d1fbfff95c48bbb2dc43964946972"), + "f0e8bdb87c964420e857bd35b5d6ed310bd44f0170aba48dd91039c6036bdb41", + SHA256_DIGEST_LENGTH * 2 + 1, /* +1 for null terminator */ + }, + { SUCCEED, + {'J','e','f','e'}, + 4, + "what do ya want for nothing?", + 28, + "5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843", + SHA256_DIGEST_LENGTH * 2 + 1, + }, + { FAIL, + "DOESN'T MATTER", + 14, + "ALSO IRRELEVANT", + 15, + NULL, + 0, /* dest -> null, resulting in immediate error */ + }, + }; + char *dest = NULL; + int i = 0; + int n_cases = 3; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("HMAC_SHA256"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD is not enabled"); + fflush(stdout); + return 0; +#else + for (i = 0; i < n_cases; i++) { + if (cases[i].dest_size == 0) { + dest = NULL; + } else { + dest = (char *)HDmalloc(sizeof(char) * cases[i].dest_size); + HDassert(dest != NULL); + } + + JSVERIFY( cases[i].ret, + H5FD_s3comms_HMAC_SHA256( + cases[i].key, + cases[i].key_len, + cases[i].msg, + cases[i].msg_len, + dest), + cases[i].msg ); + if (cases[i].ret == SUCCEED) { +#ifdef VERBOSE + if (0 != + strncmp(cases[i].exp, + dest, + HDstrlen(cases[i].exp))) + { + /* print out how wrong things are, and then fail + */ + dest = (char *)realloc(dest, cases[i].dest_size + 1); + HDassert(dest != NULL); + dest[cases[i].dest_size] = 0; + HDfprintf(stdout, + "ERROR:\n!!! \"%s\"\n != \"%s\"\n", + cases[i].exp, + dest); + TEST_ERROR; + } +#else + /* simple pass/fail test + */ + JSVERIFY( 0, + strncmp(cases[i].exp, dest, HDstrlen(cases[i].exp)), + NULL); +#endif + } + free(dest); + } + + PASSED(); + return 0; + +error: + free(dest); + return -1; +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_HMAC_SHA256 */ + + +/*---------------------------------------------------------------------------- + * + * Function: test_nlowercase() + * + * Purpose: + * + * Define and verify behavior of `H5FD_s3comms_nlowercase()` + * + * Programmer: Jacob Smith + * 2017-19-18 + * + *---------------------------------------------------------------------------- + */ +static herr_t +test_nlowercase(void) +{ + /************************* + * test-local structures * + *************************/ + +#ifdef H5_HAVE_ROS3_VFD + struct testcase { + const char *in; + size_t len; + const char *exp; + }; + + /************************ + * test-local variables * + ************************/ + + /* any character after in exp on or after exp[len] is undefined. + * in this test, kept as the null character for simplicity. + */ + struct testcase cases[] = { + { "HALlEluJAh", + 6, + "hallel", + }, + { "all\0 lower", + 10, + "all\0 lower", + }, + { "to meeeeeee", + 0, + "", + }, + }; + char *dest = NULL; + int i = 0; + int n_cases = 3; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("nlowercase"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD is not enabled"); + fflush(stdout); + return 0; +#else + for (i = 0; i < n_cases; i++) { + dest = (char *)HDmalloc(sizeof(char) * 16); + + JSVERIFY( SUCCEED, + H5FD_s3comms_nlowercase(dest, + cases[i].in, + cases[i].len), + cases[i].in ) + if (cases[i].len > 0) { + JSVERIFY( 0, strncmp(dest, cases[i].exp, cases[i].len), NULL ) + } + free(dest); + } + + JSVERIFY( FAIL, + H5FD_s3comms_nlowercase(NULL, + cases[0].in, + cases[0].len), + "null distination should fail" ) + + PASSED(); + return 0; + +error: + free(dest); + return -1; +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_nlowercase */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_parse_url() + * + * Programmer: Jacob Smith + * 2017-11-?? + * + *--------------------------------------------------------------------------- + */ +static herr_t +test_parse_url(void) +{ + /********************* + * test-local macros * + *********************/ + + /************************* + * test-local structures * + *************************/ + +#ifdef H5_HAVE_ROS3_VFD + typedef struct { + const char *scheme; + const char *host; + const char *port; + const char *path; + const char *query; + } const_purl_t; + + struct testcase { + const char *url; + herr_t exp_ret; /* expected return; */ + /* if FAIL, `expected` is unused */ + const_purl_t expected; + const char *msg; + }; + + /************************ + * test-local variables * + ************************/ + + parsed_url_t *purl = NULL; + unsigned int i = 0; + unsigned int ncases = 15; + struct testcase cases[] = { + { NULL, + FAIL, + { NULL, NULL, NULL, NULL, NULL }, + "null url", + }, + { "", + FAIL, + { NULL, NULL, NULL, NULL, NULL }, + "empty url", + }, + { "ftp://[1000:4000:0002:2010]", + SUCCEED, + { "ftp", + "[1000:4000:0002:2010]", + NULL, + NULL, + NULL, + }, + "IPv6 ftp and empty path (root)", + }, + { "ftp://[1000:4000:0002:2010]:2040", + SUCCEED, + { "ftp", + "[1000:4000:0002:2010]", + "2040", + NULL, + NULL, + }, + "root IPv6 ftp with port", + }, + { "http://some.domain.org:9000/path/to/resource.txt", + SUCCEED, + { "http", + "some.domain.org", + "9000", + "path/to/resource.txt", + NULL, + }, + "without query", + }, + { "https://domain.me:00/file.txt?some_params unchecked", + SUCCEED, + { "https", + "domain.me", + "00", + "file.txt", + "some_params unchecked", + }, + "with query", + }, + { "ftp://domain.com/", + SUCCEED, + { "ftp", + "domain.com", + NULL, + NULL, + NULL, + }, + "explicit root w/out port", + }, + { "ftp://domain.com:1234/", + SUCCEED, + { "ftp", + "domain.com", + "1234", + NULL, + NULL, + }, + "explicit root with port", + }, + { "ftp://domain.com:1234/file?", + FAIL, + { NULL, NULL, NULL, NULL, NULL, }, + "empty query is invalid", + }, + { "ftp://:1234/file", + FAIL, + { NULL, NULL, NULL, NULL, NULL, }, + "no host", + }, + { "h&r block", + FAIL, + { NULL, NULL, NULL, NULL, NULL, }, + "no scheme (bad URL)", + }, + { "http://domain.com?a=b&d=b", + SUCCEED, + { "http", + "domain.com", + NULL, + NULL, + "a=b&d=b", + }, + "QUERY with implict PATH", + }, + { "http://[5]/path?a=b&d=b", + SUCCEED, + { "http", + "[5]", + NULL, + "path", + "a=b&d=b", + }, + "IPv6 extraction is really dumb", + }, + { "http://[1234:5678:0910:1112]:port/path", + FAIL, + { NULL, NULL, NULL, NULL, NULL, }, + "non-decimal PORT (port)", + }, + { "http://mydomain.com:01a3/path", + FAIL, + { NULL, NULL, NULL, NULL, NULL, }, + "non-decimal PORT (01a3)", + }, + }; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("url-parsing functionality"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD is not enabled"); + fflush(stdout); + return 0; +#else + /********* + * TESTS * + *********/ + + for (i = 0; i < ncases; i++) { + HDassert( purl == NULL ); + + JSVERIFY( cases[i].exp_ret, + H5FD_s3comms_parse_url(cases[i].url, &purl), + cases[i].msg ) + + if (cases[i].exp_ret == FAIL) { + /* on FAIL, `purl` should be untouched--remains NULL */ + FAIL_UNLESS( purl == NULL ) + } else { + /* on SUCCEED, `purl` should be set */ + FAIL_IF( purl == NULL ) + + if (cases[i].expected.scheme != NULL) { + FAIL_IF( NULL == purl->scheme ) + JSVERIFY_STR( cases[i].expected.scheme, + purl->scheme, + cases[i].msg ) + } else { + FAIL_UNLESS( NULL == purl->scheme ) + } + + if (cases[i].expected.host != NULL) { + FAIL_IF( NULL == purl->host ) + JSVERIFY_STR( cases[i].expected.host, + purl->host, + cases[i].msg ) + } else { + FAIL_UNLESS( NULL == purl->host ) + } + + if (cases[i].expected.port != NULL) { + FAIL_IF( NULL == purl->port ) + JSVERIFY_STR( cases[i].expected.port, + purl->port, + cases[i].msg ) + } else { + FAIL_UNLESS( NULL == purl->port ) + } + + if (cases[i].expected.path != NULL) { + FAIL_IF( NULL == purl->path ) + JSVERIFY_STR( cases[i].expected.path, + purl->path, + cases[i].msg ) + } else { + FAIL_UNLESS( NULL == purl->path ) + } + + if (cases[i].expected.query != NULL) { + FAIL_IF( NULL == purl->query ) + JSVERIFY_STR( cases[i].expected.query, + purl->query, + cases[i].msg ) + } else { + FAIL_UNLESS( NULL == purl->query ) + } + } /* if parse-url return SUCCEED/FAIL */ + + /* per-test cleanup + * well-behaved, even if `purl` is NULL + */ + FAIL_IF( FAIL == H5FD_s3comms_free_purl(purl) ) + purl = NULL; + + } /* for each testcase */ + + PASSED(); + return 0; + +error: + /*********** + * cleanup * + ***********/ + (void)H5FD_s3comms_free_purl(purl); + + return -1; +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_parse_url */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_percent_encode_char() + * + * Purpose: + * + * Define and verify behavior of `H5FD_s3comms_percent_encode_char()` + * + * Return: + * + * Success: 0 + * Failure: -1 + * + * Programmer: Jacob Smith + * 2017-09-14 + * + *--------------------------------------------------------------------------- + */ +static herr_t +test_percent_encode_char(void) +{ + /************************* + * test-local structures * + *************************/ + +#ifdef H5_HAVE_ROS3_VFD + struct testcase { + const char c; + const char *exp; + size_t exp_len; + }; + + /************************ + * test-local variables * + ************************/ + + struct testcase cases[] = { + {'$', "%24", 3}, /* u+0024 dollar sign */ + {' ', "%20", 3}, /* u+0020 space */ + {'^', "%5E", 3}, /* u+0094 carat */ + {'/', "%2F", 3}, /* u+002f solidus (forward slash) */ + /* {??, "%C5%8C", 6},*/ /* u+014c Latin Capital Letter O with Macron */ + /* Not included because it is multibyte "wide" character that poses */ + /* issues both in the underlying function and in being written in */ + /* this file. */ + /* {'¢', "%C2%A2", 6}, */ /* u+00a2 cent sign */ + /* above works, but complains about wide character overflow */ + /* Elide for now, until it is determined (a) unnecessary or */ + /* (b) requiring signature change to accommodate wide characters */ + {'\0', "%00", 3}, /* u+0000 null */ + }; + char dest[13]; + size_t dest_len = 0; + int i = 0; + int n_cases = 5; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("percent encode characters"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD is not enabled"); + fflush(stdout); + return 0; +#else + for (i = 0; i < n_cases; i++) { + JSVERIFY( SUCCEED, + H5FD_s3comms_percent_encode_char( + dest, + (const unsigned char)cases[i].c, + &dest_len), + NULL ) + JSVERIFY(cases[i].exp_len, dest_len, NULL ) + JSVERIFY(0, strncmp(dest, cases[i].exp, dest_len), NULL ) + JSVERIFY_STR( cases[i].exp, dest, NULL ) + } + + JSVERIFY( FAIL, + H5FD_s3comms_percent_encode_char( + NULL, + (const unsigned char)'^', + &dest_len), + NULL ) + + PASSED(); + return 0; + +error: + return -1; +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_percent_encode_char */ + + +/*--------------------------------------------------------------------------- + * Function: test_s3r_open() + * + * Programmer: Jacob Smith 2018-01-24 + * + * Changes: None + * + *--------------------------------------------------------------------------- + */ +static herr_t +test_s3r_get_filesize(void) +{ +#ifdef H5_HAVE_ROS3_VFD + + /************************ + * test-local variables * + ************************/ + + char url_raven[S3_TEST_MAX_URL_SIZE]; + s3r_t *handle = NULL; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("s3r_get_filesize"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD is not enabled"); + fflush(stdout); + return 0; +#else + /* setup -- compose url to target resource + */ + if (FALSE == s3_test_bucket_defined) { + SKIPPED(); + puts(" environment variable HDF5_ROS3_TEST_BUCKET_URL not defined"); + fflush(stdout); + return 0; + } + + FAIL_IF( S3_TEST_MAX_URL_SIZE < + HDsnprintf(url_raven, + S3_TEST_MAX_URL_SIZE, + "%s/%s", + s3_test_bucket_url, + S3_TEST_RESOURCE_TEXT_PUBLIC) ); + + JSVERIFY( 0, H5FD_s3comms_s3r_get_filesize(NULL), + "filesize of the null handle should be 0" ) + + handle = H5FD_s3comms_s3r_open(url_raven, NULL, NULL, NULL); + FAIL_IF( handle == NULL ) + + JSVERIFY( 6464, H5FD_s3comms_s3r_get_filesize(handle), NULL ) + + + FAIL_IF( SUCCEED != H5FD_s3comms_s3r_close(handle) ) + + PASSED(); + return 0; + +error: + if (handle != NULL) + (void)H5FD_s3comms_s3r_close(handle); + + return -1; +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_s3r_get_filesize */ + + +/*--------------------------------------------------------------------------- + * Function: test_s3r_open() + * + * Programmer: Jacob Smith 2018-01-?? + * + * Changes: None + * + *--------------------------------------------------------------------------- + */ +static herr_t +test_s3r_open(void) +{ +#ifdef H5_HAVE_ROS3_VFD + + /************************ + * test-local variables * + ************************/ + + char url_missing[S3_TEST_MAX_URL_SIZE]; + char url_raven[S3_TEST_MAX_URL_SIZE]; + char url_raven_badport[S3_TEST_MAX_URL_SIZE]; + char url_shakespeare[S3_TEST_MAX_URL_SIZE]; + unsigned char signing_key[SHA256_DIGEST_LENGTH]; + struct tm *now = NULL; + char iso8601now[ISO8601_SIZE]; + s3r_t *handle = NULL; + hbool_t curl_ready = FALSE; + parsed_url_t *purl = NULL; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("s3r_open"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD is not enabled"); + fflush(stdout); + return 0; +#else + if (s3_test_credentials_loaded == 0) { + SKIPPED(); + puts(" s3 credentials are not loaded"); + fflush(stdout); + return 0; + } + if (FALSE == s3_test_bucket_defined) { + SKIPPED(); + puts(" environment variable HDF5_ROS3_TEST_BUCKET_URL not defined"); + fflush(stdout); + return 0; + } + + /****************** + * PRE-TEST SETUP * + ******************/ + + FAIL_IF( S3_TEST_MAX_URL_SIZE < + HDsnprintf(url_shakespeare, + S3_TEST_MAX_URL_SIZE, + "%s/%s", + s3_test_bucket_url, + S3_TEST_RESOURCE_TEXT_RESTRICTED) ); + + FAIL_IF( S3_TEST_MAX_URL_SIZE < + HDsnprintf(url_missing, + S3_TEST_MAX_URL_SIZE, + "%s/%s", + s3_test_bucket_url, + S3_TEST_RESOURCE_MISSING) ); + + FAIL_IF( S3_TEST_MAX_URL_SIZE < + HDsnprintf(url_raven, + S3_TEST_MAX_URL_SIZE, + "%s/%s", + s3_test_bucket_url, + S3_TEST_RESOURCE_TEXT_PUBLIC) ); + + /* Set given bucket url with invalid/inactive port number for badport. + * Note, this sort of micro-management of parsed_url_t is not advised + */ + FAIL_IF( FAIL == H5FD_s3comms_parse_url(s3_test_bucket_url, &purl) ) + if (purl->port == NULL) { + purl->port = (char *)H5MM_malloc(sizeof(char) * 5); + FAIL_IF( purl->port == NULL ); + FAIL_IF( 5 < HDsnprintf(purl->port, 5, "9000") ) + } else if (strcmp(purl->port, "9000") != 0) { + FAIL_IF( 5 < HDsnprintf(purl->port, 5, "9000") ) + } else { + FAIL_IF( 5 < HDsnprintf(purl->port, 5, "1234") ) + } + FAIL_IF( S3_TEST_MAX_URL_SIZE < + HDsnprintf(url_raven_badport, + S3_TEST_MAX_URL_SIZE, + "%s://%s:%s/%s", + purl->scheme, + purl->host, + purl->port, + S3_TEST_RESOURCE_TEXT_PUBLIC) ); + + curl_global_init(CURL_GLOBAL_DEFAULT); + curl_ready = TRUE; + + now = gmnow(); + FAIL_IF( now == NULL ) + FAIL_IF( ISO8601NOW(iso8601now, now) != (ISO8601_SIZE - 1) ); + + /* It is desired to have means available to verify that signing_key + * was set successfully and to an expected value. + */ + FAIL_IF( FAIL == + H5FD_s3comms_signing_key( + signing_key, + (const char *)s3_test_aws_secret_access_key, + (const char *)s3_test_aws_region, + (const char *)iso8601now) ); + + /************************* + * OPEN NONEXISTENT FILE * + *************************/ + + /* attempt anonymously + */ + handle = H5FD_s3comms_s3r_open(url_missing, NULL, NULL, NULL); + FAIL_IF( handle != NULL ); + + /* attempt with authentication + */ + handle = H5FD_s3comms_s3r_open( + url_missing, + (const char *)s3_test_aws_region, + (const char *)s3_test_aws_access_key_id, + (const unsigned char *)signing_key); + FAIL_IF( handle != NULL ); + + /************************* + * INACTIVE PORT ON HOST * + *************************/ + +#if S3_TEST_RUN_TIMEOUT +printf("Opening on inactive port may hang for a minute; waiting for timeout\n"); + handle = H5FD_s3comms_s3r_open(url_raven_badport, NULL, NULL, NULL); + FAIL_IF( handle != NULL ); +#endif + + /******************************* + * INVALID AUTHENTICATION INFO * + *******************************/ + + /* anonymous access on restricted file + */ + handle = H5FD_s3comms_s3r_open(url_shakespeare, NULL, NULL, NULL); + FAIL_IF( handle != NULL ); + + /* passed in a bad ID + */ + handle = H5FD_s3comms_s3r_open( + url_shakespeare, + (const char *)s3_test_aws_region, + "I_MADE_UP_MY_ID", + (const unsigned char *)signing_key); + FAIL_IF( handle != NULL ); + + /* using an invalid signing key + */ + handle = H5FD_s3comms_s3r_open( + url_shakespeare, + (const char *)s3_test_aws_region, + (const char *)s3_test_aws_access_key_id, + (const unsigned char *)EMPTY_SHA256); + FAIL_IF( handle != NULL ); + + /******************************* + * SUCCESSFUL OPEN (AND CLOSE) * + *******************************/ + + /* anonymous + */ + handle = H5FD_s3comms_s3r_open(url_raven, NULL, NULL, NULL); + FAIL_IF( handle == NULL ); + JSVERIFY( 6464, H5FD_s3comms_s3r_get_filesize(handle), + "did not get expected filesize" ) + JSVERIFY( SUCCEED, + H5FD_s3comms_s3r_close(handle), + "unable to close file" ) + handle = NULL; + + /* using authentication on anonymously-accessible file? + */ + handle = H5FD_s3comms_s3r_open( + url_raven, + (const char *)s3_test_aws_region, + (const char *)s3_test_aws_access_key_id, + (const unsigned char *)signing_key); + FAIL_IF( handle == NULL ); + JSVERIFY( 6464, H5FD_s3comms_s3r_get_filesize(handle), NULL ) + JSVERIFY( SUCCEED, + H5FD_s3comms_s3r_close(handle), + "unable to close file" ) + handle = NULL; + + /* authenticating + */ + handle = H5FD_s3comms_s3r_open( + url_shakespeare, + (const char *)s3_test_aws_region, + (const char *)s3_test_aws_access_key_id, + (const unsigned char *)signing_key); + FAIL_IF( handle == NULL ); + JSVERIFY( 5458199, H5FD_s3comms_s3r_get_filesize(handle), NULL ) + JSVERIFY( SUCCEED, + H5FD_s3comms_s3r_close(handle), + "unable to close file" ) + handle = NULL; + + + + curl_global_cleanup(); + curl_ready = FALSE; + + FAIL_IF( FAIL == H5FD_s3comms_free_purl(purl) ) + purl = NULL; + + PASSED(); + return 0; +error: + /*********** + * cleanup * + ***********/ + + if (handle != NULL) + H5FD_s3comms_s3r_close(handle); + if (purl != NULL) + H5FD_s3comms_free_purl(purl); + if (curl_ready == TRUE) + curl_global_cleanup(); + + return -1; +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_s3r_open */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_s3r_read() + * + * Purpose: + * + * Specify and demonstrate the use and life cycle of an S3 Request handle + * `s3r_t`, through its related functions. + * + * H5FD_s3comms_s3r_open + * H5FD_s3comms_s3r_getsize << called by open() _only_ + * H5FD_s3comms_s3r_read << called by getsize(), multiple times working + * H5FD_s3comms_s3r_close + * + * Shows most basic curl interation. + * + * Programmer: Jacob Smith + * 2017-10-06 + * + *--------------------------------------------------------------------------- + */ +static herr_t +test_s3r_read(void) +{ +#ifdef H5_HAVE_ROS3_VFD + +#define S3COMMS_TEST_BUFFER_SIZE 256 + + /************************ + * test-local variables * + ************************/ + + char url_raven[S3_TEST_MAX_URL_SIZE]; + char buffer[S3COMMS_TEST_BUFFER_SIZE]; + s3r_t *handle = NULL; + hbool_t curl_ready = FALSE; + unsigned int i = 0; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("test_s3r_read"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD is not enabled"); + fflush(stdout); + return 0; +#else + /* + * initial setup + */ + if (FALSE == s3_test_bucket_defined) { + SKIPPED(); + puts(" environment variable HDF5_ROS3_TEST_BUCKET_URL not defined"); + fflush(stdout); + return 0; + } + + curl_global_init(CURL_GLOBAL_DEFAULT); + curl_ready = TRUE; + FAIL_IF( S3_TEST_MAX_URL_SIZE < + HDsnprintf(url_raven, + S3_TEST_MAX_URL_SIZE, + "%s/%s", + s3_test_bucket_url, + S3_TEST_RESOURCE_TEXT_PUBLIC) ); + + for (i = 0; i < S3COMMS_TEST_BUFFER_SIZE; i++) + buffer[i] = '\0'; + + /* open file + */ + handle = H5FD_s3comms_s3r_open(url_raven, NULL, NULL, NULL); + FAIL_IF( handle == NULL ) + JSVERIFY( 6464, H5FD_s3comms_s3r_get_filesize(handle), NULL ) + + for (i = 0; i < S3COMMS_TEST_BUFFER_SIZE; i++) + buffer[i] = '\0'; + + /********************** + * read start of file * + **********************/ + + JSVERIFY( SUCCEED, + H5FD_s3comms_s3r_read( + handle, + (haddr_t)0, + (size_t)118, + buffer), + NULL ) + JSVERIFY_STR ( + "Once upon a midnight dreary, while I pondered, weak and weary,\n" \ + "Over many a quaint and curious volume of forgotten lore", + buffer, + NULL ) + + for (i = 0; i < S3COMMS_TEST_BUFFER_SIZE; i++) + buffer[i] = '\0'; + + /************************ + * read arbitrary range * + ************************/ + + JSVERIFY( SUCCEED, + H5FD_s3comms_s3r_read( + handle, + (haddr_t)2540, + (size_t)54, + buffer), + NULL ) + JSVERIFY_STR( "the grave and stern decorum of the countenance it wore", + buffer, + NULL ) + + for (i = 0; i < S3COMMS_TEST_BUFFER_SIZE; i++) + buffer[i] = '\0'; + + /********************** + * read one character * + **********************/ + + JSVERIFY(SUCCEED, + H5FD_s3comms_s3r_read( + handle, + (haddr_t)2540, + (size_t)1, + buffer), + NULL ) + JSVERIFY_STR( "t", buffer, NULL ) + + + for (i = 0; i < S3COMMS_TEST_BUFFER_SIZE; i++) + buffer[i] = '\0'; + + /*************** + * read to EoF * + ***************/ + + JSVERIFY( SUCCEED, + H5FD_s3comms_s3r_read( + handle, + (haddr_t)6370, + (size_t)0, + buffer), + NULL ) + JSVERIFY( 0, + strncmp(buffer, + "And my soul from out that shadow that lies floating on the floor\nShall be lifted—nevermore!\n", + 94), + buffer ) + + for (i = 0; i < S3COMMS_TEST_BUFFER_SIZE; i++) + buffer[i] = '\0'; + + /***************** + * read past eof * + *****************/ + + JSVERIFY( FAIL, + H5FD_s3comms_s3r_read( + handle, + (haddr_t)6400, + (size_t)100, /* 6400+100 > 6464 */ + buffer), + NULL ) + JSVERIFY( 0, strcmp("", buffer), NULL ) + + /************************ + * read starts past eof * + ************************/ + + JSVERIFY( FAIL, + H5FD_s3comms_s3r_read( + handle, + (haddr_t)1200699, /* 1200699 > 6464 */ + (size_t)100, + buffer), + NULL ) + JSVERIFY( 0, strcmp("", buffer), NULL ) + + /********************** + * read starts on eof * + **********************/ + + JSVERIFY( FAIL, + H5FD_s3comms_s3r_read( + handle, + (haddr_t)6464, + (size_t)0, + buffer), + NULL ) + JSVERIFY( 0, strcmp("", buffer), NULL ) + + /************* + * TEAR DOWN * + *************/ + + JSVERIFY( SUCCEED, + H5FD_s3comms_s3r_close(handle), + "unable to close file" ) + handle = NULL; + + curl_global_cleanup(); + curl_ready = FALSE; + + PASSED(); + return 0; + +error: + /*********** + * cleanup * + ***********/ + + if (handle != NULL) + H5FD_s3comms_s3r_close(handle); + + if (curl_ready == TRUE) + curl_global_cleanup(); + + return -1; + +#undef S3COMMS_TEST_BUFFER_SIZE +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_s3r_read */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_signing_key() + * + * Purpose: + * + * Define and verify behavior of `H5FD_s3comms_signing_key()` + * + * More test cases would be a very good idea. + * + * Programmer: Jacob Smith + * 2017-09-18 + * + *--------------------------------------------------------------------------- + */ +static herr_t +test_signing_key(void) +{ +#ifdef H5_HAVE_ROS3_VFD + /************************* + * test-local structures * + *************************/ + + struct testcase { + const char *region; + const char *secret_key; + const char *when; + unsigned char exp[SHA256_DIGEST_LENGTH]; + }; + + /************************ + * test-local variables * + ************************/ + + struct testcase cases[] = { + { "us-east-1", + "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + "20130524T000000Z", + { 0xdb, 0xb8, 0x93, 0xac, 0xc0, 0x10, 0x96, 0x49, + 0x18, 0xf1, 0xfd, 0x43, 0x3a, 0xdd, 0x87, 0xc7, + 0x0e, 0x8b, 0x0d, 0xb6, 0xbe, 0x30, 0xc1, 0xfb, + 0xea, 0xfe, 0xfa, 0x5e, 0xc6, 0xba, 0x83, 0x78, + }, + }, + }; + int i = 0; + unsigned char *key = NULL; + int ncases = 1; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("signing_key"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD is not enabled"); + fflush(stdout); + return 0; +#else + for (i = 0; i < ncases; i++) { + key = (unsigned char *)HDmalloc(sizeof(unsigned char) * \ + SHA256_DIGEST_LENGTH); + HDassert(key != NULL); + + JSVERIFY( SUCCEED, + H5FD_s3comms_signing_key( + key, + cases[i].secret_key, + cases[i].region, + cases[i].when), + NULL ) + + JSVERIFY( 0, + strncmp((const char *)cases[i].exp, + (const char *)key, + SHA256_DIGEST_LENGTH), + cases[i].exp ) + + free(key); + key = NULL; + } + + + /*************** + * ERROR CASES * + ***************/ + + key = (unsigned char *)HDmalloc(sizeof(unsigned char) * \ + SHA256_DIGEST_LENGTH); + HDassert(key != NULL); + + JSVERIFY( FAIL, + H5FD_s3comms_signing_key( + NULL, + cases[0].secret_key, + cases[0].region, + cases[0].when), + "destination cannot be NULL" ) + + JSVERIFY( FAIL, + H5FD_s3comms_signing_key( + key, + NULL, + cases[0].region, + cases[0].when), + "secret key cannot be NULL" ) + + JSVERIFY( FAIL, + H5FD_s3comms_signing_key( + key, + cases[0].secret_key, + NULL, + cases[0].when), + "aws region cannot be NULL" ) + + JSVERIFY( FAIL, + H5FD_s3comms_signing_key( + key, + cases[0].secret_key, + cases[0].region, + NULL), + "time string cannot be NULL" ) + + free(key); + key = NULL; + + PASSED(); + return 0; + +error: + if (key != NULL) { + free(key); + } + + return -1; +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_signing_key */ + + +/*--------------------------------------------------------------------------- + * + * Function: test_tostringtosign() + * + * Purpose: + * + * Verify that we can get the "string to sign" from a Canonical Request and + * related information. + * + * Demonstrate failure cases. + * + * Return: + * + * Success: 0 + * Failure: -1 + * + * Programmer: Jacob Smith + * 2017-09-13 + * + *--------------------------------------------------------------------------- + */ +static herr_t +test_tostringtosign(void) +{ +#ifdef H5_HAVE_ROS3_VFD + /************************ + * test-local variables * + ************************/ + + const char canonreq[] = "GET\n/test.txt\n\nhost:examplebucket.s3.amazonaws.com\nrange:bytes=0-9\nx-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\nx-amz-date:20130524T000000Z\n\nhost;range;x-amz-content-sha256;x-amz-date\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"; + const char iso8601now[] = "20130524T000000Z"; + const char region[] = "us-east-1"; + char s2s[512]; +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("s3comms tostringtosign"); + +#ifndef H5_HAVE_ROS3_VFD + SKIPPED(); + puts(" ROS3 VFD is not enabled"); + fflush(stdout); + return 0; +#else + JSVERIFY( SUCCEED, + H5FD_s3comms_tostringtosign(s2s, canonreq, iso8601now, region), + "unable to create string to sign" ) + + JSVERIFY_STR( "AWS4-HMAC-SHA256\n20130524T000000Z\n20130524/us-east-1/s3/aws4_request\n7344ae5b7ee6c3e7e6b0fe0640412a37625d1fbfff95c48bbb2dc43964946972", + s2s, NULL ) + + JSVERIFY( FAIL, + H5FD_s3comms_tostringtosign(s2s, NULL, iso8601now, region), + "canonical request string cannot be NULL" ) + + JSVERIFY( FAIL, + H5FD_s3comms_tostringtosign(s2s, canonreq, NULL, region), + "time string cannot be NULL" ) + + JSVERIFY( FAIL, + H5FD_s3comms_tostringtosign(s2s, canonreq, iso8601now, NULL), + "aws region cannot be NULL" ) + + PASSED(); + return 0; + +error : + return -1; +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_tostringtosign */ + + +/*---------------------------------------------------------------------------- + * + * Function: test_trim() + * + * Purpose: + * + * Define and verify behavior of `H5FD_s3comms_trim()`. + * + * Programmer: Jacob Smith + * 2017-09-14 + * + *---------------------------------------------------------------------------- + */ +static herr_t +test_trim(void) +{ + /************************* + * test-local structures * + *************************/ + + struct testcase { + const char *in; + size_t in_len; + const char *exp; + size_t exp_len; + }; + + /************************ + * test-local variables * + ************************/ + + struct testcase cases[] = { + { "block string", + 12, + "block string", + 12, + }, + { " \n\r \t", + 6, + "", + 0, + }, + { " \twhite b4", + 10, + "white b4", + 8, + }, + { "white after\r\n ", + 15, + "white after", + 11, + }, + { " on\nends\t", + 9, + "on\nends", + 7, + }, + }; + char dest[32]; + size_t dest_len = 0; + int i = 0; + int n_cases = 5; + char *str = NULL; + + + + TESTING("s3comms trim"); + + for (i = 0; i < n_cases; i++) { + HDassert(str == NULL); + str = (char *)HDmalloc(sizeof(char) * cases[i].in_len); + HDassert(str != NULL); + HDstrncpy(str, cases[i].in, cases[i].in_len); + + JSVERIFY( SUCCEED, + H5FD_s3comms_trim(dest, str, cases[i].in_len, &dest_len), + NULL ) + JSVERIFY( cases[i].exp_len, dest_len, cases[i].in ) + if (dest_len > 0) { + JSVERIFY( 0, strncmp(cases[i].exp, dest, dest_len), + cases[i].exp ) + } + free(str); + str = NULL; + } + + JSVERIFY( SUCCEED, H5FD_s3comms_trim(dest, NULL, 3, &dest_len), + "should not fail when trimming a null string" ); + JSVERIFY( 0, dest_len, "trimming NULL string writes 0 characters" ) + + HDassert(str == NULL); + str = (char *)HDmalloc(sizeof(char *) * 11); + HDassert(str != NULL); + memcpy(str, "some text ", 11); /* string with null terminator */ + JSVERIFY( FAIL, H5FD_s3comms_trim(NULL, str, 10, &dest_len), + "destination for trim cannot be NULL" ); + free(str); + str = NULL; + + PASSED(); + return 0; + +error: + if (str != NULL) + free(str); + return -1; + +} /* test_trim */ + + +/*---------------------------------------------------------------------------- + * + * Function: test_uriencode() + * + * Purpose: + * + * Define and verify behavior of `H5FD_s3comms_uriencode()`. + * + * Programmer: Jacob Smith + * 2017-09-14 + * + *---------------------------------------------------------------------------- + */ +static herr_t +test_uriencode(void) +{ + /************************* + * test-local structures * + *************************/ + + struct testcase { + const char *str; + size_t s_len; + hbool_t encode_slash; + const char *expected; + }; + + /************************ + * test-local variables * + ************************/ + + struct testcase cases[] = { + { "/path/to/resource.jpg", + 21, + FALSE, + "/path/to/resource.jpg", + }, + { "/path/to/resource.jpg", + 21, + TRUE, + "%2Fpath%2Fto%2Fresource.jpg", + }, + { "string got_spaa ces", + 20, + TRUE, + "string%20got_spaa%20%20ces", + }, + { "sp ac~es/and-sl ash.encoded", + 27, + TRUE, + "sp%20ac~es%2Fand-sl%20ash.encoded", + }, + { "sp ac~es/and-sl ash.unencoded", + 29, + FALSE, + "sp%20ac~es/and-sl%20ash.unencoded", + }, + { "/path/to/resource.txt", + 0, + FALSE, + "", + + } + }; + char *dest = NULL; + size_t dest_written = 0; + int i = 0; + int ncases = 6; + size_t str_len = 0; + + + + TESTING("s3comms uriencode") + + for (i = 0; i < ncases; i++) { + str_len = cases[i].s_len; + dest = (char *)HDmalloc(sizeof(char) * str_len * 3 + 1); + FAIL_IF( dest == NULL ) + + JSVERIFY( SUCCEED, + H5FD_s3comms_uriencode( + dest, + cases[i].str, + str_len, + cases[i].encode_slash, + &dest_written), + NULL ); + JSVERIFY( HDstrlen(cases[i].expected), + dest_written, + NULL ) + JSVERIFY( 0, + strncmp(dest, cases[i].expected, dest_written), + cases[i].expected ); + + free(dest); + dest = NULL; + } + + /*************** + * ERROR CASES * + ***************/ + + dest = (char *)HDmalloc(sizeof(char) * 15); + HDassert(dest != NULL); + + JSVERIFY( FAIL, + H5FD_s3comms_uriencode(NULL, "word$", 5, false, &dest_written), + "destination cannot be NULL" ); + JSVERIFY( FAIL, + H5FD_s3comms_uriencode(dest, NULL, 5, false, &dest_written), + "source string cannot be NULL" ); + + free(dest); + dest = NULL; + + PASSED(); + return 0; + +error: + if (dest != NULL) { + free(dest); + } + return -1; + +} /* test_uriencode */ + + + + +/*------------------------------------------------------------------------- + * Function: main() + * + * Purpose: + * + * Run unit tests for S3 Communications (s3comms). + * + * Return: + * + * Success: 0 + * Failure: 1 + * + * Programmer: Jacob Smith + * 2017-10-12 + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + int nerrors = 0; +#ifdef H5_HAVE_ROS3_VFD + const char *bucket_url_env = NULL; +#endif /* H5_HAVE_ROS3_VFD */ + + h5_reset(); + + HDprintf("Testing S3Communications functionality.\n"); + +#ifdef H5_HAVE_ROS3_VFD + + /* "clear" profile data strings */ + s3_test_aws_access_key_id[0] = '\0'; + s3_test_aws_secret_access_key[0] = '\0'; + s3_test_aws_region[0] = '\0'; + s3_test_bucket_url[0] = '\0'; + +/* TODO: unit/regression test for H5FD_s3comms_load_aws_profile() + * requires a few test files and/or manipulation of default path + */ + /* attempt to load test credentials + * if unable, certain tests will be skipped + */ + if (SUCCEED == H5FD_s3comms_load_aws_profile( + S3_TEST_PROFILE_NAME, + s3_test_aws_access_key_id, + s3_test_aws_secret_access_key, + s3_test_aws_region)) + { + s3_test_credentials_loaded = 1; + } + + bucket_url_env = HDgetenv("HDF5_ROS3_TEST_BUCKET_URL"); + if (bucket_url_env == NULL || bucket_url_env[0] == '\0') { + HDprintf("WARNING: S3 bucket url is not defined in enviornment " \ + "variable 'HDF5_ROS3_TEST_BUCKET_URL'!\n"); + } else { + HDstrncpy(s3_test_bucket_url, bucket_url_env, S3_TEST_MAX_URL_SIZE); + s3_test_bucket_defined = TRUE; + } + +#endif /* H5_HAVE_ROS3_VFD */ + + /* tests ordered rougly by dependence */ + nerrors += test_macro_format_credential() < 0 ? 1 : 0; + nerrors += test_trim() < 0 ? 1 : 0; + nerrors += test_nlowercase() < 0 ? 1 : 0; + nerrors += test_uriencode() < 0 ? 1 : 0; + nerrors += test_percent_encode_char() < 0 ? 1 : 0; + nerrors += test_bytes_to_hex() < 0 ? 1 : 0; + nerrors += test_HMAC_SHA256() < 0 ? 1 : 0; + nerrors += test_signing_key() < 0 ? 1 : 0; + nerrors += test_hrb_node_set() < 0 ? 1 : 0; + nerrors += test_hrb_init_request() < 0 ? 1 : 0; + nerrors += test_parse_url() < 0 ? 1 : 0; + nerrors += test_aws_canonical_request() < 0 ? 1 : 0; + nerrors += test_tostringtosign() < 0 ? 1 : 0; + nerrors += test_s3r_open() < 0 ? 1 : 0; + nerrors += test_s3r_get_filesize() < 0 ? 1 : 0; + nerrors += test_s3r_read() < 0 ? 1 : 0; + + if(nerrors) { + HDprintf("***** %d S3comms TEST%s FAILED! *****\n", + nerrors, + nerrors > 1 ? "S" : ""); + return 1; + } /* end if */ + + HDprintf("All S3comms tests passed.\n"); + + return 0; +} /* end main() */ + diff --git a/test/vfd.c b/test/vfd.c index b196406..2b15430 100644 --- a/test/vfd.c +++ b/test/vfd.c @@ -58,6 +58,7 @@ const char *FILENAME[] = { "stdio_file", /*7*/ "windows_file", /*8*/ "new_multi_file_v16",/*9*/ + "ro_s3_file6", /*10*/ NULL }; @@ -66,7 +67,7 @@ const char *FILENAME[] = { #define COMPAT_BASENAME "family_v16_" #define MULTI_COMPAT_BASENAME "multi_file_v16" - + /*------------------------------------------------------------------------- * Function: test_sec2 * @@ -178,7 +179,7 @@ error: return -1; } /* end test_sec2() */ - + /*------------------------------------------------------------------------- * Function: test_core * @@ -534,7 +535,7 @@ error: return -1; } /* end test_core() */ - + /*------------------------------------------------------------------------- * Function: test_direct * @@ -754,7 +755,7 @@ error: #endif /*H5_HAVE_DIRECT*/ } - + /*------------------------------------------------------------------------- * Function: test_family_opens * @@ -835,7 +836,7 @@ error: } /* end test_family_opens() */ #pragma GCC diagnostic pop - + /*------------------------------------------------------------------------- * Function: test_family * @@ -1017,7 +1018,7 @@ error: return -1; } - + /*------------------------------------------------------------------------- * Function: test_family_compat * @@ -1129,7 +1130,7 @@ error: } /* end test_family_compat() */ #pragma GCC diagnostic pop - + /*------------------------------------------------------------------------- * Function: test_multi_opens * @@ -1170,7 +1171,7 @@ test_multi_opens(char *fname) } /* end test_multi_opens() */ #pragma GCC diagnostic pop - + /*------------------------------------------------------------------------- * Function: test_multi * @@ -1404,7 +1405,7 @@ error: return FAIL; } /* end test_multi() */ - + /*------------------------------------------------------------------------- * Function: test_multi_compat * @@ -1578,7 +1579,7 @@ error: return -1; } - + /*------------------------------------------------------------------------- * Function: test_log * @@ -1689,7 +1690,7 @@ error: return -1; } - + /*------------------------------------------------------------------------- * Function: test_stdio * @@ -1794,7 +1795,7 @@ error: } - + /*------------------------------------------------------------------------- * Function: test_windows * @@ -1916,7 +1917,146 @@ error: } /* end test_windows() */ - +/*------------------------------------------------------------------------- + * Function: test_ros3 + * + * Purpose: Tests the file handle interface for the ROS3 driver + * + * As the ROS3 driver is 1) read only, 2) requires access + * to an S3 server (minio for now), this test is quite + * different from the other tests. + * + * For now, test only fapl & flags. Extend as the + * work on the VFD continues. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: John Mainzer + * 7/12/17 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_ros3(void) +{ + hid_t fid = -1; /* file ID */ + hid_t fapl_id = -1; /* file access property list ID */ + hid_t fapl_id_out = -1; /* from H5Fget_access_plist */ + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ + char filename[1024]; /* filename */ + void *os_file_handle = NULL; /* OS file handle */ + hsize_t file_size; /* file size */ + H5FD_ros3_fapl_t test_ros3_fa; + H5FD_ros3_fapl_t ros3_fa_0 = + { + /* version = */ H5FD__CURR_ROS3_FAPL_T_VERSION, + /* authenticate = */ FALSE, + /* aws_region = */ "", + /* secret_id = */ "", + /* secret_key = */ "plugh", + }; + + TESTING("ROS3 file driver"); + + /* Set property list and file name for ROS3 driver. */ + if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR; + + if(H5Pset_fapl_ros3(fapl_id, &ros3_fa_0) < 0) + TEST_ERROR; + + /* verify that the ROS3 FAPL entry is set as expected */ + if(H5Pget_fapl_ros3(fapl_id, &test_ros3_fa) < 0) + TEST_ERROR; + + /* need a macro to compare instances of H5FD_ros3_fapl_t */ + if((test_ros3_fa.version != ros3_fa_0.version) || + (test_ros3_fa.authenticate != ros3_fa_0.authenticate) || + (strcmp(test_ros3_fa.aws_region, ros3_fa_0.aws_region) != 0) || + (strcmp(test_ros3_fa.secret_id, ros3_fa_0.secret_id) != 0) || + (strcmp(test_ros3_fa.secret_key, ros3_fa_0.secret_key) != 0)) + TEST_ERROR; + + h5_fixname(FILENAME[10], fapl_id, filename, sizeof(filename)); + + /* Check that the VFD feature flags are correct */ + if ((driver_id = H5Pget_driver(fapl_id)) < 0) + TEST_ERROR; + + if (H5FDdriver_query(driver_id, &driver_flags) < 0) + TEST_ERROR; + + if(!(driver_flags & H5FD_FEAT_DATA_SIEVE)) TEST_ERROR + + /* Check for extra flags not accounted for above */ + if(driver_flags != (H5FD_FEAT_DATA_SIEVE)) + TEST_ERROR + + /* can't create analogs of the following tests until the + * ROS3 driver is up and running in a minimal fashion. + * Comment them out until we get to them. + */ +#if 0 + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + TEST_ERROR; + + /* Retrieve the access property list... */ + if((fapl_id_out = H5Fget_access_plist(fid)) < 0) + TEST_ERROR; + + /* Check that the driver is correct */ + if(H5FD_ROS3 != H5Pget_driver(fapl_id_out)) + TEST_ERROR; + + /* ...and close the property list */ + if(H5Pclose(fapl_id_out) < 0) + TEST_ERROR; + + /* Check that we can get an operating-system-specific handle from + * the library. + */ + if(H5Fget_vfd_handle(fid, H5P_DEFAULT, &os_file_handle) < 0) + TEST_ERROR; + if(os_file_handle == NULL) + FAIL_PUTS_ERROR("NULL os-specific vfd/file handle was returned from H5Fget_vfd_handle"); + + + /* There is no garantee the size of metadata in file is constant. + * Just try to check if it's reasonable. + * + * Currently it should be around 2 KB. + */ + if(H5Fget_filesize(fid, &file_size) < 0) + TEST_ERROR; + if(file_size < 1 * KB || file_size > 4 * KB) + FAIL_PUTS_ERROR("suspicious file size obtained from H5Fget_filesize"); + + /* Close and delete the file */ + if(H5Fclose(fid) < 0) + TEST_ERROR; + h5_delete_test_file(FILENAME[0], fapl_id); + + /* Close the fapl */ + if(H5Pclose(fapl_id) < 0) + TEST_ERROR; +#endif + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(fapl_id); + H5Pclose(fapl_id_out); + H5Fclose(fid); + } H5E_END_TRY; + return -1; +} /* end test_ros3() */ + + + /*------------------------------------------------------------------------- * Function: main * @@ -1949,6 +2089,7 @@ main(void) nerrors += test_log() < 0 ? 1 : 0; nerrors += test_stdio() < 0 ? 1 : 0; nerrors += test_windows() < 0 ? 1 : 0; + nerrors += test_ros3() < 0 ? 1 : 0; if(nerrors) { HDprintf("***** %d Virtual File Driver TEST%s FAILED! *****\n", diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 400039e..aa09aa6 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -9,4 +9,11 @@ add_subdirectory (src) #-- Add the tests if (BUILD_TESTING) add_subdirectory (test) + +# -------------------------------------------------------------------- +# If S3 or HDFS enabled, then we need to test the tools library +# -------------------------------------------------------------------- + if (HDF5_ENABLE_ROS3_VFD OR HDF5_ENABLE_HDFS) + add_subdirectory (libtest) + endif () endif () diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index e7e017f..a3cd7d9 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -21,6 +21,10 @@ #include "H5private.h" #include "h5trav.h" +#ifdef H5_HAVE_ROS3_VFD +#include "H5FDros3.h" +#endif + /* global variables */ unsigned h5tools_nCols = 80; /* ``get_option'' variables */ @@ -97,7 +101,7 @@ parallel_print(const char* format, ...) HDva_end(ap); } - + /*------------------------------------------------------------------------- * Function: error_msg * @@ -122,7 +126,7 @@ error_msg(const char *fmt, ...) HDva_end(ap); } - + /*------------------------------------------------------------------------- * Function: warn_msg * @@ -161,7 +165,7 @@ help_ref_msg(FILE *output) HDfprintf(output, "see the <%s> entry in the 'HDF5 Reference Manual'.\n",h5tools_getprogname()); } - + /*------------------------------------------------------------------------- * Function: get_option * @@ -322,7 +326,229 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti return opt_opt; } - + +/***************************************************************************** + * + * Function: parse_tuple() + * + * Purpose: + * + * Create array of pointers to strings, identified as elements in a tuple + * of arbitrary length separated by provided character. + * ("tuple" because "nple" looks strange) + * + * * Receives pointer to start of tuple sequence string, '('. + * * Attempts to separate elements by token-character `sep`. + * * If the separator character is preceded by a backslash '\', + * the backslash is deleted and the separator is included in the + * element string as any other character. + * * To end an element with a backslash, escape the backslash, e.g. + * "(myelem\\,otherelem) -> {"myelem\", "otherelem"} + * * In all other cases, a backslash appearing not as part of "\\" or + * "\" digraph will be included berbatim. + * * Last two characters in the string MUST be ")\0". + * + * * Generates a copy of the input string `start`, (src..")\0"), replacing + * separators and close-paren with null charaters. + * * This string is allocated at runtime and should be freed when done. + * * Generates array of char pointers, and directs start of each element + * (each pointer) into this copy. + * * Each tuple element points to the start of its string (substring) + * and ends with a null terminator. + * * This array is allocated at runtime and should be freed when done. + * * Reallocates and expands elements array during parsing. + * * Initially allocated for 2 (plus one null entry), and grows by + * powers of 2. + * * The final 'slot' in the element array (elements[nelements], e.g.) + * always points to NULL. + * * The number of elements found and stored are passed out through pointer + * to unsigned, `nelems`. + * + * Return: + * + * FAIL If malformed--does not look like a tuple "(...)" + * or major error was encountered while parsing. + * or + * SUCCEED String looks properly formed "(...)" and no major errors. + * + * Stores number of elements through pointer `nelems`. + * Stores list of pointers to char (first char in each element + * string) through pointer `ptrs_out`. + * NOTE: `ptrs_out[nelems] == NULL` should be true. + * NOTE: list is malloc'd by function, and should be freed + * when done. + * Stores "source string" for element pointers through `cpy_out`. + * NOTE: Each element substring is null-terminated. + * NOTE: There may be extra characters after the last element + * (past its null terminator), but is guaranteed to + * be null-terminated. + * NOTE: `cpy_out` string is malloc'd by function, + * and should be freed when done. + * + * Programmer: Jacob Smith + * 2017-11-10 + * + * Changes: None. + * + ***************************************************************************** + */ +herr_t +parse_tuple(const char *start, + int sep, + char **cpy_out, + unsigned *nelems, + char ***ptrs_out) +{ + char *elem_ptr = NULL; + char *dest_ptr = NULL; + unsigned elems_count = 0; + char **elems = NULL; /* more like *elems[], but complier... */ + char **elems_re = NULL; /* temporary pointer, for realloc */ + char *cpy = NULL; + herr_t ret_value = SUCCEED; + unsigned init_slots = 2; + + + + /***************** + * SANITY-CHECKS * + *****************/ + + /* must start with "(" + */ + if (start[0] != '(') { + ret_value = FAIL; + goto done; + } + + /* must end with ")" + */ + while (start[elems_count] != '\0') { + elems_count++; + } + if (start[elems_count - 1] != ')') { + ret_value = FAIL; + goto done; + } + + elems_count = 0; + + + + /*********** + * PREPARE * + ***********/ + + /* create list + */ + elems = (char **)HDmalloc(sizeof(char *) * (init_slots + 1)); + if (elems == NULL) { ret_value = FAIL; goto done; } /* CANTALLOC */ + + /* create destination string + */ + start++; /* advance past opening paren '(' */ + cpy = (char *)HDmalloc(sizeof(char) * (HDstrlen(start))); /* no +1; less '(' */ + if (cpy == NULL) { ret_value = FAIL; goto done; } /* CANTALLOC */ + + /* set pointers + */ + dest_ptr = cpy; /* start writing copy here */ + elem_ptr = cpy; /* first element starts here */ + elems[elems_count++] = elem_ptr; /* set first element pointer into list */ + + + + /********* + * PARSE * + *********/ + + while (*start != '\0') { + /* For each character in the source string... + */ + if (*start == '\\') { + /* Possibly an escape digraph. + */ + if ((*(start + 1) == '\\') || + (*(start + 1) == sep) ) + { + /* Valid escape digraph of "\\" or "\". + */ + start++; /* advance past escape char '\' */ + *(dest_ptr++) = *(start++); /* Copy subsequent char */ + /* and advance pointers. */ + } else { + /* Not an accepted escape digraph. + * Copy backslash character. + */ + *(dest_ptr++) = *(start++); + } + } else if (*start == sep) { + /* Non-escaped separator. + * Terminate elements substring in copy, record element, advance. + * Expand elements list if appropriate. + */ + *(dest_ptr++) = 0; /* Null-terminate elem substring in copy */ + /* and advance pointer. */ + start++; /* Advance src pointer past separator. */ + elem_ptr = dest_ptr; /* Element pointer points to start of first */ + /* character after null sep in copy. */ + elems[elems_count++] = elem_ptr; /* Set elem pointer in list */ + /* and increment count. */ + + /* Expand elements list, if necessary. + */ + if (elems_count == init_slots) { + init_slots *= 2; + elems_re = (char **)realloc(elems, sizeof(char *) * \ + (init_slots + 1)); + if (elems_re == NULL) { + /* CANTREALLOC */ + ret_value = FAIL; + goto done; + } + elems = elems_re; + } + } else if (*start == ')' && *(start + 1) == '\0') { + /* Found terminal, non-escaped close-paren. Last element. + * Write null terminator to copy. + * Advance source pointer to gently break from loop. + * Requred to prevent ")" from always being added to last element. + */ + start++; + } else { + /* Copy character into destination. Advance pointers. + */ + *(dest_ptr++) = *(start++); + } + } + *dest_ptr = '\0'; /* Null-terminate destination string. */ + elems[elems_count] = NULL; /* Null-terminate elements list. */ + + + + /******************** + * PASS BACK VALUES * + ********************/ + + *ptrs_out = elems; + *nelems = elems_count; + *cpy_out = cpy; + +done: + if (ret_value == FAIL) { + /* CLEANUP */ + if (cpy) free(cpy); + if (elems) free(elems); + } + + return ret_value; + +} /* parse_tuple */ + + + + + /*------------------------------------------------------------------------- * Function: indentation * @@ -344,7 +570,7 @@ indentation(unsigned x) } } - + /*------------------------------------------------------------------------- * Function: print_version * @@ -362,7 +588,7 @@ print_version(const char *progname) ((const char *)H5_VERS_SUBRELEASE)[0] ? "-" : "", H5_VERS_SUBRELEASE); } - + /*------------------------------------------------------------------------- * Function: init_table * @@ -384,7 +610,7 @@ init_table(table_t **tbl) *tbl = table; } - + /*------------------------------------------------------------------------- * Function: free_table * @@ -408,7 +634,7 @@ free_table(table_t *table) } #ifdef H5DUMP_DEBUG - + /*------------------------------------------------------------------------- * Function: dump_table * @@ -429,7 +655,7 @@ dump_table(char* tablename, table_t *table) table->objs[u].displayed, table->objs[u].recorded); } - + /*------------------------------------------------------------------------- * Function: dump_tables * @@ -447,7 +673,7 @@ dump_tables(find_objs_t *info) } #endif /* H5DUMP_DEBUG */ - + /*------------------------------------------------------------------------- * Function: search_obj * @@ -470,7 +696,7 @@ search_obj(table_t *table, haddr_t objno) return NULL; } - + /*------------------------------------------------------------------------- * Function: find_objs_cb * @@ -546,7 +772,7 @@ find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen return ret_value; } - + /*------------------------------------------------------------------------- * Function: init_objs * @@ -591,7 +817,7 @@ done: return ret_value; } - + /*------------------------------------------------------------------------- * Function: add_obj * @@ -622,7 +848,7 @@ add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t record) table->objs[u].displayed = 0; } - + #ifndef H5_HAVE_TMPFILE /*------------------------------------------------------------------------- * Function: tmpfile @@ -841,3 +1067,266 @@ done: return ret_value; } + +/*---------------------------------------------------------------------------- + * + * Function: h5tools_populate_ros3_fapl() + * + * Purpose: + * + * Set the values of a ROS3 fapl configuration object. + * + * If the values pointer is NULL, sets fapl target `fa` to a default + * (valid, current-version, non-authenticating) fapl config. + * + * If `values` pointer is _not_ NULL, expects `values` to contain at least + * three non-null pointers to null-terminated strings, corresponding to: + * { aws_region, + * secret_id, + * secret_key, + * } + * If all three strings are empty (""), the default fapl will be default. + * Both aws_region and secret_id values must be both empty or both + * populated. If + * Only secret_key is allowed to be empty (the empty string, ""). + * All values are checked against overflow as defined in the ros3 vfd + * header file; if a value overruns the permitted space, FAIL is returned + * and the function aborts without resetting the fapl to values initially + * present. + * + * Return: + * + * 0 (failure) if... + * * Read-Only S3 VFD is not enabled. + * * NULL fapl pointer: (NULL, {...} ) + * * Warning: In all cases below, fapl will be set as "default" + * before error occurs. + * * NULL value strings: (&fa, {NULL?, NULL? NULL?, ...}) + * * Incomplete fapl info: + * * empty region, non-empty id, key either way + * * (&fa, {"", "...", "?"}) + * * empty id, non-empty region, key either way + * * (&fa, {"...", "", "?"}) + * * "non-empty key and either id or region empty + * * (&fa, {"", "", "...") + * * (&fa, {"", "...", "...") + * * (&fa, {"...", "", "...") + * * Any string would overflow allowed space in fapl definition. + * or + * 1 (success) + * * Sets components in fapl_t pointer, copying strings as appropriate. + * * "Default" fapl (valid version, authenticate->False, empty strings) + * * `values` pointer is NULL + * * (&fa, NULL) + * * first three strings in `values` are empty ("") + * * (&fa, {"", "", "", ...} + * * Authenticating fapl + * * region, id, and optional key provided + * * (&fa, {"...", "...", ""}) + * * (&fa, {"...", "...", "..."}) + * + * Programmer: Jacob Smith + * 2017-11-13 + * + * Changes: None. + * + *---------------------------------------------------------------------------- + */ +int +h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, + const char **values) +{ +#ifndef H5_HAVE_ROS3_VFD + return 0; +#else + int show_progress = 0; /* set to 1 for debugging */ + int ret_value = 1; /* 1 for success, 0 for failure */ + /* e.g.? if (!populate()) { then failed } */ + + if (show_progress) { + HDprintf("called h5tools_populate_ros3_fapl\n"); + } + + if (fa == NULL) { + if (show_progress) { + HDprintf(" ERROR: null pointer to fapl_t\n"); + } + ret_value = 0; + goto done; + } + + if (show_progress) { + HDprintf(" preset fapl with default values\n"); + } + fa->version = H5FD__CURR_ROS3_FAPL_T_VERSION; + fa->authenticate = FALSE; + *(fa->aws_region) = '\0'; + *(fa->secret_id) = '\0'; + *(fa->secret_key) = '\0'; + + /* sanity-check supplied values + */ + if (values != NULL) { + if (values[0] == NULL) { + if (show_progress) { + HDprintf(" ERROR: aws_region value cannot be NULL\n"); + } + ret_value = 0; + goto done; + } + if (values[1] == NULL) { + if (show_progress) { + HDprintf(" ERROR: secret_id value cannot be NULL\n"); + } + ret_value = 0; + goto done; + } + if (values[2] == NULL) { + if (show_progress) { + HDprintf(" ERROR: secret_key value cannot be NULL\n"); + } + ret_value = 0; + goto done; + } + + /* if region and ID are supplied (key optional), write to fapl... + * fail if value would overflow + */ + if (*values[0] != '\0' && + *values[1] != '\0') + { + if (HDstrlen(values[0]) > H5FD__ROS3_MAX_REGION_LEN) { + if (show_progress) { + HDprintf(" ERROR: aws_region value too long\n"); + } + ret_value = 0; + goto done; + } + HDmemcpy(fa->aws_region, values[0], + (HDstrlen(values[0]) + 1)); + if (show_progress) { + HDprintf(" aws_region set\n"); + } + + + if (HDstrlen(values[1]) > H5FD__ROS3_MAX_SECRET_ID_LEN) { + if (show_progress) { + HDprintf(" ERROR: secret_id value too long\n"); + } + ret_value = 0; + goto done; + } + HDmemcpy(fa->secret_id, + values[1], + (HDstrlen(values[1]) + 1)); + if (show_progress) { + HDprintf(" secret_id set\n"); + } + + if (HDstrlen(values[2]) > H5FD__ROS3_MAX_SECRET_KEY_LEN) { + if (show_progress) { + HDprintf(" ERROR: secret_key value too long\n"); + } + ret_value = 0; + goto done; + } + HDmemcpy(fa->secret_key, + values[2], + (HDstrlen(values[2]) + 1)); + if (show_progress) { + HDprintf(" secret_key set\n"); + } + + fa->authenticate = TRUE; + if (show_progress) { + HDprintf(" set to authenticate\n"); + } + + } else if (*values[0] != '\0' || + *values[1] != '\0' || + *values[2] != '\0') + { + if (show_progress) { + HDprintf( + " ERROR: invalid assortment of empty/non-empty values\n" + ); + } + ret_value = 0; + goto done; + } + } /* values != NULL */ + +done: + return ret_value; +#endif /* H5_HAVE_ROS3_VFD */ + +} /* h5tools_populate_ros3_fapl */ + + +/*----------------------------------------------------------------------------- + * + * Function: h5tools_set_configured_fapl + * + * Purpose: prepare fapl_id with the given property list, according to + * VFD prototype. + * + * Return: 0 on failure, 1 on success + * + * Programmer: Jacob Smith + * 2018-05-21 + * + * Changes: None. + * + *----------------------------------------------------------------------------- + */ +int +h5tools_set_configured_fapl(hid_t fapl_id, + const char vfd_name[], + void *fapl_t_ptr) +{ + int ret_value = 1; + + if (fapl_id < 0) { + return 0; + } + + if (!strcmp("", vfd_name)) { + goto done; + +#ifdef H5_HAVE_ROS3_VFD + } else if (!strcmp("ros3", vfd_name)) { + if ((fapl_id == H5P_DEFAULT) || + (fapl_t_ptr == NULL) || + (FAIL == H5Pset_fapl_ros3( + fapl_id, + (H5FD_ros3_fapl_t *)fapl_t_ptr))) + { + ret_value = 0; + goto done; + } +#endif /* H5_HAVE_ROS3_VFD */ + +#ifdef H5_HAVE_LIBHDFS + } else if (!strcmp("hdfs", vfd_name)) { + if ((fapl_id == H5P_DEFAULT) || + (fapl_t_ptr == NULL) || + (FAIL == H5Pset_fapl_hdfs( + fapl_id, + (H5FD_hdfs_fapl_t *)fapl_t_ptr))) + { + ret_value = 0; + goto done; + } +#endif /* H5_HAVE_LIBHDFS */ + + } else { + ret_value = 0; /* unrecognized fapl type "name" */ + } + +done: + return ret_value; + +} /* h5tools_set_configured_fapl() */ + + + diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h index 4c2bf1e..1c6ba2a 100644 --- a/tools/lib/h5tools_utils.h +++ b/tools/lib/h5tools_utils.h @@ -123,6 +123,11 @@ H5TOOLS_DLLVAR unsigned h5tools_nCols; /*max number of columns for H5TOOLS_DLL void indentation(unsigned); H5TOOLS_DLL void print_version(const char *progname); H5TOOLS_DLL void parallel_print(const char* format, ... ); +H5TOOLS_DLL herr_t parse_tuple(const char *start, + int sep, + char **cpy_out, + unsigned *nelems, + char ***ptrs_out); H5TOOLS_DLL void error_msg(const char *fmt, ...); H5TOOLS_DLL void warn_msg(const char *fmt, ...); H5TOOLS_DLL void help_ref_msg(FILE *output); @@ -174,6 +179,11 @@ H5TOOLS_DLL void h5tools_setprogname(const char*progname); H5TOOLS_DLL int h5tools_getstatus(void); H5TOOLS_DLL void h5tools_setstatus(int d_status); H5TOOLS_DLL int h5tools_getenv_update_hyperslab_bufsize(void); +H5TOOLS_DLL int h5tools_set_configured_fapl(hid_t fapl_id, + const char vfd_name[], + void *fapl_t_ptr); +H5TOOLS_DLL int h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, + const char **values); #ifdef __cplusplus } #endif diff --git a/tools/libtest/CMakeLists.txt b/tools/libtest/CMakeLists.txt new file mode 100644 index 0000000..f5e0aa6 --- /dev/null +++ b/tools/libtest/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required (VERSION 3.10) +project (HDF5_TOOLS_LIBTEST C) + +#----------------------------------------------------------------------------- +# Add the h5tools_utils test executables +#----------------------------------------------------------------------------- +add_executable (h5tools_utils ${HDF5_TOOLS_LIBTEST_SOURCE_DIR}/h5tools_utils.c) +target_include_directories(h5tools_utils PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") +TARGET_C_PROPERTIES (h5tools_utils STATIC) +target_link_libraries (h5tools_utils PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) +set_target_properties (h5tools_utils PROPERTIES FOLDER tools) + +if (BUILD_SHARED_LIBS) + add_executable (h5tools_utils-shared ${HDF5_TOOLS_LIBTEST_SOURCE_DIR}/h5tools_utils.c) + target_include_directories(h5tools_utils-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") + TARGET_C_PROPERTIES (h5tools_utils-shared SHARED) + target_link_libraries (h5tools_utils-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + set_target_properties (h5tools_utils-shared PROPERTIES FOLDER tools) +endif () + +include (CMakeTests.cmake) diff --git a/tools/libtest/CMakeTests.cmake b/tools/libtest/CMakeTests.cmake new file mode 100644 index 0000000..403969d --- /dev/null +++ b/tools/libtest/CMakeTests.cmake @@ -0,0 +1,49 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## + + +############################################################################## +############################################################################## +### T H E T E S T S M A C R O S ### +############################################################################## +############################################################################## + + macro (ADD_H5_TEST resultfile resultcode) + add_test ( + NAME H5LIBTEST-${resultfile}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${resultfile}.out + ${resultfile}.out.err + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5LIBTEST-${resultfile}-clear-objects PROPERTIES DEPENDS ${last_test}) + endif () + add_test (NAME H5LIBTEST-${resultfile} COMMAND $ ${ARGN}) + if (NOT "${resultcode}" STREQUAL "0") + set_tests_properties (H5LIBTEST-${resultfile} PROPERTIES WILL_FAIL "true") + endif () + set_tests_properties (H5LIBTEST-${resultfile} PROPERTIES DEPENDS H5LIBTEST-${resultfile}-clear-objects) + endmacro () + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + ADD_H5_TEST (h5tools_utils-default 0) diff --git a/tools/libtest/Makefile.am b/tools/libtest/Makefile.am new file mode 100644 index 0000000..5aa72b8 --- /dev/null +++ b/tools/libtest/Makefile.am @@ -0,0 +1,34 @@ +# +# Read-Only S3 Virtual File Driver (VFD) +# Copyright (c) 2017-2018, The HDF Group. +# +# All rights reserved. +# +# NOTICE: +# All information contained herein is, and remains, the property of The HDF +# Group. The intellectual and technical concepts contained herein are +# proprietary to The HDF Group. Dissemination of this information or +# reproduction of this material is strictly forbidden unless prior written +# permission is obtained from The HDF Group. +## +## Makefile.am +## Run automake to generate a Makefile.in from this file. +# +# HDF5 Library Makefile(.in) +# + +include $(top_srcdir)/config/commence.am + +# Include src and tools/lib directories +AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib + +# All programs depend on the hdf5 and h5tools libraries +LDADD=$(LIBH5TOOLS) $(LIBHDF5) + + +# main target +bin_PROGRAMS=h5tools_utils +# check_PROGRAMS=$(TEST_PROG) + + +include $(top_srcdir)/config/conclude.am diff --git a/tools/libtest/h5tools_utils.c b/tools/libtest/h5tools_utils.c new file mode 100644 index 0000000..56e8a01 --- /dev/null +++ b/tools/libtest/h5tools_utils.c @@ -0,0 +1,1296 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright (c) 2017-2018, The HDF Group. * + * * + * All rights reserved. * + * * + * NOTICE: * + * All information contained herein is, and remains, the property of The HDF * + * Group. The intellectual and technical concepts contained herein are * + * proprietary to The HDF Group. Dissemination of this information or * + * reproduction of this material is strictly forbidden unless prior written * + * permission is obtained from The HDF Group. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: unit-test functionality of the routines in `tools/lib/h5tools_utils` + * + * Jacob Smith 2017-11-10 + */ + +#include "hdf5.h" +#include "H5private.h" +#include "h5tools_utils.h" +/* #include "h5test.h" */ /* linking failure */ + +#define UTIL_TEST_DEBUG 0 + +#ifndef _H5TEST_ + +#define AT() fprintf(stdout, " at %s:%d in %s()...\n", \ + __FILE__, __LINE__, FUNC); + +#define FAILED(msg) { \ + fprintf(stdout, "*FAILED*"); AT() \ + if (msg == NULL) { \ + fprintf(stdout,"(NULL)\n"); \ + } else { \ + fprintf(stdout, "%s\n", msg); \ + } \ + fflush(stdout); \ +} + +#define TESTING(msg) { \ + fprintf(stdout, "TESTING %-62s", (msg)); \ + fflush(stdout); \ +} + +#define PASSED() { \ + fprintf(stdout, " PASSED\n"); \ + fflush(stdout); \ +} + +#endif /* ifndef _H5TEST_ */ + +#ifndef __js_test__ + +#define __js_test__ 1L + +/***************************************************************************** + * + * FILE-LOCAL TESTING MACROS + * + * Purpose: + * + * 1. Upon test failure, goto-jump to single-location teardown in test + * function. E.g., `error:` (consistency with HDF corpus) or + * `failed:` (reflects purpose). + * >>> using "error", in part because `H5E_BEGIN_TRY` expects it. + * 2. Increase clarity and reduce overhead found with `TEST_ERROR`. + * e.g., "if(somefunction(arg, arg2) < 0) TEST_ERROR:" + * requires reading of entire line to know whether this if/call is + * part of the test setup, test operation, or a test unto itself. + * 3. Provide testing macros with optional user-supplied failure message; + * if not supplied (NULL), generate comparison output in the spirit of + * test-driven development. E.g., "expected 5 but was -3" + * User messages clarify test's purpose in code, encouraging description + * without relying on comments. + * 4. Configurable expected-actual order in generated comparison strings. + * Some prefer `VERIFY(expected, actual)`, others + * `VERIFY(actual, expected)`. Provide preprocessor ifdef switch + * to satifsy both parties, assuming one paradigm per test file. + * (One could #undef and redefine the flag through the file as desired, + * but _why_.) + * + * Provided as courtesy, per consideration for inclusion in the library + * proper. + * + * Macros: + * + * JSVERIFY_EXP_ACT - ifdef flag, configures comparison order + * FAIL_IF() - check condition + * FAIL_UNLESS() - check _not_ condition + * JSVERIFY() - long-int equality check; prints reason/comparison + * JSVERIFY_NOT() - long-int inequality check; prints + * JSVERIFY_STR() - string equality check; prints + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *****************************************************************************/ + + +/*---------------------------------------------------------------------------- + * + * ifdef flag: JSVERIFY_EXP_ACT + * + * JSVERIFY macros accept arguments as (EXPECTED, ACTUAL[, reason]) + * default, if this is undefined, is (ACTUAL, EXPECTED[, reason]) + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_EXP_ACT 1L + + +/*---------------------------------------------------------------------------- + * + * Macro: JSFAILED_AT() + * + * Purpose: + * + * Preface a test failure by printing "*FAILED*" and location to stdout + * Similar to `H5_FAILED(); AT();` from h5test.h + * + * *FAILED* at somefile.c:12 in function_name()... + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSFAILED_AT() { \ + HDprintf("*FAILED* at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: FAIL_IF() + * + * Purpose: + * + * Make tests more accessible and less cluttered than + * `if (thing == otherthing()) TEST_ERROR` + * paradigm. + * + * The following lines are roughly equivalent: + * + * `if (myfunc() < 0) TEST_ERROR;` (as seen elsewhere in HDF tests) + * `FAIL_IF(myfunc() < 0)` + * + * Prints a generic "FAILED AT" line to stdout and jumps to `error`, + * similar to `TEST_ERROR` in h5test.h + * + * Programmer: Jacob Smith + * 2017-10-23 + * + *---------------------------------------------------------------------------- + */ +#define FAIL_IF(condition) \ +if (condition) { \ + JSFAILED_AT() \ + goto error; \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: FAIL_UNLESS() + * + * Purpose: + * + * TEST_ERROR wrapper to reduce cognitive overhead from "negative tests", + * e.g., "a != b". + * + * Opposite of FAIL_IF; fails if the given condition is _not_ true. + * + * `FAIL_IF( 5 != my_op() )` + * is equivalent to + * `FAIL_UNLESS( 5 == my_op() )` + * However, `JSVERIFY(5, my_op(), "bad return")` may be even clearer. + * (see JSVERIFY) + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define FAIL_UNLESS(condition) \ +if (!(condition)) { \ + JSFAILED_AT() \ + goto error; \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: JSERR_LONG() + * + * Purpose: + * + * Print an failure message for long-int arguments. + * ERROR-AT printed first. + * If `reason` is given, it is printed on own line and newlined after + * else, prints "expected/actual" aligned on own lines. + * + * *FAILED* at myfile.c:488 in somefunc()... + * forest must be made of trees. + * + * or + * + * *FAILED* at myfile.c:488 in somefunc()... + * ! Expected 425 + * ! Actual 3 + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSERR_LONG(expected, actual, reason) { \ + JSFAILED_AT() \ + if (reason!= NULL) { \ + HDprintf("%s\n", (reason)); \ + } else { \ + HDprintf(" ! Expected %ld\n ! Actual %ld\n", \ + (long)(expected), (long)(actual)); \ + } \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: JSERR_STR() + * + * Purpose: + * + * Print an failure message for string arguments. + * ERROR-AT printed first. + * If `reason` is given, it is printed on own line and newlined after + * else, prints "expected/actual" aligned on own lines. + * + * *FAILED* at myfile.c:421 in myfunc()... + * Blue and Red strings don't match! + * + * or + * + * *FAILED* at myfile.c:421 in myfunc()... + * !!! Expected: + * this is my expected + * string + * !!! Actual: + * not what I expected at all + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSERR_STR(expected, actual, reason) { \ + JSFAILED_AT() \ + if ((reason) != NULL) { \ + HDprintf("%s\n", (reason)); \ + } else { \ + HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", \ + (expected), (actual)); \ + } \ +} + +#ifdef JSVERIFY_EXP_ACT + + +/*---------------------------------------------------------------------------- + * + * Macro: JSVERIFY() + * + * Purpose: + * + * Verify that two long integers are equal. + * If unequal, print failure message + * (with `reason`, if not NULL; expected/actual if NULL) + * and jump to `error` at end of function + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY(expected, actual, reason) \ +if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ +} /* JSVERIFY */ + + +/*---------------------------------------------------------------------------- + * + * Macro: JSVERIFY_NOT() + * + * Purpose: + * + * Verify that two long integers are _not_ equal. + * If equal, print failure message + * (with `reason`, if not NULL; expected/actual if NULL) + * and jump to `error` at end of function + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_NOT(expected, actual, reason) \ +if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ +} /* JSVERIFY_NOT */ + + +/*---------------------------------------------------------------------------- + * + * Macro: JSVERIFY_STR() + * + * Purpose: + * + * Verify that two strings are equal. + * If unequal, print failure message + * (with `reason`, if not NULL; expected/actual if NULL) + * and jump to `error` at end of function + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_STR(expected, actual, reason) \ +if (strcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ +} /* JSVERIFY_STR */ + + +#else /* JSVERIFY_EXP_ACT not defined */ + /* Repeats macros above, but with actual/expected parameters reversed. */ + + +/*---------------------------------------------------------------------------- + * Macro: JSVERIFY() + * See: JSVERIFY documentation above. + * Programmer: Jacob Smith + * 2017-10-14 + *---------------------------------------------------------------------------- + */ +#define JSVERIFY(actual, expected, reason) \ +if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)); \ + goto error; \ +} /* JSVERIFY */ + + +/*---------------------------------------------------------------------------- + * Macro: JSVERIFY_NOT() + * See: JSVERIFY_NOT documentation above. + * Programmer: Jacob Smith + * 2017-10-14 + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_NOT(actual, expected, reason) \ +if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ +} /* JSVERIFY_NOT */ + + +/*---------------------------------------------------------------------------- + * Macro: JSVERIFY_STR() + * See: JSVERIFY_STR documentation above. + * Programmer: Jacob Smith + * 2017-10-14 + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_STR(actual, expected, reason) \ +if (strcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ +} /* JSVERIFY_STR */ + +#endif /* ifdef/else JSVERIFY_EXP_ACT */ + +#endif /* __js_test__ */ + +/* if > 0, be very verbose when performing tests */ +#define H5TOOLS_UTILS_TEST_DEBUG 0 + +/******************/ +/* TEST FUNCTIONS */ +/******************/ + + +/*---------------------------------------------------------------------------- + * + * Function: test_parse_tuple() + * + * Purpose: + * + * Provide unit tests and specification for the `parse_tuple()` function. + * + * Return: + * + * 0 Tests passed. + * 1 Tests failed. + * + * Programmer: Jacob Smith + * 2017-11-11 + * + * Changes: None. + * + *---------------------------------------------------------------------------- + */ +static unsigned +test_parse_tuple(void) +{ + /************************* + * TEST-LOCAL STRUCTURES * + *************************/ + + struct testcase { + const char *test_msg; /* info about test case */ + const char *in_str; /* input string */ + int sep; /* separator "character" */ + herr_t exp_ret; /* expected SUCCEED / FAIL */ + unsigned exp_nelems; /* expected number of elements */ + /* (no more than 7!) */ + const char *exp_elems[7]; /* list of elements (no more than 7!) */ + }; + + /****************** + * TEST VARIABLES * + ******************/ + + struct testcase cases[] = { + { "bad start", + "words(before)", + ';', + FAIL, + 0, + {NULL}, + }, + { "tuple not closed", + "(not ok", + ',', + FAIL, + 0, + {NULL}, + }, + { "empty tuple", + "()", + '-', + SUCCEED, + 1, + {""}, + }, + { "no separator", + "(stuff keeps on going)", + ',', + SUCCEED, + 1, + {"stuff keeps on going"}, + }, + { "4-ple, escaped seperator", + "(elem0,elem1,el\\,em2,elem3)", /* "el\,em" */ + ',', + SUCCEED, + 4, + {"elem0", "elem1", "el,em2", "elem3"}, + }, + { "5-ple, escaped escaped separator", + "(elem0,elem1,el\\\\,em2,elem3)", + ',', + SUCCEED, + 5, + {"elem0", "elem1", "el\\", "em2", "elem3"}, + }, + { "escaped non-comma separator", + "(5-2-7-2\\-6-2)", + '-', + SUCCEED, + 5, + {"5","2","7","2-6","2"}, + }, + { "embedded close-paren", + "(be;fo)re)", + ';', + SUCCEED, + 2, + {"be", "fo)re"}, + }, + { "embedded non-escaping backslash", + "(be;fo\\re)", + ';', + SUCCEED, + 2, + {"be", "fo\\re"}, + }, + { "double close-paren at end", + "(be;fore))", + ';', + SUCCEED, + 2, + {"be", "fore)"}, + }, + { "empty elements", + "(;a1;;a4;)", + ';', + SUCCEED, + 5, + {"", "a1", "", "a4", ""}, + }, + { "nested tuples with different separators", + "((4,e,a);(6,2,a))", + ';', + SUCCEED, + 2, + {"(4,e,a)","(6,2,a)"}, + }, + { "nested tuples with same separators", + "((4,e,a),(6,2,a))", + ',', + SUCCEED, + 6, + {"(4","e","a)","(6","2","a)"}, + }, + { "real-world use case", + "(us-east-2,AKIAIMC3D3XLYXLN5COA,ugs5aVVnLFCErO/8uW14iWE3K5AgXMpsMlWneO/+)", + ',', + SUCCEED, + 3, + {"us-east-2", + "AKIAIMC3D3XLYXLN5COA", + "ugs5aVVnLFCErO/8uW14iWE3K5AgXMpsMlWneO/+"}, + } + }; + struct testcase tc; + unsigned n_tests = 14; + unsigned i = 0; + unsigned count = 0; + unsigned elem_i = 0; + char **parsed = NULL; + char *cpy = NULL; + herr_t success = TRUE; + hbool_t show_progress = FALSE; + + + + TESTING("arbitrary-count tuple parsing"); + +#if H5TOOLS_UTILS_TEST_DEBUG > 0 + show_progress = TRUE; +#endif /* H5TOOLS_UTILS_TEST_DEBUG */ + + /********* + * TESTS * + *********/ + + for (i = 0; i < n_tests; i++) { + + /* SETUP + */ + HDassert(parsed == NULL); + HDassert(cpy == NULL); + tc = cases[i]; + if (show_progress == TRUE) { + printf("testing %d: %s...\n", i, tc.test_msg); + } + + /* VERIFY + */ + success = parse_tuple(tc.in_str, tc.sep, + &cpy, &count, &parsed); + + JSVERIFY( tc.exp_ret, success, "function returned incorrect value" ) + JSVERIFY( tc.exp_nelems, count, NULL ) + if (success == SUCCEED) { + FAIL_IF( parsed == NULL ) + for (elem_i = 0; elem_i < count; elem_i++) { + JSVERIFY_STR( tc.exp_elems[elem_i], parsed[elem_i], NULL ) + } + /* TEARDOWN */ + HDassert(parsed != NULL); + HDassert(cpy != NULL); + free(parsed); + parsed = NULL; + free(cpy); + cpy = NULL; + } else { + FAIL_IF( parsed != NULL ) + } /* if parse_tuple() == SUCCEED or no */ + + } /* for each testcase */ + + PASSED(); + return 0; + +error: + /*********** + * CLEANUP * + ***********/ + + if (parsed != NULL) free(parsed); + if (cpy != NULL) free(cpy); + + return 1; + +} /* test_parse_tuple */ + + +/*---------------------------------------------------------------------------- + * + * Function: test_populate_ros3_fa() + * + * Purpose: Verify behavior of `populate_ros3_fa()` + * + * Return: 0 if test passes + * 1 if failure + * + * Programmer: Jacob Smith + * 2017-11-13 + * + * Changes: None + * + *---------------------------------------------------------------------------- + */ +static unsigned +test_populate_ros3_fa(void) +{ +#ifdef H5_HAVE_ROS3_VFD + /************************* + * TEST-LOCAL STRUCTURES * + *************************/ + + /************************ + * TEST-LOCAL VARIABLES * + ************************/ + + hbool_t show_progress = FALSE; + int bad_version = 0xf87a; /* arbitrarily wrong version number */ +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("programmatic ros3 fapl population"); + +#ifndef H5_HAVE_ROS3_VFD + puts(" -SKIP-"); + puts(" Read-Only S3 VFD not enabled"); + fflush(stdout); + return 0; +#else +#if H5TOOLS_UTILS_TEST_DEBUG > 0 + show_progress = TRUE; +#endif /* H5TOOLS_UTILS_TEST_DEBUG */ + + HDassert(bad_version != H5FD__CURR_ROS3_FAPL_T_VERSION); + + /********* + * TESTS * + *********/ + + /* NULL fapl config pointer fails + */ + { + const char *values[] = {"x", "y", "z"}; + + if (show_progress) { HDprintf("NULL fapl pointer\n"); } + + JSVERIFY( 0, h5tools_populate_ros3_fapl(NULL, values), + "fapl pointer cannot be null" ) + } + + /* NULL values pointer yields default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, TRUE, "u", "v", "w"}; + + if (show_progress) { HDprintf("NULL values pointer\n"); } + + JSVERIFY( 1, h5tools_populate_ros3_fapl(&fa, NULL), + "NULL values pointer yields \"default\" fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* all-empty values + * yields default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, TRUE, "u", "v", "w"}; + const char *values[] = {"", "", ""}; + + if (show_progress) { HDprintf("all empty values\n"); } + + JSVERIFY( 1, h5tools_populate_ros3_fapl(&fa, values), + "empty values yields \"default\" fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* successfully set fapl with values + * excess value is ignored + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {"x", "y", "z", "a"}; + + if (show_progress) { HDprintf("successful full set\n"); } + + JSVERIFY( 1, h5tools_populate_ros3_fapl(&fa, values), + "four values" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( TRUE, fa.authenticate, NULL ) + JSVERIFY_STR( "x", fa.aws_region, NULL ) + JSVERIFY_STR( "y", fa.secret_id, NULL ) + JSVERIFY_STR( "z", fa.secret_key, NULL ) + } + + /* NULL region + * yeilds default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {NULL, "y", "z", NULL}; + + if (show_progress) { HDprintf("NULL region\n"); } + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* empty region + * yeilds default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {"", "y", "z", NULL}; + + if (show_progress) { HDprintf("empty region; non-empty id, key\n"); } + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* region overflow + * yeilds default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = { + "somewhere over the rainbow not too high " \ + "there is another rainbow bounding some darkened sky", + "y", + "z"}; + + if (show_progress) { HDprintf("region overflow\n"); } + + HDassert(strlen(values[0]) > H5FD__ROS3_MAX_REGION_LEN); + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* NULL id + * yields default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {"x", NULL, "z", NULL}; + + if (show_progress) { HDprintf("NULL id\n"); } + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* empty id (non-empty region, key) + * yeilds default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {"x", "", "z", NULL}; + + if (show_progress) { HDprintf("empty id; non-empty region and key\n"); } + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* id overflow + * partial set: region + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = { + "x", + "Why is it necessary to solve the problem? " \ + "What benefits will you receive by solving the problem? " \ + "What is the unknown? " \ + "What is it you don't yet understand? " \ + "What is the information you have? " \ + "What isn't the problem? " \ + "Is the information insufficient, redundant, or contradictory? " \ + "Should you draw a diagram or figure of the problem? " \ + "What are the boundaries of the problem? " \ + "Can you separate the various parts of the problem?", + "z"}; + + if (show_progress) { HDprintf("id overflow\n"); } + + HDassert(strlen(values[1]) > H5FD__ROS3_MAX_SECRET_ID_LEN); + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "x", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* NULL key + * yields default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {"x", "y", NULL, NULL}; + + if (show_progress) { HDprintf("NULL key\n"); } + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* empty key (non-empty region, id) + * yeilds authenticating fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {"x", "y", "", NULL}; + + if (show_progress) { HDprintf("empty key; non-empty region and id\n"); } + + JSVERIFY( 1, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( TRUE, fa.authenticate, NULL ) + JSVERIFY_STR( "x", fa.aws_region, NULL ) + JSVERIFY_STR( "y", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* empty key, region (non-empty id) + * yeilds default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {"", "y", "", NULL}; + + if (show_progress) { HDprintf("empty key and region; non-empty id\n"); } + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* empty key, id (non-empty region) + * yeilds default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {"x", "", "", NULL}; + + if (show_progress) { HDprintf("empty key and id; non-empty region\n"); } + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* key overflow + * partial set: region, id + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = { + "x", + "y", + "Why is it necessary to solve the problem? " \ + "What benefits will you receive by solving the problem? " \ + "What is the unknown? " \ + "What is it you don't yet understand? " \ + "What is the information you have? " \ + "What isn't the problem? " \ + "Is the information insufficient, redundant, or contradictory? " \ + "Should you draw a diagram or figure of the problem? " \ + "What are the boundaries of the problem? " \ + "Can you separate the various parts of the problem?"}; + + if (show_progress) { HDprintf("key overflow\n"); } + + HDassert(strlen(values[2]) > H5FD__ROS3_MAX_SECRET_KEY_LEN); + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "x", fa.aws_region, NULL ) + JSVERIFY_STR( "y", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* use case + */ + { + H5FD_ros3_fapl_t fa = {0, 0, "", "", ""}; + const char *values[] = { + "us-east-2", + "AKIAIMC3D3XLYXLN5COA", + "ugs5aVVnLFCErO/8uW14iWE3K5AgXMpsMlWneO/+" + }; + JSVERIFY( 1, + h5tools_populate_ros3_fapl(&fa, values), + "unable to set use case" ) + JSVERIFY( 1, fa.version, "version check" ) + JSVERIFY( 1, fa.authenticate, "should authenticate" ) + } + + PASSED(); + return 0; + +error : + /*********** + * CLEANUP * + ***********/ + + return 1; + +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_populate_ros3_fa */ + + +/*---------------------------------------------------------------------------- + * + * Function: test_set_configured_fapl() + * + * Purpose: Verify `h5tools_set_configured_fapl()` with ROS3 VFD + * + * Return: 0 if test passes + * 1 if failure + * + * Programmer: Jacob Smith + * 2018-07-12 + * + * Changes: None + * + *---------------------------------------------------------------------------- + */ +static unsigned +test_set_configured_fapl(void) +{ +#define UTIL_TEST_NOFAPL 1 +#define UTIL_TEST_DEFAULT 2 +#define UTIL_TEST_CREATE 3 + + /************************* + * TEST-LOCAL STRUCTURES * + *************************/ + typedef struct testcase { + const char message[88]; + int expected; + int fapl_choice; + const char vfdname[12]; + void *conf_fa; + } testcase; + + typedef struct other_fa_t { + int a; + int b; + int c; + } other_fa_t; + + /************************ + * TEST-LOCAL VARIABLES * + ************************/ + + hid_t fapl_id = -1; + other_fa_t wrong_fa = {0x432, 0xf82, 0x9093}; + H5FD_ros3_fapl_t ros3_anon_fa = {1, FALSE, "", "", ""}; + H5FD_ros3_fapl_t ros3_auth_fa = { + 1, /* fapl version */ + TRUE, /* authenticate */ + "us-east-1", /* aws region */ + "12345677890abcdef", /* simulate access key ID */ + "oiwnerwe9u0234nJw0-aoj+dsf", /* simulate secret key */ + }; + H5FD_hdfs_fapl_t hdfs_fa = { + 1, /* fapl version */ + "", /* namenode name */ + 0, /* namenode port */ + "", /* kerberos ticket cache */ + "", /* user name */ + 2048, /* stream buffer size */ + }; + unsigned n_cases = 7; /* number of common testcases */ + testcase cases[] = { + { "(common) should fail: no fapl id", + 0, + UTIL_TEST_NOFAPL, + "", + NULL, + }, + { "(common) should fail: no fapl id (with struct)", + 0, + UTIL_TEST_NOFAPL, + "", + &wrong_fa, + }, + { "(common) H5P_DEFAULT with no struct should succeed", + 1, + UTIL_TEST_DEFAULT, + "", + NULL, + }, + { "(common) H5P_DEFAULT with (ignored) struct should succeed", + 1, + UTIL_TEST_DEFAULT, + "", + &wrong_fa, + }, + { "(common) provided fapl entry should not fail", + 1, + UTIL_TEST_CREATE, + "", + NULL, + }, + { "(common) provided fapl entry should not fail; ignores struct", + 1, + UTIL_TEST_CREATE, + "", + &wrong_fa, + }, + { "(common) should fail: unrecoginzed vfd name", + 0, + UTIL_TEST_DEFAULT, + "unknown", + NULL, + }, + +#ifdef H5_HAVE_ROS3_VFD + /* WARNING: add number of ROS3 test cases after array definition + */ + { "(ROS3) should fail: no fapl id, no struct", + 0, + UTIL_TEST_NOFAPL, + "ros3", + NULL, + }, + { "(ROS3) should fail: no fapl id", + 0, + UTIL_TEST_NOFAPL, + "ros3", + &ros3_anon_fa, + }, + { "(ROS3) should fail: no struct", + 0, + UTIL_TEST_CREATE, + "ros3", + NULL, + }, + { "(ROS3) successful set", + 1, + UTIL_TEST_CREATE, + "ros3", + &ros3_anon_fa, + }, + { "(ROS3) should fail: attempt to set DEFAULT fapl", + 0, + UTIL_TEST_DEFAULT, + "ros3", + &ros3_anon_fa, + }, +#endif /* H5_HAVE_ROS3_VFD */ + +#ifdef H5_HAVE_LIBHDFS + /* WARNING: add number of HDFS test cases after array definition + */ + { "(HDFS) should fail: no fapl id, no struct", + 0, + UTIL_TEST_NOFAPL, + "hdfs", + NULL, + }, + { "(HDFS) should fail: no fapl id", + 0, + UTIL_TEST_NOFAPL, + "hdfs", + &hdfs_fa, + }, + { "(HDFS) should fail: no struct", + 0, + UTIL_TEST_CREATE, + "hdfs", + NULL, + }, + { "(HDFS) successful set", + 1, + UTIL_TEST_CREATE, + "hdfs", + &hdfs_fa, + }, + { "(HDFS) should fail: attempt to set DEFAULT fapl", + 0, + UTIL_TEST_DEFAULT, + "hdfs", + &hdfs_fa, + }, +#endif /* H5_HAVE_LIBHDFS */ + + }; /* testcases `cases` array */ + +#ifdef H5_HAVE_ROS3_VFD + n_cases += 5; +#endif /* H5_HAVE_ROS3_VFD */ + +#ifdef H5_HAVE_LIBHDFS + n_cases += 5; +#endif /* H5_HAVE_LIBHDFS */ + + TESTING("programmatic fapl set"); + + for (unsigned i = 0; i < n_cases; i++) { + int result; + testcase C = cases[i]; + + fapl_id = -1; + +#if UTIL_TEST_DEBUG + HDfprintf(stderr, "setup test %d\t%s\n", i, C.message); fflush(stderr); +#endif /* UTIL_TEST_DEBUG */ + + /* per-test setup */ + if (C.fapl_choice == UTIL_TEST_DEFAULT) { + fapl_id = H5P_DEFAULT; + } else if (C.fapl_choice == UTIL_TEST_CREATE) { + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( fapl_id < 0 ) + } + +#if UTIL_TEST_DEBUG + HDfprintf(stderr, "before test\n"); fflush(stderr); +#endif /* UTIL_TEST_DEBUG */ + + /* test */ + result = h5tools_set_configured_fapl( + fapl_id, + C.vfdname, + C.conf_fa); + JSVERIFY( result, C.expected, C.message ) + +#if UTIL_TEST_DEBUG + HDfprintf(stderr, "after test\n"); fflush(stderr); +#endif /* UTIL_TEST_DEBUG */ + + /* per-test-teardown */ + if (fapl_id > 0) { + FAIL_IF( FAIL == H5Pclose(fapl_id) ) + } + fapl_id = -1; + +#if UTIL_TEST_DEBUG + HDfprintf(stderr, "after cleanup\n"); fflush(stderr); +#endif /* UTIL_TEST_DEBUG */ + + } + +#if UTIL_TEST_DEBUG + HDfprintf(stderr, "after loop\n"); fflush(stderr); +#endif /* UTIL_TEST_DEBUG */ + + PASSED(); + return 0; + +error : + /*********** + * CLEANUP * + ***********/ + +#if UTIL_TEST_DEBUG + HDfprintf(stderr, "ERROR\n"); fflush(stderr); +#endif /* UTIL_TEST_DEBUG */ + + if (fapl_id > 0) { + (void)H5Pclose(fapl_id); + } + + return 1; + +#undef UTIL_TEST_NOFAPL +#undef UTIL_TEST_DEFAULT +#undef UTIL_TEST_CREATE +} /* test_set_configured_fapl */ + + +/*---------------------------------------------------------------------------- + * + * Function: main() + * + * Purpose: Run all test functions. + * + * Return: 0 iff all test pass + * 1 iff any failures + * + * Programmer: Jacob Smith + * 2017-11-10 + * + * Changes: None. + * + *---------------------------------------------------------------------------- + */ +int +main(void) +{ + unsigned nerrors = 0; + +#ifdef _H5TEST_ + h5reset(); /* h5test? */ +#endif /* _H5TEST_ */ + + HDfprintf(stdout, "Testing h5tools_utils corpus.\n"); + + nerrors += test_parse_tuple(); + nerrors += test_populate_ros3_fa(); + nerrors += test_set_configured_fapl(); + + if (nerrors > 0) { + HDfprintf(stdout, "***** %d h5tools_utils TEST%s FAILED! *****\n", + nerrors, + nerrors > 1 ? "S" : ""); + nerrors = 1; + } else { + HDfprintf(stdout, "All h5tools_utils tests passed\n"); + } + + return (int)nerrors; + +} /* main */ + + diff --git a/tools/src/h5dump/h5dump.c b/tools/src/h5dump/h5dump.c index b9e37e8..a824197 100644 --- a/tools/src/h5dump/h5dump.c +++ b/tools/src/h5dump/h5dump.c @@ -24,6 +24,23 @@ static int doxml = 0; static int useschema = 1; static const char *xml_dtd_uri = NULL; +static H5FD_ros3_fapl_t ros3_fa = { + 1, /* version */ + false, /* authenticate */ + "", /* aws region */ + "", /* access key id */ + "", /* secret access key */ +}; + +static H5FD_hdfs_fapl_t hdfs_fa = { + 1, /* fapl version */ + "localhost", /* namenode name */ + 0, /* namenode port */ + "", /* kerberos ticket cache */ + "", /* user name */ + 2048, /* stream buffer size */ +}; + /* module-scoped variables for XML option */ #define DEFAULT_XSD "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd" #define DEFAULT_DTD "http://www.hdfgroup.org/HDF5/XML/DTD/HDF5-File.dtd" @@ -188,6 +205,8 @@ static struct long_options l_opts[] = { { "any_path", require_arg, 'N' }, { "vds-view-first-missing", no_arg, 'v' }, { "vds-gap-size", require_arg, 'G' }, + { "s3-cred", require_arg, '$' }, + { "hdfs-attrs", require_arg, '#' }, { NULL, 0, '\0' } }; @@ -241,6 +260,16 @@ usage(const char *prog) PRINTVALSTREAM(rawoutstream, " -b B, --binary=B Binary file output, of form B\n"); PRINTVALSTREAM(rawoutstream, " -O F, --ddl=F Output ddl text into file F\n"); PRINTVALSTREAM(rawoutstream, " Use blank(empty) filename F to suppress ddl display\n"); + PRINTVALSTREAM(rawoutstream, " --s3-cred= Supply S3 authentication information to \"ros3\" vfd.\n"); + PRINTVALSTREAM(rawoutstream, " :: \"(,,)\"\n"); + PRINTVALSTREAM(rawoutstream, " If absent or -> \"(,,)\", no authentication.\n"); + PRINTVALSTREAM(rawoutstream, " Has no effect is filedriver is not `ros3'.\n"); + PRINTVALSTREAM(rawoutstream, " --hdfs-attrs= Supply configuration information for HDFS file access.\n"); + PRINTVALSTREAM(rawoutstream, " For use with \"--filedriver=hdfs\"\n"); + PRINTVALSTREAM(rawoutstream, " :: (,,\n"); + PRINTVALSTREAM(rawoutstream, " ,,\n"); + PRINTVALSTREAM(rawoutstream, " )\n"); + PRINTVALSTREAM(rawoutstream, " Any absent attribute will use a default value.\n"); PRINTVALSTREAM(rawoutstream, "--------------- Object Options ---------------\n"); PRINTVALSTREAM(rawoutstream, " -a P, --attribute=P Print the specified attribute\n"); PRINTVALSTREAM(rawoutstream, " If an attribute name contains a slash (/), escape the\n"); @@ -1282,6 +1311,126 @@ end_collect: hand = NULL; h5tools_setstatus(EXIT_SUCCESS); goto done; + + case '$': +#ifndef H5_HAVE_ROS3_VFD + error_msg("Read-Only S3 VFD not enabled.\n"); + h5tools_setstatus(EXIT_FAILURE); + goto done; +#else + /* s3 credential */ + { + char **s3_cred = NULL; + char *s3_cred_string = NULL; + const char *ccred[3]; + unsigned nelems = 0; + if ( FAIL == + parse_tuple(opt_arg, ',', + &s3_cred_string, &nelems, &s3_cred)) + { + error_msg("unable to parse malformed s3 credentials\n"); + usage(h5tools_getprogname()); + free_handler(hand, argc); + hand= NULL; + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + if (nelems != 3) { + error_msg("s3 credentials expects 3 elements\n"); + usage(h5tools_getprogname()); + free_handler(hand, argc); + hand= NULL; + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + ccred[0] = (const char *)s3_cred[0]; + ccred[1] = (const char *)s3_cred[1]; + ccred[2] = (const char *)s3_cred[2]; + if (0 == h5tools_populate_ros3_fapl(&ros3_fa, ccred)) { + error_msg("Invalid S3 credentials\n"); + usage(h5tools_getprogname()); + free_handler(hand, argc); + hand= NULL; + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + HDfree(s3_cred); + HDfree(s3_cred_string); + } /* s3 credential block */ + break; +#endif /* H5_HAVE_ROS3_VFD */ + + case '#': +#ifndef H5_HAVE_LIBHDFS + error_msg("HDFS VFD is not enabled.\n"); + goto error; +#else + { + /* read hdfs properties tuple and store values in `hdfs_fa` + */ + unsigned nelems = 0; + char *props_src = NULL; + char **props = NULL; + unsigned long k = 0; + if (FAIL == parse_tuple( + (const char *)opt_arg, + ',', + &props_src, + &nelems, + &props)) + { + error_msg("unable to parse hdfs properties tuple\n"); + goto error; + } + /* sanity-check tuple count + */ + if (nelems != 5) { + h5tools_setstatus(EXIT_FAILURE); + goto error; + } + /* Populate fapl configuration structure with given + * properties. + * WARNING: No error-checking is done on length of input + * strings... Silent overflow is possible, albeit + * unlikely. + */ + if (strncmp(props[0], "", 1)) { + HDstrncpy(hdfs_fa.namenode_name, + (const char *)props[0], + HDstrlen(props[0])); + } + if (strncmp(props[1], "", 1)) { + k = strtoul((const char *)props[1], NULL, 0); + if (errno == ERANGE) { + h5tools_setstatus(EXIT_FAILURE); + goto error; + } + hdfs_fa.namenode_port = (int32_t)k; + } + if (strncmp(props[2], "", 1)) { + HDstrncpy(hdfs_fa.kerberos_ticket_cache, + (const char *)props[2], + HDstrlen(props[2])); + } + if (strncmp(props[3], "", 1)) { + HDstrncpy(hdfs_fa.user_name, + (const char *)props[3], + HDstrlen(props[3])); + } + if (strncmp(props[4], "", 1)) { + k = strtoul((const char *)props[4], NULL, 0); + if (errno == ERANGE) { + h5tools_setstatus(EXIT_FAILURE); + goto error; + } + hdfs_fa.stream_buffer_size = (int32_t)k; + } + HDfree(props); + HDfree(props_src); + } +#endif /* H5_HAVE_LIBHDFS */ + break; + case '?': default: usage(h5tools_getprogname()); @@ -1354,6 +1503,7 @@ main(int argc, const char *argv[]) { hid_t fid = -1; hid_t gid = -1; + hid_t fapl_id = H5P_DEFAULT; H5E_auto2_t func; H5E_auto2_t tools_func; H5O_info_t oi; @@ -1440,10 +1590,60 @@ main(int argc, const char *argv[]) /* Initialize indexing options */ h5trav_set_index(sort_by, sort_order); + if (driver != NULL) { + void *conf_fa = NULL; + + if (!strcmp(driver, "ros3")) { +#ifndef H5_HAVE_ROS3_VFD + error_msg("Read-Only S3 VFD not enabled.\n"); + h5tools_setstatus(EXIT_FAILURE); + goto done; +#else + conf_fa = (void *)&ros3_fa; +#endif /* H5_HAVE_ROS3_VFD */ + } else if (!HDstrcmp(driver, "hdfs")) { +#ifndef H5_HAVE_LIBHDFS + error_msg("HDFS VFD is not enabled.\n"); + h5tools_setstatus(EXIT_FAILURE); + goto done; +#else + conf_fa = (void *)&hdfs_fa; +#endif /* H5_HAVE_LIBHDFS */ + } + + if (conf_fa != NULL) { + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if (fapl_id < 0) { + error_msg("unable to create fapl entry\n"); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + if (0 == h5tools_set_configured_fapl( + fapl_id, + driver, /* guaranteed "ros3" or "hdfs" */ + conf_fa)) /* appropriate to driver */ + { + error_msg("unable to set fapl\n"); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + } + } /* driver defined */ + while(opt_ind < argc) { fname = HDstrdup(argv[opt_ind++]); - fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, driver, NULL, 0); + if (fapl_id != H5P_DEFAULT) { + fid = H5Fopen(fname, H5F_ACC_RDONLY, fapl_id); + } else { + fid = h5tools_fopen( + fname, + H5F_ACC_RDONLY, + H5P_DEFAULT, + driver, + NULL, + 0); + } if (fid < 0) { error_msg("unable to open file \"%s\"\n", fname); @@ -1624,6 +1824,11 @@ done: /* Free tables for objects */ table_list_free(); + if (fapl_id != H5P_DEFAULT && 0 < H5Pclose(fapl_id)) { + error_msg("Can't close fapl entry\n"); + h5tools_setstatus(EXIT_FAILURE); + } + if(fid >=0) if (H5Fclose(fid) < 0) h5tools_setstatus(EXIT_FAILURE); @@ -1645,127 +1850,7 @@ done: H5Eset_auto2(H5E_DEFAULT, func, edata); leave(h5tools_getstatus()); -} - -/*------------------------------------------------------------------------- - * Function: h5_fileaccess - * - * Purpose: Returns a file access template which is the default template - * but with a file driver set according to the constant or - * environment variable HDF5_DRIVER - * - * Return: Success: A file access property list - * - * Failure: -1 - * - * Programmer: Robb Matzke - * Thursday, November 19, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -hid_t -h5_fileaccess(void) -{ - static const char *multi_letters = "msbrglo"; - const char *val = NULL; - const char *name; - char s[1024]; - hid_t fapl = -1; - - /* First use the environment variable, then the constant */ - val = HDgetenv("HDF5_DRIVER"); -#ifdef HDF5_DRIVER - if (!val) val = HDF5_DRIVER; -#endif - - if ((fapl=H5Pcreate(H5P_FILE_ACCESS))<0) return -1; - if (!val || !*val) return fapl; /*use default*/ - - HDstrncpy(s, val, sizeof s); - s[sizeof(s)-1] = '\0'; - if (NULL==(name=HDstrtok(s, " \t\n\r"))) return fapl; - - if (!HDstrcmp(name, "sec2")) { - /* Unix read() and write() system calls */ - if (H5Pset_fapl_sec2(fapl)<0) return -1; - } - else if (!HDstrcmp(name, "stdio")) { - /* Standard C fread() and fwrite() system calls */ - if (H5Pset_fapl_stdio(fapl)<0) return -1; - } - else if (!HDstrcmp(name, "core")) { - /* In-core temporary file with 1MB increment */ - if (H5Pset_fapl_core(fapl, 1024*1024, FALSE)<0) return -1; - } - else if (!HDstrcmp(name, "split")) { - /* Split meta data and raw data each using default driver */ - if (H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) - return -1; - } - else if (!HDstrcmp(name, "multi")) { - /* Multi-file driver, general case of the split driver */ - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; - const char *memb_name[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][1024]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - H5FD_mem_t mt; - - HDmemset(memb_map, 0, sizeof memb_map); - HDmemset(memb_fapl, 0, sizeof memb_fapl); - HDmemset(memb_name, 0, sizeof memb_name); - HDmemset(memb_addr, 0, sizeof memb_addr); - - if(HDstrlen(multi_letters)==H5FD_MEM_NTYPES) { - for (mt=H5FD_MEM_DEFAULT; mt,,)\".\n"); + PRINTVALSTREAM(rawoutstream, " If absent or C->\"(,,)\", defaults to no-authentication.\n"); + PRINTVALSTREAM(rawoutstream, " Has no effect if vfd flag not set to \"ros3\".\n"); + PRINTVALSTREAM(rawoutstream, " --hdfs-attrs=A Supply configuration information to Hadoop VFD.\n"); + PRINTVALSTREAM(rawoutstream, " Accepts tuple of (,,\n"); + PRINTVALSTREAM(rawoutstream, " ...,,)\n"); + PRINTVALSTREAM(rawoutstream, " If absent or A == '(,,,,)', all default values are used.\n"); + PRINTVALSTREAM(rawoutstream, " Has no effect if vfd flag is not 'hdfs'.\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " file/OBJECT\n"); PRINTVALSTREAM(rawoutstream, " Each object consists of an HDF5 file name optionally followed by a\n"); @@ -237,7 +246,7 @@ usage (void) PRINTVALSTREAM(rawoutstream, " Replaced by --enable-error-stack.\n"); } - + /*------------------------------------------------------------------------- * Function: print_string @@ -315,7 +324,7 @@ print_string(h5tools_str_t *buffer, const char *s, hbool_t escape_spaces) return nprint; } - + /*------------------------------------------------------------------------- * Function: print_obj_name * @@ -364,7 +373,7 @@ print_obj_name(h5tools_str_t *buffer, const iter_t *iter, const char *oname, return TRUE; } - + /*------------------------------------------------------------------------- * Function: print_native_type * @@ -489,7 +498,7 @@ print_native_type(h5tools_str_t *buffer, hid_t type, int ind) return TRUE; } - + /*------------------------------------------------------------------------- * Function: print_ieee_type * @@ -527,7 +536,7 @@ print_ieee_type(h5tools_str_t *buffer, hid_t type, int ind) return TRUE; } - + /*------------------------------------------------------------------------- * Function: print_precision * @@ -619,7 +628,7 @@ print_precision(h5tools_str_t *buffer, hid_t type, int ind) } } - + /*------------------------------------------------------------------------- * Function: print_int_type * @@ -693,7 +702,7 @@ print_int_type(h5tools_str_t *buffer, hid_t type, int ind) return TRUE; } - + /*------------------------------------------------------------------------- * Function: print_float_type * @@ -807,7 +816,7 @@ print_float_type(h5tools_str_t *buffer, hid_t type, int ind) return TRUE; } - + /*------------------------------------------------------------------------- * Function: print_cmpd_type * @@ -860,7 +869,7 @@ print_cmpd_type(h5tools_str_t *buffer, hid_t type, int ind) return TRUE; } - + /*------------------------------------------------------------------------- * Function: print_enum_type * @@ -985,7 +994,7 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind) return TRUE; } - + /*------------------------------------------------------------------------- * Function: print_string_type * @@ -1086,7 +1095,7 @@ print_string_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind) return TRUE; } - + /*------------------------------------------------------------------------- * Function: print_reference_type * @@ -1124,7 +1133,7 @@ print_reference_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind) return TRUE; } - + /*------------------------------------------------------------------------- * Function: print_opaque_type * @@ -1160,7 +1169,7 @@ print_opaque_type(h5tools_str_t *buffer, hid_t type, int ind) return TRUE; } - + /*------------------------------------------------------------------------- * Function: print_vlen_type * @@ -1190,7 +1199,7 @@ print_vlen_type(h5tools_str_t *buffer, hid_t type, int ind) return TRUE; } - + /*--------------------------------------------------------------------------- * Purpose: Print information about an array type * @@ -1237,7 +1246,7 @@ print_array_type(h5tools_str_t *buffer, hid_t type, int ind) return TRUE; } - + /*------------------------------------------------------------------------- * Function: print_bitfield_type * @@ -1345,7 +1354,7 @@ print_type(h5tools_str_t *buffer, hid_t type, int ind) (unsigned long)H5Tget_size(type), (unsigned)data_class); } - + /*------------------------------------------------------------------------- * Function: dump_dataset_values * @@ -1475,7 +1484,7 @@ dump_dataset_values(hid_t dset) PRINTVALSTREAM(rawoutstream, "\n"); } - + /*------------------------------------------------------------------------- * Function: list_attr * @@ -1662,7 +1671,7 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ain return 0; } - + /*------------------------------------------------------------------------- * Function: dataset_list1 * @@ -1727,7 +1736,7 @@ dataset_list1(hid_t dset) return 0; } - + /*------------------------------------------------------------------------- * Function: dataset_list2 * @@ -1962,7 +1971,7 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name) return 0; } /* end dataset_list2() */ - + /*------------------------------------------------------------------------- * Function: datatype_list2 * @@ -2004,7 +2013,7 @@ datatype_list2(hid_t type, const char H5_ATTR_UNUSED *name) return 0; } - + /*------------------------------------------------------------------------- * Function: list_obj * @@ -2160,7 +2169,7 @@ done: } /* end list_obj() */ - + /*------------------------------------------------------------------------- * Function: list_lnk * @@ -2354,7 +2363,7 @@ done: return 0; } /* end list_lnk() */ - + /*------------------------------------------------------------------------- * Function: visit_obj * @@ -2434,7 +2443,7 @@ done: return retval; } - + /*------------------------------------------------------------------------- * Function: get_width * @@ -2550,7 +2559,7 @@ out: return ret; } - + /*------------------------------------------------------------------------- * Function: leave * @@ -2573,7 +2582,7 @@ leave(int ret) HDexit(ret); } - + /*------------------------------------------------------------------------- * Function: main * @@ -2602,6 +2611,26 @@ main(int argc, const char *argv[]) char drivername[50]; const char *preferred_driver = NULL; int err_exit = 0; + hid_t fapl_id = H5P_DEFAULT; + + /* default "anonymous" s3 configuration */ + H5FD_ros3_fapl_t ros3_fa = { + 1, /* fapl version */ + false, /* authenticate */ + "", /* aws region */ + "", /* access key id */ + "", /* secret access key */ + }; + + /* "default" HDFS configuration */ + H5FD_hdfs_fapl_t hdfs_fa = { + 1, /* fapl version */ + "localhost", /* namenode name */ + 0, /* namenode port */ + "", /* kerberos ticket cache */ + "", /* user name */ + 2048, /* stream buffer size */ + }; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -2701,6 +2730,185 @@ main(int argc, const char *argv[]) usage(); leave(EXIT_FAILURE); } + + } else if (!HDstrncmp(argv[argno], "--s3-cred=", (size_t)10)) { +#ifndef H5_HAVE_ROS3_VFD + HDfprintf(rawerrorstream, + "Error: Read-Only S3 VFD is not enabled\n\n"); + usage(); + leave(EXIT_FAILURE); +#else + unsigned nelems = 0; + char *start = NULL; + char *s3cred_src = NULL; + char **s3cred = NULL; + char const *ccred[3]; + /* try to parse s3 credentials tuple + */ + start = strchr(argv[argno], '='); + if (start == NULL) { + HDfprintf(rawerrorstream, + "Error: Unable to parse null credentials tuple\n" + " For anonymous access, omit \"--s3-cred\" and use" + "only \"--vfd=ros3\"\n\n"); + usage(); + leave(EXIT_FAILURE); + } + start++; + if (FAIL == + parse_tuple((const char *)start, ',', + &s3cred_src, &nelems, &s3cred)) + { + HDfprintf(rawerrorstream, + "Error: Unable to parse S3 credentials\n\n"); + usage(); + leave(EXIT_FAILURE); + } + /* sanity-check tuple count + */ + if (nelems != 3) { + HDfprintf(rawerrorstream, + "Error: Invalid S3 credentials\n\n"); + usage(); + leave(EXIT_FAILURE); + } + ccred[0] = (const char *)s3cred[0]; + ccred[1] = (const char *)s3cred[1]; + ccred[2] = (const char *)s3cred[2]; + if (0 == h5tools_populate_ros3_fapl(&ros3_fa, ccred)) { + HDfprintf(rawerrorstream, + "Error: Invalid S3 credentials\n\n"); + usage(); + leave(EXIT_FAILURE); + } + HDfree(s3cred); + HDfree(s3cred_src); +#endif /* H5_HAVE_ROS3_VFD */ + + } else if (!HDstrncmp(argv[argno], "--hdfs-attrs=", (size_t)13)) { +#ifndef H5_HAVE_LIBHDFS + PRINTVALSTREAM(rawoutstream, "The HDFS VFD is not enabled.\n"); + leave(EXIT_FAILURE); +#else + /* Parse received configuration data and set fapl config struct + */ + + hbool_t _debug = FALSE; + unsigned nelems = 0; + char const *start = NULL; + char *props_src = NULL; + char **props = NULL; + unsigned long k = 0; + + /* try to parse tuple + */ + if (_debug) { + HDfprintf(stderr, "configuring hdfs...\n"); + } + start = argv[argno]+13; /* should never segfault: worst case of */ + if (*start != '(') /* null-termintor after '='. */ + { + if (_debug) { + HDfprintf(stderr, " no tuple.\n"); + } + usage(); + leave(EXIT_FAILURE); + } + if (FAIL == + parse_tuple((const char *)start, ',', + &props_src, &nelems, &props)) + { + HDfprintf(stderr, + " unable to parse tuple.\n"); + usage(); + leave(EXIT_FAILURE); + } + + /* sanity-check tuple count + */ + if (nelems != 5) { + HDfprintf(stderr, + " expected 5-ple, got `%d`\n", + nelems); + usage(); + leave(EXIT_FAILURE); + } + if (_debug) { + HDfprintf(stderr, + " got hdfs-attrs tuple: `(%s,%s,%s,%s,%s)`\n", + props[0], + props[1], + props[2], + props[3], + props[4]); + } + + /* Populate fapl configuration structure with given properties. + * WARNING: No error-checking is done on length of input strings... + * Silent overflow is possible, albeit unlikely. + */ + if (HDstrncmp(props[0], "", 1)) { + if (_debug) { + HDfprintf(stderr, + " setting namenode name: %s\n", + props[0]); + } + HDstrncpy(hdfs_fa.namenode_name, + (const char *)props[0], + HDstrlen(props[0])); + } + if (HDstrncmp(props[1], "", 1)) { + k = strtoul((const char *)props[1], NULL, 0); + if (errno == ERANGE) { + HDfprintf(stderr, + " supposed port number wasn't.\n"); + leave(EXIT_FAILURE); + } + if (_debug) { + HDfprintf(stderr, + " setting namenode port: %lu\n", + k); + } + hdfs_fa.namenode_port = (int32_t)k; + } + if (HDstrncmp(props[2], "", 1)) { + if (_debug) { + HDfprintf(stderr, + " setting kerb cache path: %s\n", + props[2]); + } + HDstrncpy(hdfs_fa.kerberos_ticket_cache, + (const char *)props[2], + HDstrlen(props[2])); + } + if (HDstrncmp(props[3], "", 1)) { + if (_debug) { + HDfprintf(stderr, + " setting username: %s\n", + props[3]); + } + HDstrncpy(hdfs_fa.user_name, + (const char *)props[3], + HDstrlen(props[3])); + } + if (HDstrncmp(props[4], "", 1)) { + k = HDstrtoul((const char *)props[4], NULL, 0); + if (errno == ERANGE) { + HDfprintf(stderr, + " supposed buffersize number wasn't.\n"); + leave(EXIT_FAILURE); + } + if (_debug) { + HDfprintf(stderr, + " setting stream buffer size: %lu\n", + k); + } + hdfs_fa.stream_buffer_size = (int32_t)k; + } + HDfree(props); + HDfree(props_src); +#endif /* H5_HAVE_LIBHDFS */ + } else if('-'!=argv[argno][1]) { /* Single-letter switches */ for(s = argv[argno] + 1; *s; s++) { @@ -2772,6 +2980,7 @@ main(int argc, const char *argv[]) } /* end switch */ } /* end for */ } else { + HDfprintf(stderr, "Unknown argument: %s\n", argv[argno]); usage(); leave(EXIT_FAILURE); } @@ -2791,6 +3000,49 @@ main(int argc, const char *argv[]) leave(EXIT_FAILURE); } + if (preferred_driver) { + void *conf_fa = NULL; + + if (!HDstrcmp(preferred_driver, "ros3")) { +#ifndef H5_HAVE_ROS3_VFD + HDfprintf(rawerrorstream, + "Error: Read-Only S3 VFD not enabled.\n\n"); + usage(); + leave(EXIT_FAILURE); +#else + conf_fa = (void *)&ros3_fa; +#endif /* H5_HAVE_ROS3_VFD */ + + } else if (!HDstrcmp(preferred_driver, "hdfs")) { +#ifndef H5_HAVE_LIBHDFS + PRINTVALSTREAM(rawoutstream, "The HDFS VFD is not enabled.\n"); + leave(EXIT_FAILURE); +#else + conf_fa = (void *)&hdfs_fa; +#endif /* H5_HAVE_LIBHDFS */ + } + + if (conf_fa != NULL) { + HDassert(fapl_id == H5P_DEFAULT); + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if (fapl_id < 0) { + HDfprintf(rawerrorstream, + "Error: Unable to create fapl entry\n\n"); + leave(EXIT_FAILURE); + } + if (0 == h5tools_set_configured_fapl( + fapl_id, + preferred_driver, + conf_fa)) + { + HDfprintf(rawerrorstream, + "Error: Unable to set fapl\n\n"); + usage(); + leave(EXIT_FAILURE); + } + } + } /* preferred_driver defined */ + /* Turn off HDF5's automatic error printing unless you're debugging h5ls */ if(!show_errors_g) H5Eset_auto2(H5E_DEFAULT, NULL, NULL); @@ -2820,7 +3072,12 @@ main(int argc, const char *argv[]) file = -1; while(fname && *fname) { - file = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, preferred_driver, drivername, sizeof drivername); + if (fapl_id != H5P_DEFAULT) { + file = H5Fopen(fname, H5F_ACC_RDONLY, fapl_id); + } + else { + file = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, preferred_driver, drivername, sizeof drivername); + } if(file >= 0) { if(verbose_g) @@ -2933,6 +3190,14 @@ main(int argc, const char *argv[]) err_exit = 1; } /* end while */ + if (fapl_id != H5P_DEFAULT) { + if (0 < H5Pclose(fapl_id)) { + HDfprintf(rawerrorstream, + "Error: Unable to set close fapl entry\n\n"); + leave(EXIT_FAILURE); + } + } + if (err_exit) leave(EXIT_FAILURE); else diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c index 450f731..59038a0 100644 --- a/tools/src/h5stat/h5stat.c +++ b/tools/src/h5stat/h5stat.c @@ -74,7 +74,7 @@ typedef struct iter_t { ohdr_info_t group_ohdr_info; /* Object header information for groups */ hsize_t max_attrs; /* Maximum attributes from a group */ - unsigned long *num_small_attrs; /* Size of small attributes tracked */ + unsigned long *num_small_attrs; /* Size of small attributes tracked */ unsigned attr_nbins; /* Number of bins for attribute counts */ unsigned long *attr_bins; /* Pointer to array of bins for attribute counts */ @@ -118,6 +118,29 @@ typedef struct iter_t { } iter_t; +static const char *drivername = ""; + +/* default "anonymous" s3 configuration + */ +static H5FD_ros3_fapl_t ros3_fa = { + 1, /* fapl version */ + false, /* authenticate */ + "", /* aws region */ + "", /* access key id */ + "", /* secret access key */ +}; + +/* default HDFS access configuration + */ +static H5FD_hdfs_fapl_t hdfs_fa = { + 1, /* fapl version */ + "localhost", /* namenode name */ + 0, /* namenode port */ + "", /* kerberos ticket cache */ + "", /* user name */ + 2048, /* stream buffer size */ +}; + static int display_all = TRUE; /* Enable the printing of selected statistics */ @@ -146,7 +169,7 @@ struct handler_t { char **obj; }; -static const char *s_opts ="Aa:Ddm:EFfhGgl:sSTO:V"; +static const char *s_opts ="Aa:Ddm:EFfhGgl:sSTO:Vw:"; /* e.g. "filemetadata" has to precede "file"; "groupmetadata" has to precede "group" etc. */ static struct long_options l_opts[] = { {"help", no_arg, 'h'}, @@ -246,6 +269,8 @@ static struct long_options l_opts[] = { { "summ", no_arg, 'S' }, { "sum", no_arg, 'S' }, { "su", no_arg, 'S' }, + { "s3-cred", require_arg, 'w' }, + { "hdfs-attrs", require_arg, 'H' }, { NULL, 0, '\0' } }; @@ -257,7 +282,7 @@ leave(int ret) } - + /*------------------------------------------------------------------------- * Function: usage * @@ -295,9 +320,19 @@ static void usage(const char *prog) HDfprintf(stdout, " -s, --freespace Print free space information\n"); HDfprintf(stdout, " -S, --summary Print summary of file space information\n"); HDfprintf(stdout, " --enable-error-stack Prints messages from the HDF5 error stack as they occur\n"); + HDfprintf(stdout, " --s3-cred= Access file on S3, using provided credential\n"); + HDfprintf(stdout, " :: (region,id,key)\n"); + HDfprintf(stdout, " If == \"(,,)\", no authentication is used.\n"); + HDfprintf(stdout, " --hdfs-attrs= Access a file on HDFS with given configuration\n"); + HDfprintf(stdout, " attributes.\n"); + HDfprintf(stdout, " :: (,,\n"); + HDfprintf(stdout, " ,,\n"); + HDfprintf(stdout, " )\n"); + HDfprintf(stdout, " If an attribute is empty, a default value will be\n"); + HDfprintf(stdout, " used.\n"); } - + /*------------------------------------------------------------------------- * Function: ceil_log10 * @@ -324,7 +359,7 @@ ceil_log10(unsigned long x) return ret; } /* ceil_log10() */ - + /*------------------------------------------------------------------------- * Function: attribute_stats * @@ -374,7 +409,7 @@ attribute_stats(iter_t *iter, const H5O_info_t *oi) return 0; } /* end attribute_stats() */ - + /*------------------------------------------------------------------------- * Function: group_stats * @@ -456,7 +491,7 @@ done: return ret_value; } /* end group_stats() */ - + /*------------------------------------------------------------------------- * Function: dataset_stats * @@ -647,7 +682,7 @@ done: return ret_value; } /* end dataset_stats() */ - + /*------------------------------------------------------------------------- * Function: datatype_stats * @@ -679,7 +714,7 @@ done: return ret_value; } /* end datatype_stats() */ - + /*------------------------------------------------------------------------- * Function: obj_stats * @@ -735,7 +770,7 @@ done: return ret_value; } /* end obj_stats() */ - + /*------------------------------------------------------------------------- * Function: lnk_stats * @@ -833,7 +868,7 @@ freespace_stats(hid_t fid, iter_t *iter) return 0; } /* end freespace_stats() */ - + /*------------------------------------------------------------------------- * Function: hand_free * @@ -862,7 +897,7 @@ hand_free(struct handler_t *hand) } /* end if */ } /* end hand_free() */ - + /*------------------------------------------------------------------------- * Function: parse_command_line * @@ -1014,6 +1049,119 @@ parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret) } /* end if */ break; + case 'w': +#ifndef H5_HAVE_ROS3_VFD + error_msg("Read-Only S3 VFD not enabled.\n"); + goto error; +#else + { + char *cred_str = NULL; + unsigned nelems = 0; + char **cred = NULL; + char const *ccred[3]; + + if (FAIL == parse_tuple((const char *)opt_arg, ',', + &cred_str, &nelems, &cred)) { + error_msg("Unable to parse s3 credential\n"); + goto error; + } + if (nelems != 3) { + error_msg("s3 credential must have three elements\n"); + goto error; + } + ccred[0] = (const char *)cred[0]; + ccred[1] = (const char *)cred[1]; + ccred[2] = (const char *)cred[2]; + if (0 == + h5tools_populate_ros3_fapl(&ros3_fa, ccred)) + { + error_msg("Unable to set ros3 fapl config\n"); + goto error; + } + HDfree(cred); + HDfree(cred_str); + } /* parse s3-cred block */ + drivername = "ros3"; + break; +#endif /* H5_HAVE_ROS3_VFD */ + + case 'H': +#ifndef H5_HAVE_LIBHDFS + error_msg("HDFS VFD is not enabled.\n"); + goto error; +#else + { + unsigned nelems = 0; + char *props_src = NULL; + char **props = NULL; + unsigned long k = 0; + if (FAIL == parse_tuple( + (const char *)opt_arg, + ',', + &props_src, + &nelems, + &props)) + { + error_msg("unable to parse hdfs properties tuple\n"); + goto error; + } + /* sanity-check tuple count + */ + if (nelems != 5) { + char str[64] = ""; + sprintf(str, + "expected 5 elements in hdfs properties tuple " + "but found %u\n", + nelems); + HDfree(props); + HDfree(props_src); + error_msg(str); + goto error; + } + /* Populate fapl configuration structure with given + * properties. + * TODO/WARNING: No error-checking is done on length of + * input strings... Silent overflow is possible, + * albeit unlikely. + */ + if (strncmp(props[0], "", 1)) { + HDstrncpy(hdfs_fa.namenode_name, + (const char *)props[0], + HDstrlen(props[0])); + } + if (strncmp(props[1], "", 1)) { + k = strtoul((const char *)props[1], NULL, 0); + if (errno == ERANGE) { + error_msg("supposed port number wasn't.\n"); + goto error; + } + hdfs_fa.namenode_port = (int32_t)k; + } + if (strncmp(props[2], "", 1)) { + HDstrncpy(hdfs_fa.kerberos_ticket_cache, + (const char *)props[2], + HDstrlen(props[2])); + } + if (strncmp(props[3], "", 1)) { + HDstrncpy(hdfs_fa.user_name, + (const char *)props[3], + HDstrlen(props[3])); + } + if (strncmp(props[4], "", 1)) { + k = strtoul((const char *)props[4], NULL, 0); + if (errno == ERANGE) { + error_msg("supposed buffersize number wasn't.\n"); + goto error; + } + hdfs_fa.stream_buffer_size = (int32_t)k; + } + HDfree(props); + HDfree(props_src); + drivername = "hdfs"; + } + break; +#endif /* H5_HAVE_LIBHDFS */ + default: usage(h5tools_getprogname()); goto error; @@ -1040,7 +1188,7 @@ error: return -1; } - + /*------------------------------------------------------------------------- * Function: iter_free * @@ -1105,7 +1253,7 @@ iter_free(iter_t *iter) } /* end if */ } /* end iter_free() */ - + /*------------------------------------------------------------------------- * Function: print_file_info * @@ -1137,7 +1285,7 @@ print_file_info(const iter_t *iter) return 0; } /* print_file_info() */ - + /*------------------------------------------------------------------------- * Function: print_file_metadata * @@ -1197,7 +1345,7 @@ print_file_metadata(const iter_t *iter) return 0; } /* print_file_metadata() */ - + /*------------------------------------------------------------------------- * Function: print_group_info * @@ -1254,7 +1402,7 @@ print_group_info(const iter_t *iter) return 0; } /* print_group_info() */ - + /*------------------------------------------------------------------------- * Function: print_group_metadata * @@ -1281,7 +1429,7 @@ print_group_metadata(const iter_t *iter) return 0; } /* print_group_metadata() */ - + /*------------------------------------------------------------------------- * Function: print_dataset_info * @@ -1368,7 +1516,7 @@ print_dataset_info(const iter_t *iter) return 0; } /* print_dataset_info() */ - + /*------------------------------------------------------------------------- * Function: print_dataset_metadata * @@ -1397,7 +1545,7 @@ print_dset_metadata(const iter_t *iter) return 0; } /* print_dset_metadata() */ - + /*------------------------------------------------------------------------- * Function: print_dset_dtype_meta * @@ -1438,7 +1586,7 @@ print_dset_dtype_meta(const iter_t *iter) return 0; } /* print_dset_dtype_meta() */ - + /*------------------------------------------------------------------------- * Function: print_attr_info * @@ -1487,7 +1635,7 @@ print_attr_info(const iter_t *iter) return 0; } /* print_attr_info() */ - + /*------------------------------------------------------------------------- * Function: print_freespace_info * @@ -1537,7 +1685,7 @@ print_freespace_info(const iter_t *iter) return 0; } /* print_freespace_info() */ - + /*------------------------------------------------------------------------- * Function: print_storage_summary * @@ -1601,7 +1749,7 @@ print_storage_summary(const iter_t *iter) return 0; } /* print_storage_summary() */ - + /*------------------------------------------------------------------------- * Function: print_file_statistics * @@ -1648,7 +1796,7 @@ print_file_statistics(const iter_t *iter) if(display_summary) print_storage_summary(iter); } /* print_file_statistics() */ - + /*------------------------------------------------------------------------- * Function: print_object_statistics * @@ -1671,7 +1819,7 @@ print_object_statistics(const char *name) printf("Object name %s\n", name); } /* print_object_statistics() */ - + /*------------------------------------------------------------------------- * Function: print_statistics * @@ -1697,7 +1845,7 @@ print_statistics(const char *name, const iter_t *iter) print_file_statistics(iter); } /* print_statistics() */ - + /*------------------------------------------------------------------------- * Function: main * @@ -1718,6 +1866,7 @@ main(int argc, const char *argv[]) void *edata; void *tools_edata; struct handler_t *hand = NULL; + hid_t fapl_id = H5P_DEFAULT; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -1738,6 +1887,45 @@ main(int argc, const char *argv[]) if(parse_command_line(argc, argv, &hand) < 0) goto done; + /* if drivername is not null, probably need to set the fapl */ + if (HDstrcmp(drivername, "")) { + void *conf_fa = NULL; + + if (!HDstrcmp(drivername, "ros3")) { +#ifndef H5_HAVE_ROS3_VFD + error_msg("Read-Only S3 VFD not enabled.\n\n"); + goto done; +#else + conf_fa = (void *)&ros3_fa; +#endif /* H5_HAVE_ROS3_VFD */ + + } else if (!HDstrcmp(drivername, "hdfs")) { +#ifndef H5_HAVE_LIBHDFS + error_msg("HDFS VFD not enabled.\n\n"); + goto done; +#else + conf_fa = (void *)&hdfs_fa; +#endif /* H5_HAVE_LIBHDFS */ + } + + if (conf_fa != NULL) { + HDassert(fapl_id == H5P_DEFAULT); + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if (fapl_id < 0) { + error_msg("Unable to create fapl entry\n"); + goto done; + } + if (1 > h5tools_set_configured_fapl( + fapl_id, + drivername, + conf_fa)) + { + error_msg("Unable to set fapl\n"); + goto done; + } + } + } /* drivername set */ + fname = argv[opt_ind]; if(enable_error_stack > 0) { @@ -1752,7 +1940,7 @@ main(int argc, const char *argv[]) printf("Filename: %s\n", fname); - fid = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT); + fid = H5Fopen(fname, H5F_ACC_RDONLY, fapl_id); if(fid < 0) { error_msg("unable to open file \"%s\"\n", fname); h5tools_setstatus(EXIT_FAILURE); @@ -1833,6 +2021,13 @@ done: /* Free iter structure */ iter_free(&iter); + if (fapl_id != H5P_DEFAULT) { + if (0 < H5Pclose(fapl_id)) { + error_msg("unable to close fapl entry\n"); + h5tools_setstatus(EXIT_FAILURE); + } + } + if(fid >= 0 && H5Fclose(fid) < 0) { error_msg("unable to close file \"%s\"\n", fname); h5tools_setstatus(EXIT_FAILURE); diff --git a/tools/test/h5stat/testfiles/h5stat_help1.ddl b/tools/test/h5stat/testfiles/h5stat_help1.ddl index 01e39af..2ba7772 100644 --- a/tools/test/h5stat/testfiles/h5stat_help1.ddl +++ b/tools/test/h5stat/testfiles/h5stat_help1.ddl @@ -23,3 +23,13 @@ Usage: h5stat [OPTIONS] file -s, --freespace Print free space information -S, --summary Print summary of file space information --enable-error-stack Prints messages from the HDF5 error stack as they occur + --s3-cred= Access file on S3, using provided credential + :: (region,id,key) + If == "(,,)", no authentication is used. + --hdfs-attrs= Access a file on HDFS with given configuration + attributes. + :: (,, + ,, + ) + If an attribute is empty, a default value will be + used. diff --git a/tools/test/h5stat/testfiles/h5stat_help2.ddl b/tools/test/h5stat/testfiles/h5stat_help2.ddl index 01e39af..2ba7772 100644 --- a/tools/test/h5stat/testfiles/h5stat_help2.ddl +++ b/tools/test/h5stat/testfiles/h5stat_help2.ddl @@ -23,3 +23,13 @@ Usage: h5stat [OPTIONS] file -s, --freespace Print free space information -S, --summary Print summary of file space information --enable-error-stack Prints messages from the HDF5 error stack as they occur + --s3-cred= Access file on S3, using provided credential + :: (region,id,key) + If == "(,,)", no authentication is used. + --hdfs-attrs= Access a file on HDFS with given configuration + attributes. + :: (,, + ,, + ) + If an attribute is empty, a default value will be + used. diff --git a/tools/test/h5stat/testfiles/h5stat_nofile.ddl b/tools/test/h5stat/testfiles/h5stat_nofile.ddl index 01e39af..2ba7772 100644 --- a/tools/test/h5stat/testfiles/h5stat_nofile.ddl +++ b/tools/test/h5stat/testfiles/h5stat_nofile.ddl @@ -23,3 +23,13 @@ Usage: h5stat [OPTIONS] file -s, --freespace Print free space information -S, --summary Print summary of file space information --enable-error-stack Prints messages from the HDF5 error stack as they occur + --s3-cred= Access file on S3, using provided credential + :: (region,id,key) + If == "(,,)", no authentication is used. + --hdfs-attrs= Access a file on HDFS with given configuration + attributes. + :: (,, + ,, + ) + If an attribute is empty, a default value will be + used. diff --git a/tools/testfiles/h5dump-help.txt b/tools/testfiles/h5dump-help.txt index 19de76f..95dfc3b 100644 --- a/tools/testfiles/h5dump-help.txt +++ b/tools/testfiles/h5dump-help.txt @@ -12,6 +12,16 @@ usage: h5dump [OPTIONS] files -b B, --binary=B Binary file output, of form B -O F, --ddl=F Output ddl text into file F Use blank(empty) filename F to suppress ddl display + --s3-cred= Supply S3 authentication information to "ros3" vfd. + :: "(,,)" + If absent or -> "(,,)", no authentication. + Has no effect is filedriver is not `ros3'. + --hdfs-attrs= Supply configuration information for HDFS file access. + For use with "--filedriver=hdfs" + :: (,, + ,, + ) + Any absent attribute will use a default value. --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/help-1.ls b/tools/testfiles/help-1.ls index 491f696..396bed3 100644 --- a/tools/testfiles/help-1.ls +++ b/tools/testfiles/help-1.ls @@ -37,6 +37,15 @@ usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...] -V, --version Print version number and exit --vfd=DRIVER Use the specified virtual file driver -x, --hexdump Show raw data in hexadecimal format + --s3-cred=C Supply S3 authentication information to "ros3" vfd. + Accepts tuple of "(,,)". + If absent or C->"(,,)", defaults to no-authentication. + Has no effect if vfd flag not set to "ros3". + --hdfs-attrs=A Supply configuration information to Hadoop VFD. + Accepts tuple of (,, + ...,,) + If absent or A == '(,,,,)', all default values are used. + Has no effect if vfd flag is not 'hdfs'. file/OBJECT Each object consists of an HDF5 file name optionally followed by a diff --git a/tools/testfiles/help-2.ls b/tools/testfiles/help-2.ls index 491f696..396bed3 100644 --- a/tools/testfiles/help-2.ls +++ b/tools/testfiles/help-2.ls @@ -37,6 +37,15 @@ usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...] -V, --version Print version number and exit --vfd=DRIVER Use the specified virtual file driver -x, --hexdump Show raw data in hexadecimal format + --s3-cred=C Supply S3 authentication information to "ros3" vfd. + Accepts tuple of "(,,)". + If absent or C->"(,,)", defaults to no-authentication. + Has no effect if vfd flag not set to "ros3". + --hdfs-attrs=A Supply configuration information to Hadoop VFD. + Accepts tuple of (,, + ...,,) + If absent or A == '(,,,,)', all default values are used. + Has no effect if vfd flag is not 'hdfs'. file/OBJECT Each object consists of an HDF5 file name optionally followed by a diff --git a/tools/testfiles/help-3.ls b/tools/testfiles/help-3.ls index 491f696..396bed3 100644 --- a/tools/testfiles/help-3.ls +++ b/tools/testfiles/help-3.ls @@ -37,6 +37,15 @@ usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...] -V, --version Print version number and exit --vfd=DRIVER Use the specified virtual file driver -x, --hexdump Show raw data in hexadecimal format + --s3-cred=C Supply S3 authentication information to "ros3" vfd. + Accepts tuple of "(,,)". + If absent or C->"(,,)", defaults to no-authentication. + Has no effect if vfd flag not set to "ros3". + --hdfs-attrs=A Supply configuration information to Hadoop VFD. + Accepts tuple of (,, + ...,,) + If absent or A == '(,,,,)', all default values are used. + Has no effect if vfd flag is not 'hdfs'. file/OBJECT Each object consists of an HDF5 file name optionally followed by a diff --git a/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl b/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl index 19de76f..95dfc3b 100644 --- a/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl +++ b/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl @@ -12,6 +12,16 @@ usage: h5dump [OPTIONS] files -b B, --binary=B Binary file output, of form B -O F, --ddl=F Output ddl text into file F Use blank(empty) filename F to suppress ddl display + --s3-cred= Supply S3 authentication information to "ros3" vfd. + :: "(,,)" + If absent or -> "(,,)", no authentication. + Has no effect is filedriver is not `ros3'. + --hdfs-attrs= Supply configuration information for HDFS file access. + For use with "--filedriver=hdfs" + :: (,, + ,, + ) + Any absent attribute will use a default value. --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsIncomplete.ddl b/tools/testfiles/pbits/tpbitsIncomplete.ddl index 19de76f..95dfc3b 100644 --- a/tools/testfiles/pbits/tpbitsIncomplete.ddl +++ b/tools/testfiles/pbits/tpbitsIncomplete.ddl @@ -12,6 +12,16 @@ usage: h5dump [OPTIONS] files -b B, --binary=B Binary file output, of form B -O F, --ddl=F Output ddl text into file F Use blank(empty) filename F to suppress ddl display + --s3-cred= Supply S3 authentication information to "ros3" vfd. + :: "(,,)" + If absent or -> "(,,)", no authentication. + Has no effect is filedriver is not `ros3'. + --hdfs-attrs= Supply configuration information for HDFS file access. + For use with "--filedriver=hdfs" + :: (,, + ,, + ) + Any absent attribute will use a default value. --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsLengthExceeded.ddl b/tools/testfiles/pbits/tpbitsLengthExceeded.ddl index 19de76f..95dfc3b 100644 --- a/tools/testfiles/pbits/tpbitsLengthExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsLengthExceeded.ddl @@ -12,6 +12,16 @@ usage: h5dump [OPTIONS] files -b B, --binary=B Binary file output, of form B -O F, --ddl=F Output ddl text into file F Use blank(empty) filename F to suppress ddl display + --s3-cred= Supply S3 authentication information to "ros3" vfd. + :: "(,,)" + If absent or -> "(,,)", no authentication. + Has no effect is filedriver is not `ros3'. + --hdfs-attrs= Supply configuration information for HDFS file access. + For use with "--filedriver=hdfs" + :: (,, + ,, + ) + Any absent attribute will use a default value. --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsLengthPositive.ddl b/tools/testfiles/pbits/tpbitsLengthPositive.ddl index 19de76f..95dfc3b 100644 --- a/tools/testfiles/pbits/tpbitsLengthPositive.ddl +++ b/tools/testfiles/pbits/tpbitsLengthPositive.ddl @@ -12,6 +12,16 @@ usage: h5dump [OPTIONS] files -b B, --binary=B Binary file output, of form B -O F, --ddl=F Output ddl text into file F Use blank(empty) filename F to suppress ddl display + --s3-cred= Supply S3 authentication information to "ros3" vfd. + :: "(,,)" + If absent or -> "(,,)", no authentication. + Has no effect is filedriver is not `ros3'. + --hdfs-attrs= Supply configuration information for HDFS file access. + For use with "--filedriver=hdfs" + :: (,, + ,, + ) + Any absent attribute will use a default value. --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsMaxExceeded.ddl b/tools/testfiles/pbits/tpbitsMaxExceeded.ddl index 19de76f..95dfc3b 100644 --- a/tools/testfiles/pbits/tpbitsMaxExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsMaxExceeded.ddl @@ -12,6 +12,16 @@ usage: h5dump [OPTIONS] files -b B, --binary=B Binary file output, of form B -O F, --ddl=F Output ddl text into file F Use blank(empty) filename F to suppress ddl display + --s3-cred= Supply S3 authentication information to "ros3" vfd. + :: "(,,)" + If absent or -> "(,,)", no authentication. + Has no effect is filedriver is not `ros3'. + --hdfs-attrs= Supply configuration information for HDFS file access. + For use with "--filedriver=hdfs" + :: (,, + ,, + ) + Any absent attribute will use a default value. --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl b/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl index 19de76f..95dfc3b 100644 --- a/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl @@ -12,6 +12,16 @@ usage: h5dump [OPTIONS] files -b B, --binary=B Binary file output, of form B -O F, --ddl=F Output ddl text into file F Use blank(empty) filename F to suppress ddl display + --s3-cred= Supply S3 authentication information to "ros3" vfd. + :: "(,,)" + If absent or -> "(,,)", no authentication. + Has no effect is filedriver is not `ros3'. + --hdfs-attrs= Supply configuration information for HDFS file access. + For use with "--filedriver=hdfs" + :: (,, + ,, + ) + Any absent attribute will use a default value. --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsOffsetNegative.ddl b/tools/testfiles/pbits/tpbitsOffsetNegative.ddl index 19de76f..95dfc3b 100644 --- a/tools/testfiles/pbits/tpbitsOffsetNegative.ddl +++ b/tools/testfiles/pbits/tpbitsOffsetNegative.ddl @@ -12,6 +12,16 @@ usage: h5dump [OPTIONS] files -b B, --binary=B Binary file output, of form B -O F, --ddl=F Output ddl text into file F Use blank(empty) filename F to suppress ddl display + --s3-cred= Supply S3 authentication information to "ros3" vfd. + :: "(,,)" + If absent or -> "(,,)", no authentication. + Has no effect is filedriver is not `ros3'. + --hdfs-attrs= Supply configuration information for HDFS file access. + For use with "--filedriver=hdfs" + :: (,, + ,, + ) + Any absent attribute will use a default value. --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/textlinksrc-nodangle-1.ls b/tools/testfiles/textlinksrc-nodangle-1.ls index 491f696..396bed3 100644 --- a/tools/testfiles/textlinksrc-nodangle-1.ls +++ b/tools/testfiles/textlinksrc-nodangle-1.ls @@ -37,6 +37,15 @@ usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...] -V, --version Print version number and exit --vfd=DRIVER Use the specified virtual file driver -x, --hexdump Show raw data in hexadecimal format + --s3-cred=C Supply S3 authentication information to "ros3" vfd. + Accepts tuple of "(,,)". + If absent or C->"(,,)", defaults to no-authentication. + Has no effect if vfd flag not set to "ros3". + --hdfs-attrs=A Supply configuration information to Hadoop VFD. + Accepts tuple of (,, + ...,,) + If absent or A == '(,,,,)', all default values are used. + Has no effect if vfd flag is not 'hdfs'. file/OBJECT Each object consists of an HDF5 file name optionally followed by a diff --git a/tools/testfiles/tgroup-1.ls b/tools/testfiles/tgroup-1.ls index 491f696..396bed3 100644 --- a/tools/testfiles/tgroup-1.ls +++ b/tools/testfiles/tgroup-1.ls @@ -37,6 +37,15 @@ usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...] -V, --version Print version number and exit --vfd=DRIVER Use the specified virtual file driver -x, --hexdump Show raw data in hexadecimal format + --s3-cred=C Supply S3 authentication information to "ros3" vfd. + Accepts tuple of "(,,)". + If absent or C->"(,,)", defaults to no-authentication. + Has no effect if vfd flag not set to "ros3". + --hdfs-attrs=A Supply configuration information to Hadoop VFD. + Accepts tuple of (,, + ...,,) + If absent or A == '(,,,,)', all default values are used. + Has no effect if vfd flag is not 'hdfs'. file/OBJECT Each object consists of an HDF5 file name optionally followed by a -- cgit v0.12 From 094f14ef3857a47deb15bdfe45a1d4fe26655a6a Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Fri, 26 Jul 2019 11:56:03 -0500 Subject: Add HD to string functions. Switched strtoul to strtoumax in H5FDs3comms.c. Removed unused functions and variables in s3 and hdfs TestH5Pfapl*.java. Update Copyright headers. --- config/cmake/ConfigureChecks.cmake | 2 +- java/examples/groups/JavaGroupExample.sh.in | 2 - java/test/TestH5Pfaplhdfs.java | 212 ----- java/test/TestH5Pfapls3.java | 212 ----- src/H5FDros3.c | 34 +- src/H5FDros3.h | 18 +- src/H5FDs3comms.c | 42 +- src/H5FDs3comms.h | 17 +- test/hdfs.c | 18 +- test/ros3.c | 18 +- test/s3comms.c | 18 +- tools/libtest/Makefile.am | 2 +- tools/libtest/h5tools_test_utils.c | 1295 ++++++++++++++++++++++++++ tools/libtest/h5tools_utils.c | 1296 --------------------------- 14 files changed, 1382 insertions(+), 1804 deletions(-) create mode 100644 tools/libtest/h5tools_test_utils.c delete mode 100644 tools/libtest/h5tools_utils.c diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index f295a1c..cb1eb48 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -155,7 +155,7 @@ if (NOT WINDOWS) endif () #----------------------------------------------------------------------------- -# Check if ROS3 driver works +# Check if ROS3 driver can be built #----------------------------------------------------------------------------- option (HDF5_ENABLE_ROS3_VFD "Build the ROS3 Virtual File Driver" OFF) if (HDF5_ENABLE_ROS3_VFD) diff --git a/java/examples/groups/JavaGroupExample.sh.in b/java/examples/groups/JavaGroupExample.sh.in index 3ba512a..9d4673f 100644 --- a/java/examples/groups/JavaGroupExample.sh.in +++ b/java/examples/groups/JavaGroupExample.sh.in @@ -64,8 +64,6 @@ $HDFTEST_HOME/h5ex_g_iterate.h5 $HDFTEST_HOME/h5ex_g_visit.h5 " LIST_DATA_FILES=" -$HDFTEST_HOME/h5ex_g_iterate.h5 -$HDFTEST_HOME/h5ex_g_visit.h5 $HDFTEST_HOME/../testfiles/examples.groups.H5Ex_G_Create.txt $HDFTEST_HOME/../testfiles/examples.groups.H5Ex_G_Iterate.txt $HDFTEST_HOME/../testfiles/examples.groups.H5Ex_G_Compact.txt diff --git a/java/test/TestH5Pfaplhdfs.java b/java/test/TestH5Pfaplhdfs.java index 2b0a808..30d326e 100644 --- a/java/test/TestH5Pfaplhdfs.java +++ b/java/test/TestH5Pfaplhdfs.java @@ -41,228 +41,16 @@ import org.junit.rules.TestName; public class TestH5Pfaplhdfs { @Rule public TestName testname = new TestName(); - private static final String H5_FILE = "testPf.h5"; - private static final String H5_LOG_FILE = "testPf.log"; - private static final String H5_FAMILY_FILE = "testPf%05d"; - private static final String H5_MULTI_FILE = "testPfmulti"; - private static char MULTI_LETTERS[] = {'X','s','b','r','g','l','o'}; - private static final int DIM_X = 4; - private static final int DIM_Y = 6; - private static final int DIMF_X = 12; - private static final int DIMF_Y = 18; long H5fid = -1; long H5dsid = -1; long H5did = -1; long H5Fdsid = -1; long H5Fdid = -1; - long[] H5dims = { DIM_X, DIM_Y }; long fapl_id = -1; long plapl_id = -1; long dapl_id = -1; long plist_id = -1; long btplist_id = -1; - long[] H5Fdims = { DIMF_X, DIMF_Y }; - double windchillF[][] = - {{36.0, 31.0, 25.0, 19.0, 13.0, 7.0, 1.0, -5.0, -11.0, -16.0, -22.0, -28.0, -34.0, -40.0, -46.0, -52.0, -57.0, -63.0}, - {34.0, 27.0, 21.0, 15.0, 9.0, 3.0, -4.0, -10.0, -16.0, -22.0, -28.0, -35.0, -41.0, -47.0, -53.0, -59.0, -66.0, -72.0}, - {32.0, 25.0, 19.0, 13.0, 6.0, 0.0, -7.0, -13.0, -19.0, -26.0, -32.0, -39.0, -45.0, -51.0, -58.0, -64.0, -71.0, -77.0}, - {30.0, 24.0, 17.0, 11.0, 4.0, -2.0, -9.0, -15.0, -22.0, -29.0, -35.0, -42.0, -48.0, -55.0, -61.0, -68.0, -74.0, -81.0}, - {29.0, 23.0, 16.0, 9.0, 3.0, -4.0, -11.0, -17.0, -24.0, -31.0, -37.0, -44.0, -51.0, -58.0, -64.0, -71.0, -78.0, -84.0}, - {28.0, 22.0, 15.0, 8.0, 1.0, -5.0, -12.0, -19.0, -26.0, -33.0, -39.0, -46.0, -53.0, -60.0, -67.0, -73.0, -80.0, -87.0}, - {28.0, 21.0, 14.0, 7.0, 0.0, -7.0, -14.0, -21.0, -27.0, -34.0, -41.0, -48.0, -55.0, -62.0, -69.0, -76.0, -82.0, -89.0}, - {27.0, 20.0, 13.0, 6.0, -1.0, -8.0, -15.0, -22.0, -29.0, -36.0, -43.0, -50.0, -57.0, -64.0, -71.0, -78.0, -84.0, -91.0}, - {26.0, 19.0, 12.0, 5.0, -2.0, -9.0, -16.0, -23.0, -30.0, -37.0, -44.0, -51.0, -58.0, -65.0, -72.0, -79.0, -86.0, -93.0}, - {26.0, 19.0, 12.0, 4.0, -3.0, -10.0, -17.0, -24.0, -31.0, -38.0, -45.0, -52.0, -60.0, -67.0, -74.0, -81.0, -88.0, -95.0}, - {25.0, 18.0, 11.0, 4.0, -3.0, -11.0, -18.0, -25.0, -32.0, -39.0, -46.0, -54.0, -61.0, -68.0, -75.0, -82.0, -89.0, -97.0}, - {25.0, 17.0, 10.0, 3.0, -4.0, -11.0, -19.0, -26.0, -33.0, -40.0, -48.0, -55.0, -62.0, -69.0, -76.0, -84.0, -91.0, -98.0} - }; - - private final void _deleteFile(String filename) { - File file = null; - try { - file = new File(filename); - } - catch (Throwable err) {} - - if (file.exists()) { - try {file.delete();} catch (SecurityException e) {} - } - } - - private final void _deleteLogFile() { - File file = null; - try { - file = new File(H5_LOG_FILE); - } - catch (Throwable err) {} - - if (file.exists()) { - try {file.delete();} catch (SecurityException e) {} - } - } - - private final void _deleteFamilyFile() { - File file = null; - for(int indx = 0; ;indx++) { - java.text.DecimalFormat myFormat = new java.text.DecimalFormat("00000"); - try { - file = new File("test"+myFormat.format(new Integer(indx))+".h5"); - } - catch (Throwable err) {} - - if (file.exists()) { - try {file.delete();} catch (SecurityException e) {} - } - else - return; - } - } - - private final void _deleteMultiFile() { - File file = null; - for(int indx = 1;indx<7;indx++) { - try { - file = new File(H5_MULTI_FILE+"-"+MULTI_LETTERS[indx]+".h5"); - } - catch (Throwable err) {} - - if (file.exists()) { - try {file.delete();} catch (SecurityException e) {} - } - } - } - - private final long _createDataset(long fid, long dsid, String name, long dapl) { - long did = -1; - try { - did = H5.H5Dcreate(fid, name, HDF5Constants.H5T_STD_I32BE, dsid, - HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, dapl); - } - catch (Throwable err) { - err.printStackTrace(); - fail("H5.H5Dcreate: " + err); - } - assertTrue("TestH5Pfapl._createDataset: ", did > 0); - - return did; - } - - private final void _createFloatDataset() { - try { - H5Fdsid = H5.H5Screate_simple(2, H5Fdims, null); - H5Fdid = H5.H5Dcreate(H5fid, "dsfloat", HDF5Constants.H5T_NATIVE_FLOAT, H5Fdsid, - HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); - } - catch (Throwable err) { - err.printStackTrace(); - fail("H5.H5Dcreate: " + err); - } - assertTrue("TestH5Pfapl._createFloatDataset: ", H5Fdid > 0); - - try { - H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); - } - catch (Throwable err) { - err.printStackTrace(); - } - } - - private final void _createH5multiFileDS() { - try { - H5did = _createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT); - } - catch (Throwable err) { - err.printStackTrace(); - fail("TestH5Pfapl.createH5file: " + err); - } - assertTrue("TestH5Pfapl.createH5file: _createDataset: ", H5did > 0); - - try { - H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); - } - catch (Throwable err) { - err.printStackTrace(); - } - } - - private final void _createH5File(long fapl) { - try { - H5fid = H5.H5Fcreate(H5_FILE, HDF5Constants.H5F_ACC_TRUNC, - HDF5Constants.H5P_DEFAULT, fapl); - H5dsid = H5.H5Screate_simple(2, H5dims, null); - H5did = _createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT); - } - catch (Throwable err) { - err.printStackTrace(); - fail("TestH5Pfapl.createH5file: " + err); - } - assertTrue("TestH5Pfapl.createH5file: H5.H5Fcreate: ", H5fid > 0); - assertTrue("TestH5Pfapl.createH5file: H5.H5Screate_simple: ", H5dsid > 0); - assertTrue("TestH5Pfapl.createH5file: _createDataset: ", H5did > 0); - - try { - H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); - } - catch (Throwable err) { - err.printStackTrace(); - } - } - - private final void _createH5familyFile(long fapl) { - try { - H5fid = H5.H5Fcreate(H5_FAMILY_FILE+".h5", HDF5Constants.H5F_ACC_TRUNC, - HDF5Constants.H5P_DEFAULT, fapl); - H5dsid = H5.H5Screate_simple(2, H5dims, null); - H5did = _createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT); - } - catch (Throwable err) { - err.printStackTrace(); - fail("TestH5Pfapl.createH5file: " + err); - } - assertTrue("TestH5Pfapl.createH5file: H5.H5Fcreate: ", H5fid > 0); - assertTrue("TestH5Pfapl.createH5file: H5.H5Screate_simple: ", H5dsid > 0); - assertTrue("TestH5Pfapl.createH5file: _createDataset: ", H5did > 0); - - try { - H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); - } - catch (Throwable err) { - err.printStackTrace(); - } - } - - private final void _createH5multiFile(long fapl) { - try { - H5fid = H5.H5Fcreate(H5_MULTI_FILE, HDF5Constants.H5F_ACC_TRUNC, - HDF5Constants.H5P_DEFAULT, fapl); - H5dsid = H5.H5Screate_simple(2, H5dims, null); - } - catch (Throwable err) { - err.printStackTrace(); - fail("TestH5Pfapl.createH5file: " + err); - } - assertTrue("TestH5Pfapl.createH5file: H5.H5Fcreate: ", H5fid > 0); - assertTrue("TestH5Pfapl.createH5file: H5.H5Screate_simple: ", H5dsid > 0); - - try { - H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); - } - catch (Throwable err) { - err.printStackTrace(); - } - } - - public void deleteH5file() { - _deleteFile(H5_FILE); - } - - public void deleteH5familyfile() { - _deleteFamilyFile(); - } - - public void deleteH5multifile() { - _deleteMultiFile(); - } @Before public void createFileAccess() diff --git a/java/test/TestH5Pfapls3.java b/java/test/TestH5Pfapls3.java index 3107bc8..00a2a73 100644 --- a/java/test/TestH5Pfapls3.java +++ b/java/test/TestH5Pfapls3.java @@ -41,228 +41,16 @@ import org.junit.rules.TestName; public class TestH5Pfapls3 { @Rule public TestName testname = new TestName(); - private static final String H5_FILE = "testPf.h5"; - private static final String H5_LOG_FILE = "testPf.log"; - private static final String H5_FAMILY_FILE = "testPf%05d"; - private static final String H5_MULTI_FILE = "testPfmulti"; - private static char MULTI_LETTERS[] = {'X','s','b','r','g','l','o'}; - private static final int DIM_X = 4; - private static final int DIM_Y = 6; - private static final int DIMF_X = 12; - private static final int DIMF_Y = 18; long H5fid = -1; long H5dsid = -1; long H5did = -1; long H5Fdsid = -1; long H5Fdid = -1; - long[] H5dims = { DIM_X, DIM_Y }; long fapl_id = -1; long plapl_id = -1; long dapl_id = -1; long plist_id = -1; long btplist_id = -1; - long[] H5Fdims = { DIMF_X, DIMF_Y }; - double windchillF[][] = - {{36.0, 31.0, 25.0, 19.0, 13.0, 7.0, 1.0, -5.0, -11.0, -16.0, -22.0, -28.0, -34.0, -40.0, -46.0, -52.0, -57.0, -63.0}, - {34.0, 27.0, 21.0, 15.0, 9.0, 3.0, -4.0, -10.0, -16.0, -22.0, -28.0, -35.0, -41.0, -47.0, -53.0, -59.0, -66.0, -72.0}, - {32.0, 25.0, 19.0, 13.0, 6.0, 0.0, -7.0, -13.0, -19.0, -26.0, -32.0, -39.0, -45.0, -51.0, -58.0, -64.0, -71.0, -77.0}, - {30.0, 24.0, 17.0, 11.0, 4.0, -2.0, -9.0, -15.0, -22.0, -29.0, -35.0, -42.0, -48.0, -55.0, -61.0, -68.0, -74.0, -81.0}, - {29.0, 23.0, 16.0, 9.0, 3.0, -4.0, -11.0, -17.0, -24.0, -31.0, -37.0, -44.0, -51.0, -58.0, -64.0, -71.0, -78.0, -84.0}, - {28.0, 22.0, 15.0, 8.0, 1.0, -5.0, -12.0, -19.0, -26.0, -33.0, -39.0, -46.0, -53.0, -60.0, -67.0, -73.0, -80.0, -87.0}, - {28.0, 21.0, 14.0, 7.0, 0.0, -7.0, -14.0, -21.0, -27.0, -34.0, -41.0, -48.0, -55.0, -62.0, -69.0, -76.0, -82.0, -89.0}, - {27.0, 20.0, 13.0, 6.0, -1.0, -8.0, -15.0, -22.0, -29.0, -36.0, -43.0, -50.0, -57.0, -64.0, -71.0, -78.0, -84.0, -91.0}, - {26.0, 19.0, 12.0, 5.0, -2.0, -9.0, -16.0, -23.0, -30.0, -37.0, -44.0, -51.0, -58.0, -65.0, -72.0, -79.0, -86.0, -93.0}, - {26.0, 19.0, 12.0, 4.0, -3.0, -10.0, -17.0, -24.0, -31.0, -38.0, -45.0, -52.0, -60.0, -67.0, -74.0, -81.0, -88.0, -95.0}, - {25.0, 18.0, 11.0, 4.0, -3.0, -11.0, -18.0, -25.0, -32.0, -39.0, -46.0, -54.0, -61.0, -68.0, -75.0, -82.0, -89.0, -97.0}, - {25.0, 17.0, 10.0, 3.0, -4.0, -11.0, -19.0, -26.0, -33.0, -40.0, -48.0, -55.0, -62.0, -69.0, -76.0, -84.0, -91.0, -98.0} - }; - - private final void _deleteFile(String filename) { - File file = null; - try { - file = new File(filename); - } - catch (Throwable err) {} - - if (file.exists()) { - try {file.delete();} catch (SecurityException e) {} - } - } - - private final void _deleteLogFile() { - File file = null; - try { - file = new File(H5_LOG_FILE); - } - catch (Throwable err) {} - - if (file.exists()) { - try {file.delete();} catch (SecurityException e) {} - } - } - - private final void _deleteFamilyFile() { - File file = null; - for(int indx = 0; ;indx++) { - java.text.DecimalFormat myFormat = new java.text.DecimalFormat("00000"); - try { - file = new File("test"+myFormat.format(new Integer(indx))+".h5"); - } - catch (Throwable err) {} - - if (file.exists()) { - try {file.delete();} catch (SecurityException e) {} - } - else - return; - } - } - - private final void _deleteMultiFile() { - File file = null; - for(int indx = 1;indx<7;indx++) { - try { - file = new File(H5_MULTI_FILE+"-"+MULTI_LETTERS[indx]+".h5"); - } - catch (Throwable err) {} - - if (file.exists()) { - try {file.delete();} catch (SecurityException e) {} - } - } - } - - private final long _createDataset(long fid, long dsid, String name, long dapl) { - long did = -1; - try { - did = H5.H5Dcreate(fid, name, HDF5Constants.H5T_STD_I32BE, dsid, - HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, dapl); - } - catch (Throwable err) { - err.printStackTrace(); - fail("H5.H5Dcreate: " + err); - } - assertTrue("TestH5Pfapl._createDataset: ", did > 0); - - return did; - } - - private final void _createFloatDataset() { - try { - H5Fdsid = H5.H5Screate_simple(2, H5Fdims, null); - H5Fdid = H5.H5Dcreate(H5fid, "dsfloat", HDF5Constants.H5T_NATIVE_FLOAT, H5Fdsid, - HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); - } - catch (Throwable err) { - err.printStackTrace(); - fail("H5.H5Dcreate: " + err); - } - assertTrue("TestH5Pfapl._createFloatDataset: ", H5Fdid > 0); - - try { - H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); - } - catch (Throwable err) { - err.printStackTrace(); - } - } - - private final void _createH5multiFileDS() { - try { - H5did = _createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT); - } - catch (Throwable err) { - err.printStackTrace(); - fail("TestH5Pfapl.createH5file: " + err); - } - assertTrue("TestH5Pfapl.createH5file: _createDataset: ", H5did > 0); - - try { - H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); - } - catch (Throwable err) { - err.printStackTrace(); - } - } - - private final void _createH5File(long fapl) { - try { - H5fid = H5.H5Fcreate(H5_FILE, HDF5Constants.H5F_ACC_TRUNC, - HDF5Constants.H5P_DEFAULT, fapl); - H5dsid = H5.H5Screate_simple(2, H5dims, null); - H5did = _createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT); - } - catch (Throwable err) { - err.printStackTrace(); - fail("TestH5Pfapl.createH5file: " + err); - } - assertTrue("TestH5Pfapl.createH5file: H5.H5Fcreate: ", H5fid > 0); - assertTrue("TestH5Pfapl.createH5file: H5.H5Screate_simple: ", H5dsid > 0); - assertTrue("TestH5Pfapl.createH5file: _createDataset: ", H5did > 0); - - try { - H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); - } - catch (Throwable err) { - err.printStackTrace(); - } - } - - private final void _createH5familyFile(long fapl) { - try { - H5fid = H5.H5Fcreate(H5_FAMILY_FILE+".h5", HDF5Constants.H5F_ACC_TRUNC, - HDF5Constants.H5P_DEFAULT, fapl); - H5dsid = H5.H5Screate_simple(2, H5dims, null); - H5did = _createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT); - } - catch (Throwable err) { - err.printStackTrace(); - fail("TestH5Pfapl.createH5file: " + err); - } - assertTrue("TestH5Pfapl.createH5file: H5.H5Fcreate: ", H5fid > 0); - assertTrue("TestH5Pfapl.createH5file: H5.H5Screate_simple: ", H5dsid > 0); - assertTrue("TestH5Pfapl.createH5file: _createDataset: ", H5did > 0); - - try { - H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); - } - catch (Throwable err) { - err.printStackTrace(); - } - } - - private final void _createH5multiFile(long fapl) { - try { - H5fid = H5.H5Fcreate(H5_MULTI_FILE, HDF5Constants.H5F_ACC_TRUNC, - HDF5Constants.H5P_DEFAULT, fapl); - H5dsid = H5.H5Screate_simple(2, H5dims, null); - } - catch (Throwable err) { - err.printStackTrace(); - fail("TestH5Pfapl.createH5file: " + err); - } - assertTrue("TestH5Pfapl.createH5file: H5.H5Fcreate: ", H5fid > 0); - assertTrue("TestH5Pfapl.createH5file: H5.H5Screate_simple: ", H5dsid > 0); - - try { - H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); - } - catch (Throwable err) { - err.printStackTrace(); - } - } - - public void deleteH5file() { - _deleteFile(H5_FILE); - } - - public void deleteH5familyfile() { - _deleteFamilyFile(); - } - - public void deleteH5multifile() { - _deleteMultiFile(); - } @Before public void createFileAccess() diff --git a/src/H5FDros3.c b/src/H5FDros3.c index 8bf0420..86642aa 100644 --- a/src/H5FDros3.c +++ b/src/H5FDros3.c @@ -1,18 +1,18 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Read-Only S3 Virtual File Driver (VFD) * - * Copyright (c) 2017-2018, The HDF Group. * - * * + * Copyright by The HDF Group. * * All rights reserved. * * * - * NOTICE: * - * All information contained herein is, and remains, the property of The HDF * - * Group. The intellectual and technical concepts contained herein are * - * proprietary to The HDF Group. Dissemination of this information or * - * reproduction of this material is strictly forbidden unless prior written * - * permission is obtained from The HDF Group. * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* + * Read-Only S3 Virtual File Driver (VFD) + * * Programmer: Jacob Smith * 2017-10-13 * @@ -1334,14 +1334,14 @@ H5FD_ros3_cmp(const H5FD_t *_f1, HDassert(purl2->host != NULL); /* URL: SCHEME */ - if (strcmp(purl1->scheme, purl2->scheme)) HGOTO_DONE(-1); + if (HDstrcmp(purl1->scheme, purl2->scheme)) HGOTO_DONE(-1); /* URL: HOST */ - if (strcmp(purl1->host, purl2->host)) HGOTO_DONE(-1); + if (HDstrcmp(purl1->host, purl2->host)) HGOTO_DONE(-1); /* URL: PORT */ if (purl1->port && purl2->port) { - if (strcmp(purl1->port, purl2->port)) HGOTO_DONE(-1); + if (HDstrcmp(purl1->port, purl2->port)) HGOTO_DONE(-1); } else if (purl1->port) { HGOTO_DONE(-1); } else if (purl2->port) { @@ -1350,7 +1350,7 @@ H5FD_ros3_cmp(const H5FD_t *_f1, /* URL: PATH */ if (purl1->path && purl2->path) { - if (strcmp(purl1->path, purl2->path)) HGOTO_DONE(-1); + if (HDstrcmp(purl1->path, purl2->path)) HGOTO_DONE(-1); } else if (purl1->path && !purl2->path) { HGOTO_DONE(-1); } else if (purl2->path && !purl1->path) { @@ -1359,7 +1359,7 @@ H5FD_ros3_cmp(const H5FD_t *_f1, /* URL: QUERY */ if (purl1->query && purl2->query) { - if (strcmp(purl1->query, purl2->query)) HGOTO_DONE(-1); + if (HDstrcmp(purl1->query, purl2->query)) HGOTO_DONE(-1); } else if (purl1->query && !purl2->query) { HGOTO_DONE(-1); } else if (purl2->query && !purl1->query) { @@ -1368,7 +1368,7 @@ H5FD_ros3_cmp(const H5FD_t *_f1, /* FAPL: AWS_REGION */ if (f1->fa.aws_region[0] != '\0' && f1->fa.aws_region[0] != '\0') { - if (strcmp(f1->fa.aws_region, f2->fa.aws_region)) HGOTO_DONE(-1); + if (HDstrcmp(f1->fa.aws_region, f2->fa.aws_region)) HGOTO_DONE(-1); } else if (f1->fa.aws_region[0] != '\0') { HGOTO_DONE(-1); } else if (f2->fa.aws_region[0] != '\0') { @@ -1377,7 +1377,7 @@ H5FD_ros3_cmp(const H5FD_t *_f1, /* FAPL: SECRET_ID */ if (f1->fa.secret_id[0] != '\0' && f1->fa.secret_id[0] != '\0') { - if (strcmp(f1->fa.secret_id, f2->fa.secret_id)) HGOTO_DONE(-1); + if (HDstrcmp(f1->fa.secret_id, f2->fa.secret_id)) HGOTO_DONE(-1); } else if (f1->fa.secret_id[0] != '\0') { HGOTO_DONE(-1); } else if (f2->fa.secret_id[0] != '\0') { @@ -1386,7 +1386,7 @@ H5FD_ros3_cmp(const H5FD_t *_f1, /* FAPL: SECRET_KEY */ if (f1->fa.secret_key[0] != '\0' && f1->fa.secret_key[0] != '\0') { - if (strcmp(f1->fa.secret_key, f2->fa.secret_key)) HGOTO_DONE(-1); + if (HDstrcmp(f1->fa.secret_key, f2->fa.secret_key)) HGOTO_DONE(-1); } else if (f1->fa.secret_key[0] != '\0') { HGOTO_DONE(-1); } else if (f2->fa.secret_key[0] != '\0') { diff --git a/src/H5FDros3.h b/src/H5FDros3.h index 49e757c..7dfc95b 100644 --- a/src/H5FDros3.h +++ b/src/H5FDros3.h @@ -1,18 +1,18 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Read-Only S3 Virtual File Driver (VFD) * - * Copyright (c) 2017-2018, The HDF Group. * - * * + * Copyright by The HDF Group. * * All rights reserved. * * * - * NOTICE: * - * All information contained herein is, and remains, the property of The HDF * - * Group. The intellectual and technical concepts contained herein are * - * proprietary to The HDF Group. Dissemination of this information or * - * reproduction of this material is strictly forbidden unless prior written * - * permission is obtained from The HDF Group. * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* + * Read-Only S3 Virtual File Driver (VFD) + * * Programmer: John Mainzer * 2017-10-10 * diff --git a/src/H5FDs3comms.c b/src/H5FDs3comms.c index 7caeacb..4c24866 100644 --- a/src/H5FDs3comms.c +++ b/src/H5FDs3comms.c @@ -1,18 +1,18 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Read-Only S3 Virtual File Driver (VFD) * - * Copyright (c) 2017-2018, The HDF Group. * - * * + * Copyright by The HDF Group. * * All rights reserved. * * * - * NOTICE: * - * All information contained herein is, and remains, the property of The HDF * - * Group. The intellectual and technical concepts contained herein are * - * proprietary to The HDF Group. Dissemination of this information or * - * reproduction of this material is strictly forbidden unless prior written * - * permission is obtained from The HDF Group. * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /***************************************************************************** + * Read-Only S3 Virtual File Driver (VFD) + * * Source for S3 Communications module * * ***NOT A FILE DRIVER*** @@ -1005,7 +1005,7 @@ herr_t H5FD_s3comms_s3r_getsize(s3r_t *handle) { #ifdef H5_HAVE_ROS3_VFD - unsigned long int content_length = 0; + uintmax_t content_length = 0; CURL *curlh = NULL; char *end = NULL; char *headerresponse = NULL; @@ -1135,9 +1135,14 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) */ *end = '\0'; - content_length = strtoul((const char *)start, + content_length = strtoumax((const char *)start, NULL, 0); + + if (UINTMAX_MAX > SIZE_MAX && content_length > SIZE_MAX) { + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "content_length overflows size_t\n"); + } + if (content_length == 0 || content_length == ULONG_MAX || errno == ERANGE) /* errno set by strtoul */ @@ -1156,7 +1161,7 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) if ( CURLE_OK != curl_easy_setopt(curlh, CURLOPT_NOBODY, - 0) ) + NULL) ) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while setting CURL option (CURLOPT_NOBODY). " @@ -1166,7 +1171,7 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) if ( CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HEADERDATA, - 0) ) + NULL) ) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while setting CURL option (CURLOPT_HEADERDATA). " @@ -2518,7 +2523,7 @@ done: * + internal error occurred. * + -1 :: unable to format profile label * + -2 :: profile name/label not found in file - * + -3 :: some other error + * + -3 :: some other error * * Programmer: Jacob Smith * 2018-02-27 @@ -2602,14 +2607,14 @@ H5FD__s3comms_load_aws_creds_from_file( "unable to format line prefix") /* found a matching name? */ - if (!strncmp(line_buffer, line_prefix, setting_name_len + 1)) { + if (!HDstrncmp(line_buffer, line_prefix, setting_name_len + 1)) { found_setting = 1; /* skip NULL destination buffer */ if (setting_pointers[setting_i] == NULL) break; - /* advance to end fo name in string */ + /* advance to end of name in string */ do { line_buffer++; } while (*line_buffer != 0 && *line_buffer != '='); @@ -2620,7 +2625,8 @@ H5FD__s3comms_load_aws_creds_from_file( line_buffer++; /* was pointing at '='; advance */ /* copy line buffer into out pointer */ - strcpy(setting_pointers[setting_i], (const char *)line_buffer); + HDstrncpy(setting_pointers[setting_i], (const char *)line_buffer, + HDstrlen(line_buffer)); /* "trim" tailing whitespace by replacing with null terminator*/ buffer_i = 0; @@ -2889,7 +2895,7 @@ H5FD_s3comms_parse_url(const char *str, * READ SCHEME * ***************/ - tmpstr = strchr(curstr, ':'); + tmpstr = HDstrchr(curstr, ':'); if (tmpstr == NULL) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid SCHEME construction: probably not URL"); diff --git a/src/H5FDs3comms.h b/src/H5FDs3comms.h index 0524c46..93a5a81 100644 --- a/src/H5FDs3comms.h +++ b/src/H5FDs3comms.h @@ -1,18 +1,17 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Read-Only S3 Virtual File Driver (VFD) * - * Copyright (c) 2017-2018, The HDF Group. * - * * + * Copyright by The HDF Group. * * All rights reserved. * * * - * NOTICE: * - * All information contained herein is, and remains, the property of The HDF * - * Group. The intellectual and technical concepts contained herein are * - * proprietary to The HDF Group. Dissemination of this information or * - * reproduction of this material is strictly forbidden unless prior written * - * permission is obtained from The HDF Group. * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /***************************************************************************** + * Read-Only S3 Virtual File Driver (VFD) * * This is the header for the S3 Communications module * diff --git a/test/hdfs.c b/test/hdfs.c index 11b9918..57dbac9 100644 --- a/test/hdfs.c +++ b/test/hdfs.c @@ -1,18 +1,18 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Read-Only HDFS Virtual File Driver (VFD) * - * Copyright (c) 2018, The HDF Group. * - * * + * Copyright by The HDF Group. * * All rights reserved. * * * - * NOTICE: * - * All information contained herein is, and remains, the property of The HDF * - * Group. The intellectual and technical concepts contained herein are * - * proprietary to The HDF Group. Dissemination of this information or * - * reproduction of this material is strictly forbidden unless prior written * - * permission is obtained from The HDF Group. * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* + * Read-Only HDFS Virtual File Driver (VFD) + * * Purpose: * * Verify behavior for Read-Only HDFS VFD. diff --git a/test/ros3.c b/test/ros3.c index 51c1a89..60d3932 100644 --- a/test/ros3.c +++ b/test/ros3.c @@ -1,18 +1,18 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Read-Only S3 Virtual File Driver (VFD) * - * Copyright (c) 2017-2018, The HDF Group. * - * * + * Copyright by The HDF Group. * * All rights reserved. * * * - * NOTICE: * - * All information contained herein is, and remains, the property of The HDF * - * Group. The intellectual and technical concepts contained herein are * - * proprietary to The HDF Group. Dissemination of this information or * - * reproduction of this material is strictly forbidden unless prior written * - * permission is obtained from The HDF Group. * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* + * Read-Only S3 Virtual File Driver (VFD) + * * Purpose: * * Verify behavior for Read-Only S3 VFD diff --git a/test/s3comms.c b/test/s3comms.c index 71d93c2..a797e04 100644 --- a/test/s3comms.c +++ b/test/s3comms.c @@ -1,18 +1,18 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Read-Only S3 Virtual File Driver (VFD) * - * Copyright (c) 2017-2018, The HDF Group. * - * * + * Copyright by The HDF Group. * * All rights reserved. * * * - * NOTICE: * - * All information contained herein is, and remains, the property of The HDF * - * Group. The intellectual and technical concepts contained herein are * - * proprietary to The HDF Group. Dissemination of this information or * - * reproduction of this material is strictly forbidden unless prior written * - * permission is obtained from The HDF Group. * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* + * Read-Only S3 Virtual File Driver (VFD) + * * Purpose: Unit tests for the S3 Communications (s3comms) module. * * Programmer: Jacob Smith diff --git a/tools/libtest/Makefile.am b/tools/libtest/Makefile.am index 5aa72b8..a93e25d 100644 --- a/tools/libtest/Makefile.am +++ b/tools/libtest/Makefile.am @@ -27,7 +27,7 @@ LDADD=$(LIBH5TOOLS) $(LIBHDF5) # main target -bin_PROGRAMS=h5tools_utils +bin_PROGRAMS=h5tools_test_utils # check_PROGRAMS=$(TEST_PROG) diff --git a/tools/libtest/h5tools_test_utils.c b/tools/libtest/h5tools_test_utils.c new file mode 100644 index 0000000..ac8e4c0 --- /dev/null +++ b/tools/libtest/h5tools_test_utils.c @@ -0,0 +1,1295 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: unit-test functionality of the routines in `tools/lib/h5tools_utils` + * + * Jacob Smith 2017-11-10 + */ + +#include "hdf5.h" +#include "H5private.h" +#include "h5tools_utils.h" +/* #include "h5test.h" */ /* linking failure */ + +#define UTIL_TEST_DEBUG 0 + +#ifndef _H5TEST_ + +#define AT() fprintf(stdout, " at %s:%d in %s()...\n", \ + __FILE__, __LINE__, FUNC); + +#define FAILED(msg) { \ + fprintf(stdout, "*FAILED*"); AT() \ + if (msg == NULL) { \ + fprintf(stdout,"(NULL)\n"); \ + } else { \ + fprintf(stdout, "%s\n", msg); \ + } \ + fflush(stdout); \ +} + +#define TESTING(msg) { \ + fprintf(stdout, "TESTING %-62s", (msg)); \ + fflush(stdout); \ +} + +#define PASSED() { \ + fprintf(stdout, " PASSED\n"); \ + fflush(stdout); \ +} + +#endif /* ifndef _H5TEST_ */ + +#ifndef __js_test__ + +#define __js_test__ 1L + +/***************************************************************************** + * + * FILE-LOCAL TESTING MACROS + * + * Purpose: + * + * 1. Upon test failure, goto-jump to single-location teardown in test + * function. E.g., `error:` (consistency with HDF corpus) or + * `failed:` (reflects purpose). + * >>> using "error", in part because `H5E_BEGIN_TRY` expects it. + * 2. Increase clarity and reduce overhead found with `TEST_ERROR`. + * e.g., "if(somefunction(arg, arg2) < 0) TEST_ERROR:" + * requires reading of entire line to know whether this if/call is + * part of the test setup, test operation, or a test unto itself. + * 3. Provide testing macros with optional user-supplied failure message; + * if not supplied (NULL), generate comparison output in the spirit of + * test-driven development. E.g., "expected 5 but was -3" + * User messages clarify test's purpose in code, encouraging description + * without relying on comments. + * 4. Configurable expected-actual order in generated comparison strings. + * Some prefer `VERIFY(expected, actual)`, others + * `VERIFY(actual, expected)`. Provide preprocessor ifdef switch + * to satifsy both parties, assuming one paradigm per test file. + * (One could #undef and redefine the flag through the file as desired, + * but _why_.) + * + * Provided as courtesy, per consideration for inclusion in the library + * proper. + * + * Macros: + * + * JSVERIFY_EXP_ACT - ifdef flag, configures comparison order + * FAIL_IF() - check condition + * FAIL_UNLESS() - check _not_ condition + * JSVERIFY() - long-int equality check; prints reason/comparison + * JSVERIFY_NOT() - long-int inequality check; prints + * JSVERIFY_STR() - string equality check; prints + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *****************************************************************************/ + + +/*---------------------------------------------------------------------------- + * + * ifdef flag: JSVERIFY_EXP_ACT + * + * JSVERIFY macros accept arguments as (EXPECTED, ACTUAL[, reason]) + * default, if this is undefined, is (ACTUAL, EXPECTED[, reason]) + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_EXP_ACT 1L + + +/*---------------------------------------------------------------------------- + * + * Macro: JSFAILED_AT() + * + * Purpose: + * + * Preface a test failure by printing "*FAILED*" and location to stdout + * Similar to `H5_FAILED(); AT();` from h5test.h + * + * *FAILED* at somefile.c:12 in function_name()... + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSFAILED_AT() { \ + HDprintf("*FAILED* at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: FAIL_IF() + * + * Purpose: + * + * Make tests more accessible and less cluttered than + * `if (thing == otherthing()) TEST_ERROR` + * paradigm. + * + * The following lines are roughly equivalent: + * + * `if (myfunc() < 0) TEST_ERROR;` (as seen elsewhere in HDF tests) + * `FAIL_IF(myfunc() < 0)` + * + * Prints a generic "FAILED AT" line to stdout and jumps to `error`, + * similar to `TEST_ERROR` in h5test.h + * + * Programmer: Jacob Smith + * 2017-10-23 + * + *---------------------------------------------------------------------------- + */ +#define FAIL_IF(condition) \ +if (condition) { \ + JSFAILED_AT() \ + goto error; \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: FAIL_UNLESS() + * + * Purpose: + * + * TEST_ERROR wrapper to reduce cognitive overhead from "negative tests", + * e.g., "a != b". + * + * Opposite of FAIL_IF; fails if the given condition is _not_ true. + * + * `FAIL_IF( 5 != my_op() )` + * is equivalent to + * `FAIL_UNLESS( 5 == my_op() )` + * However, `JSVERIFY(5, my_op(), "bad return")` may be even clearer. + * (see JSVERIFY) + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define FAIL_UNLESS(condition) \ +if (!(condition)) { \ + JSFAILED_AT() \ + goto error; \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: JSERR_LONG() + * + * Purpose: + * + * Print an failure message for long-int arguments. + * ERROR-AT printed first. + * If `reason` is given, it is printed on own line and newlined after + * else, prints "expected/actual" aligned on own lines. + * + * *FAILED* at myfile.c:488 in somefunc()... + * forest must be made of trees. + * + * or + * + * *FAILED* at myfile.c:488 in somefunc()... + * ! Expected 425 + * ! Actual 3 + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSERR_LONG(expected, actual, reason) { \ + JSFAILED_AT() \ + if (reason!= NULL) { \ + HDprintf("%s\n", (reason)); \ + } else { \ + HDprintf(" ! Expected %ld\n ! Actual %ld\n", \ + (long)(expected), (long)(actual)); \ + } \ +} + + +/*---------------------------------------------------------------------------- + * + * Macro: JSERR_STR() + * + * Purpose: + * + * Print an failure message for string arguments. + * ERROR-AT printed first. + * If `reason` is given, it is printed on own line and newlined after + * else, prints "expected/actual" aligned on own lines. + * + * *FAILED* at myfile.c:421 in myfunc()... + * Blue and Red strings don't match! + * + * or + * + * *FAILED* at myfile.c:421 in myfunc()... + * !!! Expected: + * this is my expected + * string + * !!! Actual: + * not what I expected at all + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSERR_STR(expected, actual, reason) { \ + JSFAILED_AT() \ + if ((reason) != NULL) { \ + HDprintf("%s\n", (reason)); \ + } else { \ + HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", \ + (expected), (actual)); \ + } \ +} + +#ifdef JSVERIFY_EXP_ACT + + +/*---------------------------------------------------------------------------- + * + * Macro: JSVERIFY() + * + * Purpose: + * + * Verify that two long integers are equal. + * If unequal, print failure message + * (with `reason`, if not NULL; expected/actual if NULL) + * and jump to `error` at end of function + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY(expected, actual, reason) \ +if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ +} /* JSVERIFY */ + + +/*---------------------------------------------------------------------------- + * + * Macro: JSVERIFY_NOT() + * + * Purpose: + * + * Verify that two long integers are _not_ equal. + * If equal, print failure message + * (with `reason`, if not NULL; expected/actual if NULL) + * and jump to `error` at end of function + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_NOT(expected, actual, reason) \ +if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ +} /* JSVERIFY_NOT */ + + +/*---------------------------------------------------------------------------- + * + * Macro: JSVERIFY_STR() + * + * Purpose: + * + * Verify that two strings are equal. + * If unequal, print failure message + * (with `reason`, if not NULL; expected/actual if NULL) + * and jump to `error` at end of function + * + * Programmer: Jacob Smith + * 2017-10-24 + * + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_STR(expected, actual, reason) \ +if (HDstrcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ +} /* JSVERIFY_STR */ + + +#else /* JSVERIFY_EXP_ACT not defined */ + /* Repeats macros above, but with actual/expected parameters reversed. */ + + +/*---------------------------------------------------------------------------- + * Macro: JSVERIFY() + * See: JSVERIFY documentation above. + * Programmer: Jacob Smith + * 2017-10-14 + *---------------------------------------------------------------------------- + */ +#define JSVERIFY(actual, expected, reason) \ +if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)); \ + goto error; \ +} /* JSVERIFY */ + + +/*---------------------------------------------------------------------------- + * Macro: JSVERIFY_NOT() + * See: JSVERIFY_NOT documentation above. + * Programmer: Jacob Smith + * 2017-10-14 + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_NOT(actual, expected, reason) \ +if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ +} /* JSVERIFY_NOT */ + + +/*---------------------------------------------------------------------------- + * Macro: JSVERIFY_STR() + * See: JSVERIFY_STR documentation above. + * Programmer: Jacob Smith + * 2017-10-14 + *---------------------------------------------------------------------------- + */ +#define JSVERIFY_STR(actual, expected, reason) \ +if (HDstrcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ +} /* JSVERIFY_STR */ + +#endif /* ifdef/else JSVERIFY_EXP_ACT */ + +#endif /* __js_test__ */ + +/* if > 0, be very verbose when performing tests */ +#define H5TOOLS_UTILS_TEST_DEBUG 0 + +/******************/ +/* TEST FUNCTIONS */ +/******************/ + + +/*---------------------------------------------------------------------------- + * + * Function: test_parse_tuple() + * + * Purpose: + * + * Provide unit tests and specification for the `parse_tuple()` function. + * + * Return: + * + * 0 Tests passed. + * 1 Tests failed. + * + * Programmer: Jacob Smith + * 2017-11-11 + * + * Changes: None. + * + *---------------------------------------------------------------------------- + */ +static unsigned +test_parse_tuple(void) +{ + /************************* + * TEST-LOCAL STRUCTURES * + *************************/ + + struct testcase { + const char *test_msg; /* info about test case */ + const char *in_str; /* input string */ + int sep; /* separator "character" */ + herr_t exp_ret; /* expected SUCCEED / FAIL */ + unsigned exp_nelems; /* expected number of elements */ + /* (no more than 7!) */ + const char *exp_elems[7]; /* list of elements (no more than 7!) */ + }; + + /****************** + * TEST VARIABLES * + ******************/ + + struct testcase cases[] = { + { "bad start", + "words(before)", + ';', + FAIL, + 0, + {NULL}, + }, + { "tuple not closed", + "(not ok", + ',', + FAIL, + 0, + {NULL}, + }, + { "empty tuple", + "()", + '-', + SUCCEED, + 1, + {""}, + }, + { "no separator", + "(stuff keeps on going)", + ',', + SUCCEED, + 1, + {"stuff keeps on going"}, + }, + { "4-ple, escaped seperator", + "(elem0,elem1,el\\,em2,elem3)", /* "el\,em" */ + ',', + SUCCEED, + 4, + {"elem0", "elem1", "el,em2", "elem3"}, + }, + { "5-ple, escaped escaped separator", + "(elem0,elem1,el\\\\,em2,elem3)", + ',', + SUCCEED, + 5, + {"elem0", "elem1", "el\\", "em2", "elem3"}, + }, + { "escaped non-comma separator", + "(5-2-7-2\\-6-2)", + '-', + SUCCEED, + 5, + {"5","2","7","2-6","2"}, + }, + { "embedded close-paren", + "(be;fo)re)", + ';', + SUCCEED, + 2, + {"be", "fo)re"}, + }, + { "embedded non-escaping backslash", + "(be;fo\\re)", + ';', + SUCCEED, + 2, + {"be", "fo\\re"}, + }, + { "double close-paren at end", + "(be;fore))", + ';', + SUCCEED, + 2, + {"be", "fore)"}, + }, + { "empty elements", + "(;a1;;a4;)", + ';', + SUCCEED, + 5, + {"", "a1", "", "a4", ""}, + }, + { "nested tuples with different separators", + "((4,e,a);(6,2,a))", + ';', + SUCCEED, + 2, + {"(4,e,a)","(6,2,a)"}, + }, + { "nested tuples with same separators", + "((4,e,a),(6,2,a))", + ',', + SUCCEED, + 6, + {"(4","e","a)","(6","2","a)"}, + }, + { "real-world use case", + "(us-east-2,AKIAIMC3D3XLYXLN5COA,ugs5aVVnLFCErO/8uW14iWE3K5AgXMpsMlWneO/+)", + ',', + SUCCEED, + 3, + {"us-east-2", + "AKIAIMC3D3XLYXLN5COA", + "ugs5aVVnLFCErO/8uW14iWE3K5AgXMpsMlWneO/+"}, + } + }; + struct testcase tc; + unsigned n_tests = 14; + unsigned i = 0; + unsigned count = 0; + unsigned elem_i = 0; + char **parsed = NULL; + char *cpy = NULL; + herr_t success = TRUE; + hbool_t show_progress = FALSE; + + + + TESTING("arbitrary-count tuple parsing"); + +#if H5TOOLS_UTILS_TEST_DEBUG > 0 + show_progress = TRUE; +#endif /* H5TOOLS_UTILS_TEST_DEBUG */ + + /********* + * TESTS * + *********/ + + for (i = 0; i < n_tests; i++) { + + /* SETUP + */ + HDassert(parsed == NULL); + HDassert(cpy == NULL); + tc = cases[i]; + if (show_progress == TRUE) { + printf("testing %d: %s...\n", i, tc.test_msg); + } + + /* VERIFY + */ + success = parse_tuple(tc.in_str, tc.sep, + &cpy, &count, &parsed); + + JSVERIFY( tc.exp_ret, success, "function returned incorrect value" ) + JSVERIFY( tc.exp_nelems, count, NULL ) + if (success == SUCCEED) { + FAIL_IF( parsed == NULL ) + for (elem_i = 0; elem_i < count; elem_i++) { + JSVERIFY_STR( tc.exp_elems[elem_i], parsed[elem_i], NULL ) + } + /* TEARDOWN */ + HDassert(parsed != NULL); + HDassert(cpy != NULL); + free(parsed); + parsed = NULL; + free(cpy); + cpy = NULL; + } else { + FAIL_IF( parsed != NULL ) + } /* if parse_tuple() == SUCCEED or no */ + + } /* for each testcase */ + + PASSED(); + return 0; + +error: + /*********** + * CLEANUP * + ***********/ + + if (parsed != NULL) free(parsed); + if (cpy != NULL) free(cpy); + + return 1; + +} /* test_parse_tuple */ + + +/*---------------------------------------------------------------------------- + * + * Function: test_populate_ros3_fa() + * + * Purpose: Verify behavior of `populate_ros3_fa()` + * + * Return: 0 if test passes + * 1 if failure + * + * Programmer: Jacob Smith + * 2017-11-13 + * + * Changes: None + * + *---------------------------------------------------------------------------- + */ +static unsigned +test_populate_ros3_fa(void) +{ +#ifdef H5_HAVE_ROS3_VFD + /************************* + * TEST-LOCAL STRUCTURES * + *************************/ + + /************************ + * TEST-LOCAL VARIABLES * + ************************/ + + hbool_t show_progress = FALSE; + int bad_version = 0xf87a; /* arbitrarily wrong version number */ +#endif /* H5_HAVE_ROS3_VFD */ + + TESTING("programmatic ros3 fapl population"); + +#ifndef H5_HAVE_ROS3_VFD + puts(" -SKIP-"); + puts(" Read-Only S3 VFD not enabled"); + fflush(stdout); + return 0; +#else +#if H5TOOLS_UTILS_TEST_DEBUG > 0 + show_progress = TRUE; +#endif /* H5TOOLS_UTILS_TEST_DEBUG */ + + HDassert(bad_version != H5FD__CURR_ROS3_FAPL_T_VERSION); + + /********* + * TESTS * + *********/ + + /* NULL fapl config pointer fails + */ + { + const char *values[] = {"x", "y", "z"}; + + if (show_progress) { HDprintf("NULL fapl pointer\n"); } + + JSVERIFY( 0, h5tools_populate_ros3_fapl(NULL, values), + "fapl pointer cannot be null" ) + } + + /* NULL values pointer yields default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, TRUE, "u", "v", "w"}; + + if (show_progress) { HDprintf("NULL values pointer\n"); } + + JSVERIFY( 1, h5tools_populate_ros3_fapl(&fa, NULL), + "NULL values pointer yields \"default\" fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* all-empty values + * yields default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, TRUE, "u", "v", "w"}; + const char *values[] = {"", "", ""}; + + if (show_progress) { HDprintf("all empty values\n"); } + + JSVERIFY( 1, h5tools_populate_ros3_fapl(&fa, values), + "empty values yields \"default\" fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* successfully set fapl with values + * excess value is ignored + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {"x", "y", "z", "a"}; + + if (show_progress) { HDprintf("successful full set\n"); } + + JSVERIFY( 1, h5tools_populate_ros3_fapl(&fa, values), + "four values" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( TRUE, fa.authenticate, NULL ) + JSVERIFY_STR( "x", fa.aws_region, NULL ) + JSVERIFY_STR( "y", fa.secret_id, NULL ) + JSVERIFY_STR( "z", fa.secret_key, NULL ) + } + + /* NULL region + * yeilds default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {NULL, "y", "z", NULL}; + + if (show_progress) { HDprintf("NULL region\n"); } + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* empty region + * yeilds default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {"", "y", "z", NULL}; + + if (show_progress) { HDprintf("empty region; non-empty id, key\n"); } + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* region overflow + * yeilds default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = { + "somewhere over the rainbow not too high " \ + "there is another rainbow bounding some darkened sky", + "y", + "z"}; + + if (show_progress) { HDprintf("region overflow\n"); } + + HDassert(HDstrlen(values[0]) > H5FD__ROS3_MAX_REGION_LEN); + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* NULL id + * yields default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {"x", NULL, "z", NULL}; + + if (show_progress) { HDprintf("NULL id\n"); } + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* empty id (non-empty region, key) + * yeilds default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {"x", "", "z", NULL}; + + if (show_progress) { HDprintf("empty id; non-empty region and key\n"); } + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* id overflow + * partial set: region + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = { + "x", + "Why is it necessary to solve the problem? " \ + "What benefits will you receive by solving the problem? " \ + "What is the unknown? " \ + "What is it you don't yet understand? " \ + "What is the information you have? " \ + "What isn't the problem? " \ + "Is the information insufficient, redundant, or contradictory? " \ + "Should you draw a diagram or figure of the problem? " \ + "What are the boundaries of the problem? " \ + "Can you separate the various parts of the problem?", + "z"}; + + if (show_progress) { HDprintf("id overflow\n"); } + + HDassert(HDstrlen(values[1]) > H5FD__ROS3_MAX_SECRET_ID_LEN); + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "x", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* NULL key + * yields default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {"x", "y", NULL, NULL}; + + if (show_progress) { HDprintf("NULL key\n"); } + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* empty key (non-empty region, id) + * yeilds authenticating fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {"x", "y", "", NULL}; + + if (show_progress) { HDprintf("empty key; non-empty region and id\n"); } + + JSVERIFY( 1, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( TRUE, fa.authenticate, NULL ) + JSVERIFY_STR( "x", fa.aws_region, NULL ) + JSVERIFY_STR( "y", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* empty key, region (non-empty id) + * yeilds default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {"", "y", "", NULL}; + + if (show_progress) { HDprintf("empty key and region; non-empty id\n"); } + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* empty key, id (non-empty region) + * yeilds default fapl + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = {"x", "", "", NULL}; + + if (show_progress) { HDprintf("empty key and id; non-empty region\n"); } + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "", fa.aws_region, NULL ) + JSVERIFY_STR( "", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* key overflow + * partial set: region, id + */ + { + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char *values[] = { + "x", + "y", + "Why is it necessary to solve the problem? " \ + "What benefits will you receive by solving the problem? " \ + "What is the unknown? " \ + "What is it you don't yet understand? " \ + "What is the information you have? " \ + "What isn't the problem? " \ + "Is the information insufficient, redundant, or contradictory? " \ + "Should you draw a diagram or figure of the problem? " \ + "What are the boundaries of the problem? " \ + "Can you separate the various parts of the problem?"}; + + if (show_progress) { HDprintf("key overflow\n"); } + + HDassert(HDstrlen(values[2]) > H5FD__ROS3_MAX_SECRET_KEY_LEN); + + JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), + "could not fill fapl" ) + JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) + JSVERIFY( FALSE, fa.authenticate, NULL ) + JSVERIFY_STR( "x", fa.aws_region, NULL ) + JSVERIFY_STR( "y", fa.secret_id, NULL ) + JSVERIFY_STR( "", fa.secret_key, NULL ) + } + + /* use case + */ + { + H5FD_ros3_fapl_t fa = {0, 0, "", "", ""}; + const char *values[] = { + "us-east-2", + "AKIAIMC3D3XLYXLN5COA", + "ugs5aVVnLFCErO/8uW14iWE3K5AgXMpsMlWneO/+" + }; + JSVERIFY( 1, + h5tools_populate_ros3_fapl(&fa, values), + "unable to set use case" ) + JSVERIFY( 1, fa.version, "version check" ) + JSVERIFY( 1, fa.authenticate, "should authenticate" ) + } + + PASSED(); + return 0; + +error : + /*********** + * CLEANUP * + ***********/ + + return 1; + +#endif /* H5_HAVE_ROS3_VFD */ + +} /* test_populate_ros3_fa */ + + +/*---------------------------------------------------------------------------- + * + * Function: test_set_configured_fapl() + * + * Purpose: Verify `h5tools_set_configured_fapl()` with ROS3 VFD + * + * Return: 0 if test passes + * 1 if failure + * + * Programmer: Jacob Smith + * 2018-07-12 + * + * Changes: None + * + *---------------------------------------------------------------------------- + */ +static unsigned +test_set_configured_fapl(void) +{ +#define UTIL_TEST_NOFAPL 1 +#define UTIL_TEST_DEFAULT 2 +#define UTIL_TEST_CREATE 3 + + /************************* + * TEST-LOCAL STRUCTURES * + *************************/ + typedef struct testcase { + const char message[88]; + int expected; + int fapl_choice; + const char vfdname[12]; + void *conf_fa; + } testcase; + + typedef struct other_fa_t { + int a; + int b; + int c; + } other_fa_t; + + /************************ + * TEST-LOCAL VARIABLES * + ************************/ + + hid_t fapl_id = -1; + other_fa_t wrong_fa = {0x432, 0xf82, 0x9093}; + H5FD_ros3_fapl_t ros3_anon_fa = {1, FALSE, "", "", ""}; + H5FD_ros3_fapl_t ros3_auth_fa = { + 1, /* fapl version */ + TRUE, /* authenticate */ + "us-east-1", /* aws region */ + "12345677890abcdef", /* simulate access key ID */ + "oiwnerwe9u0234nJw0-aoj+dsf", /* simulate secret key */ + }; + H5FD_hdfs_fapl_t hdfs_fa = { + 1, /* fapl version */ + "", /* namenode name */ + 0, /* namenode port */ + "", /* kerberos ticket cache */ + "", /* user name */ + 2048, /* stream buffer size */ + }; + unsigned n_cases = 7; /* number of common testcases */ + testcase cases[] = { + { "(common) should fail: no fapl id", + 0, + UTIL_TEST_NOFAPL, + "", + NULL, + }, + { "(common) should fail: no fapl id (with struct)", + 0, + UTIL_TEST_NOFAPL, + "", + &wrong_fa, + }, + { "(common) H5P_DEFAULT with no struct should succeed", + 1, + UTIL_TEST_DEFAULT, + "", + NULL, + }, + { "(common) H5P_DEFAULT with (ignored) struct should succeed", + 1, + UTIL_TEST_DEFAULT, + "", + &wrong_fa, + }, + { "(common) provided fapl entry should not fail", + 1, + UTIL_TEST_CREATE, + "", + NULL, + }, + { "(common) provided fapl entry should not fail; ignores struct", + 1, + UTIL_TEST_CREATE, + "", + &wrong_fa, + }, + { "(common) should fail: unrecoginzed vfd name", + 0, + UTIL_TEST_DEFAULT, + "unknown", + NULL, + }, + +#ifdef H5_HAVE_ROS3_VFD + /* WARNING: add number of ROS3 test cases after array definition + */ + { "(ROS3) should fail: no fapl id, no struct", + 0, + UTIL_TEST_NOFAPL, + "ros3", + NULL, + }, + { "(ROS3) should fail: no fapl id", + 0, + UTIL_TEST_NOFAPL, + "ros3", + &ros3_anon_fa, + }, + { "(ROS3) should fail: no struct", + 0, + UTIL_TEST_CREATE, + "ros3", + NULL, + }, + { "(ROS3) successful set", + 1, + UTIL_TEST_CREATE, + "ros3", + &ros3_anon_fa, + }, + { "(ROS3) should fail: attempt to set DEFAULT fapl", + 0, + UTIL_TEST_DEFAULT, + "ros3", + &ros3_anon_fa, + }, +#endif /* H5_HAVE_ROS3_VFD */ + +#ifdef H5_HAVE_LIBHDFS + /* WARNING: add number of HDFS test cases after array definition + */ + { "(HDFS) should fail: no fapl id, no struct", + 0, + UTIL_TEST_NOFAPL, + "hdfs", + NULL, + }, + { "(HDFS) should fail: no fapl id", + 0, + UTIL_TEST_NOFAPL, + "hdfs", + &hdfs_fa, + }, + { "(HDFS) should fail: no struct", + 0, + UTIL_TEST_CREATE, + "hdfs", + NULL, + }, + { "(HDFS) successful set", + 1, + UTIL_TEST_CREATE, + "hdfs", + &hdfs_fa, + }, + { "(HDFS) should fail: attempt to set DEFAULT fapl", + 0, + UTIL_TEST_DEFAULT, + "hdfs", + &hdfs_fa, + }, +#endif /* H5_HAVE_LIBHDFS */ + + }; /* testcases `cases` array */ + +#ifdef H5_HAVE_ROS3_VFD + n_cases += 5; +#endif /* H5_HAVE_ROS3_VFD */ + +#ifdef H5_HAVE_LIBHDFS + n_cases += 5; +#endif /* H5_HAVE_LIBHDFS */ + + TESTING("programmatic fapl set"); + + for (unsigned i = 0; i < n_cases; i++) { + int result; + testcase C = cases[i]; + + fapl_id = -1; + +#if UTIL_TEST_DEBUG + HDfprintf(stderr, "setup test %d\t%s\n", i, C.message); fflush(stderr); +#endif /* UTIL_TEST_DEBUG */ + + /* per-test setup */ + if (C.fapl_choice == UTIL_TEST_DEFAULT) { + fapl_id = H5P_DEFAULT; + } else if (C.fapl_choice == UTIL_TEST_CREATE) { + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF( fapl_id < 0 ) + } + +#if UTIL_TEST_DEBUG + HDfprintf(stderr, "before test\n"); fflush(stderr); +#endif /* UTIL_TEST_DEBUG */ + + /* test */ + result = h5tools_set_configured_fapl( + fapl_id, + C.vfdname, + C.conf_fa); + JSVERIFY( result, C.expected, C.message ) + +#if UTIL_TEST_DEBUG + HDfprintf(stderr, "after test\n"); fflush(stderr); +#endif /* UTIL_TEST_DEBUG */ + + /* per-test-teardown */ + if (fapl_id > 0) { + FAIL_IF( FAIL == H5Pclose(fapl_id) ) + } + fapl_id = -1; + +#if UTIL_TEST_DEBUG + HDfprintf(stderr, "after cleanup\n"); fflush(stderr); +#endif /* UTIL_TEST_DEBUG */ + + } + +#if UTIL_TEST_DEBUG + HDfprintf(stderr, "after loop\n"); fflush(stderr); +#endif /* UTIL_TEST_DEBUG */ + + PASSED(); + return 0; + +error : + /*********** + * CLEANUP * + ***********/ + +#if UTIL_TEST_DEBUG + HDfprintf(stderr, "ERROR\n"); fflush(stderr); +#endif /* UTIL_TEST_DEBUG */ + + if (fapl_id > 0) { + (void)H5Pclose(fapl_id); + } + + return 1; + +#undef UTIL_TEST_NOFAPL +#undef UTIL_TEST_DEFAULT +#undef UTIL_TEST_CREATE +} /* test_set_configured_fapl */ + + +/*---------------------------------------------------------------------------- + * + * Function: main() + * + * Purpose: Run all test functions. + * + * Return: 0 iff all test pass + * 1 iff any failures + * + * Programmer: Jacob Smith + * 2017-11-10 + * + * Changes: None. + * + *---------------------------------------------------------------------------- + */ +int +main(void) +{ + unsigned nerrors = 0; + +#ifdef _H5TEST_ + h5reset(); /* h5test? */ +#endif /* _H5TEST_ */ + + HDfprintf(stdout, "Testing h5tools_utils corpus.\n"); + + nerrors += test_parse_tuple(); + nerrors += test_populate_ros3_fa(); + nerrors += test_set_configured_fapl(); + + if (nerrors > 0) { + HDfprintf(stdout, "***** %d h5tools_utils TEST%s FAILED! *****\n", + nerrors, + nerrors > 1 ? "S" : ""); + nerrors = 1; + } else { + HDfprintf(stdout, "All h5tools_utils tests passed\n"); + } + + return (int)nerrors; + +} /* main */ + + diff --git a/tools/libtest/h5tools_utils.c b/tools/libtest/h5tools_utils.c deleted file mode 100644 index 56e8a01..0000000 --- a/tools/libtest/h5tools_utils.c +++ /dev/null @@ -1,1296 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright (c) 2017-2018, The HDF Group. * - * * - * All rights reserved. * - * * - * NOTICE: * - * All information contained herein is, and remains, the property of The HDF * - * Group. The intellectual and technical concepts contained herein are * - * proprietary to The HDF Group. Dissemination of this information or * - * reproduction of this material is strictly forbidden unless prior written * - * permission is obtained from The HDF Group. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Purpose: unit-test functionality of the routines in `tools/lib/h5tools_utils` - * - * Jacob Smith 2017-11-10 - */ - -#include "hdf5.h" -#include "H5private.h" -#include "h5tools_utils.h" -/* #include "h5test.h" */ /* linking failure */ - -#define UTIL_TEST_DEBUG 0 - -#ifndef _H5TEST_ - -#define AT() fprintf(stdout, " at %s:%d in %s()...\n", \ - __FILE__, __LINE__, FUNC); - -#define FAILED(msg) { \ - fprintf(stdout, "*FAILED*"); AT() \ - if (msg == NULL) { \ - fprintf(stdout,"(NULL)\n"); \ - } else { \ - fprintf(stdout, "%s\n", msg); \ - } \ - fflush(stdout); \ -} - -#define TESTING(msg) { \ - fprintf(stdout, "TESTING %-62s", (msg)); \ - fflush(stdout); \ -} - -#define PASSED() { \ - fprintf(stdout, " PASSED\n"); \ - fflush(stdout); \ -} - -#endif /* ifndef _H5TEST_ */ - -#ifndef __js_test__ - -#define __js_test__ 1L - -/***************************************************************************** - * - * FILE-LOCAL TESTING MACROS - * - * Purpose: - * - * 1. Upon test failure, goto-jump to single-location teardown in test - * function. E.g., `error:` (consistency with HDF corpus) or - * `failed:` (reflects purpose). - * >>> using "error", in part because `H5E_BEGIN_TRY` expects it. - * 2. Increase clarity and reduce overhead found with `TEST_ERROR`. - * e.g., "if(somefunction(arg, arg2) < 0) TEST_ERROR:" - * requires reading of entire line to know whether this if/call is - * part of the test setup, test operation, or a test unto itself. - * 3. Provide testing macros with optional user-supplied failure message; - * if not supplied (NULL), generate comparison output in the spirit of - * test-driven development. E.g., "expected 5 but was -3" - * User messages clarify test's purpose in code, encouraging description - * without relying on comments. - * 4. Configurable expected-actual order in generated comparison strings. - * Some prefer `VERIFY(expected, actual)`, others - * `VERIFY(actual, expected)`. Provide preprocessor ifdef switch - * to satifsy both parties, assuming one paradigm per test file. - * (One could #undef and redefine the flag through the file as desired, - * but _why_.) - * - * Provided as courtesy, per consideration for inclusion in the library - * proper. - * - * Macros: - * - * JSVERIFY_EXP_ACT - ifdef flag, configures comparison order - * FAIL_IF() - check condition - * FAIL_UNLESS() - check _not_ condition - * JSVERIFY() - long-int equality check; prints reason/comparison - * JSVERIFY_NOT() - long-int inequality check; prints - * JSVERIFY_STR() - string equality check; prints - * - * Programmer: Jacob Smith - * 2017-10-24 - * - *****************************************************************************/ - - -/*---------------------------------------------------------------------------- - * - * ifdef flag: JSVERIFY_EXP_ACT - * - * JSVERIFY macros accept arguments as (EXPECTED, ACTUAL[, reason]) - * default, if this is undefined, is (ACTUAL, EXPECTED[, reason]) - * - *---------------------------------------------------------------------------- - */ -#define JSVERIFY_EXP_ACT 1L - - -/*---------------------------------------------------------------------------- - * - * Macro: JSFAILED_AT() - * - * Purpose: - * - * Preface a test failure by printing "*FAILED*" and location to stdout - * Similar to `H5_FAILED(); AT();` from h5test.h - * - * *FAILED* at somefile.c:12 in function_name()... - * - * Programmer: Jacob Smith - * 2017-10-24 - * - *---------------------------------------------------------------------------- - */ -#define JSFAILED_AT() { \ - HDprintf("*FAILED* at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); \ -} - - -/*---------------------------------------------------------------------------- - * - * Macro: FAIL_IF() - * - * Purpose: - * - * Make tests more accessible and less cluttered than - * `if (thing == otherthing()) TEST_ERROR` - * paradigm. - * - * The following lines are roughly equivalent: - * - * `if (myfunc() < 0) TEST_ERROR;` (as seen elsewhere in HDF tests) - * `FAIL_IF(myfunc() < 0)` - * - * Prints a generic "FAILED AT" line to stdout and jumps to `error`, - * similar to `TEST_ERROR` in h5test.h - * - * Programmer: Jacob Smith - * 2017-10-23 - * - *---------------------------------------------------------------------------- - */ -#define FAIL_IF(condition) \ -if (condition) { \ - JSFAILED_AT() \ - goto error; \ -} - - -/*---------------------------------------------------------------------------- - * - * Macro: FAIL_UNLESS() - * - * Purpose: - * - * TEST_ERROR wrapper to reduce cognitive overhead from "negative tests", - * e.g., "a != b". - * - * Opposite of FAIL_IF; fails if the given condition is _not_ true. - * - * `FAIL_IF( 5 != my_op() )` - * is equivalent to - * `FAIL_UNLESS( 5 == my_op() )` - * However, `JSVERIFY(5, my_op(), "bad return")` may be even clearer. - * (see JSVERIFY) - * - * Programmer: Jacob Smith - * 2017-10-24 - * - *---------------------------------------------------------------------------- - */ -#define FAIL_UNLESS(condition) \ -if (!(condition)) { \ - JSFAILED_AT() \ - goto error; \ -} - - -/*---------------------------------------------------------------------------- - * - * Macro: JSERR_LONG() - * - * Purpose: - * - * Print an failure message for long-int arguments. - * ERROR-AT printed first. - * If `reason` is given, it is printed on own line and newlined after - * else, prints "expected/actual" aligned on own lines. - * - * *FAILED* at myfile.c:488 in somefunc()... - * forest must be made of trees. - * - * or - * - * *FAILED* at myfile.c:488 in somefunc()... - * ! Expected 425 - * ! Actual 3 - * - * Programmer: Jacob Smith - * 2017-10-24 - * - *---------------------------------------------------------------------------- - */ -#define JSERR_LONG(expected, actual, reason) { \ - JSFAILED_AT() \ - if (reason!= NULL) { \ - HDprintf("%s\n", (reason)); \ - } else { \ - HDprintf(" ! Expected %ld\n ! Actual %ld\n", \ - (long)(expected), (long)(actual)); \ - } \ -} - - -/*---------------------------------------------------------------------------- - * - * Macro: JSERR_STR() - * - * Purpose: - * - * Print an failure message for string arguments. - * ERROR-AT printed first. - * If `reason` is given, it is printed on own line and newlined after - * else, prints "expected/actual" aligned on own lines. - * - * *FAILED* at myfile.c:421 in myfunc()... - * Blue and Red strings don't match! - * - * or - * - * *FAILED* at myfile.c:421 in myfunc()... - * !!! Expected: - * this is my expected - * string - * !!! Actual: - * not what I expected at all - * - * Programmer: Jacob Smith - * 2017-10-24 - * - *---------------------------------------------------------------------------- - */ -#define JSERR_STR(expected, actual, reason) { \ - JSFAILED_AT() \ - if ((reason) != NULL) { \ - HDprintf("%s\n", (reason)); \ - } else { \ - HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", \ - (expected), (actual)); \ - } \ -} - -#ifdef JSVERIFY_EXP_ACT - - -/*---------------------------------------------------------------------------- - * - * Macro: JSVERIFY() - * - * Purpose: - * - * Verify that two long integers are equal. - * If unequal, print failure message - * (with `reason`, if not NULL; expected/actual if NULL) - * and jump to `error` at end of function - * - * Programmer: Jacob Smith - * 2017-10-24 - * - *---------------------------------------------------------------------------- - */ -#define JSVERIFY(expected, actual, reason) \ -if ((long)(actual) != (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY */ - - -/*---------------------------------------------------------------------------- - * - * Macro: JSVERIFY_NOT() - * - * Purpose: - * - * Verify that two long integers are _not_ equal. - * If equal, print failure message - * (with `reason`, if not NULL; expected/actual if NULL) - * and jump to `error` at end of function - * - * Programmer: Jacob Smith - * 2017-10-24 - * - *---------------------------------------------------------------------------- - */ -#define JSVERIFY_NOT(expected, actual, reason) \ -if ((long)(actual) == (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY_NOT */ - - -/*---------------------------------------------------------------------------- - * - * Macro: JSVERIFY_STR() - * - * Purpose: - * - * Verify that two strings are equal. - * If unequal, print failure message - * (with `reason`, if not NULL; expected/actual if NULL) - * and jump to `error` at end of function - * - * Programmer: Jacob Smith - * 2017-10-24 - * - *---------------------------------------------------------------------------- - */ -#define JSVERIFY_STR(expected, actual, reason) \ -if (strcmp((actual), (expected)) != 0) { \ - JSERR_STR((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY_STR */ - - -#else /* JSVERIFY_EXP_ACT not defined */ - /* Repeats macros above, but with actual/expected parameters reversed. */ - - -/*---------------------------------------------------------------------------- - * Macro: JSVERIFY() - * See: JSVERIFY documentation above. - * Programmer: Jacob Smith - * 2017-10-14 - *---------------------------------------------------------------------------- - */ -#define JSVERIFY(actual, expected, reason) \ -if ((long)(actual) != (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY */ - - -/*---------------------------------------------------------------------------- - * Macro: JSVERIFY_NOT() - * See: JSVERIFY_NOT documentation above. - * Programmer: Jacob Smith - * 2017-10-14 - *---------------------------------------------------------------------------- - */ -#define JSVERIFY_NOT(actual, expected, reason) \ -if ((long)(actual) == (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY_NOT */ - - -/*---------------------------------------------------------------------------- - * Macro: JSVERIFY_STR() - * See: JSVERIFY_STR documentation above. - * Programmer: Jacob Smith - * 2017-10-14 - *---------------------------------------------------------------------------- - */ -#define JSVERIFY_STR(actual, expected, reason) \ -if (strcmp((actual), (expected)) != 0) { \ - JSERR_STR((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY_STR */ - -#endif /* ifdef/else JSVERIFY_EXP_ACT */ - -#endif /* __js_test__ */ - -/* if > 0, be very verbose when performing tests */ -#define H5TOOLS_UTILS_TEST_DEBUG 0 - -/******************/ -/* TEST FUNCTIONS */ -/******************/ - - -/*---------------------------------------------------------------------------- - * - * Function: test_parse_tuple() - * - * Purpose: - * - * Provide unit tests and specification for the `parse_tuple()` function. - * - * Return: - * - * 0 Tests passed. - * 1 Tests failed. - * - * Programmer: Jacob Smith - * 2017-11-11 - * - * Changes: None. - * - *---------------------------------------------------------------------------- - */ -static unsigned -test_parse_tuple(void) -{ - /************************* - * TEST-LOCAL STRUCTURES * - *************************/ - - struct testcase { - const char *test_msg; /* info about test case */ - const char *in_str; /* input string */ - int sep; /* separator "character" */ - herr_t exp_ret; /* expected SUCCEED / FAIL */ - unsigned exp_nelems; /* expected number of elements */ - /* (no more than 7!) */ - const char *exp_elems[7]; /* list of elements (no more than 7!) */ - }; - - /****************** - * TEST VARIABLES * - ******************/ - - struct testcase cases[] = { - { "bad start", - "words(before)", - ';', - FAIL, - 0, - {NULL}, - }, - { "tuple not closed", - "(not ok", - ',', - FAIL, - 0, - {NULL}, - }, - { "empty tuple", - "()", - '-', - SUCCEED, - 1, - {""}, - }, - { "no separator", - "(stuff keeps on going)", - ',', - SUCCEED, - 1, - {"stuff keeps on going"}, - }, - { "4-ple, escaped seperator", - "(elem0,elem1,el\\,em2,elem3)", /* "el\,em" */ - ',', - SUCCEED, - 4, - {"elem0", "elem1", "el,em2", "elem3"}, - }, - { "5-ple, escaped escaped separator", - "(elem0,elem1,el\\\\,em2,elem3)", - ',', - SUCCEED, - 5, - {"elem0", "elem1", "el\\", "em2", "elem3"}, - }, - { "escaped non-comma separator", - "(5-2-7-2\\-6-2)", - '-', - SUCCEED, - 5, - {"5","2","7","2-6","2"}, - }, - { "embedded close-paren", - "(be;fo)re)", - ';', - SUCCEED, - 2, - {"be", "fo)re"}, - }, - { "embedded non-escaping backslash", - "(be;fo\\re)", - ';', - SUCCEED, - 2, - {"be", "fo\\re"}, - }, - { "double close-paren at end", - "(be;fore))", - ';', - SUCCEED, - 2, - {"be", "fore)"}, - }, - { "empty elements", - "(;a1;;a4;)", - ';', - SUCCEED, - 5, - {"", "a1", "", "a4", ""}, - }, - { "nested tuples with different separators", - "((4,e,a);(6,2,a))", - ';', - SUCCEED, - 2, - {"(4,e,a)","(6,2,a)"}, - }, - { "nested tuples with same separators", - "((4,e,a),(6,2,a))", - ',', - SUCCEED, - 6, - {"(4","e","a)","(6","2","a)"}, - }, - { "real-world use case", - "(us-east-2,AKIAIMC3D3XLYXLN5COA,ugs5aVVnLFCErO/8uW14iWE3K5AgXMpsMlWneO/+)", - ',', - SUCCEED, - 3, - {"us-east-2", - "AKIAIMC3D3XLYXLN5COA", - "ugs5aVVnLFCErO/8uW14iWE3K5AgXMpsMlWneO/+"}, - } - }; - struct testcase tc; - unsigned n_tests = 14; - unsigned i = 0; - unsigned count = 0; - unsigned elem_i = 0; - char **parsed = NULL; - char *cpy = NULL; - herr_t success = TRUE; - hbool_t show_progress = FALSE; - - - - TESTING("arbitrary-count tuple parsing"); - -#if H5TOOLS_UTILS_TEST_DEBUG > 0 - show_progress = TRUE; -#endif /* H5TOOLS_UTILS_TEST_DEBUG */ - - /********* - * TESTS * - *********/ - - for (i = 0; i < n_tests; i++) { - - /* SETUP - */ - HDassert(parsed == NULL); - HDassert(cpy == NULL); - tc = cases[i]; - if (show_progress == TRUE) { - printf("testing %d: %s...\n", i, tc.test_msg); - } - - /* VERIFY - */ - success = parse_tuple(tc.in_str, tc.sep, - &cpy, &count, &parsed); - - JSVERIFY( tc.exp_ret, success, "function returned incorrect value" ) - JSVERIFY( tc.exp_nelems, count, NULL ) - if (success == SUCCEED) { - FAIL_IF( parsed == NULL ) - for (elem_i = 0; elem_i < count; elem_i++) { - JSVERIFY_STR( tc.exp_elems[elem_i], parsed[elem_i], NULL ) - } - /* TEARDOWN */ - HDassert(parsed != NULL); - HDassert(cpy != NULL); - free(parsed); - parsed = NULL; - free(cpy); - cpy = NULL; - } else { - FAIL_IF( parsed != NULL ) - } /* if parse_tuple() == SUCCEED or no */ - - } /* for each testcase */ - - PASSED(); - return 0; - -error: - /*********** - * CLEANUP * - ***********/ - - if (parsed != NULL) free(parsed); - if (cpy != NULL) free(cpy); - - return 1; - -} /* test_parse_tuple */ - - -/*---------------------------------------------------------------------------- - * - * Function: test_populate_ros3_fa() - * - * Purpose: Verify behavior of `populate_ros3_fa()` - * - * Return: 0 if test passes - * 1 if failure - * - * Programmer: Jacob Smith - * 2017-11-13 - * - * Changes: None - * - *---------------------------------------------------------------------------- - */ -static unsigned -test_populate_ros3_fa(void) -{ -#ifdef H5_HAVE_ROS3_VFD - /************************* - * TEST-LOCAL STRUCTURES * - *************************/ - - /************************ - * TEST-LOCAL VARIABLES * - ************************/ - - hbool_t show_progress = FALSE; - int bad_version = 0xf87a; /* arbitrarily wrong version number */ -#endif /* H5_HAVE_ROS3_VFD */ - - TESTING("programmatic ros3 fapl population"); - -#ifndef H5_HAVE_ROS3_VFD - puts(" -SKIP-"); - puts(" Read-Only S3 VFD not enabled"); - fflush(stdout); - return 0; -#else -#if H5TOOLS_UTILS_TEST_DEBUG > 0 - show_progress = TRUE; -#endif /* H5TOOLS_UTILS_TEST_DEBUG */ - - HDassert(bad_version != H5FD__CURR_ROS3_FAPL_T_VERSION); - - /********* - * TESTS * - *********/ - - /* NULL fapl config pointer fails - */ - { - const char *values[] = {"x", "y", "z"}; - - if (show_progress) { HDprintf("NULL fapl pointer\n"); } - - JSVERIFY( 0, h5tools_populate_ros3_fapl(NULL, values), - "fapl pointer cannot be null" ) - } - - /* NULL values pointer yields default fapl - */ - { - H5FD_ros3_fapl_t fa = {bad_version, TRUE, "u", "v", "w"}; - - if (show_progress) { HDprintf("NULL values pointer\n"); } - - JSVERIFY( 1, h5tools_populate_ros3_fapl(&fa, NULL), - "NULL values pointer yields \"default\" fapl" ) - JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) - } - - /* all-empty values - * yields default fapl - */ - { - H5FD_ros3_fapl_t fa = {bad_version, TRUE, "u", "v", "w"}; - const char *values[] = {"", "", ""}; - - if (show_progress) { HDprintf("all empty values\n"); } - - JSVERIFY( 1, h5tools_populate_ros3_fapl(&fa, values), - "empty values yields \"default\" fapl" ) - JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) - } - - /* successfully set fapl with values - * excess value is ignored - */ - { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {"x", "y", "z", "a"}; - - if (show_progress) { HDprintf("successful full set\n"); } - - JSVERIFY( 1, h5tools_populate_ros3_fapl(&fa, values), - "four values" ) - JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( TRUE, fa.authenticate, NULL ) - JSVERIFY_STR( "x", fa.aws_region, NULL ) - JSVERIFY_STR( "y", fa.secret_id, NULL ) - JSVERIFY_STR( "z", fa.secret_key, NULL ) - } - - /* NULL region - * yeilds default fapl - */ - { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {NULL, "y", "z", NULL}; - - if (show_progress) { HDprintf("NULL region\n"); } - - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) - } - - /* empty region - * yeilds default fapl - */ - { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {"", "y", "z", NULL}; - - if (show_progress) { HDprintf("empty region; non-empty id, key\n"); } - - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) - } - - /* region overflow - * yeilds default fapl - */ - { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = { - "somewhere over the rainbow not too high " \ - "there is another rainbow bounding some darkened sky", - "y", - "z"}; - - if (show_progress) { HDprintf("region overflow\n"); } - - HDassert(strlen(values[0]) > H5FD__ROS3_MAX_REGION_LEN); - - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) - } - - /* NULL id - * yields default fapl - */ - { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {"x", NULL, "z", NULL}; - - if (show_progress) { HDprintf("NULL id\n"); } - - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) - } - - /* empty id (non-empty region, key) - * yeilds default fapl - */ - { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {"x", "", "z", NULL}; - - if (show_progress) { HDprintf("empty id; non-empty region and key\n"); } - - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) - } - - /* id overflow - * partial set: region - */ - { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = { - "x", - "Why is it necessary to solve the problem? " \ - "What benefits will you receive by solving the problem? " \ - "What is the unknown? " \ - "What is it you don't yet understand? " \ - "What is the information you have? " \ - "What isn't the problem? " \ - "Is the information insufficient, redundant, or contradictory? " \ - "Should you draw a diagram or figure of the problem? " \ - "What are the boundaries of the problem? " \ - "Can you separate the various parts of the problem?", - "z"}; - - if (show_progress) { HDprintf("id overflow\n"); } - - HDassert(strlen(values[1]) > H5FD__ROS3_MAX_SECRET_ID_LEN); - - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "x", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) - } - - /* NULL key - * yields default fapl - */ - { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {"x", "y", NULL, NULL}; - - if (show_progress) { HDprintf("NULL key\n"); } - - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) - } - - /* empty key (non-empty region, id) - * yeilds authenticating fapl - */ - { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {"x", "y", "", NULL}; - - if (show_progress) { HDprintf("empty key; non-empty region and id\n"); } - - JSVERIFY( 1, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( TRUE, fa.authenticate, NULL ) - JSVERIFY_STR( "x", fa.aws_region, NULL ) - JSVERIFY_STR( "y", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) - } - - /* empty key, region (non-empty id) - * yeilds default fapl - */ - { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {"", "y", "", NULL}; - - if (show_progress) { HDprintf("empty key and region; non-empty id\n"); } - - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) - } - - /* empty key, id (non-empty region) - * yeilds default fapl - */ - { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {"x", "", "", NULL}; - - if (show_progress) { HDprintf("empty key and id; non-empty region\n"); } - - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) - } - - /* key overflow - * partial set: region, id - */ - { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = { - "x", - "y", - "Why is it necessary to solve the problem? " \ - "What benefits will you receive by solving the problem? " \ - "What is the unknown? " \ - "What is it you don't yet understand? " \ - "What is the information you have? " \ - "What isn't the problem? " \ - "Is the information insufficient, redundant, or contradictory? " \ - "Should you draw a diagram or figure of the problem? " \ - "What are the boundaries of the problem? " \ - "Can you separate the various parts of the problem?"}; - - if (show_progress) { HDprintf("key overflow\n"); } - - HDassert(strlen(values[2]) > H5FD__ROS3_MAX_SECRET_KEY_LEN); - - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD__CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "x", fa.aws_region, NULL ) - JSVERIFY_STR( "y", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) - } - - /* use case - */ - { - H5FD_ros3_fapl_t fa = {0, 0, "", "", ""}; - const char *values[] = { - "us-east-2", - "AKIAIMC3D3XLYXLN5COA", - "ugs5aVVnLFCErO/8uW14iWE3K5AgXMpsMlWneO/+" - }; - JSVERIFY( 1, - h5tools_populate_ros3_fapl(&fa, values), - "unable to set use case" ) - JSVERIFY( 1, fa.version, "version check" ) - JSVERIFY( 1, fa.authenticate, "should authenticate" ) - } - - PASSED(); - return 0; - -error : - /*********** - * CLEANUP * - ***********/ - - return 1; - -#endif /* H5_HAVE_ROS3_VFD */ - -} /* test_populate_ros3_fa */ - - -/*---------------------------------------------------------------------------- - * - * Function: test_set_configured_fapl() - * - * Purpose: Verify `h5tools_set_configured_fapl()` with ROS3 VFD - * - * Return: 0 if test passes - * 1 if failure - * - * Programmer: Jacob Smith - * 2018-07-12 - * - * Changes: None - * - *---------------------------------------------------------------------------- - */ -static unsigned -test_set_configured_fapl(void) -{ -#define UTIL_TEST_NOFAPL 1 -#define UTIL_TEST_DEFAULT 2 -#define UTIL_TEST_CREATE 3 - - /************************* - * TEST-LOCAL STRUCTURES * - *************************/ - typedef struct testcase { - const char message[88]; - int expected; - int fapl_choice; - const char vfdname[12]; - void *conf_fa; - } testcase; - - typedef struct other_fa_t { - int a; - int b; - int c; - } other_fa_t; - - /************************ - * TEST-LOCAL VARIABLES * - ************************/ - - hid_t fapl_id = -1; - other_fa_t wrong_fa = {0x432, 0xf82, 0x9093}; - H5FD_ros3_fapl_t ros3_anon_fa = {1, FALSE, "", "", ""}; - H5FD_ros3_fapl_t ros3_auth_fa = { - 1, /* fapl version */ - TRUE, /* authenticate */ - "us-east-1", /* aws region */ - "12345677890abcdef", /* simulate access key ID */ - "oiwnerwe9u0234nJw0-aoj+dsf", /* simulate secret key */ - }; - H5FD_hdfs_fapl_t hdfs_fa = { - 1, /* fapl version */ - "", /* namenode name */ - 0, /* namenode port */ - "", /* kerberos ticket cache */ - "", /* user name */ - 2048, /* stream buffer size */ - }; - unsigned n_cases = 7; /* number of common testcases */ - testcase cases[] = { - { "(common) should fail: no fapl id", - 0, - UTIL_TEST_NOFAPL, - "", - NULL, - }, - { "(common) should fail: no fapl id (with struct)", - 0, - UTIL_TEST_NOFAPL, - "", - &wrong_fa, - }, - { "(common) H5P_DEFAULT with no struct should succeed", - 1, - UTIL_TEST_DEFAULT, - "", - NULL, - }, - { "(common) H5P_DEFAULT with (ignored) struct should succeed", - 1, - UTIL_TEST_DEFAULT, - "", - &wrong_fa, - }, - { "(common) provided fapl entry should not fail", - 1, - UTIL_TEST_CREATE, - "", - NULL, - }, - { "(common) provided fapl entry should not fail; ignores struct", - 1, - UTIL_TEST_CREATE, - "", - &wrong_fa, - }, - { "(common) should fail: unrecoginzed vfd name", - 0, - UTIL_TEST_DEFAULT, - "unknown", - NULL, - }, - -#ifdef H5_HAVE_ROS3_VFD - /* WARNING: add number of ROS3 test cases after array definition - */ - { "(ROS3) should fail: no fapl id, no struct", - 0, - UTIL_TEST_NOFAPL, - "ros3", - NULL, - }, - { "(ROS3) should fail: no fapl id", - 0, - UTIL_TEST_NOFAPL, - "ros3", - &ros3_anon_fa, - }, - { "(ROS3) should fail: no struct", - 0, - UTIL_TEST_CREATE, - "ros3", - NULL, - }, - { "(ROS3) successful set", - 1, - UTIL_TEST_CREATE, - "ros3", - &ros3_anon_fa, - }, - { "(ROS3) should fail: attempt to set DEFAULT fapl", - 0, - UTIL_TEST_DEFAULT, - "ros3", - &ros3_anon_fa, - }, -#endif /* H5_HAVE_ROS3_VFD */ - -#ifdef H5_HAVE_LIBHDFS - /* WARNING: add number of HDFS test cases after array definition - */ - { "(HDFS) should fail: no fapl id, no struct", - 0, - UTIL_TEST_NOFAPL, - "hdfs", - NULL, - }, - { "(HDFS) should fail: no fapl id", - 0, - UTIL_TEST_NOFAPL, - "hdfs", - &hdfs_fa, - }, - { "(HDFS) should fail: no struct", - 0, - UTIL_TEST_CREATE, - "hdfs", - NULL, - }, - { "(HDFS) successful set", - 1, - UTIL_TEST_CREATE, - "hdfs", - &hdfs_fa, - }, - { "(HDFS) should fail: attempt to set DEFAULT fapl", - 0, - UTIL_TEST_DEFAULT, - "hdfs", - &hdfs_fa, - }, -#endif /* H5_HAVE_LIBHDFS */ - - }; /* testcases `cases` array */ - -#ifdef H5_HAVE_ROS3_VFD - n_cases += 5; -#endif /* H5_HAVE_ROS3_VFD */ - -#ifdef H5_HAVE_LIBHDFS - n_cases += 5; -#endif /* H5_HAVE_LIBHDFS */ - - TESTING("programmatic fapl set"); - - for (unsigned i = 0; i < n_cases; i++) { - int result; - testcase C = cases[i]; - - fapl_id = -1; - -#if UTIL_TEST_DEBUG - HDfprintf(stderr, "setup test %d\t%s\n", i, C.message); fflush(stderr); -#endif /* UTIL_TEST_DEBUG */ - - /* per-test setup */ - if (C.fapl_choice == UTIL_TEST_DEFAULT) { - fapl_id = H5P_DEFAULT; - } else if (C.fapl_choice == UTIL_TEST_CREATE) { - fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( fapl_id < 0 ) - } - -#if UTIL_TEST_DEBUG - HDfprintf(stderr, "before test\n"); fflush(stderr); -#endif /* UTIL_TEST_DEBUG */ - - /* test */ - result = h5tools_set_configured_fapl( - fapl_id, - C.vfdname, - C.conf_fa); - JSVERIFY( result, C.expected, C.message ) - -#if UTIL_TEST_DEBUG - HDfprintf(stderr, "after test\n"); fflush(stderr); -#endif /* UTIL_TEST_DEBUG */ - - /* per-test-teardown */ - if (fapl_id > 0) { - FAIL_IF( FAIL == H5Pclose(fapl_id) ) - } - fapl_id = -1; - -#if UTIL_TEST_DEBUG - HDfprintf(stderr, "after cleanup\n"); fflush(stderr); -#endif /* UTIL_TEST_DEBUG */ - - } - -#if UTIL_TEST_DEBUG - HDfprintf(stderr, "after loop\n"); fflush(stderr); -#endif /* UTIL_TEST_DEBUG */ - - PASSED(); - return 0; - -error : - /*********** - * CLEANUP * - ***********/ - -#if UTIL_TEST_DEBUG - HDfprintf(stderr, "ERROR\n"); fflush(stderr); -#endif /* UTIL_TEST_DEBUG */ - - if (fapl_id > 0) { - (void)H5Pclose(fapl_id); - } - - return 1; - -#undef UTIL_TEST_NOFAPL -#undef UTIL_TEST_DEFAULT -#undef UTIL_TEST_CREATE -} /* test_set_configured_fapl */ - - -/*---------------------------------------------------------------------------- - * - * Function: main() - * - * Purpose: Run all test functions. - * - * Return: 0 iff all test pass - * 1 iff any failures - * - * Programmer: Jacob Smith - * 2017-11-10 - * - * Changes: None. - * - *---------------------------------------------------------------------------- - */ -int -main(void) -{ - unsigned nerrors = 0; - -#ifdef _H5TEST_ - h5reset(); /* h5test? */ -#endif /* _H5TEST_ */ - - HDfprintf(stdout, "Testing h5tools_utils corpus.\n"); - - nerrors += test_parse_tuple(); - nerrors += test_populate_ros3_fa(); - nerrors += test_set_configured_fapl(); - - if (nerrors > 0) { - HDfprintf(stdout, "***** %d h5tools_utils TEST%s FAILED! *****\n", - nerrors, - nerrors > 1 ? "S" : ""); - nerrors = 1; - } else { - HDfprintf(stdout, "All h5tools_utils tests passed\n"); - } - - return (int)nerrors; - -} /* main */ - - -- cgit v0.12 From e852c8deb81f1ded2b9f4f7276967a6b7d2712ba Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Fri, 26 Jul 2019 12:58:56 -0500 Subject: Modify CMakeLists.txt file for renamed h5tools_test_utils files. --- tools/libtest/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/libtest/CMakeLists.txt b/tools/libtest/CMakeLists.txt index f5e0aa6..105607d 100644 --- a/tools/libtest/CMakeLists.txt +++ b/tools/libtest/CMakeLists.txt @@ -4,7 +4,7 @@ project (HDF5_TOOLS_LIBTEST C) #----------------------------------------------------------------------------- # Add the h5tools_utils test executables #----------------------------------------------------------------------------- -add_executable (h5tools_utils ${HDF5_TOOLS_LIBTEST_SOURCE_DIR}/h5tools_utils.c) +add_executable (h5tools_test_utils ${HDF5_TOOLS_LIBTEST_SOURCE_DIR}/h5tools_test_utils.c) target_include_directories(h5tools_utils PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h5tools_utils STATIC) target_link_libraries (h5tools_utils PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) -- cgit v0.12 From a7d74160d043310d3819692c0aff5074bf466b1a Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 26 Jul 2019 16:18:39 -0500 Subject: Correct generator and add HD prefix --- hl/test/test_ds.c | 6 +++--- tools/test/misc/CMakeLists.txt | 18 ++++-------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c index d7af9e9..6c75423 100644 --- a/hl/test/test_ds.c +++ b/hl/test/test_ds.c @@ -4876,12 +4876,12 @@ static int read_data( const char* fname, for(i=0, nelms=1; i < ndims; i++) { if(fscanf( f, "%s %u", str, &j) && HDferror(f)) { - printf( "fscanf error in file %s\n", data_file ); + HDprintf( "fscanf error in file %s\n", data_file ); HDfclose(f); return -1; } /* end if */ if(fscanf( f, "%d",&n ) < 0 && HDferror(f)) { - printf( "fscanf error in file %s\n", data_file ); + HDprintf( "fscanf error in file %s\n", data_file ); HDfclose(f); return -1; } /* end if */ @@ -4899,7 +4899,7 @@ static int read_data( const char* fname, for(j = 0; j < nelms; j++) { if(fscanf( f, "%f",&val ) < 0 && HDferror(f)) { - printf( "fscanf error in file %s\n", data_file ); + HDprintf( "fscanf error in file %s\n", data_file ); HDfclose(f); return -1; } /* end if */ diff --git a/tools/test/misc/CMakeLists.txt b/tools/test/misc/CMakeLists.txt index a250222..3d63681 100644 --- a/tools/test/misc/CMakeLists.txt +++ b/tools/test/misc/CMakeLists.txt @@ -7,25 +7,15 @@ project (HDF5_TOOLS_TEST_MISC C) if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) add_executable (h5repart_gentest ${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/h5repart_gentest.c) target_include_directories (h5repart_gentest PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") - if (NOT ONLY_SHARED_LIBS) - TARGET_C_PROPERTIES (h5repart_gentest STATIC) - target_link_libraries (h5repart_gentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) - else () - TARGET_C_PROPERTIES (h5repart_gentest SHARED) - target_link_libraries (h5repart_gentest PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET}) - endif () + TARGET_C_PROPERTIES (h5repart_gentest STATIC) + target_link_libraries (h5repart_gentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) set_target_properties (h5repart_gentest PROPERTIES FOLDER generator/tools) #add_test (NAME h5repart_gentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) add_executable (h5clear_gentest ${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/h5clear_gentest.c) target_include_directories (h5clear_gentest PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") - if (NOT ONLY_SHARED_LIBS) - TARGET_C_PROPERTIES (h5clear_gentest STATIC) - target_link_libraries (h5clear_gentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) - else () - TARGET_C_PROPERTIES (h5clear_gentest SHARED) - target_link_libraries (h5clear_gentest PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET}) - endif () + TARGET_C_PROPERTIES (h5clear_gentest STATIC) + target_link_libraries (h5clear_gentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) set_target_properties (h5clear_gentest PROPERTIES FOLDER tools) #add_test (NAME H5CLEAR-h5clear_gentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) -- cgit v0.12 From 8aa9043837ea217280098b4b32da8d98ac18f58b Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Fri, 26 Jul 2019 16:36:45 -0500 Subject: Update comment and check for strtoumax. --- src/H5FDs3comms.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/H5FDs3comms.c b/src/H5FDs3comms.c index 4c24866..8c0515d 100644 --- a/src/H5FDs3comms.c +++ b/src/H5FDs3comms.c @@ -1143,9 +1143,8 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "content_length overflows size_t\n"); } - if (content_length == 0 || - content_length == ULONG_MAX || - errno == ERANGE) /* errno set by strtoul */ + if (content_length == 0 || + errno == ERANGE) /* errno set by strtoumax*/ { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not convert found \"Content-Length\" response (\"%s\")", -- cgit v0.12 From da2ec6163d4a8f76ef9c32518b5a0b5810f2d63f Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Sun, 28 Jul 2019 14:41:52 -0500 Subject: Update libvers usage --- java/test/TestH5Fparams.java | 2 +- java/test/TestH5P.java | 4 ++-- tools/src/h5repack/h5repack_main.c | 3 ++- tools/test/h5repack/testfiles/h5repack-help.txt | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/java/test/TestH5Fparams.java b/java/test/TestH5Fparams.java index 40cbe4b..6b541c6 100644 --- a/java/test/TestH5Fparams.java +++ b/java/test/TestH5Fparams.java @@ -244,7 +244,7 @@ public class TestH5Fparams { catch (Throwable err) { fail("H5.H5Fcreate: " + err); } - H5.H5Fset_libver_bounds(fid, HDF5Constants.H5F_LIBVER_V110, HDF5Constants.H5F_LIBVER_V110+1); + H5.H5Fset_libver_bounds(fid, HDF5Constants.H5F_LIBVER_LATEST, HDF5Constants.H5F_LIBVER_LATEST+1); } finally { try {H5.H5Fclose(fid);} catch (Exception ex) {} diff --git a/java/test/TestH5P.java b/java/test/TestH5P.java index e46ed48..a85405b 100644 --- a/java/test/TestH5P.java +++ b/java/test/TestH5P.java @@ -209,12 +209,12 @@ public class TestH5P { @Test(expected = HDF5FunctionArgumentException.class) public void testH5Pset_libver_bounds_invalidlow() throws Throwable { - H5.H5Pset_libver_bounds(fapl_id, 5, HDF5Constants.H5F_LIBVER_LATEST); + H5.H5Pset_libver_bounds(fapl_id, HDF5Constants.H5F_LIBVER_EARLIEST-1, HDF5Constants.H5F_LIBVER_LATEST); } @Test(expected = HDF5FunctionArgumentException.class) public void testH5Pset_libver_bounds_invalidhigh() throws Throwable { - H5.H5Pset_libver_bounds(fapl_id, HDF5Constants.H5F_LIBVER_V112, HDF5Constants.H5F_LIBVER_V112+1); + H5.H5Pset_libver_bounds(fapl_id, HDF5Constants.H5F_LIBVER_LATEST, HDF5Constants.H5F_LIBVER_LATEST+1); } @Test diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index dec25f9..b961765 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -127,7 +127,8 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " 0: This is H5F_LIBVER_EARLIEST in H5F_libver_t struct\n"); PRINTVALSTREAM(rawoutstream, " 1: This is H5F_LIBVER_V18 in H5F_libver_t struct\n"); PRINTVALSTREAM(rawoutstream, " 2: This is H5F_LIBVER_V110 in H5F_libver_t struct\n"); - PRINTVALSTREAM(rawoutstream, " (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V110 for this release\n"); + PRINTVALSTREAM(rawoutstream, " 3: This is H5F_LIBVER_V112 in H5F_libver_t struct\n"); + PRINTVALSTREAM(rawoutstream, " (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V112 for this release\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " FS_STRATEGY is a string indicating the file space strategy used:\n"); PRINTVALSTREAM(rawoutstream, " FSM_AGGR:\n"); diff --git a/tools/test/h5repack/testfiles/h5repack-help.txt b/tools/test/h5repack/testfiles/h5repack-help.txt index 0eef0f5..2381865 100644 --- a/tools/test/h5repack/testfiles/h5repack-help.txt +++ b/tools/test/h5repack/testfiles/h5repack-help.txt @@ -50,7 +50,8 @@ usage: h5repack [OPTIONS] file1 file2 0: This is H5F_LIBVER_EARLIEST in H5F_libver_t struct 1: This is H5F_LIBVER_V18 in H5F_libver_t struct 2: This is H5F_LIBVER_V110 in H5F_libver_t struct - (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V110 for this release + 3: This is H5F_LIBVER_V112 in H5F_libver_t struct + (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V112 for this release FS_STRATEGY is a string indicating the file space strategy used: FSM_AGGR: -- cgit v0.12 From 99a6a5a16e84512dfc57ba2eb7c3e09ecef94b1c Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 30 Jul 2019 07:29:37 -0700 Subject: Fixed the MANIFEST --- MANIFEST | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST b/MANIFEST index f5e718e..9c7c0db 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1555,7 +1555,7 @@ ./tools/lib/io_timer.h ./tools/libtest/Makefile.am -./tools/libtest/h5tools_utils.c +./tools/libtest/h5tools_test_utils.c ./tools/src/misc/Makefile.am ./tools/src/misc/h5clear.c -- cgit v0.12 From 44e2ddac97a6bae4637ef040c9f1a9f7b70978f3 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 30 Jul 2019 12:39:20 -0500 Subject: Merge cleanup mostly whitespace --- CTestConfig.cmake | 2 +- config/cmake/scripts/HDF5config.cmake | 2 +- java/test/TestH5P.java | 2 +- java/test/TestH5Pfapl.java | 3 - java/test/TestH5Z.java | 1 - test/direct_chunk.c | 178 ++-- test/dsets.c | 245 +++--- test/dt_arith.c | 1460 ++++++++++++++++----------------- test/earray.c | 4 +- test/th5o.c | 32 +- test/titerate.c | 2 +- 11 files changed, 963 insertions(+), 968 deletions(-) diff --git a/CTestConfig.cmake b/CTestConfig.cmake index d80f48f..4868d07 100644 --- a/CTestConfig.cmake +++ b/CTestConfig.cmake @@ -50,5 +50,5 @@ set (CTEST_TEST_TIMEOUT 1200 CACHE STRING set (DART_TESTING_TIMEOUT 1200 CACHE STRING "Maximum time allowed before CTest will kill the test." FORCE) -SET(CTEST_SUBMIT_RETRY_DELAY 20 CACHE STRING +set (CTEST_SUBMIT_RETRY_DELAY 20 CACHE STRING "How long to wait between timed-out CTest submissions.") diff --git a/config/cmake/scripts/HDF5config.cmake b/config/cmake/scripts/HDF5config.cmake index e6c9619..3511d05 100644 --- a/config/cmake/scripts/HDF5config.cmake +++ b/config/cmake/scripts/HDF5config.cmake @@ -45,7 +45,7 @@ set (CTEST_SOURCE_VERSEXT "") #CTEST_SOURCE_NAME - name of source folder; HDF5-1.10.0 #MODEL - CDash group name #HPC - run alternate configurations for HPC machines; sbatch, bsub, raybsub, qsub -#MPI - enable MPI; +#MPI - enable MPI if (DEFINED CTEST_SCRIPT_ARG) # transform ctest script arguments of the form # script.ctest,var1=value1,var2=value2 diff --git a/java/test/TestH5P.java b/java/test/TestH5P.java index a85405b..b1c29b2 100644 --- a/java/test/TestH5P.java +++ b/java/test/TestH5P.java @@ -209,7 +209,7 @@ public class TestH5P { @Test(expected = HDF5FunctionArgumentException.class) public void testH5Pset_libver_bounds_invalidlow() throws Throwable { - H5.H5Pset_libver_bounds(fapl_id, HDF5Constants.H5F_LIBVER_EARLIEST-1, HDF5Constants.H5F_LIBVER_LATEST); + H5.H5Pset_libver_bounds(fapl_id, HDF5Constants.H5F_LIBVER_LATEST+1, HDF5Constants.H5F_LIBVER_LATEST); } @Test(expected = HDF5FunctionArgumentException.class) diff --git a/java/test/TestH5Pfapl.java b/java/test/TestH5Pfapl.java index 81a7ecb..7d690cf 100644 --- a/java/test/TestH5Pfapl.java +++ b/java/test/TestH5Pfapl.java @@ -29,8 +29,6 @@ import hdf.hdf5lib.exceptions.HDF5Exception; import hdf.hdf5lib.exceptions.HDF5LibraryException; import hdf.hdf5lib.exceptions.HDF5PropertyListInterfaceException; import hdf.hdf5lib.structs.H5AC_cache_config_t; -import hdf.hdf5lib.structs.H5FD_hdfs_fapl_t; -import hdf.hdf5lib.structs.H5FD_ros3_fapl_t; import org.junit.After; import org.junit.Before; @@ -1401,5 +1399,4 @@ public class TestH5Pfapl { fail("H5P_evict_on_close: " + err); } } - } diff --git a/java/test/TestH5Z.java b/java/test/TestH5Z.java index f3049ed..27bda6f 100644 --- a/java/test/TestH5Z.java +++ b/java/test/TestH5Z.java @@ -109,4 +109,3 @@ public class TestH5Z { H5.H5Zunregister(HDF5Constants.H5Z_FILTER_SHUFFLE); } } - diff --git a/test/direct_chunk.c b/test/direct_chunk.c index 9ea814c..447e827 100644 --- a/test/direct_chunk.c +++ b/test/direct_chunk.c @@ -13,7 +13,7 @@ #include "h5test.h" -#if defined(H5_HAVE_ZLIB_H) && !defined(H5_ZLIB_HEADER) +#if defined(H5_HAVE_ZLIB_H) && !defined(H5_ZLIB_HEADER) # define H5_ZLIB_HEADER "zlib.h" #endif #if defined(H5_ZLIB_HEADER) @@ -46,10 +46,10 @@ #define DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s))*H5_DOUBLE(1.001))+H5_DOUBLE(12.0)) /* Temporary filter IDs used for testing */ -#define H5Z_FILTER_BOGUS1 305 -#define H5Z_FILTER_BOGUS2 306 -#define ADD_ON 7 -#define FACTOR 3 +#define H5Z_FILTER_BOGUS1 305 +#define H5Z_FILTER_BOGUS2 306 +#define ADD_ON 7 +#define FACTOR 3 /* Constants for the overwrite test */ #define OVERWRITE_NDIMS 3 @@ -83,33 +83,33 @@ static size_t filter_bogus2(unsigned int flags, size_t cd_nelmts, /* This message derives from H5Z */ const H5Z_class2_t H5Z_BOGUS1[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_BOGUS1, /* Filter id number */ + H5Z_FILTER_BOGUS1, /* Filter id number */ 1, 1, /* Encoding and decoding enabled */ - "bogus1", /* Filter name for debugging */ + "bogus1", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ - filter_bogus1, /* The actual filter function */ + filter_bogus1, /* The actual filter function */ }}; const H5Z_class2_t H5Z_BOGUS2[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_BOGUS2, /* Filter id number */ + H5Z_FILTER_BOGUS2, /* Filter id number */ 1, 1, /* Encoding and decoding enabled */ - "bogus2", /* Filter name for debugging */ + "bogus2", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ - filter_bogus2, /* The actual filter function */ + filter_bogus2, /* The actual filter function */ }}; /*------------------------------------------------------------------------- - * Function: test_direct_chunk_write + * Function: test_direct_chunk_write * - * Purpose: Test the basic functionality of H5Dwrite_chunk + * Purpose: Test the basic functionality of H5Dwrite_chunk * - * Return: Success: 0 - * Failure: 1 + * Return: Success: 0 + * Failure: 1 * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * 30 November 2012 * *------------------------------------------------------------------------- @@ -121,7 +121,7 @@ test_direct_chunk_write (hid_t file) hid_t dataspace = -1, dataset = -1; hid_t mem_space = -1; hid_t cparms = -1, dxpl = -1; - hsize_t dims[2] = {NX, NY}; + hsize_t dims[2] = {NX, NY}; hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; hsize_t chunk_dims[2] ={CHUNK_NX, CHUNK_NY}; herr_t status; @@ -136,11 +136,11 @@ test_direct_chunk_write (hid_t file) size_t buf_size = CHUNK_NX*CHUNK_NY*sizeof(int); const Bytef *z_src = (const Bytef*)(direct_buf); - Bytef *z_dst = NULL; /*destination buffer */ - uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size); - uLong z_src_nbytes = (uLong)buf_size; + Bytef *z_dst = NULL; /*destination buffer */ + uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size); + uLong z_src_nbytes = (uLong)buf_size; int aggression = 9; /* Compression aggression setting */ - void *outbuf = NULL; /* Pointer to new buffer */ + void *outbuf = NULL; /* Pointer to new buffer */ hsize_t start[2]; /* Start of hyperslab */ hsize_t stride[2]; /* Stride of hyperslab */ @@ -175,29 +175,29 @@ test_direct_chunk_write (hid_t file) * creation properties. */ if((dataset = H5Dcreate2(file, DATASETNAME1, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + cparms, H5P_DEFAULT)) < 0) goto error; /* Initialize the dataset */ for(i = n = 0; i < NX; i++) for(j = 0; j < NY; j++) - data[i][j] = n++; + data[i][j] = n++; if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; /* * Write the data for the dataset. It should stay in the chunk cache. - * It will be evicted from the cache by the H5Dwrite_chunk calls. + * It will be evicted from the cache by the H5Dwrite_chunk calls. */ if((status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - dxpl, data)) < 0) + dxpl, data)) < 0) goto error; /* Initialize data for one chunk */ for(i = n = 0; i < CHUNK_NX; i++) for(j = 0; j < CHUNK_NY; j++) - direct_buf[i][j] = n++; + direct_buf[i][j] = n++; /* Allocate output (compressed) buffer */ outbuf = HDmalloc(z_dst_nbytes); @@ -218,8 +218,8 @@ test_direct_chunk_write (hid_t file) goto error; } - /* Write the compressed chunk data repeatedly to cover all the chunks in the - * dataset, using the direct writing function. */ + /* Write the compressed chunk data repeatedly to cover all the chunks in the + * dataset, using the direct writing function. */ for(i=0; i H5Fset_dset_no_attrs_hint(file, TRUE)) + /* Create the file for this test */ + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, my_fcpl, my_fapl)) < 0) goto error; - puts("(minimized dataset object headers with file setting)"); - } - /* Cause the library to emit initial messages */ - if((grp = H5Gcreate2(file, "emit diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; - if(H5Oset_comment(grp, "Causes diagnostic messages to be emitted") < 0) - goto error; - if(H5Gclose(grp) < 0) - goto error; + if (TRUE == minimized_ohdr) { + if (0 > H5Fset_dset_no_attrs_hint(file, TRUE)) + goto error; + puts("(minimized dataset object headers with file setting)"); + } - nerrors += (test_create(file) < 0 ? 1 : 0); - nerrors += (test_simple_io(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_compact_io(my_fapl) < 0 ? 1 : 0); - nerrors += (test_max_compact(my_fapl) < 0 ? 1 : 0); - nerrors += (test_compact_open_close_dirty(my_fapl) < 0 ? 1 : 0); - nerrors += (test_conv_buffer(file) < 0 ? 1 : 0); - nerrors += (test_tconv(file) < 0 ? 1 : 0); - nerrors += (test_filters(file, my_fapl) < 0 ? 1 : 0); - nerrors += (test_onebyte_shuffle(file) < 0 ? 1 : 0); - nerrors += (test_nbit_int(file) < 0 ? 1 : 0); - nerrors += (test_nbit_float(file) < 0 ? 1 : 0); - nerrors += (test_nbit_double(file) < 0 ? 1 : 0); - nerrors += (test_nbit_array(file) < 0 ? 1 : 0); - nerrors += (test_nbit_compound(file) < 0 ? 1 : 0); - nerrors += (test_nbit_compound_2(file) < 0 ? 1 : 0); - nerrors += (test_nbit_compound_3(file) < 0 ? 1 : 0); - nerrors += (test_nbit_int_size(file) < 0 ? 1 : 0); - nerrors += (test_nbit_flt_size(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_int(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_double_2(file) < 0 ? 1 : 0); - nerrors += (test_multiopen (file) < 0 ? 1 : 0); - nerrors += (test_types(file) < 0 ? 1 : 0); - nerrors += (test_userblock_offset(envval, my_fapl, new_format) < 0 ? 1 : 0); - nerrors += (test_missing_filter(file) < 0 ? 1 : 0); - nerrors += (test_can_apply(file) < 0 ? 1 : 0); - nerrors += (test_can_apply2(file) < 0 ? 1 : 0); - nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0); - nerrors += (test_can_apply_szip(file) < 0 ? 1 : 0); - nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0); - nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0); - nerrors += (test_filter_delete(file) < 0 ? 1 : 0); - nerrors += (test_filters_endianess() < 0 ? 1 : 0); - nerrors += (test_zero_dims(file) < 0 ? 1 : 0); - nerrors += (test_missing_chunk(file) < 0 ? 1 : 0); - nerrors += (test_random_chunks(my_fapl) < 0 ? 1 : 0); + /* Cause the library to emit initial messages */ + if((grp = H5Gcreate2(file, "emit diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if(H5Oset_comment(grp, "Causes diagnostic messages to be emitted") < 0) + goto error; + if(H5Gclose(grp) < 0) + goto error; + + nerrors += (test_create(file) < 0 ? 1 : 0); + nerrors += (test_simple_io(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_compact_io(my_fapl) < 0 ? 1 : 0); + nerrors += (test_max_compact(my_fapl) < 0 ? 1 : 0); + nerrors += (test_compact_open_close_dirty(my_fapl) < 0 ? 1 : 0); + nerrors += (test_conv_buffer(file) < 0 ? 1 : 0); + nerrors += (test_tconv(file) < 0 ? 1 : 0); + nerrors += (test_filters(file, my_fapl) < 0 ? 1 : 0); + nerrors += (test_onebyte_shuffle(file) < 0 ? 1 : 0); + nerrors += (test_nbit_int(file) < 0 ? 1 : 0); + nerrors += (test_nbit_float(file) < 0 ? 1 : 0); + nerrors += (test_nbit_double(file) < 0 ? 1 : 0); + nerrors += (test_nbit_array(file) < 0 ? 1 : 0); + nerrors += (test_nbit_compound(file) < 0 ? 1 : 0); + nerrors += (test_nbit_compound_2(file) < 0 ? 1 : 0); + nerrors += (test_nbit_compound_3(file) < 0 ? 1 : 0); + nerrors += (test_nbit_int_size(file) < 0 ? 1 : 0); + nerrors += (test_nbit_flt_size(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_int(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_double_2(file) < 0 ? 1 : 0); + nerrors += (test_multiopen (file) < 0 ? 1 : 0); + nerrors += (test_types(file) < 0 ? 1 : 0); + nerrors += (test_userblock_offset(envval, my_fapl, new_format) < 0 ? 1 : 0); + nerrors += (test_missing_filter(file) < 0 ? 1 : 0); + nerrors += (test_can_apply(file) < 0 ? 1 : 0); + nerrors += (test_can_apply2(file) < 0 ? 1 : 0); + nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0); + nerrors += (test_can_apply_szip(file) < 0 ? 1 : 0); + nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0); + nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0); + nerrors += (test_filter_delete(file) < 0 ? 1 : 0); + nerrors += (test_filters_endianess() < 0 ? 1 : 0); + nerrors += (test_zero_dims(file) < 0 ? 1 : 0); + nerrors += (test_missing_chunk(file) < 0 ? 1 : 0); + nerrors += (test_random_chunks(my_fapl) < 0 ? 1 : 0); #ifndef H5_NO_DEPRECATED_SYMBOLS - nerrors += (test_deprec(file) < 0 ? 1 : 0); + nerrors += (test_deprec(file) < 0 ? 1 : 0); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - nerrors += (test_huge_chunks(my_fapl) < 0 ? 1 : 0); - nerrors += (test_chunk_cache(my_fapl) < 0 ? 1 : 0); - nerrors += (test_big_chunks_bypass_cache(my_fapl) < 0 ? 1 : 0); - nerrors += (test_chunk_fast(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_reopen_chunk_fast(my_fapl) < 0 ? 1 : 0); - nerrors += (test_chunk_fast_bug1(my_fapl) < 0 ? 1 : 0); - nerrors += (test_chunk_expand(my_fapl) < 0 ? 1 : 0); - nerrors += (test_layout_extend(my_fapl) < 0 ? 1 : 0); - nerrors += (test_fixed_array(my_fapl) < 0 ? 1 : 0); - nerrors += (test_idx_compatible() < 0 ? 1 : 0); - nerrors += (test_unfiltered_edge_chunks(my_fapl) < 0 ? 1 : 0); - nerrors += (test_single_chunk(my_fapl) < 0 ? 1 : 0); - nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0); - nerrors += (test_zero_dim_dset(my_fapl) < 0 ? 1 : 0); - nerrors += (test_storage_size(my_fapl) < 0 ? 1 : 0); - nerrors += (test_power2up(my_fapl) < 0 ? 1 : 0); - - nerrors += (test_swmr_non_latest(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_earray_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_farray_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_bt2_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); - - if(H5Fclose(file) < 0) - goto error; - } /* end for new_format */ - } /* for minimized dset object headers */ + nerrors += (test_huge_chunks(my_fapl) < 0 ? 1 : 0); + nerrors += (test_chunk_cache(my_fapl) < 0 ? 1 : 0); + nerrors += (test_big_chunks_bypass_cache(my_fapl) < 0 ? 1 : 0); + nerrors += (test_chunk_fast(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_reopen_chunk_fast(my_fapl) < 0 ? 1 : 0); + nerrors += (test_chunk_fast_bug1(my_fapl) < 0 ? 1 : 0); + nerrors += (test_chunk_expand(my_fapl) < 0 ? 1 : 0); + nerrors += (test_layout_extend(my_fapl) < 0 ? 1 : 0); + nerrors += (test_fixed_array(my_fapl) < 0 ? 1 : 0); + nerrors += (test_idx_compatible() < 0 ? 1 : 0); + nerrors += (test_unfiltered_edge_chunks(my_fapl) < 0 ? 1 : 0); + nerrors += (test_single_chunk(my_fapl) < 0 ? 1 : 0); + nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0); + nerrors += (test_zero_dim_dset(my_fapl) < 0 ? 1 : 0); + nerrors += (test_storage_size(my_fapl) < 0 ? 1 : 0); + nerrors += (test_power2up(my_fapl) < 0 ? 1 : 0); + + nerrors += (test_swmr_non_latest(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_earray_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_farray_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_bt2_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); + + if(H5Fclose(file) < 0) + goto error; + } /* end for new_format */ + } /* end for minimized_ohdr */ } /* end for paged */ /* Close property lists */ @@ -13363,7 +13368,7 @@ main(void) nerrors += (test_gather_error() < 0 ? 1 : 0); /* Tests version bounds using its own file */ - nerrors += (test_versionbounds() < 0 ? 1 : 0); + nerrors += (test_versionbounds() < 0 ? 1 : 0); nerrors += (test_object_header_minimization_dcpl() < 0 ? 1 : 0); diff --git a/test/dt_arith.c b/test/dt_arith.c index 645608b..7e1adf5 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -21,7 +21,7 @@ #include "h5test.h" /* Number of elements in each random test */ -#define NTESTELEM 10000 +#define NTESTELEM 10000 /* Epsilon for floating-point comparisons */ #define FP_EPSILON 0.000001F @@ -30,7 +30,7 @@ * Offset from alinged memory returned by malloc(). This can be used to test * that type conversions handle non-aligned buffers correctly. */ -#define ALIGNMENT 1 +#define ALIGNMENT 1 /* * Define if you want to test alignment code on a machine that doesn't @@ -41,7 +41,7 @@ /* Alignment test stuff */ #ifdef TEST_ALIGNMENT -#define H5T_FRIEND /*suppress error about including H5Tpkg */ +#define H5T_FRIEND /*suppress error about including H5Tpkg */ #include "H5Tpkg.h" #endif #define SET_ALIGNMENT(TYPE,VAL) \ @@ -58,7 +58,7 @@ const char *FILENAME[] = { * endian. If local variable `endian' is H5T_ORDER_BE then the result will * be I, otherwise the result will be Z-(I+1). */ -#define ENDIAN(Z,I,E) (H5T_ORDER_BE==E?(I):(Z)-((I)+1)) +#define ENDIAN(Z,I,E) (H5T_ORDER_BE==E?(I):(Z)-((I)+1)) typedef enum dtype_t { INT_SCHAR, INT_UCHAR, INT_SHORT, INT_USHORT, INT_INT, INT_UINT, @@ -100,8 +100,8 @@ static int skip_overflow_tests_g = 0; static int without_hardware_g = 0; /* Allocates memory aligned on a certain boundary. */ -#define aligned_malloc(Z) ((void*)((char*)HDmalloc(ALIGNMENT+Z)+ALIGNMENT)) -#define aligned_free(M) HDfree((char*)(M)-ALIGNMENT) +#define aligned_malloc(Z) ((void*)((char*)HDmalloc(ALIGNMENT+Z)+ALIGNMENT)) +#define aligned_free(M) HDfree((char*)(M)-ALIGNMENT) /* Initialize source buffer of integer for integer->integer and integer->floating-point conversion test. * This algorithm is mainly to avoid any casting and comparison between source and destination types @@ -394,13 +394,13 @@ static int my_isinf(int endian, unsigned char *val, size_t size, size_t mpos, size_t msize, size_t epos, size_t esize); /*------------------------------------------------------------------------- - * Function: fpe_handler + * Function: fpe_handler * - * Purpose: Exit with 255 + * Purpose: Exit with 255 * - * Return: void + * Return: void * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, July 6, 1998 * * Modifications: @@ -419,16 +419,16 @@ fpe_handler(int H5_ATTR_UNUSED signo) HDexit(255); } - + /*------------------------------------------------------------------------- - * Function: reset_hdf5 + * Function: reset_hdf5 * - * Purpose: Reset the hdf5 library. This causes statistics to be printed - * and counters to be reset. + * Purpose: Reset the hdf5 library. This causes statistics to be printed + * and counters to be reset. * - * Return: void + * Return: void * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, November 16, 1998 * * Modifications: @@ -461,19 +461,19 @@ reset_hdf5(void) } - + /*------------------------------------------------------------------------- - * Function: except_func + * Function: except_func * - * Purpose: Gets called for all data type conversion exceptions. + * Purpose: Gets called for all data type conversion exceptions. * - * Return: H5T_CONV_ABORT: -1 + * Return: H5T_CONV_ABORT: -1 * * H5T_CONV_UNHANDLED 0 * * H5T_CONV_HANDLED 1 * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * April 19, 2004 * * Modifications: @@ -482,7 +482,7 @@ reset_hdf5(void) */ static H5T_conv_ret_t except_func(H5T_conv_except_t except_type, hid_t H5_ATTR_UNUSED src_id, hid_t H5_ATTR_UNUSED dst_id, void H5_ATTR_UNUSED *src_buf, - void *dst_buf, void *user_data) + void *dst_buf, void *user_data) { H5T_conv_ret_t ret = H5T_CONV_HANDLED; @@ -509,19 +509,19 @@ except_func(H5T_conv_except_t except_type, hid_t H5_ATTR_UNUSED src_id, hid_t H5 return ret; } - + /*------------------------------------------------------------------------- - * Function: some_dummy_func + * Function: some_dummy_func * - * Purpose: A dummy function to help check for overflow. + * Purpose: A dummy function to help check for overflow. * - * Note: DO NOT DECLARE THIS FUNCTION STATIC OR THE COMPILER MIGHT - * PROMOTE ARGUMENT `x' TO DOUBLE AND DEFEAT THE OVERFLOW - * CHECKING. + * Note: DO NOT DECLARE THIS FUNCTION STATIC OR THE COMPILER MIGHT + * PROMOTE ARGUMENT `x' TO DOUBLE AND DEFEAT THE OVERFLOW + * CHECKING. * - * Return: void + * Return: void * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Tuesday, July 21, 1998 * *------------------------------------------------------------------------- @@ -529,21 +529,21 @@ except_func(H5T_conv_except_t except_type, hid_t H5_ATTR_UNUSED src_id, hid_t H5 void some_dummy_func(float x) { - char s[128]; + char s[128]; HDsnprintf(s, sizeof(s), "%g", (double)x); } - + /*------------------------------------------------------------------------- - * Function: generates_sigfpe + * Function: generates_sigfpe * - * Purpose: Determines if SIGFPE is generated from overflows. We must be - * able to fork() and waitpid() in order for this test to work - * properly. Sets skip_overflow_tests_g to non-zero if they - * would generate SIGBUS, zero otherwise. + * Purpose: Determines if SIGFPE is generated from overflows. We must be + * able to fork() and waitpid() in order for this test to work + * properly. Sets skip_overflow_tests_g to non-zero if they + * would generate SIGBUS, zero otherwise. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Tuesday, July 21, 1998 * * Modifications: @@ -554,38 +554,38 @@ static void generates_sigfpe(void) { #if defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID) - pid_t pid; - int status; - size_t i, j; - double d; + pid_t pid; + int status; + size_t i, j; + double d; unsigned char *dp = (unsigned char*)&d; - float f; + float f; HDfflush(stdout); HDfflush(stderr); if ((pid=fork()) < 0) { - HDperror("fork"); - HDexit(EXIT_FAILURE); + HDperror("fork"); + HDexit(EXIT_FAILURE); } else if (0==pid) { - for (i=0; i<2000; i++) { - for(j = 0; j < sizeof(double); j++) + for (i=0; i<2000; i++) { + for(j = 0; j < sizeof(double); j++) dp[j] = (unsigned char)HDrand(); - f = (float)d; - some_dummy_func((float)f); - } - HDexit(EXIT_SUCCESS); + f = (float)d; + some_dummy_func((float)f); + } + HDexit(EXIT_SUCCESS); } while (pid!=waitpid(pid, &status, 0)) /*void*/; if (WIFEXITED(status) && 0==WEXITSTATUS(status)) { - HDputs("Floating-point overflow cases will be tested."); - skip_overflow_tests_g = FALSE; + HDputs("Floating-point overflow cases will be tested."); + skip_overflow_tests_g = FALSE; } else if (WIFSIGNALED(status) && SIGFPE==WTERMSIG(status)) { - HDputs("Floating-point overflow cases cannot be safely tested."); - skip_overflow_tests_g = TRUE; - /* delete the core dump file that SIGFPE may have created */ - HDunlink("core"); + HDputs("Floating-point overflow cases cannot be safely tested."); + skip_overflow_tests_g = TRUE; + /* delete the core dump file that SIGFPE may have created */ + HDunlink("core"); } #else HDputs("Cannot determine if floating-point overflows generate a SIGFPE;"); @@ -595,7 +595,7 @@ generates_sigfpe(void) #endif } - + /*------------------------------------------------------------------------- * Function: test_hard_query * @@ -621,7 +621,7 @@ test_hard_query(void) /* Verify the conversion from int to float is a hard conversion. */ if(H5Tcompiler_conv(H5T_NATIVE_INT, H5T_NATIVE_FLOAT) != TRUE) { H5_FAILED(); - printf("Can't query conversion function\n"); + HDprintf("Can't query conversion function\n"); goto error; } @@ -630,7 +630,7 @@ test_hard_query(void) H5Tunregister(H5T_PERS_HARD, NULL, H5T_NATIVE_INT, H5T_NATIVE_FLOAT, (H5T_conv_t)((void (*) (void))H5T__conv_int_float)); if(H5Tcompiler_conv(H5T_NATIVE_INT, H5T_NATIVE_FLOAT) != FALSE) { H5_FAILED(); - printf("Can't query conversion function\n"); + HDprintf("Can't query conversion function\n"); goto error; } @@ -639,7 +639,7 @@ test_hard_query(void) H5Tregister(H5T_PERS_HARD, "int_flt", H5T_NATIVE_INT, H5T_NATIVE_FLOAT, (H5T_conv_t)((void (*) (void))H5T__conv_int_float)); if(H5Tcompiler_conv(H5T_NATIVE_INT, H5T_NATIVE_FLOAT) != TRUE) { H5_FAILED(); - printf("Can't query conversion function\n"); + HDprintf("Can't query conversion function\n"); goto error; } @@ -660,16 +660,16 @@ error: return 1; } - + /*------------------------------------------------------------------------- - * Function: expt_handle + * Function: expt_handle * - * Purpose: Gets called from test_particular_fp_integer() for data type + * Purpose: Gets called from test_particular_fp_integer() for data type * conversion exceptions. * - * Return: H5T_CONV_HANDLED 1 + * Return: H5T_CONV_HANDLED 1 * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Sept 7, 2005 * * Modifications: @@ -678,7 +678,7 @@ error: */ static H5T_conv_ret_t expt_handle(H5T_conv_except_t except_type, hid_t H5_ATTR_UNUSED src_id, hid_t H5_ATTR_UNUSED dst_id, void H5_ATTR_UNUSED *src_buf, - void *dst_buf, void *user_data) + void *dst_buf, void *user_data) { signed char fill_value1 = 7; int fill_value2 = 13; @@ -694,7 +694,7 @@ expt_handle(H5T_conv_except_t except_type, hid_t H5_ATTR_UNUSED src_id, hid_t H5 return H5T_CONV_HANDLED; } - + /*------------------------------------------------------------------------- * Function: test_particular_fp_integer * @@ -714,12 +714,6 @@ expt_handle(H5T_conv_except_t except_type, hid_t H5_ATTR_UNUSED src_id, hid_t H5 * Return: Success: 0 * * Failure: number of errors - * - * Programmer: Raymond Lu - * Sept 7, 2005 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int test_particular_fp_integer(void) @@ -735,7 +729,7 @@ static int test_particular_fp_integer(void) float src_f = (float)INT_MAX; int dst_i; int fill_value = 13; - int endian; /*endianess */ + int endian; /*endianess */ unsigned int fails_this_test = 0; size_t j; @@ -743,7 +737,7 @@ static int test_particular_fp_integer(void) if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) { H5_FAILED(); - printf("Can't create data transfer property list\n"); + HDprintf("Can't create data transfer property list\n"); goto error; } @@ -754,25 +748,25 @@ static int test_particular_fp_integer(void) buf1 = (unsigned char*)HDcalloc((size_t)1, (size_t)MAX(src_size1, dst_size1)); saved_buf1 = (unsigned char*)HDcalloc((size_t)1, (size_t)MAX(src_size1, dst_size1)); - memcpy(buf1, &src_d, src_size1); - memcpy(saved_buf1, &src_d, src_size1); + HDmemcpy(buf1, &src_d, src_size1); + HDmemcpy(saved_buf1, &src_d, src_size1); /* Register exception handling function and signal the destination is "signed char". */ flag = 1; if(H5Pset_type_conv_cb(dxpl_id, expt_handle, &flag) < 0) { H5_FAILED(); - printf("Can't register conversion callback\n"); + HDprintf("Can't register conversion callback\n"); goto error; } /* Do conversion */ if(H5Tconvert(H5T_NATIVE_DOUBLE, H5T_NATIVE_SCHAR, (size_t)1, buf1, NULL, dxpl_id) < 0) { H5_FAILED(); - printf("Can't convert data\n"); + HDprintf("Can't convert data\n"); goto error; } - memcpy(&dst_c, buf1, dst_size1); + HDmemcpy(&dst_c, buf1, dst_size1); /* Print errors */ if(dst_c != SCHAR_MAX) { @@ -782,20 +776,20 @@ static int test_particular_fp_integer(void) if(0 == fails_this_test++) H5_FAILED(); - printf(" test double to signed char:\n"); - printf(" src = "); + HDprintf(" test double to signed char:\n"); + HDprintf(" src = "); for (j=0; j derived floating-point conversions"); - printf("%-70s", str); - HDfflush(stdout); + HDsnprintf(str, sizeof(str), "\nTesting random sw derived floating-point -> derived floating-point conversions"); + HDprintf("%-70s", str); + HDfflush(stdout); H5_FAILED(); } - printf(" test %u elmt %u: \n", 1, (unsigned)i); + HDprintf(" test %u elmt %u: \n", 1, (unsigned)i); - printf(" src = "); + HDprintf(" src = "); for (j=0; j=max_fails) { HDputs(" maximum failures reached, aborting test..."); @@ -1127,43 +1121,43 @@ test_derived_flt(void) *--------------------------------------------------------------------------*/ if(H5Tset_fields(tid2, (size_t)23, (size_t)16, (size_t)7, (size_t)0, (size_t)16) < 0) { H5_FAILED(); - printf("Can't set fields\n"); + HDprintf("Can't set fields\n"); goto error; } if(H5Tset_offset(tid2, (size_t)0) < 0) { H5_FAILED(); - printf("Can't set offset\n"); + HDprintf("Can't set offset\n"); goto error; } if(H5Tset_precision(tid2, (size_t)24) < 0) { H5_FAILED(); - printf("Can't set precision 2\n"); + HDprintf("Can't set precision 2\n"); goto error; } if(H5Tset_size(tid2, (size_t)3) < 0) { H5_FAILED(); - printf("Can't set size\n"); + HDprintf("Can't set size\n"); goto error; } if(H5Tset_ebias(tid2, (size_t)63) < 0) { H5_FAILED(); - printf("Can't set size\n"); + HDprintf("Can't set size\n"); goto error; } if(H5Tset_pad(tid2, H5T_PAD_ZERO, H5T_PAD_ZERO) < 0) { H5_FAILED(); - printf("Can't set padding\n"); + HDprintf("Can't set padding\n"); goto error; } if(H5Tcommit2(file, "new float type 2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5_FAILED(); - printf("Can't set inpad\n"); + HDprintf("Can't set inpad\n"); goto error; } if(H5Tclose(tid2) < 0) { H5_FAILED(); - printf("Can't close datatype\n"); + HDprintf("Can't close datatype\n"); goto error; } @@ -1171,33 +1165,33 @@ test_derived_flt(void) FAIL_PUTS_ERROR("Can't open datatype") if(H5Tget_fields(tid2, &spos, &epos, &esize, &mpos, &msize) < 0) { H5_FAILED(); - printf("Can't get fields\n"); + HDprintf("Can't get fields\n"); goto error; } if(spos != 23 || epos != 16 || esize != 7 || mpos != 0 || msize != 16) { H5_FAILED(); - printf("Wrong field values\n"); + HDprintf("Wrong field values\n"); goto error; } if(H5Tget_precision(tid2) != 24) { H5_FAILED(); - printf("Can't get precision or wrong precision\n"); + HDprintf("Can't get precision or wrong precision\n"); goto error; } if(H5Tget_offset(tid2)!=0) { H5_FAILED(); - printf("Can't get offset or wrong offset\n"); + HDprintf("Can't get offset or wrong offset\n"); goto error; } if((size = H5Tget_size(tid2))!=3) { H5_FAILED(); - printf("Can't get size or wrong size\n"); + HDprintf("Can't get size or wrong size\n"); goto error; } if(H5Tget_ebias(tid2)!=63) { H5_FAILED(); - printf("Can't get exponent bias or wrong bias\n"); + HDprintf("Can't get exponent bias or wrong bias\n"); goto error; } @@ -1221,13 +1215,13 @@ test_derived_flt(void) * the precision and exponent power. */ if(H5Tconvert(tid2, tid1, nelmts, buf, NULL, dxpl_id) < 0) { H5_FAILED(); - printf("Can't convert data\n"); + HDprintf("Can't convert data\n"); goto error; } /* Convert data from the 1st back to the 2nd derived floating-point type. */ if(H5Tconvert(tid1, tid2, nelmts, buf, NULL, dxpl_id) < 0) { H5_FAILED(); - printf("Can't convert data\n"); + HDprintf("Can't convert data\n"); goto error; } @@ -1249,22 +1243,22 @@ test_derived_flt(void) /* Print errors */ if (0==fails_this_test++) { - HDsnprintf(str, sizeof(str), "\nTesting random sw derived floating-point -> derived floating-point conversions"); - printf("%-70s", str); - HDfflush(stdout); + HDsnprintf(str, sizeof(str), "\nTesting random sw derived floating-point -> derived floating-point conversions"); + HDprintf("%-70s", str); + HDfflush(stdout); H5_FAILED(); } - printf(" test %u elmt %u: \n", 1, (unsigned)i); + HDprintf(" test %u elmt %u: \n", 1, (unsigned)i); - printf(" src = "); + HDprintf(" src = "); for (j=0; j=max_fails) { HDputs(" maximum failures reached, aborting test..."); @@ -1277,25 +1271,25 @@ test_derived_flt(void) if(H5Tclose(tid1) < 0) { H5_FAILED(); - printf("Can't close datatype\n"); + HDprintf("Can't close datatype\n"); goto error; } if(H5Tclose(tid2) < 0) { H5_FAILED(); - printf("Can't close datatype\n"); + HDprintf("Can't close datatype\n"); goto error; } if(H5Pclose(dxpl_id) < 0) { H5_FAILED(); - printf("Can't close property list\n"); + HDprintf("Can't close property list\n"); goto error; } if(H5Fclose(file) < 0) { H5_FAILED(); - printf("Can't close file\n"); + HDprintf("Can't close file\n"); goto error; } /* end if */ @@ -1304,7 +1298,7 @@ test_derived_flt(void) /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); - reset_hdf5(); /*print statistics*/ + reset_hdf5(); /*print statistics*/ return 0; @@ -1328,7 +1322,7 @@ test_derived_flt(void) return MAX((int)fails_this_test, 1); } - + /*------------------------------------------------------------------------- * Function: test_derived_integer * @@ -1353,11 +1347,11 @@ test_derived_integer(void) char filename[1024]; size_t src_size, dst_size; unsigned char *buf=NULL, *saved_buf=NULL; - int endian; /*endianess */ + int endian; /*endianess */ size_t nelmts = NTESTELEM; unsigned int fails_this_test = 0; - const size_t max_fails=40; /*max number of failures*/ - char str[256]; /*message string */ + const size_t max_fails=40; /*max number of failures*/ + char str[256]; /*message string */ unsigned int i, j; TESTING("user-define and query functions of integer types"); @@ -1366,25 +1360,25 @@ test_derived_integer(void) h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof filename); if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); - printf("Can't create file\n"); + HDprintf("Can't create file\n"); goto error; } if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) { H5_FAILED(); - printf("Can't create data transfer property list\n"); + HDprintf("Can't create data transfer property list\n"); goto error; } if((tid1 = H5Tcopy(H5T_STD_I32LE)) < 0) { H5_FAILED(); - printf("Can't copy data type\n"); + HDprintf("Can't copy data type\n"); goto error; } if((tid2 = H5Tcopy(H5T_STD_U64LE)) < 0) { H5_FAILED(); - printf("Can't copy data type\n"); + HDprintf("Can't copy data type\n"); goto error; } @@ -1402,37 +1396,37 @@ test_derived_integer(void) *--------------------------------------------------------------------------*/ if(H5Tset_offset(tid1, (size_t)0) < 0) { H5_FAILED(); - printf("Can't set offset\n"); + HDprintf("Can't set offset\n"); goto error; } if(H5Tset_size(tid1, (size_t)3) < 0) { H5_FAILED(); - printf("Can't set size\n"); + HDprintf("Can't set size\n"); goto error; } if(H5Tset_precision(tid1, (size_t)24) < 0) { H5_FAILED(); - printf("Can't set precision\n"); + HDprintf("Can't set precision\n"); goto error; } if(H5Tset_order(tid1, H5T_ORDER_BE) < 0) { H5_FAILED(); - printf("Can't set order\n"); + HDprintf("Can't set order\n"); goto error; } if(H5Tcommit2(file, "new integer type 1", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5_FAILED(); - printf("Can't commit data type\n"); + HDprintf("Can't commit data type\n"); goto error; } if(H5Tclose(tid1) < 0) { H5_FAILED(); - printf("Can't close datatype\n"); + HDprintf("Can't close datatype\n"); goto error; } @@ -1440,22 +1434,22 @@ test_derived_integer(void) FAIL_PUTS_ERROR("Can't open datatype") if(H5Tget_precision(tid1) != 24) { H5_FAILED(); - printf("Can't get precision or wrong precision\n"); + HDprintf("Can't get precision or wrong precision\n"); goto error; } if(H5Tget_offset(tid1) != 0) { H5_FAILED(); - printf("Can't get offset or wrong offset\n"); + HDprintf("Can't get offset or wrong offset\n"); goto error; } if(H5Tget_size(tid1) != 3) { H5_FAILED(); - printf("Can't get size or wrong size\n"); + HDprintf("Can't get size or wrong size\n"); goto error; } if(H5Tget_order(tid1)!=H5T_ORDER_BE) { H5_FAILED(); - printf("Can't get order or wrong order\n"); + HDprintf("Can't get order or wrong order\n"); goto error; } @@ -1469,31 +1463,31 @@ test_derived_integer(void) *--------------------------------------------------------------------------*/ if(H5Tset_precision(tid2, (size_t)48) < 0) { H5_FAILED(); - printf("Can't set precision\n"); + HDprintf("Can't set precision\n"); goto error; } if(H5Tset_offset(tid2, (size_t)10) < 0) { H5_FAILED(); - printf("Can't set offset\n"); + HDprintf("Can't set offset\n"); goto error; } if(H5Tset_sign(tid2, H5T_SGN_2) < 0) { H5_FAILED(); - printf("Can't set offset\n"); + HDprintf("Can't set offset\n"); goto error; } if(H5Tcommit2(file, "new integer type 2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5_FAILED(); - printf("Can't commit data type\n"); + HDprintf("Can't commit data type\n"); goto error; } if(H5Tclose(tid2) < 0) { H5_FAILED(); - printf("Can't close datatype\n"); + HDprintf("Can't close datatype\n"); goto error; } @@ -1501,22 +1495,22 @@ test_derived_integer(void) FAIL_PUTS_ERROR("Can't open datatype") if(H5Tget_precision(tid2) != 48) { H5_FAILED(); - printf("Can't get precision or wrong precision\n"); + HDprintf("Can't get precision or wrong precision\n"); goto error; } if(H5Tget_offset(tid2) != 10) { H5_FAILED(); - printf("Can't get offset or wrong offset\n"); + HDprintf("Can't get offset or wrong offset\n"); goto error; } if(H5Tget_size(tid2) != 8) { H5_FAILED(); - printf("Can't get size or wrong size\n"); + HDprintf("Can't get size or wrong size\n"); goto error; } if(H5Tget_sign(tid2)!=H5T_SGN_2) { H5_FAILED(); - printf("Can't get sign or wrong sign\n"); + HDprintf("Can't get sign or wrong sign\n"); goto error; } @@ -1540,13 +1534,13 @@ test_derived_integer(void) * the 1st type's precision. */ if(H5Tconvert(tid1, tid2, nelmts, buf, NULL, dxpl_id) < 0) { H5_FAILED(); - printf("Can't convert data\n"); + HDprintf("Can't convert data\n"); goto error; } /* Convert data from the 2nd back to the 1st derived integer type. */ if(H5Tconvert(tid2, tid1, nelmts, buf, NULL, dxpl_id) < 0) { H5_FAILED(); - printf("Can't convert data\n"); + HDprintf("Can't convert data\n"); goto error; } @@ -1560,22 +1554,22 @@ test_derived_integer(void) /* Print errors */ if (0==fails_this_test++) { - HDsnprintf(str, sizeof(str), "\nTesting random sw derived integer -> derived integer conversions"); - printf("%-70s", str); - HDfflush(stdout); + HDsnprintf(str, sizeof(str), "\nTesting random sw derived integer -> derived integer conversions"); + HDprintf("%-70s", str); + HDfflush(stdout); H5_FAILED(); } - printf(" test %u elmt %u: \n", 1, (unsigned)i); + HDprintf(" test %u elmt %u: \n", 1, (unsigned)i); - printf(" src = "); + HDprintf(" src = "); for (j=0; j=max_fails) { HDputs(" maximum failures reached, aborting test..."); @@ -1585,25 +1579,25 @@ test_derived_integer(void) if(H5Tclose(tid1) < 0) { H5_FAILED(); - printf("Can't close datatype\n"); + HDprintf("Can't close datatype\n"); goto error; } if(H5Tclose(tid2) < 0) { H5_FAILED(); - printf("Can't close datatype\n"); + HDprintf("Can't close datatype\n"); goto error; } if(H5Pclose(dxpl_id) < 0) { H5_FAILED(); - printf("Can't close property list\n"); + HDprintf("Can't close property list\n"); goto error; } if(H5Fclose(file) < 0) { H5_FAILED(); - printf("Can't close file\n"); + HDprintf("Can't close file\n"); goto error; } /* end if */ @@ -1615,7 +1609,7 @@ test_derived_integer(void) /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); - reset_hdf5(); /*print statistics*/ + reset_hdf5(); /*print statistics*/ return 0; @@ -1638,24 +1632,24 @@ test_derived_integer(void) return MAX((int)fails_this_test, 1); } - + /*------------------------------------------------------------------------- - * Function: test_conv_int_1 + * Function: test_conv_int_1 * - * Purpose: Test conversion of integer values from SRC to DST. - * These types should be any combination of: + * Purpose: Test conversion of integer values from SRC to DST. + * These types should be any combination of: * - * H5T_NATIVE_SCHAR H5T_NATIVE_UCHAR - * H5T_NATIVE_SHORT H5T_NATIVE_USHORT - * H5T_NATIVE_INT H5T_NATIVE_UINT - * H5T_NATIVE_LONG H5T_NATIVE_ULONG - * H5T_NATIVE_LLONG H5T_NATIVE_ULLONG + * H5T_NATIVE_SCHAR H5T_NATIVE_UCHAR + * H5T_NATIVE_SHORT H5T_NATIVE_USHORT + * H5T_NATIVE_INT H5T_NATIVE_UINT + * H5T_NATIVE_LONG H5T_NATIVE_ULONG + * H5T_NATIVE_LLONG H5T_NATIVE_ULLONG * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: number of errors + * Failure: number of errors * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, November 16, 1998 * * Modifications: @@ -1665,121 +1659,121 @@ test_derived_integer(void) static int test_conv_int_1(const char *name, hid_t src, hid_t dst) { - size_t nelmts=0; /*num values per test */ - const size_t max_fails=8; /*max number of failures*/ - size_t fails_all_tests=0; /*number of failures */ - size_t fails_this_test; /*fails for this test */ - char str[256]; /*hello string */ - dtype_t src_type, dst_type; /*data types */ - const char *src_type_name=NULL; /*source type name */ - const char *dst_type_name=NULL; /*destination type name */ - int endian; /*machine endianess */ - size_t src_size, dst_size; /*type sizes */ - unsigned char *buf=NULL; /*buffer for conversion */ - unsigned char *saved=NULL; /*original values */ - size_t j, k; /*counters */ - unsigned char *hw=NULL; /*hardware conv result */ - unsigned char src_bits[32]; /*src value in LE order */ - unsigned char dst_bits[32]; /*dest value in LE order*/ - size_t src_nbits; /*source length in bits */ - size_t dst_nbits; /*dst length in bits */ + size_t nelmts=0; /*num values per test */ + const size_t max_fails=8; /*max number of failures*/ + size_t fails_all_tests=0; /*number of failures */ + size_t fails_this_test; /*fails for this test */ + char str[256]; /*hello string */ + dtype_t src_type, dst_type; /*data types */ + const char *src_type_name=NULL; /*source type name */ + const char *dst_type_name=NULL; /*destination type name */ + int endian; /*machine endianess */ + size_t src_size, dst_size; /*type sizes */ + unsigned char *buf=NULL; /*buffer for conversion */ + unsigned char *saved=NULL; /*original values */ + size_t j, k; /*counters */ + unsigned char *hw=NULL; /*hardware conv result */ + unsigned char src_bits[32]; /*src value in LE order */ + unsigned char dst_bits[32]; /*dest value in LE order*/ + size_t src_nbits; /*source length in bits */ + size_t dst_nbits; /*dst length in bits */ H5T_sign_t src_sign; /*source sign type */ H5T_sign_t dst_sign; /*dst sign type */ - void *aligned=NULL; /*aligned temp buffer */ - signed char hw_char; - unsigned char hw_uchar; - short hw_short; - unsigned short hw_ushort; - int hw_int; - unsigned hw_uint; - long hw_long; - unsigned long hw_ulong; - long long hw_llong; - unsigned long long hw_ullong; + void *aligned=NULL; /*aligned temp buffer */ + signed char hw_char; + unsigned char hw_uchar; + short hw_short; + unsigned short hw_ushort; + int hw_int; + unsigned hw_uint; + long hw_long; + unsigned long hw_ulong; + long long hw_llong; + unsigned long long hw_ullong; /* What are the names of the source and destination types */ if (H5Tequal(src, H5T_NATIVE_SCHAR)) { - src_type_name = "signed char"; - src_type = INT_SCHAR; + src_type_name = "signed char"; + src_type = INT_SCHAR; } else if (H5Tequal(src, H5T_NATIVE_UCHAR)) { - src_type_name = "unsigned char"; - src_type = INT_UCHAR; + src_type_name = "unsigned char"; + src_type = INT_UCHAR; } else if (H5Tequal(src, H5T_NATIVE_SHORT)) { - src_type_name = "short"; - src_type = INT_SHORT; + src_type_name = "short"; + src_type = INT_SHORT; } else if (H5Tequal(src, H5T_NATIVE_USHORT)) { - src_type_name = "unsigned short"; - src_type = INT_USHORT; + src_type_name = "unsigned short"; + src_type = INT_USHORT; } else if (H5Tequal(src, H5T_NATIVE_INT)) { - src_type_name = "int"; - src_type = INT_INT; + src_type_name = "int"; + src_type = INT_INT; } else if (H5Tequal(src, H5T_NATIVE_UINT)) { - src_type_name = "unsigned int"; - src_type = INT_UINT; + src_type_name = "unsigned int"; + src_type = INT_UINT; } else if (H5Tequal(src, H5T_NATIVE_LONG)) { - src_type_name = "long"; - src_type = INT_LONG; + src_type_name = "long"; + src_type = INT_LONG; } else if (H5Tequal(src, H5T_NATIVE_ULONG)) { - src_type_name = "unsigned long"; - src_type = INT_ULONG; + src_type_name = "unsigned long"; + src_type = INT_ULONG; } else if (H5Tequal(src, H5T_NATIVE_LLONG)) { - src_type_name = "long long"; - src_type = INT_LLONG; + src_type_name = "long long"; + src_type = INT_LLONG; } else if (H5Tequal(src, H5T_NATIVE_ULLONG)) { - src_type_name = "unsigned long long"; - src_type = INT_ULLONG; + src_type_name = "unsigned long long"; + src_type = INT_ULLONG; } else { - src_type_name = "UNKNOWN"; - src_type = OTHER; + src_type_name = "UNKNOWN"; + src_type = OTHER; } if (H5Tequal(dst, H5T_NATIVE_SCHAR)) { - dst_type_name = "signed char"; - dst_type = INT_SCHAR; + dst_type_name = "signed char"; + dst_type = INT_SCHAR; } else if (H5Tequal(dst, H5T_NATIVE_UCHAR)) { - dst_type_name = "unsigned char"; - dst_type = INT_UCHAR; + dst_type_name = "unsigned char"; + dst_type = INT_UCHAR; } else if (H5Tequal(dst, H5T_NATIVE_SHORT)) { - dst_type_name = "short"; - dst_type = INT_SHORT; + dst_type_name = "short"; + dst_type = INT_SHORT; } else if (H5Tequal(dst, H5T_NATIVE_USHORT)) { - dst_type_name = "unsigned short"; - dst_type = INT_USHORT; + dst_type_name = "unsigned short"; + dst_type = INT_USHORT; } else if (H5Tequal(dst, H5T_NATIVE_INT)) { - dst_type_name = "int"; - dst_type = INT_INT; + dst_type_name = "int"; + dst_type = INT_INT; } else if (H5Tequal(dst, H5T_NATIVE_UINT)) { - dst_type_name = "unsigned int"; - dst_type = INT_UINT; + dst_type_name = "unsigned int"; + dst_type = INT_UINT; } else if (H5Tequal(dst, H5T_NATIVE_LONG)) { - dst_type_name = "long"; - dst_type = INT_LONG; + dst_type_name = "long"; + dst_type = INT_LONG; } else if (H5Tequal(dst, H5T_NATIVE_ULONG)) { - dst_type_name = "unsigned long"; - dst_type = INT_ULONG; + dst_type_name = "unsigned long"; + dst_type = INT_ULONG; } else if (H5Tequal(dst, H5T_NATIVE_LLONG)) { - dst_type_name = "long long"; - dst_type = INT_LLONG; + dst_type_name = "long long"; + dst_type = INT_LLONG; } else if (H5Tequal(dst, H5T_NATIVE_ULLONG)) { - dst_type_name = "unsigned long long"; - dst_type = INT_ULLONG; + dst_type_name = "unsigned long long"; + dst_type = INT_ULLONG; } else { - dst_type_name = "UNKNOWN"; - dst_type = OTHER; + dst_type_name = "UNKNOWN"; + dst_type = OTHER; } /* Sanity checks */ if (OTHER==src_type || OTHER==dst_type) { - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, src_type_name, dst_type_name); - printf("%-70s", str); - H5_FAILED(); - HDputs(" Unknown data type."); - goto error; + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", + name, src_type_name, dst_type_name); + HDprintf("%-70s", str); + H5_FAILED(); + HDputs(" Unknown data type."); + goto error; } else { HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, src_type_name, dst_type_name); - printf("%-70s", str); + HDprintf("%-70s", str); HDfflush(stdout); fails_this_test=0; } @@ -2462,44 +2456,44 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) /* Print errors */ if (0==fails_this_test++) H5_FAILED(); - printf(" elmt %u\n", (unsigned)j); + HDprintf(" elmt %u\n", (unsigned)j); - printf(" src = "); + HDprintf(" src = "); for (k=0; k0) { - while (child_pid!=waitpid(child_pid, &status, 0)) /*void*/; - if (WIFEXITED(status) && 255==WEXITSTATUS(status)) { - return 0; /*child exit after catching SIGFPE*/ - } else if (WIFEXITED(status)) { - return WEXITSTATUS(status); - } else if (WIFSIGNALED(status)) { - HDsnprintf(str, sizeof(str), " Child caught signal %d.", WTERMSIG(status)); - HDputs(str); - return 1; /*child exit after catching non-SIGFPE signal */ - } else { - HDputs(" Child didn't exit normally."); - return 1; - } + while (child_pid!=waitpid(child_pid, &status, 0)) /*void*/; + if (WIFEXITED(status) && 255==WEXITSTATUS(status)) { + return 0; /*child exit after catching SIGFPE*/ + } else if (WIFEXITED(status)) { + return WEXITSTATUS(status); + } else if (WIFSIGNALED(status)) { + HDsnprintf(str, sizeof(str), " Child caught signal %d.", WTERMSIG(status)); + HDputs(str); + return 1; /*child exit after catching non-SIGFPE signal */ + } else { + HDputs(" Child didn't exit normally."); + return 1; + } } #endif @@ -2916,35 +2910,35 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) /* What are the names of the source and destination types */ if (H5Tequal(src, H5T_NATIVE_FLOAT)) { - src_type_name = "float"; - src_type = FLT_FLOAT; + src_type_name = "float"; + src_type = FLT_FLOAT; } else if (H5Tequal(src, H5T_NATIVE_DOUBLE)) { - src_type_name = "double"; - src_type = FLT_DOUBLE; + src_type_name = "double"; + src_type = FLT_DOUBLE; #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 } else if (H5Tequal(src, H5T_NATIVE_LDOUBLE)) { - src_type_name = "long double"; - src_type = FLT_LDOUBLE; + src_type_name = "long double"; + src_type = FLT_LDOUBLE; #endif } else { - src_type_name = "UNKNOWN"; - src_type = OTHER; + src_type_name = "UNKNOWN"; + src_type = OTHER; } if (H5Tequal(dst, H5T_NATIVE_FLOAT)) { - dst_type_name = "float"; - dst_type = FLT_FLOAT; + dst_type_name = "float"; + dst_type = FLT_FLOAT; } else if (H5Tequal(dst, H5T_NATIVE_DOUBLE)) { - dst_type_name = "double"; - dst_type = FLT_DOUBLE; + dst_type_name = "double"; + dst_type = FLT_DOUBLE; #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 } else if (H5Tequal(dst, H5T_NATIVE_LDOUBLE)) { - dst_type_name = "long double"; - dst_type = FLT_LDOUBLE; + dst_type_name = "long double"; + dst_type = FLT_LDOUBLE; #endif } else { - dst_type_name = "UNKNOWN"; - dst_type = OTHER; + dst_type_name = "UNKNOWN"; + dst_type = OTHER; } /* Sanity checks */ @@ -2952,22 +2946,22 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) HDputs("Sizeof(float)==sizeof(double) - some tests may not be sensible."); if (OTHER==src_type || OTHER==dst_type) { if(!strcmp(name, "noop")) - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, src_type_name, dst_type_name); + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", + name, src_type_name, dst_type_name); else if(run_test==TEST_SPECIAL) - HDsnprintf(str, sizeof(str), "Testing %s special %s -> %s conversions", - name, src_type_name, dst_type_name); + HDsnprintf(str, sizeof(str), "Testing %s special %s -> %s conversions", + name, src_type_name, dst_type_name); else if(run_test==TEST_NORMAL) - HDsnprintf(str, sizeof(str), "Testing %s normalized %s -> %s conversions", - name, src_type_name, dst_type_name); + HDsnprintf(str, sizeof(str), "Testing %s normalized %s -> %s conversions", + name, src_type_name, dst_type_name); else if(run_test==TEST_DENORM) - HDsnprintf(str, sizeof(str), "Testing %s denormalized %s -> %s conversions", - name, src_type_name, dst_type_name); + HDsnprintf(str, sizeof(str), "Testing %s denormalized %s -> %s conversions", + name, src_type_name, dst_type_name); - printf("%-70s", str); - H5_FAILED(); - HDputs(" Unknown data type."); - goto error; + HDprintf("%-70s", str); + H5_FAILED(); + HDputs(" Unknown data type."); + goto error; } else { if(!strcmp(name, "noop")) HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", @@ -2982,7 +2976,7 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) HDsnprintf(str, sizeof(str), "Testing %s denormalized %s -> %s conversions", name, src_type_name, dst_type_name); - printf("%-70s", str); + HDprintf("%-70s", str); HDfflush(stdout); fails_this_test = 0; } @@ -3199,18 +3193,18 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) * the SGI compiler assigns the dst's maximal value. */ { - double check_mant[2]; - int check_expo[2]; + double check_mant[2]; + int check_expo[2]; if (FLT_FLOAT==dst_type) { float x; HDmemcpy(&x, &buf[j*dst_size], sizeof(float)); if (underflow && HDfabsf(x) <= FLT_MIN && HDfabsf(hw_f) <= FLT_MIN) - continue; /* all underflowed, no error */ + continue; /* all underflowed, no error */ if (overflow && my_isinf(dendian, buf+j*sizeof(float), dst_size, dst_mpos, dst_msize, dst_epos, dst_esize)) - continue; /* all overflowed, no error */ + continue; /* all overflowed, no error */ check_mant[0] = HDfrexpf(x, check_expo+0); check_mant[1] = HDfrexpf(hw_f, check_expo+1); } else if (FLT_DOUBLE==dst_type) { @@ -3218,10 +3212,10 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) HDmemcpy(&x, &buf[j*dst_size], sizeof(double)); if (underflow && HDfabs(x) <= DBL_MIN && HDfabs(hw_d) <= DBL_MIN) - continue; /* all underflowed, no error */ + continue; /* all underflowed, no error */ if (overflow && my_isinf(dendian, buf+j*sizeof(double), dst_size, dst_mpos, dst_msize, dst_epos, dst_esize)) - continue; /* all overflowed, no error */ + continue; /* all overflowed, no error */ check_mant[0] = HDfrexp(x, check_expo+0); check_mant[1] = HDfrexp(hw_d, check_expo+1); #if H5_SIZEOF_LONG_DOUBLE !=0 && (H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE) @@ -3264,20 +3258,20 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) H5_WARNING(); } } - printf(" elmt %u\n", (unsigned)j); + HDprintf(" elmt %u\n", (unsigned)j); - printf(" src ="); + HDprintf(" src ="); for (k=0; k %s conversions", - name, src_type_name, dst_type_name); - printf("%-70s", str); - H5_FAILED(); - HDputs(" Unknown data type."); - goto error; + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", + name, src_type_name, dst_type_name); + HDprintf("%-70s", str); + H5_FAILED(); + HDputs(" Unknown data type."); + goto error; } if ((INT_SCHAR==src_type || INT_UCHAR==src_type || INT_SHORT==src_type || @@ -3566,12 +3560,12 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) && FLT_LDOUBLE!=dst_type #endif )) { - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, src_type_name, dst_type_name); - printf("%-70s", str); - H5_FAILED(); - HDputs(" 1. Not an integer-float conversion."); - goto error; + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", + name, src_type_name, dst_type_name); + HDprintf("%-70s", str); + H5_FAILED(); + HDputs(" 1. Not an integer-float conversion."); + goto error; } if ((FLT_FLOAT==src_type || FLT_DOUBLE==src_type @@ -3583,12 +3577,12 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) && INT_USHORT!=dst_type && INT_INT!=dst_type && INT_UINT!=dst_type && INT_LONG!=dst_type && INT_ULONG!=dst_type && INT_LLONG!=dst_type && INT_ULLONG!=dst_type)) { - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, src_type_name, dst_type_name); - printf("%-70s", str); - H5_FAILED(); - HDputs(" 2. Not a float-integer conversion."); - goto error; + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", + name, src_type_name, dst_type_name); + HDprintf("%-70s", str); + H5_FAILED(); + HDputs(" 2. Not a float-integer conversion."); + goto error; } if (INT_SCHAR==src_type || INT_UCHAR==src_type || INT_SHORT==src_type || @@ -3597,7 +3591,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) INT_ULLONG==src_type) { HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, src_type_name, dst_type_name); - printf("%-70s", str); + HDprintf("%-70s", str); HDfflush(stdout); fails_this_test=0; } else { @@ -3610,7 +3604,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) else HDsnprintf(str, sizeof(str), "Testing %s special %s -> %s conversions", name, src_type_name, dst_type_name); - printf("%-70s", str); + HDprintf("%-70s", str); HDfflush(stdout); fails_this_test=0; } @@ -4347,44 +4341,44 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) H5_WARNING(); } } - printf(" elmt %u: \n", (unsigned)j); + HDprintf(" elmt %u: \n", (unsigned)j); - printf(" src = "); + HDprintf(" src = "); for (k=0; k %s conversions", name, "long double", "float"); - printf("%-70s", str); + HDprintf("%-70s", str); SKIPPED(); #if H5_SIZEOF_LONG_DOUBLE!=0 HDputs(" Test skipped due to the conversion problem on IBM ppc64le cpu."); @@ -4915,11 +4909,11 @@ run_fp_tests(const char *name) nerrors += test_conv_flt_1(name, TEST_SPECIAL, H5T_NATIVE_LDOUBLE, H5T_NATIVE_DOUBLE); #else { - char str[256]; /*string */ + char str[256]; /*string */ HDsnprintf(str, sizeof(str), "Testing %s special %s -> %s conversions", name, "long double", "float or double"); - printf("%-70s", str); + HDprintf("%-70s", str); SKIPPED(); #if H5_SIZEOF_LONG_DOUBLE!=0 HDputs(" Test skipped due to the conversion problem on IBM ppc64le cpu."); @@ -4934,15 +4928,15 @@ done: return nerrors; } - + /*------------------------------------------------------------------------- - * Function: run_int_fp_conv + * Function: run_int_fp_conv * - * Purpose: Runs all integer-float tests. + * Purpose: Runs all integer-float tests. * - * Return: Number of errors + * Return: Number of errors * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Monday, November 10, 2003 * * Modifications: @@ -4952,7 +4946,7 @@ done: static int run_int_fp_conv(const char *name) { - int nerrors = 0; + int nerrors = 0; nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_SCHAR, H5T_NATIVE_FLOAT); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_SCHAR, H5T_NATIVE_DOUBLE); @@ -5001,11 +4995,11 @@ run_int_fp_conv(const char *name) nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULONG, H5T_NATIVE_LDOUBLE); #else { - char str[256]; /*string */ + char str[256]; /*string */ HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, "(unsigned) long", "long double"); - printf("%-70s", str); + HDprintf("%-70s", str); SKIPPED(); #if H5_SIZEOF_LONG_DOUBLE!=0 HDputs(" Test skipped due to the special algorithm of hardware conversion."); @@ -5020,11 +5014,11 @@ run_int_fp_conv(const char *name) nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LLONG, H5T_NATIVE_LDOUBLE); #else /* H5_LLONG_TO_LDOUBLE_CORRECT */ { - char str[256]; /*hello string */ + char str[256]; /*hello string */ HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, "long long", "long double"); - printf("%-70s", str); + HDprintf("%-70s", str); SKIPPED(); HDputs(" Test skipped due to compiler error in handling conversion."); } @@ -5033,11 +5027,11 @@ run_int_fp_conv(const char *name) nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULLONG, H5T_NATIVE_LDOUBLE); #else /* H5_LLONG_TO_LDOUBLE_CORRECT */ { - char str[256]; /*hello string */ + char str[256]; /*hello string */ HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, "unsigned long long", "long double"); - printf("%-70s", str); + HDprintf("%-70s", str); SKIPPED(); HDputs(" Test skipped due to compiler not handling conversion."); } @@ -5048,15 +5042,15 @@ run_int_fp_conv(const char *name) return nerrors; } - + /*------------------------------------------------------------------------- - * Function: run_fp_int_conv + * Function: run_fp_int_conv * - * Purpose: Runs all float-integer tests. + * Purpose: Runs all float-integer tests. * - * Return: Number of errors + * Return: Number of errors * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Monday, November 10, 2003 * * Modifications: @@ -5066,7 +5060,7 @@ run_int_fp_conv(const char *name) static int run_fp_int_conv(const char *name) { - int nerrors = 0; + int nerrors = 0; int test_values; for(test_values = TEST_NORMAL; test_values <= TEST_SPECIAL; test_values++) { @@ -5111,7 +5105,7 @@ run_fp_int_conv(const char *name) #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE if(test_values != TEST_SPECIAL) { - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SCHAR); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SCHAR); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_UCHAR); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SHORT); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_USHORT); @@ -5119,18 +5113,18 @@ run_fp_int_conv(const char *name) nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_UINT); } else { #ifndef H5_DISABLE_SOME_LDOUBLE_CONV - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SCHAR); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SCHAR); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_UCHAR); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SHORT); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_USHORT); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_INT); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_UINT); #else - char str[256]; /*string */ + char str[256]; /*string */ HDsnprintf(str, sizeof(str), "Testing %s special %s -> %s conversions", name, "long double", "signed and unsigned char, short, int, long"); - printf("%-70s", str); + HDprintf("%-70s", str); SKIPPED(); #if H5_SIZEOF_LONG_DOUBLE!=0 HDputs(" Test skipped due to the conversion problem on IBM ppc64le cpu."); @@ -5152,11 +5146,11 @@ run_fp_int_conv(const char *name) } #else { - char str[256]; /*string */ + char str[256]; /*string */ HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, "long double", "(unsigned) long"); - printf("%-70s", str); + HDprintf("%-70s", str); SKIPPED(); #if H5_SIZEOF_LONG_DOUBLE!=0 HDputs(" Test skipped due to the special algorithm of hardware conversion."); @@ -5172,11 +5166,11 @@ run_fp_int_conv(const char *name) nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LLONG); #else /*H5_LDOUBLE_TO_LLONG_ACCURATE*/ { - char str[256]; /*string */ + char str[256]; /*string */ HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, "long double", "long long"); - printf("%-70s", str); + HDprintf("%-70s", str); SKIPPED(); #if H5_SIZEOF_LONG_DOUBLE!=0 HDputs(" Test skipped due to hardware conversion error."); @@ -5189,11 +5183,11 @@ run_fp_int_conv(const char *name) nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_ULLONG); #else /*H5_LDOUBLE_TO_LLONG_ACCURATE*/ { - char str[256]; /*string */ + char str[256]; /*string */ HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, "long double", "unsigned long long"); - printf("%-70s", str); + HDprintf("%-70s", str); SKIPPED(); #if H5_SIZEOF_LONG_DOUBLE!=0 HDputs(" Test skipped due to hardware conversion error."); @@ -5209,7 +5203,7 @@ run_fp_int_conv(const char *name) return nerrors; } - + /*------------------------------------------------------------------------- * Function: main * @@ -5233,7 +5227,7 @@ run_fp_int_conv(const char *name) int main(void) { - unsigned long nerrors = 0; + unsigned long nerrors = 0; /* Set the random # seed */ HDsrandom((unsigned)HDtime(NULL)); @@ -5241,7 +5235,7 @@ main(void) reset_hdf5(); if (ALIGNMENT) - printf("Testing non-aligned conversions (ALIGNMENT=%d)....\n", ALIGNMENT); + HDprintf("Testing non-aligned conversions (ALIGNMENT=%d)....\n", ALIGNMENT); /* Do the tests */ @@ -5310,11 +5304,11 @@ main(void) h5_restore_err(); if (nerrors) { - printf("***** %lu FAILURE%s! *****\n", + HDprintf("***** %lu FAILURE%s! *****\n", nerrors, 1==nerrors?"":"S"); HDexit(EXIT_FAILURE); } - printf("All data type tests passed.\n"); + HDprintf("All data type tests passed.\n"); return 0; } diff --git a/test/earray.c b/test/earray.c index bb258c7..57df4d5 100644 --- a/test/earray.c +++ b/test/earray.c @@ -530,10 +530,10 @@ verify_cparam(const H5EA_t *ea, const H5EA_create_t *cparam) TEST_ERROR /* Success */ - return 0; + return SUCCEED; error: - return -1; + return FAIL; } /* verify_cparam() */ diff --git a/test/th5o.c b/test/th5o.c index 0aa589f..099bb92 100644 --- a/test/th5o.c +++ b/test/th5o.c @@ -378,7 +378,7 @@ test_h5o_refcount(void) { hid_t fid; /* HDF5 File ID */ hid_t grp, dset, dtype, dspace; /* Object identifiers */ - H5O_info_t oinfo; /* Object info struct */ + H5O_info_t oinfo; /* Object info struct */ hsize_t dims[RANK]; herr_t ret; /* Value returned from API calls */ @@ -850,7 +850,7 @@ test_h5o_link(void) /* Verify the data */ for(i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++) VERIFY(wdata[i], rdata[i], "H5Dread"); - + /* Create a group with no name*/ group_id = H5Gcreate_anon(file_id, H5P_DEFAULT, H5P_DEFAULT); CHECK(group_id, FAIL, "H5Gcreate_anon"); @@ -1254,7 +1254,7 @@ test_h5o_getinfo_same_file(void) { hid_t fid1, fid2; /* HDF5 File ID */ hid_t gid1, gid2; /* Group IDs */ - H5O_info_t oinfo1, oinfo2; /* Object info structs */ + H5O_info_t oinfo1, oinfo2; /* Object info structs */ herr_t ret; /* Value returned from API calls */ /* Create a new HDF5 file */ @@ -1491,29 +1491,29 @@ test_h5o(void) /* Output message about test being performed */ MESSAGE(5, ("Testing Objects\n")); - test_h5o_open(); /* Test generic open function */ - test_h5o_open_by_addr(); /* Test opening objects by address */ - test_h5o_close(); /* Test generic close function */ - test_h5o_refcount(); /* Test incrementing and decrementing reference count */ - test_h5o_plist(); /* Test object creation properties */ - test_h5o_link(); /* Test object link routine */ - test_h5o_comment(); /* Test routines for comment */ - test_h5o_comment_by_name(); /* Test routines for comment by name */ + test_h5o_open(); /* Test generic open function */ + test_h5o_open_by_addr(); /* Test opening objects by address */ + test_h5o_close(); /* Test generic close function */ + test_h5o_refcount(); /* Test incrementing and decrementing reference count */ + test_h5o_plist(); /* Test object creation properties */ + test_h5o_link(); /* Test object link routine */ + test_h5o_comment(); /* Test routines for comment */ + test_h5o_comment_by_name(); /* Test routines for comment by name */ test_h5o_getinfo_same_file(); /* Test info for objects in the same file */ #ifndef H5_NO_DEPRECATED_SYMBOLS - test_h5o_getinfo_visit(); /* Test object info for H5Oget_info1/2 and H5Ovisit1 */ + test_h5o_getinfo_visit(); /* Test object info for H5Oget_info1/2 and H5Ovisit1 */ #endif } /* test_h5o() */ /*------------------------------------------------------------------------- - * Function: cleanup_h5o + * Function: cleanup_h5o * - * Purpose: Cleanup temporary test files + * Purpose: Cleanup temporary test files * - * Return: none + * Return: none * - * Programmer: James Laird + * Programmer: James Laird * June 3, 2006 * *------------------------------------------------------------------------- diff --git a/test/titerate.c b/test/titerate.c index 716654d..7bc3bf7 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -946,7 +946,7 @@ find_err_msg_cb(unsigned H5_ATTR_UNUSED n, const H5E_error2_t *err_desc, void *_ if (searched_err == NULL) return H5_ITER_ERROR; - + /* If the searched error message is found, stop the iteration */ if (err_desc->desc != NULL && strcmp(err_desc->desc, searched_err->message) == 0) { -- cgit v0.12 From 605889fde8a92ed902bb4c5207912d1d687f7a99 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 30 Jul 2019 15:34:53 -0500 Subject: Add H5Sselect_shape_same and H5Sselect_intersect_block API routines, along with tests and minor cleanups and refactorings. --- src/H5Dchunk.c | 10 +- src/H5Dio.c | 4 +- src/H5Fint.c | 2 +- src/H5Pdcpl.c | 4 +- src/H5Sall.c | 48 +- src/H5Shyper.c | 114 ++--- src/H5Snone.c | 51 +- src/H5Spkg.h | 13 +- src/H5Spoint.c | 76 ++- src/H5Sprivate.h | 14 +- src/H5Spublic.h | 3 + src/H5Sselect.c | 168 ++++++- src/H5Stest.c | 44 -- test/objcopy.c | 90 +--- test/th5s.c | 42 +- test/tselect.c | 1310 +++++++++++++++++++++++++++---------------------- testpar/t_shapesame.c | 225 +++------ testpar/t_span_tree.c | 53 +- 18 files changed, 1238 insertions(+), 1033 deletions(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 7a07225..ec8ea4d 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -1245,7 +1245,7 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf } /* end else */ /* Build the memory selection for each chunk */ - if(sel_hyper_flag && H5S_select_shape_same(file_space, mem_space) == TRUE) { + if(sel_hyper_flag && H5S_SELECT_SHAPE_SAME(file_space, mem_space) == TRUE) { /* Reset chunk template information */ fm->mchunk_tmpl = NULL; @@ -1811,7 +1811,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t while(sel_points) { /* Check for intersection of current chunk and file selection */ /* (Casting away const OK - QAK) */ - if(TRUE == H5S_hyper_intersect_block((H5S_t *)fm->file_space, coords, end)) { + if(TRUE == H5S_SELECT_INTERSECT_BLOCK(fm->file_space, coords, end)) { H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */ hssize_t schunk_points; /* Number of elements in chunk selection */ @@ -2030,12 +2030,8 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) /* Sanity check */ HDassert(H5S_SEL_HYPERSLABS == chunk_sel_type); - /* Release the current selection */ - if(H5S_SELECT_RELEASE(chunk_info->mspace) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection") - /* Copy the file chunk's selection */ - if(H5S_select_copy(chunk_info->mspace, chunk_info->fspace, FALSE) < 0) + if(H5S_SELECT_COPY(chunk_info->mspace, chunk_info->fspace, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy selection") /* Compute the adjustment for this chunk */ diff --git a/src/H5Dio.c b/src/H5Dio.c index 9343b80..cdb73e3 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -490,7 +490,7 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, * Note that in general, this requires us to touch up the memory buffer as * well. */ - if(TRUE == H5S_select_shape_same(mem_space, file_space) && + if(TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) { void *adj_buf = NULL; /* Pointer to the location in buf corresponding */ /* to the beginning of the projected mem space. */ @@ -725,7 +725,7 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, * Note that in general, this requires us to touch up the memory buffer * as well. */ - if(TRUE == H5S_select_shape_same(mem_space, file_space) && + if(TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) { void *adj_buf = NULL; /* Pointer to the location in buf corresponding */ /* to the beginning of the projected mem space. */ diff --git a/src/H5Fint.c b/src/H5Fint.c index 758900b..7ed3ca8 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -868,7 +868,7 @@ H5F__is_hdf5(const char *name, hid_t fapl_id) /* The file is an hdf5 file if the hdf5 file signature can be found */ if(H5FD_locate_signature(file, &sig_addr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature") + HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "error while trying to locate file signature") ret_value = (HADDR_UNDEF != sig_addr); done: diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 6b9edf1..721ba89 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -827,7 +827,7 @@ H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, if((equal = H5S_extent_equal(layout1->storage.u.virt.list[u].source_dset.virtual_select, layout2->storage.u.virt.list[u].source_dset.virtual_select)) < 0) HGOTO_DONE(-1) if(!equal) HGOTO_DONE(1) - if((equal = H5S_select_shape_same(layout1->storage.u.virt.list[u].source_dset.virtual_select, layout2->storage.u.virt.list[u].source_dset.virtual_select)) < 0) HGOTO_DONE(-1) + if((equal = H5S_SELECT_SHAPE_SAME(layout1->storage.u.virt.list[u].source_dset.virtual_select, layout2->storage.u.virt.list[u].source_dset.virtual_select)) < 0) HGOTO_DONE(-1) if(!equal) HGOTO_DONE(1) @@ -847,7 +847,7 @@ H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, if((equal = H5S_extent_equal(layout1->storage.u.virt.list[u].source_select, layout2->storage.u.virt.list[u].source_select)) < 0) HGOTO_DONE(-1) if(!equal) HGOTO_DONE(1) - if((equal = H5S_select_shape_same(layout1->storage.u.virt.list[u].source_select, layout2->storage.u.virt.list[u].source_select)) < 0) HGOTO_DONE(-1) + if((equal = H5S_SELECT_SHAPE_SAME(layout1->storage.u.virt.list[u].source_select, layout2->storage.u.virt.list[u].source_select)) < 0) HGOTO_DONE(-1) if(!equal) HGOTO_DONE(1) } /* end for */ diff --git a/src/H5Sall.c b/src/H5Sall.c index fbe7041..9d0a65a 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -28,11 +28,11 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5Spkg.h" /* Dataspace functions */ -#include "H5VMprivate.h" /* Vector functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* ID Functions */ +#include "H5Spkg.h" /* Dataspace functions */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ @@ -63,6 +63,8 @@ static htri_t H5S__all_is_contiguous(const H5S_t *space); static htri_t H5S__all_is_single(const H5S_t *space); static htri_t H5S__all_is_regular(const H5S_t *space); static htri_t H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2); +static htri_t H5S__all_intersect_block(const H5S_t *space, const hsize_t *start, + const hsize_t *end); static herr_t H5S__all_adjust_u(H5S_t *space, const hsize_t *offset); static herr_t H5S__all_project_scalar(const H5S_t *space, hsize_t *offset); static herr_t H5S__all_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); @@ -108,6 +110,7 @@ const H5S_select_class_t H5S_sel_all[1] = {{ H5S__all_is_single, H5S__all_is_regular, H5S__all_shape_same, + H5S__all_intersect_block, H5S__all_adjust_u, H5S__all_project_scalar, H5S__all_project_simple, @@ -976,6 +979,41 @@ done: /*-------------------------------------------------------------------------- NAME + H5S__all_intersect_block + PURPOSE + Detect intersections of selection with block + USAGE + htri_t H5S__all_intersect_block(space, start, end) + const H5S_t *space; IN: Dataspace with selection to use + const hsize_t *start; IN: Starting coordinate for block + const hsize_t *end; IN: Ending coordinate for block + RETURNS + Non-negative TRUE / FALSE on success, negative on failure + DESCRIPTION + Quickly detect intersections with a block + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +htri_t +H5S__all_intersect_block(const H5S_t H5_ATTR_UNUSED *space, + const hsize_t H5_ATTR_UNUSED *start, const hsize_t H5_ATTR_UNUSED *end) +{ + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(space); + HDassert(H5S_SEL_ALL == H5S_GET_SELECT_TYPE(space)); + HDassert(start); + HDassert(end); + + FUNC_LEAVE_NOAPI(TRUE) +} /* end H5S__all_intersect_block() */ + + +/*-------------------------------------------------------------------------- + NAME H5S__all_adjust_u PURPOSE Adjust an "all" selection by subtracting an offset diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 2acc135..492cd9e 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -28,30 +28,20 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Spkg.h" /* Dataspace functions */ -#include "H5VMprivate.h" /* Vector functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* ID Functions */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Spkg.h" /* Dataspace functions */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ -/* Macro for checking if two ranges overlap one another */ -/* - * Check for the inverse of whether the ranges are disjoint. If they are - * disjoint, then the low bound of one of the ranges must be greater than the - * high bound of the other. - */ -/* (Assumes that low & high bounds are _inclusive_) */ -#define H5S_RANGE_OVERLAP(L1, H1, L2, H2) \ - (!((L1) > (H2) || (L2) > (H1))) - /* Flags for which hyperslab fragments to compute */ #define H5S_HYPER_COMPUTE_B_NOT_A 0x01 #define H5S_HYPER_COMPUTE_A_AND_B 0x02 @@ -197,6 +187,8 @@ static htri_t H5S__hyper_is_contiguous(const H5S_t *space); static htri_t H5S__hyper_is_single(const H5S_t *space); static htri_t H5S__hyper_is_regular(const H5S_t *space); static htri_t H5S__hyper_shape_same(const H5S_t *space1, const H5S_t *space2); +static htri_t H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, + const hsize_t *end); static herr_t H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset); static herr_t H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset); static herr_t H5S__hyper_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); @@ -242,6 +234,7 @@ const H5S_select_class_t H5S_sel_hyper[1] = {{ H5S__hyper_is_single, H5S__hyper_is_regular, H5S__hyper_shape_same, + H5S__hyper_intersect_block, H5S__hyper_adjust_u, H5S__hyper_project_scalar, H5S__hyper_project_simple, @@ -4829,7 +4822,6 @@ static herr_t H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { const hsize_t *low_bounds, *high_bounds; /* Pointers to the correct pair of low & high bounds */ - unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4849,22 +4841,32 @@ H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) high_bounds = space->select.sel_info.hslab->span_lst->high_bounds; } /* end else */ - /* Loop over dimensions */ - for(u = 0; u < space->extent.rank; u++) { - /* Sanity check */ - HDassert(low_bounds[u] <= high_bounds[u]); + /* Check for offset set */ + if(space->select.offset_changed) { + unsigned u; /* Local index variable */ - /* Check for offset moving selection negative */ - if(((hssize_t)low_bounds[u] + space->select.offset[u]) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds") + /* Loop over dimensions */ + for(u = 0; u < space->extent.rank; u++) { + /* Sanity check */ + HDassert(low_bounds[u] <= high_bounds[u]); - /* Set the low & high bounds in this dimension */ - start[u] = (hsize_t)((hssize_t)low_bounds[u] + space->select.offset[u]); - if((int)u == space->select.sel_info.hslab->unlim_dim) - end[u] = H5S_UNLIMITED; - else - end[u] = (hsize_t)((hssize_t)high_bounds[u] + space->select.offset[u]); - } /* end for */ + /* Check for offset moving selection negative */ + if(((hssize_t)low_bounds[u] + space->select.offset[u]) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds") + + /* Set the low & high bounds in this dimension */ + start[u] = (hsize_t)((hssize_t)low_bounds[u] + space->select.offset[u]); + if((int)u == space->select.sel_info.hslab->unlim_dim) + end[u] = H5S_UNLIMITED; + else + end[u] = (hsize_t)((hssize_t)high_bounds[u] + space->select.offset[u]); + } /* end for */ + } /* end if */ + else { + /* Offset vector is still zeros, just copy low & high bounds */ + H5MM_memcpy(start, low_bounds, sizeof(hsize_t) * space->extent.rank); + H5MM_memcpy(end, high_bounds, sizeof(hsize_t) * space->extent.rank); + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -6240,32 +6242,31 @@ done: /*-------------------------------------------------------------------------- NAME - H5S_hyper_intersect_block + H5S__hyper_intersect_block PURPOSE - Detect intersections in span trees + Detect intersections of selection with block USAGE - htri_t H5S_hyper_intersect_block(space, start, end) - H5S_t *space; IN: First dataspace to operate on span tree - hssize_t *start; IN: Starting coordinate for block - hssize_t *end; IN: Ending coordinate for block + htri_t H5S__hyper_intersect_block(space, start, end) + const H5S_t *space; IN: Dataspace with selection to use + const hsize_t *start; IN: Starting coordinate for block + const hsize_t *end; IN: Ending coordinate for block RETURNS - Non-negative on success, negative on failure + Non-negative TRUE / FALSE on success, negative on failure DESCRIPTION - Quickly detect intersections between span tree and block + Quickly detect intersections between both regular hyperslabs and span trees + with a block GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Does not use selection offset. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t -H5S_hyper_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end) +static htri_t +H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end) { - const hsize_t *low_bounds, *high_bounds; /* Pointers to the correct pair of low & high bounds */ - unsigned u; /* Local index variable */ htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* Sanity check */ HDassert(space); @@ -6277,27 +6278,12 @@ H5S_hyper_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end * to be impossible. */ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) - H5S__hyper_rebuild(space); - - /* Check which set of low & high bounds we should be using */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - low_bounds = space->select.sel_info.hslab->diminfo.low_bounds; - high_bounds = space->select.sel_info.hslab->diminfo.high_bounds; - } /* end if */ - else { - low_bounds = space->select.sel_info.hslab->span_lst->low_bounds; - high_bounds = space->select.sel_info.hslab->span_lst->high_bounds; - } /* end else */ - - /* Loop over selection bounds and block, checking for overlap */ - for(u = 0; u < space->extent.rank; u++) - /* If selection bounds & block don't overlap, can leave now */ - if(!H5S_RANGE_OVERLAP(low_bounds[u], high_bounds[u], start[u], end[u])) - HGOTO_DONE(FALSE) + H5S__hyper_rebuild((H5S_t *)space); /* Casting away const OK -QAK */ /* Check for regular hyperslab intersection */ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { hbool_t single_block; /* Whether the regular selection is a single block */ + unsigned u; /* Local index variable */ /* Check for a single block */ /* For a regular hyperslab to be single, it must have only one block @@ -6381,7 +6367,7 @@ H5S_hyper_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_hyper_intersect_block() */ +} /* end H5S__hyper_intersect_block() */ /*-------------------------------------------------------------------------- diff --git a/src/H5Snone.c b/src/H5Snone.c index 9d64e9d..c262d18 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -28,11 +28,11 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5Spkg.h" /* Dataspace functions */ -#include "H5VMprivate.h" /* Vector functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* ID Functions */ +#include "H5Spkg.h" /* Dataspace functions */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ @@ -63,9 +63,12 @@ static htri_t H5S__none_is_contiguous(const H5S_t *space); static htri_t H5S__none_is_single(const H5S_t *space); static htri_t H5S__none_is_regular(const H5S_t *space); static htri_t H5S__none_shape_same(const H5S_t *space1, const H5S_t *space2); +static htri_t H5S__none_intersect_block(const H5S_t *space, const hsize_t *start, + const hsize_t *end); static herr_t H5S__none_adjust_u(H5S_t *space, const hsize_t *offset); static herr_t H5S__none_project_scalar(const H5S_t *space, hsize_t *offset); -static herr_t H5S__none_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); +static herr_t H5S__none_project_simple(const H5S_t *space, H5S_t *new_space, + hsize_t *offset); static herr_t H5S__none_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); /* Selection iteration callbacks */ @@ -108,6 +111,7 @@ const H5S_select_class_t H5S_sel_none[1] = {{ H5S__none_is_single, H5S__none_is_regular, H5S__none_shape_same, + H5S__none_intersect_block, H5S__none_adjust_u, H5S__none_project_scalar, H5S__none_project_simple, @@ -886,6 +890,41 @@ H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1, /*-------------------------------------------------------------------------- NAME + H5S__none_intersect_block + PURPOSE + Detect intersections of selection with block + USAGE + htri_t H5S__none_intersect_block(space, start, end) + const H5S_t *space; IN: Dataspace with selection to use + const hsize_t *start; IN: Starting coordinate for block + const hsize_t *end; IN: Ending coordinate for block + RETURNS + Non-negative TRUE / FALSE on success, negative on failure + DESCRIPTION + Quickly detect intersections with a block + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +htri_t +H5S__none_intersect_block(const H5S_t H5_ATTR_UNUSED *space, + const hsize_t H5_ATTR_UNUSED *start, const hsize_t H5_ATTR_UNUSED *end) +{ + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(space); + HDassert(H5S_SEL_NONE == H5S_GET_SELECT_TYPE(space)); + HDassert(start); + HDassert(end); + + FUNC_LEAVE_NOAPI(FALSE) +} /* end H5S__none_intersect_block() */ + + +/*-------------------------------------------------------------------------- + NAME H5S__none_adjust_u PURPOSE Adjust an "none" selection by subtracting an offset diff --git a/src/H5Spkg.h b/src/H5Spkg.h index 4752c59..278f08d 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -91,6 +91,15 @@ * H5S_UNLIMITED) */ #define H5S_MAX_SIZE ((hsize_t)(hssize_t)(-2)) +/* Macro for checking if two ranges overlap one another */ +/* + * Check for the inverse of whether the ranges are disjoint. If they are + * disjoint, then the low bound of one of the ranges must be greater than the + * high bound of the other. + */ +/* (Assumes that low & high bounds are _inclusive_) */ +#define H5S_RANGE_OVERLAP(L1, H1, L2, H2) (!((L1) > (H2) || (L2) > (H1))) + /* * Dataspace extent information @@ -240,6 +249,8 @@ typedef htri_t (*H5S_sel_is_single_func_t)(const H5S_t *space); typedef htri_t (*H5S_sel_is_regular_func_t)(const H5S_t *space); /* Method to determine if two dataspaces' selections are the same shape */ typedef htri_t (*H5S_sel_shape_same_func_t)(const H5S_t *space1, const H5S_t *space2); +/* Method to determine if selection intersects a block */ +typedef htri_t (*H5S_sel_intersect_block_func_t)(const H5S_t *space, const hsize_t *start, const hsize_t *end); /* Method to adjust a selection by an offset */ typedef herr_t (*H5S_sel_adjust_u_func_t)(H5S_t *space, const hsize_t *offset); /* Method to construct single element projection onto scalar dataspace */ @@ -268,6 +279,7 @@ typedef struct { H5S_sel_is_single_func_t is_single; /* Method to determine if current selection is a single block */ H5S_sel_is_regular_func_t is_regular; /* Method to determine if current selection is "regular" */ H5S_sel_shape_same_func_t shape_same; /* Method to determine if two dataspaces' selections are the same shape */ + H5S_sel_intersect_block_func_t intersect_block; /* Method to determine if a dataspaces' selection intersects a block */ H5S_sel_adjust_u_func_t adjust_u; /* Method to adjust a selection by an offset */ H5S_sel_project_scalar project_scalar; /* Method to construct scalar dataspace projection */ H5S_sel_project_simple project_simple; /* Method to construct simple dataspace projection */ @@ -369,7 +381,6 @@ H5_DLL herr_t H5S__hyper_project_intersection(const H5S_t *src_space, /* Testing functions */ #ifdef H5S_TESTING -H5_DLL htri_t H5S__select_shape_same_test(hid_t sid1, hid_t sid2); H5_DLL herr_t H5S__get_rebuild_status_test(hid_t space_id, H5S_diminfo_valid_t *status1, H5S_diminfo_valid_t *status2); H5_DLL herr_t H5S__get_diminfo_status_test(hid_t space_id, diff --git a/src/H5Spoint.c b/src/H5Spoint.c index 875c018..8e1175a 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -28,14 +28,14 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Spkg.h" /* Dataspace functions */ -#include "H5VMprivate.h" /* Vector functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* ID Functions */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Spkg.h" /* Dataspace functions */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ @@ -75,6 +75,8 @@ static htri_t H5S__point_is_contiguous(const H5S_t *space); static htri_t H5S__point_is_single(const H5S_t *space); static htri_t H5S__point_is_regular(const H5S_t *space); static htri_t H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2); +static htri_t H5S__point_intersect_block(const H5S_t *space, const hsize_t *start, + const hsize_t *end); static herr_t H5S__point_adjust_u(H5S_t *space, const hsize_t *offset); static herr_t H5S__point_project_scalar(const H5S_t *space, hsize_t *offset); static herr_t H5S__point_project_simple(const H5S_t *space, H5S_t *new_space, @@ -124,6 +126,7 @@ const H5S_select_class_t H5S_sel_point[1] = {{ H5S__point_is_single, H5S__point_is_regular, H5S__point_shape_same, + H5S__point_intersect_block, H5S__point_adjust_u, H5S__point_project_scalar, H5S__point_project_simple, @@ -1998,6 +2001,63 @@ done: /*-------------------------------------------------------------------------- NAME + H5S__point_intersect_block + PURPOSE + Detect intersections of selection with block + USAGE + htri_t H5S__point_intersect_block(space, start, end) + const H5S_t *space; IN: Dataspace with selection to use + const hsize_t *start; IN: Starting coordinate for block + const hsize_t *end; IN: Ending coordinate for block + RETURNS + Non-negative TRUE / FALSE on success, negative on failure + DESCRIPTION + Quickly detect intersections with a block + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +htri_t +H5S__point_intersect_block(const H5S_t *space, const hsize_t *start, + const hsize_t *end) +{ + H5S_pnt_node_t *pnt; /* Point information node */ + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(space); + HDassert(H5S_SEL_POINTS == H5S_GET_SELECT_TYPE(space)); + HDassert(start); + HDassert(end); + + /* Loop over points */ + pnt = space->select.sel_info.pnt_lst->head; + while(pnt) { + unsigned u; /* Local index variable */ + + /* Verify that the point is within the block */ + for(u = 0; u < space->extent.rank; u++) + if(pnt->pnt[u] < start[u] || pnt->pnt[u] > end[u]) + break; + + /* Check if point was within block for all dimensions */ + if(u == space->extent.rank) + HGOTO_DONE(TRUE) + + /* Advance to next point */ + pnt = pnt->next; + } /* end while */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5S__point_intersect_block() */ + + +/*-------------------------------------------------------------------------- + NAME H5S__point_adjust_u PURPOSE Adjust a "point" selection by subtracting an offset diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 6646f84..0a9d2e7 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -30,15 +30,6 @@ #include "H5Pprivate.h" /* Property lists */ #include "H5Tprivate.h" /* Datatypes */ -/* Flags for H5S_find */ -#define H5S_CONV_PAR_IO_POSSIBLE 0x0001 -/* The storage options are mutually exclusive */ -/* (2-bits reserved for storage type currently) */ -#define H5S_CONV_STORAGE_COMPACT 0x0000 /* i.e. '0' */ -#define H5S_CONV_STORAGE_CONTIGUOUS 0x0002 /* i.e. '1' */ -#define H5S_CONV_STORAGE_CHUNKED 0x0004 /* i.e. '2' */ -#define H5S_CONV_STORAGE_MASK 0x0006 - /* Forward references of package typedefs */ typedef struct H5S_extent_t H5S_extent_t; typedef struct H5S_pnt_node_t H5S_pnt_node_t; @@ -192,6 +183,8 @@ typedef struct H5S_sel_iter_op_t { #endif /* H5S_MODULE */ /* Handle these callbacks in a special way, since they have prologs that need to be executed */ #define H5S_SELECT_COPY(DST,SRC,SHARE) (H5S_select_copy(DST,SRC,SHARE)) +#define H5S_SELECT_SHAPE_SAME(S1,S2) (H5S_select_shape_same(S1,S2)) +#define H5S_SELECT_INTERSECT_BLOCK(S,START,END) (H5S_select_intersect_block(S,START,END)) #define H5S_SELECT_RELEASE(S) (H5S_select_release(S)) #define H5S_SELECT_DESERIALIZE(S,BUF) (H5S_select_deserialize(S,BUF)) @@ -252,6 +245,8 @@ H5_DLL herr_t H5S_get_select_num_elem_non_unlim(const H5S_t *space, H5_DLL herr_t H5S_select_offset(H5S_t *space, const hssize_t *offset); H5_DLL herr_t H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); H5_DLL htri_t H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2); +H5_DLL htri_t H5S_select_intersect_block(const H5S_t *space, const hsize_t *start, + const hsize_t *end); H5_DLL herr_t H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, unsigned new_space_rank, const void *buf, void const **adj_buf_ptr, hsize_t element_size); @@ -287,7 +282,6 @@ H5_DLL herr_t H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, const hsize_t *block, H5S_t **new_space); H5_DLL herr_t H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords); -H5_DLL htri_t H5S_hyper_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end); H5_DLL herr_t H5S_hyper_adjust_s(H5S_t *space, const hssize_t *offset); H5_DLL htri_t H5S_hyper_normalize_offset(H5S_t *space, hssize_t *old_offset); H5_DLL herr_t H5S_hyper_denormalize_offset(H5S_t *space, const hssize_t *old_offset); diff --git a/src/H5Spublic.h b/src/H5Spublic.h index 23e6846..9e76b4b 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -145,6 +145,9 @@ H5_DLL herr_t H5Sselect_copy(hid_t dst_id, hid_t src_id); H5_DLL htri_t H5Sselect_valid(hid_t spaceid); H5_DLL herr_t H5Sget_select_bounds(hid_t spaceid, hsize_t start[], hsize_t end[]); +H5_DLL htri_t H5Sselect_shape_same(hid_t space1_id, hid_t space2_id); +H5_DLL htri_t H5Sselect_intersect_block(hid_t space_id, const hsize_t *start, + const hsize_t *end); H5_DLL herr_t H5Soffset_simple(hid_t space_id, const hssize_t *offset); H5_DLL herr_t H5Sselect_all(hid_t spaceid); H5_DLL herr_t H5Sselect_none(hid_t spaceid); diff --git a/src/H5Sselect.c b/src/H5Sselect.c index c383fed..8b84e2c 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -250,11 +250,15 @@ H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection) HDassert(dst); HDassert(src); + /* Release the current selection */ + if(H5S_SELECT_RELEASE(dst) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection") + /* Copy regular fields */ dst->select = src->select; /* Perform correct type of copy based on the type of selection */ - if((ret_value = (*src->select.type->copy)(dst,src,share_selection)) < 0) + if((ret_value = (*src->select.type->copy)(dst, src, share_selection)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy selection specific information") done: @@ -281,7 +285,7 @@ done: herr_t H5S_select_release(H5S_t *ds) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1689,9 +1693,12 @@ H5S_get_select_type(const H5S_t *space) DESCRIPTION Checks to see if the current selection in the dataspaces are the same dimensionality and shape. + This is primarily used for reading the entire selection in one swoop. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS + This routine participates in the "Inlining C function pointers" pattern, + don't call it directly, use the appropriate macro defined in H5Sprivate.h. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ @@ -1945,6 +1952,163 @@ done: /*-------------------------------------------------------------------------- NAME + H5Sselect_shape_same + PURPOSE + Check if two selections are the same shape + USAGE + htri_t H5Sselect_shape_same(space1_id, space2_id) + hid_t space1_id; IN: ID of 1st Dataspace pointer to compare + hid_t space2_id; IN: ID of 2nd Dataspace pointer to compare + RETURNS + TRUE/FALSE/FAIL + DESCRIPTION + Checks to see if the current selection in the dataspaces are the same + dimensionality and shape. + This is primarily used for reading the entire selection in one swoop. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +htri_t +H5Sselect_shape_same(hid_t space1_id, hid_t space2_id) +{ + H5S_t *space1, *space2; /* Dataspaces to compare */ + htri_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("t", "ii", space1_id, space2_id); + + if(NULL == (space1 = (H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") + if(NULL == (space2 = (H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") + + if((ret_value = H5S_select_shape_same(space1, space2)) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "can't compare selections") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Sselect_shape_same() */ + + +/*-------------------------------------------------------------------------- + NAME + H5S_select_intersect_block + PURPOSE + Check if current selection intersects with a block + USAGE + htri_t H5S_select_intersect_block(space, start, end) + const H5S_t *space; IN: Dataspace to compare + const hsize_t *start; IN: Starting coordinate of block + const hsize_t *end; IN: Opposite ("ending") coordinate of block + RETURNS + TRUE / FALSE / FAIL + DESCRIPTION + Checks to see if the current selection in the dataspace intersects with + the block given. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + Assumes that start & end block bounds are _inclusive_, so start == end + value OK. + + This routine participates in the "Inlining C function pointers" pattern, + don't call it directly, use the appropriate macro defined in H5Sprivate.h. +--------------------------------------------------------------------------*/ +htri_t +H5S_select_intersect_block(const H5S_t *space, const hsize_t *start, + const hsize_t *end) +{ + htri_t ret_value = TRUE; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args */ + HDassert(space); + HDassert(start); + HDassert(end); + + /* If selections aren't "none", compare their bounds */ + if(H5S_SEL_NONE != H5S_GET_SELECT_TYPE(space)) { + hsize_t low[H5S_MAX_RANK]; /* Low bound of selection in dataspace */ + hsize_t high[H5S_MAX_RANK]; /* High bound of selection in dataspace */ + unsigned u; /* Local index variable */ + + /* Get low & high bounds for dataspace selection */ + if(H5S_SELECT_BOUNDS(space, low, high) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds for dataspace") + + /* Loop over selection bounds and block, checking for overlap */ + for(u = 0; u < space->extent.rank; u++) + /* If selection bounds & block don't overlap, can leave now */ + if(!H5S_RANGE_OVERLAP(low[u], high[u], start[u], end[u])) + HGOTO_DONE(FALSE) + } /* end if */ + + /* Call selection type's intersect routine */ + if((ret_value = (*space->select.type->intersect_block)(space, start, end)) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "can't intersect block with selection") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5S_select_intersect_block() */ + + +/*-------------------------------------------------------------------------- + NAME + H5Sselect_intersect_block + PURPOSE + Check if current selection intersects with a block + USAGE + htri_t H5Sselect_intersect_block(space_id, start, end) + hid_t space1_id; IN: ID of dataspace pointer to compare + const hsize_t *start; IN: Starting coordinate of block + const hsize_t *end; IN: Opposite ("ending") coordinate of block + RETURNS + TRUE / FALSE / FAIL + DESCRIPTION + Checks to see if the current selection in the dataspace intersects with + the block given. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + Assumes that start & end block bounds are _inclusive_, so start == end + value OK. + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +htri_t +H5Sselect_intersect_block(hid_t space_id, const hsize_t *start, const hsize_t *end) +{ + H5S_t *space; /* Dataspace to query */ + unsigned u; /* Local index value */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + + /* Check arguments */ + if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") + if(NULL == start) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "block start array pointer is NULL") + if(NULL == end) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "block end array pointer is NULL") + + /* Range check start & end values */ + for(u = 0; u < space->extent.rank; u++) + if(start[u] > end[u]) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "block start[%u] (%llu) > end[%u] (%llu)", u, (unsigned long long)start[u], u, (unsigned long long)end[u]) + + /* Call internal routine to do comparison */ + if((ret_value = H5S_select_intersect_block(space, start, end)) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "can't compare selection and block") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Sselect_intersect_block() */ + + +/*-------------------------------------------------------------------------- + NAME H5S_select_construct_projection PURPOSE diff --git a/src/H5Stest.c b/src/H5Stest.c index 2c42713..b61b6bf 100644 --- a/src/H5Stest.c +++ b/src/H5Stest.c @@ -66,50 +66,6 @@ /*-------------------------------------------------------------------------- NAME - H5S__select_shape_same_test - PURPOSE - Determine if two dataspace selections are the same shape - USAGE - htri_t H5S__select_shape_same_test(sid1, sid2) - hid_t sid1; IN: 1st dataspace to compare - hid_t sid2; IN: 2nd dataspace to compare - RETURNS - Non-negative TRUE/FALSE on success, negative on failure - DESCRIPTION - Checks to see if the current selection in the dataspaces are the same - dimensionality and shape. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -htri_t -H5S__select_shape_same_test(hid_t sid1, hid_t sid2) -{ - H5S_t *space1; /* Pointer to 1st dataspace */ - H5S_t *space2; /* Pointer to 2nd dataspace */ - htri_t ret_value = FAIL; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Get dataspace structures */ - if(NULL == (space1 = (H5S_t *)H5I_object_verify(sid1, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == (space2 = (H5S_t *)H5I_object_verify(sid2, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - - /* Check if the dataspace selections are the same shape */ - if((ret_value = H5S_select_shape_same(space1, space2)) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "unable to compare dataspace selections") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5S__select_shape_same_test() */ - - -/*-------------------------------------------------------------------------- - NAME H5S__get_rebuild_status_test PURPOSE Determine the status of the diminfo_valid field (whether we know the diff --git a/test/objcopy.c b/test/objcopy.c index 1f89e16..94a2b36 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -284,8 +284,6 @@ addr_reset(void) * Programmer: Peter Cao * Friday, August 4, 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -345,8 +343,6 @@ error: * Programmer: Peter Cao * Monday, March 5, 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -422,8 +418,6 @@ error: * Programmer: Peter Cao * Friday, August 4, 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -517,8 +511,6 @@ error: * Programmer: Peter Cao * Saturday, December 17, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -579,8 +571,6 @@ done: * Programmer: Peter Cao * Friday, September 30, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -856,10 +846,6 @@ error: * Note: This isn't very general, the attributes are assumed to be * those written in test_copy_attach_attributes(). * - * Modifier: Peter Cao - * Wednesday, March 21, 2007 - * Change to compare any attributes of two objects - * *------------------------------------------------------------------------- */ static int @@ -1167,7 +1153,7 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, if((obj2_sid = H5Rget_region(parent2, H5R_DATASET_REGION, ref_buf2)) < 0) TEST_ERROR /* Check if dataspaces are the same shape */ - if(H5S__select_shape_same_test(obj1_sid, obj2_sid) < 0) TEST_ERROR + if(H5Sselect_shape_same(obj1_sid, obj2_sid) < 0) TEST_ERROR /* Close dataspaces */ if(H5Sclose(obj1_sid) < 0) TEST_ERROR @@ -1213,8 +1199,8 @@ compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf) hssize_t nelmts; /* # of elements in dataspace */ void *rbuf = NULL; /* Buffer for reading raw data */ void *rbuf2 = NULL; /* Buffer for reading raw data */ - H5D_space_status_t space_status; /* Dataset's raw data space status */ - H5D_space_status_t space_status2; /* Dataset's raw data space status */ + H5D_space_status_t space_status; /* Dataset's raw dataspace status */ + H5D_space_status_t space_status2; /* Dataset's raw dataspace status */ /* Check the datatypes are equal */ @@ -1569,8 +1555,6 @@ error: * Programmer: Peter Cao * Friday, September 30, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -1858,8 +1842,6 @@ error: * Programmer: Neil * Friday, March 11, 2011 * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -1999,8 +1981,6 @@ error: * Programmer: Peter Cao * Friday, September 30, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -2294,8 +2274,6 @@ error: * Programmer: Neil Fortner * Thursday, January 15, 2009 * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -2519,8 +2497,6 @@ error: * Programmer: Peter Cao * Friday, September 30, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -2651,8 +2627,6 @@ error: * Programmer: Peter Cao * Friday, September 30, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -4396,8 +4370,6 @@ error: * Programmer: Peter Cao * Friday, September 30, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -6281,8 +6253,6 @@ error: * Programmer: Peter Cao * Friday, September 30, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -6376,8 +6346,6 @@ error: * Programmer: Peter Cao * August 8, 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -6509,8 +6477,6 @@ error: * Programmer: Peter Cao * Friday, September 30, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -7024,12 +6990,6 @@ error: * Programmer: Peter Cao * Friday, September 30, 2005 * - * Modifications: - * Neil Fortner - * Tuesday, February 16, 2010 - * Modified test to test flags for expanding soft and external - * links. - * *------------------------------------------------------------------------- */ static int @@ -8017,7 +7977,7 @@ test_copy_dataset_compact_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap /* make a copy of the datatype for later use */ if((tid_copy = H5Tcopy(tid)) < 0)TEST_ERROR - /* named data type */ + /* named datatype */ if((H5Tcommit2(fid_src, NAME_DATATYPE_VL, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* create and set compact plist */ @@ -8171,7 +8131,7 @@ test_copy_dataset_contig_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl /* make a copy of the datatype for later use */ if((tid_copy = H5Tcopy(tid)) < 0)TEST_ERROR - /* named data type */ + /* named datatype */ if((H5Tcommit2(fid_src, NAME_DATATYPE_VL, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* create dataset at SRC file */ @@ -8326,7 +8286,7 @@ test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap /* make a copy of the datatype for later use */ if((tid_copy = H5Tcopy(tid)) < 0)TEST_ERROR - /* named data type */ + /* named datatype */ if((H5Tcommit2(fid_src, NAME_DATATYPE_VL, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* create and set chunk plist */ @@ -8487,7 +8447,7 @@ test_copy_dataset_compressed_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_ /* make a copy of the datatype for later use */ if((tid_copy = H5Tcopy(tid)) < 0)TEST_ERROR - /* named data type */ + /* named datatype */ if((H5Tcommit2(fid_src, NAME_DATATYPE_VL, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* create and set chunk plist */ @@ -10289,7 +10249,7 @@ test_copy_committed_datatype_merge(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap /* create datatype */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR - /* committed data type */ + /* committed datatype */ if((H5Tcommit2(fid_src1, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* create dataset at SRC file */ @@ -10313,7 +10273,7 @@ test_copy_committed_datatype_merge(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap /* create datatype */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR - /* committed data type */ + /* committed datatype */ if((H5Tcommit2(fid_src2, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* create dataset at SRC file */ @@ -10524,7 +10484,7 @@ test_copy_committed_datatype_merge_same_file(hid_t fcpl, hid_t fapl, hbool_t reo /* create datatype */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR - /* committed data type */ + /* committed datatype */ if((H5Tcommit2(fid, NAME_GROUP_TOP "/" NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* create dataset */ @@ -10551,7 +10511,7 @@ test_copy_committed_datatype_merge_same_file(hid_t fcpl, hid_t fapl, hbool_t reo /* create datatype */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR - /* committed data type */ + /* committed datatype */ if((H5Tcommit2(fid, NAME_GROUP_TOP2 "/" NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* create dataset */ @@ -10796,7 +10756,7 @@ test_copy_committed_dt_merge_sugg(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl /* create datatype */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR - /* committed data type */ + /* committed datatype */ if((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* create dataset at SRC file */ @@ -10823,7 +10783,7 @@ test_copy_committed_dt_merge_sugg(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl /* create datatype */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR - /* committed data type "a" */ + /* committed datatype "a" */ if((H5Tcommit2(fid_dst, "/a", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* close the datatype */ @@ -10832,7 +10792,7 @@ test_copy_committed_dt_merge_sugg(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl /* create datatype */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR - /* committed data type "b" */ + /* committed datatype "b" */ if((H5Tcommit2(fid_dst, "/b", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* close the datatype */ @@ -11027,7 +10987,7 @@ test_copy_committed_dt_merge_attr(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl /* create datatype */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR - /* committed data type */ + /* committed datatype */ if((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* create dataset at SRC file */ @@ -11057,7 +11017,7 @@ test_copy_committed_dt_merge_attr(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl /* create datatype */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR - /* create anonymous committed data type */ + /* create anonymous committed datatype */ if((H5Tcommit_anon(fid_dst, tid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* create attribute at SRC file */ @@ -12817,7 +12777,7 @@ test_copy_set_mcdt_search_cb(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* create datatype */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR - /* named data type */ + /* named datatype */ if((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* create dataset at SRC file */ @@ -12847,7 +12807,7 @@ test_copy_set_mcdt_search_cb(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* create datatype */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR - /* committed data type "a" */ + /* committed datatype "a" */ if((H5Tcommit2(fid_dst, "/a", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* close the datatype */ @@ -12856,7 +12816,7 @@ test_copy_set_mcdt_search_cb(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* create datatype */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR - /* committed data type "b" */ + /* committed datatype "b" */ if((H5Tcommit2(fid_dst, "/b", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* close the datatype */ @@ -13176,7 +13136,7 @@ test_copy_set_get_mcdt_search_cb(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* create datatype */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR - /* committed data type */ + /* committed datatype */ if((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* create dataset at SRC file */ @@ -13206,7 +13166,7 @@ test_copy_set_get_mcdt_search_cb(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* create datatype */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR - /* committed data type "a" */ + /* committed datatype "a" */ if((H5Tcommit2(fid_dst, "/a", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* close the datatype */ @@ -13215,7 +13175,7 @@ test_copy_set_get_mcdt_search_cb(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* create datatype */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR - /* committed data type "b" */ + /* committed datatype "b" */ if((H5Tcommit2(fid_dst, "/b", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* close the datatype */ @@ -13499,8 +13459,6 @@ error: * Programmer: Peter Cao * March 11, 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -13817,8 +13775,6 @@ error: * Programmer: Vailin Choi * Feb 7, 2012 * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -14138,8 +14094,6 @@ error: * Programmer: Peter Cao * Friday, September 30, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ int diff --git a/test/th5s.c b/test/th5s.c index a48979b..f0365de 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -187,7 +187,7 @@ test_h5s_basic(void) CHECK(ret, FAIL, "H5Sclose"); /* - * Check to be sure we can't create a simple data space that has too many + * Check to be sure we can't create a simple dataspace that has too many * dimensions. */ H5E_BEGIN_TRY { @@ -318,7 +318,7 @@ test_h5s_basic(void) /**************************************************************** ** -** test_h5s_null(): Test NULL data space +** test_h5s_null(): Test NULL dataspace ** ****************************************************************/ static void @@ -460,7 +460,7 @@ test_h5s_null(void) CHECK(ret, FAIL, "H5Fclose"); /*============================================ - * Reopen the file to check the data space + * Reopen the file to check the dataspace *============================================ */ fid = H5Fopen(NULLFILE, H5F_ACC_RDONLY, H5P_DEFAULT); @@ -1078,7 +1078,7 @@ test_h5s_zero_dim(void) CHECK(ret, FAIL, "H5Fclose"); /*============================================ - * Reopen the file to check the data space + * Reopen the file to check the dataspace *============================================ */ fid1 = H5Fopen(ZEROFILE, H5F_ACC_RDONLY, H5P_DEFAULT); @@ -1227,7 +1227,7 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high) ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Encode simple data space in a buffer with the fapl setting */ + /* Encode simple dataspace in a buffer with the fapl setting */ ret = H5Sencode2(sid1, NULL, &sbuf_size, fapl); CHECK(ret, FAIL, "H5Sencode2"); @@ -1242,7 +1242,7 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high) } H5E_END_TRY; VERIFY(ret_id, FAIL, "H5Sdecode"); - /* Encode the simple data space in a buffer with the fapl setting */ + /* Encode the simple dataspace in a buffer with the fapl setting */ ret = H5Sencode2(sid1, sbuf, &sbuf_size, fapl); CHECK(ret, FAIL, "H5Sencode"); @@ -1289,7 +1289,7 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high) sid2 = H5Screate(H5S_NULL); CHECK(sid2, FAIL, "H5Screate"); - /* Encode null data space in a buffer */ + /* Encode null dataspace in a buffer */ ret = H5Sencode2(sid2, NULL, &null_size, fapl); CHECK(ret, FAIL, "H5Sencode"); @@ -1298,7 +1298,7 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high) CHECK(null_sbuf, NULL, "HDcalloc"); } - /* Encode the null data space in the buffer */ + /* Encode the null dataspace in the buffer */ ret = H5Sencode2(sid2, null_sbuf, &null_size, fapl); CHECK(ret, FAIL, "H5Sencode2"); @@ -1325,7 +1325,7 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high) sid3 = H5Screate(H5S_SCALAR); CHECK(sid3, FAIL, "H5Screate_simple"); - /* Encode scalar data space in a buffer */ + /* Encode scalar dataspace in a buffer */ ret = H5Sencode2(sid3, NULL, &scalar_size, fapl); CHECK(ret, FAIL, "H5Sencode"); @@ -1334,7 +1334,7 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high) CHECK(scalar_buf, NULL, "HDcalloc"); } - /* Encode the scalar data space in the buffer */ + /* Encode the scalar dataspace in the buffer */ ret = H5Sencode2(sid3, scalar_buf, &scalar_size, fapl); CHECK(ret, FAIL, "H5Sencode2"); @@ -1419,7 +1419,7 @@ test_h5s_encode1(void) ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Encode simple data space in a buffer with the fapl setting */ + /* Encode simple dataspace in a buffer with the fapl setting */ ret = H5Sencode1(sid1, NULL, &sbuf_size); CHECK(ret, FAIL, "H5Sencode2"); @@ -1434,7 +1434,7 @@ test_h5s_encode1(void) } H5E_END_TRY; VERIFY(ret_id, FAIL, "H5Sdecode"); - /* Encode the simple data space in a buffer */ + /* Encode the simple dataspace in a buffer */ ret = H5Sencode1(sid1, sbuf, &sbuf_size); CHECK(ret, FAIL, "H5Sencode"); @@ -1481,7 +1481,7 @@ test_h5s_encode1(void) sid2 = H5Screate(H5S_NULL); CHECK(sid2, FAIL, "H5Screate"); - /* Encode null data space in a buffer */ + /* Encode null dataspace in a buffer */ ret = H5Sencode1(sid2, NULL, &null_size); CHECK(ret, FAIL, "H5Sencode"); @@ -1490,7 +1490,7 @@ test_h5s_encode1(void) CHECK(null_sbuf, NULL, "HDcalloc"); } - /* Encode the null data space in the buffer */ + /* Encode the null dataspace in the buffer */ ret = H5Sencode1(sid2, null_sbuf, &null_size); CHECK(ret, FAIL, "H5Sencode2"); @@ -1515,9 +1515,9 @@ test_h5s_encode1(void) */ /* Create scalar dataspace */ sid3 = H5Screate(H5S_SCALAR); - CHECK(sid3, FAIL, "H5Screate_simple"); + CHECK(sid3, FAIL, "H5Screate"); - /* Encode scalar data space in a buffer */ + /* Encode scalar dataspace in a buffer */ ret = H5Sencode1(sid3, NULL, &scalar_size); CHECK(ret, FAIL, "H5Sencode"); @@ -1526,7 +1526,7 @@ test_h5s_encode1(void) CHECK(scalar_buf, NULL, "HDcalloc"); } - /* Encode the scalar data space in the buffer */ + /* Encode the scalar dataspace in the buffer */ ret = H5Sencode1(sid3, scalar_buf, &scalar_size); CHECK(ret, FAIL, "H5Sencode2"); @@ -1622,8 +1622,8 @@ test_h5s_check_encoding(hid_t in_fapl, hid_t in_sid, VERIFY(H5Sget_select_npoints(in_sid), H5Sget_select_npoints(d_sid), "Compare npoints"); /* Verify if the two dataspace selections (in_sid, d_sid) are the same shape */ - check = H5S__select_shape_same_test(in_sid, d_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(in_sid, d_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* Compare the starting/ending coordinates of the bounding box for in_sid and d_sid */ ret = H5Sget_select_bounds(in_sid, in_low_bounds, in_high_bounds); @@ -2127,7 +2127,7 @@ test_h5s_encode_length(void) ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Encode simple data space in a buffer */ + /* Encode simple dataspace in a buffer */ ret = H5Sencode2(sid, NULL, &sbuf_size, H5P_DEFAULT); CHECK(ret, FAIL, "H5Sencode"); @@ -2493,7 +2493,7 @@ test_h5s_chunk(void) status = H5Pset_chunk(plist_id, 2, csize); CHECK(status, FAIL, "H5Pset_chunk"); - /* Create the data space */ + /* Create the dataspace */ dims[0] = 50000; dims[1] = 3; space_id = H5Screate_simple(2, dims, NULL); diff --git a/test/tselect.c b/test/tselect.c index bbab868..4a47929 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -869,7 +869,7 @@ test_select_all_hyper(hid_t xfer_plist) /* Select no extent for disk dataset */ ret = H5Sselect_none(sid1); - CHECK(ret, FAIL, "H5Sselect_all"); + CHECK(ret, FAIL, "H5Sselect_none"); /* Read selection from disk (should fail with no selection defined) */ ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid2,sid1,xfer_plist,rbuf); @@ -890,7 +890,7 @@ test_select_all_hyper(hid_t xfer_plist) /* A quick check to make certain that iterating through a "none" selection works */ ret = H5Sselect_none(sid2); - CHECK(ret, FAIL, "H5Sselect_all"); + CHECK(ret, FAIL, "H5Sselect_none"); ret = H5Diterate(rbuf,H5T_NATIVE_UCHAR,sid2,test_select_none_iter1,&tbuf); CHECK(ret, FAIL, "H5Diterate"); @@ -1662,7 +1662,7 @@ verify_select_hyper_contig_dr__run_test(const uint16_t *cube_buf, ** test_select_hyper_contig_dr__run_test(): Test H5S (dataspace) ** selection code with contiguous source and target having ** different ranks but the same shape. We have already -** tested H5S_shape_same in isolation, so now we try to do +** tested H5Sselect_shape_same in isolation, so now we try to do ** I/O. ** ****************************************************************/ @@ -1846,11 +1846,11 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, /* first, verify that we can read from disk correctly using selections - * of different rank that H5S_select_shape_same() views as being of the + * of different rank that H5Sselect_shape_same() views as being of the * same shape. * * Start by reading small_rank-D slice from the on disk large cube, and - * verifying that the data read is correct. Verify that H5S_select_shape_same() + * verifying that the data read is correct. Verify that H5Sselect_shape_same() * returns true on the memory and file selections. */ @@ -1894,12 +1894,11 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, block_ptr); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* verify that H5S_select_shape_same() reports the two + /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. */ - check = H5S__select_shape_same_test(small_cube_sid, - file_large_cube_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(small_cube_sid, file_large_cube_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* Read selection from disk */ ret = H5Dread(large_cube_dataset, @@ -1971,12 +1970,11 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* verify that H5S_select_shape_same() reports the two + /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. */ - check = H5S__select_shape_same_test(small_cube_sid, - mem_large_cube_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(small_cube_sid, mem_large_cube_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* Read selection from disk */ @@ -2038,12 +2036,12 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, /* now we go in the opposite direction, verifying that we can write * from memory to file using selections of different rank that - * H5S_select_shape_same() views as being of the same shape. + * H5Sselect_shape_same() views as being of the same shape. * * Start by writing small_rank D slices from the in memory large cube, to * the the on disk small cube dataset. After each write, read the small * cube dataset back from disk, and verify that it contains the expected - * data. Verify that H5S_select_shape_same() returns true on the + * data. Verify that H5Sselect_shape_same() returns true on the * memory and file selections. */ @@ -2087,13 +2085,12 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* verify that H5S_select_shape_same() reports the in + /* verify that H5Sselect_shape_same() reports the in * memory slice through the cube selection and the * on disk full small cube selections as having the same shape. */ - check = H5S__select_shape_same_test(small_cube_sid, - mem_large_cube_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(small_cube_sid, mem_large_cube_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* write the slice from the in memory large cube to the on disk small cube */ @@ -2145,7 +2142,7 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, /* Now write the contents of the in memory small cube to slices of * the on disk cube. After each write, read the on disk cube * into memeory, and verify that it contains the expected - * data. Verify that H5S_select_shape_same() returns true on + * data. Verify that H5Sselect_shape_same() returns true on * the memory and file selections. */ @@ -2197,14 +2194,13 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* verify that H5S_select_shape_same() reports the in + /* verify that H5Sselect_shape_same() reports the in * memory full selection of the small cube and the * on disk slice through the large cube selection * as having the same shape. */ - check = H5S__select_shape_same_test(small_cube_sid, - file_large_cube_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(small_cube_sid, file_large_cube_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* write the cube from memory to the target slice of the disk cube */ @@ -2309,7 +2305,7 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, ** test_select_hyper_contig_dr(): Test H5S (dataspace) ** selection code with contiguous source and target having ** different ranks but the same shape. We have already -** tested H5S_shape_same in isolation, so now we try to do +** tested H5Sselect_shape_same in isolation, so now we try to do ** I/O. ** ****************************************************************/ @@ -2375,7 +2371,7 @@ test_select_hyper_contig_dr(hid_t dset_type, hid_t xfer_plist) /**************************************************************** ** ** test_select_hyper_checker_board_dr__select_checker_board(): -** Given an n-cube data space with each edge of length +** Given an n-cube dataspace with each edge of length ** edge_size, and a checker_edge_size either select a checker ** board selection of the entire cube(if sel_rank == n), ** or select a checker board selection of a @@ -2567,8 +2563,8 @@ test_select_hyper_checker_board_dr__select_checker_board(hid_t tgt_n_cube_sid, /* Wierdness alert: * * Some how, it seems that selections can extend beyond the - * boundaries of the target data space -- hence the following - * code to manually clip the selection back to the data space + * boundaries of the target dataspace -- hence the following + * code to manually clip the selection back to the dataspace * proper. */ for(u = 0; u < SS_DR_MAX_RANK; u++) { @@ -2732,7 +2728,7 @@ test_select_hyper_checker_board_dr__verify_data(uint16_t * buf_ptr, ** test_select_hyper_checker_board_dr__run_test(): Test H5S ** (dataspace) selection code with checker board source and ** target selections having different ranks but the same -** shape. We have already tested H5S_shape_same in +** shape. We have already tested H5Sselect_shape_same in ** isolation, so now we try to do I/O. ** ****************************************************************/ @@ -2938,11 +2934,11 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ /* first, verify that we can read from disk correctly using selections - * of different rank that H5S_select_shape_same() views as being of the + * of different rank that H5Sselect_shape_same() views as being of the * same shape. * * Start by reading small_rank-D slice from the on disk large cube, and - * verifying that the data read is correct. Verify that H5S_select_shape_same() + * verifying that the data read is correct. Verify that H5Sselect_shape_same() * returns true on the memory and file selections. * * The first step is to set up the needed checker board selection in the @@ -3004,12 +3000,11 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ sel_start ); - /* verify that H5S_select_shape_same() reports the two + /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. */ - check = H5S__select_shape_same_test(mem_small_cube_sid, - file_large_cube_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(mem_small_cube_sid, file_large_cube_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* zero the buffer that we will be using for reading */ HDmemset(small_cube_buf_1, 0, sizeof(*small_cube_buf_1) * small_cube_size); @@ -3111,12 +3106,11 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ sel_start ); - /* verify that H5S_select_shape_same() reports the two + /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. */ - check = H5S__select_shape_same_test(file_small_cube_sid, - mem_large_cube_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(file_small_cube_sid, mem_large_cube_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* zero out the in memory large cube */ @@ -3195,12 +3189,12 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ /* now we go in the opposite direction, verifying that we can write * from memory to file using selections of different rank that - * H5S_select_shape_same() views as being of the same shape. + * H5Sselect_shape_same() views as being of the same shape. * * Start by writing small_rank D slices from the in memory large cube, to * the the on disk small cube dataset. After each write, read the small * cube dataset back from disk, and verify that it contains the expected - * data. Verify that H5S_select_shape_same() returns true on the + * data. Verify that H5Sselect_shape_same() returns true on the * memory and file selections. */ @@ -3264,12 +3258,11 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ sel_start ); - /* verify that H5S_select_shape_same() reports the two + /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. */ - check = H5S__select_shape_same_test(file_small_cube_sid, - mem_large_cube_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(file_small_cube_sid, mem_large_cube_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* write the slice from the in memory large cube to the @@ -3332,7 +3325,7 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ * small cube to slices of the on disk cube. After each write, * read the on disk large cube * into memeory, and verify that * it contains the expected * data. Verify that - * H5S_select_shape_same() returns true on the memory and file + * H5Sselect_shape_same() returns true on the memory and file * selections. */ @@ -3396,12 +3389,11 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ sel_start ); - /* verify that H5S_select_shape_same() reports the two + /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. */ - check = H5S__select_shape_same_test(file_large_cube_sid, - mem_small_cube_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(file_large_cube_sid, mem_small_cube_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* write the checker board selection of the in memory @@ -3537,7 +3529,7 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ ** test_select_hyper_checker_board_dr(): Test H5S (dataspace) ** selection code with checkerboard source and target having ** different ranks but the same shape. We have already -** tested H5S_shape_same in isolation, so now we try to do +** tested H5Sselect_shape_same in isolation, so now we try to do ** I/O. ** ** This is just an initial smoke check, so we will work @@ -6133,7 +6125,7 @@ test_select_hyper_chunk(hid_t fapl_plist, hid_t xfer_plist) CHECK(file, FAIL, "H5Fcreate"); /* - * Describe the size of the array and create the data space for fixed + * Describe the size of the array and create the dataspace for fixed * size dataset. */ dimsf[0] = X; @@ -7874,7 +7866,7 @@ test_scalar_select2(void) /* Select all elements in memory & file with "all" selection */ ret = H5Sselect_all(sid); - CHECK(ret, FAIL, "H5Sselect_none"); + CHECK(ret, FAIL, "H5Sselect_all"); /* Close disk dataspace */ ret = H5Sclose(sid); @@ -8202,294 +8194,294 @@ test_shape_same(void) /* Compare "all" selection to all the selections created */ /* Compare against itself */ - check = H5S__select_shape_same_test(all_sid,all_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(all_sid ,all_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* Compare against copy of itself */ - tmp_sid=H5Scopy(all_sid); + tmp_sid = H5Scopy(all_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); - check = H5S__select_shape_same_test(all_sid,tmp_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(all_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against "none" selection */ - check = H5S__select_shape_same_test(all_sid,none_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(all_sid, none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against single point selection */ - check = H5S__select_shape_same_test(all_sid,single_pt_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(all_sid, single_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against multiple point selection */ - check = H5S__select_shape_same_test(all_sid,mult_pt_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(all_sid, mult_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "plain" single hyperslab selection */ - check = H5S__select_shape_same_test(all_sid,single_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(all_sid, single_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "all" single hyperslab selection */ - check = H5S__select_shape_same_test(all_sid,single_hyper_all_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(all_sid, single_hyper_all_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* Compare against "single point" single hyperslab selection */ - check = H5S__select_shape_same_test(all_sid,single_hyper_pt_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(all_sid, single_hyper_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against regular, strided hyperslab selection */ - check = H5S__select_shape_same_test(all_sid,regular_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(all_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against irregular hyperslab selection */ - check = H5S__select_shape_same_test(all_sid,irreg_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(all_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "no" hyperslab selection */ - check = H5S__select_shape_same_test(all_sid,none_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(all_sid, none_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against scalar "all" hyperslab selection */ - check = H5S__select_shape_same_test(all_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(all_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against scalar "none" hyperslab selection */ - check = H5S__select_shape_same_test(all_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(all_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare "none" selection to all the selections created */ /* Compare against itself */ - check = H5S__select_shape_same_test(none_sid,none_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(none_sid, none_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* Compare against copy of itself */ - tmp_sid=H5Scopy(none_sid); + tmp_sid = H5Scopy(none_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); - check = H5S__select_shape_same_test(none_sid,tmp_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(none_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against "all" selection */ - check = H5S__select_shape_same_test(none_sid,all_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(none_sid, all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against single point selection */ - check = H5S__select_shape_same_test(none_sid,single_pt_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(none_sid, single_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against multiple point selection */ - check = H5S__select_shape_same_test(none_sid,mult_pt_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(none_sid, mult_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "plain" single hyperslab selection */ - check = H5S__select_shape_same_test(none_sid,single_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(none_sid, single_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "all" single hyperslab selection */ - check = H5S__select_shape_same_test(none_sid,single_hyper_all_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(none_sid, single_hyper_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "single point" single hyperslab selection */ - check = H5S__select_shape_same_test(none_sid,single_hyper_pt_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(none_sid, single_hyper_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against regular, strided hyperslab selection */ - check = H5S__select_shape_same_test(none_sid,regular_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(none_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against irregular hyperslab selection */ - check = H5S__select_shape_same_test(none_sid,irreg_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(none_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "no" hyperslab selection */ - check = H5S__select_shape_same_test(none_sid,none_hyper_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(none_sid, none_hyper_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* Compare against scalar "all" hyperslab selection */ - check = H5S__select_shape_same_test(none_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(none_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against scalar "none" hyperslab selection */ - check = H5S__select_shape_same_test(none_sid, scalar_none_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(none_sid, scalar_none_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* Compare single point selection to all the selections created */ /* Compare against itself */ - check = H5S__select_shape_same_test(single_pt_sid,single_pt_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_pt_sid, single_pt_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* Compare against copy of itself */ - tmp_sid=H5Scopy(single_pt_sid); + tmp_sid = H5Scopy(single_pt_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); - check = H5S__select_shape_same_test(single_pt_sid,tmp_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_pt_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against "all" selection */ - check = H5S__select_shape_same_test(single_pt_sid,all_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_pt_sid, all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "none" selection */ - check = H5S__select_shape_same_test(single_pt_sid,none_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_pt_sid, none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against multiple point selection */ - check = H5S__select_shape_same_test(single_pt_sid,mult_pt_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_pt_sid, mult_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "plain" single hyperslab selection */ - check = H5S__select_shape_same_test(single_pt_sid,single_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_pt_sid, single_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "all" single hyperslab selection */ - check = H5S__select_shape_same_test(single_pt_sid,single_hyper_all_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_pt_sid, single_hyper_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "single point" single hyperslab selection */ - check = H5S__select_shape_same_test(single_pt_sid,single_hyper_pt_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_pt_sid, single_hyper_pt_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* Compare against regular, strided hyperslab selection */ - check = H5S__select_shape_same_test(single_pt_sid,regular_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_pt_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against irregular hyperslab selection */ - check = H5S__select_shape_same_test(single_pt_sid,irreg_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_pt_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "no" hyperslab selection */ - check = H5S__select_shape_same_test(single_pt_sid,none_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_pt_sid, none_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against scalar "all" hyperslab selection */ - check = H5S__select_shape_same_test(single_pt_sid, scalar_all_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_pt_sid, scalar_all_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* Compare against scalar "none" hyperslab selection */ - check = H5S__select_shape_same_test(single_pt_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_pt_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare multiple point selection to all the selections created */ /* Compare against itself */ - check = H5S__select_shape_same_test(mult_pt_sid,mult_pt_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(mult_pt_sid, mult_pt_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* Compare against copy of itself */ - tmp_sid=H5Scopy(mult_pt_sid); + tmp_sid = H5Scopy(mult_pt_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); - check = H5S__select_shape_same_test(mult_pt_sid,tmp_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(mult_pt_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against "all" selection */ - check = H5S__select_shape_same_test(mult_pt_sid,all_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(mult_pt_sid, all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "none" selection */ - check = H5S__select_shape_same_test(mult_pt_sid,none_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(mult_pt_sid, none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against single point selection */ - check = H5S__select_shape_same_test(mult_pt_sid,single_pt_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(mult_pt_sid, single_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "plain" single hyperslab selection */ - check = H5S__select_shape_same_test(mult_pt_sid,single_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(mult_pt_sid, single_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "all" single hyperslab selection */ - check = H5S__select_shape_same_test(mult_pt_sid,single_hyper_all_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(mult_pt_sid, single_hyper_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "single point" single hyperslab selection */ - check = H5S__select_shape_same_test(mult_pt_sid,single_hyper_pt_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(mult_pt_sid, single_hyper_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against regular, strided hyperslab selection */ - check = H5S__select_shape_same_test(mult_pt_sid,regular_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(mult_pt_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against irregular hyperslab selection */ - check = H5S__select_shape_same_test(mult_pt_sid,irreg_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(mult_pt_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "no" hyperslab selection */ - check = H5S__select_shape_same_test(mult_pt_sid,none_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(mult_pt_sid, none_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against scalar "all" hyperslab selection */ - check = H5S__select_shape_same_test(mult_pt_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(mult_pt_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against scalar "none" hyperslab selection */ - check = H5S__select_shape_same_test(mult_pt_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(mult_pt_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare single "normal" hyperslab selection to all the selections created */ /* Compare against itself */ - check = H5S__select_shape_same_test(single_hyper_sid,single_hyper_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_sid, single_hyper_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* Compare against copy of itself */ - tmp_sid=H5Scopy(single_hyper_sid); + tmp_sid = H5Scopy(single_hyper_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); - check = H5S__select_shape_same_test(single_hyper_sid,tmp_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against "all" selection */ - check = H5S__select_shape_same_test(single_hyper_sid,all_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_sid, all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "none" selection */ - check = H5S__select_shape_same_test(single_hyper_sid,none_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_sid, none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against single point selection */ - check = H5S__select_shape_same_test(single_hyper_sid,single_pt_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_sid, single_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against multiple point selection */ - check = H5S__select_shape_same_test(single_hyper_sid,mult_pt_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_sid, mult_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "all" single hyperslab selection */ - check = H5S__select_shape_same_test(single_hyper_sid,single_hyper_all_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_sid, single_hyper_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "single point" single hyperslab selection */ - check = H5S__select_shape_same_test(single_hyper_sid,single_hyper_pt_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_sid, single_hyper_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against regular, strided hyperslab selection */ - check = H5S__select_shape_same_test(single_hyper_sid,regular_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against irregular hyperslab selection */ - check = H5S__select_shape_same_test(single_hyper_sid,irreg_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "no" hyperslab selection */ - check = H5S__select_shape_same_test(single_hyper_sid,none_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_sid, none_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); #ifdef NOT_YET /* In theory, these two selections are the same shape, but the - * H5S_select_shape_same() routine is just not this sophisticated yet and it + * H5Sselect_shape_same() routine is just not this sophisticated yet and it * would take too much effort to make this work. The worst case is that the * non-optimized chunk mapping routines will be invoked instead of the more * optimized routines, so this only hurts performance, not correctness @@ -8500,17 +8492,19 @@ test_shape_same(void) CHECK(tmp_sid, FAIL, "H5Screate_simple"); /* Select sequence of points for point selection */ - for(u=1; u<(SPACE9_DIM1-1); u++) { - for(v=1; v<(SPACE9_DIM2-1); v++) { - coord2[v-1][0]=u; coord2[v-1][1]=v; + for(u = 1; u < (SPACE9_DIM1 - 1); u++) { + for(v = 1; v < (SPACE9_DIM2 - 1); v++) { + coord2[v - 1][0] = u; + coord2[v - 1][1] = v; } /* end for */ - ret = H5Sselect_elements(tmp_sid,H5S_SELECT_APPEND,(SPACE9_DIM2-2),coord2); + + ret = H5Sselect_elements(tmp_sid, H5S_SELECT_APPEND, (SPACE9_DIM2 - 2), coord2); CHECK(ret, FAIL, "H5Sselect_elements"); } /* end for */ /* Compare against hyperslab selection */ - check = H5S__select_shape_same_test(single_hyper_sid,tmp_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -8526,80 +8520,80 @@ test_shape_same(void) CHECK(ret, FAIL, "H5Sselect_none"); /* Select sequence of rows for hyperslab selection */ - for(u=1; u<(SPACE9_DIM1-1); u++) { - start[0]=u; start[1]=1; - stride[0]=1; stride[1]=1; - count[0]=1; count[1]=1; - block[0]=1; block[1]=(SPACE9_DIM2-2); - ret = H5Sselect_hyperslab(tmp_sid,H5S_SELECT_OR,start,stride,count,block); + for(u = 1; u < (SPACE9_DIM1 - 1); u++) { + start[0] = u; start[1] = 1; + stride[0] = 1; stride[1] = 1; + count[0] = 1; count[1] = 1; + block[0] = 1; block[1] = (SPACE9_DIM2 - 2); + ret = H5Sselect_hyperslab(tmp_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); } /* end for */ /* Compare against hyperslab selection */ - check = H5S__select_shape_same_test(single_hyper_sid,tmp_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against scalar "all" hyperslab selection */ - check = H5S__select_shape_same_test(single_hyper_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against scalar "none" hyperslab selection */ - check = H5S__select_shape_same_test(single_hyper_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare single "all" hyperslab selection to all the selections created */ /* Compare against itself */ - check = H5S__select_shape_same_test(single_hyper_all_sid,single_hyper_all_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_all_sid, single_hyper_all_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* Compare against copy of itself */ - tmp_sid=H5Scopy(single_hyper_all_sid); + tmp_sid = H5Scopy(single_hyper_all_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); - check = H5S__select_shape_same_test(single_hyper_all_sid,tmp_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_all_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against "all" selection */ - check = H5S__select_shape_same_test(single_hyper_all_sid,all_sid); - VERIFY(check, TRUE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_all_sid, all_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* Compare against "none" selection */ - check = H5S__select_shape_same_test(single_hyper_all_sid,none_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_all_sid, none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against single point selection */ - check = H5S__select_shape_same_test(single_hyper_all_sid,single_pt_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_all_sid, single_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against multiple point selection */ - check = H5S__select_shape_same_test(single_hyper_all_sid,mult_pt_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_all_sid, mult_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "plain" single hyperslab selection */ - check = H5S__select_shape_same_test(single_hyper_all_sid,single_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_all_sid, single_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "single point" single hyperslab selection */ - check = H5S__select_shape_same_test(single_hyper_all_sid,single_hyper_pt_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_all_sid, single_hyper_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against regular, strided hyperslab selection */ - check = H5S__select_shape_same_test(single_hyper_all_sid,regular_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_all_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against irregular hyperslab selection */ - check = H5S__select_shape_same_test(single_hyper_all_sid,irreg_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_all_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare against "no" hyperslab selection */ - check = H5S__select_shape_same_test(single_hyper_all_sid,none_hyper_sid); - VERIFY(check, FALSE, "H5S__select_shape_same_test"); + check = H5Sselect_shape_same(single_hyper_all_sid, none_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); #ifdef NOT_YET /* In theory, these two selections are the same shape, but the @@ -8614,17 +8608,18 @@ test_shape_same(void) CHECK(tmp_sid, FAIL, "H5Screate_simple"); /* Select sequence of points for point selection */ - for(u=0; u n) in a call to H5S_select_shape_same(). +** of a full n-cube dataspace vs an n-dimensional slice of +** of an m-cube (m > n) in a call to H5Sselect_shape_same(). ** Note that this test does not require the n-cube and the ** n-dimensional slice to have the same rank (although -** H5S_select_shape_same() should always return FALSE if +** H5Sselect_shape_same() should always return FALSE if ** they don't). ** ** Per Quincey's suggestion, only test up to 5 dimensional @@ -10634,15 +10628,15 @@ test_shape_same_dr__full_space_vs_slice(int test_num, block_ptr = &(block[i]); - /* select the hyper slab */ + /* select the hyperslab */ ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_SET, start_ptr, stride_ptr, count_ptr, block_ptr); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* setup is done -- run the test: */ - check = H5S__select_shape_same_test(n_cube_0_sid, n_cube_1_sid); - VERIFY(check, expected_result, "test_shape_same_dr__full_space_vs_slice"); + check = H5Sselect_shape_same(n_cube_0_sid, n_cube_1_sid); + VERIFY(check, expected_result, "H5Sselect_shape_same"); /* Close dataspaces */ @@ -10651,7 +10645,6 @@ test_shape_same_dr__full_space_vs_slice(int test_num, ret = H5Sclose(n_cube_1_sid); CHECK(ret, FAIL, "H5Sclose"); - } /* test_shape_same_dr__full_space_vs_slice() */ @@ -10659,10 +10652,10 @@ test_shape_same_dr__full_space_vs_slice(int test_num, ** ** test_shape_same_dr__run_full_space_vs_slice_tests(): ** -** Run the est_shape_same_dr__full_space_vs_slice() test +** Run the test_shape_same_dr__full_space_vs_slice() test ** over a variety of ranks and offsets. ** -** At present, we test H5S_select_shape_same() with +** At present, we test H5Sselect_shape_same() with ** fully selected 1, 2, 3, and 4 cubes as one parameter, and ** 1, 2, 3, and 4 dimensional slices through a n-cube of rank ** no more than 5 (and at least the rank of the slice). @@ -10670,7 +10663,7 @@ test_shape_same_dr__full_space_vs_slice(int test_num, ** sufficient. ** ** All the n-cubes will have lengths of the same size, so -** H5S_select_shape_same() should return true iff: +** H5Sselect_shape_same() should return true iff: ** ** 1) the rank for the fully selected n cube equals the ** number of dimensions selected in the slice through the @@ -10800,20 +10793,19 @@ test_shape_same_dr__run_full_space_vs_slice_tests(void) } while((v < 2) && (large_rank >= 5)); } /* end for */ } /* end for */ - } /* test_shape_same_dr__run_full_space_vs_slice_tests() */ /**************************************************************** ** ** test_shape_same_dr__checkerboard(): Tests selection of a -** "checker board" subset of a full n-cube data space vs +** "checker board" subset of a full n-cube dataspace vs ** a "checker board" n-dimensional slice of an m-cube (m > n). -** in a call to H5S_select_shape_same(). +** in a call to H5Sselect_shape_same(). ** ** Note that this test does not require the n-cube and the ** n-dimensional slice to have the same rank (although -** H5S_select_shape_same() should always return FALSE if +** H5Sselect_shape_same() should always return FALSE if ** they don't). ** ** Per Quincey's suggestion, only test up to 5 dimensional @@ -11016,8 +11008,8 @@ test_shape_same_dr__checkerboard(int test_num, /* Wierdness alert: * * Some how, it seems that selections can extend beyond the - * boundaries of the target data space -- hence the following - * code to manually clip the selection back to the data space + * boundaries of the target dataspace -- hence the following + * code to manually clip the selection back to the dataspace * proper. */ for(i = 0; i < SS_DR_MAX_RANK; i++) { @@ -11078,7 +11070,7 @@ test_shape_same_dr__checkerboard(int test_num, count_ptr = &(count[i]); block_ptr = &(block[i]); - /* select the hyper slab */ + /* select the hyperslab */ ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_SET, start_ptr, stride_ptr, count_ptr, block_ptr); CHECK(ret, FAIL, "H5Sselect_hyperslab"); @@ -11117,8 +11109,8 @@ test_shape_same_dr__checkerboard(int test_num, /* Wierdness alert: * * Again, it seems that selections can extend beyond the - * boundaries of the target data space -- hence the following - * code to manually clip the selection back to the data space + * boundaries of the target dataspace -- hence the following + * code to manually clip the selection back to the dataspace * proper. */ for(i = 0; i < SS_DR_MAX_RANK; i++) { @@ -11133,8 +11125,8 @@ test_shape_same_dr__checkerboard(int test_num, CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* setup is done -- run the test: */ - check = H5S__select_shape_same_test(n_cube_0_sid, n_cube_1_sid); - VERIFY(check, expected_result, "test_shape_same_dr__checkerboard"); + check = H5Sselect_shape_same(n_cube_0_sid, n_cube_1_sid); + VERIFY(check, expected_result, "H5Sselect_shape_same"); /* Close dataspaces */ @@ -11143,7 +11135,6 @@ test_shape_same_dr__checkerboard(int test_num, ret = H5Sclose(n_cube_1_sid); CHECK(ret, FAIL, "H5Sclose"); - } /* test_shape_same_dr__checkerboard() */ @@ -11151,14 +11142,14 @@ test_shape_same_dr__checkerboard(int test_num, ** ** test_shape_same_dr__run_checkerboard_tests(): ** -** In this set of tests, we test H5S_select_shape_same() +** In this set of tests, we test H5Sselect_shape_same() ** with a "checkerboard" selection of 1, 2, 3, and 4 cubes as ** one parameter, and 1, 2, 3, and 4 dimensional checkerboard ** slices through a n-cube of rank no more than 5 (and at ** least the rank of the slice). ** ** All the n-cubes will have lengths of the same size, so -** H5S_select_shape_same() should return true iff: +** H5Sselect_shape_same() should return true iff: ** ** 1) the rank of the n cube equals the number of dimensions ** selected in the checker board slice through the m-cube @@ -11414,7 +11405,6 @@ test_shape_same_dr__run_checkerboard_tests(void) } while((v < 2) && (large_rank >= 5)); } /* end for */ } /* end for */ - } /* test_shape_same_dr__run_checkerboard_tests() */ @@ -11423,13 +11413,13 @@ test_shape_same_dr__run_checkerboard_tests(void) ** test_shape_same_dr__irregular(): ** ** Tests selection of an "irregular" subset of a full -** n-cube data space vs an identical "irregular" subset +** n-cube dataspace vs an identical "irregular" subset ** of an n-dimensional slice of an m-cube (m > n). -** in a call to H5S_select_shape_same(). +** in a call to H5Sselect_shape_same(). ** ** Note that this test does not require the n-cube and the ** n-dimensional slice to have the same rank (although -** H5S_select_shape_same() should always return FALSE if +** H5Sselect_shape_same() should always return FALSE if ** they don't). ** ****************************************************************/ @@ -11588,7 +11578,7 @@ test_shape_same_dr__irregular(int test_num, * Note that is this case, since the edge size is fixed, * the pattern does not change. However, we do use the * displacement parameter to allow it to be moved around - * within the n-cube or hyper slab. + * within the n-cube or hyperslab. */ /* first, ensure that the small n-cube has no selection */ @@ -11664,13 +11654,13 @@ test_shape_same_dr__irregular(int test_num, } /* end else */ } /* end for */ - /* select the hyper slab */ + /* select the hyperslab */ ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_OR, start_ptr, stride_ptr, count_ptr, block_ptr); CHECK(ret, FAIL, "H5Sselect_hyperslab"); } /* end for */ - /* it is possible that the selection extends beyond the data space. + /* it is possible that the selection extends beyond the dataspace. * clip the selection to ensure that it doesn't. */ ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_AND, @@ -11679,8 +11669,8 @@ test_shape_same_dr__irregular(int test_num, /* setup is done -- run the test: */ - check = H5S__select_shape_same_test(n_cube_0_sid, n_cube_1_sid); - VERIFY(check, expected_result, "test_shape_same_dr__checkerboard"); + check = H5Sselect_shape_same(n_cube_0_sid, n_cube_1_sid); + VERIFY(check, expected_result, "H5Sselect_shape_same"); /* Close dataspaces */ @@ -11689,7 +11679,6 @@ test_shape_same_dr__irregular(int test_num, ret = H5Sclose(n_cube_1_sid); CHECK(ret, FAIL, "H5Sclose"); - } /* test_shape_same_dr__irregular() */ @@ -11697,7 +11686,7 @@ test_shape_same_dr__irregular(int test_num, ** ** test_shape_same_dr__run_irregular_tests(): ** -** In this set of tests, we test H5S_select_shape_same() +** In this set of tests, we test H5Sselect_shape_same() ** with an "irregular" subselection of 1, 2, 3, and 4 cubes as ** one parameter, and irregular subselections of 1, 2, 3, ** and 4 dimensional slices through a n-cube of rank no more @@ -11706,7 +11695,7 @@ test_shape_same_dr__irregular(int test_num, ** the n-cube and the slice. ** ** All the irregular selections will be identical (modulo rank) -** so H5S_select_shape_same() should return true iff: +** so H5Sselect_shape_same() should return true iff: ** ** 1) the rank of the n cube equals the number of dimensions ** selected in the irregular slice through the m-cube @@ -11904,7 +11893,6 @@ test_shape_same_dr__run_irregular_tests(void) } while((v < 2 ) && (large_rank >= 5)); } /* end for */ } /* end for */ - } /* test_shape_same_dr__run_irregular_tests() */ @@ -11921,19 +11909,16 @@ test_shape_same_dr(void) /* Output message about test being performed */ MESSAGE(6, ("Testing Same Shape/Different Rank Comparisons\n")); - /* first run some smoke checks */ test_shape_same_dr__smoke_check_1(); test_shape_same_dr__smoke_check_2(); test_shape_same_dr__smoke_check_3(); test_shape_same_dr__smoke_check_4(); - /* now run more intensive tests. */ test_shape_same_dr__run_full_space_vs_slice_tests(); test_shape_same_dr__run_checkerboard_tests(); test_shape_same_dr__run_irregular_tests(); - } /* test_shape_same_dr() */ @@ -12042,8 +12027,8 @@ test_space_rebuild(void) } /* end if */ if(ret != FAIL) { /* In this case, rebuild_check should be TRUE. */ - rebuild_check = H5S__select_shape_same_test(sid_reg1,sid_reg_ori1); - CHECK(rebuild_check,FALSE,"H5S_hyper_rebuild"); + rebuild_check = H5Sselect_shape_same(sid_reg1, sid_reg_ori1); + CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); } /* end if */ /* For irregular hyperslab */ @@ -12130,8 +12115,8 @@ test_space_rebuild(void) } /* end if */ if(ret != FAIL) { /* In this case, rebuild_check should be TRUE. */ - rebuild_check = H5S__select_shape_same_test(sid_reg2,sid_reg_ori2); - CHECK(rebuild_check,FALSE,"H5S_hyper_rebuild"); + rebuild_check = H5Sselect_shape_same(sid_reg2, sid_reg_ori2); + CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); } /* end if */ /* 2-D irregular case */ @@ -12228,8 +12213,8 @@ test_space_rebuild(void) } /* end if */ if(ret != FAIL) { /* In this case, rebuild_check should be TRUE. */ - rebuild_check = H5S__select_shape_same_test(sid_reg3,sid_reg_ori3); - CHECK(rebuild_check,FALSE,"H5S_hyper_rebuild"); + rebuild_check = H5Sselect_shape_same(sid_reg3, sid_reg_ori3); + CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); } /* end if */ sid_irreg3 = H5Screate_simple(SPACERE3_RANK,dims3,NULL); @@ -12339,8 +12324,8 @@ test_space_rebuild(void) } /* end if */ if(ret != FAIL) { /* In this case, rebuild_check should be TRUE. */ - rebuild_check = H5S__select_shape_same_test(sid_reg4,sid_reg_ori4); - CHECK(rebuild_check,FALSE,"H5S_hyper_rebuild"); + rebuild_check = H5Sselect_shape_same(sid_reg4, sid_reg_ori4); + CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); } /* end if */ /* Testing irregular selection */ @@ -12465,8 +12450,8 @@ test_space_rebuild(void) } /* end if */ if(ret != FAIL) { /* In this case, rebuild_check should be TRUE. */ - rebuild_check = H5S__select_shape_same_test(sid_reg5,sid_reg_ori5); - CHECK(rebuild_check,FALSE,"H5S_hyper_rebuild"); + rebuild_check = H5Sselect_shape_same(sid_reg5, sid_reg_ori5); + CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); } /* end if */ sid_irreg5 = H5Screate_simple(SPACERE5_RANK,dims5,NULL); @@ -15189,6 +15174,148 @@ test_sel_iter(void) CHECK(ret, FAIL, "H5Sclose"); } /* test_sel_iter() */ +/**************************************************************** +** +** test_select_intersect_block(): Test selections on dataspace, +** verify that "intersect block" routine is working correctly. +** +****************************************************************/ +static void +test_select_intersect_block(void) +{ + hid_t sid; /* Dataspace ID */ + hsize_t dims1[] = {6, 12}; /* 2-D Dataspace dimensions */ + hsize_t block_start[] = {1, 3}; /* Start offset for block */ + hsize_t block_end[] = {2, 5}; /* End offset for block */ + hsize_t block_end2[] = {0, 5}; /* Bad end offset for block */ + hsize_t block_end3[] = {2, 2}; /* Another bad end offset for block */ + hsize_t block_end4[] = {1, 3}; /* End offset that makes a single element block */ + hsize_t coord[10][2]; /* Coordinates for point selection */ + hsize_t start[2]; /* Starting location of hyperslab */ + hsize_t stride[2]; /* Stride of hyperslab */ + hsize_t count[2]; /* Element count of hyperslab */ + hsize_t block[2]; /* Block size of hyperslab */ + htri_t status; /* Intersection status */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(6, ("Testing Dataspace Selection Block Intersection\n")); + + /* Create dataspace */ + sid = H5Screate_simple(2, dims1, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + + + /* Try intersection calls with bad parameters */ + H5E_BEGIN_TRY { /* Bad dataspace ID */ + status = H5Sselect_intersect_block(H5I_INVALID_HID, block_start, block_end); + } H5E_END_TRY; + VERIFY(status, FAIL, "H5Sselect_intersect_block"); + H5E_BEGIN_TRY { /* Bad start pointer */ + status = H5Sselect_intersect_block(sid, NULL, block_end); + } H5E_END_TRY; + VERIFY(status, FAIL, "H5Sselect_intersect_block"); + H5E_BEGIN_TRY { /* Bad end pointer */ + status = H5Sselect_intersect_block(sid, block_start, NULL); + } H5E_END_TRY; + VERIFY(status, FAIL, "H5Sselect_intersect_block"); + H5E_BEGIN_TRY { /* Invalid block */ + status = H5Sselect_intersect_block(sid, block_start, block_end2); + } H5E_END_TRY; + VERIFY(status, FAIL, "H5Sselect_intersect_block"); + H5E_BEGIN_TRY { /* Another invalid block */ + status = H5Sselect_intersect_block(sid, block_start, block_end3); + } H5E_END_TRY; + VERIFY(status, FAIL, "H5Sselect_intersect_block"); + + + /* Set selection to 'none' */ + ret = H5Sselect_none(sid); + CHECK(ret, FAIL, "H5Sselect_none"); + + /* Test block intersection with 'none' selection (always false) */ + status = H5Sselect_intersect_block(sid, block_start, block_end); + VERIFY(status, FALSE, "H5Sselect_intersect_block"); + + + /* Set selection to 'all' */ + ret = H5Sselect_all(sid); + CHECK(ret, FAIL, "H5Sselect_all"); + + /* Test block intersection with 'all' selection (always true) */ + status = H5Sselect_intersect_block(sid, block_start, block_end); + VERIFY(status, TRUE, "H5Sselect_intersect_block"); + + + /* Select sequence of ten points */ + coord[0][0] = 0; coord[0][1] = 10; + coord[1][0] = 1; coord[1][1] = 2; + coord[2][0] = 2; coord[2][1] = 4; + coord[3][0] = 0; coord[3][1] = 6; + coord[4][0] = 1; coord[4][1] = 8; + coord[5][0] = 2; coord[5][1] = 11; + coord[6][0] = 0; coord[6][1] = 4; + coord[7][0] = 1; coord[7][1] = 0; + coord[8][0] = 2; coord[8][1] = 1; + coord[9][0] = 0; coord[9][1] = 3; + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)10, (const hsize_t *)coord); + CHECK(ret, FAIL, "H5Sselect_elements"); + + /* Test block intersection with 'point' selection */ + status = H5Sselect_intersect_block(sid, block_start, block_end); + VERIFY(status, TRUE, "H5Sselect_intersect_block"); + status = H5Sselect_intersect_block(sid, block_start, block_end4); + VERIFY(status, FALSE, "H5Sselect_intersect_block"); + + + /* Select single 4x6 hyperslab block at (2,1) */ + start[0] = 2; start[1] = 1; + stride[0] = 1; stride[1] = 1; + count[0] = 4; count[1] = 6; + block[0] = 1; block[1] = 1; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Test block intersection with single 'hyperslab' selection */ + status = H5Sselect_intersect_block(sid, block_start, block_end); + VERIFY(status, TRUE, "H5Sselect_intersect_block"); + status = H5Sselect_intersect_block(sid, block_start, block_end4); + VERIFY(status, FALSE, "H5Sselect_intersect_block"); + + /* 'OR' another hyperslab block in, making an irregular hyperslab selection */ + start[0] = 3; start[1] = 2; + stride[0] = 1; stride[1] = 1; + count[0] = 4; count[1] = 6; + block[0] = 1; block[1] = 1; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Test block intersection with 'hyperslab' selection */ + status = H5Sselect_intersect_block(sid, block_start, block_end); + VERIFY(status, TRUE, "H5Sselect_intersect_block"); + status = H5Sselect_intersect_block(sid, block_start, block_end4); + VERIFY(status, FALSE, "H5Sselect_intersect_block"); + + /* Select regular, strided hyperslab selection */ + start[0] = 2; start[1] = 1; + stride[0] = 2; stride[1] = 2; + count[0] = 2; count[1] = 4; + block[0] = 1; block[1] = 1; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Test block intersection with single 'hyperslab' selection */ + status = H5Sselect_intersect_block(sid, block_start, block_end); + VERIFY(status, TRUE, "H5Sselect_intersect_block"); + status = H5Sselect_intersect_block(sid, block_start, block_end4); + VERIFY(status, FALSE, "H5Sselect_intersect_block"); + + + /* Close dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); +} /* test_select_intersect_block() */ + /**************************************************************** ** @@ -15369,6 +15496,9 @@ test_select(void) /* Test selection iterators */ test_sel_iter(); + + /* Test selection intersection with block */ + test_select_intersect_block(); } /* test_select() */ @@ -15382,8 +15512,6 @@ test_select(void) * Programmer: Albert Cheng * July 2, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ void diff --git a/testpar/t_shapesame.c b/testpar/t_shapesame.c index f5282bd..b65e219 100644 --- a/testpar/t_shapesame.c +++ b/testpar/t_shapesame.c @@ -110,10 +110,6 @@ struct hs_dr_pio_test_vars_t * * Programmer: JRM -- 8/9/11 * - * Modifications: - * - * None. - * *------------------------------------------------------------------------- */ @@ -573,7 +569,7 @@ hs_dr_pio_test__setup(const int test_num, tv_ptr->block); VRFY((ret >= 0), "H5Sselect_hyperslab(file_large_ds_sid_0, set) suceeded"); - /* In passing, setup the process slice data spaces as well */ + /* In passing, setup the process slice dataspaces as well */ ret = H5Sselect_hyperslab(tv_ptr->mem_large_ds_process_slice_sid, H5S_SELECT_SET, @@ -685,10 +681,6 @@ hs_dr_pio_test__setup(const int test_num, * * Programmer: JRM -- 9/18/09 * - * Modifications: - * - * None. - * *------------------------------------------------------------------------- */ @@ -791,22 +783,18 @@ hs_dr_pio_test__takedown( struct hs_dr_pio_test_vars_t * tv_ptr) * selections of different rank in the parallel. * * Verify that we can read from disk correctly using - * selections of different rank that H5S_select_shape_same() + * selections of different rank that H5Sselect_shape_same() * views as being of the same shape. * * In this function, we test this by reading small_rank - 1 * slices from the on disk large cube, and verifying that the - * data read is correct. Verify that H5S_select_shape_same() + * data read is correct. Verify that H5Sselect_shape_same() * returns true on the memory and file selections. * * Return: void * * Programmer: JRM -- 9/10/11 * - * Modifications: - * - * None. - * *------------------------------------------------------------------------- */ @@ -831,7 +819,7 @@ contig_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) mpi_rank = tv_ptr->mpi_rank; - /* We have already done a H5Sselect_all() on the data space + /* We have already done a H5Sselect_all() on the dataspace * small_ds_slice_sid in the initialization phase, so no need to * call H5Sselect_all() again. */ @@ -945,12 +933,11 @@ contig_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) "H5Sselect_hyperslab(file_large_cube_sid) succeeded"); - /* verify that H5S_select_shape_same() reports the two + /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. */ - check = H5S__select_shape_same_test(tv_ptr->small_ds_slice_sid, - tv_ptr->file_large_ds_sid_0); - VRFY((check == TRUE), "H5S__select_shape_same_test passed"); + check = H5Sselect_shape_same(tv_ptr->small_ds_slice_sid, tv_ptr->file_large_ds_sid_0); + VRFY((check == TRUE), "H5Sselect_shape_same passed"); /* Read selection from disk */ @@ -1032,7 +1019,7 @@ contig_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * selections of different rank in the parallel. * * Verify that we can read from disk correctly using - * selections of different rank that H5S_select_shape_same() + * selections of different rank that H5Sselect_shape_same() * views as being of the same shape. * * In this function, we test this by reading slices of the @@ -1044,10 +1031,6 @@ contig_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * * Programmer: JRM -- 8/10/11 * - * Modifications: - * - * None. - * *------------------------------------------------------------------------- */ @@ -1213,12 +1196,11 @@ contig_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) "H5Sselect_hyperslab(mem_large_ds_sid) succeeded"); - /* verify that H5S_select_shape_same() reports the two + /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. */ - check = H5S__select_shape_same_test(tv_ptr->file_small_ds_sid_0, - tv_ptr->mem_large_ds_sid); - VRFY((check == TRUE), "H5S__select_shape_same_test passed"); + check = H5Sselect_shape_same(tv_ptr->file_small_ds_sid_0, tv_ptr->mem_large_ds_sid); + VRFY((check == TRUE), "H5Sselect_shape_same passed"); /* Read selection from disk */ @@ -1315,24 +1297,20 @@ contig_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * selections of different rank in the parallel. * * Verify that we can write from memory to file using - * selections of different rank that H5S_select_shape_same() + * selections of different rank that H5Sselect_shape_same() * views as being of the same shape. * * Do this by writing small_rank - 1 dimensional slices from * the in memory large data set to the on disk small cube * dataset. After each write, read the slice of the small * dataset back from disk, and verify that it contains - * the expected data. Verify that H5S_select_shape_same() + * the expected data. Verify that H5Sselect_shape_same() * returns true on the memory and file selections. * * Return: void * * Programmer: JRM -- 8/10/11 * - * Modifications: - * - * None. - * *------------------------------------------------------------------------- */ @@ -1361,12 +1339,12 @@ contig_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) /* now we go in the opposite direction, verifying that we can write * from memory to file using selections of different rank that - * H5S_select_shape_same() views as being of the same shape. + * H5Sselect_shape_same() views as being of the same shape. * * Start by writing small_rank - 1 dimensional slices from the in memory large * data set to the on disk small cube dataset. After each write, read the * slice of the small dataset back from disk, and verify that it contains - * the expected data. Verify that H5S_select_shape_same() returns true on + * the expected data. Verify that H5Sselect_shape_same() returns true on * the memory and file selections. */ @@ -1527,13 +1505,12 @@ contig_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) "H5Sselect_hyperslab() mem_large_ds_sid succeeded."); - /* verify that H5S_select_shape_same() reports the in + /* verify that H5Sselect_shape_same() reports the in * memory slice through the cube selection and the * on disk full square selections as having the same shape. */ - check = H5S__select_shape_same_test(tv_ptr->file_small_ds_sid_0, - tv_ptr->mem_large_ds_sid); - VRFY((check == TRUE), "H5S__select_shape_same_test passed."); + check = H5Sselect_shape_same(tv_ptr->file_small_ds_sid_0, tv_ptr->mem_large_ds_sid); + VRFY((check == TRUE), "H5Sselect_shape_same passed."); /* write the slice from the in memory large data set to the @@ -1643,7 +1620,7 @@ contig_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * selections of different rank in the parallel. * * Verify that we can write from memory to file using - * selections of different rank that H5S_select_shape_same() + * selections of different rank that H5Sselect_shape_same() * views as being of the same shape. * * Do this by writing the contents of the process's slice of @@ -1652,17 +1629,13 @@ contig_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * slice of the large data set back into memory, and verify * that it contains the expected data. * - * Verify that H5S_select_shape_same() returns true on the + * Verify that H5Sselect_shape_same() returns true on the * memory and file selections. * * Return: void * * Programmer: JRM -- 8/10/11 * - * Modifications: - * - * None - * *------------------------------------------------------------------------- */ @@ -1692,7 +1665,7 @@ contig_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * small data set to slices of the on disk large data set. After * each write, read the process's slice of the large data set back * into memory, and verify that it contains the expected data. - * Verify that H5S_select_shape_same() returns true on the memory + * Verify that H5Sselect_shape_same() returns true on the memory * and file selections. */ @@ -1859,14 +1832,13 @@ contig_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) "H5Sselect_hyperslab() target large ds slice succeeded"); - /* verify that H5S_select_shape_same() reports the in + /* verify that H5Sselect_shape_same() reports the in * memory small data set slice selection and the * on disk slice through the large data set selection * as having the same shape. */ - check = H5S__select_shape_same_test(tv_ptr->mem_small_ds_sid, - tv_ptr->file_large_ds_sid_0); - VRFY((check == TRUE), "H5S__select_shape_same_test passed"); + check = H5Sselect_shape_same(tv_ptr->mem_small_ds_sid, tv_ptr->file_large_ds_sid_0); + VRFY((check == TRUE), "H5Sselect_shape_same passed"); /* write the small data set slice from memory to the @@ -1986,21 +1958,6 @@ contig_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * * Programmer: JRM -- 9/18/09 * - * Modifications: - * - * JRM -- 9/16/10 - * Added express_test parameter. Use it to control whether - * we set up the chunks so that no chunk is shared between - * processes, and also whether we set an alignment when we - * create the test file. - * - * JRM -- 8/11/11 - * Refactored function heavily & broke it into six functions. - * Added the skips_ptr, max_skips, total_tests_ptr, - * tests_run_ptr, and tests_skiped_ptr parameters to support - * skipping portions of the test according to the express - * test value. - * *------------------------------------------------------------------------- */ @@ -2108,12 +2065,12 @@ contig_hs_dr_pio_test__run_test(const int test_num, #endif /* CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG */ /* first, verify that we can read from disk correctly using selections - * of different rank that H5S_select_shape_same() views as being of the + * of different rank that H5Sselect_shape_same() views as being of the * same shape. * * Start by reading small_rank - 1 dimensional slice from the on disk * large cube, and verifying that the data read is correct. Verify that - * H5S_select_shape_same() returns true on the memory and file selections. + * H5Sselect_shape_same() returns true on the memory and file selections. */ #if CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG @@ -2139,12 +2096,12 @@ contig_hs_dr_pio_test__run_test(const int test_num, /* now we go in the opposite direction, verifying that we can write * from memory to file using selections of different rank that - * H5S_select_shape_same() views as being of the same shape. + * H5Sselect_shape_same() views as being of the same shape. * * Start by writing small_rank - 1 D slices from the in memory large data * set to the on disk small cube dataset. After each write, read the * slice of the small dataset back from disk, and verify that it contains - * the expected data. Verify that H5S_select_shape_same() returns true on + * the expected data. Verify that H5Sselect_shape_same() returns true on * the memory and file selections. */ @@ -2160,7 +2117,7 @@ contig_hs_dr_pio_test__run_test(const int test_num, * small data set to slices of the on disk large data set. After * each write, read the process's slice of the large data set back * into memory, and verify that it contains the expected data. - * Verify that H5S_select_shape_same() returns true on the memory + * Verify that H5Sselect_shape_same() returns true on the memory * and file selections. */ @@ -2208,20 +2165,6 @@ contig_hs_dr_pio_test__run_test(const int test_num, * * Programmer: JRM -- 9/18/09 * - * Modifications: - * - * Modified function to take a sample of the run times - * of the different tests, and skip some of them if - * run times are too long. - * - * We need to do this because Lustre runns very slowly - * if two or more processes are banging on the same - * block of memory. - * JRM -- 9/10/10 - * Break this one big test into 4 smaller tests according - * to {independent,collective}x{contigous,chunked} datasets. - * AKC -- 2010/01/14 - * *------------------------------------------------------------------------- */ @@ -2395,18 +2338,18 @@ contig_hs_dr_pio_test(ShapeSameTestMethods sstest_type) /**************************************************************** ** ** ckrbrd_hs_dr_pio_test__slct_ckrbrd(): -** Given a data space of tgt_rank, and dimensions: +** Given a dataspace of tgt_rank, and dimensions: ** ** (mpi_size + 1), edge_size, ... , edge_size ** ** edge_size, and a checker_edge_size, select a checker ** board selection of a sel_rank (sel_rank < tgt_rank) -** dimensional slice through the data space parallel to the +** dimensional slice through the dataspace parallel to the ** sel_rank fastest changing indicies, with origin (in the ** higher indicies) as indicated by the start array. ** ** Note that this function, like all its relatives, is -** hard coded to presume a maximum data space rank of 5. +** hard coded to presume a maximum dataspace rank of 5. ** While this maximum is declared as a constant, increasing ** it will require extensive coding in addition to changing ** the value of the constant. @@ -2707,7 +2650,7 @@ ckrbrd_hs_dr_pio_test__slct_ckrbrd(const int mpi_rank, fcnName, mpi_rank, (int)H5Sget_select_npoints(tgt_sid)); #endif /* CKRBRD_HS_DR_PIO_TEST__SELECT_CHECKER_BOARD__DEBUG */ - /* Clip the selection back to the data space proper. */ + /* Clip the selection back to the dataspace proper. */ for ( i = 0; i < test_max_rank; i++ ) { @@ -2956,22 +2899,18 @@ ckrbrd_hs_dr_pio_test__verify_data(uint32_t * buf_ptr, * * Verify that we can read from disk correctly using checker * board selections of different rank that - * H5S_select_shape_same() views as being of the same shape. + * H5Sselect_shape_same() views as being of the same shape. * - * In this function, we test this by reading small_rank - 1 + * In this function, we test this by reading small_rank - 1 * checker board slices from the on disk large cube, and * verifying that the data read is correct. Verify that - * H5S_select_shape_same() returns true on the memory and + * H5Sselect_shape_same() returns true on the memory and * file selections. * * Return: void * * Programmer: JRM -- 9/15/11 * - * Modifications: - * - * None. - * *------------------------------------------------------------------------- */ @@ -2997,12 +2936,12 @@ ckrbrd_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) /* first, verify that we can read from disk correctly using selections - * of different rank that H5S_select_shape_same() views as being of the + * of different rank that H5Sselect_shape_same() views as being of the * same shape. * * Start by reading a (small_rank - 1)-D checker board slice from this * processes slice of the on disk large data set, and verifying that the - * data read is correct. Verify that H5S_select_shape_same() returns + * data read is correct. Verify that H5Sselect_shape_same() returns * true on the memory and file selections. * * The first step is to set up the needed checker board selection in the @@ -3146,12 +3085,11 @@ ckrbrd_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) tv_ptr->start ); - /* verify that H5S_select_shape_same() reports the two + /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. */ - check = H5S__select_shape_same_test(tv_ptr->small_ds_slice_sid, - tv_ptr->file_large_ds_sid_0); - VRFY((check == TRUE), "H5S__select_shape_same_test passed"); + check = H5Sselect_shape_same(tv_ptr->small_ds_slice_sid, tv_ptr->file_large_ds_sid_0); + VRFY((check == TRUE), "H5Sselect_shape_same passed"); /* Read selection from disk */ @@ -3231,7 +3169,7 @@ ckrbrd_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * selections of different rank in the parallel. * * Verify that we can read from disk correctly using - * selections of different rank that H5S_select_shape_same() + * selections of different rank that H5Sselect_shape_same() * views as being of the same shape. * * In this function, we test this by reading checker board @@ -3243,10 +3181,6 @@ ckrbrd_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * * Programmer: JRM -- 8/15/11 * - * Modifications: - * - * None. - * *------------------------------------------------------------------------- */ @@ -3412,12 +3346,11 @@ ckrbrd_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) ); - /* verify that H5S_select_shape_same() reports the two + /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. */ - check = H5S__select_shape_same_test(tv_ptr->file_small_ds_sid_0, - tv_ptr->mem_large_ds_sid); - VRFY((check == TRUE), "H5S__select_shape_same_test passed"); + check = H5Sselect_shape_same(tv_ptr->file_small_ds_sid_0, tv_ptr->mem_large_ds_sid); + VRFY((check == TRUE), "H5Sselect_shape_same passed"); /* Read selection from disk */ @@ -3561,24 +3494,20 @@ ckrbrd_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * * Verify that we can write from memory to file using checker * board selections of different rank that - * H5S_select_shape_same() views as being of the same shape. + * H5Sselect_shape_same() views as being of the same shape. * * Do this by writing small_rank - 1 dimensional checker * board slices from the in memory large data set to the on * disk small cube dataset. After each write, read the * slice of the small dataset back from disk, and verify * that it contains the expected data. Verify that - * H5S_select_shape_same() returns true on the memory and + * H5Sselect_shape_same() returns true on the memory and * file selections. * * Return: void * * Programmer: JRM -- 8/15/11 * - * Modifications: - * - * None. - * *------------------------------------------------------------------------- */ @@ -3609,12 +3538,12 @@ ckrbrd_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) /* now we go in the opposite direction, verifying that we can write * from memory to file using selections of different rank that - * H5S_select_shape_same() views as being of the same shape. + * H5Sselect_shape_same() views as being of the same shape. * * Start by writing small_rank - 1 D slices from the in memory large data * set to the on disk small dataset. After each write, read the slice of * the small dataset back from disk, and verify that it contains the - * expected data. Verify that H5S_select_shape_same() returns true on + * expected data. Verify that H5Sselect_shape_same() returns true on * the memory and file selections. */ @@ -3795,14 +3724,13 @@ ckrbrd_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) ); - /* verify that H5S_select_shape_same() reports the in + /* verify that H5Sselect_shape_same() reports the in * memory checkerboard selection of the slice through the * large dataset and the checkerboard selection of the process * slice of the small data set as having the same shape. */ - check = H5S__select_shape_same_test(tv_ptr->file_small_ds_sid_1, - tv_ptr->mem_large_ds_sid); - VRFY((check == TRUE), "H5S__select_shape_same_test passed."); + check = H5Sselect_shape_same(tv_ptr->file_small_ds_sid_1, tv_ptr->mem_large_ds_sid); + VRFY((check == TRUE), "H5Sselect_shape_same passed."); /* write the checker board selection of the slice from the in @@ -3922,7 +3850,7 @@ ckrbrd_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * board hyperslab selections of different rank in the parallel. * * Verify that we can write from memory to file using - * selections of different rank that H5S_select_shape_same() + * selections of different rank that H5Sselect_shape_same() * views as being of the same shape. * * Do this by writing checker board selections of the contents @@ -3931,17 +3859,13 @@ ckrbrd_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * read the process's slice of the large data set back into * memory, and verify that it contains the expected data. * - * Verify that H5S_select_shape_same() returns true on the + * Verify that H5Sselect_shape_same() returns true on the * memory and file selections. * * Return: void * * Programmer: JRM -- 8/15/11 * - * Modifications: - * - * None - * *------------------------------------------------------------------------- */ @@ -3974,7 +3898,7 @@ ckrbrd_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * small data set to slices of the on disk large data set. After * each write, read the process's slice of the large data set back * into memory, and verify that it contains the expected data. - * Verify that H5S_select_shape_same() returns true on the memory + * Verify that H5Sselect_shape_same() returns true on the memory * and file selections. */ @@ -4150,14 +4074,13 @@ ckrbrd_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) ); - /* verify that H5S_select_shape_same() reports the in + /* verify that H5Sselect_shape_same() reports the in * memory small data set slice selection and the * on disk slice through the large data set selection * as having the same shape. */ - check = H5S__select_shape_same_test(tv_ptr->mem_small_ds_sid, - tv_ptr->file_large_ds_sid_1); - VRFY((check == TRUE), "H5S__select_shape_same_test passed"); + check = H5Sselect_shape_same(tv_ptr->mem_small_ds_sid, tv_ptr->file_large_ds_sid_1); + VRFY((check == TRUE), "H5Sselect_shape_same passed"); /* write the small data set slice from memory to the @@ -4287,14 +4210,6 @@ ckrbrd_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * * Programmer: JRM -- 10/10/09 * - * Modifications: - * - * JRM -- 9/16/10 - * Added the express_test parameter. Use it to control - * whether we set an alignment, and whether we allocate - * chunks such that no two processes will normally touch - * the same chunk. - * *------------------------------------------------------------------------- */ @@ -4409,12 +4324,12 @@ ckrbrd_hs_dr_pio_test__run_test(const int test_num, /* first, verify that we can read from disk correctly using selections - * of different rank that H5S_select_shape_same() views as being of the + * of different rank that H5Sselect_shape_same() views as being of the * same shape. * * Start by reading a (small_rank - 1)-D slice from this processes slice * of the on disk large data set, and verifying that the data read is - * correct. Verify that H5S_select_shape_same() returns true on the + * correct. Verify that H5Sselect_shape_same() returns true on the * memory and file selections. * * The first step is to set up the needed checker board selection in the @@ -4434,12 +4349,12 @@ ckrbrd_hs_dr_pio_test__run_test(const int test_num, /* now we go in the opposite direction, verifying that we can write * from memory to file using selections of different rank that - * H5S_select_shape_same() views as being of the same shape. + * H5Sselect_shape_same() views as being of the same shape. * * Start by writing small_rank - 1 D slices from the in memory large data * set to the on disk small dataset. After each write, read the slice of * the small dataset back from disk, and verify that it contains the - * expected data. Verify that H5S_select_shape_same() returns true on + * expected data. Verify that H5Sselect_shape_same() returns true on * the memory and file selections. */ @@ -4450,7 +4365,7 @@ ckrbrd_hs_dr_pio_test__run_test(const int test_num, * small data set to slices of the on disk large data set. After * each write, read the process's slice of the large data set back * into memory, and verify that it contains the expected data. - * Verify that H5S_select_shape_same() returns true on the memory + * Verify that H5Sselect_shape_same() returns true on the memory * and file selections. */ @@ -4494,20 +4409,6 @@ ckrbrd_hs_dr_pio_test__run_test(const int test_num, * * Programmer: JRM -- 9/18/09 * - * Modifications: - * - * Modified function to take a sample of the run times - * of the different tests, and skip some of them if - * run times are too long. - * - * We need to do this because Lustre runns very slowly - * if two or more processes are banging on the same - * block of memory. - * JRM -- 9/10/10 - * Break this one big test into 4 smaller tests according - * to {independent,collective}x{contigous,chunked} datasets. - * AKC -- 2010/01/17 - * *------------------------------------------------------------------------- */ diff --git a/testpar/t_span_tree.c b/testpar/t_span_tree.c index cc79af2..352a089 100644 --- a/testpar/t_span_tree.c +++ b/testpar/t_span_tree.c @@ -60,8 +60,6 @@ static void coll_read_test(int chunk_factor); * Programmer: Unknown * Dec 2nd, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ void @@ -87,8 +85,6 @@ coll_irregular_cont_write(void) * Programmer: Unknown * Dec 2nd, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ void @@ -113,8 +109,6 @@ coll_irregular_cont_read(void) * Programmer: Unknown * Dec 2nd, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ void @@ -140,8 +134,6 @@ coll_irregular_simple_chunk_write(void) * Programmer: Unknown * Dec 2nd, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ void @@ -165,8 +157,6 @@ coll_irregular_simple_chunk_read(void) * Programmer: Unknown * Dec 2nd, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ void @@ -192,8 +182,6 @@ coll_irregular_complex_chunk_write(void) * Programmer: Unknown * Dec 2nd, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ void @@ -219,8 +207,6 @@ coll_irregular_complex_chunk_read(void) * Programmer: Unknown * Dec 2nd, 2004 * - * Modifications: Oct 18th, 2005 - * *------------------------------------------------------------------------- */ void coll_write_test(int chunk_factor) @@ -694,9 +680,6 @@ void coll_write_test(int chunk_factor) * Programmer: Unknown * Dec 2nd, 2004 * - * Modifications: Oct 18th, 2005 - * Note: This test must be used with the correpsonding - coll_write_test. *------------------------------------------------------------------------- */ static void @@ -948,18 +931,18 @@ coll_read_test(int chunk_factor) ** ** lower_dim_size_comp_test__select_checker_board(): ** -** Given a data space of tgt_rank, and dimensions: +** Given a dataspace of tgt_rank, and dimensions: ** ** (mpi_size + 1), edge_size, ... , edge_size ** ** edge_size, and a checker_edge_size, select a checker ** board selection of a sel_rank (sel_rank < tgt_rank) -** dimensional slice through the data space parallel to the +** dimensional slice through the dataspace parallel to the ** sel_rank fastest changing indicies, with origin (in the ** higher indicies) as indicated by the start array. ** ** Note that this function, is hard coded to presume a -** maximum data space rank of 5. +** maximum dataspace rank of 5. ** ** While this maximum is declared as a constant, increasing ** it will require extensive coding in addition to changing @@ -1304,7 +1287,7 @@ lower_dim_size_comp_test__select_checker_board( } #endif /* LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG */ - /* Clip the selection back to the data space proper. */ + /* Clip the selection back to the dataspace proper. */ for ( i = 0; i < test_max_rank; i++ ) { @@ -1564,15 +1547,13 @@ lower_dim_size_comp_test__verify_data(uint32_t * buf_ptr, * Function: lower_dim_size_comp_test__run_test() * * Purpose: Verify that a bug in the computation of the size of the - * lower dimensions of a data space in H5S_obtain_datatype() + * lower dimensions of a dataspace in H5S_obtain_datatype() * has been corrected. * * Return: void * * Programmer: JRM -- 11/11/09 * - * Modifications: - * *------------------------------------------------------------------------- */ @@ -1763,7 +1744,7 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, } #endif - /* create data spaces */ + /* create dataspaces */ full_mem_small_ds_sid = H5Screate_simple(5, small_dims, NULL); VRFY((full_mem_small_ds_sid != 0), @@ -2177,7 +2158,7 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */ } - /* try clipping the selection back to the large data space proper */ + /* try clipping the selection back to the large dataspace proper */ start[0] = start[1] = start[2] = start[3] = start[4] = (hsize_t)0; stride[0] = (hsize_t)(2 * (mpi_size + 1)); @@ -2331,12 +2312,11 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, large_sel_start); - /* verify that H5S_select_shape_same() reports the two + /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. */ - check = H5S__select_shape_same_test(mem_large_ds_sid, - file_small_ds_sid); - VRFY((check == TRUE), "H5S__select_shape_same_test passed (1)"); + check = H5Sselect_shape_same(mem_large_ds_sid, file_small_ds_sid); + VRFY((check == TRUE), "H5Sselect_shape_same passed (1)"); ret = H5Dread(small_dataset, @@ -2452,12 +2432,11 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, large_sel_start); - /* verify that H5S_select_shape_same() reports the two + /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. */ - check = H5S__select_shape_same_test(mem_small_ds_sid, - file_large_ds_sid); - VRFY((check == TRUE), "H5S__select_shape_same_test passed (2)"); + check = H5Sselect_shape_same(mem_small_ds_sid, file_large_ds_sid); + VRFY((check == TRUE), "H5Sselect_shape_same passed (2)"); ret = H5Dread(large_dataset, @@ -2613,8 +2592,6 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, * * Programmer: JRM -- 11/11/09 * - * Modifications: - * *------------------------------------------------------------------------- */ @@ -2672,8 +2649,6 @@ lower_dim_size_comp_test(void) * * Programmer: JRM -- 12/16/09 * - * Modifications: - * *------------------------------------------------------------------------- */ @@ -2737,7 +2712,7 @@ link_chunk_collective_io_test(void) /* setup dims */ dims[0] = ((hsize_t)mpi_size) * ((hsize_t)(LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE)); - /* setup mem and file data spaces */ + /* setup mem and file dataspaces */ write_mem_ds_sid = H5Screate_simple(1, chunk_dims, NULL); VRFY((write_mem_ds_sid != 0), "H5Screate_simple() write_mem_ds_sid succeeded"); -- cgit v0.12 From 41537eeb3c3012d2aefda6c115818b6921ac07ff Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 30 Jul 2019 16:08:22 -0500 Subject: Updated H5TRACE macro. --- src/H5Sselect.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 8b84e2c..af93feb 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -2084,6 +2084,7 @@ H5Sselect_intersect_block(hid_t space_id, const hsize_t *start, const hsize_t *e herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) + H5TRACE3("t", "i*h*h", space_id, start, end); /* Check arguments */ if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) -- cgit v0.12 From ab6679315c5027576c3a80d0ea3b67fd2fa58ff0 Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Tue, 30 Jul 2019 16:37:57 -0500 Subject: Update COPYING file. Remove hdfs from list of vfds for check-vfd testing as it is read-only. --- COPYING | 32 ++++++++++++++++---------------- test/Makefile.am | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/COPYING b/COPYING index 560e8c4..659bf1c 100644 --- a/COPYING +++ b/COPYING @@ -3,10 +3,10 @@ HDF5 (Hierarchical Data Format 5) Software Library and Utilities ----------------------------------------------------------------------------- HDF5 (Hierarchical Data Format 5) Software Library and Utilities -Copyright (c) 2006-2018, The HDF Group. +Copyright 2006 by The HDF Group. NCSA HDF5 (Hierarchical Data Format 5) Software Library and Utilities -Copyright (c) 1998-2006, The Board of Trustees of the University of Illinois. +Copyright 1998-2006 by The Board of Trustees of the University of Illinois. All rights reserved. @@ -80,20 +80,20 @@ and/or accompanying materials: for the operation of UC LLNL. DISCLAIMER: - This work was prepared as an account of work sponsored by an agency of - the United States Government. Neither the United States Government nor - the University of California nor any of their employees, makes any - warranty, express or implied, or assumes any liability or responsibility - for the accuracy, completeness, or usefulness of any information, - apparatus, product, or process disclosed, or represents that its use - would not infringe privately- owned rights. Reference herein to any - specific commercial products, process, or service by trade name, - trademark, manufacturer, or otherwise, does not necessarily constitute - or imply its endorsement, recommendation, or favoring by the United - States Government or the University of California. The views and - opinions of authors expressed herein do not necessarily state or reflect - those of the United States Government or the University of California, - and shall not be used for advertising or product endorsement purposes. + THIS WORK WAS PREPARED AS AN ACCOUNT OF WORK SPONSORED BY AN AGENCY OF + THE UNITED STATES GOVERNMENT. NEITHER THE UNITED STATES GOVERNMENT NOR + THE UNIVERSITY OF CALIFORNIA NOR ANY OF THEIR EMPLOYEES, MAKES ANY + WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY OR RESPONSIBILITY + FOR THE ACCURACY, COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, + APPARATUS, PRODUCT, OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE + WOULD NOT INFRINGE PRIVATELY- OWNED RIGHTS. REFERENCE HEREIN TO ANY + SPECIFIC COMMERCIAL PRODUCTS, PROCESS, OR SERVICE BY TRADE NAME, + TRADEMARK, MANUFACTURER, OR OTHERWISE, DOES NOT NECESSARILY CONSTITUTE + OR IMPLY ITS ENDORSEMENT, RECOMMENDATION, OR FAVORING BY THE UNITED + STATES GOVERNMENT OR THE UNIVERSITY OF CALIFORNIA. THE VIEWS AND + OPINIONS OF AUTHORS EXPRESSED HEREIN DO NOT NECESSARILY STATE OR REFLECT + THOSE OF THE UNITED STATES GOVERNMENT OR THE UNIVERSITY OF CALIFORNIA, + AND SHALL NOT BE USED FOR ADVERTISING OR PRODUCT ENDORSEMENT PURPOSES. ----------------------------------------------------------------------------- diff --git a/test/Makefile.am b/test/Makefile.am index dbee9c2..aa6afee 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -145,7 +145,7 @@ ttsafe_SOURCES=ttsafe.c ttsafe_dcreate.c ttsafe_error.c ttsafe_cancel.c \ ttsafe_acreate.c cache_image_SOURCES=cache_image.c genall5.c -VFD_LIST = hdfs sec2 stdio core core_paged split multi family +VFD_LIST = sec2 stdio core core_paged split multi family if DIRECT_VFD_CONDITIONAL VFD_LIST += direct endif -- cgit v0.12 From 905d40aa6f6eb603c5507e7967130760e3a2e43c Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 31 Jul 2019 09:34:01 -0500 Subject: Fix return type for H5Sselect_intersect_block(). --- src/H5Sselect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5Sselect.c b/src/H5Sselect.c index af93feb..e632b11 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -2081,7 +2081,7 @@ H5Sselect_intersect_block(hid_t space_id, const hsize_t *start, const hsize_t *e { H5S_t *space; /* Dataspace to query */ unsigned u; /* Local index value */ - herr_t ret_value = SUCCEED; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("t", "i*h*h", space_id, start, end); -- cgit v0.12 From 0ee5526c2c95dd77ee61b917b16adfcacbd3a540 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 31 Jul 2019 09:08:16 -0700 Subject: Fixed typo in optimization. --- config/gnu-fflags | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/gnu-fflags b/config/gnu-fflags index 90a3656..d6d0b39 100644 --- a/config/gnu-fflags +++ b/config/gnu-fflags @@ -111,11 +111,11 @@ if test "X-gfortran" = "X-$f9x_vendor"; then ################ if test $f9x_vers_major -le 4; then - HIGH_OPT_CFLAGS="-O3" - DEBUG_OPT_CFLAGS= + HIGH_OPT_FCFLAGS="-O3" + DEBUG_OPT_FCFLAGS= else - HIGH_OPT_CFLAGS="-O3" - DEBUG_OPT_CFLAGS="-Og" + HIGH_OPT_FCFLAGS="-O3" + DEBUG_OPT_FCFLAGS="-Og" fi NO_OPT_FCFLAGS="-O0" -- cgit v0.12 From 519dfe549a4b8ffb4bd5d4c72a3f5fb61b80143f Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 31 Jul 2019 15:06:33 -0500 Subject: Mostly whitespace cleanup and consistent test format --- test/links.c | 3832 ++++++++++++++++++++++------------------------------------ 1 file changed, 1413 insertions(+), 2419 deletions(-) diff --git a/test/links.c b/test/links.c index b7eb6af..f8be2b5 100644 --- a/test/links.c +++ b/test/links.c @@ -12,9 +12,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke - * Friday, April 10, 1998 - * * Purpose: Tests hard, soft (symbolic) & external links. */ @@ -34,10 +31,10 @@ #include "h5test.h" #include "H5srcdir.h" -#include "H5FDpkg.h" /* File drivers */ -#include "H5Gpkg.h" /* Groups */ +#include "H5FDpkg.h" /* File drivers */ +#include "H5Gpkg.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ +#include "H5Lprivate.h" /* Links */ /* File for external link test. Created with gen_udlinks.c */ #define LINKED_FILE "be_extlink2.h5" @@ -62,55 +59,55 @@ const char *FILENAME[] = { "links6", /* 9 */ "links7", /* 10 */ "links8", /* 11 */ - "extlinks0", /* 12: main files */ - TMPDIR "extlinks0", /* 13: */ - "extlinks1", /* 14: target files */ - TMPDIR "extlinks1", /* 15: */ - "extlinks2", /* 16: */ - TMPDIR "extlinks2", /* 17: */ - "extlinks3", /* 18: */ - TMPDIR "extlinks3", /* 19: */ - "extlinks4", /* 20: */ - TMPDIR "extlinks4", /* 21: */ - "extlinks5", /* 22: */ - TMPDIR "extlinks6", /* 23: */ - "extlinks7", /* 24: */ - TMPDIR "extlinks7", /* 25: */ - TMPDIR "extlinks8", /* 26: */ - "extlinks9", /* 27: */ - TMPDIR "extlinks9", /* 28: */ - "extlinks10", /* 29: */ /* TESTS for windows */ - TMPDIR "extlinks10",/* 30: */ - TMPDIR "extlinks11",/* 31: */ - TMPDIR "extlinks12",/* 32: */ - "extlinks13", /* 33: */ - TMPDIR "extlinks13",/* 34: */ - TMPDIR "extlinks14",/* 35: */ - TMPDIR "extlinks15",/* 36: */ - "extlinks16A", /* 37: */ /* TESTS for H5P_set_elink_fapl */ - "extlinks16B", /* 38: */ - "extlinks17", /* 39: */ - "extlinks18A", /* 40: */ - "extlinks18B", /* 41: */ - "extlinks19A", /* 42: */ - "extlinks19B", /* 43: */ - "extlinks20", /* 44: */ - "extlinks21A", /* 45: Files for symlink() tests*/ - TMPDIR2 "extlinks21B",/* 46: */ - TMPDIR2 "extlinks21C",/* 47: */ - "extlinks21C", /* 48: (same as #47, only without the TMPDIR2 prefix) */ - TMPDIR "extlinks21D",/* 49: */ - TMPDIR "extlinks21E",/* 50: */ - "extlinks21E", /* 51: (same as #50, only without the TMPDIR prefix) */ + "extlinks0", /* 12: main files */ + TMPDIR "extlinks0", /* 13: */ + "extlinks1", /* 14: target files */ + TMPDIR "extlinks1", /* 15: */ + "extlinks2", /* 16: */ + TMPDIR "extlinks2", /* 17: */ + "extlinks3", /* 18: */ + TMPDIR "extlinks3", /* 19: */ + "extlinks4", /* 20: */ + TMPDIR "extlinks4", /* 21: */ + "extlinks5", /* 22: */ + TMPDIR "extlinks6", /* 23: */ + "extlinks7", /* 24: */ + TMPDIR "extlinks7", /* 25: */ + TMPDIR "extlinks8", /* 26: */ + "extlinks9", /* 27: */ + TMPDIR "extlinks9", /* 28: */ + "extlinks10", /* 29: */ /* TESTS for windows */ + TMPDIR "extlinks10", /* 30: */ + TMPDIR "extlinks11", /* 31: */ + TMPDIR "extlinks12", /* 32: */ + "extlinks13", /* 33: */ + TMPDIR "extlinks13", /* 34: */ + TMPDIR "extlinks14", /* 35: */ + TMPDIR "extlinks15", /* 36: */ + "extlinks16A", /* 37: */ /* TESTS for H5P_set_elink_fapl */ + "extlinks16B", /* 38: */ + "extlinks17", /* 39: */ + "extlinks18A", /* 40: */ + "extlinks18B", /* 41: */ + "extlinks19A", /* 42: */ + "extlinks19B", /* 43: */ + "extlinks20", /* 44: */ + "extlinks21A", /* 45: Files for symlink() tests*/ + TMPDIR2 "extlinks21B", /* 46: */ + TMPDIR2 "extlinks21C", /* 47: */ + "extlinks21C", /* 48: (same as #47, only without the TMPDIR2 prefix) */ + TMPDIR "extlinks21D", /* 49: */ + TMPDIR "extlinks21E", /* 50: */ + "extlinks21E", /* 51: (same as #50, only without the TMPDIR prefix) */ NULL }; -#define FAMILY_SIZE 1024 +#define FAMILY_SIZE 1024 #define CORE_INCREMENT 1024 -#define NUM40 40 +#define NUM40 40 /* do not do check_all_closed() for "ext*" files and "tmp/ext*" */ -#define EXTSTOP 12 +#define EXTSTOP 12 #define LINK_BUF_SIZE 1024 #define NAME_BUF_SIZE 1024 @@ -326,43 +323,32 @@ static hid_t dcpl_g; /* for [un]minimized dataset object headers */ * path name of Unix and Windows. * * Return: void - * - * Programmer: Raymond Lu - * 14 Jan. 2009 *------------------------------------------------------------------------- */ static void fix_ext_filename(char *path_name, char *cwd, const char *file_name) { HDstrcpy(path_name, cwd); - HDstrcat(path_name, "/"); HDstrcat(path_name, file_name); } /*------------------------------------------------------------------------- - * Function: mklinks + * Function: mklinks * * Purpose: Build a file with assorted links. * - * Return: Success: 0 - * - * Failure: -1 - * - * Programmer: Robb Matzke - * Friday, August 14, 1998 - * - * Modifications: - * + * Return: Success: 0 + * Failure: -1 *------------------------------------------------------------------------- */ static int mklinks(hid_t fapl, hbool_t new_format) { hid_t file, scalar, grp, d1; - hsize_t size[1] = {1}; - char filename[NAME_BUF_SIZE]; + hsize_t size[1] = {1}; + char filename[NAME_BUF_SIZE]; if(new_format) TESTING("link creation (w/new group format)") @@ -399,10 +385,10 @@ mklinks(hid_t fapl, hbool_t new_format) if(H5Fclose(file) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: - return -1; + return FAIL; } @@ -412,14 +398,7 @@ mklinks(hid_t fapl, hbool_t new_format) * Purpose: Build a file with assorted links for different locations. * * Return: Success: 0 - * * Failure: -1 - * - * Programmer: Raymond Lu - * Friday, April 19, 2002 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -429,8 +408,8 @@ new_links(hid_t fapl, hbool_t new_format) hid_t grp1_a=(-1), grp1_b=(-1), grp2_a=(-1), grp2_b=(-1); hid_t scalar=(-1); hid_t dset1=(-1), dset2=(-1); - char filename[NAME_BUF_SIZE]; - hsize_t size[1] = {1}; + char filename[NAME_BUF_SIZE]; + hsize_t size[1] = {1}; if(new_format) TESTING("H5Lcreate functions (w/new group format)") @@ -488,7 +467,7 @@ new_links(hid_t fapl, hbool_t new_format) if(H5Fclose(file_b) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -502,36 +481,29 @@ new_links(hid_t fapl, hbool_t new_format) H5Fclose(file_a); H5Fclose(file_b); } H5E_END_TRY; - return -1; + return FAIL; } /*------------------------------------------------------------------------- - * Function: cklinks + * Function: cklinks * * Purpose: Open the file created in the first step and check that the - * links look correct. - * - * Return: Success: 0 - * - * Failure: -1 - * - * Programmer: Robb Matzke - * Friday, August 14, 1998 - * - * Modifications: + * links look correct. * + * Return: Success: 0 + * Failure: -1 *------------------------------------------------------------------------- */ static int cklinks(hid_t fapl, hbool_t new_format) { hid_t file; - H5O_info_t oinfo1, oinfo2; - H5L_info_t linfo2; - char linkval[LINK_BUF_SIZE]; - char filename[NAME_BUF_SIZE]; - herr_t status; + H5O_info_t oinfo1, oinfo2; + H5L_info_t linfo2; + char linkval[LINK_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; + herr_t status; if(new_format) TESTING("link queries (w/new group format)") @@ -546,15 +518,15 @@ cklinks(hid_t fapl, hbool_t new_format) if(H5Oget_info_by_name2(file, "d1", &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5Oget_info_by_name2(file, "grp1/hard", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5O_TYPE_DATASET != oinfo2.type) { - H5_FAILED(); - HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); - TEST_ERROR + H5_FAILED(); + HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); + TEST_ERROR } /* end if */ if(H5F_addr_ne(oinfo1.addr, oinfo2.addr)) { - H5_FAILED(); - HDputs(" Hard link test failed. Link seems not to point to the "); - HDputs(" expected file location."); - TEST_ERROR + H5_FAILED(); + HDputs(" Hard link test failed. Link seems not to point to the "); + HDputs(" expected file location."); + TEST_ERROR } /* end if */ if(H5Lexists(file, "/", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR if(H5Lexists(file, "d1", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR @@ -573,83 +545,83 @@ cklinks(hid_t fapl, hbool_t new_format) status = H5Lexists(file, "/no_grp1/hard", H5P_DEFAULT); } H5E_END_TRY; if(status >= 0) { - H5_FAILED(); - HDputs(" H5Lexists() should have failed for a path with missing components."); - TEST_ERROR + H5_FAILED(); + HDputs(" H5Lexists() should have failed for a path with missing components."); + TEST_ERROR } /* end if */ /* Symbolic link */ if(H5Oget_info_by_name2(file, "grp1/soft", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5O_TYPE_DATASET != oinfo2.type) { - H5_FAILED(); - HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); - TEST_ERROR + H5_FAILED(); + HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); + TEST_ERROR } /* end if */ if(H5F_addr_ne(oinfo1.addr, oinfo2.addr)) { - H5_FAILED(); - HDputs(" Soft link test failed. Link seems not to point to the "); - HDputs(" expected file location."); - TEST_ERROR + H5_FAILED(); + HDputs(" Soft link test failed. Link seems not to point to the "); + HDputs(" expected file location."); + TEST_ERROR } /* end if */ if(H5Lget_val(file, "grp1/soft", linkval, sizeof linkval, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(HDstrcmp(linkval, "/d1")) { - H5_FAILED(); - HDputs(" Soft link test failed. Wrong link value"); - TEST_ERROR + H5_FAILED(); + HDputs(" Soft link test failed. Wrong link value"); + TEST_ERROR } /* end if */ if(H5Lexists(file, "grp1/soft", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR /* Dangling link */ H5E_BEGIN_TRY { - status = H5Oget_info_by_name2(file, "grp1/dangle", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT); + status = H5Oget_info_by_name2(file, "grp1/dangle", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT); } H5E_END_TRY; if(status >= 0) { - H5_FAILED(); - HDputs(" H5Oget_info_by_name() should have failed for a dangling link."); - TEST_ERROR + H5_FAILED(); + HDputs(" H5Oget_info_by_name() should have failed for a dangling link."); + TEST_ERROR } /* end if */ if(H5Lget_info(file, "grp1/dangle", &linfo2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5L_TYPE_SOFT != linfo2.type) { - H5_FAILED(); - HDprintf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); - TEST_ERROR + H5_FAILED(); + HDprintf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); + TEST_ERROR } /* end if */ if(H5Lget_val(file, "grp1/dangle", linkval, sizeof linkval, H5P_DEFAULT) < 0) { - H5_FAILED(); - HDprintf(" %d: Can't retrieve link value\n", __LINE__); - TEST_ERROR + H5_FAILED(); + HDprintf(" %d: Can't retrieve link value\n", __LINE__); + TEST_ERROR } /* end if */ if(HDstrcmp(linkval, "foobar")) { - H5_FAILED(); - HDputs(" Dangling link test failed. Wrong link value"); - TEST_ERROR + H5_FAILED(); + HDputs(" Dangling link test failed. Wrong link value"); + TEST_ERROR } /* end if */ if(H5Lexists(file, "grp1/dangle", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR /* Recursive link */ H5E_BEGIN_TRY { - status = H5Oget_info_by_name2(file, "grp1/recursive", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT); + status = H5Oget_info_by_name2(file, "grp1/recursive", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT); } H5E_END_TRY; if(status >= 0) { - H5_FAILED(); - HDputs(" H5Oget_info_by_name() should have failed for a recursive link."); - TEST_ERROR + H5_FAILED(); + HDputs(" H5Oget_info_by_name() should have failed for a recursive link."); + TEST_ERROR } /* end if */ if(H5Lget_info(file, "grp1/recursive", &linfo2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5L_TYPE_SOFT != linfo2.type) { - H5_FAILED(); - HDprintf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); - TEST_ERROR + H5_FAILED(); + HDprintf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); + TEST_ERROR } /* end if */ if(H5Lget_val(file, "grp1/recursive", linkval, sizeof linkval, H5P_DEFAULT) < 0) { - H5_FAILED(); - HDprintf(" %d: Can't retrieve link value\n", __LINE__); - TEST_ERROR + H5_FAILED(); + HDprintf(" %d: Can't retrieve link value\n", __LINE__); + TEST_ERROR } /* end if */ if(HDstrcmp(linkval, "/grp1/recursive")) { - H5_FAILED(); - HDputs(" Recursive link test failed. Wrong link value"); - TEST_ERROR + H5_FAILED(); + HDputs(" Recursive link test failed. Wrong link value"); + TEST_ERROR } /* end if */ /* Non-existent link */ @@ -659,10 +631,10 @@ cklinks(hid_t fapl, hbool_t new_format) if(H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: - return -1; + return FAIL; } @@ -673,20 +645,15 @@ error: * links look correct. * * Return: Success: 0 - * * Failure: -1 - * - * Programmer: Raymond Lu - * Thursday, April 25, 2002 - * *------------------------------------------------------------------------- */ static int ck_new_links(hid_t fapl, hbool_t new_format) { hid_t file; - H5O_info_t oi_dset, oi_hard1, oi_hard2; - char filename[NAME_BUF_SIZE]; + H5O_info_t oi_dset, oi_hard1, oi_hard2; + char filename[NAME_BUF_SIZE]; if(new_format) TESTING("new link queries (w/new group format)") @@ -698,34 +665,31 @@ ck_new_links(hid_t fapl, hbool_t new_format) if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR /* Get hard link info */ - if(H5Oget_info_by_name2(file, "/grp1/dataset2", &oi_dset, H5O_INFO_BASIC, H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Oget_info_by_name2(file, "/grp1/hard1", &oi_hard1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Oget_info_by_name2(file, "/grp2/hard2", &oi_hard2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Oget_info_by_name2(file, "/grp1/dataset2", &oi_dset, H5O_INFO_BASIC, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Oget_info_by_name2(file, "/grp1/hard1", &oi_hard1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Oget_info_by_name2(file, "/grp2/hard2", &oi_hard2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) TEST_ERROR /* Check hard links */ if(H5O_TYPE_DATASET != oi_hard1.type || H5O_TYPE_DATASET != oi_hard2.type) { - H5_FAILED(); - HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); - TEST_ERROR + H5_FAILED(); + HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); + TEST_ERROR } if(H5F_addr_ne(oi_dset.addr, oi_hard1.addr) || H5F_addr_ne(oi_dset.addr, oi_hard2.addr)) { - H5_FAILED(); - HDputs(" Hard link test failed. Link seems not to point to the "); - HDputs(" expected file location."); - TEST_ERROR + H5_FAILED(); + HDputs(" Hard link test failed. Link seems not to point to the "); + HDputs(" expected file location."); + TEST_ERROR } /* Cleanup */ if(H5Fclose(file) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: - return -1; + return FAIL; } @@ -735,25 +699,18 @@ error: * Purpose: Build a file with long names * * Return: Success: 0 - * * Failure: -1 - * - * Programmer: Quincey Koziol - * Saturday, April 16, 2005 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int long_links(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ - hid_t gid2 = (-1); /* Datatype ID */ - char *objname = NULL; /* Name of object [Long] */ - size_t u; /* Local index variable */ - char filename[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + hid_t gid2 = -1; /* Datatype ID */ + char *objname = NULL; /* Name of object [Long] */ + size_t u; /* Local index variable */ + char filename[NAME_BUF_SIZE]; if(new_format) TESTING("long names for objects & links (w/new group format)") @@ -792,7 +749,7 @@ long_links(hid_t fapl, hbool_t new_format) HDfree(objname); PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -801,7 +758,7 @@ long_links(hid_t fapl, hbool_t new_format) H5Fclose (fid); } H5E_END_TRY; HDfree(objname); - return -1; + return FAIL; } @@ -811,23 +768,16 @@ long_links(hid_t fapl, hbool_t new_format) * Purpose: Build a file with too many symbolic links * * Return: Success: 0 - * * Failure: -1 - * - * Programmer: Quincey Koziol - * Tuesday, August 9, 2005 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int toomany(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; if(new_format) TESTING("too many links (w/new group format)") @@ -917,9 +867,9 @@ toomany(hid_t fapl, hbool_t new_format) gid = H5Gopen2(fid, "soft17", H5P_DEFAULT); } H5E_END_TRY; if(gid >= 0) { - H5_FAILED(); - HDputs(" Should have failed for sequence of too many nested links."); - TEST_ERROR + H5_FAILED(); + HDputs(" Should have failed for sequence of too many nested links."); + TEST_ERROR } /* end if */ /* Open object through lesser soft link */ @@ -940,7 +890,7 @@ toomany(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -948,7 +898,7 @@ toomany(hid_t fapl, hbool_t new_format) H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end toomany() */ @@ -959,26 +909,20 @@ toomany(hid_t fapl, hbool_t new_format) * * Return: Success: 0 * Failure: number of errors - * - * Programmer: James Laird - * Monday, January 30, 2006 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int test_lcpl(hid_t fapl, hbool_t new_format) { - hid_t file_id=-1; - hid_t group_id=-1; - hid_t space_id=-1; - hid_t dset_id=-1; - hid_t type_id=-1; - hid_t lcpl_id=-1; - H5L_info_t linfo; - char filename[1024]; - hsize_t dims[2]; + hid_t file_id = -1; + hid_t group_id = -1; + hid_t space_id = -1; + hid_t dset_id = -1; + hid_t type_id = -1; + hid_t lcpl_id = -1; + H5L_info_t linfo; + char filename[1024]; + hsize_t dims[2]; if(new_format) TESTING("link creation property lists (w/new group format)") @@ -1097,7 +1041,7 @@ test_lcpl(hid_t fapl, hbool_t new_format) if(H5Fclose(file_id) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -1118,22 +1062,15 @@ error: * Purpose: Tests H5Lmove() * * Return: Success: 0 - * * Failure: number of errors - * - * Programmer: James Laird - * Friday, March 30, 2006 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int test_move(hid_t fapl, hbool_t new_format) { - hid_t file_a, file_b=(-1); - hid_t grp_1=(-1), grp_2=(-1), grp_move=(-1), moved_grp=(-1); - char filename[1024]; + hid_t file_a = -1, file_b = -1; + hid_t grp_1 = -1, grp_2 = -1, grp_move = -1, moved_grp = -1; + char filename[1024]; if(new_format) TESTING("H5Lmove (w/new group format)") @@ -1142,11 +1079,9 @@ test_move(hid_t fapl, hbool_t new_format) /* Create two new files */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if ((file_a=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR + if ((file_a=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if ((file_b=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR + if ((file_b=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create groups in first file */ if((grp_1 = H5Gcreate2(file_a, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -1154,99 +1089,75 @@ test_move(hid_t fapl, hbool_t new_format) if((grp_move = H5Gcreate2(grp_1, "group_move", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create hard, soft and external links. */ - if(H5Lcreate_hard(grp_1, "group_move", H5L_SAME_LOC, "hard", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lcreate_soft("/group1/group_move", grp_2, "soft", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lcreate_external("filename", "pathname", grp_2, "ext", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcreate_hard(grp_1, "group_move", H5L_SAME_LOC, "hard", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_soft("/group1/group_move", grp_2, "soft", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_external("filename", "pathname", grp_2, "ext", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Move a group within the file. Both of source and destination use * H5L_SAME_LOC. Should fail. */ H5E_BEGIN_TRY { - if(H5Lmove(H5L_SAME_LOC, "group_move", H5L_SAME_LOC, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) - !=FAIL) TEST_ERROR + if(H5Lmove(H5L_SAME_LOC, "group_move", H5L_SAME_LOC, "group_new_name", H5P_DEFAULT, H5P_DEFAULT)!=FAIL) TEST_ERROR } H5E_END_TRY; /* Move a group across files. Should fail. */ H5E_BEGIN_TRY { - if(H5Lmove(grp_1, "group_move", file_b, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) - !=FAIL) TEST_ERROR + if(H5Lmove(grp_1, "group_move", file_b, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) !=FAIL) TEST_ERROR } H5E_END_TRY; /* Move a soft link across files. Should succeed. */ - if(H5Lmove(grp_2, "soft", file_b, "soft_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lexists(file_b, "soft_new_name", H5P_DEFAULT) != TRUE) - TEST_ERROR + if(H5Lmove(grp_2, "soft", file_b, "soft_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lexists(file_b, "soft_new_name", H5P_DEFAULT) != TRUE) TEST_ERROR /* Move an external link across files. Should succeed. */ - if(H5Lmove(grp_2, "ext", file_b, "ext_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lexists(file_b, "ext_new_name", H5P_DEFAULT) != TRUE) - TEST_ERROR + if(H5Lmove(grp_2, "ext", file_b, "ext_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lexists(file_b, "ext_new_name", H5P_DEFAULT) != TRUE) TEST_ERROR /* Move a group across groups in the same file while renaming it. */ - if(H5Lmove(grp_1, "group_move", grp_2, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lmove(grp_1, "group_move", grp_2, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Open the group just moved to the new location. */ if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if( H5Gclose(moved_grp) < 0) - TEST_ERROR + if( H5Gclose(moved_grp) < 0) TEST_ERROR /* Verify that the group is no longer in the original location */ H5E_BEGIN_TRY { moved_grp = H5Gopen2(grp_1, "group_move", H5P_DEFAULT); } H5E_END_TRY; if(moved_grp >= 0) { - H5_FAILED(); - HDputs(" Group still in original location?"); - TEST_ERROR + H5_FAILED(); + HDputs(" Group still in original location?"); + TEST_ERROR } /* end if */ /* Use H5Lmove to rename a group without moving it. */ - if(H5Lmove(grp_2, "group_new_name", H5L_SAME_LOC, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lmove(grp_2, "group_new_name", H5L_SAME_LOC, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Open the group. */ - if((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) - TEST_ERROR + if((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Use H5Lmove to move a group without renaming it. */ - if(H5Lmove(grp_2, "group_newer_name", grp_1, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lmove(grp_2, "group_newer_name", grp_1, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Open the group . */ - if((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) - TEST_ERROR + if((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Move the group while giving long paths. */ - if(H5Lmove(file_a, "/group1/group_newer_name", grp_2, "/group2/group_newest_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lmove(file_a, "/group1/group_newer_name", grp_2, "/group2/group_newest_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Open the group just moved to the new location. */ - if((moved_grp = H5Gopen2(grp_2, "group_newest_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if((moved_grp = H5Gopen2(grp_2, "group_newest_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) - TEST_ERROR + if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Verify that the group is in no previous locations */ H5E_BEGIN_TRY { - if((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) >= 0) - FAIL_STACK_ERROR - if((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) >= 0) - FAIL_STACK_ERROR - if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) >= 0) - FAIL_STACK_ERROR - if((moved_grp = H5Gopen2(grp_1, "group_copy", H5P_DEFAULT)) >= 0) - FAIL_STACK_ERROR + if((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) >= 0) FAIL_STACK_ERROR + if((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) >= 0) FAIL_STACK_ERROR + if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) >= 0) FAIL_STACK_ERROR + if((moved_grp = H5Gopen2(grp_1, "group_copy", H5P_DEFAULT)) >= 0) FAIL_STACK_ERROR } H5E_END_TRY; H5Gclose(grp_1); @@ -1256,17 +1167,17 @@ test_move(hid_t fapl, hbool_t new_format) H5Fclose(file_b); PASSED(); - return 0; + return SUCCEED; - error: +error: H5_FAILED(); H5E_BEGIN_TRY { - H5Gclose(grp_1); - H5Gclose(grp_2); - H5Gclose(grp_move); + H5Gclose(grp_1); + H5Gclose(grp_2); + H5Gclose(grp_move); H5Gclose(moved_grp); - H5Fclose(file_a); - H5Fclose(file_b); + H5Fclose(file_a); + H5Fclose(file_b); } H5E_END_TRY; return 1; } @@ -1278,21 +1189,14 @@ test_move(hid_t fapl, hbool_t new_format) * Purpose: Tests H5Lcopy() * * Return: Success: 0 - * * Failure: number of errors - * - * Programmer: James Laird - * Friday, March 30, 2006 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int test_copy(hid_t fapl, hbool_t new_format) { - hid_t file_a, file_b=(-1); - hid_t grp_1=(-1), grp_2=(-1), grp_move=(-1), moved_grp=(-1); + hid_t file_a = -1, file_b = -1; + hid_t grp_1 = -1, grp_2 = -1, grp_move = -1, moved_grp = -1; char filename[1024]; if(new_format) @@ -1302,11 +1206,9 @@ test_copy(hid_t fapl, hbool_t new_format) /* Create two new files */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if ((file_a=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR + if ((file_a=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if ((file_b=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR + if ((file_b=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create groups in first file */ if((grp_1 = H5Gcreate2(file_a, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -1314,111 +1216,76 @@ test_copy(hid_t fapl, hbool_t new_format) if((grp_move = H5Gcreate2(grp_1, "group_copy", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create hard, soft and external links. */ - if(H5Lcreate_hard(grp_1, "group_copy", H5L_SAME_LOC, "hard", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lcreate_soft("/group1/group_copy", grp_2, "soft", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lcreate_external("filename", "pathname", grp_2, "ext", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcreate_hard(grp_1, "group_copy", H5L_SAME_LOC, "hard", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_soft("/group1/group_copy", grp_2, "soft", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_external("filename", "pathname", grp_2, "ext", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Copy a group within the file. Both of source and destination use * H5L_SAME_LOC. Should fail. */ H5E_BEGIN_TRY { - if(H5Lcopy(H5L_SAME_LOC, "group_copy", H5L_SAME_LOC, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) - !=FAIL) TEST_ERROR + if(H5Lcopy(H5L_SAME_LOC, "group_copy", H5L_SAME_LOC, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) !=FAIL) TEST_ERROR } H5E_END_TRY; /* Copy a group across files. Should fail. */ H5E_BEGIN_TRY { - if(H5Lcopy(grp_1, "group_copy", file_b, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) - !=FAIL) TEST_ERROR + if(H5Lcopy(grp_1, "group_copy", file_b, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) !=FAIL) TEST_ERROR } H5E_END_TRY; /* Copy a soft link across files. Should succeed. */ - if(H5Lcopy(grp_2, "soft", file_b, "soft_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lexists(file_b, "soft_new_name", H5P_DEFAULT) != TRUE) - TEST_ERROR + if(H5Lcopy(grp_2, "soft", file_b, "soft_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lexists(file_b, "soft_new_name", H5P_DEFAULT) != TRUE) TEST_ERROR /* Copy an external link across files. Should succeed. */ - if(H5Lcopy(grp_2, "ext", file_b, "ext_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lexists(file_b, "ext_new_name", H5P_DEFAULT) != TRUE) - TEST_ERROR + if(H5Lcopy(grp_2, "ext", file_b, "ext_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lexists(file_b, "ext_new_name", H5P_DEFAULT) != TRUE) TEST_ERROR /* Move a group across groups in the same file while renaming it. */ - if(H5Lcopy(grp_1, "group_copy", grp_2, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcopy(grp_1, "group_copy", grp_2, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Open the group just moved to the new location. */ - if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) - TEST_ERROR + if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Verify that the group is also in the original location */ - if((moved_grp = H5Gopen2(grp_1, "group_copy", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) - TEST_ERROR + if((moved_grp = H5Gopen2(grp_1, "group_copy", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Use H5Lcopy to create a group in the same location with a different name. */ - if(H5Lcopy(grp_2, "group_new_name", H5L_SAME_LOC, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcopy(grp_2, "group_new_name", H5L_SAME_LOC, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Open the group. */ - if((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) - TEST_ERROR + if((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Verify that the group is also in the original location */ - if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) - TEST_ERROR + if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Use H5Lcopy to copy to a different location with the same name. */ - if(H5Lcopy(grp_2, "group_newer_name", grp_1, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcopy(grp_2, "group_newer_name", grp_1, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Open the group . */ - if((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) - TEST_ERROR + if((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Verify that the group is still in the previous location */ - if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) - TEST_ERROR + if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Copy the group while giving long paths. */ - if(H5Lcopy(file_a, "/group1/group_newer_name", grp_2, "/group2/group_newest_name", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcopy(file_a, "/group1/group_newer_name", grp_2, "/group2/group_newest_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Open the group just moved to the new location. */ - if((moved_grp = H5Gopen2(grp_2, "group_newest_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) - TEST_ERROR + if((moved_grp = H5Gopen2(grp_2, "group_newest_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(moved_grp) < 0) TEST_ERROR /* Verify that the group is still in all previous original locations */ - if((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) - TEST_ERROR - if((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) - TEST_ERROR - if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) - TEST_ERROR - if((moved_grp = H5Gopen2(grp_1, "group_copy", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) - TEST_ERROR + if((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(moved_grp) < 0) TEST_ERROR + if((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(moved_grp) < 0) TEST_ERROR + if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(moved_grp) < 0) TEST_ERROR + if((moved_grp = H5Gopen2(grp_1, "group_copy", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(moved_grp) < 0) TEST_ERROR H5Gclose(grp_1); H5Gclose(grp_2); @@ -1427,17 +1294,17 @@ test_copy(hid_t fapl, hbool_t new_format) H5Fclose(file_b); PASSED(); - return 0; + return SUCCEED; - error: +error: H5_FAILED(); H5E_BEGIN_TRY { - H5Gclose(grp_1); - H5Gclose(grp_2); - H5Gclose(grp_move); + H5Gclose(grp_1); + H5Gclose(grp_2); + H5Gclose(grp_move); H5Gclose(moved_grp); - H5Fclose(file_a); - H5Fclose(file_b); + H5Fclose(file_a); + H5Fclose(file_b); } H5E_END_TRY; return 1; } @@ -1451,12 +1318,6 @@ test_copy(hid_t fapl, hbool_t new_format) * * Return: Success: 0 * Failure: number of errors - * - * Programmer: James Laird - * Monday, January 30, 2006 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -1604,13 +1465,13 @@ test_move_preserves(hid_t fapl_id, hbool_t new_format) if(H5Fclose(file_id) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { - H5Pclose(fcpl_id); - H5Pclose(lcpl_id); - H5Pclose(lcpl2_id); + H5Pclose(fcpl_id); + H5Pclose(lcpl_id); + H5Pclose(lcpl2_id); H5Gclose(group_id); H5Fclose(file_id); } H5E_END_TRY; @@ -1625,12 +1486,6 @@ error: * * Return: Success: 0 * Failure: number of errors - * - * Programmer: James Laird - * Wednesday, April 26 2006 - * - * Modifications: - * *------------------------------------------------------------------------- */ #ifndef H5_NO_DEPRECATED_SYMBOLS @@ -1756,7 +1611,7 @@ test_deprec(hid_t fapl, hbool_t new_format) if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -1775,25 +1630,18 @@ error: * Purpose: Build a file with external link to root group in external file * * Return: Success: 0 - * * Failure: -1 - * - * Programmer: Quincey Koziol - * Wednesday, May 25, 2005 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_root(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - H5L_info_t linfo; /* Link information */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE]; - char filename2[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + H5L_info_t linfo; /* Link information */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE]; + char filename2[NAME_BUF_SIZE]; const char *file; /* File from external link */ const char *path; /* Path from external link */ @@ -1824,21 +1672,21 @@ external_link_root(hid_t fapl, hbool_t new_format) /* Check information for external link */ if(H5Lget_info(fid, "ext_link", &linfo, H5P_DEFAULT) < 0) goto error; if(H5L_TYPE_EXTERNAL != linfo.type) { - H5_FAILED(); - HDputs(" Unexpected object type - should have been an external link"); - goto error; + H5_FAILED(); + HDputs(" Unexpected object type - should have been an external link"); + goto error; } if(H5Lget_val(fid, "ext_link", objname, sizeof(objname), H5P_DEFAULT) < 0) TEST_ERROR if(H5Lunpack_elink_val(objname, linfo.u.val_size, NULL, &file, &path) < 0) TEST_ERROR if(HDstrcmp(file, filename1)) { - H5_FAILED(); - HDputs(" External link file name incorrect"); - goto error; - } + H5_FAILED(); + HDputs(" External link file name incorrect"); + goto error; + } if(HDstrcmp(path, "/")) { - H5_FAILED(); - HDputs(" External link path incorrect"); - goto error; + H5_FAILED(); + HDputs(" External link path incorrect"); + goto error; } /* Create external link to object in first file */ @@ -1848,28 +1696,27 @@ external_link_root(hid_t fapl, hbool_t new_format) /* Check information for external link */ if(H5Lget_info(fid, "ext_link", &linfo, H5P_DEFAULT) < 0) goto error; if(H5L_TYPE_EXTERNAL != linfo.type) { - H5_FAILED(); - HDputs(" Unexpected object type - should have been an external link"); - goto error; + H5_FAILED(); + HDputs(" Unexpected object type - should have been an external link"); + goto error; } if(H5Lget_val(fid, "ext_link", objname, sizeof(objname), H5P_DEFAULT) < 0) TEST_ERROR if(H5Lunpack_elink_val(objname, linfo.u.val_size, NULL, &file, &path) < 0) TEST_ERROR if(HDstrcmp(file, filename1)) { - H5_FAILED(); - HDputs(" External link file name incorrect"); - goto error; + H5_FAILED(); + HDputs(" External link file name incorrect"); + goto error; } if(HDstrcmp(path, "/")) { - H5_FAILED(); - HDputs(" External link path incorrect"); - goto error; + H5_FAILED(); + HDputs(" External link path incorrect"); + goto error; } /* Close and re-open file to ensure that data is written to disk */ if(H5Fclose(fid) < 0) TEST_ERROR if((fid = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - /* Open object through external link */ if((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR @@ -1941,15 +1788,15 @@ external_link_root(hid_t fapl, hbool_t new_format) H5F_sfile_assert_num(0); PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Gclose (gid2); H5Gclose (gid); H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_root() */ @@ -1960,24 +1807,17 @@ external_link_root(hid_t fapl, hbool_t new_format) * external file * * Return: Success: 0 - * * Failure: -1 - * - * Programmer: Quincey Koziol - * Tuesday, July 26, 2005 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_path(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE]; - char filename2[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE]; + char filename2[NAME_BUF_SIZE]; if(new_format) TESTING("external link to object on path (w/new group format)") @@ -2049,15 +1889,15 @@ external_link_path(hid_t fapl, hbool_t new_format) PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Gclose (gid2); H5Gclose (gid); H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_path() */ @@ -2068,26 +1908,19 @@ external_link_path(hid_t fapl, hbool_t new_format) * external file links * * Return: Success: 0 - * * Failure: -1 - * - * Programmer: Quincey Koziol - * Tuesday, July 26, 2005 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_mult(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1), fid2 = (-1); /* File IDs */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - filename4[NAME_BUF_SIZE]; /* Names of files to externally link across */ + hid_t fid = -1, fid2 = -1; /* File IDs */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + filename4[NAME_BUF_SIZE]; /* Names of files to externally link across */ if(new_format) TESTING("external links across multiple files (w/new group format)") @@ -2213,15 +2046,15 @@ external_link_mult(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Gclose (gid2); H5Gclose (gid); H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_mult() */ @@ -2231,26 +2064,19 @@ external_link_mult(hid_t fapl, hbool_t new_format) * Purpose: Build a file with external link to itself * * Return: Success: 0 - * * Failure: -1 - * - * Programmer: James Laird - * Wednesday, July 12, 2006 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_self(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - hid_t lcpl_id = (-1); /* Link Creation Property List ID */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE]; - char filename2[NAME_BUF_SIZE]; - char filename3[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + hid_t lcpl_id = -1; /* Link Creation Property List ID */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE]; + char filename2[NAME_BUF_SIZE]; + char filename3[NAME_BUF_SIZE]; if(new_format) TESTING("external link to self (w/new group format)") @@ -2311,8 +2137,8 @@ external_link_self(hid_t fapl, hbool_t new_format) /* Complicate things. Use this file as an intermediate file in a chain - * of external links that will go: file2 -> file1 -> file1 -> file3 - */ + * of external links that will go: file2 -> file1 -> file1 -> file3 + */ /* Create file2 with an external link to file1 */ if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR @@ -2336,7 +2162,6 @@ external_link_self(hid_t fapl, hbool_t new_format) /* Close file1 */ if(H5Fclose(fid) < 0) TEST_ERROR - /* Re-open file2 and traverse through file1 (with its recursive extlink) to file3 */ if((fid=H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR @@ -2361,16 +2186,16 @@ external_link_self(hid_t fapl, hbool_t new_format) PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Gclose(gid2); H5Gclose(gid); H5Pclose(lcpl_id); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_self() */ @@ -2401,11 +2226,11 @@ external_link_self(hid_t fapl, hbool_t new_format) static int external_link_pingpong(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ + hid_t fid = (-1); /* File ID */ hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ if(new_format) TESTING("external links back and forth (w/new group format)") @@ -2417,7 +2242,7 @@ external_link_pingpong(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2); /* Create first file */ - if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create external links for chain */ if(H5Lcreate_external(filename2, "/link2", fid, "link1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -2432,7 +2257,7 @@ external_link_pingpong(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR /* Create second file */ - if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create external links for chain */ if(H5Lcreate_external(filename1, "/link3", fid, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -2444,7 +2269,7 @@ external_link_pingpong(hid_t fapl, hbool_t new_format) /* Open first file */ - if((fid=H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Open object through external link */ if((gid = H5Gopen2(fid, "link1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR @@ -2465,7 +2290,6 @@ external_link_pingpong(hid_t fapl, hbool_t new_format) /* Close first file */ if(H5Fclose(fid) < 0) TEST_ERROR - /* Open first file again and check on object created */ if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR @@ -2484,15 +2308,15 @@ external_link_pingpong(hid_t fapl, hbool_t new_format) PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_pingpong() */ @@ -2523,24 +2347,17 @@ external_link_pingpong(hid_t fapl, hbool_t new_format) * file1:/link17 -> file2: /final * * Return: Success: 0 - * * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, August 8, 2005 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_toomany(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ if(new_format) TESTING("too many external links (w/new group format)") @@ -2575,7 +2392,7 @@ external_link_toomany(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR /* Create second file */ - if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create external links for chain */ if(H5Lcreate_external(filename1, "/link3", fid, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -2596,16 +2413,16 @@ external_link_toomany(hid_t fapl, hbool_t new_format) /* Open first file */ - if((fid=H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Open object through external link */ H5E_BEGIN_TRY { gid = H5Gopen2(fid, "link1", H5P_DEFAULT); } H5E_END_TRY; if (gid >= 0) { - H5_FAILED(); - HDprintf("%d: Should have failed for sequence of too many nested links.", __LINE__); - goto error; + H5_FAILED(); + HDprintf("%d: Should have failed for sequence of too many nested links.", __LINE__); + goto error; } /* Open object through external link */ @@ -2628,15 +2445,15 @@ external_link_toomany(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Gclose (gid2); H5Gclose (gid); H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_toomany() */ @@ -2647,23 +2464,16 @@ external_link_toomany(hid_t fapl, hbool_t new_format) * missing files and missing objects. * * Return: Success: 0 - * * Failure: -1 - * - * Programmer: Quincey Koziol - * Tuesday, August 9, 2005 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_dangling(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - hid_t rid = (-1); /* Root Group ID */ - hid_t status = (-1); /* Status */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + hid_t rid = -1; /* Root Group ID */ + hid_t status = -1; /* Status */ char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ @@ -2677,7 +2487,7 @@ external_link_dangling(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2); /* Create first file */ - if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create dangling external links */ if(H5Lcreate_external("missing", "/missing", fid, "no_file", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -2687,26 +2497,26 @@ external_link_dangling(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR /* Create second file (for dangling object test) */ - if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Close file */ if(H5Fclose(fid) < 0) TEST_ERROR /* Open first file */ - if((fid=H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Get root group ID */ - if((rid=H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) TEST_ERROR; + if((rid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) TEST_ERROR; /* Open object through dangling file external link */ H5E_BEGIN_TRY { gid = H5Gopen2(fid, "no_file", H5P_DEFAULT); } H5E_END_TRY; if (gid >= 0) { - H5_FAILED(); - HDputs(" Should have failed for sequence of too many nested links."); - goto error; + H5_FAILED(); + HDputs(" Should have failed for sequence of too many nested links."); + goto error; } /* Open object through dangling object external link */ @@ -2714,9 +2524,9 @@ external_link_dangling(hid_t fapl, hbool_t new_format) gid = H5Gopen2(fid, "no_object", H5P_DEFAULT); } H5E_END_TRY; if (gid >= 0) { - H5_FAILED(); - HDputs(" Should have failed for sequence of too many nested links."); - goto error; + H5_FAILED(); + HDputs(" Should have failed for sequence of too many nested links."); + goto error; } /* Try to get name of object by index through dangling file external link */ @@ -2736,14 +2546,14 @@ external_link_dangling(hid_t fapl, hbool_t new_format) PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Gclose (gid); H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_dangling() */ @@ -2751,32 +2561,26 @@ external_link_dangling(hid_t fapl, hbool_t new_format) * Function: external_link_prefix * * Purpose: 1. target link: "extlinks2" - * 2. main file: "extlinks0" - * 3. target file: "tmp/extlinks2" - * 4. Set up external link prefix via H5Pset_elink_prefix() to be "tmp" - * Should be able to access the target file in tmp directory via the prefix set - * by H5Pset_elink_prefix() + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks2" + * 4. Set up external link prefix via H5Pset_elink_prefix() to be "tmp" + * Should be able to access the target file in tmp directory via the prefix set + * by H5Pset_elink_prefix() * * * Return: Success: 0 * Failure: -1 - * - * Programmer: Vailin Choi - * Feb 19, 2008 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_prefix(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - hid_t gapl_id = (-1); - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + hid_t gapl_id = -1; + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE]; if(new_format) TESTING("external links via H5Pset_elink_prefix()(w/new group format)") @@ -2796,8 +2600,8 @@ external_link_prefix(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[17], fapl, filename3, sizeof filename3); /* Create the target file */ - if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* closing for target file */ if(H5Gclose(gid) < 0) TEST_ERROR @@ -2805,7 +2609,7 @@ external_link_prefix(hid_t fapl, hbool_t new_format) /* Create the main file */ - if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create external link to target file (without the absolute path) */ if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -2821,9 +2625,9 @@ external_link_prefix(hid_t fapl, hbool_t new_format) /* should be able to find the target file from pathnames set via H5Pset_elink_prefix() */ if (gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in tmp directory."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in tmp directory."); + goto error; } /* closing for main file */ @@ -2831,14 +2635,14 @@ external_link_prefix(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Gclose (gid); H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_prefix() */ @@ -2846,25 +2650,19 @@ external_link_prefix(hid_t fapl, hbool_t new_format) * Function: external_link_abs_mainpath: test 3 * * Purpose: 1. target link: "extlinks3" - * 2. main file: Linux:"/CWD/tmp/extlinks0"; Windows: ":/CWD/tmp/extlinks0" - * 3. target file: "tmp/extlinks3" - * Should be able to access the target file via the main file's absolute path + * 2. main file: Linux:"/CWD/tmp/extlinks0"; Windows: ":/CWD/tmp/extlinks0" + * 3. target file: "tmp/extlinks3" + * Should be able to access the target file via the main file's absolute path * * Return: Success: 0 * Failure: -1 - * - * Programmer: Vailin Choi - * Feb 19, 2008 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_abs_mainpath(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], @@ -2925,14 +2723,14 @@ external_link_abs_mainpath(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_abs_mainpath() */ @@ -2940,25 +2738,19 @@ external_link_abs_mainpath(hid_t fapl, hbool_t new_format) * Function: external_link_rel_mainpath: test 4 * * Purpose: 1. target link: "extlinks4" - * 2. main file: "tmp/extlinks0" - * 3. target file: "tmp/extlinks4" - * Should be able to access the target file via the main file's CWD+relative path + * 2. main file: "tmp/extlinks0" + * 3. target file: "tmp/extlinks4" + * Should be able to access the target file via the main file's CWD+relative path * * Return: Success: 0 * Failure: -1 - * - * Programmer: Vailin Choi - * Feb 19, 2008 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_rel_mainpath(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE]; @@ -2980,8 +2772,8 @@ external_link_rel_mainpath(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[21], fapl, filename3, sizeof filename3); /* Create the target file */ - if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* closing for target file */ if(H5Gclose(gid) < 0) TEST_ERROR @@ -2989,7 +2781,7 @@ external_link_rel_mainpath(hid_t fapl, hbool_t new_format) /* Create the main file */ - if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create external link to target file */ if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -3001,9 +2793,9 @@ external_link_rel_mainpath(hid_t fapl, hbool_t new_format) /* should be able to find the target file from the main file's relative pathname */ if (gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in current working directory"); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in current working directory"); + goto error; } /* closing for main file */ @@ -3011,45 +2803,37 @@ external_link_rel_mainpath(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_rel_mainpath() */ /*------------------------------------------------------------------------- * Function: external_link_cwd: test 5 * * Purpose: 1. target link: "extlinks5" - * 2. main file: Linux:"/CWD/tmp/extlinks0"; Window: ":/CWD/tmp/extlinks0" - * 2. target file: "extlinks5" - * Should be able to access the target file in the current working directory - * + * 2. main file: Linux:"/CWD/tmp/extlinks0"; Window: ":/CWD/tmp/extlinks0" + * 3. target file: "extlinks5" + * Should be able to access the target file in the current working directory * * Return: Success: 0 * Failure: -1 - * - * Programmer: Vailin Choi - * Feb 19, 2008 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_cwd(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; - + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; if(new_format) TESTING("external links via current working directory(w/new group format)") @@ -3093,9 +2877,9 @@ external_link_cwd(hid_t fapl, hbool_t new_format) /* should be able to find the target file from the current working directory */ if(gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in current working directory"); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in current working directory"); + goto error; } /* closing for main file */ @@ -3103,46 +2887,39 @@ external_link_cwd(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_cwd() */ - /*------------------------------------------------------------------------- * Function: external_link_abstar: test 6 * * Purpose: 1. target link: Linux:"/CWD/tmp/extlinks6"; Windows:":/CWD/tmp/extlinks6" - * 2. main file: "extlinks0" - * 3. target file: "tmp/extlinks6" - * Should be able to access the target file's absolute path + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks6" + * Should be able to access the target file's absolute path * * Return: Success: 0 * Failure: -1 - * - * Programmer: Vailin Choi - * Feb. 20, 2008 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_abstar(hid_t fapl, hbool_t new_format) { hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; if(new_format) TESTING("external links via target's absolute path (w/new group format)") @@ -3175,7 +2952,6 @@ external_link_abstar(hid_t fapl, hbool_t new_format) if(H5Gclose(gid) < 0) TEST_ERROR if(H5Fclose(fid) < 0) TEST_ERROR - /* Create the main file */ if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR @@ -3189,9 +2965,9 @@ external_link_abstar(hid_t fapl, hbool_t new_format) /* should be able to find the target file with abolute path */ if(gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in tmp directory."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in tmp directory."); + goto error; } /* closing for main file */ @@ -3199,39 +2975,33 @@ external_link_abstar(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_abstar() */ /*------------------------------------------------------------------------- * Function: external_link_abstar_cur: test 7 * * Purpose: 1. target link: Linux: "/CWD/tmp/extlinks7"; Windows: ":/CWD/tmp/extlinks7" - * 2. main file: "extlinks0" - * 3. target file: "extlinks7" - * Should be able to access the target file via the main file's CWD. + * 2. main file: "extlinks0" + * 3. target file: "extlinks7" + * Should be able to access the target file via the main file's CWD. * * Return: Success: 0 * Failure: -1 - * - * Programmer: Vailin Choi - * Feb. 20, 2008 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_abstar_cur(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], @@ -3256,7 +3026,7 @@ external_link_abstar_cur(hid_t fapl, hbool_t new_format) /* * set up name for external linked target file: * Linux: "/CWD/tmp/extlinks7" - * Windows: ":/CWD/tmp/extlinks7" + * Windows: ":/CWD/tmp/extlinks7" */ fix_ext_filename(tmpname, cwdpath, FILENAME[25]); h5_fixname(tmpname, fapl, filename2, sizeof filename2); @@ -3269,7 +3039,6 @@ external_link_abstar_cur(hid_t fapl, hbool_t new_format) if(H5Gclose(gid) < 0) TEST_ERROR if(H5Fclose(fid) < 0) TEST_ERROR - /* Create the main file */ if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR @@ -3283,9 +3052,9 @@ external_link_abstar_cur(hid_t fapl, hbool_t new_format) /* should be able to find the target file from main file's current working directory */ if (gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in current working directory."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in current working directory."); + goto error; } /* closing for main file */ @@ -3293,14 +3062,14 @@ external_link_abstar_cur(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_abstar_cur() */ @@ -3308,25 +3077,19 @@ external_link_abstar_cur(hid_t fapl, hbool_t new_format) * Function: external_link_reltar: test 8 * * Purpose: 1. target link: Linux:"tmp/extlinks8" - * 2. main file: "extlinks0" - * 3. target file: "tmp/extlinks8" - * Should be able to access the target file via the main file's CWD+ target's relative path + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks8" + * Should be able to access the target file via the main file's CWD+ target's relative path * * Return: Success: 0 * Failure: -1 - * - * Programmer: Vailin Choi - * Feb. 20, 2008 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_reltar(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; @@ -3339,8 +3102,7 @@ external_link_reltar(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); /* create tmp directory */ - if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) - TEST_ERROR + if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR /* set up name for target file name: "tmp/extlinks8" */ /* set up name for external linked target file: "tmp/extlinks8" */ @@ -3363,9 +3125,9 @@ external_link_reltar(hid_t fapl, hbool_t new_format) /* Open object through external link */ if((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) { - H5_FAILED(); - HDputs(" Should have found the file in tmp directory."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in tmp directory."); + goto error; } /* end if */ /* closing for main file */ @@ -3373,14 +3135,14 @@ external_link_reltar(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_reltar() */ @@ -3396,19 +3158,13 @@ external_link_reltar(hid_t fapl, hbool_t new_format) * * Return: Success: 0 * Failure: -1 - * - * Programmer: Vailin Choi - * Feb. 20, 2008 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_chdir(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE]; @@ -3424,8 +3180,7 @@ external_link_chdir(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[27], fapl, filename2, sizeof filename2); /* create tmp directory */ - if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) - TEST_ERROR + if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR /* set up name for target file name ("tmp/extlinks9") */ h5_fixname(FILENAME[28], fapl, filename3, sizeof filename3); @@ -3438,9 +3193,8 @@ external_link_chdir(hid_t fapl, hbool_t new_format) if(H5Gclose(gid) < 0) TEST_ERROR if(H5Fclose(fid) < 0) TEST_ERROR - /* Create the main file */ - if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create external link to target file */ if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -3460,9 +3214,9 @@ external_link_chdir(hid_t fapl, hbool_t new_format) * main file's current working directory + pathname of external linked targetfile */ if (gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in tmp directory."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in tmp directory."); + goto error; } /* closing for main file */ @@ -3470,14 +3224,14 @@ external_link_chdir(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_chdir() */ @@ -3485,10 +3239,10 @@ external_link_chdir(hid_t fapl, hbool_t new_format) * Function: external_set_elink_fapl1: test 10 * * Purpose: To verify that the external linked target file with physical layout - * different from the parent can be successfully opened. + * different from the parent can be successfully opened. * * 1. target link: "extlinks16" - * 2. target file: "extlinks16" + * 2. target file: "extlinks16" * 3. main file: Linux:"/CWD/tmp/extlinks0"; Window: ":/CWD/tmp/extlinks0" * 4. Create target file A to be a "family" file: extlinks16A * 4. Create target file B to be a "multi" file: extlinks16B @@ -3499,12 +3253,6 @@ external_link_chdir(hid_t fapl, hbool_t new_format) * * Return: Success: 0 * Failure: -1 - * - * Programmer: Vailin Choi - * Sept. 12, 2008 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -3514,18 +3262,18 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) hid_t fidA=(-1), fidB=(-1); hid_t gidA=(-1), gidB=(-1); hid_t oidA=(-1), oidB=(-1); - char filename1[NAME_BUF_SIZE], - filename2A[NAME_BUF_SIZE], - filename2B[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; - hid_t fam_fapl=-1, multi_fapl=-1; + char filename1[NAME_BUF_SIZE], + filename2A[NAME_BUF_SIZE], + filename2B[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + hid_t fam_fapl=-1, multi_fapl=-1; hid_t lapl_idA=-1, lapl_idB=-1; - H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; hid_t memb_fapl[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][64]; - const char *memb_name[H5FD_MEM_NTYPES]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; + char sv[H5FD_MEM_NTYPES][64]; + H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; + const char *memb_name[H5FD_MEM_NTYPES]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; if(new_format) TESTING("H5Pset/get_elink_fapl() with different physical layouts (w/new group format)") @@ -3533,7 +3281,7 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) TESTING("H5Pset/get_elink_fapl() with different physical layouts") if((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) - TEST_ERROR + TEST_ERROR /* * set up name for main file: @@ -3545,8 +3293,7 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) /* create "family" fapl */ fam_fapl = h5_fileaccess(); - if(H5Pset_fapl_family(fam_fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) - TEST_ERROR; + if(H5Pset_fapl_family(fam_fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) TEST_ERROR; /* set up name for external linked target file A: "extlinks16A" */ /* set up name for target file A: "extlinks16A" */ @@ -3560,8 +3307,8 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) HDmemset(sv, 0, sizeof sv); for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { - memb_map[mt] = H5FD_MEM_SUPER; - memb_fapl[mt] = H5P_DEFAULT; + memb_map[mt] = H5FD_MEM_SUPER; + memb_fapl[mt] = H5P_DEFAULT; } /* end for */ memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; @@ -3595,8 +3342,7 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) /* create "multi" fapl */ multi_fapl = h5_fileaccess(); - if(H5Pset_fapl_multi(multi_fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE) < 0) - TEST_ERROR; + if(H5Pset_fapl_multi(multi_fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE) < 0) TEST_ERROR; /* set up name for external linked target file B: "extlinks16B" */ /* set up name for target file B: "extlinks16B" */ @@ -3620,11 +3366,9 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create external link to target file A:/A */ - if(H5Lcreate_external(filename2A, "/A", fid, "ext_linkA", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcreate_external(filename2A, "/A", fid, "ext_linkA", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Create external link to target file B:/B */ - if(H5Lcreate_external(filename2B, "/B", fid, "ext_linkB", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcreate_external(filename2B, "/B", fid, "ext_linkB", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Set file access property list for link access to use the family driver */ if((lapl_idA = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR @@ -3635,9 +3379,9 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) /* should succeed in opening the target object A in the current working directory */ if (oidA < 0) { - H5_FAILED(); - HDputs(" Should succeed in opening family target file A in current working directory"); - goto error; + H5_FAILED(); + HDputs(" Should succeed in opening family target file A in current working directory"); + goto error; } /* Set file access property list for link access to use the multi driver */ @@ -3649,9 +3393,9 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) /* should succeed in opening the target object B in the current working directory */ if (oidB < 0) { - H5_FAILED(); - HDputs(" Should succeed in opening multi target file B in current working directory"); - goto error; + H5_FAILED(); + HDputs(" Should succeed in opening multi target file B in current working directory"); + goto error; } /* closing */ @@ -3664,21 +3408,21 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { - H5Pclose (lapl_idA); - H5Pclose (lapl_idB); - H5Pclose (fam_fapl); - H5Pclose (multi_fapl); - H5Gclose (gidA); - H5Gclose (gidB); - H5Oclose (oidA); - H5Oclose (oidB); - H5Fclose (fid); + H5Pclose (lapl_idA); + H5Pclose (lapl_idB); + H5Pclose (fam_fapl); + H5Pclose (multi_fapl); + H5Gclose (gidA); + H5Gclose (gidB); + H5Oclose (oidA); + H5Oclose (oidB); + H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_set_elink_fapl1() */ @@ -3686,45 +3430,39 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) * Function: external_set_elink_fapl2: test 11 * * Purpose: To verify that processing done to the external linked target object is - * correctly handled when the parent and target files have the same - * physical layout but different access methods. + * correctly handled when the parent and target files have the same + * physical layout but different access methods. * * 1. target link: "extlinks17" * 2. target file: "extlinks17" - * 3. main file: Linux:"/CWD/tmp/extlinks0"; Window: ":/CWD/tmp/extlinks0" - * 4. Create target file to be a "core" file:/A/Dataset - * 5. Create external link from main file to target file:ext_link->target file:/A/Dataset - * 6. Set the file access property list of the link access to use "core" file without - * backing store - * 6. Should succeed in opening the target dataset: ext_link - * 7. Write data to the target dataset - * 8. On closing, the file size of target should be the same as before since - * it is opened without backing store. + * 3. main file: Linux:"/CWD/tmp/extlinks0"; Window: ":/CWD/tmp/extlinks0" + * 4. Create target file to be a "core" file:/A/Dataset + * 5. Create external link from main file to target file:ext_link->target file:/A/Dataset + * 6. Set the file access property list of the link access to use "core" file without + * backing store + * 7. Should succeed in opening the target dataset: ext_link + * 8. Write data to the target dataset + * 9. On closing, the file size of target should be the same as before since + * it is opened without backing store. * * Return: Success: 0 * Failure: -1 - * - * Programmer: Vailin Choi - * Sept. 12, 2008 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_set_elink_fapl2(hid_t fapl, hbool_t new_format) { hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - hid_t core_fapl = -1, space = -1, dset = -1, did = -1, dapl_id = -1, dcpl = -1; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; - hsize_t dims[2]; - int points[NUM40][NUM40]; + hid_t gid = (-1); /* Group IDs */ + hid_t core_fapl = -1, space = -1, dset = -1, did = -1, dapl_id = -1, dcpl = -1; + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + hsize_t dims[2]; + int points[NUM40][NUM40]; + int i, j, n; h5_stat_size_t filesize, new_filesize; - int i, j, n; if(new_format) TESTING("H5Pset/get_elink_fapl() with same physical layout (w/new group format)") @@ -3736,7 +3474,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* * set up name for main file: - * Linux: "/CWD/tmp/extlinks0" + * Linux: "/CWD/tmp/extlinks0" * Windows: ":/CWD/tmp/extlinks0" */ fix_ext_filename(tmpname, cwdpath, FILENAME[13]); @@ -3744,8 +3482,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* create fapl for the target file to be a "core" file */ core_fapl = h5_fileaccess(); - if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, TRUE) < 0) - TEST_ERROR + if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, TRUE) < 0) TEST_ERROR /* set up name for external linked target file: "extlinks17" */ /* set up name for target file: "extlinks17" */ @@ -3768,8 +3505,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) TEST_ERROR; /* create "Dataset" in group "A" of target file */ - if((dset = H5Dcreate2(gid, "Dataset", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - TEST_ERROR + if((dset = H5Dcreate2(gid, "Dataset", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* closing for target file */ if(H5Pclose(dcpl) < 0) TEST_ERROR @@ -3785,12 +3521,10 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create external link to target file: ext_link->extlinks17:/A/Dataset */ - if(H5Lcreate_external(filename2, "/A/Dataset", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcreate_external(filename2, "/A/Dataset", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* create fapl to be a "core" file without backing store */ - if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, FALSE) < 0) - TEST_ERROR + if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, FALSE) < 0) TEST_ERROR /* Set file access property list for link access to use the "core" driver */ if((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) TEST_ERROR @@ -3810,8 +3544,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) points[i][j] = n++; /* Write the data to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) - TEST_ERROR + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) TEST_ERROR if(H5Pclose(dapl_id) < 0) TEST_ERROR if(H5Dclose(did) < 0) TEST_ERROR @@ -3825,20 +3558,20 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) if(H5Pclose(core_fapl) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { - H5Pclose(dcpl); - H5Sclose(space); - H5Dclose(dset); - H5Pclose(core_fapl); - H5Pclose(dapl_id); - H5Dclose(did); - H5Gclose(gid); - H5Fclose(fid); + H5Pclose(dcpl); + H5Sclose(space); + H5Dclose(dset); + H5Pclose(core_fapl); + H5Pclose(dapl_id); + H5Dclose(did); + H5Gclose(gid); + H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_set_elink_fapl2() */ @@ -3846,17 +3579,17 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) * Function: external_set_elink_fapl3: test 12 * * Purpose: To verify that the file access property list for link access is - * set and closed correctly. - * - * 1. Create fapl for core driver - * 2. Create fapl for stdio driver - * 3. Set link access's fapl to use stdio driver - * 4. Verify that link access's fapl is the stdio driver - * 5. Reset the link access' fapl to use core driver - * 6. H5Pcopy() the link access - * 7. Get the fapl property value of the original link access - * 8. Close the original link access - * 9. H5Pclose() fapl should fail since closing in step #8 should also close its fapl + * set and closed correctly. + * + * 1. Create fapl for core driver + * 2. Create fapl for stdio driver + * 3. Set link access's fapl to use stdio driver + * 4. Verify that link access's fapl is the stdio driver + * 5. Reset the link access' fapl to use core driver + * 6. H5Pcopy() the link access + * 7. Get the fapl property value of the original link access + * 8. Close the original link access + * 9. H5Pclose() fapl should fail since closing in step #8 should also close its fapl * 10. Verify that the copied link access's fapl is the core driver * 11. Get the fapl property value of the copied link access * 12. H5Premove() the fapl property from the copied link access @@ -3865,18 +3598,12 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) * * Return: Success: 0 * Failure: -1 - * - * Programmer: Vailin Choi - * Sept. 12, 2008 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_set_elink_fapl3(hbool_t new_format) { - hid_t core_fapl = -1, stdio_fapl = -1; + hid_t core_fapl = -1, stdio_fapl = -1; hid_t lapl_id = -1, new_lapl_id = -1, l_fapl = -1, out_fapl; if(new_format) @@ -3886,12 +3613,10 @@ external_set_elink_fapl3(hbool_t new_format) /* create fapl for the target file to be a "core" file */ core_fapl = h5_fileaccess(); - if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, TRUE) < 0) - TEST_ERROR + if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, TRUE) < 0) TEST_ERROR stdio_fapl = h5_fileaccess(); - if(H5Pset_fapl_stdio(stdio_fapl) < 0) - TEST_ERROR + if(H5Pset_fapl_stdio(stdio_fapl) < 0) TEST_ERROR /* Set file access property list for link access to use the "stdio" driver */ if((lapl_id = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR @@ -3932,9 +3657,9 @@ external_set_elink_fapl3(hbool_t new_format) if(H5Pclose(stdio_fapl) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Pclose(l_fapl); H5Pclose(lapl_id); @@ -3942,7 +3667,7 @@ external_set_elink_fapl3(hbool_t new_format) H5Pclose(core_fapl); H5Pclose(stdio_fapl); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_set_elink_fapl3() */ @@ -3953,12 +3678,6 @@ external_set_elink_fapl3(hbool_t new_format) * * Return: Success: 0 * Failure: -1 - * - * Programmer: Neil Fortner - * Jan. 5, 2009 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -4153,9 +3872,9 @@ external_set_elink_acc_flags(const char *env_h5_drvr, hid_t fapl, hbool_t new_fo if(H5Pclose(gapl) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Gclose(group); H5Gclose(subgroup); @@ -4163,7 +3882,7 @@ external_set_elink_acc_flags(const char *env_h5_drvr, hid_t fapl, hbool_t new_fo H5Fclose(file2); H5Pclose(gapl); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_set_elink_acc_flags() */ @@ -4174,12 +3893,6 @@ external_set_elink_acc_flags(const char *env_h5_drvr, hid_t fapl, hbool_t new_fo * * Return: Success: 0 * Failure: -1 - * - * Programmer: Neil Fortner - * Jan. 5, 2009 - * - * Modifications: - * *------------------------------------------------------------------------- */ /* User data structure for callback function */ @@ -4217,7 +3930,7 @@ external_set_elink_cb_cb(const char *parent_file, const char *parent_group, if (op_data->code == 2) *flags = H5F_ACC_DEFAULT; - return 0; + return SUCCEED; } /* Main test function */ @@ -4226,7 +3939,7 @@ external_set_elink_cb(hid_t fapl, hbool_t new_format) { hid_t file1 = -1, file2 = -1, group = -1, gapl = -1, fam_fapl = -1, ret_fapl = -1, base_driver; set_elink_cb_t op_data, - *op_data_p; + *op_data_p; H5L_elink_traverse_t cb; char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; @@ -4319,9 +4032,9 @@ external_set_elink_cb(hid_t fapl, hbool_t new_format) if(H5Pclose(gapl) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Gclose(group); H5Fclose(file1); @@ -4330,7 +4043,7 @@ external_set_elink_cb(hid_t fapl, hbool_t new_format) H5Pclose(ret_fapl); H5Pclose(fam_fapl); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_set_elink_cb() */ @@ -4342,12 +4055,6 @@ external_set_elink_cb(hid_t fapl, hbool_t new_format) * * Return: Success: 0 * Failure: -1 - * - * Programmer: Neil Fortner - * Apr. 9, 2009 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -4385,13 +4092,13 @@ external_reset_register(void) if(HDremove(filename) != 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Fclose(file); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_reset_register() */ @@ -4401,31 +4108,25 @@ external_reset_register(void) * Function: external_link_win1 * * Purpose: - * 1. target link: "/CWD/tmp/extlinks10" - * 2. main file: "extlinks0" - * 3. target file: "extlinks10" - * Should be able to find the target file via main file's current drive/rel path + * 1. target link: "/CWD/tmp/extlinks10" + * 2. main file: "extlinks0" + * 3. target file: "extlinks10" + * Should be able to find the target file via main file's current drive/rel path * * Return: Success: 0 * Failure: -1 - * - * Programmer: Vailin Choi - * April 15, 2008 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_win1(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; if(new_format) TESTING("external links via main file's current drive/rel path(windows)(w/new group format)") @@ -4455,7 +4156,6 @@ external_link_win1(hid_t fapl, hbool_t new_format) if(H5Gclose(gid) < 0) TEST_ERROR if(H5Fclose(fid) < 0) TEST_ERROR - /* Create the main file */ if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR @@ -4469,9 +4169,9 @@ external_link_win1(hid_t fapl, hbool_t new_format) /* should be able to find the target file via main file's CWD*/ if(gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in CWD."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in CWD."); + goto error; } /* closing for main file */ @@ -4479,14 +4179,14 @@ external_link_win1(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_win1() */ @@ -4495,30 +4195,24 @@ external_link_win1(hid_t fapl, hbool_t new_format) * * Purpose: * 1. target link: "/CWD/tmp/extlinks11" - * 2. main file: "extlinks0" - * 3. target file: "tmp/extlinks11" - * Should be able to access the target file directly (rel drive/abs path) + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks11" + * Should be able to access the target file directly (rel drive/abs path) * * Return: Success: 0 * Failure: -1 - * - * Programmer: Vailin Choi - * April 15, 2008 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_win2(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; if(new_format) TESTING("external links via target's rel drive/abs path directly(windows)(w/new group format)") @@ -4563,9 +4257,9 @@ external_link_win2(hid_t fapl, hbool_t new_format) /* should be able to find the target file directly */ if(gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in tmp."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in tmp."); + goto error; } /* closing for main file */ @@ -4573,14 +4267,14 @@ external_link_win2(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_win2() */ @@ -4589,30 +4283,24 @@ external_link_win2(hid_t fapl, hbool_t new_format) * * Purpose: * 1. target link: ":tmp/extlinks12" - * 2. main file: "extlinks0" - * 3. target file: "tmp/extlinks12" - * Should be able to access the target file directly (abs drive/rel path) + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks12" + * Should be able to access the target file directly (abs drive/rel path) * * Return: Success: 0 * Failure: -1 - * - * Programmer: Vailin Choi - * April i15 2008 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_win3(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - int drive=0; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + int drive = 0; + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE]; if(new_format) TESTING("external links via target's abs drive/rel path directly (windows)(w/new group format)") @@ -4656,9 +4344,9 @@ external_link_win3(hid_t fapl, hbool_t new_format) /* should be able to find the target file directly */ if (gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in tmp."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in tmp."); + goto error; } /* closing for main file */ @@ -4666,45 +4354,39 @@ external_link_win3(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_win3() */ /*------------------------------------------------------------------------- * Function: external_link_win4 * * Purpose: - * 1. target link: ":extlinks13" + * 1. target link: ":extlinks13" * 2. main file: ":tmp/extlinks0" * 3. target file: tmp/extlinks13 - * Should be able to access the target file via main file's abs drive/rel path + * Should be able to access the target file via main file's abs drive/rel path * * Return: Success: 0 * Failure: -1 - * - * Programmer: Vailin Choi - * April 15, 2008 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_win4(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - int drive=0; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + int drive=0; + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE]; if(new_format) TESTING("external links via main file's abs drive/rel path (windows)(w/new group format)") @@ -4724,16 +4406,15 @@ external_link_win4(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[34], fapl, filename3, sizeof filename3); /* Create the target file */ - if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* closing for target file */ if(H5Gclose(gid) < 0) TEST_ERROR if(H5Fclose(fid) < 0) TEST_ERROR - /* Create the main file */ - if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create external link to target file */ if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -4745,9 +4426,9 @@ external_link_win4(hid_t fapl, hbool_t new_format) /* should be able to find the target file via main file's absolute drive/relative path */ if (gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in CWD."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in CWD."); + goto error; } /* closing for main file */ @@ -4755,14 +4436,14 @@ external_link_win4(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_win4() */ @@ -4771,31 +4452,25 @@ external_link_win4(hid_t fapl, hbool_t new_format) * * Purpose: * 1. target link: ":tmp/extlinks14" - * 2. main file: "/CWD/extlinks0" - * 3. target file: "tmp/extlinks14" - * Should be able to access the target file via main file's relative drive/absolute path + * 2. main file: "/CWD/extlinks0" + * 3. target file: "tmp/extlinks14" + * Should be able to access the target file via main file's relative drive/absolute path * * Return: Success: 0 * Failure: -1 - * - * Programmer: Vailin Choi - * April 15, 2008 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_win5(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - int drive=0; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + int drive=0; + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; if(new_format) TESTING("external links via main file's rel drive/abs path (windows)(w/new group format)") @@ -4831,7 +4506,6 @@ external_link_win5(hid_t fapl, hbool_t new_format) if(H5Gclose(gid) < 0) TEST_ERROR if(H5Fclose(fid) < 0) TEST_ERROR - /* Create the main file */ if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR @@ -4845,9 +4519,9 @@ external_link_win5(hid_t fapl, hbool_t new_format) /* should be able to find the target file via main file's rel drive/abs path */ if(gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in CWD."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in CWD."); + goto error; } /* closing for main file */ @@ -4855,14 +4529,14 @@ external_link_win5(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_win5() */ @@ -4871,30 +4545,24 @@ external_link_win5(hid_t fapl, hbool_t new_format) * * Purpose: * 1. target link: ":tmp/extlinks15" - * 2. main file: "extlinks0" - * 3. target file: "tmp/extlinks15" - * Should be able to access the target file via target's current drive/rel path + * 2. main file: "extlinks0" + * 3. target file: "tmp/extlinks15" + * Should be able to access the target file via target's current drive/rel path * * Return: Success: 0 * Failure: -1 - * - * Programmer: Vailin Choi - * April 15, 2008 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_win6(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - int drive=0; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + int drive=0; + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE]; if(new_format) TESTING("external links via target's current drive/rel path (windows)(w/new group format)") @@ -4921,16 +4589,15 @@ external_link_win6(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[36], fapl, filename3, sizeof filename3); /* Create the target file */ - if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* closing for target file */ if(H5Gclose(gid) < 0) TEST_ERROR if(H5Fclose(fid) < 0) TEST_ERROR - /* Create the main file */ - if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create external link to target file */ if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -4942,9 +4609,9 @@ external_link_win6(hid_t fapl, hbool_t new_format) /* should be able to find the target file via target file's rel path in current drive */ if (gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in tmp."); - goto error; + H5_FAILED(); + HDputs(" Should have found the file in tmp."); + goto error; } /* closing for main file */ @@ -4952,14 +4619,14 @@ external_link_win6(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_win6() */ @@ -4970,7 +4637,7 @@ external_link_win6(hid_t fapl, hbool_t new_format) * 1. UNC target link: "\\127.0.01\c$/tmp/extlinks10" * 2. main file: "extlinks0" * 3. target file: "extlinks15" - * Should be able to find the target file via main file's local host/main drive/rel path + * Should be able to find the target file via main file's local host/main drive/rel path * * Return: Success: 0 * Failure: -1 @@ -4979,8 +4646,8 @@ external_link_win6(hid_t fapl, hbool_t new_format) static int external_link_win7(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], @@ -5015,7 +4682,6 @@ external_link_win7(hid_t fapl, hbool_t new_format) if(H5Gclose(gid) < 0) TEST_ERROR if(H5Fclose(fid) < 0) TEST_ERROR - /* Create the main file */ if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR @@ -5039,14 +4705,14 @@ external_link_win7(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_win7() */ @@ -5057,7 +4723,7 @@ external_link_win7(hid_t fapl, hbool_t new_format) * 1. Long UNC target link: "\\?\:\CWD\extlinks10" * 2. main file: "extlinks0" * 3. target file: "extlinks10" - * Should be able to access the target file directly (abs drive/abs path) + * Should be able to access the target file directly (abs drive/abs path) * * Return: Success: 0 * Failure: -1 @@ -5067,9 +4733,9 @@ external_link_win7(hid_t fapl, hbool_t new_format) static int external_link_win8(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - int drive=0; + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + int drive = 0; char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], @@ -5084,12 +4750,10 @@ external_link_win8(hid_t fapl, hbool_t new_format) /* set up name for main file: "extlinks0" */ h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); - if(NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) - TEST_ERROR + if(NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) TEST_ERROR /* create tmp directory */ - if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) - TEST_ERROR + if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR /* set up name for target link: ":\CWD\extlinks10" */ drive = HDgetdrive(); @@ -5107,7 +4771,6 @@ external_link_win8(hid_t fapl, hbool_t new_format) if(H5Gclose(gid) < 0) TEST_ERROR if(H5Fclose(fid) < 0) TEST_ERROR - /* Create the main file */ if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR @@ -5131,14 +4794,14 @@ external_link_win8(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_win8() */ @@ -5149,7 +4812,7 @@ external_link_win8(hid_t fapl, hbool_t new_format) * 1. Long UNC target link: "\\?\UNC\127.0.01\c$/tmp/extlinks10" * 2. main file: "extlinks0" * 3. target file: "extlinks15" - * Should be able to find the target file via main file's local host/main drive/rel path + * Should be able to find the target file via main file's local host/main drive/rel path * * Return: Success: 0 * Failure: -1 @@ -5158,13 +4821,13 @@ external_link_win8(hid_t fapl, hbool_t new_format) static int external_link_win9(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; if(new_format) TESTING("external links via main file's Long UNC local host/main drive/rel path(windows)(w/new group format)") @@ -5174,8 +4837,7 @@ external_link_win9(hid_t fapl, hbool_t new_format) /* set up name for main file: "extlinks0" */ h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); - if(NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) - TEST_ERROR + if(NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) TEST_ERROR /* set up name for target link: "\\?\UNC\127.0.0.1\c$/tmp/extlinks10" */ HDstrcpy(tmpname, "\\\\?\\UNC\127.0.0.1\\c$"); /* absolute path */ @@ -5194,7 +4856,6 @@ external_link_win9(hid_t fapl, hbool_t new_format) if(H5Gclose(gid) < 0) TEST_ERROR if(H5Fclose(fid) < 0) TEST_ERROR - /* Create the main file */ if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR @@ -5218,14 +4879,14 @@ external_link_win9(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_win9() */ #endif /* H5_HAVE_WINDOW_PATH */ @@ -5238,20 +4899,14 @@ external_link_win9(hid_t fapl, hbool_t new_format) * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, August 15, 2005 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_recursive(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char filename1[NAME_BUF_SIZE]; /* Names of files to externally link across */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + char filename1[NAME_BUF_SIZE]; /* Names of files to externally link across */ if(new_format) TESTING("recursive external links (w/new group format)") @@ -5262,7 +4917,7 @@ external_link_recursive(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[3], fapl, filename1, sizeof filename1); /* Create first file */ - if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create recursive external links */ if(H5Lcreate_external(filename1, "/recursive", fid, "recursive", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -5270,33 +4925,31 @@ external_link_recursive(hid_t fapl, hbool_t new_format) /* Close file */ if(H5Fclose(fid) < 0) TEST_ERROR - /* Open file */ - if((fid=H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR /* Open object through dangling file external link */ H5E_BEGIN_TRY { gid = H5Gopen2(fid, "recursive", H5P_DEFAULT); } H5E_END_TRY; if (gid >= 0) { - H5_FAILED(); - HDputs(" Should have failed for recursive external links."); - goto error; + H5_FAILED(); + HDputs(" Should have failed for recursive external links."); + goto error; } /* Close first file */ if(H5Fclose(fid) < 0) TEST_ERROR - PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Gclose (gid); H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_recursive() */ @@ -5308,25 +4961,19 @@ external_link_recursive(hid_t fapl, hbool_t new_format) * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, August 15, 2005 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int external_link_query(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ const char *file_name; /* Name of the file the external link points to */ const char *object_name; /* Name of the object the external link points to */ - H5O_info_t oi; /* Object information */ + H5O_info_t oi; /* Object information */ H5L_info_t li; /* Link information */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], /* Names of files to externally link across */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE], /* Names of files to externally link across */ query_buf[NAME_BUF_SIZE]; /* Buffer to hold query result */ if(new_format) @@ -5339,7 +4986,7 @@ external_link_query(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2); /* Create first file, with external link to object in second file */ - if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create external link */ /* (add a few extra '/'s to make certain library normalizes external link object names) */ @@ -5349,16 +4996,16 @@ external_link_query(hid_t fapl, hbool_t new_format) if(H5Lget_info(fid, "src", &li, H5P_DEFAULT) < 0) TEST_ERROR if(li.u.val_size != (1 + (HDstrlen(filename2) + 1) + (HDstrlen("/dst") + 1))) TEST_ERROR if (H5L_TYPE_EXTERNAL != li.type) { - H5_FAILED(); - HDputs(" Unexpected link class - should have been an external link"); - goto error; + H5_FAILED(); + HDputs(" Unexpected link class - should have been an external link"); + goto error; } /* Close file */ if(H5Fclose(fid) < 0) TEST_ERROR /* Create second file to point to */ - if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create object to link to */ if((gid = H5Gcreate2(fid, "dst", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -5367,7 +5014,6 @@ external_link_query(hid_t fapl, hbool_t new_format) /* Close file */ if(H5Fclose(fid) < 0) TEST_ERROR - /* Open first file */ if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR @@ -5375,9 +5021,9 @@ external_link_query(hid_t fapl, hbool_t new_format) if(H5Lget_info(fid, "src", &li, H5P_DEFAULT) < 0) TEST_ERROR if(li.u.val_size != (1 + (HDstrlen(filename2) + 1) + (HDstrlen("/dst") + 1))) TEST_ERROR if(H5L_TYPE_EXTERNAL != li.type) { - H5_FAILED(); - HDputs(" Unexpected link class - should have been an external link"); - goto error; + H5_FAILED(); + HDputs(" Unexpected link class - should have been an external link"); + goto error; } /* Get information for external link. It should be two strings right after each other */ @@ -5393,9 +5039,9 @@ external_link_query(hid_t fapl, hbool_t new_format) /* Query information about object that external link points to */ if(H5Oget_info_by_name2(fid, "src", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5O_TYPE_GROUP != oi.type) { - H5_FAILED(); - HDputs(" Unexpected object type - should have been a group"); - goto error; + H5_FAILED(); + HDputs(" Unexpected object type - should have been a group"); + goto error; } /* Close first file */ @@ -5406,27 +5052,27 @@ external_link_query(hid_t fapl, hbool_t new_format) /* Make sure that bogus cases trigger errors in H5Lunpack_elink_val */ H5E_BEGIN_TRY { - if(H5Lunpack_elink_val(query_buf, li.u.val_size - 1, NULL, NULL, NULL) >= 0) TEST_ERROR + if(H5Lunpack_elink_val(query_buf, li.u.val_size - 1, NULL, NULL, NULL) >= 0) TEST_ERROR } H5E_END_TRY H5E_BEGIN_TRY { - if(H5Lunpack_elink_val(query_buf, (size_t)0, NULL, NULL, NULL) >= 0) TEST_ERROR + if(H5Lunpack_elink_val(query_buf, (size_t)0, NULL, NULL, NULL) >= 0) TEST_ERROR } H5E_END_TRY H5E_BEGIN_TRY { - if(H5Lunpack_elink_val(NULL, (size_t)0, NULL, NULL, NULL) >= 0) TEST_ERROR + if(H5Lunpack_elink_val(NULL, (size_t)0, NULL, NULL, NULL) >= 0) TEST_ERROR } H5E_END_TRY H5E_BEGIN_TRY { - if(H5Lunpack_elink_val(NULL, (size_t)1000, NULL, NULL, NULL) >= 0) TEST_ERROR + if(H5Lunpack_elink_val(NULL, (size_t)1000, NULL, NULL, NULL) >= 0) TEST_ERROR } H5E_END_TRY PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_query() */ @@ -5437,17 +5083,13 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Wednesday, January 18, 2006 - * *------------------------------------------------------------------------- */ static int external_link_unlink_compact(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ @@ -5479,9 +5121,6 @@ external_link_unlink_compact(hid_t fapl, hbool_t new_format) /* Close file */ if(H5Fclose(fid) < 0) TEST_ERROR - -/* Unlink external link */ - /* Open first file */ if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR @@ -5504,7 +5143,7 @@ external_link_unlink_compact(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -5512,7 +5151,7 @@ error: H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_unlink_compact() */ @@ -5523,25 +5162,21 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Wednesday, January 18, 2006 - * *------------------------------------------------------------------------- */ static int external_link_unlink_dense(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gcpl = (-1); /* Group creation property list ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + hid_t fid = -1; /* File ID */ + hid_t gcpl = -1; /* Group creation property list ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ unsigned nmsgs; /* Number of messages in group's header */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - unsigned u; /* Local index variable */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + unsigned u; /* Local index variable */ if(new_format) TESTING("unlinking external link in dense group (w/new group format)") @@ -5606,9 +5241,6 @@ external_link_unlink_dense(hid_t fapl, hbool_t new_format) /* Close file */ if(H5Fclose(fid) < 0) TEST_ERROR - -/* Unlink external link */ - /* Open first file */ if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR @@ -5650,7 +5282,7 @@ external_link_unlink_dense(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -5658,7 +5290,7 @@ error: H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_unlink_dense() */ @@ -5669,20 +5301,16 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, December 5, 2005 - * *------------------------------------------------------------------------- */ -static int -external_link_move(hid_t fapl, hbool_t new_format) -{ - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ +static int +external_link_move(hid_t fapl, hbool_t new_format) +{ + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ if(new_format) TESTING("move external link (w/new group format)") @@ -5712,9 +5340,7 @@ external_link_move(hid_t fapl, hbool_t new_format) /* Close file */ if(H5Fclose(fid) < 0) TEST_ERROR - /* Move external link to different name within same group */ - /* Open first file */ if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR @@ -5798,7 +5424,6 @@ external_link_move(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Move external link back to original group */ - /* Open first file */ if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR @@ -5841,7 +5466,7 @@ external_link_move(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -5849,7 +5474,7 @@ error: H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_move() */ @@ -5861,25 +5486,21 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Wednesday, January 18, 2006 - * *------------------------------------------------------------------------- */ static int external_link_ride(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gcpl = (-1); /* Group creation property list ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + hid_t fid = -1; /* File ID */ + hid_t gcpl = -1; /* Group creation property list ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE], + filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ unsigned nmsgs; /* Number of messages in group's header */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - unsigned u; /* Local index variable */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + unsigned u; /* Local index variable */ if(new_format) TESTING("external link along for the ride (w/new group format)") @@ -6026,7 +5647,7 @@ external_link_ride(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -6035,7 +5656,7 @@ error: H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_ride() */ @@ -6047,10 +5668,6 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: James Laird - * Wednesday, August 16, 2006 - * *------------------------------------------------------------------------- */ static int @@ -6060,11 +5677,11 @@ external_link_closing(hid_t fapl, hbool_t new_format) hid_t gid=(-1), tid=(-1), tid2=(-1), sid=(-1), did=(-1); hid_t lcpl_id=(-1); hsize_t dims[2]; - char filename1[NAME_BUF_SIZE], + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - filename4[NAME_BUF_SIZE], /* Names of files to externally link across */ - buf[NAME_BUF_SIZE]; /* misc. buffer */ + filename3[NAME_BUF_SIZE], + filename4[NAME_BUF_SIZE], /* Names of files to externally link across */ + buf[NAME_BUF_SIZE]; /* misc. buffer */ H5L_info_t li; H5O_info_t oi; hobj_ref_t obj_ref; @@ -6254,7 +5871,7 @@ external_link_closing(hid_t fapl, hbool_t new_format) PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -6268,7 +5885,7 @@ error: H5Fclose(fid2); H5Fclose(fid1); } H5E_END_TRY; - return -1; + return FAIL; } /* external_link_closing() */ @@ -6281,19 +5898,15 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: James Laird - * Tuesday, June 6, 2006 - * *------------------------------------------------------------------------- */ static int external_link_endian(hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - hid_t lapl_id = (-1); /* Prop List ID */ - const char *pathbuf = H5_get_srcdir(); /* Path to the files */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + hid_t lapl_id = -1; /* Prop List ID */ + const char *pathbuf = H5_get_srcdir(); /* Path to the files */ const char *namebuf; if(new_format) @@ -6335,7 +5948,7 @@ external_link_endian(hbool_t new_format) PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -6343,7 +5956,7 @@ error: H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } @@ -6355,10 +5968,6 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, March 5, 2007 - * *------------------------------------------------------------------------- */ static int @@ -6368,7 +5977,7 @@ external_link_strong(hid_t fapl, hbool_t new_format) hid_t fid1 = (-1), fid2 = (-1); /* File ID */ hid_t gid1 = (-1), gid2 = (-1); /* Group IDs */ char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; if(new_format) @@ -6417,7 +6026,7 @@ external_link_strong(hid_t fapl, hbool_t new_format) if(H5Pclose(my_fapl) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -6428,7 +6037,7 @@ error: H5Fclose(fid2); H5Fclose(fid1); } H5E_END_TRY; - return -1; + return FAIL; } /* end external_link_strong() */ @@ -6440,10 +6049,6 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Nov. 23, 2009 - * *------------------------------------------------------------------------- */ static int @@ -6452,17 +6057,17 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) #ifdef H5_HAVE_SYMLINK hid_t file1 = -1, file2 = -1, file3 = -1, file4 = -1, file5 = -1; hid_t group2 = -1, group3 = -1, group4 = -1, group5 = -1; - char filename1[NAME_BUF_SIZE], - filename2a[NAME_BUF_SIZE], - filename2b[NAME_BUF_SIZE], - filename3a[NAME_BUF_SIZE], - filename3b[NAME_BUF_SIZE], - filename4a[NAME_BUF_SIZE], - filename4b[NAME_BUF_SIZE], - filename5a[NAME_BUF_SIZE], - filename5b[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; + char filename1[NAME_BUF_SIZE], + filename2a[NAME_BUF_SIZE], + filename2b[NAME_BUF_SIZE], + filename3a[NAME_BUF_SIZE], + filename3b[NAME_BUF_SIZE], + filename4a[NAME_BUF_SIZE], + filename4b[NAME_BUF_SIZE], + filename5a[NAME_BUF_SIZE], + filename5b[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; hbool_t have_posix_compat_vfd; /* Whether VFD used is compatible w/POSIX I/O calls */ #endif /* H5_HAVE_SYMLINK */ @@ -6518,7 +6123,6 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[50], fapl, filename5a, sizeof(filename5a)); h5_fixname(FILENAME[51], fapl, filename5b, sizeof(filename5b)); - /* Create file #1 in current directory */ if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR @@ -6528,7 +6132,6 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) /* Close file #1 */ if(H5Fclose(file1) < 0) TEST_ERROR - /* Create file #2 in tmp directory #2 */ if((file2 = H5Fcreate(filename2a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR if(H5Fclose(file2) < 0) TEST_ERROR @@ -6548,7 +6151,6 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) /* Close file #2 */ if(H5Fclose(file2) < 0) TEST_ERROR - /* Create file #3 in temp. directory #2 */ if((file3 = H5Fcreate(filename3a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR @@ -6564,7 +6166,6 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) /* Close file #3 */ if(H5Fclose(file3) < 0) TEST_ERROR - /* Create file #4 in temporary directory #1 */ if((file4 = H5Fcreate(filename4b, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR @@ -6580,7 +6181,6 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) /* Close file #4 */ if(H5Fclose(file4) < 0) TEST_ERROR - /* Create file #5 in temporary directory #1 */ if((file5 = H5Fcreate(filename5a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR @@ -6591,7 +6191,6 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) /* Close file #5 */ if(H5Fclose(file5) < 0) TEST_ERROR - /* Actual tests... */ /* Reopen file #1 */ @@ -6616,17 +6215,16 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) /* Close file #1 */ if(H5Fclose(file1) < 0) TEST_ERROR - PASSED(); } /* end if */ else { - SKIPPED(); - HDputs(" Current VFD doesn't support POSIX I/O calls"); + SKIPPED(); + HDputs(" Current VFD doesn't support POSIX I/O calls"); } /* end else */ - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Gclose(group5); H5Gclose(group4); @@ -6638,12 +6236,12 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) H5Fclose(file2); H5Fclose(file1); } H5E_END_TRY; - return -1; + return FAIL; #else /* H5_HAVE_SYMLINK */ SKIPPED(); HDputs(" Current file system or operating system doesn't support symbolic links"); - return 0; + return SUCCEED; #endif /* H5_HAVE_SYMLINK */ } /* end external_symlink() */ @@ -6658,18 +6256,14 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) * * Return: Success: 0 * Failure: -1 - * - * Programmer: Neil Fortner - * Wednesday, March 3, 2010 - * *------------------------------------------------------------------------- */ static int external_copy_invalid_object(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ - hid_t ocpyplid = (-1); /* Object copy plist ID */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + hid_t ocpyplid = -1; /* Object copy plist ID */ char filename[NAME_BUF_SIZE]; if(new_format) @@ -6708,7 +6302,7 @@ external_copy_invalid_object(hid_t fapl, hbool_t new_format) if(H5Pclose(ocpyplid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -6717,7 +6311,7 @@ error: H5Pclose(ocpyplid); } H5E_END_TRY - return -1; + return FAIL; } /* end external_copy_invalid_object */ @@ -6730,18 +6324,14 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Neil Fortner - * Wednesday, March 3, 2010 - * *------------------------------------------------------------------------- */ static int external_dont_fail_to_source(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ - hid_t oid = (-1); /* Object ID */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + hid_t oid = -1; /* Object ID */ char filename[NAME_BUF_SIZE]; if(new_format) @@ -6772,7 +6362,7 @@ external_dont_fail_to_source(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -6781,7 +6371,7 @@ error: H5Fclose(fid); } H5E_END_TRY - return -1; + return FAIL; } /* end external_dont_fail_to_source */ @@ -6794,21 +6384,17 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Neil Fortner - * Thursday, January 13, 2011 - * *------------------------------------------------------------------------- */ static int external_file_cache(hid_t fapl, hbool_t new_format) { - hid_t my_fapl = (-1); /* Temporary FAPL */ - hid_t fid1 = (-1); /* File ID */ - hid_t fid2 = (-1); /* File ID */ - hid_t fid3 = (-1); /* File ID */ - hid_t fid4 = (-1); /* File ID */ - hid_t oid = (-1); /* Object ID */ + hid_t my_fapl = -1; /* Temporary FAPL */ + hid_t fid1 = -1; /* File ID */ + hid_t fid2 = -1; /* File ID */ + hid_t fid3 = -1; /* File ID */ + hid_t fid4 = -1; /* File ID */ + hid_t oid = -1; /* Object ID */ unsigned efc_size; char filename1[NAME_BUF_SIZE]; char filename2[NAME_BUF_SIZE]; @@ -6827,333 +6413,229 @@ external_file_cache(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[3], fapl, filename4, sizeof filename4); /* Verify that the default EFC size is 0 */ - if(H5Pget_elink_file_cache_size(fapl, &efc_size) < 0) - TEST_ERROR + if(H5Pget_elink_file_cache_size(fapl, &efc_size) < 0) TEST_ERROR if(efc_size != 0) FAIL_PUTS_ERROR("default external file cache size is not 0") /* Copy FAPL and enable external file caching */ - if((my_fapl = H5Pcopy(fapl)) < 0) - TEST_ERROR - if(H5Pset_elink_file_cache_size(my_fapl, 8) < 0) - TEST_ERROR + if((my_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR + if(H5Pset_elink_file_cache_size(my_fapl, 8) < 0) TEST_ERROR /* Verify that the external file cache size has been set */ - if(H5Pget_elink_file_cache_size(my_fapl, &efc_size) < 0) - TEST_ERROR + if(H5Pget_elink_file_cache_size(my_fapl, &efc_size) < 0) TEST_ERROR if(efc_size != 8) FAIL_PUTS_ERROR("external file cache size different from expected") - - /* - * Test 1: One file caches another - */ + /* Test 1: One file caches another */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR /* Create link */ - if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close file 2 */ - if(H5Fclose(fid2) < 0) - TEST_ERROR + if(H5Fclose(fid2) < 0) TEST_ERROR /* Verify that only 1 file is open */ H5F_sfile_assert_num(1); /* Open and close the target of the external link */ - if((oid = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) - TEST_ERROR - if(H5Oclose(oid) < 0) - TEST_ERROR + if((oid = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Oclose(oid) < 0) TEST_ERROR /* Verify that both files are now open */ H5F_sfile_assert_num(2); /* Close file 1 */ - if(H5Fclose(fid1) < 0) - TEST_ERROR + if(H5Fclose(fid1) < 0) TEST_ERROR /* Verify that both files are now closed */ H5F_sfile_assert_num(0); - - /* - * Test 2: One file caches another, release parent's EFC - */ + /* Test 2: One file caches another, release parent's EFC */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR /* Create link */ - if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close file 2 */ - if(H5Fclose(fid2) < 0) - TEST_ERROR + if(H5Fclose(fid2) < 0) TEST_ERROR /* Verify that only 1 file is open */ H5F_sfile_assert_num(1); /* Open and close the target of the external link */ - if((oid = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) - TEST_ERROR - if(H5Oclose(oid) < 0) - TEST_ERROR + if((oid = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Oclose(oid) < 0) TEST_ERROR /* Verify that both files are now open */ H5F_sfile_assert_num(2); /* Release file 1's EFC */ - if(H5Fclear_elink_file_cache(fid1) < 0) - TEST_ERROR + if(H5Fclear_elink_file_cache(fid1) < 0) TEST_ERROR /* Verify that only the parent file is now open */ H5F_sfile_assert_num(1); /* Close file 1 */ - if(H5Fclose(fid1) < 0) - TEST_ERROR + if(H5Fclose(fid1) < 0) TEST_ERROR /* Verify that both files are now closed */ H5F_sfile_assert_num(0); - - /* - * Test 3: "Y" shaped tree - */ + /* Test 3: "Y" shaped tree */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR - if((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR /* Create links */ - if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lcreate_external(filename3, "/", fid2, "link_to_3", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lcreate_external(filename4, "/", fid2, "link_to_4", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_external(filename3, "/", fid2, "link_to_3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_external(filename4, "/", fid2, "link_to_4", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close files 2-4 */ - if(H5Fclose(fid2) < 0) - TEST_ERROR - if(H5Fclose(fid3) < 0) - TEST_ERROR - if(H5Fclose(fid4) < 0) - TEST_ERROR + if(H5Fclose(fid2) < 0) TEST_ERROR + if(H5Fclose(fid3) < 0) TEST_ERROR + if(H5Fclose(fid4) < 0) TEST_ERROR /* Verify that only 1 file is open */ H5F_sfile_assert_num(1); /* Open and close one branch of the tree */ - if((oid = H5Oopen(fid1, "link_to_2/link_to_3", H5P_DEFAULT)) < 0) - TEST_ERROR - if(H5Oclose(oid) < 0) - TEST_ERROR + if((oid = H5Oopen(fid1, "link_to_2/link_to_3", H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Oclose(oid) < 0) TEST_ERROR /* Verify that files 2 and 3 are now open */ H5F_sfile_assert_num(3); /* Open and close the other branch of the tree */ - if((oid = H5Oopen(fid1, "link_to_2/link_to_4", H5P_DEFAULT)) < 0) - TEST_ERROR - if(H5Oclose(oid) < 0) - TEST_ERROR + if((oid = H5Oopen(fid1, "link_to_2/link_to_4", H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Oclose(oid) < 0) TEST_ERROR /* Verify that all files are now open */ H5F_sfile_assert_num(4); /* Close file 1 */ - if(H5Fclose(fid1) < 0) - TEST_ERROR + if(H5Fclose(fid1) < 0) TEST_ERROR /* Verify that all files are now closed */ H5F_sfile_assert_num(0); - - /* - * Test 4: "Y" shaped tree, release parent's EFC - */ + /* Test 4: "Y" shaped tree, release parent's EFC */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR - if((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR /* Create links */ - if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lcreate_external(filename3, "/", fid2, "link_to_3", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lcreate_external(filename4, "/", fid2, "link_to_4", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_external(filename3, "/", fid2, "link_to_3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_external(filename4, "/", fid2, "link_to_4", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close files 2-4 */ - if(H5Fclose(fid2) < 0) - TEST_ERROR - if(H5Fclose(fid3) < 0) - TEST_ERROR - if(H5Fclose(fid4) < 0) - TEST_ERROR + if(H5Fclose(fid2) < 0) TEST_ERROR + if(H5Fclose(fid3) < 0) TEST_ERROR + if(H5Fclose(fid4) < 0) TEST_ERROR /* Verify that only 1 file is open */ H5F_sfile_assert_num(1); /* Open and close one branch of the tree */ - if((oid = H5Oopen(fid1, "link_to_2/link_to_3", H5P_DEFAULT)) < 0) - TEST_ERROR - if(H5Oclose(oid) < 0) - TEST_ERROR + if((oid = H5Oopen(fid1, "link_to_2/link_to_3", H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Oclose(oid) < 0) TEST_ERROR /* Verify that files 2 and 3 are now open */ H5F_sfile_assert_num(3); /* Open and close the other branch of the tree */ - if((oid = H5Oopen(fid1, "link_to_2/link_to_4", H5P_DEFAULT)) < 0) - TEST_ERROR - if(H5Oclose(oid) < 0) - TEST_ERROR + if((oid = H5Oopen(fid1, "link_to_2/link_to_4", H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Oclose(oid) < 0) TEST_ERROR /* Verify that all files are now open */ H5F_sfile_assert_num(4); /* Release file 1's EFC */ - if(H5Fclear_elink_file_cache(fid1) < 0) - TEST_ERROR + if(H5Fclear_elink_file_cache(fid1) < 0) TEST_ERROR /* Verify that only file 1 is now open */ H5F_sfile_assert_num(1); /* Close file 1 */ - if(H5Fclose(fid1) < 0) - TEST_ERROR + if(H5Fclose(fid1) < 0) TEST_ERROR /* Verify that all files are now closed */ H5F_sfile_assert_num(0); - /* - * Test 5: 3 file cycle - */ + /* Test 5: 3 file cycle */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR /* Create links */ - if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lcreate_external(filename3, "/", fid2, "link_to_3", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lcreate_external(filename1, "/", fid3, "link_to_1", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_external(filename3, "/", fid2, "link_to_3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_external(filename1, "/", fid3, "link_to_1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close files 2-3 */ - if(H5Fclose(fid2) < 0) - TEST_ERROR - if(H5Fclose(fid3) < 0) - TEST_ERROR + if(H5Fclose(fid2) < 0) TEST_ERROR + if(H5Fclose(fid3) < 0) TEST_ERROR /* Verify that only 1 file is open */ H5F_sfile_assert_num(1); /* Open and close one complete cycle */ - if((oid = H5Oopen(fid1, "link_to_2/link_to_3/link_to_1", H5P_DEFAULT)) < 0) - TEST_ERROR - if(H5Oclose(oid) < 0) - TEST_ERROR + if((oid = H5Oopen(fid1, "link_to_2/link_to_3/link_to_1", H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Oclose(oid) < 0) TEST_ERROR /* Verify that all files are now open */ H5F_sfile_assert_num(3); /* Close file 1 */ - if(H5Fclose(fid1) < 0) - TEST_ERROR + if(H5Fclose(fid1) < 0) TEST_ERROR /* Verify that all files are now closed */ H5F_sfile_assert_num(0); - - /* - * Test 6: 3 file cycle, release parent's EFC - */ + /* Test 6: 3 file cycle, release parent's EFC */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR /* Create links */ - if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lcreate_external(filename3, "/", fid2, "link_to_3", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lcreate_external(filename1, "/", fid3, "link_to_1", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_external(filename3, "/", fid2, "link_to_3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_external(filename1, "/", fid3, "link_to_1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close files 2-3 */ - if(H5Fclose(fid2) < 0) - TEST_ERROR - if(H5Fclose(fid3) < 0) - TEST_ERROR + if(H5Fclose(fid2) < 0) TEST_ERROR + if(H5Fclose(fid3) < 0) TEST_ERROR /* Verify that only 1 file is open */ H5F_sfile_assert_num(1); /* Open and close one complete cycle */ - if((oid = H5Oopen(fid1, "link_to_2/link_to_3/link_to_1", H5P_DEFAULT)) < 0) - TEST_ERROR - if(H5Oclose(oid) < 0) - TEST_ERROR + if((oid = H5Oopen(fid1, "link_to_2/link_to_3/link_to_1", H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Oclose(oid) < 0) TEST_ERROR /* Verify that all files are now open */ H5F_sfile_assert_num(3); /* Release file 1's EFC */ - if(H5Fclear_elink_file_cache(fid1) < 0) - TEST_ERROR + if(H5Fclear_elink_file_cache(fid1) < 0) TEST_ERROR /* Verify that only file 1 is now open */ H5F_sfile_assert_num(1); /* Close file 1 */ - if(H5Fclose(fid1) < 0) - TEST_ERROR + if(H5Fclose(fid1) < 0) TEST_ERROR /* Verify that all files are now closed */ H5F_sfile_assert_num(0); @@ -7162,7 +6644,7 @@ external_file_cache(hid_t fapl, hbool_t new_format) H5Pclose(my_fapl); PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -7174,7 +6656,7 @@ error: H5Pclose(my_fapl); } H5E_END_TRY - return -1; + return FAIL; } /* end external_file_cache */ @@ -7186,21 +6668,17 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Neil Fortner - * Saturday, April 30, 2011 - * *------------------------------------------------------------------------- */ static int external_open_twice(hid_t fapl, hbool_t new_format) { - hid_t fid1 = (-1); /* File ID */ - hid_t fid2 = (-1); /* File ID */ - hid_t oid1 = (-1); /* Object ID */ - hid_t oid2 = (-1); /* Object ID */ - hid_t type = (-1); /* Datatype ID */ - hid_t space = (-1); /* Dataspace ID */ + hid_t fid1 = -1; /* File ID */ + hid_t fid2 = -1; /* File ID */ + hid_t oid1 = -1; /* Object ID */ + hid_t oid2 = -1; /* Object ID */ + hid_t type = -1; /* Datatype ID */ + hid_t space = -1; /* Dataspace ID */ char filename1[NAME_BUF_SIZE]; char filename2[NAME_BUF_SIZE]; @@ -7213,192 +6691,123 @@ external_open_twice(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); - - /* - * Test 1: Open root group twice - */ + /* Test 1: Open root group twice */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create link */ - if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close file 2 */ - if(H5Fclose(fid2) < 0) - TEST_ERROR + if(H5Fclose(fid2) < 0) TEST_ERROR /* Open the target of the external link twice */ - if((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) - TEST_ERROR - if((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) - TEST_ERROR + if((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR + if((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR - /* Close both objects, in the reverse opening order (necessary to duplicate - * bug */ - if(H5Oclose(oid2) < 0) - TEST_ERROR - if(H5Oclose(oid1) < 0) - TEST_ERROR + /* Close both objects, in the reverse opening order (necessary to duplicate bug */ + if(H5Oclose(oid2) < 0) TEST_ERROR + if(H5Oclose(oid1) < 0) TEST_ERROR /* Close file 1 */ - if(H5Fclose(fid1) < 0) - TEST_ERROR + if(H5Fclose(fid1) < 0) TEST_ERROR /* Verify that both files are now closed */ H5F_sfile_assert_num(0); - - /* - * Test 2: Open group twice - */ + /* Test 2: Open group twice */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create target group */ - if((oid1 = H5Gcreate2(fid2, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) - < 0) - TEST_ERROR - if(H5Gclose(oid1) < 0) - TEST_ERROR + if((oid1 = H5Gcreate2(fid2, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Gclose(oid1) < 0) TEST_ERROR /* Create link */ - if(H5Lcreate_external(filename2, "/group", fid1, "link_to_2", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcreate_external(filename2, "/group", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close file 2 */ - if(H5Fclose(fid2) < 0) - TEST_ERROR + if(H5Fclose(fid2) < 0) TEST_ERROR /* Open the target of the external link twice */ - if((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) - TEST_ERROR - if((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) - TEST_ERROR + if((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR + if((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR - /* Close both objects, in the reverse opening order (necessary to duplicate - * bug */ - if(H5Oclose(oid2) < 0) - TEST_ERROR - if(H5Oclose(oid1) < 0) - TEST_ERROR + /* Close both objects, in the reverse opening order (necessary to duplicate bug */ + if(H5Oclose(oid2) < 0) TEST_ERROR + if(H5Oclose(oid1) < 0) TEST_ERROR /* Close file 1 */ - if(H5Fclose(fid1) < 0) - TEST_ERROR + if(H5Fclose(fid1) < 0) TEST_ERROR /* Verify that both files are now closed */ H5F_sfile_assert_num(0); - - /* - * Test 3: Open dataset twice - */ + /* Test 3: Open dataset twice */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create target dataset */ - if((space = H5Screate(H5S_SCALAR)) < 0) - TEST_ERROR - if((oid1 = H5Dcreate2(fid2, "dset", H5T_NATIVE_INT, space, H5P_DEFAULT, - dcpl_g, H5P_DEFAULT)) < 0) - TEST_ERROR - if(H5Dclose(oid1) < 0) - TEST_ERROR - if(H5Sclose(space) < 0) - TEST_ERROR + if((space = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR + if((oid1 = H5Dcreate2(fid2, "dset", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Dclose(oid1) < 0) TEST_ERROR + if(H5Sclose(space) < 0) TEST_ERROR /* Create link */ - if(H5Lcreate_external(filename2, "/dset", fid1, "link_to_2", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcreate_external(filename2, "/dset", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close file 2 */ - if(H5Fclose(fid2) < 0) - TEST_ERROR + if(H5Fclose(fid2) < 0) TEST_ERROR /* Open the target of the external link twice */ - if((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) - TEST_ERROR - if((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) - TEST_ERROR + if((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR + if((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR - /* Close both objects, in the reverse opening order (necessary to duplicate - * bug */ - if(H5Oclose(oid2) < 0) - TEST_ERROR - if(H5Oclose(oid1) < 0) - TEST_ERROR + /* Close both objects, in the reverse opening order (necessary to duplicate bug */ + if(H5Oclose(oid2) < 0) TEST_ERROR + if(H5Oclose(oid1) < 0) TEST_ERROR /* Close file 1 */ - if(H5Fclose(fid1) < 0) - TEST_ERROR + if(H5Fclose(fid1) < 0) TEST_ERROR /* Verify that both files are now closed */ H5F_sfile_assert_num(0); - - /* - * Test 4: Open datatype twice - */ + /* Test 4: Open datatype twice */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Create target datatype */ - if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) - TEST_ERROR - if(H5Tcommit2(fid2, "dtype", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) - < 0) - TEST_ERROR - if(H5Tclose(type) < 0) - TEST_ERROR + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create target datatype */ + if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR + if(H5Tcommit2(fid2, "dtype", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Tclose(type) < 0) TEST_ERROR /* Create link */ - if(H5Lcreate_external(filename2, "/dtype", fid1, "link_to_2", H5P_DEFAULT, - H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcreate_external(filename2, "/dtype", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close file 2 */ - if(H5Fclose(fid2) < 0) - TEST_ERROR + if(H5Fclose(fid2) < 0) TEST_ERROR /* Open the target of the external link twice */ - if((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) - TEST_ERROR - if((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) - TEST_ERROR + if((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR + if((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR - /* Close both objects, in the reverse opening order (necessary to duplicate - * bug */ - if(H5Oclose(oid2) < 0) - TEST_ERROR - if(H5Oclose(oid1) < 0) - TEST_ERROR + /* Close both objects, in the reverse opening order (necessary to duplicate bug */ + if(H5Oclose(oid2) < 0) TEST_ERROR + if(H5Oclose(oid1) < 0) TEST_ERROR /* Close file 1 */ - if(H5Fclose(fid1) < 0) - TEST_ERROR + if(H5Fclose(fid1) < 0) TEST_ERROR /* Verify that both files are now closed */ H5F_sfile_assert_num(0); - PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -7410,7 +6819,7 @@ error: H5Sclose(space); } H5E_END_TRY - return -1; + return FAIL; } /* end external_open_twice() */ @@ -7437,23 +6846,23 @@ static int external_link_with_committed_datatype(hid_t fapl, hbool_t new_format) { hid_t fid1 = -1, fid2 = -1; /* File IDs */ - hid_t gid1 = -1, gid2 = -1; /* Group IDs */ - hid_t tid = -1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t sid2 = -1; /* Dataspace ID */ - hid_t aid = -1; /* Attribute ID */ - hid_t atid = -1; /* Attribute's datatype ID */ - hid_t did = -1; /* Dataset ID */ - hid_t dtid = -1; /* Dataset's datatype ID */ - hid_t dcpl = -1; /* Dataset creation property list */ - int wdata = 99; /* Attribute data written */ - int wbuf[60]; /* Data buffer for writing */ - int rbuf[60]; /* Data buffer for reading */ - int i; /* Local index variable */ + hid_t gid1 = -1, gid2 = -1; /* Group IDs */ + hid_t tid = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t sid2 = -1; /* Dataspace ID */ + hid_t aid = -1; /* Attribute ID */ + hid_t atid = -1; /* Attribute's datatype ID */ + hid_t did = -1; /* Dataset ID */ + hid_t dtid = -1; /* Dataset's datatype ID */ + hid_t dcpl = -1; /* Dataset creation property list */ + int wdata = 99; /* Attribute data written */ + int wbuf[60]; /* Data buffer for writing */ + int rbuf[60]; /* Data buffer for reading */ + int i; /* Local index variable */ char filename1[NAME_BUF_SIZE]; /* File name for main file */ char filename2[NAME_BUF_SIZE]; /* File name for target file */ - hsize_t dims[2] = {5, 12}; /* Dimension sizes */ - hsize_t chunks[2] = {3, 7}; /* Chunk sizes */ + hsize_t dims[2] = {5, 12}; /* Dimension sizes */ + hsize_t chunks[2] = {3, 7}; /* Chunk sizes */ if(new_format) TESTING("attach committed datatype to external group's attribute/dataset(w/new group format)") @@ -7464,209 +6873,157 @@ external_link_with_committed_datatype(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); - /* Main file */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - FAIL_STACK_ERROR + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Create external link from main file to target file */ - if(H5Lcreate_external(filename2, "target_group", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) - FAIL_STACK_ERROR - + if(H5Lcreate_external(filename2, "target_group", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Create target file */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - FAIL_STACK_ERROR + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Create group in target file */ - if((gid2 = H5Gcreate2(fid2, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if((gid2 = H5Gcreate2(fid2, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Close the group */ - if(H5Gclose(gid2) < 0) - FAIL_STACK_ERROR + if(H5Gclose(gid2) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid2) < 0) - FAIL_STACK_ERROR + if(H5Fclose(fid2) < 0) FAIL_STACK_ERROR /* Open the group which is externally linked to target file */ - if((gid1 = H5Gopen2(fid1, "link_to_2", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if((gid1 = H5Gopen2(fid1, "link_to_2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Create a copy of integer datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) - FAIL_STACK_ERROR + if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) FAIL_STACK_ERROR /* Commit the datatype to the main file root group */ - if(H5Tcommit2(fid1, "myDatatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) - FAIL_STACK_ERROR + if(H5Tcommit2(fid1, "myDatatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Create dataspace */ - if((sid = H5Screate(H5S_SCALAR)) < 0) - FAIL_STACK_ERROR + if((sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR /* Attach an attribute with the committed datatype to the group */ - if((aid = H5Acreate2(gid1, "myAttribute", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if((aid = H5Acreate2(gid1, "myAttribute", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Write data to the attribute */ - if(H5Awrite(aid, tid, &wdata) < 0) - FAIL_STACK_ERROR + if(H5Awrite(aid, tid, &wdata) < 0) FAIL_STACK_ERROR /* Get the attribute's datatype */ - if((atid = H5Aget_type(aid)) < 0) - FAIL_STACK_ERROR + if((atid = H5Aget_type(aid)) < 0) FAIL_STACK_ERROR /* Verify the datatype is not committed */ - if(H5Tcommitted(atid) == TRUE) - FAIL_STACK_ERROR + if(H5Tcommitted(atid) == TRUE) FAIL_STACK_ERROR /* Close the attribute */ - if(H5Aclose(aid) < 0) - FAIL_STACK_ERROR + if(H5Aclose(aid) < 0) FAIL_STACK_ERROR /* Create a chunked dataset */ - if((sid2 = H5Screate_simple(2, dims, NULL)) < 0) - FAIL_STACK_ERROR + if((sid2 = H5Screate_simple(2, dims, NULL)) < 0) FAIL_STACK_ERROR if (dcpl_g == H5P_DEFAULT) dcpl = H5Pcreate(H5P_DATASET_CREATE); else dcpl = H5Pcopy(dcpl_g); if (0 > dcpl) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl, 2, chunks) < 0) - FAIL_STACK_ERROR + if(H5Pset_chunk(dcpl, 2, chunks) < 0) FAIL_STACK_ERROR /* Initialize data buffers */ for(i = 0; i < 60; i++) { - wbuf[i] = i; - rbuf[i] = 0; + wbuf[i] = i; + rbuf[i] = 0; } /* Create a dataset with the committed datatype in the group */ - if((did = H5Dcreate2(gid1, "myDataset", tid, sid2, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if((did = H5Dcreate2(gid1, "myDataset", tid, sid2, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Write to the dataset */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) - FAIL_STACK_ERROR + if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) FAIL_STACK_ERROR /* Get the dataset's datatype */ - if((dtid = H5Dget_type(did)) < 0) - FAIL_STACK_ERROR + if((dtid = H5Dget_type(did)) < 0) FAIL_STACK_ERROR /* Verify the datatype is not committed */ - if(H5Tcommitted(dtid) == TRUE) - FAIL_STACK_ERROR + if(H5Tcommitted(dtid) == TRUE) FAIL_STACK_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + if(H5Dclose(did) < 0) FAIL_STACK_ERROR /* Close the dataset creation property list */ - if(H5Pclose(dcpl) < 0) - FAIL_STACK_ERROR + if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR /* Close the dataspaces */ - if(H5Sclose(sid) < 0) - FAIL_STACK_ERROR - if(H5Sclose(sid2) < 0) - FAIL_STACK_ERROR + if(H5Sclose(sid) < 0) FAIL_STACK_ERROR + if(H5Sclose(sid2) < 0) FAIL_STACK_ERROR /* Close the datatypes */ - if(H5Tclose(tid) < 0) - FAIL_STACK_ERROR - if(H5Tclose(atid) < 0) - FAIL_STACK_ERROR - if(H5Tclose(dtid) < 0) - FAIL_STACK_ERROR + if(H5Tclose(tid) < 0) FAIL_STACK_ERROR + if(H5Tclose(atid) < 0) FAIL_STACK_ERROR + if(H5Tclose(dtid) < 0) FAIL_STACK_ERROR /* Close the group */ - if(H5Gclose(gid1) < 0) - FAIL_STACK_ERROR + if(H5Gclose(gid1) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid1) < 0) - FAIL_STACK_ERROR - + if(H5Fclose(fid1) < 0) FAIL_STACK_ERROR /* Open the mainfile */ - if((fid1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) - FAIL_STACK_ERROR + if((fid1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Open the committed datatype in the mainfile */ - if((tid = H5Topen2(fid1, "myDatatype", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if((tid = H5Topen2(fid1, "myDatatype", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Verify the datatype is committed */ - if(H5Tcommitted(tid) == FALSE) - FAIL_STACK_ERROR + if(H5Tcommitted(tid) == FALSE) FAIL_STACK_ERROR /* Open the group which is externally linked to target file */ - if((gid1 = H5Gopen2(fid1, "link_to_2", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if((gid1 = H5Gopen2(fid1, "link_to_2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Open the attribute attached to the group */ - if((aid = H5Aopen(gid1, "myAttribute", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if((aid = H5Aopen(gid1, "myAttribute", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Get the attribute's datatype */ - if((atid = H5Aget_type(aid)) < 0) - FAIL_STACK_ERROR + if((atid = H5Aget_type(aid)) < 0) FAIL_STACK_ERROR /* Verify the attribute's datatype is not committed */ - if(H5Tcommitted(atid) == TRUE) - FAIL_STACK_ERROR + if(H5Tcommitted(atid) == TRUE) FAIL_STACK_ERROR /* Close the attribute */ - if(H5Aclose(aid) < 0) - FAIL_STACK_ERROR + if(H5Aclose(aid) < 0) FAIL_STACK_ERROR /* Delete the attribute */ - if(H5Adelete(gid1, "myAttribute") < 0) - FAIL_STACK_ERROR + if(H5Adelete(gid1, "myAttribute") < 0) FAIL_STACK_ERROR /* Open the dataset in the group */ - if((did = H5Dopen2(gid1, "myDataset", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if((did = H5Dopen2(gid1, "myDataset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Get the dataset's datatype */ - if((dtid = H5Dget_type(did)) < 0) - FAIL_STACK_ERROR + if((dtid = H5Dget_type(did)) < 0) FAIL_STACK_ERROR /* Verify the dataset's datatype is not committed */ - if(H5Tcommitted(dtid) == TRUE) - FAIL_STACK_ERROR + if(H5Tcommitted(dtid) == TRUE) FAIL_STACK_ERROR /* Read the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - FAIL_STACK_ERROR + if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR /* Compare the data read should be the same as wbuf */ - if(HDmemcmp(wbuf, rbuf, sizeof(wbuf)) != 0) - FAIL_STACK_ERROR + if(HDmemcmp(wbuf, rbuf, sizeof(wbuf)) != 0) FAIL_STACK_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + if(H5Dclose(did) < 0) FAIL_STACK_ERROR /* Close the group */ - if(H5Gclose(gid1) < 0) - FAIL_STACK_ERROR + if(H5Gclose(gid1) < 0) FAIL_STACK_ERROR /* Close the datatypes */ - if(H5Tclose(tid) < 0) - FAIL_STACK_ERROR - if(H5Tclose(atid) < 0) - FAIL_STACK_ERROR - if(H5Tclose(dtid) < 0) - FAIL_STACK_ERROR + if(H5Tclose(tid) < 0) FAIL_STACK_ERROR + if(H5Tclose(atid) < 0) FAIL_STACK_ERROR + if(H5Tclose(dtid) < 0) FAIL_STACK_ERROR /* Close the file */ if(H5Fclose(fid1) < 0) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -7685,10 +7042,10 @@ error: H5Aclose(atid); H5Aclose(dtid); - H5Pclose(dcpl); + H5Pclose(dcpl); } H5E_END_TRY - return -1; + return FAIL; } /* end external_link_with_committed_datatype() */ @@ -7700,10 +7057,6 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: James Laird - * Tuesday, June 6, 2006 - * *------------------------------------------------------------------------- */ /* Callback functions for UD hard links. */ @@ -7770,7 +7123,7 @@ done: case H5I_SPACE_SEL_ITER: case H5I_NTYPES: default: - return -1; + return FAIL; } /* end switch */ } /* end if */ @@ -7787,7 +7140,7 @@ UD_hard_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, hid_t ret_value = -1; if(udata_size != sizeof(haddr_t)) - return -1; + return FAIL; addr = *((const haddr_t *) udata); @@ -7859,7 +7212,7 @@ done: case H5I_SPACE_SEL_ITER: case H5I_NTYPES: default: - return -1; + return FAIL; } /* end switch */ } /* end if */ @@ -7881,12 +7234,12 @@ const H5L_class_t UD_hard_class[1] = {{ static int ud_hard_links(hid_t fapl) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - H5L_info_t li; /* Link information */ - char objname[NAME_BUF_SIZE]; /* Object name */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + H5L_info_t li; /* Link information */ + char objname[NAME_BUF_SIZE]; /* Object name */ h5_stat_size_t empty_size; /* Size of an empty file */ - char filename[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; TESTING("user-defined hard link (w/new group format)") @@ -7920,7 +7273,6 @@ ud_hard_links(hid_t fapl) if(H5Gclose(gid) < 0) TEST_ERROR - /* Create a user-defined "hard link" to the group using the address we got * from H5Lget_info */ if(H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_HARD_TYPE, &(li.u.address), (size_t)sizeof(haddr_t), H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -7958,9 +7310,9 @@ ud_hard_links(hid_t fapl) /* UD hard links have no query function, thus return a "link length" of 0 */ if(li.u.val_size != 0) TEST_ERROR if(UD_HARD_TYPE != li.type) { - H5_FAILED(); - HDputs(" Unexpected link class - should have been a UD hard link"); - goto error; + H5_FAILED(); + HDputs(" Unexpected link class - should have been a UD hard link"); + goto error; } /* end if */ /* Unlink the group pointed to by the UD link. It shouldn't be @@ -7987,15 +7339,15 @@ ud_hard_links(hid_t fapl) if(H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end ud_hard_links() */ @@ -8007,10 +7359,6 @@ ud_hard_links(hid_t fapl) * * Return: Success: 0 * Failure: -1 - * - * Programmer: James Laird - * Tuesday, June 6, 2006 - * *------------------------------------------------------------------------- */ /* A traversal function that ignores any udata and simply opens an object @@ -8028,7 +7376,7 @@ UD_rereg_traverse(const char H5_ATTR_UNUSED * link_name, hid_t cur_group, return ret_value; error: - return -1; + return FAIL; } /* end UD_rereg_traverse() */ /* This link class has the same ID number as the UD hard links but @@ -8048,23 +7396,23 @@ const H5L_class_t UD_rereg_class[1] = {{ static int ud_link_reregister(hid_t fapl) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - H5L_info_t li; /* Link information */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE]; - h5_stat_size_t empty_size; /* Size of an empty file */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + H5L_info_t li; /* Link information */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; + h5_stat_size_t empty_size; /* Size of an empty file */ TESTING("registering a new class for existing UD links (w/new group format)") /* Set up filename and create file*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Get the size of the empty file for reference */ if(H5Fclose(fid) < 0) TEST_ERROR - if((empty_size=h5_get_file_size(filename, fapl))<0) TEST_ERROR + if((empty_size = h5_get_file_size(filename, fapl))<0) TEST_ERROR if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR @@ -8103,9 +7451,9 @@ ud_link_reregister(hid_t fapl) /* Verify that we can't create any new links of this type */ H5E_BEGIN_TRY { - if(H5Lcreate_ud(fid, "ud_link2", (H5L_type_t)UD_HARD_TYPE, &(li.u.address), + if(H5Lcreate_ud(fid, "ud_link2", (H5L_type_t)UD_HARD_TYPE, &(li.u.address), sizeof(li.u.address), H5P_DEFAULT, H5P_DEFAULT) >= 0) - TEST_ERROR + TEST_ERROR } H5E_END_TRY /* Register a new kind of link with the same ID number */ @@ -8173,15 +7521,15 @@ ud_link_reregister(hid_t fapl) if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end ud_link_reregister() */ @@ -8193,10 +7541,6 @@ ud_link_reregister(hid_t fapl) * * Return: Success: 0 * Failure: -1 - * - * Programmer: James Laird - * Tuesday, June 6, 2006 - * *------------------------------------------------------------------------- */ /* Callback functions for UD "callback" links. */ @@ -8214,10 +7558,10 @@ UD_cb_create(const char * link_name, hid_t loc_group, const void *udata, if(HDstrcmp((const char *)udata, UD_CB_TARGET)) TEST_ERROR if(udata_size != UD_CB_TARGET_LEN) TEST_ERROR - return 0; + return SUCCEED; error: - return -1; + return FAIL; } /* end UD_cb_create() */ static hid_t @@ -8241,7 +7585,7 @@ UD_cb_traverse(const char * link_name, hid_t cur_group, const void *udata, return ret_value; error: - return -1; + return FAIL; } /* end UD_cb_traverse() */ /* Callback for when the link is moved or renamed */ @@ -8257,10 +7601,10 @@ UD_cb_move(const char *new_name, hid_t new_loc, const void *udata, if(HDstrcmp((const char *)udata, UD_CB_TARGET)) TEST_ERROR if(udata_size != UD_CB_TARGET_LEN) TEST_ERROR - return 0; + return SUCCEED; error: - return -1; + return FAIL; } /* end UD_cb_move() */ /* Callback for when the link is deleted. Also called during move */ @@ -8276,10 +7620,10 @@ UD_cb_delete(const char *link_name, hid_t file, const void *udata, if(HDstrcmp((const char *)udata, UD_CB_TARGET)) TEST_ERROR if(udata_size != UD_CB_TARGET_LEN) TEST_ERROR - return 0; + return SUCCEED; error: - return -1; + return FAIL; } /* end UD_cb_delete() */ /* Callback for when the link is queried */ @@ -8303,7 +7647,7 @@ UD_cb_query(const char * link_name, const void *udata, size_t udata_size, return 16; error: - return -1; + return FAIL; } /* end UD_cb_query() */ const H5L_class_t UD_cb_class[1] = {{ @@ -8321,12 +7665,12 @@ const H5L_class_t UD_cb_class[1] = {{ static int ud_callbacks(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ - hid_t lcpl = (-1); /* Link Creation PL */ - H5L_info_t li; /* Link information */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + hid_t lcpl = -1; /* Link Creation PL */ + H5L_info_t li; /* Link information */ char ud_target_name[] = UD_CB_TARGET; /* Link target name */ - char filename[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; char query_buf[NAME_BUF_SIZE]; if(new_format) @@ -8349,8 +7693,7 @@ ud_callbacks(hid_t fapl, hbool_t new_format) * no problems. */ if(H5Lregister(UD_hard_class) < 0) TEST_ERROR - /* Register user-defined link class. This is the one we'll actually - * be using. */ + /* Register user-defined link class. This is the one we'll actually be using. */ if(H5Lregister(UD_cb_class) < 0) TEST_ERROR /* Check that registered link classes are, and unregistered ones aren't */ @@ -8392,7 +7735,6 @@ ud_callbacks(hid_t fapl, hbool_t new_format) /* Remove UD link */ if(H5Ldelete(fid, NEW_UD_CB_LINK_NAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - /* Test that the callbacks don't work if the link class is not registered */ /* Create a new link. Just for fun, give it a non-default character @@ -8430,7 +7772,7 @@ ud_callbacks(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -8438,7 +7780,7 @@ error: H5Gclose (gid); H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end ud_callbacks() */ @@ -8450,10 +7792,6 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: James Laird - * Tuesday, June 6, 2006 - * *------------------------------------------------------------------------- */ static hid_t @@ -8469,13 +7807,12 @@ UD_plist_traverse(const char H5_ATTR_UNUSED * link_name, hid_t cur_group, /* Get the name of the target from the property list. */ if(H5Pget(lapl_id, DEST_PROP_NAME, target) < 0) TEST_ERROR - if((ret_value = H5Oopen(cur_group, target, lapl_id)) < 0) - TEST_ERROR + if((ret_value = H5Oopen(cur_group, target, lapl_id)) < 0) TEST_ERROR return ret_value; error: - return -1; + return FAIL; } /* end UD_plist_traverse() */ const H5L_class_t UD_plist_class[1] = {{ @@ -8493,12 +7830,12 @@ const H5L_class_t UD_plist_class[1] = {{ static int lapl_udata(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - hid_t plist_id = (-1); /* Property List ID */ - char group_a_name[NAME_BUF_SIZE]; - char group_b_name[NAME_BUF_SIZE]; - char filename[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + hid_t plist_id = -1; /* Property List ID */ + char group_a_name[NAME_BUF_SIZE]; + char group_b_name[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; if(new_format) TESTING("user data passed through lapl (w/new group format)") @@ -8569,16 +7906,16 @@ lapl_udata(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Pclose (plist_id); H5Gclose (gid); H5Gclose (gid2); H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end lapl_udata() */ @@ -8590,10 +7927,6 @@ lapl_udata(hid_t fapl, hbool_t new_format) * * Return: Success: 0 * Failure: -1 - * - * Programmer: James Laird - * Tuesday, June 6, 2006 - * *------------------------------------------------------------------------- */ static herr_t @@ -8601,10 +7934,9 @@ UD_cbsucc_create(const char H5_ATTR_UNUSED * link_name, hid_t H5_ATTR_UNUSED loc const void *udata, size_t udata_size, hid_t H5_ATTR_UNUSED lcpl_id) { /* Check to make sure that this "soft link" has a target */ - if(udata_size < 1 || !udata) - return -1; + if(udata_size < 1 || !udata) return FAIL; - return 0; + return SUCCEED; } /* end UD_cbsucc_create() */ static hid_t @@ -8622,7 +7954,7 @@ UD_cbsucc_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, return ret_value; error: - return -1; + return FAIL; } /* end UD_cbsucc_traverse() */ /* Failure callback for when the link is moved or renamed */ @@ -8631,7 +7963,7 @@ UD_cbfail_move(const char H5_ATTR_UNUSED *new_name, hid_t H5_ATTR_UNUSED new_loc const void H5_ATTR_UNUSED *udata, size_t H5_ATTR_UNUSED udata_size) { /* This traversal function will always fail. */ - return -1; + return FAIL; } /* end UD_cbfail_move() */ /* SuccessCallback for when the link is moved or renamed */ @@ -8640,7 +7972,7 @@ UD_cbsucc_move(const char H5_ATTR_UNUSED *new_name, hid_t H5_ATTR_UNUSED new_loc const void H5_ATTR_UNUSED *udata, size_t H5_ATTR_UNUSED udata_size) { /* This traversal function will always succeed. */ - return 0; + return SUCCEED; } /* end UD_cbsucc_move() */ /* Callback for when the link is deleted. Also called during move */ @@ -8649,7 +7981,7 @@ UD_cbsucc_delete(const char H5_ATTR_UNUSED *link_name, hid_t H5_ATTR_UNUSED file const void H5_ATTR_UNUSED *udata, size_t H5_ATTR_UNUSED udata_size) { /* This callback will always succeed */ - return 0; + return SUCCEED; } /* end UD_cbsucc_delete() */ /* Callback for when the link is deleted. Also called during move */ @@ -8659,7 +7991,7 @@ UD_cbfail_delete(const char H5_ATTR_UNUSED *link_name, hid_t H5_ATTR_UNUSED file { /* This traversal function will always fail. */ /* Note: un-deletable links are in general a very bad idea! */ - return -1; + return FAIL; } /* end UD_cbfail_delete() */ /* Callback for when the link is queried */ @@ -8668,7 +8000,7 @@ UD_cbfail_query(const char H5_ATTR_UNUSED *link_name, const void H5_ATTR_UNUSED size_t H5_ATTR_UNUSED udata_size, void H5_ATTR_UNUSED *buf, size_t H5_ATTR_UNUSED buf_size) { /* This traversal function will always fail. */ - return -1; + return FAIL; } /* end UD_cbfail_query() */ /* Callback for when the link is queried */ @@ -8681,10 +8013,9 @@ UD_cbfail_on_write_query(const char H5_ATTR_UNUSED *link_name, const void H5_ATT * fails */ - if(buf != NULL) - return -1; + if(buf != NULL) return FAIL; - return 0; + return SUCCEED; } /* end UD_cbfail_on_write_query() */ /* Callback for when the link is queried */ @@ -8791,12 +8122,12 @@ const H5L_class_t UD_error4_class[1] = {{ static int ud_link_errors(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char group_name[NAME_BUF_SIZE]; - char filename[NAME_BUF_SIZE]; - char query_buf[NAME_BUF_SIZE]; - H5L_info_t li; /* Link information */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + char group_name[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; + char query_buf[NAME_BUF_SIZE]; + H5L_info_t li; /* Link information */ if(new_format) TESTING("user-defined link error conditions (w/new group format)") @@ -8809,10 +8140,10 @@ ud_link_errors(hid_t fapl, hbool_t new_format) /* Try to register some invalid link classes */ H5E_BEGIN_TRY { - if(H5Lregister(UD_error1_class) >= 0) TEST_ERROR - if(H5Lregister(UD_error2_class) >= 0) TEST_ERROR - if(H5Lregister(UD_error3_class) >= 0) TEST_ERROR - if(H5Lregister(UD_error4_class) >= 0) TEST_ERROR + if(H5Lregister(UD_error1_class) >= 0) TEST_ERROR + if(H5Lregister(UD_error2_class) >= 0) TEST_ERROR + if(H5Lregister(UD_error3_class) >= 0) TEST_ERROR + if(H5Lregister(UD_error4_class) >= 0) TEST_ERROR } H5E_END_TRY /* Register the UD plist class. */ @@ -8827,16 +8158,13 @@ ud_link_errors(hid_t fapl, hbool_t new_format) /* Try to create internally defined links with H5Lcreate_ud */ H5E_BEGIN_TRY { - if(H5Lcreate_ud(fid, "/ud_link", H5L_TYPE_HARD, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) >= 0) - TEST_ERROR - if(H5Lcreate_ud(fid, "/ud_link", H5L_TYPE_SOFT, "str", (size_t)4, H5P_DEFAULT, H5P_DEFAULT) >= 0) - TEST_ERROR + if(H5Lcreate_ud(fid, "/ud_link", H5L_TYPE_HARD, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR + if(H5Lcreate_ud(fid, "/ud_link", H5L_TYPE_SOFT, "str", (size_t)4, H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR } H5E_END_TRY /* Try to create a link with H5Lcreate_ud that has a NULL udata pointer, but a non-zero udata_size value */ H5E_BEGIN_TRY { - if(H5Lcreate_ud(fid, "/ud_link", (H5L_type_t)UD_CBFAIL_TYPE, NULL, 1, H5P_DEFAULT, H5P_DEFAULT) >= 0) - TEST_ERROR + if(H5Lcreate_ud(fid, "/ud_link", (H5L_type_t)UD_CBFAIL_TYPE, NULL, 1, H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR } H5E_END_TRY; /* Create a user-defined link to the group. */ @@ -8904,14 +8232,14 @@ ud_link_errors(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { H5Gclose (gid); H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end ud_link_errors() */ @@ -8922,28 +8250,21 @@ error: * by the user using the Link Access Property List. * * Return: Success: 0 - * * Failure: -1 - * - * Programmer: James Laird - * Tuesday, June 6, 2006 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int lapl_nlinks(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - hid_t plist = (-1); /* lapl ID */ - hid_t tid = (-1), sid = (-1), did = (-1); /* Other IDs */ - hid_t gapl = (-1), dapl = (-1), tapl = (-1); /* Other property lists */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE]; - size_t nlinks; /* nlinks for H5Pset_nlinks */ - hsize_t dims[2]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + hid_t plist = -1; /* lapl ID */ + hid_t tid = -1, sid = -1, did = -1; /* Other IDs */ + hid_t gapl = -1, dapl = -1, tapl = -1; /* Other property lists */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; + size_t nlinks; /* nlinks for H5Pset_nlinks */ + hsize_t dims[2]; if(new_format) TESTING("adjusting nlinks with LAPL (w/new group format)") @@ -8958,7 +8279,7 @@ lapl_nlinks(hid_t fapl, hbool_t new_format) /* Create file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create group with short name in file (used as target for links) */ if((gid = H5Gcreate2(fid, "final", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -8987,7 +8308,7 @@ lapl_nlinks(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR /* Open file */ - if((fid=H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create LAPL with higher-than-usual nlinks value */ /* Create a non-default lapl with udata set to point to the first group */ @@ -9041,7 +8362,6 @@ lapl_nlinks(hid_t fapl, hbool_t new_format) if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR if(HDstrcmp(objname, "/soft4")) TEST_ERROR - /* Test other functions that should use a LAPL */ nlinks = 20; if(H5Pset_nlinks(plist, nlinks) < 0) TEST_ERROR @@ -9074,7 +8394,6 @@ lapl_nlinks(hid_t fapl, hbool_t new_format) /* Close plist */ if(H5Pclose(plist) < 0) TEST_ERROR - /* Create a datatype and dataset as targets inside the group */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR if(H5Tcommit2(gid, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -9133,9 +8452,9 @@ lapl_nlinks(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Pclose(gapl); H5Pclose(dapl); @@ -9148,7 +8467,7 @@ lapl_nlinks(hid_t fapl, hbool_t new_format) H5Pclose(plist); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end lapl_nlinks() */ @@ -9159,21 +8478,17 @@ lapl_nlinks(hid_t fapl, hbool_t new_format) * * Return: Success: 0 * Failure: -1 - * - * Programmer: James Laird - * Tuesday, June 6, 2006 - * *------------------------------------------------------------------------- */ static int linkinfo(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ - hid_t tid = (-1); /* Type ID */ - hid_t sid = (-1), did = -(1); /* Dataspace and dataset IDs */ - H5L_info_t li; /* Link information */ - char filename[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + hid_t tid = -1; /* Type ID */ + hid_t sid = -1, did = -1; /* Dataspace and dataset IDs */ + H5L_info_t li; /* Link information */ + char filename[NAME_BUF_SIZE]; if(new_format) TESTING("link type field in H5Lget_info (w/new group format)") @@ -9226,16 +8541,16 @@ linkinfo(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; - error: +error: H5E_BEGIN_TRY { H5Tclose (tid); H5Dclose (did); H5Gclose (gid); H5Fclose (fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end linkinfo() */ @@ -9251,10 +8566,6 @@ linkinfo(hid_t fapl, hbool_t new_format) * * Return: Success: 0 * Failure: -1 - * - * Programmer: James Laird - * Thursday, August 17, 2006 - * *------------------------------------------------------------------------- */ static int @@ -9274,8 +8585,7 @@ check_all_closed(hid_t fapl, hbool_t new_format, int stopat) * To check this, try to create every file used in this test. If * a file is already open, creating it will fail. */ - for(x=0; FILENAME[x] != NULL && x < stopat; x++) - { + for(x=0; FILENAME[x] != NULL && x < stopat; x++) { h5_fixname(FILENAME[x], fapl, filename, sizeof filename); if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR @@ -9283,17 +8593,15 @@ check_all_closed(hid_t fapl, hbool_t new_format, int stopat) } PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end check_all_closed() */ - - /*------------------------------------------------------------------------- * Function: build_visit_file * @@ -9301,10 +8609,6 @@ error: * * Return: Success: >0, File ID for file built * Failure: -1 - * - * Programmer: Quincey Koziol - * Saturday, November 24, 2007 - * *------------------------------------------------------------------------- */ static hid_t @@ -9312,9 +8616,9 @@ build_visit_file(hid_t fapl) { hid_t fid = -1; /* File ID */ hid_t gid = -1, gid2 = -1; /* Group IDs */ - hid_t sid = (-1); /* Dataspace ID */ - hid_t did = (-1); /* Dataset ID */ - hid_t tid = (-1); /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + hid_t tid = -1; /* Datatype ID */ char filename[NAME_BUF_SIZE]; const char *pathname = H5_get_srcdir_filename(LINKED_FILE); /* Corrected test file name */ @@ -9333,7 +8637,6 @@ build_visit_file(hid_t fapl) if(H5Gclose(gid2) < 0) TEST_ERROR if(H5Gclose(gid) < 0) TEST_ERROR - /* Create soft links to groups created */ if(H5Lcreate_soft("/Group1", fid, "/soft_one", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR if(H5Lcreate_soft("/Group1/Group2", fid, "/soft_two", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -9341,7 +8644,6 @@ build_visit_file(hid_t fapl) /* Create dangling soft link */ if(H5Lcreate_soft("nowhere", fid, "/soft_dangle", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - /* Create hard links to all groups */ if(H5Lcreate_hard(fid, "/", fid, "hard_zero", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR if(H5Lcreate_hard(fid, "/Group1", fid, "hard_one", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -9390,7 +8692,7 @@ error: H5E_BEGIN_TRY { H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end build_visit_file() */ @@ -9401,15 +8703,10 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Saturday, November 24, 2007 - * *------------------------------------------------------------------------- */ static int -visit_link_cb(hid_t H5_ATTR_UNUSED group_id, const char *name, const H5L_info_t *linfo, - void *_op_data) +visit_link_cb(hid_t H5_ATTR_UNUSED group_id, const char *name, const H5L_info_t *linfo, void *_op_data) { lvisit_ud_t *op_data = (lvisit_ud_t *)_op_data; @@ -9431,10 +8728,6 @@ visit_link_cb(hid_t H5_ATTR_UNUSED group_id, const char *name, const H5L_info_t * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Saturday, November 24, 2007 - * *------------------------------------------------------------------------- */ static int @@ -9464,7 +8757,6 @@ link_visit(hid_t fapl, hbool_t new_format) if(H5Lvisit(gid, H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata) < 0) FAIL_STACK_ERROR if(H5Gclose(gid) < 0) FAIL_STACK_ERROR - /* Visit all the links reachable from each internal group */ if((gid = H5Gopen2(fid, "/Group1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR udata.idx = 0; @@ -9478,19 +8770,18 @@ link_visit(hid_t fapl, hbool_t new_format) if(H5Lvisit(gid, H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata) < 0) FAIL_STACK_ERROR if(H5Gclose(gid) < 0) FAIL_STACK_ERROR - /* Close file created */ if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end link_visit() */ @@ -9501,10 +8792,6 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Saturday, November 24, 2007 - * *------------------------------------------------------------------------- */ static int @@ -9534,7 +8821,6 @@ link_visit_by_name(hid_t fapl, hbool_t new_format) if(H5Lvisit_by_name(gid, ".", H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5Gclose(gid) < 0) FAIL_STACK_ERROR - /* Visit all the links reachable from each internal group */ udata.idx = 0; udata.info = lvisit1; @@ -9556,19 +8842,18 @@ link_visit_by_name(hid_t fapl, hbool_t new_format) if(H5Lvisit_by_name(gid, ".", H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5Gclose(gid) < 0) FAIL_STACK_ERROR - /* Close file created */ if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end link_visit_by_name() */ @@ -9579,15 +8864,10 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Sunday, November 25, 2007 - * *------------------------------------------------------------------------- */ static int -visit_obj_cb(hid_t H5_ATTR_UNUSED group_id, const char *name, const H5O_info_t *oinfo, - void *_op_data) +visit_obj_cb(hid_t H5_ATTR_UNUSED group_id, const char *name, const H5O_info_t *oinfo, void *_op_data) { ovisit_ud_t *op_data = (ovisit_ud_t *)_op_data; @@ -9609,10 +8889,6 @@ visit_obj_cb(hid_t H5_ATTR_UNUSED group_id, const char *name, const H5O_info_t * * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Sunday, November 25, 2007 - * *------------------------------------------------------------------------- */ static int @@ -9642,7 +8918,6 @@ obj_visit(hid_t fapl, hbool_t new_format) if(H5Ovisit2(gid, H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR if(H5Gclose(gid) < 0) FAIL_STACK_ERROR - /* Visit all the objects reachable from each internal group */ if((gid = H5Gopen2(fid, "/Group1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR udata.idx = 0; @@ -9656,19 +8931,18 @@ obj_visit(hid_t fapl, hbool_t new_format) if(H5Ovisit2(gid, H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR if(H5Gclose(gid) < 0) FAIL_STACK_ERROR - /* Close file created */ if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end obj_visit() */ @@ -9679,10 +8953,6 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Sunday, November 25, 2007 - * *------------------------------------------------------------------------- */ static int @@ -9712,7 +8982,6 @@ obj_visit_by_name(hid_t fapl, hbool_t new_format) if(H5Ovisit_by_name2(gid, ".", H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5Gclose(gid) < 0) FAIL_STACK_ERROR - /* Visit all the objects reachable from each internal group */ udata.idx = 0; udata.info = new_format ? ovisit1_new : ovisit1_old; @@ -9724,7 +8993,6 @@ obj_visit_by_name(hid_t fapl, hbool_t new_format) if(H5Ovisit_by_name2(gid, ".", H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5Gclose(gid) < 0) FAIL_STACK_ERROR - udata.idx = 0; udata.info = new_format ? ovisit2_new : ovisit2_old; if(H5Ovisit_by_name2(fid, "/Group1/Group2", H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR @@ -9735,19 +9003,18 @@ obj_visit_by_name(hid_t fapl, hbool_t new_format) if(H5Ovisit_by_name2(gid, ".", H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5Gclose(gid) < 0) FAIL_STACK_ERROR - /* Close file created */ if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end obj_visit_by_name() */ @@ -9757,15 +9024,10 @@ error: * Purpose: Callback routine for visiting objects in a file * * Return: 1 (H5_ITER_STOP) - * - * Programmer: Neil Fortner - * Sunday, November 2, 2008 - * *------------------------------------------------------------------------- */ static int -visit_obj_stop_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UNUSED *name, const H5O_info_t H5_ATTR_UNUSED *oinfo, - void *_op_data) +visit_obj_stop_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UNUSED *name, const H5O_info_t H5_ATTR_UNUSED *oinfo, void *_op_data) { unsigned *op_data = (unsigned *)_op_data; @@ -9784,10 +9046,6 @@ visit_obj_stop_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UNUSED *name * * Return: Success: 0 * Failure: -1 - * - * Programmer: Neil Fortner - * Sunday, November 2, 2008 - * *------------------------------------------------------------------------- */ static int @@ -9817,7 +9075,7 @@ obj_visit_stop(hid_t fapl, hbool_t new_format) /* Same test with H5Ovisit_by_name */ nvisited = 0; if((ret = H5Ovisit_by_name2(fid, "/", H5_INDEX_NAME, H5_ITER_INC, visit_obj_stop_cb, - &nvisited, H5O_INFO_BASIC, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + &nvisited, H5O_INFO_BASIC, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR if(ret != H5_ITER_STOP) TEST_ERROR if(nvisited != 1) TEST_ERROR @@ -9825,13 +9083,13 @@ obj_visit_stop(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end obj_visit_stop() */ @@ -9843,10 +9101,6 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Neil Fortner - * Tuesday, June 16, 2009 - * *------------------------------------------------------------------------- */ static enum { @@ -9859,14 +9113,11 @@ static enum { static htri_t link_filter_can_apply(hid_t dcpl_id, hid_t type_id, hid_t space_id) { - if(dcpl_id >= 0 || type_id >= 0 || space_id >= 0) - return -1; + if(dcpl_id >= 0 || type_id >= 0 || space_id >= 0) return -1; - if(link_filter_state >= LFS_ENCODED) - return 1; + if(link_filter_state >= LFS_ENCODED) return 1; - if(link_filter_state != LFS_INIT) - return -1; + if(link_filter_state != LFS_INIT) return -1; link_filter_state = LFS_CAN_APPLY_CALLED; @@ -9875,14 +9126,11 @@ static htri_t link_filter_can_apply(hid_t dcpl_id, hid_t type_id, hid_t space_id static herr_t link_filter_set_local(hid_t dcpl_id, hid_t type_id, hid_t space_id) { - if(dcpl_id >= 0 || type_id >= 0 || space_id >= 0) - return -1; + if(dcpl_id >= 0 || type_id >= 0 || space_id >= 0) return -1; - if(link_filter_state >= LFS_ENCODED) - return 0; + if(link_filter_state >= LFS_ENCODED) return 0; - if(link_filter_state != LFS_CAN_APPLY_CALLED) - return -1; + if(link_filter_state != LFS_CAN_APPLY_CALLED) return -1; link_filter_state = LFS_SET_LOCAL_CALLED; @@ -9893,19 +9141,16 @@ static size_t link_filter_filter(unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[], size_t nbytes, size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) { - if(flags & H5Z_FLAG_OPTIONAL || cd_nelmts != 1 || cd_values[0] != 2112) - return 0; + if(flags & H5Z_FLAG_OPTIONAL || cd_nelmts != 1 || cd_values[0] != 2112) return 0; - if(link_filter_state == LFS_DECODED) - return nbytes; + if(link_filter_state == LFS_DECODED) return nbytes; if(flags & H5Z_FLAG_REVERSE) { - if(link_filter_state != LFS_ENCODED) - return 0; + if(link_filter_state != LFS_ENCODED) return 0; link_filter_state = LFS_DECODED; - } else { - if(link_filter_state < LFS_SET_LOCAL_CALLED) - return 0; + } + else { + if(link_filter_state < LFS_SET_LOCAL_CALLED) return 0; link_filter_state = LFS_ENCODED; } /* end else */ @@ -9926,7 +9171,7 @@ link_filters(hid_t fapl, hbool_t new_format) int nfilters = 0; H5Z_class2_t filter_class; char name_out[24]; - char filename[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; htri_t tri_ret; herr_t status; @@ -9944,8 +9189,7 @@ link_filters(hid_t fapl, hbool_t new_format) /* Set up filename and create file*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR + if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create gcpl, force use of dense storage */ if((gcpl1 = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR @@ -9973,8 +9217,7 @@ link_filters(hid_t fapl, hbool_t new_format) filter_class.set_local = link_filter_set_local; filter_class.filter = link_filter_filter; if(H5Zregister(&filter_class) < 0) TEST_ERROR - if(H5Pset_filter(gcpl1, H5Z_FILTER_RESERVED + 42, 0, (size_t)1, &cd_value) < 0) - TEST_ERROR + if(H5Pset_filter(gcpl1, H5Z_FILTER_RESERVED + 42, 0, (size_t)1, &cd_value) < 0) TEST_ERROR nfilters++; /* Test various other filter functions for use on gcpl's */ @@ -9982,14 +9225,10 @@ link_filters(hid_t fapl, hbool_t new_format) if(H5Pall_filters_avail(gcpl1) != TRUE) TEST_ERROR /* Create a group using this filter, add some soft links to it */ - if((gid1 = H5Gcreate2(fid, "group1", H5P_DEFAULT, gcpl1, H5P_DEFAULT)) < 0) - TEST_ERROR - if(H5Lcreate_soft("/", gid1, "link1", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lcreate_soft("/", gid1, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lcreate_soft("/", gid1, "link3", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if((gid1 = H5Gcreate2(fid, "group1", H5P_DEFAULT, gcpl1, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Lcreate_soft("/", gid1, "link1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_soft("/", gid1, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_soft("/", gid1, "link3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close file and group */ if(H5Gclose(gid1) < 0) TEST_ERROR @@ -10013,12 +9252,10 @@ link_filters(hid_t fapl, hbool_t new_format) if(H5Pclose(gcpl2) < 0) TEST_ERROR /* Add another soft link */ - if(H5Lcreate_soft("/", gid1, "link4", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcreate_soft("/", gid1, "link4", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Copy the group */ - if(H5Ocopy(fid, "group1", fid, "group2", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Ocopy(fid, "group1", fid, "group2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR if((gid2 = H5Gopen2(fid, "group2", H5P_DEFAULT)) <0) TEST_ERROR /* Verify that all links have been copied */ @@ -10047,10 +9284,8 @@ link_filters(hid_t fapl, hbool_t new_format) /* Reopen file and group, add 2 links */ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR if((gid1 = H5Gopen2(fid, "group1", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Lcreate_soft("/", gid1, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR - if(H5Lcreate_soft("/", gid1, "link3", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if(H5Lcreate_soft("/", gid1, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_soft("/", gid1, "link3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close file and group */ if(H5Gclose(gid1) < 0) TEST_ERROR @@ -10061,34 +9296,27 @@ link_filters(hid_t fapl, hbool_t new_format) /* Test H5Pget_filter_by_id2 and H5Pget_filter2 */ if(H5Pget_filter_by_id2(gcpl2, H5Z_FILTER_RESERVED + 42, &flags_out, - &cd_nelmts, &cd_value_out, (size_t)24, name_out, &filter_config_out) < 0) - TEST_ERROR + &cd_nelmts, &cd_value_out, (size_t)24, name_out, &filter_config_out) < 0) TEST_ERROR if(flags_out != 0 || cd_value_out != cd_value || HDstrcmp(filter_class.name, name_out) || filter_config_out != (H5Z_FILTER_CONFIG_ENCODE_ENABLED - | H5Z_FILTER_CONFIG_DECODE_ENABLED)) - TEST_ERROR + | H5Z_FILTER_CONFIG_DECODE_ENABLED)) TEST_ERROR if(H5Pget_filter2(gcpl2, (unsigned)(nfilters - 1), &flags_out, &cd_nelmts, - &cd_value_out, (size_t)24, name_out, &filter_config_out) < 0) - TEST_ERROR + &cd_value_out, (size_t)24, name_out, &filter_config_out) < 0) TEST_ERROR if(flags_out != 0 || cd_value_out != cd_value || HDstrcmp(filter_class.name, name_out) || filter_config_out != (H5Z_FILTER_CONFIG_ENCODE_ENABLED - | H5Z_FILTER_CONFIG_DECODE_ENABLED)) - TEST_ERROR + | H5Z_FILTER_CONFIG_DECODE_ENABLED)) TEST_ERROR /* Test H5Pmodify_filter */ cd_value++; - if(H5Pmodify_filter(gcpl2, H5Z_FILTER_RESERVED + 42, 0, (size_t)1, &cd_value) < 0) - TEST_ERROR + if(H5Pmodify_filter(gcpl2, H5Z_FILTER_RESERVED + 42, 0, (size_t)1, &cd_value) < 0) TEST_ERROR if(H5Pget_filter_by_id2(gcpl2, H5Z_FILTER_RESERVED + 42, &flags_out, - &cd_nelmts, &cd_value_out, (size_t)24, name_out, &filter_config_out) < 0) - TEST_ERROR + &cd_nelmts, &cd_value_out, (size_t)24, name_out, &filter_config_out) < 0) TEST_ERROR if(flags_out != 0 || cd_value_out != cd_value || HDstrcmp(filter_class.name, name_out) || filter_config_out != (H5Z_FILTER_CONFIG_ENCODE_ENABLED - | H5Z_FILTER_CONFIG_DECODE_ENABLED)) - TEST_ERROR + | H5Z_FILTER_CONFIG_DECODE_ENABLED)) TEST_ERROR /* Test H5Premove_filter */ if(H5Premove_filter(gcpl2, H5Z_FILTER_RESERVED + 42) < 0) TEST_ERROR @@ -10114,8 +9342,7 @@ link_filters(hid_t fapl, hbool_t new_format) if(H5Pset_create_intermediate_group(lcpl, (unsigned)TRUE) < 0) TEST_ERROR /* Create new group, with missing intermediate groups, in compressed group */ - if((gid1 = H5Gcreate2(fid, "group1/group2/group3/group4", lcpl, H5P_DEFAULT, H5P_DEFAULT)) < 0) - TEST_ERROR + if((gid1 = H5Gcreate2(fid, "group1/group2/group3/group4", lcpl, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Close LCPL ID */ if(H5Pclose(lcpl) < 0) TEST_ERROR @@ -10143,7 +9370,6 @@ link_filters(hid_t fapl, hbool_t new_format) /* Close file */ if(H5Fclose(fid) < 0) TEST_ERROR - /* Now create the same file with and without deflate, and verify that the * file size is smaller with deflate */ /* But only if the deflate filter is available */ @@ -10157,8 +9383,7 @@ link_filters(hid_t fapl, hbool_t new_format) if(H5Pset_link_phase_change(fcpl, 2, 2) < 0) TEST_ERROR /* Create file */ - if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) - TEST_ERROR + if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR /* Create links in file */ if(H5Lcreate_soft("/", fid, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", H5P_DEFAULT, H5P_DEFAULT) < 0) @@ -10176,8 +9401,7 @@ link_filters(hid_t fapl, hbool_t new_format) if(H5Pset_deflate(fcpl, 6) < 0) TEST_ERROR /* Recreate the same file with the deflate filter */ - if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) - TEST_ERROR + if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR if(H5Lcreate_soft("/", fid, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR if(H5Lcreate_soft("/", fid, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", H5P_DEFAULT, H5P_DEFAULT) < 0) @@ -10190,16 +9414,14 @@ link_filters(hid_t fapl, hbool_t new_format) filesize_filtered = h5_get_file_size(filename, fapl); /* Check that the file size is smaller with the filter */ - if((double)filesize_filtered - > ((double)filesize_unfiltered * FILTER_FILESIZE_MAX_FRACTION)) - TEST_ERROR + if((double)filesize_filtered > ((double)filesize_unfiltered * FILTER_FILESIZE_MAX_FRACTION)) TEST_ERROR /* Close */ if(H5Pclose(fcpl) < 0) TEST_ERROR } /* end if */ PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -10211,7 +9433,7 @@ error: H5Pclose(gcpl2); H5Pclose(fcpl); } H5E_END_TRY; - return -1; + return FAIL; } /* end link_filters() */ @@ -10222,19 +9444,15 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Tuesday, February 2, 2010 - * *------------------------------------------------------------------------- */ static int obj_exists(hid_t fapl, hbool_t new_format) { - char filename[NAME_BUF_SIZE]; /* Buffer for file name */ - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group ID */ - herr_t status; /* Generic return value */ + char filename[NAME_BUF_SIZE]; /* Buffer for file name */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + herr_t status; /* Generic return value */ if(new_format) TESTING("object exists (w/new group format)") @@ -10244,8 +9462,7 @@ obj_exists(hid_t fapl, hbool_t new_format) /* Set up filename and create file*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - FAIL_STACK_ERROR + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Hard links */ /* Verify that H5Oexists_by_name() fails for non-existent link in root group */ @@ -10255,13 +9472,11 @@ obj_exists(hid_t fapl, hbool_t new_format) if(status >= 0) TEST_ERROR /* Create a group, as a destination for testing */ - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR if(H5Gclose(gid) < 0) FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() succeeds for hard linked object */ - if(TRUE != H5Oexists_by_name(fid, "group", H5P_DEFAULT)) - TEST_ERROR + if(TRUE != H5Oexists_by_name(fid, "group", H5P_DEFAULT)) TEST_ERROR /* Verify that H5Oexists_by_name() fails for non-existent link in non-root group */ H5E_BEGIN_TRY { @@ -10269,237 +9484,202 @@ obj_exists(hid_t fapl, hbool_t new_format) } H5E_END_TRY if(status >= 0) TEST_ERROR - /* Soft links */ /* Create dangling soft-link in root group */ if(H5Lcreate_soft("dangle", fid, "soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE for dangling soft-link in root group */ - if(FALSE != H5Oexists_by_name(fid, "soft1", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "soft1", H5P_DEFAULT)) TEST_ERROR /* Create soft-link in root group that points to object */ if(H5Lcreate_soft("/group", fid, "soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns TRUE for soft-link in root group that points to object */ - if(TRUE != H5Oexists_by_name(fid, "soft2", H5P_DEFAULT)) - TEST_ERROR + if(TRUE != H5Oexists_by_name(fid, "soft2", H5P_DEFAULT)) TEST_ERROR /* Create dangling soft-link in non-root group */ if(H5Lcreate_soft("dangle", fid, "group/soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE for dangling soft-link in non-root group */ - if(FALSE != H5Oexists_by_name(fid, "group/soft1", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "group/soft1", H5P_DEFAULT)) TEST_ERROR /* Create soft-link in non-root group that points to object */ if(H5Lcreate_soft("/group", fid, "group/soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns TRUE for soft-link in non-root group that points to object */ - if(TRUE != H5Oexists_by_name(fid, "group/soft2", H5P_DEFAULT)) - TEST_ERROR - + if(TRUE != H5Oexists_by_name(fid, "group/soft2", H5P_DEFAULT)) TEST_ERROR /* External links */ /* Create dangling (file doesn't exist) external link in root group */ if(H5Lcreate_external("nofile", "dangle", fid, "external1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Verify that H5Oexists_by_name() returns FALSE for dangling (file doesn't exist) external link in root group */ - if(FALSE != H5Oexists_by_name(fid, "external1", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "external1", H5P_DEFAULT)) TEST_ERROR /* Create dangling (object doesn't exist) external link in root group */ if(H5Lcreate_external(filename, "dangle", fid, "external2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Verify that H5Oexists_by_name() returns FALSE for dangling (object doesn't exist) external link in root group */ - if(FALSE != H5Oexists_by_name(fid, "external2", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "external2", H5P_DEFAULT)) TEST_ERROR /* Create external link in root group that points to object */ if(H5Lcreate_external(filename, "group", fid, "external3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Verify that H5Oexists_by_name() returns TRUE for external link in root group that points to object */ - if(TRUE != H5Oexists_by_name(fid, "external3", H5P_DEFAULT)) - TEST_ERROR + if(TRUE != H5Oexists_by_name(fid, "external3", H5P_DEFAULT)) TEST_ERROR /* Create dangling (file doesn't exist) external link in non-root group */ if(H5Lcreate_external("nofile", "dangle", fid, "group/external1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Verify that H5Oexists_by_name() returns FALSE for dangling (file doesn't exist) external link in non-root group */ - if(FALSE != H5Oexists_by_name(fid, "group/external1", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "group/external1", H5P_DEFAULT)) TEST_ERROR /* Create dangling (object doesn't exist) external link in non-root group */ if(H5Lcreate_external(filename, "dangle", fid, "group/external2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Verify that H5Oexists_by_name() returns FALSE for dangling (object doesn't exist) external link in non-root group */ - if(FALSE != H5Oexists_by_name(fid, "group/external2", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "group/external2", H5P_DEFAULT)) TEST_ERROR /* Create external link in non-root group that points to object */ if(H5Lcreate_external(filename, "group", fid, "group/external3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Verify that H5Oexists_by_name() returns TRUE for external link in non-root group that points to object */ - if(TRUE != H5Oexists_by_name(fid, "group/external3", H5P_DEFAULT)) - TEST_ERROR - + if(TRUE != H5Oexists_by_name(fid, "group/external3", H5P_DEFAULT)) TEST_ERROR /* Soft->External links */ /* Create soft-link in root group that points to dangling (file doesn't exist) external link */ if(H5Lcreate_soft("external1", fid, "soft-elink1", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "soft-elink1", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "soft-elink1", H5P_DEFAULT)) TEST_ERROR /* Create soft-link in root group that points to dangling (object doesn't exist) external link */ if(H5Lcreate_soft("external2", fid, "soft-elink2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "soft-elink2", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "soft-elink2", H5P_DEFAULT)) TEST_ERROR /* Create soft-link in root group that points to external link that points to object */ if(H5Lcreate_soft("external3", fid, "soft-elink3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns TRUE */ - if(TRUE != H5Oexists_by_name(fid, "soft-elink3", H5P_DEFAULT)) - TEST_ERROR + if(TRUE != H5Oexists_by_name(fid, "soft-elink3", H5P_DEFAULT)) TEST_ERROR /* Create soft-link in root group that points to dangling (file doesn't exist) external link in non-root group */ if(H5Lcreate_soft("group/external1", fid, "soft-elink4", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "soft-elink4", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "soft-elink4", H5P_DEFAULT)) TEST_ERROR /* Create soft-link in root group that points to dangling (object doesn't exist) external link in non-root group */ if(H5Lcreate_soft("group/external2", fid, "soft-elink5", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "soft-elink5", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "soft-elink5", H5P_DEFAULT)) TEST_ERROR /* Create soft-link in root group that points to external link in non-root group that points to object */ if(H5Lcreate_soft("group/external3", fid, "soft-elink6", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns TRUE */ - if(TRUE != H5Oexists_by_name(fid, "soft-elink6", H5P_DEFAULT)) - TEST_ERROR + if(TRUE != H5Oexists_by_name(fid, "soft-elink6", H5P_DEFAULT)) TEST_ERROR /* Create soft-link in non-root group that points to dangling (file doesn't exist) external link */ if(H5Lcreate_soft("/external1", fid, "group/soft-elink1", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "group/soft-elink1", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "group/soft-elink1", H5P_DEFAULT)) TEST_ERROR /* Create soft-link in non-root group that points to dangling (object doesn't exist) external link */ if(H5Lcreate_soft("/external2", fid, "group/soft-elink2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "group/soft-elink2", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "group/soft-elink2", H5P_DEFAULT)) TEST_ERROR /* Create soft-link in non-root group that points to external link that points to object */ if(H5Lcreate_soft("/external3", fid, "group/soft-elink3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns TRUE */ - if(TRUE != H5Oexists_by_name(fid, "group/soft-elink3", H5P_DEFAULT)) - TEST_ERROR + if(TRUE != H5Oexists_by_name(fid, "group/soft-elink3", H5P_DEFAULT)) TEST_ERROR /* Create soft-link in non-root group that points to dangling (file doesn't exist) external link in non-root group */ if(H5Lcreate_soft("/group/external1", fid, "group/soft-elink4", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "group/soft-elink4", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "group/soft-elink4", H5P_DEFAULT)) TEST_ERROR /* Create soft-link in non-root group that points to dangling (object doesn't exist) external link in non-root group */ if(H5Lcreate_soft("/group/external2", fid, "group/soft-elink5", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "group/soft-elink5", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "group/soft-elink5", H5P_DEFAULT)) TEST_ERROR /* Create soft-link in non-root group that points to external link in non-root group that points to object */ if(H5Lcreate_soft("/group/external3", fid, "group/soft-elink6", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns TRUE */ - if(TRUE != H5Oexists_by_name(fid, "group/soft-elink6", H5P_DEFAULT)) - TEST_ERROR - + if(TRUE != H5Oexists_by_name(fid, "group/soft-elink6", H5P_DEFAULT)) TEST_ERROR /* External->Soft links */ /* Create external link in root group that points to dangling soft link in root group */ if(H5Lcreate_external(filename, "soft1", fid, "elink-soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "elink-soft1", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "elink-soft1", H5P_DEFAULT)) TEST_ERROR /* Create external link in root group that points to soft link in root group that points to object */ if(H5Lcreate_external(filename, "soft2", fid, "elink-soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Verify that H5Oexists_by_name() returns TRUE */ - if(TRUE != H5Oexists_by_name(fid, "elink-soft2", H5P_DEFAULT)) - TEST_ERROR + if(TRUE != H5Oexists_by_name(fid, "elink-soft2", H5P_DEFAULT)) TEST_ERROR /* Create external link in root group that points to dangling soft link in non-root group */ if(H5Lcreate_external(filename, "group/soft1", fid, "elink-soft3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "elink-soft3", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "elink-soft3", H5P_DEFAULT)) TEST_ERROR /* Create external link in root group that points to soft link in root group that points to object */ if(H5Lcreate_external(filename, "group/soft2", fid, "elink-soft4", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Verify that H5Oexists_by_name() returns TRUE */ - if(TRUE != H5Oexists_by_name(fid, "elink-soft4", H5P_DEFAULT)) - TEST_ERROR + if(TRUE != H5Oexists_by_name(fid, "elink-soft4", H5P_DEFAULT)) TEST_ERROR /* Create external link in non-root group that points to dangling soft link in root group */ if(H5Lcreate_external(filename, "soft1", fid, "group/elink-soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "group/elink-soft1", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "group/elink-soft1", H5P_DEFAULT)) TEST_ERROR /* Create external link in non-root group that points to soft link in root group that points to object */ if(H5Lcreate_external(filename, "soft2", fid, "group/elink-soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Verify that H5Oexists_by_name() returns TRUE */ - if(TRUE != H5Oexists_by_name(fid, "group/elink-soft2", H5P_DEFAULT)) - TEST_ERROR + if(TRUE != H5Oexists_by_name(fid, "group/elink-soft2", H5P_DEFAULT)) TEST_ERROR /* Create external link in non-root group that points to dangling soft link in non-root group */ if(H5Lcreate_external(filename, "group/soft1", fid, "group/elink-soft3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "group/elink-soft3", H5P_DEFAULT)) - TEST_ERROR + if(FALSE != H5Oexists_by_name(fid, "group/elink-soft3", H5P_DEFAULT)) TEST_ERROR /* Create external link in non-root group that points to soft link in non-root group that points to object */ if(H5Lcreate_external(filename, "group/soft2", fid, "group/elink-soft4", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Verify that H5Oexists_by_name() returns TRUE */ - if(TRUE != H5Oexists_by_name(fid, "group/elink-soft4", H5P_DEFAULT)) - TEST_ERROR - + if(TRUE != H5Oexists_by_name(fid, "group/elink-soft4", H5P_DEFAULT)) TEST_ERROR /* Close file created */ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end obj_exists() */ @@ -10510,19 +9690,15 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, October 30, 2006 - * *------------------------------------------------------------------------- */ static int corder_create_empty(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ - unsigned crt_order_flags; /* Status of creation order info for GCPL */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + unsigned crt_order_flags; /* Status of creation order info for GCPL */ herr_t ret; /* Generic return value */ char filename[NAME_BUF_SIZE];/* File name */ @@ -10544,9 +9720,9 @@ corder_create_empty(hid_t fapl) ret = H5Pset_link_creation_order(gcpl_id, H5P_CRT_ORDER_INDEXED); } H5E_END_TRY; if(ret > 0) { - H5_FAILED(); - HDputs(" H5Pset_link_create_order() should have failed for a creation order index with no tracking."); - TEST_ERROR + H5_FAILED(); + HDputs(" H5Pset_link_create_order() should have failed for a creation order index with no tracking."); + TEST_ERROR } /* end if */ /* Set creation order tracking & indexing on group */ @@ -10571,7 +9747,6 @@ corder_create_empty(hid_t fapl) /* Close the file */ if(H5Fclose(file_id) < 0) TEST_ERROR - /* Re-open the file */ if((file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR @@ -10598,7 +9773,7 @@ corder_create_empty(hid_t fapl) if(H5Fclose(file_id) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -10606,7 +9781,7 @@ error: H5Gclose(group_id); H5Fclose(file_id); } H5E_END_TRY; - return -1; + return FAIL; } /* end corder_create_empty() */ @@ -10618,21 +9793,17 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, October 30, 2006 - * *------------------------------------------------------------------------- */ static int corder_create_compact(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1, group_id2 = -1; /* Group IDs */ + hid_t gcpl_id = -1; /* Group creation property list ID */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ - unsigned nlinks; /* Number of link messages in group's header */ + unsigned nlinks; /* Number of link messages in group's header */ char objname[NAME_BUF_SIZE]; /* Object name */ char filename[NAME_BUF_SIZE];/* File name */ unsigned u; /* Local index variable */ @@ -10682,7 +9853,6 @@ corder_create_compact(hid_t fapl) /* Close the file */ if(H5Fclose(file_id) < 0) TEST_ERROR - /* Re-open the file */ if((file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR @@ -10716,7 +9886,7 @@ corder_create_compact(hid_t fapl) if(H5Fclose(file_id) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -10724,7 +9894,7 @@ error: H5Gclose(group_id); H5Fclose(file_id); } H5E_END_TRY; - return -1; + return FAIL; } /* end corder_create_compact() */ @@ -10736,21 +9906,17 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, October 30, 2006 - * *------------------------------------------------------------------------- */ static int corder_create_dense(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1, group_id2 = -1; /* Group IDs */ + hid_t gcpl_id = -1; /* Group creation property list ID */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ - unsigned nlinks; /* Number of link messages in group's header */ + unsigned nlinks; /* Number of link messages in group's header */ hsize_t name_count; /* # of records in name index */ hsize_t corder_count; /* # of records in creation order index */ char objname[NAME_BUF_SIZE]; /* Object name */ @@ -10816,7 +9982,6 @@ corder_create_dense(hid_t fapl) /* Close the file */ if(H5Fclose(file_id) < 0) TEST_ERROR - /* Re-open the file */ if((file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR @@ -10849,7 +10014,7 @@ corder_create_dense(hid_t fapl) if(H5Fclose(file_id) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -10857,7 +10022,7 @@ error: H5Gclose(group_id); H5Fclose(file_id); } H5E_END_TRY; - return -1; + return FAIL; } /* end corder_create_dense() */ @@ -10869,25 +10034,21 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, October 30, 2006 - * *------------------------------------------------------------------------- */ static int corder_transition(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1, group_id2 = -1; /* Group IDs */ + hid_t gcpl_id = -1; /* Group creation property list ID */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ - unsigned nlinks; /* Number of link messages in group's header */ + unsigned nlinks; /* Number of link messages in group's header */ hsize_t name_count; /* # of records in name index */ hsize_t corder_count; /* # of records in creation order index */ - h5_stat_size_t empty_size; /* Size of empty file */ - h5_stat_size_t file_size; /* Size of file after operating on it */ + h5_stat_size_t empty_size; /* Size of empty file */ + h5_stat_size_t file_size; /* Size of file after operating on it */ char objname[NAME_BUF_SIZE]; /* Object name */ char filename[NAME_BUF_SIZE];/* File name */ unsigned u; /* Local index variable */ @@ -10927,7 +10088,6 @@ corder_transition(hid_t fapl) /* Get the size of the file with an empty group */ if((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR - /* Re-open the file */ if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR @@ -11002,7 +10162,6 @@ corder_transition(hid_t fapl) /* Close the file */ if(H5Fclose(file_id) < 0) TEST_ERROR - /* Re-open the file */ if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR @@ -11078,7 +10237,7 @@ corder_transition(hid_t fapl) if(file_size != empty_size) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -11086,7 +10245,7 @@ error: H5Gclose(group_id); H5Fclose(file_id); } H5E_END_TRY; - return -1; + return FAIL; } /* end corder_transition() */ @@ -11099,25 +10258,21 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, October 30, 2006 - * *------------------------------------------------------------------------- */ static int corder_delete(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1, group_id2 = -1; /* Group IDs */ + hid_t gcpl_id = -1; /* Group creation property list ID */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ hsize_t name_count; /* # of records in name index */ hsize_t corder_count; /* # of records in creation order index */ unsigned reopen_file; /* Whether to re-open the file before deleting group */ - h5_stat_size_t empty_size; /* Size of empty file */ - h5_stat_size_t file_size; /* Size of file after operating on it */ + h5_stat_size_t empty_size; /* Size of empty file */ + h5_stat_size_t file_size; /* Size of file after operating on it */ char objname[NAME_BUF_SIZE]; /* Object name */ char filename[NAME_BUF_SIZE];/* File name */ unsigned u; /* Local index variable */ @@ -11207,7 +10362,7 @@ corder_delete(hid_t fapl) } /* end for */ PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -11215,7 +10370,7 @@ error: H5Gclose(group_id); H5Fclose(file_id); } H5E_END_TRY; - return -1; + return FAIL; } /* end corder_delete() */ @@ -11225,15 +10380,11 @@ error: * Purpose: Support routine for link_info_by_idx, to verify the link * info is correct for a link * - * Note: This routine assumes that the links have been inserted in the + * Note: This routine assumes that the links have been inserted in the * group in alphabetical order. * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Tuesday, November 7, 2006 - * *------------------------------------------------------------------------- */ static int @@ -11386,18 +10537,14 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, November 6, 2006 - * *------------------------------------------------------------------------- */ static int link_info_by_idx(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t gcpl_id = -1; /* Group creation property list ID */ unsigned hard_link; /* Create hard or soft link? */ unsigned use_index; /* Use index on creation order values */ unsigned max_compact; /* Maximum # of links to store in group compactly */ @@ -11551,7 +10698,7 @@ link_info_by_idx(hid_t fapl) } /* end for */ } /* end for */ - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -11559,7 +10706,7 @@ error: H5Gclose(group_id); H5Fclose(file_id); } H5E_END_TRY; - return -1; + return FAIL; } /* end link_info_by_idx() */ @@ -11571,17 +10718,13 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Tuesday, November 7, 2006 - * *------------------------------------------------------------------------- */ static int link_info_by_idx_old(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1, group_id2 = -1; /* Group IDs */ unsigned hard_link; /* Create hard or soft link? */ H5L_info_t linfo; /* Link info struct */ char objname[NAME_BUF_SIZE]; /* Object name */ @@ -11719,14 +10862,14 @@ link_info_by_idx_old(hid_t fapl) PASSED(); } /* end for */ - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { H5Gclose(group_id); H5Fclose(file_id); } H5E_END_TRY; - return -1; + return FAIL; } /* end link_info_by_idx_old() */ @@ -11738,19 +10881,15 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Tuesday, November 14, 2006 - * *------------------------------------------------------------------------- */ static int delete_by_idx(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ - H5_index_t idx_type; /* Type of index to operate on */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + H5_index_t idx_type; /* Type of index to operate on */ H5_iter_order_t order; /* Order within in the index */ unsigned use_index; /* Use index on creation order values */ unsigned max_compact; /* Maximum # of links to store in group compactly */ @@ -11814,10 +10953,8 @@ delete_by_idx(hid_t fapl) /* Query the group creation properties */ if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR - /* Delete links from one end */ - /* Check for deletion on empty group */ H5E_BEGIN_TRY { ret = H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT); @@ -11948,10 +11085,8 @@ delete_by_idx(hid_t fapl) } H5E_END_TRY; if(ret >= 0) TEST_ERROR - /* Delete links in middle */ - /* Create more links, to push group into dense form */ for(u = 0; u < (max_compact * 2); u++) { hid_t group_id2; /* Group ID */ @@ -12028,8 +11163,6 @@ delete_by_idx(hid_t fapl) if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR - - /* Close the group */ if(H5Gclose(group_id) < 0) TEST_ERROR @@ -12044,7 +11177,7 @@ delete_by_idx(hid_t fapl) } /* end for */ } /* end for */ - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -12052,7 +11185,7 @@ error: H5Gclose(group_id); H5Fclose(file_id); } H5E_END_TRY; - return -1; + return FAIL; } /* end delete_by_idx() */ @@ -12064,17 +11197,13 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Wednesday, November 15, 2006 - * *------------------------------------------------------------------------- */ static int delete_by_idx_old(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1), group_id2 = (-1); /* Group IDs */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1, group_id2 = -1; /* Group IDs */ H5L_info_t linfo; /* Link info struct */ H5_iter_order_t order; /* Order within in the index */ char objname[NAME_BUF_SIZE]; /* Object name */ @@ -12099,10 +11228,8 @@ delete_by_idx_old(hid_t fapl) /* Create group to operate on */ if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* Delete links from one end */ - /* Check for deletion in empty group */ H5E_BEGIN_TRY { ret = H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT); @@ -12178,10 +11305,8 @@ delete_by_idx_old(hid_t fapl) /* Verify state of group */ if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR - /* Delete links in middle */ - /* Create several links */ for(u = 0; u < CORDER_NLINKS; u++) { H5O_info_t oi; /* Buffer for querying object's info */ @@ -12269,7 +11394,7 @@ delete_by_idx_old(hid_t fapl) PASSED(); } /* end for */ - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -12277,7 +11402,7 @@ error: H5Fclose(file_id); } H5E_END_TRY; - return -1; + return FAIL; } /* end delete_by_idx_old() */ @@ -12288,10 +11413,6 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, November 20, 2006 - * *------------------------------------------------------------------------- */ static int @@ -12300,14 +11421,14 @@ link_iterate_cb(hid_t group_id, const char *link_name, const H5L_info_t *info, { link_iter_info_t *op_data = (link_iter_info_t *)_op_data; /* User data */ char objname[NAME_BUF_SIZE]; /* Object name */ - H5L_info_t my_info; /* Local link info */ + H5L_info_t my_info; /* Local link info */ /* Increment # of times the callback was called */ op_data->ncalled++; /* Get the link information directly to compare */ if(H5Lget_info(group_id, link_name, &my_info, H5P_DEFAULT) < 0) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; /* Check more things for link iteration (vs. group iteration) */ if(info) { @@ -12315,31 +11436,31 @@ link_iterate_cb(hid_t group_id, const char *link_name, const H5L_info_t *info, /* (if we are operating in increasing or decreasing order) */ if(op_data->order != H5_ITER_NATIVE) if(info->corder != op_data->curr) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; /* Compare link info structs */ if(info->type != my_info.type) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; if(info->corder_valid != my_info.corder_valid) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; if(info->corder != my_info.corder) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; if(info->cset != my_info.cset) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; if(H5F_addr_ne(info->u.address, my_info.u.address)) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; } /* end if */ /* Verify name of link */ HDsnprintf(objname, sizeof(objname), "filler %02u", (unsigned)my_info.corder); if(HDstrcmp(link_name, objname)) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; /* Check if we've visited this link before */ if((size_t)op_data->curr >= op_data->max_visit) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; if(op_data->visited[op_data->curr]) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; op_data->visited[op_data->curr] = TRUE; /* Advance to next value, in correct direction */ @@ -12351,9 +11472,9 @@ link_iterate_cb(hid_t group_id, const char *link_name, const H5L_info_t *info, /* Check for stopping in the middle of iterating */ if(op_data->stop > 0) if(--op_data->stop == 0) - return(CORDER_ITER_STOP); + return CORDER_ITER_STOP; - return(H5_ITER_CONT); + return H5_ITER_CONT; } /* end link_iterate_cb() */ #ifndef H5_NO_DEPRECATED_SYMBOLS @@ -12366,16 +11487,12 @@ link_iterate_cb(hid_t group_id, const char *link_name, const H5L_info_t *info, * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, November 20, 2006 - * *------------------------------------------------------------------------- */ static int group_iterate_cb(hid_t group_id, const char *link_name, void *_op_data) { - return(link_iterate_cb(group_id, link_name, NULL, _op_data)); + return link_iterate_cb(group_id, link_name, NULL, _op_data); } /* end group_iterate_cb() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -12388,17 +11505,13 @@ group_iterate_cb(hid_t group_id, const char *link_name, void *_op_data) * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, November 20, 2006 - * *------------------------------------------------------------------------- */ static int link_iterate_fail_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UNUSED *link_name, const H5L_info_t H5_ATTR_UNUSED *info, void H5_ATTR_UNUSED *_op_data) { - return(H5_ITER_ERROR); + return H5_ITER_ERROR; } /* end link_iterate_fail_cb() */ @@ -12409,10 +11522,6 @@ link_iterate_fail_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UNUSED *l * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, November 20, 2006 - * *------------------------------------------------------------------------- */ static int @@ -12440,7 +11549,6 @@ link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, for(v = 0; v < max_links; v++) if(iter_info->visited[v] == FALSE) TEST_ERROR - #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over links in group, with H5Giterate */ iter_info->nskipped = (unsigned)(gskip = 0); @@ -12457,7 +11565,6 @@ link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, if(iter_info->visited[v] == FALSE) TEST_ERROR #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /* Skip over some links in group */ iter_info->nskipped = (unsigned)(skip = max_links / 2); iter_info->order = order; @@ -12488,7 +11595,6 @@ link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, if(nvisit != (max_links / 2)) TEST_ERROR } /* end else */ - #ifndef H5_NO_DEPRECATED_SYMBOLS /* Skip over some links in group, with H5Giterate */ iter_info->nskipped = (unsigned)(gskip = (int)(max_links / 2)); @@ -12521,7 +11627,6 @@ link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, } /* end else */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /* Iterate over links in group, stopping in the middle */ iter_info->nskipped = (unsigned)(skip = 0); iter_info->order = order; @@ -12533,7 +11638,6 @@ link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, if(ret != CORDER_ITER_STOP) TEST_ERROR if(iter_info->ncalled != 3) TEST_ERROR - #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over links in group, stopping in the middle, with H5Giterate() */ iter_info->nskipped = (unsigned)(gskip = 0); @@ -12547,7 +11651,6 @@ link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, if(iter_info->ncalled != 3) TEST_ERROR #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /* Check for iteration routine indicating failure */ skip = 0; H5E_BEGIN_TRY { @@ -12556,10 +11659,10 @@ link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, if(ret >= 0) TEST_ERROR /* Success */ - return(0); + return SUCCEED; error: - return(-1); + return FAIL; } /* end link_iterate_check() */ @@ -12667,7 +11770,6 @@ link_iterate(hid_t fapl) /* Create group with creation order tracking on */ if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR - /* Check for iteration on empty group */ /* (should be OK) */ if(H5Literate(group_id, idx_type, order, NULL, link_iterate_cb, NULL) < 0) TEST_ERROR @@ -12697,7 +11799,6 @@ link_iterate(hid_t fapl) /* Test iteration over links in compact group */ if(link_iterate_check(group_id, idx_type, order, u, &iter_info) < 0) TEST_ERROR - /* Create more links, to push group into dense form */ for(; u < (max_compact * 2); u++) { hid_t group_id2; /* Group ID */ @@ -12742,7 +11843,7 @@ link_iterate(hid_t fapl) if(visited) HDfree(visited); - return 0; + return SUCCEED; error: /* Free resources */ @@ -12755,7 +11856,7 @@ error: if(visited) HDfree(visited); - return -1; + return FAIL; } /* end link_iterate() */ @@ -12766,52 +11867,47 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, November 20, 2006 - * *------------------------------------------------------------------------- */ static int -link_iterate_old_cb(hid_t group_id, const char *link_name, const H5L_info_t *info, - void *_op_data) +link_iterate_old_cb(hid_t group_id, const char *link_name, const H5L_info_t *info, void *_op_data) { link_iter_info_t *op_data = (link_iter_info_t *)_op_data; /* User data */ char objname[NAME_BUF_SIZE]; /* Object name */ - H5L_info_t my_info; /* Local link info */ + H5L_info_t my_info; /* Local link info */ /* Increment # of times the callback was called */ op_data->ncalled++; /* Get the link information directly to compare */ if(H5Lget_info(group_id, link_name, &my_info, H5P_DEFAULT) < 0) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; /* Check more things for link iteration (vs. group iteration) */ if(info) { /* Compare link info structs */ if(info->type != my_info.type) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; if(info->corder_valid != my_info.corder_valid) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; if(info->corder != my_info.corder) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; if(info->cset != my_info.cset) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; if(H5F_addr_ne(info->u.address, my_info.u.address)) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; } /* end if */ /* Verify name of link */ HDsnprintf(objname, sizeof(objname), "filler %02u", (info ? (unsigned)op_data->curr : (unsigned)((op_data->ncalled - 1) + op_data->nskipped))); if(HDstrcmp(link_name, objname)) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; /* Check if we've visited this link before */ if((size_t)op_data->curr >= op_data->max_visit) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; if(op_data->visited[op_data->curr]) - return(H5_ITER_ERROR); + return H5_ITER_ERROR; op_data->visited[op_data->curr] = TRUE; /* Advance to next value, in correct direction */ @@ -12823,9 +11919,9 @@ link_iterate_old_cb(hid_t group_id, const char *link_name, const H5L_info_t *inf /* Check for stopping in the middle of iterating */ if(op_data->stop > 0) if(--op_data->stop == 0) - return(CORDER_ITER_STOP); + return CORDER_ITER_STOP; - return(H5_ITER_CONT); + return H5_ITER_CONT; } /* end link_iterate_old_cb() */ #ifndef H5_NO_DEPRECATED_SYMBOLS @@ -12838,16 +11934,12 @@ link_iterate_old_cb(hid_t group_id, const char *link_name, const H5L_info_t *inf * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, November 20, 2006 - * *------------------------------------------------------------------------- */ static int group_iterate_old_cb(hid_t group_id, const char *link_name, void *_op_data) { - return(link_iterate_old_cb(group_id, link_name, NULL, _op_data)); + return link_iterate_old_cb(group_id, link_name, NULL, _op_data); } /* end group_iterate_old_cb() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -12859,15 +11951,10 @@ group_iterate_old_cb(hid_t group_id, const char *link_name, void *_op_data) * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, November 20, 2006 - * *------------------------------------------------------------------------- */ static int -link_iterate_old_check(hid_t group_id, H5_iter_order_t order, - unsigned max_links, link_iter_info_t *iter_info) +link_iterate_old_check(hid_t group_id, H5_iter_order_t order, unsigned max_links, link_iter_info_t *iter_info) { unsigned v; /* Local index variable */ hsize_t skip; /* # of links to skip in group */ @@ -12890,7 +11977,6 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, for(v = 0; v < max_links; v++) if(iter_info->visited[v] == FALSE) TEST_ERROR - #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over links in group, with H5Giterate */ iter_info->nskipped = (unsigned)(gskip = 0); @@ -12907,7 +11993,6 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, if(iter_info->visited[v] == FALSE) TEST_ERROR #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /* Skip over some links in group */ iter_info->nskipped = (unsigned)(skip = max_links / 2); iter_info->order = order; @@ -12938,7 +12023,6 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, if(nvisit != (max_links / 2)) TEST_ERROR } /* end else */ - #ifndef H5_NO_DEPRECATED_SYMBOLS /* Skip over some links in group, with H5Giterate */ iter_info->nskipped = (unsigned)(gskip = (int)(max_links / 2)); @@ -12971,7 +12055,6 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, } /* end else */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /* Iterate over links in group, stopping in the middle */ iter_info->nskipped = (unsigned)(skip = 0); iter_info->order = order; @@ -12983,7 +12066,6 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, if(ret != CORDER_ITER_STOP) TEST_ERROR if(iter_info->ncalled != 3) TEST_ERROR - #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over links in group, stopping in the middle, with H5Giterate() */ iter_info->nskipped = (unsigned)(gskip = 0); @@ -12997,7 +12079,6 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, if(iter_info->ncalled != 3) TEST_ERROR #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /* Check for iteration routine indicating failure */ skip = 0; H5E_BEGIN_TRY { @@ -13020,10 +12101,10 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Success */ - return(0); + return SUCCEED; error: - return(-1); + return FAIL; } /* end link_iterate_old_check() */ @@ -13034,17 +12115,13 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Tuesday, November 14, 2006 - * *------------------------------------------------------------------------- */ static int link_iterate_old(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ H5_iter_order_t order; /* Order within in the index */ char objname[NAME_BUF_SIZE]; /* Object name */ char filename[NAME_BUF_SIZE];/* File name */ @@ -13080,7 +12157,6 @@ link_iterate_old(hid_t fapl) /* Create group with creation order tracking on */ if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* Check for iteration on empty group */ /* (should be OK) */ if(H5Literate(group_id, H5_INDEX_NAME, order, NULL, link_iterate_old_cb, NULL) < 0) TEST_ERROR @@ -13118,7 +12194,6 @@ link_iterate_old(hid_t fapl) /* Test iteration over links in group */ if(link_iterate_old_check(group_id, order, u, &iter_info) < 0) TEST_ERROR - /* Close the group */ if(H5Gclose(group_id) < 0) TEST_ERROR @@ -13132,7 +12207,7 @@ link_iterate_old(hid_t fapl) if(visited) HDfree(visited); - return 0; + return SUCCEED; error: /* Free resources */ @@ -13144,7 +12219,7 @@ error: if(visited) HDfree(visited); - return -1; + return FAIL; } /* end link_iterate_old() */ @@ -13155,19 +12230,14 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Tuesday, November 21, 2006 - * *------------------------------------------------------------------------- */ static int open_by_idx_check(hid_t main_group_id, hid_t soft_group_id, hid_t mount_file_id, - H5_index_t idx_type, H5_iter_order_t order, unsigned max_links, - haddr_t *objno) + H5_index_t idx_type, H5_iter_order_t order, unsigned max_links, haddr_t *objno) { char mntname[NAME_BUF_SIZE]; /* Link value */ - hid_t group_id = (-1); /* ID of group to test */ + hid_t group_id = -1; /* ID of group to test */ H5O_info_t oi; /* Buffer for querying object's info */ haddr_t mnt_root_addr; /* Address of root group in file to mount */ hid_t obj_id; /* ID of object opened */ @@ -13208,10 +12278,7 @@ open_by_idx_check(hid_t main_group_id, hid_t soft_group_id, hid_t mount_file_id, } /* end for */ } /* end for */ - - /* - * Verify opening correct object by index when file mounting is present - */ + /* Verify opening correct object by index when file mounting is present */ /* Get the address of the root group in the file to mount */ if(H5Oget_info2(mount_file_id, &oi, H5O_INFO_BASIC) < 0) TEST_ERROR @@ -13238,12 +12305,11 @@ open_by_idx_check(hid_t main_group_id, hid_t soft_group_id, hid_t mount_file_id, /* Unmount the file */ if(H5Funmount(main_group_id, mntname) < 0) TEST_ERROR - /* Success */ - return(0); + return SUCCEED; error: - return(-1); + return FAIL; } /* end open_by_idx_check() */ @@ -13255,21 +12321,17 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Tuesday, November 21, 2006 - * *------------------------------------------------------------------------- */ static int open_by_idx(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t mount_file_id = (-1); /* File ID for file to mount */ - hid_t group_id = (-1); /* Group ID */ - hid_t soft_group_id = (-1); /* Group ID for soft links */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ - H5_index_t idx_type; /* Type of index to operate on */ + hid_t file_id = -1; /* File ID */ + hid_t mount_file_id = -1; /* File ID for file to mount */ + hid_t group_id = -1; /* Group ID */ + hid_t soft_group_id = -1; /* Group ID for soft links */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + H5_index_t idx_type; /* Type of index to operate on */ H5_iter_order_t order; /* Order within in the index */ unsigned use_index; /* Use index on creation order values */ unsigned max_compact; /* Maximum # of links to store in group compactly */ @@ -13358,14 +12420,12 @@ open_by_idx(hid_t fapl) /* Create group with creation order tracking on for soft links */ if((soft_group_id = H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR - /* Try to open on object in an empty group */ H5E_BEGIN_TRY { ret = H5Oopen_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT); } H5E_END_TRY; if(ret >= 0) TEST_ERROR - /* Create several links, up to limit of compact form */ for(u = 0; u < max_compact; u++) { hid_t group_id2; /* Group ID */ @@ -13400,7 +12460,6 @@ open_by_idx(hid_t fapl) /* Verify opening objects by index */ if(open_by_idx_check(group_id, soft_group_id, mount_file_id, idx_type, order, u, objno) < 0) TEST_ERROR - /* Create more links, to push group into dense form */ for(; u < (max_compact * 2); u++) { hid_t group_id2; /* Group ID */ @@ -13435,7 +12494,6 @@ open_by_idx(hid_t fapl) /* Verify opening objects by index */ if(open_by_idx_check(group_id, soft_group_id, mount_file_id, idx_type, order, u, objno) < 0) TEST_ERROR - /* Close the groups */ if(H5Gclose(group_id) < 0) TEST_ERROR if(H5Gclose(soft_group_id) < 0) TEST_ERROR @@ -13458,7 +12516,7 @@ open_by_idx(hid_t fapl) if(objno) HDfree(objno); - return 0; + return SUCCEED; error: /* Free resources */ @@ -13473,7 +12531,7 @@ error: if(objno) HDfree(objno); - return -1; + return FAIL; } /* end open_by_idx() */ @@ -13485,19 +12543,15 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Tuesday, November 21, 2006 - * *------------------------------------------------------------------------- */ static int open_by_idx_old(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t mount_file_id = (-1); /* File ID for file to mount */ - hid_t group_id = (-1); /* Group ID */ - hid_t soft_group_id = (-1); /* Group ID for soft links */ + hid_t file_id = -1; /* File ID */ + hid_t mount_file_id = -1; /* File ID for file to mount */ + hid_t group_id = -1; /* Group ID */ + hid_t soft_group_id = -1; /* Group ID for soft links */ H5_iter_order_t order; /* Order within in the index */ H5O_info_t oi; /* Buffer for querying object's info */ char filename[NAME_BUF_SIZE];/* File name */ @@ -13542,7 +12596,6 @@ open_by_idx_old(hid_t fapl) } H5E_END_TRY; if(ret >= 0) TEST_ERROR - /* Create several links */ for(u = 0; u < CORDER_NLINKS; u++) { hid_t group_id2; /* Group ID */ @@ -13583,7 +12636,6 @@ open_by_idx_old(hid_t fapl) /* Verify opening objects by index */ if(open_by_idx_check(group_id, soft_group_id, mount_file_id, H5_INDEX_NAME, order, u, objno) < 0) TEST_ERROR - /* Close the groups */ if(H5Gclose(group_id) < 0) TEST_ERROR if(H5Gclose(soft_group_id) < 0) TEST_ERROR @@ -13597,7 +12649,7 @@ open_by_idx_old(hid_t fapl) /* Close the file for mounting */ if(H5Fclose(mount_file_id) < 0) TEST_ERROR - return 0; + return SUCCEED; error: /* Free resources */ @@ -13608,7 +12660,7 @@ error: H5Fclose(mount_file_id); } H5E_END_TRY; - return -1; + return FAIL; } /* end open_by_idx_old() */ @@ -13619,10 +12671,6 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Sunday, November 26, 2006 - * *------------------------------------------------------------------------- */ static int @@ -13630,7 +12678,7 @@ object_info_check(hid_t main_group_id, hid_t soft_group_id, H5_index_t idx_type, H5_iter_order_t order, unsigned max_links, haddr_t *objno) { char objname[NAME_BUF_SIZE]; /* Object name */ - hid_t group_id = (-1); /* ID of group to test */ + hid_t group_id = -1; /* ID of group to test */ H5O_info_t oinfo; /* Buffer for querying object's info */ unsigned u, v; /* Local index variables */ @@ -13676,10 +12724,10 @@ object_info_check(hid_t main_group_id, hid_t soft_group_id, H5_index_t idx_type, } /* end for */ /* Success */ - return(0); + return SUCCEED; error: - return(-1); + return FAIL; } /* end object_info_check() */ @@ -13691,21 +12739,17 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Sunday, November 26, 2006 - * *------------------------------------------------------------------------- */ static int object_info(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t soft_group_id = (-1); /* Group ID for soft links */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ - hid_t space_id = (-1); /* Dataspace ID (for attributes) */ - H5_index_t idx_type; /* Type of index to operate on */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t soft_group_id = -1; /* Group ID for soft links */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + hid_t space_id = -1; /* Dataspace ID (for attributes) */ + H5_index_t idx_type; /* Type of index to operate on */ H5_iter_order_t order; /* Order within in the index */ unsigned use_index; /* Use index on creation order values */ unsigned max_compact; /* Maximum # of links to store in group compactly */ @@ -13915,7 +12959,7 @@ object_info(hid_t fapl) if(objno) HDfree(objno); - return 0; + return SUCCEED; error: /* Free resources */ @@ -13930,7 +12974,7 @@ error: if(objno) HDfree(objno); - return -1; + return FAIL; } /* end object_info() */ @@ -13941,19 +12985,15 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Sunday, November 26, 2006 - * *------------------------------------------------------------------------- */ static int object_info_old(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t soft_group_id = (-1); /* Group ID for soft links */ - hid_t space_id = (-1); /* Dataspace ID (for attributes) */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t soft_group_id = -1; /* Group ID for soft links */ + hid_t space_id = -1; /* Dataspace ID (for attributes) */ H5_iter_order_t order; /* Order within in the index */ H5O_info_t oinfo; /* Buffer for querying object's info */ char filename[NAME_BUF_SIZE];/* File name */ @@ -13991,7 +13031,6 @@ object_info_old(hid_t fapl) /* Create old-style group for soft links */ if((soft_group_id = H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* Check for out of bound query by index on empty group */ H5E_BEGIN_TRY { ret = H5Oget_info_by_idx2(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); @@ -14051,7 +13090,6 @@ object_info_old(hid_t fapl) /* Verify querying objects by name */ if(object_info_check(group_id, soft_group_id, H5_INDEX_NAME, order, u, objno) < 0) TEST_ERROR - /* Close the groups */ if(H5Gclose(group_id) < 0) TEST_ERROR if(H5Gclose(soft_group_id) < 0) TEST_ERROR @@ -14065,7 +13103,7 @@ object_info_old(hid_t fapl) /* Free resources */ if(H5Sclose(space_id) < 0) TEST_ERROR - return 0; + return SUCCEED; error: /* Free resources */ @@ -14076,7 +13114,7 @@ error: H5Fclose(file_id); } H5E_END_TRY; - return -1; + return FAIL; } /* end object_info_old() */ @@ -14088,20 +13126,16 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, November 27, 2006 - * *------------------------------------------------------------------------- */ static int group_info(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t soft_group_id = (-1); /* Group ID for soft links */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ - H5_index_t idx_type; /* Type of index to operate on */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t soft_group_id = -1; /* Group ID for soft links */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + H5_index_t idx_type; /* Type of index to operate on */ H5_iter_order_t order; /* Order within in the index */ unsigned use_index; /* Use index on creation order values */ unsigned max_compact; /* Maximum # of links to store in group compactly */ @@ -14183,7 +13217,6 @@ group_info(hid_t fapl) /* Create group with creation order tracking on for soft links */ if((soft_group_id = H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR - /* Check for out of bound query by index on empty group */ H5E_BEGIN_TRY { ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &grp_info, H5P_DEFAULT); @@ -14200,7 +13233,6 @@ group_info(hid_t fapl) /* Create hard link, with group object */ if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR - /* Retrieve group's information */ if(H5Gget_info(group_id2, &grp_info) < 0) TEST_ERROR @@ -14225,7 +13257,6 @@ group_info(hid_t fapl) if(grp_info.max_corder != 0) TEST_ERROR if(grp_info.nlinks != 0) TEST_ERROR - /* Create objects in new group created */ for(v = 0; v <= u; v++) { /* Make name for link */ @@ -14238,7 +13269,6 @@ group_info(hid_t fapl) if(H5Gclose(group_id3) < 0) TEST_ERROR } /* end for */ - /* Retrieve group's information */ if(H5Gget_info(group_id2, &grp_info) < 0) TEST_ERROR @@ -14263,7 +13293,6 @@ group_info(hid_t fapl) if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR - /* Retrieve group's information */ if(order != H5_ITER_NATIVE) { if(order == H5_ITER_INC) { @@ -14282,7 +13311,6 @@ group_info(hid_t fapl) /* Close group created */ if(H5Gclose(group_id2) < 0) TEST_ERROR - /* Retrieve main group's information */ if(H5Gget_info(group_id, &grp_info) < 0) TEST_ERROR @@ -14307,7 +13335,6 @@ group_info(hid_t fapl) if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR - /* Create soft link in another group, to objects in main group */ HDsnprintf(valname, sizeof(valname), "/%s/%s", CORDER_GROUP_NAME, objname); if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -14330,7 +13357,6 @@ group_info(hid_t fapl) } H5E_END_TRY; if(ret >= 0) TEST_ERROR - /* Create more links, to push group into dense form */ for(; u < (max_compact * 2); u++) { hid_t group_id2, group_id3; /* Group IDs */ @@ -14341,7 +13367,6 @@ group_info(hid_t fapl) /* Create hard link, with group object */ if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR - /* Retrieve group's information */ if(H5Gget_info(group_id2, &grp_info) < 0) TEST_ERROR @@ -14366,7 +13391,6 @@ group_info(hid_t fapl) if(grp_info.max_corder != 0) TEST_ERROR if(grp_info.nlinks != 0) TEST_ERROR - /* Create objects in new group created */ for(v = 0; v <= u; v++) { /* Make name for link */ @@ -14379,7 +13403,6 @@ group_info(hid_t fapl) if(H5Gclose(group_id3) < 0) TEST_ERROR } /* end for */ - /* Retrieve group's information */ if(H5Gget_info(group_id2, &grp_info) < 0) TEST_ERROR @@ -14404,7 +13427,6 @@ group_info(hid_t fapl) if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR - /* Retrieve group's information */ if(order != H5_ITER_NATIVE) { if(order == H5_ITER_INC) { @@ -14423,7 +13445,6 @@ group_info(hid_t fapl) /* Close group created */ if(H5Gclose(group_id2) < 0) TEST_ERROR - /* Retrieve main group's information */ if(H5Gget_info(group_id, &grp_info) < 0) TEST_ERROR @@ -14448,7 +13469,6 @@ group_info(hid_t fapl) if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR - /* Create soft link in another group, to objects in main group */ HDsnprintf(valname, sizeof(valname), "/%s/%s", CORDER_GROUP_NAME, objname); if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -14471,7 +13491,6 @@ group_info(hid_t fapl) } H5E_END_TRY; if(ret >= 0) TEST_ERROR - /* Close the groups */ if(H5Gclose(group_id) < 0) TEST_ERROR if(H5Gclose(soft_group_id) < 0) TEST_ERROR @@ -14487,7 +13506,7 @@ group_info(hid_t fapl) /* Free resources */ if(H5Pclose(gcpl_id) < 0) TEST_ERROR - return 0; + return SUCCEED; error: /* Free resources */ @@ -14498,7 +13517,7 @@ error: H5Fclose(file_id); } H5E_END_TRY; - return -1; + return FAIL; } /* end group_info() */ @@ -14510,18 +13529,14 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Monday, November 27, 2006 - * *------------------------------------------------------------------------- */ static int group_info_old(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t soft_group_id = (-1); /* Group ID for soft links */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t soft_group_id = -1; /* Group ID for soft links */ H5_iter_order_t order; /* Order within in the index */ H5G_info_t grp_info; /* Buffer for querying object's info */ char filename[NAME_BUF_SIZE];/* File name */ @@ -14554,7 +13569,6 @@ group_info_old(hid_t fapl) /* Create old-style group for soft links */ if((soft_group_id = H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* Check for out of bound query by index on empty group */ H5E_BEGIN_TRY { ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &grp_info, H5P_DEFAULT); @@ -14571,7 +13585,6 @@ group_info_old(hid_t fapl) /* Create hard link, with group object */ if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* Retrieve group's information */ if(H5Gget_info(group_id2, &grp_info) < 0) TEST_ERROR @@ -14596,7 +13609,6 @@ group_info_old(hid_t fapl) if(grp_info.max_corder != 0) TEST_ERROR if(grp_info.nlinks != 0) TEST_ERROR - /* Create objects in new group created */ for(v = 0; v <= u; v++) { /* Make name for link */ @@ -14609,7 +13621,6 @@ group_info_old(hid_t fapl) if(H5Gclose(group_id3) < 0) TEST_ERROR } /* end for */ - /* Retrieve group's information */ if(H5Gget_info(group_id2, &grp_info) < 0) TEST_ERROR @@ -14634,7 +13645,6 @@ group_info_old(hid_t fapl) if(grp_info.max_corder != 0) TEST_ERROR if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR - /* Retrieve group's information */ if(order != H5_ITER_NATIVE) { if(order == H5_ITER_INC) { @@ -14653,7 +13663,6 @@ group_info_old(hid_t fapl) /* Close group created */ if(H5Gclose(group_id2) < 0) TEST_ERROR - /* Retrieve main group's information */ if(H5Gget_info(group_id, &grp_info) < 0) TEST_ERROR @@ -14678,7 +13687,6 @@ group_info_old(hid_t fapl) if(grp_info.max_corder != 0) TEST_ERROR if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR - /* Create soft link in another group, to objects in main group */ HDsnprintf(valname, sizeof(valname), "/%s/%s", CORDER_GROUP_NAME, objname); if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -14707,7 +13715,6 @@ group_info_old(hid_t fapl) } H5E_END_TRY; if(ret >= 0) TEST_ERROR - /* Close the groups */ if(H5Gclose(group_id) < 0) TEST_ERROR if(H5Gclose(soft_group_id) < 0) TEST_ERROR @@ -14718,7 +13725,7 @@ group_info_old(hid_t fapl) PASSED(); } /* end for */ - return 0; + return SUCCEED; error: /* Free resources */ @@ -14728,7 +13735,7 @@ error: H5Fclose(file_id); } H5E_END_TRY; - return -1; + return FAIL; } /* end group_info_old() */ @@ -14740,20 +13747,16 @@ error: * * Return: Success: 0 * Failure: -1 - * - * Programmer: Quincey Koziol - * Saturday, March 3, 2007 - * *------------------------------------------------------------------------- */ static int timestamps(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t group_id2 = (-1); /* Group ID */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ - hid_t gcpl_id2 = (-1); /* Group creation property list ID */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t group_id2 = -1; /* Group ID */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + hid_t gcpl_id2 = -1; /* Group creation property list ID */ H5O_info_t oinfo, oinfo2; /* Object info for groups created */ char filename[NAME_BUF_SIZE];/* File name */ hbool_t track_times; /* The object timestamp setting */ @@ -14779,7 +13782,6 @@ timestamps(hid_t fapl) /* Check default timestamp information */ if(track_times != FALSE) TEST_ERROR - /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR @@ -14832,7 +13834,6 @@ timestamps(hid_t fapl) /* Close the file */ if(H5Fclose(file_id) < 0) TEST_ERROR - /* Re-open the file */ if((file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR @@ -14881,7 +13882,7 @@ timestamps(hid_t fapl) PASSED(); - return 0; + return SUCCEED; error: /* Free resources */ @@ -14891,32 +13892,27 @@ error: H5Fclose(file_id); } H5E_END_TRY; - return -1; + return FAIL; } /* end timestamps() */ /*------------------------------------------------------------------------- * Function: main * - * Purpose: Test links - * - * Return: Success: exit(EXIT_SUCCESS) - * - * Failure: exit(EXIT_FAILURE) - * - * Programmer: Robb Matzke - * Friday, August 14, 1998 + * Purpose: Test links * + * Return: Success: exit(EXIT_SUCCESS) + * Failure: exit(EXIT_FAILURE) *------------------------------------------------------------------------- */ int main(void) { - hid_t fapl, fapl2; /* File access property lists */ - int nerrors = 0; - unsigned new_format; /* Whether to use the new format or not */ - unsigned minimize_dset_oh; - unsigned efc; /* Whether to use the external file cache */ + hid_t fapl = -1, fapl2 = -1; /* File access property lists */ + int nerrors = 0; + unsigned new_format; /* Whether to use the new format or not */ + unsigned minimize_dset_oh; + unsigned efc; /* Whether to use the external file cache */ const char *env_h5_drvr; /* File Driver value from environment */ env_h5_drvr = HDgetenv("HDF5_DRIVER"); @@ -14935,7 +13931,8 @@ main(void) HDprintf("\n-Testing with minimzed dataset object headers-\n"); dcpl_g = H5Pcreate(H5P_DATASET_CREATE); if (0 > dcpl_g) TEST_ERROR - } else { + } + else { HDprintf("\n-Testing with unminimzed dataset object headers-\n"); dcpl_g = H5P_DEFAULT; } @@ -14947,14 +13944,14 @@ main(void) if(new_format) { my_fapl = fapl2; HDprintf("\n--Testing with 'new format'--\n"); - } else { + } + else { my_fapl = fapl; HDprintf("\n--Testing with 'old format'--\n"); } /* always enter tests without external cache */ - if(H5Pset_elink_file_cache_size(my_fapl, 0) < 0) - TEST_ERROR + if(H5Pset_elink_file_cache_size(my_fapl, 0) < 0) TEST_ERROR /* General tests... (on both old & new format groups */ nerrors += mklinks(my_fapl, new_format) < 0 ? 1 : 0; @@ -14974,29 +13971,28 @@ main(void) #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* tests for external link */ - /* Test external file cache first, so it sees the default efc setting on - * the fapl */ + /* Test external file cache first, so it sees the default efc setting on the fapl + */ nerrors += external_file_cache(my_fapl, new_format) < 0 ? 1 : 0; /* This test cannot run with the EFC because it assumes that an - * intermediate file is not held open */ + * intermediate file is not held open + */ nerrors += external_link_mult(my_fapl, new_format) < 0 ? 1 : 0; /* This test cannot run with the EFC because the EFC cannot currently - * reopen a cached file with a different intent */ + * reopen a cached file with a different intent + */ nerrors += external_set_elink_acc_flags(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0; - /* Try external link tests both with and without the external file cache - */ + /* Try external link tests both with and without the external file cache */ for(efc = FALSE; efc <= TRUE; efc++) { if(efc) { - if(H5Pset_elink_file_cache_size(my_fapl, 8) < 0) - TEST_ERROR + if(H5Pset_elink_file_cache_size(my_fapl, 8) < 0) TEST_ERROR HDprintf("\n---Testing with external file cache---\n"); } /* end if */ else { - if(H5Pset_elink_file_cache_size(my_fapl, 0) < 0) - TEST_ERROR + if(H5Pset_elink_file_cache_size(my_fapl, 0) < 0) TEST_ERROR HDprintf("\n---Testing without external file cache---\n"); } /* end else */ @@ -15043,7 +14039,7 @@ main(void) nerrors += external_copy_invalid_object(my_fapl, new_format) < 0 ? 1 : 0; nerrors += external_dont_fail_to_source(my_fapl, new_format) < 0 ? 1 : 0; nerrors += external_open_twice(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_with_committed_datatype(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_with_committed_datatype(my_fapl, new_format) < 0 ? 1 : 0; } /* with/without external file cache */ /* These tests assume that external links are a form of UD links, @@ -15078,9 +14074,9 @@ main(void) nerrors += corder_create_empty(fapl2) < 0 ? 1 : 0; /* XXX: when creation order indexing is fully working, go back and add checks -* to these tests to make certain that the creation order values are -* correct. -*/ + * to these tests to make certain that the creation order values are + * correct. + */ nerrors += corder_create_compact(fapl2) < 0 ? 1 : 0; nerrors += corder_create_dense(fapl2) < 0 ? 1 : 0; nerrors += corder_transition(fapl2) < 0 ? 1 : 0; @@ -15102,8 +14098,7 @@ main(void) nerrors += group_info_old(fapl) < 0 ? 1 : 0; if (minimize_dset_oh) { - if (H5Pclose(dcpl_g) < 0) - TEST_ERROR; + if (H5Pclose(dcpl_g) < 0) TEST_ERROR; dcpl_g = -1; } } /* [un]minimized dataset object headers */ @@ -15123,8 +14118,7 @@ main(void) /* Results */ if(nerrors) { - HDprintf("***** %d LINK TEST%s FAILED! *****\n", - nerrors, 1 == nerrors ? "" : "S"); + HDprintf("***** %d LINK TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); HDexit(EXIT_FAILURE); } HDprintf("All link tests passed.\n"); @@ -15137,7 +14131,7 @@ main(void) HDrmdir(TMPDIR); HDrmdir(TMPDIR2); - return 0; + return SUCCEED; error: HDputs("*** TESTS FAILED ***"); -- cgit v0.12 From 8120ba8bc1fab68a999995677a3cd1af2bc1da67 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 31 Jul 2019 16:50:31 -0500 Subject: Fix missing export tag --- test/external_common.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/external_common.h b/test/external_common.h index a2cb03e..f02652b 100644 --- a/test/external_common.h +++ b/test/external_common.h @@ -31,7 +31,15 @@ #define TOTAL_SIZE 100 #define GARBAGE_PER_FILE 10 -H5TEST_DLL herr_t reset_raw_data_files(int); -#endif /* _EXTERNAL_COMMON_H */ +#ifdef __cplusplus +extern "C" { +#endif + +H5TEST_DLL herr_t reset_raw_data_files(hbool_t is_env); +#ifdef __cplusplus +} +#endif + +#endif /* _EXTERNAL_COMMON_H */ -- cgit v0.12 From 438935557e04d6025a389fbe5fccb6290a62c054 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 31 Jul 2019 22:16:50 -0500 Subject: Fixed a couple of typos. --- config/conclude.am | 2 +- config/gnu-flags | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/conclude.am b/config/conclude.am index 2eec03a..58c2934 100644 --- a/config/conclude.am +++ b/config/conclude.am @@ -68,7 +68,7 @@ all-local: $(EXTRA_LIB) $(EXTRA_PROG) $(chk_TESTS) # make install-doc doesn't do anything outside of doc directory, but # Makefiles should recognize it. # UPDATE: docs no longer reside in this build tree, so this target -# is depreciated. +# is deprecated. install-doc uninstall-doc: @echo "Nothing to be done." diff --git a/config/gnu-flags b/config/gnu-flags index ae8ddb0..6355ccf 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -195,7 +195,7 @@ if test "X-gcc" = "X-$cc_vendor"; then # -Wvolatile-register-var was later incorporated into -Wall and # only needs to be specified explicitly for gcc 4.2-4.3 - if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -o $cc_vers_major -eq 4 -a $$cc_vers_minor -le 3; then + if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -o $cc_vers_major -eq 4 -a $cc_vers_minor -le 3; then H5_CFLAGS="$H5_CFLAGS -Wvolatile-register-var" fi -- cgit v0.12 From 4227b8948d7091205b4f8dc1271d7dcae01bb0fb Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 31 Jul 2019 22:51:53 -0500 Subject: Reverts the removal of config/conclude_fc.am while keeping the changes to config/gnu-fflags. --- MANIFEST | 1 + config/conclude_fc.am | 31 +++++++++++++++++++++++++++++++ fortran/examples/Makefile.am | 2 +- fortran/src/Makefile.am | 2 +- fortran/test/Makefile.am | 2 +- fortran/testpar/Makefile.am | 2 +- hl/fortran/examples/Makefile.am | 2 +- hl/fortran/src/Makefile.am | 3 +-- hl/fortran/test/Makefile.am | 2 +- 9 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 config/conclude_fc.am diff --git a/MANIFEST b/MANIFEST index 9c7c0db..594f4bc 100644 --- a/MANIFEST +++ b/MANIFEST @@ -119,6 +119,7 @@ ./config/cce-flags ./config/commence.am ./config/conclude.am +./config/conclude_fc.am ./config/examples.am ./config/freebsd ./config/gnu-cxxflags diff --git a/config/conclude_fc.am b/config/conclude_fc.am new file mode 100644 index 0000000..15d04a7 --- /dev/null +++ b/config/conclude_fc.am @@ -0,0 +1,31 @@ +## config/conclude_fc.am +## (Use double hashes for copyright notice so that automake treats it as +## comments and does not pass it to Makefile.in) +## Copyright by The HDF Group. +## Copyright by the Board of Trustees of the University of Illinois. +## All rights reserved. +## +## This file is part of HDF5. The full HDF5 copyright notice, including +## terms governing use, modification, and redistribution, is contained in +## the COPYING file, which can be found at the root of the source code +## distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +## If you do not have access to either file, you may request a copy from +## help@hdfgroup.org. + + +## Textually included at the end of the Fortran HDF5 Makefiles.am. + +# Makefile.am include fragment with Fortran helper rules and macros. + +# AM_FCCPPFLAGS, FCCPPFLAGS are currently not used. + +PPFCCOMPILE = $(FC) $(FCDEFS) $(DEFAULT_INCLUDES) $(FCINCLUDES) $(AM_FCCPPFLAGS) $(FCCPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS) +LTPPFCCOMPILE = $(LIBTOOL) --tag=FC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(PPFCCOMPILE) + +# Treat all .f90 and .F90 files as preprocessed Fortran. +.f90.o: + $(PPFCCOMPILE) -c -o $@ $< +.F90.o: + $(PPFCCOMPILE) -c -o $@ $< + +include $(top_srcdir)/config/conclude.am diff --git a/fortran/examples/Makefile.am b/fortran/examples/Makefile.am index 00afb3a..6bf2edb 100644 --- a/fortran/examples/Makefile.am +++ b/fortran/examples/Makefile.am @@ -105,4 +105,4 @@ compound_fortran2003: compound_fortran2003.f90 compound_complex_fortran2003: compound_complex_fortran2003.f90 include $(top_srcdir)/config/examples.am -include $(top_srcdir)/config/conclude.am +include $(top_srcdir)/config/conclude_fc.am diff --git a/fortran/src/Makefile.am b/fortran/src/Makefile.am index 3489566..4009439 100644 --- a/fortran/src/Makefile.am +++ b/fortran/src/Makefile.am @@ -165,4 +165,4 @@ HDF5.lo: $(srcdir)/HDF5.F90 H5f90global.lo H5_ff.lo H5Aff.lo \ H5Off.lo H5Pff.lo H5Rff.lo \ H5Sff.lo H5Tff.lo H5Zff.lo H5_gen.lo -include $(top_srcdir)/config/conclude.am +include $(top_srcdir)/config/conclude_fc.am diff --git a/fortran/test/Makefile.am b/fortran/test/Makefile.am index e5fe7d6..f0d7f03 100644 --- a/fortran/test/Makefile.am +++ b/fortran/test/Makefile.am @@ -100,4 +100,4 @@ H5_test_buildiface_LDADD = fflush2.chkexe_: fflush1.chkexe_ -include $(top_srcdir)/config/conclude.am +include $(top_srcdir)/config/conclude_fc.am diff --git a/fortran/testpar/Makefile.am b/fortran/testpar/Makefile.am index 00bc3db..e597a84 100644 --- a/fortran/testpar/Makefile.am +++ b/fortran/testpar/Makefile.am @@ -48,4 +48,4 @@ LDADD=$(LIBH5FTEST) $(LIBH5TEST) $(LIBH5F) $(LIBHDF5) # Mark this directory as part of the Fortran API FORTRAN_API=yes -include $(top_srcdir)/config/conclude.am +include $(top_srcdir)/config/conclude_fc.am diff --git a/hl/fortran/examples/Makefile.am b/hl/fortran/examples/Makefile.am index 71c2866..d383f9a 100644 --- a/hl/fortran/examples/Makefile.am +++ b/hl/fortran/examples/Makefile.am @@ -62,4 +62,4 @@ EXAMPLETOPDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples/hl # and fortran libraries above. include $(top_srcdir)/config/examples.am -include $(top_srcdir)/config/conclude.am +include $(top_srcdir)/config/conclude_fc.am diff --git a/hl/fortran/src/Makefile.am b/hl/fortran/src/Makefile.am index f51d595..37e074c 100644 --- a/hl/fortran/src/Makefile.am +++ b/hl/fortran/src/Makefile.am @@ -114,5 +114,4 @@ H5IMff.lo: $(srcdir)/H5IMff.F90 H5TBff.lo: $(srcdir)/H5TBff.F90 H5LTff_gen.lo: H5LTff.lo H5LTff_gen.F90 H5TBff_gen.lo: H5TBff.lo H5LTff_gen.F90 H5TBff_gen.F90 - -include $(top_srcdir)/config/conclude.am +include $(top_srcdir)/config/conclude_fc.am diff --git a/hl/fortran/test/Makefile.am b/hl/fortran/test/Makefile.am index ef7cd4b..0552aaa 100644 --- a/hl/fortran/test/Makefile.am +++ b/hl/fortran/test/Makefile.am @@ -62,4 +62,4 @@ clean-local: # from tests in conclude.am) FORTRAN_API=yes -include $(top_srcdir)/config/conclude.am +include $(top_srcdir)/config/conclude_fc.am -- cgit v0.12 From 0c374d65c65e1c559efe7f81a4620af2d3676f07 Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Thu, 1 Aug 2019 10:18:45 -0500 Subject: Fix conflicting types for reset_raw_data_files() parameter in external_common.c changed from int to hbool_t. Change 0 and 1 to FALSE and TRUE in calls to reset_raw_data_files(). --- test/external.c | 12 ++++++------ test/external_common.c | 2 +- test/external_env.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/external.c b/test/external.c index 597878f..2a90711 100644 --- a/test/external.c +++ b/test/external.c @@ -636,7 +636,7 @@ test_read_file_set(hid_t fapl) TEST_ERROR /* Reset the raw data files */ - if(reset_raw_data_files(0) < 0) + if(reset_raw_data_files(FALSE) < 0) TEST_ERROR /* Create the file and an initial group. This causes messages about @@ -776,7 +776,7 @@ test_write_file_set(hid_t fapl) } /* end for */ /* Reset the raw data files */ - if(reset_raw_data_files(0) < 0) + if(reset_raw_data_files(FALSE) < 0) TEST_ERROR /* Create the dataset */ @@ -877,7 +877,7 @@ test_path_absolute(hid_t fapl) FAIL_STACK_ERROR /* Reset the raw data files */ - if(reset_raw_data_files(0) < 0) + if(reset_raw_data_files(FALSE) < 0) TEST_ERROR /* Create the dcpl */ @@ -973,7 +973,7 @@ test_path_relative(hid_t fapl) FAIL_STACK_ERROR; /* Reset the raw data files */ - if(reset_raw_data_files(0) < 0) + if(reset_raw_data_files(FALSE) < 0) TEST_ERROR /* Create the dataset */ @@ -1068,7 +1068,7 @@ test_path_relative_cwd(hid_t fapl) FAIL_STACK_ERROR; /* Reset the raw data files */ - if(reset_raw_data_files(0) < 0) + if(reset_raw_data_files(FALSE) < 0) TEST_ERROR /* Create the dataset */ @@ -1210,7 +1210,7 @@ test_h5d_get_access_plist(hid_t fapl_id) TEST_ERROR /* Reset the raw data files */ - if(reset_raw_data_files(0) < 0) + if(reset_raw_data_files(FALSE) < 0) TEST_ERROR /* Create the file */ diff --git a/test/external_common.c b/test/external_common.c index c3aa455..c9b6584 100644 --- a/test/external_common.c +++ b/test/external_common.c @@ -35,7 +35,7 @@ *------------------------------------------------------------------------- */ herr_t -reset_raw_data_files(int is_env) +reset_raw_data_files(hbool_t is_env) { int fd = 0; /* external file descriptor */ size_t i, j; /* iterators */ diff --git a/test/external_env.c b/test/external_env.c index 8ecebf6..0a96f8e 100644 --- a/test/external_env.c +++ b/test/external_env.c @@ -70,7 +70,7 @@ test_path_env(hid_t fapl) FAIL_STACK_ERROR /* Reset the raw data files */ - if(reset_raw_data_files(1) < 0) + if(reset_raw_data_files(TRUE) < 0) TEST_ERROR /* Create the dataset */ -- cgit v0.12 From 4cb865fc5938a303c197aedf46f90021e2f4b3d6 Mon Sep 17 00:00:00 2001 From: "M. Scot Breitenfeld" Date: Thu, 1 Aug 2019 11:37:13 -0500 Subject: enabled commented-out code --- testpar/t_file.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/testpar/t_file.c b/testpar/t_file.c index f670034..4ecfc30 100644 --- a/testpar/t_file.c +++ b/testpar/t_file.c @@ -179,8 +179,6 @@ test_page_buffer_access(void) for(i=0 ; ishared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); - ret = H5PB_flush(f, FALSE); + ret = H5PB_flush(f); VRFY((ret == 0), ""); /* read elements 0 - 200 */ @@ -288,7 +286,6 @@ test_page_buffer_access(void) /* Pop API context */ if(api_ctx_pushed) { ret = H5CX_pop(); VRFY((ret == 0), "H5CX_pop()"); api_ctx_pushed = FALSE; } } -#endif MPI_Barrier(MPI_COMM_WORLD); -- cgit v0.12 From c234479258038be93e059a6964bf19332ef162f8 Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Fri, 2 Aug 2019 09:58:48 -0500 Subject: Update junit.sh.in to copy lib files to $prefix/lib. Correct checking for s3 and hdfs options. --- java/test/junit.sh.in | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/java/test/junit.sh.in b/java/test/junit.sh.in index 008c89c..ac09db7 100644 --- a/java/test/junit.sh.in +++ b/java/test/junit.sh.in @@ -15,6 +15,7 @@ top_builddir=@top_builddir@ top_srcdir=@top_srcdir@ srcdir=@srcdir@ +prefix=@prefix@ USE_FILTER_SZIP="@USE_FILTER_SZIP@" USE_FILTER_DEFLATE="@USE_FILTER_DEFLATE@" @@ -42,7 +43,7 @@ myos=`uname -s` # where the libs exist HDFLIB_HOME="$top_srcdir/java/lib" -BLDLIBDIR="$top_builddir/hdf5/lib" +BLDLIBDIR="$prefix/lib" BLDDIR="." HDFTEST_HOME="$top_srcdir/java/test" JARFILE=jar@PACKAGE_TARNAME@-@PACKAGE_VERSION@.jar @@ -1100,7 +1101,7 @@ if test $USE_FILTER_SZIP = "yes"; then test yes = "$verbose" && $DIFF JUnit-TestH5Giterate.txt JUnit-TestH5Giterate.out |sed 's/^/ /' fi fi -if test $ROS3_VFD = "yes"; then +if test "X$ROS3_VFD" = "Xyes"; then echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Pfapls3" TESTING JUnit-TestH5Pfapls3 ($RUNSERIAL $JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Pfapls3 > JUnit-TestH5Pfapls3.ext) @@ -1122,7 +1123,7 @@ if test $ROS3_VFD = "yes"; then test yes = "$verbose" && $DIFF JUnit-TestH5Pfapls3.txt JUnit-TestH5Pfapls3.out |sed 's/^/ /' fi fi -if test $HAVE_LIBHDFS = "yes"; then +if test "X$HAVE_LIBHDFS" = "Xyes"; then echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Pfaplhdfs" TESTING JUnit-TestH5Pfaplhdfs ($RUNSERIAL $JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Pfaplhdfs > JUnit-TestH5Pfaplhdfs.ext) -- cgit v0.12 From 2b1231ddd89dd2f1b59ec9ca1e4e124d7e76f1b5 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sat, 3 Aug 2019 11:17:53 -0700 Subject: Moved -Wimplicit-procedure gfortran warning to version 4.5 warnings instead of default. --- config/gnu-fflags | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/config/gnu-fflags b/config/gnu-fflags index d6d0b39..3fc112d 100644 --- a/config/gnu-fflags +++ b/config/gnu-fflags @@ -128,7 +128,7 @@ if test "X-gfortran" = "X-$f9x_vendor"; then ########### H5_FCFLAGS="$H5_FCFLAGS -pedantic -Wall -Wextra -Wunderflow -Wimplicit-interface -Wsurprising" - H5_FCFLAGS="$H5_FCFLAGS -Waliasing -Wcharacter-truncation -Wimplicit-procedure" + H5_FCFLAGS="$H5_FCFLAGS -Waliasing -Wcharacter-truncation" ############################# # Version-specific warnings # @@ -141,7 +141,10 @@ if test "X-gfortran" = "X-$f9x_vendor"; then H5_FCFLAGS="$H5_FCFLAGS -Warray-temporaries -Wintrinsics-std" fi - # gfortran 4.5 (nothing new) + # gfortran 4.5 + if test $f9x_vers_major -ge 5 -o $f9x_vers_major -eq 4 -a $f9x_vers_minor -ge 5; then + H5_FCFLAGS="$H5_FCFLAGS -Wimplicit-procedure" + fi # gfortran 4.6 (nothing new) -- cgit v0.12 From 0147a6c713c784f5df9189fc7334c65f54958434 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Sat, 3 Aug 2019 17:28:50 -0500 Subject: Fix VFD tests and repack --- c++/test/CMakeVFDTests.cmake | 81 +++++++++++++++------------- test/CMakeVFDTests.cmake | 1 - testpar/CMakeVFDTests.cmake | 69 +++++++++++++----------- tools/test/h5repack/CMakeTests.cmake | 27 +++++----- tools/test/h5repack/CMakeVFDTests.cmake | 96 +++++++++++++++++++++++---------- 5 files changed, 165 insertions(+), 109 deletions(-) diff --git a/c++/test/CMakeVFDTests.cmake b/c++/test/CMakeVFDTests.cmake index b26165a..fcae446 100644 --- a/c++/test/CMakeVFDTests.cmake +++ b/c++/test/CMakeVFDTests.cmake @@ -15,36 +15,43 @@ ### T E S T I N G ### ############################################################################## ############################################################################## - set (VFD_LIST - sec2 - stdio - core - split - multi - family - ) - if (DIRECT_VFD) - set (VFD_LIST ${VFD_LIST} direct) - endif () +set (VFD_LIST + sec2 + stdio + core + core_paged + split + multi + family +) + +if (DIRECT_VFD) + set (VFD_LIST ${VFD_LIST} direct) +endif () + +############################################################################## +############################################################################## +### T H E T E S T S M A C R O S ### +############################################################################## +############################################################################## - macro (ADD_VFD_TEST vfdname resultcode) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdname}") - add_test ( - NAME CPP_VFD-${vfdname}-cpp_testhdf5-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - tattr_basic.h5 - tattr_compound.h5 - tattr_dtype.h5 - tattr_multi.h5 - tattr_scalar.h5 - tfattrs.h5 - titerate.h5 - WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${vfdname} - ) - add_test ( +macro (ADD_VFD_TEST vfdname resultcode) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdname}") + add_test ( + NAME CPP_VFD-${vfdname}-cpp_testhdf5-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove + tattr_basic.h5 + tattr_compound.h5 + tattr_dtype.h5 + tattr_multi.h5 + tattr_scalar.h5 + tfattrs.h5 + titerate.h5 + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${vfdname} + ) + add_test ( NAME CPP_VFD-${vfdname}-cpp_testhdf5 COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -55,13 +62,13 @@ -D "TEST_OUTPUT=${vfdname}-cpp_testhdf5.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" - ) - set_tests_properties (CPP_VFD-${vfdname}-cpp_testhdf5 PROPERTIES DEPENDS CPP_VFD-${vfdname}-cpp_testhdf5-clear-objects) - set_tests_properties (CPP_VFD-${vfdname}-cpp_testhdf5 PROPERTIES TIMEOUT ${CTEST_SHORT_TIMEOUT}) - endif () - endmacro () + ) + set_tests_properties (CPP_VFD-${vfdname}-cpp_testhdf5 PROPERTIES DEPENDS CPP_VFD-${vfdname}-cpp_testhdf5-clear-objects) + set_tests_properties (CPP_VFD-${vfdname}-cpp_testhdf5 PROPERTIES TIMEOUT ${CTEST_SHORT_TIMEOUT}) + endif () +endmacro () - # Run test with different Virtual File Driver - foreach (vfd ${VFD_LIST}) - ADD_VFD_TEST (${vfd} 0) - endforeach () +# Run test with different Virtual File Driver +foreach (vfd ${VFD_LIST}) + ADD_VFD_TEST (${vfd} 0) +endforeach () diff --git a/test/CMakeVFDTests.cmake b/test/CMakeVFDTests.cmake index 27335ad..cf938f5 100644 --- a/test/CMakeVFDTests.cmake +++ b/test/CMakeVFDTests.cmake @@ -18,7 +18,6 @@ # included from CMakeTEsts.cmake set (VFD_LIST - hdfs sec2 stdio core diff --git a/testpar/CMakeVFDTests.cmake b/testpar/CMakeVFDTests.cmake index 7db99de..8d131db 100644 --- a/testpar/CMakeVFDTests.cmake +++ b/testpar/CMakeVFDTests.cmake @@ -15,32 +15,33 @@ ### T E S T I N G ### ############################################################################## ############################################################################## - set (VFD_LIST - sec2 - stdio - core - split - multi - family - ) +set (VFD_LIST + sec2 + stdio + core + core_paged + split + multi + family +) - set (H5P_VFD_TESTS - t_pflush1 - t_pflush2 - ) +set (H5P_VFD_TESTS + t_pflush1 + t_pflush2 +) - if (DIRECT_VFD) - set (VFD_LIST ${VFD_LIST} direct) - endif () +if (DIRECT_VFD) + set (VFD_LIST ${VFD_LIST} direct) +endif () foreach (vfdtest ${VFD_LIST}) file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdtest}") endforeach () - macro (ADD_VFD_TEST vfdname resultcode) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - foreach (h5_test ${H5P_VFD_TESTS}) - add_test ( +macro (ADD_VFD_TEST vfdname resultcode) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + foreach (h5_test ${H5P_VFD_TESTS}) + add_test ( NAME MPI_TEST_VFD-${vfdname}-${h5_test} COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" @@ -51,16 +52,22 @@ endforeach () -D "TEST_OUTPUT=${vfdname}-${h5_test}.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" - ) - set_tests_properties (MPI_TEST_VFD-${vfdname}-${h5_test} PROPERTIES - ENVIRONMENT "srcdir=${HDF5_TEST_PAR_BINARY_DIR}/${vfdname}" - WORKING_DIRECTORY ${HDF5_TEST_PAR_BINARY_DIR}/${vfdname} - ) - endforeach () - endif () - endmacro () + ) + set_tests_properties (MPI_TEST_VFD-${vfdname}-${h5_test} PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_PAR_BINARY_DIR}/${vfdname}" + WORKING_DIRECTORY ${HDF5_TEST_PAR_BINARY_DIR}/${vfdname} + ) + endforeach () + endif () +endmacro () + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## - # Run test with different Virtual File Driver - foreach (h5_vfd ${VFD_LIST}) - ADD_VFD_TEST (${h5_vfd} 0) - endforeach () +# Run test with different Virtual File Driver +foreach (h5_vfd ${VFD_LIST}) + ADD_VFD_TEST (${h5_vfd} 0) +endforeach () diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index cd20f77..a28a282 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -727,6 +727,7 @@ set (FILE15 h5repack_named_dtypes.h5) set (FILE16 tfamily%05d.h5) # located in common testfiles folder set (FILE18 h5repack_layout2.h5) + set (FILE19 h5repack_layout3.h5) set (FILE_REF h5repack_refs.h5) set (FILE_ATTR_REF h5repack_attr_refs.h5) set (FILEV1 1_vds.h5) @@ -869,11 +870,11 @@ set_tests_properties (H5REPACK-testh5repack_detect_szip PROPERTIES PASS_REGULAR_EXPRESSION "no") endif () set_tests_properties (H5REPACK-testh5repack_detect_szip PROPERTIES DEPENDS H5REPACK-clearall-objects) + set (last_test "H5REPACK-testh5repack_detect_szip") - add_test (NAME H5REPACK-h5repacktest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - set_tests_properties (H5REPACK-h5repacktest PROPERTIES DEPENDS H5REPACK-testh5repack_detect_szip) - set (last_test "H5REPACK-h5repacktest") - +# add_test (NAME H5REPACK-h5repacktest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) +# set_tests_properties (H5REPACK-h5repacktest PROPERTIES DEPENDS H5REPACK-testh5repack_detect_szip) +# set (last_test "H5REPACK-h5repacktest") # # The tests # We use the files generated by h5repacktst @@ -1194,14 +1195,14 @@ # Use first dset to test. #--------------------------------------------------------------------------- # chunk to chunk - specify chunk dim bigger than any current dim - ADD_H5_VERIFY_TEST (chunk2chunk "TEST" 0 h5repack_layout3.h5 chunk_unlimit1 CHUNK -l chunk_unlimit1:CHUNK=100x300) + ADD_H5_VERIFY_TEST (chunk2chunk "TEST" 0 ${FILE19} chunk_unlimit1 CHUNK -l chunk_unlimit1:CHUNK=100x300) # chunk to contiguous - ADD_H5_VERIFY_TEST (chunk2conti "TEST" 0 h5repack_layout3.h5 chunk_unlimit1 CONTI -l chunk_unlimit1:CONTI) + ADD_H5_VERIFY_TEST (chunk2conti "TEST" 0 ${FILE19} chunk_unlimit1 CONTI -l chunk_unlimit1:CONTI) # chunk to compact - convert big dataset (should be > 64k) for this purpose, # should remain as original layout (chunk) - ADD_H5_VERIFY_TEST (chunk2compa "TEST" 0 h5repack_layout3.h5 chunk_unlimit1 CHUNK -l chunk_unlimit1:COMPA) + ADD_H5_VERIFY_TEST (chunk2compa "TEST" 0 ${FILE19} chunk_unlimit1 CHUNK -l chunk_unlimit1:COMPA) #-------------------------------------------------------------------------- # Test -f for some specific cases. Chunked dataset with unlimited max dims. @@ -1211,16 +1212,16 @@ # - should not change max dims from unlimit # chunk dim is bigger than dataset dim. ( dset size < 64k ) - ADD_H5_VERIFY_TEST (error1 "TEST" 0 h5repack_layout3.h5 chunk_unlimit1 H5S_UNLIMITED -f chunk_unlimit1:NONE) + ADD_H5_VERIFY_TEST (error1 "TEST" 0 ${FILE19} chunk_unlimit1 H5S_UNLIMITED -f chunk_unlimit1:NONE) # chunk dim is bigger than dataset dim. ( dset size > 64k ) - ADD_H5_VERIFY_TEST (error2 "TEST" 0 h5repack_layout3.h5 chunk_unlimit2 H5S_UNLIMITED -f chunk_unlimit2:NONE) + ADD_H5_VERIFY_TEST (error2 "TEST" 0 ${FILE19} chunk_unlimit2 H5S_UNLIMITED -f chunk_unlimit2:NONE) # chunk dims are smaller than dataset dims. ( dset size < 64k ) - ADD_H5_VERIFY_TEST (error3 "TEST" 0 h5repack_layout3.h5 chunk_unlimit3 H5S_UNLIMITED -f chunk_unlimit3:NONE) + ADD_H5_VERIFY_TEST (error3 "TEST" 0 ${FILE19} chunk_unlimit3 H5S_UNLIMITED -f chunk_unlimit3:NONE) # file input - should not fail - ADD_H5_TEST (error4 "TEST" h5repack_layout3.h5 -f NONE) + ADD_H5_TEST (error4 "TEST" ${FILE19} -f NONE) #-------------------------------------------------------------------------- # Test base: Convert CHUNK to CONTI for a chunked dataset with small dataset @@ -1228,9 +1229,9 @@ # (HDFFV-8214) #-------------------------------------------------------------------------- # chunk dim is bigger than dataset dim. should succeed. - ADD_H5_VERIFY_TEST (ckdim_biger "TEST" 0 h5repack_layout3.h5 chunk_unlimit2 CONTI -l chunk_unlimit2:CONTI) + ADD_H5_VERIFY_TEST (ckdim_biger "TEST" 0 ${FILE19} chunk_unlimit2 CONTI -l chunk_unlimit2:CONTI) # chunk dim is smaller than dataset dim. should succeed. - ADD_H5_VERIFY_TEST (ckdim_smaller "TEST" 0 h5repack_layout3.h5 chunk_unlimit3 CONTI -l chunk_unlimit3:CONTI) + ADD_H5_VERIFY_TEST (ckdim_smaller "TEST" 0 ${FILE19} chunk_unlimit3 CONTI -l chunk_unlimit3:CONTI) diff --git a/tools/test/h5repack/CMakeVFDTests.cmake b/tools/test/h5repack/CMakeVFDTests.cmake index f88f147..c1a280b 100644 --- a/tools/test/h5repack/CMakeVFDTests.cmake +++ b/tools/test/h5repack/CMakeVFDTests.cmake @@ -16,18 +16,19 @@ ############################################################################## ############################################################################## - set (VFD_LIST - sec2 - stdio - core - split - multi - family - ) +set (VFD_LIST + sec2 + stdio + core + core_paged + split + multi + family +) - if (DIRECT_VFD) - set (VFD_LIST ${VFD_LIST} direct) - endif () +if (DIRECT_VFD) + set (VFD_LIST ${VFD_LIST} direct) +endif () ############################################################################## ############################################################################## @@ -35,20 +36,61 @@ ############################################################################## ############################################################################## - macro (ADD_VFD_TEST vfdname resultcode) +macro (ADD_VFD_TEST vfdname resultcode) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdname}") + add_test ( + NAME H5REPACK-${vfdname}-h5repacktest-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove + bounds_latest_latest.h5 + h5repack_attr.h5 + h5repack_attr_refs.h5 + h5repack_deflate.h5 + h5repack_early.h5 + h5repack_ext.h5 + h5repack_fill.h5 + h5repack_filters.h5 + h5repack_fletcher.h5 + h5repack_hlink.h5 + h5repack_layout.h5 + h5repack_layouto.h5 + h5repack_layout2.h5 + h5repack_layout3.h5 + h5repack_layout.UD.h5 + h5repack_named_dtypes.h5 + h5repack_nested_8bit_enum.h5 + h5repack_nested_8bit_enum_deflated.h5 + h5repack_nbit.h5 + h5repack_objs.h5 + h5repack_refs.h5 + h5repack_shuffle.h5 + h5repack_soffset.h5 + h5repack_szip.h5 + # fsm + h5repack_aggr.h5 + h5repack_fsm_aggr_nopersist.h5 + h5repack_fsm_aggr_persist.h5 + h5repack_none.h5 + h5repack_paged_nopersist.h5 + h5repack_paged_persist.h5 + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${vfdname} + ) add_test ( - NAME H5REPACK-VFD-${vfdname}-h5repacktest - COMMAND "${CMAKE_COMMAND}" - -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=" - -D "TEST_VFD:STRING=${vfdname}" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=h5repacktest" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" + NAME H5REPACK_VFD-${vfdname}-h5repacktest + COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VFD:STRING=${vfdname}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${vfdname}-h5repacktest.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" + -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) - endmacro () + set_tests_properties (H5REPACK_VFD-${vfdname}-h5repacktest PROPERTIES DEPENDS H5REPACK_VFD-${vfdname}-h5repacktest-clear-objects) + set_tests_properties (H5REPACK_VFD-${vfdname}-h5repacktest PROPERTIES TIMEOUT ${CTEST_SHORT_TIMEOUT}) + endif () +endmacro () ############################################################################## ############################################################################## @@ -56,7 +98,7 @@ ############################################################################## ############################################################################## - # Run test with different Virtual File Driver - foreach (vfd ${VFD_LIST}) - ADD_VFD_TEST (${vfd} 0) - endforeach () +# Run test with different Virtual File Driver +foreach (vfd ${VFD_LIST}) + ADD_VFD_TEST (${vfd} 0) +endforeach () -- cgit v0.12 From 4cd461168ef6dbd799792b1893c41dccebae59f9 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 4 Aug 2019 09:12:43 -0700 Subject: Fixed warning typo --- config/cmake/HDFCompilerFlags.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index d658c48..aea417a 100644 --- a/config/cmake/HDFCompilerFlags.cmake +++ b/config/cmake/HDFCompilerFlags.cmake @@ -210,7 +210,7 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC) # Append more extra warning flags that only gcc 9.x+ know about if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0) - set (H5_CFLAGS4 "${H5_CFLAGS4} Wattribute-alias=2 -Wmissing-profile") + set (H5_CFLAGS4 "${H5_CFLAGS4} -Wattribute-alias=2 -Wmissing-profile") endif () endif () -- cgit v0.12 From c60ceb8c08b6c5472bd79ebf2464b2409a398919 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Sun, 4 Aug 2019 15:19:04 -0500 Subject: Merge reconciliation and VFD test fixes --- MANIFEST | 1 + examples/h5_extend_write.c | 6 +- test/cache_image.c | 6 +- test/dsets.c | 519 +++++++++++++++++----------------- test/error_test.c | 54 ++-- test/flush2.c | 8 +- test/gheap.c | 26 +- test/h5test.c | 2 - test/mf.c | 1 - tools/src/h5dump/h5dump.c | 1 - tools/src/h5ls/h5ls.c | 1 - tools/src/h5stat/h5stat.c | 13 +- tools/test/h5dump/CMakeTests.cmake | 10 + tools/test/h5dump/CMakeVFDTests.cmake | 91 ++++++ tools/test/h5dump/h5dumpgentest.c | 12 +- tools/test/misc/CMakeLists.txt | 18 +- 16 files changed, 438 insertions(+), 331 deletions(-) create mode 100644 tools/test/h5dump/CMakeVFDTests.cmake diff --git a/MANIFEST b/MANIFEST index 594f4bc..83c03a5 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3393,6 +3393,7 @@ ./tools/test/h5dump/CMakeTestsPBITS.cmake ./tools/test/h5dump/CMakeTestsXML.cmake ./tools/test/h5dump/CMakeTestsVDS.cmake +./tools/test/h5dump/CMakeVFDTests.cmake ./tools/src/h5format_convert/CMakeLists.txt ./tools/test/h5format_convert/CMakeLists.txt ./tools/test/h5format_convert/CMakeTests.cmake diff --git a/examples/h5_extend_write.c b/examples/h5_extend_write.c index f3f6077..4abda30 100644 --- a/examples/h5_extend_write.c +++ b/examples/h5_extend_write.c @@ -163,9 +163,9 @@ main (void) /* * Resulting dataset * - * 1 1 1 3 3 - * 1 1 1 3 3 - * 1 1 1 0 0 + * 1 1 1 3 3 + * 1 1 1 3 3 + * 1 1 1 0 0 * 2 0 0 0 0 * 2 0 0 0 0 * 2 0 0 0 0 diff --git a/test/cache_image.c b/test/cache_image.c index f8252ac..9150836 100644 --- a/test/cache_image.c +++ b/test/cache_image.c @@ -93,7 +93,6 @@ static unsigned evict_on_close_test(hbool_t single_file_vfd); #define DSET_SIZE (40 * CHUNK_SIZE) #define MAX_NUM_DSETS 256 - static void create_datasets(hid_t file_id, int min_dset, int max_dset) { @@ -4486,7 +4485,6 @@ cache_image_smoke_check_4(hbool_t single_file_vfd) if ( show_progress ) HDfprintf(stdout, "%s:L3 cp = %d, max_dset = %d, pass = %d.\n", fcn_name, cp + 2, max_dset, pass); - } /* end while */ cp += 3; @@ -5111,8 +5109,8 @@ cache_image_smoke_check_5(hbool_t single_file_vfd) * extension message has been deleted. */ i = min_group; - while ( ( pass ) && ( i <= max_group ) ) { - sprintf(process_group_name, "/process_%d", i); + while ( ( pass ) && ( i <= max_group ) ) { + sprintf(process_group_name, "/process_%d", i); validate_zoo(file_id, process_group_name, i++); } diff --git a/test/dsets.c b/test/dsets.c index 5976df5..50a6907 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -88,7 +88,6 @@ const char *FILENAME[] = { #define OHMIN_FILENAME_A "ohdr_min_a" - #define FILENAME_BUF_SIZE 1024 #define KB 1024 @@ -401,7 +400,7 @@ test_create(hid_t file) } H5E_END_TRY; if(dataset >= 0) { H5_FAILED(); - puts(" Library allowed overwrite of existing dataset."); + HDputs(" Library allowed overwrite of existing dataset."); goto error; } @@ -423,7 +422,7 @@ test_create(hid_t file) } H5E_END_TRY; if(dataset >= 0) { H5_FAILED(); - puts(" Opened a non-existent dataset."); + HDputs(" Opened a non-existent dataset."); goto error; } @@ -445,7 +444,7 @@ test_create(hid_t file) } H5E_END_TRY; if(dataset >= 0) { H5_FAILED(); - puts(" Opened a dataset with incorrect chunking parameters."); + HDputs(" Opened a dataset with incorrect chunking parameters."); goto error; } @@ -566,8 +565,8 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) for(j = 0; j < DSET_DIM2; j++) { if(points[i][j] != check[i][j]) { H5_FAILED(); - printf(" Read different values than written.\n"); - printf(" At index %d,%d\n", i, j); + HDprintf(" Read different values than written.\n"); + HDprintf(" At index %d,%d\n", i, j); goto error; } } @@ -590,8 +589,8 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) for(j = 0; j < DSET_DIM2; j++) { if(points[i][j] != rdata[i][j]) { H5_FAILED(); - printf(" Read different values than written.\n"); - printf(" At index %d,%d\n", i, j); + HDprintf(" Read different values than written.\n"); + HDprintf(" At index %d,%d\n", i, j); goto error; } } @@ -605,7 +604,7 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) } /* end if */ else { SKIPPED(); - puts(" Current VFD doesn't support continuous address space"); + HDputs(" Current VFD doesn't support continuous address space"); } /* end else */ return SUCCEED; @@ -699,8 +698,8 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) for(j = 0; j < DSET_DIM2; j++) { if(points[i][j] != rdata[i][j]) { H5_FAILED(); - printf(" Read different values than written.\n"); - printf(" At index %d,%d\n", i, j); + HDprintf(" Read different values than written.\n"); + HDprintf(" At index %d,%d\n", i, j); goto error; } } @@ -713,7 +712,7 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) } /* end if */ else { SKIPPED(); - puts(" Current VFD doesn't support continuous address space"); + HDputs(" Current VFD doesn't support continuous address space"); } /* end else */ return SUCCEED; @@ -814,10 +813,10 @@ test_compact_io(hid_t fapl) for(j = 0; j < 8; j++) if(rbuf[i][j] != wbuf[i][j]) { H5_FAILED(); - printf(" Read different values than written.\n"); - printf(" At index %d,%d\n", i, j); - printf(" wbuf[%d][%d]=%d\n", i, j, wbuf[i][j]); - printf(" rbuf[%d][%d]=%d\n", i, j, rbuf[i][j]); + HDprintf(" Read different values than written.\n"); + HDprintf(" At index %d,%d\n", i, j); + HDprintf(" wbuf[%d][%d]=%d\n", i, j, wbuf[i][j]); + HDprintf(" rbuf[%d][%d]=%d\n", i, j, rbuf[i][j]); goto error; } /* end */ @@ -872,10 +871,10 @@ test_compact_io(hid_t fapl) for(j = 0; j < 8; j++) if(rbuf[i][j] != wbuf[i][j]) { H5_FAILED(); - printf(" Read different values than written.\n"); - printf(" At index %d,%d\n", i, j); - printf(" wbuf[%d][%d]=%d\n", i, j, wbuf[i][j]); - printf(" rbuf[%d][%d]=%d\n", i, j, rbuf[i][j]); + HDprintf(" Read different values than written.\n"); + HDprintf(" At index %d,%d\n", i, j); + HDprintf(" wbuf[%d][%d]=%d\n", i, j, wbuf[i][j]); + HDprintf(" rbuf[%d][%d]=%d\n", i, j, rbuf[i][j]); goto error; } /* end */ @@ -1013,8 +1012,8 @@ test_max_compact(hid_t fapl) for(u = 0; u < compact_size; u++) if(rbuf[u] != wbuf[u]) { H5_FAILED(); - printf(" Read different values than written.\n"); - printf(" At index %u\n", (unsigned)u); + HDprintf(" Read different values than written.\n"); + HDprintf(" At index %u\n", (unsigned)u); goto error; } /* end if */ @@ -1313,7 +1312,7 @@ test_conv_buffer(hid_t fid) } H5E_END_TRY; if(status >= 0) { H5_FAILED(); - puts(" Library shouldn't allow conversion buffer too small"); + HDputs(" Library shouldn't allow conversion buffer too small"); goto error; } @@ -1338,7 +1337,7 @@ test_conv_buffer(hid_t fid) HDfree(cf); HDfree(cfrR); - puts(" PASSED"); + HDputs(" PASSED"); return SUCCEED; error: @@ -1415,7 +1414,7 @@ test_tconv(hid_t file) in[4 * i + 2] != out[4 * i + 1] || in[4 * i + 3] != out[4 * i + 0]) { H5_FAILED(); - puts(" Read with byte order conversion failed."); + HDputs(" Read with byte order conversion failed."); goto error; } } @@ -1425,7 +1424,7 @@ test_tconv(hid_t file) HDfree(out); HDfree(in); - puts(" PASSED"); + HDputs(" PASSED"); return SUCCEED; error: @@ -1771,7 +1770,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, /* Check if all the filters are available */ if(H5Pall_filters_avail(dcpl)!=TRUE) { H5_FAILED(); - printf(" Line %d: Incorrect filter availability\n",__LINE__); + HDprintf(" Line %d: Incorrect filter availability\n",__LINE__); goto error; } /* end if */ @@ -1794,8 +1793,8 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, for(j=0; j<(size_t)size[1]; j++) { if(0!=check[i][j]) { H5_FAILED(); - printf(" Read a non-zero value.\n"); - printf(" At index %lu,%lu\n", + HDprintf(" Read a non-zero value.\n"); + HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); goto error; } @@ -1860,10 +1859,10 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, for(j=0; j HDpow(10.0F, -3.0F)) { H5_FAILED(); - printf(" Read different values than written.\n"); - printf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); + HDprintf(" Read different values than written.\n"); + HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); goto error; } } @@ -4931,8 +4930,8 @@ test_scaleoffset_float_2(hid_t file) for(j=0; j<(size_t)size[1]; j++) { if(HDfabs(new_data[0][j]-orig_data[0][j]) > HDpow(10.0F, -3.0F)) { H5_FAILED(); - printf(" Read different values than written.\n"); - printf(" At index %lu,%lu\n", (unsigned long)0, (unsigned long)j); + HDprintf(" Read different values than written.\n"); + HDprintf(" At index %lu,%lu\n", (unsigned long)0, (unsigned long)j); goto error; } } @@ -5042,8 +5041,8 @@ test_scaleoffset_double(hid_t file) for(j=0; j<(size_t)size[1]; j++) { if(HDfabs(new_data[i][j]-orig_data[i][j]) > HDpow(10.0F, -7.0F)) { H5_FAILED(); - printf(" Read different values than written.\n"); - printf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); + HDprintf(" Read different values than written.\n"); + HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); goto error; } } @@ -5173,8 +5172,8 @@ test_scaleoffset_double_2(hid_t file) for(j=0; j<(size_t)size[1]; j++) { if(HDfabs(new_data[0][j]-orig_data[0][j]) > HDpow(10.0F, -7.0F)) { H5_FAILED(); - printf(" Read different values than written.\n"); - printf(" At index %lu,%lu\n", (unsigned long)0, (unsigned long)j); + HDprintf(" Read different values than written.\n"); + HDprintf(" At index %lu,%lu\n", (unsigned long)0, (unsigned long)j); goto error; } } @@ -5240,7 +5239,7 @@ test_multiopen (hid_t file) if(H5Sget_simple_extent_dims(space, tmp_size, NULL) < 0) goto error; if(cur_size[0] != tmp_size[0]) { H5_FAILED(); - printf(" Got %d instead of %d!\n", (int)tmp_size[0], (int)cur_size[0]); + HDprintf(" Got %d instead of %d!\n", (int)tmp_size[0], (int)cur_size[0]); goto error; } /* end if */ @@ -5402,30 +5401,30 @@ test_can_apply(hid_t file) /* Create dcpl with special filter */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { H5_FAILED(); - printf(" Line %d: Can't create dcpl\n",__LINE__); + HDprintf(" Line %d: Can't create dcpl\n",__LINE__); goto error; } /* end if */ if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) { H5_FAILED(); - printf(" Line %d: Can't set chunk sizes\n",__LINE__); + HDprintf(" Line %d: Can't set chunk sizes\n",__LINE__); goto error; } /* end if */ if(H5Zregister (H5Z_CAN_APPLY_TEST) < 0) { H5_FAILED(); - printf(" Line %d: Can't register 'can apply' filter\n",__LINE__); + HDprintf(" Line %d: Can't register 'can apply' filter\n",__LINE__); goto error; } /* The filter is mandate. */ if(H5Pset_filter(dcpl, H5Z_FILTER_CAN_APPLY_TEST, 0, (size_t)0, NULL) < 0) { H5_FAILED(); - printf(" Line %d: Can't set bogus filter\n",__LINE__); + HDprintf(" Line %d: Can't set bogus filter\n",__LINE__); goto error; } /* Create the data space */ if((sid = H5Screate_simple(2, dims, NULL)) < 0) { H5_FAILED(); - printf(" Line %d: Can't open dataspace\n",__LINE__); + HDprintf(" Line %d: Can't open dataspace\n",__LINE__); goto error; } /* end if */ @@ -5437,7 +5436,7 @@ test_can_apply(hid_t file) } H5E_END_TRY; if(dsid >=0) { H5_FAILED(); - printf(" Line %d: Shouldn't have created dataset!\n",__LINE__); + HDprintf(" Line %d: Shouldn't have created dataset!\n",__LINE__); H5Dclose(dsid); goto error; } /* end if */ @@ -5448,7 +5447,7 @@ test_can_apply(hid_t file) } H5E_END_TRY; if(dsid >=0) { H5_FAILED(); - printf(" Line %d: Shouldn't have created dataset!\n",__LINE__); + HDprintf(" Line %d: Shouldn't have created dataset!\n",__LINE__); H5Dclose(dsid); goto error; } /* end if */ @@ -5456,42 +5455,42 @@ test_can_apply(hid_t file) /* Create new dataset */ if((dsid = H5Dcreate2(file, DSET_CAN_APPLY_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { H5_FAILED(); - printf(" Line %d: Can't create dataset\n",__LINE__); + HDprintf(" Line %d: Can't create dataset\n",__LINE__); goto error; } /* end if */ /* Write data */ if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) { H5_FAILED(); - printf(" Line %d: Error writing dataset data\n",__LINE__); + HDprintf(" Line %d: Error writing dataset data\n",__LINE__); goto error; } /* end if */ /* Flush the file (to clear the cache) */ if(H5Fflush(file, H5F_SCOPE_GLOBAL) < 0) { H5_FAILED(); - printf(" Line %d: Error flushing file\n",__LINE__); + HDprintf(" Line %d: Error flushing file\n",__LINE__); goto error; } /* end if */ /* Query the dataset's size on disk */ if((dset_size=H5Dget_storage_size(dsid))==0) { H5_FAILED(); - printf(" Line %d: Error querying dataset size\n",__LINE__); + HDprintf(" Line %d: Error querying dataset size\n",__LINE__); goto error; } /* end if */ /* Verify that the size indicates data is uncompressed */ if((H5Tget_size(H5T_NATIVE_INT)*dims[0]*dims[1])!=dset_size) { H5_FAILED(); - printf(" Line %d: Incorrect dataset size: %lu\n",__LINE__,(unsigned long)dset_size); + HDprintf(" Line %d: Incorrect dataset size: %lu\n",__LINE__,(unsigned long)dset_size); goto error; } /* end if */ /* Read data */ if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0) { H5_FAILED(); - printf(" Line %d: Error reading dataset data\n",__LINE__); + HDprintf(" Line %d: Error reading dataset data\n",__LINE__); goto error; } /* end if */ @@ -5501,10 +5500,10 @@ test_can_apply(hid_t file) for(j=0; j<(size_t)dims[1]; j++) { if(points[i][j] != check[i][j]) { H5_FAILED(); - printf(" Line %d: Read different values than written.\n",__LINE__); - printf(" At index %lu,%lu\n", (unsigned long)(i), (unsigned long)(j)); - printf(" At original: %d\n",points[i][j]); - printf(" At returned: %d\n",check[i][j]); + HDprintf(" Line %d: Read different values than written.\n",__LINE__); + HDprintf(" At index %lu,%lu\n", (unsigned long)(i), (unsigned long)(j)); + HDprintf(" At original: %d\n",points[i][j]); + HDprintf(" At returned: %d\n",check[i][j]); goto error; } /* end if */ } /* end for */ @@ -5513,21 +5512,21 @@ test_can_apply(hid_t file) /* Close dataset */ if(H5Dclose(dsid) < 0) { H5_FAILED(); - printf(" Line %d: Can't close dataset\n",__LINE__); + HDprintf(" Line %d: Can't close dataset\n",__LINE__); goto error; } /* end if */ /* Close dataspace */ if(H5Sclose(sid) < 0) { H5_FAILED(); - printf(" Line %d: Can't close dataspace\n",__LINE__); + HDprintf(" Line %d: Can't close dataspace\n",__LINE__); goto error; } /* end if */ /* Close dataset creation property list */ if(H5Pclose(dcpl) < 0) { H5_FAILED(); - printf(" Line %d: Can't close dcpl\n",__LINE__); + HDprintf(" Line %d: Can't close dcpl\n",__LINE__); goto error; } /* end if */ @@ -5585,72 +5584,72 @@ test_can_apply2(hid_t file) /* Create dcpl with special filter */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { H5_FAILED(); - printf(" Line %d: Can't create dcpl\n",__LINE__); + HDprintf(" Line %d: Can't create dcpl\n",__LINE__); goto error; } /* end if */ if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) { H5_FAILED(); - printf(" Line %d: Can't set chunk sizes\n",__LINE__); + HDprintf(" Line %d: Can't set chunk sizes\n",__LINE__); goto error; } /* end if */ if(H5Zregister (H5Z_CAN_APPLY_TEST2) < 0) { H5_FAILED(); - printf(" Line %d: Can't register 'can apply' filter\n",__LINE__); + HDprintf(" Line %d: Can't register 'can apply' filter\n",__LINE__); goto error; } /* The filter is optional. */ if(H5Pset_filter(dcpl, H5Z_FILTER_CAN_APPLY_TEST2, H5Z_FLAG_OPTIONAL, (size_t)0, NULL) < 0) { H5_FAILED(); - printf(" Line %d: Can't set bogus filter\n",__LINE__); + HDprintf(" Line %d: Can't set bogus filter\n",__LINE__); goto error; } /* Create the data space */ if((sid = H5Screate_simple(2, dims, NULL)) < 0) { H5_FAILED(); - printf(" Line %d: Can't open dataspace\n",__LINE__); + HDprintf(" Line %d: Can't open dataspace\n",__LINE__); goto error; } /* end if */ /* Create new dataset */ if((dsid = H5Dcreate2(file, DSET_CAN_APPLY_NAME2, H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { H5_FAILED(); - printf(" Line %d: Can't create dataset\n",__LINE__); + HDprintf(" Line %d: Can't create dataset\n",__LINE__); goto error; } /* end if */ /* Write data */ if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) { H5_FAILED(); - printf(" Line %d: Error writing dataset data\n",__LINE__); + HDprintf(" Line %d: Error writing dataset data\n",__LINE__); goto error; } /* end if */ /* Flush the file (to clear the cache) */ if(H5Fflush(file, H5F_SCOPE_GLOBAL) < 0) { H5_FAILED(); - printf(" Line %d: Error flushing file\n",__LINE__); + HDprintf(" Line %d: Error flushing file\n",__LINE__); goto error; } /* end if */ /* Query the dataset's size on disk */ if((dset_size=H5Dget_storage_size(dsid))==0) { H5_FAILED(); - printf(" Line %d: Error querying dataset size\n",__LINE__); + HDprintf(" Line %d: Error querying dataset size\n",__LINE__); goto error; } /* end if */ /* Verify that the size indicates data is uncompressed */ if((H5Tget_size(H5T_NATIVE_DOUBLE)*dims[0]*dims[1])!=dset_size) { H5_FAILED(); - printf(" Line %d: Incorrect dataset size: %lu\n",__LINE__,(unsigned long)dset_size); + HDprintf(" Line %d: Incorrect dataset size: %lu\n",__LINE__,(unsigned long)dset_size); goto error; } /* end if */ /* Read data */ if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0) { H5_FAILED(); - printf(" Line %d: Error reading dataset data\n",__LINE__); + HDprintf(" Line %d: Error reading dataset data\n",__LINE__); goto error; } /* end if */ @@ -5660,10 +5659,10 @@ test_can_apply2(hid_t file) for(j=0; j<(size_t)dims[1]; j++) { if(points[i][j] != check[i][j]) { H5_FAILED(); - printf(" Line %d: Read different values than written.\n",__LINE__); - printf(" At index %lu,%lu\n", (unsigned long)(i), (unsigned long)(j)); - printf(" At original: %d\n",points[i][j]); - printf(" At returned: %d\n",check[i][j]); + HDprintf(" Line %d: Read different values than written.\n",__LINE__); + HDprintf(" At index %lu,%lu\n", (unsigned long)(i), (unsigned long)(j)); + HDprintf(" At original: %d\n",points[i][j]); + HDprintf(" At returned: %d\n",check[i][j]); goto error; } /* end if */ } /* end for */ @@ -5672,21 +5671,21 @@ test_can_apply2(hid_t file) /* Close dataset */ if(H5Dclose(dsid) < 0) { H5_FAILED(); - printf(" Line %d: Can't close dataset\n",__LINE__); + HDprintf(" Line %d: Can't close dataset\n",__LINE__); goto error; } /* end if */ /* Close dataspace */ if(H5Sclose(sid) < 0) { H5_FAILED(); - printf(" Line %d: Can't close dataspace\n",__LINE__); + HDprintf(" Line %d: Can't close dataspace\n",__LINE__); goto error; } /* end if */ /* Close dataset creation property list */ if(H5Pclose(dcpl) < 0) { H5_FAILED(); - printf(" Line %d: Can't close dcpl\n",__LINE__); + HDprintf(" Line %d: Can't close dcpl\n",__LINE__); goto error; } /* end if */ @@ -5742,19 +5741,19 @@ file) /* Create the data space */ if((sid = H5Screate_simple(2, dims, NULL)) < 0) { H5_FAILED(); - printf(" Line %d: Can't open dataspace\n",__LINE__); + HDprintf(" Line %d: Can't open dataspace\n",__LINE__); goto error; } /* end if */ /* Create dcpl with special filter */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { H5_FAILED(); - printf(" Line %d: Can't create dcpl\n",__LINE__); + HDprintf(" Line %d: Can't create dcpl\n",__LINE__); goto error; } /* end if */ if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) { H5_FAILED(); - printf(" Line %d: Can't set chunk sizes\n",__LINE__); + HDprintf(" Line %d: Can't set chunk sizes\n",__LINE__); goto error; } /* end if */ @@ -5765,7 +5764,7 @@ file) } H5E_END_TRY; if(ret>=0) { H5_FAILED(); - printf(" Line %d: Shouldn't be able to set szip filter\n",__LINE__); + HDprintf(" Line %d: Shouldn't be able to set szip filter\n",__LINE__); goto error; } @@ -5776,7 +5775,7 @@ file) } H5E_END_TRY; if(ret>=0) { H5_FAILED(); - printf(" Line %d: Shouldn't be able to set szip filter\n",__LINE__); + HDprintf(" Line %d: Shouldn't be able to set szip filter\n",__LINE__); goto error; } @@ -5784,7 +5783,7 @@ file) szip_pixels_per_block=2; if(H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block) < 0) { H5_FAILED(); - printf(" Line %d: Can't set szip filter\n",__LINE__); + HDprintf(" Line %d: Can't set szip filter\n",__LINE__); goto error; } @@ -5796,47 +5795,47 @@ file) } H5E_END_TRY; if(dsid <=0) { H5_FAILED(); - printf(" Line %d: Should have created dataset!\n",__LINE__); + HDprintf(" Line %d: Should have created dataset!\n",__LINE__); goto error; } /* end if */ /* Close dataset */ if(H5Dclose(dsid) < 0) { H5_FAILED(); - printf(" Line %d: Can't close dataset\n",__LINE__); + HDprintf(" Line %d: Can't close dataset\n",__LINE__); goto error; } /* end if */ /* Close dataspace */ if(H5Sclose(sid) < 0) { H5_FAILED(); - printf(" Line %d: Can't close dataspace\n",__LINE__); + HDprintf(" Line %d: Can't close dataspace\n",__LINE__); goto error; } /* end if */ /* Close dataset creation property list */ if(H5Pclose(dcpl) < 0) { H5_FAILED(); - printf(" Line %d: Can't close dcpl\n",__LINE__); + HDprintf(" Line %d: Can't close dcpl\n",__LINE__); goto error; } /* end if */ /* Create another data space */ if((sid = H5Screate_simple(2, dims2, NULL)) < 0) { H5_FAILED(); - printf(" Line %d: Can't open dataspace\n",__LINE__); + HDprintf(" Line %d: Can't open dataspace\n",__LINE__); goto error; } /* end if */ /* Create dcpl with special filter */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { H5_FAILED(); - printf(" Line %d: Can't create dcpl\n",__LINE__); + HDprintf(" Line %d: Can't create dcpl\n",__LINE__); goto error; } /* end if */ if(H5Pset_chunk(dcpl, 2, chunk_dims2) < 0) { H5_FAILED(); - printf(" Line %d: Can't set chunk sizes\n",__LINE__); + HDprintf(" Line %d: Can't set chunk sizes\n",__LINE__); goto error; } /* end if */ @@ -5844,7 +5843,7 @@ file) szip_pixels_per_block=32; if(H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block) < 0) { H5_FAILED(); - printf(" Line %d: Can't set szip filter\n",__LINE__); + HDprintf(" Line %d: Can't set szip filter\n",__LINE__); goto error; } @@ -5855,7 +5854,7 @@ file) } H5E_END_TRY; if(dsid >=0) { H5_FAILED(); - printf(" Line %d: Shouldn't have created dataset!\n",__LINE__); + HDprintf(" Line %d: Shouldn't have created dataset!\n",__LINE__); H5Dclose(dsid); goto error; } /* end if */ @@ -5863,14 +5862,14 @@ file) /* Close dataspace */ if(H5Sclose(sid) < 0) { H5_FAILED(); - printf(" Line %d: Can't close dataspace\n",__LINE__); + HDprintf(" Line %d: Can't close dataspace\n",__LINE__); goto error; } /* end if */ /* Close dataset creation property list */ if(H5Pclose(dcpl) < 0) { H5_FAILED(); - printf(" Line %d: Can't close dcpl\n",__LINE__); + HDprintf(" Line %d: Can't close dcpl\n",__LINE__); goto error; } /* end if */ @@ -5878,11 +5877,11 @@ file) PASSED(); } else { SKIPPED(); - puts(" Szip encoding is not enabled."); + HDputs(" Szip encoding is not enabled."); } #else /* H5_HAVE_FILTER_SZIP */ SKIPPED(); - puts(" Szip filter is not enabled."); + HDputs(" Szip filter is not enabled."); #endif /* H5_HAVE_FILTER_SZIP */ return SUCCEED; @@ -5948,57 +5947,57 @@ test_set_local(hid_t fapl) /* Open file */ if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { H5_FAILED(); - printf(" Line %d: Can't open file\n",__LINE__); + HDprintf(" Line %d: Can't open file\n",__LINE__); goto error; } /* Create dcpl with special filter */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { H5_FAILED(); - printf(" Line %d: Can't create dcpl\n",__LINE__); + HDprintf(" Line %d: Can't create dcpl\n",__LINE__); goto error; } /* end if */ if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) { H5_FAILED(); - printf(" Line %d: Can't set chunk sizes\n",__LINE__); + HDprintf(" Line %d: Can't set chunk sizes\n",__LINE__); goto error; } /* end if */ if(H5Zregister (H5Z_SET_LOCAL_TEST) < 0) { H5_FAILED(); - printf(" Line %d: Can't register 'set local' filter\n",__LINE__); + HDprintf(" Line %d: Can't register 'set local' filter\n",__LINE__); goto error; } if(H5Pset_filter(dcpl, H5Z_FILTER_SET_LOCAL_TEST, 0, (size_t)BOGUS2_PERM_NPARMS, cd_values) < 0) { H5_FAILED(); - printf(" Line %d: Can't set bogus2 filter\n",__LINE__); + HDprintf(" Line %d: Can't set bogus2 filter\n",__LINE__); goto error; } /* Create the data space */ if((sid = H5Screate_simple(2, dims, NULL)) < 0) { H5_FAILED(); - printf(" Line %d: Can't open dataspace\n",__LINE__); + HDprintf(" Line %d: Can't open dataspace\n",__LINE__); goto error; } /* end if */ /* Create new dataset */ if((dsid = H5Dcreate2(file, DSET_SET_LOCAL_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { H5_FAILED(); - printf(" Line %d: Can't create dataset\n",__LINE__); + HDprintf(" Line %d: Can't create dataset\n",__LINE__); goto error; } /* end if */ /* Write data */ if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) { H5_FAILED(); - printf(" Line %d: Error writing dataset data\n",__LINE__); + HDprintf(" Line %d: Error writing dataset data\n",__LINE__); goto error; } /* end if */ /* Close dataset */ if(H5Dclose(dsid) < 0) { H5_FAILED(); - printf(" Line %d: Can't close dataset\n",__LINE__); + HDprintf(" Line %d: Can't close dataset\n",__LINE__); goto error; } /* end if */ @@ -6006,77 +6005,77 @@ test_set_local(hid_t fapl) /* (Shouldn't get modified by output filter) */ if((dsid = H5Dcreate2(file, DSET_SET_LOCAL_NAME_2, H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { H5_FAILED(); - printf(" Line %d: Can't create dataset\n",__LINE__); + HDprintf(" Line %d: Can't create dataset\n",__LINE__); goto error; } /* end if */ /* Write data */ if(H5Dwrite(dsid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_dbl) < 0) { H5_FAILED(); - printf(" Line %d: Error writing dataset data\n",__LINE__); + HDprintf(" Line %d: Error writing dataset data\n",__LINE__); goto error; } /* end if */ /* Close dataset */ if(H5Dclose(dsid) < 0) { H5_FAILED(); - printf(" Line %d: Can't close dataset\n",__LINE__); + HDprintf(" Line %d: Can't close dataset\n",__LINE__); goto error; } /* end if */ /* Close dataspace */ if(H5Sclose(sid) < 0) { H5_FAILED(); - printf(" Line %d: Can't close dataspace\n", __LINE__); + HDprintf(" Line %d: Can't close dataspace\n", __LINE__); goto error; } /* end if */ /* Close dataset creation property list */ if(H5Pclose(dcpl) < 0) { H5_FAILED(); - printf(" Line %d: Can't close dcpl\n", __LINE__); + HDprintf(" Line %d: Can't close dcpl\n", __LINE__); goto error; } /* end if */ /* Close file (flushes & empties cache) */ if(H5Fclose(file) < 0) { H5_FAILED(); - printf(" Line %d: Can't close file\n", __LINE__); + HDprintf(" Line %d: Can't close file\n", __LINE__); goto error; } /* end if */ /* Open file */ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) { H5_FAILED(); - printf(" Line %d: Can't open file\n", __LINE__); + HDprintf(" Line %d: Can't open file\n", __LINE__); goto error; } /* Re-open dataset */ if((dsid = H5Dopen2(file, DSET_SET_LOCAL_NAME, H5P_DEFAULT)) < 0) { H5_FAILED(); - printf(" Line %d: Can't open dataset\n", __LINE__); + HDprintf(" Line %d: Can't open dataset\n", __LINE__); goto error; } /* end if */ /* Query the dataset's size on disk */ if((dset_size = H5Dget_storage_size(dsid)) == 0) { H5_FAILED(); - printf(" Line %d: Error querying dataset size\n", __LINE__); + HDprintf(" Line %d: Error querying dataset size\n", __LINE__); goto error; } /* end if */ /* Verify that the size indicates data is uncompressed */ if((H5Tget_size(H5T_NATIVE_INT) * dims[0] * dims[1]) != dset_size) { H5_FAILED(); - printf(" Line %d: Incorrect dataset size: %lu\n", __LINE__, (unsigned long)dset_size); + HDprintf(" Line %d: Incorrect dataset size: %lu\n", __LINE__, (unsigned long)dset_size); goto error; } /* end if */ /* Read data */ if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0) { H5_FAILED(); - printf(" Line %d: Error reading dataset data\n", __LINE__); + HDprintf(" Line %d: Error reading dataset data\n", __LINE__); goto error; } /* end if */ @@ -6086,10 +6085,10 @@ test_set_local(hid_t fapl) for(j=0; j=0) { H5_FAILED(); - printf(" Line %d: Shouldn't have deleted filter!\n",__LINE__); + HDprintf(" Line %d: Shouldn't have deleted filter!\n",__LINE__); goto error; } /* end if */ @@ -6468,7 +6467,7 @@ test_filter_delete(hid_t file) } H5E_END_TRY; if(ret >=0) { H5_FAILED(); - printf(" Line %d: Shouldn't have deleted filter!\n",__LINE__); + HDprintf(" Line %d: Shouldn't have deleted filter!\n",__LINE__); goto error; } /* end if */ @@ -6566,7 +6565,7 @@ auxread_fdata(hid_t fid, const char *name) if(nelmts) { buf = (void *)HDmalloc((size_t)(nelmts * msize)); if(buf == NULL) { - printf( "cannot read into memory\n" ); + HDprintf( "cannot read into memory\n" ); goto error; } if(H5Dread(dset_id, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) @@ -6965,13 +6964,13 @@ test_missing_chunk(hid_t file) for(u=0; u=5) { if(rdata[u]!=911) { - printf(" Line %d: Incorrect value, rdata[%u]=%d\n",__LINE__,(unsigned)u,rdata[u]); + HDprintf(" Line %d: Incorrect value, rdata[%u]=%d\n",__LINE__,(unsigned)u,rdata[u]); TEST_ERROR; } /* end if */ } /* end if */ else { if(rdata[u]!=wdata[u]) { - printf(" Line %d: Incorrect value, wdata[%u]=%d, rdata[%u]=%d\n",__LINE__,(unsigned)u,wdata[u],(unsigned)u,rdata[u]); + HDprintf(" Line %d: Incorrect value, wdata[%u]=%d, rdata[%u]=%d\n",__LINE__,(unsigned)u,wdata[u],(unsigned)u,rdata[u]); TEST_ERROR; } /* end if */ } /* end else */ @@ -6983,14 +6982,14 @@ test_missing_chunk(hid_t file) if((i % 10) >= 5 || (j % 10) >= 5) { if(rdata2[i][j] != 911) { - printf(" Line %d: Incorrect value, rdata2[%u][%u] = %d\n", + HDprintf(" Line %d: Incorrect value, rdata2[%u][%u] = %d\n", __LINE__,(unsigned)i, (unsigned)j, rdata2[i][j]); TEST_ERROR; } /* end if */ } /* end if */ else { if(rdata2[i][j] != wdata2[i][j]) { - printf(" Line %d: Incorrect value, wdata2[%u][%u] = %d, rdata2[%u][%u] = %d\n", + HDprintf(" Line %d: Incorrect value, wdata2[%u][%u] = %d, rdata2[%u][%u] = %d\n", __LINE__,(unsigned)i, (unsigned)j, wdata2[i][j],(unsigned)i, (unsigned)j, rdata2[i][j]); TEST_ERROR; } /* end if */ @@ -7154,8 +7153,8 @@ test_random_chunks_real(const char *testname, hbool_t early_alloc, hid_t fapl) /* Verify that written and read data are the same */ for(i = 0; i < NPOINTS; i++) if(rbuf[i] != wbuf[i]){ - printf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n",__LINE__,(unsigned)i,wbuf[i],(unsigned)i,rbuf[i]); - printf(" coord[%u] = {%lu, %lu}\n", (unsigned)i, (unsigned long)coord[i][0], (unsigned long)coord[i][1]); + HDprintf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n",__LINE__,(unsigned)i,wbuf[i],(unsigned)i,rbuf[i]); + HDprintf(" coord[%u] = {%lu, %lu}\n", (unsigned)i, (unsigned long)coord[i][0], (unsigned long)coord[i][1]); TEST_ERROR; } /* end if */ @@ -7261,7 +7260,7 @@ test_random_chunks_real(const char *testname, hbool_t early_alloc, hid_t fapl) /* Verify that written and read data are the same */ for(i = 0; i < NPOINTS; i++) if(rbuf[i] != wbuf[i]){ - printf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n",__LINE__,(unsigned)i,wbuf[i],(unsigned)i,rbuf[i]); + HDprintf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n",__LINE__,(unsigned)i,wbuf[i],(unsigned)i,rbuf[i]); TEST_ERROR; } /* end if */ @@ -7367,7 +7366,7 @@ test_random_chunks_real(const char *testname, hbool_t early_alloc, hid_t fapl) /* Verify that written and read data are the same */ for(i = 0; i < NPOINTS; i++) if(rbuf[i] != wbuf[i]){ - printf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n",__LINE__,(unsigned)i,wbuf[i],(unsigned)i,rbuf[i]); + HDprintf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n",__LINE__,(unsigned)i,wbuf[i],(unsigned)i,rbuf[i]); TEST_ERROR; } /* end if */ @@ -7508,7 +7507,7 @@ test_deprec(hid_t file) } H5E_END_TRY; if(dataset >= 0) { H5_FAILED(); - puts(" Library allowed overwrite of existing dataset."); + HDputs(" Library allowed overwrite of existing dataset."); goto error; } @@ -7529,7 +7528,7 @@ test_deprec(hid_t file) } H5E_END_TRY; if(dataset >= 0) { H5_FAILED(); - puts(" Opened a non-existent dataset."); + HDputs(" Opened a non-existent dataset."); goto error; } @@ -7578,7 +7577,7 @@ test_deprec(hid_t file) } H5E_END_TRY; if(dataset >= 0) { H5_FAILED(); - puts(" Opened a dataset with incorrect chunking parameters."); + HDputs(" Opened a dataset with incorrect chunking parameters."); goto error; } @@ -7630,7 +7629,7 @@ test_deprec(hid_t file) if(H5Zregister(H5Z_DEPREC) < 0) goto error; if(H5Pset_filter(dcpl, H5Z_FILTER_DEPREC, 0, (size_t)0, NULL) < 0) goto error; - puts(""); + HDputs(""); if(test_filter_internal(file,DSET_DEPREC_NAME_FILTER,dcpl,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&deprec_size) < 0) goto error; if(H5Pclose(dcpl) < 0) goto error; @@ -8130,15 +8129,15 @@ test_big_chunks_bypass_cache(hid_t fapl) /* Verify data for the first 1-D dataset */ for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++) if(rdata1[i] != i) { - printf(" Read different values than written in the 1st chunk.\n"); - printf(" At line %d and index %d, rdata1 = %d. It should be %d.\n", __LINE__, i, rdata1[i], i); + HDprintf(" Read different values than written in the 1st chunk.\n"); + HDprintf(" At line %d and index %d, rdata1 = %d. It should be %d.\n", __LINE__, i, rdata1[i], i); TEST_ERROR } /* end if */ for(j = BYPASS_CHUNK_DIM / 2; j < BYPASS_DIM; j++) if(rdata1[j] != fvalue) { - printf(" Read different values than written in the 2nd chunk.\n"); - printf(" At line %d and index %d, rdata1 = %d. It should be %d.\n", __LINE__, i, rdata1[i], fvalue); + HDprintf(" Read different values than written in the 2nd chunk.\n"); + HDprintf(" At line %d and index %d, rdata1 = %d. It should be %d.\n", __LINE__, i, rdata1[i], fvalue); TEST_ERROR } /* end if */ @@ -8146,8 +8145,8 @@ test_big_chunks_bypass_cache(hid_t fapl) for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++) for(j = 0; j < BYPASS_CHUNK_DIM / 2; j++) if(t_rdata1[i][j] != j) { - printf(" Read different values than written in the 1st chunk.\n"); - printf(" At line %d and index (%d, %d), t_rdata1 = %d. It should be %d.\n", + HDprintf(" Read different values than written in the 1st chunk.\n"); + HDprintf(" At line %d and index (%d, %d), t_rdata1 = %d. It should be %d.\n", __LINE__, i, j, t_rdata1[i][j], j); TEST_ERROR } /* end if */ @@ -8155,8 +8154,8 @@ test_big_chunks_bypass_cache(hid_t fapl) for(i = BYPASS_CHUNK_DIM / 2; i < BYPASS_DIM; i++) for(j = BYPASS_CHUNK_DIM / 2; j < BYPASS_DIM; j++) if(t_rdata1[i][j] != fvalue) { - printf(" Read different values than written in the 2nd chunk.\n"); - printf(" At line %d and index (%d, %d), t_rdata1 = %d. It should be %d.\n", + HDprintf(" Read different values than written in the 2nd chunk.\n"); + HDprintf(" At line %d and index (%d, %d), t_rdata1 = %d. It should be %d.\n", __LINE__, i, j, t_rdata1[i][j], fvalue); TEST_ERROR } /* end if */ @@ -8202,8 +8201,8 @@ test_big_chunks_bypass_cache(hid_t fapl) /* Verify data for the second 1-D dataset */ for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++) if(rdata2[i] != i) { - printf(" Read different values than written in the chunk.\n"); - printf(" At line %d and index %d, rdata2 = %d. It should be %d.\n", __LINE__, i, rdata2[i], i); + HDprintf(" Read different values than written in the chunk.\n"); + HDprintf(" At line %d and index %d, rdata2 = %d. It should be %d.\n", __LINE__, i, rdata2[i], i); TEST_ERROR } /* end if */ @@ -8211,8 +8210,8 @@ test_big_chunks_bypass_cache(hid_t fapl) for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++) for(j = 0; j < BYPASS_CHUNK_DIM / 2; j++) if(t_rdata2[i][j] != j) { - printf(" Read different values than written in the chunk.\n"); - printf(" At line %d and index (%d, %d), t_rdata2 = %d. It should be %d.\n", + HDprintf(" Read different values than written in the chunk.\n"); + HDprintf(" At line %d and index (%d, %d), t_rdata2 = %d. It should be %d.\n", __LINE__, i, j, t_rdata2[i][j], j); TEST_ERROR } /* end if */ @@ -8941,7 +8940,7 @@ test_chunk_expand(hid_t fapl) if(sizeof(size_t) <= 4 && low != H5F_LIBVER_LATEST) { SKIPPED(); - puts(" Current machine can't test for error w/old file format"); + HDputs(" Current machine can't test for error w/old file format"); } /* end if */ else { /* Register "expansion" filter */ @@ -9604,7 +9603,7 @@ test_fixed_array(hid_t fapl) /* Verify that written and read data are the same */ for(i = 0; i < POINTS; i++) if(rbuf[i] != wbuf[i]){ - printf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n", + HDprintf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n", __LINE__,(unsigned)i,wbuf[i],(unsigned)i,rbuf[i]); TEST_ERROR; } /* end if */ @@ -9632,7 +9631,7 @@ test_fixed_array(hid_t fapl) /* Verify that written and read data are the same */ for(i = 0; i < POINTS; i++) if(rbuf[i] != wbuf[i]){ - printf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n", + HDprintf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n", __LINE__,(unsigned)i,wbuf[i],(unsigned)i,rbuf[i]); TEST_ERROR; } /* end if */ @@ -9658,7 +9657,7 @@ test_fixed_array(hid_t fapl) /* Verify that written and read data are the same */ for(i = 0; i < POINTS_BIG; i++) if(rbuf_big[i] != wbuf_big[i]) { - printf(" Line %d: Incorrect value, wbuf_bif[%u]=%d, rbuf_big[%u]=%d\n", + HDprintf(" Line %d: Incorrect value, wbuf_bif[%u]=%d, rbuf_big[%u]=%d\n", __LINE__,(unsigned)i,wbuf_big[i],(unsigned)i,rbuf_big[i]); TEST_ERROR; } /* end if */ @@ -9897,7 +9896,7 @@ test_single_chunk(hid_t fapl) /* Verify that written and read data are the same */ for(i = 0; i < (DSET_DIM1 * DSET_DIM2); i++) if(rbuf[i] != wbuf[i]){ - printf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n", + HDprintf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n", __LINE__,(unsigned)i,wbuf[i],(unsigned)i,rbuf[i]); TEST_ERROR; } /* end if */ @@ -9916,7 +9915,7 @@ test_single_chunk(hid_t fapl) /* Verify that written and read data are the same */ for(i = 0; i < (DSET_TMP_DIM1* DSET_TMP_DIM2); i++) if(t_rbuf[i] != t_wbuf[i]) { - printf(" Line %d: Incorrect value, t_wbuf[%u]=%d, t_rbuf[%u]=%d\n", + HDprintf(" Line %d: Incorrect value, t_wbuf[%u]=%d, t_rbuf[%u]=%d\n", __LINE__,(unsigned)i,t_wbuf[i],(unsigned)i,t_rbuf[i]); TEST_ERROR; } /* end if */ @@ -11518,7 +11517,7 @@ typedef struct scatter_info_t { for(k=0; k<(int)(sizeof(ARR[0][0])/sizeof(ARR[0][0][0])); k++) \ if(ARR[i][j][k] != EXP[i][j][k]) { \ H5_FAILED(); AT(); \ - printf(" " #ARR "[%d][%d][%d] == %d, " #EXP "[%d][%d][%d] == %d\n", i, j, k, ARR[i][j][k], i, j, k, EXP[i][j][k]); \ + HDprintf(" " #ARR "[%d][%d][%d] == %d, " #EXP "[%d][%d][%d] == %d\n", i, j, k, ARR[i][j][k], i, j, k, EXP[i][j][k]); \ goto error; \ } @@ -13079,10 +13078,12 @@ test_object_header_minimization_dcpl(void) TEST_ERROR file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if (0 > file_id) TEST_ERROR + if (file_id == H5I_INVALID_HID) + TEST_ERROR dcpl_id = H5Pcreate(H5P_DATASET_CREATE); - if (0 > dcpl_id) TEST_ERROR + if (dcpl_id == H5I_INVALID_HID) + TEST_ERROR /*********/ /* TESTS */ @@ -13249,20 +13250,20 @@ main(void) my_fapl = fapl2; if(paged) { my_fcpl = fcpl2; - puts("\nTesting with new file format and paged aggregation"); + HDputs("\nTesting with new file format and paged aggregation"); } else { my_fcpl = fcpl; - puts("\nTesting with new file format and non-paged aggregation"); + HDputs("\nTesting with new file format and non-paged aggregation"); } } /* end if */ else { my_fapl = fapl; if(paged) { my_fcpl = fcpl2; - puts("Testing with old file format and paged aggregation:"); + HDputs("Testing with old file format and paged aggregation:"); } else { my_fcpl = fcpl; - puts("Testing with old file format and non-paged aggregation:"); + HDputs("Testing with old file format and non-paged aggregation:"); } } /* end else */ @@ -13273,7 +13274,7 @@ main(void) if (TRUE == minimized_ohdr) { if (0 > H5Fset_dset_no_attrs_hint(file, TRUE)) goto error; - puts("(minimized dataset object headers with file setting)"); + HDputs("(minimized dataset object headers with file setting)"); } /* Cause the library to emit initial messages */ @@ -13380,7 +13381,7 @@ main(void) if(nerrors) goto error; - printf("All dataset tests passed.\n"); + HDprintf("All dataset tests passed.\n"); #ifdef H5_HAVE_FILTER_SZIP if (GetTestCleanup()) HDremove(NOENCODER_COPY_FILENAME); @@ -13391,7 +13392,7 @@ main(void) error: nerrors = MAX(1, nerrors); - printf("***** %d DATASET TEST%s FAILED! *****\n", + HDprintf("***** %d DATASET TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); return EXIT_FAILURE; } /* end main() */ diff --git a/test/error_test.c b/test/error_test.c index 44f6210..1de9065 100644 --- a/test/error_test.c +++ b/test/error_test.c @@ -12,10 +12,10 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Raymond Lu + * Programmer: Raymond Lu * October 14, 2001 * - * Purpose: Tests the error API routines. + * Purpose: Tests the error API routines. */ #include "h5test.h" #include "H5srcdir.h" @@ -23,7 +23,7 @@ #ifdef H5_USE_16_API int main(void) { - HDfprintf(stderr, "Test skipped because backward compatbility with v1.6 is configured in\n"); + HDfprintf(stderr, "Test skipped because backward compatibility with v1.6 is configured in\n"); return 0; } #else /* H5_USE_16_API */ @@ -38,7 +38,7 @@ const char *FILENAME[] = { #define DIM0 100 #define DIM1 200 -int ipoints2[DIM0][DIM1], icheck2[DIM0][DIM1]; +int ipoints2[DIM0][DIM1], icheck2[DIM0][DIM1]; hid_t ERR_CLS; hid_t ERR_CLS2; @@ -80,7 +80,7 @@ hid_t ERR_MIN_GETNUM; static herr_t custom_print_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data); - + /*------------------------------------------------------------------------- * Function: test_error * @@ -94,10 +94,10 @@ static herr_t custom_print_cb(unsigned n, const H5E_error2_t *err_desc, static herr_t test_error(hid_t file) { - hid_t dataset = -1; + hid_t dataset = -1; hid_t space = -1; hid_t estack_id = -1; - hsize_t dims[2]; + hsize_t dims[2]; const char *FUNC_test_error = "test_error"; H5E_auto2_t old_func; void *old_data = NULL; @@ -169,7 +169,7 @@ test_error(hid_t file) return -1; } /* end test_error() */ - + /*------------------------------------------------------------------------- * Function: init_error * @@ -245,7 +245,7 @@ error: return -1; } /* end init_error() */ - + /*------------------------------------------------------------------------- * Function: error_stack * @@ -287,7 +287,7 @@ error: return -1; } /* end error_stack() */ - + /*------------------------------------------------------------------------- * Function: long_desc_cb * @@ -309,7 +309,7 @@ long_desc_cb(unsigned H5_ATTR_UNUSED n, const H5E_error2_t *err_desc, void *clie return -1; } /* end long_desc_cb() */ - + /*------------------------------------------------------------------------- * Function: test_long_desc * @@ -384,7 +384,7 @@ error: } /* end test_long_desc() */ #pragma GCC diagnostic pop - + /*------------------------------------------------------------------------- * Function: dump_error * @@ -414,7 +414,7 @@ error: return -1; } /* end dump_error() */ - + /*------------------------------------------------------------------------- * Function: custom_print_cb * @@ -445,8 +445,8 @@ custom_print_cb(unsigned n, const H5E_error2_t *err_desc, void* client_data) TEST_ERROR; HDfprintf(stream, "%*serror #%03d: %s in %s(): line %u\n", - indent, "", n, err_desc->file_name, - err_desc->func_name, err_desc->line); + indent, "", n, err_desc->file_name, + err_desc->func_name, err_desc->line); HDfprintf(stream, "%*sclass: %s\n", indent * 2, "", cls); HDfprintf(stream, "%*smajor: %s\n", indent * 2, "", maj); HDfprintf(stream, "%*sminor: %s\n", indent * 2, "", min); @@ -457,7 +457,7 @@ error: return -1; } /* end custom_print_cb() */ - + /*------------------------------------------------------------------------- * Function: test_create * @@ -540,11 +540,11 @@ test_copy(void) err_num = H5Eget_num(H5E_DEFAULT); if (err_num != 1) TEST_ERROR - + /* Copy error stack, which clears the original */ if ((estack_id = H5Eget_current_stack()) < 0) TEST_ERROR - + /* Check the number of errors on stack copy */ err_num = H5Eget_num(estack_id); if (err_num != 1) @@ -564,7 +564,7 @@ test_copy(void) if (err_num != 1) TEST_ERROR - /* Try to close error stack copy. Should fail because + /* Try to close error stack copy. Should fail because * the current H5Eset_current_stack closes the stack to be set. */ H5E_BEGIN_TRY { @@ -579,7 +579,7 @@ error: return -1; } /* end test_copy() */ - + /*------------------------------------------------------------------------- * Function: close_error * @@ -615,17 +615,17 @@ error: return -1; } /* end close_error() */ - + /*------------------------------------------------------------------------- * Function: test_filter_error * * Purpose: Make sure the error message prints out the filter name - * when the existent file is opened but the filter isn't - * registered. The existent file was created with - * gen_filters.c. + * when the existent file is opened but the filter isn't + * registered. The existent file was created with + * gen_filters.c. * * Return: Success: 0 - * Failure: -1 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -663,7 +663,7 @@ error: return -1; } /* end test_filter_error() */ - + /*------------------------------------------------------------------------- * Function: main * @@ -745,7 +745,7 @@ main(void) if (close_error() < 0) TEST_ERROR; - /* Test error message during data reading when filter isn't registered + /* Test error message during data reading when filter isn't registered * Use default FAPL to avoid some VFD drivers by the check-vfd test because * the test file was pre-generated. */ diff --git a/test/flush2.c b/test/flush2.c index 8ebfb75..0f15903 100644 --- a/test/flush2.c +++ b/test/flush2.c @@ -15,10 +15,10 @@ * Programmer: Robb Matzke * Friday, October 23, 1998 * - * Purpose: This is the second half of a two-part test that makes sure - * that a file can be read after an application crashes as long - * as the file was flushed first. This half tries to read the - * file created by the first half. + * Purpose: This is the second half of a two-part test that makes sure + * that a file can be read after an application crashes as long + * as the file was flushed first. This half tries to read the + * file created by the first half. */ #include "h5test.h" diff --git a/test/gheap.c b/test/gheap.c index 5b51c0e..09ba1cf 100644 --- a/test/gheap.c +++ b/test/gheap.c @@ -57,7 +57,7 @@ const char *FILENAME[] = { NULL }; - + /*------------------------------------------------------------------------- * Function: test_1 * @@ -68,7 +68,7 @@ const char *FILENAME[] = { * * Failure: number of errors * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Tuesday, March 31, 1998 * *------------------------------------------------------------------------- @@ -165,7 +165,7 @@ error: return MAX(1, nerrors); } - + /*------------------------------------------------------------------------- * Function: test_2 * @@ -176,7 +176,7 @@ error: * * Failure: number of errors * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Tuesday, March 31, 1998 * *------------------------------------------------------------------------- @@ -264,7 +264,7 @@ test_2 (hid_t fapl) return MAX(1, nerrors); } - + /*------------------------------------------------------------------------- * Function: test_3 * @@ -275,7 +275,7 @@ test_2 (hid_t fapl) * * Failure: number of errors * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Tuesday, March 31, 1998 * *------------------------------------------------------------------------- @@ -353,7 +353,7 @@ test_3 (hid_t fapl) return MAX(1, nerrors); } - + /*------------------------------------------------------------------------- * Function: test_4 * @@ -365,7 +365,7 @@ test_3 (hid_t fapl) * * Failure: number of errors * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Tuesday, March 31, 1998 * *------------------------------------------------------------------------- @@ -448,7 +448,7 @@ test_4 (hid_t fapl) return MAX(1, nerrors); } - + /*------------------------------------------------------------------------- * Function: test_ooo_indices * @@ -461,7 +461,7 @@ test_4 (hid_t fapl) * * Failure: number of errors * - * Programmer: Neil Fortner + * Programmer: Neil Fortner * Monday, October 26, 2009 * *------------------------------------------------------------------------- @@ -566,7 +566,7 @@ test_ooo_indices(hid_t fapl) return MAX(1, nerrors); } /* end test_ooo_indices */ - + /*------------------------------------------------------------------------- * Function: main * @@ -579,8 +579,8 @@ test_ooo_indices(hid_t fapl) int main (void) { - int nerrors = 0; - hid_t fapl_id = H5I_INVALID_HID; + int nerrors = 0; + hid_t fapl_id = H5I_INVALID_HID; hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ h5_reset(); diff --git a/test/h5test.c b/test/h5test.c index d83c6e7..707c436 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -110,7 +110,6 @@ const char *LIBVER_NAMES[] = { NULL }; - /* Previous error reporting function */ static H5E_auto2_t err_func = NULL; @@ -1983,7 +1982,6 @@ error: return NULL; } /* h5_get_dummy_vfd_class */ - /*------------------------------------------------------------------------- * Function: h5_get_dummy_vol_class() * diff --git a/test/mf.c b/test/mf.c index 8c17df5..fe98000 100644 --- a/test/mf.c +++ b/test/mf.c @@ -6916,7 +6916,6 @@ test_mf_fs_gone(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) H5FD_mem_t fs_type; hbool_t contig_addr_vfd; - if(new_format) TESTING("File's free-space is going away with new library format") else diff --git a/tools/src/h5dump/h5dump.c b/tools/src/h5dump/h5dump.c index a824197..347c189 100644 --- a/tools/src/h5dump/h5dump.c +++ b/tools/src/h5dump/h5dump.c @@ -1898,4 +1898,3 @@ add_prefix(char **prfx, size_t *prfx_len, const char *name) HDstrcat(HDstrcat(*prfx, "/"), name); } /* end add_prefix */ - diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c index c81da1e..2364f23 100644 --- a/tools/src/h5ls/h5ls.c +++ b/tools/src/h5ls/h5ls.c @@ -247,7 +247,6 @@ usage (void) } - /*------------------------------------------------------------------------- * Function: print_string * diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c index 59038a0..5f0452c 100644 --- a/tools/src/h5stat/h5stat.c +++ b/tools/src/h5stat/h5stat.c @@ -74,14 +74,14 @@ typedef struct iter_t { ohdr_info_t group_ohdr_info; /* Object header information for groups */ hsize_t max_attrs; /* Maximum attributes from a group */ - unsigned long *num_small_attrs; /* Size of small attribu