summaryrefslogtreecommitdiffstats
path: root/hl/test
diff options
context:
space:
mode:
Diffstat (limited to 'hl/test')
-rw-r--r--hl/test/CMakeLists.txt128
-rw-r--r--hl/test/CMakeTests.cmake80
-rw-r--r--hl/test/COPYING2
-rw-r--r--hl/test/H5srcdir_str.h.in2
-rw-r--r--hl/test/Makefile.am3
-rw-r--r--hl/test/Makefile.in29
-rw-r--r--hl/test/dectris_hl_perf.c481
-rw-r--r--hl/test/gen_test_ds.c419
-rw-r--r--hl/test/h5hltest.h21
-rw-r--r--hl/test/pal_rgb.h518
-rw-r--r--hl/test/test_ds.c4164
-rw-r--r--hl/test/test_dset_opt.c1696
-rw-r--r--hl/test/test_file_image.c230
-rw-r--r--hl/test/test_image.c822
-rw-r--r--hl/test/test_lite.c2213
-rw-r--r--hl/test/test_packet.c796
-rw-r--r--hl/test/test_packet_vlen.c1275
-rw-r--r--hl/test/test_table.c1878
18 files changed, 7577 insertions, 7180 deletions
diff --git a/hl/test/CMakeLists.txt b/hl/test/CMakeLists.txt
index 054b786..d005e67 100644
--- a/hl/test/CMakeLists.txt
+++ b/hl/test/CMakeLists.txt
@@ -1,5 +1,5 @@
-cmake_minimum_required (VERSION 3.10)
-PROJECT (HDF5_HL_TEST)
+cmake_minimum_required (VERSION 3.12)
+project (HDF5_HL_TEST C)
# --------------------------------------------------------------------
# Notes: When creating unit test executables they should be prefixed
# with "hl_". This allows for easier filtering of the test suite when
@@ -14,63 +14,127 @@ PROJECT (HDF5_HL_TEST)
set (srcdir ${CMAKE_CURRENT_SOURCE_DIR})
configure_file (${HDF5_HL_TEST_SOURCE_DIR}/H5srcdir_str.h.in H5srcdir_str.h @ONLY)
-include_directories (${CMAKE_CURRENT_BINARY_DIR})
-include_directories (${HDF5_TEST_SRC_DIR})
-
# --------------------------------------------------------------------
# Macro used to add a unit test
# --------------------------------------------------------------------
-MACRO (HL_ADD_EXE hl_name)
+macro (HL_ADD_EXE hl_name)
add_executable (hl_${hl_name} ${hl_name}.c)
- TARGET_C_PROPERTIES (hl_${hl_name} STATIC " " " ")
- target_link_libraries (hl_${hl_name}
- ${HDF5_HL_LIB_TARGET}
- ${HDF5_TEST_LIB_TARGET}
- ${HDF5_LIB_TARGET}
- )
+ target_compile_options(hl_${hl_name} PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ target_include_directories (hl_${hl_name} PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ if (NOT BUILD_SHARED_LIBS)
+ TARGET_C_PROPERTIES (hl_${hl_name} STATIC)
+ target_link_libraries (hl_${hl_name} PRIVATE
+ ${HDF5_HL_LIB_TARGET}
+ ${HDF5_TEST_LIB_TARGET}
+ ${HDF5_LIB_TARGET}
+ )
+ else ()
+ TARGET_C_PROPERTIES (hl_${hl_name} SHARED)
+ target_link_libraries (hl_${hl_name} PRIVATE
+ ${HDF5_HL_LIBSH_TARGET}
+ ${HDF5_TEST_LIBSH_TARGET}
+ ${HDF5_LIBSH_TARGET}
+ )
+ endif ()
set_target_properties (hl_${hl_name} PROPERTIES FOLDER test/hl)
-ENDMACRO ()
-MACRO (HL_ADD_SHEXE hl_name)
+ #-----------------------------------------------------------------------------
+ # Add Target to clang-format
+ #-----------------------------------------------------------------------------
+ if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_HL_TEST_${hl_name}_FORMAT hl_${hl_name})
+ endif ()
+endmacro ()
+
+macro (HL_ADD_ZEXE hl_name)
add_executable (hl_${hl_name} ${hl_name}.c)
- TARGET_C_PROPERTIES (hl_${hl_name} SHARED " " " ")
- target_link_libraries (hl_${hl_name}
- ${HDF5_HL_LIBSH_TARGET}
- ${HDF5_TEST_LIBSH_TARGET}
- ${HDF5_LIBSH_TARGET}
- )
+ target_compile_options(hl_${hl_name} PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ target_include_directories (hl_${hl_name} PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ if (NOT BUILD_SHARED_LIBS)
+ TARGET_C_PROPERTIES (hl_${hl_name} STATIC)
+ target_link_libraries (hl_${hl_name} PRIVATE
+ ${HDF5_HL_LIB_TARGET}
+ ${HDF5_TEST_LIB_TARGET}
+ ${HDF5_LIB_TARGET}
+ ${LINK_COMP_LIBS}
+ )
+ else ()
+ TARGET_C_PROPERTIES (hl_${hl_name} SHARED)
+ target_link_libraries (hl_${hl_name} PRIVATE
+ ${HDF5_HL_LIBSH_TARGET}
+ ${HDF5_TEST_LIBSH_TARGET}
+ ${HDF5_LIBSH_TARGET}
+ ${LINK_COMP_LIBS}
+ )
+ endif ()
set_target_properties (hl_${hl_name} PROPERTIES FOLDER test/hl)
-ENDMACRO ()
+
+ #-----------------------------------------------------------------------------
+ # Add Target to clang-format
+ #-----------------------------------------------------------------------------
+ if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_HL_TEST_${hl_name}_FORMAT hl_${hl_name})
+ endif ()
+endmacro ()
HL_ADD_EXE (test_ds)
-HL_ADD_EXE (test_dset_opt)
+HL_ADD_ZEXE (test_dset_opt)
HL_ADD_EXE (test_image)
HL_ADD_EXE (test_lite)
HL_ADD_EXE (test_table)
# test_packet has two source files
add_executable (hl_test_packet test_packet.c test_packet_vlen.c)
-TARGET_C_PROPERTIES (hl_test_packet STATIC " " " ")
-target_link_libraries (hl_test_packet
- ${HDF5_HL_LIB_TARGET}
- ${HDF5_TEST_LIB_TARGET}
- ${HDF5_LIB_TARGET}
-)
+target_compile_options(hl_test_packet PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+target_include_directories (hl_test_packet PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+if (NOT BUILD_SHARED_LIBS)
+ TARGET_C_PROPERTIES (hl_test_packet STATIC)
+ target_link_libraries (hl_test_packet PRIVATE
+ ${HDF5_HL_LIB_TARGET}
+ ${HDF5_TEST_LIB_TARGET}
+ ${HDF5_LIB_TARGET}
+ )
+else ()
+ TARGET_C_PROPERTIES (hl_test_packet SHARED)
+ target_link_libraries (hl_test_packet PRIVATE
+ ${HDF5_HL_LIBSH_TARGET}
+ ${HDF5_TEST_LIBSH_TARGET}
+ ${HDF5_LIBSH_TARGET}
+ )
+endif ()
set_target_properties (hl_test_packet PROPERTIES FOLDER test/hl)
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_HL_TEST_hl_test_packet_FORMAT hl_test_packet)
+endif ()
+
# --------------------------------------------------------------------
# This executable is used to generate test files for the test_ds test.
# It should only be run during development when new test files are needed
# --------------------------------------------------------------------
-if (HDF5_BUILD_GENERATORS)
+if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS)
add_executable (hl_gen_test_ds gen_test_ds.c)
- TARGET_C_PROPERTIES (hl_gen_test_ds STATIC " " " ")
- target_link_libraries (hl_gen_test_ds
+ target_compile_options(hl_gen_test_ds PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ target_include_directories (hl_gen_test_ds PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ TARGET_C_PROPERTIES (hl_gen_test_ds STATIC)
+ target_link_libraries (hl_gen_test_ds PRIVATE
${HDF5_HL_LIB_TARGET}
${HDF5_TEST_LIB_TARGET}
${HDF5_LIB_TARGET}
)
set_target_properties (hl_gen_test_ds PROPERTIES FOLDER test/hl/gen)
+
+ #-----------------------------------------------------------------------------
+ # Add Target to clang-format
+ #-----------------------------------------------------------------------------
+ if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_HL_TEST_hl_gen_test_ds_FORMAT hl_gen_test_ds)
+ endif ()
endif ()
-include (CMakeTests.cmake)
+if (HDF5_TEST_SERIAL)
+ include (CMakeTests.cmake)
+endif ()
diff --git a/hl/test/CMakeTests.cmake b/hl/test/CMakeTests.cmake
index c4b0814..ec45435 100644
--- a/hl/test/CMakeTests.cmake
+++ b/hl/test/CMakeTests.cmake
@@ -5,7 +5,7 @@
# 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.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
@@ -42,14 +42,48 @@ 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
+ 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_dectris.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_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
# --------------------------------------------------------------------
macro (HL_ADD_TEST hl_name)
if (HDF5_ENABLE_USING_MEMCHECKER)
- add_test (NAME HL_${hl_name} COMMAND $<TARGET_FILE:hl_${hl_name}>)
+ add_test (NAME HL_${hl_name} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:hl_${hl_name}>)
else ()
add_test (NAME HL_${hl_name} COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
-D "TEST_PROGRAM=$<TARGET_FILE:hl_${hl_name}>"
-D "TEST_ARGS:STRING="
-D "TEST_EXPECT=0"
@@ -60,49 +94,13 @@ macro (HL_ADD_TEST hl_name)
-P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
)
endif ()
- if (NOT "${last_test}" STREQUAL "")
- 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
- 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_dectris.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_table.h5
-)
-if (NOT "${last_test}" STREQUAL "")
- set_tests_properties (HL_test-clear-objects PROPERTIES DEPENDS ${last_test})
-endif ()
-set (last_test "HL_test-clear-objects")
-
HL_add_test (test_ds)
HL_add_test (test_dset_opt)
HL_add_test (test_image)
diff --git a/hl/test/COPYING b/hl/test/COPYING
index 6497ace..97969da 100644
--- a/hl/test/COPYING
+++ b/hl/test/COPYING
@@ -7,7 +7,7 @@
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
+ or in https://www.hdfgroup.org/licenses. If you do
not have access to either file, you may request a copy from
help@hdfgroup.org.
diff --git a/hl/test/H5srcdir_str.h.in b/hl/test/H5srcdir_str.h.in
index bab1df3..988c065 100644
--- a/hl/test/H5srcdir_str.h.in
+++ b/hl/test/H5srcdir_str.h.in
@@ -6,7 +6,7 @@
* 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. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
diff --git a/hl/test/Makefile.am b/hl/test/Makefile.am
index c176f2e..e634e76 100644
--- a/hl/test/Makefile.am
+++ b/hl/test/Makefile.am
@@ -1,4 +1,3 @@
-#
# Copyright by The HDF Group.
# Copyright by the Board of Trustees of the University of Illinois.
# All rights reserved.
@@ -6,7 +5,7 @@
# 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.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
diff --git a/hl/test/Makefile.in b/hl/test/Makefile.in
index 4a8cc5a..3b60254 100644
--- a/hl/test/Makefile.in
+++ b/hl/test/Makefile.in
@@ -14,7 +14,6 @@
@SET_MAKE@
-#
# Copyright by The HDF Group.
# Copyright by the Board of Trustees of the University of Illinois.
# All rights reserved.
@@ -22,7 +21,7 @@
# 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.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
@@ -440,14 +439,14 @@ AMTAR = @AMTAR@
# AM_CFLAGS is an automake construct which should be used by Makefiles
# instead of CFLAGS, as CFLAGS is reserved solely for the user to define.
# This applies to FCFLAGS, CXXFLAGS, CPPFLAGS, and LDFLAGS as well.
-AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@
+AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ @H5_ECFLAGS@
# Add include directories to C preprocessor flags
AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@ -I. -I$(srcdir) \
-I$(top_builddir)/src -I$(top_srcdir)/src \
-I$(top_builddir)/test -I$(top_srcdir)/test \
-I$(top_srcdir)/hl/src
-AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@
+AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ @H5_ECXXFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@
AM_LDFLAGS = @AM_LDFLAGS@ @H5_LDFLAGS@
@@ -462,6 +461,7 @@ CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_VERSION = @CC_VERSION@
CFLAGS = @CFLAGS@
+CLANG_SANITIZE_CHECKS = @CLANG_SANITIZE_CHECKS@
CLEARFILEBUF = @CLEARFILEBUF@
CODESTACK = @CODESTACK@
CONFIG_DATE = @CONFIG_DATE@
@@ -480,6 +480,7 @@ DEFAULT_API_VERSION = @DEFAULT_API_VERSION@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@
+DEV_WARNINGS = @DEV_WARNINGS@
DIRECT_VFD = @DIRECT_VFD@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
@@ -507,6 +508,8 @@ GREP = @GREP@
H5_CFLAGS = @H5_CFLAGS@
H5_CPPFLAGS = @H5_CPPFLAGS@
H5_CXXFLAGS = @H5_CXXFLAGS@
+H5_ECFLAGS = @H5_ECFLAGS@
+H5_ECXXFLAGS = @H5_ECXXFLAGS@
H5_FCFLAGS = @H5_FCFLAGS@
H5_FORTRAN_SHARED = @H5_FORTRAN_SHARED@
H5_LDFLAGS = @H5_LDFLAGS@
@@ -514,9 +517,12 @@ H5_VERSION = @H5_VERSION@
HADDR_T = @HADDR_T@
HAVE_DMALLOC = @HAVE_DMALLOC@
HAVE_FORTRAN_2003 = @HAVE_FORTRAN_2003@
+HAVE_LIBHDFS = @HAVE_LIBHDFS@
HAVE_PTHREAD = @HAVE_PTHREAD@
HDF5_HL = @HDF5_HL@
HDF5_INTERFACES = @HDF5_INTERFACES@
+HDF5_TESTS = @HDF5_TESTS@
+HDF5_TOOLS = @HDF5_TOOLS@
HDF_CXX = @HDF_CXX@
HDF_FORTRAN = @HDF_FORTRAN@
HDF_FORTRAN2003 = @HDF_FORTRAN2003@
@@ -532,6 +538,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INSTRUMENT = @INSTRUMENT@
INSTRUMENT_LIBRARY = @INSTRUMENT_LIBRARY@
+JNI_LDFLAGS = @JNI_LDFLAGS@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
@@ -553,6 +560,7 @@ NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJECT_NAMELEN_DEFAULT_F = @OBJECT_NAMELEN_DEFAULT_F@
OBJEXT = @OBJEXT@
+OPTIMIZATION = @OPTIMIZATION@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
@@ -565,8 +573,10 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PARALLEL = @PARALLEL@
PATH_SEPARATOR = @PATH_SEPARATOR@
PERL = @PERL@
+PROFILING = @PROFILING@
RANLIB = @RANLIB@
ROOT = @ROOT@
+ROS3_VFD = @ROS3_VFD@
RUNPARALLEL = @RUNPARALLEL@
RUNSERIAL = @RUNSERIAL@
R_INTEGER = @R_INTEGER@
@@ -580,6 +590,7 @@ STATIC_EXEC = @STATIC_EXEC@
STATIC_SHARED = @STATIC_SHARED@
STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@
STRIP = @STRIP@
+SYMBOLS = @SYMBOLS@
TESTPARALLEL = @TESTPARALLEL@
THREADSAFE = @THREADSAFE@
TIME = @TIME@
@@ -621,6 +632,7 @@ docdir = $(exec_prefix)/doc
dvidir = @dvidir@
enable_shared = @enable_shared@
enable_static = @enable_static@
+examplesdir = @examplesdir@
exec_prefix = @exec_prefix@
fortran_linux_linker_option = @fortran_linux_linker_option@
host = @host@
@@ -729,11 +741,11 @@ BUILD_ALL_PROGS = gen_test_ds
# Sources for test_packet executable
test_packet_SOURCES = test_packet.c test_packet_vlen.c
-# Automake needs to be taught how to build lib, dyn, progs, and tests targets.
+# Automake needs to be taught how to build lib, progs and tests targets.
# These will be filled in automatically for the most part (e.g.,
# lib_LIBRARIES are built for lib target), but EXTRA_LIB, EXTRA_PROG, and
# EXTRA_TEST variables are supplied to allow the user to force targets to
-# be built at certain times.
+# be built at certain times.
LIB = $(lib_LIBRARIES) $(lib_LTLIBRARIES) $(noinst_LIBRARIES) \
$(noinst_LTLIBRARIES) $(check_LIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LIB)
@@ -1295,6 +1307,7 @@ uninstall-am:
help:
@$(top_srcdir)/bin/makehelp
+
# lib/progs/tests targets recurse into subdirectories. build-* targets
# build files in this directory.
build-lib: $(LIB)
@@ -1330,7 +1343,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."
@@ -1491,7 +1504,7 @@ build-check-p: $(LIB) $(PROGS) $(chk_TESTS)
echo "**** Hint ****"; \
echo "Parallel test files reside in the current directory" \
"by default."; \
- echo "Set HDF5_PARAPREFIX to use another directory. E.g.,"; \
+ echo "Set HDF5_PARAPREFIX to use another directory. e.g.,"; \
echo " HDF5_PARAPREFIX=/PFS/user/me"; \
echo " export HDF5_PARAPREFIX"; \
echo " make check"; \
diff --git a/hl/test/dectris_hl_perf.c b/hl/test/dectris_hl_perf.c
index befebf5..c9e1307 100644
--- a/hl/test/dectris_hl_perf.c
+++ b/hl/test/dectris_hl_perf.c
@@ -6,7 +6,7 @@
* 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. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -27,190 +27,203 @@
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
-
-const char *FILENAME[] = {
- "dectris_perf",
- "unix.raw",
- NULL
-};
+
+const char *FILENAME[] = {"dectris_perf", "unix.raw", NULL};
/*
* Print the current location on the standard output stream.
*/
#define FUNC __func__
-#define AT() printf (" at %s:%d in %s()...\n", \
- __FILE__, __LINE__, FUNC);
-#define H5_FAILED() {puts("*FAILED*");fflush(stdout);}
-#define TEST_ERROR {H5_FAILED(); AT(); goto error;}
-#define TESTING(WHAT) {printf("Testing %-62s",WHAT); fflush(stdout);}
-#define PASSED() {puts(" PASSED");fflush(stdout);}
-
-#define DIRECT_UNCOMPRESSED_DSET "direct_uncompressed_dset"
-#define DIRECT_COMPRESSED_DSET "direct_compressed_dset"
-#define REG_COMPRESSED_DSET "reg_compressed_dset"
-#define REG_NO_COMPRESS_DSET "reg_no_compress_dset"
-#define RANK 3
-#define NX 100
-#define NY 1000
-#define NZ 250
-#define CHUNK_NX 1
-#define CHUNK_NY 1000
-#define CHUNK_NZ 250
-
-#define DEFLATE_SIZE_ADJUST(s) (ceil(((double)(s))*1.001)+12)
-char filename[1024];
+#define AT() printf(" at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC);
+#define H5_FAILED() \
+ { \
+ puts("*FAILED*"); \
+ fflush(stdout); \
+ }
+#define TEST_ERROR \
+ { \
+ H5_FAILED(); \
+ AT(); \
+ goto error; \
+ }
+#define TESTING(WHAT) \
+ { \
+ printf("Testing %-62s", WHAT); \
+ fflush(stdout); \
+ }
+#define PASSED() \
+ { \
+ puts(" PASSED"); \
+ fflush(stdout); \
+ }
+
+#define DIRECT_UNCOMPRESSED_DSET "direct_uncompressed_dset"
+#define DIRECT_COMPRESSED_DSET "direct_compressed_dset"
+#define REG_COMPRESSED_DSET "reg_compressed_dset"
+#define REG_NO_COMPRESS_DSET "reg_no_compress_dset"
+#define RANK 3
+#define NX 100
+#define NY 1000
+#define NZ 250
+#define CHUNK_NX 1
+#define CHUNK_NY 1000
+#define CHUNK_NZ 250
+
+#define DEFLATE_SIZE_ADJUST(s) (ceil(((double)(s)) * 1.001) + 12)
+char filename[1024];
unsigned int *outbuf[NX];
-size_t data_size[NX];
-double total_size = 0.0;
+size_t data_size[NX];
+double total_size = 0.0;
unsigned int *direct_buf[NX];
-double MB = 1048576.0;
+double MB = 1048576.0;
/*--------------------------------------------------
* Function to report IO rate
*--------------------------------------------------
*/
-void reportTime(struct timeval start, double mbytes)
+void
+reportTime(struct timeval start, double mbytes)
{
- struct timeval timeval_stop,timeval_diff;
+ struct timeval timeval_stop, timeval_diff;
/*end timing*/
- gettimeofday(&timeval_stop,NULL);
+ gettimeofday(&timeval_stop, NULL);
/* Calculate the elapsed gettimeofday time */
- timeval_diff.tv_usec=timeval_stop.tv_usec-start.tv_usec;
- timeval_diff.tv_sec=timeval_stop.tv_sec-start.tv_sec;
+ timeval_diff.tv_usec = timeval_stop.tv_usec - start.tv_usec;
+ timeval_diff.tv_sec = timeval_stop.tv_sec - start.tv_sec;
- if(timeval_diff.tv_usec<0) {
- timeval_diff.tv_usec+=1000000;
+ if (timeval_diff.tv_usec < 0) {
+ timeval_diff.tv_usec += 1000000;
timeval_diff.tv_sec--;
} /* end if */
-/*printf("mbytes=%lf, sec=%lf, usec=%lf\n", mbytes, (double)timeval_diff.tv_sec, (double)timeval_diff.tv_usec);*/
- printf("MBytes/second: %lf\n", (double)mbytes/((double)timeval_diff.tv_sec+((double)timeval_diff.tv_usec/(double)1000000.0)));
+ /*printf("mbytes=%lf, sec=%lf, usec=%lf\n", mbytes, (double)timeval_diff.tv_sec,
+ * (double)timeval_diff.tv_usec);*/
+ printf("MBytes/second: %lf\n", (double)mbytes / ((double)timeval_diff.tv_sec +
+ ((double)timeval_diff.tv_usec / (double)1000000.0)));
}
/*--------------------------------------------------
* Create file, datasets, and initialize data
*--------------------------------------------------
*/
-int create_file(hid_t fapl_id)
+int
+create_file(hid_t fapl_id)
{
- hid_t file; /* handles */
- hid_t fapl;
- hid_t cparms;
- hid_t dataspace, dataset;
- hsize_t dims[RANK] = {NX, NY, NZ};
- hsize_t chunk_dims[RANK] ={CHUNK_NX, CHUNK_NY, CHUNK_NZ};
- unsigned int aggression = 9; /* Compression aggression setting */
- int ret;
- int i, j, n;
+ hid_t file; /* handles */
+ hid_t fapl;
+ hid_t cparms;
+ hid_t dataspace, dataset;
+ hsize_t dims[RANK] = {NX, NY, NZ};
+ hsize_t chunk_dims[RANK] = {CHUNK_NX, CHUNK_NY, CHUNK_NZ};
+ unsigned int aggression = 9; /* Compression aggression setting */
+ int ret;
+ int i, j, n;
int flag;
int unix_file;
unsigned int *p;
- size_t buf_size = CHUNK_NY*CHUNK_NZ*sizeof(unsigned int);
+ size_t buf_size = CHUNK_NY * CHUNK_NZ * sizeof(unsigned int);
const Bytef *z_src;
- Bytef *z_dst; /*destination buffer */
- uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size);
- uLong z_src_nbytes = (uLong)buf_size;
+ Bytef * z_dst; /*destination buffer */
+ uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size);
+ uLong z_src_nbytes = (uLong)buf_size;
TESTING("Create a file and dataset");
/*
* Create the data space with unlimited dimensions.
*/
- if((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0)
+ if ((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0)
TEST_ERROR;
/*
* Create a new file. If file exists its contents will be overwritten.
*/
- if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0)
+ if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0)
TEST_ERROR;
/*
* Modify dataset creation properties, i.e. enable chunking and compression
*/
- if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
TEST_ERROR;
- if(H5Pset_chunk( cparms, RANK, chunk_dims) < 0)
+ if (H5Pset_chunk(cparms, RANK, chunk_dims) < 0)
TEST_ERROR;
/*
* Create a new dataset within the file using cparms
* creation properties.
*/
- if((dataset = H5Dcreate2(file, DIRECT_UNCOMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
- cparms, H5P_DEFAULT)) < 0)
+ if ((dataset = H5Dcreate2(file, DIRECT_UNCOMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms,
+ H5P_DEFAULT)) < 0)
TEST_ERROR;
- if(H5Dclose(dataset) < 0)
+ if (H5Dclose(dataset) < 0)
TEST_ERROR;
- if((dataset = H5Dcreate2(file, REG_NO_COMPRESS_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
- cparms, H5P_DEFAULT)) < 0)
+ if ((dataset = H5Dcreate2(file, REG_NO_COMPRESS_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms,
+ H5P_DEFAULT)) < 0)
TEST_ERROR;
- if(H5Dclose(dataset) < 0)
+ if (H5Dclose(dataset) < 0)
TEST_ERROR;
/* Set compression */
- if(H5Pset_deflate( cparms, aggression) < 0)
+ if (H5Pset_deflate(cparms, aggression) < 0)
TEST_ERROR;
- if((dataset = H5Dcreate2(file, DIRECT_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
- cparms, H5P_DEFAULT)) < 0)
+ if ((dataset = H5Dcreate2(file, DIRECT_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms,
+ H5P_DEFAULT)) < 0)
TEST_ERROR;
- if(H5Dclose(dataset) < 0)
+ if (H5Dclose(dataset) < 0)
TEST_ERROR;
-
- if((dataset = H5Dcreate2(file, REG_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
- cparms, H5P_DEFAULT)) < 0)
+ if ((dataset = H5Dcreate2(file, REG_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms,
+ H5P_DEFAULT)) < 0)
TEST_ERROR;
- if(H5Dclose(dataset) < 0)
+ if (H5Dclose(dataset) < 0)
TEST_ERROR;
- if(H5Fclose(file) < 0)
+ if (H5Fclose(file) < 0)
TEST_ERROR;
- if(H5Sclose(dataspace) < 0)
+ if (H5Sclose(dataspace) < 0)
TEST_ERROR;
- if(H5Pclose(cparms) < 0)
+ if (H5Pclose(cparms) < 0)
TEST_ERROR;
/* create a unix file*/
- flag = O_CREAT|O_TRUNC|O_WRONLY;
+ flag = O_CREAT | O_TRUNC | O_WRONLY;
- if ((unix_file=open(FILENAME[1],flag,S_IRWXU))== -1)
+ if ((unix_file = open(FILENAME[1], flag, S_IRWXU)) == -1)
TEST_ERROR;
- if (close(unix_file) < 0)
- {
+ if (close(unix_file) < 0) {
printf(" unable to close the file\n");
TEST_ERROR;
}
-
/* Initialize data for chunks */
- for(i = 0; i < NX; i++) {
- p = direct_buf[i] = (unsigned int*)malloc(CHUNK_NY*CHUNK_NZ*sizeof(unsigned int));
-
- for(j=0; j < CHUNK_NY*CHUNK_NZ; j++, p++)
+ for (i = 0; i < NX; i++) {
+ p = direct_buf[i] = (unsigned int *)malloc(CHUNK_NY * CHUNK_NZ * sizeof(unsigned int));
+
+ for (j = 0; j < CHUNK_NY * CHUNK_NZ; j++, p++)
*p = rand() % 65000;
- z_src = (const Bytef*)direct_buf[i];
+ z_src = (const Bytef *)direct_buf[i];
z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size);
/* Allocate output (compressed) buffer */
- outbuf[i] = (unsigned int*)malloc((size_t)z_dst_nbytes);
- z_dst = (Bytef *)outbuf[i];
+ outbuf[i] = (unsigned int *)malloc((size_t)z_dst_nbytes);
+ z_dst = (Bytef *)outbuf[i];
/* Perform compression from the source to the destination buffer */
ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
@@ -219,70 +232,73 @@ int create_file(hid_t fapl_id)
total_size += data_size[i];
/* Check for various zlib errors */
- if(Z_BUF_ERROR == ret) {
+ if (Z_BUF_ERROR == ret) {
fprintf(stderr, "overflow");
TEST_ERROR;
- } else if(Z_MEM_ERROR == ret) {
- fprintf(stderr, "deflate memory error");
+ }
+ else if (Z_MEM_ERROR == ret) {
+ fprintf(stderr, "deflate memory error");
TEST_ERROR;
- } else if(Z_OK != ret) {
- fprintf(stderr, "other deflate error");
+ }
+ else if (Z_OK != ret) {
+ fprintf(stderr, "other deflate error");
TEST_ERROR;
}
}
-
PASSED();
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(dataset);
H5Sclose(dataspace);
H5Pclose(cparms);
H5Fclose(file);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return 1;
}
/*--------------------------------------------------
- * Benchmark the performance of the new function
+ * Benchmark the performance of the new function
* with precompressed data.
*--------------------------------------------------
*/
int
test_direct_write_uncompressed_data(hid_t fapl_id)
{
- hid_t file; /* handles */
- hid_t dataspace, dataset;
- hid_t dxpl;
- herr_t status;
- int i;
+ hid_t file; /* handles */
+ hid_t dataspace, dataset;
+ hid_t dxpl;
+ herr_t status;
+ int i;
+
+ unsigned filter_mask = 0;
+ hsize_t offset[RANK] = {0, 0, 0};
- unsigned filter_mask = 0;
- hsize_t offset[RANK] = {0, 0, 0};
+ struct timeval timeval_start;
- struct timeval timeval_start;
-
TESTING("H5DOwrite_chunk for uncompressed data");
- if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
TEST_ERROR;
/* Start the timer */
- gettimeofday(&timeval_start,NULL);
+ gettimeofday(&timeval_start, NULL);
/* Reopen the file and dataset */
- if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0)
+ if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0)
TEST_ERROR;
- if((dataset = H5Dopen2(file, DIRECT_UNCOMPRESSED_DSET, H5P_DEFAULT)) < 0)
+ if ((dataset = H5Dopen2(file, DIRECT_UNCOMPRESSED_DSET, H5P_DEFAULT)) < 0)
TEST_ERROR;
-
- /* Write the compressed chunk data repeatedly to cover all the chunks in the
- * dataset, using the direct writing function. */
- for(i=0; i<NX; i++) {
- status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, CHUNK_NY*CHUNK_NZ*sizeof(unsigned int), direct_buf[i]);
+ /* Write the compressed chunk data repeatedly to cover all the chunks in the
+ * dataset, using the direct writing function. */
+ for (i = 0; i < NX; i++) {
+ status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset,
+ CHUNK_NY * CHUNK_NZ * sizeof(unsigned int), direct_buf[i]);
(offset[0])++;
}
@@ -293,60 +309,60 @@ test_direct_write_uncompressed_data(hid_t fapl_id)
H5Pclose(dxpl);
H5Fclose(file);
- /* Report the performance */
- reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB));
+ /* Report the performance */
+ reportTime(timeval_start, (double)(NX * NY * NZ * sizeof(unsigned int) / MB));
PASSED();
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(dataset);
H5Pclose(dxpl);
H5Fclose(file);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return 1;
}
-
/*--------------------------------------------------
- * Benchmark the performance of the new function
+ * Benchmark the performance of the new function
* with precompressed data.
*--------------------------------------------------
*/
int
test_direct_write_compressed_data(hid_t fapl_id)
{
- hid_t file; /* handles */
- hid_t dataspace, dataset;
- hid_t dxpl;
- herr_t status;
- int i;
+ hid_t file; /* handles */
+ hid_t dataspace, dataset;
+ hid_t dxpl;
+ herr_t status;
+ int i;
+
+ unsigned filter_mask = 0;
+ hsize_t offset[RANK] = {0, 0, 0};
- unsigned filter_mask = 0;
- hsize_t offset[RANK] = {0, 0, 0};
+ struct timeval timeval_start;
- struct timeval timeval_start;
-
TESTING("H5DOwrite_chunk for pre-compressed data");
- if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
TEST_ERROR;
/* Start the timer */
- gettimeofday(&timeval_start,NULL);
+ gettimeofday(&timeval_start, NULL);
/* Reopen the file and dataset */
- if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0)
+ if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0)
TEST_ERROR;
- if((dataset = H5Dopen2(file, DIRECT_COMPRESSED_DSET, H5P_DEFAULT)) < 0)
+ if ((dataset = H5Dopen2(file, DIRECT_COMPRESSED_DSET, H5P_DEFAULT)) < 0)
TEST_ERROR;
-
- /* Write the compressed chunk data repeatedly to cover all the chunks in the
- * dataset, using the direct writing function. */
- for(i=0; i<NX; i++) {
+ /* Write the compressed chunk data repeatedly to cover all the chunks in the
+ * dataset, using the direct writing function. */
+ for (i = 0; i < NX; i++) {
status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, data_size[i], outbuf[i]);
(offset[0])++;
}
@@ -357,19 +373,21 @@ test_direct_write_compressed_data(hid_t fapl_id)
H5Dclose(dataset);
H5Pclose(dxpl);
H5Fclose(file);
-
- /* Report the performance */
- reportTime(timeval_start, (double)(total_size/MB));
+
+ /* Report the performance */
+ reportTime(timeval_start, (double)(total_size / MB));
PASSED();
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(dataset);
H5Pclose(dxpl);
H5Fclose(file);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return 1;
}
@@ -381,57 +399,59 @@ error:
int
test_compressed_write(hid_t fapl_id)
{
- hid_t file; /* handles */
- hid_t dataspace, dataset;
- hid_t mem_space;
- hsize_t chunk_dims[RANK] ={CHUNK_NX, CHUNK_NY, CHUNK_NZ};
- hid_t dxpl;
- herr_t status;
- int i;
+ hid_t file; /* handles */
+ hid_t dataspace, dataset;
+ hid_t mem_space;
+ hsize_t chunk_dims[RANK] = {CHUNK_NX, CHUNK_NY, CHUNK_NZ};
+ hid_t dxpl;
+ herr_t status;
+ int i;
hsize_t start[RANK]; /* Start of hyperslab */
hsize_t stride[RANK]; /* Stride of hyperslab */
hsize_t count[RANK]; /* Block count */
hsize_t block[RANK]; /* Block sizes */
- struct timeval timeval_start;
+ struct timeval timeval_start;
TESTING("H5Dwrite with compression enabled");
- if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
TEST_ERROR;
- if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
+ if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
TEST_ERROR;
/* Start the timer */
- gettimeofday(&timeval_start,NULL);
+ gettimeofday(&timeval_start, NULL);
/* Reopen the file and dataset */
- if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0)
+ if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0)
TEST_ERROR;
- if((dataset = H5Dopen2(file, REG_COMPRESSED_DSET, H5P_DEFAULT)) < 0)
+ if ((dataset = H5Dopen2(file, REG_COMPRESSED_DSET, H5P_DEFAULT)) < 0)
TEST_ERROR;
- if((dataspace = H5Dget_space(dataset)) < 0)
+ if ((dataspace = H5Dget_space(dataset)) < 0)
TEST_ERROR;
- start[0] = start[1] = start[2] = 0;
+ start[0] = start[1] = start[2] = 0;
stride[0] = stride[1] = stride[2] = 1;
- count[0] = count[1] = count[2] = 1;
- block[0] = CHUNK_NX; block[1] = CHUNK_NY; block[2] = CHUNK_NZ;
-
- for(i=0; i<NX; i++) {
+ count[0] = count[1] = count[2] = 1;
+ block[0] = CHUNK_NX;
+ block[1] = CHUNK_NY;
+ block[2] = CHUNK_NZ;
+
+ for (i = 0; i < NX; i++) {
/*
* Select hyperslab for one chunk in the file
*/
- if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
+ if ((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
TEST_ERROR;
- (start[0])++;
+ (start[0])++;
- if((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace,
- H5P_DEFAULT, direct_buf[i])) < 0)
+ if ((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, direct_buf[i])) <
+ 0)
TEST_ERROR;
}
@@ -443,21 +463,23 @@ test_compressed_write(hid_t fapl_id)
H5Sclose(mem_space);
H5Pclose(dxpl);
H5Fclose(file);
-
- /* Report the performance */
- reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB));
-
+
+ /* Report the performance */
+ reportTime(timeval_start, (double)(NX * NY * NZ * sizeof(unsigned int) / MB));
+
PASSED();
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(dataset);
H5Sclose(dataspace);
H5Sclose(mem_space);
H5Pclose(dxpl);
H5Fclose(file);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return 1;
}
@@ -469,57 +491,59 @@ error:
int
test_no_compress_write(hid_t fapl_id)
{
- hid_t file; /* handles */
- hid_t dataspace, dataset;
- hid_t mem_space;
- hsize_t chunk_dims[RANK] ={CHUNK_NX, CHUNK_NY, CHUNK_NZ};
- hid_t dxpl;
- herr_t status;
- int i;
+ hid_t file; /* handles */
+ hid_t dataspace, dataset;
+ hid_t mem_space;
+ hsize_t chunk_dims[RANK] = {CHUNK_NX, CHUNK_NY, CHUNK_NZ};
+ hid_t dxpl;
+ herr_t status;
+ int i;
hsize_t start[RANK]; /* Start of hyperslab */
hsize_t stride[RANK]; /* Stride of hyperslab */
hsize_t count[RANK]; /* Block count */
hsize_t block[RANK]; /* Block sizes */
- struct timeval timeval_start;
+ struct timeval timeval_start;
TESTING("H5Dwrite without compression");
- if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
TEST_ERROR;
- if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
+ if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
TEST_ERROR;
/* Start the timer */
- gettimeofday(&timeval_start,NULL);
+ gettimeofday(&timeval_start, NULL);
/* Reopen the file and dataset */
- if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0)
+ if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0)
TEST_ERROR;
- if((dataset = H5Dopen2(file, REG_NO_COMPRESS_DSET, H5P_DEFAULT)) < 0)
+ if ((dataset = H5Dopen2(file, REG_NO_COMPRESS_DSET, H5P_DEFAULT)) < 0)
TEST_ERROR;
- if((dataspace = H5Dget_space(dataset)) < 0)
+ if ((dataspace = H5Dget_space(dataset)) < 0)
TEST_ERROR;
- start[0] = start[1] = start[2] = 0;
+ start[0] = start[1] = start[2] = 0;
stride[0] = stride[1] = stride[2] = 1;
- count[0] = count[1] = count[2] = 1;
- block[0] = CHUNK_NX; block[1] = CHUNK_NY; block[2] = CHUNK_NZ;
-
- for(i=0; i<NX; i++) {
+ count[0] = count[1] = count[2] = 1;
+ block[0] = CHUNK_NX;
+ block[1] = CHUNK_NY;
+ block[2] = CHUNK_NZ;
+
+ for (i = 0; i < NX; i++) {
/*
* Select hyperslab for one chunk in the file
*/
- if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
+ if ((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
TEST_ERROR;
- (start[0])++;
+ (start[0])++;
- if((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace,
- H5P_DEFAULT, direct_buf[i])) < 0)
+ if ((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, direct_buf[i])) <
+ 0)
TEST_ERROR;
}
@@ -531,21 +555,23 @@ test_no_compress_write(hid_t fapl_id)
H5Sclose(mem_space);
H5Pclose(dxpl);
H5Fclose(file);
-
- /* Report the performance */
- reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB));
-
+
+ /* Report the performance */
+ reportTime(timeval_start, (double)(NX * NY * NZ * sizeof(unsigned int) / MB));
+
PASSED();
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(dataset);
H5Sclose(dataspace);
H5Sclose(mem_space);
H5Pclose(dxpl);
H5Fclose(file);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return 1;
}
@@ -554,13 +580,13 @@ error:
* data to a Unix file
*--------------------------------------------------
*/
-int
+int
test_unix_write(void)
{
- int file, flag;
- ssize_t op_size;
- int i;
- struct timeval timeval_start;
+ int file, flag;
+ ssize_t op_size;
+ int i;
+ struct timeval timeval_start;
TESTING("Write compressed data to a Unix file");
@@ -568,41 +594,38 @@ test_unix_write(void)
flag = O_WRONLY;
/* Start the timer */
- gettimeofday(&timeval_start,NULL);
+ gettimeofday(&timeval_start, NULL);
- if ((file=open(FILENAME[1],flag))== -1)
+ if ((file = open(FILENAME[1], flag)) == -1)
TEST_ERROR;
- /* Write the compressed chunk data repeatedly to cover all the chunks in the
- * dataset, using the direct writing function. */
- for(i=0; i<NX; i++) {
- op_size = write(file, outbuf[i],data_size[i]);
- if (op_size < 0)
- {
+ /* Write the compressed chunk data repeatedly to cover all the chunks in the
+ * dataset, using the direct writing function. */
+ for (i = 0; i < NX; i++) {
+ op_size = write(file, outbuf[i], data_size[i]);
+ if (op_size < 0) {
printf(" Error in writing data to file because %s \n", strerror(errno));
TEST_ERROR;
}
- else if (op_size == 0)
- {
+ else if (op_size == 0) {
printf(" unable to write sufficent data to file because %s \n", strerror(errno));
TEST_ERROR;
}
}
- if (close(file) < 0)
- {
+ if (close(file) < 0) {
printf(" unable to close the file\n");
TEST_ERROR;
}
- /* Report the performance */
- reportTime(timeval_start, (double)(total_size/MB));
+ /* Report the performance */
+ reportTime(timeval_start, (double)(total_size / MB));
PASSED();
return 0;
error:
- return 1;
+ return 1;
}
/*--------------------------------------------------
@@ -610,16 +633,16 @@ error:
*--------------------------------------------------
*/
int
-main (void)
+main(void)
{
- hid_t fapl = H5P_DEFAULT;
- int i;
+ hid_t fapl = H5P_DEFAULT;
+ int i;
/* Testing setup */
-/* h5_reset();
- fapl = h5_fileaccess();
+ /* h5_reset();
+ fapl = h5_fileaccess();
- h5_fixname(FILENAME[0], fapl, filename, sizeof filename);*/
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);*/
sprintf(filename, "%s.h5", FILENAME[0]);
@@ -630,11 +653,11 @@ main (void)
test_compressed_write(fapl);
test_unix_write();
- for(i=0; i<NX; i++) {
+ for (i = 0; i < NX; i++) {
free(outbuf[i]);
free(direct_buf[i]);
}
-
-/* h5_cleanup(FILENAME, fapl);*/
+
+ /* h5_cleanup(FILENAME, fapl);*/
return 0;
}
diff --git a/hl/test/gen_test_ds.c b/hl/test/gen_test_ds.c
index f8f1d39..c3fc7ff 100644
--- a/hl/test/gen_test_ds.c
+++ b/hl/test/gen_test_ds.c
@@ -6,7 +6,7 @@
* 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. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -31,9 +31,9 @@
/* prototypes */
static hid_t open_test_file(const char *fileext);
-herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx);
-herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx);
-herr_t test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx);
+herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx);
+herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx);
+herr_t test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx);
herr_t test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx);
herr_t test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx);
@@ -43,48 +43,47 @@ static int test_long_scalenames(const char *filename);
static int test_samelong_scalenames(const char *filename);
static int test_foreign_scaleattached(const char *filename);
-
-#define DIM_DATA 12
-#define DIM1_SIZE 3
-#define DIM2_SIZE 4
-#define DIM3_SIZE 12
-#define DIM4_SIZE 2
-#define DIM0 0
-#define DIM1 1
-#define DIM2 2
-#define DIM3 3
-
-#define DATASET_NAME "dset_"
-#define DS_1_NAME "ds_1_"
-#define DS_2_NAME "ds_2_"
-#define DS_3_NAME "ds_3_"
-#define DS_4_NAME "ds_4_"
-
-#define SCALE_1_NAME "scalename_1_"
-#define SCALE_2_NAME "scalename_2_"
-#define SCALE_3_NAME "scalename_3_"
-#define SCALE_4_NAME "scalename_4_"
-
-#define FILENAME "test_ds_"
-#define FILEEXT ".h5"
+#define DIM_DATA 12
+#define DIM1_SIZE 3
+#define DIM2_SIZE 4
+#define DIM3_SIZE 12
+#define DIM4_SIZE 2
+#define DIM0 0
+#define DIM1 1
+#define DIM2 2
+#define DIM3 3
+
+#define DATASET_NAME "dset_"
+#define DS_1_NAME "ds_1_"
+#define DS_2_NAME "ds_2_"
+#define DS_3_NAME "ds_3_"
+#define DS_4_NAME "ds_4_"
+
+#define SCALE_1_NAME "scalename_1_"
+#define SCALE_2_NAME "scalename_2_"
+#define SCALE_3_NAME "scalename_3_"
+#define SCALE_4_NAME "scalename_4_"
+
+#define FILENAME "test_ds_"
+#define FILEEXT ".h5"
/*-------------------------------------------------------------------------
* the main program
*-------------------------------------------------------------------------
*/
-int main(int argc , char **argv)
+int
+main(int argc, char **argv)
{
- int nerrors=0;
+ int nerrors = 0;
char filename[65];
-
if (argc < 2) {
- printf("Usage: gen_test [le | be]\n");
+ HDprintf("Usage: gen_test [le | be]\n");
return 1;
}
- if ( argv[1] && (strcmp("le",argv[1])!=0) && (strcmp("be",argv[1])!=0) ) {
- printf("Usage: gen_test [le | be]\n");
+ if (argv[1] && (strcmp("le", argv[1]) != 0) && (strcmp("be", argv[1]) != 0)) {
+ HDprintf("Usage: gen_test [le | be]\n");
return 1;
}
@@ -92,26 +91,28 @@ int main(int argc , char **argv)
strcpy(filename, FILENAME);
strcat(filename, argv[1]);
strcat(filename, FILEEXT);
- if(H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT) < 0) {
+ if (H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT) < 0) {
nerrors = 1;
goto error;
}
- nerrors += test_long_attachscales(filename) < 0 ? 1 : 0;
- nerrors += test_duplicatelong_attachscales(filename) < 0 ? 1 : 0;
- nerrors += test_samelong_scalenames(filename) < 0 ? 1 : 0;
- nerrors += test_foreign_scaleattached(filename) < 0 ? 1 : 0;
- nerrors += test_long_scalenames(filename) < 0 ? 1 : 0;
-
- if(nerrors) goto error;
- printf("Dimension scales file generation passed.\n");
+ nerrors += test_long_attachscales(filename) < 0 ? 1 : 0;
+ nerrors += test_duplicatelong_attachscales(filename) < 0 ? 1 : 0;
+ nerrors += test_samelong_scalenames(filename) < 0 ? 1 : 0;
+ nerrors += test_foreign_scaleattached(filename) < 0 ? 1 : 0;
+ nerrors += test_long_scalenames(filename) < 0 ? 1 : 0;
+
+ if (nerrors)
+ goto error;
+ HDprintf("Dimension scales file generation passed.\n");
return 0;
error:
- printf("***** %d DIMENSION SCALES FILE GENERATION FAILED! *****\n",nerrors);
+ HDprintf("***** %d DIMENSION SCALES FILE GENERATION FAILED! *****\n", nerrors);
return 1;
}
-static hid_t open_test_file(const char *fileext)
+static hid_t
+open_test_file(const char *fileext)
{
char filename[65];
@@ -127,191 +128,197 @@ static hid_t open_test_file(const char *fileext)
*-------------------------------------------------------------------------
*/
-herr_t create_long_dataset(hid_t fid, const char *name, const char *dsidx)
+herr_t
+create_long_dataset(hid_t fid, const char *name, const char *dsidx)
{
- int rank = 4;
- int rankds = 1;
- hsize_t dims[4] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE,DIM4_SIZE};
- long buf[DIM_DATA*3*2] = {1,2,3,4,5,6,7,8,9,10,11,12,
- 1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,4,5,6,7,8,9,10,11,12,
- 1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,4,5,6,7,8,9,10,11,12,
- 1,2,3,4,5,6,7,8,9,10,11,12};
- hsize_t s1_dim[1] = {DIM1_SIZE};
- hsize_t s2_dim[1] = {DIM2_SIZE};
- hsize_t s3_dim[1] = {DIM3_SIZE};
- hsize_t s4_dim[1] = {DIM4_SIZE};
- long s1_wbuf[DIM1_SIZE] = {10,20,30};
- long s2_wbuf[DIM2_SIZE] = {100,200,300,400};
- long s3_wbuf[DIM3_SIZE] = {10,10,10,20,20,20,30,30,30,40,40,40};
- long s4_wbuf[DIM4_SIZE] = {18,18};
+ int rank = 4;
+ int rankds = 1;
+ hsize_t dims[4] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE, DIM4_SIZE};
+ long buf[DIM_DATA * 3 * 2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
+ hsize_t s1_dim[1] = {DIM1_SIZE};
+ hsize_t s2_dim[1] = {DIM2_SIZE};
+ hsize_t s3_dim[1] = {DIM3_SIZE};
+ hsize_t s4_dim[1] = {DIM4_SIZE};
+ long s1_wbuf[DIM1_SIZE] = {10, 20, 30};
+ long s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400};
+ long s3_wbuf[DIM3_SIZE] = {10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40};
+ long s4_wbuf[DIM4_SIZE] = {18, 18};
/* make a dataset */
- if(H5LTmake_dataset_long(fid, name, rank, dims, buf) >= 0) {
+ if (H5LTmake_dataset_long(fid, name, rank, dims, buf) >= 0) {
/* make a DS dataset for the first dimension */
char dsname[32];
strcpy(dsname, DS_1_NAME);
strcat(dsname, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_long(fid, dsname, rankds, s1_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, dsname, rankds, s1_dim, s1_wbuf) < 0)
return FAIL;
strcpy(dsname, DS_2_NAME);
strcat(dsname, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_long(fid, dsname, rankds, s2_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, dsname, rankds, s2_dim, s2_wbuf) < 0)
return FAIL;
strcpy(dsname, DS_3_NAME);
strcat(dsname, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_long(fid, dsname, rankds, s3_dim, s3_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, dsname, rankds, s3_dim, s3_wbuf) < 0)
return FAIL;
strcpy(dsname, DS_4_NAME);
strcat(dsname, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_long(fid, dsname, rankds, s4_dim, s4_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, dsname, rankds, s4_dim, s4_wbuf) < 0)
return FAIL;
- }
- else
- return FAIL;
+ }
+ else
+ return FAIL;
return SUCCEED;
}
-herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
+herr_t
+test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
{
- herr_t ret_value = FAIL;
- hid_t dsid = -1;
-
- if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 0) {
- if(H5DSattach_scale(did, dsid, idx) >= 0) {
- if(H5DSis_attached(did, dsid, idx) > 0) {
- /* printf(" scale attached "); */
+ herr_t ret_value = FAIL;
+ hid_t dsid = -1;
+
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 0) {
+ if (H5DSattach_scale(did, dsid, idx) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) > 0) {
+ /* HDprintf(" scale attached "); */
ret_value = SUCCEED;
}
- else if(H5DSis_attached(did, dsid, idx) == 0) {
- printf(" scale not attached ");
+ else if (H5DSis_attached(did, dsid, idx) == 0) {
+ HDprintf(" scale not attached ");
}
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
ret_value = FAIL;
}
return ret_value;
}
-herr_t test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
+herr_t
+test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
{
- herr_t ret_value = FAIL;
- hid_t dsid = -1;
+ herr_t ret_value = FAIL;
+ hid_t dsid = -1;
- if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 1) {
- if(H5DSdetach_scale(did, dsid, idx) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 0) {
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 1) {
+ if (H5DSdetach_scale(did, dsid, idx) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 0) {
ret_value = SUCCEED;
}
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
ret_value = FAIL;
}
return ret_value;
}
-herr_t test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
+herr_t
+test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
{
- herr_t ret_value = FAIL;
- hid_t dsid = -1;
+ herr_t ret_value = FAIL;
+ hid_t dsid = -1;
- if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 1) {
- if(H5DSset_scale(dsid, scalename) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 1) {
- ret_value = SUCCEED;
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 1) {
+ if (H5DSset_scale(dsid, scalename) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 1) {
+ ret_value = SUCCEED;
}
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
ret_value = FAIL;
}
return ret_value;
}
-herr_t test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
+herr_t
+test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
{
herr_t ret_value = FAIL;
- hid_t dsid = -1;
+ hid_t dsid = -1;
ssize_t name_len;
- char *name_out=NULL;
-
- if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 1) {
- if((name_len=H5DSget_scale_name(dsid,NULL,(size_t)0)) > 0) {
- name_out = (char*)HDmalloc((size_t)name_len * sizeof (char));
- if(name_out != NULL) {
- if(H5DSget_scale_name(dsid, name_out, (size_t)name_len) >= 0) {
- if(strcmp(scalename,name_out)==0) {
+ char * name_out = NULL;
+
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 1) {
+ if ((name_len = H5DSget_scale_name(dsid, NULL, (size_t)0)) > 0) {
+ name_out = (char *)HDmalloc((size_t)name_len * sizeof(char));
+ if (name_out != NULL) {
+ if (H5DSget_scale_name(dsid, name_out, (size_t)name_len) >= 0) {
+ if (strcmp(scalename, name_out) == 0) {
ret_value = SUCCEED;
}
HDfree(name_out);
- name_out=NULL;
+ name_out = NULL;
}
}
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
ret_value = FAIL;
}
return ret_value;
}
-static int test_long_attachscales(const char *filename)
+static int
+test_long_attachscales(const char *filename)
{
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
strcpy(dsname, DATASET_NAME);
strcat(dsname, "al");
- TESTING2("test_long_attachscales");
+ HL_TESTING2("test_long_attachscales");
- if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ if ((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
goto out;
/* make a dataset */
- if(create_long_dataset(fid, dsname, "al") < 0)
+ if (create_long_dataset(fid, dsname, "al") < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
strcpy(scalename, DS_1_NAME);
strcat(scalename, "al");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
strcpy(scalename, DS_2_NAME);
strcat(scalename, "al");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
strcpy(scalename, DS_3_NAME);
strcat(scalename, "al");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
strcpy(scalename, DS_4_NAME);
strcat(scalename, "al");
- if(test_attach_scale(fid, did, scalename, DIM3) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM3) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -323,56 +330,59 @@ static int test_long_attachscales(const char *filename)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_duplicatelong_attachscales(const char *filename)
+static int
+test_duplicatelong_attachscales(const char *filename)
{
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
strcpy(dsname, DATASET_NAME);
strcat(dsname, "al2");
- TESTING2("test_duplicatelong_attachscales");
+ HL_TESTING2("test_duplicatelong_attachscales");
- if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ if ((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
goto out;
/* make a dataset 2 */
- if(create_long_dataset(fid, dsname, "al2") < 0)
+ if (create_long_dataset(fid, dsname, "al2") < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
strcpy(scalename, DS_1_NAME);
strcat(scalename, "al");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
strcpy(scalename, DS_2_NAME);
strcat(scalename, "al");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
strcpy(scalename, DS_3_NAME);
strcat(scalename, "al");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
strcpy(scalename, DS_4_NAME);
strcat(scalename, "al");
- if(test_attach_scale(fid, did, scalename, DIM3) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM3) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -384,71 +394,75 @@ static int test_duplicatelong_attachscales(const char *filename)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_long_scalenames(const char *filename) {
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
- char name[32];
+static int
+test_long_scalenames(const char *filename)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
strcpy(dsname, DATASET_NAME);
strcat(dsname, "al");
- if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ if ((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
goto out;
- TESTING2("set long scale/cmp scale name");
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ HL_TESTING2("set long scale/cmp scale name");
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
strcpy(scalename, DS_1_NAME);
strcat(scalename, "al");
strcpy(name, SCALE_1_NAME);
strcat(name, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
strcpy(scalename, DS_2_NAME);
strcat(scalename, "al");
strcpy(name, SCALE_2_NAME);
strcat(name, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
strcpy(scalename, DS_3_NAME);
strcat(scalename, "al");
strcpy(name, SCALE_3_NAME);
strcat(name, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
strcpy(scalename, DS_4_NAME);
strcat(scalename, "al");
strcpy(name, SCALE_4_NAME);
strcat(name, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM3) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM3) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -460,72 +474,76 @@ static int test_long_scalenames(const char *filename) {
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_samelong_scalenames(const char *filename) {
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
- char name[32];
+static int
+test_samelong_scalenames(const char *filename)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
strcpy(dsname, DATASET_NAME);
strcat(dsname, "al2");
- if((fid = open_test_file(filename)) < 0)
+ if ((fid = open_test_file(filename)) < 0)
goto out;
- TESTING2("set same long scale/cmp scale name");
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ HL_TESTING2("set same long scale/cmp scale name");
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
strcpy(scalename, DS_1_NAME);
strcat(scalename, "al");
strcpy(name, DS_1_NAME);
strcat(name, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
strcpy(scalename, DS_2_NAME);
strcat(scalename, "al");
strcpy(name, DS_2_NAME);
strcat(name, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
strcpy(scalename, DS_3_NAME);
strcat(scalename, "al");
strcpy(name, DS_3_NAME);
strcat(name, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
strcpy(scalename, DS_4_NAME);
strcat(scalename, "al");
strcpy(name, DS_4_NAME);
strcat(name, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM3) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM3) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -537,43 +555,46 @@ static int test_samelong_scalenames(const char *filename) {
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_foreign_scaleattached(const char *filename)
+static int
+test_foreign_scaleattached(const char *filename)
{
- herr_t ret_value = FAIL;
- hid_t fid = -1;
- hid_t did = -1;
- hid_t dsid = -1;
+ herr_t ret_value = FAIL;
+ hid_t fid = -1;
+ hid_t did = -1;
+ hid_t dsid = -1;
- TESTING2("test_foreign_scaleattached");
+ HL_TESTING2("test_foreign_scaleattached");
- if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
goto out;
- if((did = H5Dopen2(fid, "/dset_al", H5P_DEFAULT)) >= 0) {
- if((dsid = H5Dopen2(fid, "/ds_4_al", H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, 3) == 1) {
+ if ((did = H5Dopen2(fid, "/dset_al", H5P_DEFAULT)) >= 0) {
+ if ((dsid = H5Dopen2(fid, "/ds_4_al", H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, 3) == 1) {
ret_value = SUCCEED;
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
goto out;
- if(ret_value == FAIL)
+ if (ret_value == FAIL)
goto out;
PASSED();
@@ -582,10 +603,12 @@ static int test_foreign_scaleattached(const char *filename)
return 0;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
diff --git a/hl/test/h5hltest.h b/hl/test/h5hltest.h
index f368b8e..d286c00 100644
--- a/hl/test/h5hltest.h
+++ b/hl/test/h5hltest.h
@@ -6,7 +6,7 @@
* 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. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -28,13 +28,24 @@
#include "H5HLprivate2.h"
/* Macros used in HL tests */
-#define TESTING2(WHAT) {printf("%-70s", "Testing " WHAT); fflush(stdout);}
-#define TESTING3(WHAT) {printf("%-70s", "" WHAT); fflush(stdout);}
+#define HL_TESTING2(WHAT) \
+ { \
+ HDprintf("Testing %-62s", WHAT); \
+ HDfflush(stdout); \
+ }
+#define HL_TESTING3(WHAT) \
+ { \
+ HDprintf("Testing %-62s", WHAT); \
+ HDfflush(stdout); \
+ }
/* Implements verbose 'assert' with 'goto error' exit */
-#define VERIFY(condition, string) do { if (!(condition)) FAIL_PUTS_ERROR(string) } while(0)
+#define VERIFY(condition, string) \
+ do { \
+ if (!(condition)) \
+ FAIL_PUTS_ERROR(string) \
+ } while (0)
int test_packet_table_with_varlen(void);
#endif /* _H5HLTEST_H */
-
diff --git a/hl/test/pal_rgb.h b/hl/test/pal_rgb.h
index 4b22bea..a2b17e2 100644
--- a/hl/test/pal_rgb.h
+++ b/hl/test/pal_rgb.h
@@ -6,266 +6,268 @@
* 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. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-const unsigned char pal_rgb[256*3] = {255,255,255,
-0,0,131,
-0,0,135,
-0,0,139,
-0,0,143,
-0,0,147,
-0,0,151,
-0,0,155,
-0,0,159,
-0,0,163,
-0,0,167,
-0,0,171,
-0,0,175,
-0,0,179,
-0,0,183,
-0,0,187,
-0,0,191,
-0,0,195,
-0,0,199,
-0,0,203,
-0,0,207,
-0,0,211,
-0,0,215,
-0,0,219,
-0,0,223,
-0,0,227,
-0,0,231,
-0,0,235,
-0,0,239,
-0,0,243,
-0,0,247,
-0,0,251,
-0,0,255,
-0,0,255,
-0,3,255,
-0,7,255,
-0,11,255,
-0,15,255,
-0,19,255,
-0,23,255,
-0,27,255,
-0,31,255,
-0,35,255,
-0,39,255,
-0,43,255,
-0,47,255,
-0,51,255,
-0,55,255,
-0,59,255,
-0,63,255,
-0,67,255,
-0,71,255,
-0,75,255,
-0,79,255,
-0,83,255,
-0,87,255,
-0,91,255,
-0,95,255,
-0,99,255,
-0,103,255,
-0,107,255,
-0,111,255,
-0,115,255,
-0,119,255,
-0,123,255,
-0,127,255,
-0,131,255,
-0,135,255,
-0,139,255,
-0,143,255,
-0,147,255,
-0,151,255,
-0,155,255,
-0,159,255,
-0,163,255,
-0,167,255,
-0,171,255,
-0,175,255,
-0,179,255,
-0,183,255,
-0,187,255,
-0,191,255,
-0,195,255,
-0,199,255,
-0,203,255,
-0,207,255,
-0,211,255,
-0,215,255,
-0,219,255,
-0,223,255,
-0,227,255,
-0,231,255,
-0,235,255,
-0,239,255,
-0,243,255,
-0,247,255,
-0,251,255,
-0,255,255,
-0,255,255,
-3,255,251,
-7,255,247,
-11,255,243,
-15,255,239,
-19,255,235,
-23,255,231,
-27,255,227,
-31,255,223,
-35,255,219,
-39,255,215,
-43,255,211,
-47,255,207,
-51,255,203,
-55,255,199,
-59,255,195,
-63,255,191,
-67,255,187,
-71,255,183,
-75,255,179,
-79,255,175,
-83,255,171,
-87,255,167,
-91,255,163,
-95,255,159,
-99,255,155,
-103,255,151,
-107,255,147,
-111,255,143,
-115,255,139,
-119,255,135,
-123,255,131,
-127,255,127,
-131,255,123,
-135,255,119,
-139,255,115,
-143,255,111,
-147,255,107,
-151,255,103,
-155,255,99,
-159,255,95,
-163,255,91,
-167,255,87,
-171,255,83,
-175,255,79,
-179,255,75,
-183,255,71,
-187,255,67,
-191,255,63,
-195,255,59,
-199,255,55,
-203,255,51,
-207,255,47,
-211,255,43,
-215,255,39,
-219,255,35,
-223,255,31,
-227,255,27,
-231,255,23,
-235,255,19,
-239,255,15,
-243,255,11,
-247,255,7,
-251,255,3,
-255,255,0,
-255,251,0,
-255,247,0,
-255,243,0,
-255,239,0,
-255,235,0,
-255,231,0,
-255,227,0,
-255,223,0,
-255,219,0,
-255,215,0,
-255,211,0,
-255,207,0,
-255,203,0,
-255,199,0,
-255,195,0,
-255,191,0,
-255,187,0,
-255,183,0,
-255,179,0,
-255,175,0,
-255,171,0,
-255,167,0,
-255,163,0,
-255,159,0,
-255,155,0,
-255,151,0,
-255,147,0,
-255,143,0,
-255,139,0,
-255,135,0,
-255,131,0,
-255,127,0,
-255,123,0,
-255,119,0,
-255,115,0,
-255,111,0,
-255,107,0,
-255,103,0,
-255,99,0,
-255,95,0,
-255,91,0,
-255,87,0,
-255,83,0,
-255,79,0,
-255,75,0,
-255,71,0,
-255,67,0,
-255,63,0,
-255,59,0,
-255,55,0,
-255,51,0,
-255,47,0,
-255,43,0,
-255,39,0,
-255,35,0,
-255,31,0,
-255,27,0,
-255,23,0,
-255,19,0,
-255,15,0,
-255,11,0,
-255,7,0,
-255,3,0,
-255,0,0,
-250,0,0,
-246,0,0,
-241,0,0,
-237,0,0,
-233,0,0,
-228,0,0,
-224,0,0,
-219,0,0,
-215,0,0,
-211,0,0,
-206,0,0,
-202,0,0,
-197,0,0,
-193,0,0,
-189,0,0,
-184,0,0,
-180,0,0,
-175,0,0,
-171,0,0,
-167,0,0,
-162,0,0,
-158,0,0,
-153,0,0,
-149,0,0,
-145,0,0,
-140,0,0,
-136,0,0,
-131,0,0,
-127,0,0
+/* clang-format off */
+const unsigned char pal_rgb[256*3] = {
+ 255,255,255,
+ 0,0,131,
+ 0,0,135,
+ 0,0,139,
+ 0,0,143,
+ 0,0,147,
+ 0,0,151,
+ 0,0,155,
+ 0,0,159,
+ 0,0,163,
+ 0,0,167,
+ 0,0,171,
+ 0,0,175,
+ 0,0,179,
+ 0,0,183,
+ 0,0,187,
+ 0,0,191,
+ 0,0,195,
+ 0,0,199,
+ 0,0,203,
+ 0,0,207,
+ 0,0,211,
+ 0,0,215,
+ 0,0,219,
+ 0,0,223,
+ 0,0,227,
+ 0,0,231,
+ 0,0,235,
+ 0,0,239,
+ 0,0,243,
+ 0,0,247,
+ 0,0,251,
+ 0,0,255,
+ 0,0,255,
+ 0,3,255,
+ 0,7,255,
+ 0,11,255,
+ 0,15,255,
+ 0,19,255,
+ 0,23,255,
+ 0,27,255,
+ 0,31,255,
+ 0,35,255,
+ 0,39,255,
+ 0,43,255,
+ 0,47,255,
+ 0,51,255,
+ 0,55,255,
+ 0,59,255,
+ 0,63,255,
+ 0,67,255,
+ 0,71,255,
+ 0,75,255,
+ 0,79,255,
+ 0,83,255,
+ 0,87,255,
+ 0,91,255,
+ 0,95,255,
+ 0,99,255,
+ 0,103,255,
+ 0,107,255,
+ 0,111,255,
+ 0,115,255,
+ 0,119,255,
+ 0,123,255,
+ 0,127,255,
+ 0,131,255,
+ 0,135,255,
+ 0,139,255,
+ 0,143,255,
+ 0,147,255,
+ 0,151,255,
+ 0,155,255,
+ 0,159,255,
+ 0,163,255,
+ 0,167,255,
+ 0,171,255,
+ 0,175,255,
+ 0,179,255,
+ 0,183,255,
+ 0,187,255,
+ 0,191,255,
+ 0,195,255,
+ 0,199,255,
+ 0,203,255,
+ 0,207,255,
+ 0,211,255,
+ 0,215,255,
+ 0,219,255,
+ 0,223,255,
+ 0,227,255,
+ 0,231,255,
+ 0,235,255,
+ 0,239,255,
+ 0,243,255,
+ 0,247,255,
+ 0,251,255,
+ 0,255,255,
+ 0,255,255,
+ 3,255,251,
+ 7,255,247,
+ 11,255,243,
+ 15,255,239,
+ 19,255,235,
+ 23,255,231,
+ 27,255,227,
+ 31,255,223,
+ 35,255,219,
+ 39,255,215,
+ 43,255,211,
+ 47,255,207,
+ 51,255,203,
+ 55,255,199,
+ 59,255,195,
+ 63,255,191,
+ 67,255,187,
+ 71,255,183,
+ 75,255,179,
+ 79,255,175,
+ 83,255,171,
+ 87,255,167,
+ 91,255,163,
+ 95,255,159,
+ 99,255,155,
+ 103,255,151,
+ 107,255,147,
+ 111,255,143,
+ 115,255,139,
+ 119,255,135,
+ 123,255,131,
+ 127,255,127,
+ 131,255,123,
+ 135,255,119,
+ 139,255,115,
+ 143,255,111,
+ 147,255,107,
+ 151,255,103,
+ 155,255,99,
+ 159,255,95,
+ 163,255,91,
+ 167,255,87,
+ 171,255,83,
+ 175,255,79,
+ 179,255,75,
+ 183,255,71,
+ 187,255,67,
+ 191,255,63,
+ 195,255,59,
+ 199,255,55,
+ 203,255,51,
+ 207,255,47,
+ 211,255,43,
+ 215,255,39,
+ 219,255,35,
+ 223,255,31,
+ 227,255,27,
+ 231,255,23,
+ 235,255,19,
+ 239,255,15,
+ 243,255,11,
+ 247,255,7,
+ 251,255,3,
+ 255,255,0,
+ 255,251,0,
+ 255,247,0,
+ 255,243,0,
+ 255,239,0,
+ 255,235,0,
+ 255,231,0,
+ 255,227,0,
+ 255,223,0,
+ 255,219,0,
+ 255,215,0,
+ 255,211,0,
+ 255,207,0,
+ 255,203,0,
+ 255,199,0,
+ 255,195,0,
+ 255,191,0,
+ 255,187,0,
+ 255,183,0,
+ 255,179,0,
+ 255,175,0,
+ 255,171,0,
+ 255,167,0,
+ 255,163,0,
+ 255,159,0,
+ 255,155,0,
+ 255,151,0,
+ 255,147,0,
+ 255,143,0,
+ 255,139,0,
+ 255,135,0,
+ 255,131,0,
+ 255,127,0,
+ 255,123,0,
+ 255,119,0,
+ 255,115,0,
+ 255,111,0,
+ 255,107,0,
+ 255,103,0,
+ 255,99,0,
+ 255,95,0,
+ 255,91,0,
+ 255,87,0,
+ 255,83,0,
+ 255,79,0,
+ 255,75,0,
+ 255,71,0,
+ 255,67,0,
+ 255,63,0,
+ 255,59,0,
+ 255,55,0,
+ 255,51,0,
+ 255,47,0,
+ 255,43,0,
+ 255,39,0,
+ 255,35,0,
+ 255,31,0,
+ 255,27,0,
+ 255,23,0,
+ 255,19,0,
+ 255,15,0,
+ 255,11,0,
+ 255,7,0,
+ 255,3,0,
+ 255,0,0,
+ 250,0,0,
+ 246,0,0,
+ 241,0,0,
+ 237,0,0,
+ 233,0,0,
+ 228,0,0,
+ 224,0,0,
+ 219,0,0,
+ 215,0,0,
+ 211,0,0,
+ 206,0,0,
+ 202,0,0,
+ 197,0,0,
+ 193,0,0,
+ 189,0,0,
+ 184,0,0,
+ 180,0,0,
+ 175,0,0,
+ 171,0,0,
+ 167,0,0,
+ 162,0,0,
+ 158,0,0,
+ 153,0,0,
+ 149,0,0,
+ 145,0,0,
+ 140,0,0,
+ 136,0,0,
+ 131,0,0,
+ 127,0,0
};
-
+/* clang-format on */
diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c
index 5560f03..a2568cd 100644
--- a/hl/test/test_ds.c
+++ b/hl/test/test_ds.c
@@ -6,7 +6,7 @@
* 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. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -29,27 +29,43 @@ static herr_t op_stop(hid_t did, unsigned dim, hid_t dsid, void *visitor_data);
/* prototypes */
static hid_t create_test_file(const char *fileext);
static hid_t open_test_file(const char *fileext);
-herr_t create_char_dataset(hid_t fid, const char *dsidx, int fulldims);
-herr_t create_short_dataset(hid_t fid, const char *dsidx, int fulldims);
-herr_t create_int_dataset(hid_t fid, const char *dsidx, int fulldims);
-herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldims);
-herr_t create_float_dataset(hid_t fid, const char *dsidx, int fulldims);
-herr_t create_DS1_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf);
-herr_t create_DS2_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf, char *s2_wbuf);
-herr_t create_DS3_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf, char *s2_wbuf, char *s3_wbuf);
-herr_t create_DS1_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf);
-herr_t create_DS2_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf, short *s2_wbuf);
-herr_t create_DS3_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf, short *s2_wbuf, short *s3_wbuf);
-herr_t create_DS1_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf);
-herr_t create_DS2_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf, int *s2_wbuf);
-herr_t create_DS3_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf, int *s2_wbuf, int *s3_wbuf);
-herr_t create_DS1_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf);
-herr_t create_DS2_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf);
-herr_t create_DS3_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf, long *s3_wbuf);
-herr_t create_DS4_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf, long *s3_wbuf, long *s4_wbuf);
-herr_t create_DS1_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf);
-herr_t create_DS2_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf, float *s2_wbuf);
-herr_t create_DS3_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf, float *s2_wbuf, float *s3_wbuf);
+herr_t create_char_dataset(hid_t fid, const char *dsidx, int fulldims);
+herr_t create_short_dataset(hid_t fid, const char *dsidx, int fulldims);
+herr_t create_int_dataset(hid_t fid, const char *dsidx, int fulldims);
+herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldims);
+herr_t create_float_dataset(hid_t fid, const char *dsidx, int fulldims);
+herr_t create_DS1_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf,
+ char *s1_wbuf);
+herr_t create_DS2_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf,
+ char *s1_wbuf, char *s2_wbuf);
+herr_t create_DS3_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf,
+ char *s1_wbuf, char *s2_wbuf, char *s3_wbuf);
+herr_t create_DS1_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf,
+ short *s1_wbuf);
+herr_t create_DS2_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf,
+ short *s1_wbuf, short *s2_wbuf);
+herr_t create_DS3_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf,
+ short *s1_wbuf, short *s2_wbuf, short *s3_wbuf);
+herr_t create_DS1_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf,
+ int *s1_wbuf);
+herr_t create_DS2_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf,
+ int *s1_wbuf, int *s2_wbuf);
+herr_t create_DS3_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf,
+ int *s1_wbuf, int *s2_wbuf, int *s3_wbuf);
+herr_t create_DS1_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf,
+ long *s1_wbuf);
+herr_t create_DS2_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf,
+ long *s1_wbuf, long *s2_wbuf);
+herr_t create_DS3_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf,
+ long *s1_wbuf, long *s2_wbuf, long *s3_wbuf);
+herr_t create_DS4_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf,
+ long *s1_wbuf, long *s2_wbuf, long *s3_wbuf, long *s4_wbuf);
+herr_t create_DS1_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf,
+ float *s1_wbuf);
+herr_t create_DS2_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf,
+ float *s1_wbuf, float *s2_wbuf);
+herr_t create_DS3_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf,
+ float *s1_wbuf, float *s2_wbuf, float *s3_wbuf);
herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx);
herr_t test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx);
herr_t test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx);
@@ -78,64 +94,64 @@ static int test_rank(void);
static int test_types(void);
static int test_iterators(void);
static int test_data(void);
-static int read_data( const char* fname, int ndims, hsize_t *dims, float **buf );
+static int read_data(const char *fname, int ndims, hsize_t *dims, float **buf);
static int test_attach_detach(void);
-#define RANK1 1
-#define RANK 2
-#define DIM_DATA 12
-#define DIM1_SIZE 3
-#define DIM2_SIZE 4
-#define DIM3_SIZE 12
-#define DIM4_SIZE 2
-#define DIM0 0
-#define DIM1 1
-#define DIM2 2
-#define DIM3 3
-
-#define DATASET_NAME "dset_"
-#define DS_1_NAME "ds_1_"
-#define DS_11_NAME "ds_11_"
-#define DS_2_NAME "ds_2_"
-#define DS_21_NAME "ds_21_"
-#define DS_22_NAME "ds_22_"
-#define DS_3_NAME "ds_3_"
-#define DS_31_NAME "ds_31_"
-#define DS_32_NAME "ds_32_"
-#define DS_33_NAME "ds_33_"
-#define DS_4_NAME "ds_4_"
-#define DS_41_NAME "ds_41_"
-#define DS_42_NAME "ds_42_"
-#define DS_43_NAME "ds_43_"
-#define DS_44_NAME "ds_44_"
-
-#define SCALE_1_NAME "scalename_1_"
-#define SCALE_11_NAME "scalename_11_"
-#define SCALE_2_NAME "scalename_2_"
-#define SCALE_21_NAME "scalename_21_"
-#define SCALE_22_NAME "scalename_22_"
-#define SCALE_3_NAME "scalename_3_"
-#define SCALE_31_NAME "scalename_31_"
-#define SCALE_32_NAME "scalename_32_"
-#define SCALE_33_NAME "scalename_33_"
-#define SCALE_4_NAME "scalename_4_"
-
-#define DIM0_LABEL "Latitude"
-#define DIM1_LABEL "Longitude"
-
-#define FOREIGN_FILE1 "test_ds_le.h5"
-#define FOREIGN_FILE2 "test_ds_be.h5"
-#define FILENAME "test_ds"
-#define FILEEXT ".h5"
-
-#define FILE1 "test_ds3.h5"
-#define FILE2 "test_ds4.h5"
-#define FILE3 "test_ds5.h5"
-#define FILE4 "test_ds6.h5"
-#define FILE5 "test_ds7.h5"
-#define FILE6 "test_ds8.h5"
-#define FILE7 "test_ds9.h5"
-#define FILE8 "test_ds10.h5"
+#define RANK1 1
+#define RANK 2
+#define DIM_DATA 12
+#define DIM1_SIZE 3
+#define DIM2_SIZE 4
+#define DIM3_SIZE 12
+#define DIM4_SIZE 2
+#define DIM0 0
+#define DIM1 1
+#define DIM2 2
+#define DIM3 3
+
+#define DATASET_NAME "dset_"
+#define DS_1_NAME "ds_1_"
+#define DS_11_NAME "ds_11_"
+#define DS_2_NAME "ds_2_"
+#define DS_21_NAME "ds_21_"
+#define DS_22_NAME "ds_22_"
+#define DS_3_NAME "ds_3_"
+#define DS_31_NAME "ds_31_"
+#define DS_32_NAME "ds_32_"
+#define DS_33_NAME "ds_33_"
+#define DS_4_NAME "ds_4_"
+#define DS_41_NAME "ds_41_"
+#define DS_42_NAME "ds_42_"
+#define DS_43_NAME "ds_43_"
+#define DS_44_NAME "ds_44_"
+
+#define SCALE_1_NAME "scalename_1_"
+#define SCALE_11_NAME "scalename_11_"
+#define SCALE_2_NAME "scalename_2_"
+#define SCALE_21_NAME "scalename_21_"
+#define SCALE_22_NAME "scalename_22_"
+#define SCALE_3_NAME "scalename_3_"
+#define SCALE_31_NAME "scalename_31_"
+#define SCALE_32_NAME "scalename_32_"
+#define SCALE_33_NAME "scalename_33_"
+#define SCALE_4_NAME "scalename_4_"
+
+#define DIM0_LABEL "Latitude"
+#define DIM1_LABEL "Longitude"
+
+#define FOREIGN_FILE1 "test_ds_le.h5"
+#define FOREIGN_FILE2 "test_ds_be.h5"
+#define FILENAME "test_ds"
+#define FILEEXT ".h5"
+
+#define FILE1 "test_ds3.h5"
+#define FILE2 "test_ds4.h5"
+#define FILE3 "test_ds5.h5"
+#define FILE4 "test_ds6.h5"
+#define FILE5 "test_ds7.h5"
+#define FILE6 "test_ds8.h5"
+#define FILE7 "test_ds9.h5"
+#define FILE8 "test_ds10.h5"
#define DIMENSION_LIST "DIMENSION_LIST"
#define REFERENCE_LIST "REFERENCE_LIST"
@@ -144,57 +160,57 @@ static int test_attach_detach(void);
* the main program
*-------------------------------------------------------------------------
*/
-int main(void)
+int
+main(void)
{
- int nerrors=0;
+ int nerrors = 0;
/* create file to be used in following tests */
- if(create_test_file("1") < 0) {
+ if (create_test_file("1") < 0) {
nerrors = 1;
goto error;
}
- nerrors += test_char_attachscales("1") < 0 ? 1 : 0;
- nerrors += test_short_attachscales("1") < 0 ? 1 : 0;
- nerrors += test_int_attachscales("1") < 0 ? 1 : 0;
- nerrors += test_long_attachscales("1") < 0 ? 1 : 0;
- nerrors += test_float_attachscales("1") < 0 ? 1 : 0;
- nerrors += test_char_scalenames("1") < 0 ? 1 : 0;
- nerrors += test_short_scalenames("1") < 0 ? 1 : 0;
- nerrors += test_int_scalenames("1") < 0 ? 1 : 0;
- nerrors += test_long_scalenames("1") < 0 ? 1 : 0;
- nerrors += test_float_scalenames("1") < 0 ? 1 : 0;
- nerrors += test_numberofscales("1") < 0 ? 1 : 0;
- if(create_test_file("2") < 0) {
+ nerrors += test_char_attachscales("1") < 0 ? 1 : 0;
+ nerrors += test_short_attachscales("1") < 0 ? 1 : 0;
+ nerrors += test_int_attachscales("1") < 0 ? 1 : 0;
+ nerrors += test_long_attachscales("1") < 0 ? 1 : 0;
+ nerrors += test_float_attachscales("1") < 0 ? 1 : 0;
+ nerrors += test_char_scalenames("1") < 0 ? 1 : 0;
+ nerrors += test_short_scalenames("1") < 0 ? 1 : 0;
+ nerrors += test_int_scalenames("1") < 0 ? 1 : 0;
+ nerrors += test_long_scalenames("1") < 0 ? 1 : 0;
+ nerrors += test_float_scalenames("1") < 0 ? 1 : 0;
+ nerrors += test_numberofscales("1") < 0 ? 1 : 0;
+ if (create_test_file("2") < 0) {
nerrors = 1;
goto error;
}
- nerrors += test_long_attachscales("2") < 0 ? 1 : 0;
- nerrors += test_duplicatelong_attachscales("2") < 0 ? 1 : 0;
- nerrors += test_samelong_scalenames("2") < 0 ? 1 : 0;
- nerrors += test_foreign_scaleattached(FOREIGN_FILE1) < 0 ? 1 : 0;
- nerrors += test_foreign_scaleattached(FOREIGN_FILE2) < 0 ? 1 : 0;
- nerrors += test_detachscales() < 0 ? 1 : 0;
- nerrors += test_attach_detach() < 0 ? 1 : 0;
-/* the following tests have not been rewritten to match those above */
- nerrors += test_simple() < 0 ?1:0;
- nerrors += test_errors() < 0 ?1:0;
- nerrors += test_errors2() < 0 ?1:0;
- nerrors += test_rank() < 0 ?1:0;
- nerrors += test_iterators() < 0 ?1:0;
- nerrors += test_types() < 0 ?1:0;
- nerrors += test_data() < 0 ?1:0;
-
-
- if(nerrors) goto error;
- printf("All dimension scales tests passed.\n");
+ nerrors += test_long_attachscales("2") < 0 ? 1 : 0;
+ nerrors += test_duplicatelong_attachscales("2") < 0 ? 1 : 0;
+ nerrors += test_samelong_scalenames("2") < 0 ? 1 : 0;
+ nerrors += test_foreign_scaleattached(FOREIGN_FILE1) < 0 ? 1 : 0;
+ nerrors += test_foreign_scaleattached(FOREIGN_FILE2) < 0 ? 1 : 0;
+ nerrors += test_detachscales() < 0 ? 1 : 0;
+ nerrors += test_attach_detach() < 0 ? 1 : 0;
+ /* the following tests have not been rewritten to match those above */
+ nerrors += test_simple() < 0 ? 1 : 0;
+ nerrors += test_errors() < 0 ? 1 : 0;
+ nerrors += test_errors2() < 0 ? 1 : 0;
+ nerrors += test_rank() < 0 ? 1 : 0;
+ nerrors += test_iterators() < 0 ? 1 : 0;
+ nerrors += test_types() < 0 ? 1 : 0;
+ nerrors += test_data() < 0 ? 1 : 0;
+
+ if (nerrors)
+ goto error;
+ HDprintf("All dimension scales tests passed.\n");
return 0;
error:
- printf("***** %d DIMENSION SCALES TEST%s FAILED! *****\n",nerrors, 1 == nerrors ? "" : "S");
+ HDprintf("***** %d DIMENSION SCALES TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S");
return 1;
}
-
/*-------------------------------------------------------------------------
* DS API test
*
@@ -213,7 +229,8 @@ error:
*-------------------------------------------------------------------------
*/
-static hid_t create_test_file(const char *fileext)
+static hid_t
+create_test_file(const char *fileext)
{
char filename[65];
@@ -222,7 +239,8 @@ static hid_t create_test_file(const char *fileext)
return H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
}
-static hid_t open_test_file(const char *fileext)
+static hid_t
+open_test_file(const char *fileext)
{
char filename[65];
@@ -235,254 +253,270 @@ static hid_t open_test_file(const char *fileext)
* create "data" dataset
*-------------------------------------------------------------------------
*/
-herr_t create_char_dataset(hid_t fid, const char *dsidx, int fulldims)
+herr_t
+create_char_dataset(hid_t fid, const char *dsidx, int fulldims)
{
- int rank = 3;
- int rankds = 1;
- hsize_t dims[3] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE};
- char buf[DIM1_SIZE*DIM2_SIZE*DIM3_SIZE];
- hsize_t s1_dim[1] = {DIM1_SIZE};
- hsize_t s2_dim[1] = {DIM2_SIZE};
- hsize_t s3_dim[1] = {DIM3_SIZE};
- char s1_wbuf[DIM1_SIZE] = {1,2,3};
- char s11_wbuf[DIM1_SIZE] = {10,20,30};
- char s2_wbuf[DIM2_SIZE] = {10,20,30,40};
- char s21_wbuf[DIM2_SIZE] = {1,2,3,4};
- char s22_wbuf[DIM2_SIZE] = {5,10,50,100};
- char s3_wbuf[DIM3_SIZE] = {10,10,10,20,20,20,30,30,30,40,40,40};
- char s31_wbuf[DIM3_SIZE] = {1,1,1,2,2,2,3,3,3,4,4,4};
- char s32_wbuf[DIM3_SIZE] = {5,5,5,10,10,10,50,50,50,100,100,100};
- char s33_wbuf[DIM3_SIZE] = {6,6,6,12,12,12,53,53,53,120,120,120};
+ int rank = 3;
+ int rankds = 1;
+ hsize_t dims[3] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE};
+ char buf[DIM1_SIZE * DIM2_SIZE * DIM3_SIZE];
+ hsize_t s1_dim[1] = {DIM1_SIZE};
+ hsize_t s2_dim[1] = {DIM2_SIZE};
+ hsize_t s3_dim[1] = {DIM3_SIZE};
+ char s1_wbuf[DIM1_SIZE] = {1, 2, 3};
+ char s11_wbuf[DIM1_SIZE] = {10, 20, 30};
+ char s2_wbuf[DIM2_SIZE] = {10, 20, 30, 40};
+ char s21_wbuf[DIM2_SIZE] = {1, 2, 3, 4};
+ char s22_wbuf[DIM2_SIZE] = {5, 10, 50, 100};
+ char s3_wbuf[DIM3_SIZE] = {10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40};
+ char s31_wbuf[DIM3_SIZE] = {1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4};
+ char s32_wbuf[DIM3_SIZE] = {5, 5, 5, 10, 10, 10, 50, 50, 50, 100, 100, 100};
+ char s33_wbuf[DIM3_SIZE] = {6, 6, 6, 12, 12, 12, 53, 53, 53, 120, 120, 120};
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx);
/* make a dataset */
- if(H5LTmake_dataset_char(fid, name, rank, dims, buf) >= 0) {
- if(fulldims==0) {
+ if (H5LTmake_dataset_char(fid, name, rank, dims, buf) >= 0) {
+ if (fulldims == 0) {
/* make a DS dataset for the first dimension */
- if(create_DS1_char_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
- return FAIL;
+ if (create_DS1_char_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the second dimension */
- if(create_DS2_char_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS2_char_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the third dimension */
- if(create_DS3_char_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS3_char_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0)
+ return FAIL;
}
else {
- if(create_DS1_char_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
- return FAIL;
+ if (create_DS1_char_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
+ return FAIL;
- if(create_DS2_char_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
- return FAIL;
+ if (create_DS2_char_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
+ return FAIL;
- if(create_DS3_char_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) < 0)
- return FAIL;
+ if (create_DS3_char_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) <
+ 0)
+ return FAIL;
}
- }
- else
- return FAIL;
+ }
+ else
+ return FAIL;
return SUCCEED;
}
-herr_t create_short_dataset(hid_t fid, const char *dsidx, int fulldims)
+herr_t
+create_short_dataset(hid_t fid, const char *dsidx, int fulldims)
{
- int rank = 3;
- int rankds = 1;
- hsize_t dims[3] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE};
- short buf[DIM1_SIZE*DIM2_SIZE*DIM3_SIZE];
- hsize_t s1_dim[1] = {DIM1_SIZE};
- hsize_t s2_dim[1] = {DIM2_SIZE};
- hsize_t s3_dim[1] = {DIM3_SIZE};
- short s1_wbuf[DIM1_SIZE] = {10,20,30};
- short s11_wbuf[DIM1_SIZE] = {10,100,300};
- short s2_wbuf[DIM2_SIZE] = {100,200,300,400};
- short s21_wbuf[DIM2_SIZE] = {10,20,30,40};
- short s22_wbuf[DIM2_SIZE] = {5,10,50,300};
- short s3_wbuf[DIM3_SIZE] = {10,10,10,20,20,20,30,30,30,40,40,40};
- short s31_wbuf[DIM3_SIZE] = {1,1,1,2,2,2,3,3,3,4,4,4};
- short s32_wbuf[DIM3_SIZE] = {5,5,5,10,10,10,50,50,50,100,100,100};
- short s33_wbuf[DIM3_SIZE] = {6,6,6,12,12,12,53,53,53,140,140,140};
+ int rank = 3;
+ int rankds = 1;
+ hsize_t dims[3] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE};
+ short buf[DIM1_SIZE * DIM2_SIZE * DIM3_SIZE];
+ hsize_t s1_dim[1] = {DIM1_SIZE};
+ hsize_t s2_dim[1] = {DIM2_SIZE};
+ hsize_t s3_dim[1] = {DIM3_SIZE};
+ short s1_wbuf[DIM1_SIZE] = {10, 20, 30};
+ short s11_wbuf[DIM1_SIZE] = {10, 100, 300};
+ short s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400};
+ short s21_wbuf[DIM2_SIZE] = {10, 20, 30, 40};
+ short s22_wbuf[DIM2_SIZE] = {5, 10, 50, 300};
+ short s3_wbuf[DIM3_SIZE] = {10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40};
+ short s31_wbuf[DIM3_SIZE] = {1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4};
+ short s32_wbuf[DIM3_SIZE] = {5, 5, 5, 10, 10, 10, 50, 50, 50, 100, 100, 100};
+ short s33_wbuf[DIM3_SIZE] = {6, 6, 6, 12, 12, 12, 53, 53, 53, 140, 140, 140};
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx);
/* make a dataset */
- if(H5LTmake_dataset_short(fid, name, rank, dims, buf) >= 0) {
- if(fulldims==0) {
+ if (H5LTmake_dataset_short(fid, name, rank, dims, buf) >= 0) {
+ if (fulldims == 0) {
/* make a DS dataset for the first dimension */
- if(create_DS1_short_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
- return FAIL;
+ if (create_DS1_short_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the second dimension */
- if(create_DS2_short_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS2_short_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the third dimension */
- if(create_DS3_short_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS3_short_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0)
+ return FAIL;
}
else {
- if(create_DS1_short_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
- return FAIL;
+ if (create_DS1_short_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
+ return FAIL;
- if(create_DS2_short_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
- return FAIL;
+ if (create_DS2_short_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
+ return FAIL;
- if(create_DS3_short_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) < 0)
- return FAIL;
+ if (create_DS3_short_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) <
+ 0)
+ return FAIL;
}
- }
- else
- return FAIL;
+ }
+ else
+ return FAIL;
return SUCCEED;
}
-herr_t create_int_dataset(hid_t fid, const char *dsidx, int fulldims)
+herr_t
+create_int_dataset(hid_t fid, const char *dsidx, int fulldims)
{
- int rank = RANK;
- int rankds = 1;
- hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE};
- int buf[DIM1_SIZE*DIM2_SIZE];
- hsize_t s1_dim[1] = {DIM1_SIZE};
- hsize_t s2_dim[1] = {DIM2_SIZE};
- int s1_wbuf[DIM1_SIZE] = {10,20,30};
- int s11_wbuf[DIM1_SIZE] = {10,100,300};
- int s2_wbuf[DIM2_SIZE] = {100,200,300,400};
- int s21_wbuf[DIM2_SIZE] = {10,20,30,40};
- int s22_wbuf[DIM2_SIZE] = {5,10,50,300};
+ int rank = RANK;
+ int rankds = 1;
+ hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE};
+ int buf[DIM1_SIZE * DIM2_SIZE];
+ hsize_t s1_dim[1] = {DIM1_SIZE};
+ hsize_t s2_dim[1] = {DIM2_SIZE};
+ int s1_wbuf[DIM1_SIZE] = {10, 20, 30};
+ int s11_wbuf[DIM1_SIZE] = {10, 100, 300};
+ int s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400};
+ int s21_wbuf[DIM2_SIZE] = {10, 20, 30, 40};
+ int s22_wbuf[DIM2_SIZE] = {5, 10, 50, 300};
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx);
/* make a dataset */
- if(H5LTmake_dataset_int(fid, name, rank, dims, buf) >= 0) {
- if(fulldims==0) {
+ if (H5LTmake_dataset_int(fid, name, rank, dims, buf) >= 0) {
+ if (fulldims == 0) {
/* make a DS dataset for the first dimension */
- if(create_DS1_int_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
- return FAIL;
+ if (create_DS1_int_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the second dimension */
- if(create_DS2_int_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS2_int_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
+ return FAIL;
}
else {
- if(create_DS1_int_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
- return FAIL;
+ if (create_DS1_int_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
+ return FAIL;
- if(create_DS2_int_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
- return FAIL;
+ if (create_DS2_int_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
+ return FAIL;
}
- }
- else
- return FAIL;
+ }
+ else
+ return FAIL;
return SUCCEED;
}
-herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldims)
+herr_t
+create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldims)
{
- int rank = 4;
- int rankds = 1;
- hsize_t dims[4] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE,DIM4_SIZE};
- long buf[DIM1_SIZE*DIM2_SIZE*DIM3_SIZE*DIM4_SIZE];
- hsize_t s1_dim[1] = {DIM1_SIZE};
- hsize_t s2_dim[1] = {DIM2_SIZE};
- hsize_t s3_dim[1] = {DIM3_SIZE};
- hsize_t s4_dim[1] = {DIM4_SIZE};
- long s1_wbuf[DIM1_SIZE] = {10,20,30};
- long s11_wbuf[DIM1_SIZE] = {10,100,300};
- long s2_wbuf[DIM2_SIZE] = {100,200,300,400};
- long s21_wbuf[DIM2_SIZE] = {10,20,30,40};
- long s22_wbuf[DIM2_SIZE] = {5,10,50,300};
- long s3_wbuf[DIM3_SIZE] = {10,10,10,20,20,20,30,30,30,40,40,40};
- long s31_wbuf[DIM3_SIZE] = {1,1,1,2,2,2,3,3,3,4,4,4};
- long s32_wbuf[DIM3_SIZE] = {5,5,5,10,10,10,50,50,50,100,100,100};
- long s33_wbuf[DIM3_SIZE] = {6,6,6,12,12,12,53,53,53,140,140,140};
- long s4_wbuf[DIM4_SIZE] = {18,18};
- long s41_wbuf[DIM4_SIZE] = {8,8};
- long s42_wbuf[DIM4_SIZE] = {80,80};
- long s43_wbuf[DIM4_SIZE] = {180,180};
- long s44_wbuf[DIM4_SIZE] = {280,280};
+ int rank = 4;
+ int rankds = 1;
+ hsize_t dims[4] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE, DIM4_SIZE};
+ long * buf;
+ hsize_t s1_dim[1] = {DIM1_SIZE};
+ hsize_t s2_dim[1] = {DIM2_SIZE};
+ hsize_t s3_dim[1] = {DIM3_SIZE};
+ hsize_t s4_dim[1] = {DIM4_SIZE};
+ long s1_wbuf[DIM1_SIZE] = {10, 20, 30};
+ long s11_wbuf[DIM1_SIZE] = {10, 100, 300};
+ long s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400};
+ long s21_wbuf[DIM2_SIZE] = {10, 20, 30, 40};
+ long s22_wbuf[DIM2_SIZE] = {5, 10, 50, 300};
+ long s3_wbuf[DIM3_SIZE] = {10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40};
+ long s31_wbuf[DIM3_SIZE] = {1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4};
+ long s32_wbuf[DIM3_SIZE] = {5, 5, 5, 10, 10, 10, 50, 50, 50, 100, 100, 100};
+ long s33_wbuf[DIM3_SIZE] = {6, 6, 6, 12, 12, 12, 53, 53, 53, 140, 140, 140};
+ long s4_wbuf[DIM4_SIZE] = {18, 18};
+ long s41_wbuf[DIM4_SIZE] = {8, 8};
+ long s42_wbuf[DIM4_SIZE] = {80, 80};
+ long s43_wbuf[DIM4_SIZE] = {180, 180};
+ long s44_wbuf[DIM4_SIZE] = {280, 280};
+
+ /* Allocate buffer */
+ if (NULL == (buf = (long *)HDmalloc(sizeof(long) * DIM1_SIZE * DIM2_SIZE * DIM3_SIZE * DIM4_SIZE)))
+ return FAIL;
/* make a dataset */
- if(H5LTmake_dataset_long(fid, dsname, rank, dims, buf) >= 0) {
- if(fulldims==0) {
+ if (H5LTmake_dataset_long(fid, dsname, rank, dims, buf) >= 0) {
+ if (fulldims == 0) {
/* make a DS dataset for the first dimension */
- if(create_DS1_long_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
- return FAIL;
+ if (create_DS1_long_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the second dimension */
- if(create_DS2_long_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS2_long_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the third dimension */
- if(create_DS3_long_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS3_long_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the fourth dimension */
- if(create_DS4_long_datasets(fid, dsidx, rankds, s4_dim, s4_wbuf, NULL, NULL, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS4_long_datasets(fid, dsidx, rankds, s4_dim, s4_wbuf, NULL, NULL, NULL, NULL) < 0)
+ return FAIL;
}
else {
- if(create_DS1_long_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
- return FAIL;
+ if (create_DS1_long_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
+ return FAIL;
- if(create_DS2_long_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
- return FAIL;
+ if (create_DS2_long_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
+ return FAIL;
- if(create_DS3_long_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) < 0)
- return FAIL;
+ if (create_DS3_long_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) <
+ 0)
+ return FAIL;
- if(create_DS4_long_datasets(fid, dsidx, rankds, s4_dim, s4_wbuf, s41_wbuf, s42_wbuf, s43_wbuf, s44_wbuf) < 0)
- return FAIL;
+ if (create_DS4_long_datasets(fid, dsidx, rankds, s4_dim, s4_wbuf, s41_wbuf, s42_wbuf, s43_wbuf,
+ s44_wbuf) < 0)
+ return FAIL;
}
- }
- else
- return FAIL;
+ }
+ else
+ return FAIL;
+
+ HDfree(buf);
+
return SUCCEED;
}
-herr_t create_float_dataset(hid_t fid, const char *dsidx, int fulldims)
+herr_t
+create_float_dataset(hid_t fid, const char *dsidx, int fulldims)
{
- int rank = RANK;
- int rankds = 1;
- hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE};
- float buf[DIM1_SIZE*DIM2_SIZE];
- hsize_t s1_dim[1] = {DIM1_SIZE};
- hsize_t s2_dim[1] = {DIM2_SIZE};
- float s1_wbuf[DIM1_SIZE] = {10,20,30};
- float s11_wbuf[DIM1_SIZE] = {10,100,300};
- float s2_wbuf[DIM2_SIZE] = {100,200,300,400};
- float s21_wbuf[DIM2_SIZE] = {10,20,30,40};
- float s22_wbuf[DIM2_SIZE] = {5,10,50,300};
+ int rank = RANK;
+ int rankds = 1;
+ hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE};
+ float buf[DIM1_SIZE * DIM2_SIZE];
+ hsize_t s1_dim[1] = {DIM1_SIZE};
+ hsize_t s2_dim[1] = {DIM2_SIZE};
+ float s1_wbuf[DIM1_SIZE] = {10, 20, 30};
+ float s11_wbuf[DIM1_SIZE] = {10, 100, 300};
+ float s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400};
+ float s21_wbuf[DIM2_SIZE] = {10, 20, 30, 40};
+ float s22_wbuf[DIM2_SIZE] = {5, 10, 50, 300};
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx);
/* make a dataset */
- if(H5LTmake_dataset_float(fid, name, rank, dims, buf) >= 0) {
- if(fulldims==0) {
+ if (H5LTmake_dataset_float(fid, name, rank, dims, buf) >= 0) {
+ if (fulldims == 0) {
/* make a DS dataset for the first dimension */
- if(create_DS1_float_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
- return FAIL;
+ if (create_DS1_float_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the second dimension */
- if(create_DS2_float_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS2_float_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
+ return FAIL;
}
else {
- if(create_DS1_float_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
- return FAIL;
+ if (create_DS1_float_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
+ return FAIL;
- if(create_DS2_float_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
- return FAIL;
+ if (create_DS2_float_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
+ return FAIL;
}
- }
- else
- return FAIL;
+ }
+ else
+ return FAIL;
return SUCCEED;
}
@@ -490,21 +524,23 @@ herr_t create_float_dataset(hid_t fid, const char *dsidx, int fulldims)
* create 2 dimension scales datasets for first dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS1_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf)
+herr_t
+create_DS1_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf,
+ char *s1_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_11_NAME, dsidx);
/* make a DS dataset with an alternate scale for the first dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
@@ -515,29 +551,31 @@ herr_t create_DS1_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_
* create 3 dimension scales datasets for second dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS2_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf, char *s2_wbuf)
+herr_t
+create_DS2_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf,
+ char *s1_wbuf, char *s2_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, dsidx);
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_21_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_22_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
@@ -548,37 +586,39 @@ herr_t create_DS2_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_
* create 1 dimension scales datasets for third dimension of dataset
*-------------------------------------------------------------------------
*/
-herr_t create_DS3_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf, char *s2_wbuf, char *s3_wbuf)
+herr_t
+create_DS3_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf,
+ char *s1_wbuf, char *s2_wbuf, char *s3_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_31_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_32_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
- if(s3_wbuf != NULL) {
+ if (s3_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_33_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s3_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s3_wbuf) < 0)
return FAIL;
}
@@ -589,21 +629,23 @@ herr_t create_DS3_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_
* create 2 dimension scales datasets for first dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS1_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf)
+herr_t
+create_DS1_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf,
+ short *s1_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_11_NAME, dsidx);
/* make a DS dataset with an alternate scale for the first dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
@@ -614,29 +656,31 @@ herr_t create_DS1_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize
* create 3 dimension scales datasets for second dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS2_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf, short *s2_wbuf)
+herr_t
+create_DS2_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf,
+ short *s1_wbuf, short *s2_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, dsidx);
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_21_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_22_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
@@ -647,37 +691,39 @@ herr_t create_DS2_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize
* create 1 dimension scales datasets for third dimension of dataset
*-------------------------------------------------------------------------
*/
-herr_t create_DS3_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf, short *s2_wbuf, short *s3_wbuf)
+herr_t
+create_DS3_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf,
+ short *s1_wbuf, short *s2_wbuf, short *s3_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_31_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_32_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
- if(s3_wbuf != NULL) {
+ if (s3_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_33_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s3_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s3_wbuf) < 0)
return FAIL;
}
@@ -688,21 +734,22 @@ herr_t create_DS3_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize
* create 2 dimension scales datasets for first dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS1_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf)
+herr_t
+create_DS1_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_11_NAME, dsidx);
/* make a DS dataset with an alternate scale for the first dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
@@ -713,29 +760,31 @@ herr_t create_DS1_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t
* create 3 dimension scales datasets for second dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS2_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf, int *s2_wbuf)
+herr_t
+create_DS2_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf,
+ int *s2_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, dsidx);
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_21_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_22_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
@@ -746,37 +795,39 @@ herr_t create_DS2_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t
* create 1 dimension scales datasets for third dimension of dataset
*-------------------------------------------------------------------------
*/
-herr_t create_DS3_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf, int *s2_wbuf, int *s3_wbuf)
+herr_t
+create_DS3_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf,
+ int *s2_wbuf, int *s3_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_31_NAME, dsidx);
/* make a DS dataset with an alternate scale for the first dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_32_NAME, dsidx);
/* make a DS dataset with an alternate scale for the first dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
- if(s3_wbuf != NULL) {
+ if (s3_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_33_NAME, dsidx);
/* make a DS dataset with an alternate scale for the first dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s3_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s3_wbuf) < 0)
return FAIL;
}
@@ -787,21 +838,23 @@ herr_t create_DS3_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t
* create 2 dimension scales datasets for first dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS1_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf)
+herr_t
+create_DS1_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf,
+ long *s1_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_11_NAME, dsidx);
/* make a DS dataset with an alternate scale for the first dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
@@ -812,29 +865,31 @@ herr_t create_DS1_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_
* create 3 dimension scales datasets for second dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS2_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf)
+herr_t
+create_DS2_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf,
+ long *s1_wbuf, long *s2_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, dsidx);
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_21_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_22_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
@@ -845,37 +900,39 @@ herr_t create_DS2_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_
* create 3 dimension scales datasets for third dimension of dataset
*-------------------------------------------------------------------------
*/
-herr_t create_DS3_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf, long *s3_wbuf)
+herr_t
+create_DS3_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf,
+ long *s1_wbuf, long *s2_wbuf, long *s3_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_31_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_32_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
- if(s3_wbuf != NULL) {
+ if (s3_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_33_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s3_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s3_wbuf) < 0)
return FAIL;
}
@@ -886,45 +943,47 @@ herr_t create_DS3_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_
* create 4 dimension scales datasets for third dimension of dataset
*-------------------------------------------------------------------------
*/
-herr_t create_DS4_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf, long *s3_wbuf, long *s4_wbuf)
+herr_t
+create_DS4_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf,
+ long *s1_wbuf, long *s2_wbuf, long *s3_wbuf, long *s4_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_4_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_41_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_42_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
- if(s3_wbuf != NULL) {
+ if (s3_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_43_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s3_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s3_wbuf) < 0)
return FAIL;
}
- if(s4_wbuf != NULL) {
+ if (s4_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_44_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s4_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s4_wbuf) < 0)
return FAIL;
}
@@ -935,21 +994,23 @@ herr_t create_DS4_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_
* create 2 dimension scales datasets for first dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS1_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf)
+herr_t
+create_DS1_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf,
+ float *s1_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_11_NAME, dsidx);
/* make a DS dataset with an alternate scale for the first dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
@@ -960,29 +1021,31 @@ herr_t create_DS1_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize
* create 3 dimension scales datasets for second dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS2_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf, float *s2_wbuf)
+herr_t
+create_DS2_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf,
+ float *s1_wbuf, float *s2_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, dsidx);
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_21_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_22_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
@@ -993,145 +1056,152 @@ herr_t create_DS2_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize
* create 3 dimension scales datasets for third dimension of dataset
*-------------------------------------------------------------------------
*/
-herr_t create_DS3_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf, float *s2_wbuf, float *s3_wbuf)
+herr_t
+create_DS3_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf,
+ float *s1_wbuf, float *s2_wbuf, float *s3_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_31_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_32_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
- if(s3_wbuf != NULL) {
+ if (s3_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_33_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s3_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s3_wbuf) < 0)
return FAIL;
}
return SUCCEED;
}
-herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
+herr_t
+test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
{
- herr_t ret_value = FAIL;
- hid_t dsid = -1;
+ herr_t ret_value = FAIL;
+ hid_t dsid = -1;
- if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 0) {
- if(H5DSattach_scale(did, dsid, idx) >= 0) {
- if(H5DSis_attached(did, dsid, idx) > 0) {
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 0) {
+ if (H5DSattach_scale(did, dsid, idx) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) > 0) {
ret_value = SUCCEED;
}
- else if(H5DSis_attached(did, dsid, idx) == 0) {
- printf(" scale not attached ");
+ else if (H5DSis_attached(did, dsid, idx) == 0) {
+ HDprintf(" scale not attached ");
}
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
ret_value = FAIL;
}
return ret_value;
}
-herr_t test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
+herr_t
+test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
{
- herr_t ret_value = FAIL;
- hid_t dsid = -1;
+ herr_t ret_value = FAIL;
+ hid_t dsid = -1;
- if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 1) {
- if(H5DSdetach_scale(did, dsid, idx) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 0) {
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 1) {
+ if (H5DSdetach_scale(did, dsid, idx) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 0) {
ret_value = SUCCEED;
}
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
ret_value = FAIL;
}
return ret_value;
}
-herr_t test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
+herr_t
+test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
{
- herr_t ret_value = FAIL;
- hid_t dsid = -1;
+ herr_t ret_value = FAIL;
+ hid_t dsid = -1;
- if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 1) {
- if(H5DSset_scale(dsid, scalename) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 1) {
- ret_value = SUCCEED;
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 1) {
+ if (H5DSset_scale(dsid, scalename) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 1) {
+ ret_value = SUCCEED;
}
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
ret_value = FAIL;
}
return ret_value;
}
-herr_t test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
+herr_t
+test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
{
herr_t ret_value = FAIL;
- hid_t dsid = -1;
+ hid_t dsid = -1;
ssize_t name_len;
- char *name_out=NULL;
-
- if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 1) {
- if((name_len=H5DSget_scale_name(dsid,NULL,(size_t)0)) > 0) {
- name_out = (char*)HDmalloc((name_len+1) * sizeof (char));
- if(name_out != NULL) {
- if(H5DSget_scale_name(dsid, name_out, (size_t)name_len+1) >= 0) {
- if(HDstrcmp(scalename,name_out)==0) {
+ char * name_out = NULL;
+
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 1) {
+ if ((name_len = H5DSget_scale_name(dsid, NULL, (size_t)0)) > 0) {
+ name_out = (char *)HDmalloc(((size_t)name_len + 1) * sizeof(char));
+ if (name_out != NULL) {
+ if (H5DSget_scale_name(dsid, name_out, (size_t)name_len + 1) >= 0) {
+ if (HDstrncmp(scalename, name_out, (size_t)name_len) == 0) {
ret_value = SUCCEED;
}
HDfree(name_out);
- name_out=NULL;
+ name_out = NULL;
}
}
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
ret_value = FAIL;
}
return ret_value;
}
-static int test_detachscales(void)
+static int
+test_detachscales(void)
{
- hid_t fid = -1;
- hid_t did = -1;
- hid_t dsid = -1;
- int rank1 = 1;
- int rank3 = 3;
- hsize_t dims[] = {1,2,3}; /*some bogus numbers, not important for the test*/
- int *buf = NULL;
- char dname[10];
+ hid_t fid = -1;
+ hid_t did = -1;
+ hid_t dsid = -1;
+ int rank1 = 1;
+ int rank3 = 3;
+ hsize_t dims[] = {1, 2, 3}; /*some bogus numbers, not important for the test*/
+ int * buf = NULL;
+ char dname[16];
int i;
/* This tests creates two three dimensional datasets; then it creates
@@ -1139,54 +1209,54 @@ static int test_detachscales(void)
and detach them to check that at the end there is no attributes
REFERENCE_LIST on a dimension scale and DIMENSION_LIST on a dataset */
- TESTING2("test_detachscales");
+ HL_TESTING2("test_detachscales");
- if((fid = H5Fcreate("test_detach.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate("test_detach.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* make datasets; they are three dimensional*/
- for (i=0; i < 2; i++) {
- sprintf(dname,"D%d", i);
- if(H5LTmake_dataset_int(fid, dname, rank3, dims, buf) < 0)
+ for (i = 0; i < 2; i++) {
+ HDsprintf(dname, "D%d", i);
+ if (H5LTmake_dataset_int(fid, dname, rank3, dims, buf) < 0)
goto out;
- }
+ }
/* create datasets and make them dim. scales */
- for (i=0; i < 4; i++) {
- sprintf(dname, "DS%d", i);
- if(H5LTmake_dataset_int(fid, dname, rank1, dims, buf) < 0)
+ for (i = 0; i < 4; i++) {
+ HDsprintf(dname, "DS%d", i);
+ if (H5LTmake_dataset_int(fid, dname, rank1, dims, buf) < 0)
goto out;
}
- /* attach scales to the first dataset; first dimension will have
+ /* attach scales to the first dataset; first dimension will have
two scales attached */
- if((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) >= 0) {
- for (i=0; i<4; i++) {
- sprintf(dname, "DS%d", i);
- if((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
- goto out;
- if(H5DSattach_scale(did, dsid, (unsigned int) i%3) < 0)
- goto out;
- if(H5Dclose(dsid) < 0)
- goto out;
+ if ((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) >= 0) {
+ for (i = 0; i < 4; i++) {
+ HDsprintf(dname, "DS%d", i);
+ if ((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
+ goto out;
+ if (H5DSattach_scale(did, dsid, (unsigned int)i % 3) < 0)
+ goto out;
+ if (H5Dclose(dsid) < 0)
+ goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
goto out;
- /* attach scales to the second dataset */
- if((did = H5Dopen2(fid, "D1", H5P_DEFAULT)) >= 0) {
- for (i=0; i<3; i++) {
- sprintf(dname, "DS%d", i);
- if((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
- goto out;
- if(H5DSattach_scale(did, dsid, (unsigned int) i) < 0)
- goto out;
- if(H5Dclose(dsid) < 0)
- goto out;
+ /* attach scales to the second dataset */
+ if ((did = H5Dopen2(fid, "D1", H5P_DEFAULT)) >= 0) {
+ for (i = 0; i < 3; i++) {
+ HDsprintf(dname, "DS%d", i);
+ if ((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
+ goto out;
+ if (H5DSattach_scale(did, dsid, (unsigned int)i) < 0)
+ goto out;
+ if (H5Dclose(dsid) < 0)
+ goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1195,107 +1265,109 @@ static int test_detachscales(void)
/* detach DS0 from first dimension of D0 and D1; then check
that DS0 doesn't have attribute REFERENCE _LIST */
- if((dsid = H5Dopen2(fid, "DS0", H5P_DEFAULT)) < 0)
- goto out;
+ if ((dsid = H5Dopen2(fid, "DS0", H5P_DEFAULT)) < 0)
+ goto out;
- for (i=0; i<2; i++) {
- sprintf(dname, "D%d", i);
- if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
+ for (i = 0; i < 2; i++) {
+ HDsprintf(dname, "D%d", i);
+ if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
goto out;
- if(H5DSdetach_scale(did, dsid, (unsigned int)0) < 0)
+ if (H5DSdetach_scale(did, dsid, (unsigned int)0) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- }
+ }
/* Check that attribute "REFERENCE_LIST" doesn't exist anymore */
- if(H5Aexists(dsid, REFERENCE_LIST)!= 0)
+ if (H5Aexists(dsid, REFERENCE_LIST) != 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- /* Check that DS3 is the only dim. scale attached to the first
+ /* Check that DS3 is the only dim. scale attached to the first
dimension of D0 */
- if((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) < 0)
goto out;
- if((dsid = H5Dopen2(fid, "DS3", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "DS3", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSis_attached(did, dsid, (unsigned int) 0) <= 0)
+ if (H5DSis_attached(did, dsid, (unsigned int)0) <= 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- /* Detach the rest of the scales DS3, DS1, DS2 from D0 and make
+ /* Detach the rest of the scales DS3, DS1, DS2 from D0 and make
sure that attribute "DIMENSION_LIST" doesn't exist anymore */
- if((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) >= 0) {
- for (i=1; i<4; i++) {
- sprintf(dname, "DS%d", i);
- if((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
- goto out;
- if(H5DSdetach_scale(did, dsid, (unsigned int) i%3) < 0)
- goto out;
- if(H5Dclose(dsid) < 0)
- goto out;
+ if ((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) >= 0) {
+ for (i = 1; i < 4; i++) {
+ HDsprintf(dname, "DS%d", i);
+ if ((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
+ goto out;
+ if (H5DSdetach_scale(did, dsid, (unsigned int)i % 3) < 0)
+ goto out;
+ if (H5Dclose(dsid) < 0)
+ goto out;
}
/* Check that attribute "DIMENSION_LIST" doesn't exist anymore */
- if(H5Aexists(did, DIMENSION_LIST)!= 0)
+ if (H5Aexists(did, DIMENSION_LIST) != 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
goto out;
-
PASSED();
H5Fclose(fid);
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Dclose(dsid);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_char_attachscales(const char *fileext)
+static int
+test_char_attachscales(const char *fileext)
{
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "ac");
- TESTING2("test_char_attachscales");
+ HL_TESTING2("test_char_attachscales");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
/* make a dataset */
- if(create_char_dataset(fid, "ac", 0) < 0)
+ if (create_char_dataset(fid, "ac", 0) < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "ac");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "ac");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "ac");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1307,72 +1379,75 @@ static int test_char_attachscales(const char *fileext)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_short_attachscales(const char *fileext)
+static int
+test_short_attachscales(const char *fileext)
{
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "as");
- TESTING2("test_short_attachscales");
+ HL_TESTING2("test_short_attachscales");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
/* make a dataset */
- if(create_short_dataset(fid, "as", 1) < 0)
+ if (create_short_dataset(fid, "as", 1) < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_31_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_32_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_33_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1384,56 +1459,59 @@ static int test_short_attachscales(const char *fileext)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_int_attachscales(const char *fileext)
+static int
+test_int_attachscales(const char *fileext)
{
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "a");
- TESTING2("test_int_attachscales");
+ HL_TESTING2("test_int_attachscales");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
/* make a dataset */
- if(create_int_dataset(fid, "a", 1) < 0)
+ if (create_int_dataset(fid, "a", 1) < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "a");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "a");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "a");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "a");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "a");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1445,52 +1523,55 @@ static int test_int_attachscales(const char *fileext)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_long_attachscales(const char *fileext)
+static int
+test_long_attachscales(const char *fileext)
{
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "al");
- TESTING2("test_long_attachscales");
+ HL_TESTING2("test_long_attachscales");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
/* make a dataset */
- if(create_long_dataset(fid, dsname, "al", 0) < 0)
+ if (create_long_dataset(fid, dsname, "al", 0) < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "al");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "al");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "al");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_4_NAME, "al");
- if(test_attach_scale(fid, did, scalename, DIM3) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM3) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1502,52 +1583,55 @@ static int test_long_attachscales(const char *fileext)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_duplicatelong_attachscales(const char *fileext)
+static int
+test_duplicatelong_attachscales(const char *fileext)
{
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "al2");
- TESTING2("test_duplicatelong_attachscales");
+ HL_TESTING2("test_duplicatelong_attachscales");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
/* make a dataset 2 */
- if(create_long_dataset(fid, dsname, "al2", 0) < 0)
+ if (create_long_dataset(fid, dsname, "al2", 0) < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "al");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "al");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "al");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_4_NAME, "al");
- if(test_attach_scale(fid, did, scalename, DIM3) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM3) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1559,56 +1643,59 @@ static int test_duplicatelong_attachscales(const char *fileext)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_float_attachscales(const char *fileext)
+static int
+test_float_attachscales(const char *fileext)
{
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "af");
- TESTING2("test_float_attachscales");
+ HL_TESTING2("test_float_attachscales");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
/* make a dataset */
- if(create_float_dataset(fid, "af", 1) < 0)
+ if (create_float_dataset(fid, "af", 1) < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "af");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "af");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "af");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "af");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "af");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1620,45 +1707,48 @@ static int test_float_attachscales(const char *fileext)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_numberofscales(const char *fileext)
+static int
+test_numberofscales(const char *fileext)
{
- hid_t fid = -1;
- hid_t did = -1;
- int nscales; /* number of scales in DIM */
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ int nscales; /* number of scales in DIM */
+ char dsname[32];
+ char scalename[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "a");
- TESTING2("test_numberofscales");
+ HL_TESTING2("test_numberofscales");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
- if((nscales = H5DSget_num_scales(did, 0)) < 0)
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((nscales = H5DSget_num_scales(did, 0)) < 0)
goto out;
- if(nscales != 2)
+ if (nscales != 2)
goto out;
- if((nscales = H5DSget_num_scales(did, 1)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 1)) < 0)
goto out;
- if(nscales != 3)
+ if (nscales != 3)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1667,28 +1757,28 @@ static int test_numberofscales(const char *fileext)
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "b");
/* make a dataset */
- if(create_int_dataset(fid, "b", 1) < 0)
+ if (create_int_dataset(fid, "b", 1) < 0)
goto out;
/* make a DS dataset for the first dimension */
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "b");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
- if((nscales = H5DSget_num_scales(did, 0)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 0)) < 0)
goto out;
- if(nscales != 1)
+ if (nscales != 1)
goto out;
- if((nscales = H5DSget_num_scales(did, 1)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 1)) < 0)
goto out;
- if(nscales != 0)
+ if (nscales != 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1700,55 +1790,59 @@ static int test_numberofscales(const char *fileext)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_char_scalenames(const char *fileext) {
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
- char name[32];
+static int
+test_char_scalenames(const char *fileext)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "ac");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
- TESTING2("set char scale/cmp scale name");
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ HL_TESTING2("set char scale/cmp scale name");
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "ac");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "ac");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "ac");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_2_NAME, "ac");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "ac");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_3_NAME, "ac");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1760,103 +1854,107 @@ static int test_char_scalenames(const char *fileext) {
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_short_scalenames(const char *fileext) {
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
- char name[32];
+static int
+test_short_scalenames(const char *fileext)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "as");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
- TESTING2("set short scale/cmp scale name");
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ HL_TESTING2("set short scale/cmp scale name");
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_11_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_2_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_21_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_22_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_3_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_31_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_31_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_32_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_32_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_33_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_33_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1868,71 +1966,75 @@ static int test_short_scalenames(const char *fileext) {
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_int_scalenames(const char *fileext) {
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
- char name[32];
+static int
+test_int_scalenames(const char *fileext)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "a");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
- TESTING2("set int scale/cmp scale name");
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ HL_TESTING2("set int scale/cmp scale name");
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "a");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "a");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "a");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_11_NAME, "a");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "a");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_2_NAME, "a");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "a");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_21_NAME, "a");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "a");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_22_NAME, "a");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1944,63 +2046,67 @@ static int test_int_scalenames(const char *fileext) {
return 0;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_long_scalenames(const char *fileext) {
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
- char name[32];
+static int
+test_long_scalenames(const char *fileext)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "al");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
- TESTING2("set long scale/cmp scale name");
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ HL_TESTING2("set long scale/cmp scale name");
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "al");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "al");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_2_NAME, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "al");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_3_NAME, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_4_NAME, "al");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_4_NAME, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM3) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM3) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -2012,63 +2118,67 @@ static int test_long_scalenames(const char *fileext) {
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_samelong_scalenames(const char *fileext) {
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
- char name[32];
+static int
+test_samelong_scalenames(const char *fileext)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "al2");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
- TESTING2("set same long scale/cmp scale name");
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ HL_TESTING2("set same long scale/cmp scale name");
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "al");
HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "al");
HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "al");
HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_4_NAME, "al");
HDsnprintf(name, sizeof(name), "%s%s", DS_4_NAME, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM3) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM3) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -2080,71 +2190,75 @@ static int test_samelong_scalenames(const char *fileext) {
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_float_scalenames(const char *fileext) {
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
- char name[32];
+static int
+test_float_scalenames(const char *fileext)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "af");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
- TESTING2("set float scale/cmp scale name");
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ HL_TESTING2("set float scale/cmp scale name");
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "af");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "af");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "af");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_11_NAME, "af");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "af");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_2_NAME, "af");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "af");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_21_NAME, "af");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "af");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_22_NAME, "af");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -2156,52 +2270,47 @@ static int test_float_scalenames(const char *fileext) {
return 0;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_foreign_scaleattached(const char *fileforeign)
+static int
+test_foreign_scaleattached(const char *fileforeign)
{
- herr_t ret_value = FAIL;
- hid_t fid = -1;
- hid_t did = -1;
- hid_t dsid = -1;
- char *srcdir = getenv("srcdir"); /* the source directory */
- char filename[512]=""; /* buffer to hold name of existing file */
-
- /* compose the name of the file to open, using the srcdir, if appropriate */
- if (srcdir) {
- HDstrcpy(filename,srcdir);
- HDstrcat(filename,"/");
- }
- HDstrcat(filename, fileforeign);
+ herr_t ret_value = FAIL;
+ hid_t fid = -1;
+ hid_t did = -1;
+ hid_t dsid = -1;
+ const char *filename = H5_get_srcdir_filename(fileforeign);
- TESTING2("test_foreign_scaleattached");
+ HL_TESTING2("test_foreign_scaleattached");
- if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
goto out;
- if((did = H5Dopen2(fid, "/dset_al", H5P_DEFAULT)) >= 0) {
- if((dsid = H5Dopen2(fid, "/ds_4_al", H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, 3) == 1) {
+ if ((did = H5Dopen2(fid, "/dset_al", H5P_DEFAULT)) >= 0) {
+ if ((dsid = H5Dopen2(fid, "/ds_4_al", H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, 3) == 1) {
ret_value = SUCCEED;
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
goto out;
- if(ret_value == FAIL)
+ if (ret_value == FAIL)
goto out;
PASSED();
@@ -2210,1225 +2319,1206 @@ static int test_foreign_scaleattached(const char *fileforeign)
return 0;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_simple(void)
+static int
+test_simple(void)
{
- hid_t fid = -1;
- hid_t did = -1;
- hid_t dsid = -1;
- hid_t sid = -1;
- hid_t gid = -1;
- int rank = RANK;
- int rankds = 1;
- hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE};
- int buf[DIM_DATA] = {1,2,3,4,5,6,7,8,9,10,11,12};
- hsize_t s1_dim[1] = {DIM1_SIZE};
- hsize_t s2_dim[1] = {DIM2_SIZE};
- char sname[30];
- char dname[30];
- int s1_wbuf[DIM1_SIZE] = {10,20,30};
- int s11_wbuf[DIM1_SIZE] = {10,100,300};
- int s2_wbuf[DIM2_SIZE] = {100,200,300,400};
- int s21_wbuf[DIM2_SIZE] = {10,20,30,40};
- int s22_wbuf[DIM2_SIZE] = {5,10,50,300};
- char dim0_label[16];
- char dim1_label[16];
- char *dim0_labeld;
- char *dim1_labeld;
- char dim0_labels[3];
- char dim1_labels[3];
- ssize_t dim0_label_size;
- ssize_t dim1_label_size;
+ hid_t fid = -1;
+ hid_t did = -1;
+ hid_t dsid = -1;
+ hid_t sid = -1;
+ hid_t gid = -1;
+ int rank = RANK;
+ int rankds = 1;
+ hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE};
+ int buf[DIM_DATA] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
+ hsize_t s1_dim[1] = {DIM1_SIZE};
+ hsize_t s2_dim[1] = {DIM2_SIZE};
+ char sname[30];
+ char dname[30];
+ int s1_wbuf[DIM1_SIZE] = {10, 20, 30};
+ int s11_wbuf[DIM1_SIZE] = {10, 100, 300};
+ int s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400};
+ int s21_wbuf[DIM2_SIZE] = {10, 20, 30, 40};
+ int s22_wbuf[DIM2_SIZE] = {5, 10, 50, 300};
+ char dim0_label[16];
+ char dim1_label[16];
+ char * dim0_labeld;
+ char * dim1_labeld;
+ char dim0_labels[3];
+ char dim1_labels[3];
+ ssize_t dim0_label_size;
+ ssize_t dim1_label_size;
unsigned int dim;
- int scale_idx;
- int nscales;
- ssize_t name_len;
- char *name_out=NULL;
- char snames[3];
- int i, j;
+ int scale_idx;
+ int nscales;
+ ssize_t name_len;
+ char * name_out = NULL;
+ char snames[3];
+ int i, j;
- printf("Testing API functions\n");
+ HDprintf("Testing API functions\n");
/*-------------------------------------------------------------------------
- * create a file for the test
- *-------------------------------------------------------------------------
- */
+ * create a file for the test
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- if((fid=H5Fcreate(FILE1,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/*-------------------------------------------------------------------------
- * create datasets: 1 "data" dataset and 4 dimension scales
- *-------------------------------------------------------------------------
- */
+ * create datasets: 1 "data" dataset and 4 dimension scales
+ *-------------------------------------------------------------------------
+ */
/* make a dataset */
- if(H5LTmake_dataset_int(fid,"dset_a",rank,dims,buf) < 0)
+ if (H5LTmake_dataset_int(fid, "dset_a", rank, dims, buf) < 0)
goto out;
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_int(fid,"ds_a_1",rankds,s1_dim,s1_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a_1", rankds, s1_dim, s1_wbuf) < 0)
goto out;
/* make a DS dataset with an alternate scale for the 2nd dimension */
- if(H5LTmake_dataset_int(fid,"ds_a_11",rankds,s1_dim,s11_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a_11", rankds, s1_dim, s11_wbuf) < 0)
goto out;
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_int(fid,"ds_a_2",rankds,s2_dim,s2_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a_2", rankds, s2_dim, s2_wbuf) < 0)
goto out;
/* make a DS dataset with an alternate scale for the 2nd dimension */
- if(H5LTmake_dataset_int(fid,"ds_a_21",rankds,s2_dim,s21_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a_21", rankds, s2_dim, s21_wbuf) < 0)
goto out;
/* make a DS dataset with an alternate scale for the 2nd dimension */
- if(H5LTmake_dataset_int(fid,"ds_a_22",rankds,s2_dim,s22_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a_22", rankds, s2_dim, s22_wbuf) < 0)
goto out;
/* get the dataset id for "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach the DS_1_NAME dimension scale to "dset_a"
- *-------------------------------------------------------------------------
- */
+ * attach the DS_1_NAME dimension scale to "dset_a"
+ *-------------------------------------------------------------------------
+ */
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_a_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_1", H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_1_NAME dimension scale to "dset_a" at dimension 0 */
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach the DS_11_NAME dimension scale to "dset_a"
- *-------------------------------------------------------------------------
- */
+ * attach the DS_11_NAME dimension scale to "dset_a"
+ *-------------------------------------------------------------------------
+ */
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_a_11", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_11", H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_11_NAME dimension scale to "dset_a" at dimension 0 */
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach the DS_2_NAME dimension scale to "dset_a"
- *-------------------------------------------------------------------------
- */
+ * attach the DS_2_NAME dimension scale to "dset_a"
+ *-------------------------------------------------------------------------
+ */
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_a_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_2", H5P_DEFAULT)) < 0)
goto out;
/* attach the "ds2" dimension scale to "dset_a" as the 2nd dimension */
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach the DS_21_NAME dimension scale to "dset_a"
- *-------------------------------------------------------------------------
- */
+ * attach the DS_21_NAME dimension scale to "dset_a"
+ *-------------------------------------------------------------------------
+ */
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_a_21", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_21", H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_21_NAME dimension scale to "dset_a" as the 2nd dimension */
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach the DS_22_NAME dimension scale to "dset_a"
- *-------------------------------------------------------------------------
- */
+ * attach the DS_22_NAME dimension scale to "dset_a"
+ *-------------------------------------------------------------------------
+ */
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_a_22", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_22", H5P_DEFAULT)) < 0)
goto out;
/* attach the "ds22" dimension scale to "dset_a" as the 2nd dimension */
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_a" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * create datasets: 1 "data" dataset and 1 dimension scale
- *-------------------------------------------------------------------------
- */
+ * create datasets: 1 "data" dataset and 1 dimension scale
+ *-------------------------------------------------------------------------
+ */
/* make a dataset */
- if(H5LTmake_dataset_int(fid,"dset_b",rank,dims,buf) < 0)
+ if (H5LTmake_dataset_int(fid, "dset_b", rank, dims, buf) < 0)
goto out;
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_int(fid,"ds_b_1",rankds,s1_dim,s1_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_b_1", rankds, s1_dim, s1_wbuf) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach the scale to "dset_b"
- *-------------------------------------------------------------------------
- */
+ * attach the scale to "dset_b"
+ *-------------------------------------------------------------------------
+ */
- if((did = H5Dopen2(fid,"dset_b", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_b", H5P_DEFAULT)) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_b_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_b_1", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did,dsid,0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_b" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
-
-
/*-------------------------------------------------------------------------
- * H5DSdetach_scale
- *-------------------------------------------------------------------------
- */
-
- TESTING2("detach scales ");
+ * H5DSdetach_scale
+ *-------------------------------------------------------------------------
+ */
+ HL_TESTING2("detach scales ");
/*-------------------------------------------------------------------------
- * create datasets: one "data" dataset and 4 dimension scales
- *-------------------------------------------------------------------------
- */
+ * create datasets: one "data" dataset and 4 dimension scales
+ *-------------------------------------------------------------------------
+ */
/* make a dataset */
- if(H5LTmake_dataset_int(fid, "dset_c", rank, dims, buf) < 0)
+ if (H5LTmake_dataset_int(fid, "dset_c", rank, dims, buf) < 0)
goto out;
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_int(fid, "ds_c_1", rankds, s1_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_c_1", rankds, s1_dim, s1_wbuf) < 0)
goto out;
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_int(fid, "ds_c_2", rankds, s2_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_c_2", rankds, s2_dim, s2_wbuf) < 0)
goto out;
/* make a DS dataset with an alternate scale for the 2nd dimension */
- if(H5LTmake_dataset_int(fid, "ds_c_21", rankds, s2_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_c_21", rankds, s2_dim, s2_wbuf) < 0)
goto out;
/* make a DS dataset with an alternate scale for the 2nd dimension */
- if(H5LTmake_dataset_int(fid, "ds_c_22", rankds, s2_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_c_22", rankds, s2_dim, s2_wbuf) < 0)
goto out;
-
/*-------------------------------------------------------------------------
- * attach the scales to "dset_c"
- *-------------------------------------------------------------------------
- */
+ * attach the scales to "dset_c"
+ *-------------------------------------------------------------------------
+ */
- if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_c_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_c_1", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did, dsid, 0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_c_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_c_2", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did, dsid, 1) < 0)
+ if (H5DSattach_scale(did, dsid, 1) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_c_21", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_c_21", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did, dsid, 1) < 0)
+ if (H5DSattach_scale(did, dsid, 1) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_c_22", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_c_22", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did, dsid, 1) < 0)
+ if (H5DSattach_scale(did, dsid, 1) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * verify if "dset_c" has dimension scales
- *-------------------------------------------------------------------------
- */
+ * verify if "dset_c" has dimension scales
+ *-------------------------------------------------------------------------
+ */
- if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0)
goto out;
/* verify that "dset_c" has 1 dimension scale at DIM 0 */
- if((nscales = H5DSget_num_scales(did, 0)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 0)) < 0)
goto out;
- if(nscales != 1)
+ if (nscales != 1)
goto out;
/* verify that "dset_c" has 3 dimension scales at DIM 1 */
- if((nscales = H5DSget_num_scales(did, 1)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 1)) < 0)
goto out;
- if(nscales != 3)
+ if (nscales != 3)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * detach the "ds_c_21" dimension scale to "dset_c"
- *-------------------------------------------------------------------------
- */
+ * detach the "ds_c_21" dimension scale to "dset_c"
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_c" */
- if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_c_21", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_c_21", H5P_DEFAULT)) < 0)
goto out;
/* detach the "ds_c_21" dimension scale to "dset_c" in DIM 1 */
- if(H5DSdetach_scale(did, dsid, 1) < 0)
+ if (H5DSdetach_scale(did, dsid, 1) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_c" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * "dset_c" must have now 2 dimension scales at DIM 1
- *-------------------------------------------------------------------------
- */
+ * "dset_c" must have now 2 dimension scales at DIM 1
+ *-------------------------------------------------------------------------
+ */
- if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0)
goto out;
/* verify that "dset_c" has 2 dimension scales at DIM 1 */
- if((nscales = H5DSget_num_scales(did, 1)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 1)) < 0)
goto out;
- if(nscales != 2)
+ if (nscales != 2)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * detach the "ds_c_22" dimension scale to "dset_c"
- *-------------------------------------------------------------------------
- */
+ * detach the "ds_c_22" dimension scale to "dset_c"
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_c" */
- if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_c_22", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_c_22", H5P_DEFAULT)) < 0)
goto out;
/* detach the "ds_c_22" dimension scale to "dset_c" in DIM 1 */
- if(H5DSdetach_scale(did, dsid, 1) < 0)
+ if (H5DSdetach_scale(did, dsid, 1) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_c" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * "dset_c" must have now 1 dimension scale at DIM 1
- *-------------------------------------------------------------------------
- */
+ * "dset_c" must have now 1 dimension scale at DIM 1
+ *-------------------------------------------------------------------------
+ */
- if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0)
goto out;
/* verify that "dset_c" has 1 dimension scale at DIM 1 */
- if((nscales = H5DSget_num_scales(did, 1)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 1)) < 0)
goto out;
- if(nscales != 1)
+ if (nscales != 1)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * detach the "ds_c_2" dimension scale to "dset_c"
- *-------------------------------------------------------------------------
- */
+ * detach the "ds_c_2" dimension scale to "dset_c"
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_c" */
- if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_c_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_c_2", H5P_DEFAULT)) < 0)
goto out;
/* detach the "ds_c_2" dimension scale to "dset_c" in DIM 1 */
- if(H5DSdetach_scale(did, dsid, 1) < 0)
+ if (H5DSdetach_scale(did, dsid, 1) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_c" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * "dset_c" must have now 0 dimension scales at DIM 1
- *-------------------------------------------------------------------------
- */
+ * "dset_c" must have now 0 dimension scales at DIM 1
+ *-------------------------------------------------------------------------
+ */
- if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0)
goto out;
/* verify that "dset_c" has 1 dimension scale at DIM 1 */
- if((nscales = H5DSget_num_scales(did, 1)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 1)) < 0)
goto out;
- if(nscales != 0)
+ if (nscales != 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
-
/*-------------------------------------------------------------------------
- * create 3 datasets: 1 "data" dataset and 2 dimension scales
- *-------------------------------------------------------------------------
- */
- if(H5LTmake_dataset_int(fid,"dset_d",rank,dims,NULL) < 0)
+ * create 3 datasets: 1 "data" dataset and 2 dimension scales
+ *-------------------------------------------------------------------------
+ */
+ if (H5LTmake_dataset_int(fid, "dset_d", rank, dims, NULL) < 0)
goto out;
- if(H5LTmake_dataset_int(fid,"ds_d_1",rankds,s1_dim,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_d_1", rankds, s1_dim, NULL) < 0)
goto out;
- if(H5LTmake_dataset_int(fid,"ds_d_2",rankds,s2_dim,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_d_2", rankds, s2_dim, NULL) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach them
- *-------------------------------------------------------------------------
- */
- if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0)
+ * attach them
+ *-------------------------------------------------------------------------
+ */
+ if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_d_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_d_1", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did, dsid, 0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_d_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_d_2", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did, dsid, 1) < 0)
+ if (H5DSattach_scale(did, dsid, 1) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * verify
- *-------------------------------------------------------------------------
- */
+ * verify
+ *-------------------------------------------------------------------------
+ */
- if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_d_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_d_1", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSis_attached(did,dsid,DIM0)<=0)
+ if (H5DSis_attached(did, dsid, DIM0) <= 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_d_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_d_2", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSis_attached(did,dsid,DIM1)<=0)
+ if (H5DSis_attached(did, dsid, DIM1) <= 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
-
/*-------------------------------------------------------------------------
- * detach
- *-------------------------------------------------------------------------
- */
+ * detach
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_d" */
- if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_d_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_d_1", H5P_DEFAULT)) < 0)
goto out;
/* detach the dimension scale to "dset_d" in DIM 0 */
- if(H5DSdetach_scale(did,dsid,DIM0) < 0)
+ if (H5DSdetach_scale(did, dsid, DIM0) < 0)
goto out;
/* verify attach, it must return 0 for no attach */
- if(H5DSis_attached(did,dsid,DIM0)!=0)
+ if (H5DSis_attached(did, dsid, DIM0) != 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_d" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach again
- *-------------------------------------------------------------------------
- */
+ * attach again
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_d" */
- if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_d_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_d_1", H5P_DEFAULT)) < 0)
goto out;
/* attach "ds_d_1" again in DIM 0 */
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
/* verify attach, it must return 1 for attach */
- if(H5DSis_attached(did,dsid,DIM0)!=1)
+ if (H5DSis_attached(did, dsid, DIM0) != 1)
goto out;
/* verify that "ds_d_1" has only 1 scale at DIM0 */
- if((nscales = H5DSget_num_scales(did,DIM0)) < 0)
+ if ((nscales = H5DSget_num_scales(did, DIM0)) < 0)
goto out;
- if(nscales != 1)
+ if (nscales != 1)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_d" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * detach/detach
- *-------------------------------------------------------------------------
- */
+ * detach/detach
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_d" */
- if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_d_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_d_2", H5P_DEFAULT)) < 0)
goto out;
/* detach the "ds_d_2" dimension scale to "dset_d" in DIM 1 */
- if(H5DSdetach_scale(did,dsid,DIM1) < 0)
+ if (H5DSdetach_scale(did, dsid, DIM1) < 0)
goto out;
/* detach again, it should fail */
- if(H5DSdetach_scale(did,dsid,DIM1)==SUCCEED)
+ if (H5DSdetach_scale(did, dsid, DIM1) == SUCCEED)
goto out;
/* verify attach, it must return 0 for no attach */
- if(H5DSis_attached(did,dsid,DIM1)!=0)
+ if (H5DSis_attached(did, dsid, DIM1) != 0)
goto out;
/* verify that "ds_d_1" has no scale at DIM1 */
- if((nscales = H5DSget_num_scales(did,DIM1)) < 0)
+ if ((nscales = H5DSget_num_scales(did, DIM1)) < 0)
goto out;
- if(nscales != 0)
+ if (nscales != 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_d" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach twice
- *-------------------------------------------------------------------------
- */
+ * attach twice
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_d" */
- if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_d_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_d_2", H5P_DEFAULT)) < 0)
goto out;
/* attach "ds_d_2" in DIM 1 */
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
/* verify attach, it must return 1 for attach */
- if(H5DSis_attached(did,dsid,DIM1)!=1)
+ if (H5DSis_attached(did, dsid, DIM1) != 1)
goto out;
/* verify that "ds_d_2" has only 1 scale at DIM1 */
- if((nscales = H5DSget_num_scales(did,DIM0)) < 0)
+ if ((nscales = H5DSget_num_scales(did, DIM0)) < 0)
goto out;
- if(nscales != 1)
+ if (nscales != 1)
goto out;
/* attach "ds_d_2" again in DIM 1 */
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
/* verify attach, it must return 1 for attach */
- if(H5DSis_attached(did,dsid,DIM1)!=1)
+ if (H5DSis_attached(did, dsid, DIM1) != 1)
goto out;
/* verify that "ds_d_2" has only 1 scale at DIM1 */
- if((nscales = H5DSget_num_scales(did,DIM0)) < 0)
+ if ((nscales = H5DSget_num_scales(did, DIM0)) < 0)
goto out;
- if(nscales != 1)
+ if (nscales != 1)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_d" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * create 10 datasets: 5 "data" dataset and 5 dimension scales
- *-------------------------------------------------------------------------
- */
+ * create 10 datasets: 5 "data" dataset and 5 dimension scales
+ *-------------------------------------------------------------------------
+ */
/* create a group */
- if((gid = H5Gcreate2(fid, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((gid = H5Gcreate2(fid, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* create the data space for the dataset */
- if((sid = H5Screate_simple(rank,dims,NULL)) < 0)
+ if ((sid = H5Screate_simple(rank, dims, NULL)) < 0)
goto out;
- for(i = 0; i < 5; i++) {
- sprintf(dname,"dset_%d",i);
- if((did = H5Dcreate2(gid, dname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ for (i = 0; i < 5; i++) {
+ HDsprintf(dname, "dset_%d", i);
+ if ((did = H5Dcreate2(gid, dname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
- sprintf(sname,"ds_%d",i);
- if((dsid = H5Dcreate2(gid, sname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ HDsprintf(sname, "ds_%d", i);
+ if ((dsid = H5Dcreate2(gid, sname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
- if(H5DSset_scale(dsid,"scale") < 0)
+ if (H5DSset_scale(dsid, "scale") < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
/*-------------------------------------------------------------------------
- * attach for DIM 0
- *-------------------------------------------------------------------------
- */
+ * attach for DIM 0
+ *-------------------------------------------------------------------------
+ */
- for(i = 0; i < 5; i++) {
- sprintf(dname, "dset_%d", i);
- if((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0)
+ for (i = 0; i < 5; i++) {
+ HDsprintf(dname, "dset_%d", i);
+ if ((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0)
goto out;
- for(j = 0; j < 5; j++) {
- sprintf(sname, "ds_%d", j);
- if((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0)
+ for (j = 0; j < 5; j++) {
+ HDsprintf(sname, "ds_%d", j);
+ if ((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did, dsid, DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
/*-------------------------------------------------------------------------
- * dettach for DIM0
- *-------------------------------------------------------------------------
- */
+ * dettach for DIM0
+ *-------------------------------------------------------------------------
+ */
- for(i = 0; i < 5; i++) {
- sprintf(dname, "dset_%d", i);
- if((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0)
+ for (i = 0; i < 5; i++) {
+ HDsprintf(dname, "dset_%d", i);
+ if ((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0)
goto out;
- for(j = 0; j < 5; j++) {
- sprintf(sname, "ds_%d", j);
- if((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0)
+ for (j = 0; j < 5; j++) {
+ HDsprintf(sname, "ds_%d", j);
+ if ((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0)
goto out;
- if(H5DSdetach_scale(did, dsid, DIM0) < 0)
+ if (H5DSdetach_scale(did, dsid, DIM0) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
-
/*-------------------------------------------------------------------------
- * attach again for DIM0
- *-------------------------------------------------------------------------
- */
+ * attach again for DIM0
+ *-------------------------------------------------------------------------
+ */
- for(i=0; i<5; i++) {
- sprintf(dname,"dset_%d",i);
- if((did = H5Dopen2(gid,dname, H5P_DEFAULT)) < 0)
+ for (i = 0; i < 5; i++) {
+ HDsprintf(dname, "dset_%d", i);
+ if ((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0)
goto out;
- for(j=0; j<5; j++) {
- sprintf(sname,"ds_%d",j);
- if((dsid = H5Dopen2(gid,sname, H5P_DEFAULT)) < 0)
+ for (j = 0; j < 5; j++) {
+ HDsprintf(sname, "ds_%d", j);
+ if ((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
/* close */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Gclose(gid) < 0)
+ if (H5Gclose(gid) < 0)
goto out;
-
-
/*-------------------------------------------------------------------------
- * create a dataset and attach only to 1 dimension
- *-------------------------------------------------------------------------
- */
+ * create a dataset and attach only to 1 dimension
+ *-------------------------------------------------------------------------
+ */
/* make a dataset */
- if(H5LTmake_dataset_int(fid,"dset_e",rank,dims,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "dset_e", rank, dims, NULL) < 0)
goto out;
/* make a scale */
- if(H5LTmake_dataset_int(fid,"ds_e_1",rankds,s1_dim,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_e_1", rankds, s1_dim, NULL) < 0)
goto out;
/* attach the DS to dimension 1 */
- if((did = H5Dopen2(fid,"dset_e", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_e", H5P_DEFAULT)) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_e_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_e_1", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
- if(H5DSis_attached(did,dsid,DIM1)<=0)
+ if (H5DSis_attached(did, dsid, DIM1) <= 0)
goto out;
-
/* try to detach all dimensions. for dimensions 0 and 2, it is an error */
- for(i=0; i<rank; i++) {
- if( i==1 ) {
- if(H5DSdetach_scale(did,dsid,(unsigned)i) < 0)
+ for (i = 0; i < rank; i++) {
+ if (i == 1) {
+ if (H5DSdetach_scale(did, dsid, (unsigned)i) < 0)
goto out;
}
else {
- if(H5DSdetach_scale(did,dsid,(unsigned)i)!=FAIL)
+ if (H5DSdetach_scale(did, dsid, (unsigned)i) != FAIL)
goto out;
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
-
-
/*-------------------------------------------------------------------------
- * H5DSset_label, H5DSget_label
- *-------------------------------------------------------------------------
- */
+ * H5DSset_label, H5DSget_label
+ *-------------------------------------------------------------------------
+ */
- TESTING2("set/get label");
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ HL_TESTING2("set/get label");
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/*-------------------------------------------------------------------------
- * set label
- *-------------------------------------------------------------------------
- */
+ * set label
+ *-------------------------------------------------------------------------
+ */
- if(H5DSset_label(did,DIM0,DIM0_LABEL) < 0)
+ if (H5DSset_label(did, DIM0, DIM0_LABEL) < 0)
goto out;
/* check getting a label which does not exist */
- if(H5DSget_label(did,DIM1,dim1_label,sizeof(dim1_label)) != 0)
+ if (H5DSget_label(did, DIM1, dim1_label, sizeof(dim1_label)) != 0)
goto out;
- if(H5DSset_label(did,DIM1,DIM1_LABEL) < 0)
+ if (H5DSset_label(did, DIM1, DIM1_LABEL) < 0)
goto out;
/*-------------------------------------------------------------------------
- * get the scale name using a static buffer
- *-------------------------------------------------------------------------
- */
+ * get the scale name using a static buffer
+ *-------------------------------------------------------------------------
+ */
- if(H5DSget_label(did,DIM0,dim0_label,sizeof(dim0_label)) < 0)
+ if (H5DSget_label(did, DIM0, dim0_label, sizeof(dim0_label)) < 0)
goto out;
- if(H5DSget_label(did,DIM1,dim1_label,sizeof(dim1_label)) < 0)
+ if (H5DSget_label(did, DIM1, dim1_label, sizeof(dim1_label)) < 0)
goto out;
- if(HDstrncmp(DIM0_LABEL,dim0_label,sizeof(dim0_label))!=0)
+ if (HDstrncmp(DIM0_LABEL, dim0_label, sizeof(dim0_label)) != 0)
goto out;
- if(HDstrncmp(DIM1_LABEL,dim1_label,sizeof(dim1_label))!=0)
+ if (HDstrncmp(DIM1_LABEL, dim1_label, sizeof(dim1_label)) != 0)
goto out;
/*-------------------------------------------------------------------------
- * get the scale name using a dynamic buffer
- *-------------------------------------------------------------------------
- */
+ * get the scale name using a dynamic buffer
+ *-------------------------------------------------------------------------
+ */
- if((dim0_label_size=H5DSget_label(did,DIM0,NULL,(size_t)0)) < 0)
+ if ((dim0_label_size = H5DSget_label(did, DIM0, NULL, (size_t)0)) < 0)
goto out;
- if((dim1_label_size=H5DSget_label(did,DIM1,NULL,(size_t)0)) < 0)
+ if ((dim1_label_size = H5DSget_label(did, DIM1, NULL, (size_t)0)) < 0)
goto out;
/* allocate */
- dim0_labeld = (char*)HDmalloc((size_t)dim0_label_size * sizeof (char));
- dim1_labeld = (char*)HDmalloc((size_t)dim1_label_size * sizeof (char));
- if( dim0_labeld==NULL || dim1_labeld==NULL)
+ dim0_labeld = (char *)HDmalloc((size_t)dim0_label_size * sizeof(char));
+ dim1_labeld = (char *)HDmalloc((size_t)dim1_label_size * sizeof(char));
+ if (dim0_labeld == NULL || dim1_labeld == NULL)
goto out;
- if(H5DSget_label(did,DIM0,dim0_labeld,(size_t)dim0_label_size) < 0)
+ if (H5DSget_label(did, DIM0, dim0_labeld, (size_t)dim0_label_size) < 0)
goto out;
- if(H5DSget_label(did,DIM1,dim1_labeld,(size_t)dim1_label_size) < 0)
+ if (H5DSget_label(did, DIM1, dim1_labeld, (size_t)dim1_label_size) < 0)
goto out;
- if(HDstrncmp(DIM0_LABEL,dim0_labeld,(size_t)(dim0_label_size-1))!=0)
+ if (HDstrncmp(DIM0_LABEL, dim0_labeld, (size_t)(dim0_label_size - 1)) != 0)
goto out;
- if(HDstrncmp(DIM1_LABEL,dim1_labeld,(size_t)(dim1_label_size-1))!=0)
+ if (HDstrncmp(DIM1_LABEL, dim1_labeld, (size_t)(dim1_label_size - 1)) != 0)
goto out;
- if(dim0_labeld) {
+ if (dim0_labeld) {
HDfree(dim0_labeld);
- dim0_labeld=NULL;
+ dim0_labeld = NULL;
}
- if(dim1_labeld) {
+ if (dim1_labeld) {
HDfree(dim1_labeld);
- dim1_labeld=NULL;
+ dim1_labeld = NULL;
}
-
/*-------------------------------------------------------------------------
- * get the label using a static buffer smaller than the string lenght
- *-------------------------------------------------------------------------
- */
+ * get the label using a static buffer smaller than the string length
+ *-------------------------------------------------------------------------
+ */
- if(H5DSget_label(did,DIM0,dim0_labels,sizeof(dim0_labels)) < 0)
+ if (H5DSget_label(did, DIM0, dim0_labels, sizeof(dim0_labels)) < 0)
goto out;
- if(H5DSget_label(did,DIM1,dim1_labels,sizeof(dim1_labels)) < 0)
+ if (H5DSget_label(did, DIM1, dim1_labels, sizeof(dim1_labels)) < 0)
goto out;
- if(HDstrncmp(DIM0_LABEL,dim0_labels,sizeof(dim0_labels)-1)!=0)
+ if (HDstrncmp(DIM0_LABEL, dim0_labels, sizeof(dim0_labels) - 1) != 0)
goto out;
- if(HDstrncmp(DIM1_LABEL,dim1_labels,sizeof(dim1_labels)-1)!=0)
+ if (HDstrncmp(DIM1_LABEL, dim1_labels, sizeof(dim1_labels) - 1) != 0)
goto out;
- if(H5Dclose(did))
+ if (H5Dclose(did))
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * H5DSget_scale_name, H5DSget_scale_name
- *-------------------------------------------------------------------------
- */
+ * H5DSget_scale_name, H5DSget_scale_name
+ *-------------------------------------------------------------------------
+ */
-
- TESTING2("set scale/get scale name");
- if((dsid = H5Dopen2(fid,"ds_a_1", H5P_DEFAULT)) < 0)
+ HL_TESTING2("set scale/get scale name");
+ if ((dsid = H5Dopen2(fid, "ds_a_1", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSset_scale(dsid,"Latitude set 0") < 0)
+ if (H5DSset_scale(dsid, "Latitude set 0") < 0)
goto out;
/* verify that DS_1_NAME is a dimension scale dataset */
- if((H5DSis_scale(dsid)) == 0)
+ if ((H5DSis_scale(dsid)) == 0)
goto out;
/*-------------------------------------------------------------------------
- * get the scale name using a dynamic buffer
- *-------------------------------------------------------------------------
- */
+ * get the scale name using a dynamic buffer
+ *-------------------------------------------------------------------------
+ */
- /* get the lenght of the scale name (pass NULL in name) */
- if((name_len=H5DSget_scale_name(dsid,NULL,(size_t)0)) < 0)
+ /* get the length of the scale name (pass NULL in name) */
+ if ((name_len = H5DSget_scale_name(dsid, NULL, (size_t)0)) < 0)
goto out;
/* allocate a buffer */
- name_out = (char*)HDmalloc((name_len+1) * sizeof (char));
- if(name_out == NULL)
+ name_out = (char *)HDmalloc(((size_t)name_len + 1) * sizeof(char));
+ if (name_out == NULL)
goto out;
/* get the scale name using this buffer */
- if(H5DSget_scale_name(dsid, name_out, (size_t)name_len+1) < 0)
+ if (H5DSget_scale_name(dsid, name_out, (size_t)name_len + 1) < 0)
goto out;
- if(HDstrncmp("Latitude set 0",name_out, (size_t)name_len)!=0)
+ if (HDstrncmp("Latitude set 0", name_out, (size_t)name_len) != 0)
goto out;
- if(name_out) {
+ if (name_out) {
HDfree(name_out);
- name_out=NULL;
+ name_out = NULL;
}
/*-------------------------------------------------------------------------
- * get the scale name using a static buffer
- *-------------------------------------------------------------------------
- */
+ * get the scale name using a static buffer
+ *-------------------------------------------------------------------------
+ */
/* get the scale name using this buffer */
- if(H5DSget_scale_name(dsid, sname, sizeof(sname)) < 0)
+ if (H5DSget_scale_name(dsid, sname, sizeof(sname)) < 0)
goto out;
- if(HDstrncmp("Latitude set 0", sname, sizeof(sname))!=0)
+ if (HDstrncmp("Latitude set 0", sname, sizeof(sname)) != 0)
goto out;
/*-------------------------------------------------------------------------
- * get the scale name using a static buffer smaller than the string lenght
- *-------------------------------------------------------------------------
- */
+ * get the scale name using a static buffer smaller than the string length
+ *-------------------------------------------------------------------------
+ */
/* get the scale name using this buffer */
- if(H5DSget_scale_name(dsid, snames, sizeof (snames)) < 0)
+ if (H5DSget_scale_name(dsid, snames, sizeof(snames)) < 0)
goto out;
- if(HDstrncmp("Latitude set 0",snames,sizeof(snames)-1)!=0)
+ if (HDstrncmp("Latitude set 0", snames, sizeof(snames) - 1) != 0)
goto out;
- if(H5Dclose(dsid))
+ if (H5Dclose(dsid))
goto out;
/*-------------------------------------------------------------------------
- * add scale names
- *-------------------------------------------------------------------------
- */
+ * add scale names
+ *-------------------------------------------------------------------------
+ */
- if((dsid = H5Dopen2(fid,"ds_a_11", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_11", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSset_scale(dsid,"Latitude set 1") < 0)
+ if (H5DSset_scale(dsid, "Latitude set 1") < 0)
goto out;
- if(H5Dclose(dsid))
+ if (H5Dclose(dsid))
goto out;
- if((dsid = H5Dopen2(fid,"ds_a_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_2", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSset_scale(dsid,"Longitude set 0") < 0)
+ if (H5DSset_scale(dsid, "Longitude set 0") < 0)
goto out;
- if(H5Dclose(dsid))
+ if (H5Dclose(dsid))
goto out;
- if((dsid = H5Dopen2(fid,"ds_a_21", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_21", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSset_scale(dsid,"Longitude set 1") < 0)
+ if (H5DSset_scale(dsid, "Longitude set 1") < 0)
goto out;
- if(H5Dclose(dsid))
+ if (H5Dclose(dsid))
goto out;
- if((dsid = H5Dopen2(fid,"ds_a_22", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_22", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSset_scale(dsid,"Longitude set 2") < 0)
+ if (H5DSset_scale(dsid, "Longitude set 2") < 0)
goto out;
- if(H5Dclose(dsid))
+ if (H5Dclose(dsid))
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * H5DSiterate_scales
- *-------------------------------------------------------------------------
- */
-
-
- TESTING2("iterate scales");
+ * H5DSiterate_scales
+ *-------------------------------------------------------------------------
+ */
+ HL_TESTING2("iterate scales");
/*-------------------------------------------------------------------------
- * test 6: test iterate scales with a function verify_scale
- *-------------------------------------------------------------------------
- */
+ * test 6: test iterate scales with a function verify_scale
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
dim = 0;
/* iterate trough the 1st dimension of "dset_a" and verify that its DS is valid */
- if(H5DSiterate_scales(did,dim,NULL,verify_scale,NULL) < 0)
+ if (H5DSiterate_scales(did, dim, NULL, verify_scale, NULL) < 0)
goto out;
/* iterate trough the 2nd dimension of "dset_a" and verify that its DS is valid
start at DS index 2 */
- dim = 1;
+ dim = 1;
scale_idx = 2;
- if(H5DSiterate_scales(did,dim,&scale_idx,verify_scale,NULL) < 0)
+ if (H5DSiterate_scales(did, dim, &scale_idx, verify_scale, NULL) < 0)
goto out;
/* close dataset ID of "dset_a" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
-
/*-------------------------------------------------------------------------
- * test iterate scales with a function read_scale
- *-------------------------------------------------------------------------
- */
-
+ * test iterate scales with a function read_scale
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
dim = 0;
/* iterate trough the 1st dimension of "dset_a" and read the DS */
- if(H5DSiterate_scales(did,dim,NULL,read_scale,s1_wbuf) < 0)
+ if (H5DSiterate_scales(did, dim, NULL, read_scale, s1_wbuf) < 0)
goto out;
/* iterate trough the 2nd dimension of "dset_a" and read the DS
start at DS index 2 */
- dim = 1;
+ dim = 1;
scale_idx = 2;
- if(H5DSiterate_scales(did, dim, &scale_idx, read_scale, s22_wbuf) < 0)
+ if (H5DSiterate_scales(did, dim, &scale_idx, read_scale, s22_wbuf) < 0)
goto out;
/* close dataset ID of "dset_a" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
-
/*-------------------------------------------------------------------------
- * test iterate scales with a function match_dim_scale
- *-------------------------------------------------------------------------
- */
+ * test iterate scales with a function match_dim_scale
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* get dataset space */
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto out;
/* get rank */
- if((rank = H5Sget_simple_extent_ndims(sid)) < 0)
+ if ((rank = H5Sget_simple_extent_ndims(sid)) < 0)
goto out;
/* get dimensions of dataset */
- if(H5Sget_simple_extent_dims(sid,dims,NULL) < 0)
+ if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
goto out;
{
- int match_size; /* does this scale size matches the dataset DIM size */
- int idx = 0; /* scale index to start iterating, on return, index where iterator stoped */
+ int match_size; /* does this scale size matches the dataset DIM size */
+ int idx = 0; /* scale index to start iterating, on return, index where iterator stoped */
/* iterate trough all the dimensions */
- for(dim=0; dim<(unsigned)rank; dim++) {
- if((match_size=H5DSiterate_scales(did,dim,&idx,match_dim_scale,NULL)) < 0)
+ for (dim = 0; dim < (unsigned)rank; dim++) {
+ if ((match_size = H5DSiterate_scales(did, dim, &idx, match_dim_scale, NULL)) < 0)
goto out;
/* "dset_a" was defined with all dimension scales size matching the size of its dimensions */
- if(match_size==0)
+ if (match_size == 0)
goto out;
/* both DS_1_NAME and DS_2_NAME are the on the first index */
- if(idx!=0)
+ if (idx != 0)
goto out;
}
}
-
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
-
/*-------------------------------------------------------------------------
- * test iterate scales with a function match_dim_scale
- *-------------------------------------------------------------------------
- */
+ * test iterate scales with a function match_dim_scale
+ *-------------------------------------------------------------------------
+ */
/*-------------------------------------------------------------------------
- * create 3 datasets: 1 "data" dataset and dimension scales (some are empty)
- *-------------------------------------------------------------------------
- */
- if(H5LTmake_dataset_int(fid, "dset_f", rank, dims, buf) < 0)
+ * create 3 datasets: 1 "data" dataset and dimension scales (some are empty)
+ *-------------------------------------------------------------------------
+ */
+ if (H5LTmake_dataset_int(fid, "dset_f", rank, dims, buf) < 0)
goto out;
- if(H5LTmake_dataset_int(fid,"ds_f_1",rankds,s1_dim,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_f_1", rankds, s1_dim, NULL) < 0)
goto out;
- if(H5LTmake_dataset_int(fid, "ds_f_11", rankds, s1_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_f_11", rankds, s1_dim, s1_wbuf) < 0)
goto out;
- if(H5LTmake_dataset_int(fid,"ds_f_2",rankds,s2_dim,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_f_2", rankds, s2_dim, NULL) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach them
- *-------------------------------------------------------------------------
- */
- if((did = H5Dopen2(fid,"dset_f", H5P_DEFAULT)) < 0)
+ * attach them
+ *-------------------------------------------------------------------------
+ */
+ if ((did = H5Dopen2(fid, "dset_f", H5P_DEFAULT)) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_f_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_f_1", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_f_11", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_f_11", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_f_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_f_2", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * verify match
- *-------------------------------------------------------------------------
- */
+ * verify match
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_f" */
- if((did = H5Dopen2(fid,"dset_f", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_f", H5P_DEFAULT)) < 0)
goto out;
/* get dataset space */
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto out;
/* get rank */
- if((rank = H5Sget_simple_extent_ndims(sid)) < 0)
+ if ((rank = H5Sget_simple_extent_ndims(sid)) < 0)
goto out;
/* get dimensions of dataset */
- if(H5Sget_simple_extent_dims(sid,dims,NULL) < 0)
+ if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
goto out;
{
int match_size; /* does this scale size matches the dataset DIM size */
int idx; /* scale index to start iterating, on return, index where iterator stoped */
/* iterate trough all the dimensions */
- for(dim=0; dim<(unsigned)rank; dim++) {
+ for (dim = 0; dim < (unsigned)rank; dim++) {
/* always start at 1st scale */
- idx=0;
+ idx = 0;
- if((match_size=H5DSiterate_scales(did,dim,&idx,match_dim_scale,NULL)) < 0)
+ if ((match_size = H5DSiterate_scales(did, dim, &idx, match_dim_scale, NULL)) < 0)
goto out;
/* "dset_e" was defined with :
dim 0: 2 scales, first is empty
dim 1: 1 scale, empty */
- switch(dim) {
- case 0: /* for DIM 0, we get a valid scale at IDX 1 */
- if(match_size!=1 && idx!=1)
- goto out;
- break;
- case 1: /* for DIM 1, we get no valid scales */
- if(match_size!=0 && idx!=0)
- goto out;
- break;
- default:
- HDassert(0);
- break;
- }/*switch*/
- }/*for*/
+ switch (dim) {
+ case 0: /* for DIM 0, we get a valid scale at IDX 1 */
+ if (match_size != 1 && idx != 1)
+ goto out;
+ break;
+ case 1: /* for DIM 1, we get no valid scales */
+ if (match_size != 0 && idx != 0)
+ goto out;
+ break;
+ default:
+ HDassert(0);
+ break;
+ } /*switch*/
+ } /*for*/
}
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * end
- *-------------------------------------------------------------------------
- */
+ * end
+ *-------------------------------------------------------------------------
+ */
/* close */
H5Fclose(fid);
return 0;
- /* error zone */
- out:
+/* error zone */
+out:
H5E_BEGIN_TRY
{
H5Dclose(did);
@@ -3436,13 +3526,12 @@ static int test_simple(void)
H5Fclose(fid);
H5Sclose(sid);
H5Gclose(gid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-
-
/*-------------------------------------------------------------------------
* Function: verify_scale
*
@@ -3460,29 +3549,29 @@ static int test_simple(void)
*-------------------------------------------------------------------------
*/
-static herr_t verify_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data)
+static herr_t
+verify_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data)
{
/* define a default zero value for return. This will cause the iterator to continue */
int ret = 0;
/* unused */
- dset=dset;
- dim=dim;
- visitor_data=visitor_data;
+ dset = dset;
+ dim = dim;
+ visitor_data = visitor_data;
/* define a positive value for return value. This will cause the iterator to
immediately return that positive value, indicating short-circuit success
*/
/* the parameter DS dataset must be a valid DS dataset */
- if((H5DSis_scale(scale_id))==1) {
+ if ((H5DSis_scale(scale_id)) == 1) {
ret = 1;
}
return ret;
}
-
/*-------------------------------------------------------------------------
* Function: read_scale
*
@@ -3501,81 +3590,82 @@ static herr_t verify_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visit
*-------------------------------------------------------------------------
*/
-static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data)
+static herr_t
+read_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data)
{
- int ret = 0; /* define a default zero value for return. This will cause the iterator to continue */
- hid_t sid = -1; /* space ID */
- hid_t tid = -1; /* file type ID */
+ int ret = 0; /* define a default zero value for return. This will cause the iterator to continue */
+ hid_t sid = -1; /* space ID */
+ hid_t tid = -1; /* file type ID */
hid_t mtid = -1; /* memory type ID */
hssize_t nelmts; /* number of data elements */
- char *buf=NULL; /* data buffer */
+ char * buf = NULL; /* data buffer */
size_t size;
int i;
- char *data = (char*) visitor_data;
+ char * data = (char *)visitor_data;
/* unused */
- dset=dset;
- dim=dim;
+ dset = dset;
+ dim = dim;
/* get space */
- if((sid = H5Dget_space(scale_id)) < 0)
+ if ((sid = H5Dget_space(scale_id)) < 0)
goto out;
/* get type */
- if((tid = H5Dget_type(scale_id)) < 0)
+ if ((tid = H5Dget_type(scale_id)) < 0)
goto out;
/* get size of the DS array */
- if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
+ if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
goto out;
/* get type */
- if((mtid=H5Tget_native_type(tid,H5T_DIR_DEFAULT)) < 0)
+ if ((mtid = H5Tget_native_type(tid, H5T_DIR_DEFAULT)) < 0)
goto out;
/* get type size */
- if((size=H5Tget_size(mtid))==0)
+ if ((size = H5Tget_size(mtid)) == 0)
goto out;
- if(nelmts) {
- buf=(char *)HDmalloc(((size_t)nelmts*size));
- if(buf==NULL)
+ if (nelmts) {
+ buf = (char *)HDmalloc(((size_t)nelmts * size));
+ if (buf == NULL)
goto out;
- if(H5Dread(scale_id,mtid,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0)
+ if (H5Dread(scale_id, mtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
goto out;
- for(i=0; i<nelmts; i++) {
- if(buf[i] != data[i]) {
- printf("read and write buffers differ\n");
+ for (i = 0; i < nelmts; i++) {
+ if (buf[i] != data[i]) {
+ HDprintf("read and write buffers differ\n");
goto out;
}
}
} /* if */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Tclose(tid) < 0)
+ if (H5Tclose(tid) < 0)
goto out;
- if(H5Tclose(mtid) < 0)
+ if (H5Tclose(mtid) < 0)
goto out;
- if(buf)
+ if (buf)
HDfree(buf);
-
return ret;
/* error zone */
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Sclose(sid);
H5Tclose(tid);
H5Tclose(mtid);
- if(buf) {
+ if (buf) {
HDfree(buf);
}
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return FAIL;
}
-
/*-------------------------------------------------------------------------
* Function: match_dim_scale
*
@@ -3593,71 +3683,70 @@ out:
*-------------------------------------------------------------------------
*/
-static herr_t match_dim_scale(hid_t did, unsigned dim, hid_t dsid, void *visitor_data)
+static herr_t
+match_dim_scale(hid_t did, unsigned dim, hid_t dsid, void *visitor_data)
{
- int ret = 0; /* define a default zero value for return. This will cause the iterator to continue */
- hid_t sid; /* space ID */
- hssize_t nelmts; /* size of a dimension scale array */
- hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */
- hsize_t storage_size;
+ int ret = 0; /* define a default zero value for return. This will cause the iterator to continue */
+ hid_t sid; /* space ID */
+ hssize_t nelmts; /* size of a dimension scale array */
+ hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */
+ hsize_t storage_size;
/* Stop compiler from whining about "unused parameters" */
visitor_data = visitor_data;
/*-------------------------------------------------------------------------
- * get DID (dataset) space info
- *-------------------------------------------------------------------------
- */
+ * get DID (dataset) space info
+ *-------------------------------------------------------------------------
+ */
/* get dataset space */
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto out;
/* get dimensions of dataset */
- if(H5Sget_simple_extent_dims(sid,dims,NULL) < 0)
+ if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
goto out;
/* close the dataspace id */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
/*-------------------------------------------------------------------------
- * get DSID (scale) space info
- *-------------------------------------------------------------------------
- */
+ * get DSID (scale) space info
+ *-------------------------------------------------------------------------
+ */
/* get the space for the scale */
- if((sid = H5Dget_space(dsid)) < 0)
+ if ((sid = H5Dget_space(dsid)) < 0)
goto out;
/* get size of the DS array */
- if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
+ if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
goto out;
/* close */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
/* the size of the DS array must match the dimension of the dataset */
- if(nelmts == (hssize_t)dims[dim])
+ if (nelmts == (hssize_t)dims[dim])
ret = 1;
/* if the scale is empty assume it cannot be used */
- storage_size=H5Dget_storage_size(dsid);
+ storage_size = H5Dget_storage_size(dsid);
- if(storage_size==0)
+ if (storage_size == 0)
ret = 0;
return ret;
out:
- H5E_BEGIN_TRY {
- H5Sclose(sid);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { H5Sclose(sid); }
+ H5E_END_TRY;
return FAIL;
}
-
/*-------------------------------------------------------------------------
* Function: op_continue
*
@@ -3675,14 +3764,15 @@ out:
*-------------------------------------------------------------------------
*/
-static herr_t op_continue(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data)
+static herr_t
+op_continue(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data)
{
/* Stop compiler from whining about "unused parameters" */
- dset = dset;
- dim = dim;
+ dset = dset;
+ dim = dim;
scale_id = scale_id;
- if ( visitor_data != NULL ) {
+ if (visitor_data != NULL) {
(*(int *)visitor_data)++;
}
@@ -3707,14 +3797,15 @@ static herr_t op_continue(hid_t dset, unsigned dim, hid_t scale_id, void *visito
*-------------------------------------------------------------------------
*/
-static herr_t op_stop(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data)
+static herr_t
+op_stop(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data)
{
/* Stop compiler from whining about "unused parameters" */
- dset = dset;
- dim = dim;
+ dset = dset;
+ dim = dim;
scale_id = scale_id;
- if ( visitor_data != NULL ) {
+ if (visitor_data != NULL) {
(*(int *)visitor_data)++;
}
@@ -3727,360 +3818,356 @@ static herr_t op_stop(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_da
*-------------------------------------------------------------------------
*/
-static int test_errors(void)
+static int
+test_errors(void)
{
- hid_t fid; /* file ID */
- int rank = RANK; /* rank of data dataset */
- int rankds = 1; /* rank of DS dataset */
- hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */
- hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */
- hid_t did = -1; /* dataset ID */
- hid_t dsid = -1; /* scale ID */
- hid_t gid = -1; /* group ID */
- hid_t sid = -1; /* space ID */
- hid_t sidds = -1; /* space ID */
- hsize_t pal_dims[] = {9,3};
-
- printf("Testing error conditions\n");
+ hid_t fid; /* file ID */
+ int rank = RANK; /* rank of data dataset */
+ int rankds = 1; /* rank of DS dataset */
+ hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE}; /* size of data dataset */
+ hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */
+ hid_t did = -1; /* dataset ID */
+ hid_t dsid = -1; /* scale ID */
+ hid_t gid = -1; /* group ID */
+ hid_t sid = -1; /* space ID */
+ hid_t sidds = -1; /* space ID */
+ hsize_t pal_dims[] = {9, 3};
+
+ HDprintf("Testing error conditions\n");
/*-------------------------------------------------------------------------
- * create a file, spaces, dataset and group ids
- *-------------------------------------------------------------------------
- */
+ * create a file, spaces, dataset and group ids
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- if((fid = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* create a group */
- if((gid = H5Gcreate2(fid, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((gid = H5Gcreate2(fid, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* create the data space for the dataset */
- if((sid = H5Screate_simple(rank, dims, NULL)) < 0)
+ if ((sid = H5Screate_simple(rank, dims, NULL)) < 0)
goto out;
/* create the data space for the scale */
- if((sidds = H5Screate_simple(rankds, s1_dim, NULL)) < 0)
+ if ((sidds = H5Screate_simple(rankds, s1_dim, NULL)) < 0)
goto out;
/* create a dataset */
- if((did = H5Dcreate2(fid, "dset_a", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((did = H5Dcreate2(fid, "dset_a", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* create a dataset for the scale */
- if((dsid = H5Dcreate2(fid, "ds_a", H5T_NATIVE_INT, sidds, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dcreate2(fid, "ds_a", H5T_NATIVE_INT, sidds, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attempt to attach a dataset to itself, it should fail
- *-------------------------------------------------------------------------
- */
+ * attempt to attach a dataset to itself, it should fail
+ *-------------------------------------------------------------------------
+ */
- TESTING2("attach a dataset to itself");
+ HL_TESTING2("attach a dataset to itself");
- if(H5DSattach_scale(did, did, 0) == SUCCEED)
+ if (H5DSattach_scale(did, did, 0) == SUCCEED)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * attempt to attach a group with a dataset, it should fail
- *-------------------------------------------------------------------------
- */
- TESTING2("attach a group with a dataset");
+ * attempt to attach a group with a dataset, it should fail
+ *-------------------------------------------------------------------------
+ */
+ HL_TESTING2("attach a group with a dataset");
- if(H5DSattach_scale(gid,dsid,0)==SUCCEED)
+ if (H5DSattach_scale(gid, dsid, 0) == SUCCEED)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * attempt to attach a dataset with a group, it should fail
- *-------------------------------------------------------------------------
- */
- TESTING2("attach a dataset with a group");
+ * attempt to attach a dataset with a group, it should fail
+ *-------------------------------------------------------------------------
+ */
+ HL_TESTING2("attach a dataset with a group");
- if(H5DSattach_scale(did,gid,0)==SUCCEED)
+ if (H5DSattach_scale(did, gid, 0) == SUCCEED)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * attempt to set scale for a group, it should fail
- *-------------------------------------------------------------------------
- */
- TESTING2("set scale for a group");
+ * attempt to set scale for a group, it should fail
+ *-------------------------------------------------------------------------
+ */
+ HL_TESTING2("set scale for a group");
- if(H5DSset_scale(gid,"scale 1")==SUCCEED)
+ if (H5DSset_scale(gid, "scale 1") == SUCCEED)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * close IDs for this set
- *-------------------------------------------------------------------------
- */
+ * close IDs for this set
+ *-------------------------------------------------------------------------
+ */
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Sclose(sidds) < 0)
+ if (H5Sclose(sidds) < 0)
goto out;
- if(H5Gclose(gid) < 0)
+ if (H5Gclose(gid) < 0)
goto out;
-
/*-------------------------------------------------------------------------
- * try to attach a scale that has scales
- *-------------------------------------------------------------------------
- */
+ * try to attach a scale that has scales
+ *-------------------------------------------------------------------------
+ */
- TESTING2("attach a scale that has scales");
+ HL_TESTING2("attach a scale that has scales");
/* create the data space for the scale */
- if((sidds = H5Screate_simple(rankds, s1_dim, NULL)) < 0)
+ if ((sidds = H5Screate_simple(rankds, s1_dim, NULL)) < 0)
goto out;
/* create a dataset "ds_b" for the scale */
- if((dsid = H5Dcreate2(fid, "ds_b", H5T_NATIVE_INT, sidds, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dcreate2(fid, "ds_b", H5T_NATIVE_INT, sidds, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* open the previous written "ds_a" */
- if((did = H5Dopen2(fid,"ds_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "ds_a", H5P_DEFAULT)) < 0)
goto out;
/* attach "ds_b" to "ds_a", valid */
- if(H5DSattach_scale(did, dsid, 0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- if(H5Sclose(sidds) < 0)
+ if (H5Sclose(sidds) < 0)
goto out;
/* open the previous written "dset_a" */
- if((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* open the previous written "ds_a" */
- if((dsid = H5Dopen2(fid, "ds_a", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a", H5P_DEFAULT)) < 0)
goto out;
/* try to attach "ds_a" to "dset_a", not valid */
- if(H5DSattach_scale(did,dsid,0)==SUCCEED)
+ if (H5DSattach_scale(did, dsid, 0) == SUCCEED)
goto out;
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/* open the previous written "ds_a" */
- if((did = H5Dopen2(fid,"ds_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "ds_a", H5P_DEFAULT)) < 0)
goto out;
/* open the previous written "ds_b" */
- if((dsid = H5Dopen2(fid,"ds_b", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_b", H5P_DEFAULT)) < 0)
goto out;
/* detach "ds_b" to "ds_a" */
- if(H5DSdetach_scale(did,dsid,0) < 0)
+ if (H5DSdetach_scale(did, dsid, 0) < 0)
goto out;
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * try to attach a dataset that is a scale
- *-------------------------------------------------------------------------
- */
+ * try to attach a dataset that is a scale
+ *-------------------------------------------------------------------------
+ */
- TESTING2("attach to a dataset that is a scale");
+ HL_TESTING2("attach to a dataset that is a scale");
/* open the previous written "ds_b", that is a scale */
- if((dsid = H5Dopen2(fid,"ds_b", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_b", H5P_DEFAULT)) < 0)
goto out;
/* open the previous written "ds_a" */
- if((did = H5Dopen2(fid,"ds_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "ds_a", H5P_DEFAULT)) < 0)
goto out;
/* try to attach "ds_a" to "ds_b", not valid */
- if(H5DSattach_scale(dsid,did,0)==SUCCEED)
+ if (H5DSattach_scale(dsid, did, 0) == SUCCEED)
goto out;
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * try to attach a scale to an image, pallete or table
- *-------------------------------------------------------------------------
- */
+ * try to attach a scale to an image, pallete or table
+ *-------------------------------------------------------------------------
+ */
- TESTING2("attach to a dataset that is a reserved class dataset");
+ HL_TESTING2("attach to a dataset that is a reserved class dataset");
/* make an image */
- if(H5IMmake_image_8bit(fid,"image",(hsize_t)100,(hsize_t)50,NULL) < 0)
+ if (H5IMmake_image_8bit(fid, "image", (hsize_t)100, (hsize_t)50, NULL) < 0)
goto out;
/* make a palette */
- if(H5IMmake_palette(fid,"pallete",pal_dims,NULL) < 0)
+ if (H5IMmake_palette(fid, "pallete", pal_dims, NULL) < 0)
goto out;
/* open the previous written "ds_b" */
- if((dsid = H5Dopen2(fid,"ds_b", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_b", H5P_DEFAULT)) < 0)
goto out;
/* open the image dataset */
- if((did = H5Dopen2(fid,"image", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "image", H5P_DEFAULT)) < 0)
goto out;
/* try to attach "ds_a" to the image, not valid */
- if(H5DSattach_scale(did,dsid,0)==SUCCEED)
+ if (H5DSattach_scale(did, dsid, 0) == SUCCEED)
goto out;
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * is scale
- *-------------------------------------------------------------------------
- */
+ * is scale
+ *-------------------------------------------------------------------------
+ */
- TESTING2("is scale");
+ HL_TESTING2("is scale");
/* open a non scale dataset */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* verify that it is not a dimension scale dataset */
- if((H5DSis_scale(did))==1)
+ if ((H5DSis_scale(did)) == 1)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/* open the group. */
- if((gid = H5Gopen2(fid, "grp", H5P_DEFAULT)) < 0)
+ if ((gid = H5Gopen2(fid, "grp", H5P_DEFAULT)) < 0)
goto out;
/* verify that it is not a dimension scale dataset */
- if((H5DSis_scale(gid))==1)
+ if ((H5DSis_scale(gid)) == 1)
goto out;
/* close */
- if(H5Gclose(gid) < 0)
+ if (H5Gclose(gid) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * detach
- *-------------------------------------------------------------------------
- */
+ * detach
+ *-------------------------------------------------------------------------
+ */
- TESTING2("detach scale from dataset it is not attached to");
+ HL_TESTING2("detach scale from dataset it is not attached to");
/* open the previous written "ds_a" */
- if((dsid = H5Dopen2(fid,"ds_a", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a", H5P_DEFAULT)) < 0)
goto out;
/* open the previous written "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* try to detach "ds_a" from "dset_a" */
- if(H5DSdetach_scale(did,dsid,0)==SUCCEED)
+ if (H5DSdetach_scale(did, dsid, 0) == SUCCEED)
goto out;
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * detach
- *-------------------------------------------------------------------------
- */
+ * detach
+ *-------------------------------------------------------------------------
+ */
- TESTING2("detach scale from group");
+ HL_TESTING2("detach scale from group");
/* open the previous written "ds_a" */
- if((dsid = H5Dopen2(fid,"ds_a", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a", H5P_DEFAULT)) < 0)
goto out;
/* open the group. */
- if((gid = H5Gopen2(fid, "grp", H5P_DEFAULT)) < 0)
+ if ((gid = H5Gopen2(fid, "grp", H5P_DEFAULT)) < 0)
goto out;
/* try to detach "ds_a" from "grp" */
- if(H5DSdetach_scale(gid,dsid,0)==SUCCEED)
+ if (H5DSdetach_scale(gid, dsid, 0) == SUCCEED)
goto out;
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Gclose(gid) < 0)
+ if (H5Gclose(gid) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * detach
- *-------------------------------------------------------------------------
- */
+ * detach
+ *-------------------------------------------------------------------------
+ */
- TESTING2("detach scale when scale is group");
+ HL_TESTING2("detach scale when scale is group");
/* open the previous written "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* open the group. */
- if((gid = H5Gopen2(fid, "grp", H5P_DEFAULT)) < 0)
+ if ((gid = H5Gopen2(fid, "grp", H5P_DEFAULT)) < 0)
goto out;
/* try to detach "grp" from "dset_a" */
- if(H5DSdetach_scale(did,gid,0)==SUCCEED)
+ if (H5DSdetach_scale(did, gid, 0) == SUCCEED)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- if(H5Gclose(gid) < 0)
+ if (H5Gclose(gid) < 0)
goto out;
PASSED();
-
/* close */
- if(H5Fclose(fid) < 0)
+ if (H5Fclose(fid) < 0)
goto out;
return 0;
@@ -4095,183 +4182,180 @@ out:
H5Dclose(dsid);
H5Gclose(gid);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-
-
/*-------------------------------------------------------------------------
* test iterators
*-------------------------------------------------------------------------
*/
-static int test_iterators(void)
+static int
+test_iterators(void)
{
- hid_t fid; /* file ID */
- int rank = RANK; /* rank of data dataset */
- int rankds = 1; /* rank of DS dataset */
- hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */
- hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */
- hid_t gid = -1; /* group ID */
- hid_t did = -1; /* dataset ID */
- hid_t dsid = -1; /* scale ID */
- char dname[30]; /* dataset name */
+ hid_t fid; /* file ID */
+ int rank = RANK; /* rank of data dataset */
+ int rankds = 1; /* rank of DS dataset */
+ hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE}; /* size of data dataset */
+ hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */
+ hid_t gid = -1; /* group ID */
+ hid_t did = -1; /* dataset ID */
+ hid_t dsid = -1; /* scale ID */
+ char dname[30]; /* dataset name */
int i;
- printf("Testing iterators\n");
+ HDprintf("Testing iterators\n");
/*-------------------------------------------------------------------------
- * create a file, spaces, dataset and group ids
- *-------------------------------------------------------------------------
- */
+ * create a file, spaces, dataset and group ids
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- if((fid=H5Fcreate(FILE3,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate(FILE3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* create a group */
- if((gid = H5Gcreate2(fid, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((gid = H5Gcreate2(fid, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* close */
- if(H5Gclose(gid) < 0)
+ if (H5Gclose(gid) < 0)
goto out;
/* make a dataset */
- if(H5LTmake_dataset_int(fid,"dset_a",rank,dims,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "dset_a", rank, dims, NULL) < 0)
goto out;
/* make a DS dataset */
- if(H5LTmake_dataset_int(fid,"ds_a",rankds,s1_dim,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a", rankds, s1_dim, NULL) < 0)
goto out;
/*-------------------------------------------------------------------------
- * iterate when the dataset has no scales
- *-------------------------------------------------------------------------
- */
+ * iterate when the dataset has no scales
+ *-------------------------------------------------------------------------
+ */
- TESTING2("iterate when the dataset has no scales ");
+ HL_TESTING2("iterate when the dataset has no scales ");
/* get the dataset id for "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* try to iterate trough the 1st dimension of "dset_a", return error */
- if(H5DSiterate_scales(did,0,NULL,verify_scale,NULL) < 0)
+ if (H5DSiterate_scales(did, 0, NULL, verify_scale, NULL) < 0)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * iterate on dimension that is outside the rank
- *-------------------------------------------------------------------------
- */
+ * iterate on dimension that is outside the rank
+ *-------------------------------------------------------------------------
+ */
- TESTING2("iterate on dimension that is outside the rank ");
+ HL_TESTING2("iterate on dimension that is outside the rank ");
/* get the dataset id for "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* try to iterate trough the 3rd dimension of "dset_a", return error */
- if(H5DSiterate_scales(did,3,NULL,verify_scale,NULL)==SUCCEED)
+ if (H5DSiterate_scales(did, 3, NULL, verify_scale, NULL) == SUCCEED)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * iterate for dimension with many scales
- *-------------------------------------------------------------------------
- */
+ * iterate for dimension with many scales
+ *-------------------------------------------------------------------------
+ */
- TESTING2("iterate for dimension with many scales ");
+ HL_TESTING2("iterate for dimension with many scales ");
/* open the previously written "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
- for(i=0; i<100; i++) {
+ for (i = 0; i < 100; i++) {
/* make a DS */
- sprintf(dname,"ds_%d",i);
- if(H5LTmake_dataset_int(fid,dname,rankds,s1_dim,NULL) < 0)
+ HDsprintf(dname, "ds_%d", i);
+ if (H5LTmake_dataset_int(fid, dname, rankds, s1_dim, NULL) < 0)
goto out;
/* open */
- if((dsid = H5Dopen2(fid,dname, H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
goto out;
/* attach */
- if(H5DSattach_scale(did,dsid,0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
}
/* iterate trough the 1st dimension of "dset_a" */
- if(H5DSiterate_scales(did,0,NULL,op_continue,NULL) < 0)
+ if (H5DSiterate_scales(did, 0, NULL, op_continue, NULL) < 0)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * iterate on group
- *-------------------------------------------------------------------------
- */
+ * iterate on group
+ *-------------------------------------------------------------------------
+ */
- TESTING2("iterate on group ");
+ HL_TESTING2("iterate on group ");
/* open */
- if((gid = H5Gopen2(fid, "grp", H5P_DEFAULT)) < 0)
+ if ((gid = H5Gopen2(fid, "grp", H5P_DEFAULT)) < 0)
goto out;
/* try to iterate, return error */
- if(H5DSiterate_scales(gid,0,NULL,verify_scale,NULL)==SUCCEED)
+ if (H5DSiterate_scales(gid, 0, NULL, verify_scale, NULL) == SUCCEED)
goto out;
/* close */
- if(H5Gclose(gid) < 0)
+ if (H5Gclose(gid) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * iterate in deleted scales
- *-------------------------------------------------------------------------
- */
+ * iterate in deleted scales
+ *-------------------------------------------------------------------------
+ */
- TESTING2("iterate in deleted scales ");
+ HL_TESTING2("iterate in deleted scales ");
- if(H5Ldelete(fid, "ds_0", H5P_DEFAULT) < 0)
+ if (H5Ldelete(fid, "ds_0", H5P_DEFAULT) < 0)
goto out;
/* open the previously written "dset_a" */
- if((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* iterate */
- if(H5DSiterate_scales(did, 0, NULL, op_continue, NULL) == SUCCEED)
+ if (H5DSiterate_scales(did, 0, NULL, op_continue, NULL) == SUCCEED)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
-
/* close */
- if(H5Fclose(fid) < 0)
+ if (H5Fclose(fid) < 0)
goto out;
return 0;
@@ -4283,201 +4367,202 @@ out:
H5Gclose(gid);
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-
/*-------------------------------------------------------------------------
* test several ranks
*-------------------------------------------------------------------------
*/
-static int test_rank(void)
+static int
+test_rank(void)
{
- hid_t fid; /* file ID */
- hid_t did = -1; /* dataset ID */
- hid_t dsid = -1; /* scale ID */
- hid_t sid = -1; /* space ID */
- hid_t sidds = -1; /* space ID */
- hsize_t dims1[1] = {DIM1_SIZE}; /* size of data dataset */
- hsize_t dims2[2] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */
- hsize_t dims3[3] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE}; /* size of data dataset */
- hsize_t dimss[2] = {1,1}; /* size of data dataset */
- char name[30]; /* dataset name buffer */
- char names[30]; /* dataset scale name buffer */
- char namel[30]; /* dataset label name buffer */
- int bufi[1]={2};
- float buff[1]={1};
+ hid_t fid; /* file ID */
+ hid_t did = -1; /* dataset ID */
+ hid_t dsid = -1; /* scale ID */
+ hid_t sid = -1; /* space ID */
+ hid_t sidds = -1; /* space ID */
+ hsize_t dims1[1] = {DIM1_SIZE}; /* size of data dataset */
+ hsize_t dims2[2] = {DIM1_SIZE, DIM2_SIZE}; /* size of data dataset */
+ hsize_t dims3[3] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE}; /* size of data dataset */
+ hsize_t dimss[2] = {1, 1}; /* size of data dataset */
+ char name[30]; /* dataset name buffer */
+ char names[30]; /* dataset scale name buffer */
+ char namel[30]; /* dataset label name buffer */
+ int bufi[1] = {2};
+ float buff[1] = {1};
int i;
- printf("Testing ranks\n");
+ HDprintf("Testing ranks\n");
/*-------------------------------------------------------------------------
- * create a file, a dataset, scales
- *-------------------------------------------------------------------------
- */
+ * create a file, a dataset, scales
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- if((fid=H5Fcreate(FILE4,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate(FILE4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* make a dataset a 3D data dataset */
- if(H5LTmake_dataset_int(fid,"dset_a",3,dims3,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "dset_a", 3, dims3, NULL) < 0)
goto out;
/* make a 1D scale dataset */
- if(H5LTmake_dataset_int(fid,"ds_a_0",1,dims1,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a_0", 1, dims1, NULL) < 0)
goto out;
/* make a 2D scale dataset */
- if(H5LTmake_dataset_int(fid,"ds_a_1",2,dims2,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a_1", 2, dims2, NULL) < 0)
goto out;
/* make a 3D scale dataset */
- if(H5LTmake_dataset_int(fid,"ds_a_2",3,dims3,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a_2", 3, dims3, NULL) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach
- *-------------------------------------------------------------------------
- */
+ * attach
+ *-------------------------------------------------------------------------
+ */
- TESTING2("attach");
+ HL_TESTING2("attach");
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
- for(i=0; i<3; i++) {
- sprintf(name,"ds_a_%d",i);
- if((dsid = H5Dopen2(fid,name, H5P_DEFAULT)) < 0)
+ for (i = 0; i < 3; i++) {
+ HDsprintf(name, "ds_a_%d", i);
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did,dsid,(unsigned)i) < 0)
+ if (H5DSattach_scale(did, dsid, (unsigned)i) < 0)
goto out;
- if(H5DSis_attached(did,dsid,(unsigned)i)<=0)
+ if (H5DSis_attached(did, dsid, (unsigned)i) <= 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * detach
- *-------------------------------------------------------------------------
- */
+ * detach
+ *-------------------------------------------------------------------------
+ */
- TESTING2("detach");
+ HL_TESTING2("detach");
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
- for(i=0; i<3; i++) {
- sprintf(name,"ds_a_%d",i);
- if((dsid = H5Dopen2(fid,name, H5P_DEFAULT)) < 0)
+ for (i = 0; i < 3; i++) {
+ HDsprintf(name, "ds_a_%d", i);
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
goto out;
- if(H5DSdetach_scale(did,dsid,(unsigned)i) < 0)
+ if (H5DSdetach_scale(did, dsid, (unsigned)i) < 0)
goto out;
- if(H5DSis_attached(did,dsid,(unsigned)i)!=0)
+ if (H5DSis_attached(did, dsid, (unsigned)i) != 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * attach, set, get names, labels
- *-------------------------------------------------------------------------
- */
+ * attach, set, get names, labels
+ *-------------------------------------------------------------------------
+ */
- TESTING2("attach, set, get names, labels");
+ HL_TESTING2("attach, set, get names, labels");
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
- for(i=0; i<3; i++) {
- sprintf(name,"ds_a_%d",i);
- if((dsid = H5Dopen2(fid,name, H5P_DEFAULT)) < 0)
+ for (i = 0; i < 3; i++) {
+ HDsprintf(name, "ds_a_%d", i);
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
goto out;
- if(H5DSset_scale(dsid,name) < 0)
+ if (H5DSset_scale(dsid, name) < 0)
goto out;
- if(H5DSattach_scale(did,dsid,(unsigned)i) < 0)
+ if (H5DSattach_scale(did, dsid, (unsigned)i) < 0)
goto out;
- if(H5DSis_attached(did,dsid,(unsigned)i)<=0)
+ if (H5DSis_attached(did, dsid, (unsigned)i) <= 0)
goto out;
- if(H5DSget_scale_name(dsid,names,sizeof(names)) < 0)
+ if (H5DSget_scale_name(dsid, names, sizeof(names)) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5DSset_label(did,(unsigned)i,name) < 0)
+ if (H5DSset_label(did, (unsigned)i, name) < 0)
goto out;
- if(H5DSget_label(did,(unsigned)i,namel,sizeof(namel)) < 0)
+ if (H5DSget_label(did, (unsigned)i, namel, sizeof(namel)) < 0)
goto out;
- if(HDstrncmp(name, names, sizeof(names))!=0)
+ if (HDstrncmp(name, names, sizeof(names)) != 0)
goto out;
- if(HDstrncmp(name, namel, sizeof(namel))!=0)
+ if (HDstrncmp(name, namel, sizeof(namel)) != 0)
goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * attach a scalar scale
- *-------------------------------------------------------------------------
- */
+ * attach a scalar scale
+ *-------------------------------------------------------------------------
+ */
- TESTING2("attach a scalar scale");
+ HL_TESTING2("attach a scalar scale");
/* create the data space for the dataset */
- if((sid = H5Screate_simple(2, dimss, NULL)) < 0)
+ if ((sid = H5Screate_simple(2, dimss, NULL)) < 0)
goto out;
/* create a dataset of rank 2 */
- if((did = H5Dcreate2(fid, "dset_b", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((did = H5Dcreate2(fid, "dset_b", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* create a scalar space */
- if((sidds = H5Screate(H5S_SCALAR)) < 0)
+ if ((sidds = H5Screate(H5S_SCALAR)) < 0)
goto out;
/* create a dataset of scalar rank for the scale */
- if((dsid = H5Dcreate2(fid, "ds_b_1", H5T_NATIVE_FLOAT, sidds, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dcreate2(fid, "ds_b_1", H5T_NATIVE_FLOAT, sidds, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) <
+ 0)
goto out;
/* write */
- if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, bufi) < 0)
+ if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, bufi) < 0)
goto out;
- if(H5Dwrite(dsid, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buff) < 0)
+ if (H5Dwrite(dsid, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buff) < 0)
goto out;
/* attach */
- if(H5DSattach_scale(did, dsid, 0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
- if(H5DSattach_scale(did, dsid, 1) < 0)
+ if (H5DSattach_scale(did, dsid, 1) < 0)
goto out;
/* close */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Sclose(sidds) < 0)
+ if (H5Sclose(sidds) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if(H5Fclose(fid) < 0)
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Fclose(fid) < 0)
goto out;
return 0;
@@ -4491,173 +4576,174 @@ out:
H5Sclose(sidds);
H5Sclose(sid);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-
/*-------------------------------------------------------------------------
* attach scales with several datatypes
*-------------------------------------------------------------------------
*/
-static int test_types(void)
+static int
+test_types(void)
{
- hid_t fid; /* file ID */
- hid_t did = -1; /* dataset ID */
- hid_t dsid = -1; /* DS dataset ID */
- int rank = RANK; /* rank of data dataset */
- int rankds = 1; /* rank of DS dataset */
- hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */
- int buf[DIM_DATA] = {1,2,3,4,5,6,7,8,9,10,11,12}; /* data of data dataset */
- hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */
- hsize_t s2_dim[1] = {DIM2_SIZE}; /* size of DS 2 dataset */
- float s1_float[DIM1_SIZE] = {10,20,30}; /* data of DS 1 dataset */
- unsigned short s2_ushort[DIM2_SIZE] = {10,20,30,40}; /* data of DS 2 dataset */
- const char *s1_str = "ABC";
- const char *s2_str = "ABCD";
-
- printf("Testing scales with several datatypes\n");
+ hid_t fid; /* file ID */
+ hid_t did = -1; /* dataset ID */
+ hid_t dsid = -1; /* DS dataset ID */
+ int rank = RANK; /* rank of data dataset */
+ int rankds = 1; /* rank of DS dataset */
+ hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE}; /* size of data dataset */
+ int buf[DIM_DATA] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; /* data of data dataset */
+ hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */
+ hsize_t s2_dim[1] = {DIM2_SIZE}; /* size of DS 2 dataset */
+ float s1_float[DIM1_SIZE] = {10, 20, 30}; /* data of DS 1 dataset */
+ unsigned short s2_ushort[DIM2_SIZE] = {10, 20, 30, 40}; /* data of DS 2 dataset */
+ const char * s1_str = "ABC";
+ const char * s2_str = "ABCD";
+
+ HDprintf("Testing scales with several datatypes\n");
/*-------------------------------------------------------------------------
- * create a file for the test
- *-------------------------------------------------------------------------
- */
+ * create a file for the test
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- if((fid=H5Fcreate(FILE5,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate(FILE5, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/*-------------------------------------------------------------------------
- * create datasets: 1 "data" dataset and 2 dimension scales
- *-------------------------------------------------------------------------
- */
+ * create datasets: 1 "data" dataset and 2 dimension scales
+ *-------------------------------------------------------------------------
+ */
/* make a dataset */
- if(H5LTmake_dataset_int(fid,"dset_a",rank,dims,buf) < 0)
+ if (H5LTmake_dataset_int(fid, "dset_a", rank, dims, buf) < 0)
goto out;
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_float(fid,DS_1_NAME,rankds,s1_dim,s1_float) < 0)
+ if (H5LTmake_dataset_float(fid, DS_1_NAME, rankds, s1_dim, s1_float) < 0)
goto out;
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset(fid,DS_2_NAME,rankds,s2_dim,H5T_NATIVE_USHORT,s2_ushort) < 0)
+ if (H5LTmake_dataset(fid, DS_2_NAME, rankds, s2_dim, H5T_NATIVE_USHORT, s2_ushort) < 0)
goto out;
/*-------------------------------------------------------------------------
- * floating point and short scales
- *-------------------------------------------------------------------------
- */
+ * floating point and short scales
+ *-------------------------------------------------------------------------
+ */
- TESTING2("floating point and short scales");
+ HL_TESTING2("floating point and short scales");
/* get the dataset id for "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,DS_1_NAME, H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, DS_1_NAME, H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_1_NAME dimension scale to "dset_a" at dimension 0 */
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
/* set name */
- if(H5DSset_scale(dsid,SCALE_1_NAME) < 0)
+ if (H5DSset_scale(dsid, SCALE_1_NAME) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,DS_2_NAME, H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, DS_2_NAME, H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_2_NAME dimension scale to "dset_a" at dimension 1 */
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
/* set name */
- if(H5DSset_scale(dsid,SCALE_2_NAME) < 0)
+ if (H5DSset_scale(dsid, SCALE_2_NAME) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* set a label */
- if(H5DSset_label(did,DIM0,DIM0_LABEL) < 0)
+ if (H5DSset_label(did, DIM0, DIM0_LABEL) < 0)
goto out;
- if(H5DSset_label(did,DIM1,DIM1_LABEL) < 0)
+ if (H5DSset_label(did, DIM1, DIM1_LABEL) < 0)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * create datasets: 1 "data" dataset and 2 dimension scales
- *-------------------------------------------------------------------------
- */
+ * create datasets: 1 "data" dataset and 2 dimension scales
+ *-------------------------------------------------------------------------
+ */
/* make a dataset */
- if(H5LTmake_dataset_int(fid,"dset_b",rank,dims,buf) < 0)
+ if (H5LTmake_dataset_int(fid, "dset_b", rank, dims, buf) < 0)
goto out;
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_string(fid,"ds_b_1",s1_str) < 0)
+ if (H5LTmake_dataset_string(fid, "ds_b_1", s1_str) < 0)
goto out;
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_string(fid,"ds_b_2",s2_str) < 0)
+ if (H5LTmake_dataset_string(fid, "ds_b_2", s2_str) < 0)
goto out;
/*-------------------------------------------------------------------------
- * floating point and short scales
- *-------------------------------------------------------------------------
- */
+ * floating point and short scales
+ *-------------------------------------------------------------------------
+ */
- TESTING2("string scales");
+ HL_TESTING2("string scales");
/* get the dataset id for "dset_b" */
- if((did = H5Dopen2(fid,"dset_b", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_b", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_b_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_b_1", H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_1_NAME dimension scale to "dset_b" at dimension 0 */
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
/* set name */
- if(H5DSset_scale(dsid,SCALE_1_NAME) < 0)
+ if (H5DSset_scale(dsid, SCALE_1_NAME) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_b_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_b_2", H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_2_NAME dimension scale to "dset_b" at dimension 1 */
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
/* set name */
- if(H5DSset_scale(dsid,SCALE_2_NAME) < 0)
+ if (H5DSset_scale(dsid, SCALE_2_NAME) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* set a label */
- if(H5DSset_label(did,DIM0,DIM0_LABEL) < 0)
+ if (H5DSset_label(did, DIM0, DIM0_LABEL) < 0)
goto out;
- if(H5DSset_label(did,DIM1,DIM1_LABEL) < 0)
+ if (H5DSset_label(did, DIM1, DIM1_LABEL) < 0)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if(H5Fclose(fid) < 0)
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Fclose(fid) < 0)
goto out;
return 0;
@@ -4669,7 +4755,8 @@ out:
H5Dclose(did);
H5Dclose(dsid);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
@@ -4679,144 +4766,142 @@ out:
*-------------------------------------------------------------------------
*/
-static int test_data(void)
+static int
+test_data(void)
{
- hid_t fid; /* file ID */
- hid_t did = -1; /* dataset ID */
- hid_t dsid = -1; /* DS dataset ID */
- hid_t dcpl; /* dataset creation property list */
- hid_t sid; /* dataspace ID */
- float *vals=NULL; /* array to hold data values */
- float *latbuf=NULL; /* array to hold the latitude values */
- float *lonbuf=NULL; /* array to hold the longitude values */
- hsize_t dims[2]; /* array to hold dimensions */
- hsize_t latdims[1]; /* array to hold dimensions */
- hsize_t londims[1]; /* array to hold dimensions */
- float fill=-99; /* fill value */
-
-
- printf("Testing reading ASCII data and generate HDF5 data with scales\n");
+ hid_t fid; /* file ID */
+ hid_t did = -1; /* dataset ID */
+ hid_t dsid = -1; /* DS dataset ID */
+ hid_t dcpl; /* dataset creation property list */
+ hid_t sid; /* dataspace ID */
+ float * vals = NULL; /* array to hold data values */
+ float * latbuf = NULL; /* array to hold the latitude values */
+ float * lonbuf = NULL; /* array to hold the longitude values */
+ hsize_t dims[2]; /* array to hold dimensions */
+ hsize_t latdims[1]; /* array to hold dimensions */
+ hsize_t londims[1]; /* array to hold dimensions */
+ float fill = -99; /* fill value */
+
+ HDprintf("Testing reading ASCII data and generate HDF5 data with scales\n");
/*-------------------------------------------------------------------------
- * create a file for the test
- *-------------------------------------------------------------------------
- */
+ * create a file for the test
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- if((fid=H5Fcreate(FILE6,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate(FILE6, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/*-------------------------------------------------------------------------
- * generating scales
- *-------------------------------------------------------------------------
- */
+ * generating scales
+ *-------------------------------------------------------------------------
+ */
- TESTING2("generating scales");
+ HL_TESTING2("generating scales");
/*-------------------------------------------------------------------------
- * create datasets: 1 "data" dataset and 2 dimension scales
- *-------------------------------------------------------------------------
- */
+ * create datasets: 1 "data" dataset and 2 dimension scales
+ *-------------------------------------------------------------------------
+ */
/* read the latitude */
- if(read_data("dslat.txt",1,latdims,&latbuf) < 0)
+ if (read_data("dslat.txt", 1, latdims, &latbuf) < 0)
goto out;
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_float(fid, "lat", 1, latdims, latbuf) < 0)
+ if (H5LTmake_dataset_float(fid, "lat", 1, latdims, latbuf) < 0)
goto out;
- HDfree( latbuf );
+ HDfree(latbuf);
latbuf = NULL;
- /* read the longitude */
- if(read_data("dslon.txt",1,londims,&lonbuf) < 0)
+ /* read the longitude */
+ if (read_data("dslon.txt", 1, londims, &lonbuf) < 0)
goto out;
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_float(fid, "lon", 1, londims, lonbuf) < 0)
+ if (H5LTmake_dataset_float(fid, "lon", 1, londims, lonbuf) < 0)
goto out;
- HDfree( lonbuf );
+ HDfree(lonbuf);
lonbuf = NULL;
/* make a dataset for the data. a fill value is set */
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto out;
- if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fill) < 0)
+ if (H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fill) < 0)
goto out;
/* read ASCII bathymetry data and dimensions to create dataset */
- if(read_data("dsdata.txt",2,dims,&vals) < 0)
+ if (read_data("dsdata.txt", 2, dims, &vals) < 0)
goto out;
- if((sid = H5Screate_simple(2, dims, NULL)) < 0)
+ if ((sid = H5Screate_simple(2, dims, NULL)) < 0)
goto out;
- if((did = H5Dcreate2(fid, "data", H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ if ((did = H5Dcreate2(fid, "data", H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
goto out;
- if(H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, vals) < 0)
+ if (H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, vals) < 0)
goto out;
- HDfree ( vals );
+ HDfree(vals);
vals = NULL;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- if(H5Pclose(dcpl) < 0)
+ if (H5Pclose(dcpl) < 0)
goto out;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach
- *-------------------------------------------------------------------------
- */
+ * attach
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "data" */
- if((did = H5Dopen2(fid,"data", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "data", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"lat", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "lat", H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_1_NAME dimension scale to "data" at dimension 0 */
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
/* set name */
- if(H5DSset_scale(dsid,SCALE_1_NAME) < 0)
+ if (H5DSset_scale(dsid, SCALE_1_NAME) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"lon", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "lon", H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_2_NAME dimension scale to "data" at dimension 1 */
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
/* set name */
- if(H5DSset_scale(dsid,SCALE_2_NAME) < 0)
+ if (H5DSset_scale(dsid, SCALE_2_NAME) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* set a label */
- if(H5DSset_label(did,DIM0,DIM0_LABEL) < 0)
+ if (H5DSset_label(did, DIM0, DIM0_LABEL) < 0)
goto out;
- if(H5DSset_label(did,DIM1,DIM1_LABEL) < 0)
+ if (H5DSset_label(did, DIM1, DIM1_LABEL) < 0)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
-
-
/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if(H5Fclose(fid) < 0)
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Fclose(fid) < 0)
goto out;
return 0;
@@ -4828,20 +4913,19 @@ out:
H5Dclose(did);
H5Dclose(dsid);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
if (latbuf)
- HDfree( latbuf );
+ HDfree(latbuf);
if (lonbuf)
- HDfree( lonbuf );
+ HDfree(lonbuf);
if (vals)
- HDfree( vals );
+ HDfree(vals);
return FAIL;
}
-
-
/*-------------------------------------------------------------------------
* read_data
* utility function to read ASCII data
@@ -4855,119 +4939,116 @@ out:
*-------------------------------------------------------------------------
*/
-static int read_data( const char* fname,
- int ndims,
- hsize_t *dims,
- float **buf )
+static int
+read_data(const char *fname, int ndims, hsize_t *dims, float **buf)
{
- int i, n;
- unsigned j;
- char str[20];
- size_t nelms;
- FILE *f;
- float val;
- char *srcdir = getenv("srcdir"); /* the source directory */
- char data_file[512]; /* buffer to hold name of existing data file */
-
- HDstrcpy(data_file, "");
- /* compose the name of the file to open, using the srcdir, if appropriate */
- if(srcdir)
- {
- HDstrcpy(data_file, srcdir);
- HDstrcat(data_file, "/");
- }
- /* read first data file */
- HDstrcat(data_file,fname);
+ int i, n;
+ unsigned j;
+ char str[20];
+ size_t nelms;
+ FILE * f;
+ float val;
+ const char *data_file = H5_get_srcdir_filename(fname);
+ /* read first data file */
f = HDfopen(data_file, "r");
- if( f == NULL ) {
- printf( "Could not open file %s\n", data_file );
+ if (f == NULL) {
+ HDprintf("Could not open file %s\n", data_file);
return -1;
}
- for(i=0, nelms=1; i < ndims; i++) {
- fscanf( f, "%s %u", str, &j);
- fscanf( f, "%d",&n );
+ for (i = 0, nelms = 1; i < ndims; i++) {
+ if (fscanf(f, "%s %u", str, &j) && HDferror(f)) {
+ HDprintf("fscanf error in file %s\n", data_file);
+ HDfclose(f);
+ return -1;
+ } /* end if */
+ if (fscanf(f, "%d", &n) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s\n", data_file);
+ HDfclose(f);
+ return -1;
+ } /* end if */
dims[i] = (hsize_t)n;
nelms *= (size_t)n;
}
- *buf = (float*) HDmalloc (nelms * sizeof( float ));
+ *buf = (float *)HDmalloc(nelms * sizeof(float));
- if ( *buf == NULL ) {
- printf( "memory allocation failed\n" );
+ if (*buf == NULL) {
+ HDprintf("memory allocation failed\n");
HDfclose(f);
return -1;
}
- for(j = 0; j < nelms; j++) {
- fscanf( f, "%f",&val );
+ for (j = 0; j < nelms; j++) {
+ if (fscanf(f, "%f", &val) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s\n", data_file);
+ HDfclose(f);
+ return -1;
+ } /* end if */
(*buf)[j] = val;
}
HDfclose(f);
return 1;
-
}
-
/*-------------------------------------------------------------------------
* test parameter errors
*-------------------------------------------------------------------------
*/
-static int test_errors2(void)
+static int
+test_errors2(void)
{
- hid_t fid; /* file ID */
- hid_t did = -1; /* dataset ID */
- hid_t dsid = -1; /* scale ID */
- hsize_t dimd[2] = {3,3}; /* size of data dataset */
- hsize_t dims[1] = {3}; /* size of scale dataset */
- char lbuf[255]; /* label buffer */
- ssize_t label_len; /* label lenght */
- int scale_idx; /* scale index */
- int nscales; /* number of scales in DIM */
- int count; /* visitor data */
-
- printf("Testing parameter errors\n");
+ hid_t fid; /* file ID */
+ hid_t did = -1; /* dataset ID */
+ hid_t dsid = -1; /* scale ID */
+ hsize_t dimd[2] = {3, 3}; /* size of data dataset */
+ hsize_t dims[1] = {3}; /* size of scale dataset */
+ char lbuf[255]; /* label buffer */
+ ssize_t label_len; /* label length */
+ int scale_idx; /* scale index */
+ int nscales; /* number of scales in DIM */
+ int count; /* visitor data */
+
+ HDprintf("Testing parameter errors\n");
/*-------------------------------------------------------------------------
- * create a file, a dataset, scales
- *-------------------------------------------------------------------------
- */
+ * create a file, a dataset, scales
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- if ((fid=H5Fcreate(FILE7,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate(FILE7, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* make a dataset */
- if (H5LTmake_dataset_int(fid,"dset",2,dimd,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "dset", 2, dimd, NULL) < 0)
goto out;
/* make a scale dataset */
- if(H5LTmake_dataset_int(fid,"ds1",1,dims,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds1", 1, dims, NULL) < 0)
goto out;
/* make a scale dataset */
- if(H5LTmake_dataset_int(fid,"ds2",1,dims,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds2", 1, dims, NULL) < 0)
goto out;
-
- TESTING2("attach scales");
-
+ HL_TESTING2("attach scales");
/*-------------------------------------------------------------------------
- * attach with invalid indices
- *-------------------------------------------------------------------------
- */
+ * attach with invalid indices
+ *-------------------------------------------------------------------------
+ */
- if ((did = H5Dopen2(fid,"dset", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0)
goto out;
- if ((dsid = H5Dopen2(fid,"ds1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds1", H5P_DEFAULT)) < 0)
goto out;
- if (H5DSattach_scale(did,dsid,2) == SUCCEED)
+ if (H5DSattach_scale(did, dsid, 2) == SUCCEED)
goto out;
- if (H5DSattach_scale(did,dsid,0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
if (H5Dclose(dsid) < 0)
goto out;
@@ -4976,19 +5057,19 @@ static int test_errors2(void)
PASSED();
- TESTING2("detach scales");
+ HL_TESTING2("detach scales");
/*-------------------------------------------------------------------------
- * detach with invalid indices
- *-------------------------------------------------------------------------
- */
- if ((did = H5Dopen2(fid,"dset", H5P_DEFAULT)) < 0)
+ * detach with invalid indices
+ *-------------------------------------------------------------------------
+ */
+ if ((did = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0)
goto out;
- if ((dsid = H5Dopen2(fid,"ds1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds1", H5P_DEFAULT)) < 0)
goto out;
- if (H5DSdetach_scale(did,dsid,2) == SUCCEED)
+ if (H5DSdetach_scale(did, dsid, 2) == SUCCEED)
goto out;
- if (H5DSdetach_scale(did,dsid,0) < 0)
+ if (H5DSdetach_scale(did, dsid, 0) < 0)
goto out;
if (H5Dclose(dsid) < 0)
goto out;
@@ -4997,97 +5078,95 @@ static int test_errors2(void)
PASSED();
- TESTING2("set/get label");
+ HL_TESTING2("set/get label");
/*-------------------------------------------------------------------------
- * set/get label invalid indices
- *-------------------------------------------------------------------------
- */
- if ((did = H5Dopen2(fid,"dset", H5P_DEFAULT)) < 0)
+ * set/get label invalid indices
+ *-------------------------------------------------------------------------
+ */
+ if ((did = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0)
goto out;
- if (H5DSset_label(did,2,"label")== SUCCEED)
+ if (H5DSset_label(did, 2, "label") == SUCCEED)
goto out;
- if (H5DSset_label(did,0,"label") < 0)
+ if (H5DSset_label(did, 0, "label") < 0)
goto out;
- if (H5DSget_label(did,2,lbuf,sizeof(lbuf)) == SUCCEED)
+ if (H5DSget_label(did, 2, lbuf, sizeof(lbuf)) == SUCCEED)
goto out;
- if ((label_len=H5DSget_label(did,0,NULL,0)) < 0)
+ if ((label_len = H5DSget_label(did, 0, NULL, 0)) < 0)
goto out;
- if ( label_len != strlen("label") )
+ if (label_len != HDstrlen("label"))
goto out;
- if (H5DSget_label(did,0,lbuf,sizeof(lbuf)) < 0)
+ if (H5DSget_label(did, 0, lbuf, sizeof(lbuf)) < 0)
goto out;
if (H5Dclose(did) < 0)
goto out;
PASSED();
- TESTING2("iterate scales");
-
+ HL_TESTING2("iterate scales");
/*-------------------------------------------------------------------------
- * iterate_scales invalid indices and return DS_IDX and visitor data
- *-------------------------------------------------------------------------
- */
- if ((did = H5Dopen2(fid,"dset", H5P_DEFAULT)) < 0)
+ * iterate_scales invalid indices and return DS_IDX and visitor data
+ *-------------------------------------------------------------------------
+ */
+ if ((did = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0)
goto out;
- if ((dsid = H5Dopen2(fid,"ds1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds1", H5P_DEFAULT)) < 0)
goto out;
- if (H5DSattach_scale(did,dsid,0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
if (H5Dclose(dsid) < 0)
goto out;
- if ((dsid = H5Dopen2(fid,"ds2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds2", H5P_DEFAULT)) < 0)
goto out;
- if (H5DSattach_scale(did,dsid,0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
if (H5Dclose(dsid) < 0)
goto out;
- if((nscales = H5DSget_num_scales(did,0)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 0)) < 0)
goto out;
- if(nscales!=2)
+ if (nscales != 2)
goto out;
/* invalid DIM */
- if (H5DSiterate_scales(did,2,NULL,op_continue,NULL)== SUCCEED)
+ if (H5DSiterate_scales(did, 2, NULL, op_continue, NULL) == SUCCEED)
goto out;
/* invalid DS_IDX */
scale_idx = 2;
- if (H5DSiterate_scales(did,0,&scale_idx,op_continue,NULL)== SUCCEED)
+ if (H5DSiterate_scales(did, 0, &scale_idx, op_continue, NULL) == SUCCEED)
goto out;
/* continue iteration */
scale_idx = 0;
- count = 0;
- if (H5DSiterate_scales(did,0,&scale_idx,op_continue,(void *)&count) < 0)
+ count = 0;
+ if (H5DSiterate_scales(did, 0, &scale_idx, op_continue, (void *)&count) < 0)
goto out;
- if ( scale_idx != 1 && count != nscales ) {
+ if (scale_idx != 1 && count != nscales) {
goto out;
}
/* stop iteration */
scale_idx = 0;
- count = 0;
- if (H5DSiterate_scales(did,0,&scale_idx,op_stop,(void *)&count) < 0)
+ count = 0;
+ if (H5DSiterate_scales(did, 0, &scale_idx, op_stop, (void *)&count) < 0)
goto out;
- if ( scale_idx != 0 && count != 1 ) {
+ if (scale_idx != 0 && count != 1) {
goto out;
}
-
if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if(H5Fclose(fid) < 0)
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Fclose(fid) < 0)
goto out;
PASSED();
@@ -5101,7 +5180,8 @@ out:
H5Dclose(did);
H5Dclose(dsid);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
@@ -5111,220 +5191,219 @@ out:
*-------------------------------------------------------------------------
*/
-static int test_attach_detach(void)
+static int
+test_attach_detach(void)
{
- hid_t fid; /* file ID */
- hid_t gid; /* group ID */
- hid_t sid; /* dataspace ID */
- hid_t dcpl_id; /* dataset creation property */
- hid_t dsid = -1; /* DS dataset ID */
- hid_t var1_id, var2_id, var3_id; /* DS component name */
- hsize_t dims[RANK1] = {DIM1};
+ hid_t fid; /* file ID */
+ hid_t gid; /* group ID */
+ hid_t sid; /* dataspace ID */
+ hid_t dcpl_id; /* dataset creation property */
+ hid_t dsid = -1; /* DS dataset ID */
+ hid_t var1_id, var2_id, var3_id; /* DS component name */
+ hsize_t dims[RANK1] = {DIM1};
- TESTING2("permutations of attaching and detaching");
+ HL_TESTING2("permutations of attaching and detaching");
- if((fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto out;
+ if ((fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0)
- goto out;
+ if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0)
+ goto out;
/* Create dimension scale. */
- if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
- goto out;
-
- if((sid = H5Screate_simple(1, dims, dims)) < 0)
- goto out;
+ if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ goto out;
- if((dsid = H5Dcreate2(gid, DS_3_NAME, H5T_IEEE_F32BE, sid,
- H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
- goto out;
+ if ((sid = H5Screate_simple(1, dims, dims)) < 0)
+ goto out;
+
+ if ((dsid = H5Dcreate2(gid, DS_3_NAME, H5T_IEEE_F32BE, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
+ goto out;
- if(H5Sclose(sid) < 0)
- goto out;
- if(H5Pclose(dcpl_id) < 0)
- goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
+ if (H5Pclose(dcpl_id) < 0)
+ goto out;
- if(H5DSset_scale(dsid, DS_3_NAME) < 0)
- goto out;
+ if (H5DSset_scale(dsid, DS_3_NAME) < 0)
+ goto out;
/* Create a variable that uses this dimension scale. */
- if((sid = H5Screate_simple(DIM1, dims, dims)) < 0)
- goto out;
+ if ((sid = H5Screate_simple(DIM1, dims, dims)) < 0)
+ goto out;
- if((var1_id = H5Dcreate2(gid, DS_31_NAME, H5T_NATIVE_FLOAT, sid,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto out;
+ if ((var1_id =
+ H5Dcreate2(gid, DS_31_NAME, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- if(H5Sclose(sid) < 0)
- goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
- if(H5DSattach_scale(var1_id, dsid, 0) < 0)
- goto out;
+ if (H5DSattach_scale(var1_id, dsid, 0) < 0)
+ goto out;
/* Create another variable that uses this dimension scale. */
- if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
- goto out;
+ if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ goto out;
- if(H5Pset_attr_creation_order(dcpl_id, H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED) < 0)
- goto out;
+ if (H5Pset_attr_creation_order(dcpl_id, H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED) < 0)
+ goto out;
- if((sid = H5Screate_simple(DIM1, dims, dims)) < 0)
- goto out;
+ if ((sid = H5Screate_simple(DIM1, dims, dims)) < 0)
+ goto out;
- if((var2_id = H5Dcreate2(gid, DS_32_NAME, H5T_NATIVE_FLOAT, sid,
- H5P_DEFAULT, H5P_DEFAULT,H5P_DEFAULT)) < 0)
- goto out;
+ if ((var2_id =
+ H5Dcreate2(gid, DS_32_NAME, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- if(H5Pclose(dcpl_id) < 0)
- goto out;
+ if (H5Pclose(dcpl_id) < 0)
+ goto out;
- if(H5Sclose(sid) < 0)
- goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
/* Create 3rd variable that uses this dimension scale. */
- if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
- goto out;
+ if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ goto out;
- if(H5Pset_attr_creation_order(dcpl_id, H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED) < 0)
- goto out;
+ if (H5Pset_attr_creation_order(dcpl_id, H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED) < 0)
+ goto out;
- if((sid = H5Screate_simple(DIM1, dims, dims)) < 0)
- goto out;
+ if ((sid = H5Screate_simple(DIM1, dims, dims)) < 0)
+ goto out;
- if((var3_id = H5Dcreate2(gid, DS_33_NAME, H5T_NATIVE_FLOAT, sid,
- H5P_DEFAULT, H5P_DEFAULT,H5P_DEFAULT)) < 0)
- goto out;
+ if ((var3_id =
+ H5Dcreate2(gid, DS_33_NAME, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+
+ if (H5Pclose(dcpl_id) < 0)
+ goto out;
- if(H5Pclose(dcpl_id) < 0)
- goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
- if(H5Sclose(sid) < 0)
- goto out;
-
/* Attached var2 scale */
- if(H5DSattach_scale(var2_id, dsid, 0) < 0)
- goto out;
+ if (H5DSattach_scale(var2_id, dsid, 0) < 0)
+ goto out;
/* Detach the var2 scale */
- if(H5DSdetach_scale(var2_id, dsid, 0) < 0)
- goto out;
+ if (H5DSdetach_scale(var2_id, dsid, 0) < 0)
+ goto out;
/* Check if in correct state of detached and attached */
- if(H5DSis_attached(var1_id, dsid, 0) == 0) /* should still be attached */
- goto out;
- if(H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
- goto out;
+ if (H5DSis_attached(var1_id, dsid, 0) == 0) /* should still be attached */
+ goto out;
+ if (H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
/* Detach the var1 scale */
- if(H5DSdetach_scale(var1_id, dsid, 0) < 0)
- goto out;
+ if (H5DSdetach_scale(var1_id, dsid, 0) < 0)
+ goto out;
/* Check if in correct state of detached and attached */
- if(H5DSis_attached(var1_id, dsid, 0) != 0) /* should not be attached */
- goto out;
- if(H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
- goto out;
+ if (H5DSis_attached(var1_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
+ if (H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
/* Attach the DS again and remove them in the opposite order */
- if(H5DSattach_scale(var1_id, dsid, 0) < 0)
- goto out;
+ if (H5DSattach_scale(var1_id, dsid, 0) < 0)
+ goto out;
- if(H5DSattach_scale(var2_id, dsid, 0) < 0)
- goto out;
+ if (H5DSattach_scale(var2_id, dsid, 0) < 0)
+ goto out;
/* Detach the var1 scale */
- if(H5DSdetach_scale(var1_id, dsid, 0) < 0)
- goto out;
+ if (H5DSdetach_scale(var1_id, dsid, 0) < 0)
+ goto out;
/* Check if in correct state of detached and attached */
- if(H5DSis_attached(var1_id, dsid, 0) != 0) /* should not be attached */
- goto out;
- if(H5DSis_attached(var2_id, dsid, 0) == 0) /* should still be attached */
- goto out;
+ if (H5DSis_attached(var1_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
+ if (H5DSis_attached(var2_id, dsid, 0) == 0) /* should still be attached */
+ goto out;
/* Detach the var2 scale */
- if(H5DSdetach_scale(var2_id, dsid, 0) < 0)
- goto out;
+ if (H5DSdetach_scale(var2_id, dsid, 0) < 0)
+ goto out;
/* Check if in correct state of detached and attached */
- if(H5DSis_attached(var1_id, dsid, 0) != 0) /* should not be attached */
- goto out;
- if(H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
- goto out;
+ if (H5DSis_attached(var1_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
+ if (H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
/***************************************************
* Attach Three DS and remove the middle one first
*****************************************************/
- if(H5DSattach_scale(var1_id, dsid, 0) < 0)
- goto out;
-
- if(H5DSattach_scale(var2_id, dsid, 0) < 0)
- goto out;
+ if (H5DSattach_scale(var1_id, dsid, 0) < 0)
+ goto out;
- if(H5DSattach_scale(var3_id, dsid, 0) < 0)
- goto out;
+ if (H5DSattach_scale(var2_id, dsid, 0) < 0)
+ goto out;
+ if (H5DSattach_scale(var3_id, dsid, 0) < 0)
+ goto out;
/* Detach the var2 scale */
- if(H5DSdetach_scale(var2_id, dsid, 0) < 0)
- goto out;
+ if (H5DSdetach_scale(var2_id, dsid, 0) < 0)
+ goto out;
/* Check if in correct state of detached and attached */
- if(H5DSis_attached(var1_id, dsid, 0) == 0) /* should still be attached */
- goto out;
- if(H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
- goto out;
- if(H5DSis_attached(var3_id, dsid, 0) == 0) /* should still be attached */
- goto out;
+ if (H5DSis_attached(var1_id, dsid, 0) == 0) /* should still be attached */
+ goto out;
+ if (H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
+ if (H5DSis_attached(var3_id, dsid, 0) == 0) /* should still be attached */
+ goto out;
/* Detach the var3 scale */
- if(H5DSdetach_scale(var3_id, dsid, 0) < 0)
- goto out;
+ if (H5DSdetach_scale(var3_id, dsid, 0) < 0)
+ goto out;
/* Check if in correct state of detached and attached */
- if(H5DSis_attached(var1_id, dsid, 0) == 0) /* should still be attached */
- goto out;
- if(H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
- goto out;
- if(H5DSis_attached(var3_id, dsid, 0) != 0) /* should not be attached */
- goto out;
+ if (H5DSis_attached(var1_id, dsid, 0) == 0) /* should still be attached */
+ goto out;
+ if (H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
+ if (H5DSis_attached(var3_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
/* Detach the var1 scale */
- if(H5DSdetach_scale(var1_id, dsid, 0) < 0)
- goto out;
+ if (H5DSdetach_scale(var1_id, dsid, 0) < 0)
+ goto out;
/* Check if in correct state of detached and attached */
- if(H5DSis_attached(var1_id, dsid, 0) != 0) /* should not be attached */
- goto out;
- if(H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
- goto out;
- if(H5DSis_attached(var3_id, dsid, 0) != 0) /* should not be attached */
- goto out;
+ if (H5DSis_attached(var1_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
+ if (H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
+ if (H5DSis_attached(var3_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
+ * close
+ *-------------------------------------------------------------------------
+ */
- if(H5Dclose(var1_id) < 0)
- goto out;
- if(H5Dclose(var2_id) < 0)
- goto out;
- if(H5Dclose(var3_id) < 0)
- goto out;
- if(H5Dclose(dsid) < 0)
- goto out;
- if(H5Gclose(gid) < 0)
- goto out;
- if(H5Fclose(fid) < 0)
- goto out;
+ if (H5Dclose(var1_id) < 0)
+ goto out;
+ if (H5Dclose(var2_id) < 0)
+ goto out;
+ if (H5Dclose(var3_id) < 0)
+ goto out;
+ if (H5Dclose(dsid) < 0)
+ goto out;
+ if (H5Gclose(gid) < 0)
+ goto out;
+ if (H5Fclose(fid) < 0)
+ goto out;
PASSED();
@@ -5334,13 +5413,14 @@ static int test_attach_detach(void)
out:
H5E_BEGIN_TRY
{
- H5Dclose(var1_id);
- H5Dclose(var2_id);
- H5Dclose(var3_id);
+ H5Dclose(var1_id);
+ H5Dclose(var2_id);
+ H5Dclose(var3_id);
H5Dclose(dsid);
H5Gclose(gid);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
diff --git a/hl/test/test_dset_opt.c b/hl/test/test_dset_opt.c
index 179e068..d6edbf2 100644
--- a/hl/test/test_dset_opt.c
+++ b/hl/test/test_dset_opt.c
@@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* 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 *
+ * 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. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdlib.h>
#include <string.h>
@@ -19,76 +19,92 @@
#include <math.h>
#if defined(H5_HAVE_ZLIB_H) && !defined(H5_ZLIB_HEADER)
-# define H5_ZLIB_HEADER "zlib.h"
+#define H5_ZLIB_HEADER "zlib.h"
#endif
#if defined(H5_ZLIB_HEADER)
-# include H5_ZLIB_HEADER /* "zlib.h" */
+#include H5_ZLIB_HEADER /* "zlib.h" */
#endif
#define FILE_NAME "test_dectris.h5"
/* Datasets for Direct Write tests */
-#define DATASETNAME1 "direct_write"
-#define DATASETNAME2 "skip_one_filter"
-#define DATASETNAME3 "skip_two_filters"
-#define DATASETNAME4 "data_conv"
-#define DATASETNAME5 "contiguous_dset"
-#define DATASETNAME6 "invalid_argue"
-#define DATASETNAME7 "overwrite_chunk"
+#define DATASETNAME1 "direct_write"
+#define DATASETNAME2 "skip_one_filter"
+#define DATASETNAME3 "skip_two_filters"
+#define DATASETNAME4 "data_conv"
+#define DATASETNAME5 "contiguous_dset"
+#define DATASETNAME6 "invalid_argue"
+#define DATASETNAME7 "overwrite_chunk"
/* Datasets for Direct Read tests */
-#define DATASETNAME8 "disabled_chunk_cache"
-#define DATASETNAME9 "flush_chunk_cache"
-#define DATASETNAME10 "read_w_valid_cache"
-#define DATASETNAME11 "unallocated_chunk"
-#define DATASETNAME12 "unfiltered_data"
+#define DATASETNAME8 "disabled_chunk_cache"
+#define DATASETNAME9 "flush_chunk_cache"
+#define DATASETNAME10 "read_w_valid_cache"
+#define DATASETNAME11 "unallocated_chunk"
+#define DATASETNAME12 "unfiltered_data"
-#define RANK 2
-#define NX 16
-#define NY 16
-#define CHUNK_NX 4
-#define CHUNK_NY 4
+#define RANK 2
+#define NX 16
+#define NY 16
+#define CHUNK_NX 4
+#define CHUNK_NY 4
-#define DEFLATE_SIZE_ADJUST(s) (ceil(((double)(s))*1.001)+12)
+#define DEFLATE_SIZE_ADJUST(s) (ceil(((double)(s)) * 1.001) + 12)
/* Temporary filter IDs used for testing */
-#define H5Z_FILTER_BOGUS1 305
-#define H5Z_FILTER_BOGUS2 306
+#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
-#define OVERWRITE_CHUNK_NX 3
-#define OVERWRITE_CHUNK_2NX 6
-#define OVERWRITE_CHUNK_NY 2
-#define OVERWRITE_VALUE 42
+#define OVERWRITE_NDIMS 3
+#define OVERWRITE_CHUNK_NX 3
+#define OVERWRITE_CHUNK_2NX 6
+#define OVERWRITE_CHUNK_NY 2
+#define OVERWRITE_VALUE 42
+
+/* Test configurations */
+#define CONFIG_LATEST 0x01
+#define CONFIG_REOPEN_FILE 0x02
+#define CONFIG_REOPEN_DSET 0x04
+#define CONFIG_DIRECT_WRITE 0x08
+#define CONFIG_DIRECT_READ 0x10
+#define CONFIG_END 0x20
+
+/* Defines used in test_single_chunk() */
+#define SINGLE_FILE "single.h5"
+#define DATASET "dataset"
+#define DIM0 4
+#define DIM1 32
+#define CHUNK0 DIM0
+#define CHUNK1 DIM1
/* Local prototypes for filter functions */
-static size_t filter_bogus1(unsigned int flags, size_t cd_nelmts,
- const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
-static size_t filter_bogus2(unsigned int flags, size_t cd_nelmts,
- const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
+static size_t filter_bogus1(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values,
+ size_t nbytes, size_t *buf_size, void **buf);
+static size_t filter_bogus2(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values,
+ size_t nbytes, size_t *buf_size, void **buf);
/* 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 */
- 1, 1, /* Encoding and decoding enabled */
- "bogus1", /* Filter name for debugging */
- NULL, /* The "can apply" callback */
- NULL, /* The "set local" callback */
- filter_bogus1, /* The actual filter function */
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
+ H5Z_FILTER_BOGUS1, /* Filter id number */
+ 1, 1, /* Encoding and decoding enabled */
+ "bogus1", /* Filter name for debugging */
+ NULL, /* The "can apply" callback */
+ NULL, /* The "set local" callback */
+ 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 */
- 1, 1, /* Encoding and decoding enabled */
- "bogus2", /* Filter name for debugging */
- NULL, /* The "can apply" callback */
- NULL, /* The "set local" callback */
- filter_bogus2, /* The actual filter function */
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
+ H5Z_FILTER_BOGUS2, /* Filter id number */
+ 1, 1, /* Encoding and decoding enabled */
+ "bogus2", /* Filter name for debugging */
+ NULL, /* The "can apply" callback */
+ NULL, /* The "set local" callback */
+ filter_bogus2, /* The actual filter function */
}};
/*-------------------------------------------------------------------------
@@ -106,112 +122,113 @@ const H5Z_class2_t H5Z_BOGUS2[1] = {{
*/
#ifdef H5_HAVE_FILTER_DEFLATE
static int
-test_direct_chunk_write (hid_t file)
+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 maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
- hsize_t chunk_dims[2] ={CHUNK_NX, CHUNK_NY};
- herr_t status;
- int ret;
- int data[NX][NY];
- int i, j, n;
-
- unsigned filter_mask = 0;
- int direct_buf[CHUNK_NX][CHUNK_NY];
- int check_chunk[CHUNK_NX][CHUNK_NY];
- hsize_t offset[2] = {0, 0};
- 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;
- int aggression = 9; /* Compression aggression setting */
- void *outbuf = NULL; /* Pointer to new buffer */
+ 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 maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
+ hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY};
+ herr_t status;
+ int ret;
+ int data[NX][NY];
+ int i, j, n;
+
+ unsigned filter_mask = 0;
+ int direct_buf[CHUNK_NX][CHUNK_NY];
+ int check_chunk[CHUNK_NX][CHUNK_NY];
+ hsize_t offset[2] = {0, 0};
+ 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;
+ int aggression = 9; /* Compression aggression setting */
+ void * outbuf = NULL; /* Pointer to new buffer */
hsize_t start[2]; /* Start of hyperslab */
hsize_t stride[2]; /* Stride of hyperslab */
hsize_t count[2]; /* Block count */
hsize_t block[2]; /* Block sizes */
- TESTING("basic functionality of H5DOwrite_chunk");
+ HL_TESTING2("basic functionality of H5DOwrite_chunk");
/*
* Create the data space with unlimited dimensions.
*/
- if((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0)
+ if ((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0)
goto error;
- if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
+ if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
goto error;
/*
* Modify dataset creation properties, i.e. enable chunking and compression
*/
- if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto error;
- if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0)
+ if ((status = H5Pset_chunk(cparms, RANK, chunk_dims)) < 0)
goto error;
- if((status = H5Pset_deflate( cparms, (unsigned) aggression)) < 0)
+ if ((status = H5Pset_deflate(cparms, (unsigned)aggression)) < 0)
goto error;
/*
* Create a new dataset within the file using cparms
* creation properties.
*/
- if((dataset = H5Dcreate2(file, DATASETNAME1, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
- cparms, H5P_DEFAULT)) < 0)
+ if ((dataset =
+ H5Dcreate2(file, DATASETNAME1, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, 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++;
+ for (i = n = 0; i < NX; i++)
+ for (j = 0; j < NY; j++)
+ data[i][j] = n++;
- if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ 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 H5DOwrite_chunk calls.
*/
- if((status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- dxpl, data)) < 0)
+ if ((status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, 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++;
+ for (i = n = 0; i < CHUNK_NX; i++)
+ for (j = 0; j < CHUNK_NY; j++)
+ direct_buf[i][j] = n++;
/* Allocate output (compressed) buffer */
outbuf = HDmalloc(z_dst_nbytes);
- z_dst = (Bytef *)outbuf;
+ z_dst = (Bytef *)outbuf;
/* Perform compression from the source to the destination buffer */
ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
/* Check for various zlib errors */
- if(Z_BUF_ERROR == ret) {
+ if (Z_BUF_ERROR == ret) {
HDfprintf(stderr, "overflow");
goto error;
- } else if(Z_MEM_ERROR == ret) {
+ }
+ else if (Z_MEM_ERROR == ret) {
HDfprintf(stderr, "deflate memory error");
goto error;
- } else if(Z_OK != ret) {
+ }
+ else if (Z_OK != ret) {
HDfprintf(stderr, "other deflate error");
goto error;
}
/* Write the compressed chunk data repeatedly to cover all the chunks in the
* dataset, using the direct writing function. */
- for(i=0; i<NX/CHUNK_NX; i++) {
- for(j=0; j<NY/CHUNK_NY; j++) {
+ for (i = 0; i < NX / CHUNK_NX; i++) {
+ for (j = 0; j < NY / CHUNK_NY; j++) {
status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, z_dst_nbytes, outbuf);
offset[1] += CHUNK_NY;
}
@@ -219,36 +236,40 @@ test_direct_chunk_write (hid_t file)
offset[1] = 0;
}
- if(outbuf)
+ if (outbuf)
HDfree(outbuf);
- if(H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0)
+ if (H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0)
goto error;
- if(H5Dclose(dataset) < 0)
+ if (H5Dclose(dataset) < 0)
goto error;
- if((dataset = H5Dopen2(file, DATASETNAME1, H5P_DEFAULT)) < 0)
+ if ((dataset = H5Dopen2(file, DATASETNAME1, H5P_DEFAULT)) < 0)
goto error;
/*
* Select hyperslab for one chunk in the file
*/
- start[0] = CHUNK_NX; start[1] = CHUNK_NY;
- stride[0] = 1; stride[1] = 1;
- count[0] = 1; count[1] = 1;
- block[0] = CHUNK_NX; block[1] = CHUNK_NY;
- if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
+ start[0] = CHUNK_NX;
+ start[1] = CHUNK_NY;
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = 1;
+ count[1] = 1;
+ block[0] = CHUNK_NX;
+ block[1] = CHUNK_NY;
+ if ((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
goto error;
/* Read the chunk back */
- if((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0)
+ if ((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0)
goto error;
/* Check that the values read are the same as the values written */
- for(i = 0; i < CHUNK_NX; i++) {
- for(j = 0; j < CHUNK_NY; j++) {
- if(direct_buf[i][j] != check_chunk[i][j]) {
+ for (i = 0; i < CHUNK_NX; i++) {
+ for (j = 0; j < CHUNK_NY; j++) {
+ if (direct_buf[i][j] != check_chunk[i][j]) {
HDprintf(" 1. Read different values than written.");
HDprintf(" At index %d,%d\n", i, j);
HDprintf(" direct_buf=%d, check_chunk=%d\n", direct_buf[i][j], check_chunk[i][j]);
@@ -258,25 +279,27 @@ test_direct_chunk_write (hid_t file)
}
/* Reinitialize different data for one chunk */
- for(i = 0; i < CHUNK_NX; i++)
- for(j = 0; j < CHUNK_NY; j++)
- direct_buf[i][j] = i + j;
+ for (i = 0; i < CHUNK_NX; i++)
+ for (j = 0; j < CHUNK_NY; j++)
+ direct_buf[i][j] = i + j;
/* Allocate output (compressed) buffer */
outbuf = HDmalloc(z_dst_nbytes);
- z_dst = (Bytef *)outbuf;
+ z_dst = (Bytef *)outbuf;
/* Perform compression from the source to the destination buffer */
ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
/* Check for various zlib errors */
- if(Z_BUF_ERROR == ret) {
+ if (Z_BUF_ERROR == ret) {
HDfprintf(stderr, "overflow");
goto error;
- } else if(Z_MEM_ERROR == ret) {
+ }
+ else if (Z_MEM_ERROR == ret) {
HDfprintf(stderr, "deflate memory error");
goto error;
- } else if(Z_OK != ret) {
+ }
+ else if (Z_OK != ret) {
HDfprintf(stderr, "other deflate error");
goto error;
}
@@ -284,8 +307,8 @@ test_direct_chunk_write (hid_t file)
/* Rewrite the compressed chunk data repeatedly to cover all the chunks in the
* dataset, using the direct writing function. */
offset[0] = offset[1] = 0;
- for(i=0; i<NX/CHUNK_NX; i++) {
- for(j=0; j<NY/CHUNK_NY; j++) {
+ for (i = 0; i < NX / CHUNK_NX; i++) {
+ for (j = 0; j < NY / CHUNK_NY; j++) {
status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, z_dst_nbytes, outbuf);
offset[1] += CHUNK_NY;
}
@@ -293,26 +316,26 @@ test_direct_chunk_write (hid_t file)
offset[1] = 0;
}
- if(outbuf)
+ if (outbuf)
HDfree(outbuf);
- if(H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0)
+ if (H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0)
goto error;
- if(H5Dclose(dataset) < 0)
+ if (H5Dclose(dataset) < 0)
goto error;
- if((dataset = H5Dopen2(file, DATASETNAME1, H5P_DEFAULT)) < 0)
+ if ((dataset = H5Dopen2(file, DATASETNAME1, H5P_DEFAULT)) < 0)
goto error;
/* Read the chunk back */
- if((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0)
+ if ((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0)
goto error;
/* Check that the values read are the same as the values written */
- for(i = 0; i < CHUNK_NX; i++) {
- for(j = 0; j < CHUNK_NY; j++) {
- if(direct_buf[i][j] != check_chunk[i][j]) {
+ for (i = 0; i < CHUNK_NX; i++) {
+ for (j = 0; j < CHUNK_NY; j++) {
+ if (direct_buf[i][j] != check_chunk[i][j]) {
HDprintf(" 2. Read different values than written.");
HDprintf(" At index %d,%d\n", i, j);
HDprintf(" direct_buf=%d, check_chunk=%d\n", direct_buf[i][j], check_chunk[i][j]);
@@ -334,15 +357,17 @@ test_direct_chunk_write (hid_t file)
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(dataset);
H5Sclose(mem_space);
H5Sclose(dataspace);
H5Pclose(cparms);
H5Pclose(dxpl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
- if(outbuf)
+ if (outbuf)
HDfree(outbuf);
H5_FAILED();
@@ -366,24 +391,24 @@ error:
static int
test_direct_chunk_overwrite_data(hid_t fid)
{
- size_t buf_size = OVERWRITE_CHUNK_NX * OVERWRITE_CHUNK_NY * sizeof(int16_t);
- int16_t data_buf[OVERWRITE_CHUNK_NY][OVERWRITE_CHUNK_NX];
- int16_t overwrite_buf[OVERWRITE_CHUNK_NY][OVERWRITE_CHUNK_NX];
- uint32_t filter_mask = 0;
- hid_t tid = H5T_NATIVE_UINT16;
- hid_t dcpl_id = -1;
- hid_t sid = -1;
- hid_t did = -1;
- uint16_t fill_value = 0;
- hsize_t dset_dims[] = {1, OVERWRITE_CHUNK_NY, OVERWRITE_CHUNK_2NX};
- hsize_t dset_max_dims[] = {H5S_UNLIMITED, OVERWRITE_CHUNK_NY, OVERWRITE_CHUNK_2NX};
- hsize_t chunk_dims[] = {1, OVERWRITE_CHUNK_NY, OVERWRITE_CHUNK_NX};
- hsize_t offset[] = {0, 0, 0};
- hsize_t i, j;
- int16_t n;
- int16_t read_buf[OVERWRITE_CHUNK_NY][OVERWRITE_CHUNK_2NX];
-
- TESTING("overwriting existing data with H5DOwrite_chunk");
+ size_t buf_size = OVERWRITE_CHUNK_NX * OVERWRITE_CHUNK_NY * sizeof(int16_t);
+ int16_t data_buf[OVERWRITE_CHUNK_NY][OVERWRITE_CHUNK_NX];
+ int16_t overwrite_buf[OVERWRITE_CHUNK_NY][OVERWRITE_CHUNK_NX];
+ uint32_t filter_mask = 0;
+ hid_t tid = H5T_NATIVE_UINT16;
+ hid_t dcpl_id = -1;
+ hid_t sid = -1;
+ hid_t did = -1;
+ uint16_t fill_value = 0;
+ hsize_t dset_dims[] = {1, OVERWRITE_CHUNK_NY, OVERWRITE_CHUNK_2NX};
+ hsize_t dset_max_dims[] = {H5S_UNLIMITED, OVERWRITE_CHUNK_NY, OVERWRITE_CHUNK_2NX};
+ hsize_t chunk_dims[] = {1, OVERWRITE_CHUNK_NY, OVERWRITE_CHUNK_NX};
+ hsize_t offset[] = {0, 0, 0};
+ hsize_t i, j;
+ int16_t n;
+ int16_t read_buf[OVERWRITE_CHUNK_NY][OVERWRITE_CHUNK_2NX];
+
+ HL_TESTING2("overwriting existing data with H5DOwrite_chunk");
/* Create the dataset's data space */
if ((sid = H5Screate_simple(OVERWRITE_NDIMS, dset_dims, dset_max_dims)) < 0)
@@ -405,7 +430,7 @@ test_direct_chunk_overwrite_data(hid_t fid)
n = 0;
for (i = 0; i < OVERWRITE_CHUNK_NY; i++) {
for (j = 0; j < OVERWRITE_CHUNK_NX; j++) {
- data_buf[i][j] = n++;
+ data_buf[i][j] = n++;
overwrite_buf[i][j] = OVERWRITE_VALUE;
}
}
@@ -446,18 +471,20 @@ test_direct_chunk_overwrite_data(hid_t fid)
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(dcpl_id);
H5Sclose(sid);
H5Dclose(did);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return 1;
} /* end test_direct_chunk_overwrite_data() */
/*-------------------------------------------------------------------------
- * Function: test_skip_compress_write1
+ * Function: test_skip_compress_write1
*
* Purpose: Test skipping compression filter when it is the only filter
* for the dataset
@@ -473,70 +500,70 @@ error:
static int
test_skip_compress_write1(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 maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
- hsize_t chunk_dims[2] ={CHUNK_NX, CHUNK_NY};
- herr_t status;
- int i, j, n;
-
- unsigned filter_mask = 0;
- int direct_buf[CHUNK_NX][CHUNK_NY];
- int check_chunk[CHUNK_NX][CHUNK_NY];
- hsize_t offset[2] = {0, 0};
- size_t buf_size = CHUNK_NX*CHUNK_NY*sizeof(int);
- int aggression = 9; /* Compression aggression setting */
-
- unsigned read_filter_mask = 0; /* filter mask after direct read */
- int read_direct_buf[CHUNK_NX][CHUNK_NY];
- hsize_t read_buf_size = 0; /* buf size */
+ 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 maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
+ hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY};
+ herr_t status;
+ int i, j, n;
+
+ unsigned filter_mask = 0;
+ int direct_buf[CHUNK_NX][CHUNK_NY];
+ int check_chunk[CHUNK_NX][CHUNK_NY];
+ hsize_t offset[2] = {0, 0};
+ size_t buf_size = CHUNK_NX * CHUNK_NY * sizeof(int);
+ int aggression = 9; /* Compression aggression setting */
+
+ unsigned read_filter_mask = 0; /* filter mask after direct read */
+ int read_direct_buf[CHUNK_NX][CHUNK_NY];
+ hsize_t read_buf_size = 0; /* buf size */
hsize_t start[2]; /* Start of hyperslab */
hsize_t stride[2]; /* Stride of hyperslab */
hsize_t count[2]; /* Block count */
hsize_t block[2]; /* Block sizes */
- TESTING("skipping compression filter for H5DOwrite_chunk/H5DOread_chunk");
+ HL_TESTING2("skipping compression filter for H5DOwrite_chunk/H5DOread_chunk");
/*
* Create the data space with unlimited dimensions.
*/
- if((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0)
+ if ((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0)
goto error;
- if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
+ if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
goto error;
/*
* Modify dataset creation properties, i.e. enable chunking and compression
*/
- if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto error;
- if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0)
+ if ((status = H5Pset_chunk(cparms, RANK, chunk_dims)) < 0)
goto error;
- if((status = H5Pset_deflate( cparms, (unsigned ) aggression)) < 0)
+ if ((status = H5Pset_deflate(cparms, (unsigned)aggression)) < 0)
goto error;
/*
* Create a new dataset within the file using cparms
* creation properties.
*/
- if((dataset = H5Dcreate2(file, DATASETNAME2, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
- cparms, H5P_DEFAULT)) < 0)
+ if ((dataset =
+ H5Dcreate2(file, DATASETNAME2, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0)
goto error;
- if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 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++;
- }
+ for (i = n = 0; i < CHUNK_NX; i++)
+ for (j = 0; j < CHUNK_NY; j++) {
+ direct_buf[i][j] = n++;
+ }
/* write the uncompressed chunk data repeatedly to dataset, using the direct writing function.
* Indicate skipping the compression filter. */
@@ -545,36 +572,40 @@ test_skip_compress_write1(hid_t file)
filter_mask = 0x00000001;
- if((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) < 0)
+ if ((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) < 0)
goto error;
- if(H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0)
+ if (H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0)
goto error;
- if(H5Dclose(dataset) < 0)
+ if (H5Dclose(dataset) < 0)
goto error;
- if((dataset = H5Dopen2(file, DATASETNAME2, H5P_DEFAULT)) < 0)
+ if ((dataset = H5Dopen2(file, DATASETNAME2, H5P_DEFAULT)) < 0)
goto error;
/*
* Select hyperslab for the chunk just written in the file
*/
- start[0] = CHUNK_NX; start[1] = CHUNK_NY;
- stride[0] = 1; stride[1] = 1;
- count[0] = 1; count[1] = 1;
- block[0] = CHUNK_NX; block[1] = CHUNK_NY;
- if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
+ start[0] = CHUNK_NX;
+ start[1] = CHUNK_NY;
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = 1;
+ count[1] = 1;
+ block[0] = CHUNK_NX;
+ block[1] = CHUNK_NY;
+ if ((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
goto error;
/* Read the chunk back */
- if((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0)
+ if ((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0)
goto error;
/* Check that the values read are the same as the values written */
- for(i = 0; i < CHUNK_NX; i++) {
- for(j = 0; j < CHUNK_NY; j++) {
- if(direct_buf[i][j] != check_chunk[i][j]) {
+ for (i = 0; i < CHUNK_NX; i++) {
+ for (j = 0; j < CHUNK_NY; j++) {
+ if (direct_buf[i][j] != check_chunk[i][j]) {
HDprintf(" 1. Read different values than written.");
HDprintf(" At index %d,%d\n", i, j);
HDprintf(" direct_buf=%d, check_chunk=%d\n", direct_buf[i][j], check_chunk[i][j]);
@@ -584,22 +615,22 @@ test_skip_compress_write1(hid_t file)
}
/* Query chunk storage size */
- if((status = H5Dget_chunk_storage_size(dataset, offset, &read_buf_size)) < 0)
+ if ((status = H5Dget_chunk_storage_size(dataset, offset, &read_buf_size)) < 0)
goto error;
- if(read_buf_size != buf_size)
+ if (read_buf_size != buf_size)
goto error;
/* Read the raw chunk back */
HDmemset(&read_direct_buf, 0, sizeof(read_direct_buf));
- if((status = H5DOread_chunk(dataset, H5P_DEFAULT, offset, &read_filter_mask, read_direct_buf)) < 0)
+ if ((status = H5DOread_chunk(dataset, H5P_DEFAULT, offset, &read_filter_mask, read_direct_buf)) < 0)
goto error;
- if(read_filter_mask != filter_mask)
+ if (read_filter_mask != filter_mask)
goto error;
/* Check that the direct chunk read is the same as the chunk written */
- for(i = 0; i < CHUNK_NX; i++) {
- for(j = 0; j < CHUNK_NY; j++) {
- if(direct_buf[i][j] != read_direct_buf[i][j]) {
+ for (i = 0; i < CHUNK_NX; i++) {
+ for (j = 0; j < CHUNK_NY; j++) {
+ if (direct_buf[i][j] != read_direct_buf[i][j]) {
HDprintf(" 1. Read different values than written.");
HDprintf(" At index %d,%d\n", i, j);
HDprintf(" direct_buf=%d, read_direct_buf=%d\n", direct_buf[i][j], read_direct_buf[i][j]);
@@ -621,13 +652,15 @@ test_skip_compress_write1(hid_t file)
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(dataset);
H5Sclose(mem_space);
H5Sclose(dataspace);
H5Pclose(cparms);
H5Pclose(dxpl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return 1;
@@ -647,26 +680,25 @@ error:
*/
static size_t
filter_bogus1(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts,
- const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes,
- size_t *buf_size, void **buf)
+ const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, size_t *buf_size, void **buf)
{
- int *int_ptr=(int *)*buf; /* Pointer to the data values */
- ssize_t buf_left=(ssize_t)*buf_size; /* Amount of data buffer left to process */
+ int * int_ptr = (int *)*buf; /* Pointer to the data values */
+ ssize_t buf_left = (ssize_t)*buf_size; /* Amount of data buffer left to process */
- if(flags & H5Z_FLAG_REVERSE) { /* read */
+ if (flags & H5Z_FLAG_REVERSE) { /* read */
/* Substract the "add on" value to all the data values */
- while(buf_left>0) {
+ while (buf_left > 0) {
*int_ptr++ -= (int)ADD_ON;
buf_left -= (ssize_t)sizeof(int);
- } /* end while */
- } /* end if */
+ } /* end while */
+ } /* end if */
else { /* write */
/* Add the "add on" value to all the data values */
- while(buf_left>0) {
+ while (buf_left > 0) {
*int_ptr++ += (int)ADD_ON;
buf_left -= (ssize_t)sizeof(int);
} /* end while */
- } /* end else */
+ } /* end else */
return nbytes;
} /* filter_bogus1() */
@@ -684,26 +716,25 @@ filter_bogus1(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts,
*/
static size_t
filter_bogus2(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts,
- const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes,
- size_t *buf_size, void **buf)
+ const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, size_t *buf_size, void **buf)
{
- int *int_ptr=(int *)*buf; /* Pointer to the data values */
- ssize_t buf_left=(ssize_t)*buf_size; /* Amount of data buffer left to process */
+ int * int_ptr = (int *)*buf; /* Pointer to the data values */
+ ssize_t buf_left = (ssize_t)*buf_size; /* Amount of data buffer left to process */
- if(flags & H5Z_FLAG_REVERSE) { /* read */
+ if (flags & H5Z_FLAG_REVERSE) { /* read */
/* Substract the "add on" value to all the data values */
- while(buf_left>0) {
+ while (buf_left > 0) {
*int_ptr++ /= (int)FACTOR;
buf_left -= (ssize_t)sizeof(int);
- } /* end while */
- } /* end if */
+ } /* end while */
+ } /* end if */
else { /* write */
/* Add the "add on" value to all the data values */
- while(buf_left>0) {
+ while (buf_left > 0) {
*int_ptr++ *= (int)FACTOR;
buf_left -= (ssize_t)sizeof(int);
} /* end while */
- } /* end else */
+ } /* end else */
return nbytes;
} /* filter_bogus2() */
@@ -725,87 +756,87 @@ filter_bogus2(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts,
static int
test_skip_compress_write2(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 maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
- hsize_t chunk_dims[2] ={CHUNK_NX, CHUNK_NY};
- herr_t status;
- int i, j, n;
-
- unsigned filter_mask = 0; /* orig filter mask */
- int origin_direct_buf[CHUNK_NX][CHUNK_NY];
- int direct_buf[CHUNK_NX][CHUNK_NY];
- int check_chunk[CHUNK_NX][CHUNK_NY];
- hsize_t offset[2] = {0, 0};
- size_t buf_size = CHUNK_NX*CHUNK_NY*sizeof(int);
- int aggression = 9; /* Compression aggression setting */
-
- unsigned read_filter_mask = 0; /* filter mask after direct read */
- int read_direct_buf[CHUNK_NX][CHUNK_NY];
- hsize_t read_buf_size = 0; /* buf size */
-
- hsize_t start[2]; /* Start of hyperslab */
- hsize_t stride[2]; /* Stride of hyperslab */
- hsize_t count[2]; /* Block count */
- hsize_t block[2]; /* Block sizes */
-
- TESTING("skipping compression filters but keep two other filters");
+ 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 maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
+ hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY};
+ herr_t status;
+ int i, j, n;
+
+ unsigned filter_mask = 0; /* orig filter mask */
+ int origin_direct_buf[CHUNK_NX][CHUNK_NY];
+ int direct_buf[CHUNK_NX][CHUNK_NY];
+ int check_chunk[CHUNK_NX][CHUNK_NY];
+ hsize_t offset[2] = {0, 0};
+ size_t buf_size = CHUNK_NX * CHUNK_NY * sizeof(int);
+ int aggression = 9; /* Compression aggression setting */
+
+ unsigned read_filter_mask = 0; /* filter mask after direct read */
+ int read_direct_buf[CHUNK_NX][CHUNK_NY];
+ hsize_t read_buf_size = 0; /* buf size */
+
+ hsize_t start[2]; /* Start of hyperslab */
+ hsize_t stride[2]; /* Stride of hyperslab */
+ hsize_t count[2]; /* Block count */
+ hsize_t block[2]; /* Block sizes */
+
+ HL_TESTING2("skipping compression filters but keep two other filters");
/*
* Create the data space with unlimited dimensions.
*/
- if((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0)
+ if ((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0)
goto error;
- if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
+ if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
goto error;
/*
* Modify dataset creation properties, i.e. enable chunking and compression.
* The order of filters is bogus 1 + deflate + bogus 2.
*/
- if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto error;
- if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0)
+ if ((status = H5Pset_chunk(cparms, RANK, chunk_dims)) < 0)
goto error;
/* Register and enable first bogus filter */
- if(H5Zregister (H5Z_BOGUS1) < 0)
+ if (H5Zregister(H5Z_BOGUS1) < 0)
goto error;
- if(H5Pset_filter(cparms, H5Z_FILTER_BOGUS1, 0, (size_t)0, NULL) < 0)
+ if (H5Pset_filter(cparms, H5Z_FILTER_BOGUS1, 0, (size_t)0, NULL) < 0)
goto error;
/* Enable compression filter */
- if((status = H5Pset_deflate( cparms, (unsigned) aggression)) < 0)
+ if ((status = H5Pset_deflate(cparms, (unsigned)aggression)) < 0)
goto error;
/* Register and enable second bogus filter */
- if(H5Zregister (H5Z_BOGUS2) < 0)
+ if (H5Zregister(H5Z_BOGUS2) < 0)
goto error;
- if(H5Pset_filter(cparms, H5Z_FILTER_BOGUS2, 0, (size_t)0, NULL) < 0)
+ if (H5Pset_filter(cparms, H5Z_FILTER_BOGUS2, 0, (size_t)0, NULL) < 0)
goto error;
/*
* Create a new dataset within the file using cparms
* creation properties.
*/
- if((dataset = H5Dcreate2(file, DATASETNAME3, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
- cparms, H5P_DEFAULT)) < 0)
+ if ((dataset =
+ H5Dcreate2(file, DATASETNAME3, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0)
goto error;
- if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
goto error;
/* Initialize data for one chunk. Apply operations of two bogus filters to the chunk */
- for(i = n = 0; i < CHUNK_NX; i++)
- for(j = 0; j < CHUNK_NY; j++) {
+ for (i = n = 0; i < CHUNK_NX; i++)
+ for (j = 0; j < CHUNK_NY; j++) {
origin_direct_buf[i][j] = n++;
- direct_buf[i][j] = (origin_direct_buf[i][j] + ADD_ON) * FACTOR;
+ direct_buf[i][j] = (origin_direct_buf[i][j] + ADD_ON) * FACTOR;
}
/* write the uncompressed chunk data repeatedly to dataset, using the direct writing function.
@@ -816,61 +847,66 @@ test_skip_compress_write2(hid_t file)
/* compression filter is the middle one to be skipped */
filter_mask = 0x00000002;
- if((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) < 0)
+ if ((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) < 0)
goto error;
- if(H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0)
+ if (H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0)
goto error;
- if(H5Dclose(dataset) < 0)
+ if (H5Dclose(dataset) < 0)
goto error;
- if((dataset = H5Dopen2(file, DATASETNAME3, H5P_DEFAULT)) < 0)
+ if ((dataset = H5Dopen2(file, DATASETNAME3, H5P_DEFAULT)) < 0)
goto error;
/*
* Select hyperslab for one chunk in the file
*/
- start[0] = CHUNK_NX; start[1] = CHUNK_NY;
- stride[0] = 1; stride[1] = 1;
- count[0] = 1; count[1] = 1;
- block[0] = CHUNK_NX; block[1] = CHUNK_NY;
- if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
+ start[0] = CHUNK_NX;
+ start[1] = CHUNK_NY;
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = 1;
+ count[1] = 1;
+ block[0] = CHUNK_NX;
+ block[1] = CHUNK_NY;
+ if ((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
goto error;
/* Read the chunk back */
- if((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0)
+ if ((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0)
goto error;
/* Check that the values read are the same as the values written */
- for(i = 0; i < CHUNK_NX; i++) {
- for(j = 0; j < CHUNK_NY; j++) {
- if(origin_direct_buf[i][j] != check_chunk[i][j]) {
+ for (i = 0; i < CHUNK_NX; i++) {
+ for (j = 0; j < CHUNK_NY; j++) {
+ if (origin_direct_buf[i][j] != check_chunk[i][j]) {
HDprintf(" 1. Read different values than written.");
HDprintf(" At index %d,%d\n", i, j);
- HDprintf(" origin_direct_buf=%d, check_chunk=%d\n", origin_direct_buf[i][j], check_chunk[i][j]);
+ HDprintf(" origin_direct_buf=%d, check_chunk=%d\n", origin_direct_buf[i][j],
+ check_chunk[i][j]);
goto error;
}
}
}
/* Query chunk storage size */
- if((status = H5Dget_chunk_storage_size(dataset, offset, &read_buf_size)) < 0)
+ if ((status = H5Dget_chunk_storage_size(dataset, offset, &read_buf_size)) < 0)
goto error;
- if(read_buf_size != buf_size)
+ if (read_buf_size != buf_size)
goto error;
/* Read the raw chunk back */
HDmemset(&read_direct_buf, 0, sizeof(read_direct_buf));
- if((status = H5DOread_chunk(dataset, H5P_DEFAULT, offset, &read_filter_mask, read_direct_buf)) < 0)
+ if ((status = H5DOread_chunk(dataset, H5P_DEFAULT, offset, &read_filter_mask, read_direct_buf)) < 0)
goto error;
- if(read_filter_mask != filter_mask)
+ if (read_filter_mask != filter_mask)
goto error;
/* Check that the direct chunk read is the same as the chunk written */
- for(i = 0; i < CHUNK_NX; i++) {
- for(j = 0; j < CHUNK_NY; j++) {
- if(direct_buf[i][j] != read_direct_buf[i][j]) {
+ for (i = 0; i < CHUNK_NX; i++) {
+ for (j = 0; j < CHUNK_NY; j++) {
+ if (direct_buf[i][j] != read_direct_buf[i][j]) {
HDprintf(" 1. Read different values than written.");
HDprintf(" At index %d,%d\n", i, j);
HDprintf(" direct_buf=%d, read_direct_buf=%d\n", direct_buf[i][j], read_direct_buf[i][j]);
@@ -892,13 +928,15 @@ test_skip_compress_write2(hid_t file)
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(dataset);
H5Sclose(mem_space);
H5Sclose(dataspace);
H5Pclose(cparms);
H5Pclose(dxpl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return 1;
@@ -924,99 +962,98 @@ test_data_conv(hid_t file)
int a, b, c[4], d, e;
} src_type_t;
typedef struct {
- int a, c[4], e;
+ int a, c[4], e;
} dst_type_t;
- 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 maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
- hsize_t chunk_dims[2] ={CHUNK_NX, CHUNK_NY};
- herr_t status;
- int i, j, n;
- const hsize_t four = 4;
- hid_t st=-1, dt=-1;
- hid_t array_dt;
-
- unsigned filter_mask = 0;
- src_type_t direct_buf[CHUNK_NX][CHUNK_NY];
- dst_type_t check_chunk[CHUNK_NX][CHUNK_NY];
- src_type_t read_chunk[CHUNK_NX][CHUNK_NY]; /* For H5DOread_chunk */
-
- hsize_t offset[2] = {0, 0};
- size_t buf_size = CHUNK_NX*CHUNK_NY*sizeof(src_type_t);
+ 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 maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
+ hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY};
+ herr_t status;
+ int i, j, n;
+ const hsize_t four = 4;
+ hid_t st = -1, dt = -1;
+ hid_t array_dt;
+
+ unsigned filter_mask = 0;
+ src_type_t direct_buf[CHUNK_NX][CHUNK_NY];
+ dst_type_t check_chunk[CHUNK_NX][CHUNK_NY];
+ src_type_t read_chunk[CHUNK_NX][CHUNK_NY]; /* For H5DOread_chunk */
+
+ hsize_t offset[2] = {0, 0};
+ size_t buf_size = CHUNK_NX * CHUNK_NY * sizeof(src_type_t);
hsize_t start[2]; /* Start of hyperslab */
hsize_t stride[2]; /* Stride of hyperslab */
hsize_t count[2]; /* Block count */
hsize_t block[2]; /* Block sizes */
- TESTING("data conversion for H5DOwrite_chunk/H5DOread_chunk");
+ HL_TESTING2("data conversion for H5DOwrite_chunk/H5DOread_chunk");
/*
* Create the data space with unlimited dimensions.
*/
- if((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0)
+ if ((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0)
goto error;
- if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
+ if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
goto error;
/*
* Modify dataset creation properties, i.e. enable chunking
*/
- if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto error;
- if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0)
+ if ((status = H5Pset_chunk(cparms, RANK, chunk_dims)) < 0)
goto error;
/* Build hdf5 datatypes */
array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, &four);
- if((st = H5Tcreate(H5T_COMPOUND, sizeof(src_type_t))) < 0 ||
- H5Tinsert(st, "a", HOFFSET(src_type_t, a), H5T_NATIVE_INT) < 0 ||
- H5Tinsert(st, "b", HOFFSET(src_type_t, b), H5T_NATIVE_INT) < 0 ||
- H5Tinsert(st, "c", HOFFSET(src_type_t, c), array_dt) < 0 ||
- H5Tinsert(st, "d", HOFFSET(src_type_t, d), H5T_NATIVE_INT) < 0 ||
- H5Tinsert(st, "e", HOFFSET(src_type_t, e), H5T_NATIVE_INT) < 0)
+ if ((st = H5Tcreate(H5T_COMPOUND, sizeof(src_type_t))) < 0 ||
+ H5Tinsert(st, "a", HOFFSET(src_type_t, a), H5T_NATIVE_INT) < 0 ||
+ H5Tinsert(st, "b", HOFFSET(src_type_t, b), H5T_NATIVE_INT) < 0 ||
+ H5Tinsert(st, "c", HOFFSET(src_type_t, c), array_dt) < 0 ||
+ H5Tinsert(st, "d", HOFFSET(src_type_t, d), H5T_NATIVE_INT) < 0 ||
+ H5Tinsert(st, "e", HOFFSET(src_type_t, e), H5T_NATIVE_INT) < 0)
goto error;
- if(H5Tclose(array_dt) < 0)
+ if (H5Tclose(array_dt) < 0)
goto error;
array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, &four);
- if((dt = H5Tcreate(H5T_COMPOUND, sizeof(dst_type_t))) < 0 ||
- H5Tinsert(dt, "a", HOFFSET(dst_type_t, a), H5T_NATIVE_INT) < 0 ||
- H5Tinsert(dt, "c", HOFFSET(dst_type_t, c), array_dt) < 0 ||
- H5Tinsert(dt, "e", HOFFSET(dst_type_t, e), H5T_NATIVE_INT) < 0)
+ if ((dt = H5Tcreate(H5T_COMPOUND, sizeof(dst_type_t))) < 0 ||
+ H5Tinsert(dt, "a", HOFFSET(dst_type_t, a), H5T_NATIVE_INT) < 0 ||
+ H5Tinsert(dt, "c", HOFFSET(dst_type_t, c), array_dt) < 0 ||
+ H5Tinsert(dt, "e", HOFFSET(dst_type_t, e), H5T_NATIVE_INT) < 0)
goto error;
- if(H5Tclose(array_dt) < 0)
+ if (H5Tclose(array_dt) < 0)
goto error;
/*
* Create a new dataset within the file using cparms
* creation properties.
*/
- if((dataset = H5Dcreate2(file, DATASETNAME4, st, dataspace, H5P_DEFAULT,
- cparms, H5P_DEFAULT)) < 0)
+ if ((dataset = H5Dcreate2(file, DATASETNAME4, st, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0)
goto error;
- if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 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]).a = i*j+0;
- (direct_buf[i][j]).b = i*j+1;
- (direct_buf[i][j]).c[0] = i*j+2;
- (direct_buf[i][j]).c[1] = i*j+3;
- (direct_buf[i][j]).c[2] = i*j+4;
- (direct_buf[i][j]).c[3] = i*j+5;
- (direct_buf[i][j]).d = i*j+6;
- (direct_buf[i][j]).e = i*j+7;
+ for (i = n = 0; i < CHUNK_NX; i++) {
+ for (j = 0; j < CHUNK_NY; j++) {
+ (direct_buf[i][j]).a = i * j + 0;
+ (direct_buf[i][j]).b = i * j + 1;
+ (direct_buf[i][j]).c[0] = i * j + 2;
+ (direct_buf[i][j]).c[1] = i * j + 3;
+ (direct_buf[i][j]).c[2] = i * j + 4;
+ (direct_buf[i][j]).c[3] = i * j + 5;
+ (direct_buf[i][j]).d = i * j + 6;
+ (direct_buf[i][j]).e = i * j + 7;
}
}
@@ -1025,43 +1062,45 @@ test_data_conv(hid_t file)
offset[0] = CHUNK_NX;
offset[1] = CHUNK_NY;
- if((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) < 0)
+ if ((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) < 0)
goto error;
- if(H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0)
+ if (H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0)
goto error;
- if(H5Dclose(dataset) < 0)
+ if (H5Dclose(dataset) < 0)
goto error;
- if((dataset = H5Dopen2(file, DATASETNAME4, H5P_DEFAULT)) < 0)
+ if ((dataset = H5Dopen2(file, DATASETNAME4, H5P_DEFAULT)) < 0)
goto error;
/* Use H5DOread_chunk() to read the uncompressed data */
- if((status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, read_chunk)) < 0)
+ if ((status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, read_chunk)) < 0)
goto error;
/* Check that the values read are the same as the values written */
- for(i = 0; i < CHUNK_NX; i++) {
- for(j = 0; j < CHUNK_NY; j++) {
- if ((direct_buf[i][j]).a != (read_chunk[i][j]).a ||
- (direct_buf[i][j]).b != (read_chunk[i][j]).b ||
+ for (i = 0; i < CHUNK_NX; i++) {
+ for (j = 0; j < CHUNK_NY; j++) {
+ if ((direct_buf[i][j]).a != (read_chunk[i][j]).a ||
+ (direct_buf[i][j]).b != (read_chunk[i][j]).b ||
(direct_buf[i][j]).c[0] != (read_chunk[i][j]).c[0] ||
(direct_buf[i][j]).c[1] != (read_chunk[i][j]).c[1] ||
(direct_buf[i][j]).c[2] != (read_chunk[i][j]).c[2] ||
(direct_buf[i][j]).c[3] != (read_chunk[i][j]).c[3] ||
- (direct_buf[i][j]).d != (read_chunk[i][j]).d ||
- (direct_buf[i][j]).e != (read_chunk[i][j]).e) {
- HDprintf(" 1. Read different values than written.");
- HDprintf(" At index %d,%d\n", i, j);
- HDprintf(" src={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n",
- (direct_buf[i][j]).a, (direct_buf[i][j]).b, (direct_buf[i][j]).c[0], (direct_buf[i][j]).c[1],
- (direct_buf[i][j]).c[2], (direct_buf[i][j]).c[3], (direct_buf[i][j]).d, (direct_buf[i][j]).e);
- HDprintf(" dst={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n",
- (read_chunk[i][j]).a, (read_chunk[i][j]).b, (read_chunk[i][j]).c[0], (read_chunk[i][j]).c[1],
- (read_chunk[i][j]).c[2], (read_chunk[i][j]).c[3], (read_chunk[i][j]).d, (read_chunk[i][j]).e);
-
- goto error;
+ (direct_buf[i][j]).d != (read_chunk[i][j]).d ||
+ (direct_buf[i][j]).e != (read_chunk[i][j]).e) {
+ HDprintf(" 1. Read different values than written.");
+ HDprintf(" At index %d,%d\n", i, j);
+ HDprintf(" src={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", (direct_buf[i][j]).a,
+ (direct_buf[i][j]).b, (direct_buf[i][j]).c[0], (direct_buf[i][j]).c[1],
+ (direct_buf[i][j]).c[2], (direct_buf[i][j]).c[3], (direct_buf[i][j]).d,
+ (direct_buf[i][j]).e);
+ HDprintf(" dst={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", (read_chunk[i][j]).a,
+ (read_chunk[i][j]).b, (read_chunk[i][j]).c[0], (read_chunk[i][j]).c[1],
+ (read_chunk[i][j]).c[2], (read_chunk[i][j]).c[3], (read_chunk[i][j]).d,
+ (read_chunk[i][j]).e);
+
+ goto error;
}
}
}
@@ -1069,36 +1108,41 @@ test_data_conv(hid_t file)
/*
* Select hyperslab for the chunk just written in the file
*/
- start[0] = CHUNK_NX; start[1] = CHUNK_NY;
- stride[0] = 1; stride[1] = 1;
- count[0] = 1; count[1] = 1;
- block[0] = CHUNK_NX; block[1] = CHUNK_NY;
- if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
+ start[0] = CHUNK_NX;
+ start[1] = CHUNK_NY;
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = 1;
+ count[1] = 1;
+ block[0] = CHUNK_NX;
+ block[1] = CHUNK_NY;
+ if ((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
goto error;
/* Read the chunk back. Data should be converted */
- if((status = H5Dread(dataset, dt, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0)
+ if ((status = H5Dread(dataset, dt, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0)
goto error;
/* Check that the values read are the same as the values written */
- for(i = 0; i < CHUNK_NX; i++) {
- for(j = 0; j < CHUNK_NY; j++) {
- if ((direct_buf[i][j]).a != (check_chunk[i][j]).a ||
+ for (i = 0; i < CHUNK_NX; i++) {
+ for (j = 0; j < CHUNK_NY; j++) {
+ if ((direct_buf[i][j]).a != (check_chunk[i][j]).a ||
(direct_buf[i][j]).c[0] != (check_chunk[i][j]).c[0] ||
(direct_buf[i][j]).c[1] != (check_chunk[i][j]).c[1] ||
(direct_buf[i][j]).c[2] != (check_chunk[i][j]).c[2] ||
(direct_buf[i][j]).c[3] != (check_chunk[i][j]).c[3] ||
- (direct_buf[i][j]).e != (check_chunk[i][j]).e) {
- HDprintf(" 1. Read different values than written.");
- HDprintf(" At index %d,%d\n", i, j);
- HDprintf(" src={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n",
- (direct_buf[i][j]).a, (direct_buf[i][j]).b, (direct_buf[i][j]).c[0], (direct_buf[i][j]).c[1],
- (direct_buf[i][j]).c[2], (direct_buf[i][j]).c[3], (direct_buf[i][j]).d, (direct_buf[i][j]).e);
- HDprintf(" dst={a=%d, c=[%d,%d,%d,%d], e=%d\n",
- (check_chunk[i][j]).a, (check_chunk[i][j]).c[0], (check_chunk[i][j]).c[1], (check_chunk[i][j]).c[2],
- (check_chunk[i][j]).c[3], (check_chunk[i][j]).e);
-
- goto error;
+ (direct_buf[i][j]).e != (check_chunk[i][j]).e) {
+ HDprintf(" 1. Read different values than written.");
+ HDprintf(" At index %d,%d\n", i, j);
+ HDprintf(" src={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", (direct_buf[i][j]).a,
+ (direct_buf[i][j]).b, (direct_buf[i][j]).c[0], (direct_buf[i][j]).c[1],
+ (direct_buf[i][j]).c[2], (direct_buf[i][j]).c[3], (direct_buf[i][j]).d,
+ (direct_buf[i][j]).e);
+ HDprintf(" dst={a=%d, c=[%d,%d,%d,%d], e=%d\n", (check_chunk[i][j]).a,
+ (check_chunk[i][j]).c[0], (check_chunk[i][j]).c[1], (check_chunk[i][j]).c[2],
+ (check_chunk[i][j]).c[3], (check_chunk[i][j]).e);
+
+ goto error;
}
}
}
@@ -1114,12 +1158,12 @@ test_data_conv(hid_t file)
H5Tclose(st);
H5Tclose(dt);
-
PASSED();
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(dataset);
H5Sclose(mem_space);
H5Sclose(dataspace);
@@ -1127,7 +1171,8 @@ error:
H5Pclose(dxpl);
H5Tclose(st);
H5Tclose(dt);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return 1;
@@ -1149,52 +1194,52 @@ error:
static int
test_invalid_parameters(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 chunk_dims[2] ={CHUNK_NX, CHUNK_NY};
- herr_t status;
- int i, j, n;
+ 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 chunk_dims[2] = {CHUNK_NX, CHUNK_NY};
+ herr_t status;
+ int i, j, n;
- unsigned filter_mask = 0;
- int direct_buf[CHUNK_NX][CHUNK_NY];
- hsize_t offset[2] = {0, 0};
- size_t buf_size = CHUNK_NX*CHUNK_NY*sizeof(int);
- int aggression = 9; /* Compression aggression setting */
+ unsigned filter_mask = 0;
+ int direct_buf[CHUNK_NX][CHUNK_NY];
+ hsize_t offset[2] = {0, 0};
+ size_t buf_size = CHUNK_NX * CHUNK_NY * sizeof(int);
+ int aggression = 9; /* Compression aggression setting */
- hsize_t chunk_nbytes; /* Chunk size */
+ hsize_t chunk_nbytes; /* Chunk size */
- TESTING("invalid parameters for H5DOwrite_chunk/H5DOread_chunk");
+ HL_TESTING2("invalid parameters for H5DOwrite_chunk/H5DOread_chunk");
/*
* Create the data space with unlimited dimensions.
*/
- if((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0)
+ if ((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0)
goto error;
- if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
+ if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
goto error;
/*
* Modify dataset creation properties
*/
- if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto error;
/*
* Create a new contiguous dataset to verify H5DOwrite_chunk/H5DOread_chunk doesn't work
*/
- if((dataset = H5Dcreate2(file, DATASETNAME5, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
- cparms, H5P_DEFAULT)) < 0)
+ if ((dataset =
+ H5Dcreate2(file, DATASETNAME5, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0)
goto error;
- if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
goto error;
/* Initialize data for one chunk */
- for(i = n = 0; i < CHUNK_NX; i++)
- for(j = 0; j < CHUNK_NY; j++) {
+ for (i = n = 0; i < CHUNK_NX; i++)
+ for (j = 0; j < CHUNK_NY; j++) {
direct_buf[i][j] = n++;
}
@@ -1202,123 +1247,154 @@ test_invalid_parameters(hid_t file)
offset[0] = CHUNK_NX;
offset[1] = CHUNK_NY;
- H5E_BEGIN_TRY {
- if((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL)
+ H5E_BEGIN_TRY
+ {
+ if ((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL)
goto error;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
/* Try to get chunk size for a contiguous dataset. It should fail */
- H5E_BEGIN_TRY {
- if((status = H5Dget_chunk_storage_size(dataset, offset, &chunk_nbytes)) != FAIL)
+ H5E_BEGIN_TRY
+ {
+ if ((status = H5Dget_chunk_storage_size(dataset, offset, &chunk_nbytes)) != FAIL)
goto error;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
/* Try to H5DOread_chunk from the contiguous dataset. It should fail */
- H5E_BEGIN_TRY {
- if((status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, direct_buf)) != FAIL)
+ H5E_BEGIN_TRY
+ {
+ if ((status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, direct_buf)) != FAIL)
goto error;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
- if(H5Dclose(dataset) < 0)
+ if (H5Dclose(dataset) < 0)
goto error;
-
/* Create a chunked dataset with compression filter */
- if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0)
+ if ((status = H5Pset_chunk(cparms, RANK, chunk_dims)) < 0)
goto error;
- if((status = H5Pset_deflate( cparms, (unsigned ) aggression)) < 0)
+ if ((status = H5Pset_deflate(cparms, (unsigned)aggression)) < 0)
goto error;
/*
* Create a new dataset within the file using cparms
* creation properties.
*/
- if((dataset = H5Dcreate2(file, DATASETNAME6, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
- cparms, H5P_DEFAULT)) < 0)
+ if ((dataset =
+ H5Dcreate2(file, DATASETNAME6, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0)
goto error;
/* Check invalid dataset ID for H5DOwrite_chunk and H5DOread_chunk */
- H5E_BEGIN_TRY {
- if((status = H5DOwrite_chunk((hid_t)-1, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL)
+ H5E_BEGIN_TRY
+ {
+ if ((status = H5DOwrite_chunk((hid_t)-1, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL)
goto error;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
- H5E_BEGIN_TRY {
- if((status = H5DOread_chunk((hid_t)-1, dxpl, offset, &filter_mask, direct_buf)) != FAIL)
+ H5E_BEGIN_TRY
+ {
+ if ((status = H5DOread_chunk((hid_t)-1, dxpl, offset, &filter_mask, direct_buf)) != FAIL)
goto error;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
/* Check invalid DXPL ID for H5DOwrite_chunk and H5DOread_chunk */
- H5E_BEGIN_TRY {
- if((status = H5DOwrite_chunk(dataset, (hid_t)-1, filter_mask, offset, buf_size, direct_buf)) != FAIL)
+ H5E_BEGIN_TRY
+ {
+ if ((status = H5DOwrite_chunk(dataset, (hid_t)-1, filter_mask, offset, buf_size, direct_buf)) != FAIL)
goto error;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
- H5E_BEGIN_TRY {
- if((status = H5DOread_chunk(dataset, (hid_t)-1, offset, &filter_mask, direct_buf)) != FAIL)
+ H5E_BEGIN_TRY
+ {
+ if ((status = H5DOread_chunk(dataset, (hid_t)-1, offset, &filter_mask, direct_buf)) != FAIL)
goto error;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
/* Check invalid OFFSET for H5DOwrite_chunk and H5DOread_chunk */
- H5E_BEGIN_TRY {
- if((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, NULL, buf_size, direct_buf)) != FAIL)
+ H5E_BEGIN_TRY
+ {
+ if ((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, NULL, buf_size, direct_buf)) != FAIL)
goto error;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
- H5E_BEGIN_TRY {
- if((status = H5DOread_chunk(dataset, dxpl, NULL, &filter_mask, direct_buf)) != FAIL)
+ H5E_BEGIN_TRY
+ {
+ if ((status = H5DOread_chunk(dataset, dxpl, NULL, &filter_mask, direct_buf)) != FAIL)
goto error;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
/* Check when OFFSET is out of dataset range for H5DOwrite_chunk and H5DOread_chunk */
offset[0] = NX + 1;
offset[1] = NY;
- H5E_BEGIN_TRY {
- if((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL)
+ H5E_BEGIN_TRY
+ {
+ if ((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL)
goto error;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
- H5E_BEGIN_TRY {
- if((status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, direct_buf)) != FAIL)
+ H5E_BEGIN_TRY
+ {
+ if ((status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, direct_buf)) != FAIL)
goto error;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
/* Check when OFFSET is not on chunk boundary for H5DOwrite_chunk and H5DOread_chunk */
offset[0] = CHUNK_NX;
offset[1] = CHUNK_NY + 1;
- H5E_BEGIN_TRY {
- if((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL)
+ H5E_BEGIN_TRY
+ {
+ if ((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL)
goto error;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
- H5E_BEGIN_TRY {
- if((status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, direct_buf)) != FAIL)
+ H5E_BEGIN_TRY
+ {
+ if ((status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, direct_buf)) != FAIL)
goto error;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
/* Check invalid buffer size for H5DOwrite_chunk only */
offset[0] = CHUNK_NX;
offset[1] = CHUNK_NY;
- buf_size = 0;
- H5E_BEGIN_TRY {
- if((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL)
+ buf_size = 0;
+ H5E_BEGIN_TRY
+ {
+ if ((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL)
goto error;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
/* Check invalid data buffer for H5DOwrite_chunk and H5DOread_chunk */
- buf_size = CHUNK_NX*CHUNK_NY*sizeof(int);
- H5E_BEGIN_TRY {
- if((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, NULL)) != FAIL)
+ buf_size = CHUNK_NX * CHUNK_NY * sizeof(int);
+ H5E_BEGIN_TRY
+ {
+ if ((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, NULL)) != FAIL)
goto error;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
- H5E_BEGIN_TRY {
- if((status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, NULL)) != FAIL)
+ H5E_BEGIN_TRY
+ {
+ if ((status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, NULL)) != FAIL)
goto error;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
- if(H5Dclose(dataset) < 0)
+ if (H5Dclose(dataset) < 0)
goto error;
/*
@@ -1333,13 +1409,15 @@ test_invalid_parameters(hid_t file)
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(dataset);
H5Sclose(mem_space);
H5Sclose(dataspace);
H5Pclose(cparms);
H5Pclose(dxpl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return 1;
@@ -1361,130 +1439,138 @@ error:
*/
#ifdef H5_HAVE_FILTER_DEFLATE
static int
-test_direct_chunk_read_no_cache (hid_t file)
+test_direct_chunk_read_no_cache(hid_t file)
{
- hid_t dataspace = -1, dataset = -1;
- hid_t mem_space = -1;
- hid_t cparms = -1, dxpl = -1, dapl = -1;
- 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; /* status from H5 function calls */
- int ret; /* deflate return status */
- int data[NX][NY];
- int i, j, k, l, n; /* local index variables */
-
- unsigned filter_mask = 0; /* filter mask returned from H5DOread_chunk */
- int direct_buf[CHUNK_NX][CHUNK_NY]; /* chunk read with H5DOread and manually decompressed */
- int check_chunk[CHUNK_NX][CHUNK_NY]; /* chunk read with H5Dread */
- hsize_t offset[2]; /* chunk offset used for H5DOread_chunk */
- size_t buf_size = CHUNK_NX*CHUNK_NY*sizeof(int);
-
- Bytef *z_src = NULL; /* source buffer */
- uLongf z_src_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size);
- Bytef *z_dst = (Bytef*)(direct_buf);
- uLong z_dst_nbytes = (uLong)buf_size;
- int aggression = 9; /* Compression aggression setting */
- void *outbuf = NULL; /* Pointer to new buffer */
+ hid_t dataspace = -1, dataset = -1;
+ hid_t mem_space = -1;
+ hid_t cparms = -1, dxpl = -1, dapl = -1;
+ 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; /* status from H5 function calls */
+ int ret; /* deflate return status */
+ int data[NX][NY];
+ int i, j, k, l, n; /* local index variables */
+
+ unsigned filter_mask = 0; /* filter mask returned from H5DOread_chunk */
+ int direct_buf[CHUNK_NX][CHUNK_NY]; /* chunk read with H5DOread and manually decompressed */
+ int check_chunk[CHUNK_NX][CHUNK_NY]; /* chunk read with H5Dread */
+ hsize_t offset[2]; /* chunk offset used for H5DOread_chunk */
+ size_t buf_size = CHUNK_NX * CHUNK_NY * sizeof(int);
+
+ Bytef *z_src = NULL; /* source buffer */
+ uLongf z_src_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size);
+ Bytef *z_dst = (Bytef *)(direct_buf);
+ uLong z_dst_nbytes = (uLong)buf_size;
+ int aggression = 9; /* Compression aggression setting */
+ void * outbuf = NULL; /* Pointer to new buffer */
hsize_t start[2]; /* Start of hyperslab */
hsize_t stride[2]; /* Stride of hyperslab */
hsize_t count[2]; /* Block count */
hsize_t block[2]; /* Block sizes */
- TESTING("basic functionality of H5DOread_chunk (chunk cache disabled)");
+ HL_TESTING2("basic functionality of H5DOread_chunk (chunk cache disabled)");
/* Create the data space with unlimited dimensions. */
- if((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0)
+ if ((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0)
goto error;
- if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
+ if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
goto error;
/* Modify dataset creation properties, i.e. enable chunking and compression */
- if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto error;
- if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0)
+ if ((status = H5Pset_chunk(cparms, RANK, chunk_dims)) < 0)
goto error;
- if((status = H5Pset_deflate( cparms, (unsigned) aggression)) < 0)
+ if ((status = H5Pset_deflate(cparms, (unsigned)aggression)) < 0)
goto error;
- if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
+ if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
goto error;
/* Disable chunk cache by setting number of slots to 0 */
- if((status = H5Pset_chunk_cache(dapl, 0, H5D_CHUNK_CACHE_NBYTES_DEFAULT, H5D_CHUNK_CACHE_W0_DEFAULT)) < 0)
+ if ((status = H5Pset_chunk_cache(dapl, 0, H5D_CHUNK_CACHE_NBYTES_DEFAULT, H5D_CHUNK_CACHE_W0_DEFAULT)) <
+ 0)
goto error;
/* Create a new dataset within the file using cparms creation properties. */
- if((dataset = H5Dcreate2(file, DATASETNAME8, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
- cparms, dapl)) < 0)
+ if ((dataset = H5Dcreate2(file, DATASETNAME8, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, dapl)) < 0)
goto error;
/* Initialize the dataset */
- for(i = n = 0; i < NX; i++)
- for(j = 0; j < NY; j++)
+ for (i = n = 0; i < NX; i++)
+ for (j = 0; j < NY; j++)
data[i][j] = n++;
- if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
goto error;
/* Write the data for the dataset.
* Data will skip chunk cache and go directly to disk. */
- if((status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- dxpl, data)) < 0)
+ if ((status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, data)) < 0)
goto error;
/* Allocate output (compressed) buffer */
outbuf = HDmalloc(z_src_nbytes);
- z_src = (Bytef *)outbuf;
+ z_src = (Bytef *)outbuf;
/* For each chunk in the dataset, compare the result of H5Dread and H5DOread_chunk. */
- for(i=0; i<NX/CHUNK_NX; i++) {
- for(j=0; j<NY/CHUNK_NY; j++) {
+ for (i = 0; i < NX / CHUNK_NX; i++) {
+ for (j = 0; j < NY / CHUNK_NY; j++) {
/* Select hyperslab for one chunk in the file */
- start[0] = (hsize_t)i * CHUNK_NX; start[1] = (hsize_t)j * CHUNK_NY;
- stride[0] = 1; stride[1] = 1;
- count[0] = 1; count[1] = 1;
- block[0] = CHUNK_NX; block[1] = CHUNK_NY;
+ start[0] = (hsize_t)i * CHUNK_NX;
+ start[1] = (hsize_t)j * CHUNK_NY;
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = 1;
+ count[1] = 1;
+ block[0] = CHUNK_NX;
+ block[1] = CHUNK_NY;
/* Hyperslab selection equals single chunk */
- if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
+ if ((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
goto error;
/* Read the chunk back */
- if((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0)
+ if ((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) <
+ 0)
goto error;
- offset[0] = (hsize_t)i * CHUNK_NX; offset[1] = (hsize_t)j * CHUNK_NY;
+ offset[0] = (hsize_t)i * CHUNK_NX;
+ offset[1] = (hsize_t)j * CHUNK_NY;
/* Read the compressed chunk back using the direct read function. */
- if((status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, outbuf)) < 0)
+ if ((status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, outbuf)) < 0)
goto error;
/* Check filter mask return value */
- if(filter_mask != 0)
+ if (filter_mask != 0)
goto error;
/* Perform decompression from the source to the destination buffer */
ret = uncompress(z_dst, &z_dst_nbytes, z_src, z_src_nbytes);
/* Check for various zlib errors */
- if(Z_BUF_ERROR == ret) {
+ if (Z_BUF_ERROR == ret) {
HDfprintf(stderr, "overflow\n");
goto error;
- } else if(Z_MEM_ERROR == ret) {
+ }
+ else if (Z_MEM_ERROR == ret) {
HDfprintf(stderr, "deflate memory error\n");
goto error;
- } else if(Z_DATA_ERROR == ret) {
+ }
+ else if (Z_DATA_ERROR == ret) {
HDfprintf(stderr, "corrupted data\n");
goto error;
- } else if(Z_OK != ret) {
+ }
+ else if (Z_OK != ret) {
HDfprintf(stderr, "other deflate error\n");
goto error;
}
/* Check that the decompressed values match those read from H5Dread */
- for(k = 0; k < CHUNK_NX; k++) {
- for(l = 0; l < CHUNK_NY; l++) {
- if(direct_buf[k][l] != check_chunk[k][l]) {
+ for (k = 0; k < CHUNK_NX; k++) {
+ for (l = 0; l < CHUNK_NY; l++) {
+ if (direct_buf[k][l] != check_chunk[k][l]) {
HDprintf("\n 1. Read different values than written.");
HDprintf(" At index %d,%d\n", k, l);
HDprintf(" direct_buf=%d, check_chunk=%d\n", direct_buf[k][l], check_chunk[k][l]);
@@ -1503,23 +1589,25 @@ test_direct_chunk_read_no_cache (hid_t file)
H5Pclose(dxpl);
H5Pclose(dapl);
- if(outbuf)
+ if (outbuf)
HDfree(outbuf);
PASSED();
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(dataset);
H5Sclose(mem_space);
H5Sclose(dataspace);
H5Pclose(cparms);
H5Pclose(dxpl);
H5Pclose(dapl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
- if(outbuf)
+ if (outbuf)
HDfree(outbuf);
H5_FAILED();
@@ -1529,142 +1617,151 @@ error:
#ifdef H5_HAVE_FILTER_DEFLATE
static int
-test_direct_chunk_read_cache (hid_t file, hbool_t flush)
+test_direct_chunk_read_cache(hid_t file, hbool_t flush)
{
- 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 maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
- hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY};
- herr_t status; /* status from H5 function calls */
- int ret; /* deflate return status */
- int data[NX][NY];
- int i, j, k, l, n; /* local index variables */
-
- unsigned filter_mask = 0; /* filter mask returned from H5DOread_chunk */
- int direct_buf[CHUNK_NX][CHUNK_NY]; /* chunk read with H5DOread and manually decompressed */
- int check_chunk[CHUNK_NX][CHUNK_NY]; /* chunk read with H5Dread */
- hsize_t offset[2]; /* chunk offset used for H5DOread_chunk */
- size_t buf_size = CHUNK_NX*CHUNK_NY*sizeof(int);
-
- Bytef *z_src = NULL; /* source buffer */
- uLongf z_src_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size);
- Bytef *z_dst = (Bytef*)(direct_buf);
- uLong z_dst_nbytes = (uLong)buf_size;
- int aggression = 9; /* Compression aggression setting */
- void *outbuf = NULL; /* Pointer to new buffer */
- hsize_t read_buf_size = 0;
+ 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 maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
+ hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY};
+ herr_t status; /* status from H5 function calls */
+ int ret; /* deflate return status */
+ int data[NX][NY];
+ int i, j, k, l, n; /* local index variables */
+
+ unsigned filter_mask = 0; /* filter mask returned from H5DOread_chunk */
+ int direct_buf[CHUNK_NX][CHUNK_NY]; /* chunk read with H5DOread and manually decompressed */
+ int check_chunk[CHUNK_NX][CHUNK_NY]; /* chunk read with H5Dread */
+ hsize_t offset[2]; /* chunk offset used for H5DOread_chunk */
+ size_t buf_size = CHUNK_NX * CHUNK_NY * sizeof(int);
+
+ Bytef * z_src = NULL; /* source buffer */
+ uLongf z_src_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size);
+ Bytef * z_dst = (Bytef *)(direct_buf);
+ uLong z_dst_nbytes = (uLong)buf_size;
+ int aggression = 9; /* Compression aggression setting */
+ void * outbuf = NULL; /* Pointer to new buffer */
+ hsize_t read_buf_size = 0;
hsize_t start[2]; /* Start of hyperslab */
hsize_t stride[2]; /* Stride of hyperslab */
hsize_t count[2]; /* Block count */
hsize_t block[2]; /* Block sizes */
- if(flush) {
- TESTING("basic functionality of H5DOread_chunk (flush chunk cache)");
- } else {
- TESTING("basic functionality of H5DOread_chunk (does not flush chunk cache)");
+ if (flush) {
+ HL_TESTING2("basic functionality of H5DOread_chunk (flush chunk cache)");
+ }
+ else {
+ HL_TESTING2("basic functionality of H5DOread_chunk (does not flush chunk cache)");
}
/* Create the data space with unlimited dimensions. */
- if((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0)
+ if ((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0)
goto error;
- if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
+ if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
goto error;
/* Modify dataset creation properties, i.e. enable chunking and compression */
- if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto error;
- if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0)
+ if ((status = H5Pset_chunk(cparms, RANK, chunk_dims)) < 0)
goto error;
- if((status = H5Pset_deflate( cparms, (unsigned) aggression)) < 0)
+ if ((status = H5Pset_deflate(cparms, (unsigned)aggression)) < 0)
goto error;
/* Create a new dataset within the file using cparms creation properties. */
- if((dataset = H5Dcreate2(file, flush?DATASETNAME9:DATASETNAME10, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
- cparms, H5P_DEFAULT)) < 0)
+ if ((dataset = H5Dcreate2(file, flush ? DATASETNAME9 : DATASETNAME10, H5T_NATIVE_INT, dataspace,
+ H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0)
goto error;
/* Initialize the dataset */
- for(i = n = 0; i < NX; i++)
- for(j = 0; j < NY; j++)
+ for (i = n = 0; i < NX; i++)
+ for (j = 0; j < NY; j++)
data[i][j] = n++;
- if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
goto error;
/* Write the data for the dataset.
* It should stay in the chunk cache. */
- if((status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- dxpl, data)) < 0)
+ if ((status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, data)) < 0)
goto error;
- if(flush) {
+ if (flush) {
/* Flush the chunk cache to disk. Cache entry is not evicted. */
- if(H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0)
+ if (H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0)
goto error;
}
/* Allocate output (compressed) buffer */
outbuf = HDmalloc(z_src_nbytes);
- z_src = (Bytef *)outbuf;
+ z_src = (Bytef *)outbuf;
/* For each chunk in the dataset, compare the result of H5Dread and H5DOread_chunk. */
- for(i=0; i<NX/CHUNK_NX; i++) {
- for(j=0; j<NY/CHUNK_NY; j++) {
+ for (i = 0; i < NX / CHUNK_NX; i++) {
+ for (j = 0; j < NY / CHUNK_NY; j++) {
/* Select hyperslab for one chunk in the file */
- start[0] = (hsize_t)i * CHUNK_NX; start[1] = (hsize_t)j * CHUNK_NY;
- stride[0] = 1; stride[1] = 1;
- count[0] = 1; count[1] = 1;
- block[0] = CHUNK_NX; block[1] = CHUNK_NY;
+ start[0] = (hsize_t)i * CHUNK_NX;
+ start[1] = (hsize_t)j * CHUNK_NY;
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = 1;
+ count[1] = 1;
+ block[0] = CHUNK_NX;
+ block[1] = CHUNK_NY;
/* Hyperslab selection equals single chunk */
- if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
+ if ((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
goto error;
/* Read the chunk back */
- if((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0)
+ if ((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) <
+ 0)
goto error;
- offset[0] = (hsize_t)i * CHUNK_NX; offset[1] = (hsize_t)j * CHUNK_NY;
+ offset[0] = (hsize_t)i * CHUNK_NX;
+ offset[1] = (hsize_t)j * CHUNK_NY;
/* Query chunk storage size */
- if((status = H5Dget_chunk_storage_size(dataset, offset, &read_buf_size)) < 0)
+ if ((status = H5Dget_chunk_storage_size(dataset, offset, &read_buf_size)) < 0)
goto error;
- if(read_buf_size == 0)
+ if (read_buf_size == 0)
goto error;
/* Read the compressed chunk back using the direct read function. */
- if((status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, outbuf)) < 0)
+ if ((status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, outbuf)) < 0)
goto error;
/* Check filter mask return value */
- if(filter_mask != 0)
+ if (filter_mask != 0)
goto error;
/* Perform decompression from the source to the destination buffer */
ret = uncompress(z_dst, &z_dst_nbytes, z_src, z_src_nbytes);
/* Check for various zlib errors */
- if(Z_BUF_ERROR == ret) {
+ if (Z_BUF_ERROR == ret) {
HDfprintf(stderr, "overflow\n");
goto error;
- } else if(Z_MEM_ERROR == ret) {
+ }
+ else if (Z_MEM_ERROR == ret) {
HDfprintf(stderr, "deflate memory error\n");
goto error;
- } else if(Z_DATA_ERROR == ret) {
+ }
+ else if (Z_DATA_ERROR == ret) {
HDfprintf(stderr, "corrupted data\n");
goto error;
- } else if(Z_OK != ret) {
+ }
+ else if (Z_OK != ret) {
HDfprintf(stderr, "other deflate error\n");
goto error;
}
/* Check that the decompressed values match those read from H5Dread */
- for(k = 0; k < CHUNK_NX; k++) {
- for(l = 0; l < CHUNK_NY; l++) {
- if(direct_buf[k][l] != check_chunk[k][l]) {
+ for (k = 0; k < CHUNK_NX; k++) {
+ for (l = 0; l < CHUNK_NY; l++) {
+ if (direct_buf[k][l] != check_chunk[k][l]) {
HDprintf("\n 1. Read different values than written.");
HDprintf(" At index %d,%d\n", k, l);
HDprintf(" direct_buf=%d, check_chunk=%d\n", direct_buf[k][l], check_chunk[k][l]);
@@ -1682,22 +1779,24 @@ test_direct_chunk_read_cache (hid_t file, hbool_t flush)
H5Pclose(cparms);
H5Pclose(dxpl);
- if(outbuf)
+ if (outbuf)
HDfree(outbuf);
PASSED();
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(dataset);
H5Sclose(mem_space);
H5Sclose(dataspace);
H5Pclose(cparms);
H5Pclose(dxpl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
- if(outbuf)
+ if (outbuf)
HDfree(outbuf);
H5_FAILED();
@@ -1722,104 +1821,109 @@ error:
static int
test_read_unfiltered_dset(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 maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
- hsize_t chunk_dims[2] ={CHUNK_NX, CHUNK_NY};
- herr_t status;
- int data[NX][NY];
- int i, j, k, l, n;
-
- unsigned filter_mask = 0;
- int direct_buf[CHUNK_NX][CHUNK_NY];
- int check_chunk[CHUNK_NX][CHUNK_NY]; /* chunk read with H5Dread */
- hsize_t offset[2] = {0, 0};
- size_t buf_size = CHUNK_NX*CHUNK_NY*sizeof(int);
- hsize_t read_buf_size = 0;
+ 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 maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
+ hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY};
+ herr_t status;
+ int data[NX][NY];
+ int i, j, k, l, n;
+
+ unsigned filter_mask = 0;
+ int direct_buf[CHUNK_NX][CHUNK_NY];
+ int check_chunk[CHUNK_NX][CHUNK_NY]; /* chunk read with H5Dread */
+ hsize_t offset[2] = {0, 0};
+ size_t buf_size = CHUNK_NX * CHUNK_NY * sizeof(int);
+ hsize_t read_buf_size = 0;
hsize_t start[2]; /* Start of hyperslab */
hsize_t stride[2]; /* Stride of hyperslab */
hsize_t count[2]; /* Block count */
hsize_t block[2]; /* Block sizes */
- TESTING("basic functionality of H5DOread_chunk on unfiltered datasets");
+ HL_TESTING2("basic functionality of H5DOread_chunk on unfiltered datasets");
/* Create the data space with unlimited dimensions. */
- if((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0)
+ if ((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0)
goto error;
- if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
+ if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
goto error;
/* Modify dataset creation properties, i.e. enable chunking, no compression */
- if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto error;
- if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0)
+ if ((status = H5Pset_chunk(cparms, RANK, chunk_dims)) < 0)
goto error;
/* Create a new dataset within the file using cparms creation properties. */
- if((dataset = H5Dcreate2(file, DATASETNAME12, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
- cparms, H5P_DEFAULT)) < 0)
+ if ((dataset = H5Dcreate2(file, DATASETNAME12, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms,
+ H5P_DEFAULT)) < 0)
goto error;
/* Initialize the dataset */
- for(i = n = 0; i < NX; i++)
- for(j = 0; j < NY; j++)
+ for (i = n = 0; i < NX; i++)
+ for (j = 0; j < NY; j++)
data[i][j] = n++;
- if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
goto error;
/* Write the data for the dataset.
* It should stay in the chunk cache and will be evicted/flushed by
* the H5DOread_chunk function call. */
- if((status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- dxpl, data)) < 0)
+ if ((status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, data)) < 0)
goto error;
- if(H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0)
+ if (H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0)
goto error;
/* For each chunk in the dataset, compare the result of H5Dread and H5DOread_chunk. */
- for(i=0; i<NX/CHUNK_NX; i++) {
- for(j=0; j<NY/CHUNK_NY; j++) {
+ for (i = 0; i < NX / CHUNK_NX; i++) {
+ for (j = 0; j < NY / CHUNK_NY; j++) {
/* Select hyperslab for one chunk in the file */
- start[0] = (hsize_t)i * CHUNK_NX; start[1] = (hsize_t)j * CHUNK_NY;
- stride[0] = 1; stride[1] = 1;
- count[0] = 1; count[1] = 1;
- block[0] = CHUNK_NX; block[1] = CHUNK_NY;
+ start[0] = (hsize_t)i * CHUNK_NX;
+ start[1] = (hsize_t)j * CHUNK_NY;
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = 1;
+ count[1] = 1;
+ block[0] = CHUNK_NX;
+ block[1] = CHUNK_NY;
/* Hyperslab selection equals single chunk */
- if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
+ if ((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0)
goto error;
/* Read the chunk back */
- if((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0)
+ if ((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) <
+ 0)
goto error;
/* Query chunk storage size */
- if((status = H5Dget_chunk_storage_size(dataset, offset, &read_buf_size)) < 0)
+ if ((status = H5Dget_chunk_storage_size(dataset, offset, &read_buf_size)) < 0)
goto error;
- if(read_buf_size != buf_size )
+ if (read_buf_size != buf_size)
goto error;
- offset[0] = (hsize_t)i * CHUNK_NX; offset[1] = (hsize_t)j * CHUNK_NY;
+ offset[0] = (hsize_t)i * CHUNK_NX;
+ offset[1] = (hsize_t)j * CHUNK_NY;
/* Read the raw chunk back */
HDmemset(&direct_buf, 0, sizeof(direct_buf));
filter_mask = UINT_MAX;
- if((status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, direct_buf)) < 0)
+ if ((status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, direct_buf)) < 0)
goto error;
/* Check filter mask return value */
- if(filter_mask != 0)
+ if (filter_mask != 0)
goto error;
/* Check that the decompressed values match those read from H5Dread */
- for(k = 0; k < CHUNK_NX; k++) {
- for(l = 0; l < CHUNK_NY; l++) {
- if(direct_buf[k][l] != check_chunk[k][l]) {
+ for (k = 0; k < CHUNK_NX; k++) {
+ for (l = 0; l < CHUNK_NY; l++) {
+ if (direct_buf[k][l] != check_chunk[k][l]) {
HDprintf("\n 1. Read different values than written.");
HDprintf(" At index %d,%d\n", k, l);
HDprintf(" direct_buf=%d, check_chunk=%d\n", direct_buf[k][l], check_chunk[k][l]);
@@ -1841,13 +1945,15 @@ test_read_unfiltered_dset(hid_t file)
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(dataset);
H5Sclose(mem_space);
H5Sclose(dataspace);
H5Pclose(cparms);
H5Pclose(dxpl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return 1;
@@ -1869,82 +1975,80 @@ error:
*-------------------------------------------------------------------------
*/
static int
-test_read_unallocated_chunk (hid_t file)
+test_read_unallocated_chunk(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 maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
- hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY};
- hsize_t chunk_nbytes = CHUNK_NX*CHUNK_NY*sizeof(int);
- hsize_t direct_chunk_nbytes = 0; /* size (bytes) of the on-disk chunk */
- herr_t status; /* status from H5 function calls */
- hsize_t i, j; /* local index variables */
-
- unsigned filter_mask = 0; /* filter mask returned from H5DOread_chunk */
- int direct_buf[CHUNK_NX][CHUNK_NY]; /* chunk read with H5DOread and manually decompressed */
- hsize_t offset[2]; /* chunk offset used for H5DOread_chunk */
-
- TESTING("H5DOread_chunk with unallocated chunks");
+ 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 maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
+ hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY};
+ hsize_t chunk_nbytes = CHUNK_NX * CHUNK_NY * sizeof(int);
+ hsize_t direct_chunk_nbytes = 0; /* size (bytes) of the on-disk chunk */
+ herr_t status; /* status from H5 function calls */
+ hsize_t i, j; /* local index variables */
+
+ unsigned filter_mask = 0; /* filter mask returned from H5DOread_chunk */
+ int direct_buf[CHUNK_NX][CHUNK_NY]; /* chunk read with H5DOread and manually decompressed */
+ hsize_t offset[2]; /* chunk offset used for H5DOread_chunk */
+
+ HL_TESTING2("H5DOread_chunk with unallocated chunks");
/* Create the data space with unlimited dimensions. */
- if((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0)
+ if ((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0)
goto error;
- if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
+ if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0)
goto error;
/* Modify dataset creation properties, i.e. enable chunking, no compression */
- if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto error;
- if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0)
+ if ((status = H5Pset_chunk(cparms, RANK, chunk_dims)) < 0)
goto error;
/* Create a new dataset within the file using cparms creation properties. */
- if((dataset = H5Dcreate2(file, DATASETNAME11, H5T_NATIVE_INT, dataspace, H5P_DEFAULT,
- cparms, H5P_DEFAULT)) < 0)
+ if ((dataset = H5Dcreate2(file, DATASETNAME11, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms,
+ H5P_DEFAULT)) < 0)
goto error;
- if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
goto error;
/* Write a single chunk to intialize the chunk storage */
HDmemset(&chunk_dims, 0, sizeof(chunk_dims));
- offset[0] = 0; offset[1] = 0;
+ offset[0] = 0;
+ offset[1] = 0;
- if(H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, chunk_nbytes, &chunk_dims) < 0)
+ if (H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, chunk_nbytes, &chunk_dims) < 0)
goto error;
/* Attempt to read each chunk in the dataset. Chunks are not allocated,
* therefore we expect the result of H5DOread_chunk to fail. Chunk idx starts
* at 1, since one chunk was written to init the chunk storage. */
- for(i=1; i<NX/CHUNK_NX; i++) {
- for(j=0; j<NY/CHUNK_NY; j++) {
+ for (i = 1; i < NX / CHUNK_NX; i++) {
+ for (j = 0; j < NY / CHUNK_NY; j++) {
offset[0] = i * CHUNK_NX;
offset[1] = j * CHUNK_NY;
/* Read a non-existant chunk using the direct read function. */
- H5E_BEGIN_TRY {
- status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, &direct_buf);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { status = H5DOread_chunk(dataset, dxpl, offset, &filter_mask, &direct_buf); }
+ H5E_END_TRY;
/* Check that the chunk read call does not succeed. */
- if(status != -1)
+ if (status != -1)
goto error;
/* Query the size of the non-existant chunk */
direct_chunk_nbytes = ULONG_MAX;
- H5E_BEGIN_TRY {
- status = H5Dget_chunk_storage_size(dataset, offset, &direct_chunk_nbytes);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { status = H5Dget_chunk_storage_size(dataset, offset, &direct_chunk_nbytes); }
+ H5E_END_TRY;
/* Check that the chunk storage size call does not succeed. */
- if(status != -1 )
+ if (status != -1)
goto error;
- if(direct_chunk_nbytes != 0 )
+ if (direct_chunk_nbytes != 0)
goto error;
-
}
}
@@ -1959,44 +2063,195 @@ test_read_unallocated_chunk (hid_t file)
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(dataset);
H5Sclose(mem_space);
H5Sclose(dataspace);
H5Pclose(cparms);
H5Pclose(dxpl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return 1;
} /* test_read_unallocated_chunk() */
/*-------------------------------------------------------------------------
- * Function: Main function
+ * Function: test_single_chunk
*
- * Purpose: Test direct chunk write function H5DOwrite_chunk
+ * Purpose: Tests direct chunk I/O with a dataset containing a single
+ * chunk using different combinations of configuration
+ * parameters. Simple create-write-read-verify pattern.
*
- * Return: Success: 0
+ * Return: Success: 0
+ * Failure: 1
*
- * Failure: 1
+ *-------------------------------------------------------------------------
+ */
+static int
+test_single_chunk(unsigned config)
+{
+ hid_t fid; /* File ID */
+ hid_t fapl; /* File access property list ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t did; /* Dataset ID */
+ hid_t dcpl; /* Dataset creation property list */
+ hsize_t dims[2] = {DIM0, DIM1}; /* Dimension sizes */
+ hsize_t chunk[2] = {CHUNK0, CHUNK1}; /* Chunk dimension sizes */
+ hsize_t offset[2] = {0, 0}; /* Offset for writing */
+ uint32_t filters; /* Filter mask out */
+ int wdata[DIM0][DIM1]; /* Write buffer */
+ int rdata[DIM0][DIM1]; /* Read buffer */
+ int i, j; /* Local index variable */
+
+ HL_TESTING2("Single chunk I/O");
+
+ /* Initialize data */
+ for (i = 0; i < DIM0; i++) {
+ for (j = 0; j < DIM1; j++)
+ wdata[i][j] = j / CHUNK0;
+ }
+
+ /* Create a new file with the latest format */
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ goto error;
+ if (config & CONFIG_LATEST)
+ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ goto error;
+ if ((fid = H5Fcreate(SINGLE_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ goto error;
+
+ /* Create dataspace */
+ if ((sid = H5Screate_simple(2, dims, NULL)) < 0)
+ goto error;
+
+ /* Create the dataset creation property list and set the chunk size */
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ goto error;
+ if (H5Pset_chunk(dcpl, 2, chunk) < 0)
+ goto error;
+
+ /* Create the dataset */
+ if ((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ goto error;
+
+ if (config & CONFIG_DIRECT_WRITE) {
+ /* Write the data directly to the dataset */
+ if (H5DOwrite_chunk(did, H5P_DEFAULT, 0, offset, CHUNK0 * CHUNK1 * 4, (void *)wdata) < 0)
+ goto error;
+ } /* end if */
+ else
+ /* Write the data to the dataset */
+ if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)wdata) < 0)
+ goto error;
+
+ /*
+ * Close and release resources.
+ */
+ if (H5Pclose(dcpl) < 0)
+ goto error;
+ if (config & CONFIG_REOPEN_DSET)
+ if (H5Dclose(did) < 0)
+ goto error;
+ if (H5Sclose(sid) < 0)
+ goto error;
+ if (H5Pclose(fapl) < 0)
+ goto error;
+ if (config & CONFIG_REOPEN_FILE)
+ if (H5Fclose(fid) < 0)
+ goto error;
+
+ /* Open the file and dataset with default properties */
+ if (config & CONFIG_REOPEN_FILE)
+ if ((fid = H5Fopen(SINGLE_FILE, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ goto error;
+ if (config & CONFIG_REOPEN_DSET)
+ if ((did = H5Dopen2(fid, DATASET, H5P_DEFAULT)) < 0)
+ goto error;
+
+ /* Retrieve dataset creation property list */
+ if ((dcpl = H5Dget_create_plist(did)) < 0)
+ goto error;
+
+ if (config & CONFIG_DIRECT_READ) {
+ /* Read the data directly */
+ if (H5DOread_chunk(did, H5P_DEFAULT, offset, &filters, rdata) < 0)
+ goto error;
+
+ /* Verify returned filter mask */
+ if (filters != 0)
+ goto error;
+ } /* end if */
+ else
+ /* Read the data */
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0)
+ goto error;
+
+ /* Verify that the data read was correct. */
+ for (i = 0; i < DIM0; i++) {
+ for (j = 0; j < DIM1; j++) {
+ if (rdata[i][j] != wdata[i][j])
+ goto error;
+ }
+ }
+
+ /*
+ * Close and release resources
+ */
+ if (H5Pclose(dcpl) < 0)
+ goto error;
+ if (H5Dclose(did) < 0)
+ goto error;
+ if (H5Fclose(fid) < 0)
+ goto error;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY
+ {
+ H5Dclose(did);
+ H5Sclose(sid);
+ H5Pclose(dcpl);
+ H5Pclose(fapl);
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
+
+ H5_FAILED();
+ return 1;
+} /* test_single_chunk_latest() */
+
+/*-------------------------------------------------------------------------
+ * Function: Main function
+ *
+ * Purpose: Test direct chunk write function H5Dwrite_chunk and
+ * chunk direct read function H5Dread_chunk
+ *
+ * Return: Success: 0
+ * Failure: 1
*
* Programmer: Raymond Lu
* 30 November 2012
*
*-------------------------------------------------------------------------
*/
-int main( void )
+int
+main(void)
{
- hid_t file_id;
- int nerrors=0;
+ hid_t file_id;
+ unsigned config;
+ int nerrors = 0;
/*
* Create a new file. If file exists its contents will be overwritten.
*/
- if((file_id = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((file_id = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto error;
- /* Test direct chunk write and direct chunk read */
+ /* Test direct chunk write and direct chunk read */
#ifdef H5_HAVE_FILTER_DEFLATE
nerrors += test_direct_chunk_write(file_id);
#endif /* H5_HAVE_FILTER_DEFLATE */
@@ -2006,7 +2261,6 @@ int main( void )
nerrors += test_data_conv(file_id);
nerrors += test_invalid_parameters(file_id);
-
/* Test direct chunk read */
#ifdef H5_HAVE_FILTER_DEFLATE
nerrors += test_direct_chunk_read_no_cache(file_id);
@@ -2016,7 +2270,55 @@ int main( void )
nerrors += test_read_unfiltered_dset(file_id);
nerrors += test_read_unallocated_chunk(file_id);
- if(H5Fclose(file_id) < 0)
+ /* Loop over test configurations */
+ for (config = 0; config < CONFIG_END; config++) {
+ hbool_t need_comma = FALSE;
+
+ /* Check for invalid combinations */
+ if ((config & CONFIG_REOPEN_FILE) && !(config & CONFIG_REOPEN_DSET))
+ continue;
+
+ /* Print configuration */
+ HDprintf("Configuration: ");
+ if (config == 0)
+ HDprintf("<empty>");
+ if (config & CONFIG_LATEST) {
+ if (need_comma)
+ HDprintf(", ");
+ HDprintf("latest format");
+ need_comma = TRUE;
+ } /* end if */
+ if (config & CONFIG_REOPEN_FILE) {
+ if (need_comma)
+ HDprintf(", ");
+ HDprintf("reopen file");
+ need_comma = TRUE;
+ } /* end if */
+ else if (config & CONFIG_REOPEN_DSET) {
+ if (need_comma)
+ HDprintf(", ");
+ HDprintf("reopen dataset");
+ need_comma = TRUE;
+ } /* end if */
+ if (config & CONFIG_DIRECT_WRITE) {
+ if (need_comma)
+ HDprintf(", ");
+ HDprintf("direct write");
+ need_comma = TRUE;
+ } /* end if */
+ if (config & CONFIG_DIRECT_READ) {
+ if (need_comma)
+ HDprintf(", ");
+ HDprintf("direct read");
+ need_comma = TRUE;
+ } /* end if */
+ HDprintf(":\n");
+ fflush(stdout);
+
+ nerrors += test_single_chunk(config);
+ } /* end for */
+
+ if (H5Fclose(file_id) < 0)
goto error;
/* check for errors */
diff --git a/hl/test/test_file_image.c b/hl/test/test_file_image.c
index 0f079ca..34d52a5 100644
--- a/hl/test/test_file_image.c
+++ b/hl/test/test_file_image.c
@@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* 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 *
+ * 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. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5hltest.h"
#include "H5LTpublic.h"
@@ -38,35 +38,35 @@
extend the image, and then performs writes that extend the images. The fifth
loop reads the extended images and verify that the content are correct. The
sixth and final loop closes the file images and deallocates the image
- buffers if appropriate. */
+ buffers if appropriate. */
/*-------------------------------------------------------------------------
-* test file image operations
-*-------------------------------------------------------------------------
-*/
+ * test file image operations
+ *-------------------------------------------------------------------------
+ */
static int
test_file_image(size_t open_images, size_t nflags, unsigned *flags)
{
- hid_t *file_id, *dset_id, file_space, plist; /* HDF5 ids */
- hsize_t dims1[RANK] = {2,3}; /* original dimension of datasets */
- hsize_t max_dims[RANK] = {H5S_UNLIMITED, H5S_UNLIMITED};
- int data1[6] = {1,2,3,4,5,6}; /* original contents of dataset */
- int data2[6] = {7,8,9,10,11,12}; /* "wrong" contents of dataset */
- hsize_t dims3[RANK]; /* array to read dataset dimensions */
- int data3[15]; /* array to read dataset contents */
- hsize_t dims4[RANK] = {3,5}; /* extended dimensions of datasets */
- int data4[15] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
- /* extended contents of dataset */
- ssize_t *buf_size; /* pointer to array of buffer sizes */
- void **buf_ptr; /* pointer to array of pointers to image buffers */
- char **filename; /* pointer to array of pointers to filenames */
- unsigned *input_flags; /* pointer to array of flag combinations */
- size_t i, j, k, nrow, n_values;
- herr_t status1;
- void *handle_ptr = NULL; /* pointers to driver buffer */
- unsigned char **core_buf_ptr_ptr = NULL;
-
- VERIFY(open_images > 1 , "The number of open images must be greater than 1");
+ hid_t * file_id, *dset_id, file_space, plist; /* HDF5 ids */
+ hsize_t dims1[RANK] = {2, 3}; /* original dimension of datasets */
+ hsize_t max_dims[RANK] = {H5S_UNLIMITED, H5S_UNLIMITED};
+ int data1[6] = {1, 2, 3, 4, 5, 6}; /* original contents of dataset */
+ int data2[6] = {7, 8, 9, 10, 11, 12}; /* "wrong" contents of dataset */
+ hsize_t dims3[RANK]; /* array to read dataset dimensions */
+ int data3[15]; /* array to read dataset contents */
+ hsize_t dims4[RANK] = {3, 5}; /* extended dimensions of datasets */
+ int data4[15] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ /* extended contents of dataset */
+ ssize_t * buf_size; /* pointer to array of buffer sizes */
+ void ** buf_ptr; /* pointer to array of pointers to image buffers */
+ char ** filename; /* pointer to array of pointers to filenames */
+ unsigned * input_flags; /* pointer to array of flag combinations */
+ size_t i, j, k, nrow, n_values;
+ herr_t status1;
+ void * handle_ptr = NULL; /* pointers to driver buffer */
+ unsigned char **core_buf_ptr_ptr = NULL;
+
+ VERIFY(open_images > 1, "The number of open images must be greater than 1");
VERIFY(nflags > 0, "The number of flag combinations must be greater than 0");
@@ -94,7 +94,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
if (NULL == (dset_id = (hid_t *)HDmalloc(sizeof(hid_t) * open_images)))
FAIL_PUTS_ERROR("malloc() failed");
- TESTING("get file images");
+ HL_TESTING2("get file images");
/* create several file images */
for (i = 0; i < open_images; i++) {
@@ -106,17 +106,17 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
filename[i] = (char *)HDmalloc(sizeof(char) * 32);
/* create file name */
- sprintf(filename[i], "image_file%d.h5", (int)i);
+ HDsprintf(filename[i], "image_file%d.h5", (int)i);
/* create file */
if ((file_id[i] = H5Fcreate(filename[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
FAIL_PUTS_ERROR("H5Fcreate() failed");
- /* define dataspace for the dataset */
- if ((file_space = H5Screate_simple(RANK, dims1, max_dims)) < 0)
+ /* define dataspace for the dataset */
+ if ((file_space = H5Screate_simple(RANK, dims1, max_dims)) < 0)
FAIL_PUTS_ERROR("H5Screate_simple() failed");
- /* create dataset property list */
+ /* create dataset property list */
if ((plist = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_PUTS_ERROR("H5Pcreate() failed");
@@ -125,10 +125,11 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
FAIL_PUTS_ERROR("H5Pset_chunk() failed");
/* create and write an integer type dataset named "dset" */
- if ((dset_id[i] = H5Dcreate2(file_id[i], DSET_NAME, H5T_NATIVE_INT, file_space, H5P_DEFAULT, plist, H5P_DEFAULT)) < 0)
+ if ((dset_id[i] = H5Dcreate2(file_id[i], DSET_NAME, H5T_NATIVE_INT, file_space, H5P_DEFAULT, plist,
+ H5P_DEFAULT)) < 0)
FAIL_PUTS_ERROR("H5Dcreate() failed");
-
- /* dataset in open image 1 is written with "wrong" data */
+
+ /* dataset in open image 1 is written with "wrong" data */
if (i == 1) {
if (H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2) < 0)
FAIL_PUTS_ERROR("H5Dwrite() failed");
@@ -138,7 +139,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
if (H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1) < 0)
FAIL_PUTS_ERROR("H5Dwrite() failed");
} /* end else */
-
+
/* flush into the file */
if (H5Fflush(file_id[i], H5F_SCOPE_LOCAL) < 0)
FAIL_PUTS_ERROR("H5Fflush() failed");
@@ -146,7 +147,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
/* close dataset property list */
if (H5Pclose(plist) < 0)
FAIL_PUTS_ERROR("H5Pclose() failed");
-
+
/* close dataspace */
if (H5Sclose(file_space) < 0)
FAIL_PUTS_ERROR("H5Sclose() failed");
@@ -156,7 +157,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
FAIL_PUTS_ERROR("H5Dclose() failed");
/* get size of the file image i */
- if ((buf_size[i] = H5Fget_file_image(file_id[i], NULL, 0)) < 0)
+ if ((buf_size[i] = H5Fget_file_image(file_id[i], NULL, (size_t)0)) < 0)
FAIL_PUTS_ERROR("H5Fget_file_image() failed");
/* allocate buffer for the file image i */
@@ -166,7 +167,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
/* buffer for file image 2 is filled with counter data (non-valid image) */
if (i == 2) {
for (j = 0; j < (size_t)buf_size[i]; j++)
- ((char*)(buf_ptr[i]))[j] = (char)j;
+ ((char *)(buf_ptr[i]))[j] = (char)j;
} /* end if */
/* buffers for the rest of the file images are filled with data from the respective files */
else {
@@ -175,40 +176,43 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
} /* end else */
/* file close */
- if (H5Fclose (file_id[i]) < 0)
+ if (H5Fclose(file_id[i]) < 0)
FAIL_PUTS_ERROR("H5Fclose() failed");
} /* end for */
PASSED();
- TESTING("open file images and check image copies");
-
- /* open the file images with the core driver for data access */
+ HL_TESTING2("open file images and check image copies");
+
+ /* open the file images with the core driver for data access */
for (i = 0; i < open_images; i++) {
/* open file image 2 filled with counter data (non-valid image) */
if (i == 2) {
- H5E_BEGIN_TRY {
- /* attempt to set file image in the core driver */
+ H5E_BEGIN_TRY
+ {
+ /* attempt to set file image in the core driver */
file_id[i] = H5LTopen_file_image(buf_ptr[i], (size_t)buf_size[i], input_flags[i]);
- } H5E_END_TRY
+ }
+ H5E_END_TRY
VERIFY(file_id[i] < 0, "H5LTopen_file_image() should have failed");
} /* end if */
/* open rest of valid file images */
else {
- /* set file image in the core driver */
+ /* set file image in the core driver */
if ((file_id[i] = H5LTopen_file_image(buf_ptr[i], (size_t)buf_size[i], input_flags[i])) < 0)
FAIL_PUTS_ERROR("H5LTopen_file_image() failed");
/* get pointer to the image buffer of the core driver */
if (H5Fget_vfd_handle(file_id[i], H5P_DEFAULT, &handle_ptr) < 0)
- FAIL_PUTS_ERROR("H5Fget_vfd_handle() failed");
+ FAIL_PUTS_ERROR("H5Fget_vfd_handle() failed");
core_buf_ptr_ptr = (unsigned char **)handle_ptr;
/* test whether the user buffer has been copied or not */
if (input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY)
- VERIFY(*core_buf_ptr_ptr == buf_ptr[i], "vfd buffer and user buffer should have been the same");
+ VERIFY(*core_buf_ptr_ptr == buf_ptr[i],
+ "vfd buffer and user buffer should have been the same");
else
VERIFY(*core_buf_ptr_ptr != buf_ptr[i], "vfd buffer and user buffer should be different");
@@ -217,11 +221,11 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
if (HDmemcmp(*core_buf_ptr_ptr, buf_ptr[i], (size_t)buf_size[i]) != 0)
FAIL_PUTS_ERROR("comparison of vfd and user buffer failed");
} /* end else */
- } /* end for */
+ } /* end for */
PASSED();
- TESTING("read file images");
+ HL_TESTING2("read file images");
/* read open file images and verify data */
for (i = 0; i < open_images; i++) {
@@ -231,7 +235,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
continue;
} /* end if */
- /* open dataset in file image */
+ /* open dataset in file image */
if ((dset_id[i] = H5Dopen2(file_id[i], DSET_NAME, H5P_DEFAULT)) < 0)
FAIL_PUTS_ERROR("H5Dopen() failed");
@@ -244,10 +248,10 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
FAIL_PUTS_ERROR("H5Sget_simple_extent_dims() failed");
/* read dataset */
- if (H5Dread(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data3) < 0)
+ if (H5Dread(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data3) < 0)
FAIL_PUTS_ERROR("H5Dread() failed");
-
- /* compute number of elements in dataset */
+
+ /* compute number of elements in dataset */
n_values = (size_t)(dims3[0] * dims3[1]);
/* determine the number of rows in dataset */
@@ -258,7 +262,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
/* compare file image values with original data */
for (j = 0; j < n_values / nrow; j++)
for (k = 0; k < nrow; k++)
- if (data3[j * nrow + k ] == data1[j * nrow + k ])
+ if (data3[j * nrow + k] == data1[j * nrow + k])
FAIL_PUTS_ERROR("comparison of image values with original data should have failed");
} /* end if */
/* verify contents for the rest of the file images */
@@ -266,18 +270,18 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
/* compare file image values with original data */
for (j = 0; j < n_values / nrow; j++)
for (k = 0; k < nrow; k++)
- if (data3[j * nrow + k ] != data1[j * nrow + k ])
+ if (data3[j * nrow + k] != data1[j * nrow + k])
FAIL_PUTS_ERROR("comparison of image values with original data failed");
} /* end else */
-
- /* close dataspace */
- if (H5Sclose (file_space) < 0)
+
+ /* close dataspace */
+ if (H5Sclose(file_space) < 0)
FAIL_PUTS_ERROR("H5Sclose() failed");
} /* end for */
- PASSED();
+ PASSED();
- TESTING("write and extend file images");
+ HL_TESTING2("write and extend file images");
/* write open file images and verify data */
for (i = 0; i < open_images; i++) {
@@ -290,23 +294,26 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
/* test data write when file image access is read-only */
if (!(input_flags[i] & H5LT_FILE_IMAGE_OPEN_RW)) {
/* write dataset without extending it */
- H5E_BEGIN_TRY {
- status1 = H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY
+ {
+ status1 = H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1);
+ }
+ H5E_END_TRY;
VERIFY(status1 < 0, "H5Dwrite() should have failed");
/* extend dimensions of dataset */
- H5E_BEGIN_TRY {
- status1 = H5Dset_extent(dset_id[i], dims4);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { status1 = H5Dset_extent(dset_id[i], dims4); }
+ H5E_END_TRY;
VERIFY(status1 < 0, "H5Dset_extent() should have failed");
/* write extended dataset */
- H5E_BEGIN_TRY {
- status1 = H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data4);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY
+ {
+ status1 = H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data4);
+ }
+ H5E_END_TRY;
VERIFY(status1 < 0, "H5Dwrite() should have failed");
@@ -316,7 +323,8 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
} /* end if */
/* test data write where file image access is read-write */
else {
- if ((input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY) && (input_flags[i] & H5LT_FILE_IMAGE_DONT_RELEASE)) {
+ if ((input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY) &&
+ (input_flags[i] & H5LT_FILE_IMAGE_DONT_RELEASE)) {
/* This test is disabled currently, since the new attribute causes the file
* to increase in size, but the realloc call in H5FD_core_write() fails, causing
* the flush operation to fail and the file to fail to close, eventually
@@ -337,7 +345,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
hid_t attr_space_id = -1;
hid_t attr_id = -1;
herr_t status2;
- size_t l;
+ size_t l;
if ((attr_space_id = H5Screate_simple(attr_rank, attr_dims, attr_dims)) < 0)
FAIL_PUTS_ERROR("attr_space H5Screate_simple() failed");
@@ -372,7 +380,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
} /* end if */
else {
/* write dataset without extending it */
- if (H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1) < 0)
+ if (H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1) < 0)
FAIL_PUTS_ERROR("H5Dwrite() failed");
/* extend dimensions of dataset */
@@ -380,27 +388,27 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
FAIL_PUTS_ERROR("H5Dset_extent() failed");
/* write extended dataset */
- if (H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data4) < 0)
+ if (H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data4) < 0)
FAIL_PUTS_ERROR("H5Dwrite() failed");
/* close dataset */
if (H5Dclose(dset_id[i]) < 0)
FAIL_PUTS_ERROR("H5Dclose() failed");
} /* end else */
- } /* end else */
- } /* end for */
+ } /* end else */
+ } /* end for */
PASSED();
- TESTING("read extended file images");
+ HL_TESTING2("read extended file images");
/* read open file images and verify data */
for (i = 0; i < open_images; i++) {
/* if opening the file image failed, continue next iteration */
- if ((file_id[i] < 0) || (!(input_flags[i] & H5LT_FILE_IMAGE_OPEN_RW )))
+ if ((file_id[i] < 0) || (!(input_flags[i] & H5LT_FILE_IMAGE_OPEN_RW)))
continue;
- /* open dataset in file image */
+ /* open dataset in file image */
if ((dset_id[i] = H5Dopen2(file_id[i], DSET_NAME, H5P_DEFAULT)) < 0)
FAIL_PUTS_ERROR("H5Dopen() failed");
@@ -413,10 +421,10 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
FAIL_PUTS_ERROR("H5Sget_simple_extent_dims() failed");
/* read dataset */
- if (H5Dread(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data3) < 0)
+ if (H5Dread(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data3) < 0)
FAIL_PUTS_ERROR("H5Dread() failed");
-
- /* compute number of elements in dataset */
+
+ /* compute number of elements in dataset */
n_values = (size_t)(dims3[0] * dims3[1]);
/* determine the number of rows in dataset */
@@ -425,11 +433,11 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
/* verify contents for the file images */
for (j = 0; j < n_values / nrow; j++)
for (k = 0; k < nrow; k++)
- if (data3[j * nrow + k ] != data4[j * nrow + k ])
+ if (data3[j * nrow + k] != data4[j * nrow + k])
FAIL_PUTS_ERROR("comparison of image values with original data failed");
-
- /* close dataspace */
- if (H5Sclose (file_space) < 0)
+
+ /* close dataspace */
+ if (H5Sclose(file_space) < 0)
FAIL_PUTS_ERROR("H5Sclose() failed");
/* close dataset */
@@ -439,7 +447,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
PASSED()
- TESTING("close file images");
+ HL_TESTING2("close file images");
/* close file images and release buffer if appropriate */
for (i = 0; i < open_images; i++) {
@@ -455,11 +463,12 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
FAIL_PUTS_ERROR("HDremove() failed");
/* free shared buffer if appropriate */
- if (!(input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY) || (input_flags[i] & H5LT_FILE_IMAGE_DONT_RELEASE)) {
+ if (!(input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY) ||
+ (input_flags[i] & H5LT_FILE_IMAGE_DONT_RELEASE)) {
VERIFY(buf_ptr[i] != NULL, "buffer pointer must be non NULL");
HDfree(buf_ptr[i]);
} /* end if */
-
+
} /* end for */
/* release temporary working buffers */
@@ -482,17 +491,18 @@ error:
}
/*-------------------------------------------------------------------------
-* the main program
-*-------------------------------------------------------------------------
-*/
-int main( void )
+ * the main program
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
{
- int nerrors = 0;
- size_t open_images = 10; /* number of open file images */
- size_t nflags = 8; /* number of flag combinations */
- unsigned flags[8]; /* array with flag combinations */
-
- /* set flag combinations for testing */
+ int nerrors = 0;
+ size_t open_images = 10; /* number of open file images */
+ size_t nflags = 8; /* number of flag combinations */
+ unsigned flags[8]; /* array with flag combinations */
+
+ /* set flag combinations for testing */
flags[0] = 0;
flags[1] = H5LT_FILE_IMAGE_DONT_RELEASE;
flags[2] = H5LT_FILE_IMAGE_DONT_COPY;
@@ -503,14 +513,14 @@ int main( void )
flags[7] = H5LT_FILE_IMAGE_OPEN_RW | H5LT_FILE_IMAGE_DONT_COPY | H5LT_FILE_IMAGE_DONT_RELEASE;
/* Test file image operations. The flag combinations are assigned to file images in round-robin fashion */
- nerrors += test_file_image(open_images, nflags, flags) < 0? 1 : 0;
+ nerrors += test_file_image(open_images, nflags, flags) < 0 ? 1 : 0;
- if (nerrors) goto error;
- printf("File image tests passed.\n");
+ if (nerrors)
+ goto error;
+ HDprintf("File image tests passed.\n");
return 0;
error:
- printf("***** %d IMAGE TEST%s FAILED! *****\n",nerrors, 1 == nerrors ? "" : "S");
+ HDprintf("***** %d IMAGE TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S");
return 1;
}
-
diff --git a/hl/test/test_image.c b/hl/test/test_image.c
index ac818d0..ff53d4f 100644
--- a/hl/test/test_image.c
+++ b/hl/test/test_image.c
@@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* 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 *
+ * 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. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <limits.h>
#include <stdlib.h>
@@ -39,10 +39,9 @@
#define PAL3_NAME "earth"
#define PAL4_NAME "blue-red"
-
-#define WIDTH 400
-#define HEIGHT 200
-#define PAL_ENTRIES 256
+#define WIDTH 400
+#define HEIGHT 200
+#define PAL_ENTRIES 256
/* struct to store RGB values read from a .pal file */
typedef struct rgb_t {
@@ -55,54 +54,57 @@ typedef struct rgb_t {
static int test_simple(void);
static int test_data(void);
static int test_generate(void);
-static int read_data(const char* file_name, hsize_t *width, hsize_t *height );
-static int read_palette(const char* file_name, rgb_t *palette, size_t palette_size);
+static int read_data(const char *file_name, hsize_t *width, hsize_t *height);
+static int read_palette(const char *file_name, rgb_t *palette, size_t palette_size);
/* globals */
unsigned char *image_data = NULL;
/*-------------------------------------------------------------------------
-* the main program
-*-------------------------------------------------------------------------
-*/
+ * the main program
+ *-------------------------------------------------------------------------
+ */
-int main(void)
+int
+main(void)
{
- int nerrors=0;
+ int nerrors = 0;
- nerrors += test_simple()<0 ?1:0;
- nerrors += test_data()<0 ?1:0;
- nerrors += test_generate()<0 ?1:0;
+ nerrors += test_simple() < 0 ? 1 : 0;
+ nerrors += test_data() < 0 ? 1 : 0;
+ nerrors += test_generate() < 0 ? 1 : 0;
- if (nerrors) goto error;
- printf("All image tests passed.\n");
+ if (nerrors)
+ goto error;
+ HDprintf("All image tests passed.\n");
return 0;
error:
- printf("***** %d IMAGE TEST%s FAILED! *****\n",nerrors, 1 == nerrors ? "" : "S");
+ HDprintf("***** %d IMAGE TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S");
return 1;
}
/*-------------------------------------------------------------------------
-* a simple test that generates images and palettes
-*-------------------------------------------------------------------------
-*/
+ * a simple test that generates images and palettes
+ *-------------------------------------------------------------------------
+ */
-static int test_simple(void)
+static int
+test_simple(void)
{
- hsize_t width = WIDTH;
- hsize_t height = HEIGHT;
- hsize_t planes;
- hid_t fid;
- int i, j, n, space;
- hsize_t u;
- char interlace[20];
- hssize_t npals;
+ hsize_t width = WIDTH;
+ hsize_t height = HEIGHT;
+ hsize_t planes;
+ hid_t fid;
+ int i, j, n, space;
+ hsize_t u;
+ char interlace[20];
+ hssize_t npals;
/* 8-bit image */
unsigned char *buf1 = NULL;
- unsigned char pal[ PAL_ENTRIES * 3 ]; /* palette array */
- hsize_t pal_dims[2] = {PAL_ENTRIES,3}; /* palette dimensions */
+ unsigned char pal[PAL_ENTRIES * 3]; /* palette array */
+ hsize_t pal_dims[2] = {PAL_ENTRIES, 3}; /* palette dimensions */
/* 24-bit image */
unsigned char *buf2 = NULL;
@@ -110,395 +112,373 @@ static int test_simple(void)
/* read data */
unsigned char *buf1_out = NULL;
unsigned char *buf2_out = NULL;
- unsigned char pal_out[ PAL_ENTRIES * 3 ]; /* palette array */
- hsize_t pal_dims_out[2]; /* palette dimensions */
+ unsigned char pal_out[PAL_ENTRIES * 3]; /* palette array */
+ hsize_t pal_dims_out[2]; /* palette dimensions */
/* Allocate image buffers */
buf1 = (unsigned char *)HDmalloc(WIDTH * HEIGHT);
HDassert(buf1);
- buf2 = (unsigned char *)HDmalloc(WIDTH * HEIGHT * 3);
+ buf2 = (unsigned char *)HDmalloc(WIDTH * HEIGHT * 3);
HDassert(buf2);
buf1_out = (unsigned char *)HDmalloc(WIDTH * HEIGHT);
HDassert(buf1_out);
- buf2_out = (unsigned char *)HDmalloc(WIDTH * HEIGHT * 3);
+ buf2_out = (unsigned char *)HDmalloc(WIDTH * HEIGHT * 3);
HDassert(buf2_out);
/* create an image */
- space = WIDTH*HEIGHT / PAL_ENTRIES;
- for (i=0, j=0, n=0; i < WIDTH*HEIGHT; i++, j++ )
- {
+ space = WIDTH * HEIGHT / PAL_ENTRIES;
+ for (i = 0, j = 0, n = 0; i < WIDTH * HEIGHT; i++, j++) {
buf1[i] = (unsigned char)n;
- if ( j > space )
- {
+ if (j > space) {
n++;
- j=0;
+ j = 0;
}
-
}
/* create an image */
- space = WIDTH*HEIGHT / 256;
- for (i=0, j=0, n=0; i < WIDTH*HEIGHT*3; i+=3, j++ )
- {
- buf2[i] = (unsigned char)n;
- buf2[i+1] = 0;
- buf2[i+2] = (unsigned char)(255 - n);
- if ( j > space )
- {
+ space = WIDTH * HEIGHT / 256;
+ for (i = 0, j = 0, n = 0; i < WIDTH * HEIGHT * 3; i += 3, j++) {
+ buf2[i] = (unsigned char)n;
+ buf2[i + 1] = 0;
+ buf2[i + 2] = (unsigned char)(255 - n);
+ if (j > space) {
n++;
- j=0;
+ j = 0;
}
}
/*-------------------------------------------------------------------------
- * define a palette, blue to red tones
- *-------------------------------------------------------------------------
- */
- for ( i=0, n=0; i<PAL_ENTRIES*3; i+=3, n++)
- {
- pal[i] =(unsigned char)n; /* red */
- pal[i+1]=0; /* green */
- pal[i+2]=(unsigned char)(255 - n); /* blue */
+ * define a palette, blue to red tones
+ *-------------------------------------------------------------------------
+ */
+ for (i = 0, n = 0; i < PAL_ENTRIES * 3; i += 3, n++) {
+ pal[i] = (unsigned char)n; /* red */
+ pal[i + 1] = 0; /* green */
+ pal[i + 2] = (unsigned char)(255 - n); /* blue */
}
/* Create a new HDF5 file using default properties. */
- fid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
+ fid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/*-------------------------------------------------------------------------
- * Indexed image test
- *-------------------------------------------------------------------------
- */
+ * Indexed image test
+ *-------------------------------------------------------------------------
+ */
- TESTING("indexed image");
+ HL_TESTING2("indexed image");
/* Write image */
- if ( H5IMmake_image_8bit( fid, IMAGE1_NAME, width, height, buf1 ) < 0 )
+ if (H5IMmake_image_8bit(fid, IMAGE1_NAME, width, height, buf1) < 0)
goto out;
/* Make a palette */
- if ( H5IMmake_palette( fid, PAL_NAME, pal_dims, pal ) < 0 )
+ if (H5IMmake_palette(fid, PAL_NAME, pal_dims, pal) < 0)
goto out;
/* Attach a palette to the image dataset */
- if ( H5IMlink_palette( fid, IMAGE1_NAME, PAL_NAME ) < 0 )
+ if (H5IMlink_palette(fid, IMAGE1_NAME, PAL_NAME) < 0)
goto out;
/* Read image */
- if ( H5IMget_image_info( fid, IMAGE1_NAME, &width, &height, &planes, interlace, &npals ) < 0 )
+ if (H5IMget_image_info(fid, IMAGE1_NAME, &width, &height, &planes, interlace, &npals) < 0)
goto out;
- if ( H5IMread_image( fid, IMAGE1_NAME, buf1_out ) < 0 )
+ if (H5IMread_image(fid, IMAGE1_NAME, buf1_out) < 0)
goto out;
- for (u = 0; u < height*width*planes; u++)
- {
- if ( buf1[u] != buf1_out[u] )
+ for (u = 0; u < height * width * planes; u++) {
+ if (buf1[u] != buf1_out[u])
goto out;
-
}
-
PASSED();
/*-------------------------------------------------------------------------
- * True color image test
- *-------------------------------------------------------------------------
- */
+ * True color image test
+ *-------------------------------------------------------------------------
+ */
- TESTING("true color image");
+ HL_TESTING2("true color image");
/* Write image */
- if ( H5IMmake_image_24bit( fid, IMAGE2_NAME, width, height, "INTERLACE_PIXEL", buf2 ) )
+ if (H5IMmake_image_24bit(fid, IMAGE2_NAME, width, height, "INTERLACE_PIXEL", buf2))
goto out;
/* Read image */
- if ( H5IMget_image_info( fid, IMAGE2_NAME, &width, &height, &planes, interlace, &npals ) < 0 )
+ if (H5IMget_image_info(fid, IMAGE2_NAME, &width, &height, &planes, interlace, &npals) < 0)
goto out;
- if ( H5IMread_image( fid, IMAGE2_NAME, buf2_out ) < 0 )
+ if (H5IMread_image(fid, IMAGE2_NAME, buf2_out) < 0)
goto out;
- for (u = 0; u < height*width*planes; u++)
- {
- if ( buf2[u] != buf2_out[u] )
+ for (u = 0; u < height * width * planes; u++) {
+ if (buf2[u] != buf2_out[u])
goto out;
}
-
PASSED();
/*-------------------------------------------------------------------------
- * H5IMget_npalettes test
- *-------------------------------------------------------------------------
- */
+ * H5IMget_npalettes test
+ *-------------------------------------------------------------------------
+ */
- TESTING("pallete functions");
+ HL_TESTING2("pallete functions");
- if ( H5IMget_npalettes( fid, IMAGE1_NAME, &npals ) < 0 )
+ if (H5IMget_npalettes(fid, IMAGE1_NAME, &npals) < 0)
goto out;
/*-------------------------------------------------------------------------
- * H5IMget_palette_info test
- *-------------------------------------------------------------------------
- */
+ * H5IMget_palette_info test
+ *-------------------------------------------------------------------------
+ */
- if ( H5IMget_palette_info( fid, IMAGE1_NAME, 0, pal_dims_out ) < 0 )
+ if (H5IMget_palette_info(fid, IMAGE1_NAME, 0, pal_dims_out) < 0)
goto out;
- for (i = 0; i < 2; i++)
- {
- if ( pal_dims[i] != pal_dims_out[i] )
+ for (i = 0; i < 2; i++) {
+ if (pal_dims[i] != pal_dims_out[i])
goto out;
}
/*-------------------------------------------------------------------------
- * H5IMget_palette test
- *-------------------------------------------------------------------------
- */
+ * H5IMget_palette test
+ *-------------------------------------------------------------------------
+ */
- if ( H5IMget_palette( fid, IMAGE1_NAME, 0, pal_out ) < 0 )
+ if (H5IMget_palette(fid, IMAGE1_NAME, 0, pal_out) < 0)
goto out;
- for (i = 0; i < PAL_ENTRIES * 3; i++)
- {
- if ( pal[i] != pal_out[i] )
+ for (i = 0; i < PAL_ENTRIES * 3; i++) {
+ if (pal[i] != pal_out[i])
goto out;
}
/*-------------------------------------------------------------------------
- * H5IMis_image test
- *-------------------------------------------------------------------------
- */
+ * H5IMis_image test
+ *-------------------------------------------------------------------------
+ */
- if ( H5IMis_image( fid, IMAGE1_NAME ) < 0 )
+ if (H5IMis_image(fid, IMAGE1_NAME) < 0)
goto out;
- if ( H5IMis_image( fid, IMAGE2_NAME ) < 0 )
+ if (H5IMis_image(fid, IMAGE2_NAME) < 0)
goto out;
/*-------------------------------------------------------------------------
- * H5IMis_palette test
- *-------------------------------------------------------------------------
- */
+ * H5IMis_palette test
+ *-------------------------------------------------------------------------
+ */
- if ( H5IMis_palette( fid, PAL_NAME ) < 0 )
+ if (H5IMis_palette(fid, PAL_NAME) < 0)
goto out;
/*-------------------------------------------------------------------------
- * end tests
- *-------------------------------------------------------------------------
- */
+ * end tests
+ *-------------------------------------------------------------------------
+ */
- if(buf1)
+ if (buf1)
HDfree(buf1);
- if(buf2)
+ if (buf2)
HDfree(buf2);
- if(buf1_out)
+ if (buf1_out)
HDfree(buf1_out);
- if(buf2_out)
+ if (buf2_out)
HDfree(buf2_out);
/* Close the file. */
- if(H5Fclose( fid ) < 0)
+ if (H5Fclose(fid) < 0)
goto out;
-
PASSED();
return 0;
/* error zone, gracefully close */
out:
- if(buf1)
+ if (buf1)
HDfree(buf1);
- if(buf2)
+ if (buf2)
HDfree(buf2);
- if(buf1_out)
+ if (buf1_out)
HDfree(buf1_out);
- if(buf2_out)
+ if (buf2_out)
HDfree(buf2_out);
- H5E_BEGIN_TRY {
- H5Fclose(fid);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { H5Fclose(fid); }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-
/*-------------------------------------------------------------------------
-* read sample realistic image data from ASCII files
-*-------------------------------------------------------------------------
-*/
+ * read sample realistic image data from ASCII files
+ *-------------------------------------------------------------------------
+ */
-static int test_data(void)
+static int
+test_data(void)
{
- hid_t fid;
- hsize_t pal_dims[2];
- hsize_t width;
- hsize_t height;
- unsigned char pal[256*3]; /* buffer to hold an HDF5 palette */
- rgb_t rgb[256]; /* buffer to hold a .pal file palette */
- int i, n;
+ hid_t fid;
+ hsize_t pal_dims[2];
+ hsize_t width;
+ hsize_t height;
+ unsigned char pal[256 * 3]; /* buffer to hold an HDF5 palette */
+ rgb_t rgb[256]; /* buffer to hold a .pal file palette */
+ int i, n;
/* create a file using default properties */
- if ((fid=H5Fcreate(FILE2,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0)
+ if ((fid = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
- printf("Testing read ascii image data and generate images\n");
+ HDprintf("Testing read ascii image data and generate images\n");
/*-------------------------------------------------------------------------
- * read 8bit image data
- *-------------------------------------------------------------------------
- */
+ * read 8bit image data
+ *-------------------------------------------------------------------------
+ */
- TESTING2("make indexed image");
+ HL_TESTING2("make indexed image");
/* read first data file */
- if (read_data(DATA_FILE1,&width,&height)<0)
+ if (read_data(DATA_FILE1, &width, &height) < 0)
goto out;
/* make an image */
- if (H5IMmake_image_8bit(fid,IMAGE1_NAME,width,height,image_data)<0)
+ if (H5IMmake_image_8bit(fid, IMAGE1_NAME, width, height, image_data) < 0)
goto out;
PASSED();
-
- TESTING2("attaching palettes");
+ HL_TESTING2("attaching palettes");
/*-------------------------------------------------------------------------
- * palette #1. rainbow palette. data is contained in "pal_rgb.h"
- *-------------------------------------------------------------------------
- */
+ * palette #1. rainbow palette. data is contained in "pal_rgb.h"
+ *-------------------------------------------------------------------------
+ */
/* initialize the palette data */
pal_dims[0] = 256;
pal_dims[1] = 3;
/* make a palette */
- if (H5IMmake_palette(fid,PAL1_NAME,pal_dims,pal_rgb)<0)
+ if (H5IMmake_palette(fid, PAL1_NAME, pal_dims, pal_rgb) < 0)
goto out;
/* attach a palette to the image dataset */
- if (H5IMlink_palette(fid,IMAGE1_NAME,PAL1_NAME)<0)
+ if (H5IMlink_palette(fid, IMAGE1_NAME, PAL1_NAME) < 0)
goto out;
/*-------------------------------------------------------------------------
- * palette #2. sepia palette.
- * read a PAL file and attach the palette to the HDF5 file
- *-------------------------------------------------------------------------
- */
+ * palette #2. sepia palette.
+ * read a PAL file and attach the palette to the HDF5 file
+ *-------------------------------------------------------------------------
+ */
/* read a PAL file */
if (read_palette(PAL2_FILE, rgb, (sizeof(rgb) / sizeof(rgb[0]))) < 0)
goto out;
/* transfer to the HDF5 buffer */
- for ( i=0, n=0; i<256*3; i+=3, n++)
- {
- pal[i] =rgb[n].r;
- pal[i+1]=rgb[n].g;
- pal[i+2]=rgb[n].b;
+ for (i = 0, n = 0; i < 256 * 3; i += 3, n++) {
+ pal[i] = rgb[n].r;
+ pal[i + 1] = rgb[n].g;
+ pal[i + 2] = rgb[n].b;
}
/* make a palette */
- if (H5IMmake_palette(fid,PAL2_NAME,pal_dims,pal)<0)
+ if (H5IMmake_palette(fid, PAL2_NAME, pal_dims, pal) < 0)
goto out;
/* attach the palette to the image dataset */
- if (H5IMlink_palette(fid,IMAGE1_NAME,PAL2_NAME)<0)
+ if (H5IMlink_palette(fid, IMAGE1_NAME, PAL2_NAME) < 0)
goto out;
/*-------------------------------------------------------------------------
- * palette #3. earth palette.
- * read a PAL file and attach the palette to the HDF5 file
- *-------------------------------------------------------------------------
- */
+ * palette #3. earth palette.
+ * read a PAL file and attach the palette to the HDF5 file
+ *-------------------------------------------------------------------------
+ */
/* read a PAL file */
if (read_palette(PAL3_FILE, rgb, (sizeof(rgb) / sizeof(rgb[0]))) < 0)
goto out;
/* transfer to the HDF5 buffer */
- for ( i=0, n=0; i<256*3; i+=3, n++)
- {
- pal[i] =rgb[n].r;
- pal[i+1]=rgb[n].g;
- pal[i+2]=rgb[n].b;
+ for (i = 0, n = 0; i < 256 * 3; i += 3, n++) {
+ pal[i] = rgb[n].r;
+ pal[i + 1] = rgb[n].g;
+ pal[i + 2] = rgb[n].b;
}
/* make a palette */
- if (H5IMmake_palette(fid,PAL3_NAME,pal_dims,pal)<0)
+ if (H5IMmake_palette(fid, PAL3_NAME, pal_dims, pal) < 0)
goto out;
/* attach the palette to the image dataset */
- if (H5IMlink_palette(fid,IMAGE1_NAME,PAL3_NAME)<0)
+ if (H5IMlink_palette(fid, IMAGE1_NAME, PAL3_NAME) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * palette #4. blue-red
- * make a palette whith blue to red colors
- *-------------------------------------------------------------------------
- */
- for ( i=0, n=0; i<256*3; i+=3, n++)
- {
- pal[i] =(unsigned char)n;
- pal[i+1]=0;
- pal[i+2]=(unsigned char)(255 - n);
+ * palette #4. blue-red
+ * make a palette whith blue to red colors
+ *-------------------------------------------------------------------------
+ */
+ for (i = 0, n = 0; i < 256 * 3; i += 3, n++) {
+ pal[i] = (unsigned char)n;
+ pal[i + 1] = 0;
+ pal[i + 2] = (unsigned char)(255 - n);
}
/* make a palette */
- if (H5IMmake_palette(fid,PAL4_NAME,pal_dims,pal)<0)
+ if (H5IMmake_palette(fid, PAL4_NAME, pal_dims, pal) < 0)
goto out;
/* attach the palette to the image dataset */
- if (H5IMlink_palette(fid,IMAGE1_NAME,PAL4_NAME)<0)
+ if (H5IMlink_palette(fid, IMAGE1_NAME, PAL4_NAME) < 0)
goto out;
-
/*-------------------------------------------------------------------------
- * true color image example with pixel interlace
- *-------------------------------------------------------------------------
- */
+ * true color image example with pixel interlace
+ *-------------------------------------------------------------------------
+ */
- TESTING2("make true color image with pixel interlace");
+ HL_TESTING2("make true color image with pixel interlace");
/* read second data file */
- if ((read_data(DATA_FILE2,&width,&height))<0)
+ if ((read_data(DATA_FILE2, &width, &height)) < 0)
goto out;
/* make image */
- if ((H5IMmake_image_24bit(fid,IMAGE2_NAME,width,height,"INTERLACE_PIXEL",image_data))<0)
+ if ((H5IMmake_image_24bit(fid, IMAGE2_NAME, width, height, "INTERLACE_PIXEL", image_data)) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * True color image example with plane interlace
- *-------------------------------------------------------------------------
- */
+ * True color image example with plane interlace
+ *-------------------------------------------------------------------------
+ */
- TESTING2("make true color image with plane interlace");
+ HL_TESTING2("make true color image with plane interlace");
/* read third data file */
- if ((read_data(DATA_FILE3,&width,&height))<0)
+ if ((read_data(DATA_FILE3, &width, &height)) < 0)
goto out;
/* make image */
- if ((H5IMmake_image_24bit(fid,IMAGE3_NAME,width,height,"INTERLACE_PLANE",image_data))<0)
+ if ((H5IMmake_image_24bit(fid, IMAGE3_NAME, width, height, "INTERLACE_PLANE", image_data)) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if (H5Fclose(fid)<0)
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Fclose(fid) < 0)
goto out;
/* Release memory buffer */
@@ -509,18 +489,16 @@ static int test_data(void)
/* error zone, gracefully close */
out:
/* Release memory buffer */
- if(image_data)
+ if (image_data)
HDfree(image_data);
- H5E_BEGIN_TRY {
- H5Fclose(fid);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { H5Fclose(fid); }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-
/*
The following test provides an examples of how to generate HDF5 image data from
floating point data. In the example we use real life topographic data
@@ -534,46 +512,34 @@ http://modb.oce.ulg.ac.be/
*/
-static int test_generate(void)
+static int
+test_generate(void)
{
- hid_t fid;
- hsize_t pal_dims[2] = { 256, 3 };
- float *data;
- int imax, jmax, kmax;
- int n_elements;
- float valex, xmin, xmax, value;
- FILE *f = NULL;
- char *srcdir = getenv("srcdir"); /* the source directory */
- char data_file[512]=""; /* buffer to hold name of existing data file */
- int i;
- int retval = FAIL;
+ hid_t fid;
+ hsize_t pal_dims[2] = {256, 3};
+ float * data = NULL;
+ int imax, jmax, kmax;
+ int n_elements;
+ float valex, xmin, xmax, value;
+ FILE * f = NULL;
+ const char *data_file = H5_get_srcdir_filename(DATA_FILE4);
+ int i;
+ int retval = FAIL;
/* create a file using default properties */
- if ((fid=H5Fcreate(FILE3,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0)
+ if ((fid = H5Fcreate(FILE3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
- printf("Testing read and process data and make indexed images\n");
-
- /*-------------------------------------------------------------------------
- * compose the name of the file to open, using the srcdir, if appropriate
- *-------------------------------------------------------------------------
- */
- if ( srcdir )
- {
- HDstrcpy(data_file, srcdir);
- HDstrcat(data_file, "/");
- }
- HDstrcat(data_file,DATA_FILE4);
+ HDprintf("Testing read and process data and make indexed images\n");
/*-------------------------------------------------------------------------
- * read data; the file data format is described below
- *-------------------------------------------------------------------------
- */
+ * read data; the file data format is described below
+ *-------------------------------------------------------------------------
+ */
- f = HDfopen( data_file, "r" ) ;
- if ( f == NULL )
- {
- printf( "Could not find file %s. Try set $srcdir \n", data_file );
+ f = HDfopen(data_file, "r");
+ if (f == NULL) {
+ HDprintf("Could not find file %s. Try set $srcdir \n", data_file);
goto out;
}
@@ -612,131 +578,135 @@ static int test_generate(void)
!
*/
-
- fscanf( f, "%d %d %d", &imax, &jmax, &kmax );
- fscanf( f, "%f %f %f", &valex, &xmin, &xmax );
+ if (fscanf(f, "%d %d %d", &imax, &jmax, &kmax) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
+ goto out;
+ } /* end if */
+ if (fscanf(f, "%f %f %f", &valex, &xmin, &xmax) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
+ goto out;
+ } /* end if */
/* Sanity check on scanned-in values */
- if(imax < 1 || jmax < 1 || kmax < 1)
+ if (imax < 1 || jmax < 1 || kmax < 1)
goto out;
/* Test product for integer overflow */
- if(imax > INT_MAX / jmax)
+ if (imax > INT_MAX / jmax)
goto out;
- if(imax * jmax > INT_MAX / kmax)
+ if (imax * jmax > INT_MAX / kmax)
goto out;
n_elements = imax * jmax * kmax;
/* Test buffer sizes for overflow */
- if(n_elements > INT_MAX / (int)sizeof(unsigned char))
+ if (n_elements > INT_MAX / (int)sizeof(unsigned char))
goto out;
- if(n_elements > INT_MAX / (int)sizeof(float))
+ if (n_elements > INT_MAX / (int)sizeof(float))
goto out;
-
+
data = (float *)HDmalloc((size_t)n_elements * sizeof(float));
- if(NULL == data)
+ if (NULL == data)
goto out;
image_data = (unsigned char *)HDmalloc((size_t)n_elements * sizeof(unsigned char));
- if(NULL == image_data)
+ if (NULL == image_data)
goto out;
- for ( i = 0; i < n_elements; i++ )
- {
- fscanf( f, "%f ", &value );
+ for (i = 0; i < n_elements; i++) {
+ if (fscanf(f, "%f ", &value) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
+ goto out;
+ } /* end if */
data[i] = value;
}
HDfclose(f);
f = NULL;
/*-------------------------------------------------------------------------
- * transform the data from floating point to unsigned char
- * we are processing all the data here
- *-------------------------------------------------------------------------
- */
+ * transform the data from floating point to unsigned char
+ * we are processing all the data here
+ *-------------------------------------------------------------------------
+ */
- TESTING2("make indexed image from all the data");
+ HL_TESTING2("make indexed image from all the data");
- for ( i = 0; i < n_elements; i++ )
- image_data[i] = (unsigned char)(( 255 * (data[i] - xmin ) ) / (xmax - xmin ));
+ for (i = 0; i < n_elements; i++)
+ image_data[i] = (unsigned char)((255 * (data[i] - xmin)) / (xmax - xmin));
/* Make the image */
- if ((H5IMmake_image_8bit(fid,"All data",(hsize_t)imax,(hsize_t)jmax,image_data))<0)
+ if ((H5IMmake_image_8bit(fid, "All data", (hsize_t)imax, (hsize_t)jmax, image_data)) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * transform the data from floating point to unsigned char
- * here we just process the land data
- *-------------------------------------------------------------------------
- */
+ * transform the data from floating point to unsigned char
+ * here we just process the land data
+ *-------------------------------------------------------------------------
+ */
- TESTING2("make indexed image from land data");
+ HL_TESTING2("make indexed image from land data");
- for ( i = 0; i < n_elements; i++ )
- {
- if ( data[i] < 0 )
+ for (i = 0; i < n_elements; i++) {
+ if (data[i] < 0)
image_data[i] = 0;
else
- image_data[i] = (unsigned char)(( 255 * (data[i] ) ) / xmax );
+ image_data[i] = (unsigned char)((255 * (data[i])) / xmax);
}
/* make the image */
- if ((H5IMmake_image_8bit(fid,"Land data",(hsize_t)imax,(hsize_t)jmax,image_data))<0)
+ if ((H5IMmake_image_8bit(fid, "Land data", (hsize_t)imax, (hsize_t)jmax, image_data)) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * transform the data from floating point to unsigned char
- * here we just process the sea data
- *-------------------------------------------------------------------------
- */
+ * transform the data from floating point to unsigned char
+ * here we just process the sea data
+ *-------------------------------------------------------------------------
+ */
- TESTING2("make indexed image from sea data");
+ HL_TESTING2("make indexed image from sea data");
- for ( i = 0; i < n_elements; i++ )
- {
- if ( data[i] > 0 )
+ for (i = 0; i < n_elements; i++) {
+ if (data[i] > 0)
image_data[i] = 0;
else
- image_data[i] = (unsigned char)(( 255 * (data[i] - xmin ) ) / xmin );
+ image_data[i] = (unsigned char)((255 * (data[i] - xmin)) / xmin);
}
/* make the image */
- if ((H5IMmake_image_8bit(fid,"Sea data",(hsize_t)imax,(hsize_t)jmax,image_data))<0)
+ if ((H5IMmake_image_8bit(fid, "Sea data", (hsize_t)imax, (hsize_t)jmax, image_data)) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * make a palette and attach it to the datasets
- *-------------------------------------------------------------------------
- */
+ * make a palette and attach it to the datasets
+ *-------------------------------------------------------------------------
+ */
- TESTING2("attaching palettes");
+ HL_TESTING2("attaching palettes");
/* make a palette */
- if ((H5IMmake_palette(fid,PAL1_NAME,pal_dims,pal_rgb))<0)
+ if ((H5IMmake_palette(fid, PAL1_NAME, pal_dims, pal_rgb)) < 0)
goto out;
/* attach the palette to the image datasets */
- if ((H5IMlink_palette(fid,"All data",PAL1_NAME))<0)
+ if ((H5IMlink_palette(fid, "All data", PAL1_NAME)) < 0)
goto out;
- if ((H5IMlink_palette(fid,"Land data",PAL1_NAME))<0)
+ if ((H5IMlink_palette(fid, "Land data", PAL1_NAME)) < 0)
goto out;
- if ((H5IMlink_palette(fid,"Sea data",PAL1_NAME))<0)
+ if ((H5IMlink_palette(fid, "Sea data", PAL1_NAME)) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if (H5Fclose(fid)<0)
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Fclose(fid) < 0)
goto out;
/* Release memory buffers */
@@ -749,235 +719,232 @@ static int test_generate(void)
/* error zone, gracefully close */
out:
/* Release memory buffers */
- if(data)
+ if (data)
HDfree(data);
- if(image_data)
+ if (image_data)
HDfree(image_data);
- H5E_BEGIN_TRY {
- H5Fclose(fid);
- } H5E_END_TRY;
- if(f)
+ H5E_BEGIN_TRY { H5Fclose(fid); }
+ H5E_END_TRY;
+ if (f)
HDfclose(f);
H5_FAILED();
return retval;
}
-
/*-------------------------------------------------------------------------
-* read_data
-* utility function to read ASCII image data
-* the files have a header of the type
-*
-* components
-* n
-* height
-* n
-* width
-* n
-*
-* followed by the image data
-*
-*-------------------------------------------------------------------------
-*/
-
-static int read_data(const char* fname, /*IN*/
- hsize_t *width, /*OUT*/
- hsize_t *height /*OUT*/)
+ * read_data
+ * utility function to read ASCII image data
+ * the files have a header of the type
+ *
+ * components
+ * n
+ * height
+ * n
+ * width
+ * n
+ *
+ * followed by the image data
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static int
+read_data(const char *fname, /*IN*/
+ hsize_t * width, /*OUT*/
+ hsize_t * height /*OUT*/)
{
- int i, n;
- int color_planes;
- char str[20];
- FILE *f = NULL;
- int w, h;
- int n_elements;
+ int i, n;
+ int color_planes;
+ char str[20];
+ FILE * f = NULL;
+ int w, h;
+ int n_elements;
const char *data_file = H5_get_srcdir_filename(fname);
- int ret_val = -1;
+ int ret_val = -1;
/*-------------------------------------------------------------------------
- * read
- *-------------------------------------------------------------------------
- */
+ * read
+ *-------------------------------------------------------------------------
+ */
- if(NULL == (f = HDfopen(data_file, "r"))) {
- printf( "Could not open file %s. Try set $srcdir \n", data_file );
+ if (NULL == (f = HDfopen(data_file, "r"))) {
+ HDprintf("Could not open file %s. Try set $srcdir \n", data_file);
goto out;
}
- fscanf(f, "%s", str);
- fscanf(f, "%d", &color_planes);
- fscanf(f, "%s", str);
- fscanf(f, "%d", &h);
- fscanf(f, "%s", str);
- fscanf(f, "%d", &w);
+ if (fscanf(f, "%s", str) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
+ goto out;
+ } /* end if */
+
+ if (fscanf(f, "%d", &color_planes) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
+ goto out;
+ } /* end if */
+
+ if (fscanf(f, "%s", str) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
+ goto out;
+ } /* end if */
+
+ if (fscanf(f, "%d", &h) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
+ goto out;
+ } /* end if */
+
+ if (fscanf(f, "%s", str) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
+ goto out;
+ } /* end if */
+
+ if (fscanf(f, "%d", &w) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
+ goto out;
+ } /* end if */
/* Check product for overflow */
- if(w < 1 || h < 1 || color_planes < 1)
+ if (w < 1 || h < 1 || color_planes < 1)
goto out;
- if(w > INT_MAX / h)
+ if (w > INT_MAX / h)
goto out;
- if(w * h > INT_MAX / color_planes)
+ if (w * h > INT_MAX / color_planes)
goto out;
/* Compute buffer size */
n_elements = w * h * color_planes;
/* Check buffer size for overflow */
- if(n_elements > INT_MAX / (int)sizeof(unsigned char))
+ if (n_elements > INT_MAX / (int)sizeof(unsigned char))
goto out;
/* Release the buffer, if it was previously allocated */
- if(image_data)
+ if (image_data)
HDfree(image_data);
/* Allocate the image data buffer */
image_data = (unsigned char *)HDmalloc((size_t)n_elements * sizeof(unsigned char));
- if(NULL == image_data)
+ if (NULL == image_data)
goto out;
- *width = (hsize_t)w;
+ *width = (hsize_t)w;
*height = (hsize_t)h;
/* Read data elements */
- for(i = 0; i < n_elements; i++) {
- fscanf(f, "%d",&n);
+ for (i = 0; i < n_elements; i++) {
+ if (fscanf(f, "%d", &n) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
+ goto out;
+ } /* end if */
image_data[i] = (unsigned char)n;
} /* end for */
/* Indicate success */
ret_val = 1;
-out:
- if(f)
+out:
+ if (f)
HDfclose(f);
return ret_val;
} /* end read_data() */
-
/*-------------------------------------------------------------------------
-* read_palette
-* Read an ASCII palette file .PAL into an array
-* the files have a header of the type
-*
-* Parameters:
-* fname - name of file to read.
-* palette - array of rgb_t to store the read palette.
-* palette_size - number of elements in 'palette' array
-*
-*-------------------------------------------------------------------------
-*/
-
+ * read_palette
+ * Read an ASCII palette file .PAL into an array
+ * the files have a header of the type
+ *
+ * Parameters:
+ * fname - name of file to read.
+ * palette - array of rgb_t to store the read palette.
+ * palette_size - number of elements in 'palette' array
+ *
+ *-------------------------------------------------------------------------
+ */
#define STRING_JASC "JASC-PAL"
#define VERSION_JASC "0100"
#define STRING_CWPAL "CWPAL"
#define VERSION_CWPAL "100"
-static int read_palette(const char* fname,
- rgb_t *palette,
- size_t palette_size)
+static int
+read_palette(const char *fname, rgb_t *palette, size_t palette_size)
{
- FILE *file;
- char buffer[80];
- unsigned u;
- unsigned int red;
- unsigned int green;
- unsigned int blue;
- unsigned nentries;
- char *srcdir = getenv("srcdir"); /* the source directory */
- char data_file[512]; /* buffer to hold name of existing data file */
-
- /*-------------------------------------------------------------------------
- * compose the name of the file to open, using "srcdir", if appropriate
- *-------------------------------------------------------------------------
- */
- HDstrcpy(data_file, "");
- if (srcdir)
- {
- HDstrcpy(data_file, srcdir);
- HDstrcat(data_file, "/");
- }
- HDstrcat(data_file,fname);
+ FILE * file;
+ char buffer[80];
+ unsigned u;
+ unsigned int red;
+ unsigned int green;
+ unsigned int blue;
+ unsigned nentries;
+ const char * data_file = H5_get_srcdir_filename(fname);
/* ensure the given palette is valid */
if (!palette)
return -1;
/* open the input file */
- if (!(file = HDfopen(data_file, "r")))
- {
- printf( "Could not open file %s. Try set $srcdir \n", data_file );
+ if (!(file = HDfopen(data_file, "r"))) {
+ HDprintf("Could not open file %s. Try set $srcdir \n", data_file);
return -1;
}
/* read the file ident string */
- if (HDfgets(buffer, sizeof(buffer), file) == NULL)
- {
+ if (HDfgets(buffer, sizeof(buffer), file) == NULL) {
HDfclose(file);
return -1;
}
/* ensure it matches the palette file ident string */
- if ( HDstrncmp(buffer, STRING_JASC, sizeof(STRING_JASC) - 1) != 0 &&
- HDstrncmp(buffer, STRING_CWPAL, sizeof(STRING_CWPAL) - 1) != 0 )
- {
+ if (HDstrncmp(buffer, STRING_JASC, sizeof(STRING_JASC) - 1) != 0 &&
+ HDstrncmp(buffer, STRING_CWPAL, sizeof(STRING_CWPAL) - 1) != 0) {
HDfclose(file);
return -1;
}
/* read the version string */
- if (HDfgets(buffer, sizeof(buffer), file) == NULL)
- {
+ if (HDfgets(buffer, sizeof(buffer), file) == NULL) {
HDfclose(file);
return -1;
}
/* ensure it matches the palette file version string */
- if ( HDstrncmp(buffer, VERSION_JASC, sizeof(VERSION_JASC) - 1) != 0 &&
- HDstrncmp(buffer, VERSION_CWPAL, sizeof(VERSION_CWPAL) - 1) != 0 )
- {
+ if (HDstrncmp(buffer, VERSION_JASC, sizeof(VERSION_JASC) - 1) != 0 &&
+ HDstrncmp(buffer, VERSION_CWPAL, sizeof(VERSION_CWPAL) - 1) != 0) {
HDfclose(file);
return -1;
}
/* read the number of colors */
- if (HDfgets(buffer, sizeof(buffer), file) == NULL)
- {
+ if (HDfgets(buffer, sizeof(buffer), file) == NULL) {
HDfclose(file);
return -1;
}
-
/* extract the number of colors.
check for missing version or number of colors
in this case it reads the first entry
*/
- if ( HDstrlen( buffer ) > 4 )
- {
+ if (HDstrlen(buffer) > 4) {
HDfclose(file);
return -1;
}
- if (sscanf(buffer, "%u", &nentries) != 1)
- {
+ if (sscanf(buffer, "%u", &nentries) != 1) {
HDfclose(file);
return -1;
}
/* ensure there are a sensible number of colors in the palette */
- if ((nentries > 256) || (nentries > palette_size))
- {
+ if ((nentries > 256) || (nentries > palette_size)) {
HDfclose(file);
- return(-1);
+ return (-1);
}
/* read the palette entries */
- for (u = 0; u < nentries; u++)
- {
+ for (u = 0; u < nentries; u++) {
/* extract the red, green and blue color components. */
- if (fscanf(file, "%u %u %u", &red, &green, &blue) != 3)
- {
+ if (fscanf(file, "%u %u %u", &red, &green, &blue) != 3) {
HDfclose(file);
return -1;
}
@@ -992,4 +959,3 @@ static int read_palette(const char* fname,
return (int)nentries;
}
-
diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c
index 8d3d0b9..69a1fe5 100644
--- a/hl/test/test_lite.c
+++ b/hl/test/test_lite.c
@@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* 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 *
+ * 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. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdlib.h>
#include <string.h>
@@ -17,7 +17,7 @@
#include "H5srcdir.h"
#include "H5LTpublic.h"
-#define FILE_NAME "test_lite1.h5"
+#define FILE_NAME "test_lite1.h5"
#define FILE_NAME2 "test_lite2.h5"
#define FILE_NAME3 "test_lite3.h5"
#define FILE_NAME4 "test_lite4.h5"
@@ -35,78 +35,76 @@
#define DIM 6
#define ATTR_NAME_SUB "att"
-#define ATTR1_NAME "attr string"
-#define ATTR2_NAME "attr char"
-#define ATTR3_NAME "attr short"
-#define ATTR4_NAME "attr int"
+#define ATTR1_NAME "attr string"
+#define ATTR2_NAME "attr char"
+#define ATTR3_NAME "attr short"
+#define ATTR4_NAME "attr int"
#define ATTR_NAME_EXT "att int ext"
-#define ATTR5_NAME "attr long"
-#define ATTR6_NAME "attr uchar"
-#define ATTR7_NAME "attr ushort"
-#define ATTR8_NAME "attr uint"
-#define ATTR9_NAME "attr ulong"
-#define ATTR10_NAME "attr float"
-#define ATTR11_NAME "attr double"
-
-static herr_t make_attributes( hid_t loc_id, const char* obj_name );
+#define ATTR5_NAME "attr long"
+#define ATTR6_NAME "attr uchar"
+#define ATTR7_NAME "attr ushort"
+#define ATTR8_NAME "attr uint"
+#define ATTR9_NAME "attr ulong"
+#define ATTR10_NAME "attr float"
+#define ATTR11_NAME "attr double"
+static herr_t make_attributes(hid_t loc_id, const char *obj_name);
/*-------------------------------------------------------------------------
-* test dataset functions
-*-------------------------------------------------------------------------
-*/
+ * test dataset functions
+ *-------------------------------------------------------------------------
+ */
-static int test_dsets( void )
+static int
+test_dsets(void)
{
- int rank = 2;
- hsize_t dims[2] = {2,3};
- hid_t file_id;
- hid_t dataset_id;
- char data_char_in[DIM] = {1,2,3,4,5,6};
- char data_char_out[DIM];
- short data_short_in[DIM] = {1,2,3,4,5,6};
- short data_short_out[DIM];
- int data_int_in[DIM] = {1,2,3,4,5,6};
- int data_int_out[DIM];
- long data_long_in[DIM] = {1,2,3,4,5,6};
- long data_long_out[DIM];
- float data_float_in[DIM] = {1,2,3,4,5,6};
- float data_float_out[DIM];
- double data_double_in[DIM] = {1,2,3,4,5,6};
- double data_double_out[DIM];
- const char *data_string_in = "This is a string";
- char data_string_out[20];
- int i;
-
+ int rank = 2;
+ hsize_t dims[2] = {2, 3};
+ hid_t file_id;
+ hid_t dataset_id;
+ char data_char_in[DIM] = {1, 2, 3, 4, 5, 6};
+ char data_char_out[DIM];
+ short data_short_in[DIM] = {1, 2, 3, 4, 5, 6};
+ short data_short_out[DIM];
+ int data_int_in[DIM] = {1, 2, 3, 4, 5, 6};
+ int data_int_out[DIM];
+ long data_long_in[DIM] = {1, 2, 3, 4, 5, 6};
+ long data_long_out[DIM];
+ float data_float_in[DIM] = {1, 2, 3, 4, 5, 6};
+ float data_float_out[DIM];
+ double data_double_in[DIM] = {1, 2, 3, 4, 5, 6};
+ double data_double_out[DIM];
+ const char *data_string_in = "This is a string";
+ char data_string_out[20];
+ int i;
/* Create a new file using default properties. */
- file_id = H5Fcreate( FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
+ file_id = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/*-------------------------------------------------------------------------
- * H5LTmake_dataset test
- *-------------------------------------------------------------------------
- */
+ * H5LTmake_dataset test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTmake_dataset");
+ HL_TESTING2("H5LTmake_dataset");
/* Make dataset */
- if ( H5LTmake_dataset( file_id, DSET0_NAME, rank, dims, H5T_NATIVE_INT, data_int_in ) < 0 )
+ if (H5LTmake_dataset(file_id, DSET0_NAME, rank, dims, H5T_NATIVE_INT, data_int_in) < 0)
goto out;
/* Read dataset using the basic HDF5 API */
- if ( ( dataset_id = H5Dopen2(file_id, DSET0_NAME, H5P_DEFAULT) ) < 0 )
+ if ((dataset_id = H5Dopen2(file_id, DSET0_NAME, H5P_DEFAULT)) < 0)
goto out;
- if ( H5Dread ( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_int_out ) < 0 )
+ if (H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_int_out) < 0)
goto out;
- if ( H5Dclose( dataset_id ) < 0 )
+ if (H5Dclose(dataset_id) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_int_in[i] != data_int_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_int_in[i] != data_int_out[i]) {
goto out;
}
}
@@ -114,18 +112,17 @@ static int test_dsets( void )
PASSED();
/*-------------------------------------------------------------------------
- * read using the LT function H5LTread_dataset
- *-------------------------------------------------------------------------
- */
+ * read using the LT function H5LTread_dataset
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTread_dataset");
+ HL_TESTING2("H5LTread_dataset");
- if ( H5LTread_dataset( file_id, DSET0_NAME, H5T_NATIVE_INT, data_int_out ) < 0 )
+ if (H5LTread_dataset(file_id, DSET0_NAME, H5T_NATIVE_INT, data_int_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_int_in[i] != data_int_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_int_in[i] != data_int_out[i]) {
goto out;
}
}
@@ -133,76 +130,70 @@ static int test_dsets( void )
PASSED();
/*-------------------------------------------------------------------------
- * test the H5LTmake_dataset_ functions
- *-------------------------------------------------------------------------
- */
-
+ * test the H5LTmake_dataset_ functions
+ *-------------------------------------------------------------------------
+ */
/*-------------------------------------------------------------------------
- * H5LTmake_dataset_char
- *-------------------------------------------------------------------------
- */
+ * H5LTmake_dataset_char
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTmake_dataset_char");
+ HL_TESTING2("H5LTmake_dataset_char");
/* Make dataset char */
- if ( H5LTmake_dataset_char( file_id, DSET1_NAME, rank, dims, data_char_in ) < 0 )
+ if (H5LTmake_dataset_char(file_id, DSET1_NAME, rank, dims, data_char_in) < 0)
goto out;
/* Read dataset */
- if ( H5LTread_dataset( file_id, DSET1_NAME, H5T_NATIVE_CHAR, data_char_out ) < 0 )
+ if (H5LTread_dataset(file_id, DSET1_NAME, H5T_NATIVE_CHAR, data_char_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_char_in[i] != data_char_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_char_in[i] != data_char_out[i]) {
goto out;
}
}
/* Read dataset */
- if ( H5LTread_dataset_char( file_id, DSET1_NAME, data_char_out ) < 0 )
+ if (H5LTread_dataset_char(file_id, DSET1_NAME, data_char_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_char_in[i] != data_char_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_char_in[i] != data_char_out[i]) {
goto out;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTmake_dataset_short
- *-------------------------------------------------------------------------
- */
+ * H5LTmake_dataset_short
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTmake_dataset_short");
+ HL_TESTING2("H5LTmake_dataset_short");
/* Make dataset short */
- if ( H5LTmake_dataset_short( file_id, DSET2_NAME, rank, dims, data_short_in ) < 0 )
+ if (H5LTmake_dataset_short(file_id, DSET2_NAME, rank, dims, data_short_in) < 0)
goto out;
/* Read dataset */
- if ( H5LTread_dataset( file_id, DSET2_NAME, H5T_NATIVE_SHORT, data_short_out ) < 0 )
+ if (H5LTread_dataset(file_id, DSET2_NAME, H5T_NATIVE_SHORT, data_short_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_short_in[i] != data_short_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_short_in[i] != data_short_out[i]) {
goto out;
}
}
/* Read dataset */
- if ( H5LTread_dataset_short( file_id, DSET2_NAME, data_short_out ) < 0 )
+ if (H5LTread_dataset_short(file_id, DSET2_NAME, data_short_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_short_in[i] != data_short_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_short_in[i] != data_short_out[i]) {
goto out;
}
}
@@ -210,180 +201,165 @@ static int test_dsets( void )
PASSED();
/*-------------------------------------------------------------------------
- * H5LTmake_dataset_int
- *-------------------------------------------------------------------------
- */
+ * H5LTmake_dataset_int
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTmake_dataset_int");
+ HL_TESTING2("H5LTmake_dataset_int");
/* Make dataset int */
- if ( H5LTmake_dataset_int( file_id, DSET3_NAME, rank, dims, data_int_in ) < 0 )
+ if (H5LTmake_dataset_int(file_id, DSET3_NAME, rank, dims, data_int_in) < 0)
goto out;
/* Read dataset */
- if ( H5LTread_dataset( file_id, DSET3_NAME, H5T_NATIVE_INT, data_int_out ) < 0 )
+ if (H5LTread_dataset(file_id, DSET3_NAME, H5T_NATIVE_INT, data_int_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_int_in[i] != data_int_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_int_in[i] != data_int_out[i]) {
goto out;
}
}
/* Read dataset */
- if ( H5LTread_dataset_int( file_id, DSET3_NAME, data_int_out ) < 0 )
+ if (H5LTread_dataset_int(file_id, DSET3_NAME, data_int_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_int_in[i] != data_int_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_int_in[i] != data_int_out[i]) {
goto out;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTmake_dataset_long
- *-------------------------------------------------------------------------
- */
+ * H5LTmake_dataset_long
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTmake_dataset_long");
+ HL_TESTING2("H5LTmake_dataset_long");
/* Make dataset long */
- if ( H5LTmake_dataset_long( file_id, DSET4_NAME, rank, dims, data_long_in ) < 0 )
+ if (H5LTmake_dataset_long(file_id, DSET4_NAME, rank, dims, data_long_in) < 0)
goto out;
/* Read dataset */
- if ( H5LTread_dataset( file_id, DSET4_NAME, H5T_NATIVE_LONG, data_long_out ) < 0 )
+ if (H5LTread_dataset(file_id, DSET4_NAME, H5T_NATIVE_LONG, data_long_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_long_in[i] != data_long_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_long_in[i] != data_long_out[i]) {
goto out;
}
}
/* Read dataset */
- if ( H5LTread_dataset_long( file_id, DSET4_NAME, data_long_out ) < 0 )
+ if (H5LTread_dataset_long(file_id, DSET4_NAME, data_long_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_long_in[i] != data_long_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_long_in[i] != data_long_out[i]) {
goto out;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTmake_dataset_float
- *-------------------------------------------------------------------------
- */
+ * H5LTmake_dataset_float
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTmake_dataset_float");
+ HL_TESTING2("H5LTmake_dataset_float");
/* Make dataset float */
- if ( H5LTmake_dataset_float( file_id, DSET5_NAME, rank, dims, data_float_in ) < 0 )
+ if (H5LTmake_dataset_float(file_id, DSET5_NAME, rank, dims, data_float_in) < 0)
goto out;
/* Read dataset */
- if ( H5LTread_dataset( file_id, DSET5_NAME, H5T_NATIVE_FLOAT, data_float_out ) < 0 )
+ if (H5LTread_dataset(file_id, DSET5_NAME, H5T_NATIVE_FLOAT, data_float_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if(!FLT_ABS_EQUAL(data_float_in[i],data_float_out[i])) {
+ for (i = 0; i < DIM; i++) {
+ if (!H5_FLT_ABS_EQUAL(data_float_in[i], data_float_out[i])) {
goto out;
}
}
/* Read dataset */
- if ( H5LTread_dataset_float( file_id, DSET5_NAME, data_float_out ) < 0 )
+ if (H5LTread_dataset_float(file_id, DSET5_NAME, data_float_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if(!FLT_ABS_EQUAL(data_float_in[i],data_float_out[i])) {
+ for (i = 0; i < DIM; i++) {
+ if (!H5_FLT_ABS_EQUAL(data_float_in[i], data_float_out[i])) {
goto out;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTmake_dataset_double
- *-------------------------------------------------------------------------
- */
+ * H5LTmake_dataset_double
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTmake_dataset_double");
+ HL_TESTING2("H5LTmake_dataset_double");
/* Make dataset double */
- if ( H5LTmake_dataset_double( file_id, DSET6_NAME, rank, dims, data_double_in ) < 0 )
+ if (H5LTmake_dataset_double(file_id, DSET6_NAME, rank, dims, data_double_in) < 0)
goto out;
/* Read dataset */
- if ( H5LTread_dataset( file_id, DSET6_NAME, H5T_NATIVE_DOUBLE, data_double_out ) < 0 )
+ if (H5LTread_dataset(file_id, DSET6_NAME, H5T_NATIVE_DOUBLE, data_double_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if(!DBL_ABS_EQUAL(data_double_in[i],data_double_out[i])) {
+ for (i = 0; i < DIM; i++) {
+ if (!H5_DBL_ABS_EQUAL(data_double_in[i], data_double_out[i])) {
goto out;
}
}
/* Read dataset */
- if ( H5LTread_dataset_double( file_id, DSET6_NAME, data_double_out ) < 0 )
+ if (H5LTread_dataset_double(file_id, DSET6_NAME, data_double_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if(!DBL_ABS_EQUAL(data_double_in[i],data_double_out[i])) {
+ for (i = 0; i < DIM; i++) {
+ if (!H5_DBL_ABS_EQUAL(data_double_in[i], data_double_out[i])) {
goto out;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTmake_dataset_string
- *-------------------------------------------------------------------------
- */
+ * H5LTmake_dataset_string
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTmake_dataset_string");
+ HL_TESTING2("H5LTmake_dataset_string");
/* Make dataset string */
- if ( H5LTmake_dataset_string(file_id,DSET7_NAME,data_string_in) < 0 )
+ if (H5LTmake_dataset_string(file_id, DSET7_NAME, data_string_in) < 0)
goto out;
/* Read dataset */
- if ( H5LTread_dataset_string(file_id,DSET7_NAME,data_string_out) < 0 )
+ if (H5LTread_dataset_string(file_id, DSET7_NAME, data_string_out) < 0)
goto out;
- if ( HDstrcmp(data_string_in,data_string_out) != 0 )
+ if (HDstrcmp(data_string_in, data_string_out) != 0)
goto out;
-
-
/*-------------------------------------------------------------------------
- * end tests
- *-------------------------------------------------------------------------
- */
+ * end tests
+ *-------------------------------------------------------------------------
+ */
/* Close the file. */
- H5Fclose( file_id );
+ H5Fclose(file_id);
PASSED();
-
return 0;
out:
@@ -393,75 +369,83 @@ out:
}
/*-------------------------------------------------------------------------
-* test attribute functions
-*-------------------------------------------------------------------------
-*/
+ * test attribute functions
+ *-------------------------------------------------------------------------
+ */
-static int test_attr(void)
+static int
+test_attr(void)
{
hid_t file_id;
hid_t dataset_id;
hid_t group_id;
hid_t space_id;
- hsize_t dims[1] = { 5 };
+ hsize_t dims[1] = {5};
/* Create a new file using default properties. */
file_id = H5Fcreate(FILE_NAME2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/*-------------------------------------------------------------------------
- * Create a dataset named "dset" on the root group
- *-------------------------------------------------------------------------
- */
+ * Create a dataset named "dset" on the root group
+ *-------------------------------------------------------------------------
+ */
/* Create the data space */
- if((space_id = H5Screate_simple(1, dims, NULL)) < 0) goto out;
+ if ((space_id = H5Screate_simple(1, dims, NULL)) < 0)
+ goto out;
/* Create the dataset */
- if((dataset_id = H5Dcreate2(file_id , "dset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out;
+ if ((dataset_id = H5Dcreate2(file_id, "dset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT,
+ H5P_DEFAULT)) < 0)
+ goto out;
/* Close */
H5Dclose(dataset_id);
/*-------------------------------------------------------------------------
- * Create a group named "grp" on the root group
- *-------------------------------------------------------------------------
- */
+ * Create a group named "grp" on the root group
+ *-------------------------------------------------------------------------
+ */
/* Create a group. */
- if((group_id = H5Gcreate2(file_id, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out;
+ if ((group_id = H5Gcreate2(file_id, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
/* Close */
H5Gclose(group_id);
/*-------------------------------------------------------------------------
- *
- * Create attributes in the root group
- * Note that we are calling the H5LTset_attribute functions with the name "."
- *
- *-------------------------------------------------------------------------
- */
- if(make_attributes(file_id, ".") < 0) goto out;
+ *
+ * Create attributes in the root group
+ * Note that we are calling the H5LTset_attribute functions with the name "."
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (make_attributes(file_id, ".") < 0)
+ goto out;
/*-------------------------------------------------------------------------
- *
- * Create attributes in the dataset "dset"
- *
- *-------------------------------------------------------------------------
- */
- if(make_attributes(file_id, "dset") < 0) goto out;
+ *
+ * Create attributes in the dataset "dset"
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (make_attributes(file_id, "dset") < 0)
+ goto out;
/*-------------------------------------------------------------------------
- *
- * Create attributes in the group "grp"
- *
- *-------------------------------------------------------------------------
- */
- if(make_attributes(file_id, "grp") < 0) goto out;
+ *
+ * Create attributes in the group "grp"
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (make_attributes(file_id, "grp") < 0)
+ goto out;
/*-------------------------------------------------------------------------
- * end
- *-------------------------------------------------------------------------
- */
+ * end
+ *-------------------------------------------------------------------------
+ */
/* Close the file. */
H5Fclose(file_id);
@@ -476,113 +460,109 @@ out:
}
/*-------------------------------------------------------------------------
-* make_attributes
-*-------------------------------------------------------------------------
-*/
+ * make_attributes
+ *-------------------------------------------------------------------------
+ */
-static herr_t make_attributes( hid_t loc_id, const char* obj_name )
+static herr_t
+make_attributes(hid_t loc_id, const char *obj_name)
{
int rank_out;
- hsize_t *dims_out = 0;
+ hsize_t * dims_out = 0;
H5T_class_t type_class;
size_t type_size;
int i;
- char attr_str_in[] = {"My attribute"};
- char attr_str_out[20];
- char attr_char_in[5] = {1,2,3,4,5};
- char attr_char_out[5];
- short attr_short_in[5] = {1,2,3,4,5};
- short attr_short_out[5];
- int attr_int_in[5] = {1,2,3,4,5};
- int attr_int_out[5];
- long attr_long_in[5] = {1,2,3,4,5};
- long attr_long_out[5];
- float attr_float_in[5] = {1,2,3,4,5};
- float attr_float_out[5];
- double attr_double_in[5] = {1,2,3,4,5};
- double attr_double_out[5];
- unsigned char attr_uchar_in[5] = {1,2,3,4,5};
- unsigned char attr_uchar_out[5];
- unsigned short attr_ushort_in[5] = {1,2,3,4,5};
- unsigned short attr_ushort_out[5];
- unsigned int attr_uint_in[5] = {1,2,3,4,5};
- unsigned int attr_uint_out[5];
- unsigned long attr_ulong_in[5] = {1,2,3,4,5};
- unsigned long attr_ulong_out[5];
+ char attr_str_in[] = {"My attribute"};
+ char attr_str_out[20];
+ char attr_char_in[5] = {1, 2, 3, 4, 5};
+ char attr_char_out[5];
+ short attr_short_in[5] = {1, 2, 3, 4, 5};
+ short attr_short_out[5];
+ int attr_int_in[5] = {1, 2, 3, 4, 5};
+ int attr_int_out[5];
+ long attr_long_in[5] = {1, 2, 3, 4, 5};
+ long attr_long_out[5];
+ float attr_float_in[5] = {1, 2, 3, 4, 5};
+ float attr_float_out[5];
+ double attr_double_in[5] = {1, 2, 3, 4, 5};
+ double attr_double_out[5];
+ unsigned char attr_uchar_in[5] = {1, 2, 3, 4, 5};
+ unsigned char attr_uchar_out[5];
+ unsigned short attr_ushort_in[5] = {1, 2, 3, 4, 5};
+ unsigned short attr_ushort_out[5];
+ unsigned int attr_uint_in[5] = {1, 2, 3, 4, 5};
+ unsigned int attr_uint_out[5];
+ unsigned long attr_ulong_in[5] = {1, 2, 3, 4, 5};
+ unsigned long attr_ulong_out[5];
/*-------------------------------------------------------------------------
- * H5LTset_attribute_string test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_string test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_string");
+ HL_TESTING2("H5LTset_attribute_string");
/* Set the attribute */
- if ( H5LTset_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_in ) < 0 )
+ if (H5LTset_attribute_string(loc_id, obj_name, ATTR1_NAME, attr_str_in) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTset_attribute_string test
- *-------------------------------------------------------------------------
- */
-
- TESTING("H5LTget_attribute_string");
+ * H5LTset_attribute_string test
+ *-------------------------------------------------------------------------
+ */
+ HL_TESTING2("H5LTget_attribute_string");
/* Get the attribute */
- if ( H5LTget_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_out ) < 0 )
+ if (H5LTget_attribute_string(loc_id, obj_name, ATTR1_NAME, attr_str_out) < 0)
return -1;
- if ( HDstrcmp( attr_str_in, attr_str_out ) != 0 )
- {
+ if (HDstrcmp(attr_str_in, attr_str_out) != 0) {
return -1;
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTset_attribute_char test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_char test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_char");
+ HL_TESTING2("H5LTset_attribute_char");
/* Set the attribute */
- if ( H5LTset_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_char(loc_id, obj_name, ATTR2_NAME, attr_char_in, (size_t)5) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_char test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_char test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_char");
+ HL_TESTING2("H5LTget_attribute_char");
/* Get the attribute */
- if ( H5LTget_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_out ) < 0 )
+ if (H5LTget_attribute_char(loc_id, obj_name, ATTR2_NAME, attr_char_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_char_in[i] != attr_char_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_char_in[i] != attr_char_out[i]) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR2_NAME, H5T_NATIVE_CHAR, attr_char_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR2_NAME, H5T_NATIVE_CHAR, attr_char_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_char_in[i] != attr_char_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_char_in[i] != attr_char_out[i]) {
return -1;
}
}
@@ -590,117 +570,109 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
PASSED();
/*-------------------------------------------------------------------------
- * H5LTset_attribute_short test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_short test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_short");
+ HL_TESTING2("H5LTset_attribute_short");
/* Set the attribute */
- if ( H5LTset_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_short(loc_id, obj_name, ATTR3_NAME, attr_short_in, (size_t)5) < 0)
return -1;
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTget_attribute_short test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_short test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_short");
+ HL_TESTING2("H5LTget_attribute_short");
/* Get the attribute */
- if ( H5LTget_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_out ) < 0 )
+ if (H5LTget_attribute_short(loc_id, obj_name, ATTR3_NAME, attr_short_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_short_in[i] != attr_short_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_short_in[i] != attr_short_out[i]) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR3_NAME, H5T_NATIVE_SHORT, attr_short_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR3_NAME, H5T_NATIVE_SHORT, attr_short_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_short_in[i] != attr_short_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_short_in[i] != attr_short_out[i]) {
return -1;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTset_attribute_int test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_int test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_int");
+ HL_TESTING2("H5LTset_attribute_int");
/* Set the attribute */
- if ( H5LTset_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_int(loc_id, obj_name, ATTR4_NAME, attr_int_in, (size_t)5) < 0)
return -1;
/* Set the attribute which is a substring of an existing attribute */
- if ( H5LTset_attribute_int( loc_id, obj_name, ATTR_NAME_SUB, attr_int_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_int(loc_id, obj_name, ATTR_NAME_SUB, attr_int_in, (size_t)5) < 0)
return -1;
/* Set the attribute which is an extension of an existing attribute */
- if ( H5LTset_attribute_int( loc_id, obj_name, ATTR_NAME_EXT, attr_int_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_int(loc_id, obj_name, ATTR_NAME_EXT, attr_int_in, (size_t)5) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_int test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_int test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_int");
+ HL_TESTING2("H5LTget_attribute_int");
/* Get the attribute */
- if ( H5LTget_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_out ) < 0 )
+ if (H5LTget_attribute_int(loc_id, obj_name, ATTR4_NAME, attr_int_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_int_in[i] != attr_int_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_int_in[i] != attr_int_out[i]) {
return -1;
}
}
- if ( H5LTget_attribute_int( loc_id, obj_name, ATTR_NAME_SUB, attr_int_out ) < 0 )
+ if (H5LTget_attribute_int(loc_id, obj_name, ATTR_NAME_SUB, attr_int_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_int_in[i] != attr_int_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_int_in[i] != attr_int_out[i]) {
return -1;
}
}
- if ( H5LTget_attribute_int( loc_id, obj_name, ATTR_NAME_EXT, attr_int_out ) < 0 )
+ if (H5LTget_attribute_int(loc_id, obj_name, ATTR_NAME_EXT, attr_int_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_int_in[i] != attr_int_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_int_in[i] != attr_int_out[i]) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR4_NAME, H5T_NATIVE_INT, attr_int_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR4_NAME, H5T_NATIVE_INT, attr_int_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_int_in[i] != attr_int_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_int_in[i] != attr_int_out[i]) {
return -1;
}
}
@@ -708,43 +680,41 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
PASSED();
/*-------------------------------------------------------------------------
- * H5LTset_attribute_long test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_long test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_long");
+ HL_TESTING2("H5LTset_attribute_long");
/* Set the attribute */
- if ( H5LTset_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_long(loc_id, obj_name, ATTR5_NAME, attr_long_in, (size_t)5) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_long test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_long test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_long");
+ HL_TESTING2("H5LTget_attribute_long");
/* Get the attribute */
- if ( H5LTget_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_out ) < 0 )
+ if (H5LTget_attribute_long(loc_id, obj_name, ATTR5_NAME, attr_long_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_long_in[i] != attr_long_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_long_in[i] != attr_long_out[i]) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR5_NAME, H5T_NATIVE_LONG, attr_long_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR5_NAME, H5T_NATIVE_LONG, attr_long_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_long_in[i] != attr_long_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_long_in[i] != attr_long_out[i]) {
return -1;
}
}
@@ -752,43 +722,41 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
PASSED();
/*-------------------------------------------------------------------------
- * H5LTset_attribute_uchar test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_uchar test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_uchar");
+ HL_TESTING2("H5LTset_attribute_uchar");
/* Set the attribute */
- if ( H5LTset_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_uchar(loc_id, obj_name, ATTR6_NAME, attr_uchar_in, (size_t)5) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_uchar test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_uchar test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_uchar");
+ HL_TESTING2("H5LTget_attribute_uchar");
/* Get the attribute */
- if ( H5LTget_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_out ) < 0 )
+ if (H5LTget_attribute_uchar(loc_id, obj_name, ATTR6_NAME, attr_uchar_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_uchar_in[i] != attr_uchar_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_uchar_in[i] != attr_uchar_out[i]) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR6_NAME, H5T_NATIVE_UCHAR, attr_uchar_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR6_NAME, H5T_NATIVE_UCHAR, attr_uchar_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_uchar_in[i] != attr_uchar_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_uchar_in[i] != attr_uchar_out[i]) {
return -1;
}
}
@@ -796,89 +764,83 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
PASSED();
/*-------------------------------------------------------------------------
- * H5LTset_attribute_ushort test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_ushort test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_ushort");
+ HL_TESTING2("H5LTset_attribute_ushort");
/* Set the attribute */
- if ( H5LTset_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_ushort(loc_id, obj_name, ATTR7_NAME, attr_ushort_in, (size_t)5) < 0)
return -1;
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTget_attribute_ushort test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_ushort test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_ushort");
+ HL_TESTING2("H5LTget_attribute_ushort");
/* Get the attribute */
- if ( H5LTget_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_out ) < 0 )
+ if (H5LTget_attribute_ushort(loc_id, obj_name, ATTR7_NAME, attr_ushort_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_ushort_in[i] != attr_ushort_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_ushort_in[i] != attr_ushort_out[i]) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR7_NAME, H5T_NATIVE_USHORT, attr_ushort_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR7_NAME, H5T_NATIVE_USHORT, attr_ushort_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_ushort_in[i] != attr_ushort_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_ushort_in[i] != attr_ushort_out[i]) {
return -1;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTset_attribute_int test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_int test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_uint");
+ HL_TESTING2("H5LTset_attribute_uint");
/* Set the attribute */
- if ( H5LTset_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_uint(loc_id, obj_name, ATTR8_NAME, attr_uint_in, (size_t)5) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_int test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_int test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_uint");
+ HL_TESTING2("H5LTget_attribute_uint");
/* Get the attribute */
- if ( H5LTget_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_out ) < 0 )
+ if (H5LTget_attribute_uint(loc_id, obj_name, ATTR8_NAME, attr_uint_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_uint_in[i] != attr_uint_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_uint_in[i] != attr_uint_out[i]) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR8_NAME, H5T_NATIVE_UINT, attr_uint_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR8_NAME, H5T_NATIVE_UINT, attr_uint_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_uint_in[i] != attr_uint_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_uint_in[i] != attr_uint_out[i]) {
return -1;
}
}
@@ -886,89 +848,83 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
PASSED();
/*-------------------------------------------------------------------------
- * H5LTset_attribute_ulong test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_ulong test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_ulong");
+ HL_TESTING2("H5LTset_attribute_ulong");
/* Set the attribute */
- if ( H5LTset_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_ulong(loc_id, obj_name, ATTR9_NAME, attr_ulong_in, (size_t)5) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_long test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_long test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_ulong");
+ HL_TESTING2("H5LTget_attribute_ulong");
/* Get the attribute */
- if ( H5LTget_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_out ) < 0 )
+ if (H5LTget_attribute_ulong(loc_id, obj_name, ATTR9_NAME, attr_ulong_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_ulong_in[i] != attr_ulong_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_ulong_in[i] != attr_ulong_out[i]) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR9_NAME, H5T_NATIVE_ULONG, attr_ulong_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR9_NAME, H5T_NATIVE_ULONG, attr_ulong_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_ulong_in[i] != attr_ulong_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_ulong_in[i] != attr_ulong_out[i]) {
return -1;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTset_attribute_float test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_float test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_float");
+ HL_TESTING2("H5LTset_attribute_float");
/* Set the attribute */
- if ( H5LTset_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_float(loc_id, obj_name, ATTR10_NAME, attr_float_in, (size_t)5) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_float test
- *-------------------------------------------------------------------------
- */
-
- TESTING("H5LTget_attribute_float");
+ * H5LTget_attribute_float test
+ *-------------------------------------------------------------------------
+ */
+ HL_TESTING2("H5LTget_attribute_float");
/* Get the attribute */
- if ( H5LTget_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_out ) < 0 )
+ if (H5LTget_attribute_float(loc_id, obj_name, ATTR10_NAME, attr_float_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if(!FLT_ABS_EQUAL(attr_float_in[i],attr_float_out[i])) {
+ for (i = 0; i < 5; i++) {
+ if (!H5_FLT_ABS_EQUAL(attr_float_in[i], attr_float_out[i])) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR10_NAME, H5T_NATIVE_FLOAT, attr_float_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR10_NAME, H5T_NATIVE_FLOAT, attr_float_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if(!FLT_ABS_EQUAL(attr_float_in[i],attr_float_out[i])) {
+ for (i = 0; i < 5; i++) {
+ if (!H5_FLT_ABS_EQUAL(attr_float_in[i], attr_float_out[i])) {
return -1;
}
}
@@ -976,93 +932,90 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
PASSED();
/*-------------------------------------------------------------------------
- * H5LTset_attribute_double test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_double test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_double");
+ HL_TESTING2("H5LTset_attribute_double");
/* Set the attribute */
- if ( H5LTset_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_double(loc_id, obj_name, ATTR11_NAME, attr_double_in, (size_t)5) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_double test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_double test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_double");
+ HL_TESTING2("H5LTget_attribute_double");
/* Get the attribute */
- if ( H5LTget_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_out ) < 0 )
+ if (H5LTget_attribute_double(loc_id, obj_name, ATTR11_NAME, attr_double_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if(!DBL_ABS_EQUAL(attr_double_in[i],attr_double_out[i])) {
+ for (i = 0; i < 5; i++) {
+ if (!H5_DBL_ABS_EQUAL(attr_double_in[i], attr_double_out[i])) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR11_NAME, H5T_NATIVE_DOUBLE, attr_double_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR11_NAME, H5T_NATIVE_DOUBLE, attr_double_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if(!DBL_ABS_EQUAL(attr_double_in[i],attr_double_out[i])) {
+ for (i = 0; i < 5; i++) {
+ if (!H5_DBL_ABS_EQUAL(attr_double_in[i], attr_double_out[i])) {
return -1;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTget_attribute_ndims test
- *-------------------------------------------------------------------------
- */
-
+ * H5LTget_attribute_ndims test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_ndims");
+ HL_TESTING2("H5LTget_attribute_ndims");
- if ( H5LTget_attribute_ndims( loc_id, obj_name, ATTR2_NAME, &rank_out ) < 0 )
+ if (H5LTget_attribute_ndims(loc_id, obj_name, ATTR2_NAME, &rank_out) < 0)
return -1;
- if ( rank_out != 1 ) {
+ if (rank_out != 1) {
return -1;
}
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_info test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_info test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_info");
+ HL_TESTING2("H5LTget_attribute_info");
- if(NULL==(dims_out = (hsize_t*) HDmalloc( sizeof(hsize_t) * (size_t)rank_out ))) return -1;
+ if (NULL == (dims_out = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)rank_out)))
+ return -1;
- if ( H5LTget_attribute_info( loc_id, obj_name, ATTR2_NAME, dims_out, &type_class, &type_size) < 0 ) {
- HDfree( dims_out );
+ if (H5LTget_attribute_info(loc_id, obj_name, ATTR2_NAME, dims_out, &type_class, &type_size) < 0) {
+ HDfree(dims_out);
return -1;
}
-
+
for (i = 0; i < rank_out; i++) {
- if ( dims_out[i] != 5 ) {
- HDfree( dims_out );
+ if (dims_out[i] != 5) {
+ HDfree(dims_out);
return -1;
}
}
- if ( type_class != H5T_INTEGER ) {
- HDfree( dims_out );
+ if (type_class != H5T_INTEGER) {
+ HDfree(dims_out);
return -1;
}
- HDfree( dims_out );
+ HDfree(dims_out);
PASSED();
@@ -1070,52 +1023,53 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_integers().
-*-------------------------------------------------------------------------
-*/
-static int test_integers(void)
+ * subroutine for test_text_dtype(): test_integers().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_integers(void)
{
- hid_t dtype;
- char* dt_str;
- size_t str_len;
+ hid_t dtype;
+ char * dt_str;
+ size_t str_len;
- TESTING3("\n text for integer types");
+ HL_TESTING3("\n text for integer types");
- if((dtype = H5LTtext_to_dtype("H5T_NATIVE_INT\n", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_NATIVE_INT\n", H5LT_DDL)) < 0)
goto out;
- if(!H5Tequal(dtype, H5T_NATIVE_INT))
+ if (!H5Tequal(dtype, H5T_NATIVE_INT))
goto out;
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
- if((dtype = H5LTtext_to_dtype("H5T_STD_I8BE\n", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_STD_I8BE\n", H5LT_DDL)) < 0)
goto out;
- if(!H5Tequal(dtype, H5T_STD_I8BE))
+ if (!H5Tequal(dtype, H5T_STD_I8BE))
goto out;
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_STD_I8BE")) {
+ if (HDstrcmp(dt_str, "H5T_STD_I8BE")) {
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
- if((dtype = H5LTtext_to_dtype("H5T_STD_U16LE\n", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_STD_U16LE\n", H5LT_DDL)) < 0)
goto out;
- if(!H5Tequal(dtype, H5T_STD_U16LE))
+ if (!H5Tequal(dtype, H5T_STD_U16LE))
goto out;
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
PASSED();
@@ -1127,52 +1081,53 @@ out:
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_fps().
-*-------------------------------------------------------------------------
-*/
-static int test_fps(void)
+ * subroutine for test_text_dtype(): test_fps().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_fps(void)
{
- hid_t dtype;
- char* dt_str;
- size_t str_len;
+ hid_t dtype;
+ char * dt_str;
+ size_t str_len;
- TESTING3(" text for floating-point types");
+ HL_TESTING3(" text for floating-point types");
- if((dtype = H5LTtext_to_dtype("H5T_NATIVE_LDOUBLE\n", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_NATIVE_LDOUBLE\n", H5LT_DDL)) < 0)
goto out;
- if(!H5Tequal(dtype, H5T_NATIVE_LDOUBLE))
+ if (!H5Tequal(dtype, H5T_NATIVE_LDOUBLE))
goto out;
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
- if((dtype = H5LTtext_to_dtype("H5T_IEEE_F32BE\n", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_IEEE_F32BE\n", H5LT_DDL)) < 0)
goto out;
- if(!H5Tequal(dtype, H5T_IEEE_F32BE))
+ if (!H5Tequal(dtype, H5T_IEEE_F32BE))
goto out;
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
-
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_IEEE_F32BE")) {
+ if (HDstrcmp(dt_str, "H5T_IEEE_F32BE")) {
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
- if((dtype = H5LTtext_to_dtype("H5T_IEEE_F64LE\n", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_IEEE_F64LE\n", H5LT_DDL)) < 0)
goto out;
- if(!H5Tequal(dtype, H5T_IEEE_F64LE))
+ if (!H5Tequal(dtype, H5T_IEEE_F64LE))
goto out;
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
PASSED();
@@ -1184,83 +1139,90 @@ out:
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_strings().
-*-------------------------------------------------------------------------
-*/
-static int test_strings(void)
+ * subroutine for test_text_dtype(): test_strings().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_strings(void)
{
- hid_t dtype;
- size_t str_size;
+ hid_t dtype;
+ size_t str_size;
H5T_str_t str_pad;
H5T_cset_t str_cset;
H5T_class_t type_class;
- char* dt_str;
- size_t str_len;
+ char * dt_str = NULL;
+ size_t str_len;
- TESTING3(" text for string types");
+ HL_TESTING3(" text for string types");
- if((dtype = H5LTtext_to_dtype("H5T_STRING { STRSIZE 13; STRPAD H5T_STR_NULLTERM; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; }", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype(
+ "H5T_STRING { STRSIZE 13; STRPAD H5T_STR_NULLTERM; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; }",
+ H5LT_DDL)) < 0)
goto out;
- if((type_class = H5Tget_class(dtype))<0)
+ if ((type_class = H5Tget_class(dtype)) < 0)
goto out;
- if(type_class != H5T_STRING)
+ if (type_class != H5T_STRING)
goto out;
str_size = H5Tget_size(dtype);
- if(str_size != 13)
+ if (str_size != 13)
goto out;
str_pad = H5Tget_strpad(dtype);
- if(str_pad != H5T_STR_NULLTERM)
+ if (str_pad != H5T_STR_NULLTERM)
goto out;
str_cset = H5Tget_cset(dtype);
- if(str_cset != H5T_CSET_ASCII)
+ if (str_cset != H5T_CSET_ASCII)
goto out;
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_STRING {\n STRSIZE 13;\n STRPAD H5T_STR_NULLTERM;\n CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }")) {
- printf("dt=\n%s\n", dt_str);
+ if (HDstrcmp(dt_str, "H5T_STRING {\n STRSIZE 13;\n STRPAD H5T_STR_NULLTERM;\n CSET "
+ "H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }")) {
+ HDprintf("dt=\n%s\n", dt_str);
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
- if((dtype = H5LTtext_to_dtype("H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_STR_NULLPAD; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; }", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_STR_NULLPAD; CSET "
+ "H5T_CSET_ASCII; CTYPE H5T_C_S1; }",
+ H5LT_DDL)) < 0)
goto out;
- if(!H5Tis_variable_str(dtype))
+ if (!H5Tis_variable_str(dtype))
goto out;
str_pad = H5Tget_strpad(dtype);
- if(str_pad != H5T_STR_NULLPAD)
+ if (str_pad != H5T_STR_NULLPAD)
goto out;
str_cset = H5Tget_cset(dtype);
- if(str_cset != H5T_CSET_ASCII)
+ if (str_cset != H5T_CSET_ASCII)
goto out;
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }")) {
- printf("dt=\n%s\n", dt_str);
+ if (HDstrcmp(dt_str, "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n "
+ "CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }")) {
+ HDprintf("dt=\n%s\n", dt_str);
HDfree(dt_str);
goto out;
}
@@ -1268,96 +1230,108 @@ static int test_strings(void)
/* Length of the character buffer is larger then needed */
str_len = str_len + 10;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
- goto out;
-
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
- HDfree(dt_str);
- goto out;
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
+ goto out;
+
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
+ HDfree(dt_str);
+ goto out;
}
- if(HDstrncmp(dt_str, "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }", str_len-1)) {
- printf("dt=\n%s\n", dt_str);
- HDfree(dt_str);
- goto out;
+ if (HDstrncmp(dt_str,
+ "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET "
+ "H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }",
+ str_len - 1)) {
+ HDprintf("dt=\n%s\n", dt_str);
+ HDfree(dt_str);
+ goto out;
}
+ HDfree(dt_str);
/* Length of the character buffer is smaller then needed */
str_len = 21;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
- goto out;
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
+ goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
- HDfree(dt_str);
- goto out;
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
+ HDfree(dt_str);
+ goto out;
}
/* check the truncated string */
- if(strlen(dt_str) != str_len-1) goto out;
- str_len = strlen(dt_str);
- if(HDstrncmp(dt_str, "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }", str_len)) {
- printf("dt=\n%s\n", dt_str);
- HDfree(dt_str);
- goto out;
+ if (HDstrlen(dt_str) != str_len - 1)
+ goto out;
+ str_len = HDstrlen(dt_str);
+ if (HDstrncmp(dt_str,
+ "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET "
+ "H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }",
+ str_len)) {
+ HDprintf("dt=\n%s\n", dt_str);
+ HDfree(dt_str);
+ goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
PASSED();
return 0;
out:
- if(dt_str)
- HDfree(dt_str);
+ if (dt_str)
+ HDfree(dt_str);
H5_FAILED();
return -1;
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_opaques().
-*-------------------------------------------------------------------------
-*/
-static int test_opaques(void)
+ * subroutine for test_text_dtype(): test_opaques().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_opaques(void)
{
- hid_t dtype;
- size_t opq_size;
+ hid_t dtype;
+ size_t opq_size;
H5T_class_t type_class;
- char* dt_str;
- size_t str_len;
+ char * dt_str;
+ size_t str_len;
- TESTING3(" text for opaque types");
+ HL_TESTING3(" text for opaque types");
- if((dtype = H5LTtext_to_dtype("H5T_OPAQUE { OPQ_SIZE 19; OPQ_TAG \"This is a tag for opaque type\"; }", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_OPAQUE { OPQ_SIZE 19; OPQ_TAG \"This is a tag for opaque type\"; }",
+ H5LT_DDL)) < 0)
goto out;
- if((type_class = H5Tget_class(dtype))<0)
+ if ((type_class = H5Tget_class(dtype)) < 0)
goto out;
- if(type_class != H5T_OPAQUE)
+ if (type_class != H5T_OPAQUE)
goto out;
- if((opq_size = H5Tget_size(dtype)) == 0)
+ if ((opq_size = H5Tget_size(dtype)) == 0)
goto out;
- if(opq_size != 19)
+ if (opq_size != 19)
goto out;
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_OPAQUE {\n OPQ_SIZE 19;\n OPQ_TAG \"This is a tag for opaque type\";\n }")) {
- printf("dt=\n%s\n", dt_str);
+ if (HDstrcmp(
+ dt_str,
+ "H5T_OPAQUE {\n OPQ_SIZE 19;\n OPQ_TAG \"This is a tag for opaque type\";\n }")) {
+ HDprintf("dt=\n%s\n", dt_str);
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
PASSED();
@@ -1369,72 +1343,75 @@ out:
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_enums().
-*-------------------------------------------------------------------------
-*/
-static int test_enums(void)
+ * subroutine for test_text_dtype(): test_enums().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_enums(void)
{
- hid_t dtype;
- size_t size = 16;
- char name1[16];
- int value1 = 7;
- const char *name2 = "WHITE";
- int value2;
+ hid_t dtype;
+ size_t size = 16;
+ char name1[16];
+ int value1 = 7;
+ const char *name2 = "WHITE";
+ int value2;
H5T_class_t type_class;
- char* dt_str;
- size_t str_len;
+ char * dt_str;
+ size_t str_len;
- TESTING3(" text for enum types");
+ HL_TESTING3(" text for enum types");
- if((dtype = H5LTtext_to_dtype("H5T_ENUM { H5T_STD_I32LE; \"RED\" 5; \"GREEN\" 6; \"BLUE\" 7; \"WHITE\" 8; }", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype(
+ "H5T_ENUM { H5T_STD_I32LE; \"RED\" 5; \"GREEN\" 6; \"BLUE\" 7; \"WHITE\" 8; }", H5LT_DDL)) < 0)
goto out;
- if((type_class = H5Tget_class(dtype))<0)
+ if ((type_class = H5Tget_class(dtype)) < 0)
goto out;
- if(type_class != H5T_ENUM)
+ if (type_class != H5T_ENUM)
goto out;
/* Convert the variable before using it */
- if(!H5Tequal(H5T_STD_I32LE, H5T_NATIVE_INT)) {
- if(H5Tconvert(H5T_NATIVE_INT, H5T_STD_I32LE, 1, &value1, NULL, H5P_DEFAULT) < 0)
+ if (!H5Tequal(H5T_STD_I32LE, H5T_NATIVE_INT)) {
+ if (H5Tconvert(H5T_NATIVE_INT, H5T_STD_I32LE, 1, &value1, NULL, H5P_DEFAULT) < 0)
goto out;
}
- if(H5Tenum_nameof(dtype, &value1, name1, size)<0)
+ if (H5Tenum_nameof(dtype, &value1, name1, size) < 0)
goto out;
- if(HDstrcmp(name1, "BLUE"))
+ if (HDstrcmp(name1, "BLUE"))
goto out;
- if(H5Tenum_valueof(dtype, name2, &value2)<0)
+ if (H5Tenum_valueof(dtype, name2, &value2) < 0)
goto out;
/* Convert the variable before comparing it */
- if(!H5Tequal(H5T_STD_I32LE, H5T_NATIVE_INT)) {
- if(H5Tconvert(H5T_NATIVE_INT, H5T_STD_I32LE, 1, &value2, NULL, H5P_DEFAULT) < 0)
+ if (!H5Tequal(H5T_STD_I32LE, H5T_NATIVE_INT)) {
+ if (H5Tconvert(H5T_NATIVE_INT, H5T_STD_I32LE, 1, &value2, NULL, H5P_DEFAULT) < 0)
goto out;
}
- if(value2 != 8)
+ if (value2 != 8)
goto out;
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_ENUM {\n H5T_STD_I32LE;\n \"RED\" 5;\n \"GREEN\" 6;\n \"BLUE\" 7;\n \"WHITE\" 8;\n }")) {
+ if (HDstrcmp(dt_str, "H5T_ENUM {\n H5T_STD_I32LE;\n \"RED\" 5;\n \"GREEN\" "
+ " 6;\n \"BLUE\" 7;\n \"WHITE\" 8;\n }")) {
- printf("dt=\n%s\n", dt_str);
+ HDprintf("dt=\n%s\n", dt_str);
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
PASSED();
@@ -1446,56 +1423,57 @@ out:
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_variables().
-*-------------------------------------------------------------------------
-*/
-static int test_variables(void)
+ * subroutine for test_text_dtype(): test_variables().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_variables(void)
{
- hid_t dtype;
+ hid_t dtype;
H5T_class_t type_class;
- char* dt_str;
- size_t str_len;
+ char * dt_str;
+ size_t str_len;
- TESTING3(" text for variable types");
+ HL_TESTING3(" text for variable types");
- if((dtype = H5LTtext_to_dtype("H5T_VLEN { H5T_NATIVE_CHAR }\n", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_VLEN { H5T_NATIVE_CHAR }\n", H5LT_DDL)) < 0)
goto out;
- if((type_class = H5Tget_class(dtype))<0)
+ if ((type_class = H5Tget_class(dtype)) < 0)
goto out;
- if(type_class != H5T_VLEN)
+ if (type_class != H5T_VLEN)
goto out;
- if(H5Tis_variable_str(dtype))
+ if (H5Tis_variable_str(dtype))
goto out;
-
- if(H5Tclose(dtype)<0)
+
+ if (H5Tclose(dtype) < 0)
goto out;
-
- if((dtype = H5LTtext_to_dtype("H5T_VLEN { H5T_VLEN { H5T_STD_I32BE } }", H5LT_DDL))<0)
+
+ if ((dtype = H5LTtext_to_dtype("H5T_VLEN { H5T_VLEN { H5T_STD_I32BE } }", H5LT_DDL)) < 0)
goto out;
-
- if(H5Tis_variable_str(dtype))
+
+ if (H5Tis_variable_str(dtype))
goto out;
-
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_VLEN {\n H5T_VLEN {\n H5T_STD_I32BE\n }\n }")) {
- printf("dt=\n%s\n", dt_str);
+ if (HDstrcmp(dt_str, "H5T_VLEN {\n H5T_VLEN {\n H5T_STD_I32BE\n }\n }")) {
+ HDprintf("dt=\n%s\n", dt_str);
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
-
- if(H5Tclose(dtype)<0)
+
+ if (H5Tclose(dtype) < 0)
goto out;
-
+
PASSED();
return 0;
@@ -1505,55 +1483,60 @@ out:
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_arrays().
-*-------------------------------------------------------------------------
-*/
-static int test_arrays(void)
+ * subroutine for test_text_dtype(): test_arrays().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_arrays(void)
{
- hid_t dtype;
- int ndims;
- hsize_t dims[3];
+ hid_t dtype;
+ int ndims;
+ hsize_t dims[3];
H5T_class_t type_class;
- char* dt_str;
- size_t str_len;
+ char * dt_str;
+ size_t str_len;
- TESTING3(" text for array types");
+ HL_TESTING3(" text for array types");
- if((dtype = H5LTtext_to_dtype("H5T_ARRAY { [5][7][13] H5T_ARRAY { [17][19] H5T_COMPOUND { H5T_STD_I8BE \"arr_compound_1\"; H5T_STD_I32BE \"arr_compound_2\"; } } }", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_ARRAY { [5][7][13] H5T_ARRAY { [17][19] H5T_COMPOUND { H5T_STD_I8BE "
+ "\"arr_compound_1\"; H5T_STD_I32BE \"arr_compound_2\"; } } }",
+ H5LT_DDL)) < 0)
goto out;
- if((type_class = H5Tget_class(dtype))<0)
+ if ((type_class = H5Tget_class(dtype)) < 0)
goto out;
- if(type_class != H5T_ARRAY)
+ if (type_class != H5T_ARRAY)
goto out;
- if((ndims = H5Tget_array_ndims(dtype))<0)
+ if ((ndims = H5Tget_array_ndims(dtype)) < 0)
goto out;
- if(ndims != 3)
+ if (ndims != 3)
goto out;
- if(H5Tget_array_dims2(dtype, dims) < 0)
+ if (H5Tget_array_dims2(dtype, dims) < 0)
goto out;
- if(dims[0] != 5 || dims[1] != 7 || dims[2] != 13)
+ if (dims[0] != 5 || dims[1] != 7 || dims[2] != 13)
goto out;
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_ARRAY {\n [5][7][13] H5T_ARRAY {\n [17][19] H5T_COMPOUND {\n H5T_STD_I8BE \"arr_compound_1\" : 0;\n H5T_STD_I32BE \"arr_compound_2\" : 1;\n }\n }\n }")) {
- printf("dt=\n%s\n", dt_str);
+ if (HDstrcmp(dt_str, "H5T_ARRAY {\n [5][7][13] H5T_ARRAY {\n [17][19] H5T_COMPOUND {\n "
+ " H5T_STD_I8BE \"arr_compound_1\" : 0;\n H5T_STD_I32BE "
+ "\"arr_compound_2\" : 1;\n }\n }\n }")) {
+ HDprintf("dt=\n%s\n", dt_str);
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
PASSED();
@@ -1565,66 +1548,74 @@ out:
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_compounds().
-*-------------------------------------------------------------------------
-*/
-static int test_compounds(void)
+ * subroutine for test_text_dtype(): test_compounds().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_compounds(void)
{
- hid_t dtype;
- int nmembs;
- char *memb_name = NULL;
+ hid_t dtype;
+ int nmembs;
+ char * memb_name = NULL;
H5T_class_t memb_class;
H5T_class_t type_class;
- char* dt_str;
- size_t str_len;
+ char * dt_str;
+ size_t str_len;
- TESTING3(" text for compound types");
+ HL_TESTING3(" text for compound types");
- if((dtype = H5LTtext_to_dtype("H5T_COMPOUND { H5T_STD_I16BE \"one_field\" : 2; H5T_STD_U8LE \"two_field\" : 6; }", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype(
+ "H5T_COMPOUND { H5T_STD_I16BE \"one_field\" : 2; H5T_STD_U8LE \"two_field\" : 6; }", H5LT_DDL)) <
+ 0)
goto out;
- if((type_class = H5Tget_class(dtype))<0)
+ if ((type_class = H5Tget_class(dtype)) < 0)
goto out;
- if(type_class != H5T_COMPOUND)
+ if (type_class != H5T_COMPOUND)
goto out;
- if((nmembs = H5Tget_nmembers(dtype))<0)
+ if ((nmembs = H5Tget_nmembers(dtype)) < 0)
goto out;
- if(nmembs != 2)
+ if (nmembs != 2)
goto out;
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_COMPOUND {\n H5T_STD_I16BE \"one_field\" : 2;\n H5T_STD_U8LE \"two_field\" : 6;\n }")) {
- printf("dt=\n%s\n", dt_str);
+ if (HDstrcmp(dt_str, "H5T_COMPOUND {\n H5T_STD_I16BE \"one_field\" : 2;\n H5T_STD_U8LE "
+ "\"two_field\" : 6;\n }")) {
+ HDprintf("dt=\n%s\n", dt_str);
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
- if((dtype = H5LTtext_to_dtype("H5T_COMPOUND { H5T_STD_I32BE \"i32_field\"; H5T_STD_I16BE \"i16_field\"; H5T_COMPOUND { H5T_STD_I16BE \"sec_field\"; H5T_COMPOUND { H5T_STD_I32BE \"thd_field\"; } \"grandchild\"; } \"child_compound\"; H5T_STD_I8BE \"i8_field\"; }", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype(
+ "H5T_COMPOUND { H5T_STD_I32BE \"i32_field\"; H5T_STD_I16BE \"i16_field\"; H5T_COMPOUND { "
+ "H5T_STD_I16BE \"sec_field\"; H5T_COMPOUND { H5T_STD_I32BE \"thd_field\"; } \"grandchild\"; } "
+ "\"child_compound\"; H5T_STD_I8BE \"i8_field\"; }",
+ H5LT_DDL)) < 0)
goto out;
- if((memb_name = H5Tget_member_name(dtype, 1)) == NULL)
+ if ((memb_name = H5Tget_member_name(dtype, 1)) == NULL)
goto out;
- if(HDstrcmp(memb_name, "i16_field")) {
+ if (HDstrcmp(memb_name, "i16_field")) {
H5free_memory(memb_name);
goto out;
}
H5free_memory(memb_name);
- if((memb_class = H5Tget_member_class(dtype, 2))<0)
+ if ((memb_class = H5Tget_member_class(dtype, 2)) < 0)
goto out;
- if(memb_class != H5T_COMPOUND)
+ if (memb_class != H5T_COMPOUND)
goto out;
PASSED();
@@ -1636,110 +1627,120 @@ out:
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_compound_bug(). Test case for
-* issue 7701.
-*-------------------------------------------------------------------------
-*/
-static int test_compound_bug(void)
+ * subroutine for test_text_dtype(): test_compound_bug(). Test case for
+ * issue 7701.
+ *-------------------------------------------------------------------------
+ */
+static int
+test_compound_bug(void)
{
hid_t dtype;
H5T_class_t type_class;
int nmembs;
- char* memb_name = NULL;
- char* dt_str;
+ char * memb_name = NULL;
+ char * dt_str;
size_t str_len;
- char text[] = "H5T_COMPOUND { H5T_STD_I32LE \"state_________________________________________________________________________________\"; H5T_STD_I32LE \"desc_________________________________________________________________________________________\"; H5T_VLEN { H5T_COMPOUND { H5T_ENUM { H5T_STD_I16LE; \"ZERO\" 0; \"ONE\" 1; \"TWO\" 2; \"THREE\" 3; } \"type____\"; H5T_STD_I32LE \"sub_______________________________________________________________________________________________________________\"; H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_STR_SPACEPAD; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; } \"sub_desc\"; H5T_STD_I32LE \"final___________________________________________________________________________________________________\"; } } \"sub\"; }";
- char text2[] =
- "H5T_COMPOUND {\n"
- " H5T_STD_I16LE \"state___________________________"
- "__________________________________________________"
- "____\" : 0;\n"
- " H5T_STD_I16LE \"desc____________________________"
- "__________________________________________________"
- "___________\" : 2;\n"
- " H5T_VLEN { H5T_COMPOUND {\n"
- " H5T_ENUM { H5T_STD_I16LE; \"ZERO\" 0; \"ONE\" "
- "1; \"TWO\" 2; \"THREE\" 3; } \"type____\" : 0;\n"
- " H5T_STD_I32LE \"sub___________________________"
- "__________________________________________________"
- "__________________________________1\" : 4;\n"
- " H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_"
- "STR_SPACEPAD; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1;"
- " } \"sub_desc\" : 8;\n"
- " H5T_STD_I32LE \"final_________________________"
- "__________________________________________________"
- "________________________\" : 16;\n"
- " } } \"sub\" : 8;\n"
- "}\n";
-
- TESTING3(" text for compound type of bug fix");
-
- if((dtype = H5LTtext_to_dtype(text, H5LT_DDL))<0)
- goto out;
-
- if((type_class = H5Tget_class(dtype))<0)
- goto out;
- if(type_class != H5T_COMPOUND)
- goto out;
-
- if((memb_name = H5Tget_member_name(dtype, 2)) == NULL)
- goto out;
- if(HDstrcmp(memb_name, "sub")) {
+ char text[] = "H5T_COMPOUND { H5T_STD_I32LE "
+ "\"state_________________________________________________________________________________"
+ "\"; H5T_STD_I32LE "
+ "\"desc____________________________________________________________________________________"
+ "_____\"; H5T_VLEN { H5T_COMPOUND { H5T_ENUM { H5T_STD_I16LE; \"ZERO\" 0; \"ONE\" 1; "
+ "\"TWO\" 2; \"THREE\" 3; } \"type____\"; H5T_STD_I32LE "
+ "\"sub_____________________________________________________________________________________"
+ "__________________________\"; H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_STR_SPACEPAD; "
+ "CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; } \"sub_desc\"; H5T_STD_I32LE "
+ "\"final___________________________________________________________________________________"
+ "________________\"; } } \"sub\"; }";
+ char text2[] = "H5T_COMPOUND {\n"
+ " H5T_STD_I16LE \"state___________________________"
+ "__________________________________________________"
+ "____\" : 0;\n"
+ " H5T_STD_I16LE \"desc____________________________"
+ "__________________________________________________"
+ "___________\" : 2;\n"
+ " H5T_VLEN { H5T_COMPOUND {\n"
+ " H5T_ENUM { H5T_STD_I16LE; \"ZERO\" 0; \"ONE\" "
+ "1; \"TWO\" 2; \"THREE\" 3; } \"type____\" : 0;\n"
+ " H5T_STD_I32LE \"sub___________________________"
+ "__________________________________________________"
+ "__________________________________1\" : 4;\n"
+ " H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_"
+ "STR_SPACEPAD; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1;"
+ " } \"sub_desc\" : 8;\n"
+ " H5T_STD_I32LE \"final_________________________"
+ "__________________________________________________"
+ "________________________\" : 16;\n"
+ " } } \"sub\" : 8;\n"
+ "}\n";
+
+ HL_TESTING3(" text for compound type of bug fix");
+
+ if ((dtype = H5LTtext_to_dtype(text, H5LT_DDL)) < 0)
+ goto out;
+
+ if ((type_class = H5Tget_class(dtype)) < 0)
+ goto out;
+ if (type_class != H5T_COMPOUND)
+ goto out;
+
+ if ((memb_name = H5Tget_member_name(dtype, 2)) == NULL)
+ goto out;
+ if (HDstrcmp(memb_name, "sub")) {
H5free_memory(memb_name);
goto out;
}
H5free_memory(memb_name);
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
-
/* Test similar datatype in another format */
- if((dtype = H5LTtext_to_dtype(text2, H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype(text2, H5LT_DDL)) < 0)
goto out;
- if((type_class = H5Tget_class(dtype))<0)
+ if ((type_class = H5Tget_class(dtype)) < 0)
goto out;
- if(type_class != H5T_COMPOUND)
+ if (type_class != H5T_COMPOUND)
goto out;
- if((nmembs = H5Tget_nmembers(dtype))<0)
+ if ((nmembs = H5Tget_nmembers(dtype)) < 0)
goto out;
- if(nmembs != 3)
+ if (nmembs != 3)
goto out;
- if((memb_name = H5Tget_member_name(dtype, 1)) == NULL)
+ if ((memb_name = H5Tget_member_name(dtype, 1)) == NULL)
goto out;
- if(HDstrcmp(memb_name, "desc_________________________________________________________________________________________")) {
+ if (HDstrcmp(memb_name, "desc____________________________________________________________________________"
+ "_____________")) {
H5free_memory(memb_name);
goto out;
}
H5free_memory(memb_name);
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
PASSED();
@@ -1751,74 +1752,67 @@ out:
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_complicated_compound().
-*-------------------------------------------------------------------------
-*/
-static int test_complicated_compound(void)
+ * subroutine for test_text_dtype(): test_complicated_compound().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_complicated_compound(void)
{
- hid_t dtype;
- int nmembs;
+ hid_t dtype;
+ int nmembs;
H5T_class_t type_class;
- char *line = NULL;
- FILE *fp = NULL;
- size_t size = 1024;
- char *srcdir = getenv("srcdir"); /* the source directory */
- char filename[1024]="";
+ char * line = NULL;
+ FILE * fp = NULL;
+ size_t size = 1024;
+ const char *filename = H5_get_srcdir_filename(INPUT_FILE);
- TESTING3(" text for complicated compound types");
-
- /* compose the name of the file to open, using the srcdir, if appropriate */
- if(srcdir) {
- HDstrcpy(filename, srcdir);
- HDstrcat(filename, "/");
- }
- HDstrcat(filename, INPUT_FILE);
+ HL_TESTING3(" text for complicated compound types");
/* Open input file */
fp = HDfopen(filename, "r");
- if(fp == NULL) {
- printf( "Could not find file %s. Try set $srcdir \n", filename);
+ if (fp == NULL) {
+ HDprintf("Could not find file %s. Try set $srcdir \n", filename);
goto out;
}
/* This part reads in the input as a string in a slow manner. GNU C
- * Library has convenient function getline() but isn't available on
- * all machines.
- */
- if((line = (char*)HDcalloc(size, sizeof(char)))==NULL)
+ * Library has convenient function getline() but isn't available on
+ * all machines.
+ */
+ if ((line = (char *)HDcalloc(size, sizeof(char))) == NULL)
goto out;
- if(HDfgets(line, (int)size, fp)==NULL)
+ if (HDfgets(line, (int)size, fp) == NULL)
goto out;
- while(HDstrlen(line)==size-1) {
+ while (HDstrlen(line) == size - 1) {
size *= 2;
- if(line)
+ if (line)
HDfree(line);
- if((line = (char*)HDcalloc(size, sizeof(char)))==NULL)
+ if ((line = (char *)HDcalloc(size, sizeof(char))) == NULL)
goto out;
- if(HDfseek(fp, 0L, SEEK_SET)!=0)
+ if (HDfseek(fp, 0L, SEEK_SET) != 0)
goto out;
- if(HDfgets(line, (int)size, fp)==NULL)
+ if (HDfgets(line, (int)size, fp) == NULL)
goto out;
}
HDfclose(fp);
fp = NULL;
- if((dtype = H5LTtext_to_dtype(line, H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype(line, H5LT_DDL)) < 0)
goto out;
- if((type_class = H5Tget_class(dtype))<0)
+ if ((type_class = H5Tget_class(dtype)) < 0)
goto out;
- if(type_class != H5T_COMPOUND)
+ if (type_class != H5T_COMPOUND)
goto out;
/* There should be 101 compound members */
- if((nmembs = H5Tget_nmembers(dtype))<0)
+ if ((nmembs = H5Tget_nmembers(dtype)) < 0)
goto out;
- if(nmembs != 101)
+ if (nmembs != 101)
goto out;
- if(line)
+ if (line)
HDfree(line);
PASSED();
@@ -1826,9 +1820,9 @@ static int test_complicated_compound(void)
out:
- if(line)
+ if (line)
HDfree(line);
- if(fp)
+ if (fp)
HDfclose(fp);
H5_FAILED();
@@ -1836,41 +1830,42 @@ out:
}
/*-------------------------------------------------------------------------
-* test H5LTtext_to_dtype function
-*-------------------------------------------------------------------------
-*/
-static int test_text_dtype(void)
+ * test H5LTtext_to_dtype function
+ *-------------------------------------------------------------------------
+ */
+static int
+test_text_dtype(void)
{
- TESTING("H5LTtext_to_dtype");
+ HL_TESTING2("H5LTtext_to_dtype");
- if(test_integers()<0)
+ if (test_integers() < 0)
goto out;
- if(test_fps()<0)
+ if (test_fps() < 0)
goto out;
- if(test_strings()<0)
+ if (test_strings() < 0)
goto out;
- if(test_opaques()<0)
+ if (test_opaques() < 0)
goto out;
- if(test_enums()<0)
+ if (test_enums() < 0)
goto out;
- if(test_variables()<0)
+ if (test_variables() < 0)
goto out;
- if(test_arrays()<0)
+ if (test_arrays() < 0)
goto out;
- if(test_compounds()<0)
+ if (test_compounds() < 0)
goto out;
- if(test_compound_bug()<0)
+ if (test_compound_bug() < 0)
goto out;
- if(test_complicated_compound()<0)
+ if (test_complicated_compound() < 0)
goto out;
return 0;
@@ -1883,362 +1878,364 @@ out:
* test H5LTpath_valid function
*-------------------------------------------------------------------------
*/
-static int test_valid_path(void)
+static int
+test_valid_path(void)
{
- hid_t file_id, group;
- htri_t path_valid;
- const char *data_string_in = "test";
-
- TESTING("H5LTpath_valid");
-
- /* Create a new file using default properties. */
-
- /**************************************************************
- * The file structure should look like this:
- *
- * +----------------------------------+
- * | / |
- * +----------------------------------+
- * / | \ \
- * / | \ \
- * / | \ \
- * / | \ G8 (dangled external link)
- * / DS \
- * / \
- * G1 G2
- * | --> DS1 |
- * / \--> DS3 / \
- * / / \
- * G2 DS4 G7
- * | (hard link (dangled soft link
- * | to /G1/DS3) to /G1/G20 )
- * |
- * |
- * | --- Gcyc (soft link to /G1)
- * / \
- * / \
- * G5 \
- * (soft link G6 (external link /G1 in FILENAME4)
- * to /G2)
- *
- ****************************************************************/
-
- file_id = H5Fcreate(FILE_NAME3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
- /*
- * Create dataset "/DS"
- */
- if(H5LTmake_dataset_string(file_id, "DS", data_string_in)<0)
- goto out;
-
- /*
- * Create an external dangled link
- */
- if(H5Lcreate_external("NonExistant_File.h5", "G8", file_id, "DangledExternalLink", H5P_DEFAULT, H5P_DEFAULT)<0)
- goto out;
-
- /*
- * Create a group named "G2" in the file.
- */
- if((group = H5Gcreate2(file_id, "G2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0)
- goto out;
-
- /*
- * Create a dataset named "G2/DS4" in the file.
- */
- if(H5LTmake_dataset_string(group, "/G2/DS4", data_string_in)<0)
- goto out;
-
- /*
- * Create a soft link
- */
- if(H5Lcreate_soft("/G1/G20", file_id, "/G2/G7", H5P_DEFAULT, H5P_DEFAULT) <0)
- goto out;
-
- if(H5Gclose(group)<0)
- goto out;
-
- /*
- * Create a group named "G1" in the file.
- */
- if((group = H5Gcreate2(file_id, "G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0)
- goto out;
-
- /*
- * Create a group named "G1/DS1" in the file.
- */
- if(H5LTmake_dataset_string(group, "/G1/DS1", data_string_in)<0)
- goto out;
-
- if(H5Gclose(group)<0)
- goto out;
-
- /*
- * Create a hard link
- */
- if(H5Lcreate_hard(file_id, "/G2/DS4", file_id, "/G1/DS3",H5P_DEFAULT, H5P_DEFAULT)<0)
- goto out;
- /*
- * Create a group named "/G1/G2" in the file.
- */
- if((group = H5Gcreate2(file_id, "/G1/G2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0)
- goto out;
-
- /*
- * Create a soft link
- */
- if(H5Lcreate_soft("/G2", file_id, "/G1/G2/G5", H5P_DEFAULT, H5P_DEFAULT)<0)
- goto out;
-
- /*
- * Create a cyclic soft link
- */
- if(H5Lcreate_soft("/G1", file_id, "/G1/G2/Gcyc", H5P_DEFAULT, H5P_DEFAULT)<0)
- goto out;
-
- if(H5Gclose(group)<0)
- goto out;
-
- /*
- * Create a group named "/G1/G2/G6" in the file.
- */
- if((group = H5Gcreate2(file_id, "/G1/G2/G6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0)
- goto out;
-
- /*
- * Create an external link
- */
- if(H5Lcreate_external( FILE_NAME4, "G1", group, "ExternalLink", H5P_DEFAULT, H5P_DEFAULT)<0)
- goto out;
-
- if(H5Gclose(group)<0)
- goto out;
- /*
- * Close the file.
- */
- if(H5Fclose (file_id) < 0)
- goto out;
-
- /* Create another file for checking external links */
-
- /**************************************************************
- * The file structure should look like this:
- *
- * +----+
- * | / |
- * +----+
- * |
- * |
- * |
- * G1
- * / \
- * / \
- * DS1 G2
- * (dangled soft link to /G1/G20)
- *
- ****************************************************************/
-
- /* Make external link file */
- file_id = H5Fcreate(FILE_NAME4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
- /*
- * Create a group named "G1" in the file.
- */
- if((group = H5Gcreate2(file_id, "G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0)
- goto out;
- /*
- * Create a dataset named "G1/DS1" in the file.
- */
- if(H5LTmake_dataset_string(group, "/G1/DS1", data_string_in)<0)
- goto out;
-
- /*
- * Create a dangling soft link
- */
-
- if(H5Lcreate_soft("/G1/G2", file_id, "/G1/G20", H5P_DEFAULT, H5P_DEFAULT)<0)
- goto out;
-
- if(H5Gclose(group)<0)
- goto out;
-
- H5Fclose(file_id);
-
- /* Open input file */
- if((file_id = H5Fopen(FILE_NAME3,H5F_ACC_RDONLY, H5P_DEFAULT))<0)
- goto out;
-
- /**************************************
- * CHECK ABSOLUTE PATHS
- **************************************/
-
- if( (path_valid = H5LTpath_valid(file_id, "/", TRUE)) != FALSE) {
- goto out;
- }
-
- if( (path_valid = H5LTpath_valid(file_id, "/", FALSE)) != FALSE) {
- goto out;
- }
-
- if( (path_valid = H5LTpath_valid(file_id, "/G1", TRUE)) != TRUE) {
- goto out;
- }
-
- if((path_valid = H5LTpath_valid(file_id, "/G1/DS1", TRUE)) != TRUE)
- goto out;
-
- if( (path_valid = H5LTpath_valid(file_id, "/G1/DS3", TRUE)) != TRUE)
- goto out;
-
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2", TRUE)) != TRUE)
- goto out;
-
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G5", TRUE)) != TRUE)
- goto out;
-
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/DS1", FALSE)) != TRUE)
- goto out;
-
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/DS1", TRUE)) != TRUE)
- goto out;
-
- if( (path_valid = H5LTpath_valid(file_id, "/G2", TRUE)) != TRUE)
- goto out;
-
- /* check soft link points to a valid object*/
- if( (path_valid = H5LTpath_valid(file_id, "/G2/DS4", TRUE)) != TRUE)
- goto out;
-
- /* check if path exist, but not the object */
- if( (path_valid = H5LTpath_valid(file_id, "/G2/G7", FALSE)) != TRUE )
- goto out;
- /* check if path exist and if the object exists. It should fail
- * since it is a dangling soft link
- */
- if( (path_valid = H5LTpath_valid(file_id, "/G2/G7", TRUE)) == TRUE)
- goto out;
-
- /* check soft links */
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G5/DS4", TRUE)) != TRUE)
- goto out;
-
- /**************************************
- * CHECK RELATIVE PATHS
- ***************************************/
-
- if( (group = H5Gopen2(file_id, "/", H5P_DEFAULT)) < 0)
- goto out;
-
- if( (path_valid = H5LTpath_valid(group, "/", TRUE)) != FALSE) {
- goto out;
- }
+ hid_t file_id, group;
+ htri_t path_valid;
+ const char *data_string_in = "test";
- if( (path_valid = H5LTpath_valid(group, "/", FALSE)) != FALSE) {
- goto out;
- }
+ HL_TESTING2("H5LTpath_valid");
- if(H5Gclose(group)<0)
- goto out;
+ /* Create a new file using default properties. */
- if( (group = H5Gopen2(file_id, "/G1", H5P_DEFAULT)) < 0)
- goto out;
+ /**************************************************************
+ * The file structure should look like this:
+ *
+ * +----------------------------------+
+ * | / |
+ * +----------------------------------+
+ * / | \ \
+ * / | \ \
+ * / | \ \
+ * / | \ G8 (dangled external link)
+ * / DS \
+ * / \
+ * G1 G2
+ * | --> DS1 |
+ * / \--> DS3 / \
+ * / / \
+ * G2 DS4 G7
+ * | (hard link (dangled soft link
+ * | to /G1/DS3) to /G1/G20 )
+ * |
+ * |
+ * | --- Gcyc (soft link to /G1)
+ * / \
+ * / \
+ * G5 \
+ * (soft link G6 (external link /G1 in FILENAME4)
+ * to /G2)
+ *
+ ****************************************************************/
- /* The identifier (file id) is the object itself, i.e. "." */
+ file_id = H5Fcreate(FILE_NAME3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- if((path_valid = H5LTpath_valid(file_id, ".", FALSE)) != TRUE)
- goto out;
+ /*
+ * Create dataset "/DS"
+ */
+ if (H5LTmake_dataset_string(file_id, "DS", data_string_in) < 0)
+ goto out;
- if( (path_valid = H5LTpath_valid(file_id, ".", TRUE)) != TRUE)
- goto out;
+ /*
+ * Create an external dangled link
+ */
+ if (H5Lcreate_external("NonExistant_File.h5", "G8", file_id, "DangledExternalLink", H5P_DEFAULT,
+ H5P_DEFAULT) < 0)
+ goto out;
- /* The identifier (group id) is the object itself, i.e. "." */
+ /*
+ * Create a group named "G2" in the file.
+ */
+ if ((group = H5Gcreate2(file_id, "G2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- if( (path_valid = H5LTpath_valid(group, ".", TRUE)) != TRUE)
- goto out;
+ /*
+ * Create a dataset named "G2/DS4" in the file.
+ */
+ if (H5LTmake_dataset_string(group, "/G2/DS4", data_string_in) < 0)
+ goto out;
- if( (path_valid = H5LTpath_valid(group, "DS3", FALSE)) != TRUE)
- goto out;
+ /*
+ * Create a soft link
+ */
+ if (H5Lcreate_soft("/G1/G20", file_id, "/G2/G7", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
- if( (path_valid = H5LTpath_valid(group, "DS3", TRUE)) != TRUE)
- goto out;
+ if (H5Gclose(group) < 0)
+ goto out;
- if( (path_valid = H5LTpath_valid(group, "G2/G5", TRUE)) != TRUE)
- goto out;
+ /*
+ * Create a group named "G1" in the file.
+ */
+ if ((group = H5Gcreate2(file_id, "G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- /* Check the "./" case */
- if( (path_valid = H5LTpath_valid(group, "./DS3", TRUE)) != TRUE)
- goto out;
+ /*
+ * Create a group named "G1/DS1" in the file.
+ */
+ if (H5LTmake_dataset_string(group, "/G1/DS1", data_string_in) < 0)
+ goto out;
- if( (path_valid = H5LTpath_valid(group, "./G2/G5", TRUE)) != TRUE)
- goto out;
+ if (H5Gclose(group) < 0)
+ goto out;
- /* Should fail, does not exist */
- if( (path_valid = H5LTpath_valid(group, "./G2/G20", FALSE)) == TRUE)
- goto out;
+ /*
+ * Create a hard link
+ */
+ if (H5Lcreate_hard(file_id, "/G2/DS4", file_id, "/G1/DS3", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
+ /*
+ * Create a group named "/G1/G2" in the file.
+ */
+ if ((group = H5Gcreate2(file_id, "/G1/G2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- /* Should fail, does not exist */
- if( (path_valid = H5LTpath_valid(group, "./G2/G20", TRUE)) == TRUE)
- goto out;
+ /*
+ * Create a soft link
+ */
+ if (H5Lcreate_soft("/G2", file_id, "/G1/G2/G5", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
- if(H5Gclose(group)<0)
- goto out;
+ /*
+ * Create a cyclic soft link
+ */
+ if (H5Lcreate_soft("/G1", file_id, "/G1/G2/Gcyc", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
+
+ if (H5Gclose(group) < 0)
+ goto out;
+
+ /*
+ * Create a group named "/G1/G2/G6" in the file.
+ */
+ if ((group = H5Gcreate2(file_id, "/G1/G2/G6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+
+ /*
+ * Create an external link
+ */
+ if (H5Lcreate_external(FILE_NAME4, "G1", group, "ExternalLink", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
+
+ if (H5Gclose(group) < 0)
+ goto out;
+ /*
+ * Close the file.
+ */
+ if (H5Fclose(file_id) < 0)
+ goto out;
+
+ /* Create another file for checking external links */
+
+ /**************************************************************
+ * The file structure should look like this:
+ *
+ * +----+
+ * | / |
+ * +----+
+ * |
+ * |
+ * |
+ * G1
+ * / \
+ * / \
+ * DS1 G2
+ * (dangled soft link to /G1/G20)
+ *
+ ****************************************************************/
+
+ /* Make external link file */
+ file_id = H5Fcreate(FILE_NAME4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Create a group named "G1" in the file.
+ */
+ if ((group = H5Gcreate2(file_id, "G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ /*
+ * Create a dataset named "G1/DS1" in the file.
+ */
+ if (H5LTmake_dataset_string(group, "/G1/DS1", data_string_in) < 0)
+ goto out;
+
+ /*
+ * Create a dangling soft link
+ */
+
+ if (H5Lcreate_soft("/G1/G2", file_id, "/G1/G20", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
+
+ if (H5Gclose(group) < 0)
+ goto out;
+
+ H5Fclose(file_id);
+
+ /* Open input file */
+ if ((file_id = H5Fopen(FILE_NAME3, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ goto out;
+
+ /**************************************
+ * CHECK ABSOLUTE PATHS
+ **************************************/
+
+ if ((path_valid = H5LTpath_valid(file_id, "/", TRUE)) != FALSE) {
+ goto out;
+ }
+
+ if ((path_valid = H5LTpath_valid(file_id, "/", FALSE)) != FALSE) {
+ goto out;
+ }
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1", TRUE)) != TRUE) {
+ goto out;
+ }
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/DS1", TRUE)) != TRUE)
+ goto out;
- /*****************************
- * Check external links
- *****************************/
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/DS3", TRUE)) != TRUE)
+ goto out;
- /* The dangled external link path is valid */
- if( (path_valid = H5LTpath_valid(file_id, "/DangledExternalLink", FALSE)) != TRUE)
- goto out;
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2", TRUE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G5", TRUE)) != TRUE)
+ goto out;
- /* The file however does not exists, so the link dangles -> should return false */
- if( (path_valid = H5LTpath_valid(file_id, "/DangledExternalLink", TRUE)) == TRUE)
- goto out;
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/DS1", FALSE)) != TRUE)
+ goto out;
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink", FALSE)) != TRUE)
- goto out;
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/DS1", TRUE)) != TRUE)
+ goto out;
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink", TRUE)) != TRUE)
- goto out;
+ if ((path_valid = H5LTpath_valid(file_id, "/G2", TRUE)) != TRUE)
+ goto out;
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/DS1", TRUE)) != TRUE)
- goto out;
+ /* check soft link points to a valid object*/
+ if ((path_valid = H5LTpath_valid(file_id, "/G2/DS4", TRUE)) != TRUE)
+ goto out;
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/G20", FALSE)) != TRUE)
- goto out;
+ /* check if path exist, but not the object */
+ if ((path_valid = H5LTpath_valid(file_id, "/G2/G7", FALSE)) != TRUE)
+ goto out;
+ /* check if path exist and if the object exists. It should fail
+ * since it is a dangling soft link
+ */
+ if ((path_valid = H5LTpath_valid(file_id, "/G2/G7", TRUE)) == TRUE)
+ goto out;
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/DS1", TRUE)) != TRUE)
- goto out;
+ /* check soft links */
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G5/DS4", TRUE)) != TRUE)
+ goto out;
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/G20", FALSE)) != TRUE)
- goto out;
+ /**************************************
+ * CHECK RELATIVE PATHS
+ ***************************************/
- /* Should fail, does not exist */
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/G20", TRUE)) == TRUE)
- goto out;
+ if ((group = H5Gopen2(file_id, "/", H5P_DEFAULT)) < 0)
+ goto out;
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/G20", TRUE)) == TRUE)
- goto out;
+ if ((path_valid = H5LTpath_valid(group, "/", TRUE)) != FALSE) {
+ goto out;
+ }
+ if ((path_valid = H5LTpath_valid(group, "/", FALSE)) != FALSE) {
+ goto out;
+ }
- if(H5Fclose(file_id)<0)
- goto out;
+ if (H5Gclose(group) < 0)
+ goto out;
- PASSED();
- return 0;
+ if ((group = H5Gopen2(file_id, "/G1", H5P_DEFAULT)) < 0)
+ goto out;
- out:
- H5_FAILED();
- return -1;
+ /* The identifier (file id) is the object itself, i.e. "." */
+
+ if ((path_valid = H5LTpath_valid(file_id, ".", FALSE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, ".", TRUE)) != TRUE)
+ goto out;
+
+ /* The identifier (group id) is the object itself, i.e. "." */
+
+ if ((path_valid = H5LTpath_valid(group, ".", TRUE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(group, "DS3", FALSE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(group, "DS3", TRUE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(group, "G2/G5", TRUE)) != TRUE)
+ goto out;
+
+ /* Check the "./" case */
+ if ((path_valid = H5LTpath_valid(group, "./DS3", TRUE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(group, "./G2/G5", TRUE)) != TRUE)
+ goto out;
+
+ /* Should fail, does not exist */
+ if ((path_valid = H5LTpath_valid(group, "./G2/G20", FALSE)) == TRUE)
+ goto out;
+
+ /* Should fail, does not exist */
+ if ((path_valid = H5LTpath_valid(group, "./G2/G20", TRUE)) == TRUE)
+ goto out;
+
+ if (H5Gclose(group) < 0)
+ goto out;
+
+ /*****************************
+ * Check external links
+ *****************************/
+
+ /* The dangled external link path is valid */
+ if ((path_valid = H5LTpath_valid(file_id, "/DangledExternalLink", FALSE)) != TRUE)
+ goto out;
+
+ /* The file however does not exists, so the link dangles -> should return false */
+ if ((path_valid = H5LTpath_valid(file_id, "/DangledExternalLink", TRUE)) == TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink", FALSE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink", TRUE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/DS1", TRUE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/G20", FALSE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/DS1", TRUE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/G20", FALSE)) != TRUE)
+ goto out;
+
+ /* Should fail, does not exist */
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/G20", TRUE)) == TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/G20", TRUE)) == TRUE)
+ goto out;
+
+ if (H5Fclose(file_id) < 0)
+ goto out;
+
+ PASSED();
+ return 0;
+
+out:
+ H5_FAILED();
+ return -1;
}
/*-------------------------------------------------------------------------
-* the main program
-*-------------------------------------------------------------------------
-*/
-int main( void )
+ * the main program
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
{
- int nerrors=0;
+ int nerrors = 0;
/* test dataset functions */
nerrors += test_dsets();
diff --git a/hl/test/test_packet.c b/hl/test/test_packet.c
index 7003b26..6ff70dc 100644
--- a/hl/test/test_packet.c
+++ b/hl/test/test_packet.c
@@ -6,7 +6,7 @@
* 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. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -23,41 +23,34 @@
*-------------------------------------------------------------------------
*/
-#define NRECORDS 8
-#define BIG_TABLE_SIZE 8000
-#define NFIELDS 5
-#define TEST_FILE_NAME "test_packet_table.h5"
+#define NRECORDS 8
+#define BIG_TABLE_SIZE 8000
+#define NFIELDS 5
+#define TEST_FILE_NAME "test_packet_table.h5"
#define TEST_COMPRESS_FILE "test_packet_compress.h5"
-#define PT_NAME "Test Packet Table"
-#define H5TB_TABLE_NAME "Table1"
+#define PT_NAME "Test Packet Table"
+#define H5TB_TABLE_NAME "Table1"
/*-------------------------------------------------------------------------
* structure used for some tests, a particle
*-------------------------------------------------------------------------
*/
-typedef struct particle_t
-{
- char name[16];
- int lati;
- int longi;
- float pressure;
- double temperature;
+typedef struct particle_t {
+ char name[16];
+ int lati;
+ int longi;
+ float pressure;
+ double temperature;
} particle_t;
/*-------------------------------------------------------------------------
* a static array of particles for writing and checking reads
*-------------------------------------------------------------------------
*/
-static particle_t testPart[NRECORDS] = {
- {"zero", 0,0, 0.0f, 0.0f},
- {"one", 10,10, 1.0f, 10.0f},
- {"two", 20,20, 2.0f, 20.0f},
- {"three",30,30, 3.0f, 30.0f},
- {"four", 40,40, 4.0f, 40.0f},
- {"five", 50,50, 5.0f, 50.0f},
- {"six", 60,60, 6.0f, 60.0f},
- {"seven",70,70, 7.0f, 70.0f}
- };
+static particle_t testPart[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0f}, {"one", 10, 10, 1.0f, 10.0f},
+ {"two", 20, 20, 2.0f, 20.0f}, {"three", 30, 30, 3.0f, 30.0f},
+ {"four", 40, 40, 4.0f, 40.0f}, {"five", 50, 50, 5.0f, 50.0f},
+ {"six", 60, 60, 6.0f, 60.0f}, {"seven", 70, 70, 7.0f, 70.0f}};
/*-------------------------------------------------------------------------
* function that compares one particle
@@ -65,16 +58,15 @@ static particle_t testPart[NRECORDS] = {
* fields verbatim and not lose any bits. -JML
*-------------------------------------------------------------------------
*/
-static int cmp_par(size_t i, size_t j, particle_t *rbuf, particle_t *wbuf )
+static int
+cmp_par(size_t i, size_t j, particle_t *rbuf, particle_t *wbuf)
{
- if ( ( HDstrcmp( rbuf[i].name, wbuf[j].name ) != 0 ) ||
- rbuf[i].lati != wbuf[j].lati ||
- rbuf[i].longi != wbuf[j].longi ||
- !H5_FLT_ABS_EQUAL(rbuf[i].pressure,wbuf[j].pressure) ||
- !H5_DBL_ABS_EQUAL(rbuf[i].temperature,wbuf[j].temperature) ) {
- return FAIL;
- }
- return SUCCEED;
+ if ((HDstrcmp(rbuf[i].name, wbuf[j].name) != 0) || rbuf[i].lati != wbuf[j].lati ||
+ rbuf[i].longi != wbuf[j].longi || !H5_FLT_ABS_EQUAL(rbuf[i].pressure, wbuf[j].pressure) ||
+ !H5_DBL_ABS_EQUAL(rbuf[i].temperature, wbuf[j].temperature)) {
+ return FAIL;
+ }
+ return SUCCEED;
}
/*-------------------------------------------------------------------------
@@ -84,53 +76,51 @@ static int cmp_par(size_t i, size_t j, particle_t *rbuf, particle_t *wbuf )
static hid_t
make_particle_type(void)
{
- hid_t type_id;
- hid_t string_type;
- size_t type_size = sizeof(particle_t);
-
- /* Create the memory data type. */
- if ((type_id = H5Tcreate (H5T_COMPOUND, type_size )) < 0 )
- return FAIL;
-
- /* Insert fields. */
- if ((string_type = H5Tcopy(H5T_C_S1)) < 0)
- return FAIL;
- if (H5Tset_size(string_type, (size_t)16) < 0)
- return FAIL;
-
- if ( H5Tinsert(type_id, "Name", HOFFSET(particle_t, name) , string_type ) < 0 )
- return FAIL;
- if ( H5Tinsert(type_id, "Lat", HOFFSET(particle_t, lati) , H5T_NATIVE_INT ) < 0 )
- return FAIL;
- if ( H5Tinsert(type_id, "Long", HOFFSET(particle_t, longi) , H5T_NATIVE_INT ) < 0 )
- return FAIL;
- if ( H5Tinsert(type_id, "Pressure", HOFFSET(particle_t, pressure) , H5T_NATIVE_FLOAT ) < 0 )
- return FAIL;
- if ( H5Tinsert(type_id, "Temperature", HOFFSET(particle_t, temperature) , H5T_NATIVE_DOUBLE ) < 0 )
- return FAIL;
-
- return type_id;
+ hid_t type_id;
+ hid_t string_type;
+ size_t type_size = sizeof(particle_t);
+
+ /* Create the memory data type. */
+ if ((type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0)
+ return FAIL;
+
+ /* Insert fields. */
+ if ((string_type = H5Tcopy(H5T_C_S1)) < 0)
+ return FAIL;
+ if (H5Tset_size(string_type, (size_t)16) < 0)
+ return FAIL;
+
+ if (H5Tinsert(type_id, "Name", HOFFSET(particle_t, name), string_type) < 0)
+ return FAIL;
+ if (H5Tinsert(type_id, "Lat", HOFFSET(particle_t, lati), H5T_NATIVE_INT) < 0)
+ return FAIL;
+ if (H5Tinsert(type_id, "Long", HOFFSET(particle_t, longi), H5T_NATIVE_INT) < 0)
+ return FAIL;
+ if (H5Tinsert(type_id, "Pressure", HOFFSET(particle_t, pressure), H5T_NATIVE_FLOAT) < 0)
+ return FAIL;
+ if (H5Tinsert(type_id, "Temperature", HOFFSET(particle_t, temperature), H5T_NATIVE_DOUBLE) < 0)
+ return FAIL;
+
+ return type_id;
}
- /* Create a normal HL table just like the HL examples do */
-static int create_hl_table(hid_t fid)
+/* Create a normal HL table just like the HL examples do */
+static int
+create_hl_table(hid_t fid)
{
- /* Calculate the offsets of the particle struct members in memory */
- size_t part_offset[NFIELDS] = { HOFFSET( particle_t, name ),
- HOFFSET( particle_t, lati ),
- HOFFSET( particle_t, longi ),
- HOFFSET( particle_t, pressure ),
- HOFFSET( particle_t, temperature )};
+ /* Calculate the offsets of the particle struct members in memory */
+ size_t part_offset[NFIELDS] = {HOFFSET(particle_t, name), HOFFSET(particle_t, lati),
+ HOFFSET(particle_t, longi), HOFFSET(particle_t, pressure),
+ HOFFSET(particle_t, temperature)};
/* Define field information */
- const char *field_names[NFIELDS] =
- { "Name","Latitude", "Longitude", "Pressure", "Temperature" };
- hid_t field_type[NFIELDS];
- hid_t string_type;
- hsize_t chunk_size = 10;
- int *fill_data = NULL;
- int compress = 0;
- herr_t status;
+ const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
+ hid_t field_type[NFIELDS];
+ hid_t string_type;
+ hsize_t chunk_size = 10;
+ int * fill_data = NULL;
+ int compress = 0;
+ herr_t status;
/* Initialize the field field_type */
if ((string_type = H5Tcopy(H5T_C_S1)) < 0)
@@ -143,27 +133,24 @@ static int create_hl_table(hid_t fid)
field_type[3] = H5T_NATIVE_FLOAT;
field_type[4] = H5T_NATIVE_DOUBLE;
+ /*------------------------------------------------------------------------
+ * H5TBmake_table
+ *-------------------------------------------------------------------------
+ */
- /*------------------------------------------------------------------------
- * H5TBmake_table
- *-------------------------------------------------------------------------
- */
-
- status=H5TBmake_table( "Table Title", fid, H5TB_TABLE_NAME, (hsize_t)NFIELDS,
- (hsize_t)NRECORDS, sizeof(particle_t),
- field_names, part_offset, field_type,
- chunk_size, fill_data, compress, testPart );
+ status = H5TBmake_table("Table Title", fid, H5TB_TABLE_NAME, (hsize_t)NFIELDS, (hsize_t)NRECORDS,
+ sizeof(particle_t), field_names, part_offset, field_type, chunk_size, fill_data,
+ compress, testPart);
- if (H5Tclose(string_type) < 0)
- return FAIL;
+ if (H5Tclose(string_type) < 0)
+ return FAIL;
- if(status<0)
- return FAIL;
- else
- return SUCCEED;
+ if (status < 0)
+ return FAIL;
+ else
+ return SUCCEED;
}
-
/*-------------------------------------------------------------------------
* test_create_close
*
@@ -172,13 +159,14 @@ static int create_hl_table(hid_t fid)
*-------------------------------------------------------------------------
*/
-static int test_create_close(hid_t fid)
+static int
+test_create_close(hid_t fid)
{
herr_t err;
- hid_t table;
- hid_t part_t;
+ hid_t table;
+ hid_t part_t;
- TESTING("H5PTcreate_fl and H5PTclose");
+ HL_TESTING2("H5PTcreate_fl and H5PTclose");
/* Create a datatype for the particle struct */
part_t = make_particle_type();
@@ -188,23 +176,23 @@ static int test_create_close(hid_t fid)
/* Create the table */
table = H5PTcreate_fl(fid, PT_NAME, part_t, (hsize_t)100, -1);
if (H5Tclose(part_t) < 0)
- goto error;
- if( H5PTis_valid(table) < 0)
- goto error;
- if( H5PTis_varlen(table) != 0)
- goto error;
+ goto error;
+ if (H5PTis_valid(table) < 0)
+ goto error;
+ if (H5PTis_varlen(table) != 0)
+ goto error;
/* Close the table */
err = H5PTclose(table);
- if( err < 0)
+ if (err < 0)
goto error;
PASSED();
return SUCCEED;
error:
- H5_FAILED();
- return FAIL;
+ H5_FAILED();
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -214,32 +202,34 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_open(hid_t fid)
+static int
+test_open(hid_t fid)
{
herr_t err;
- hid_t table;
+ hid_t table;
- TESTING("H5PTopen");
+ HL_TESTING2("H5PTopen");
/* Open the table */
table = H5PTopen(fid, PT_NAME);
- if( H5PTis_valid(table) < 0)
+ if (H5PTis_valid(table) < 0)
goto error;
- if( H5PTis_varlen(table) != 0)
+ if (H5PTis_varlen(table) != 0)
goto error;
/* Close the table */
err = H5PTclose(table);
- if( err < 0)
+ if (err < 0)
goto error;
PASSED();
return SUCCEED;
error:
- if (table > 0) H5PTclose(table);
- H5_FAILED();
- return FAIL;
+ if (table > 0)
+ H5PTclose(table);
+ H5_FAILED();
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -249,63 +239,64 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_append(hid_t fid)
+static int
+test_append(hid_t fid)
{
- herr_t err;
- hid_t table;
+ herr_t err;
+ hid_t table;
hsize_t count = 0;
- TESTING("H5PTappend");
+ HL_TESTING2("H5PTappend");
/* Open the table */
table = H5PTopen(fid, PT_NAME);
- if( H5PTis_valid(table) < 0)
+ if (H5PTis_valid(table) < 0)
goto error;
/* Count the number of packets in the table */
err = H5PTget_num_packets(table, &count);
- if( err < 0)
+ if (err < 0)
goto error;
/* There should be 0 records in the table */
- if( count != 0 )
+ if (count != 0)
goto error;
/* Append one particle */
err = H5PTappend(table, (size_t)1, &(testPart[0]));
- if( err < 0)
+ if (err < 0)
goto error;
/* Append several particles */
err = H5PTappend(table, (size_t)6, &(testPart[1]));
- if( err < 0)
+ if (err < 0)
goto error;
/* Append one more particle */
err = H5PTappend(table, (size_t)1, &(testPart[7]));
- if( err < 0)
+ if (err < 0)
goto error;
/* Count the number of packets in the table */
err = H5PTget_num_packets(table, &count);
- if( err < 0)
+ if (err < 0)
goto error;
/* There should be 8 records in the table now */
- if( count != 8 )
+ if (count != 8)
goto error;
/* Close the table */
err = H5PTclose(table);
- if( err < 0)
+ if (err < 0)
goto error;
PASSED();
return SUCCEED;
error:
- H5_FAILED();
- if( H5PTis_valid(table) > 0)
- H5PTclose(table);
- return FAIL;
+ H5_FAILED();
+ if (H5PTis_valid(table) > 0)
+ H5PTclose(table);
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -315,45 +306,45 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_read(hid_t fid)
+static int
+test_read(hid_t fid)
{
- herr_t err;
- hid_t table;
+ herr_t err;
+ hid_t table;
particle_t readBuf[NRECORDS];
- size_t c;
+ size_t c;
- TESTING("H5PTread_packets");
+ HL_TESTING2("H5PTread_packets");
/* Open the table */
table = H5PTopen(fid, PT_NAME);
- if( H5PTis_valid(table) < 0)
+ if (H5PTis_valid(table) < 0)
goto error;
/* Read several particles */
err = H5PTread_packets(table, (hsize_t)0, 3, &(readBuf[0]));
- if( err < 0)
+ if (err < 0)
goto error;
/* Read one particle */
err = H5PTread_packets(table, (hsize_t)3, 1, &(readBuf[3]));
- if( err < 0)
+ if (err < 0)
goto error;
/* Read several particles */
- err = H5PTread_packets(table, (hsize_t)4, (NRECORDS - 4 ), &(readBuf[4]));
- if( err < 0)
+ err = H5PTread_packets(table, (hsize_t)4, (NRECORDS - 4), &(readBuf[4]));
+ if (err < 0)
goto error;
/* Ensure that particles were read correctly */
- for(c=0; c<NRECORDS; c++)
- {
- if( cmp_par(c%8, c, testPart, readBuf) != 0)
+ for (c = 0; c < NRECORDS; c++) {
+ if (cmp_par(c % 8, c, testPart, readBuf) != 0)
goto error;
}
/* Close the table */
err = H5PTclose(table);
- if( err < 0)
+ if (err < 0)
goto error;
PASSED();
@@ -361,10 +352,10 @@ static int test_read(hid_t fid)
return SUCCEED;
error:
- H5_FAILED();
- if( H5PTis_valid(table) > 0)
- H5PTclose(table);
- return FAIL;
+ H5_FAILED();
+ if (H5PTis_valid(table) > 0)
+ H5PTclose(table);
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -375,66 +366,63 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_get_next(hid_t fid)
+static int
+test_get_next(hid_t fid)
{
- herr_t err;
- hid_t table;
+ herr_t err;
+ hid_t table;
particle_t readBuf[NRECORDS];
particle_t readBuf2[NRECORDS];
- size_t c;
+ size_t c;
- TESTING("H5PTget_next");
+ HL_TESTING2("H5PTget_next");
/* Open the table */
table = H5PTopen(fid, PT_NAME);
- if( H5PTis_valid(table) < 0)
+ if (H5PTis_valid(table) < 0)
goto error;
/* Read several particles consecutively */
- for(c=0; c < NRECORDS; c++)
- {
+ for (c = 0; c < NRECORDS; c++) {
err = H5PTget_next(table, (size_t)1, &readBuf[c]);
- if(err < 0)
+ if (err < 0)
goto error;
}
/* Ensure that particles were read correctly */
- for(c=0; c<NRECORDS; c++)
- {
- if( cmp_par(c, c, testPart, readBuf) != 0)
+ for (c = 0; c < NRECORDS; c++) {
+ if (cmp_par(c, c, testPart, readBuf) != 0)
goto error;
}
H5PTcreate_index(table);
/* Read particles two by two */
- for(c=0; c < NRECORDS / 2; c++)
- {
+ for (c = 0; c < NRECORDS / 2; c++) {
err = H5PTget_next(table, (size_t)2, &readBuf2[c * 2]);
- if(err < 0)
+ if (err < 0)
goto error;
}
/* Ensure that particles were read correctly */
- for(c=0; c<NRECORDS; c++)
- {
- if( cmp_par(c, c, testPart, readBuf2) != 0)
+ for (c = 0; c < NRECORDS; c++) {
+ if (cmp_par(c, c, testPart, readBuf2) != 0)
goto error;
}
/* Close the table */
err = H5PTclose(table);
- if( err < 0)
+ if (err < 0)
goto error;
PASSED();
return SUCCEED;
error:
- H5_FAILED();
- if( H5PTis_valid(table) > 0)
- H5PTclose(table);
- return FAIL;
+ H5_FAILED();
+ if (H5PTis_valid(table) > 0)
+ H5PTclose(table);
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -445,16 +433,17 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_big_table(hid_t fid)
+static int
+test_big_table(hid_t fid)
{
- herr_t err;
- hid_t table;
- hid_t part_t;
- size_t c;
+ herr_t err;
+ hid_t table;
+ hid_t part_t;
+ size_t c;
particle_t readPart;
- hsize_t count;
+ hsize_t count;
- TESTING("large packet table");
+ HL_TESTING2("large packet table");
/* Create a datatype for the particle struct */
part_t = make_particle_type();
@@ -465,52 +454,50 @@ static int test_big_table(hid_t fid)
table = H5PTcreate_fl(fid, "Packet Test Dataset2", part_t, (hsize_t)33, -1);
if (H5Tclose(part_t) < 0)
goto error;
- if( H5PTis_valid(table) < 0)
+ if (H5PTis_valid(table) < 0)
goto error;
- /* Add many particles */
- for(c = 0; c < BIG_TABLE_SIZE ; c+=8)
- {
+ /* Add many particles */
+ for (c = 0; c < BIG_TABLE_SIZE; c += 8) {
/* Append eight particles at once*/
err = H5PTappend(table, (size_t)8, &(testPart[0]));
- if( err < 0)
+ if (err < 0)
goto error;
}
/* Count the number of packets in the table */
err = H5PTget_num_packets(table, &count);
- if( err < 0)
+ if (err < 0)
goto error;
- if( count != BIG_TABLE_SIZE )
+ if (count != BIG_TABLE_SIZE)
goto error;
/* Read particles to ensure that all of them were written correctly */
/* Also, ensure that H5PTcreate_fl set the current packet to */
/* the first packet in the table */
- for(c = 0; c < BIG_TABLE_SIZE; c++)
- {
+ for (c = 0; c < BIG_TABLE_SIZE; c++) {
err = H5PTget_next(table, (size_t)1, &readPart);
- if(err < 0)
+ if (err < 0)
goto error;
/* Ensure that particles were read correctly */
- if( cmp_par(c % 8, 0, testPart, &readPart) != 0)
+ if (cmp_par(c % 8, 0, testPart, &readPart) != 0)
goto error;
}
/* Close the table */
err = H5PTclose(table);
- if( err < 0)
+ if (err < 0)
goto error;
PASSED();
return SUCCEED;
error:
- H5_FAILED();
- if( H5PTis_valid(table) > 0)
- H5PTclose(table);
- return FAIL;
+ H5_FAILED();
+ if (H5PTis_valid(table) > 0)
+ H5PTclose(table);
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -520,63 +507,63 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_opaque(hid_t fid)
+static int
+test_opaque(hid_t fid)
{
- herr_t err;
- hid_t table;
- hid_t part_t;
- size_t c;
+ herr_t err;
+ hid_t table;
+ hid_t part_t;
+ size_t c;
particle_t readBuf[NRECORDS];
- TESTING("opaque data");
+ HL_TESTING2("opaque data");
/* Create an opaque datatype for the particle struct */
- if ((part_t = H5Tcreate (H5T_OPAQUE, sizeof(particle_t) )) < 0 )
+ if ((part_t = H5Tcreate(H5T_OPAQUE, sizeof(particle_t))) < 0)
return FAIL;
HDassert(part_t != -1);
/* Tag the opaque datatype */
- if ( H5Tset_tag(part_t, "Opaque Particle" ) < 0)
+ if (H5Tset_tag(part_t, "Opaque Particle") < 0)
return FAIL;
/* Create a new table */
table = H5PTcreate_fl(fid, "Packet Test Dataset3", part_t, (hsize_t)100, -1);
- if( H5Tclose(part_t) < 0)
+ if (H5Tclose(part_t) < 0)
goto error;
- if( H5PTis_valid(table) < 0)
+ if (H5PTis_valid(table) < 0)
goto error;
/* Append several particles, starting at particle 1 */
err = H5PTappend(table, (size_t)(NRECORDS - 1), &(testPart[1]));
- if( err < 0)
+ if (err < 0)
goto error;
/* Read the particles back */
err = H5PTread_packets(table, (hsize_t)0, 7, &(readBuf[0]));
- if( err < 0)
+ if (err < 0)
goto error;
/* Ensure that particles were read correctly */
- for(c=0; c<NRECORDS - 1; c++)
- {
- if( cmp_par(c+1, c, testPart, readBuf) != 0)
+ for (c = 0; c < NRECORDS - 1; c++) {
+ if (cmp_par(c + 1, c, testPart, readBuf) != 0)
goto error;
}
/* Close the table */
err = H5PTclose(table);
- if( err < 0)
+ if (err < 0)
goto error;
PASSED();
return SUCCEED;
error:
- H5_FAILED();
- if( H5PTis_valid(table) > 0)
- H5PTclose(table);
- return FAIL;
+ H5_FAILED();
+ if (H5PTis_valid(table) > 0)
+ H5PTclose(table);
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -590,22 +577,23 @@ error:
static int
test_compress(void)
{
- hid_t fid1 = H5I_INVALID_HID;
- herr_t err;
- hid_t table = H5I_INVALID_HID;
- hid_t part_t = H5I_INVALID_HID;
- hid_t dset_id = H5I_INVALID_HID;
- hid_t plist_id = H5I_INVALID_HID;
- size_t c;
- size_t num_elems = 1;
- unsigned filter_vals[1];
+ hid_t fid1 = H5I_INVALID_HID;
+ herr_t err;
+ hid_t table = H5I_INVALID_HID;
+ hid_t part_t = H5I_INVALID_HID;
+ hid_t dset_id = H5I_INVALID_HID;
+ hid_t plist_id = H5I_INVALID_HID;
+ size_t c;
+ size_t num_elems = 1;
+ unsigned filter_vals[1];
particle_t readPart[1];
- hsize_t count;
+ hsize_t count;
- TESTING("packet table compression");
+ HL_TESTING2("packet table compression");
/* Create a file. */
- if((fid1 = H5Fcreate(TEST_COMPRESS_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ if ((fid1 = H5Fcreate(TEST_COMPRESS_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create a datatype for the particle struct */
part_t = make_particle_type();
@@ -614,106 +602,129 @@ test_compress(void)
/* Create a new table with compression level 8 */
table = H5PTcreate_fl(fid1, "Compressed Test Dataset", part_t, (hsize_t)80, 8);
- if( H5PTis_valid(table) < 0) TEST_ERROR;
+ if (H5PTis_valid(table) < 0)
+ TEST_ERROR;
/* We can now use this table exactly the same way we use a normal uncompressed
* packet table, and it should pass the same tests. */
- /* Add many particles */
- for(c = 0; c < BIG_TABLE_SIZE ; c+=8)
- {
+ /* Add many particles */
+ for (c = 0; c < BIG_TABLE_SIZE; c += 8) {
/* Append eight particles at once*/
err = H5PTappend(table, (size_t)8, &(testPart[0]));
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
}
/* Count the number of packets in the table */
err = H5PTget_num_packets(table, &count);
- if( err < 0) TEST_ERROR;
- if( count != BIG_TABLE_SIZE ) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
+ if (count != BIG_TABLE_SIZE)
+ TEST_ERROR;
/* Read particles to ensure that all of them were written correctly */
HDmemset(readPart, 0, sizeof(readPart));
- for(c = 0; c < BIG_TABLE_SIZE; c++)
- {
+ for (c = 0; c < BIG_TABLE_SIZE; c++) {
err = H5PTget_next(table, (size_t)1, readPart);
- if(err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
/* Ensure that particles were read correctly */
- if( cmp_par(c % 8, 0, testPart, readPart) != 0) TEST_ERROR;
+ if (cmp_par(c % 8, 0, testPart, readPart) != 0)
+ TEST_ERROR;
}
/* Close the table */
err = H5PTclose(table);
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
/* Open the packet table as a regular dataset and make sure that the
* compression filter is set.
*/
dset_id = H5Dopen2(fid1, "Compressed Test Dataset", H5P_DEFAULT);
- if( dset_id < 0) TEST_ERROR;
+ if (dset_id < 0)
+ TEST_ERROR;
plist_id = H5Dget_create_plist(dset_id);
- if( plist_id < 0) TEST_ERROR;
+ if (plist_id < 0)
+ TEST_ERROR;
- err = H5Pget_filter_by_id2(plist_id, H5Z_FILTER_DEFLATE, NULL, &num_elems,
- filter_vals, 0, NULL, NULL);
- if( err < 0) TEST_ERROR;
+ err = H5Pget_filter_by_id2(plist_id, H5Z_FILTER_DEFLATE, NULL, &num_elems, filter_vals, 0, NULL, NULL);
+ if (err < 0)
+ TEST_ERROR;
/* The compression level should be 8, the value we passed in */
- if(filter_vals[0] != 8) TEST_ERROR;
+ if (filter_vals[0] != 8)
+ TEST_ERROR;
/* Clean up */
err = H5Pclose(plist_id);
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
err = H5Dclose(dset_id);
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
/* Create a new table without compression. */
table = H5PTcreate_fl(fid1, "Uncompressed Dataset", part_t, (hsize_t)80, -1);
- if(table < 0) TEST_ERROR;
+ if (table < 0)
+ TEST_ERROR;
/* Close the packet table */
err = H5PTclose(table);
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
/* Open the packet table as a regular dataset and make sure that the
* compression filter is not set.
*/
dset_id = H5Dopen2(fid1, "Uncompressed Dataset", H5P_DEFAULT);
- if( dset_id < 0) TEST_ERROR;
+ if (dset_id < 0)
+ TEST_ERROR;
plist_id = H5Dget_create_plist(dset_id);
- if( plist_id < 0) TEST_ERROR;
+ if (plist_id < 0)
+ TEST_ERROR;
- H5E_BEGIN_TRY {
- err = H5Pget_filter_by_id2(plist_id, H5Z_FILTER_DEFLATE, NULL, &num_elems,
- filter_vals, 0, NULL, NULL);
- if( err >= 0) TEST_ERROR;
- } H5E_END_TRY
+ H5E_BEGIN_TRY
+ {
+ err =
+ H5Pget_filter_by_id2(plist_id, H5Z_FILTER_DEFLATE, NULL, &num_elems, filter_vals, 0, NULL, NULL);
+ if (err >= 0)
+ TEST_ERROR;
+ }
+ H5E_END_TRY
/* Clean up */
err = H5Pclose(plist_id);
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
err = H5Dclose(dset_id);
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
/* Close the datatype and the file */
err = H5Tclose(part_t);
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
err = H5Fclose(fid1);
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
PASSED();
return SUCCEED;
error:
- H5E_BEGIN_TRY {
- H5Pclose(plist_id);
- H5Dclose(dset_id);
- H5Tclose(part_t);
- H5PTclose(table);
- H5Fclose(fid1);
- } H5E_END_TRY
+ H5E_BEGIN_TRY
+ {
+ H5Pclose(plist_id);
+ H5Dclose(dset_id);
+ H5Tclose(part_t);
+ H5PTclose(table);
+ H5Fclose(fid1);
+ }
+ H5E_END_TRY
H5_FAILED();
return FAIL;
}
@@ -726,83 +737,85 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_rw_nonnative_dt(hid_t fid)
+static int
+test_rw_nonnative_dt(hid_t fid)
{
- hid_t ptable; /* Packet table identifier */
+ hid_t ptable; /* Packet table identifier */
- herr_t err; /* Function return status */
- hsize_t count; /* Number of records in the table */
+ herr_t err; /* Function return status */
+ hsize_t count; /* Number of records in the table */
- int x; /* Loop variable */
+ int x; /* Loop variable */
- /* Buffers to hold data */
- int writeBuffer[5];
- int readBuffer[5];
+ /* Buffers to hold data */
+ int writeBuffer[5];
+ int readBuffer[5];
- TESTING("reading/writing non-native packet table");
+ HL_TESTING2("reading/writing non-native packet table");
- /* Initialize buffers */
- for(x=0; x<5; x++) {
- writeBuffer[x]=x;
- readBuffer[x] = -1;
- }
+ /* Initialize buffers */
+ for (x = 0; x < 5; x++) {
+ writeBuffer[x] = x;
+ readBuffer[x] = -1;
+ }
- /* Create a fixed-length packet table within the file */
- /* This table's "packets" will be simple integers and it will use no compression */
- if(H5Tget_order(H5T_NATIVE_INT) == H5T_ORDER_LE) {
- ptable = H5PTcreate(fid, "Packet Test Dataset, Non-native", H5T_STD_I32BE, (hsize_t)100, H5P_DEFAULT);
- } else {
- ptable = H5PTcreate(fid, "Packet Test Dataset, Non-native", H5T_STD_I32LE, (hsize_t)100, H5P_DEFAULT);
- }
- if(ptable == H5I_INVALID_HID)
+ /* Create a fixed-length packet table within the file */
+ /* This table's "packets" will be simple integers and it will use no compression */
+ if (H5Tget_order(H5T_NATIVE_INT) == H5T_ORDER_LE) {
+ ptable = H5PTcreate(fid, "Packet Test Dataset, Non-native", H5T_STD_I32BE, (hsize_t)100, H5P_DEFAULT);
+ }
+ else {
+ ptable = H5PTcreate(fid, "Packet Test Dataset, Non-native", H5T_STD_I32LE, (hsize_t)100, H5P_DEFAULT);
+ }
+ if (ptable == H5I_INVALID_HID)
goto error;
- /* Write one packet to the packet table */
- if( (err = H5PTappend(ptable, (size_t)1, &(writeBuffer[0]))) < 0 )
+ /* Write one packet to the packet table */
+ if ((err = H5PTappend(ptable, (size_t)1, &(writeBuffer[0]))) < 0)
goto error;
- /* Write several packets to the packet table */
- if( (err = H5PTappend(ptable, (size_t)4, &(writeBuffer[1]))) < 0)
+ /* Write several packets to the packet table */
+ if ((err = H5PTappend(ptable, (size_t)4, &(writeBuffer[1]))) < 0)
goto error;
- if( (err = H5PTclose(ptable)) < 0)
+ if ((err = H5PTclose(ptable)) < 0)
goto error;
- /* Open the Packet table */
- if( (ptable = H5PTopen(fid, "Packet Test Dataset, Non-native")) < 0)
+ /* Open the Packet table */
+ if ((ptable = H5PTopen(fid, "Packet Test Dataset, Non-native")) < 0)
goto error;
- /* Get the number of packets in the packet table. This should be five. */
- if( (err = H5PTget_num_packets(ptable, &count)) < 0)
+ /* Get the number of packets in the packet table. This should be five. */
+ if ((err = H5PTget_num_packets(ptable, &count)) < 0)
goto error;
- if( (int)count != 5 )
+ if ((int)count != 5)
goto error;
- /* Initialize packet table's "current record" */
- if( (err = H5PTcreate_index(ptable)) < 0)
+ /* Initialize packet table's "current record" */
+ if ((err = H5PTcreate_index(ptable)) < 0)
goto error;
- /* Iterate through packets, read each one back */
- for(x=0; x<5; x++) {
- if( (err = H5PTget_next(ptable, (size_t)1, &(readBuffer[x]))) < 0)
- goto error;
- if( x != readBuffer[x])
- goto error;
- }
+ /* Iterate through packets, read each one back */
+ for (x = 0; x < 5; x++) {
+ if ((err = H5PTget_next(ptable, (size_t)1, &(readBuffer[x]))) < 0)
+ goto error;
+ if (x != readBuffer[x])
+ goto error;
+ }
- /* Close the packet table */
- if( (err = H5PTclose(ptable)) < 0)
+ /* Close the packet table */
+ if ((err = H5PTclose(ptable)) < 0)
goto error;
-
- PASSED();
- return SUCCEED;
+
+ PASSED();
+ return SUCCEED;
error:
- H5_FAILED();
- if( H5PTis_valid(ptable) > 0)
- H5PTclose(ptable);
- return FAIL;
+ H5_FAILED();
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -813,109 +826,110 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_error(hid_t fid)
+static int
+test_error(hid_t fid)
{
- hid_t id = H5I_INVALID_HID;
- int id_open=0;
- particle_t readBuf[1];
+ hid_t id = H5I_INVALID_HID;
+ int id_open = 0;
+ particle_t readBuf[1];
- TESTING("error conditions");
+ HL_TESTING2("error conditions");
- /* Create a HL table */
- if(create_hl_table(fid) < 0)
+ /* Create a HL table */
+ if (create_hl_table(fid) < 0)
goto error;
- /* Try to open things that are not packet tables */
- H5E_BEGIN_TRY
- if(H5PTopen(fid, "Bogus_name") >= 0)
+ /* Try to open things that are not packet tables */
+ H5E_BEGIN_TRY
+ if (H5PTopen(fid, "Bogus_name") >= 0)
goto error;
- if(H5PTopen(fid, "group1") >= 0)
+ if (H5PTopen(fid, "group1") >= 0)
goto error;
- H5E_END_TRY
+ H5E_END_TRY
- /* Try to execute packet table commands on an invalid ID */
- H5E_BEGIN_TRY
- if(H5PTis_valid(id) >= 0)
+ /* Try to execute packet table commands on an invalid ID */
+ H5E_BEGIN_TRY
+ if (H5PTis_valid(id) >= 0)
goto error;
- if(H5PTis_varlen(id) >= 0)
+ if (H5PTis_varlen(id) >= 0)
goto error;
- if(H5PTclose(id) >= 0)
+ if (H5PTclose(id) >= 0)
goto error;
- if(H5PTappend(id, (size_t)1, testPart) >= 0)
+ if (H5PTappend(id, (size_t)1, testPart) >= 0)
goto error;
- if(H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0)
+ if (H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0)
goto error;
- if(H5PTcreate_index(id) >= 0)
+ if (H5PTcreate_index(id) >= 0)
goto error;
- if(H5PTset_index(id, (hsize_t)1) >= 0)
+ if (H5PTset_index(id, (hsize_t)1) >= 0)
goto error;
- if(H5PTget_index(id, NULL) >= 0)
+ if (H5PTget_index(id, NULL) >= 0)
goto error;
- H5E_END_TRY
+ H5E_END_TRY
- /* Open a high-level non-packet (H5TB) table and try to */
- /* execute commands on it. */
- if((id=H5Dopen2(fid, H5TB_TABLE_NAME, H5P_DEFAULT)) <0)
+ /* Open a high-level non-packet (H5TB) table and try to */
+ /* execute commands on it. */
+ if ((id = H5Dopen2(fid, H5TB_TABLE_NAME, H5P_DEFAULT)) < 0)
goto error;
- id_open = 1;
+ id_open = 1;
- H5E_BEGIN_TRY
- if(H5PTis_valid(id) >= 0)
+ H5E_BEGIN_TRY
+ if (H5PTis_valid(id) >= 0)
goto error;
- if(H5PTis_varlen(id) >= 0)
+ if (H5PTis_varlen(id) >= 0)
goto error;
- if(H5PTclose(id) >= 0)
+ if (H5PTclose(id) >= 0)
goto error;
- if(H5PTappend(id, (size_t)1, testPart) >= 0)
+ if (H5PTappend(id, (size_t)1, testPart) >= 0)
goto error;
- if(H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0)
+ if (H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0)
goto error;
- if(H5PTcreate_index(id) >= 0)
+ if (H5PTcreate_index(id) >= 0)
goto error;
- if(H5PTset_index(id, (hsize_t)1) >= 0)
+ if (H5PTset_index(id, (hsize_t)1) >= 0)
goto error;
- if(H5PTget_index(id, NULL) >= 0)
+ if (H5PTget_index(id, NULL) >= 0)
goto error;
- H5E_END_TRY
+ H5E_END_TRY
- id_open=0;
- if(H5Dclose(id) <0)
+ id_open = 0;
+ if (H5Dclose(id) < 0)
goto error;
- /* Open and close a packet table. Try to execute */
- /* commands on the closed ID. */
- if((id=H5PTopen(fid, PT_NAME))<0)
+ /* Open and close a packet table. Try to execute */
+ /* commands on the closed ID. */
+ if ((id = H5PTopen(fid, PT_NAME)) < 0)
goto error;
- if(H5PTclose(id) <0)
+ if (H5PTclose(id) < 0)
goto error;
- H5E_BEGIN_TRY
- if(H5PTis_valid(id) >= 0)
+ H5E_BEGIN_TRY
+ if (H5PTis_valid(id) >= 0)
goto error;
- if(H5PTis_varlen(id) >= 0)
+ if (H5PTis_varlen(id) >= 0)
goto error;
- if(H5PTclose(id) >= 0)
+ if (H5PTclose(id) >= 0)
goto error;
- if(H5PTappend(id, (size_t)1, testPart) >= 0)
+ if (H5PTappend(id, (size_t)1, testPart) >= 0)
goto error;
- if(H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0)
+ if (H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0)
goto error;
- if(H5PTcreate_index(id) >= 0)
+ if (H5PTcreate_index(id) >= 0)
goto error;
- if(H5PTset_index(id, (hsize_t)1) >= 0)
+ if (H5PTset_index(id, (hsize_t)1) >= 0)
goto error;
- if(H5PTget_index(id, NULL) >= 0)
+ if (H5PTget_index(id, NULL) >= 0)
goto error;
- H5E_END_TRY
+ H5E_END_TRY
- PASSED();
- return SUCCEED;
+ PASSED();
+ return SUCCEED;
error:
- H5_FAILED();
- if(id_open)
- H5Dclose(id);
- return FAIL;
+ H5_FAILED();
+ if (id_open)
+ H5Dclose(id);
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -925,18 +939,19 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_packet_table(hid_t fid)
+static int
+test_packet_table(hid_t fid)
{
- if( test_create_close(fid) < 0 )
+ if (test_create_close(fid) < 0)
return FAIL;
- if( test_open(fid) < 0 )
+ if (test_open(fid) < 0)
return FAIL;
/* test_append must be run before test_count and test_read, as it */
/* creates the packet table they use. */
- if( test_append(fid) < 0 )
+ if (test_append(fid) < 0)
return FAIL;
/* These tests will not necessarily cause failures in each other,
@@ -954,22 +969,23 @@ static int test_packet_table(hid_t fid)
/*
*
-*/
-int main(void)
+ */
+int
+main(void)
{
/* identifier for the file that is used in FL PT tests */
- hid_t fid;
- int status = 0;
+ hid_t fid;
+ int status = 0;
-/*-------------------------------------------------------------------------
- * Packet test: test each function of the packet table library
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * Packet test: test each function of the packet table library
+ *-------------------------------------------------------------------------
+ */
- /* create a file using default properties */
- fid=H5Fcreate(TEST_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ /* create a file using default properties */
+ fid = H5Fcreate(TEST_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- HDputs("Testing packet table");
+ HDputs("Testing packet table");
/* Test packet table with fixed length */
if (test_packet_table(fid) < 0)
@@ -981,7 +997,7 @@ int main(void)
/* Close the file */
if (H5Fclose(fid) < 0)
- status = 1;
+ status = 1;
return status;
}
diff --git a/hl/test/test_packet_vlen.c b/hl/test/test_packet_vlen.c
index 35bd43a..c668a07 100644
--- a/hl/test/test_packet_vlen.c
+++ b/hl/test/test_packet_vlen.c
@@ -5,7 +5,7 @@
* 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. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -18,17 +18,17 @@
*-------------------------------------------------------------------------
*/
-#define NRECORDS 5
-#define TEST_FILE_NAME "test_packet_table_vlen.h5"
+#define NRECORDS 5
+#define TEST_FILE_NAME "test_packet_table_vlen.h5"
#define TESTFL_FILE_NAME "testfl_packet_table_vlen.h5"
-#define PT_VLEN_ATOMIC "Dataset with VL of Atomic types"
-#define PT_VLEN_COMP "Dataset with VL of Compound Types"
-#define PT_COMP_VLEN "Dataset with Compound Type of VL types"
-#define PT_VLEN_VLEN "Dataset with VL of VL types"
-#define PT_FIXED_LEN "Fixed-length Packet Table"
-#define L1_INCM 16
-#define L2_INCM 8
-#define NAME_BUF_SIZE 80
+#define PT_VLEN_ATOMIC "Dataset with VL of Atomic types"
+#define PT_VLEN_COMP "Dataset with VL of Compound Types"
+#define PT_COMP_VLEN "Dataset with Compound Type of VL types"
+#define PT_VLEN_VLEN "Dataset with VL of VL types"
+#define PT_FIXED_LEN "Fixed-length Packet Table"
+#define L1_INCM 16
+#define L2_INCM 8
+#define NAME_BUF_SIZE 80
/*-------------------------------------------------------------------------
* Local functions
@@ -46,109 +46,112 @@ static int verify_attribute(hid_t fid, const char *table_name, const char *attr_
/*-------------------------------------------------------------------------
* test_VLof_atomic(): Test that a packet table with VL datatypes of atomic
- * datatypes can be created and written correctly. (HDFFV-442)
+ * datatypes can be created and written correctly. (HDFFV-442)
*
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int test_VLof_atomic(void)
+static int
+test_VLof_atomic(void)
{
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */
- hsize_t count; /* Number of records in the table */
- unsigned uu, vv; /* Loop variables */
- hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
- hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
- char msg[80]; /* For error message */
- herr_t ret; /* Returned status from a callee */
-
- TESTING3(" with vlen of atomic");
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t vltype = H5I_INVALID_HID; /* Variable length datatype */
+ hsize_t count; /* Number of records in the table */
+ unsigned uu, vv; /* Loop variables */
+ hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
+ hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
+ char msg[80]; /* For error message */
+ herr_t ret; /* Returned status from a callee */
+
+ HL_TESTING3(" with vlen of atomic");
/* Allocate and initialize VL data to write (copied from C test) */
for (uu = 0; uu < NRECORDS; uu++) {
writeBuf[uu].p = HDmalloc((uu + 1) * sizeof(unsigned int));
if (writeBuf[uu].p == NULL) {
- fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
+ HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
goto error;
- }
+ }
writeBuf[uu].len = uu + 1;
for (vv = 0; vv < (uu + 1); vv++)
- ((unsigned int *)writeBuf[uu].p)[vv] = uu * 10 + vv;
+ ((unsigned int *)writeBuf[uu].p)[vv] = uu * 10 + vv;
} /* end for */
/* Open the file */
fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create a vlen type that uses an atomic datatype as its base type */
- vltype = H5Tvlen_create (H5T_NATIVE_UINT);
+ vltype = H5Tvlen_create(H5T_NATIVE_UINT);
if (vltype < 0)
- goto error;
+ goto error;
/* Create a packet table that uses a vlen datatype of an atomic type */
ptable = H5PTcreate(fid, PT_VLEN_ATOMIC, vltype, (hsize_t)1, H5P_DEFAULT);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Close the vlen datatype */
if (H5Tclose(vltype) < 0)
- goto error;
+ goto error;
/* Write the entire buffer to the packet table */
ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Get the number of packets in the packet table, should be NRECORDS. */
ret = H5PTget_num_packets(ptable, &count);
if (ret < 0)
- goto error;
+ goto error;
- sprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
+ HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
VERIFY(count == NRECORDS, msg);
/* Read all five packets back */
- ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void*)readBuf );
+ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void *)readBuf);
if (ret < 0)
- goto error;
+ goto error;
for (uu = 0; uu < NRECORDS; uu++)
- for (vv = 0; vv < (uu + 1); vv++)
- {
- if (((unsigned int *)readBuf[uu].p)[vv] != ((unsigned int *)writeBuf[uu].p)[vv]) {
- printf("Packet %u's value should be %d\n", uu, ((unsigned int *)writeBuf[uu].p)[vv]);
- printf("Packet %u's value in readBuf is %d\n", uu, ((unsigned int *)readBuf[uu].p)[vv]);
- }
+ for (vv = 0; vv < (uu + 1); vv++) {
+ if (((unsigned int *)readBuf[uu].p)[vv] != ((unsigned int *)writeBuf[uu].p)[vv]) {
+ HDprintf("Packet %u's value should be %d\n", uu, ((unsigned int *)writeBuf[uu].p)[vv]);
+ HDprintf("Packet %u's value in readBuf is %d\n", uu, ((unsigned int *)readBuf[uu].p)[vv]);
+ }
}
/* Free the buffers */
- ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf );
+ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
if (ret < 0)
- goto error;
+ goto error;
ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (vltype > 0) H5Tclose(vltype);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
- if (fid > 0) H5Fclose(fid);
+ if (vltype > 0)
+ H5Tclose(vltype);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ if (fid > 0)
+ H5Fclose(fid);
H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
H5_FAILED();
@@ -157,139 +160,147 @@ error: /* An error has occurred. Clean up and exit. */
/*-------------------------------------------------------------------------
* test_VLof_comptype(): Test that a packet table with VL datatypes of
- * compound datatypes can be created and written correctly. (HDFFV-442)
+ * compound datatypes can be created and written correctly. (HDFFV-442)
*
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int test_VLof_comptype(void)
+static int
+test_VLof_comptype(void)
{
/* Struct that the VL sequences are composed of */
typedef struct {
unsigned u;
- float f;
+ float f;
} VLcomp_t;
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */
- hid_t cmptype=H5I_INVALID_HID; /* Compound datatype */
- hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
- hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
- hsize_t count; /* Number of records in the table */
- unsigned uu, vv; /* Loop variables */
- char msg[80]; /* For error message */
- herr_t ret;
-
- TESTING3(" with vlen of compound datatypes");
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t vltype = H5I_INVALID_HID; /* Variable length datatype */
+ hid_t cmptype = H5I_INVALID_HID; /* Compound datatype */
+ hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
+ hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
+ hsize_t count; /* Number of records in the table */
+ unsigned uu, vv; /* Loop variables */
+ char msg[80]; /* For error message */
+ herr_t ret;
+
+ HL_TESTING3(" with vlen of compound datatypes");
/* Allocate and initialize VL data to write (copied from C test) */
for (uu = 0; uu < NRECORDS; uu++) {
writeBuf[uu].p = HDmalloc((uu + 1) * sizeof(VLcomp_t));
- if(writeBuf[uu].p == NULL) {
- fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
+ if (writeBuf[uu].p == NULL) {
+ HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
goto error;
- }
+ }
writeBuf[uu].len = uu + 1;
for (vv = 0; vv < (uu + 1); vv++) {
((VLcomp_t *)writeBuf[uu].p)[vv].u = uu + vv;
((VLcomp_t *)writeBuf[uu].p)[vv].f = (float)(uu + vv) / 3.0F;
- } /* end for */
- } /* end for */
+ } /* end for */
+ } /* end for */
/* Open the file */
fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create the base compound type */
cmptype = H5Tcreate(H5T_COMPOUND, sizeof(VLcomp_t));
if (cmptype < 0)
- goto error;
+ goto error;
/* Insert fields */
ret = H5Tinsert(cmptype, "u", HOFFSET(VLcomp_t, u), H5T_NATIVE_UINT);
if (ret < 0)
- goto error;
+ goto error;
ret = H5Tinsert(cmptype, "f", HOFFSET(VLcomp_t, f), H5T_NATIVE_FLOAT);
if (ret < 0)
- goto error;
+ goto error;
/* Create a variable length type that uses the VLcomp_t as its base type */
vltype = H5Tvlen_create(cmptype);
if (vltype < 0)
- goto error;
+ goto error;
/* Create a packet table that uses a vlen datatype of compound datatype */
ptable = H5PTcreate(fid, PT_VLEN_COMP, vltype, (hsize_t)1, H5P_DEFAULT);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Release the datatypes */
if (H5Tclose(cmptype) < 0)
- goto error;
+ goto error;
if (H5Tclose(vltype) < 0)
- goto error;
+ goto error;
/* Write the entire buffer to the packet table */
- ret = H5PTappend(ptable, (size_t)5, writeBuf );
+ ret = H5PTappend(ptable, (size_t)5, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Get the number of packets in the packet table, should be NRECORDS. */
ret = H5PTget_num_packets(ptable, &count);
if (ret < 0)
- goto error;
+ goto error;
- sprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
+ HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
VERIFY(count == NRECORDS, msg);
/* Read all five packets back */
- ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void*)readBuf );
+ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void *)readBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Compare data read in */
for (uu = 0; uu < NRECORDS; uu++) {
if (writeBuf[uu].len != readBuf[uu].len) {
- fprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].len=%d, readBuf[%u].len=%d\n", __LINE__, uu, (int)writeBuf[uu].len, uu, (int)readBuf[uu].len);
- continue;
- } /* write len != read len */
+ HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].len=%d, readBuf[%u].len=%d\n",
+ __LINE__, uu, (int)writeBuf[uu].len, uu, (int)readBuf[uu].len);
+ continue;
+ } /* write len != read len */
for (vv = 0; vv < (uu + 1); vv++) {
- if (((unsigned int *)writeBuf[uu].p)[vv] != ((unsigned int *)readBuf[uu].p)[vv] ) {
- fprintf(stderr, "VL data values don't match!, writeBuf[uu].p[%d]=%d, readBuf[uu].p[%d]=%d\n", vv, (int)((unsigned int *)writeBuf[uu].p)[vv], vv, (int)((unsigned int *)readBuf[uu].p)[vv]);
+ if (((unsigned int *)writeBuf[uu].p)[vv] != ((unsigned int *)readBuf[uu].p)[vv]) {
+ HDfprintf(
+ stderr, "VL data values don't match!, writeBuf[uu].p[%d]=%d, readBuf[uu].p[%d]=%d\n", vv,
+ (int)((unsigned int *)writeBuf[uu].p)[vv], vv, (int)((unsigned int *)readBuf[uu].p)[vv]);
continue;
- } /* write value != read value */
- }
+ } /* write value != read value */
+ }
} /* end for */
/* Free the buffers */
ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
if (ret < 0)
- goto error;
+ goto error;
ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (cmptype > 0) H5Tclose(cmptype);
- if (vltype > 0) H5Tclose(vltype);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
- if (fid > 0) H5Fclose(fid);
+ if (cmptype > 0)
+ H5Tclose(cmptype);
+ if (vltype > 0)
+ H5Tclose(vltype);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ if (fid > 0)
+ H5Fclose(fid);
H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
H5_FAILED();
@@ -298,53 +309,53 @@ error: /* An error has occurred. Clean up and exit. */
/*-------------------------------------------------------------------------
* test_compound_VL_VL(): Test that a packet table of compound datatypes
- * containing VL datatypes can be created and written
- * correctly. (HDFFV-442)
+ * containing VL datatypes can be created and written
+ * correctly. (HDFFV-442)
*
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int test_compound_VL_VLtype(void)
+static int
+test_compound_VL_VLtype(void)
{
/* Struct that the VL sequences are composed of */
typedef struct {
unsigned u;
- float f;
- hvl_t v;
+ float f;
+ hvl_t v;
} compVLVL_t;
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */
- hid_t vlofvl=H5I_INVALID_HID; /* Variable length datatype */
- hid_t comp_vlvl=H5I_INVALID_HID; /* ID of a compound datatype containing
- a VL of VL of atomic datatype */
- hsize_t count; /* Number of records in the table */
- compVLVL_t writeBuf[NRECORDS];/* Buffer to hold data to be written */
- compVLVL_t readBuf[NRECORDS]; /* Buffer to hold read data */
- hvl_t *t1, *t2;
- unsigned uu, vv, ww; /* Loop variables */
- char msg[80]; /* For error message */
- herr_t ret; /* Returned status from a callee */
-
- TESTING3(" with compound datatype containing vlen datatype");
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t vlatomic = H5I_INVALID_HID; /* Variable length datatype */
+ hid_t vlofvl = H5I_INVALID_HID; /* Variable length datatype */
+ hid_t comp_vlvl = H5I_INVALID_HID; /* ID of a compound datatype containing
+ a VL of VL of atomic datatype */
+ hsize_t count; /* Number of records in the table */
+ compVLVL_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
+ compVLVL_t readBuf[NRECORDS]; /* Buffer to hold read data */
+ hvl_t * t1, *t2;
+ unsigned uu, vv, ww; /* Loop variables */
+ char msg[80]; /* For error message */
+ herr_t ret; /* Returned status from a callee */
+
+ HL_TESTING3(" with compound datatype containing vlen datatype");
/* Allocate and initialize VL data to write (copied from C test) */
for (uu = 0; uu < NRECORDS; uu++) {
- writeBuf[uu].u = uu * 10;
- writeBuf[uu].f = (float)(uu * 20) / 3.0F;
+ writeBuf[uu].u = uu * 10;
+ writeBuf[uu].f = (float)(uu * 20) / 3.0F;
writeBuf[uu].v.p = HDmalloc((uu + L1_INCM) * sizeof(hvl_t));
if (writeBuf[uu].v.p == NULL) {
- fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
+ HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
goto error;
- }
+ }
writeBuf[uu].v.len = uu + L1_INCM;
- for (t1 = (hvl_t *)((writeBuf[uu].v).p), vv = 0; vv < (uu + L1_INCM); vv++, t1++)
- {
+ for (t1 = (hvl_t *)((writeBuf[uu].v).p), vv = 0; vv < (uu + L1_INCM); vv++, t1++) {
t1->p = HDmalloc((vv + L2_INCM) * sizeof(unsigned int));
- if (t1->p == NULL) {
- fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
- goto error;
- }
+ if (t1->p == NULL) {
+ HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
+ goto error;
+ }
t1->len = vv + L2_INCM;
for (ww = 0; ww < vv + L2_INCM; ww++)
((unsigned int *)t1->p)[ww] = uu * 100 + vv * 10 + ww;
@@ -354,123 +365,135 @@ static int test_compound_VL_VLtype(void)
/* Open the file */
fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create a VL datatype of an atomic type */
- vlatomic = H5Tvlen_create (H5T_NATIVE_UINT);
+ vlatomic = H5Tvlen_create(H5T_NATIVE_UINT);
if (vlatomic < 0)
- goto error;
+ goto error;
/* Create a VL datatype of the VL of atomic datatype */
- vlofvl = H5Tvlen_create (vlatomic);
+ vlofvl = H5Tvlen_create(vlatomic);
if (vlofvl < 0)
- goto error;
+ goto error;
/* Create the base compound type */
comp_vlvl = H5Tcreate(H5T_COMPOUND, sizeof(compVLVL_t));
if (comp_vlvl < 0)
- goto error;
+ goto error;
/* Insert fields: atomic, atomic, vlen */
ret = H5Tinsert(comp_vlvl, "u", HOFFSET(compVLVL_t, u), H5T_NATIVE_UINT);
if (ret < 0)
- goto error;
+ goto error;
ret = H5Tinsert(comp_vlvl, "f", HOFFSET(compVLVL_t, f), H5T_NATIVE_FLOAT);
if (ret < 0)
- goto error;
+ goto error;
ret = H5Tinsert(comp_vlvl, "v", HOFFSET(compVLVL_t, v), vlofvl);
if (ret < 0)
- goto error;
+ goto error;
/* Create a packet table that uses a compound datatype of vlen datatype */
ptable = H5PTcreate(fid, PT_COMP_VLEN, comp_vlvl, (hsize_t)1, H5P_DEFAULT);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Release datatypes */
if (H5Tclose(vlatomic) < 0)
- goto error;
+ goto error;
if (H5Tclose(vlofvl) < 0)
- goto error;
+ goto error;
if (H5Tclose(comp_vlvl) < 0)
- goto error;
+ goto error;
/* Write the entire buffer to the packet table */
- ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf );
+ ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Get the number of packets in the packet table, should be NRECORDS. */
ret = H5PTget_num_packets(ptable, &count);
if (ret < 0)
- goto error;
+ goto error;
- sprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
+ HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
VERIFY(count == NRECORDS, msg);
/* Read all five packets back */
- ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void*)readBuf );
+ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void *)readBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Compare data read in */
for (uu = 0; uu < NRECORDS; uu++) {
if (writeBuf[uu].u != readBuf[uu].u) {
- fprintf(stderr, "Integer components don't match!, writeBuf[%u].u=%u, readBuf[%u].u=%u\n", uu, writeBuf[uu].u, uu, readBuf[uu].u);
+ HDfprintf(stderr, "Integer components don't match!, writeBuf[%u].u=%u, readBuf[%u].u=%u\n", uu,
+ writeBuf[uu].u, uu, readBuf[uu].u);
continue;
} /* end if */
- if (!H5_FLT_ABS_EQUAL(writeBuf[uu].f,readBuf[uu].f)) {
- fprintf(stderr, "Float components don't match!, writeBuf[%u].f=%f, readBuf[%u].f=%f\n", uu, (double)writeBuf[uu].f, uu, (double)readBuf[uu].f);
+ if (!H5_FLT_ABS_EQUAL(writeBuf[uu].f, readBuf[uu].f)) {
+ HDfprintf(stderr, "Float components don't match!, writeBuf[%u].f=%f, readBuf[%u].f=%f\n", uu,
+ (double)writeBuf[uu].f, uu, (double)readBuf[uu].f);
continue;
} /* end if */
if (writeBuf[uu].v.len != readBuf[uu].v.len) {
- fprintf(stderr, "%d: VL data length don't match!, writeBuf[%d].v.len=%zu, readBuf[%d].v.len=%zu\n", __LINE__, uu, writeBuf[uu].v.len, uu, readBuf[uu].v.len);
+ HDfprintf(stderr,
+ "%d: VL data length don't match!, writeBuf[%d].v.len=%zu, readBuf[%d].v.len=%zu\n",
+ __LINE__, uu, writeBuf[uu].v.len, uu, readBuf[uu].v.len);
continue;
} /* end if */
- for (t1 = (hvl_t *)(writeBuf[uu].v.p), t2 = (hvl_t *)(readBuf[uu].v.p), vv = 0; (size_t)vv < readBuf[uu].v.len; vv++, t1++, t2++) {
+ for (t1 = (hvl_t *)(writeBuf[uu].v.p), t2 = (hvl_t *)(readBuf[uu].v.p), vv = 0;
+ (size_t)vv < readBuf[uu].v.len; vv++, t1++, t2++) {
if (t1->len != t2->len) {
- fprintf(stderr, "%d: VL data length don't match!, uu=%u, vv=%u, t1->len=%zu, t2->len=%zu\n", __LINE__, uu, vv, t1->len, t2->len);
+ HDfprintf(stderr, "%d: VL data length don't match!, uu=%u, vv=%u, t1->len=%zu, t2->len=%zu\n",
+ __LINE__, uu, vv, t1->len, t2->len);
continue;
} /* end if */
for (ww = 0; (size_t)ww < t2->len; ww++) {
- if (((unsigned int *)t1->p)[ww] != ((unsigned int *)t2->p)[ww] ) {
- fprintf(stderr, "VL data values don't match!, t1->p[%u]=%u, t2->p[%u]=%u\n", ww, ((unsigned int *)t1->p)[ww], ww, ((unsigned int *)t2->p)[ww]);
+ if (((unsigned int *)t1->p)[ww] != ((unsigned int *)t2->p)[ww]) {
+ HDfprintf(stderr, "VL data values don't match!, t1->p[%u]=%u, t2->p[%u]=%u\n", ww,
+ ((unsigned int *)t1->p)[ww], ww, ((unsigned int *)t2->p)[ww]);
continue;
} /* end if */
- } /* end for */
- } /* end for */
- } /* end for */
+ } /* end for */
+ } /* end for */
+ } /* end for */
/* Free the buffers */
ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
if (ret < 0)
- goto error;
+ goto error;
ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (vlatomic > 0) H5Tclose(vlatomic);
- if (vlofvl > 0) H5Tclose(vlofvl);
- if (comp_vlvl > 0) H5Tclose(comp_vlvl);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
- if (fid > 0) H5Fclose(fid);
+ if (vlatomic > 0)
+ H5Tclose(vlatomic);
+ if (vlofvl > 0)
+ H5Tclose(vlofvl);
+ if (comp_vlvl > 0)
+ H5Tclose(comp_vlvl);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ if (fid > 0)
+ H5Fclose(fid);
H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
H5_FAILED();
@@ -479,119 +502,123 @@ error: /* An error has occurred. Clean up and exit. */
/*-------------------------------------------------------------------------
* test_VLof_VLtype(): Test that a packet table of VL datatype with VL
- * datatypes of atomic datatypes can be created and written
- * correctly. (HDFFV-442)
+ * datatypes of atomic datatypes can be created and written
+ * correctly. (HDFFV-442)
*
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int test_VLof_VLtype(void)
+static int
+test_VLof_VLtype(void)
{
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */
- hid_t vlofvl=H5I_INVALID_HID; /* VL datatype of VL datatypes */
- hsize_t count; /* Number of records in the table */
- hvl_t *t1; /* pointer to advance */
- unsigned uu, vv, ww; /* Loop variables */
- hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
- hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
- char msg[80]; /* For error message */
- herr_t ret; /* Returned status from a callee */
-
- TESTING3(" with vlen datatype of vlen datatype");
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t vlatomic = H5I_INVALID_HID; /* Variable length datatype */
+ hid_t vlofvl = H5I_INVALID_HID; /* VL datatype of VL datatypes */
+ hsize_t count; /* Number of records in the table */
+ hvl_t * t1; /* pointer to advance */
+ unsigned uu, vv, ww; /* Loop variables */
+ hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
+ hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
+ char msg[80]; /* For error message */
+ herr_t ret; /* Returned status from a callee */
+
+ HL_TESTING3(" with vlen datatype of vlen datatype");
/* Allocate and initialize VL data to write (copied from C test) */
for (uu = 0; uu < NRECORDS; uu++) {
writeBuf[uu].p = HDmalloc((uu + 1) * sizeof(hvl_t));
if (writeBuf[uu].p == NULL) {
- fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
+ HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
goto error;
} /* end if */
writeBuf[uu].len = uu + 1;
- for (t1=(hvl_t *)(writeBuf[uu].p), vv = 0; vv < (uu + 1); vv++, t1++)
- {
+ for (t1 = (hvl_t *)(writeBuf[uu].p), vv = 0; vv < (uu + 1); vv++, t1++) {
t1->p = HDmalloc((vv + 1) * sizeof(unsigned int));
- if (t1->p == NULL) {
- fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
- goto error;
- }
+ if (t1->p == NULL) {
+ HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
+ goto error;
+ }
t1->len = vv * 1;
for (ww = 0; ww < (vv * 1); ww++)
((unsigned int *)t1->p)[ww] = uu * 100 + vv * 10 + ww;
} /* end for */
- } /* end for */
+ } /* end for */
/* Open the file */
fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create a VL datatype of an atomic type */
- vlatomic = H5Tvlen_create (H5T_NATIVE_UINT);
+ vlatomic = H5Tvlen_create(H5T_NATIVE_UINT);
if (vlatomic < 0)
- goto error;
+ goto error;
- vlofvl = H5Tvlen_create (vlatomic);
+ vlofvl = H5Tvlen_create(vlatomic);
if (vlofvl < 0)
- goto error;
+ goto error;
/* Create a packet table that uses a vlen datatype of vlen datatype */
ptable = H5PTcreate(fid, PT_VLEN_VLEN, vlofvl, (hsize_t)1, H5P_DEFAULT);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Release datatypes */
if (H5Tclose(vlatomic) < 0)
- goto error;
+ goto error;
if (H5Tclose(vlofvl) < 0)
- goto error;
+ goto error;
/* Write the entire buffer to the packet table */
- ret = H5PTappend(ptable, (size_t)5, writeBuf );
+ ret = H5PTappend(ptable, (size_t)5, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Get the number of packets in the packet table, should be NRECORDS. */
ret = H5PTget_num_packets(ptable, &count);
if (ret < 0)
- goto error;
+ goto error;
- sprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
+ HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
VERIFY(count == NRECORDS, msg);
/* Read all five packets back */
- ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void*)readBuf );
+ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void *)readBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Free the buffers */
ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
if (ret < 0)
- goto error;
+ goto error;
ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (vlatomic > 0) H5Tclose(vlatomic);
- if (vlofvl > 0) H5Tclose(vlofvl);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
- if (fid > 0) H5Fclose(fid);
+ if (vlatomic > 0)
+ H5Tclose(vlatomic);
+ if (vlofvl > 0)
+ H5Tclose(vlofvl);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ if (fid > 0)
+ H5Fclose(fid);
H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
H5_FAILED();
@@ -600,248 +627,259 @@ error: /* An error has occurred. Clean up and exit. */
/*-------------------------------------------------------------------------
* verify_ptlengthtype() - helper function, verifies that the named packet
- * table is a fixed-length or variable-length as indicated by the last
- * argument.
+ * table is a fixed-length or variable-length as indicated by the last
+ * argument.
*
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int verify_ptlengthtype(hid_t fid, const char *table_name, herr_t expected_value)
+static int
+verify_ptlengthtype(hid_t fid, const char *table_name, herr_t expected_value)
{
- hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
- herr_t is_varlen = 0;
- herr_t ret = FAIL;
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ herr_t is_varlen = 0;
+ herr_t ret = FAIL;
/* Open the named packet table */
- if( (ptable = H5PTopen(fid, table_name)) < 0)
- goto error;
+ if ((ptable = H5PTopen(fid, table_name)) < 0)
+ goto error;
/* Verify the value returned from H5PTis_varlen is as expected */
is_varlen = H5PTis_varlen(ptable);
if (is_varlen == FAIL)
- goto error;
+ goto error;
else if (is_varlen == expected_value)
- ret = SUCCEED;
- else
- {
- char lenthtype[20];
- HDstrcpy(lenthtype, "fixed-length");
- if (expected_value == 1)
- HDstrcpy(lenthtype, "variable-length");
- fprintf(stderr, "\nPacket table '%s' should be %s but is not\n", table_name, lenthtype);
- ret = FAIL;
+ ret = SUCCEED;
+ else {
+ char lenthtype[20];
+ HDstrcpy(lenthtype, "fixed-length");
+ if (expected_value == 1)
+ HDstrcpy(lenthtype, "variable-length");
+ HDfprintf(stderr, "\nPacket table '%s' should be %s but is not\n", table_name, lenthtype);
+ ret = FAIL;
}
/* Close the packet table */
if (H5PTclose(ptable) < 0)
- goto error;
+ goto error;
return ret;
error: /* An error has occurred. Clean up and exit. */
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
return ret;
} /* verify_ptlengthtype */
/*-------------------------------------------------------------------------
* test_H5PTis_varlen(): Test that H5PTis_varlen works correctly on both
- * fixed- and variable-length packet tables.
+ * fixed- and variable-length packet tables.
*
* Description:
- * - Added a fixed-length packet table to the file for variety
- * - Use the helper funtion verify_ptlengthtype to test H5PTis_varlen
- * on each packet table.
+ * - Added a fixed-length packet table to the file for variety
+ * - Use the helper funtion verify_ptlengthtype to test H5PTis_varlen
+ * on each packet table.
*
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int test_H5PTis_varlen(void)
+static int
+test_H5PTis_varlen(void)
{
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- herr_t ret; /* Returned status from a callee */
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ herr_t ret; /* Returned status from a callee */
- TESTING("H5PTis_varlen");
+ HL_TESTING2("H5PTis_varlen");
/* Open the file */
fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create a new table */
ptable = H5PTcreate(fid, PT_FIXED_LEN, H5T_STD_I32BE, (hsize_t)100, H5P_DEFAULT);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
/* Open the file */
fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Open each packet table, and verify that H5PTis_varlen returns correct
type for each table */
ret = verify_ptlengthtype(fid, PT_VLEN_ATOMIC, 1); /* vlen of atomic */
if (ret < 0)
- goto error;
+ goto error;
ret = verify_ptlengthtype(fid, PT_VLEN_COMP, 1); /* vlen of compound */
if (ret < 0)
- goto error;
+ goto error;
ret = verify_ptlengthtype(fid, PT_COMP_VLEN, 0); /* compound of vlen, no vlen */
if (ret < 0)
- goto error;
+ goto error;
ret = verify_ptlengthtype(fid, PT_VLEN_VLEN, 1); /* vlen of vlen */
if (ret < 0)
- goto error;
+ goto error;
ret = verify_ptlengthtype(fid, PT_FIXED_LEN, 0); /* no vlen */
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (fid > 0) H5Fclose(fid);
+ if (fid > 0)
+ H5Fclose(fid);
H5_FAILED();
return FAIL;
} /* test_H5PTis_varlen */
/*-------------------------------------------------------------------------
* adding_attribute() - helper function, adds an attribute to the named
- * packet table.
+ * packet table.
* Note:
- * For simplicity, the attributes that are added to the packet tables
- * have the same characteristics except their names. They have the
- * same type, space, and values.
+ * For simplicity, the attributes that are added to the packet tables
+ * have the same characteristics except their names. They have the
+ * same type, space, and values.
*
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-#define ATTR_RANK 1
-#define ATTR_DIM 3
-int attr_data[ATTR_DIM]={256,11945,-22107}; /* values to be written to attr */
+#define ATTR_RANK 1
+#define ATTR_DIM 3
+int attr_data[ATTR_DIM] = {256, 11945, -22107}; /* values to be written to attr */
-static int adding_attribute(hid_t fid, const char *table_name, const char *attr_name)
+static int
+adding_attribute(hid_t fid, const char *table_name, const char *attr_name)
{
- hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
- hid_t space_id = H5I_INVALID_HID; /* Dataspace for the attribute */
- hid_t attr_id = H5I_INVALID_HID; /* Attribute identifier */
- hid_t dset_id = H5I_INVALID_HID; /* Dataset identifier */
- hsize_t dims[] = {ATTR_DIM}; /* Dimension for dataspace */
- int ret = FAIL; /* Returned status from a callee */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t space_id = H5I_INVALID_HID; /* Dataspace for the attribute */
+ hid_t attr_id = H5I_INVALID_HID; /* Attribute identifier */
+ hid_t dset_id = H5I_INVALID_HID; /* Dataset identifier */
+ hsize_t dims[] = {ATTR_DIM}; /* Dimension for dataspace */
+ int ret = FAIL; /* Returned status from a callee */
/* Create dataspace for attribute */
space_id = H5Screate_simple(ATTR_RANK, dims, NULL);
if (space_id < 0)
- goto error;
+ goto error;
/* Open the named packet table */
- if( (ptable = H5PTopen(fid, table_name)) < 0)
- goto error;
+ if ((ptable = H5PTopen(fid, table_name)) < 0)
+ goto error;
dset_id = H5PTget_dataset(ptable);
if (dset_id < 0)
- goto error;
+ goto error;
/* Add the specified attribute to it */
attr_id = H5Acreate2(dset_id, attr_name, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT);
if (attr_id < 0)
- goto error;
+ goto error;
/* Write attribute values */
ret = H5Awrite(attr_id, H5T_NATIVE_INT, attr_data);
if (ret < 0)
- goto error;
+ goto error;
/* Close the attribute */
if (H5Aclose(attr_id) < 0)
- goto error;
+ goto error;
/* Close the dataspace */
if (H5Sclose(space_id) < 0)
- goto error;
+ goto error;
/* Close the packet table */
if (H5PTclose(ptable) < 0)
- goto error;
+ goto error;
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (attr_id > 0) H5Aclose(attr_id);
- if (space_id > 0) H5Sclose(space_id);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
+ if (attr_id > 0)
+ H5Aclose(attr_id);
+ if (space_id > 0)
+ H5Sclose(space_id);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
return ret;
} /* adding_attribute */
/*-------------------------------------------------------------------------
* verify_attribute() - helper function, verifies the named attribute can
- * be read correctly.
+ * be read correctly.
*
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static herr_t verify_attribute(hid_t fid, const char *table_name, const char *attr_name)
+static herr_t
+verify_attribute(hid_t fid, const char *table_name, const char *attr_name)
{
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t attr_id=H5I_INVALID_HID; /* Attribute identifier */
- hid_t dset_id=H5I_INVALID_HID; /* Dataset associated with the pt */
- int read_data[ATTR_DIM]; /* Output buffer */
- int ii;
- herr_t ret = FAIL; /* Returned status from a callee */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t attr_id = H5I_INVALID_HID; /* Attribute identifier */
+ hid_t dset_id = H5I_INVALID_HID; /* Dataset associated with the pt */
+ int read_data[ATTR_DIM]; /* Output buffer */
+ int ii;
+ herr_t ret = FAIL; /* Returned status from a callee */
/* Open the named packet table */
ptable = H5PTopen(fid, table_name);
if (ptable < 0)
- goto error;
+ goto error;
/* Get the dataset id of this packet table */
dset_id = H5PTget_dataset(ptable);
if (dset_id < 0)
- goto error;
+ goto error;
/* Open first attribute for the dataset */
attr_id = H5Aopen(dset_id, attr_name, H5P_DEFAULT);
if (attr_id < 0)
- goto error;
+ goto error;
/* Read attribute values */
ret = H5Aread(attr_id, H5T_NATIVE_INT, read_data);
if (ret < 0)
- goto error;
+ goto error;
/* Verify values read in */
for (ii = 0; ii < ATTR_DIM; ii++)
if (attr_data[ii] != read_data[ii])
- TestErrPrintf("%d: attribute data different: attr_data[%d]=%d, read_data[%d]=%d\n", __LINE__, ii, attr_data[ii], ii, read_data[ii]);
+ TestErrPrintf("%d: attribute data different: attr_data[%d]=%d, read_data[%d]=%d\n", __LINE__, ii,
+ attr_data[ii], ii, read_data[ii]);
/* Close the attribute */
if (H5Aclose(attr_id) < 0)
- goto error;
+ goto error;
/* Close the packet table */
if (H5PTclose(ptable) < 0)
- goto error;
+ goto error;
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (attr_id > 0) H5Aclose(attr_id);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
+ if (attr_id > 0)
+ H5Aclose(attr_id);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
return ret;
} /* verify_attribute */
@@ -849,143 +887,142 @@ error: /* An error has occurred. Clean up and exit. */
* test_attributes(): Test adding attributes to packet tables
*
* Description:
- * Added attributes to some random packet tables in the file.
+ * Added attributes to some random packet tables in the file.
*
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int test_attributes(void)
+static int
+test_attributes(void)
{
- hid_t fid=H5I_INVALID_HID; /* File identifier */
- hid_t attr_id=H5I_INVALID_HID; /* Attribute identifier */
- herr_t ret = FAIL; /* Returned status from a callee */
+ hid_t fid = H5I_INVALID_HID; /* File identifier */
+ hid_t attr_id = H5I_INVALID_HID; /* Attribute identifier */
+ herr_t ret = FAIL; /* Returned status from a callee */
- TESTING("adding attributes to packet tables");
+ HL_TESTING2("adding attributes to packet tables");
/* Open the file */
fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Add an arbitrary attribute to a few packet tables, using helper func */
attr_id = adding_attribute(fid, PT_VLEN_ATOMIC, "Attribute 1");
if (attr_id < 0)
- goto error;
+ goto error;
attr_id = adding_attribute(fid, PT_VLEN_COMP, "Attribute 2");
if (attr_id < 0)
- goto error;
+ goto error;
attr_id = adding_attribute(fid, PT_COMP_VLEN, "Attribute 3");
if (attr_id < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
/* Open the file again */
fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Read each attribute and verify the values, using helper function */
ret = verify_attribute(fid, PT_VLEN_ATOMIC, "Attribute 1");
if (ret < 0)
- goto error;
+ goto error;
ret = verify_attribute(fid, PT_VLEN_COMP, "Attribute 2");
if (ret < 0)
- goto error;
+ goto error;
ret = verify_attribute(fid, PT_COMP_VLEN, "Attribute 3");
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
- return(ret);
+ return (ret);
error: /* An error has occurred. Clean up and exit. */
- if (fid > 0) H5Fclose(fid);
+ if (fid > 0)
+ H5Fclose(fid);
H5_FAILED();
return FAIL;
} /* test_attributes */
/*-------------------------------------------------------------------------
* verify_accessors() - helper function, verifies that various info can be
- * retrieved correctly using the info returned by the accessor functions.
+ * retrieved correctly using the info returned by the accessor functions.
*
* Description:
- * Testing functions H5PTget_dataset and H5PTget_type
+ * Testing functions H5PTget_dataset and H5PTget_type
*
- * - Opens the named packet table
- * - Gets its associated dataset ID then calls a C function on that ID
- * to verify the dataset name
- * - Gets its associated datatype ID then calls a C function on that ID
- * to verify that the packet table is variable- or fixed-length as
- * indicated by the expected_value argument
+ * - Opens the named packet table
+ * - Gets its associated dataset ID then calls a C function on that ID
+ * to verify the dataset name
+ * - Gets its associated datatype ID then calls a C function on that ID
+ * to verify that the packet table is variable- or fixed-length as
+ * indicated by the expected_value argument
*
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static herr_t verify_accessors(hid_t fid, const char *table_name, herr_t expected_value)
+static herr_t
+verify_accessors(hid_t fid, const char *table_name, hbool_t uses_vlen_type)
{
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t dset_id=H5I_INVALID_HID; /* Dataset associated with the pt */
- hid_t dtype_id=H5I_INVALID_HID; /* Dataset identifier */
- char buf[NAME_BUF_SIZE];
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t dset_id = H5I_INVALID_HID; /* Dataset associated with the pt */
+ hid_t dtype_id = H5I_INVALID_HID; /* Dataset identifier */
+ char buf[NAME_BUF_SIZE];
ssize_t name_size;
- herr_t is_varlen = 0;
- herr_t ret = FAIL; /* Returned status from a callee */
+ htri_t vlen_check_result = -1;
/* Open the named packet table. */
- ptable = H5PTopen(fid, table_name);
- if (ptable < 0)
- goto error;
+ if ((ptable = H5PTopen(fid, table_name)) < 0)
+ goto error;
/* Get the associated dataset ID. */
- dset_id = H5PTget_dataset(ptable);
- if (dset_id < 0)
- goto error;
+ if ((dset_id = H5PTget_dataset(ptable)) < 0)
+ goto error;
/* Check if the packet table's name matches its associated dataset's. */
*buf = '\0';
- name_size = H5Iget_name(dset_id, (char*)buf, NAME_BUF_SIZE);
- if (name_size < 0)
- goto error;
+ if ((name_size = H5Iget_name(dset_id, (char *)buf, NAME_BUF_SIZE)) < 0)
+ goto error;
VERIFY(HDstrcmp(buf, table_name), "Names of dataset and packet table don't match");
/* Get the packet table's datatype ID */
- dtype_id = H5PTget_type(ptable);
- if (dtype_id < 0)
- goto error;
+ if ((dtype_id = H5PTget_type(ptable)) < 0)
+ goto error;
/* Check if the type class matches that of the packet table. */
- is_varlen = H5Tdetect_class(dtype_id, H5T_VLEN);
- if (is_varlen == FAIL) /* failure occurred */
- goto error;
- else if (is_varlen == expected_value) /* length types match */
- ret = SUCCEED;
- else /* length types don't match */
- {
- /* Give lengthtype "fixed-length" or "variable-length" depending on the
- expected_value passed in, then print the error message. */
- char lenthtype[20];
- HDstrcpy(lenthtype, "fixed-length");
- if (expected_value == 1)
- HDstrcpy(lenthtype, "variable-length");
- fprintf(stderr, "\nThe dataset '%s' should be %s but is not\n", table_name, lenthtype);
- ret = FAIL;
+ if ((vlen_check_result = H5Tdetect_class(dtype_id, H5T_VLEN)) < 0)
+ goto error;
+
+ /* Check if length types match */
+ if (vlen_check_result != (htri_t)uses_vlen_type) {
+ /* Give lengthtype "fixed-length" or "variable-length" depending on the
+ * expected_value passed in, then print the error message.
+ */
+ char lenthtype[20];
+ if (uses_vlen_type == TRUE)
+ HDstrcpy(lenthtype, "variable-length");
+ else
+ HDstrcpy(lenthtype, "fixed-length");
+ HDfprintf(stderr, "\nThe dataset '%s' should be %s but is not\n", table_name, lenthtype);
+ goto error;
}
/* Close the packet table */
if (H5PTclose(ptable) < 0)
- goto error;
+ goto error;
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
H5_FAILED();
return FAIL;
} /* verify_accessors */
@@ -994,157 +1031,162 @@ error: /* An error has occurred. Clean up and exit. */
* test_accessors(): Test the accessor functions
*
* Description:
- * Retrieves the dataset and datatype IDs and verifies various info
- * to ensure these IDs are correct.
+ * Retrieves the dataset and datatype IDs and verifies various info
+ * to ensure these IDs are correct.
*
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int test_accessors(void)
+static int
+test_accessors(void)
{
- hid_t fid=H5I_INVALID_HID; /* File identifier */
- herr_t ret = FAIL; /* Returned status from a callee */
+ hid_t fid = H5I_INVALID_HID; /* File identifier */
+ herr_t ret = FAIL; /* Returned status from a callee */
- TESTING("accessor functions");
+ HL_TESTING2("accessor functions");
/* Open the file */
fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
ret = verify_accessors(fid, PT_VLEN_ATOMIC, TRUE);
if (ret < 0)
- goto error;
+ goto error;
ret = verify_accessors(fid, PT_FIXED_LEN, FALSE);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (fid > 0) H5Fclose(fid);
+ if (fid > 0)
+ H5Fclose(fid);
H5_FAILED();
return FAIL;
} /* test_accessors */
/**************************************************************************
- Test set for deprecated function H5PTcreate_fl
- Each test in this set is the same as the corresponding one in the
- set for H5PTcreate, as of Mar 2016
+ Test set for deprecated function H5PTcreate_fl
+ Each test in this set is the same as the corresponding one in the
+ set for H5PTcreate, as of Mar 2016
**************************************************************************/
/*-------------------------------------------------------------------------
* testfl_VLof_atomic(): Test that a packet table with VL datatypes of atomic
- * datatypes can be created and written correctly. (HDFFV-442)
+ * datatypes can be created and written correctly. (HDFFV-442)
*
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int testfl_VLof_atomic(void)
+static int
+testfl_VLof_atomic(void)
{
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */
- hsize_t count; /* Number of records in the table */
- unsigned uu, vv; /* Loop variables */
- hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
- hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
- char msg[80]; /* For error message */
- herr_t ret; /* Returned status from a callee */
-
- TESTING3(" with vlen of atomic");
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t vltype = H5I_INVALID_HID; /* Variable length datatype */
+ hsize_t count; /* Number of records in the table */
+ unsigned uu, vv; /* Loop variables */
+ hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
+ hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
+ char msg[80]; /* For error message */
+ herr_t ret; /* Returned status from a callee */
+
+ HL_TESTING3(" with vlen of atomic");
/* Allocate and initialize VL data to write (copied from C test) */
for (uu = 0; uu < NRECORDS; uu++) {
writeBuf[uu].p = HDmalloc((uu + 1) * sizeof(unsigned int));
if (writeBuf[uu].p == NULL) {
- fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
+ HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
goto error;
- }
+ }
writeBuf[uu].len = uu + 1;
for (vv = 0; vv < (uu + 1); vv++)
- ((unsigned int *)writeBuf[uu].p)[vv] = uu * 10 + vv;
+ ((unsigned int *)writeBuf[uu].p)[vv] = uu * 10 + vv;
} /* end for */
/* Open the file */
fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create a vlen type that uses an atomic datatype as its base type */
- vltype = H5Tvlen_create (H5T_NATIVE_UINT);
+ vltype = H5Tvlen_create(H5T_NATIVE_UINT);
if (vltype < 0)
- goto error;
+ goto error;
/* Create a packet table that uses a vlen datatype of an atomic type */
ptable = H5PTcreate_fl(fid, PT_VLEN_ATOMIC, vltype, (hsize_t)1, 0);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Close the vlen datatype */
if (H5Tclose(vltype) < 0)
- goto error;
+ goto error;
/* Write the entire buffer to the packet table */
ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Get the number of packets in the packet table, should be NRECORDS. */
ret = H5PTget_num_packets(ptable, &count);
if (ret < 0)
- goto error;
+ goto error;
- sprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
+ HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
VERIFY(count == NRECORDS, msg);
/* Read all five packets back */
- ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void*)readBuf );
+ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void *)readBuf);
if (ret < 0)
- goto error;
+ goto error;
for (uu = 0; uu < NRECORDS; uu++)
- for (vv = 0; vv < (uu + 1); vv++)
- {
- if (((unsigned int *)readBuf[uu].p)[vv] != ((unsigned int *)writeBuf[uu].p)[vv]) {
- printf("Packet %d's value should be %d\n", uu, ((unsigned int *)writeBuf[uu].p)[vv]);
- printf("Packet %d's value in readBuf is %d\n", uu, ((unsigned int *)readBuf[uu].p)[vv]);
- }
+ for (vv = 0; vv < (uu + 1); vv++) {
+ if (((unsigned int *)readBuf[uu].p)[vv] != ((unsigned int *)writeBuf[uu].p)[vv]) {
+ HDprintf("Packet %d's value should be %d\n", uu, ((unsigned int *)writeBuf[uu].p)[vv]);
+ HDprintf("Packet %d's value in readBuf is %d\n", uu, ((unsigned int *)readBuf[uu].p)[vv]);
+ }
}
/* Free the buffers */
- ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf );
+ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
if (ret < 0)
- goto error;
+ goto error;
ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (vltype > 0) H5Tclose(vltype);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
- if (fid > 0) H5Fclose(fid);
+ if (vltype > 0)
+ H5Tclose(vltype);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ if (fid > 0)
+ H5Fclose(fid);
H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
H5_FAILED();
@@ -1153,139 +1195,147 @@ error: /* An error has occurred. Clean up and exit. */
/*-------------------------------------------------------------------------
* testfl_VLof_comptype(): Test that a packet table with VL datatypes of
- * compound datatypes can be created and written correctly. (HDFFV-442)
+ * compound datatypes can be created and written correctly. (HDFFV-442)
*
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int testfl_VLof_comptype(void)
+static int
+testfl_VLof_comptype(void)
{
/* Struct that the VL sequences are composed of */
typedef struct {
unsigned u;
- float f;
+ float f;
} VLcomp_t;
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */
- hid_t cmptype=H5I_INVALID_HID; /* Compound datatype */
- hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
- hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
- hsize_t count; /* Number of records in the table */
- unsigned uu, vv; /* Loop variables */
- char msg[80]; /* For error message */
- herr_t ret;
-
- TESTING3(" with vlen of compound datatypes");
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t vltype = H5I_INVALID_HID; /* Variable length datatype */
+ hid_t cmptype = H5I_INVALID_HID; /* Compound datatype */
+ hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
+ hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
+ hsize_t count; /* Number of records in the table */
+ unsigned uu, vv; /* Loop variables */
+ char msg[80]; /* For error message */
+ herr_t ret;
+
+ HL_TESTING3(" with vlen of compound datatypes");
/* Allocate and initialize VL data to write (copied from C test) */
for (uu = 0; uu < NRECORDS; uu++) {
writeBuf[uu].p = HDmalloc((uu + 1) * sizeof(VLcomp_t));
- if(writeBuf[uu].p == NULL) {
- fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
+ if (writeBuf[uu].p == NULL) {
+ HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
goto error;
- }
+ }
writeBuf[uu].len = uu + 1;
for (vv = 0; vv < (uu + 1); vv++) {
((VLcomp_t *)writeBuf[uu].p)[vv].u = uu + vv;
((VLcomp_t *)writeBuf[uu].p)[vv].f = (float)(uu + vv) / 3.0F;
- } /* end for */
- } /* end for */
+ } /* end for */
+ } /* end for */
/* Open the file */
fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create the base compound type */
cmptype = H5Tcreate(H5T_COMPOUND, sizeof(VLcomp_t));
if (cmptype < 0)
- goto error;
+ goto error;
/* Insert fields */
ret = H5Tinsert(cmptype, "u", HOFFSET(VLcomp_t, u), H5T_NATIVE_UINT);
if (ret < 0)
- goto error;
+ goto error;
ret = H5Tinsert(cmptype, "f", HOFFSET(VLcomp_t, f), H5T_NATIVE_FLOAT);
if (ret < 0)
- goto error;
+ goto error;
/* Create a variable length type that uses the VLcomp_t as its base type */
vltype = H5Tvlen_create(cmptype);
if (vltype < 0)
- goto error;
+ goto error;
/* Create a packet table that uses a vlen datatype of compound datatype */
ptable = H5PTcreate_fl(fid, PT_VLEN_COMP, vltype, (hsize_t)1, 0);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Release the datatypes */
if (H5Tclose(cmptype) < 0)
- goto error;
+ goto error;
if (H5Tclose(vltype) < 0)
- goto error;
+ goto error;
/* Write the entire buffer to the packet table */
- ret = H5PTappend(ptable, (size_t)5, writeBuf );
+ ret = H5PTappend(ptable, (size_t)5, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Get the number of packets in the packet table, should be NRECORDS. */
ret = H5PTget_num_packets(ptable, &count);
if (ret < 0)
- goto error;
+ goto error;
- sprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
+ HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
VERIFY(count == NRECORDS, msg);
/* Read all five packets back */
- ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void*)readBuf );
+ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void *)readBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Compare data read in */
for (uu = 0; uu < NRECORDS; uu++) {
if (writeBuf[uu].len != readBuf[uu].len) {
- fprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].len=%zu, readBuf[%u].len=%zu\n",__LINE__, uu, writeBuf[uu].len, uu, readBuf[uu].len);
- continue;
- } /* write len != read len */
+ HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].len=%zu, readBuf[%u].len=%zu\n",
+ __LINE__, uu, writeBuf[uu].len, uu, readBuf[uu].len);
+ continue;
+ } /* write len != read len */
for (vv = 0; vv < (uu + 1); vv++) {
- if (((unsigned int *)writeBuf[uu].p)[vv] != ((unsigned int *)readBuf[uu].p)[vv] ) {
- fprintf(stderr, "VL data values don't match!, writeBuf[uu].p[%u]=%u, readBuf[uu].p[%u]=%u\n", vv, ((unsigned int *)writeBuf[uu].p)[vv], vv, ((unsigned int *)readBuf[uu].p)[vv]);
+ if (((unsigned int *)writeBuf[uu].p)[vv] != ((unsigned int *)readBuf[uu].p)[vv]) {
+ HDfprintf(stderr,
+ "VL data values don't match!, writeBuf[uu].p[%u]=%u, readBuf[uu].p[%u]=%u\n", vv,
+ ((unsigned int *)writeBuf[uu].p)[vv], vv, ((unsigned int *)readBuf[uu].p)[vv]);
continue;
- } /* write value != read value */
- }
+ } /* write value != read value */
+ }
} /* end for */
/* Free the buffers */
ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
if (ret < 0)
- goto error;
+ goto error;
ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (cmptype > 0) H5Tclose(cmptype);
- if (vltype > 0) H5Tclose(vltype);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
- if (fid > 0) H5Fclose(fid);
+ if (cmptype > 0)
+ H5Tclose(cmptype);
+ if (vltype > 0)
+ H5Tclose(vltype);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ if (fid > 0)
+ H5Fclose(fid);
H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
H5_FAILED();
@@ -1294,179 +1344,191 @@ error: /* An error has occurred. Clean up and exit. */
/*-------------------------------------------------------------------------
* testfl_compound_VL_VL(): Test that a packet table of compound datatypes
- * containing VL datatypes can be created and written
- * correctly. (HDFFV-442)
+ * containing VL datatypes can be created and written
+ * correctly. (HDFFV-442)
*
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int testfl_compound_VL_VLtype(void)
+static int
+testfl_compound_VL_VLtype(void)
{
/* Struct that the VL sequences are composed of */
typedef struct {
unsigned u;
- float f;
- hvl_t v;
+ float f;
+ hvl_t v;
} compVLVL_t;
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */
- hid_t vlofvl=H5I_INVALID_HID; /* Variable length datatype */
- hid_t comp_vlvl=H5I_INVALID_HID; /* ID of a compound datatype containing
- a VL of VL of atomic datatype */
- hsize_t count; /* Number of records in the table */
- compVLVL_t writeBuf[NRECORDS];/* Buffer to hold data to be written */
- compVLVL_t readBuf[NRECORDS]; /* Buffer to hold read data */
- hvl_t *t1, *t2;
- unsigned uu, vv, ww; /* Loop variables */
- char msg[80]; /* For error message */
- herr_t ret; /* Returned status from a callee */
-
- TESTING3(" with compound datatype containing vlen datatype");
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t vlatomic = H5I_INVALID_HID; /* Variable length datatype */
+ hid_t vlofvl = H5I_INVALID_HID; /* Variable length datatype */
+ hid_t comp_vlvl = H5I_INVALID_HID; /* ID of a compound datatype containing
+ a VL of VL of atomic datatype */
+ hsize_t count; /* Number of records in the table */
+ compVLVL_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
+ compVLVL_t readBuf[NRECORDS]; /* Buffer to hold read data */
+ hvl_t * t1, *t2;
+ unsigned uu, vv, ww; /* Loop variables */
+ char msg[80]; /* For error message */
+ herr_t ret; /* Returned status from a callee */
+
+ HL_TESTING3(" with compound datatype containing vlen datatype");
/* Allocate and initialize VL data to write (copied from C test) */
for (uu = 0; uu < NRECORDS; uu++) {
- writeBuf[uu].u = uu * 10;
- writeBuf[uu].f = (float)(uu * 20) / 3.0F;
+ writeBuf[uu].u = uu * 10;
+ writeBuf[uu].f = (float)(uu * 20) / 3.0F;
writeBuf[uu].v.p = HDmalloc((uu + L1_INCM) * sizeof(hvl_t));
if (writeBuf[uu].v.p == NULL) {
- fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
+ HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
goto error;
- }
+ }
writeBuf[uu].v.len = uu + L1_INCM;
- for (t1 = (hvl_t *)((writeBuf[uu].v).p), vv = 0; vv < (uu + L1_INCM); vv++, t1++)
- {
+ for (t1 = (hvl_t *)((writeBuf[uu].v).p), vv = 0; vv < (uu + L1_INCM); vv++, t1++) {
t1->p = HDmalloc((vv + L2_INCM) * sizeof(unsigned int));
- if (t1->p == NULL) {
- fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
- goto error;
- }
+ if (t1->p == NULL) {
+ HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
+ goto error;
+ }
t1->len = vv + L2_INCM;
for (ww = 0; ww < vv + L2_INCM; ww++)
- ((unsigned int*)t1->p)[ww] = uu * 100 + vv * 10 + ww;
+ ((unsigned int *)t1->p)[ww] = uu * 100 + vv * 10 + ww;
}
} /* end for */
/* Open the file */
fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create a VL datatype of an atomic type */
- vlatomic = H5Tvlen_create (H5T_NATIVE_UINT);
+ vlatomic = H5Tvlen_create(H5T_NATIVE_UINT);
if (vlatomic < 0)
- goto error;
+ goto error;
/* Create a VL datatype of the VL of atomic datatype */
- vlofvl = H5Tvlen_create (vlatomic);
+ vlofvl = H5Tvlen_create(vlatomic);
if (vlofvl < 0)
- goto error;
+ goto error;
/* Create the base compound type */
comp_vlvl = H5Tcreate(H5T_COMPOUND, sizeof(compVLVL_t));
if (comp_vlvl < 0)
- goto error;
+ goto error;
/* Insert fields: atomic, atomic, vlen */
ret = H5Tinsert(comp_vlvl, "u", HOFFSET(compVLVL_t, u), H5T_NATIVE_UINT);
if (ret < 0)
- goto error;
+ goto error;
ret = H5Tinsert(comp_vlvl, "f", HOFFSET(compVLVL_t, f), H5T_NATIVE_FLOAT);
if (ret < 0)
- goto error;
+ goto error;
ret = H5Tinsert(comp_vlvl, "v", HOFFSET(compVLVL_t, v), vlofvl);
if (ret < 0)
- goto error;
+ goto error;
/* Create a packet table that uses a compound datatype of vlen datatype */
ptable = H5PTcreate_fl(fid, PT_COMP_VLEN, comp_vlvl, (hsize_t)1, 0);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Release datatypes */
if (H5Tclose(vlatomic) < 0)
- goto error;
+ goto error;
if (H5Tclose(vlofvl) < 0)
- goto error;
+ goto error;
if (H5Tclose(comp_vlvl) < 0)
- goto error;
+ goto error;
/* Write the entire buffer to the packet table */
- ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf );
+ ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Get the number of packets in the packet table, should be NRECORDS. */
ret = H5PTget_num_packets(ptable, &count);
if (ret < 0)
- goto error;
+ goto error;
- sprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
+ HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
VERIFY(count == NRECORDS, msg);
/* Read all five packets back */
- ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void*)readBuf );
+ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void *)readBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Compare data read in */
for (uu = 0; uu < NRECORDS; uu++) {
if (writeBuf[uu].u != readBuf[uu].u) {
- fprintf(stderr, "Integer components don't match!, writeBuf[%u].u=%u, readBuf[%u].u=%u\n", uu, writeBuf[uu].u, uu, readBuf[uu].u);
+ HDfprintf(stderr, "Integer components don't match!, writeBuf[%u].u=%u, readBuf[%u].u=%u\n", uu,
+ writeBuf[uu].u, uu, readBuf[uu].u);
continue;
} /* end if */
if (!H5_FLT_ABS_EQUAL(writeBuf[uu].f, readBuf[uu].f)) {
- fprintf(stderr, "Float components don't match!, writeBuf[%u].f=%f, readBuf[%u].f=%f\n", uu, (double)writeBuf[uu].f, uu, (double)readBuf[uu].f);
+ HDfprintf(stderr, "Float components don't match!, writeBuf[%u].f=%f, readBuf[%u].f=%f\n", uu,
+ (double)writeBuf[uu].f, uu, (double)readBuf[uu].f);
continue;
} /* end if */
if (writeBuf[uu].v.len != readBuf[uu].v.len) {
- fprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].v.len=%zu, readBuf[%u].v.len=%zu\n", __LINE__, uu, writeBuf[uu].v.len, uu, readBuf[uu].v.len);
+ HDfprintf(stderr,
+ "%d: VL data length don't match!, writeBuf[%u].v.len=%zu, readBuf[%u].v.len=%zu\n",
+ __LINE__, uu, writeBuf[uu].v.len, uu, readBuf[uu].v.len);
continue;
} /* end if */
- for (t1 = (hvl_t *)(writeBuf[uu].v.p), t2 = (hvl_t *)(readBuf[uu].v.p), vv = 0; (size_t)vv < readBuf[uu].v.len; vv++, t1++, t2++) {
+ for (t1 = (hvl_t *)(writeBuf[uu].v.p), t2 = (hvl_t *)(readBuf[uu].v.p), vv = 0;
+ (size_t)vv < readBuf[uu].v.len; vv++, t1++, t2++) {
if (t1->len != t2->len) {
- fprintf(stderr, "%d: VL data length don't match!, uu=%u, vv=%u, t1->len=%zu, t2->len=%zu\n", __LINE__, uu, vv, t1->len, t2->len);
+ HDfprintf(stderr, "%d: VL data length don't match!, uu=%u, vv=%u, t1->len=%zu, t2->len=%zu\n",
+ __LINE__, uu, vv, t1->len, t2->len);
continue;
} /* end if */
for (ww = 0; (size_t)ww < t2->len; ww++) {
- if (((unsigned int *)t1->p)[ww] != ((unsigned int *)t2->p)[ww] ) {
- fprintf(stderr, "VL data values don't match!, t1->p[%u]=%u, t2->p[%u]=%u\n", ww, ((unsigned int *)t1->p)[ww], ww, ((unsigned int *)t2->p)[ww]);
+ if (((unsigned int *)t1->p)[ww] != ((unsigned int *)t2->p)[ww]) {
+ HDfprintf(stderr, "VL data values don't match!, t1->p[%u]=%u, t2->p[%u]=%u\n", ww,
+ ((unsigned int *)t1->p)[ww], ww, ((unsigned int *)t2->p)[ww]);
continue;
} /* end if */
- } /* end for */
- } /* end for */
- } /* end for */
+ } /* end for */
+ } /* end for */
+ } /* end for */
/* Free the buffers */
ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
if (ret < 0)
- goto error;
+ goto error;
ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (vlatomic > 0) H5Tclose(vlatomic);
- if (vlofvl > 0) H5Tclose(vlofvl);
- if (comp_vlvl > 0) H5Tclose(comp_vlvl);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
- if (fid > 0) H5Fclose(fid);
+ if (vlatomic > 0)
+ H5Tclose(vlatomic);
+ if (vlofvl > 0)
+ H5Tclose(vlofvl);
+ if (comp_vlvl > 0)
+ H5Tclose(comp_vlvl);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ if (fid > 0)
+ H5Fclose(fid);
H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
H5_FAILED();
@@ -1475,119 +1537,123 @@ error: /* An error has occurred. Clean up and exit. */
/*-------------------------------------------------------------------------
* testfl_VLof_VLtype(): Test that a packet table of VL datatype with VL
- * datatypes of atomic datatypes can be created and written
- * correctly. (HDFFV-442)
+ * datatypes of atomic datatypes can be created and written
+ * correctly. (HDFFV-442)
*
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int testfl_VLof_VLtype(void)
+static int
+testfl_VLof_VLtype(void)
{
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */
- hid_t vlofvl=H5I_INVALID_HID; /* VL datatype of VL datatypes */
- hsize_t count; /* Number of records in the table */
- hvl_t *t1; /* pointer to advance */
- unsigned uu, vv, ww; /* Loop variables */
- hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
- hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
- char msg[80]; /* For error message */
- herr_t ret; /* Returned status from a callee */
-
- TESTING3(" with vlen datatype of vlen datatype");
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t vlatomic = H5I_INVALID_HID; /* Variable length datatype */
+ hid_t vlofvl = H5I_INVALID_HID; /* VL datatype of VL datatypes */
+ hsize_t count; /* Number of records in the table */
+ hvl_t * t1; /* pointer to advance */
+ unsigned uu, vv, ww; /* Loop variables */
+ hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
+ hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
+ char msg[80]; /* For error message */
+ herr_t ret; /* Returned status from a callee */
+
+ HL_TESTING3(" with vlen datatype of vlen datatype");
/* Allocate and initialize VL data to write (copied from C test) */
for (uu = 0; uu < NRECORDS; uu++) {
writeBuf[uu].p = HDmalloc((uu + 1) * sizeof(hvl_t));
if (writeBuf[uu].p == NULL) {
- fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
+ HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
goto error;
} /* end if */
writeBuf[uu].len = uu + 1;
- for (t1 = (hvl_t *)(writeBuf[uu].p), vv = 0; vv < (uu + 1); vv++, t1++)
- {
+ for (t1 = (hvl_t *)(writeBuf[uu].p), vv = 0; vv < (uu + 1); vv++, t1++) {
t1->p = HDmalloc((vv + 1) * sizeof(unsigned int));
- if (t1->p == NULL) {
- fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
- goto error;
- }
+ if (t1->p == NULL) {
+ HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
+ goto error;
+ }
t1->len = vv + 1;
for (ww = 0; ww < (vv + 1); ww++)
((unsigned int *)t1->p)[ww] = uu * 100 + vv * 10 + ww;
} /* end for */
- } /* end for */
+ } /* end for */
/* Open the file */
fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create a VL datatype of an atomic type */
- vlatomic = H5Tvlen_create (H5T_NATIVE_UINT);
+ vlatomic = H5Tvlen_create(H5T_NATIVE_UINT);
if (vlatomic < 0)
- goto error;
+ goto error;
- vlofvl = H5Tvlen_create (vlatomic);
+ vlofvl = H5Tvlen_create(vlatomic);
if (vlofvl < 0)
- goto error;
+ goto error;
/* Create a packet table that uses a vlen datatype of vlen datatype */
ptable = H5PTcreate_fl(fid, PT_VLEN_VLEN, vlofvl, (hsize_t)1, 0);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Release datatypes */
if (H5Tclose(vlatomic) < 0)
- goto error;
+ goto error;
if (H5Tclose(vlofvl) < 0)
- goto error;
+ goto error;
/* Write the entire buffer to the packet table */
- ret = H5PTappend(ptable, (size_t)5, writeBuf );
+ ret = H5PTappend(ptable, (size_t)5, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Get the number of packets in the packet table, should be NRECORDS. */
ret = H5PTget_num_packets(ptable, &count);
if (ret < 0)
- goto error;
+ goto error;
- sprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
+ HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
VERIFY(count == NRECORDS, msg);
/* Read all five packets back */
- ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void*)readBuf );
+ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void *)readBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Free the buffers */
ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
if (ret < 0)
- goto error;
+ goto error;
ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (vlatomic > 0) H5Tclose(vlatomic);
- if (vlofvl > 0) H5Tclose(vlofvl);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
- if (fid > 0) H5Fclose(fid);
+ if (vlatomic > 0)
+ H5Tclose(vlatomic);
+ if (vlofvl > 0)
+ H5Tclose(vlofvl);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ if (fid > 0)
+ H5Fclose(fid);
H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
H5_FAILED();
@@ -1596,25 +1662,26 @@ error: /* An error has occurred. Clean up and exit. */
/*-------------------------------------------------------------------------
* test_packet_table_with_varlen(): Invokes individual tests to ensure that
- * packet tables with variable length are created and written correctly
- * without the specific VL PT functionality. (HDFFV-442)
+ * packet tables with variable length are created and written correctly
+ * without the specific VL PT functionality. (HDFFV-442)
*
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-int test_packet_table_with_varlen(void)
+int
+test_packet_table_with_varlen(void)
{
- hid_t fid=H5I_INVALID_HID; /* File identifier */
- int status = SUCCEED;
+ hid_t fid = H5I_INVALID_HID; /* File identifier */
+ int status = SUCCEED;
/* Create a file using default properties */
fid = H5Fcreate(TEST_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
if (fid < 0)
- return FAIL;
+ return FAIL;
/* Close the file. The file will be opened by each test function below */
if (H5Fclose(fid) < 0)
- return FAIL;
+ return FAIL;
HDputs("Testing packet table with various variable-length datatypes");
@@ -1623,46 +1690,46 @@ int test_packet_table_with_varlen(void)
/* Test variable length of a simple type */
if (test_VLof_atomic() < 0)
- status = FAIL;
+ status = FAIL;
/* Test variable length of a compound type */
if (test_VLof_comptype() < 0)
- status = FAIL;
+ status = FAIL;
/* Test compound type with variable length */
if (test_compound_VL_VLtype() < 0)
- status = FAIL;
+ status = FAIL;
/* Test variable length of a variable length */
if (test_VLof_VLtype() < 0)
- status = FAIL;
+ status = FAIL;
/* Test variable length of a variable length */
if (test_H5PTis_varlen() < 0)
- status = FAIL;
+ status = FAIL;
/* Test adding attributes to packet table */
if (test_attributes() < 0)
- status = FAIL;
+ status = FAIL;
/* Test accessor functions */
if (test_accessors() < 0)
- status = FAIL;
+ status = FAIL;
-/**************************************************************************
- Calling test functions for deprecated function H5PTcreate_fl
- Mar 2016, -BMR
+ /**************************************************************************
+ Calling test functions for deprecated function H5PTcreate_fl
+ Mar 2016, -BMR
-**************************************************************************/
+ **************************************************************************/
/* Create a file using default properties */
fid = H5Fcreate(TESTFL_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
if (fid < 0)
- return FAIL;
+ return FAIL;
/* Close the file. The file will be opened by each test function below */
if (H5Fclose(fid) < 0)
- return FAIL;
+ return FAIL;
HDputs("Testing packet table with various variable-length datatypes - H5PTcreate_fl");
@@ -1671,19 +1738,19 @@ int test_packet_table_with_varlen(void)
/* Test variable length of a simple type */
if (testfl_VLof_atomic() < 0)
- status = FAIL;
+ status = FAIL;
/* Test variable length of a compound type */
if (testfl_VLof_comptype() < 0)
- status = FAIL;
+ status = FAIL;
/* Test compound type with variable length */
if (testfl_compound_VL_VLtype() < 0)
- status = FAIL;
+ status = FAIL;
/* Test variable length of a variable length */
if (testfl_VLof_VLtype() < 0)
- status = FAIL;
+ status = FAIL;
- return(status);
+ return (status);
}
diff --git a/hl/test/test_table.c b/hl/test/test_table.c
index ff9c0eb..b462ec1 100644
--- a/hl/test/test_table.c
+++ b/hl/test/test_table.c
@@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* 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 *
+ * 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. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdlib.h>
#include <string.h>
@@ -17,48 +17,44 @@
#include "H5srcdir.h"
#include "H5TBpublic.h"
-#define TEST_FILE_BE "test_table_be.h5"
-#define TEST_FILE_LE "test_table_le.h5"
+#define TEST_FILE_BE "test_table_be.h5"
+#define TEST_FILE_LE "test_table_le.h5"
#define TEST_FILE_CRAY "test_table_cray.h5"
-
/*-------------------------------------------------------------------------
-* Table API test
-*
-* Functions tested:
-*
-* H5TBmake_table
-* H5TBread_table
-* H5TBwrite_records
-* H5TBread_records
-* H5TBappend_records
-* H5TBinsert_record
-* H5TBdelete_record
-* H5TBcombine_tables
-* H5TBwrite_fields_name
-* H5TBread_fields_name
-* H5TBwrite_fields_index
-* H5TBinsert_field
-* H5TBdelete_field
-* H5TBget_table_info
-* H5TBget_field_info
-*
-*-------------------------------------------------------------------------
-*/
-
-#define TITLE "Title"
-#define NFIELDS 5
-#define NRECORDS 8
-#define NRECORDS_ADD 3
-
-#define TESTING2(WHAT) {printf("%-70s", "Testing " WHAT); fflush(stdout);}
+ * Table API test
+ *
+ * Functions tested:
+ *
+ * H5TBmake_table
+ * H5TBread_table
+ * H5TBwrite_records
+ * H5TBread_records
+ * H5TBappend_records
+ * H5TBinsert_record
+ * H5TBdelete_record
+ * H5TBcombine_tables
+ * H5TBwrite_fields_name
+ * H5TBread_fields_name
+ * H5TBwrite_fields_index
+ * H5TBinsert_field
+ * H5TBdelete_field
+ * H5TBget_table_info
+ * H5TBget_field_info
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#define TITLE "Title"
+#define NFIELDS 5
+#define NRECORDS 8
+#define NRECORDS_ADD 3
/*-------------------------------------------------------------------------
-* structure used for all tests, a particle with properties
-*-------------------------------------------------------------------------
-*/
-typedef struct particle_t
-{
+ * structure used for all tests, a particle with properties
+ *-------------------------------------------------------------------------
+ */
+typedef struct particle_t {
char name[16];
long longi;
float pressure;
@@ -67,31 +63,28 @@ typedef struct particle_t
} particle_t;
/*-------------------------------------------------------------------------
-* a subset of particle_t, with latitude and longitude fields
-*-------------------------------------------------------------------------
-*/
-typedef struct position_t
-{
- long longi;
- int lati;
+ * a subset of particle_t, with latitude and longitude fields
+ *-------------------------------------------------------------------------
+ */
+typedef struct position_t {
+ long longi;
+ int lati;
} position_t;
/*-------------------------------------------------------------------------
-* a subset of particle_t, with name and pressure fields
-*-------------------------------------------------------------------------
-*/
-typedef struct namepressure_t
-{
- char name[16];
- float pressure;
+ * a subset of particle_t, with name and pressure fields
+ *-------------------------------------------------------------------------
+ */
+typedef struct namepressure_t {
+ char name[16];
+ float pressure;
} namepressure_t;
/*-------------------------------------------------------------------------
-* an extended particle, used in the insert field test
-*-------------------------------------------------------------------------
-*/
-typedef struct particle2_t
-{
+ * an extended particle, used in the insert field test
+ *-------------------------------------------------------------------------
+ */
+typedef struct particle2_t {
char name[16];
long longi;
float pressure;
@@ -101,11 +94,10 @@ typedef struct particle2_t
} particle2_t;
/*-------------------------------------------------------------------------
-* a particle with one field less, used in the delete field test
-*-------------------------------------------------------------------------
-*/
-typedef struct particle3_t
-{
+ * a particle with one field less, used in the delete field test
+ *-------------------------------------------------------------------------
+ */
+typedef struct particle3_t {
char name[16];
long longi;
double temperature;
@@ -117,47 +109,37 @@ typedef struct particle3_t
*-------------------------------------------------------------------------
*/
-/* Push current alignment rule forcing 4-byte alignment boundary
+/* Push current alignment rule forcing 4-byte alignment boundary
* to the internal stack ...
*/
-#pragma pack(push,4)
- typedef struct particle4_t {
- uint32_t state;
- double posx;
- double posy;
- float atx[3];
- float aty[3];
- float rro[2];
- } particle4_t;
-/*
+#pragma pack(push, 4)
+typedef struct particle4_t {
+ uint32_t state;
+ double posx;
+ double posy;
+ float atx[3];
+ float aty[3];
+ float rro[2];
+} particle4_t;
+/*
* ... and restore original alignment rules from stack
*/
#pragma pack(pop)
-
/*-------------------------------------------------------------------------
-* function to open an HDF5 file and return its file identifier
-*-------------------------------------------------------------------------
-*/
-static hid_t h5file_open(const char *fname, unsigned flags)
+ * function to open an HDF5 file and return its file identifier
+ *-------------------------------------------------------------------------
+ */
+static hid_t
+h5file_open(const char *fname, unsigned flags)
{
- hid_t fid; /* identifier for the file */
- char *srcdir = getenv("srcdir"); /* the source directory */
- char data_file[512]=""; /* buffer to hold name of existing file */
-
- /* compose the name of the file to open, using the srcdir, if appropriate */
- if (srcdir)
- {
- HDstrcpy(data_file,srcdir);
- HDstrcat(data_file,"/");
- }
- HDstrcat(data_file,fname);
+ hid_t fid; /* identifier for the file */
+ const char *data_file = H5_get_srcdir_filename(fname);
/* open */
- if ((fid = H5Fopen(data_file,flags,H5P_DEFAULT))<0)
- {
- HDfprintf(stderr,"Error: Cannot open file <%s>\n",data_file );
+ if ((fid = H5Fopen(data_file, flags, H5P_DEFAULT)) < 0) {
+ HDfprintf(stderr, "Error: Cannot open file <%s>\n", data_file);
HDexit(1);
}
@@ -165,74 +147,68 @@ static hid_t h5file_open(const char *fname, unsigned flags)
}
/*-------------------------------------------------------------------------
-* function that compares one particle
-*-------------------------------------------------------------------------
-*/
-static int cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf )
+ * function that compares one particle
+ *-------------------------------------------------------------------------
+ */
+static int
+cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf)
{
- if ( ( HDstrcmp( rbuf[i].name, wbuf[j].name ) != 0 ) ||
- rbuf[i].lati != wbuf[j].lati ||
- rbuf[i].longi != wbuf[j].longi ||
- !FLT_ABS_EQUAL(rbuf[i].pressure,wbuf[j].pressure) ||
- !DBL_ABS_EQUAL(rbuf[i].temperature,wbuf[j].temperature) )
- {
- HDfprintf(stderr,"read and write buffers have differences\n");
- HDfprintf(stderr,"%s %ld %f %f %d\n",
- rbuf[i].name,rbuf[i].longi,(double)rbuf[i].pressure,rbuf[i].temperature,rbuf[i].lati);
- HDfprintf(stderr,"%s %ld %f %f %d\n",
- wbuf[j].name,wbuf[j].longi,(double)wbuf[j].pressure,wbuf[j].temperature,wbuf[j].lati);
+ if ((HDstrcmp(rbuf[i].name, wbuf[j].name) != 0) || rbuf[i].lati != wbuf[j].lati ||
+ rbuf[i].longi != wbuf[j].longi || !H5_FLT_ABS_EQUAL(rbuf[i].pressure, wbuf[j].pressure) ||
+ !H5_DBL_ABS_EQUAL(rbuf[i].temperature, wbuf[j].temperature)) {
+ HDfprintf(stderr, "read and write buffers have differences\n");
+ HDfprintf(stderr, "%s %ld %f %f %d\n", rbuf[i].name, rbuf[i].longi, (double)rbuf[i].pressure,
+ rbuf[i].temperature, rbuf[i].lati);
+ HDfprintf(stderr, "%s %ld %f %f %d\n", wbuf[j].name, wbuf[j].longi, (double)wbuf[j].pressure,
+ wbuf[j].temperature, wbuf[j].lati);
return -1;
}
return 0;
}
/*-------------------------------------------------------------------------
-* function to compare deleted records
-*-------------------------------------------------------------------------
-*/
-static int compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords,
- particle_t *rbuf, particle_t *wbuf)
+ * function to compare deleted records
+ *-------------------------------------------------------------------------
+ */
+static int
+compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords, particle_t *rbuf, particle_t *wbuf)
{
- hsize_t i,j;
- for( i=0; i<rrecords; i++)
- {
- if (i<dstart)
- {
- if (cmp_par(i,i,rbuf,wbuf)<0)
+ hsize_t i, j;
+ for (i = 0; i < rrecords; i++) {
+ if (i < dstart) {
+ if (cmp_par(i, i, rbuf, wbuf) < 0)
return -1;
}
- else
- {
- j=i+drecords;
- if (cmp_par(i,j,rbuf,wbuf)<0)
+ else {
+ j = i + drecords;
+ if (cmp_par(i, j, rbuf, wbuf) < 0)
return -1;
}
}
return 0;
}
-
-
/*-------------------------------------------------------------------------
-* the test program
-*-------------------------------------------------------------------------
-*/
+ * the test program
+ *-------------------------------------------------------------------------
+ */
-static int test_table(hid_t fid, int do_write)
+static int
+test_table(hid_t fid, int do_write)
{
- hid_t fid1;
- hid_t fid2;
- hsize_t chunk_size=10;
- int compress=0;
- int *fill=NULL;
- particle_t fill1[1] = { {"no data",-1, -99.0f, -99.0f, -1} };
- int fill1_new[1] = { -100 };
- hsize_t position;
- char tname[20];
- hsize_t i, j;
+ hid_t fid1;
+ hid_t fid2;
+ hsize_t chunk_size = 10;
+ int compress = 0;
+ int * fill = NULL;
+ particle_t fill1[1] = {{"no data", -1, -99.0f, -99.0f, -1}};
+ int fill1_new[1] = {-100};
+ hsize_t position;
+ char tname[20];
+ hsize_t i, j;
/* write, read, append, delete, insert some records and fields */
- hsize_t FIELDS = NFIELDS;
- hsize_t RECORDS = NRECORDS;
+ hsize_t FIELDS = NFIELDS;
+ hsize_t RECORDS = NRECORDS;
hsize_t start;
hsize_t wstart;
hsize_t rstart;
@@ -246,210 +222,157 @@ static int test_table(hid_t fid, int do_write)
hsize_t drecords;
hsize_t nfields;
hsize_t rfields;
- hsize_t start1; /* record to start reading from 1st table */
- hsize_t start2; /* record to start writing in 2nd table */
+ hsize_t start1; /* record to start reading from 1st table */
+ hsize_t start2; /* record to start writing in 2nd table */
/* read, write, insert, append buffers */
- particle_t rbuf[NRECORDS+4];
+ particle_t rbuf[NRECORDS + 4];
particle2_t rbuf2[NRECORDS];
particle3_t rbuf3[NRECORDS];
- particle_t rbufc[NRECORDS*2];
- particle_t abuf[2]={{"eight",80,8.0f,80.0f,80},{"nine",90,9.0f,90.0f,90}};
- particle_t ibuf[2]={{"zero", 0, 0.0f, 0.0f, 0},{"zero", 0, 0.0f, 0.0f, 0}};
+ particle_t rbufc[NRECORDS * 2];
+ particle_t abuf[2] = {{"eight", 80, 8.0f, 80.0f, 80}, {"nine", 90, 9.0f, 90.0f, 90}};
+ particle_t ibuf[2] = {{"zero", 0, 0.0f, 0.0f, 0}, {"zero", 0, 0.0f, 0.0f, 0}};
particle_t wbufd[NRECORDS];
- particle_t wbuf[NRECORDS] = {
- {"zero", 0, 0.0f, 0.0f, 0,},
- {"one", 10, 1.0f, 10.0f, 10},
- {"two", 20, 2.0f, 20.0f, 20},
- {"three",30, 3.0f, 30.0f, 30},
- {"four", 40, 4.0f, 40.0f, 40},
- {"five", 50, 5.0f, 50.0f, 50},
- {"six", 60, 6.0f, 60.0f, 60},
- {"seven",70, 7.0f, 70.0f, 70}
- };
+ particle_t wbuf[NRECORDS] = {{
+ "zero",
+ 0,
+ 0.0f,
+ 0.0f,
+ 0,
+ },
+ {"one", 10, 1.0f, 10.0f, 10},
+ {"two", 20, 2.0f, 20.0f, 20},
+ {"three", 30, 3.0f, 30.0f, 30},
+ {"four", 40, 4.0f, 40.0f, 40},
+ {"five", 50, 5.0f, 50.0f, 50},
+ {"six", 60, 6.0f, 60.0f, 60},
+ {"seven", 70, 7.0f, 70.0f, 70}};
/* buffers for the field "Pressure" and "New_field" */
- float pressure_in [NRECORDS] = { 0.0f,1.0f,2.0f,3.0f,4.0f,5.0f,6.0f,7.0f };
- float pressure_out [NRECORDS];
- int buf_new[NRECORDS] = { 0,1,2,3,4,5,6,7 };
+ float pressure_in[NRECORDS] = {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f};
+ float pressure_out[NRECORDS];
+ int buf_new[NRECORDS] = {0, 1, 2, 3, 4, 5, 6, 7};
/* buffers for the fields "Latitude,Longitude" */
- position_t position_out[NRECORDS_ADD];
- position_t position_in[NRECORDS_ADD] = { {0,0},
- {10,10},
- {20,20}};
+ position_t position_out[NRECORDS_ADD];
+ position_t position_in[NRECORDS_ADD] = {{0, 0}, {10, 10}, {20, 20}};
/* buffers for the fields "Name,Pressure" */
- namepressure_t namepre_out[NRECORDS];
- namepressure_t namepre_in[NRECORDS] =
- { {"zero",0.0f},
- {"one", 1.0f},
- {"two", 2.0f},
- {"three", 3.0f},
- {"four", 4.0f},
- {"five", 5.0f},
- {"six", 6.0f},
- {"seven", 7.0f},
+ namepressure_t namepre_out[NRECORDS];
+ namepressure_t namepre_in[NRECORDS] = {
+ {"zero", 0.0f}, {"one", 1.0f}, {"two", 2.0f}, {"three", 3.0f},
+ {"four", 4.0f}, {"five", 5.0f}, {"six", 6.0f}, {"seven", 7.0f},
};
-
/*-------------------------------------------------------------------------
- * initialize table parameters
- * field offsets and sizes used in the fields functions
- *-------------------------------------------------------------------------
- */
-
- size_t field_offset_pos[2]=
- {
- HOFFSET( position_t, longi ),
- HOFFSET( position_t, lati )
- };
- size_t field_offset_namepre[2]=
- {
- HOFFSET( namepressure_t, name ),
- HOFFSET( namepressure_t, pressure )
- };
- size_t field_sizes_pos[2]=
- {
- sizeof(position_in[0].longi),
- sizeof(position_in[0].lati)
- };
- size_t field_sizes_namepre[2]=
- {
- sizeof(namepre_in[0].name),
- sizeof(namepre_in[0].pressure)
- };
- size_t field_sizes_pre[1]=
- {
- sizeof(namepre_in[0].pressure)
- };
+ * initialize table parameters
+ * field offsets and sizes used in the fields functions
+ *-------------------------------------------------------------------------
+ */
+
+ size_t field_offset_pos[2] = {HOFFSET(position_t, longi), HOFFSET(position_t, lati)};
+ size_t field_offset_namepre[2] = {HOFFSET(namepressure_t, name), HOFFSET(namepressure_t, pressure)};
+ size_t field_sizes_pos[2] = {sizeof(position_in[0].longi), sizeof(position_in[0].lati)};
+ size_t field_sizes_namepre[2] = {sizeof(namepre_in[0].name), sizeof(namepre_in[0].pressure)};
+ size_t field_sizes_pre[1] = {sizeof(namepre_in[0].pressure)};
/*-------------------------------------------------------------------------
- * query table test
- *-------------------------------------------------------------------------
- */
- char **names_out;
- size_t sizes_out[NFIELDS];
- size_t offset_out[NFIELDS];
- size_t size_out;
+ * query table test
+ *-------------------------------------------------------------------------
+ */
+ char **names_out;
+ size_t sizes_out[NFIELDS];
+ size_t offset_out[NFIELDS];
+ size_t size_out;
/*-------------------------------------------------------------------------
- * initialize table parameters
- * field indexes (zero based) used in the fields functions
- * "Name 0","Longitude 1","Pressure 2","Temperature 3","Latitude 4"
- *-------------------------------------------------------------------------
- */
- int field_index_pre[1] = { 2 };
- int field_index_pos[2] = { 1,4 };
- int field_index_namepre[2] = { 0,2 };
- int field_index[NFIELDS] = { 0,1,2,3,4 };
+ * initialize table parameters
+ * field indexes (zero based) used in the fields functions
+ * "Name 0","Longitude 1","Pressure 2","Temperature 3","Latitude 4"
+ *-------------------------------------------------------------------------
+ */
+ int field_index_pre[1] = {2};
+ int field_index_pos[2] = {1, 4};
+ int field_index_namepre[2] = {0, 2};
+ int field_index[NFIELDS] = {0, 1, 2, 3, 4};
/*-------------------------------------------------------------------------
- * initialize table parameters
- * size and the offsets of struct members in memory
- * define the inserted field HDF5 type and buffers
- * these are used for the insert field test
- *-------------------------------------------------------------------------
- */
- hid_t field_type_new = H5T_NATIVE_INT;
- size_t dst_size2 = sizeof( particle2_t );
- size_t dst_offset2[NFIELDS+1] = { HOFFSET( particle2_t, name ),
- HOFFSET( particle2_t, longi ),
- HOFFSET( particle2_t, pressure ),
- HOFFSET( particle2_t, temperature ),
- HOFFSET( particle2_t, lati ),
- HOFFSET( particle2_t, new_field )};
- size_t dst_sizes2[NFIELDS+1] = { sizeof( rbuf2[0].name),
- sizeof( rbuf2[0].longi),
- sizeof( rbuf2[0].pressure),
- sizeof( rbuf2[0].temperature),
- sizeof( rbuf2[0].lati),
- sizeof( rbuf2[0].new_field)};
+ * initialize table parameters
+ * size and the offsets of struct members in memory
+ * define the inserted field HDF5 type and buffers
+ * these are used for the insert field test
+ *-------------------------------------------------------------------------
+ */
+ hid_t field_type_new = H5T_NATIVE_INT;
+ size_t dst_size2 = sizeof(particle2_t);
+ size_t dst_offset2[NFIELDS + 1] = {HOFFSET(particle2_t, name), HOFFSET(particle2_t, longi),
+ HOFFSET(particle2_t, pressure), HOFFSET(particle2_t, temperature),
+ HOFFSET(particle2_t, lati), HOFFSET(particle2_t, new_field)};
+ size_t dst_sizes2[NFIELDS + 1] = {sizeof(rbuf2[0].name), sizeof(rbuf2[0].longi),
+ sizeof(rbuf2[0].pressure), sizeof(rbuf2[0].temperature),
+ sizeof(rbuf2[0].lati), sizeof(rbuf2[0].new_field)};
/*-------------------------------------------------------------------------
- * initialize table parameters
- * size and the offsets of struct members in memory
- * these are used for the delete field test
- *-------------------------------------------------------------------------
- */
- size_t dst_size3 = sizeof( particle3_t );
- size_t dst_offset3[NFIELDS-1] = { HOFFSET( particle3_t, name ),
- HOFFSET( particle3_t, longi ),
- HOFFSET( particle3_t, temperature ),
- HOFFSET( particle3_t, lati )};
-
- size_t dst_sizes3[NFIELDS-1] = { sizeof( rbuf3[0].name),
- sizeof( rbuf3[0].longi),
- sizeof( rbuf3[0].temperature),
- sizeof( rbuf3[0].lati)};
+ * initialize table parameters
+ * size and the offsets of struct members in memory
+ * these are used for the delete field test
+ *-------------------------------------------------------------------------
+ */
+ size_t dst_size3 = sizeof(particle3_t);
+ size_t dst_offset3[NFIELDS - 1] = {HOFFSET(particle3_t, name), HOFFSET(particle3_t, longi),
+ HOFFSET(particle3_t, temperature), HOFFSET(particle3_t, lati)};
+
+ size_t dst_sizes3[NFIELDS - 1] = {sizeof(rbuf3[0].name), sizeof(rbuf3[0].longi),
+ sizeof(rbuf3[0].temperature), sizeof(rbuf3[0].lati)};
/*-------------------------------------------------------------------------
- * initialize table parameters
- * size and the offsets of struct members in memory
- * these are used for the delete field test with differing memory layout
- *-------------------------------------------------------------------------
- */
+ * initialize table parameters
+ * size and the offsets of struct members in memory
+ * these are used for the delete field test with differing memory layout
+ *-------------------------------------------------------------------------
+ */
/* Calculate the size and the offsets of our struct members in memory */
- size_t tbl_size = sizeof(particle4_t);
- size_t tbl_offset[NFIELDS+1] = { HOFFSET(particle4_t, state),
- HOFFSET(particle4_t, posx),
- HOFFSET(particle4_t, posy),
- HOFFSET(particle4_t, atx),
- HOFFSET(particle4_t, aty),
- HOFFSET(particle4_t, rro)
- };
+ size_t tbl_size = sizeof(particle4_t);
+ size_t tbl_offset[NFIELDS + 1] = {HOFFSET(particle4_t, state), HOFFSET(particle4_t, posx),
+ HOFFSET(particle4_t, posy), HOFFSET(particle4_t, atx),
+ HOFFSET(particle4_t, aty), HOFFSET(particle4_t, rro)};
/* Define an array of Particles */
- particle4_t p_data[NRECORDS] = {
- {12112, 1.4f, 2.5f, {1,2,3},{4,5,6}, {99,100}},
- {12113, 1.4f, 2.5f, {1,2,3},{4,5,6}, {99,100}},
- {12114, 1.4f, 2.5f, {1,2,3},{4,5,6}, {99,100}},
- {12115, 1.4f, 2.5f, {1,2,3},{4,5,6}, {99,100}},
- {12116, 1.4f, 2.5f, {1,2,3},{4,5,6}, {99,100}},
- {12117, 1.4f, 2.5f, {1,2,3},{4,5,6}, {99,100}},
- {12118, 1.4f, 2.5f, {1,2,3},{4,5,6}, {99,100}},
- {12119, 1.4f, 2.5f, {1,2,3},{4,5,6}, {99,100}}
- };
+ particle4_t p_data[NRECORDS] = {{12112, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12113, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12114, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12115, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12116, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12117, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12118, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12119, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}}};
/*-------------------------------------------------------------------------
- * initialize table parameters
- * 1) size and the offsets of struct members in memory
- * 2) field names
- * 3) define a HDF5 type for the fields
- *-------------------------------------------------------------------------
- */
-
- size_t type_size_mem = sizeof( particle_t );
- size_t field_offset[NFIELDS]=
- {
- HOFFSET( particle_t, name ),
- HOFFSET( particle_t, longi ),
- HOFFSET( particle_t, pressure ),
- HOFFSET( particle_t, temperature ),
- HOFFSET( particle_t, lati )
- };
- size_t field_size[NFIELDS] =
- {
- sizeof( rbuf[0].name),
- sizeof( rbuf[0].longi),
- sizeof( rbuf[0].pressure),
- sizeof( rbuf[0].temperature),
- sizeof( rbuf[0].lati)
- };
+ * initialize table parameters
+ * 1) size and the offsets of struct members in memory
+ * 2) field names
+ * 3) define a HDF5 type for the fields
+ *-------------------------------------------------------------------------
+ */
- const char *field_names4[NFIELDS+1] =
- { "F1", "F2", "F3", "F4", "F5", "F6"};
- hid_t field_type4[NFIELDS+1];
- particle4_t fill_data[1] = { {9999999, -9999999, 999999, {999,999,999},{999,999,999}, {999,999}} };
+ size_t type_size_mem = sizeof(particle_t);
+ size_t field_offset[NFIELDS] = {HOFFSET(particle_t, name), HOFFSET(particle_t, longi),
+ HOFFSET(particle_t, pressure), HOFFSET(particle_t, temperature),
+ HOFFSET(particle_t, lati)};
+ size_t field_size[NFIELDS] = {sizeof(rbuf[0].name), sizeof(rbuf[0].longi), sizeof(rbuf[0].pressure),
+ sizeof(rbuf[0].temperature), sizeof(rbuf[0].lati)};
- hsize_t nfields_out;
- hsize_t nrecords_out;
- hid_t arry3_32f;
- hid_t arry2_32f;
- hsize_t dims;
+ const char *field_names4[NFIELDS + 1] = {"F1", "F2", "F3", "F4", "F5", "F6"};
+ hid_t field_type4[NFIELDS + 1];
+ particle4_t fill_data[1] = {{9999999, -9999999, 999999, {999, 999, 999}, {999, 999, 999}, {999, 999}}};
- const char *field_names[NFIELDS] =
- { "Name","Longitude","Pressure","Temperature","Latitude" };
- hid_t field_type[NFIELDS];
- hid_t string_type = H5Tcopy( H5T_C_S1 );
+ hsize_t nfields_out;
+ hsize_t nrecords_out;
+ hid_t arry3_32f;
+ hid_t arry2_32f;
+ hsize_t dims;
- H5Tset_size( string_type, 16 );
+ const char *field_names[NFIELDS] = {"Name", "Longitude", "Pressure", "Temperature", "Latitude"};
+ hid_t field_type[NFIELDS];
+ hid_t string_type = H5Tcopy(H5T_C_S1);
+
+ H5Tset_size(string_type, 16);
field_type[0] = string_type;
field_type[1] = H5T_NATIVE_LONG;
field_type[2] = H5T_NATIVE_FLOAT;
@@ -457,83 +380,76 @@ static int test_table(hid_t fid, int do_write)
field_type[4] = H5T_NATIVE_INT;
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBmake_table
- * H5TBread_table
- *
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
- TESTING2("making table");
+ *
+ * Functions tested:
+ *
+ * H5TBmake_table
+ * H5TBread_table
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
+ HL_TESTING2("making table");
- if (H5TBmake_table(TITLE,fid,"table1",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid, "table1", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbuf) < 0)
goto out;
PASSED();
}
- TESTING2("reading table");
+ HL_TESTING2("reading table");
/*-------------------------------------------------------------------------
- * read the table
- *-------------------------------------------------------------------------
- */
+ * read the table
+ *-------------------------------------------------------------------------
+ */
- if (H5TBread_table(fid,"table1",type_size_mem,field_offset,field_size,rbuf)<0)
+ if (H5TBread_table(fid, "table1", type_size_mem, field_offset, field_size, rbuf) < 0)
goto out;
/* compare the extracted table with the original array */
- for( i = 0; i < NRECORDS; i++ )
- {
- if (cmp_par(i,i,rbuf,wbuf)<0)
+ for (i = 0; i < NRECORDS; i++) {
+ if (cmp_par(i, i, rbuf, wbuf) < 0)
goto out;
}
PASSED();
-
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBwrite_records
- *
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
- TESTING2("writing records");
+ *
+ * Functions tested:
+ *
+ * H5TBwrite_records
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
+ HL_TESTING2("writing records");
/* create an empty table */
- if (H5TBmake_table(TITLE,fid,"table2",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,0)<0)
+ if (H5TBmake_table(TITLE, fid, "table2", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, 0) < 0)
goto out;
/*-------------------------------------------------------------------------
- * write records, start at 0, write 8
- * pos = 0 1 2 3 4 5 6 7
- * data= 0 1 2 3 4 5 6 7
- *-------------------------------------------------------------------------
- */
- wstart=0;
- wrecords=8;
- if (H5TBwrite_records(fid,"table2",wstart,wrecords,type_size_mem,field_offset,
- field_size,wbuf)<0)
+ * write records, start at 0, write 8
+ * pos = 0 1 2 3 4 5 6 7
+ * data= 0 1 2 3 4 5 6 7
+ *-------------------------------------------------------------------------
+ */
+ wstart = 0;
+ wrecords = 8;
+ if (H5TBwrite_records(fid, "table2", wstart, wrecords, type_size_mem, field_offset, field_size,
+ wbuf) < 0)
goto out;
/* read it back */
- if (H5TBread_table(fid,"table2",type_size_mem,field_offset,field_size,rbuf)<0)
+ if (H5TBread_table(fid, "table2", type_size_mem, field_offset, field_size, rbuf) < 0)
goto out;
/* compare */
- for( i = 0; i < NRECORDS; i++ )
- {
- if (cmp_par(i,i,rbuf,wbuf)<0)
+ for (i = 0; i < NRECORDS; i++) {
+ if (cmp_par(i, i, rbuf, wbuf) < 0)
goto out;
}
@@ -541,147 +457,139 @@ static int test_table(hid_t fid, int do_write)
}
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBread_records
- *
- *-------------------------------------------------------------------------
- */
+ *
+ * Functions tested:
+ *
+ * H5TBread_records
+ *
+ *-------------------------------------------------------------------------
+ */
- TESTING2("reading records");
+ HL_TESTING2("reading records");
/*-------------------------------------------------------------------------
- * read records, start at 0, read 8
- * pos = 0 1 2 3 4 5 6 7
- * data= 0 1 2 3 4 5 6 7
- *-------------------------------------------------------------------------
- */
+ * read records, start at 0, read 8
+ * pos = 0 1 2 3 4 5 6 7
+ * data= 0 1 2 3 4 5 6 7
+ *-------------------------------------------------------------------------
+ */
/*-------------------------------------------------------------------------
- * for the read test we cannot use "table2" because it has been appended
- * we use the original "table1" instead
- *-------------------------------------------------------------------------
- */
- if(do_write)
- HDstrcpy(tname,"table2");
+ * for the read test we cannot use "table2" because it has been appended
+ * we use the original "table1" instead
+ *-------------------------------------------------------------------------
+ */
+ if (do_write)
+ HDstrcpy(tname, "table2");
else
- HDstrcpy(tname,"table1");
+ HDstrcpy(tname, "table1");
- rstart=0;
- rrecords=8;
- if (H5TBread_records(fid,tname,rstart,rrecords,type_size_mem,field_offset,
- field_size,rbuf)<0)
+ rstart = 0;
+ rrecords = 8;
+ if (H5TBread_records(fid, tname, rstart, rrecords, type_size_mem, field_offset, field_size, rbuf) < 0)
goto out;
/* compare */
- for( i = rstart; i < rrecords; i++)
- {
- if (cmp_par(i,i,rbuf,wbuf)<0)
+ for (i = rstart; i < rrecords; i++) {
+ if (cmp_par(i, i, rbuf, wbuf) < 0)
goto out;
}
PASSED();
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBappend_records
- * H5TBread_records
- *
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
- TESTING2("appending records");
+ *
+ * Functions tested:
+ *
+ * H5TBappend_records
+ * H5TBread_records
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
+ HL_TESTING2("appending records");
/*-------------------------------------------------------------------------
- * append 2 records
- * pos = 0 1 2 3 4 5 6 7 8 9
- * data= 0 1 2 3 4 5 6 7 8 9
- *-------------------------------------------------------------------------
- */
- arecords=2;
- if (H5TBappend_records(fid,"table2",arecords,type_size_mem,field_offset,field_size,abuf)<0)
+ * append 2 records
+ * pos = 0 1 2 3 4 5 6 7 8 9
+ * data= 0 1 2 3 4 5 6 7 8 9
+ *-------------------------------------------------------------------------
+ */
+ arecords = 2;
+ if (H5TBappend_records(fid, "table2", arecords, type_size_mem, field_offset, field_size, abuf) < 0)
return 1;
- if (H5TBget_table_info(fid,"table2",&rfields,&rrecords)<0)
+ if (H5TBget_table_info(fid, "table2", &rfields, &rrecords) < 0)
return 1;
- rstart=0; rrecords=NRECORDS+arecords;
- if (H5TBread_records(fid,"table2",rstart,rrecords,type_size_mem,field_offset,
- field_size,rbuf)<0)
+ rstart = 0;
+ rrecords = NRECORDS + arecords;
+ if (H5TBread_records(fid, "table2", rstart, rrecords, type_size_mem, field_offset, field_size, rbuf) <
+ 0)
return 1;
/* compare */
- wrecords=8;
- for( i = rstart; i< wrecords; i++)
- {
- if (cmp_par(i,i,rbuf,wbuf)<0)
+ wrecords = 8;
+ for (i = rstart; i < wrecords; i++) {
+ if (cmp_par(i, i, rbuf, wbuf) < 0)
goto out;
}
- for( i = wrecords, j = 0; i < rrecords; i++,j++)
- {
- if (cmp_par(i,j,rbuf,abuf)<0)
+ for (i = wrecords, j = 0; i < rrecords; i++, j++) {
+ if (cmp_par(i, j, rbuf, abuf) < 0)
goto out;
}
PASSED();
}
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBinsert_record
- * H5TBread_records
- *
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
- TESTING2("inserting records");
+ *
+ * Functions tested:
+ *
+ * H5TBinsert_record
+ * H5TBread_records
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
+ HL_TESTING2("inserting records");
/*-------------------------------------------------------------------------
- * insert 2 records
- * pos = 0 1 2 3 4 5 6 7 8 9 10 11
- * data= 0 0 0 1 2 3 4 5 6 7 8 9
- *-------------------------------------------------------------------------
- */
- istart=1; irecords=2;
- if (H5TBinsert_record(fid,"table2",istart,irecords,type_size_mem,field_offset,field_size,ibuf)<0)
+ * insert 2 records
+ * pos = 0 1 2 3 4 5 6 7 8 9 10 11
+ * data= 0 0 0 1 2 3 4 5 6 7 8 9
+ *-------------------------------------------------------------------------
+ */
+ istart = 1;
+ irecords = 2;
+ if (H5TBinsert_record(fid, "table2", istart, irecords, type_size_mem, field_offset, field_size,
+ ibuf) < 0)
return 1;
- if (H5TBget_table_info(fid,"table2",&rfields,&rrecords)<0)
+ if (H5TBget_table_info(fid, "table2", &rfields, &rrecords) < 0)
return 1;
- if (H5TBread_records(fid,"table2",rstart,rrecords,type_size_mem,field_offset,
- field_size,rbuf)<0)
+ if (H5TBread_records(fid, "table2", rstart, rrecords, type_size_mem, field_offset, field_size, rbuf) <
+ 0)
return 1;
/* compare */
- for( i = 0; i < 12; i++)
- {
- if (i < istart)
- {
- if (cmp_par(i,i,rbuf,wbuf)<0)
+ for (i = 0; i < 12; i++) {
+ if (i < istart) {
+ if (cmp_par(i, i, rbuf, wbuf) < 0)
goto out;
}
- else if (i >= istart && i < istart + irecords)
- {
+ else if (i >= istart && i < istart + irecords) {
j = i - istart;
- if (cmp_par(i,j,rbuf,ibuf)<0)
+ if (cmp_par(i, j, rbuf, ibuf) < 0)
goto out;
}
- else if ( i >= istart + irecords && i < 10 )
- {
+ else if (i >= istart + irecords && i < 10) {
j = i - irecords;
- if (cmp_par(i,j,rbuf,wbuf)<0)
+ if (cmp_par(i, j, rbuf, wbuf) < 0)
goto out;
}
- else
- {
+ else {
j = i - 10;
- if (cmp_par(i,j,rbuf,abuf)<0)
+ if (cmp_par(i, j, rbuf, abuf) < 0)
goto out;
}
}
@@ -689,198 +597,192 @@ static int test_table(hid_t fid, int do_write)
}
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBdelete_record
- * H5TBread_records
- *
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
- TESTING2("deleting records");
+ *
+ * Functions tested:
+ *
+ * H5TBdelete_record
+ * H5TBread_records
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
+ HL_TESTING2("deleting records");
/*-------------------------------------------------------------------------
- * Create a table
- * pos = 0 1 2 3 4 5 6 7
- * data= 0 1 2 3 4 5 6 7
- *-------------------------------------------------------------------------
- */
-
- for( i=0; i<NRECORDS; i++)
- {
- wbufd[i].lati = wbuf[i].lati;
- wbufd[i].longi = wbuf[i].longi;
- wbufd[i].pressure = wbuf[i].pressure;
+ * Create a table
+ * pos = 0 1 2 3 4 5 6 7
+ * data= 0 1 2 3 4 5 6 7
+ *-------------------------------------------------------------------------
+ */
+
+ for (i = 0; i < NRECORDS; i++) {
+ wbufd[i].lati = wbuf[i].lati;
+ wbufd[i].longi = wbuf[i].longi;
+ wbufd[i].pressure = wbuf[i].pressure;
wbufd[i].temperature = wbuf[i].temperature;
- HDstrcpy(wbufd[i].name, wbuf[i].name );
-
+ HDstrcpy(wbufd[i].name, wbuf[i].name);
}
-
- if (H5TBmake_table(TITLE,fid,"table3",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbufd)<0)
+ if (H5TBmake_table(TITLE, fid, "table3", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbufd) < 0)
goto out;
/*-------------------------------------------------------------------------
- * Delete records, start at 2, delete 3
- * pos = 0 1 2 3 4
- * data= 0 1 5 6 7
- *-------------------------------------------------------------------------
- */
- dstart=2; drecords=3;
- if (H5TBdelete_record(fid,"table3",dstart,drecords)<0)
+ * Delete records, start at 2, delete 3
+ * pos = 0 1 2 3 4
+ * data= 0 1 5 6 7
+ *-------------------------------------------------------------------------
+ */
+ dstart = 2;
+ drecords = 3;
+ if (H5TBdelete_record(fid, "table3", dstart, drecords) < 0)
goto out;
- if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0)
+ if (H5TBget_table_info(fid, "table3", &rfields, &rrecords) < 0)
goto out;
- rstart=0;
- if (H5TBread_records(fid,"table3",rstart,rrecords,type_size_mem,field_offset,
- field_size,rbuf)<0)
+ rstart = 0;
+ if (H5TBread_records(fid, "table3", rstart, rrecords, type_size_mem, field_offset, field_size, rbuf) <
+ 0)
goto out;
/* compare */
- nrecords=NRECORDS;
- assert(rrecords == nrecords-drecords);
- if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0)
+ nrecords = NRECORDS;
+ assert(rrecords == nrecords - drecords);
+ if (compare_deleted(rrecords, dstart, drecords, rbuf, wbufd) < 0)
goto out;
/*-------------------------------------------------------------------------
- * reset compare buffer
- *-------------------------------------------------------------------------
- */
- nrecords=rrecords;
- for( i=0; i<nrecords; i++)
- {
+ * reset compare buffer
+ *-------------------------------------------------------------------------
+ */
+ nrecords = rrecords;
+ for (i = 0; i < nrecords; i++) {
wbufd[i] = rbuf[i];
}
/*-------------------------------------------------------------------------
- * Delete records, start at 0, delete 2
- * pos = 0 1 2
- * data= 5 6 7
- *-------------------------------------------------------------------------
- */
- dstart=0; drecords=2;
- if (H5TBdelete_record(fid,"table3",dstart,drecords)<0)
+ * Delete records, start at 0, delete 2
+ * pos = 0 1 2
+ * data= 5 6 7
+ *-------------------------------------------------------------------------
+ */
+ dstart = 0;
+ drecords = 2;
+ if (H5TBdelete_record(fid, "table3", dstart, drecords) < 0)
goto out;
- if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0)
+ if (H5TBget_table_info(fid, "table3", &rfields, &rrecords) < 0)
goto out;
- rstart=0;
- if (H5TBread_records(fid,"table3",rstart,rrecords,type_size_mem,field_offset,
- field_size,rbuf)<0)
+ rstart = 0;
+ if (H5TBread_records(fid, "table3", rstart, rrecords, type_size_mem, field_offset, field_size, rbuf) <
+ 0)
goto out;
/* Compare */
- assert(rrecords == nrecords-drecords);
- if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0)
+ assert(rrecords == nrecords - drecords);
+ if (compare_deleted(rrecords, dstart, drecords, rbuf, wbufd) < 0)
goto out;
/*-------------------------------------------------------------------------
- * reset compare buffer
- *-------------------------------------------------------------------------
- */
- nrecords=rrecords;
- for( i=0; i<nrecords; i++)
- {
+ * reset compare buffer
+ *-------------------------------------------------------------------------
+ */
+ nrecords = rrecords;
+ for (i = 0; i < nrecords; i++) {
wbufd[i] = rbuf[i];
}
/*-------------------------------------------------------------------------
- * Delete records, start at 1, delete 1
- * pos = 0 1
- * data= 5 7
- *-------------------------------------------------------------------------
- */
- dstart=1; drecords=1;
- if (H5TBdelete_record(fid,"table3",dstart,drecords)<0)
+ * Delete records, start at 1, delete 1
+ * pos = 0 1
+ * data= 5 7
+ *-------------------------------------------------------------------------
+ */
+ dstart = 1;
+ drecords = 1;
+ if (H5TBdelete_record(fid, "table3", dstart, drecords) < 0)
goto out;
- if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0)
+ if (H5TBget_table_info(fid, "table3", &rfields, &rrecords) < 0)
goto out;
- rstart=0;
- if (H5TBread_records(fid,"table3",rstart,rrecords,type_size_mem,field_offset,
- field_size,rbuf)<0)
+ rstart = 0;
+ if (H5TBread_records(fid, "table3", rstart, rrecords, type_size_mem, field_offset, field_size, rbuf) <
+ 0)
goto out;
/* Compare */
- assert(rrecords == nrecords-drecords);
- if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0)
+ assert(rrecords == nrecords - drecords);
+ if (compare_deleted(rrecords, dstart, drecords, rbuf, wbufd) < 0)
goto out;
/*-------------------------------------------------------------------------
- * reset compare buffer
- *-------------------------------------------------------------------------
- */
- nrecords=rrecords;
- for( i=0; i<nrecords; i++)
- {
+ * reset compare buffer
+ *-------------------------------------------------------------------------
+ */
+ nrecords = rrecords;
+ for (i = 0; i < nrecords; i++) {
wbufd[i] = rbuf[i];
}
/*-------------------------------------------------------------------------
- * Delete records, start at 0, delete 1
- * pos = 0
- * data= 7
- *-------------------------------------------------------------------------
- */
- dstart=0; drecords=1;
- if (H5TBdelete_record(fid,"table3",dstart,drecords)<0)
+ * Delete records, start at 0, delete 1
+ * pos = 0
+ * data= 7
+ *-------------------------------------------------------------------------
+ */
+ dstart = 0;
+ drecords = 1;
+ if (H5TBdelete_record(fid, "table3", dstart, drecords) < 0)
goto out;
- if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0)
+ if (H5TBget_table_info(fid, "table3", &rfields, &rrecords) < 0)
goto out;
- rstart=0;
- if (H5TBread_records(fid,"table3",rstart,rrecords,type_size_mem,field_offset,
- field_size,rbuf)<0)
+ rstart = 0;
+ if (H5TBread_records(fid, "table3", rstart, rrecords, type_size_mem, field_offset, field_size, rbuf) <
+ 0)
goto out;
/* Compare */
- assert(rrecords == nrecords-drecords);
- if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0)
+ assert(rrecords == nrecords - drecords);
+ if (compare_deleted(rrecords, dstart, drecords, rbuf, wbufd) < 0)
goto out;
/*-------------------------------------------------------------------------
- * reset compare buffer
- *-------------------------------------------------------------------------
- */
- nrecords=rrecords;
- for( i=0; i<nrecords; i++)
- {
+ * reset compare buffer
+ *-------------------------------------------------------------------------
+ */
+ nrecords = rrecords;
+ for (i = 0; i < nrecords; i++) {
wbufd[i] = rbuf[i];
}
/* Read complete table */
- if (H5TBread_table(fid,"table3",type_size_mem,field_offset,field_size,rbuf)<0)
+ if (H5TBread_table(fid, "table3", type_size_mem, field_offset, field_size, rbuf) < 0)
goto out;
/* Compare */
- for( i=0; i<rrecords; i++)
- {
- if (cmp_par(i,i,rbuf,wbufd)<0)
- {
+ for (i = 0; i < rrecords; i++) {
+ if (cmp_par(i, i, rbuf, wbufd) < 0) {
goto out;
}
}
/*-------------------------------------------------------------------------
- * Delete records, start at 0, delete 1
- * pos = 0
- * data= empty
- *-------------------------------------------------------------------------
- */
- dstart=0; drecords=1;
- if (H5TBdelete_record(fid,"table3",dstart,drecords)<0)
+ * Delete records, start at 0, delete 1
+ * pos = 0
+ * data= empty
+ *-------------------------------------------------------------------------
+ */
+ dstart = 0;
+ drecords = 1;
+ if (H5TBdelete_record(fid, "table3", dstart, drecords) < 0)
goto out;
- if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0)
+ if (H5TBget_table_info(fid, "table3", &rfields, &rrecords) < 0)
goto out;
if (rrecords)
@@ -892,109 +794,102 @@ static int test_table(hid_t fid, int do_write)
/*------------------------------------------------------------------------
* Functions tested:
*
- * H5TBdelete_record -- With differing memory layout from machine memory
+ * H5TBdelete_record -- With differing memory layout from machine memory
* layout. HDFFV-8055
*
*-------------------------------------------------------------------------
*/
- if (do_write)
- {
- TESTING2("deleting records (differing memory layout)");
-
- dims = 3;
- arry3_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims);
-
- dims = 2;
- arry2_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims);
-
- /* Initialize the field field_type */
- field_type4[0] = H5T_NATIVE_UINT32;
- field_type4[1] = H5T_NATIVE_DOUBLE;
- field_type4[2] = H5T_NATIVE_DOUBLE;
- field_type4[3] = arry3_32f;
- field_type4[4] = arry3_32f;
- field_type4[5] = arry2_32f;
-
- /* Make the table */
- if (H5TBmake_table("Table Title",fid,"table",NFIELDS+1,(hsize_t)NRECORDS,
- tbl_size, field_names4, tbl_offset, field_type4,
- chunk_size, fill_data, compress, p_data)<0)
- goto out;
- /* Delete records */
- start = 3;
- nrecords = 3;
- if (H5TBdelete_record(fid, "table", start, nrecords)<0)
- goto out;;
- /* Get table info */
- if (H5TBget_table_info(fid,"table", &nfields_out, &nrecords_out)<0)
- goto out;
- /* check */
- if( (int)nfields_out != (int)NFIELDS+1)
- goto out;
-
- if( (int)nrecords_out != (int)NRECORDS-3)
- goto out;
-
- /* close type */
- H5Tclose(arry3_32f);
- H5Tclose(arry2_32f);
-
- PASSED();
+ if (do_write) {
+ HL_TESTING2("deleting records (differing memory layout)");
+
+ dims = 3;
+ arry3_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims);
+
+ dims = 2;
+ arry2_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims);
+
+ /* Initialize the field field_type */
+ field_type4[0] = H5T_NATIVE_UINT32;
+ field_type4[1] = H5T_NATIVE_DOUBLE;
+ field_type4[2] = H5T_NATIVE_DOUBLE;
+ field_type4[3] = arry3_32f;
+ field_type4[4] = arry3_32f;
+ field_type4[5] = arry2_32f;
+
+ /* Make the table */
+ if (H5TBmake_table("Table Title", fid, "table", NFIELDS + 1, (hsize_t)NRECORDS, tbl_size,
+ field_names4, tbl_offset, field_type4, chunk_size, fill_data, compress,
+ p_data) < 0)
+ goto out;
+ /* Delete records */
+ start = 3;
+ nrecords = 3;
+ if (H5TBdelete_record(fid, "table", start, nrecords) < 0)
+ goto out;
+ ;
+ /* Get table info */
+ if (H5TBget_table_info(fid, "table", &nfields_out, &nrecords_out) < 0)
+ goto out;
+ /* check */
+ if ((int)nfields_out != (int)NFIELDS + 1)
+ goto out;
+
+ if ((int)nrecords_out != (int)NRECORDS - 3)
+ goto out;
+
+ /* close type */
+ H5Tclose(arry3_32f);
+ H5Tclose(arry2_32f);
+
+ PASSED();
}
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBadd_records_from
- * H5TBread_records
- *
- *-------------------------------------------------------------------------
- */
+ *
+ * Functions tested:
+ *
+ * H5TBadd_records_from
+ * H5TBread_records
+ *
+ *-------------------------------------------------------------------------
+ */
- if (do_write)
- {
- TESTING2("adding records");
+ if (do_write) {
+ HL_TESTING2("adding records");
/* create 2 tables */
- if (H5TBmake_table(TITLE,fid,"table4",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid, "table4", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbuf) < 0)
goto out;
- if (H5TBmake_table(TITLE,fid,"table5",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid, "table5", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbuf) < 0)
goto out;
/* add the records from "table4" to "table5" */
- start1 = 3;
- nrecords = 2;
- start2 = 6;
- if ( H5TBadd_records_from(fid,"table4",start1,nrecords,"table5",start2)<0)
+ start1 = 3;
+ nrecords = 2;
+ start2 = 6;
+ if (H5TBadd_records_from(fid, "table4", start1, nrecords, "table5", start2) < 0)
goto out;
/* read final table */
- if (H5TBread_table(fid,"table5",type_size_mem,field_offset,field_size,rbuf)<0)
+ if (H5TBread_table(fid, "table5", type_size_mem, field_offset, field_size, rbuf) < 0)
goto out;
/* compare */
- for( i = 0; i < NRECORDS+2; i++ )
- {
- if ( i < start2 )
- {
- if (cmp_par(i,i,rbuf,wbuf)<0)
+ for (i = 0; i < NRECORDS + 2; i++) {
+ if (i < start2) {
+ if (cmp_par(i, i, rbuf, wbuf) < 0)
goto out;
}
- else if ( i < start2 + nrecords )
- {
+ else if (i < start2 + nrecords) {
j = i - start1;
- if (cmp_par(i,j,rbuf,wbuf)<0)
+ if (cmp_par(i, j, rbuf, wbuf) < 0)
goto out;
}
- else
- {
+ else {
j = i - nrecords;
- if (cmp_par(i,j,rbuf,wbuf)<0)
+ if (cmp_par(i, j, rbuf, wbuf) < 0)
goto out;
}
}
@@ -1003,90 +898,79 @@ static int test_table(hid_t fid, int do_write)
}
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBcombine_tables
- * H5TBread_table
- *
- *-------------------------------------------------------------------------
- */
+ *
+ * Functions tested:
+ *
+ * H5TBcombine_tables
+ * H5TBread_table
+ *
+ *-------------------------------------------------------------------------
+ */
- if (do_write)
- {
- TESTING2("combining tables");
+ if (do_write) {
+ HL_TESTING2("combining tables");
/* create 2 tables */
- if (H5TBmake_table(TITLE,fid,"table6",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid, "table6", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbuf) < 0)
goto out;
- if (H5TBmake_table(TITLE,fid,"table7",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid, "table7", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbuf) < 0)
goto out;
/* combine the two tables into a third */
- if ( H5TBcombine_tables(fid,"table6",fid,"table7","table8")<0)
+ if (H5TBcombine_tables(fid, "table6", fid, "table7", "table8") < 0)
goto out;
/* read merged table */
- if (H5TBread_table(fid,"table8",type_size_mem,field_offset,field_size,rbufc)<0)
+ if (H5TBread_table(fid, "table8", type_size_mem, field_offset, field_size, rbufc) < 0)
goto out;
/* compare */
- for( i = 0; i < NRECORDS*2; i++ )
- {
- if ( i < NRECORDS )
- {
- if (cmp_par(i,i,rbufc,wbuf)<0)
+ for (i = 0; i < NRECORDS * 2; i++) {
+ if (i < NRECORDS) {
+ if (cmp_par(i, i, rbufc, wbuf) < 0)
goto out;
}
- else
- {
- if (cmp_par(i,i-NRECORDS,rbufc,wbuf)<0)
+ else {
+ if (cmp_par(i, i - NRECORDS, rbufc, wbuf) < 0)
goto out;
}
}
/*-------------------------------------------------------------------------
- * multi file test
- *-------------------------------------------------------------------------
- */
+ * multi file test
+ *-------------------------------------------------------------------------
+ */
/* create 2 files using default properties. */
- fid1 = H5Fcreate("combine_tables1.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);
- fid2 = H5Fcreate("combine_tables2.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);
+ fid1 = H5Fcreate("combine_tables1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ fid2 = H5Fcreate("combine_tables2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/* create 2 tables, one in each file */
- if (H5TBmake_table(TITLE,fid1,"table1",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid1, "table1", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbuf) < 0)
goto out;
- if (H5TBmake_table(TITLE,fid2,"table2",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid2, "table2", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbuf) < 0)
goto out;
/* combine the two tables into a third */
- if ( H5TBcombine_tables(fid1,"table1",fid2,"table2","table3")<0)
+ if (H5TBcombine_tables(fid1, "table1", fid2, "table2", "table3") < 0)
goto out;
/* read merged table */
- if (H5TBread_table(fid1,"table3",type_size_mem,field_offset,field_size,rbufc)<0)
+ if (H5TBread_table(fid1, "table3", type_size_mem, field_offset, field_size, rbufc) < 0)
goto out;
/* compare */
- for( i = 0; i < NRECORDS*2; i++ )
- {
- if ( i < NRECORDS )
- {
- if (cmp_par(i,i,rbufc,wbuf)<0)
+ for (i = 0; i < NRECORDS * 2; i++) {
+ if (i < NRECORDS) {
+ if (cmp_par(i, i, rbufc, wbuf) < 0)
goto out;
}
- else
- {
- if (cmp_par(i,i-NRECORDS,rbufc,wbuf)<0)
+ else {
+ if (cmp_par(i, i - NRECORDS, rbufc, wbuf) < 0)
goto out;
}
}
@@ -1098,98 +982,87 @@ static int test_table(hid_t fid, int do_write)
PASSED();
}
-
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBwrite_fields_name
- *
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
- TESTING2("writing fields by name");
+ *
+ * Functions tested:
+ *
+ * H5TBwrite_fields_name
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
+ HL_TESTING2("writing fields by name");
/* make an empty table with fill values */
- if (H5TBmake_table(TITLE,fid,"table9",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill1,compress,0)<0)
+ if (H5TBmake_table(TITLE, fid, "table9", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill1, compress, 0) < 0)
goto out;
/* write the pressure field starting at record 2 */
start = 2;
nrecords = NRECORDS_ADD;
- if (H5TBwrite_fields_name(fid,"table9","Pressure",start,nrecords,sizeof(float),
- 0,field_sizes_pre,pressure_in)<0)
+ if (H5TBwrite_fields_name(fid, "table9", "Pressure", start, nrecords, sizeof(float), 0,
+ field_sizes_pre, pressure_in) < 0)
goto out;
/* write the new longitude and latitude information starting at record 2 */
start = 2;
nrecords = 3;
- if (H5TBwrite_fields_name(fid,"table9","Latitude,Longitude",start,nrecords,sizeof(position_t),
- field_offset_pos,field_sizes_pos,position_in)<0)
+ if (H5TBwrite_fields_name(fid, "table9", "Latitude,Longitude", start, nrecords, sizeof(position_t),
+ field_offset_pos, field_sizes_pos, position_in) < 0)
goto out;
/* read back the all table */
start = 0;
nrecords = NRECORDS;
- if (H5TBread_table(fid,"table9",type_size_mem,field_offset,field_size,rbuf)<0)
+ if (H5TBread_table(fid, "table9", type_size_mem, field_offset, field_size, rbuf) < 0)
goto out;
{
-
/* compare the read values with the initial values */
- for( i = 0; i < NRECORDS; i++ )
- {
- if ( i >= 2 && i <= 4 )
- {
- if ( rbuf[i].lati != position_in[i-NRECORDS_ADD+1].lati ||
- rbuf[i].longi != position_in[i-NRECORDS_ADD+1].longi ||
- !FLT_ABS_EQUAL(rbuf[i].pressure,pressure_in[i-NRECORDS_ADD+1]) )
- {
- HDfprintf(stderr,"%ld %f %d\n",
- rbuf[i].longi,(double)rbuf[i].pressure,rbuf[i].lati);
- HDfprintf(stderr,"%ld %f %d\n",
- position_in[i].longi,(double)pressure_in[i],position_in[i].lati);
+ for (i = 0; i < NRECORDS; i++) {
+ if (i >= 2 && i <= 4) {
+ if (rbuf[i].lati != position_in[i - NRECORDS_ADD + 1].lati ||
+ rbuf[i].longi != position_in[i - NRECORDS_ADD + 1].longi ||
+ !H5_FLT_ABS_EQUAL(rbuf[i].pressure, pressure_in[i - NRECORDS_ADD + 1])) {
+ HDfprintf(stderr, "%ld %f %d\n", rbuf[i].longi, (double)rbuf[i].pressure,
+ rbuf[i].lati);
+ HDfprintf(stderr, "%ld %f %d\n", position_in[i].longi, (double)pressure_in[i],
+ position_in[i].lati);
goto out;
}
}
}
}
-
-
PASSED();
} /*write*/
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBread_fields_name
- *
- *-------------------------------------------------------------------------
- */
- TESTING2("reading fields by name");
+ *
+ * Functions tested:
+ *
+ * H5TBread_fields_name
+ *
+ *-------------------------------------------------------------------------
+ */
+ HL_TESTING2("reading fields by name");
/*-------------------------------------------------------------------------
- * write and read the "Pressure" field
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
- if (H5TBmake_table(TITLE,fid,"table10",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill1,compress,0)<0)
+ * write and read the "Pressure" field
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
+ if (H5TBmake_table(TITLE, fid, "table10", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill1, compress, 0) < 0)
goto out;
/* write the pressure field to all the records */
start = 0;
nrecords = NRECORDS;
- if ( H5TBwrite_fields_name(fid,"table10","Pressure",start,nrecords,
- sizeof( float ),0,field_sizes_pre,pressure_in)<0)
+ if (H5TBwrite_fields_name(fid, "table10", "Pressure", start, nrecords, sizeof(float), 0,
+ field_sizes_pre, pressure_in) < 0)
goto out;
}
@@ -1197,170 +1070,149 @@ static int test_table(hid_t fid, int do_write)
nrecords = NRECORDS;
/* read an invalid field, should fail */
- if ( H5TBread_fields_name(fid,"table10","DoesNotExist",start,nrecords,
- sizeof(float),0,field_sizes_pre,pressure_out) >=0)
- goto out;
-
+ if (H5TBread_fields_name(fid, "table10", "DoesNotExist", start, nrecords, sizeof(float), 0,
+ field_sizes_pre, pressure_out) >= 0)
+ goto out;
+
/* read the "Pressure" field */
- if ( H5TBread_fields_name(fid,"table10","Pressure",start,nrecords,
- sizeof(float),0,field_sizes_pre,pressure_out)<0)
+ if (H5TBread_fields_name(fid, "table10", "Pressure", start, nrecords, sizeof(float), 0, field_sizes_pre,
+ pressure_out) < 0)
goto out;
/* Compare the extracted table with the initial values */
- for ( i = 0; i < NRECORDS; i++ )
- {
- if ( !FLT_ABS_EQUAL(pressure_out[i], pressure_in[i]) ) {
+ for (i = 0; i < NRECORDS; i++) {
+ if (!H5_FLT_ABS_EQUAL(pressure_out[i], pressure_in[i])) {
goto out;
}
}
/*-------------------------------------------------------------------------
- * Write and read the "Latitude,Longitude" fields
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
+ * Write and read the "Latitude,Longitude" fields
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
/* Write the new longitude and latitude information to all the records */
start = 0;
nrecords = NRECORDS_ADD;
- if ( H5TBwrite_fields_name(fid,"table10", "Latitude,Longitude", start, nrecords,
- sizeof( position_t ), field_offset_pos, field_sizes_pos, position_in ) < 0 )
+ if (H5TBwrite_fields_name(fid, "table10", "Latitude,Longitude", start, nrecords, sizeof(position_t),
+ field_offset_pos, field_sizes_pos, position_in) < 0)
goto out;
- }/*write*/
+ } /*write*/
/* Read the "Latitude,Longitude" fields */
start = 0;
nrecords = NRECORDS_ADD;
- if ( H5TBread_fields_name( fid, "table10", "Latitude,Longitude",
- start, nrecords, sizeof(position_t), field_offset_pos, field_sizes_pos, position_out ) < 0 )
+ if (H5TBread_fields_name(fid, "table10", "Latitude,Longitude", start, nrecords, sizeof(position_t),
+ field_offset_pos, field_sizes_pos, position_out) < 0)
goto out;
-
/* Compare the extracted table with the initial values */
- for( i = 0; i < NRECORDS_ADD; i++ )
- {
- if ( position_out[i].lati != position_in[i].lati ||
- position_out[i].longi != position_in[i].longi )
+ for (i = 0; i < NRECORDS_ADD; i++) {
+ if (position_out[i].lati != position_in[i].lati || position_out[i].longi != position_in[i].longi)
goto out;
}
-
/*-------------------------------------------------------------------------
- * Write and read the "Name,Pressure" fields
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
+ * Write and read the "Name,Pressure" fields
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
/* Write the new name and pressure information to all the records */
start = 0;
nrecords = NRECORDS;
- if ( H5TBwrite_fields_name( fid, "table10", "Name,Pressure", start, nrecords,
- sizeof( namepressure_t ), field_offset_namepre, field_sizes_namepre, namepre_in ) < 0 )
+ if (H5TBwrite_fields_name(fid, "table10", "Name,Pressure", start, nrecords, sizeof(namepressure_t),
+ field_offset_namepre, field_sizes_namepre, namepre_in) < 0)
goto out;
- }/*write*/
+ } /*write*/
/* Read the "Name,Pressure" fields */
start = 0;
nrecords = NRECORDS;
- if ( H5TBread_fields_name( fid, "table10", "Name,Pressure",
- start, nrecords, sizeof(namepressure_t), field_offset_namepre, field_sizes_namepre,
- namepre_out ) < 0 )
+ if (H5TBread_fields_name(fid, "table10", "Name,Pressure", start, nrecords, sizeof(namepressure_t),
+ field_offset_namepre, field_sizes_namepre, namepre_out) < 0)
goto out;
-
/* Compare the extracted table with the initial values */
- for( i = 0; i < NRECORDS; i++ )
- {
- if ( ( HDstrcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) ||
- !FLT_ABS_EQUAL(namepre_out[i].pressure,namepre_in[i].pressure) ) {
- goto out;
+ for (i = 0; i < NRECORDS; i++) {
+ if ((HDstrcmp(namepre_out[i].name, namepre_in[i].name) != 0) ||
+ !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, namepre_in[i].pressure)) {
+ goto out;
}
}
/* reset buffer */
- for( i = 0; i < NRECORDS; i++ )
- {
- HDstrcpy( namepre_out[i].name, "\0" );
+ for (i = 0; i < NRECORDS; i++) {
+ HDstrcpy(namepre_out[i].name, "\0");
namepre_out[i].pressure = -1;
}
/*-------------------------------------------------------------------------
- * read only 3 records of the "Name,Pressure" fields, starting at record 2
- *-------------------------------------------------------------------------
- */
+ * read only 3 records of the "Name,Pressure" fields, starting at record 2
+ *-------------------------------------------------------------------------
+ */
start = 2;
nrecords = 3;
- if ( H5TBread_fields_name( fid, "table10", "Name,Pressure",
- start, nrecords, sizeof(namepressure_t), field_offset_namepre,
- field_sizes_namepre, namepre_out ) < 0 )
+ if (H5TBread_fields_name(fid, "table10", "Name,Pressure", start, nrecords, sizeof(namepressure_t),
+ field_offset_namepre, field_sizes_namepre, namepre_out) < 0)
goto out;
-
/* Compare the extracted table with the initial values */
- for( i = 0; i < 3; i++ )
- {
+ for (i = 0; i < 3; i++) {
hsize_t iistart = start;
- if ( ( HDstrcmp( namepre_out[i].name, namepre_in[iistart+i].name ) != 0 ) ||
- !FLT_ABS_EQUAL(namepre_out[i].pressure, namepre_in[iistart+i].pressure) ) {
- goto out;
+ if ((HDstrcmp(namepre_out[i].name, namepre_in[iistart + i].name) != 0) ||
+ !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, namepre_in[iistart + i].pressure)) {
+ goto out;
}
}
-
-
PASSED();
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBwrite_fields_index
- *
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
- TESTING2("writing fields by index");
+ *
+ * Functions tested:
+ *
+ * H5TBwrite_fields_index
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
+ HL_TESTING2("writing fields by index");
/* make an empty table */
- if (H5TBmake_table(TITLE,fid,"table11",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,NULL)<0)
+ if (H5TBmake_table(TITLE, fid, "table11", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, NULL) < 0)
goto out;
/* write the pressure field starting at record 2 */
nfields = 1;
start = 2;
nrecords = NRECORDS_ADD;
- if ( H5TBwrite_fields_index(fid, "table11", nfields, field_index_pre, start, nrecords,
- sizeof( float ), 0, field_sizes_pre, pressure_in ) < 0 )
+ if (H5TBwrite_fields_index(fid, "table11", nfields, field_index_pre, start, nrecords, sizeof(float),
+ 0, field_sizes_pre, pressure_in) < 0)
goto out;
-
/* write the new longitude and latitude information starting at record 2 */
nfields = 2;
start = 2;
nrecords = NRECORDS_ADD;
- if ( H5TBwrite_fields_index(fid, "table11", nfields, field_index_pos, start, nrecords,
- sizeof( position_t ), field_offset_pos, field_sizes_pos, position_in ) < 0 )
+ if (H5TBwrite_fields_index(fid, "table11", nfields, field_index_pos, start, nrecords,
+ sizeof(position_t), field_offset_pos, field_sizes_pos, position_in) < 0)
goto out;
/* read back the all table */
nfields = 5;
start = 0;
nrecords = NRECORDS;
- if ( H5TBread_fields_index(fid, "table11", nfields, field_index,
- start, nrecords, type_size_mem, field_offset, field_size, rbuf ) < 0 )
+ if (H5TBread_fields_index(fid, "table11", nfields, field_index, start, nrecords, type_size_mem,
+ field_offset, field_size, rbuf) < 0)
goto out;
/* Compare the extracted table with the initial values */
- for( i = 0; i < NRECORDS; i++ )
- {
- if ( i >= 2 && i <= 4 )
- {
- if ( rbuf[i].lati != position_in[i-NRECORDS_ADD+1].lati ||
- rbuf[i].longi != position_in[i-NRECORDS_ADD+1].longi ||
- !FLT_ABS_EQUAL(rbuf[i].pressure,pressure_in[i-NRECORDS_ADD+1]) )
+ for (i = 0; i < NRECORDS; i++) {
+ if (i >= 2 && i <= 4) {
+ if (rbuf[i].lati != position_in[i - NRECORDS_ADD + 1].lati ||
+ rbuf[i].longi != position_in[i - NRECORDS_ADD + 1].longi ||
+ !H5_FLT_ABS_EQUAL(rbuf[i].pressure, pressure_in[i - NRECORDS_ADD + 1]))
goto out;
}
}
@@ -1368,37 +1220,34 @@ static int test_table(hid_t fid, int do_write)
PASSED();
}
-
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBread_fields_index
- *
- *-------------------------------------------------------------------------
- */
+ *
+ * Functions tested:
+ *
+ * H5TBread_fields_index
+ *
+ *-------------------------------------------------------------------------
+ */
- TESTING2("reading fields by index");
+ HL_TESTING2("reading fields by index");
- if (do_write)
- {
+ if (do_write) {
/* make an empty table */
- if (H5TBmake_table(TITLE,fid,"table12",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,NULL)<0)
+ if (H5TBmake_table(TITLE, fid, "table12", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, NULL) < 0)
goto out;
/*-------------------------------------------------------------------------
- * write and read the "Pressure" field
- *-------------------------------------------------------------------------
- */
+ * write and read the "Pressure" field
+ *-------------------------------------------------------------------------
+ */
/* write the pressure field to all the records */
nfields = 1;
start = 0;
nrecords = NRECORDS;
- if ( H5TBwrite_fields_index(fid, "table12", nfields, field_index_pre, start, nrecords,
- sizeof( float ), 0, field_sizes_pre, pressure_in ) < 0 )
+ if (H5TBwrite_fields_index(fid, "table12", nfields, field_index_pre, start, nrecords, sizeof(float),
+ 0, field_sizes_pre, pressure_in) < 0)
goto out;
}
@@ -1406,196 +1255,178 @@ static int test_table(hid_t fid, int do_write)
nfields = 1;
start = 0;
nrecords = NRECORDS;
- if ( H5TBread_fields_index(fid, "table12", nfields, field_index_pre,
- start, nrecords, sizeof(float), 0, field_sizes_pre, pressure_out ) < 0 )
+ if (H5TBread_fields_index(fid, "table12", nfields, field_index_pre, start, nrecords, sizeof(float), 0,
+ field_sizes_pre, pressure_out) < 0)
goto out;
/* compare the extracted table with the initial values */
- for( i = 0; i < NRECORDS; i++ )
- {
- if ( !FLT_ABS_EQUAL(pressure_out[i], pressure_in[i]) ) {
+ for (i = 0; i < NRECORDS; i++) {
+ if (!H5_FLT_ABS_EQUAL(pressure_out[i], pressure_in[i])) {
goto out;
}
}
/*-------------------------------------------------------------------------
- * write and read the "Latitude,Longitude" fields
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
+ * write and read the "Latitude,Longitude" fields
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
/* write the new longitude and latitude information to all the records */
- nfields = 2;
+ nfields = 2;
start = 0;
nrecords = NRECORDS;
- if ( H5TBwrite_fields_index(fid, "table12", nfields, field_index_pos, start, nrecords,
- sizeof( position_t ), field_offset_pos, field_sizes_pos, position_in ) < 0 )
+ if (H5TBwrite_fields_index(fid, "table12", nfields, field_index_pos, start, nrecords,
+ sizeof(position_t), field_offset_pos, field_sizes_pos, position_in) < 0)
goto out;
} /*write*/
/* read the "Latitude,Longitude" fields */
- nfields = 2;
+ nfields = 2;
start = 0;
nrecords = NRECORDS_ADD;
- if ( H5TBread_fields_index(fid, "table12", nfields, field_index_pos,
- start, nrecords, sizeof(position_t), field_offset_pos, field_sizes_pos, position_out ) < 0 )
+ if (H5TBread_fields_index(fid, "table12", nfields, field_index_pos, start, nrecords, sizeof(position_t),
+ field_offset_pos, field_sizes_pos, position_out) < 0)
goto out;
/* compare the extracted table with the initial values */
- for( i = 0; i < NRECORDS_ADD; i++ )
- {
- if ( position_out[i].lati != position_in[i].lati ||
- position_out[i].longi != position_in[i].longi ) {
- goto out;
+ for (i = 0; i < NRECORDS_ADD; i++) {
+ if (position_out[i].lati != position_in[i].lati || position_out[i].longi != position_in[i].longi) {
+ goto out;
}
}
/*-------------------------------------------------------------------------
- * write and read the "Name,Pressure" fields
- *-------------------------------------------------------------------------
- */
+ * write and read the "Name,Pressure" fields
+ *-------------------------------------------------------------------------
+ */
- if (do_write)
- {
+ if (do_write) {
/* write the new name and pressure information to all the records */
- nfields = 2;
+ nfields = 2;
start = 0;
nrecords = NRECORDS;
- if ( H5TBwrite_fields_index(fid, "table12", nfields, field_index_namepre, start, nrecords,
- sizeof( namepressure_t ), field_offset_namepre, field_sizes_namepre, namepre_in ) < 0 )
+ if (H5TBwrite_fields_index(fid, "table12", nfields, field_index_namepre, start, nrecords,
+ sizeof(namepressure_t), field_offset_namepre, field_sizes_namepre,
+ namepre_in) < 0)
goto out;
}
/* read the "Name,Pressure" fields */
- nfields = 2;
+ nfields = 2;
start = 0;
nrecords = NRECORDS;
- if ( H5TBread_fields_index(fid, "table12", nfields, field_index_namepre,
- start, nrecords, sizeof(namepressure_t), field_offset_namepre,
- field_sizes_namepre, namepre_out ) < 0 )
+ if (H5TBread_fields_index(fid, "table12", nfields, field_index_namepre, start, nrecords,
+ sizeof(namepressure_t), field_offset_namepre, field_sizes_namepre,
+ namepre_out) < 0)
goto out;
/* compare the extracted table with the initial values */
- for( i = 0; i < NRECORDS; i++ )
- {
- if ( ( HDstrcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) ||
- !FLT_ABS_EQUAL(namepre_out[i].pressure,namepre_in[i].pressure) ) {
- goto out;
- }
+ for (i = 0; i < NRECORDS; i++) {
+ if ((HDstrcmp(namepre_out[i].name, namepre_in[i].name) != 0) ||
+ !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, namepre_in[i].pressure)) {
+ goto out;
+ }
}
/* reset buffer */
- for( i = 0; i < NRECORDS; i++ )
- {
- HDstrcpy( namepre_out[i].name, "\0" );
+ for (i = 0; i < NRECORDS; i++) {
+ HDstrcpy(namepre_out[i].name, "\0");
namepre_out[i].pressure = -1;
}
/*-------------------------------------------------------------------------
- * read only 3 records of the "Name,Pressure" fields, starting at record 2
- *-------------------------------------------------------------------------
- */
+ * read only 3 records of the "Name,Pressure" fields, starting at record 2
+ *-------------------------------------------------------------------------
+ */
/* write the new name and pressure information to all the records */
nfields = 2;
start = 2;
nrecords = 3;
- if ( H5TBread_fields_index(fid, "table12", nfields, field_index_namepre,
- start, nrecords, sizeof(namepressure_t), field_offset_namepre,
- field_sizes_namepre, namepre_out ) < 0 )
+ if (H5TBread_fields_index(fid, "table12", nfields, field_index_namepre, start, nrecords,
+ sizeof(namepressure_t), field_offset_namepre, field_sizes_namepre,
+ namepre_out) < 0)
goto out;
/* compare the extracted table with the initial values */
- for( i = 0; i < 3; i++ )
- {
- int iistart = (int) start;
- if ( ( HDstrcmp( namepre_out[i].name, wbuf[iistart+(int)i].name ) != 0 ) ||
- !FLT_ABS_EQUAL(namepre_out[i].pressure, wbuf[iistart+(int)i].pressure) ) {
- goto out;
+ for (i = 0; i < 3; i++) {
+ int iistart = (int)start;
+ if ((HDstrcmp(namepre_out[i].name, wbuf[iistart + (int)i].name) != 0) ||
+ !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, wbuf[iistart + (int)i].pressure)) {
+ goto out;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBinsert_field
- *
- *-------------------------------------------------------------------------
- */
+ *
+ * Functions tested:
+ *
+ * H5TBinsert_field
+ *
+ *-------------------------------------------------------------------------
+ */
- if (do_write)
- {
- TESTING2("inserting fields");
+ if (do_write) {
+ HL_TESTING2("inserting fields");
/* make a table */
- if (H5TBmake_table(TITLE,fid,"table13",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill1,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid, "table13", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill1, compress, wbuf) < 0)
goto out;
/* insert the new field at the end of the field list */
position = NFIELDS;
- if ( H5TBinsert_field( fid, "table13", "New Field", field_type_new, position,
- fill1_new, buf_new ) < 0 )
+ if (H5TBinsert_field(fid, "table13", "New Field", field_type_new, position, fill1_new, buf_new) < 0)
goto out;
/* read the table */
- if ( H5TBread_table( fid, "table13", dst_size2, dst_offset2, dst_sizes2, rbuf2 ) < 0 )
+ if (H5TBread_table(fid, "table13", dst_size2, dst_offset2, dst_sizes2, rbuf2) < 0)
goto out;
/* compare the extracted table with the original array */
- for( i = 0; i < NRECORDS; i++ )
- {
- if ( ( HDstrcmp( rbuf2[i].name, wbuf[i].name ) != 0 ) ||
- rbuf2[i].lati != wbuf[i].lati ||
- rbuf2[i].longi != wbuf[i].longi ||
- !FLT_ABS_EQUAL(rbuf2[i].pressure,wbuf[i].pressure) ||
- !DBL_ABS_EQUAL(rbuf2[i].temperature,wbuf[i].temperature) ||
- rbuf2[i].new_field != buf_new[i] ) {
- goto out;
+ for (i = 0; i < NRECORDS; i++) {
+ if ((HDstrcmp(rbuf2[i].name, wbuf[i].name) != 0) || rbuf2[i].lati != wbuf[i].lati ||
+ rbuf2[i].longi != wbuf[i].longi || !H5_FLT_ABS_EQUAL(rbuf2[i].pressure, wbuf[i].pressure) ||
+ !H5_DBL_ABS_EQUAL(rbuf2[i].temperature, wbuf[i].temperature) ||
+ rbuf2[i].new_field != buf_new[i]) {
+ goto out;
}
}
PASSED();
}
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBdelete_field
- *
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
- TESTING2("deleting fields");
+ *
+ * Functions tested:
+ *
+ * H5TBdelete_field
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
+ HL_TESTING2("deleting fields");
/* make a table */
- if (H5TBmake_table(TITLE,fid,"table14",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid, "table14", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbuf) < 0)
goto out;
/* delete the field */
- if ( H5TBdelete_field(fid, "table14", "Pressure" ) < 0 )
+ if (H5TBdelete_field(fid, "table14", "Pressure") < 0)
goto out;
/* read the table */
- if ( H5TBread_table(fid, "table14", dst_size3, dst_offset3, dst_sizes3, rbuf3 ) < 0 )
+ if (H5TBread_table(fid, "table14", dst_size3, dst_offset3, dst_sizes3, rbuf3) < 0)
goto out;
/* compare the extracted table with the original array */
- for( i = 0; i < NRECORDS; i++ )
- {
- if ( ( HDstrcmp( rbuf3[i].name, wbuf[i].name ) != 0 ) ||
- rbuf3[i].lati != wbuf[i].lati ||
+ for (i = 0; i < NRECORDS; i++) {
+ if ((HDstrcmp(rbuf3[i].name, wbuf[i].name) != 0) || rbuf3[i].lati != wbuf[i].lati ||
rbuf3[i].longi != wbuf[i].longi ||
- !DBL_ABS_EQUAL(rbuf3[i].temperature,wbuf[i].temperature) ) {
- goto out;
+ !H5_DBL_ABS_EQUAL(rbuf3[i].temperature, wbuf[i].temperature)) {
+ goto out;
}
}
@@ -1603,143 +1434,140 @@ static int test_table(hid_t fid, int do_write)
}
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBget_table_info
- * H5TBget_field_info
- *
- *-------------------------------------------------------------------------
- */
+ *
+ * Functions tested:
+ *
+ * H5TBget_table_info
+ * H5TBget_field_info
+ *
+ *-------------------------------------------------------------------------
+ */
- TESTING2("getting table info");
+ HL_TESTING2("getting table info");
/* get table info */
- if ( H5TBget_table_info (fid, "table1", &rfields, &rrecords ) < 0 )
+ if (H5TBget_table_info(fid, "table1", &rfields, &rrecords) < 0)
goto out;
- if ( NFIELDS != rfields || rrecords != NRECORDS ) {
+ if (NFIELDS != rfields || rrecords != NRECORDS) {
goto out;
}
PASSED();
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBget_field_info
- *
- *-------------------------------------------------------------------------
- */
+ *
+ * Functions tested:
+ *
+ * H5TBget_field_info
+ *
+ *-------------------------------------------------------------------------
+ */
- TESTING2("getting field info");
+ HL_TESTING2("getting field info");
/* alocate */
- names_out = (char**) HDmalloc( sizeof(char*) * (size_t)NFIELDS );
- for ( i = 0; i < NFIELDS; i++)
- {
- names_out[i] = (char*) HDmalloc( sizeof(char) * 255 );
+ names_out = (char **)HDmalloc(sizeof(char *) * (size_t)NFIELDS);
+ for (i = 0; i < NFIELDS; i++) {
+ names_out[i] = (char *)HDmalloc(sizeof(char) * 255);
}
/* Get field info */
- if ( H5TBget_field_info(fid, "table1", names_out, sizes_out, offset_out, &size_out ) < 0 )
+ if (H5TBget_field_info(fid, "table1", names_out, sizes_out, offset_out, &size_out) < 0)
goto out;
- for ( i = 0; i < NFIELDS; i++)
- {
- if ( (HDstrcmp( field_names[i], names_out[i] ) != 0)) {
+ for (i = 0; i < NFIELDS; i++) {
+ if ((HDstrcmp(field_names[i], names_out[i]) != 0)) {
goto out;
}
}
/* release */
- for ( i = 0; i < NFIELDS; i++)
- {
- HDfree ( names_out[i] );
+ for (i = 0; i < NFIELDS; i++) {
+ HDfree(names_out[i]);
}
- HDfree ( names_out );
+ HDfree(names_out);
PASSED();
/*-------------------------------------------------------------------------
- * end
- *-------------------------------------------------------------------------
- */
+ * end
+ *-------------------------------------------------------------------------
+ */
return 0;
out:
H5_FAILED();
return -1;
}
-
/*-------------------------------------------------------------------------
-* the main program
-*-------------------------------------------------------------------------
-*/
+ * the main program
+ *-------------------------------------------------------------------------
+ */
-int main(void)
+int
+main(void)
{
- hid_t fid; /* identifier for the file */
- unsigned flags=H5F_ACC_RDONLY;
+ hid_t fid; /* identifier for the file */
+ unsigned flags = H5F_ACC_RDONLY;
/*-------------------------------------------------------------------------
- * test1: create a file for the write/read test
- *-------------------------------------------------------------------------
- */
+ * test1: create a file for the write/read test
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- fid=H5Fcreate("test_table.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);
+ fid = H5Fcreate("test_table.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
HDputs("Testing table with file creation mode (read/write in native architecture):");
/* test, do write */
- if (test_table(fid,1)<0)
+ if (test_table(fid, 1) < 0)
goto out;
/* close */
H5Fclose(fid);
/*-------------------------------------------------------------------------
- * test2: open a file written in test1 on a big-endian machine
- *-------------------------------------------------------------------------
- */
+ * test2: open a file written in test1 on a big-endian machine
+ *-------------------------------------------------------------------------
+ */
HDputs("Testing table with file open mode (read big-endian data):");
- fid=h5file_open(TEST_FILE_BE,flags);
+ fid = h5file_open(TEST_FILE_BE, flags);
/* test, do not write */
- if (test_table(fid,0)<0)
+ if (test_table(fid, 0) < 0)
goto out;
/* close */
H5Fclose(fid);
/*-------------------------------------------------------------------------
- * test3: open a file written in test1 on a little-endian machine
- *-------------------------------------------------------------------------
- */
+ * test3: open a file written in test1 on a little-endian machine
+ *-------------------------------------------------------------------------
+ */
HDputs("Testing table with file open mode (read little-endian data):");
- fid=h5file_open(TEST_FILE_LE,flags);
+ fid = h5file_open(TEST_FILE_LE, flags);
/* test, do not write */
- if (test_table(fid,0)<0)
+ if (test_table(fid, 0) < 0)
goto out;
/* close */
H5Fclose(fid);
/*-------------------------------------------------------------------------
- * test4: open a file written in test1 on the Cray T3 machine
- *-------------------------------------------------------------------------
- */
+ * test4: open a file written in test1 on the Cray T3 machine
+ *-------------------------------------------------------------------------
+ */
HDputs("Testing table with file open mode (read Cray data):");
- fid=h5file_open(TEST_FILE_CRAY,flags);
+ fid = h5file_open(TEST_FILE_CRAY, flags);
/* test, do not write */
- if (test_table(fid,0)<0)
+ if (test_table(fid, 0) < 0)
goto out;
/* close */
@@ -1750,5 +1578,3 @@ out:
H5Fclose(fid);
return 1;
}
-
-