diff options
Diffstat (limited to 'hl/test')
26 files changed, 11248 insertions, 9281 deletions
diff --git a/hl/test/CMakeLists.txt b/hl/test/CMakeLists.txt index b564854..9674457 100644 --- a/hl/test/CMakeLists.txt +++ b/hl/test/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required (VERSION 3.1.0) -PROJECT (HDF5_HL_TEST) +cmake_minimum_required (VERSION 3.18) +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,45 +14,117 @@ 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_NAMING (hl_${hl_name} ${LIB_TYPE}) - TARGET_C_PROPERTIES (hl_${hl_name} ${LIB_TYPE} " " " ") - target_link_libraries (hl_${hl_name} - ${HDF5_HL_LIB_TARGET} - ${HDF5_LIB_TARGET} - ${HDF5_TEST_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_INCLUDE_DIRS};${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 (HL_ADD_EXE) -HL_ADD_EXE (test_ds) -HL_ADD_EXE (test_dset_opt) -HL_ADD_EXE (test_image) + #----------------------------------------------------------------------------- + # 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_lite) -HL_ADD_EXE (test_packet) +HL_ADD_EXE (test_image) +HL_ADD_EXE (test_file_image) HL_ADD_EXE (test_table) +HL_ADD_EXE (test_ds) +HL_ADD_EXE (test_ld) +HL_ADD_EXE (test_dset_append) +HL_ADD_EXE (test_h5do_compat) + +# test_packet has two source files +add_executable (hl_test_packet test_packet.c test_packet_vlen.c) +target_compile_options(hl_test_packet PRIVATE "${HDF5_CMAKE_C_FLAGS}") +target_include_directories (hl_test_packet PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_INCLUDE_DIRS};${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 AND NOT BUILD_SHARED_LIBS) +if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) add_executable (hl_gen_test_ds gen_test_ds.c) - TARGET_NAMING (hl_gen_test_ds ${LIB_TYPE}) - TARGET_C_PROPERTIES (hl_gen_test_ds ${LIB_TYPE} " " " ") - 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_INCLUDE_DIRS};${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_LIB_TARGET} ${HDF5_TEST_LIB_TARGET} + ${HDF5_LIB_TARGET} ) set_target_properties (hl_gen_test_ds PROPERTIES FOLDER test/hl/gen) -endif (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) -include (CMakeTests.cmake) + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_HL_TEST_hl_gen_test_ds_FORMAT hl_gen_test_ds) + endif () + + add_executable (hl_gen_test_ld gen_test_ld.c) + target_compile_options(hl_gen_test_ld PRIVATE "${HDF5_CMAKE_C_FLAGS}") + target_include_directories (hl_gen_test_ld PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + TARGET_C_PROPERTIES (hl_gen_test_ld STATIC) + target_link_libraries (hl_gen_test_ld PRIVATE + ${HDF5_HL_LIB_TARGET} + ${HDF5_TEST_LIB_TARGET} + ${HDF5_LIB_TARGET} + ) + set_target_properties (hl_gen_test_ld PROPERTIES FOLDER test/hl/gen) + + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_HL_TEST_hl_gen_test_ld_FORMAT hl_gen_test_ld) + endif () +endif () + +if (HDF5_TEST_SERIAL) + include (CMakeTests.cmake) +endif () diff --git a/hl/test/CMakeTests.cmake b/hl/test/CMakeTests.cmake index 7d632cc..9d3ff0c 100644 --- a/hl/test/CMakeTests.cmake +++ b/hl/test/CMakeTests.cmake @@ -1,3 +1,14 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# ############################################################################## ############################################################################## @@ -5,69 +16,117 @@ ############################################################################## ############################################################################## +set (HL_REFERENCE_TEST_FILES + dtype_file.txt + image8.txt + sepia.pal + earth.pal + image24pixel.txt + image24plane.txt + usa.wri + test_table_be.h5 + test_table_cray.h5 + test_table_le.h5 + dsdata.txt + dslat.txt + dslon.txt + test_ds_be.h5 + test_ds_be_new_ref.h5 + test_ds_le.h5 + test_ds_le_new_ref.h5 + test_ld.h5 +) + # -------------------------------------------------------------------- -# Macro used to add a unit test +#-- Copy the necessary files. # -------------------------------------------------------------------- -MACRO (HL_ADD_TEST hl_name files) - add_test (NAME HL_${hl_name} COMMAND $<TARGET_FILE:hl_${hl_name}>) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (HL_${hl_name} PROPERTIES DEPENDS ${last_test}) - endif (NOT "${last_test}" STREQUAL "") - - # -------------------------------------------------------------------- - #-- Copy the necessary files. - # -------------------------------------------------------------------- - foreach (h5_file ${files}) - set (dest "${HDF5_HL_TEST_BINARY_DIR}/${h5_file}") - #message (STATUS " Copying HL Test File ${h5_file} to ${dest}") - add_custom_command ( - TARGET hl_${hl_name} - PRE_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${HDF5_HL_TEST_SOURCE_DIR}/${h5_file} ${dest} - ) - - endforeach (h5_file ${HL_REFERENCE_TEST_FILES}) -ENDMACRO (HL_ADD_TEST) +foreach (h5_file ${HL_REFERENCE_TEST_FILES}) + HDFTEST_COPY_FILE("${HDF5_HL_TEST_SOURCE_DIR}/${h5_file}" "${HDF5_HL_TEST_BINARY_DIR}/${h5_file}" "hl_test_files") +endforeach () +add_custom_target(hl_test_files ALL COMMENT "Copying files needed by hl_test tests" DEPENDS ${hl_test_files_list}) # Remove any output file left over from previous test run +set (test_hl_CLEANFILES + combine_tables1.h5 + combine_tables2.h5 + file_img1.h5 + file_img2.h5 + test_append.h5 + h5do_compat.h5 + test_detach.h5 + test_ds1.h5 + test_ds2.h5 + test_ds3.h5 + test_ds4.h5 + test_ds5.h5 + test_ds6.h5 + test_ds7.h5 + test_ds8.h5 + test_ds9.h5 + test_ds10.h5 + test_image1.h5 + test_image2.h5 + test_image3.h5 + test_lite1.h5 + test_lite2.h5 + test_lite3.h5 + test_lite4.h5 + test_packet_compress.h5 + test_packet_table.h5 + test_packet_table_vlen.h5 + testfl_packet_table_vlen.h5 + test_table.h5 +) add_test ( NAME HL_test-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - 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 + COMMAND ${CMAKE_COMMAND} -E remove ${test_hl_CLEANFILES} ) -if (NOT "${last_test}" STREQUAL "") - set_tests_properties (HL_test-clear-objects PROPERTIES DEPENDS ${last_test}) -endif (NOT "${last_test}" STREQUAL "") -set (last_test "HL_test-clear-objects") +set_tests_properties (HL_test-clear-objects PROPERTIES + FIXTURES_SETUP clear_test_hl + WORKING_DIRECTORY ${HDF5_HL_TEST_BINARY_DIR} +) +add_test ( + NAME HL_test-clean-objects + COMMAND ${CMAKE_COMMAND} -E remove ${test_hl_CLEANFILES} +) +set_tests_properties (HL_test-clean-objects PROPERTIES + FIXTURES_CLEANUP clear_test_hl + WORKING_DIRECTORY ${HDF5_HL_TEST_BINARY_DIR} +) + +# -------------------------------------------------------------------- +# 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 ${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" + -D "TEST_SKIP_COMPARE=TRUE" + -D "TEST_OUTPUT=hl_${hl_name}.txt" + #-D "TEST_REFERENCE=hl_${hl_name}.out" + -D "TEST_FOLDER=${HDF5_HL_TEST_BINARY_DIR}" + -P "${HDF_RESOURCES_DIR}/runTest.cmake" + ) + endif () + 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} + ) +endmacro () + +HL_add_test (test_lite ) +HL_add_test (test_image) +HL_add_test (test_file_image) +HL_add_test (test_table) +HL_add_test (test_ds) +HL_add_test (test_packet) +HL_add_test (test_ld) +HL_add_test (test_dset_append) +HL_add_test (test_h5do_compat) -HL_add_test (test_ds "dsdata.txt;dslat.txt;dslon.txt;test_ds_be.h5;test_ds_le.h5") -HL_add_test (test_dset_opt "") -HL_add_test (test_image "image8.txt;sepia.pal;earth.pal;image24pixel.txt;image24plane.txt;usa.wri") -HL_add_test (test_lite "dtype_file.txt") -HL_add_test (test_packet "") -HL_add_test (test_table "test_table_be.h5;test_table_cray.h5;test_table_le.h5") diff --git a/hl/test/COPYING b/hl/test/COPYING deleted file mode 100644 index 6903daf..0000000 --- a/hl/test/COPYING +++ /dev/null @@ -1,16 +0,0 @@ - - Copyright by The HDF Group and - The Board of Trustees of the University of Illinois. - All rights reserved. - - The files and subdirectories in this directory are part of HDF5. - The full HDF5 copyright notice, including terms governing use, - modification, and redistribution, is contained in the files COPYING - and Copyright.html. COPYING can be found at the root of the source - code distribution tree; Copyright.html can be found at the root - level of an installed copy of the electronic HDF5 document set and - is linked from the top-level documents page. It can also be found - at http://www.hdfgroup.org/HDF5/doc/Copyright.html. 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 d472124..55280cd 100644 --- a/hl/test/H5srcdir_str.h.in +++ b/hl/test/H5srcdir_str.h.in @@ -1,16 +1,13 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * + * the COPYING file, which can be found at the root of the source code * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* If you are reading this file and it has a '.h' suffix, it was automatically diff --git a/hl/test/Makefile.am b/hl/test/Makefile.am index 0809deb..1d1cb0f 100644 --- a/hl/test/Makefile.am +++ b/hl/test/Makefile.am @@ -1,16 +1,12 @@ -# # Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. # All rights reserved. # # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in -# the files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from help@hdfgroup.org. +# the COPYING file, which can be found at the root of the source code +# 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. # # ## Makefile.am @@ -29,7 +25,8 @@ LDADD=$(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) # Test programs. These are our main targets. They should be listed in the # order to be executed, generally most specific tests to least specific tests. -TEST_PROG=test_lite test_image test_file_image test_table test_ds test_packet test_dset_opt +TEST_PROG=test_lite test_image test_file_image test_table test_ds test_packet \ + test_ld test_dset_append test_h5do_compat check_PROGRAMS=$(TEST_PROG) # These programs generate test files for the tests. They don't need to be @@ -37,7 +34,7 @@ check_PROGRAMS=$(TEST_PROG) # them in a conditional causes automake to generate rules so that they # can be built by hand. They can also be built by specifying # --enable-build-all at configure time. -BUILD_ALL_PROGS=gen_test_ds +BUILD_ALL_PROGS=gen_test_ds gen_test_ld if BUILD_ALL_CONDITIONAL noinst_PROGRAMS=$(BUILD_ALL_PROGS) @@ -47,6 +44,10 @@ endif CHECK_CLEANFILES+=combine_tables[1-2].h5 test_ds[1-9].h5 test_ds10.h5 \ test_image[1-3].h5 file_img[1-2].h5 test_lite[1-4].h5 test_table.h5 \ test_packet_table.h5 test_packet_compress.h5 test_detach.h5 \ - test_dectris.h5 + test_packet_table_vlen.h5 testfl_packet_table_vlen.h5 test_append.h5 \ + h5do_compat.h5 + +# Sources for test_packet executable +test_packet_SOURCES=test_packet.c test_packet_vlen.c include $(top_srcdir)/config/conclude.am diff --git a/hl/test/Makefile.in b/hl/test/Makefile.in deleted file mode 100644 index 983bb10..0000000 --- a/hl/test/Makefile.in +++ /dev/null @@ -1,1480 +0,0 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2013 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from help@hdfgroup.org. -# -# -# -# HDF5 High-Level Test Makefile(.in) -# - -VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -DIST_COMMON = $(top_srcdir)/config/commence.am \ - $(top_srcdir)/config/conclude.am $(srcdir)/Makefile.in \ - $(srcdir)/Makefile.am $(top_srcdir)/bin/mkinstalldirs \ - $(srcdir)/H5srcdir_str.h.in $(top_srcdir)/bin/depcomp \ - $(top_srcdir)/bin/test-driver COPYING -check_PROGRAMS = $(am__EXEEXT_1) -@BUILD_ALL_CONDITIONAL_TRUE@noinst_PROGRAMS = $(am__EXEEXT_2) -TESTS = $(am__EXEEXT_1) -subdir = hl/test -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/aclocal_cxx.m4 \ - $(top_srcdir)/m4/aclocal_fc.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/bin/mkinstalldirs -CONFIG_HEADER = $(top_builddir)/src/H5config.h -CONFIG_CLEAN_FILES = H5srcdir_str.h -CONFIG_CLEAN_VPATH_FILES = -am__EXEEXT_1 = test_lite$(EXEEXT) test_image$(EXEEXT) \ - test_file_image$(EXEEXT) test_table$(EXEEXT) test_ds$(EXEEXT) \ - test_packet$(EXEEXT) test_dset_opt$(EXEEXT) -am__EXEEXT_2 = gen_test_ds$(EXEEXT) -PROGRAMS = $(noinst_PROGRAMS) -gen_test_ds_SOURCES = gen_test_ds.c -gen_test_ds_OBJECTS = gen_test_ds.$(OBJEXT) -gen_test_ds_LDADD = $(LDADD) -gen_test_ds_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -test_ds_SOURCES = test_ds.c -test_ds_OBJECTS = test_ds.$(OBJEXT) -test_ds_LDADD = $(LDADD) -test_ds_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) -test_dset_opt_SOURCES = test_dset_opt.c -test_dset_opt_OBJECTS = test_dset_opt.$(OBJEXT) -test_dset_opt_LDADD = $(LDADD) -test_dset_opt_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) -test_file_image_SOURCES = test_file_image.c -test_file_image_OBJECTS = test_file_image.$(OBJEXT) -test_file_image_LDADD = $(LDADD) -test_file_image_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) -test_image_SOURCES = test_image.c -test_image_OBJECTS = test_image.$(OBJEXT) -test_image_LDADD = $(LDADD) -test_image_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) -test_lite_SOURCES = test_lite.c -test_lite_OBJECTS = test_lite.$(OBJEXT) -test_lite_LDADD = $(LDADD) -test_lite_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) -test_packet_SOURCES = test_packet.c -test_packet_OBJECTS = test_packet.$(OBJEXT) -test_packet_LDADD = $(LDADD) -test_packet_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) -test_table_SOURCES = test_table.c -test_table_OBJECTS = test_table.$(OBJEXT) -test_table_LDADD = $(LDADD) -test_table_DEPENDENCIES = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src -depcomp = $(SHELL) $(top_srcdir)/bin/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = gen_test_ds.c test_ds.c test_dset_opt.c test_file_image.c \ - test_image.c test_lite.c test_packet.c test_table.c -DIST_SOURCES = gen_test_ds.c test_ds.c test_dset_opt.c \ - test_file_image.c test_image.c test_lite.c test_packet.c \ - test_table.c -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red='[0;31m'; \ - grn='[0;32m'; \ - lgn='[1;32m'; \ - blu='[1;34m'; \ - mgn='[0;35m'; \ - brg='[1m'; \ - std='[m'; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -AM_RECURSIVE_TARGETS = check recheck -TEST_SUITE_LOG = test-suite.log -LOG_DRIVER = $(SHELL) $(top_srcdir)/bin/test-driver -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.sh.log=.log) -SH_LOG_DRIVER = $(SHELL) $(top_srcdir)/bin/test-driver -SH_LOG_COMPILE = $(SH_LOG_COMPILER) $(AM_SH_LOG_FLAGS) $(SH_LOG_FLAGS) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ADD_PARALLEL_FILES = @ADD_PARALLEL_FILES@ -AMTAR = @AMTAR@ - -# H5_CFLAGS holds flags that should be used when building hdf5, -# but which should not be exported to h5cc for building other programs. -# 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@ - -# 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_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@ -AM_LDFLAGS = @AM_LDFLAGS@ @H5_LDFLAGS@ -AM_MAKEFLAGS = @AM_MAKEFLAGS@ -AR = @AR@ -AS = @AS@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BYTESEX = @BYTESEX@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CC_VERSION = @CC_VERSION@ -CFLAGS = @CFLAGS@ -CLEARFILEBUF = @CLEARFILEBUF@ -CODESTACK = @CODESTACK@ -CONFIG_DATE = @CONFIG_DATE@ -CONFIG_MODE = @CONFIG_MODE@ -CONFIG_USER = @CONFIG_USER@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CXX_VERSION = @CXX_VERSION@ -CYGPATH_W = @CYGPATH_W@ -DEBUG_PKG = @DEBUG_PKG@ -DEFAULT_API_VERSION = @DEFAULT_API_VERSION@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@ -DIRECT_VFD = @DIRECT_VFD@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -EXTERNAL_FILTERS = @EXTERNAL_FILTERS@ - -# Make sure that these variables are exported to the Makefiles -F9XMODEXT = @F9XMODEXT@ -F9XMODFLAG = @F9XMODFLAG@ -F9XSUFFIXFLAG = @F9XSUFFIXFLAG@ -FC = @FC@ -FC2003 = @FC2003@ -FCFLAGS = @FCFLAGS@ -FCFLAGS_f90 = @FCFLAGS_f90@ -FCLIBS = @FCLIBS@ -FC_VERSION = @FC_VERSION@ -FGREP = @FGREP@ -FSEARCH_DIRS = @FSEARCH_DIRS@ -GREP = @GREP@ -H5_CFLAGS = @H5_CFLAGS@ -H5_CPPFLAGS = @H5_CPPFLAGS@ -H5_CXXFLAGS = @H5_CXXFLAGS@ -H5_CXX_SHARED = @H5_CXX_SHARED@ -H5_FCFLAGS = @H5_FCFLAGS@ -H5_FORTRAN_SHARED = @H5_FORTRAN_SHARED@ -H5_LDFLAGS = @H5_LDFLAGS@ -H5_LONE_COLON = @H5_LONE_COLON@ -H5_VERSION = @H5_VERSION@ -HADDR_T = @HADDR_T@ -HAVE_DMALLOC = @HAVE_DMALLOC@ -HAVE_FORTRAN_2003 = @HAVE_FORTRAN_2003@ -HAVE_PTHREAD = @HAVE_PTHREAD@ -HDF5_HL = @HDF5_HL@ -HDF5_INTERFACES = @HDF5_INTERFACES@ -HDF_CXX = @HDF_CXX@ -HDF_FORTRAN = @HDF_FORTRAN@ -HDF_FORTRAN2003 = @HDF_FORTRAN2003@ -HID_T = @HID_T@ -HL = @HL@ -HL_FOR = @HL_FOR@ -HSIZE_T = @HSIZE_T@ -HSSIZE_T = @HSSIZE_T@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INSTRUMENT = @INSTRUMENT@ -INSTRUMENT_LIBRARY = @INSTRUMENT_LIBRARY@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LL_PATH = @LL_PATH@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -LT_STATIC_EXEC = @LT_STATIC_EXEC@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MPE = @MPE@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJECT_NAMELEN_DEFAULT_F = @OBJECT_NAMELEN_DEFAULT_F@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PARALLEL = @PARALLEL@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -RANLIB = @RANLIB@ -ROOT = @ROOT@ -RUNPARALLEL = @RUNPARALLEL@ -RUNSERIAL = @RUNSERIAL@ -R_INTEGER = @R_INTEGER@ -R_LARGE = @R_LARGE@ -SEARCH = @SEARCH@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -SIZE_T = @SIZE_T@ -STATIC_EXEC = @STATIC_EXEC@ -STATIC_SHARED = @STATIC_SHARED@ -STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ -STRIP = @STRIP@ -TESTPARALLEL = @TESTPARALLEL@ -THREADSAFE = @THREADSAFE@ -TIME = @TIME@ -TR = @TR@ -TRACE_API = @TRACE_API@ -UNAME_INFO = @UNAME_INFO@ -USE_FILTER_DEFLATE = @USE_FILTER_DEFLATE@ -USE_FILTER_SZIP = @USE_FILTER_SZIP@ -USINGMEMCHECKER = @USINGMEMCHECKER@ -VERSION = @VERSION@ -WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -ac_ct_FC = @ac_ct_FC@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ - -# Install directories that automake doesn't know about -docdir = $(exec_prefix)/doc -dvidir = @dvidir@ -enable_shared = @enable_shared@ -enable_static = @enable_static@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ - -# Shell commands used in Makefiles -RM = rm -f -CP = cp - -# Some machines need a command to run executables; this is that command -# so that our tests will run. -# We use RUNEXEC instead of RUNSERIAL directly because it may be that -# some tests need to be run with a different command. Older versions -# of the makefiles used the command -# $(LIBTOOL) --mode=execute -# in some directories, for instance. -RUNEXEC = $(RUNSERIAL) - -# Libraries to link to while building -LIBHDF5 = $(top_builddir)/src/libhdf5.la -LIBH5TEST = $(top_builddir)/test/libh5test.la -LIBH5F = $(top_builddir)/fortran/src/libhdf5_fortran.la -LIBH5FTEST = $(top_builddir)/fortran/test/libh5test_fortran.la -LIBH5CPP = $(top_builddir)/c++/src/libhdf5_cpp.la -LIBH5TOOLS = $(top_builddir)/tools/lib/libh5tools.la -LIBH5_HL = $(top_builddir)/hl/src/libhdf5_hl.la -LIBH5F_HL = $(top_builddir)/hl/fortran/src/libhdf5hl_fortran.la -LIBH5CPP_HL = $(top_builddir)/hl/c++/src/libhdf5_hl_cpp.la - -# Note that in svn revision 19400 the '/' after DESTDIR in H5* variables below -# has been removed. According to the official description of DESTDIR by Gnu at -# http://www.gnu.org/prep/standards/html_node/DESTDIR.html, DESTDIR is -# prepended to the normal and complete install path that it precedes for the -# purpose of installing in a temporary directory which is useful for building -# rpms and other packages. The '/' after ${DESTDIR} will be followed by another -# '/' at the beginning of the normal install path. When DESTDIR is empty the -# path then begins with '//', which is incorrect and causes problems at least for -# Cygwin. - -# Scripts used to build examples -# If only shared libraries have been installed, have h5cc build examples with -# shared libraries instead of static libraries -H5CC = ${DESTDIR}$(bindir)/h5cc -H5CC_PP = ${DESTDIR}$(bindir)/h5pcc -H5FC = ${DESTDIR}$(bindir)/h5fc -H5FC_PP = ${DESTDIR}$(bindir)/h5pfc -H5CPP = ${DESTDIR}$(bindir)/h5c++ -ACLOCAL_AMFLAGS = "-I m4" - -# The trace script; this is used on source files from the C library to -# insert tracing macros. -TRACE = perl $(top_srcdir)/bin/trace - -# .chkexe files are used to mark tests that have run successfully. -# .chklog files are output from those tests. -# *.clog and *.clog2 are from the MPE option. - -# Temporary files. These files are the ones created by running `make test'. -CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.clog2 \ - combine_tables[1-2].h5 test_ds[1-9].h5 test_ds10.h5 \ - test_image[1-3].h5 file_img[1-2].h5 test_lite[1-4].h5 \ - test_table.h5 test_packet_table.h5 test_packet_compress.h5 \ - test_detach.h5 test_dectris.h5 - -# The tests depend on the hdf5, hdf5 test, and hdf5_hl libraries -LDADD = $(LIBH5_HL) $(LIBH5TEST) $(LIBHDF5) - -# Test programs. These are our main targets. They should be listed in the -# order to be executed, generally most specific tests to least specific tests. -TEST_PROG = test_lite test_image test_file_image test_table test_ds test_packet test_dset_opt - -# These programs generate test files for the tests. They don't need to be -# compiled every time we want to test the library. However, putting -# them in a conditional causes automake to generate rules so that they -# can be built by hand. They can also be built by specifying -# --enable-build-all at configure time. -BUILD_ALL_PROGS = gen_test_ds - -# 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. -LIB = $(lib_LIBRARIES) $(lib_LTLIBRARIES) $(noinst_LIBRARIES) \ - $(noinst_LTLIBRARIES) $(check_LIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LIB) - -PROGS = $(bin_PROGRAMS) $(bin_SCRIPTS) $(noinst_PROGRAMS) $(noinst_SCRIPTS) \ - $(EXTRA_PROG) - -chk_TESTS = $(check_PROGRAMS) $(check_SCRIPTS) $(EXTRA_TEST) -TEST_EXTENSIONS = .sh -SH_LOG_COMPILER = $(SHELL) -AM_SH_LOG_FLAGS = -TEST_PROG_CHKEXE = $(TEST_PROG:=.chkexe_) -TEST_PROG_PARA_CHKEXE = $(TEST_PROG_PARA:=.chkexe_) -TEST_SCRIPT_CHKSH = $(TEST_SCRIPT:=.chkexe_) -TEST_SCRIPT_PARA_CHKSH = $(TEST_SCRIPT_PARA:=.chkexe_) -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .sh .sh$(EXEEXT) .trs -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/conclude.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hl/test/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign hl/test/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; -$(top_srcdir)/config/commence.am $(top_srcdir)/config/conclude.am: - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): -H5srcdir_str.h: $(top_builddir)/config.status $(srcdir)/H5srcdir_str.h.in - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ - -clean-checkPROGRAMS: - @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -gen_test_ds$(EXEEXT): $(gen_test_ds_OBJECTS) $(gen_test_ds_DEPENDENCIES) $(EXTRA_gen_test_ds_DEPENDENCIES) - @rm -f gen_test_ds$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(gen_test_ds_OBJECTS) $(gen_test_ds_LDADD) $(LIBS) - -test_ds$(EXEEXT): $(test_ds_OBJECTS) $(test_ds_DEPENDENCIES) $(EXTRA_test_ds_DEPENDENCIES) - @rm -f test_ds$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_ds_OBJECTS) $(test_ds_LDADD) $(LIBS) - -test_dset_opt$(EXEEXT): $(test_dset_opt_OBJECTS) $(test_dset_opt_DEPENDENCIES) $(EXTRA_test_dset_opt_DEPENDENCIES) - @rm -f test_dset_opt$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_dset_opt_OBJECTS) $(test_dset_opt_LDADD) $(LIBS) - -test_file_image$(EXEEXT): $(test_file_image_OBJECTS) $(test_file_image_DEPENDENCIES) $(EXTRA_test_file_image_DEPENDENCIES) - @rm -f test_file_image$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_file_image_OBJECTS) $(test_file_image_LDADD) $(LIBS) - -test_image$(EXEEXT): $(test_image_OBJECTS) $(test_image_DEPENDENCIES) $(EXTRA_test_image_DEPENDENCIES) - @rm -f test_image$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_image_OBJECTS) $(test_image_LDADD) $(LIBS) - -test_lite$(EXEEXT): $(test_lite_OBJECTS) $(test_lite_DEPENDENCIES) $(EXTRA_test_lite_DEPENDENCIES) - @rm -f test_lite$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_lite_OBJECTS) $(test_lite_LDADD) $(LIBS) - -test_packet$(EXEEXT): $(test_packet_OBJECTS) $(test_packet_DEPENDENCIES) $(EXTRA_test_packet_DEPENDENCIES) - @rm -f test_packet$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_packet_OBJECTS) $(test_packet_LDADD) $(LIBS) - -test_table$(EXEEXT): $(test_table_OBJECTS) $(test_table_DEPENDENCIES) $(EXTRA_test_table_DEPENDENCIES) - @rm -f test_table$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_table_OBJECTS) $(test_table_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_test_ds.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_ds.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_dset_opt.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_file_image.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_image.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_lite.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_packet.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_table.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - else \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 -recheck: all $(check_PROGRAMS) - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -test_lite.log: test_lite$(EXEEXT) - @p='test_lite$(EXEEXT)'; \ - b='test_lite'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test_image.log: test_image$(EXEEXT) - @p='test_image$(EXEEXT)'; \ - b='test_image'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test_file_image.log: test_file_image$(EXEEXT) - @p='test_file_image$(EXEEXT)'; \ - b='test_file_image'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test_table.log: test_table$(EXEEXT) - @p='test_table$(EXEEXT)'; \ - b='test_table'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test_ds.log: test_ds$(EXEEXT) - @p='test_ds$(EXEEXT)'; \ - b='test_ds'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test_packet.log: test_packet$(EXEEXT) - @p='test_packet$(EXEEXT)'; \ - b='test_packet'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test_dset_opt.log: test_dset_opt$(EXEEXT) - @p='test_dset_opt$(EXEEXT)'; \ - b='test_dset_opt'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.sh.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(SH_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_SH_LOG_DRIVER_FLAGS) $(SH_LOG_DRIVER_FLAGS) -- $(SH_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.sh$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(SH_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_SH_LOG_DRIVER_FLAGS) $(SH_LOG_DRIVER_FLAGS) -- $(SH_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-am -all-am: Makefile $(PROGRAMS) all-local -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ - clean-noinstPROGRAMS mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool mostlyclean-local - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am all-local check check-TESTS \ - check-am clean clean-checkPROGRAMS clean-generic clean-libtool \ - clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - mostlyclean-local pdf pdf-am ps ps-am recheck tags tags-am \ - uninstall uninstall-am - - -# List all build rules defined by HDF5 Makefiles as "PHONY" targets here. -# This tells the Makefiles that these targets are not files to be built but -# commands that should be executed even if a file with the same name already -# exists. -.PHONY: build-check-clean build-check-p build-check-s build-lib build-progs \ - build-tests check-clean check-install check-p check-s check-vfd \ - install-doc lib progs tests uninstall-doc _exec_check-s _test help - -help: - @$(top_srcdir)/bin/makehelp - -# lib/progs/tests targets recurse into subdirectories. build-* targets -# build files in this directory. -build-lib: $(LIB) -build-progs: $(LIB) $(PROGS) -build-tests: $(LIB) $(PROGS) $(chk_TESTS) - -# General rule for recursive building targets. -# BUILT_SOURCES contain targets that need to be built before anything else -# in the directory (e.g., for Fortran type detection) -lib progs tests check-s check-p :: $(BUILT_SOURCES) - @$(MAKE) $(AM_MAKEFLAGS) build-$@ || exit 1; - @for d in X $(SUBDIRS); do \ - if test $$d != X && test $$d != .; then \ - (set -x; cd $$d && $(MAKE) $(AM_MAKEFLAGS) $@) || exit 1; \ - fi; \ - done - -# General rule for recursive cleaning targets. Like the rule above, -# but doesn't require building BUILT_SOURCES. -check-clean :: - @$(MAKE) $(AM_MAKEFLAGS) build-$@ || exit 1; - @for d in X $(SUBDIRS); do \ - if test $$d != X && test $$d != .; then \ - (set -x; cd $$d && $(MAKE) $(AM_MAKEFLAGS) $@) || exit 1; \ - fi; \ - done - -# Tell Automake to build tests when the user types `make all' (this is -# not its default behavior). Also build EXTRA_LIB and EXTRA_PROG since -# Automake won't build them automatically, either. -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. -install-doc uninstall-doc: - @echo "Nothing to be done." - -# clean up files generated by tests so they can be re-run. -build-check-clean: - $(RM) -rf $(CHECK_CLEANFILES) - -# run check-clean whenever mostlyclean is run -mostlyclean-local: build-check-clean - -# check-install is just a synonym for installcheck -check-install: installcheck - -# Run each test in order, passing $(TEST_FLAGS) to the program. -# Since tests are done in a shell loop, "make -i" does apply inside it. -# Set HDF5_Make_Ignore to a non-blank string to ignore errors inside the loop. -# The timestamps give a rough idea how much time the tests use. -# -# Note that targets in chk_TESTS (defined above) will be built when the user -# types 'make tests' or 'make check', but only programs in TEST_PROG, -# TEST_PROG_PARA, or TEST_SCRIPT will actually be executed. -check-TESTS: test - -test _test: - @$(MAKE) build-check-s - @$(MAKE) build-check-p - -# Actual execution of check-s. -build-check-s: $(LIB) $(PROGS) $(chk_TESTS) - @if test -n "$(TEST_PROG)$(TEST_SCRIPT)"; then \ - echo "===Serial tests in `echo ${PWD} | sed -e s:.*/::` begin `date`==="; \ - fi - @$(MAKE) $(AM_MAKEFLAGS) _exec_check-s - @if test -n "$(TEST_PROG)$(TEST_SCRIPT)"; then \ - echo "===Serial tests in `echo ${PWD} | sed -e s:.*/::` ended `date`===";\ - fi - -_exec_check-s: $(TEST_PROG_CHKEXE) $(TEST_SCRIPT_CHKSH) - -# The dummy.chkexe here prevents the target from being -# empty if there are no tests in the current directory. -# $${log} is the log file. -# $${tname} is the name of test. -$(TEST_PROG_CHKEXE) $(TEST_PROG_PARA_CHKEXE) dummy.chkexe_: - @if test "X$@" != "X.chkexe_" && test "X$@" != "Xdummy.chkexe_"; then \ - tname=$(@:.chkexe_=)$(EXEEXT);\ - log=$(@:.chkexe_=.chklog); \ - echo "============================"; \ - if $(top_srcdir)/bin/newer $(@:.chkexe_=.chkexe) $${tname}; then \ - echo "No need to test $${tname} again."; \ - else \ - echo "============================" > $${log}; \ - if test "X$(FORTRAN_API)" = "Xyes"; then \ - echo "Fortran API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ - echo "Fortran API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ - elif test "X$(CXX_API)" = "Xyes"; then \ - echo "C++ API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ - echo "C++ API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log};\ - else \ - echo "Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ - echo "$(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ - fi; \ - echo "============================" >> $${log}; \ - srcdir="$(srcdir)" \ - $(TIME) $(RUNEXEC) ./$${tname} $(TEST_FLAGS) >> $${log} 2>&1 \ - && touch $(@:.chkexe_=.chkexe) || \ - (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ - (cat $${log} && false) || exit 1; \ - echo "" >> $${log}; \ - echo "Finished testing $${tname} $(TEST_FLAGS)" >> $${log}; \ - echo "============================" >> $${log}; \ - echo "Finished testing $${tname} $(TEST_FLAGS)"; \ - cat $${log}; \ - fi; \ - fi - -# The dummysh.chkexe here prevents the target from being -# empty if there are no tests in the current directory. -# $${log} is the log file. -# $${tname} is the name of test. -$(TEST_SCRIPT_CHKSH) $(TEST_SCRIPT_PARA_CHKSH) dummysh.chkexe_: - @if test "X$@" != "X.chkexe_" && test "X$@" != "Xdummysh.chkexe_"; then \ - cmd=$(@:.chkexe_=);\ - tname=`basename $$cmd`;\ - chkname=`basename $(@:.chkexe_=.chkexe)`;\ - log=`basename $(@:.chkexe_=.chklog)`; \ - echo "============================"; \ - if $(top_srcdir)/bin/newer $${chkname} $$cmd $(SCRIPT_DEPEND); then \ - echo "No need to test $${tname} again."; \ - else \ - echo "============================" > $${log}; \ - if test "X$(FORTRAN_API)" = "Xyes"; then \ - echo "Fortran API: Testing $${tname} $(TEST_FLAGS)"; \ - echo "Fortran API: $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ - elif test "X$(CXX_API)" = "Xyes"; then \ - echo "C++ API: Testing $${tname} $(TEST_FLAGS)"; \ - echo "C++ API: $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ - else \ - echo "Testing $${tname} $(TEST_FLAGS)"; \ - echo "$${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ - fi; \ - echo "============================" >> $${log}; \ - RUNSERIAL="$(RUNSERIAL)" RUNPARALLEL="$(RUNPARALLEL)" \ - srcdir="$(srcdir)" \ - $(TIME) $(SHELL) $$cmd $(TEST_FLAGS) >> $${log} 2>&1 \ - && touch $${chkname} || \ - (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ - (cat $${log} && false) || exit 1; \ - echo "" >> $${log}; \ - echo "Finished testing $${tname} $(TEST_FLAGS)" >> $${log}; \ - echo "============================" >> $${log}; \ - echo "Finished testing $${tname} $(TEST_FLAGS)"; \ - cat $${log}; \ - fi; \ - echo "============================"; \ - fi - -# Actual execution of check-p. -build-check-p: $(LIB) $(PROGS) $(chk_TESTS) - @if test -n "$(TEST_PROG_PARA)$(TEST_SCRIPT_PARA)"; then \ - echo "===Parallel tests in `echo ${PWD} | sed -e s:.*/::` begin `date`==="; \ - fi - @if test -n "$(TEST_PROG_PARA)"; then \ - echo "**** Hint ****"; \ - echo "Parallel test files reside in the current directory" \ - "by default."; \ - echo "Set HDF5_PARAPREFIX to use another directory. E.g.,"; \ - echo " HDF5_PARAPREFIX=/PFS/user/me"; \ - echo " export HDF5_PARAPREFIX"; \ - echo " make check"; \ - echo "**** end of Hint ****"; \ - fi - @for test in $(TEST_PROG_PARA) dummy; do \ - if test $$test != dummy; then \ - $(MAKE) $(AM_MAKEFLAGS) $$test.chkexe_ \ - RUNEXEC="$(RUNPARALLEL)" || exit 1; \ - fi; \ - done - @for test in $(TEST_SCRIPT_PARA) dummy; do \ - if test $$test != dummy; then \ - $(MAKE) $(AM_MAKEFLAGS) $$test.chkexe_ || exit 1; \ - fi; \ - done - @if test -n "$(TEST_PROG_PARA)$(TEST_SCRIPT_PARA)"; then \ - echo "===Parallel tests in `echo ${PWD} | sed -e s:.*/::` ended `date`===";\ - fi - -# Run test with different Virtual File Driver -check-vfd: $(LIB) $(PROGS) $(chk_TESTS) - @for vfd in $(VFD_LIST) dummy; do \ - if test $$vfd != dummy; then \ - echo "============================"; \ - echo "Testing Virtual File Driver $$vfd"; \ - echo "============================"; \ - $(MAKE) $(AM_MAKEFLAGS) check-clean || exit 1; \ - HDF5_DRIVER=$$vfd $(MAKE) $(AM_MAKEFLAGS) check || exit 1; \ - fi; \ - done - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/hl/test/dectris_hl_perf.c b/hl/test/dectris_hl_perf.c deleted file mode 100644 index d62926a..0000000 --- a/hl/test/dectris_hl_perf.c +++ /dev/null @@ -1,642 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * This test is for the DECTRIS project to the H5DOwrite_chunk function - * - */ - -#include "hdf5_hl.h" -#include <zlib.h> -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#include <errno.h> - -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]; -unsigned int *outbuf[NX]; -size_t data_size[NX]; -double total_size = 0.0; -unsigned int *direct_buf[NX]; -double MB = 1048576.0; - -/*-------------------------------------------------- - * Function to report IO rate - *-------------------------------------------------- - */ -void reportTime(struct timeval start, double mbytes) -{ - struct timeval timeval_stop,timeval_diff; - - /*end timing*/ - 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; - - 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))); -} - -/*-------------------------------------------------- - * Create file, datasets, and initialize data - *-------------------------------------------------- - */ -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; - - int flag; - int unix_file; - - unsigned int *p; - 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; - - TESTING("Create a file and dataset"); - - /* - * Create the data space with unlimited dimensions. - */ - 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) - TEST_ERROR; - - /* - * Modify dataset creation properties, i.e. enable chunking and compression - */ - if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) - TEST_ERROR; - - 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) - TEST_ERROR; - - if(H5Dclose(dataset) < 0) - TEST_ERROR; - - if((dataset = H5Dcreate2(file, REG_NO_COMPRESS_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) - TEST_ERROR; - - if(H5Dclose(dataset) < 0) - TEST_ERROR; - - /* Set compression */ - 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) - TEST_ERROR; - - if(H5Dclose(dataset) < 0) - TEST_ERROR; - - - if((dataset = H5Dcreate2(file, REG_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) - TEST_ERROR; - - if(H5Dclose(dataset) < 0) - TEST_ERROR; - - if(H5Fclose(file) < 0) - TEST_ERROR; - - if(H5Sclose(dataspace) < 0) - TEST_ERROR; - - if(H5Pclose(cparms) < 0) - TEST_ERROR; - - /* create a unix file*/ - flag = O_CREAT|O_TRUNC|O_WRONLY; - - if ((unix_file=open(FILENAME[1],flag,S_IRWXU))== -1) - TEST_ERROR; - - 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++) - *p = rand() % 65000; - - 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]; - - /* Perform compression from the source to the destination buffer */ - ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression); - - data_size[i] = (size_t)z_dst_nbytes; - total_size += data_size[i]; - - /* Check for various zlib errors */ - if(Z_BUF_ERROR == ret) { - fprintf(stderr, "overflow"); - TEST_ERROR; - } else if(Z_MEM_ERROR == ret) { - fprintf(stderr, "deflate memory error"); - TEST_ERROR; - } else if(Z_OK != ret) { - fprintf(stderr, "other deflate error"); - TEST_ERROR; - } - } - - - PASSED(); - -error: - H5E_BEGIN_TRY { - H5Dclose(dataset); - H5Sclose(dataspace); - H5Pclose(cparms); - H5Fclose(file); - } H5E_END_TRY; - return 1; -} - -/*-------------------------------------------------- - * 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; - - unsigned filter_mask = 0; - hsize_t offset[RANK] = {0, 0, 0}; - - struct timeval timeval_start; - - TESTING("H5DOwrite_chunk for uncompressed data"); - - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) - TEST_ERROR; - - /* Start the timer */ - gettimeofday(&timeval_start,NULL); - - /* Reopen the file and dataset */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) - TEST_ERROR; - - 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]); - (offset[0])++; - } - - /* - * Close/release resources. - */ - H5Dclose(dataset); - H5Pclose(dxpl); - H5Fclose(file); - - /* Report the performance */ - reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB)); - - PASSED(); - return 0; - -error: - H5E_BEGIN_TRY { - H5Dclose(dataset); - H5Pclose(dxpl); - H5Fclose(file); - } H5E_END_TRY; - return 1; -} - - -/*-------------------------------------------------- - * 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; - - unsigned filter_mask = 0; - hsize_t offset[RANK] = {0, 0, 0}; - - struct timeval timeval_start; - - TESTING("H5DOwrite_chunk for pre-compressed data"); - - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) - TEST_ERROR; - - /* Start the timer */ - gettimeofday(&timeval_start,NULL); - - /* Reopen the file and dataset */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) - TEST_ERROR; - - 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++) { - status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, data_size[i], outbuf[i]); - (offset[0])++; - } - - /* - * Close/release resources. - */ - H5Dclose(dataset); - H5Pclose(dxpl); - H5Fclose(file); - - /* Report the performance */ - reportTime(timeval_start, (double)(total_size/MB)); - - PASSED(); - return 0; - -error: - H5E_BEGIN_TRY { - H5Dclose(dataset); - H5Pclose(dxpl); - H5Fclose(file); - } H5E_END_TRY; - return 1; -} - -/*-------------------------------------------------- - * Benchmark the performance of the regular H5Dwrite - * with compression filter enabled. - *-------------------------------------------------- - */ -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; - - 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; - - TESTING("H5Dwrite with compression enabled"); - - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) - TEST_ERROR; - - if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) - TEST_ERROR; - - /* Start the timer */ - gettimeofday(&timeval_start,NULL); - - /* Reopen the file and dataset */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) - TEST_ERROR; - - if((dataset = H5Dopen2(file, REG_COMPRESSED_DSET, H5P_DEFAULT)) < 0) - TEST_ERROR; - - if((dataspace = H5Dget_space(dataset)) < 0) - TEST_ERROR; - - 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++) { - /* - * Select hyperslab for one chunk in the file - */ - if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0) - TEST_ERROR; - (start[0])++; - - if((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace, - H5P_DEFAULT, direct_buf[i])) < 0) - TEST_ERROR; - } - - /* - * Close/release resources. - */ - H5Dclose(dataset); - H5Sclose(dataspace); - H5Sclose(mem_space); - H5Pclose(dxpl); - H5Fclose(file); - - /* Report the performance */ - reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB)); - - PASSED(); - return 0; - -error: - H5E_BEGIN_TRY { - H5Dclose(dataset); - H5Sclose(dataspace); - H5Sclose(mem_space); - H5Pclose(dxpl); - H5Fclose(file); - } H5E_END_TRY; - return 1; -} - -/*-------------------------------------------------- - * Benchmark the performance of the regular H5Dwrite - * with compression - *-------------------------------------------------- - */ -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; - - 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; - - TESTING("H5Dwrite without compression"); - - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) - TEST_ERROR; - - if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) - TEST_ERROR; - - /* Start the timer */ - gettimeofday(&timeval_start,NULL); - - /* Reopen the file and dataset */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) - TEST_ERROR; - - if((dataset = H5Dopen2(file, REG_NO_COMPRESS_DSET, H5P_DEFAULT)) < 0) - TEST_ERROR; - - if((dataspace = H5Dget_space(dataset)) < 0) - TEST_ERROR; - - 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++) { - /* - * Select hyperslab for one chunk in the file - */ - if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0) - TEST_ERROR; - (start[0])++; - - if((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace, - H5P_DEFAULT, direct_buf[i])) < 0) - TEST_ERROR; - } - - /* - * Close/release resources. - */ - H5Dclose(dataset); - H5Sclose(dataspace); - H5Sclose(mem_space); - H5Pclose(dxpl); - H5Fclose(file); - - /* Report the performance */ - reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB)); - - PASSED(); - return 0; - -error: - H5E_BEGIN_TRY { - H5Dclose(dataset); - H5Sclose(dataspace); - H5Sclose(mem_space); - H5Pclose(dxpl); - H5Fclose(file); - } H5E_END_TRY; - return 1; -} - -/*-------------------------------------------------- - * Benchmark the performance for writing compressed - * data to a Unix file - *-------------------------------------------------- - */ -int -test_unix_write(void) -{ - int file, flag; - ssize_t op_size; - int i; - struct timeval timeval_start; - - TESTING("Write compressed data to a Unix file"); - - /* create file*/ - flag = O_WRONLY; - - /* Start the timer */ - gettimeofday(&timeval_start,NULL); - - 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) - { - printf(" Error in writing data to file because %s \n", strerror(errno)); - TEST_ERROR; - } - else if (op_size == 0) - { - printf(" unable to write sufficent data to file because %s \n", strerror(errno)); - TEST_ERROR; - } - } - - if (close(file) < 0) - { - printf(" unable to close the file\n"); - TEST_ERROR; - } - - /* Report the performance */ - reportTime(timeval_start, (double)(total_size/MB)); - - PASSED(); - return 0; - -error: - return 1; -} - -/*-------------------------------------------------- - * Main function - *-------------------------------------------------- - */ -int -main (void) -{ - hid_t fapl = H5P_DEFAULT; - int i; - - /* Testing setup */ -/* h5_reset(); - fapl = h5_fileaccess(); - - h5_fixname(FILENAME[0], fapl, filename, sizeof filename);*/ - - sprintf(filename, "%s.h5", FILENAME[0]); - - create_file(fapl); - test_direct_write_uncompressed_data(fapl); - test_direct_write_compressed_data(fapl); - test_no_compress_write(fapl); - test_compressed_write(fapl); - test_unix_write(); - - for(i=0; i<NX; i++) { - free(outbuf[i]); - free(direct_buf[i]); - } - -/* h5_cleanup(FILENAME, fapl);*/ - return 0; -} diff --git a/hl/test/gen_test_ds.c b/hl/test/gen_test_ds.c index 2fc8140..e0a3499 100644 --- a/hl/test/gen_test_ds.c +++ b/hl/test/gen_test_ds.c @@ -1,16 +1,13 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * + * the COPYING file, which can be found at the root of the source code * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* @@ -25,17 +22,15 @@ * in test_ds.c will read them. */ -#include <stdlib.h> -#include <string.h> #include "h5hltest.h" #include "H5DSpublic.h" #include "H5LTpublic.h" /* 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); @@ -45,48 +40,51 @@ 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_" +#ifdef H5_DIMENSION_SCALES_WITH_NEW_REF +#define FILEEXT "_new_ref.h5" +#else +#define FILEEXT ".h5" +#endif /*------------------------------------------------------------------------- * 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"); + if (argc < 2 || !argv[0] || !argv[1]) { + 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; } @@ -94,26 +92,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]; @@ -129,191 +129,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 @@ -325,56 +331,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 @@ -386,71 +395,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 @@ -462,72 +475,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 @@ -539,43 +556,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(); @@ -584,10 +604,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/gen_test_ld.c b/hl/test/gen_test_ld.c new file mode 100644 index 0000000..8eacf55 --- /dev/null +++ b/hl/test/gen_test_ld.c @@ -0,0 +1,404 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include "hdf5.h" +#include "H5LDprivate.h" + +/* + * WATCH.h5: file with various types of datasets for testing-- + * + * The following datasets are chunked, H5D_ALLOC_TIME_INCR, max. dimensional setting: + * DSET_ONE: one-dimensional dataset + * DSET_TWO: two-dimensional dataset + * DSET_CMPD: one-dimensional dataset with compound type + * DSET_CMPD_ESC: one-dimensional dataset with compound type and member names with + * escape/separator characters + * DSET_CMPD_TWO: two-dimensional dataset with compound type + * + * The following datasets are one-dimensional, chunked, max. dimension setting: + * DSET_ALLOC_EARLY: dataset with H5D_ALLOC_TIME_EARLY + * DSET_ALLOC_LATE: dataset H5D_ALLOC_TIME_LATE + * + * The following datasets are one-dimensional: + * DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE + * DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR + */ +#define ONE_DIMS0 10 +#define MAX_ONE_DIMS0 100 + +#define DSET_ONE "DSET_ONE" +#define DSET_NONE "DSET_NONE" +#define DSET_NOMAX "DSET_NOMAX" +#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" +#define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY" +#define DSET_CMPD "DSET_CMPD" +#define DSET_CMPD_ESC "DSET_CMPD_ESC" +#define DSET_NULL "DSET_NULL" +#define DSET_SCALAR "DSET_SCALAR" + +#define TWO_DIMS0 4 +#define TWO_DIMS1 10 +#define MAX_TWO_DIMS0 60 +#define MAX_TWO_DIMS1 100 + +#define DSET_TWO "DSET_TWO" +#define DSET_CMPD_TWO "DSET_CMPD_TWO" + +#define CHUNK_SIZE 2 + +#define FILE "test_ld.h5" + +/* Data structures for datasets with compound types */ +typedef struct sub22_t { + unsigned int a; + unsigned int b; + unsigned int c; +} sub22_t; + +typedef struct sub2_t { + unsigned int a; + sub22_t b; + unsigned int c; +} sub2_t; + +typedef struct sub4_t { + unsigned int a; + unsigned int b; +} sub4_t; + +typedef struct set_t { + unsigned int field1; + sub2_t field2; + double field3; + sub4_t field4; +} set_t; + +/* + ************************************************************************************** + * + * Create a dataset with the given input parameters + * Write to the dataset with the given "data" + * + ************************************************************************************** + */ +static int +generate_dset(hid_t fid, const char *dname, int ndims, hsize_t *dims, hsize_t *maxdims, hid_t dtid, + void *data) +{ + hid_t dcpl = -1; /* Dataset creation property */ + hid_t did = -1; /* Dataset id */ + hid_t sid = -1; /* Dataspace id */ + int i; /* Local index variable */ + + /* Create the dataspace */ + if ((sid = H5Screate_simple(ndims, dims, maxdims)) < 0) + goto done; + + /* Set up dataset's creation properties */ + if (!HDstrcmp(dname, DSET_NONE)) + dcpl = H5P_DEFAULT; + else { + hsize_t chunk_dims[H5S_MAX_RANK]; /* Dimension sizes for chunks */ + + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto done; + for (i = 0; i < ndims; i++) + chunk_dims[i] = CHUNK_SIZE; + if (H5Pset_chunk(dcpl, ndims, chunk_dims) < 0) + goto done; + } /* end else */ + + if (!HDstrcmp(dname, DSET_ALLOC_LATE)) { + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) + goto done; + } /* end if */ + else if (!HDstrcmp(dname, DSET_ALLOC_EARLY)) { + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + goto done; + } /* end if */ + + /* Create the dataset */ + if ((did = H5Dcreate2(fid, dname, dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto done; + + /* Write to the dataset */ + if (H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + goto done; + + /* Closing */ + if (H5Pclose(dcpl) < 0) + goto done; + if (H5Sclose(sid) < 0) + goto done; + if (H5Dclose(did) < 0) + goto done; + + return (SUCCEED); + +done: + H5E_BEGIN_TRY + H5Sclose(sid); + H5Pclose(dcpl); + H5Dclose(did); + H5E_END_TRY + + return (FAIL); +} /* generate_dset() */ + +int +main(void) +{ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + hsize_t cur_dims[1]; /* Dimension sizes */ + hsize_t max_dims[1]; /* Maximum dimension sizes */ + hsize_t cur2_dims[2]; /* Current dimension sizes */ + hsize_t max2_dims[2]; /* Maximum dimension sizes */ + hid_t set_tid = H5I_INVALID_HID; /* Compound type ID */ + hid_t esc_set_tid = H5I_INVALID_HID; /* Compound type ID */ + hid_t sub22_tid = H5I_INVALID_HID; /* Compound type ID */ + hid_t sub2_tid = H5I_INVALID_HID; /* Compound type ID */ + hid_t esc_sub2_tid = H5I_INVALID_HID; /* Compound type ID */ + hid_t sub4_tid = H5I_INVALID_HID; /* Compound type ID */ + hid_t esc_sub4_tid = H5I_INVALID_HID; /* Compound type ID */ + hid_t null_did = H5I_INVALID_HID; /* H5S_NULL dataset ID */ + hid_t null_sid = H5I_INVALID_HID; /* H5S_NULL dataspace ID */ + hid_t scalar_did = H5I_INVALID_HID; /* H5S_SCALAR dataset ID */ + hid_t scalar_sid = H5I_INVALID_HID; /* H5S_SCALAR dataspace ID */ + int one_data[ONE_DIMS0]; /* Buffer for data */ + int two_data[TWO_DIMS0 * TWO_DIMS1]; /* Buffer for data */ + set_t one_cbuf[ONE_DIMS0]; /* Buffer for data with compound type */ + set_t two_cbuf[TWO_DIMS0 * TWO_DIMS1]; /* Buffer for data with compound type */ + + /* Create a file access property list */ + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto done; + + /* Set to use latest library format */ + if ((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0) + goto done; + + /* Create a file */ + if ((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto done; + + /* Initialization for one-dimensional dataset */ + cur_dims[0] = ONE_DIMS0; + max_dims[0] = MAX_ONE_DIMS0; + for (int i = 0; i < ONE_DIMS0; i++) + one_data[i] = i; + + /* Generate DSET_ONE, DSET_NONE, DSET_NOMAX, DSET_ALLOC_LATE, DSET_EARLY */ + if (generate_dset(fid, DSET_ONE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + goto done; + if (generate_dset(fid, DSET_NONE, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) + goto done; + if (generate_dset(fid, DSET_NOMAX, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) + goto done; + if (generate_dset(fid, DSET_ALLOC_LATE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + goto done; + if (generate_dset(fid, DSET_ALLOC_EARLY, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + goto done; + + /* Initialization for two-dimensional dataset */ + cur2_dims[0] = TWO_DIMS0; + cur2_dims[1] = TWO_DIMS1; + max2_dims[0] = MAX_TWO_DIMS0; + max2_dims[1] = MAX_TWO_DIMS1; + + for (int i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) + two_data[i] = i; + + /* Generate DSET_TWO */ + if (generate_dset(fid, DSET_TWO, 2, cur2_dims, max2_dims, H5T_NATIVE_INT, two_data) < 0) + goto done; + + /* Initialization for one-dimensional compound typed dataset */ + cur_dims[0] = ONE_DIMS0; + max_dims[0] = MAX_ONE_DIMS0; + + for (int i = 0; i < ONE_DIMS0; i++) { + one_cbuf[i].field1 = 1; + one_cbuf[i].field2.a = 2; + one_cbuf[i].field2.c = 4; + one_cbuf[i].field2.b.a = 20; + one_cbuf[i].field2.b.b = 40; + one_cbuf[i].field2.b.c = 80; + one_cbuf[i].field3 = 3.0; + one_cbuf[i].field4.a = 4; + one_cbuf[i].field4.b = 8; + } + + /* Create the compound type */ + if ((sub22_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub22_t))) < 0) + goto done; + if (H5Tinsert(sub22_tid, "a", HOFFSET(sub22_t, a), H5T_NATIVE_INT) < 0) + goto done; + if (H5Tinsert(sub22_tid, "b", HOFFSET(sub22_t, b), H5T_NATIVE_INT) < 0) + goto done; + if (H5Tinsert(sub22_tid, "c", HOFFSET(sub22_t, c), H5T_NATIVE_INT) < 0) + goto done; + + if ((sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) + goto done; + if (H5Tinsert(sub2_tid, "a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) + goto done; + if (H5Tinsert(sub2_tid, "b", HOFFSET(sub2_t, b), sub22_tid) < 0) + goto done; + if (H5Tinsert(sub2_tid, "c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) + goto done; + + if ((sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) + goto done; + if (H5Tinsert(sub4_tid, "a", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) + goto done; + if (H5Tinsert(sub4_tid, "b", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) + goto done; + + if ((set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) + goto done; + if (H5Tinsert(set_tid, "field1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) + goto done; + if (H5Tinsert(set_tid, "field2", HOFFSET(set_t, field2), sub2_tid) < 0) + goto done; + if (H5Tinsert(set_tid, "field3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) + goto done; + if (H5Tinsert(set_tid, "field4", HOFFSET(set_t, field4), sub4_tid) < 0) + goto done; + + /* Create the compound type with escape/separator characters */ + if ((esc_sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) + goto done; + if (H5Tinsert(esc_sub2_tid, ".a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) + goto done; + if (H5Tinsert(esc_sub2_tid, ",b", HOFFSET(sub2_t, b), sub22_tid) < 0) + goto done; + if (H5Tinsert(esc_sub2_tid, "\\c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) + goto done; + + if ((esc_sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) + goto done; + if (H5Tinsert(esc_sub4_tid, "a.", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) + goto done; + if (H5Tinsert(esc_sub4_tid, "b,", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) + goto done; + + if ((esc_set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) + goto done; + if (H5Tinsert(esc_set_tid, "field,1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) + goto done; + if (H5Tinsert(esc_set_tid, "field2.", HOFFSET(set_t, field2), esc_sub2_tid) < 0) + goto done; + if (H5Tinsert(esc_set_tid, "field\\3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) + goto done; + if (H5Tinsert(esc_set_tid, "field4,", HOFFSET(set_t, field4), esc_sub4_tid) < 0) + goto done; + + /* Generate DSET_CMPD, DSET_CMPD_ESC */ + if (generate_dset(fid, DSET_CMPD, 1, cur_dims, max_dims, set_tid, one_cbuf) < 0) + goto done; + if (generate_dset(fid, DSET_CMPD_ESC, 1, cur_dims, max_dims, esc_set_tid, one_cbuf) < 0) + goto done; + + /* Initialization for two-dimensional compound typed dataset */ + cur2_dims[0] = TWO_DIMS0; + cur2_dims[1] = TWO_DIMS1; + max2_dims[0] = MAX_TWO_DIMS0; + max2_dims[0] = MAX_TWO_DIMS1; + + for (int i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) { + two_cbuf[i].field1 = 1; + two_cbuf[i].field2.a = 2; + two_cbuf[i].field2.c = 4; + two_cbuf[i].field2.b.a = 20; + two_cbuf[i].field2.b.b = 40; + two_cbuf[i].field2.b.c = 80; + two_cbuf[i].field3 = 3.0; + two_cbuf[i].field4.a = 4; + two_cbuf[i].field4.b = 8; + } + + /* Generate DSET_CMPD_TWO */ + if (generate_dset(fid, DSET_CMPD_TWO, 2, cur2_dims, max2_dims, set_tid, two_cbuf) < 0) + goto done; + + /* Create NULL dataspace */ + if ((null_sid = H5Screate(H5S_NULL)) < 0) + goto done; + + /* Create the NULL dataset */ + if ((null_did = H5Dcreate2(fid, DSET_NULL, H5T_NATIVE_UINT, null_sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + goto done; + + /* Create SCALAR dataspace */ + if ((scalar_sid = H5Screate(H5S_SCALAR)) < 0) + goto done; + + /* Create the SCALAR dataset */ + if ((scalar_did = H5Dcreate2(fid, DSET_SCALAR, H5T_NATIVE_INT, scalar_sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + goto done; + + /* Closing */ + if (H5Dclose(scalar_did) < 0) + goto done; + if (H5Sclose(scalar_sid) < 0) + goto done; + + if (H5Dclose(null_did) < 0) + goto done; + if (H5Sclose(null_sid) < 0) + goto done; + + if (H5Tclose(sub22_tid) < 0) + goto done; + if (H5Tclose(sub2_tid) < 0) + goto done; + if (H5Tclose(sub4_tid) < 0) + goto done; + if (H5Tclose(set_tid) < 0) + goto done; + if (H5Tclose(esc_sub2_tid) < 0) + goto done; + if (H5Tclose(esc_sub4_tid) < 0) + goto done; + if (H5Tclose(esc_set_tid) < 0) + goto done; + + if (H5Pclose(fapl) < 0) + goto done; + if (H5Fclose(fid) < 0) + goto done; + + exit(EXIT_SUCCESS); + +done: + H5E_BEGIN_TRY + H5Tclose(sub22_tid); + H5Tclose(sub2_tid); + H5Tclose(sub4_tid); + H5Tclose(set_tid); + H5Tclose(esc_sub2_tid); + H5Tclose(esc_sub4_tid); + H5Tclose(esc_set_tid); + + H5Dclose(null_did); + H5Sclose(null_sid); + H5Dclose(scalar_did); + H5Sclose(scalar_sid); + + H5Pclose(fapl); + H5Fclose(fid); + H5E_END_TRY + + exit(EXIT_FAILURE); +} /* main() */ diff --git a/hl/test/h5hltest.h b/hl/test/h5hltest.h index e8292d2..f3df26a 100644 --- a/hl/test/h5hltest.h +++ b/hl/test/h5hltest.h @@ -1,27 +1,24 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * + * the COPYING file, which can be found at the root of the source code * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu> + * Programmer: Quincey Koziol * Friday, April 28, 2006 * * Purpose: Test support stuff. */ -#ifndef _H5HLTEST_H -#define _H5HLTEST_H +#ifndef H5HLTEST_H +#define H5HLTEST_H /* Get the HDF5 test header */ #include "h5test.h" @@ -30,11 +27,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) \ + do { \ + HDprintf("Testing %-62s", WHAT); \ + HDfflush(stdout); \ + } while (0) +#define HL_TESTING3(WHAT) \ + do { \ + HDprintf("Testing %-62s", WHAT); \ + HDfflush(stdout); \ + } while (0) /* 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) -#endif /* _H5HLTEST_H */ +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 9610258..8409f7e 100644 --- a/hl/test/pal_rgb.h +++ b/hl/test/pal_rgb.h @@ -1,273 +1,272 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * + * the COPYING file, which can be found at the root of the source code * + * 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 7b6fb82..b74b62a 100644 --- a/hl/test/test_ds.c +++ b/hl/test/test_ds.c @@ -1,20 +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 * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * + * the COPYING file, which can be found at the root of the source code * + * 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> #include "h5hltest.h" #include "H5srcdir.h" #include "H5DSpublic.h" @@ -31,27 +26,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); @@ -80,64 +91,69 @@ 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" + +#ifdef H5_DIMENSION_SCALES_WITH_NEW_REF +#define FOREIGN_FILE1 "test_ds_le_new_ref.h5" +#define FOREIGN_FILE2 "test_ds_be_new_ref.h5" +#else +#define FOREIGN_FILE1 "test_ds_le.h5" +#define FOREIGN_FILE2 "test_ds_be.h5" +#endif +#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" @@ -146,57 +162,66 @@ static int test_attach_detach(void); * the main program *------------------------------------------------------------------------- */ -int main(void) +int +main(void) { - int nerrors=0; + hid_t file_id = H5I_INVALID_HID; + int nerrors = 0; /* create file to be used in following tests */ - if(create_test_file("1") < 0) { + if ((file_id = 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) { + if (H5Fclose(file_id) < 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_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 ((file_id = create_test_file("2")) < 0) { + nerrors = 1; + goto error; + } + if (H5Fclose(file_id) < 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; + 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 * @@ -215,7 +240,8 @@ error: *------------------------------------------------------------------------- */ -static hid_t create_test_file(const char *fileext) +static hid_t +create_test_file(const char *fileext) { char filename[65]; @@ -224,7 +250,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]; @@ -237,254 +264,262 @@ 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}; + 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, NULL) >= 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}; + 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, NULL) >= 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}; + 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, NULL) >= 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}; + 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}; /* make a dataset */ - if(H5LTmake_dataset_long(fid, dsname, rank, dims, buf) >= 0) { - if(fulldims==0) { + if (H5LTmake_dataset_long(fid, dsname, rank, dims, NULL) >= 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) + goto error; /* 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) + goto error; /* 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) + goto error; /* 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) + goto error; } 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) + goto error; - 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) + goto error; - 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) + goto error; - 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) + goto error; } - } - else - return FAIL; + } + else + goto error; + return SUCCEED; + +error: + return FAIL; } -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}; + 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, NULL) >= 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; } @@ -492,21 +527,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; } @@ -517,29 +554,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; } @@ -550,37 +589,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; } @@ -591,21 +632,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; } @@ -616,29 +659,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; } @@ -649,37 +694,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; } @@ -690,21 +737,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; } @@ -715,29 +763,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; } @@ -748,37 +798,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; } @@ -789,21 +841,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; } @@ -814,29 +868,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; } @@ -847,37 +903,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; } @@ -888,45 +946,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; } @@ -937,21 +997,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; } @@ -962,29 +1024,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; } @@ -995,145 +1059,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(((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) { + 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 @@ -1141,54 +1212,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++) { + HDsnprintf(dname, sizeof(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++) { + HDsnprintf(dname, sizeof(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++) { + HDsnprintf(dname, sizeof(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++) { + HDsnprintf(dname, sizeof(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 @@ -1197,107 +1268,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++) { + HDsnprintf(dname, sizeof(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++) { + HDsnprintf(dname, sizeof(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 @@ -1309,72 +1382,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 @@ -1386,56 +1462,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 @@ -1447,52 +1526,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 @@ -1504,52 +1586,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 @@ -1561,56 +1646,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 @@ -1622,45 +1710,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 @@ -1669,28 +1760,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 @@ -1702,55 +1793,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 @@ -1762,103 +1857,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 @@ -1870,71 +1969,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 @@ -1946,63 +2049,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 @@ -2014,63 +2121,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 @@ -2082,71 +2193,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 @@ -2158,44 +2273,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; - const char *filename = H5_get_srcdir_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(); @@ -2204,1225 +2322,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++) { + HDsnprintf(dname, sizeof(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) + HDsnprintf(sname, sizeof(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++) { + HDsnprintf(dname, sizeof(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++) { + HDsnprintf(sname, sizeof(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 - *------------------------------------------------------------------------- - */ + * detach 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++) { + HDsnprintf(dname, sizeof(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++) { + HDsnprintf(sname, sizeof(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++) { + HDsnprintf(dname, sizeof(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++) { + HDsnprintf(sname, sizeof(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(((size_t)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) + /* iterate through the 1st dimension of "dset_a" and verify that its DS is valid */ + 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 + /* iterate through 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) + /* iterate through the 1st dimension of "dset_a" and read the DS */ + 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 + /* iterate through 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 stopped */ - /* 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) + /* iterate through all the dimensions */ + 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 */ + int idx; /* scale index to start iterating, on return, index where iterator stopped */ - /* iterate trough all the dimensions */ - for(dim=0; dim<(unsigned)rank; dim++) { + /* iterate through all the dimensions */ + 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); @@ -3430,13 +3529,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 * @@ -3454,29 +3552,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; + (void)dset; + (void)dim; + (void)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 * @@ -3495,81 +3593,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; + (void)dset; + (void)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 * @@ -3587,71 +3686,73 @@ 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; + (void)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 { + H5E_BEGIN_TRY + { H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } - /*------------------------------------------------------------------------- * Function: op_continue * @@ -3669,14 +3770,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; - scale_id = scale_id; + (void)dset; + (void)dim; + (void)scale_id; - if ( visitor_data != NULL ) { + if (visitor_data != NULL) { (*(int *)visitor_data)++; } @@ -3701,14 +3803,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; - scale_id = scale_id; + (void)dset; + (void)dim; + (void)scale_id; - if ( visitor_data != NULL ) { + if (visitor_data != NULL) { (*(int *)visitor_data)++; } @@ -3721,360 +3824,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, palette 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, "palette", 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; @@ -4089,183 +4188,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) + /* try to iterate through the 1st dimension of "dset_a", return error */ + 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) + /* try to iterate through the 3rd dimension of "dset_a", return error */ + 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) + HDsnprintf(dname, sizeof(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) + /* iterate through the 1st dimension of "dset_a" */ + 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; @@ -4277,201 +4373,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++) { + HDsnprintf(name, sizeof(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++) { + HDsnprintf(name, sizeof(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++) { + HDsnprintf(name, sizeof(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; @@ -4485,173 +4582,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; @@ -4663,7 +4761,8 @@ out: H5Dclose(did); H5Dclose(dsid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } @@ -4673,144 +4772,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; @@ -4822,20 +4919,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 @@ -4849,109 +4945,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; + 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 (HDfscanf(f, "%s %u", str, &j) && HDferror(f)) { + HDprintf("fscanf error in file %s\n", data_file); + HDfclose(f); + return -1; + } /* end if */ + if (HDfscanf(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 (HDfscanf(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; @@ -4960,19 +5063,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; @@ -4981,97 +5084,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(); @@ -5085,7 +5186,8 @@ out: H5Dclose(did); H5Dclose(dsid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } @@ -5095,220 +5197,221 @@ 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}; + + HL_TESTING2("permutations of attaching and detaching"); - TESTING2("permutations of attaching and detaching"); + gid = var1_id = var2_id = var3_id = H5I_INVALID_HID; - 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(); @@ -5318,13 +5421,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_ds_be_new_ref-32bit.h5 b/hl/test/test_ds_be_new_ref-32bit.h5 Binary files differnew file mode 100644 index 0000000..ee327e9 --- /dev/null +++ b/hl/test/test_ds_be_new_ref-32bit.h5 diff --git a/hl/test/test_ds_be_new_ref.h5 b/hl/test/test_ds_be_new_ref.h5 Binary files differnew file mode 100644 index 0000000..eddfa02 --- /dev/null +++ b/hl/test/test_ds_be_new_ref.h5 diff --git a/hl/test/test_ds_le_new_ref.h5 b/hl/test/test_ds_le_new_ref.h5 Binary files differnew file mode 100644 index 0000000..8625d77 --- /dev/null +++ b/hl/test/test_ds_le_new_ref.h5 diff --git a/hl/test/test_dset_append.c b/hl/test/test_dset_append.c new file mode 100644 index 0000000..f8d38c2 --- /dev/null +++ b/hl/test/test_dset_append.c @@ -0,0 +1,1297 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://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 "H5DOpublic.h" + +#if defined(H5_HAVE_ZLIB_H) && !defined(H5_ZLIB_HEADER) +#define H5_ZLIB_HEADER "zlib.h" +#endif +#if defined(H5_ZLIB_HEADER) +#include H5_ZLIB_HEADER /* "zlib.h" */ +#endif + +#define FILENAME "test_append.h5" +#define DNAME_NOTSET "dataset_notset" +#define DNAME_UNLIM "dataset_unlim" +#define DNAME_LESS "dataset_less" +#define DNAME_VARY "dataset_vary" +#define DNAME_ROW "dataset_row" +#define DNAME_COLUMN "dataset_column" +#define DBUGNAME1 "dataset_bug1" +#define DBUGNAME2 "dataset_bug2" + +/*------------------------------------------------------------------------- + * Function: test_dataset_append_notset + * + * Purpose: Verify that H5DOappend works properly with default dapl. + * That is, H5Pset_append_flush() is not used to set boundary + * and callback in dapl. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Vailin Choi; Aug 2016 + * + *------------------------------------------------------------------------- + */ +static int +test_dataset_append_notset(hid_t fid) +{ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t ffapl = -1; /* The file's file access property list */ + + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {H5S_UNLIMITED, 20}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */ + int lbuf[10]; /* The data buffers */ + int i, j; /* Local index variables */ + h5_stat_t sb1, sb2; /* File info */ + + HL_TESTING2("Append flush with H5DOappend()--append rows with default dapl"); + + /* Get the file's file access property list */ + if ((ffapl = H5Fget_access_plist(fid)) < 0) + FAIL_STACK_ERROR; + + /* Set to create a chunked dataset with extendible dimensions */ + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + FAIL_STACK_ERROR; + + /* Create the dataset */ + if ((did = H5Dcreate2(fid, DNAME_NOTSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Append 6 rows to the dataset */ + for (i = 0; i < 6; i++) { + for (j = 0; j < 10; j++) + lbuf[j] = (i * 10) + (j + 1); + /* Append without boundary, callback and flush */ + if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) + FAIL_STACK_ERROR; + } /* end for */ + + /* File size when not flushed */ + if (HDstat(FILENAME, &sb1) < 0) + TEST_ERROR; + + /* Close the dataset */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* File size after flushing */ + if (HDstat(FILENAME, &sb2) < 0) + TEST_ERROR; + + /* File size before flushing should be less */ + if (sb1.st_size > sb2.st_size) + TEST_ERROR; + + /* Closing */ + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(ffapl) < 0) + FAIL_STACK_ERROR; + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY + { + H5Pclose(dcpl); + H5Pclose(sid); + H5Dclose(did); + H5Pclose(ffapl); + } + H5E_END_TRY; + + return 1; +} /* test_dataset_append_notset() */ + +/* The callback function for the object flush property */ +static herr_t +flush_func(hid_t H5_ATTR_UNUSED obj_id, void *_udata) +{ + unsigned *flush_ct = (unsigned *)_udata; + ++(*flush_ct); + return 0; +} + +/* The callback function for the append flush property */ +static herr_t +append_func(hid_t H5_ATTR_UNUSED dset_id, hsize_t H5_ATTR_UNUSED *cur_dims, void *_udata) +{ + unsigned *append_ct = (unsigned *)_udata; + ++(*append_ct); + return 0; +} + +/*------------------------------------------------------------------------- + * Function: test_dataset_append_rows_columns + * + * Purpose: Verify that the object flush property and the append flush property + * are working properly when appending rows and columns to a dataset + * with 2 extendible dimensions. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Vailin Choi; Jan 2014 + * + *------------------------------------------------------------------------- + */ +static int +test_dataset_append_rows_columns(hid_t fid) +{ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t dapl = -1; /* A copy of dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ + + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */ + int lbuf[10], cbuf[6]; /* The data buffers */ + int buf[6][13], rbuf[6][13]; /* The data buffers */ + + hsize_t boundary[2] = {1, 1}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ + + int i, j; /* Local index variables */ + + HL_TESTING2("Append flush with H5DOappend()--append rows & columns"); + + /* Get the file's file access property list */ + if ((ffapl = H5Fget_access_plist(fid)) < 0) + FAIL_STACK_ERROR; + + /* Set to create a chunked dataset with 2 extendible dimensions */ + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + FAIL_STACK_ERROR; + + /* Set append flush property */ + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR; + if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) + FAIL_STACK_ERROR; + + /* Create the dataset */ + if ((did = H5Dcreate2(fid, DNAME_UNLIM, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR; + + /* Append 6 rows to the dataset */ + for (i = 0; i < 6; i++) { + for (j = 0; j < 10; j++) + lbuf[j] = buf[i][j] = (i * 10) + (j + 1); + if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) + TEST_ERROR; + } /* end for */ + + /* Verify the # of appends */ + if (append_ct != 6) + TEST_ERROR; + + /* Retrieve and verify object flush counts */ + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + FAIL_STACK_ERROR; + if (*flush_ptr != 6) + TEST_ERROR; + + /* Append 3 columns to the dataset */ + for (i = 0; i < 3; i++) { + for (j = 0; j < 6; j++) + cbuf[j] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1; + if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) + TEST_ERROR; + } /* end for */ + + /* Verify the # of appends */ + if (append_ct != 9) + TEST_ERROR; + + /* Retrieve and verify object flush counts */ + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + FAIL_STACK_ERROR; + if (*flush_ptr != 9) + TEST_ERROR; + + /* Read the dataset */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + FAIL_STACK_ERROR; + + /* Verify the data */ + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) + TEST_ERROR; + + /* Clear the buffer */ + HDmemset(rbuf, 0, sizeof(rbuf)); + + /* Close the dataset */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* Open the dataset again */ + if ((did = H5Dopen2(fid, DNAME_UNLIM, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Read the dataset */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + FAIL_STACK_ERROR; + + /* Verify the data */ + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) + TEST_ERROR; + + /* Closing */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(dapl) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(ffapl) < 0) + FAIL_STACK_ERROR; + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY + { + H5Pclose(dapl); + H5Pclose(dcpl); + H5Pclose(sid); + H5Dclose(did); + H5Pclose(ffapl); + } + H5E_END_TRY; + + return 1; +} /* test_dataset_append_rows_columns() */ + +/*------------------------------------------------------------------------- + * Function: test_dataset_append_rows + * + * Purpose: Verify that the object flush property and the append flush property + * are working properly when appending rows to a dataset with + * one extendible dimension (row). + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Vailin Choi; Jan 2014 + * + *------------------------------------------------------------------------- + */ +static int +test_dataset_append_rows(hid_t fid) +{ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t dapl = -1; /* A copy of dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ + + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {H5S_UNLIMITED, 10}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */ + int lbuf[10]; /* The data buffer */ + int buf[6][10], rbuf[6][10]; /* The data buffers */ + int i, j; /* Local index variables */ + + hsize_t boundary[2] = {1, 0}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ + + HL_TESTING2("Append flush with H5DOappend()--append rows"); + + /* Get the file's file access property list */ + if ((ffapl = H5Fget_access_plist(fid)) < 0) + FAIL_STACK_ERROR; + + /* Set to create a chunked dataset with 1 extendible dimension */ + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + FAIL_STACK_ERROR; + + /* Set append flush property */ + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR; + if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) + FAIL_STACK_ERROR; + + /* Create the dataset */ + if ((did = H5Dcreate2(fid, DNAME_ROW, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR; + + /* Append 6 rows to the dataset */ + for (i = 0; i < 6; i++) { + for (j = 0; j < 10; j++) + lbuf[j] = buf[i][j] = (i * 10) + (j + 1); + if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) + TEST_ERROR; + } /* end for */ + + /* Verify the # of appends */ + if (append_ct != 6) + TEST_ERROR; + + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + FAIL_STACK_ERROR; + if (*flush_ptr != 6) + TEST_ERROR; + + /* Read the dataset */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + FAIL_STACK_ERROR; + + /* Verify the data */ + for (i = 0; i < 6; i++) + for (j = 0; j < 10; j++) + if (buf[i][j] != rbuf[i][j]) + TEST_ERROR; + + /* Clear the buffer */ + HDmemset(rbuf, 0, sizeof(rbuf)); + + /* Close the dataset */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* Open the dataset again */ + if ((did = H5Dopen2(fid, DNAME_ROW, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Read the dataset */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + FAIL_STACK_ERROR; + + /* Verify the data */ + for (i = 0; i < 6; i++) + for (j = 0; j < 10; j++) + if (buf[i][j] != rbuf[i][j]) + TEST_ERROR; + + /* Closing */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(dapl) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(ffapl) < 0) + FAIL_STACK_ERROR; + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY + { + H5Pclose(dapl); + H5Pclose(dcpl); + H5Pclose(sid); + H5Dclose(did); + H5Pclose(ffapl); + } + H5E_END_TRY; + + return 1; +} /* test_dataset_append_rows() */ + +/*------------------------------------------------------------------------- + * Function: test_dataset_append_columns + * + * Purpose: Verify that the object flush property and the append flush property + * are working properly when appending columns to a dataset + * with one extendible dimension (column). + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Vailin Choi; Jan 2014 + * + *------------------------------------------------------------------------- + */ +static int +test_dataset_append_columns(hid_t fid) +{ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t dapl = -1; /* A copy of dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ + + hsize_t dims[2] = {6, 0}; /* Current dimension sizes */ + hsize_t maxdims[2] = {6, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */ + int cbuf[6]; /* The data buffer */ + int buf[6][3], rbuf[6][3]; /* The data buffers */ + int i, j; /* Local index variable */ + + hsize_t boundary[2] = {0, 1}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ + + HL_TESTING2("Append flush with H5DOappend()--append columns"); + + /* Get the file's file access property list */ + if ((ffapl = H5Fget_access_plist(fid)) < 0) + FAIL_STACK_ERROR; + + /* Set to create a chunked dataset with 1 extendible dimension */ + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + FAIL_STACK_ERROR; + + /* Set append flush property */ + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR; + if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) + FAIL_STACK_ERROR; + + /* Create the dataset */ + if ((did = H5Dcreate2(fid, DNAME_COLUMN, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR; + + /* Append 3 columns to the dataset */ + for (i = 0; i < 3; i++) { + for (j = 0; j < 6; j++) + cbuf[j] = buf[j][i] = ((i * 6) + (j + 1)) * -1; + if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) + TEST_ERROR; + } /* end for */ + + /* Verify the # of appends */ + if (append_ct != 3) + TEST_ERROR; + + /* Retrieve and verify object flush counts */ + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + FAIL_STACK_ERROR; + if (*flush_ptr != 3) + TEST_ERROR; + + /* Read the dataset */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + FAIL_STACK_ERROR; + + /* Verify the data */ + for (i = 0; i < 6; i++) + for (j = 0; j < 3; j++) + if (buf[i][j] != rbuf[i][j]) + TEST_ERROR; + + /* Clear the buffer */ + HDmemset(rbuf, 0, sizeof(rbuf)); + + /* Close the dataset */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* Open the dataset again */ + if ((did = H5Dopen2(fid, DNAME_COLUMN, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Read the dataset */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + FAIL_STACK_ERROR; + + /* Verify the data */ + for (i = 0; i < 6; i++) + for (j = 0; j < 3; j++) + if (buf[i][j] != rbuf[i][j]) + TEST_ERROR; + + /* Closing */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(dapl) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(ffapl) < 0) + FAIL_STACK_ERROR; + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY + { + H5Pclose(dapl); + H5Pclose(dcpl); + H5Pclose(sid); + H5Dclose(did); + H5Pclose(ffapl); + } + H5E_END_TRY; + + return 1; +} /* test_dataset_append_columns() */ + +/*------------------------------------------------------------------------- + * Function: test_dataset_append_BUG1 + * + * Purpose: Verify that the object flush property and the append flush property + * are working properly when appending rows and columns to an + * extendible dataset. + * + * A BUG occurs: + * when the extendible dataset is set up as follows: + * hsize_t dims[2] = {0, 10}; + * hsize_t maxdims[2] = {H5S_UNLIMITED, 50}; + * when append 6 rows and 3 columns to the dataset; + * The data is correct when the dataset is read at this point; + * The data is incorrect when the dataset is closed, opened again, and read at this point; + * NOTE: the problem does not occur when H5Dflush() is not performed for each row/column. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Vailin Choi; Jan 2014 + * + *------------------------------------------------------------------------- + */ +static int +test_dataset_append_BUG1(hid_t fid) +{ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* Dataset creation property */ + hid_t dapl = -1; /* Dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ + + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {H5S_UNLIMITED, 50}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */ + int lbuf[10], cbuf[6]; /* The data buffers */ + int buf[6][13], rbuf[6][13]; /* The data buffers */ + int i, j; /* Local index variables */ + + hsize_t boundary[2] = {1, 1}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ + + HL_TESTING2("Append flush with H5DOappend()--append rows & columns--BUG1"); + + /* Get the file's file access property list */ + if ((ffapl = H5Fget_access_plist(fid)) < 0) + FAIL_STACK_ERROR; + + /* Set to create a chunked dataset with 2 extendible dimensions */ + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + FAIL_STACK_ERROR; + + /* Set append flush property */ + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR; + if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) + FAIL_STACK_ERROR; + + /* Create the dataset */ + if ((did = H5Dcreate2(fid, DBUGNAME1, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR; + + /* Append 6 rows to the dataset */ + for (i = 0; i < 6; i++) { + for (j = 0; j < 10; j++) + lbuf[j] = buf[i][j] = (i * 10) + (j + 1); + if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) + TEST_ERROR; + } /* end for */ + + /* Verify the # of appends */ + if (append_ct != 6) + TEST_ERROR; + + /* Retrieve and verify object flush counts */ + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + FAIL_STACK_ERROR; + if (*flush_ptr != 6) + TEST_ERROR; + + /* Append 3 columns to the dataset */ + for (i = 0; i < 3; i++) { + for (j = 0; j < 6; j++) + cbuf[j] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1; + if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) + TEST_ERROR; + } /* end for */ + + /* Verify the # of appends */ + if (append_ct != 9) + TEST_ERROR; + + /* Retrieve and verify object flush counts */ + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + FAIL_STACK_ERROR; + if (*flush_ptr != 9) + TEST_ERROR; + + /* Read the dataset */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + FAIL_STACK_ERROR; + + /* Verify the data */ + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) + TEST_ERROR; + + HDmemset(rbuf, 0, sizeof(rbuf)); + + /* Close the dataset */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* Open the dataset again */ + if ((did = H5Dopen2(fid, DBUGNAME1, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Read the dataset */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + FAIL_STACK_ERROR; + + /* Verify the data */ + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) + TEST_ERROR; + + /* Closing */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(dapl) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(ffapl) < 0) + FAIL_STACK_ERROR; + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY + { + H5Pclose(dcpl); + H5Pclose(dapl); + H5Pclose(sid); + H5Dclose(did); + H5Pclose(ffapl); + } + H5E_END_TRY; + + return 1; +} /* test_dataset_append_BUG1() */ + +/*------------------------------------------------------------------------- + * Function: test_dataset_append_BUG2 + * + * Purpose: Verify that the object flush property and the append flush property + * are working properly when appending rows and columns to an + * extendible dataset. + * + * A BUG occurs: + * when the extendible dataset is set up as follows: + * hsize_t dims[2] = {0, 10}; + * hsize_t maxdims[2] = {50, H5S_UNLIMITED}; + * when append 6 rows and 3 columns to the dataset; + * The data is correct when the dataset is read at this point; + * The data is incorrect when the dataset is closed, opened again, and read at this point; + * NOTE: the problem does not occur when H5Dflush() is not performed for each row/column. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Vailin Choi; Jan 2014 + * + *------------------------------------------------------------------------- + */ +static int +test_dataset_append_BUG2(hid_t fid) +{ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* Dataset creation property */ + hid_t dapl = -1; /* Dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ + + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {50, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */ + int lbuf[10], cbuf[6]; /* Data buffers */ + int buf[6][13], rbuf[6][13]; /* Data buffers */ + int i, j; /* Local index variables */ + + hsize_t boundary[2] = {1, 1}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ + + HL_TESTING2("Append flush with H5DOappend()--append rows & columns--BUG2"); + + /* Get the file's file access property list */ + if ((ffapl = H5Fget_access_plist(fid)) < 0) + FAIL_STACK_ERROR; + + /* Set to create a chunked dataset with 2 extendible dimensions */ + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + FAIL_STACK_ERROR; + + /* Set append flush property */ + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR; + if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) + FAIL_STACK_ERROR; + + /* Create the dataset */ + if ((did = H5Dcreate2(fid, DBUGNAME2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR; + + /* Append 6 rows to the dataset */ + for (i = 0; i < 6; i++) { + for (j = 0; j < 10; j++) + lbuf[j] = buf[i][j] = (i * 10) + (j + 1); + if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) + TEST_ERROR; + } /* end for */ + + /* Verify the # of appends */ + if (append_ct != 6) + TEST_ERROR; + + /* Retrieve and verify object flush counts */ + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + FAIL_STACK_ERROR; + if (*flush_ptr != 6) + TEST_ERROR; + + /* Append 3 columns to the dataset */ + for (i = 0; i < 3; i++) { + for (j = 0; j < 6; j++) + cbuf[j] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1; + if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) + TEST_ERROR; + } /* end for */ + + /* Verify the # of appends */ + if (append_ct != 9) + TEST_ERROR; + + /* Retrieve and verify object flush counts */ + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + FAIL_STACK_ERROR; + if (*flush_ptr != 9) + TEST_ERROR; + + /* Read the dataset */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + FAIL_STACK_ERROR; + + /* Verify the data */ + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) + TEST_ERROR; + + HDmemset(rbuf, 0, sizeof(rbuf)); + + /* Close the dataset */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* Open the dataset again */ + if ((did = H5Dopen2(fid, DBUGNAME2, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Read the dataset */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + FAIL_STACK_ERROR; + + /* Verify the data */ + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) + TEST_ERROR; + + /* Closing */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(dapl) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(ffapl) < 0) + FAIL_STACK_ERROR; + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY + { + H5Pclose(dcpl); + H5Pclose(dapl); + H5Pclose(sid); + H5Dclose(did); + H5Pclose(ffapl); + } + H5E_END_TRY; + + return 1; +} /* test_dataset_append_BUG2() */ + +/*------------------------------------------------------------------------- + * Function: test_dataset_append_less + * + * Purpose: Verify that the object flush property and the append flush property + * are working properly when appending rows and columns to an + * extendible dataset where the append size is less than the boundary + * size. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Vailin Choi; Jan 2014 + * + *------------------------------------------------------------------------- + */ +static int +test_dataset_append_less(hid_t fid) +{ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t dapl = -1; /* A copy of dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ + + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {100, 100}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */ + int lbuf[20], cbuf[6][3]; /* Data buffers */ + int buf[6][13], rbuf[6][13]; /* Data buffers */ + int i, j, k; /* Local index variables */ + + hsize_t boundary[2] = {3, 3}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ + + HL_TESTING2("Append flush with H5DOappend()--append size < boundary size"); + + /* Get the file's file access property list */ + if ((ffapl = H5Fget_access_plist(fid)) < 0) + FAIL_STACK_ERROR; + + /* Set to create a chunked dataset with 2 extendible dimensions */ + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + FAIL_STACK_ERROR; + + /* Set append flush property */ + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR; + if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) + FAIL_STACK_ERROR; + + /* Create the dataset */ + if ((did = H5Dcreate2(fid, DNAME_LESS, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR; + + /* Append to the dataset 2 rows at a time for 3 times */ + for (i = 0, k = 0; i < 6; i++) { + for (j = 0; j < 10; j++, k++) + buf[i][j] = lbuf[k] = (i * 10) + (j + 1); + + if ((i + 1) % 2 == 0) { + if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)2, H5T_NATIVE_INT, lbuf) < 0) + TEST_ERROR; + k = 0; + } /* end if */ + } /* end for */ + + /* Verify the # of appends */ + if (append_ct != 2) + TEST_ERROR; + + /* Retrieve and verify object flush counts */ + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + FAIL_STACK_ERROR; + if (*flush_ptr != 2) + TEST_ERROR; + + /* Append 3 columns to the dataset, once */ + for (i = 0; i < 3; i++) + for (j = 0; j < 6; j++, k++) + cbuf[j][i] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1; + if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)3, H5T_NATIVE_INT, cbuf) < 0) + TEST_ERROR; + + /* Verify the # of appends */ + if (append_ct != 3) + TEST_ERROR; + + /* Retrieve and verify object flush counts */ + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + FAIL_STACK_ERROR; + if (*flush_ptr != 3) + TEST_ERROR; + + /* Read the dataset */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + FAIL_STACK_ERROR; + + /* Verify the data */ + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) + TEST_ERROR; + + /* Clear the buffer */ + HDmemset(rbuf, 0, sizeof(rbuf)); + + /* Close the dataset */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* Open the dataset again */ + if ((did = H5Dopen2(fid, DNAME_LESS, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Read the dataset */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + FAIL_STACK_ERROR; + + /* Verify the data */ + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) + TEST_ERROR; + + /* Closing */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(dapl) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(ffapl) < 0) + FAIL_STACK_ERROR; + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY + { + H5Pclose(dapl); + H5Pclose(dcpl); + H5Pclose(sid); + H5Dclose(did); + H5Pclose(ffapl); + } + H5E_END_TRY; + + return 1; +} /* test_dataset_append_less() */ + +/*------------------------------------------------------------------------- + * Function: test_dataset_append_vary + * + * Purpose: Verify that the object flush property and the append flush property + * are working properly when appending rows and columns to an + * extendible dataset where + * row: the append size is 3 times of the boundary size + * the append callback/flush is performed on the 1st boundary hit + * column: the boundary is greater than the append size + * the boundary is not hit at all + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Vailin Choi; Jan 2014 + * + *------------------------------------------------------------------------- + */ +static int +test_dataset_append_vary(hid_t fid) +{ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t dapl = -1; /* A copy of dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ + + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */ + int lbuf[60], cbuf[6][3]; /* Data buffers */ + int buf[6][13], rbuf[6][13]; /* Data buffers */ + int i, j, k; /* Local index variables */ + + hsize_t boundary[2] = {3, 7}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ + + HL_TESTING2("Append flush with H5DOappend()--append & boundary size vary"); + + /* Get the file's file access property list */ + if ((ffapl = H5Fget_access_plist(fid)) < 0) + FAIL_STACK_ERROR; + + /* Set to create a chunked dataset with 2 extendible dimensions */ + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + FAIL_STACK_ERROR; + + /* Set append flush property */ + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR; + if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) + FAIL_STACK_ERROR; + + /* Create the dataset */ + if ((did = H5Dcreate2(fid, DNAME_VARY, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR; + + /* Append 6 rows to the dataset, once */ + for (i = 0, k = 0; i < 6; i++) + for (j = 0; j < 10; j++, k++) + buf[i][j] = lbuf[k] = (i * 10) + (j + 1); + if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)6, H5T_NATIVE_INT, lbuf) < 0) + TEST_ERROR; + + /* Verify the # of appends */ + if (append_ct != 1) + TEST_ERROR; + + /* Retrieve and verify object flush counts */ + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + FAIL_STACK_ERROR; + if (*flush_ptr != 1) + TEST_ERROR; + + /* Append 3 columns to the dataset, once */ + for (i = 0; i < 3; i++) + for (j = 0; j < 6; j++, k++) + cbuf[j][i] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1; + if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)3, H5T_NATIVE_INT, cbuf) < 0) + TEST_ERROR; + + /* Verify the # of appends */ + if (append_ct != 1) + TEST_ERROR; + + /* Retrieve and verify object flush counts */ + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + FAIL_STACK_ERROR; + if (*flush_ptr != 1) + TEST_ERROR; + + /* Read the dataset */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + FAIL_STACK_ERROR; + + /* Verify the data */ + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) + TEST_ERROR; + + /* Clear the dataset */ + HDmemset(rbuf, 0, sizeof(rbuf)); + + /* Close the dataset */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* Open the dataset again */ + if ((did = H5Dopen2(fid, DNAME_VARY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Read the dataset */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + FAIL_STACK_ERROR; + + /* Verify the data */ + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) + TEST_ERROR; + + /* Closing */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(dapl) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(ffapl) < 0) + FAIL_STACK_ERROR; + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY + { + H5Pclose(dapl); + H5Pclose(dcpl); + H5Pclose(sid); + H5Dclose(did); + H5Pclose(ffapl); + } + H5E_END_TRY; + + return 1; +} /* test_dataset_append_vary() */ + +/*------------------------------------------------------------------------- + * Function: Main function + * + * Purpose: Test H5Pset/get_object_flush_cb() and H5Pset/get_append_flush() + * along with H5DOappend(). + * + * Return: EXIT_SUCCESS/EXIT_FAILURE + * + * Programmer: Vailin Choi; Jan 2014 + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ + unsigned flush_ct = 0; /* The # of flushes */ + int nerrors = 0; /* The # of errors encountered */ + + /* Get a copy of file access property list */ + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + FAIL_STACK_ERROR; + + /* Set to use the latest library format */ + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + FAIL_STACK_ERROR; + + /* Set object flush property */ + if (H5Pset_object_flush_cb(fapl, flush_func, &flush_ct) < 0) + FAIL_STACK_ERROR; + + /* Create the test file */ + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR; + + nerrors += test_dataset_append_notset(fid); + + nerrors += test_dataset_append_rows(fid); + + flush_ct = 0; /* Reset flush counter */ + nerrors += test_dataset_append_columns(fid); + + flush_ct = 0; /* Reset flush counter */ + nerrors += test_dataset_append_rows_columns(fid); + + /* + * The following tests illustrate the scenarios when H5DOappend does not work with extensible array + * indexing: + * - when the the dataset has 1 unlimited dimension and the other dimension is fixed but extendible + * - the dataset expands along 1 dimension and then expands along the other dimension + */ + flush_ct = 0; /* Reset flush counter */ + nerrors += test_dataset_append_BUG1(fid); + + flush_ct = 0; /* Reset flush counter */ + nerrors += test_dataset_append_BUG2(fid); + + flush_ct = 0; /* Reset flush counter */ + nerrors += test_dataset_append_less(fid); + + flush_ct = 0; /* Reset flush counter */ + nerrors += test_dataset_append_vary(fid); + + /* Closing */ + if (H5Pclose(fapl) < 0) + FAIL_STACK_ERROR; + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR; + + /* Check for errors */ + if (nerrors) + goto error; + + return EXIT_SUCCESS; + +error: + return EXIT_FAILURE; +} diff --git a/hl/test/test_dset_opt.c b/hl/test/test_dset_opt.c deleted file mode 100644 index 95ce535..0000000 --- a/hl/test/test_dset_opt.c +++ /dev/null @@ -1,1138 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * -* the files COPYING and Copyright.html. COPYING can be found at the root * -* of the source code distribution tree; Copyright.html can be found at the * -* root level of an installed copy of the electronic HDF5 document set and * -* is linked from the top-level documents page. It can also be found at * -* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * -* access to either file, you may request a copy from help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include <stdlib.h> -#include <string.h> -#include "h5hltest.h" -#include "H5srcdir.h" -#include "H5DOpublic.h" -#include <math.h> - -#if defined(H5_HAVE_ZLIB_H) && !defined(H5_ZLIB_HEADER) -# define H5_ZLIB_HEADER "zlib.h" -#endif -#if defined(H5_ZLIB_HEADER) -# include H5_ZLIB_HEADER /* "zlib.h" */ -#endif - -#define FILE_NAME "test_dectris.h5" - -#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 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.001F)+12) - -/* Temporary filter IDs used for testing */ -#define H5Z_FILTER_BOGUS1 305 -#define H5Z_FILTER_BOGUS2 306 -#define ADD_ON 7 -#define FACTOR 3 - -/* 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); - -/* 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 */ -}}; - -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 */ -}}; - -/*------------------------------------------------------------------------- - * Function: test_direct_chunk_write - * - * Purpose: Test the basic functionality of H5DOwrite_chunk - * - * Return: Success: 0 - * - * Failure: 1 - * - * Programmer: Raymond Lu - * 30 November 2012 - * - *------------------------------------------------------------------------- - */ -#ifdef H5_HAVE_FILTER_DEFLATE -static int -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; /*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"); - - /* - * Create the data space with unlimited dimensions. - */ - if((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0) - goto error; - - 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) - goto error; - - if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0) - goto error; - - 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) - goto error; - - /* Initialize the dataset */ - for(i = n = 0; i < NX; i++) - for(j = 0; j < NY; j++) - data[i][j] = n++; - - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) - goto error; - - /* - * Write the data for the dataset. It should stay in the chunk cache. - * It will be evicted from the cache by the H5DOwrite_chunk calls. - */ - 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++; - - /* Allocate output (compressed) buffer */ - outbuf = HDmalloc(z_dst_nbytes); - 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) { - fprintf(stderr, "overflow"); - goto error; - } else if(Z_MEM_ERROR == ret) { - fprintf(stderr, "deflate memory error"); - goto error; - } else if(Z_OK != ret) { - fprintf(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++) { - status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, z_dst_nbytes, outbuf); - offset[1] += CHUNK_NY; - } - offset[0] += CHUNK_NX; - offset[1] = 0; - } - - if(outbuf) - HDfree(outbuf); - - if(H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0) - goto error; - - if(H5Dclose(dataset) < 0) - goto error; - - 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) - goto error; - - /* Read the chunk back */ - 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]) { - printf(" 1. Read different values than written."); - printf(" At index %d,%d\n", i, j); - printf(" direct_buf=%d, check_chunk=%d\n", direct_buf[i][j], check_chunk[i][j]); - goto error; - } - } - } - - /* 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; - - /* Allocate output (compressed) buffer */ - outbuf = HDmalloc(z_dst_nbytes); - 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) { - fprintf(stderr, "overflow"); - goto error; - } else if(Z_MEM_ERROR == ret) { - fprintf(stderr, "deflate memory error"); - goto error; - } else if(Z_OK != ret) { - fprintf(stderr, "other deflate error"); - goto error; - } - - /* 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++) { - status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, z_dst_nbytes, outbuf); - offset[1] += CHUNK_NY; - } - offset[0] += CHUNK_NX; - offset[1] = 0; - } - - if(outbuf) - HDfree(outbuf); - - if(H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0) - goto error; - - if(H5Dclose(dataset) < 0) - goto error; - - 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) - 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]) { - printf(" 2. Read different values than written."); - printf(" At index %d,%d\n", i, j); - printf(" direct_buf=%d, check_chunk=%d\n", direct_buf[i][j], check_chunk[i][j]); - goto error; - } - } - } - - /* - * Close/release resources. - */ - H5Dclose(dataset); - H5Sclose(mem_space); - H5Sclose(dataspace); - H5Pclose(cparms); - H5Pclose(dxpl); - - PASSED(); - return 0; - -error: - H5E_BEGIN_TRY { - H5Dclose(dataset); - H5Sclose(mem_space); - H5Sclose(dataspace); - H5Pclose(cparms); - H5Pclose(dxpl); - } H5E_END_TRY; - - if(outbuf) - HDfree(outbuf); - - return 1; -} -#endif /* H5_HAVE_FILTER_DEFLATE */ - -/*------------------------------------------------------------------------- - * Function: test_skip_compress_write1 - * - * Purpose: Test skipping compression filter when it is the only filter - * for the dataset - * - * Return: Success: 0 - * - * Failure: 1 - * - * Programmer: Raymond Lu - * 30 November 2012 - * - *------------------------------------------------------------------------- - */ -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 */ - - 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"); - - /* - * Create the data space with unlimited dimensions. - */ - if((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0) - goto error; - - 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) - goto error; - - if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0) - goto error; - - 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) - goto error; - - 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++; - } - - /* write the uncompressed chunk data repeatedly to dataset, using the direct writing function. - * Indicate skipping the compression filter. */ - offset[0] = CHUNK_NX; - offset[1] = CHUNK_NY; - - filter_mask = 0x00000001; - - if((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) < 0) - goto error; - - if(H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0) - goto error; - - if(H5Dclose(dataset) < 0) - goto error; - - 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) - goto error; - - /* Read the chunk back */ - 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]) { - printf(" 1. Read different values than written."); - printf(" At index %d,%d\n", i, j); - printf(" direct_buf=%d, check_chunk=%d\n", direct_buf[i][j], check_chunk[i][j]); - goto error; - } - } - } - - /* - * Close/release resources. - */ - H5Dclose(dataset); - H5Sclose(mem_space); - H5Sclose(dataspace); - H5Pclose(cparms); - H5Pclose(dxpl); - - PASSED(); - return 0; - -error: - H5E_BEGIN_TRY { - H5Dclose(dataset); - H5Sclose(mem_space); - H5Sclose(dataspace); - H5Pclose(cparms); - H5Pclose(dxpl); - } H5E_END_TRY; - - return 1; -} - -/*------------------------------------------------------------------------- - * Function: filter_bogus1 - * - * Purpose: A bogus filte that adds ADD_ON to the original value - * - * Return: Success: Data chunk size - * - * Programmer: Raymond Lu - * 30 November 2012 - * - *------------------------------------------------------------------------- - */ -static size_t -filter_bogus1(unsigned int flags, size_t UNUSED cd_nelmts, - const unsigned int 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 */ - - if(flags & H5Z_FLAG_REVERSE) { /* read */ - /* Substract the "add on" value to all the data values */ - while(buf_left>0) { - *int_ptr++ -= (int)ADD_ON; - buf_left -= (ssize_t)sizeof(int); - } /* end while */ - } /* end if */ - else { /* write */ - /* Add the "add on" value to all the data values */ - while(buf_left>0) { - *int_ptr++ += (int)ADD_ON; - buf_left -= (ssize_t)sizeof(int); - } /* end while */ - } /* end else */ - - return nbytes; -} - -/*------------------------------------------------------------------------- - * Function: filter_bogus2 - * - * Purpose: A bogus filter that multiplies the original value by FACTOR. - * - * Return: Success: Data chunk size - * - * Programmer: Raymond Lu - * 30 November 2012 - *------------------------------------------------------------------------- - */ -static size_t -filter_bogus2(unsigned int flags, size_t UNUSED cd_nelmts, - const unsigned int 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 */ - - if(flags & H5Z_FLAG_REVERSE) { /* read */ - /* Substract the "add on" value to all the data values */ - while(buf_left>0) { - *int_ptr++ /= (int)FACTOR; - buf_left -= (ssize_t)sizeof(int); - } /* end while */ - } /* end if */ - else { /* write */ - /* Add the "add on" value to all the data values */ - while(buf_left>0) { - *int_ptr++ *= (int)FACTOR; - buf_left -= (ssize_t)sizeof(int); - } /* end while */ - } /* end else */ - - return nbytes; -} - -/*------------------------------------------------------------------------- - * Function: test_skip_compress_write2 - * - * Purpose: Test skipping compression filter when there are three filters - * for the dataset - * - * Return: Success: 0 - * - * Failure: 1 - * - * Programmer: Raymond Lu - * 30 November 2012 - * - *------------------------------------------------------------------------- - */ -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; - 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 */ - - 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"); - - /* - * Create the data space with unlimited dimensions. - */ - if((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0) - goto error; - - 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) - goto error; - - if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0) - goto error; - - /* Register and enable first bogus filter */ - if(H5Zregister (H5Z_BOGUS1) < 0) - goto error; - - 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) - goto error; - - /* Register and enable second bogus filter */ - if(H5Zregister (H5Z_BOGUS2) < 0) - goto error; - - 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) - goto error; - - 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++) { - origin_direct_buf[i][j] = n++; - 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. - * Indicate skipping the compression filter but keep the other two bogus filters */ - offset[0] = CHUNK_NX; - offset[1] = CHUNK_NY; - - /* 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) - goto error; - - if(H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0) - goto error; - - if(H5Dclose(dataset) < 0) - goto error; - - 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) - goto error; - - /* Read the chunk back */ - 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]) { - printf(" 1. Read different values than written."); - printf(" At index %d,%d\n", i, j); - printf(" origin_direct_buf=%d, check_chunk=%d\n", origin_direct_buf[i][j], check_chunk[i][j]); - goto error; - } - } - } - - /* - * Close/release resources. - */ - H5Dclose(dataset); - H5Sclose(mem_space); - H5Sclose(dataspace); - H5Pclose(cparms); - H5Pclose(dxpl); - - PASSED(); - return 0; - -error: - H5E_BEGIN_TRY { - H5Dclose(dataset); - H5Sclose(mem_space); - H5Sclose(dataspace); - H5Pclose(cparms); - H5Pclose(dxpl); - } H5E_END_TRY; - - return 1; -} - -/*------------------------------------------------------------------------- - * Function: test_data_conv - * - * Purpose: Test data conversion - * - * Return: Success: 0 - * - * Failure: 1 - * - * Programmer: Raymond Lu - * 30 November 2012 - * - *------------------------------------------------------------------------- - */ -static int -test_data_conv(hid_t file) -{ - typedef struct { - int a, b, c[4], d, e; - } src_type_t; - typedef struct { - 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]; - 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"); - - /* - * Create the data space with unlimited dimensions. - */ - if((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0) - goto error; - - 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) - goto error; - - 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) - goto error; - - 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) - goto error; - - 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) - goto error; - - 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; - } - } - - /* write the chunk data to dataset, using the direct writing function. - * There should be no data conversion involved. */ - offset[0] = CHUNK_NX; - offset[1] = CHUNK_NY; - - if((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) < 0) - goto error; - - if(H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0) - goto error; - - if(H5Dclose(dataset) < 0) - goto error; - - if((dataset = H5Dopen2(file, DATASETNAME4, 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) - goto error; - - /* Read the chunk back. Data should be converted */ - 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 || - (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) { - printf(" 1. Read different values than written."); - printf(" At index %d,%d\n", i, j); - printf(" 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); - printf(" 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; - } - } - } - - /* - * Close/release resources. - */ - H5Dclose(dataset); - H5Sclose(mem_space); - H5Sclose(dataspace); - H5Pclose(cparms); - H5Pclose(dxpl); - H5Tclose(st); - H5Tclose(dt); - - - PASSED(); - return 0; - -error: - H5E_BEGIN_TRY { - H5Dclose(dataset); - H5Sclose(mem_space); - H5Sclose(dataspace); - H5Pclose(cparms); - H5Pclose(dxpl); - H5Tclose(st); - H5Tclose(dt); - } H5E_END_TRY; - - return 1; -} - -/*------------------------------------------------------------------------- - * Function: test_invalid_parameters - * - * Purpose: Test invalid parameters for H5DOwrite_chunk - * - * Return: Success: 0 - * - * Failure: 1 - * - * Programmer: Raymond Lu - * 30 November 2012 - * - *------------------------------------------------------------------------- - */ -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; - - 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 */ - - TESTING("invalid parameters for H5DOwrite_chunk"); - - /* - * Create the data space with unlimited dimensions. - */ - if((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) - goto error; - - if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) - goto error; - - /* - * Modify dataset creation properties - */ - if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto error; - - /* - * Create a new contiguous dataset to verify H5DOwrite_chunk doesn't work - */ - if((dataset = H5Dcreate2(file, DATASETNAME5, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) - goto error; - - 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++; - } - - /* Try to write the chunk data to contiguous dataset. It should fail */ - 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) - goto error; - } H5E_END_TRY; - - if(H5Dclose(dataset) < 0) - goto error; - - /* Create a chunked dataset with compression filter */ - if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0) - goto error; - - 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) - goto error; - - /* Check invalid dataset ID */ - H5E_BEGIN_TRY { - if((status = H5DOwrite_chunk((hid_t)-1, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL) - goto error; - } H5E_END_TRY; - - /* Check invalid DXPL ID */ - H5E_BEGIN_TRY { - if((status = H5DOwrite_chunk(dataset, (hid_t)-1, filter_mask, offset, buf_size, direct_buf)) != FAIL) - goto error; - } H5E_END_TRY; - - /* Check invalid OFFSET */ - H5E_BEGIN_TRY { - if((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, NULL, buf_size, direct_buf)) != FAIL) - goto error; - } H5E_END_TRY; - - /* Check when OFFSET is out of dataset range */ - offset[0] = NX + 1; - offset[1] = NY; - H5E_BEGIN_TRY { - if((status = H5DOwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL) - goto error; - } H5E_END_TRY; - - /* Check when OFFSET is not on chunk boundary */ - 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) - goto error; - } H5E_END_TRY; - - /* Check invalid buffer size */ - 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) - goto error; - } H5E_END_TRY; - - /* Check invalid data buffer */ - 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; - - if(H5Dclose(dataset) < 0) - goto error; - - /* - * Close/release resources. - */ - H5Sclose(mem_space); - H5Sclose(dataspace); - H5Pclose(cparms); - H5Pclose(dxpl); - - PASSED(); - return 0; - -error: - H5E_BEGIN_TRY { - H5Dclose(dataset); - H5Sclose(mem_space); - H5Sclose(dataspace); - H5Pclose(cparms); - H5Pclose(dxpl); - } H5E_END_TRY; - - return 1; -} - -/*------------------------------------------------------------------------- - * Function: Main function - * - * Purpose: Test direct chunk write function H5DOwrite_chunk - * - * Return: Success: 0 - * - * Failure: 1 - * - * Programmer: Raymond Lu - * 30 November 2012 - * - *------------------------------------------------------------------------- - */ -int main( void ) -{ - hid_t file_id; - 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) - goto error; - - /* Test direct chunk write */ -#ifdef H5_HAVE_FILTER_DEFLATE - nerrors += test_direct_chunk_write(file_id); -#endif /* H5_HAVE_FILTER_DEFLATE */ - nerrors += test_skip_compress_write1(file_id); - nerrors += test_skip_compress_write2(file_id); - nerrors += test_data_conv(file_id); - nerrors += test_invalid_parameters(file_id); - - if(H5Fclose(file_id) < 0) - goto error; - - /* check for errors */ - if (nerrors) - goto error; - - return 0; - -error: - return 1; -} diff --git a/hl/test/test_file_image.c b/hl/test/test_file_image.c index 831fa23..defaab2 100644 --- a/hl/test/test_file_image.c +++ b/hl/test/test_file_image.c @@ -1,17 +1,14 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * -* the files COPYING and Copyright.html. COPYING can be found at the root * -* of the source code distribution tree; Copyright.html can be found at the * -* root level of an installed copy of the electronic HDF5 document set and * -* is linked from the top-level documents page. It can also be found at * -* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * -* access to either file, you may request a copy from help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://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" @@ -20,6 +17,12 @@ #define RANK 2 +/* For superblock version 0, 1: the offset to "file consistency flags" is 20 with size of 4 bytes */ +/* The file consistency flags is the "status_flags" field in H5F_super_t */ +/* Note: the offset and size will be different when using superblock version 2 for the test file */ +#define SUPER_STATUS_FLAGS_OFF_V0_V1 20 +#define SUPER_STATUS_FLAGS_SIZE_V0_V1 4 + /* Test of file image operations. The following code provides a means to thoroughly test the file image @@ -40,35 +43,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) +test_file_image(size_t open_images, size_t nflags, const 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 = NULL, *dset_id = NULL, 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 = NULL; /* pointer to array of buffer sizes */ + void **buf_ptr = NULL; /* pointer to array of pointers to image buffers */ + char **filename = NULL; /* pointer to array of pointers to filenames */ + unsigned *input_flags = NULL; /* 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"); @@ -81,7 +84,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) FAIL_PUTS_ERROR("malloc() failed"); /* allocate array to store the name of each of the open images */ - if (NULL == (filename = (char **)HDmalloc(sizeof(char *) * open_images))) + if (NULL == (filename = (char **)HDcalloc(1, sizeof(char *) * open_images))) FAIL_PUTS_ERROR("malloc() failed"); /* allocate array to store the size of each of the open images */ @@ -96,7 +99,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++) { @@ -105,20 +108,23 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) input_flags[i] = flags[(nflags + i) % nflags]; /* allocate name buffer for image i */ - filename[i] = (char *)HDmalloc(sizeof(char) * 32); + size_t filenamelength = sizeof(char) * 32; + filename[i] = (char *)HDmalloc(filenamelength); + if (!filename[i]) + FAIL_PUTS_ERROR("HDmalloc() failed"); /* create file name */ - sprintf(filename[i], "image_file%d.h5", (int)i); + HDsnprintf(filename[i], filenamelength, "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"); @@ -127,10 +133,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"); @@ -140,7 +147,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"); @@ -148,7 +155,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"); @@ -158,7 +165,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 */ @@ -168,7 +175,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 { @@ -177,53 +184,85 @@ 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"); - /* test whether the contents of the user buffer and driver buffer */ - /* are equal. */ - 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"); + /* + * When the vfd and user buffers are different and H5LT_FILE_IMAGE_OPEN_RW is enabled, + * status_flags in the superblock needs to be cleared in the vfd buffer for + * the comparison to proceed as expected. The user buffer as returned from H5Fget_file_image() + * has already cleared status_flags. The superblock's status_flags is used for the + * implementation of file locking. + */ + if (input_flags[i] & H5LT_FILE_IMAGE_OPEN_RW && !(input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY)) { + + void *tmp_ptr = HDmalloc((size_t)buf_size[i]); + if (!tmp_ptr) + FAIL_PUTS_ERROR("buffer allocation failed"); + + /* Copy vfd buffer to a temporary buffer */ + HDmemcpy(tmp_ptr, (void *)*core_buf_ptr_ptr, (size_t)buf_size[i]); + /* Clear status_flags in the superblock for the vfd buffer: file locking is using status_flags + */ + HDmemset((uint8_t *)tmp_ptr + SUPER_STATUS_FLAGS_OFF_V0_V1, (int)0, + (size_t)SUPER_STATUS_FLAGS_SIZE_V0_V1); + /* Does the comparison */ + if (HDmemcmp(tmp_ptr, buf_ptr[i], (size_t)buf_size[i]) != 0) + FAIL_PUTS_ERROR("comparison of TMP vfd and user buffer failed"); + /* Free the temporary buffer */ + if (tmp_ptr) + HDfree(tmp_ptr); + } + else { + + /* test whether the contents of the user buffer and driver buffer */ + /* are equal. */ + 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++) { @@ -233,7 +272,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"); @@ -246,10 +285,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 */ @@ -260,7 +299,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 */ @@ -268,18 +307,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++) { @@ -292,23 +331,29 @@ 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 { + H5E_BEGIN_TRY + { status1 = H5Dset_extent(dset_id[i], dims4); - } H5E_END_TRY; + } + 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"); @@ -318,7 +363,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 @@ -339,7 +385,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"); @@ -370,11 +416,13 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) H5Aclose(attr_id); } H5E_END_TRY; #endif - file_id[i] = -1; + if (H5Dclose(dset_id[i]) < 0) + FAIL_PUTS_ERROR("H5Dclose() failed"); + dset_id[i] = -1; } /* 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 */ @@ -382,27 +430,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 ((dset_id[i] < 0) || (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"); @@ -415,10 +463,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 */ @@ -427,11 +475,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,9 +487,9 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) FAIL_PUTS_ERROR("H5Dclose() failed"); } /* end for */ - PASSED() + 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++) { @@ -457,14 +505,17 @@ 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 */ + for (i = 0; i < open_images; i++) + HDfree(filename[i]); HDfree(filename); HDfree(file_id); HDfree(dset_id); @@ -479,22 +530,34 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) return 0; error: + if (filename) { + for (i = 0; i < open_images; i++) + HDfree(filename[i]); + HDfree(filename); + } + HDfree(file_id); + HDfree(dset_id); + HDfree(buf_ptr); + HDfree(buf_size); + HDfree(input_flags); + H5_FAILED(); return -1; } /*------------------------------------------------------------------------- -* 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; @@ -505,14 +568,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_h5do_compat.c b/hl/test/test_h5do_compat.c new file mode 100644 index 0000000..4a3c607 --- /dev/null +++ b/hl/test/test_h5do_compat.c @@ -0,0 +1,285 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://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 "H5DOpublic.h" + +/* This test is a minimal test to ensure that the H5DO compatibility wrappers + * work correctly. + */ + +#ifndef H5_NO_DEPRECATED_SYMBOLS + +#define FILE_NAME "h5do_compat.h5" +#define DATASET_NAME "direct_chunk_io" + +#define NX 8 +#define CHUNK_NX 4 + +/*------------------------------------------------------------------------- + * Function: test_direct_chunk_write + * + * Purpose: Test the basic functionality of H5DOwrite_chunk + * + * Return: Success: An identifier for the dataset used in the tests + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +static hid_t +create_dataset(hid_t fid) +{ + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hsize_t dims[1] = {NX}; + hsize_t maxdims[1] = {H5S_UNLIMITED}; + hsize_t chunk_dims[1] = {CHUNK_NX}; + int data[NX]; + int i; + + /* Create a dataspace for the new dataset */ + if ((sid = H5Screate_simple(1, dims, maxdims)) < 0) + goto error; + + /* Set up dataset creation parameters */ + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dcpl_id, 1, chunk_dims) < 0) + goto error; + + /* Create a new dataset */ + if ((did = H5Dcreate2(fid, DATASET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + goto error; + + /* Initialize the data */ + for (i = 0; i < NX; i++) + data[i] = i; + + /* Write the initialized data */ + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + goto error; + + /* Close everything */ + if (H5Sclose(sid) < 0) + goto error; + if (H5Pclose(dcpl_id) < 0) + goto error; + + return did; + +error: + H5E_BEGIN_TRY + { + H5Dclose(did); + H5Sclose(sid); + H5Pclose(dcpl_id); + } + H5E_END_TRY; + + return H5I_INVALID_HID; + +} /* end create_dataset() */ + +/*------------------------------------------------------------------------- + * Function: test_direct_chunk_write + * + * Purpose: Test the basic functionality of H5DOwrite_chunk + * + * Return: Success: 0 + * Failure: 1 + * + *------------------------------------------------------------------------- + */ +static int +test_direct_chunk_write(hid_t did) +{ + unsigned filter_mask = 0; + int chunk_data[CHUNK_NX]; + hsize_t offset[1]; + size_t data_size; + int i; + + HL_TESTING2("H5DOwrite_chunk wrapper"); + + /* Set the size of the chunk data */ + data_size = CHUNK_NX * sizeof(int); + + /* Initialize the chunk data */ + for (i = 0; i < CHUNK_NX; i++) + chunk_data[i] = (i * 10) + i; + + /* Write the direct chunk data repeatedly to cover all the chunks in the + * dataset, using the direct writing function. + */ + offset[0] = 0; + for (i = 0; i < NX / CHUNK_NX; i++) { + if (H5DOwrite_chunk(did, H5P_DEFAULT, filter_mask, offset, data_size, chunk_data) < 0) + TEST_ERROR; + offset[0] += CHUNK_NX; + } + + PASSED(); + return 0; + +error: + H5_FAILED(); + return 1; +} /* test_direct_chunk_write() */ + +/*------------------------------------------------------------------------- + * Function: test_direct_chunk_read + * + * Purpose: Test the basic functionality of H5DOread_chunk + * + * Return: Success: 0 + * Failure: 1 + * + *------------------------------------------------------------------------- + */ +static int +test_direct_chunk_read(hid_t did) +{ + hid_t mem_sid = H5I_INVALID_HID; + hid_t file_sid = H5I_INVALID_HID; + hsize_t dims[1] = {NX}; + hsize_t chunk_dims[1] = {CHUNK_NX}; + + unsigned filter_mask; + int chunk_data[CHUNK_NX]; /* Chunk read with H5DOread_chunk */ + int check[CHUNK_NX]; /* Chunk read with H5Dread */ + hsize_t offset[1]; + + hsize_t start[1]; /* Start of hyperslab */ + hsize_t stride[1]; /* Stride of hyperslab */ + hsize_t count[1]; /* Block count */ + hsize_t block[1]; /* Block sizes */ + + int i, j; + + HL_TESTING2("H5DOread_chunk wrapper"); + + /* Create dataspaces for reading */ + if ((mem_sid = H5Screate_simple(1, chunk_dims, NULL)) < 0) + TEST_ERROR; + if ((file_sid = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR; + + /* For each chunk in the dataset, compare the result of H5Dread and H5DOread_chunk. */ + for (i = 0; i < NX / CHUNK_NX; i++) { + + /* Select hyperslab for one chunk in the file */ + start[0] = (hsize_t)i * CHUNK_NX; + stride[0] = 1; + count[0] = 1; + block[0] = CHUNK_NX; + + /* Hyperslab selection equals single chunk */ + if (H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, stride, count, block) < 0) + TEST_ERROR; + + /* Read the chunk back */ + if (H5Dread(did, H5T_NATIVE_INT, mem_sid, file_sid, H5P_DEFAULT, check) < 0) + TEST_ERROR; + + /* Read the raw chunk back */ + HDmemset(chunk_data, 0, CHUNK_NX * sizeof(int)); + filter_mask = UINT_MAX; + offset[0] = (hsize_t)i * CHUNK_NX; + if (H5DOread_chunk(did, H5P_DEFAULT, offset, &filter_mask, chunk_data) < 0) + TEST_ERROR; + + /* Check filter mask return value */ + if (filter_mask != 0) + TEST_ERROR; + + /* Check that the values are correct */ + for (j = 0; j < CHUNK_NX; j++) + if (chunk_data[i] != check[i]) + TEST_ERROR; + } + + /* Close */ + if (H5Sclose(mem_sid) < 0) + TEST_ERROR; + if (H5Sclose(file_sid) < 0) + TEST_ERROR; + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY + { + H5Sclose(mem_sid); + H5Sclose(file_sid); + } + H5E_END_TRY; + + H5_FAILED(); + return 1; +} /* test_direct_chunk_read() */ + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Test direct chunk write function H5DOwrite_chunk and + * chunk direct read function H5DOread_chunk + * + * Return: Success: 0 + * Failure: 1 + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ +#ifdef H5_NO_DEPRECATED_SYMBOLS + + HDputs("Direct chunk read/write wrapper tests SKIPPED."); + HDputs("(Backward compatibility not configured)"); + return EXIT_SUCCESS; + +#else + + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + int nerrors = 0; + + if ((fid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + + if ((did = create_dataset(fid)) < 0) + goto error; + + nerrors += test_direct_chunk_write(did); + nerrors += test_direct_chunk_read(did); + + if (H5Dclose(did) < 0) + goto error; + if (H5Fclose(fid) < 0) + goto error; + + /* check for errors */ + if (nerrors) + goto error; + + HDputs("All direct chunk read/write wrapper tests passed."); + return EXIT_SUCCESS; + +error: + HDputs("*** TESTS FAILED ***"); + return EXIT_FAILURE; +#endif /* H5_NO_DEPRECATED_SYMBOLS */ +} /* end main() */ diff --git a/hl/test/test_image.c b/hl/test/test_image.c index 5d68eeb..462a3ce 100644 --- a/hl/test/test_image.c +++ b/hl/test/test_image.c @@ -1,21 +1,14 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * -* the files COPYING and Copyright.html. COPYING can be found at the root * -* of the source code distribution tree; Copyright.html can be found at the * -* root level of an installed copy of the electronic HDF5 document set and * -* is linked from the top-level documents page. It can also be found at * -* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * -* access to either file, you may request a copy from help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include <limits.h> -#include <stdlib.h> -#include <string.h> + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://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 "H5srcdir.h" @@ -41,10 +34,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 { @@ -57,54 +49,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; @@ -112,395 +107,376 @@ 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("palette 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 { + H5E_BEGIN_TRY + { H5Fclose(fid); - } H5E_END_TRY; + } + 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 with 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 */ @@ -511,18 +487,19 @@ 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 { + H5E_BEGIN_TRY + { H5Fclose(fid); - } H5E_END_TRY; + } + 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 @@ -536,34 +513,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; + 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; + 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"); + 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; } @@ -602,131 +579,136 @@ static int test_generate(void) ! */ - - fscanf( f, "%d %d %d", &imax, &jmax, &kmax ); - fscanf( f, "%f %f %f", &valex, &xmin, &xmax ); + if (HDfscanf(f, "%d %d %d", &imax, &jmax, &kmax) < 0 && HDferror(f)) { + HDprintf("fscanf error in file %s.\n", data_file); + goto out; + } /* end if */ + if (HDfscanf(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 (HDfscanf(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.0F) 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.0F) image_data[i] = 0; - else - image_data[i] = (unsigned char)(( 255 * (data[i] - xmin ) ) / xmin ); + else { + image_data[i] = (unsigned char)((255.0F * (data[i] - xmin)) / (xmax - 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 */ @@ -739,222 +721,235 @@ 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 { + H5E_BEGIN_TRY + { H5Fclose(fid); - } H5E_END_TRY; - if(f) + } + 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 (HDfscanf(f, "%s", str) < 0 && HDferror(f)) { + HDprintf("fscanf error in file %s.\n", data_file); + goto out; + } /* end if */ + + if (HDfscanf(f, "%d", &color_planes) < 0 && HDferror(f)) { + HDprintf("fscanf error in file %s.\n", data_file); + goto out; + } /* end if */ + + if (HDfscanf(f, "%s", str) < 0 && HDferror(f)) { + HDprintf("fscanf error in file %s.\n", data_file); + goto out; + } /* end if */ + + if (HDfscanf(f, "%d", &h) < 0 && HDferror(f)) { + HDprintf("fscanf error in file %s.\n", data_file); + goto out; + } /* end if */ + + if (HDfscanf(f, "%s", str) < 0 && HDferror(f)) { + HDprintf("fscanf error in file %s.\n", data_file); + goto out; + } /* end if */ + + if (HDfscanf(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 (HDfscanf(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; - const char *data_file = H5_get_srcdir_filename(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 (HDsscanf(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 (HDfscanf(file, "%u %u %u", &red, &green, &blue) != 3) { HDfclose(file); return -1; } @@ -969,4 +964,3 @@ static int read_palette(const char* fname, return (int)nentries; } - diff --git a/hl/test/test_ld.c b/hl/test/test_ld.c new file mode 100644 index 0000000..11ea0e6 --- /dev/null +++ b/hl/test/test_ld.c @@ -0,0 +1,1439 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://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 "H5srcdir.h" +#include "H5LDpublic.h" + +/* File name */ +#define FILE "test_ld.h5" +/* Copied file name */ +#define COPY_FILENAME "COPY_test_ld.h5" + +/* Dataset names */ +#define DSET_ONE "DSET_ONE" +#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" +#define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY" +#define DSET_TWO "DSET_TWO" +#define TWO_DIM_1 4 +#define TWO_DIM_2 10 +#define DSET_CMPD "DSET_CMPD" +#define DSET_CMPD_ESC "DSET_CMPD_ESC" +#define DSET_CMPD_TWO "DSET_CMPD_TWO" +#define DSET_NULL "DSET_NULL" +#define DSET_SCALAR "DSET_SCALAR" + +/* Selected compound field members for testing */ +#define VALID_FIELDS1 "field1,field2.a,field3,field4" /* TEMPORORAY */ +#define VALID_FIELDS2 "field2.b.a,field2.c,field4.b" + +#define INVALID_FIELDS1 "field2.k.a,field2.c,field4.k" +#define INVALID_FIELDS2 "field2.b.a,field2.c,field4.b." +#define INVALID_FIELDS3 "field2.b.a,,field2.c,field4.b" + +#define VALID_ESC_FIELDS1 "field\\,1,field2\\..\\.a,field\\\\3,field4\\," +#define VALID_ESC_FIELDS2 "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\," + +#define INVALID_ESC_FIELDS1 "field2\\..\\,k.a,field2\\..\\\\c,field4\\,.k\\," +#define INVALID_ESC_FIELDS2 "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\,." +#define INVALID_ESC_FIELDS3 "field2\\..\\,,b.a,field2\\..\\\\c,field4\\,.b\\," + +/* + * Test variations (retained original) for one-dimensional dataset: + * Varies from 10->13; 10->9, 10->10, 10->1, 10->11 + */ +#define ONE_NTESTS 5 +int one_tests[ONE_NTESTS] = {3, -1, 0, -9, 1}; + +/* + * Test variations (retained original) for two-dimensional dataset: + * Varies from {4,10}->{6,12}; {4,10}->{6,9}; {4,10}->{6,10}; + * {4,10}->{3,12}; {4,10}->{3,9}; {4,10}->{3,10}; + * {4,10}->{4,12}; {4,10}->{4,9}; {4,10}->{4,10} + */ +#define TWO_NTESTS 9 +int two_tests[TWO_NTESTS][2] = {{2, 2}, {2, -1}, {2, 0}, {-1, 2}, {-1, -1}, {-1, 0}, {0, 2}, {0, -1}, {0, 0}}; + +/* Verify that the two input values are the same */ +#define VERIFY_EQUAL(_x, _y) \ + { \ + long __x = (long)_x, __y = (long)_y; \ + if (__x != __y) \ + TEST_ERROR; \ + } + +/* Temporary buffer for reading in the test file */ +#define TMP_BUF_SIZE 2048 +char g_tmp_buf[TMP_BUF_SIZE]; + +/* Macros for verifying compound fields */ +/* Verify all fields */ +#define VERIFY_ELMTS_ALL(ent1, ent2) \ + { \ + VERIFY_EQUAL(ent1.field1, ent2.field1); \ + VERIFY_EQUAL(ent1.field2.a, ent2.field2.a); \ + VERIFY_EQUAL(ent1.field2.b.a, ent2.field2.b.a); \ + VERIFY_EQUAL(ent1.field2.b.b, ent2.field2.b.b); \ + VERIFY_EQUAL(ent1.field2.b.c, ent2.field2.b.c); \ + VERIFY_EQUAL(ent1.field2.c, ent2.field2.c); \ + VERIFY_EQUAL(ent1.field3, ent2.field3); \ + VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \ + } + +/* Verify fields selected in VALID_FIELDS1 */ +#define VERIFY_ELMTS_VALID1(ent1, ent2) \ + { \ + VERIFY_EQUAL(ent1.field1, ent2.field1); \ + VERIFY_EQUAL(ent1.field2_a, ent2.field2.a); \ + VERIFY_EQUAL(ent1.field3, ent2.field3); \ + VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \ + VERIFY_EQUAL(ent1.field4.b, ent2.field4.b); \ + } + +/* Verify fields selected in VALID_FIELDS2 */ +#define VERIFY_ELMTS_VALID2(ent1, ent2) \ + { \ + VERIFY_EQUAL(ent1.field2_b_a, ent2.field2.b.a); \ + VERIFY_EQUAL(ent1.field2_c, ent2.field2.c); \ + VERIFY_EQUAL(ent1.field4_b, ent2.field4.b); \ + } + +/* The types of 2-dimensional dataset: DSET_TWO or DSET_CMPD_TWO */ +#define TWO_NONE 0 /* DSET_TWO */ +#define TWO_CMPD_NULL 1 /* DSET_CMPD_TWO with NULL fields */ +#define TWO_CMPD_VALID1 2 /* DSET_CMPD_TWO with VALID_FIELDS1 or VALID_ESC_FIELDS1 */ +#define TWO_CMPD_VALID2 3 /* DSET_CMPD_TWO with VALID_FIELDS2 or VALID_ESC_FIELDS2 */ + +#define VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) \ + { \ + if (type == TWO_NONE) { \ + int *iib = (int *)_ldbuf; \ + int *ib = (int *)_buf; \ + \ + VERIFY_EQUAL(iib[k], ib[ind + n]) \ + } \ + else if (type == TWO_CMPD_NULL) { \ + set_t *ccb = (set_t *)_ldbuf; \ + set_t *cb = (set_t *)_buf; \ + \ + VERIFY_ELMTS_ALL(ccb[k], cb[ind + n]) \ + } \ + else if (type == TWO_CMPD_VALID1) { \ + test_valid_fields1 *vb1 = (test_valid_fields1 *)_ldbuf; \ + set_t *cb = (set_t *)_buf; \ + \ + VERIFY_ELMTS_VALID1(vb1[k], cb[ind + n]) \ + } \ + else if (type == TWO_CMPD_VALID2) { \ + test_valid_fields2 *vb2 = (test_valid_fields2 *)_ldbuf; \ + set_t *cb = (set_t *)_buf; \ + \ + VERIFY_ELMTS_VALID2(vb2[k], cb[ind + n]) \ + } \ + } + +/* Tests for test_LD_elmts_pipe() */ +#define ONE_TESTS 3 +int onetests[ONE_TESTS] = {3, 9, 1}; +#define TWO_TESTS 5 +int twotests[TWO_TESTS][2] = {{2, 2}, {2, -1}, {2, 0}, {-1, 2}, {0, 2}}; + +static herr_t test_LD_dims_params(const char *file); +static herr_t test_LD_dims(const char *file); + +static herr_t test_LD_size(const char *file); + +static herr_t test_LD_elmts_invalid(const char *file); +static herr_t test_LD_elmts_one(const char *file, const char *dname, const char *fields); +static herr_t test_LD_elmts_two(const char *file, const char *dname, const char *fields); + +static herr_t verify_elmts_two(int type, const hsize_t *ext_dims, const hsize_t *prev_dims, void *_ldbuf, + void *_buf); + +/* data structures for compound data type */ +typedef struct sub22_t { + int a; + int b; + int c; +} sub22_t; + +typedef struct sub2_t { + int a; + sub22_t b; + int c; +} sub2_t; + +typedef struct sub4_t { + int a; + int b; +} sub4_t; + +typedef struct set_t { + int field1; + sub2_t field2; + double field3; + sub4_t field4; +} set_t; + +/* NOTE: + * This will fail on heiwa and amani when VALID_FIELDS1 is "field1,field3,field4" + * because of alignment problems: + * amani and heiwa - 8 byte alignment + * jam - 4 byte alignment + * This will need to be fixed in the library for H5Tget_native_type(). + */ +/* VALID_FIELDS1 "field1,field2.a,field3,field4" */ +/* VALID_ESC_FIELDS1 "field\\,1,field2\\..\\.a,field\\\\3,field4\\," */ +typedef struct test_valid_fields1 { + int field1; + int field2_a; + double field3; + sub4_t field4; +} test_valid_fields1; + +/* VALID_FIELDS2 "field2.b.a,field2.c,field4.b" */ +/* VALID_ESC_FIELDS2 "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\," */ +typedef struct test_valid_fields2 { + int field2_b_a; + int field2_c; + int field4_b; +} test_valid_fields2; + +/* Temporary buffers for tests: test_LD_elmts_one() & test_LD_elmts_two() */ +#define TEST_BUF_SIZE 100 +int *iibuf; /* buffer for storing retrieved elements */ +int *ibuf; /* buffer for storing retrieved elements (integer) */ +set_t *cbuf; /* buffer for storing retrieved elements (compound) */ +set_t *ccbuf; /* buffer for storing retrieved elements (compound) */ +test_valid_fields1 *vbuf1; /* buffer for storing retrieved elements (FIELDS1) */ +test_valid_fields2 *vbuf2; /* buffer for storing retrieved elements (FIELDS2) */ + +/* + ********************************************************************************* + * + * Testing for the High Level public routine: H5LDget_dset_dims() + * 1) An invalid dataset id + * 2) "DSET_ALLOC_EARLY": NULL cur_dims + * 3) "DSET_ALLOC_LATE": nonNULL cur_dims + * 4) "DSET_CMPD_TWO": nonNULL cur_dims + * 5) "DSET_NULL": nonNULL cur_dims + * 6) "DSET_SCALAR": nonNULL cur_dims + * + ********************************************************************************* + */ +static herr_t +test_LD_dims_params(const char *file) +{ + hid_t fid = -1; /* file identifier */ + hid_t did = -1; /* dataset identifier */ + hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */ + hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */ + hid_t invalid_id = -1; + herr_t ret; /* return value */ + + const char *filename = H5_get_srcdir_filename(file); + + HL_TESTING2("H5LDget_dset_dims"); + + /* Open the copied file */ + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* + * 1. Verify failure with negative dataset id + */ + H5E_BEGIN_TRY + { + ret = H5LDget_dset_dims(invalid_id, one_cur_dims); + } + H5E_END_TRY; + VERIFY_EQUAL(ret, FAIL) + + /* + * 2. Verify failure for NULL cur_dims + */ + if ((did = H5Dopen2(fid, DSET_ALLOC_EARLY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + H5E_BEGIN_TRY + { + ret = H5LDget_dset_dims(did, NULL); + } + H5E_END_TRY; + VERIFY_EQUAL(ret, FAIL) + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* + * 3. Verify for nonNULL cur_dims + */ + if ((did = H5Dopen2(fid, DSET_ALLOC_LATE, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + if (H5LDget_dset_dims(did, one_cur_dims) < 0) + FAIL_STACK_ERROR; + VERIFY_EQUAL(one_cur_dims[0], 10) + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* + * 4. Verify nonNULL cur_dims for a 2-dimensional dataset + */ + if ((did = H5Dopen2(fid, DSET_CMPD_TWO, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + if (H5LDget_dset_dims(did, two_cur_dims) < 0) + FAIL_STACK_ERROR; + VERIFY_EQUAL(two_cur_dims[0], TWO_DIM_1) + VERIFY_EQUAL(two_cur_dims[1], TWO_DIM_2) + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* + * 5. Verify nonNULL cur_dims for dataset with H5S_NULL dataspace + */ + one_cur_dims[0] = 0; + + if ((did = H5Dopen2(fid, DSET_NULL, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + if (H5LDget_dset_dims(did, one_cur_dims) < 0) + FAIL_STACK_ERROR; + VERIFY_EQUAL(one_cur_dims[0], 0) + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* + * 6. Verify nonNULL cur_dims for dataset with H5S_SCALAR dataspace + */ + one_cur_dims[0] = 0; + + if ((did = H5Dopen2(fid, DSET_SCALAR, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + if (H5LDget_dset_dims(did, one_cur_dims) < 0) + FAIL_STACK_ERROR; + VERIFY_EQUAL(one_cur_dims[0], 0) + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* Close the file */ + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR; + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY + { + H5Dclose(did); + H5Fclose(fid); + } + H5E_END_TRY; + + return (-1); +} /* test_LD_dims_params() */ + +/* + ********************************************************************************* + * + * Testing for the High Level public routine: H5LDget_dset_dims() + * Verify that the dimension sizes retrieved via H5LDget_dset_dims() are correct + * for the following cases: + * + * DSET_ONE: one-dimensional dataset + * 1. Increase dims[0] + * 2. Decrease dims[0] + * 3. same dims[0] + * 4. Decrease dims[0] + * 5. Increase dims[0] + * + * one_tests[ONE_NTESTS] = {3, -1, 0, -9, 1} + * Varies from 10->3; 10->9, 10->10, 10->1, 10->11 + * + * DSET_TWO: two-dimensional dataset + * 1. Increase dims[0], increase dims[1] + * 2. Increase dims[0], decrease dims[1] + * 3. Increase dims[0], same dims[1] + * 4. Decrease dims[0], increase dims[1] + * 5. Decrease dims[0], decrease dims[1] + * 6. Decrease dims[0], same dims[1] + * 7. same dims[0], increase dims[1] + * 8. same dims[0], decrease dims[1] + * 9. same dims[0], same dims[1] + * + * two_tests[TWO_NTESTS][2] = { {2,2}, {2,-1}, {2,0}, + * {-1,2}, {-1,-1}, {-1,0}, + * {0,2}, {0,-1}, {0,0} } + * Varies from {4,10}->{6,12}; {4,10}->{6,9}; {4,10}->{6,10}; + * {4,10}->{3,12}; {4,10}->{3,9}; {4,10}->{3,10}; + * {4,10}->{4,12}; {4,10}->{4,9}; {4,10}->{4,10} + * + ********************************************************************************* + */ +static herr_t +test_LD_dims(const char *file) +{ + hid_t fid = -1; /* file identifier */ + hid_t did = -1; /* dataset identifier */ + hsize_t one_prev_dims[1]; /* original dimension sizes for 1-dimensonal dataset */ + hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */ + hsize_t one_ext_dims[1]; /* extended dimension sizes for 1-dimensonal dataset */ + hsize_t two_prev_dims[2]; /* original dimension sizes for 2-dimensional dataset */ + hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */ + hsize_t two_ext_dims[2]; /* extended dimension sizes for 2-dimensional dataset*/ + int i; /* local index variable */ + + HL_TESTING2("H5LDget_dset_dims with H5Dset_extent"); + + /* Make a copy of the test file */ + if (h5_make_local_copy(file, COPY_FILENAME) < 0) + TEST_ERROR; + + /* Open the copied file */ + if ((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* + * Testing with one-dimensional dataset: DSET_ONE + */ + if ((did = H5Dopen2(fid, DSET_ONE, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Retrieve dimension sizes */ + if (H5LDget_dset_dims(did, one_prev_dims) < 0) + FAIL_STACK_ERROR; + + for (i = 0; i < ONE_NTESTS; i++) { + + /* Set up the extended dimension sizes */ + one_ext_dims[0] = (hsize_t)((int)one_prev_dims[0] + one_tests[i]); + + /* Change the dimension size */ + if (H5Dset_extent(did, one_ext_dims) < 0) + FAIL_STACK_ERROR; + + /* Retrieve the dimension size */ + if (H5LDget_dset_dims(did, one_cur_dims) < 0) + FAIL_STACK_ERROR; + + /* Verify that the retrieved dimension size is correct as expected */ + VERIFY_EQUAL(one_cur_dims[0], one_ext_dims[0]) + } + + /* Close the dataset */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* + * Testing with two-dimensional dataset: DSET_TWO + */ + if ((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Retrieve the dimension sizes */ + if (H5LDget_dset_dims(did, two_prev_dims) < 0) + FAIL_STACK_ERROR; + + for (i = 0; i < TWO_NTESTS; i++) { + + /* Set up the extended dimension sizes */ + two_ext_dims[0] = (hsize_t)((int)two_prev_dims[0] + two_tests[i][0]); + two_ext_dims[1] = (hsize_t)((int)two_prev_dims[1] + two_tests[i][1]); + + /* Change the dimension sizes */ + if (H5Dset_extent(did, two_ext_dims) < 0) + FAIL_STACK_ERROR; + + /* Retrieve the dimension sizes */ + if (H5LDget_dset_dims(did, two_cur_dims) < 0) + FAIL_STACK_ERROR; + + /* Verify that the retrieved dimension sizes are correct as expected */ + VERIFY_EQUAL(two_cur_dims[0], two_ext_dims[0]) + VERIFY_EQUAL(two_cur_dims[1], two_ext_dims[1]) + } /* end TWO_NTESTS */ + + /* Close the dataset */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* Close the file */ + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR; + + /* Remove the copied file */ + HDremove(COPY_FILENAME); + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY + { + H5Dclose(did); + H5Fclose(fid); + } + H5E_END_TRY; + return (-1); + +} /* test_LD_dims() */ + +/* + ********************************************************************************** + * + * Testing for the High Level public routine: H5LDget_dset_type_size() + * Verify that the data type size returned via H5LDget_dset_type_size() + * are correct for the following cases: + * + * Verify failure for an invalid dataset id + * + * DSET_CMPD: one-dimensional dataset with compound type + * 1. The whole element + * 2. VALID_FIELDS1: "field1,field2.a,field3,field4" + * 3. VALID_FIELDS2: "field2.b.a,field2.c,field4.b" + * 4. INVALID_FIELDS1: "field2.k.a,field2.c,field4.k" + * 5. INVALID_FIELDS2: "field2.b.a,field2.c,field4.b." + * 6. INVALID_FIELDS3: "field2.b.a,,field2.c,field4.b" + * + * DSET_CMPD_ESC: one-dimensional dataset with compound type and + * member names with escape/separator characters + * 1. The whole element + * 2. VALID_ESC_FIELDS1: "field\\,1,field2\\..\\.a,field\\\\3,field4\\," + * 3. VALID_ESC_FIELDS2: "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\," + * 4. INVALID_ESC_FIELDS1: "field2\\..\\,k.a,field2\\..\\\\c,field4\\,.k\\," + * 5. INVALID_ESC_FIELDS2: "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\,." + * 6. INVALID_ESC_FIELDS3: "field2\\..\\,,b.a,field2\\..\\\\c,field4\\,.b\\," + * + ********************************************************************************** + */ +static int +test_LD_size(const char *file) +{ + hid_t fid = -1; /* file identifier */ + hid_t did = -1; /* dataset identifier */ + hid_t dtid = -1; /* dataset's datatype identifier */ + hid_t invalid_id = -1; + hid_t memb0_tid = -1; /* type identifier for a member in the compound type */ + hid_t memb1_tid = -1; /* type identifier for a member in the compound type */ + hid_t memb2_tid = -1; /* type identifier for a member in the compound type */ + hid_t memb3_tid = -1; /* type identifier for a member in the compound type */ + hid_t memb_tid = -1; /* type identifier for a member in the compound type */ + hid_t memb_tid2 = -1; /* type identifier for a member in the compound type */ + size_t dsize; /* size of the dataset's datatype */ + size_t ck_dsize; /* size of the dataset's datatype to be checked against */ + + const char *filename = H5_get_srcdir_filename(file); + + HL_TESTING2("H5LDget_dset_type_size"); + + /* Open the file */ + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* + * Verify failure with an invalid dataset id + */ + H5E_BEGIN_TRY + { + dsize = H5LDget_dset_type_size(invalid_id, NULL); + } + H5E_END_TRY; + VERIFY_EQUAL(dsize, 0) + + /* + * Testing one-dimensional dataset with compound datatype: + * DSET_CMPD + */ + + /* Open dataset DSET_CMPD */ + if ((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Return size of the whole element */ + if ((dsize = H5LDget_dset_type_size(did, NULL)) == 0) + FAIL_STACK_ERROR; + + /* Get the dataset's datatype and then its datatype size */ + if ((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + if ((ck_dsize = H5Tget_size(dtid)) == 0) + FAIL_STACK_ERROR; + + /* Verify case #1 */ + VERIFY_EQUAL(dsize, ck_dsize) + + /* Get datatype id for each member */ + if ((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field1" */ + FAIL_STACK_ERROR; + if ((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2" */ + FAIL_STACK_ERROR; + if ((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field3" */ + FAIL_STACK_ERROR; + if ((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4" */ + FAIL_STACK_ERROR; + + /* Obtain size for VALID_FIELDS1: "field1,field2.a,field3,field4" */ + if ((dsize = H5LDget_dset_type_size(did, VALID_FIELDS1)) == 0) + FAIL_STACK_ERROR; + + /* Get the datatype size for "field1" */ + if ((ck_dsize = H5Tget_size(memb0_tid)) == 0) + FAIL_STACK_ERROR; + + /* Add the datatype size for "field2.a" */ + if ((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0) + FAIL_STACK_ERROR; + if ((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR; + if (H5Tclose(memb_tid) < 0) + FAIL_STACK_ERROR; + + /* Add the datatype size for "field3" */ + if ((ck_dsize += H5Tget_size(memb2_tid)) == 0) + FAIL_STACK_ERROR; + + /* Add the datatype size for "field4" */ + if ((ck_dsize += H5Tget_size(memb3_tid)) == 0) + FAIL_STACK_ERROR; + + /* Verify case #2 */ + VERIFY_EQUAL(dsize, ck_dsize) + + /* Obtain datatype size for VALID_FIELDS2: "field2.b.a,field2.c,field4.b" */ + if ((dsize = H5LDget_dset_type_size(did, VALID_FIELDS2)) == 0) + FAIL_STACK_ERROR; + + /* Get the datatype size for "field2.b.a" */ + if ((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0) + FAIL_STACK_ERROR; + if ((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0) + FAIL_STACK_ERROR; + if ((ck_dsize = H5Tget_size(memb_tid2)) == 0) + FAIL_STACK_ERROR; + if (H5Tclose(memb_tid) < 0) + FAIL_STACK_ERROR; + if (H5Tclose(memb_tid2) < 0) + FAIL_STACK_ERROR; + + /* Add the datatype size for "field2.c" */ + if ((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0) + FAIL_STACK_ERROR; + if ((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR; + if (H5Tclose(memb_tid) < 0) + FAIL_STACK_ERROR; + + /* Add the datatype size for "field4.b" */ + if ((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0) + FAIL_STACK_ERROR; + if ((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR; + if (H5Tclose(memb_tid) < 0) + FAIL_STACK_ERROR; + + /* Verify case #3 */ + VERIFY_EQUAL(dsize, ck_dsize) + + /* + * Verify failure for the following invalid nested fields: + * INVALID_FIELDS1: "field2.k.a,field2.c,field4.k" + * INVALID_FIELDS2: "field2.b.a,field2.c,field4.b." + * INVALID_FIELDS3: "field2.b.a,,field2.c,field4.b" + */ + /* Verify failure for case #4 */ + dsize = H5LDget_dset_type_size(did, INVALID_FIELDS1); + VERIFY_EQUAL(dsize, 0) + + /* Verify failure for case #5 */ + dsize = H5LDget_dset_type_size(did, INVALID_FIELDS2); + VERIFY_EQUAL(dsize, 0) + + /* Verify failure for case #6 */ + dsize = H5LDget_dset_type_size(did, INVALID_FIELDS3); + VERIFY_EQUAL(dsize, 0) + + /* Closing */ + if (H5Tclose(memb0_tid) < 0) + FAIL_STACK_ERROR; + if (H5Tclose(memb1_tid) < 0) + FAIL_STACK_ERROR; + if (H5Tclose(memb2_tid) < 0) + FAIL_STACK_ERROR; + if (H5Tclose(memb3_tid) < 0) + FAIL_STACK_ERROR; + if (H5Tclose(dtid) < 0) + FAIL_STACK_ERROR; + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* + * Testing one-dimensional dataset with compound datatype and + * member names consisting of escape/separator characters: + * DSET_CMPD_ESC + */ + + /* Open dataset DSET_CMPD_ESC */ + if ((did = H5Dopen2(fid, DSET_CMPD_ESC, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Return size of the whole element */ + if ((dsize = H5LDget_dset_type_size(did, NULL)) == 0) + FAIL_STACK_ERROR; + + /* Get the dataset's datatype and then its datatype size */ + if ((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + FAIL_STACK_ERROR; + if ((ck_dsize = H5Tget_size(dtid)) == 0) + FAIL_STACK_ERROR; + + /* Verify case #1 */ + VERIFY_EQUAL(dsize, ck_dsize) + + /* Get datatype id for each member */ + if ((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field,1" */ + FAIL_STACK_ERROR; + if ((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2." */ + FAIL_STACK_ERROR; + if ((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field\3" */ + FAIL_STACK_ERROR; + if ((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4," */ + FAIL_STACK_ERROR; + + /* Obtain size for VALID_ESC_FIELDS1: "field\\,1,field2\\..\\.a,field\\\\3,field4\\," */ + if ((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS1)) == 0) + FAIL_STACK_ERROR; + + /* Get the datatype size for "field\\,1" */ + if ((ck_dsize = H5Tget_size(memb0_tid)) == 0) + FAIL_STACK_ERROR; + + /* Add the datatype size for "field2\\..\\.a" */ + if ((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0) + FAIL_STACK_ERROR; + if ((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR; + if (H5Tclose(memb_tid) < 0) + FAIL_STACK_ERROR; + + /* Add the datatype size for "field\\\\3" */ + if ((ck_dsize += H5Tget_size(memb2_tid)) == 0) + FAIL_STACK_ERROR; + + /* Add the datatype size for "field4\\," */ + if ((ck_dsize += H5Tget_size(memb3_tid)) == 0) + FAIL_STACK_ERROR; + + /* Verify case #2 */ + VERIFY_EQUAL(dsize, ck_dsize) + + /* Obtain datatype size for VALID_ESC_FIELDS2: + "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\," */ + if ((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS2)) == 0) + FAIL_STACK_ERROR; + + /* Get the datatype size for "field2\..,b.a" */ + if ((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0) + FAIL_STACK_ERROR; + if ((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0) + FAIL_STACK_ERROR; + if ((ck_dsize = H5Tget_size(memb_tid2)) == 0) + FAIL_STACK_ERROR; + if (H5Tclose(memb_tid) < 0) + FAIL_STACK_ERROR; + if (H5Tclose(memb_tid2) < 0) + FAIL_STACK_ERROR; + + /* Add the datatype size for "field2\..\\c" */ + if ((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0) + FAIL_STACK_ERROR; + if ((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR; + if (H5Tclose(memb_tid) < 0) + FAIL_STACK_ERROR; + + /* Add the datatype size for "field4\,.b\," */ + if ((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0) + FAIL_STACK_ERROR; + if ((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR; + if (H5Tclose(memb_tid) < 0) + FAIL_STACK_ERROR; + + /* Verify case #3 */ + VERIFY_EQUAL(dsize, ck_dsize) + + /* + * Verify failure for the following invalid nested fields: + * INVALID_ESC_FIELDS1: "field2\..\,k.a,field2\..\\c,field4\,.k\," + * INVALID_ESC_FIELDS2: "field2\..\,b.a,field2\..\\c,field4\,.b\,." + * INVALID_ESC_FIELDS3: "field2\..\,,b.a,field2\..\\c,field4\,.b\," + */ + /* Verify failure for case #4 */ + dsize = H5LDget_dset_type_size(did, INVALID_ESC_FIELDS1); + VERIFY_EQUAL(dsize, 0) + + /* Verify failure for case #5 */ + dsize = H5LDget_dset_type_size(did, INVALID_ESC_FIELDS2); + VERIFY_EQUAL(dsize, 0) + + /* Verify failure for case #6 */ + dsize = H5LDget_dset_type_size(did, INVALID_ESC_FIELDS3); + VERIFY_EQUAL(dsize, 0) + + /* Closing */ + if (H5Tclose(memb0_tid) < 0) + FAIL_STACK_ERROR; + if (H5Tclose(memb1_tid) < 0) + FAIL_STACK_ERROR; + if (H5Tclose(memb2_tid) < 0) + FAIL_STACK_ERROR; + if (H5Tclose(memb3_tid) < 0) + FAIL_STACK_ERROR; + if (H5Tclose(dtid) < 0) + FAIL_STACK_ERROR; + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR; + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY + { + H5Tclose(memb0_tid); + H5Tclose(memb1_tid); + H5Tclose(memb2_tid); + H5Tclose(memb3_tid); + H5Tclose(memb_tid); + H5Tclose(memb_tid2); + H5Tclose(dtid); + H5Dclose(did); + H5Fclose(fid); + } + H5E_END_TRY; + return (-1); + +} /* test_LD_size() */ + +/* + ************************************************************************************** + * Testing for the High Level public routine: H5LDget_dset_elmts() + * Verify failures when calling H5LDget_dset_elmts() with the following + * invalid conditions: + * + * A. DSET_TWO: two-dimensional dataset + * 1. CUR_DIMS and PREV_DIMS are NULL + * 2. PREV_DIMS is NULL + * 3. CUR_DIMS is NULL + * 4. FIELDS is nonnull but the dataset is not compound datatype + * 5. BUF is NULL + * 6. CUR_DIMS is not greater than PREV_DIMS + * + * B. DSET_CMPD: one-dimensional dataset with compound type + * 1. Invalid dataset id + * 2. FIELDS are not valid members in the compound type + * + ************************************************************************************** + */ +static int +test_LD_elmts_invalid(const char *file) +{ + hid_t fid = -1; /* file identifier */ + hid_t did = -1; /* dataset identifier */ + hid_t sid = -1; /* dataspace identifier */ + hid_t invalid_id = -1; + int ret; /* return value */ + hsize_t cur_dims[2]; /* current dimension sizes of the dataset */ + hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */ + char tbuf[2]; /* temporary buffer for testing */ + int ndims; /* # of dimension sizes */ + int i; /* local index variable */ + + const char *filename = H5_get_srcdir_filename(file); + + HL_TESTING2("H5LDget_dset_elmts on invalid conditions"); + + /* Open the copied file */ + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* + * Testing two-dimensional dataset: DSET_TWO + */ + + /* Open dataset: DSET_TWO */ + if ((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Verify failure from case #1: cur_dims and prev_dims are NULL */ + ret = H5LDget_dset_elmts(did, NULL, NULL, NULL, NULL); + VERIFY_EQUAL(ret, FAIL) + + /* Verify failure from case #2: prev_dims is NULL */ + ret = H5LDget_dset_elmts(did, cur_dims, NULL, NULL, NULL); + VERIFY_EQUAL(ret, FAIL) + + /* Verify failure from case #3: cur_dims is NULL */ + ret = H5LDget_dset_elmts(did, NULL, prev_dims, NULL, NULL); + VERIFY_EQUAL(ret, FAIL) + + if ((sid = H5Dget_space(did)) < 0) + FAIL_STACK_ERROR; + + /* Get the # of dimensions and current dimension sizes */ + if ((ndims = H5Sget_simple_extent_dims(sid, cur_dims, NULL)) < 0) + FAIL_STACK_ERROR; + + /* Set up valid cur_dims and prev_dims */ + for (i = 0; i < ndims; i++) + prev_dims[i] = cur_dims[i] - 1; + + /* Verify failure from case #4: FIELDS is nonNULL but the dataset is not compound datatype */ + ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, "field1", tbuf); + VERIFY_EQUAL(ret, FAIL) + + /* Verify failure from case #5: BUF is NULL */ + ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, NULL, NULL); + VERIFY_EQUAL(ret, FAIL) + + /* Verify failure from case #6: cur_dims is not > than prev_dims */ + cur_dims[0] = prev_dims[0] - 1; + cur_dims[1] = prev_dims[1] - 1; + ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, NULL, tbuf); + VERIFY_EQUAL(ret, FAIL) + + /* Close DSET_TWO */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* + * Testing one-dimensional dataset with compound datatype: + * DSET_CMPD + */ + + /* Verify failure from case #1: an invalid dataset id */ + H5E_BEGIN_TRY + { + ret = H5LDget_dset_elmts(invalid_id, prev_dims, cur_dims, NULL, tbuf); + } + H5E_END_TRY; + VERIFY_EQUAL(ret, FAIL) + + /* Open dataset: DSET_CMPD */ + if ((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Retrieve the current dimension sizes */ + if (H5LDget_dset_dims(did, cur_dims) < 0) + FAIL_STACK_ERROR; + + /* Set up valid cur_dims, prev_dims */ + prev_dims[0] = cur_dims[0] - 1; + + /* Verify failure from case #2: invalid FIELDS */ + ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, "field2.k.a,field2.c,field4.k", tbuf); + VERIFY_EQUAL(ret, FAIL) + + /* Close DSET_CMPD */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + + /* Close the file */ + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR; + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY + { + H5Sclose(sid); + H5Dclose(did); + H5Fclose(fid); + } + H5E_END_TRY; + return (-1); + +} /* test_LD_elmts_invalid() */ + +/* + ************************************************************************************** + * Testing for the High Level public routine: H5LDget_dset_elmts() + * Verify elements retrieved via H5LDget_dset_elmts() are correct as expected + * when the dataset's dimension sizes are changed according to one_tests[]: + * + * one-dimensional dataset : + * DSET_ONE with NULL fields + * DSET_CMPD with fields: NULL, VALID_FIELDS1, VALID_FIELDS2 + * DSET_CMPD_ESC with fields: NULL, VALID_ESC_FIELDS1, VALID_ESC_FIELDS2 + * + * case #1. increase dims[0] + * case #2. decrease dims[0] (failure) + * case #3. same dims[0] (failure) + * case #4. decrease dims[0] (failure) + * case #5. increase dims[0] + * + ************************************************************************************** + */ +static herr_t +test_LD_elmts_one(const char *file, const char *dname, const char *fields) +{ + hid_t fid = -1; /* file identifier */ + hid_t did = -1; /* dataset identifier */ + hid_t dtype = -1; /* dataset's data type */ + hsize_t ext_dims[1]; /* extended dimension sizes of the dataset */ + hsize_t prev_dims[1]; /* previous dimension sizes of the dataset */ + int i, j; /* local index variable */ + int ret = 0; /* return value */ + + HL_TESTING2("H5LDget_dset_elmts: one-dimensional dataset"); + + /* Copy the test file */ + if (h5_make_local_copy(file, COPY_FILENAME) < 0) + TEST_ERROR; + + for (i = 0; i < TEST_BUF_SIZE; i++) { + cbuf[i].field1 = i; + cbuf[i].field2.a = i; + cbuf[i].field2.b.a = i; + cbuf[i].field2.b.b = i; + cbuf[i].field2.b.c = i; + cbuf[i].field2.c = i; + cbuf[i].field3 = (double)i; + cbuf[i].field4.a = i; + cbuf[i].field4.b = i; + ibuf[i] = i; + } /* end for */ + + /* Open the copied file */ + if ((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Open the dataset */ + if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Get the dataset's data type */ + if ((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Get current dimension sizes before extending the dataset's dimension sizes */ + if (H5LDget_dset_dims(did, prev_dims) < 0) + FAIL_STACK_ERROR; + + /* Loop through different variations of extending the dataset */ + for (i = 0; i < ONE_NTESTS; i++) { + HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1)); + HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2)); + HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t)); + HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int)); + + ext_dims[0] = (hsize_t)((int)prev_dims[0] + one_tests[i]); + + /* Change the dimension sizes of the dataset */ + if (H5Dset_extent(did, ext_dims) < 0) + FAIL_STACK_ERROR; + + /* Initialize data */ + if (!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { + if (H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0) + FAIL_STACK_ERROR; + } /* end if */ + else if (!HDstrcmp(dname, DSET_ONE)) { + if (H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0) + FAIL_STACK_ERROR; + } /* end if */ + + /* There are changes in dimension sizes */ + if (one_tests[i] > 0) { + if (!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { + if (fields) { + if (!HDstrcmp(fields, VALID_FIELDS1) || !HDstrcmp(fields, VALID_ESC_FIELDS1)) { + /* Retrieve the elmemts in BUF */ + if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0) + TEST_ERROR; + for (j = 0; j < one_tests[i]; j++) + VERIFY_ELMTS_VALID1(vbuf1[j], cbuf[prev_dims[0] + (hsize_t)j]) + } /* end if */ + else if (!HDstrcmp(fields, VALID_FIELDS2) || !HDstrcmp(fields, VALID_ESC_FIELDS2)) { + /* Retrieve the elmemts in BUF */ + if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf2) < 0) + TEST_ERROR; + for (j = 0; j < one_tests[i]; j++) + VERIFY_ELMTS_VALID2(vbuf2[j], cbuf[prev_dims[0] + (hsize_t)j]) + } /* end else-if */ + else + TEST_ERROR; + } /* end if */ + else { + /* Retrieve the elmemts in BUF */ + if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0) + TEST_ERROR; + for (j = 0; j < one_tests[i]; j++) + VERIFY_ELMTS_ALL(ccbuf[j], cbuf[prev_dims[0] + (hsize_t)j]) + } /* end else-if */ + } /* end if */ + else { + /* Retrieve the elmemts in BUF */ + if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0) + TEST_ERROR; + for (j = 0; j < one_tests[i]; j++) + VERIFY_EQUAL(iibuf[j], ibuf[prev_dims[0] + (hsize_t)j]) + } /* end else */ + } /* end if */ + else { + /* Verify failure when changes between prev_dims and ext_dims are same/decrease */ + ret = H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf); + VERIFY_EQUAL(ret, FAIL) + } /* end else */ + } /* end for */ + + /* Closing */ + if (H5Tclose(dtype) < 0) + FAIL_STACK_ERROR; + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR; + + /* Remove the copied file */ + HDremove(COPY_FILENAME); + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY + { + H5Tclose(dtype); + H5Dclose(did); + H5Fclose(fid); + } + H5E_END_TRY; + return (-1); +} /* test_LD_elmts_one() */ + +/* + ************************************************************************************** + * + * Helper routine to verify elements of a 2-dimensional dataset + * _ldbuf contains the elements retrieved via H5LDget_dset_elmts() + * _buf contains the data written to the dataset + * + * e.g. prev_dims[2] = {4, 6}; ext_dims[2] = {6, 10} + * elements marked in 'v' in _buf are compared to elements in _ldbuf + * 0 1 2 3 4 5 | 6 7 8 9 + * 0 | v v v v + * 1 | v v v v + * 2 | v v v v + * 3 | v v v v + * --------------------- + * 4 v v v v v v v v v v + * 5 v v v v v v v v v v + * + ************************************************************************************** + */ +static herr_t +verify_elmts_two(int type, const hsize_t *ext_dims, const hsize_t *prev_dims, void *_ldbuf, void *_buf) +{ + int k, m; /* Local index variable */ + + k = 0; + for (m = 0; m < (int)ext_dims[0]; m++) { + int n, ind; /* Local index variable */ + + ind = m * (int)ext_dims[1]; + if (m < (int)prev_dims[0]) { + for (n = (int)prev_dims[1]; n < (int)ext_dims[1]; n++) { + VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) + ++k; + } /* end for */ + } /* end if */ + else { + for (n = 0; n < (int)ext_dims[1]; n++) { + VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) + ++k; + } /* end for */ + } /* end else */ + } /* end for */ + + return (0); + +error: + return (-1); +} /* verify_elmts_two() */ + +/* + ************************************************************************************** + * Testing for the High Level public routine: H5LDget_dset_elmts() + * Verify elements retrieved via H5LDget_dset_elmts() are correct as expected when + * the datset's dimension sizes are changed accordingly to two_tests[]: + * + * two-dimensional dataset: DSET_TWO with NULL fields + * DSET_CMPD_TWO with fields: NULL, VALID_FIELDS1, VALID_FIELDS2 + * + * dims[0] dims[1] + * ------- ------- + * case #1: increase increase + * case #2: increase decrease + * case #3: increase same + * case #4: decrease increase + * case #5: decrease decrease (failure) + * case #6: decrease same (failure) + * case #7: same increase + * case #8: same decrease (failure) + * case #9: same same (failure) + * + ************************************************************************************** + */ +static herr_t +test_LD_elmts_two(const char *file, const char *dname, const char *fields) +{ + hid_t fid = -1; /* file identifier */ + hid_t did = -1; /* dataset identifier */ + hid_t dtype = -1; /* dataset's data type */ + hsize_t ext_dims[2]; /* extended dimension sizes of the dataset */ + hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */ + int i; /* local index variable */ + int ret = 0; /* return value */ + + HL_TESTING2("H5LDget_dset_elmts: two-dimensional dataset"); + + /* Copy the test file */ + if (h5_make_local_copy(file, COPY_FILENAME) < 0) + TEST_ERROR; + + for (i = 0; i < TEST_BUF_SIZE; i++) { + cbuf[i].field1 = i; + cbuf[i].field2.a = i; + cbuf[i].field2.b.a = i; + cbuf[i].field2.b.b = i; + cbuf[i].field2.b.c = i; + cbuf[i].field2.c = i; + cbuf[i].field3 = (double)i; + cbuf[i].field4.a = i; + cbuf[i].field4.b = i; + ibuf[i] = i; + } /* end for */ + + /* Open the copied file */ + if ((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Open the dataset */ + if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Get the dataset's data type */ + if ((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Get current dimension sizes before extending the dataset's dimension sizes */ + if (H5LDget_dset_dims(did, prev_dims) < 0) + FAIL_STACK_ERROR; + + /* Loop through different variations of extending the dataset */ + for (i = 0; i < TWO_NTESTS; i++) { + HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1)); + HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2)); + HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t)); + HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int)); + + ext_dims[0] = (hsize_t)((int)prev_dims[0] + two_tests[i][0]); + ext_dims[1] = (hsize_t)((int)prev_dims[1] + two_tests[i][1]); + + /* Change the dimension sizes of the dataset */ + if (H5Dset_extent(did, ext_dims) < 0) + FAIL_STACK_ERROR; + + /* Initialize data */ + if (!HDstrcmp(dname, DSET_CMPD_TWO)) { + if (H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0) + FAIL_STACK_ERROR; + } /* end if */ + else if (!HDstrcmp(dname, DSET_TWO)) { + if (H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0) + FAIL_STACK_ERROR; + } /* end else-if */ + else + TEST_ERROR; + + /* There are changes in dimension sizes */ + if (two_tests[i][0] > 0 || two_tests[i][1] > 0) { + if (!HDstrcmp(dname, DSET_CMPD_TWO)) { + if (fields) { + if (!HDstrcmp(fields, VALID_FIELDS1) || !HDstrcmp(fields, VALID_ESC_FIELDS1)) { + /* Retrieve the elmemts in BUF */ + if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0) + TEST_ERROR; + if (verify_elmts_two(TWO_CMPD_VALID1, ext_dims, prev_dims, vbuf1, cbuf) < 0) + TEST_ERROR; + } /* end if */ + else if (!HDstrcmp(fields, VALID_FIELDS2) || !HDstrcmp(fields, VALID_ESC_FIELDS2)) { + /* Retrieve the elmemts in BUF */ + if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf2) < 0) + TEST_ERROR; + if (verify_elmts_two(TWO_CMPD_VALID2, ext_dims, prev_dims, vbuf2, cbuf) < 0) + TEST_ERROR; + } /* end else-if */ + else + TEST_ERROR; + } /* end if */ + else { + /* Retrieve the elmemts in BUF */ + if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0) + TEST_ERROR; + if (verify_elmts_two(TWO_CMPD_NULL, ext_dims, prev_dims, ccbuf, cbuf) < 0) + TEST_ERROR; + } /* end else */ + } /* end if */ + else { /* DSET_TWO */ + /* Retrieve the elmemts in BUF */ + if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0) + TEST_ERROR; + if (verify_elmts_two(TWO_NONE, ext_dims, prev_dims, iibuf, ibuf) < 0) + TEST_ERROR; + } /* end else */ + } /* end if */ + else { + /* Verify failure when changes between prev_dims and ext_dims are same/decrease */ + ret = H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf); + VERIFY_EQUAL(ret, FAIL) + } /* end else */ + } /* end for */ + + /* Closing */ + if (H5Tclose(dtype) < 0) + FAIL_STACK_ERROR; + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR; + + /* Remove the copied file */ + HDremove(COPY_FILENAME); + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY + { + H5Tclose(dtype); + H5Dclose(did); + H5Fclose(fid); + } + H5E_END_TRY; + return (-1); +} /* test_LD_elmts_two() */ + +/* + * Tests for High Level routines: + * H5LDget_dset_dims(), H5LDget_dset_elmts, H5LDget_dset_type_size() + */ +int +main(void) +{ + int nerrors = 0; + + /* Set up temporary buffers for tests: test_LD_elmts_one() & test_LD_elmts_two() */ + if (NULL == (ibuf = (int *)HDmalloc(sizeof(int) * TEST_BUF_SIZE))) + FAIL_STACK_ERROR; + if (NULL == (iibuf = (int *)HDmalloc(sizeof(int) * TEST_BUF_SIZE))) + FAIL_STACK_ERROR; + + if (NULL == (cbuf = (set_t *)HDmalloc(sizeof(set_t) * TEST_BUF_SIZE))) + FAIL_STACK_ERROR; + if (NULL == (ccbuf = (set_t *)HDmalloc(sizeof(set_t) * TEST_BUF_SIZE))) + FAIL_STACK_ERROR; + + if (NULL == (vbuf1 = (test_valid_fields1 *)HDmalloc(sizeof(test_valid_fields1) * TEST_BUF_SIZE))) + FAIL_STACK_ERROR; + if (NULL == (vbuf2 = (test_valid_fields2 *)HDmalloc(sizeof(test_valid_fields2) * TEST_BUF_SIZE))) + FAIL_STACK_ERROR; + + /* + * Testing H5LDget_dset_dims() + */ + nerrors += test_LD_dims_params(FILE); + nerrors += test_LD_dims(FILE); + + /* + * Testing H5LDget_dset_type_size() + */ + nerrors += test_LD_size(FILE); + + /* + * Testing invalid conditions for H5LDget_dset_elmts() + */ + nerrors += test_LD_elmts_invalid(FILE); + + /* + * Testing H5LDget_dset_elmts(): + * 1-dimensional dataset + */ + nerrors += test_LD_elmts_one(FILE, DSET_ONE, NULL); + + /* + * Testing H5LDget_dset_elmts(): + * 1-dimensional dataset w/ compound datatype + */ + nerrors += test_LD_elmts_one(FILE, DSET_CMPD, NULL); + nerrors += test_LD_elmts_one(FILE, DSET_CMPD, VALID_FIELDS1); + nerrors += test_LD_elmts_one(FILE, DSET_CMPD, VALID_FIELDS2); + + /* + * Testing H5LDget_dset_elmts(): + * 1-dimensional dataset with compound datatype and + * member names with escape/separator characters + */ + nerrors += test_LD_elmts_one(FILE, DSET_CMPD_ESC, NULL); + nerrors += test_LD_elmts_one(FILE, DSET_CMPD_ESC, VALID_ESC_FIELDS1); + nerrors += test_LD_elmts_one(FILE, DSET_CMPD_ESC, VALID_ESC_FIELDS2); + + /* + * Testing H5LDget_dset_elmts() for 2-dimensional datasets + */ + nerrors += test_LD_elmts_two(FILE, DSET_TWO, NULL); + nerrors += test_LD_elmts_two(FILE, DSET_CMPD_TWO, NULL); + nerrors += test_LD_elmts_two(FILE, DSET_CMPD_TWO, VALID_FIELDS1); + nerrors += test_LD_elmts_two(FILE, DSET_CMPD_TWO, VALID_FIELDS2); + + /* Free temporary buffers */ + if (ibuf) + HDfree(ibuf); + if (iibuf) + HDfree(iibuf); + if (cbuf) + HDfree(cbuf); + if (ccbuf) + HDfree(ccbuf); + if (vbuf1) + HDfree(vbuf1); + if (vbuf2) + HDfree(vbuf2); + + /* check for errors */ + if (nerrors) + goto error; + + puts("All tests for H5LD high level routines passed."); + + return (0); + +error: + return (1); +} /* main() */ diff --git a/hl/test/test_ld.h5 b/hl/test/test_ld.h5 Binary files differnew file mode 100644 index 0000000..bd5730c --- /dev/null +++ b/hl/test/test_ld.h5 diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c index 2337610..cf139d9 100644 --- a/hl/test/test_lite.c +++ b/hl/test/test_lite.c @@ -1,25 +1,20 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * -* the files COPYING and Copyright.html. COPYING can be found at the root * -* of the source code distribution tree; Copyright.html can be found at the * -* root level of an installed copy of the electronic HDF5 document set and * -* is linked from the top-level documents page. It can also be found at * -* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * -* access to either file, you may request a copy from help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include <stdlib.h> -#include <string.h> + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://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 "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" @@ -37,78 +32,77 @@ #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 ullong" +#define ATTR11_NAME "attr float" +#define ATTR12_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; } } @@ -116,18 +110,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; } } @@ -135,76 +128,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; } } @@ -212,180 +199,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: @@ -395,75 +367,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); @@ -478,113 +458,111 @@ 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]; + unsigned long long attr_ullong_in[5] = {1, 2, 3, 4, 5}; + unsigned long long attr_ullong_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"); + * H5LTget_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; } } @@ -592,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; } } @@ -710,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; } } @@ -754,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; } } @@ -798,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; } } @@ -888,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_ulong 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_ullong test + *------------------------------------------------------------------------- + */ - TESTING("H5LTset_attribute_float"); + HL_TESTING2("H5LTset_attribute_ullong"); /* Set the attribute */ - if ( H5LTset_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_in, (size_t)5 ) < 0 ) + if (H5LTset_attribute_ullong(loc_id, obj_name, ATTR10_NAME, attr_ullong_in, (size_t)5) < 0) return -1; PASSED(); /*------------------------------------------------------------------------- - * H5LTget_attribute_float test - *------------------------------------------------------------------------- - */ - - TESTING("H5LTget_attribute_float"); + * H5LTget_attribute_ullong test + *------------------------------------------------------------------------- + */ + HL_TESTING2("H5LTget_attribute_ullong"); /* Get the attribute */ - if ( H5LTget_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_out ) < 0 ) + if (H5LTget_attribute_ullong(loc_id, obj_name, ATTR10_NAME, attr_ullong_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 (attr_ullong_in[i] != attr_ullong_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_ULLONG, attr_ullong_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 (attr_ullong_in[i] != attr_ullong_out[i]) { return -1; } } @@ -978,93 +932,132 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) PASSED(); /*------------------------------------------------------------------------- - * H5LTset_attribute_double test - *------------------------------------------------------------------------- - */ + * H5LTset_attribute_float test + *------------------------------------------------------------------------- + */ - TESTING("H5LTset_attribute_double"); + HL_TESTING2("H5LTset_attribute_float"); /* Set the attribute */ - if ( H5LTset_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_in, (size_t)5 ) < 0 ) + if (H5LTset_attribute_float(loc_id, obj_name, ATTR11_NAME, attr_float_in, (size_t)5) < 0) return -1; PASSED(); /*------------------------------------------------------------------------- - * H5LTget_attribute_double test - *------------------------------------------------------------------------- - */ + * H5LTget_attribute_float test + *------------------------------------------------------------------------- + */ - TESTING("H5LTget_attribute_double"); + HL_TESTING2("H5LTget_attribute_float"); /* Get the attribute */ - if ( H5LTget_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_out ) < 0 ) + if (H5LTget_attribute_float(loc_id, obj_name, ATTR11_NAME, attr_float_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_FLT_ABS_EQUAL(attr_float_in[i], attr_float_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_FLOAT, attr_float_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_FLT_ABS_EQUAL(attr_float_in[i], attr_float_out[i])) { return -1; } } PASSED(); + /*------------------------------------------------------------------------- + * H5LTset_attribute_double test + *------------------------------------------------------------------------- + */ + + HL_TESTING2("H5LTset_attribute_double"); + + /* Set the attribute */ + if (H5LTset_attribute_double(loc_id, obj_name, ATTR12_NAME, attr_double_in, (size_t)5) < 0) + return -1; + + PASSED(); /*------------------------------------------------------------------------- - * H5LTget_attribute_ndims test - *------------------------------------------------------------------------- - */ + * H5LTget_attribute_double test + *------------------------------------------------------------------------- + */ + HL_TESTING2("H5LTget_attribute_double"); - TESTING("H5LTget_attribute_ndims"); + /* Get the attribute */ + if (H5LTget_attribute_double(loc_id, obj_name, ATTR12_NAME, attr_double_out) < 0) + return -1; - if ( H5LTget_attribute_ndims( loc_id, obj_name, ATTR2_NAME, &rank_out ) < 0 ) + 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, ATTR12_NAME, H5T_NATIVE_DOUBLE, attr_double_out) < 0) return -1; - if ( rank_out != 1 ) { + 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 + *------------------------------------------------------------------------- + */ + + HL_TESTING2("H5LTget_attribute_ndims"); + + if (H5LTget_attribute_ndims(loc_id, obj_name, ATTR2_NAME, &rank_out) < 0) + return -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(); @@ -1072,52 +1065,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") != 0) { 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(); @@ -1129,52 +1123,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") != 0) { 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(); @@ -1186,83 +1181,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 }") != 0) { + 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 }") != 0) { + HDprintf("dt=\n%s\n", dt_str); HDfree(dt_str); goto out; } @@ -1270,96 +1272,109 @@ 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) != 0) { + 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) != 0) { + 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 }") != + 0) { + 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(); @@ -1371,72 +1386,76 @@ 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") != 0) 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 }") != 0) { - 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(); @@ -1448,56 +1467,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 }") != 0) { + 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; @@ -1507,55 +1527,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 }") != 0) { + 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(); @@ -1567,66 +1592,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 }") != 0) { + 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") != 0) { 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(); @@ -1638,110 +1671,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") != 0) { 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____________________________________________________________________________" + "_____________") != 0) { 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(); @@ -1753,66 +1796,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 *line = NULL; + FILE *fp = NULL; + size_t size = 1024; const char *filename = H5_get_srcdir_filename(INPUT_FILE); - TESTING3(" text for complicated compound types"); + 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(); @@ -1820,9 +1864,9 @@ static int test_complicated_compound(void) out: - if(line) + if (line) HDfree(line); - if(fp) + if (fp) HDfclose(fp); H5_FAILED(); @@ -1830,41 +1874,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; @@ -1877,339 +1922,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, "/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, "/G1", H5P_DEFAULT)) < 0) - goto out; - - /* 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. "." */ + hid_t file_id, group; + htri_t path_valid; + const char *data_string_in = "test"; + + HL_TESTING2("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); - if( (path_valid = H5LTpath_valid(group, ".", TRUE)) != TRUE) - goto out; + /* + * 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)) != TRUE) { + goto out; + } + + if ((path_valid = H5LTpath_valid(file_id, "/", FALSE)) != TRUE) { + 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(group, "DS3", 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; + + 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; - if( (path_valid = H5LTpath_valid(group, "DS3", 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; - if( (path_valid = H5LTpath_valid(group, "G2/G5", TRUE)) != TRUE) - goto out; + /* check soft links */ + if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G5/DS4", TRUE)) != TRUE) + goto out; - /* Check the "./" case */ - if( (path_valid = H5LTpath_valid(group, "./DS3", TRUE)) != TRUE) - goto out; + /************************************** + * CHECK RELATIVE PATHS + ***************************************/ - if( (path_valid = H5LTpath_valid(group, "./G2/G5", TRUE)) != TRUE) - goto out; + if ((group = H5Gopen2(file_id, "/", H5P_DEFAULT)) < 0) + goto out; - /* Should fail, does not exist */ - if( (path_valid = H5LTpath_valid(group, "./G2/G20", FALSE)) == TRUE) - goto out; + if ((path_valid = H5LTpath_valid(group, "/", TRUE)) != TRUE) { + goto out; + } - /* Should fail, does not exist */ - if( (path_valid = H5LTpath_valid(group, "./G2/G20", TRUE)) == TRUE) - goto out; + if ((path_valid = H5LTpath_valid(group, "/", FALSE)) != TRUE) { + goto out; + } - if(H5Gclose(group)<0) - goto out; + if (H5Gclose(group) < 0) + goto out; - /***************************** - * Check external links - *****************************/ + if ((group = H5Gopen2(file_id, "/G1", H5P_DEFAULT)) < 0) + goto out; - /* The dangled external link path is valid */ - if( (path_valid = H5LTpath_valid(file_id, "/DangledExternalLink", FALSE)) != TRUE) - goto out; + /* The identifier (file id) is the object itself, i.e. "." */ - /* 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, ".", 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, ".", TRUE)) != TRUE) + goto out; - if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink", TRUE)) != TRUE) - goto out; + /* The identifier (group id) is the object itself, i.e. "." */ - if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/DS1", TRUE)) != TRUE) - goto out; + if ((path_valid = H5LTpath_valid(group, ".", 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(group, "DS3", 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(group, "DS3", TRUE)) != TRUE) + goto out; - if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/G20", FALSE)) != 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(file_id, "/G1/G2/G6/ExternalLink/G20", TRUE)) == TRUE) - goto out; + /* Check the "./" case */ + if ((path_valid = H5LTpath_valid(group, "./DS3", TRUE)) != TRUE) + 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, "./G2/G5", TRUE)) != TRUE) + goto out; + /* Should fail, does not exist */ + if ((path_valid = H5LTpath_valid(group, "./G2/G20", FALSE)) == TRUE) + goto out; - if(H5Fclose(file_id)<0) - goto out; + /* Should fail, does not exist */ + if ((path_valid = H5LTpath_valid(group, "./G2/G20", TRUE)) == TRUE) + goto out; - PASSED(); - return 0; + if (H5Gclose(group) < 0) + goto out; - out: - H5_FAILED(); - return -1; + /***************************** + * 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 256892b..3bfba6e 100644 --- a/hl/test/test_packet.c +++ b/hl/test/test_packet.c @@ -1,20 +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 * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * + * the COPYING file, which can be found at the root of the source code * + * 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> #include "h5hltest.h" #include "H5PTpublic.h" #include "H5TBpublic.h" @@ -25,44 +20,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" -#ifdef VLPT_REMOVED -#define VL_TABLE_NAME "Varlen Test Table" -#endif /* VLPT_REMOVED */ -#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.0}, {"one", 10, 10, 1.0F, 10.0}, + {"two", 20, 20, 2.0F, 20.0}, {"three", 30, 30, 3.0F, 30.0}, + {"four", 40, 40, 4.0F, 40.0}, {"five", 50, 50, 5.0F, 50.0}, + {"six", 60, 60, 6.0F, 60.0}, {"seven", 70, 70, 7.0F, 70.0}}; /*------------------------------------------------------------------------- * function that compares one particle @@ -70,16 +55,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 || - !FLT_ABS_EQUAL(rbuf[i].pressure,wbuf[j].pressure) || - !DBL_ABS_EQUAL(rbuf[i].temperature,wbuf[j].temperature) ) { - return -1; - } - return 0; + 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; } /*------------------------------------------------------------------------- @@ -89,80 +73,81 @@ 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 -1; - - /* Insert fields. */ - string_type = H5Tcopy( H5T_C_S1 ); - H5Tset_size( string_type, (size_t)16 ); - - if ( H5Tinsert(type_id, "Name", HOFFSET(particle_t, name) , string_type ) < 0 ) - return -1; - if ( H5Tinsert(type_id, "Lat", HOFFSET(particle_t, lati) , H5T_NATIVE_INT ) < 0 ) - return -1; - if ( H5Tinsert(type_id, "Long", HOFFSET(particle_t, longi) , H5T_NATIVE_INT ) < 0 ) - return -1; - if ( H5Tinsert(type_id, "Pressure", HOFFSET(particle_t, pressure) , H5T_NATIVE_FLOAT ) < 0 ) - return -1; - if ( H5Tinsert(type_id, "Temperature", HOFFSET(particle_t, temperature) , H5T_NATIVE_DOUBLE ) < 0 ) - return -1; - - 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 */ - string_type = H5Tcopy( H5T_C_S1 ); - H5Tset_size( string_type, (size_t)16 ); + if ((string_type = H5Tcopy(H5T_C_S1)) < 0) + return FAIL; + if (H5Tset_size(string_type, (size_t)16) < 0) + return FAIL; field_type[0] = string_type; field_type[1] = H5T_NATIVE_INT; field_type[2] = H5T_NATIVE_INT; 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(status<0) - return -1; -else - return 0; + if (status < 0) + return FAIL; + else + return SUCCEED; } - - /*------------------------------------------------------------------------- * test_create_close * @@ -171,13 +156,14 @@ else *------------------------------------------------------------------------- */ -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(); @@ -186,25 +172,24 @@ static int test_create_close(hid_t fid) /* Create the table */ table = H5PTcreate_fl(fid, PT_NAME, part_t, (hsize_t)100, -1); - H5Tclose(part_t); - if( H5PTis_valid(table) < 0) - goto out; -#ifdef VLPT_REMOVED - if( H5PTis_varlen(table) != 0) - goto out; -#endif /* VLPT_REMOVED */ + if (H5Tclose(part_t) < 0) + 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) - goto out; + if (err < 0) + goto error; PASSED(); - return 0; + return SUCCEED; - out: - H5_FAILED(); - return -1; +error: + H5_FAILED(); + return FAIL; } /*------------------------------------------------------------------------- @@ -214,33 +199,34 @@ static int test_create_close(hid_t fid) * *------------------------------------------------------------------------- */ -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) - goto out; -#ifdef VLPT_REMOVED - if( H5PTis_varlen(table) != 0) - goto out; -#endif /* VLPT_REMOVED */ + if (H5PTis_valid(table) < 0) + goto error; + if (H5PTis_varlen(table) != 0) + goto error; /* Close the table */ err = H5PTclose(table); - if( err < 0) - goto out; + if (err < 0) + goto error; PASSED(); - return 0; + return SUCCEED; - out: - H5_FAILED(); - return -1; +error: + if (table > 0) + H5PTclose(table); + H5_FAILED(); + return FAIL; } /*------------------------------------------------------------------------- @@ -250,63 +236,64 @@ static int test_open(hid_t fid) * *------------------------------------------------------------------------- */ -static int test_append(hid_t fid) +static int +test_append(hid_t fid) { - herr_t err; - hid_t table; - hsize_t count; + 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) - goto out; + if (H5PTis_valid(table) < 0) + goto error; /* Count the number of packets in the table */ err = H5PTget_num_packets(table, &count); - if( err < 0) - goto out; + if (err < 0) + goto error; /* There should be 0 records in the table */ - if( count != 0 ) - goto out; + if (count != 0) + goto error; /* Append one particle */ err = H5PTappend(table, (size_t)1, &(testPart[0])); - if( err < 0) - goto out; + if (err < 0) + goto error; /* Append several particles */ err = H5PTappend(table, (size_t)6, &(testPart[1])); - if( err < 0) - goto out; + if (err < 0) + goto error; /* Append one more particle */ err = H5PTappend(table, (size_t)1, &(testPart[7])); - if( err < 0) - goto out; + if (err < 0) + goto error; /* Count the number of packets in the table */ err = H5PTget_num_packets(table, &count); - if( err < 0) - goto out; + if (err < 0) + goto error; /* There should be 8 records in the table now */ - if( count != 8 ) - goto out; + if (count != 8) + goto error; /* Close the table */ err = H5PTclose(table); - if( err < 0) - goto out; + if (err < 0) + goto error; PASSED(); - return 0; + return SUCCEED; - out: - H5_FAILED(); - if( H5PTis_valid(table) < 0) - H5PTclose(table); - return -1; +error: + H5_FAILED(); + if (H5PTis_valid(table) > 0) + H5PTclose(table); + return FAIL; } /*------------------------------------------------------------------------- @@ -316,56 +303,56 @@ static int test_append(hid_t fid) * *------------------------------------------------------------------------- */ -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) - goto out; + if (H5PTis_valid(table) < 0) + goto error; /* Read several particles */ err = H5PTread_packets(table, (hsize_t)0, 3, &(readBuf[0])); - if( err < 0) - goto out; + if (err < 0) + goto error; /* Read one particle */ err = H5PTread_packets(table, (hsize_t)3, 1, &(readBuf[3])); - if( err < 0) - goto out; + if (err < 0) + goto error; /* Read several particles */ - err = H5PTread_packets(table, (hsize_t)4, (NRECORDS - 4 ), &(readBuf[4])); - if( err < 0) - goto out; + 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) - goto out; + 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) - goto out; + if (err < 0) + goto error; PASSED(); - return 0; + return SUCCEED; - out: - H5_FAILED(); - if( H5PTis_valid(table) < 0) - H5PTclose(table); - return -1; +error: + H5_FAILED(); + if (H5PTis_valid(table) > 0) + H5PTclose(table); + return FAIL; } /*------------------------------------------------------------------------- @@ -376,66 +363,63 @@ static int test_read(hid_t fid) * *------------------------------------------------------------------------- */ -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) - goto out; + if (H5PTis_valid(table) < 0) + goto error; /* Read several particles consecutively */ - for(c=0; c < NRECORDS; c++) - { - err = H5PTget_next(table, 1, &readBuf[c]); - if(err < 0) - goto out; + for (c = 0; c < NRECORDS; c++) { + err = H5PTget_next(table, (size_t)1, &readBuf[c]); + 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) - goto out; + 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++) - { - err = H5PTget_next(table, 2, &readBuf2[c * 2]); - if(err < 0) - goto out; + for (c = 0; c < NRECORDS / 2; c++) { + err = H5PTget_next(table, (size_t)2, &readBuf2[c * 2]); + 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) - goto out; + 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) - goto out; + if (err < 0) + goto error; PASSED(); - return 0; + return SUCCEED; - out: - H5_FAILED(); - if( H5PTis_valid(table) < 0) - H5PTclose(table); - return -1; +error: + H5_FAILED(); + if (H5PTis_valid(table) > 0) + H5PTclose(table); + return FAIL; } /*------------------------------------------------------------------------- @@ -446,16 +430,17 @@ static int test_get_next(hid_t fid) * *------------------------------------------------------------------------- */ -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(); @@ -464,232 +449,53 @@ static int test_big_table(hid_t fid) /* Create a new table */ table = H5PTcreate_fl(fid, "Packet Test Dataset2", part_t, (hsize_t)33, -1); - H5Tclose(part_t); - if( H5PTis_valid(table) < 0) - goto out; + if (H5Tclose(part_t) < 0) + goto error; + 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) - goto out; + if (err < 0) + goto error; } /* Count the number of packets in the table */ err = H5PTget_num_packets(table, &count); - if( err < 0) - goto out; - if( count != BIG_TABLE_SIZE ) - goto out; + if (err < 0) + goto error; + 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++) - { - err = H5PTget_next(table, 1, &readPart); - if(err < 0) - goto out; + for (c = 0; c < BIG_TABLE_SIZE; c++) { + err = H5PTget_next(table, (size_t)1, &readPart); + if (err < 0) + goto error; /* Ensure that particles were read correctly */ - if( cmp_par(c % 8, 0, testPart, &readPart) != 0) - goto out; + if (cmp_par(c % 8, 0, testPart, &readPart) != 0) + goto error; } /* Close the table */ err = H5PTclose(table); - if( err < 0) - goto out; + if (err < 0) + goto error; PASSED(); - return 0; - - out: - H5_FAILED(); - if( H5PTis_valid(table) < 0) - H5PTclose(table); - return -1; -} - -#ifdef VLPT_REMOVED -/*------------------------------------------------------------------------- - * test_varlen - * - * Tests creation, opening, closing, writing, reading, etc. on a - * variable-length packet table. - * - *------------------------------------------------------------------------- - */ -static int test_varlen(hid_t fid) -{ - herr_t err; - hid_t table=H5I_BADID; - hsize_t count; - - /* Buffers to hold data */ - hvl_t writeBuffer[NRECORDS]; - hvl_t readBuffer[NRECORDS]; - - /* This example has three different sizes of "record": longs, shorts, and particles */ - long longBuffer[NRECORDS]; - short shortBuffer[NRECORDS]; - int x; - - TESTING("variable-length packet tables"); - - /* Initialize buffers */ - for(x=0; x<NRECORDS; x++) - { - longBuffer[x] = -x; - shortBuffer[x] = x; - } - - /* Fill the write buffer with a mix of variable types */ - for(x=0; x<8; x+=4) - { - writeBuffer[x].len = sizeof(long); - writeBuffer[x].p = &(longBuffer[x]); - writeBuffer[x+1].len = sizeof(short); - writeBuffer[x+1].p = &(shortBuffer[x+1]); - writeBuffer[x+2].len = sizeof(long); - writeBuffer[x+2].p = &(longBuffer[x+2]); - writeBuffer[x+3].len = sizeof(particle_t); - writeBuffer[x+3].p = &(testPart[x+3]); - } - - /* Create the table */ - table = H5PTcreate_vl(fid, VL_TABLE_NAME, (hsize_t)1001); - if( H5PTis_valid(table) < 0) - goto out; - if( H5PTis_varlen(table) != 1) - goto out; - - /* Count the number of packets in the table */ - err = H5PTget_num_packets(table, &count); - if( err < 0) - goto out; - if( count != 0 ) - goto out; - - /* Close the table */ - err = H5PTclose(table); - if( err < 0) - goto out; - - /* Re-open the table */ - table = H5PTopen(fid, VL_TABLE_NAME); - if( H5PTis_valid(table) < 0) - goto out; - if( H5PTis_varlen(table) != 1) - goto out; - - /* Count the number of packets in the table */ - err = H5PTget_num_packets(table, &count); - if( err < 0) - goto out; - if( count != 0 ) - goto out; - - /* Add several variable-length packets */ - err = H5PTappend(table, (size_t)8, writeBuffer ); - if(err < 0) - goto out; - - /* Read them back */ - err = H5PTread_packets(table, (hsize_t)0, 4, &(readBuffer[0])); - if( err < 0) - goto out; - err = H5PTread_packets(table, (hsize_t)4, 1, &(readBuffer[4])); - if( err < 0) - goto out; - err = H5PTread_packets(table, (hsize_t)5, (NRECORDS - 5 ), &(readBuffer[5])); - if( err < 0) - goto out; - - /* Ensure that packets were read correctly */ - for(x=0; x<NRECORDS; x++) - { - if( readBuffer[x].len != writeBuffer[x%4].len) - goto out; - switch(x%4) - { - case 0: - case 2: - if( *((long*)(readBuffer[x].p)) != *((long*)(writeBuffer[x].p))) - goto out; - break; - case 1: - if( *((short*)(readBuffer[x].p)) != *((short*)(writeBuffer[x].p))) - goto out; - break; - case 3: - if( cmp_par(0, 0, readBuffer[x].p, writeBuffer[x].p) < 0) - goto out; - break; - default: - goto out; - } - } - - /* Free memory used by read buffer */ - if(H5PTfree_vlen_readbuff(table, NRECORDS, readBuffer) <0) - goto out; - - /* Read packets back using get_next */ - for(x=0; x < NRECORDS; x++) - { - err = H5PTget_next(table, 1, &readBuffer[x]); - if(err < 0) - goto out; - } - - /* Ensure that packets were read correctly */ - for(x=0; x<NRECORDS; x++) - { - if( readBuffer[x].len != writeBuffer[x%4].len) - goto out; - switch(x%4) - { - case 0: - case 2: - if( *((long*)(readBuffer[x].p)) != *((long*)(writeBuffer[x].p))) - goto out; - break; - case 1: - if( *((short*)(readBuffer[x].p)) != *((short*)(writeBuffer[x].p))) - goto out; - break; - case 3: - if( cmp_par(0, 0, readBuffer[x].p, writeBuffer[x].p) < 0) - goto out; - break; - default: - goto out; - } - } - - /* Free memory used by read buffer */ - if(H5PTfree_vlen_readbuff(table, NRECORDS, readBuffer) <0) - goto out; - - /* Close the table */ - err = H5PTclose(table); - if( err < 0) - goto out; - - PASSED(); - return 0; + return SUCCEED; - out: +error: H5_FAILED(); - H5E_BEGIN_TRY - H5PTclose(table); - H5E_END_TRY - return -1; + if (H5PTis_valid(table) > 0) + H5PTclose(table); + return FAIL; } -#endif /* VLPT_REMOVED */ /*------------------------------------------------------------------------- * test_opaque @@ -698,62 +504,63 @@ static int test_varlen(hid_t fid) * *------------------------------------------------------------------------- */ -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 ) - return -1; + 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) - return -1; + 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); - H5Tclose(part_t); - if( H5PTis_valid(table) < 0) - goto out; + if (H5Tclose(part_t) < 0) + goto error; + 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) - goto out; + if (err < 0) + goto error; /* Read the particles back */ err = H5PTread_packets(table, (hsize_t)0, 7, &(readBuf[0])); - if( err < 0) - goto out; + 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) - goto out; + 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) - goto out; + if (err < 0) + goto error; PASSED(); - return 0; + return SUCCEED; - out: - H5_FAILED(); - if( H5PTis_valid(table) < 0) - H5PTclose(table); - return -1; +error: + H5_FAILED(); + if (H5PTis_valid(table) > 0) + H5PTclose(table); + return FAIL; } /*------------------------------------------------------------------------- @@ -767,22 +574,23 @@ static int test_opaque(hid_t fid) static int test_compress(void) { - hid_t fid1 = -1; - herr_t err; - hid_t table = -1; - hid_t part_t = -1; - hid_t dset_id = -1; - hid_t plist_id = -1; - 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(); @@ -791,108 +599,131 @@ 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++) - { - err = H5PTget_next(table, 1, readPart); - if(err < 0) TEST_ERROR; + for (c = 0; c < BIG_TABLE_SIZE; c++) { + err = H5PTget_next(table, (size_t)1, readPart); + 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 0; + 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 -1; + return FAIL; } /*------------------------------------------------------------------------- @@ -903,83 +734,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 */ - - herr_t err; /* Function return status */ - hsize_t count; /* Number of records in the table */ - - int x; /* Loop variable */ - - /* Buffers to hold data */ - int writeBuffer[5]; - int readBuffer[5]; - - TESTING("reading/writing non-native packet table"); - - /* 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_fl(fid, "Packet Test Dataset, Non-native", H5T_STD_I32BE, (hsize_t)100, -1); - } else { - ptable = H5PTcreate_fl(fid, "Packet Test Dataset, Non-native", H5T_STD_I32LE, (hsize_t)100, -1); - } - if(ptable == H5I_INVALID_HID) - goto out; - - /* Write one packet to the packet table */ - if( (err = H5PTappend(ptable, (hsize_t)1, &(writeBuffer[0]))) < 0 ) - goto out; - - /* Write several packets to the packet table */ - if( (err = H5PTappend(ptable, (hsize_t)4, &(writeBuffer[1]))) < 0) - goto out; - - if( (err = H5PTclose(ptable)) < 0) - goto out; - - /* Open the Packet table */ - if( (ptable = H5PTopen(fid, "Packet Test Dataset, Non-native")) < 0) - goto out; - - /* Get the number of packets in the packet table. This should be five. */ - if( (err = H5PTget_num_packets(ptable, &count)) < 0) - goto out; - - if( (int)count != 5 ) - goto out; - - /* Initialize packet table's "current record" */ - if( (err = H5PTcreate_index(ptable)) < 0) - goto out; - - /* Iterate through packets, read each one back */ - for(x=0; x<5; x++) { - if( (err = H5PTget_next(ptable, (hsize_t)1, &(readBuffer[x]))) < 0) - goto out; - if( x != readBuffer[x]) - goto out; - } - - /* Close the packet table */ - if( (err = H5PTclose(ptable)) < 0) - goto out; - - PASSED(); - return 0; - - out: - H5_FAILED(); - if( H5PTis_valid(ptable) < 0) - H5PTclose(ptable); - return -1; + hid_t ptable; /* Packet table identifier */ + + herr_t err; /* Function return status */ + hsize_t count; /* Number of records in the table */ + + int x; /* Loop variable */ + + /* Buffers to hold data */ + int writeBuffer[5]; + int readBuffer[5]; + + HL_TESTING2("reading/writing non-native packet table"); + + /* 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) + goto error; + + /* 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) + goto error; + + if ((err = H5PTclose(ptable)) < 0) + goto error; + + /* 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) + goto error; + + if ((int)count != 5) + goto error; + + /* 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; + } + + /* Close the packet table */ + if ((err = H5PTclose(ptable)) < 0) + goto error; + + PASSED(); + return SUCCEED; + +error: + H5_FAILED(); + if (H5PTis_valid(ptable) > 0) + H5PTclose(ptable); + return FAIL; } /*------------------------------------------------------------------------- @@ -990,131 +823,133 @@ static int test_rw_nonnative_dt(hid_t fid) * *------------------------------------------------------------------------- */ -static int test_error(hid_t fid) +static int +test_error(hid_t fid) { - hid_t id = H5I_BADID; - int id_open=0; - particle_t readBuf[1]; - - TESTING("error conditions"); - - /* Create a HL table */ - if(create_hl_table(fid) < 0) - goto out; - - /* Try to open things that are not packet tables */ - H5E_BEGIN_TRY - if(H5PTopen(fid, "Bogus_name") >= 0) - goto out; - if(H5PTopen(fid, "group1") >= 0) - goto out; - H5E_END_TRY - - /* Try to execute packet table commands on an invalid ID */ - H5E_BEGIN_TRY - if(H5PTis_valid(id) >= 0) - goto out; -#ifdef VLPT_REMOVED - if(H5PTis_varlen(id) >= 0) - goto out; -#endif /* VLPT_REMOVED */ - if(H5PTclose(id) >= 0) - goto out; - if(H5PTappend(id, (size_t)1, testPart) >= 0) - goto out; - if(H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0) - goto out; - if(H5PTcreate_index(id) >= 0) - goto out; - if(H5PTset_index(id, (hsize_t)1) >= 0) - goto out; - if(H5PTget_index(id, NULL) >= 0) - goto out; - 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) - goto out; - id_open = 1; - - H5E_BEGIN_TRY - if(H5PTis_valid(id) >= 0) - goto out; -#ifdef VLPT_REMOVED - if(H5PTis_varlen(id) >= 0) - goto out; -#endif /* VLPT_REMOVED */ - if(H5PTclose(id) >= 0) - goto out; - if(H5PTappend(id, (size_t)1, testPart) >= 0) - goto out; - if(H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0) - goto out; - if(H5PTcreate_index(id) >= 0) - goto out; - if(H5PTset_index(id, (hsize_t)1) >= 0) - goto out; - if(H5PTget_index(id, NULL) >= 0) - goto out; - H5E_END_TRY - - id_open=0; - if(H5Dclose(id) <0) - goto out; - - /* Open and close a packet table. Try to execute */ - /* commands on the closed ID. */ - if((id=H5PTopen(fid, PT_NAME))<0) - goto out; - if(H5PTclose(id) <0) - goto out; - - H5E_BEGIN_TRY - if(H5PTis_valid(id) >= 0) - goto out; -#ifdef VLPT_REMOVED - if(H5PTis_varlen(id) >= 0) - goto out; -#endif /* VLPT_REMOVED */ - if(H5PTclose(id) >= 0) - goto out; - if(H5PTappend(id, (size_t)1, testPart) >= 0) - goto out; - if(H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0) - goto out; - if(H5PTcreate_index(id) >= 0) - goto out; - if(H5PTset_index(id, (hsize_t)1) >= 0) - goto out; - if(H5PTget_index(id, NULL) >= 0) - goto out; - H5E_END_TRY - - PASSED(); - return 0; - -out: - H5_FAILED(); - if(id_open) - H5Dclose(id); - return -1; -} + hid_t id = H5I_INVALID_HID; + int id_open = 0; + particle_t readBuf[1]; + HL_TESTING2("error conditions"); -static int test_packet_table(hid_t fid) + /* 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) + goto error; + if (H5PTopen(fid, "group1") >= 0) + goto error; + H5E_END_TRY + + /* 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) + goto error; + if (H5PTclose(id) >= 0) + goto error; + if (H5PTappend(id, (size_t)1, testPart) >= 0) + goto error; + if (H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0) + goto error; + if (H5PTcreate_index(id) >= 0) + goto error; + if (H5PTset_index(id, (hsize_t)1) >= 0) + goto error; + if (H5PTget_index(id, NULL) >= 0) + goto error; + 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) + goto error; + id_open = 1; + + H5E_BEGIN_TRY + if (H5PTis_valid(id) >= 0) + goto error; + if (H5PTis_varlen(id) >= 0) + goto error; + if (H5PTclose(id) >= 0) + goto error; + if (H5PTappend(id, (size_t)1, testPart) >= 0) + goto error; + if (H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0) + goto error; + if (H5PTcreate_index(id) >= 0) + goto error; + if (H5PTset_index(id, (hsize_t)1) >= 0) + goto error; + if (H5PTget_index(id, NULL) >= 0) + goto error; + H5E_END_TRY + + 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) + goto error; + if (H5PTclose(id) < 0) + goto error; + + H5E_BEGIN_TRY + if (H5PTis_valid(id) >= 0) + goto error; + if (H5PTis_varlen(id) >= 0) + goto error; + if (H5PTclose(id) >= 0) + goto error; + if (H5PTappend(id, (size_t)1, testPart) >= 0) + goto error; + if (H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0) + goto error; + if (H5PTcreate_index(id) >= 0) + goto error; + if (H5PTset_index(id, (hsize_t)1) >= 0) + goto error; + if (H5PTget_index(id, NULL) >= 0) + goto error; + H5E_END_TRY + + PASSED(); + return SUCCEED; + +error: + H5_FAILED(); + if (id_open) + H5Dclose(id); + return FAIL; +} + +/*------------------------------------------------------------------------- + * test_packet_table(): Invokes individual tests to ensure that all + * functions work correctly, except for the variable-length related + * functions, which are tested in "test_packet_vlen.c". + * + *------------------------------------------------------------------------- + */ +static int +test_packet_table(hid_t fid) { - if( test_create_close(fid) < 0 ) - return -1; + if (test_create_close(fid) < 0) + return FAIL; - if( test_open(fid) < 0 ) - return -1; + 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 ) - return -1; + if (test_append(fid) < 0) + return FAIL; /* These tests will not necessarily cause failures in each other, so we don't abort the other tests if one fails. */ @@ -1122,38 +957,44 @@ static int test_packet_table(hid_t fid) test_get_next(fid); test_big_table(fid); test_rw_nonnative_dt(fid); -#ifdef VLPT_REMOVED - test_varlen(fid); -#endif /* VLPT_REMOVED */ test_opaque(fid); test_compress(); test_error(fid); - return 0; + return SUCCEED; } -int main(void) +/* + * + */ +int +main(void) { - /* identifier for the file */ - hid_t fid; - int status = 0; + /* identifier for the file that is used in FL PT tests */ + hid_t fid; + int status = 0; -/*------------------------------------------------------------------------- - * Packet test: test each function of the packet table - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * 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) + status = 1; - /* run tests */ - if ( test_packet_table(fid) < 0) - status = 1; + /* Test packet table with variable length, using separate data file */ + if (test_packet_table_with_varlen() < 0) + status = 1; - /* close */ - H5Fclose(fid); + /* Close the file */ + if (H5Fclose(fid) < 0) + status = 1; - return status; + return status; } diff --git a/hl/test/test_packet_vlen.c b/hl/test/test_packet_vlen.c new file mode 100644 index 0000000..5e06c85 --- /dev/null +++ b/hl/test/test_packet_vlen.c @@ -0,0 +1,1756 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://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" + +/*------------------------------------------------------------------------- + * Packet Table with Variable-Length test + * + *------------------------------------------------------------------------- + */ + +#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 + +/*------------------------------------------------------------------------- + * Local functions + *------------------------------------------------------------------------- + */ + +/* Verifies that the packet table is a variable- or fixed-length */ +static int verify_ptlengthtype(hid_t fid, const char *table_name, herr_t checked_value); + +/* Adds an attribute to the named packet table */ +static int adding_attribute(hid_t fid, const char *table_name, const char *attr_name); + +/* Verifies that the named attribute was written and is read correctly */ +static int verify_attribute(hid_t fid, const char *table_name, const char *attr_name); + +/*------------------------------------------------------------------------- + * test_VLof_atomic(): Test that a packet table with VL datatypes of atomic + * datatypes can be created and written correctly. (HDFFV-442) + * + * 2016/01/27 -BMR + *------------------------------------------------------------------------- + */ +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 */ + + 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) { + 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; + } /* end for */ + + /* Open the file */ + fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); + if (fid < 0) + goto error; + + /* Create a vlen type that uses an atomic datatype as its base type */ + vltype = H5Tvlen_create(H5T_NATIVE_UINT); + if (vltype < 0) + 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; + + /* Close the vlen datatype */ + if (H5Tclose(vltype) < 0) + goto error; + + /* Write the entire buffer to the packet table */ + ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf); + if (ret < 0) + 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; + + HDsnprintf(msg, sizeof(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); + if (ret < 0) + 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]) { + 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); + if (ret < 0) + goto error; + ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); + if (ret < 0) + goto error; + + /* Close the packet table */ + ret = H5PTclose(ptable); + if (ret < 0) + goto error; + + /* Close the file */ + if (H5Fclose(fid) < 0) + 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); + H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); + H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); + H5_FAILED(); + return FAIL; +} /* test_VLof_atomic */ + +/*------------------------------------------------------------------------- + * test_VLof_comptype(): Test that a packet table with VL datatypes of + * compound datatypes can be created and written correctly. (HDFFV-442) + * + * 2016/01/27 -BMR + *------------------------------------------------------------------------- + */ +static int +test_VLof_comptype(void) +{ + /* Struct that the VL sequences are composed of */ + typedef struct { + unsigned u; + 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; + + 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) { + 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 */ + + /* Open the file */ + fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); + if (fid < 0) + goto error; + + /* Create the base compound type */ + cmptype = H5Tcreate(H5T_COMPOUND, sizeof(VLcomp_t)); + if (cmptype < 0) + goto error; + + /* Insert fields */ + ret = H5Tinsert(cmptype, "u", HOFFSET(VLcomp_t, u), H5T_NATIVE_UINT); + if (ret < 0) + goto error; + ret = H5Tinsert(cmptype, "f", HOFFSET(VLcomp_t, f), H5T_NATIVE_FLOAT); + if (ret < 0) + 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; + + /* 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; + + /* Release the datatypes */ + if (H5Tclose(cmptype) < 0) + goto error; + if (H5Tclose(vltype) < 0) + goto error; + + /* Write the entire buffer to the packet table */ + ret = H5PTappend(ptable, (size_t)5, writeBuf); + if (ret < 0) + 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; + + HDsnprintf(msg, sizeof(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); + if (ret < 0) + goto error; + + /* Compare data read in */ + for (uu = 0; uu < NRECORDS; uu++) { + if (writeBuf[uu].len != readBuf[uu].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]) { + 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 */ + } + } /* end for */ + + /* Free the buffers */ + ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); + if (ret < 0) + goto error; + ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); + if (ret < 0) + goto error; + + /* Close the packet table */ + ret = H5PTclose(ptable); + if (ret < 0) + goto error; + + /* Close the file */ + if (H5Fclose(fid) < 0) + 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); + H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); + H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); + H5_FAILED(); + return FAIL; +} /* test_VLof_comptype */ + +/*------------------------------------------------------------------------- + * test_compound_VL_VL(): Test that a packet table of compound datatypes + * containing VL datatypes can be created and written + * correctly. (HDFFV-442) + * + * 2016/01/27 -BMR + *------------------------------------------------------------------------- + */ +static int +test_compound_VL_VLtype(void) +{ + /* Struct that the VL sequences are composed of */ + typedef struct { + unsigned u; + 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 */ + + 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].v.p = HDmalloc((uu + L1_INCM) * sizeof(hvl_t)); + if (writeBuf[uu].v.p == NULL) { + 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++) { + t1->p = HDmalloc((vv + L2_INCM) * sizeof(unsigned int)); + 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; + } + } /* end for */ + + /* Open the file */ + fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); + if (fid < 0) + goto error; + + /* Create a VL datatype of an atomic type */ + vlatomic = H5Tvlen_create(H5T_NATIVE_UINT); + if (vlatomic < 0) + goto error; + + /* Create a VL datatype of the VL of atomic datatype */ + vlofvl = H5Tvlen_create(vlatomic); + if (vlofvl < 0) + goto error; + + /* Create the base compound type */ + comp_vlvl = H5Tcreate(H5T_COMPOUND, sizeof(compVLVL_t)); + if (comp_vlvl < 0) + goto error; + + /* Insert fields: atomic, atomic, vlen */ + ret = H5Tinsert(comp_vlvl, "u", HOFFSET(compVLVL_t, u), H5T_NATIVE_UINT); + if (ret < 0) + goto error; + ret = H5Tinsert(comp_vlvl, "f", HOFFSET(compVLVL_t, f), H5T_NATIVE_FLOAT); + if (ret < 0) + goto error; + ret = H5Tinsert(comp_vlvl, "v", HOFFSET(compVLVL_t, v), vlofvl); + if (ret < 0) + 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; + + /* Release datatypes */ + if (H5Tclose(vlatomic) < 0) + goto error; + if (H5Tclose(vlofvl) < 0) + goto error; + if (H5Tclose(comp_vlvl) < 0) + goto error; + + /* Write the entire buffer to the packet table */ + ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf); + if (ret < 0) + 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; + + HDsnprintf(msg, sizeof(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); + if (ret < 0) + goto error; + + /* Compare data read in */ + for (uu = 0; uu < NRECORDS; uu++) { + if (writeBuf[uu].u != 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)) { + 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) { + 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++) { + if (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]) { + 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 */ + + /* Free the buffers */ + ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); + if (ret < 0) + goto error; + ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); + if (ret < 0) + goto error; + + /* Close the packet table */ + ret = H5PTclose(ptable); + if (ret < 0) + goto error; + + /* Close the file */ + if (H5Fclose(fid) < 0) + 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); + H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); + H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); + H5_FAILED(); + return FAIL; +} /* test_compound_VL_VLtype */ + +/*------------------------------------------------------------------------- + * 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) + * + * 2016/01/27 -BMR + *------------------------------------------------------------------------- + */ +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 */ + + 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) { + 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++) { + t1->p = HDmalloc((vv + 1) * sizeof(unsigned int)); + 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 */ + + /* Open the file */ + fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); + if (fid < 0) + goto error; + + /* Create a VL datatype of an atomic type */ + vlatomic = H5Tvlen_create(H5T_NATIVE_UINT); + if (vlatomic < 0) + goto error; + + vlofvl = H5Tvlen_create(vlatomic); + if (vlofvl < 0) + 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; + + /* Release datatypes */ + if (H5Tclose(vlatomic) < 0) + goto error; + if (H5Tclose(vlofvl) < 0) + goto error; + + /* Write the entire buffer to the packet table */ + ret = H5PTappend(ptable, (size_t)5, writeBuf); + if (ret < 0) + 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; + + HDsnprintf(msg, sizeof(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); + if (ret < 0) + goto error; + + /* Free the buffers */ + ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); + if (ret < 0) + goto error; + ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); + if (ret < 0) + goto error; + + /* Close the packet table */ + ret = H5PTclose(ptable); + if (ret < 0) + goto error; + + /* Close the file */ + if (H5Fclose(fid) < 0) + 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); + H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); + H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); + H5_FAILED(); + return FAIL; +} /* test_VLof_VLtype */ + +/*------------------------------------------------------------------------- + * verify_ptlengthtype() - helper function, verifies that the named packet + * 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) +{ + 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; + + /* Verify the value returned from H5PTis_varlen is as expected */ + is_varlen = H5PTis_varlen(ptable); + if (is_varlen == FAIL) + 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"); + 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; + + return ret; + +error: /* An error has occurred. Clean up and exit. */ + 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. + * + * Description: + * - Added a fixed-length packet table to the file for variety + * - Use the helper function verify_ptlengthtype to test H5PTis_varlen + * on each packet table. + * + * 2016/01/27 -BMR + *------------------------------------------------------------------------- + */ +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 */ + + HL_TESTING2("H5PTis_varlen"); + + /* Open the file */ + fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); + if (fid < 0) + 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; + + /* Close the packet table */ + ret = H5PTclose(ptable); + if (ret < 0) + goto error; + + /* Close the file */ + if (H5Fclose(fid) < 0) + goto error; + + /* Open the file */ + fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); + if (fid < 0) + 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; + ret = verify_ptlengthtype(fid, PT_VLEN_COMP, 1); /* vlen of compound */ + if (ret < 0) + goto error; + ret = verify_ptlengthtype(fid, PT_COMP_VLEN, 0); /* compound of vlen, no vlen */ + if (ret < 0) + goto error; + ret = verify_ptlengthtype(fid, PT_VLEN_VLEN, 1); /* vlen of vlen */ + if (ret < 0) + goto error; + ret = verify_ptlengthtype(fid, PT_FIXED_LEN, 0); /* no vlen */ + if (ret < 0) + goto error; + + /* Close the file */ + if (H5Fclose(fid) < 0) + goto error; + + PASSED(); + return SUCCEED; + +error: /* An error has occurred. Clean up and exit. */ + if (fid > 0) + H5Fclose(fid); + H5_FAILED(); + return FAIL; +} /* test_H5PTis_varlen */ + +/*------------------------------------------------------------------------- + * adding_attribute() - helper function, adds an attribute to the named + * 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. + * + * 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 */ + +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 */ + + /* Create dataspace for attribute */ + space_id = H5Screate_simple(ATTR_RANK, dims, NULL); + if (space_id < 0) + goto error; + + /* Open the named packet table */ + if ((ptable = H5PTopen(fid, table_name)) < 0) + goto error; + + dset_id = H5PTget_dataset(ptable); + if (dset_id < 0) + 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; + + /* Write attribute values */ + ret = H5Awrite(attr_id, H5T_NATIVE_INT, attr_data); + if (ret < 0) + goto error; + + /* Close the attribute */ + if (H5Aclose(attr_id) < 0) + goto error; + + /* Close the dataspace */ + if (H5Sclose(space_id) < 0) + goto error; + + /* Close the packet table */ + if (H5PTclose(ptable) < 0) + 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); + return ret; +} /* adding_attribute */ + +/*------------------------------------------------------------------------- + * verify_attribute() - helper function, verifies the named attribute can + * be read correctly. + * + * 2016/01/27 -BMR + *------------------------------------------------------------------------- + */ +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 */ + + /* Open the named packet table */ + ptable = H5PTopen(fid, table_name); + if (ptable < 0) + goto error; + + /* Get the dataset id of this packet table */ + dset_id = H5PTget_dataset(ptable); + if (dset_id < 0) + goto error; + + /* Open first attribute for the dataset */ + attr_id = H5Aopen(dset_id, attr_name, H5P_DEFAULT); + if (attr_id < 0) + goto error; + + /* Read attribute values */ + ret = H5Aread(attr_id, H5T_NATIVE_INT, read_data); + if (ret < 0) + 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]); + + /* Close the attribute */ + if (H5Aclose(attr_id) < 0) + goto error; + + /* Close the packet table */ + if (H5PTclose(ptable) < 0) + 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); + return ret; +} /* verify_attribute */ + +/*------------------------------------------------------------------------- + * test_attributes(): Test adding attributes to packet tables + * + * Description: + * Added attributes to some random packet tables in the file. + * + * 2016/01/27 -BMR + *------------------------------------------------------------------------- + */ +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 */ + + 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; + + /* 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; + attr_id = adding_attribute(fid, PT_VLEN_COMP, "Attribute 2"); + if (attr_id < 0) + goto error; + attr_id = adding_attribute(fid, PT_COMP_VLEN, "Attribute 3"); + if (attr_id < 0) + goto error; + + /* Close the file */ + if (H5Fclose(fid) < 0) + goto error; + + /* Open the file again */ + fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); + if (fid < 0) + 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; + ret = verify_attribute(fid, PT_VLEN_COMP, "Attribute 2"); + if (ret < 0) + goto error; + ret = verify_attribute(fid, PT_COMP_VLEN, "Attribute 3"); + if (ret < 0) + goto error; + + /* Close the file */ + if (H5Fclose(fid) < 0) + goto error; + + PASSED(); + return (ret); + +error: /* An error has occurred. Clean up and exit. */ + 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. + * + * Description: + * 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 + * + * 2016/01/27 -BMR + *------------------------------------------------------------------------- + */ +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]; + ssize_t name_size; + htri_t vlen_check_result = -1; + + /* Open the named packet table. */ + if ((ptable = H5PTopen(fid, table_name)) < 0) + goto error; + + /* Get the associated dataset ID. */ + if ((dset_id = H5PTget_dataset(ptable)) < 0) + goto error; + + /* Check if the packet table's name matches its associated dataset's. */ + *buf = '\0'; + 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 */ + if ((dtype_id = H5PTget_type(ptable)) < 0) + goto error; + + /* Check if the type class matches that of the packet table. */ + 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; + + return SUCCEED; + +error: /* An error has occurred. Clean up and exit. */ + if (H5PTis_valid(ptable) > 0) + H5PTclose(ptable); + H5_FAILED(); + return FAIL; +} /* verify_accessors */ + +/*------------------------------------------------------------------------- + * test_accessors(): Test the accessor functions + * + * Description: + * 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) +{ + hid_t fid = H5I_INVALID_HID; /* File identifier */ + herr_t ret = FAIL; /* Returned status from a callee */ + + HL_TESTING2("accessor functions"); + + /* Open the file */ + fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); + if (fid < 0) + goto error; + + ret = verify_accessors(fid, PT_VLEN_ATOMIC, TRUE); + if (ret < 0) + goto error; + + ret = verify_accessors(fid, PT_FIXED_LEN, FALSE); + if (ret < 0) + goto error; + + /* Close the file */ + if (H5Fclose(fid) < 0) + goto error; + + PASSED(); + return SUCCEED; + +error: /* An error has occurred. Clean up and exit. */ + 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 + +**************************************************************************/ + +/*------------------------------------------------------------------------- + * testfl_VLof_atomic(): Test that a packet table with VL datatypes of atomic + * datatypes can be created and written correctly. (HDFFV-442) + * + * 2016/01/27 -BMR + *------------------------------------------------------------------------- + */ +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 */ + + 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) { + 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; + } /* end for */ + + /* Open the file */ + fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); + if (fid < 0) + goto error; + + /* Create a vlen type that uses an atomic datatype as its base type */ + vltype = H5Tvlen_create(H5T_NATIVE_UINT); + if (vltype < 0) + 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; + + /* Close the vlen datatype */ + if (H5Tclose(vltype) < 0) + goto error; + + /* Write the entire buffer to the packet table */ + ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf); + if (ret < 0) + 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; + + HDsnprintf(msg, sizeof(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); + if (ret < 0) + 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]) { + 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); + if (ret < 0) + goto error; + ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); + if (ret < 0) + goto error; + + /* Close the packet table */ + ret = H5PTclose(ptable); + if (ret < 0) + goto error; + + /* Close the file */ + if (H5Fclose(fid) < 0) + 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); + H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); + H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); + H5_FAILED(); + return FAIL; +} /* testfl_VLof_atomic */ + +/*------------------------------------------------------------------------- + * testfl_VLof_comptype(): Test that a packet table with VL datatypes of + * compound datatypes can be created and written correctly. (HDFFV-442) + * + * 2016/01/27 -BMR + *------------------------------------------------------------------------- + */ +static int +testfl_VLof_comptype(void) +{ + /* Struct that the VL sequences are composed of */ + typedef struct { + unsigned u; + 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; + + 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) { + 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 */ + + /* Open the file */ + fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); + if (fid < 0) + goto error; + + /* Create the base compound type */ + cmptype = H5Tcreate(H5T_COMPOUND, sizeof(VLcomp_t)); + if (cmptype < 0) + goto error; + + /* Insert fields */ + ret = H5Tinsert(cmptype, "u", HOFFSET(VLcomp_t, u), H5T_NATIVE_UINT); + if (ret < 0) + goto error; + ret = H5Tinsert(cmptype, "f", HOFFSET(VLcomp_t, f), H5T_NATIVE_FLOAT); + if (ret < 0) + 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; + + /* 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; + + /* Release the datatypes */ + if (H5Tclose(cmptype) < 0) + goto error; + if (H5Tclose(vltype) < 0) + goto error; + + /* Write the entire buffer to the packet table */ + ret = H5PTappend(ptable, (size_t)5, writeBuf); + if (ret < 0) + 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; + + HDsnprintf(msg, sizeof(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); + if (ret < 0) + goto error; + + /* Compare data read in */ + for (uu = 0; uu < NRECORDS; uu++) { + if (writeBuf[uu].len != readBuf[uu].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]) { + 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 */ + } + } /* end for */ + + /* Free the buffers */ + ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); + if (ret < 0) + goto error; + ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); + if (ret < 0) + goto error; + + /* Close the packet table */ + ret = H5PTclose(ptable); + if (ret < 0) + goto error; + + /* Close the file */ + if (H5Fclose(fid) < 0) + 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); + H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); + H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); + H5_FAILED(); + return FAIL; +} /* testfl_VLof_comptype */ + +/*------------------------------------------------------------------------- + * testfl_compound_VL_VL(): Test that a packet table of compound datatypes + * containing VL datatypes can be created and written + * correctly. (HDFFV-442) + * + * 2016/01/27 -BMR + *------------------------------------------------------------------------- + */ +static int +testfl_compound_VL_VLtype(void) +{ + /* Struct that the VL sequences are composed of */ + typedef struct { + unsigned u; + 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 */ + + 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].v.p = HDmalloc((uu + L1_INCM) * sizeof(hvl_t)); + if (writeBuf[uu].v.p == NULL) { + 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++) { + t1->p = HDmalloc((vv + L2_INCM) * sizeof(unsigned int)); + 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; + } + } /* end for */ + + /* Open the file */ + fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); + if (fid < 0) + goto error; + + /* Create a VL datatype of an atomic type */ + vlatomic = H5Tvlen_create(H5T_NATIVE_UINT); + if (vlatomic < 0) + goto error; + + /* Create a VL datatype of the VL of atomic datatype */ + vlofvl = H5Tvlen_create(vlatomic); + if (vlofvl < 0) + goto error; + + /* Create the base compound type */ + comp_vlvl = H5Tcreate(H5T_COMPOUND, sizeof(compVLVL_t)); + if (comp_vlvl < 0) + goto error; + + /* Insert fields: atomic, atomic, vlen */ + ret = H5Tinsert(comp_vlvl, "u", HOFFSET(compVLVL_t, u), H5T_NATIVE_UINT); + if (ret < 0) + goto error; + ret = H5Tinsert(comp_vlvl, "f", HOFFSET(compVLVL_t, f), H5T_NATIVE_FLOAT); + if (ret < 0) + goto error; + ret = H5Tinsert(comp_vlvl, "v", HOFFSET(compVLVL_t, v), vlofvl); + if (ret < 0) + 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; + + /* Release datatypes */ + if (H5Tclose(vlatomic) < 0) + goto error; + if (H5Tclose(vlofvl) < 0) + goto error; + if (H5Tclose(comp_vlvl) < 0) + goto error; + + /* Write the entire buffer to the packet table */ + ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf); + if (ret < 0) + 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; + + HDsnprintf(msg, sizeof(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); + if (ret < 0) + goto error; + + /* Compare data read in */ + for (uu = 0; uu < NRECORDS; uu++) { + if (writeBuf[uu].u != 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)) { + 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) { + 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++) { + if (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]) { + 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 */ + + /* Free the buffers */ + ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); + if (ret < 0) + goto error; + ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); + if (ret < 0) + goto error; + + /* Close the packet table */ + ret = H5PTclose(ptable); + if (ret < 0) + goto error; + + /* Close the file */ + if (H5Fclose(fid) < 0) + 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); + H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); + H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); + H5_FAILED(); + return FAIL; +} /* testfl_compound_VL_VLtype */ + +/*------------------------------------------------------------------------- + * 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) + * + * 2016/01/27 -BMR + *------------------------------------------------------------------------- + */ +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 */ + + 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) { + 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++) { + t1->p = HDmalloc((vv + 1) * sizeof(unsigned int)); + 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 */ + + /* Open the file */ + fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); + if (fid < 0) + goto error; + + /* Create a VL datatype of an atomic type */ + vlatomic = H5Tvlen_create(H5T_NATIVE_UINT); + if (vlatomic < 0) + goto error; + + vlofvl = H5Tvlen_create(vlatomic); + if (vlofvl < 0) + 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; + + /* Release datatypes */ + if (H5Tclose(vlatomic) < 0) + goto error; + if (H5Tclose(vlofvl) < 0) + goto error; + + /* Write the entire buffer to the packet table */ + ret = H5PTappend(ptable, (size_t)5, writeBuf); + if (ret < 0) + 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; + + HDsnprintf(msg, sizeof(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); + if (ret < 0) + goto error; + + /* Free the buffers */ + ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); + if (ret < 0) + goto error; + ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); + if (ret < 0) + goto error; + + /* Close the packet table */ + ret = H5PTclose(ptable); + if (ret < 0) + goto error; + + /* Close the file */ + if (H5Fclose(fid) < 0) + 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); + H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); + H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); + H5_FAILED(); + return FAIL; +} /* testfl_VLof_VLtype */ + +/*------------------------------------------------------------------------- + * 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) + * + * 2016/01/27 -BMR + *------------------------------------------------------------------------- + */ +int +test_packet_table_with_varlen(void) +{ + 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; + + /* Close the file. The file will be opened by each test function below */ + if (H5Fclose(fid) < 0) + return FAIL; + + HDputs("Testing packet table with various variable-length datatypes"); + + /* If any test fails, move on to subsequent test, but status will indicate + there is a failure. */ + + /* Test variable length of a simple type */ + if (test_VLof_atomic() < 0) + status = FAIL; + + /* Test variable length of a compound type */ + if (test_VLof_comptype() < 0) + status = FAIL; + + /* Test compound type with variable length */ + if (test_compound_VL_VLtype() < 0) + status = FAIL; + + /* Test variable length of a variable length */ + if (test_VLof_VLtype() < 0) + status = FAIL; + + /* Test variable length of a variable length */ + if (test_H5PTis_varlen() < 0) + status = FAIL; + + /* Test adding attributes to packet table */ + if (test_attributes() < 0) + status = FAIL; + + /* Test accessor functions */ + if (test_accessors() < 0) + status = FAIL; + + /************************************************************************** + 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; + + /* Close the file. The file will be opened by each test function below */ + if (H5Fclose(fid) < 0) + return FAIL; + + HDputs("Testing packet table with various variable-length datatypes - H5PTcreate_fl"); + + /* If any test fails, move on to subsequent test, but status will indicate + there is a failure. */ + + /* Test variable length of a simple type */ + if (testfl_VLof_atomic() < 0) + status = FAIL; + + /* Test variable length of a compound type */ + if (testfl_VLof_comptype() < 0) + status = FAIL; + + /* Test compound type with variable length */ + if (testfl_compound_VL_VLtype() < 0) + status = FAIL; + + /* Test variable length of a variable length */ + if (testfl_VLof_VLtype() < 0) + status = FAIL; + + return (status); +} diff --git a/hl/test/test_table.c b/hl/test/test_table.c index 3bc5e5f..3c8246a 100644 --- a/hl/test/test_table.c +++ b/hl/test/test_table.c @@ -1,66 +1,57 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * -* the files COPYING and Copyright.html. COPYING can be found at the root * -* of the source code distribution tree; Copyright.html can be found at the * -* root level of an installed copy of the electronic HDF5 document set and * -* is linked from the top-level documents page. It can also be found at * -* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * -* access to either file, you may request a copy from help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include <stdlib.h> -#include <string.h> + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://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 "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; @@ -69,31 +60,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; @@ -103,11 +91,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; @@ -119,38 +106,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 */ + 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); } @@ -158,74 +144,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.0, -99.0, -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; @@ -239,210 +219,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.0, 80.0, 80}, {"nine", 90, 9.0, 90.0, 90}}; + particle_t ibuf[2] = {{"zero", 0, 0.0, 0.0, 0}, {"zero", 0, 0.0, 0.0, 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.0, + 0.0, + 0, + }, + {"one", 10, 1.0, 10.0, 10}, + {"two", 20, 2.0, 20.0, 20}, + {"three", 30, 3.0, 30.0, 30}, + {"four", 40, 4.0, 40.0, 40}, + {"five", 50, 5.0, 50.0, 50}, + {"six", 60, 6.0, 60.0, 60}, + {"seven", 70, 7.0, 70.0, 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.4, 2.5, {1, 2, 3}, {4, 5, 6}, {99, 100}}, + {12113, 1.4, 2.5, {1, 2, 3}, {4, 5, 6}, {99, 100}}, + {12114, 1.4, 2.5, {1, 2, 3}, {4, 5, 6}, {99, 100}}, + {12115, 1.4, 2.5, {1, 2, 3}, {4, 5, 6}, {99, 100}}, + {12116, 1.4, 2.5, {1, 2, 3}, {4, 5, 6}, {99, 100}}, + {12117, 1.4, 2.5, {1, 2, 3}, {4, 5, 6}, {99, 100}}, + {12118, 1.4, 2.5, {1, 2, 3}, {4, 5, 6}, {99, 100}}, + {12119, 1.4, 2.5, {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; @@ -450,83 +377,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; } @@ -534,147 +454,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; } } @@ -682,198 +594,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) @@ -885,109 +791,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; } } @@ -996,90 +895,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; } } @@ -1091,98 +979,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; } @@ -1190,170 +1067,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; } } @@ -1361,37 +1217,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; } @@ -1399,196 +1252,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 ) + nrecords = NRECORDS_ADD; + 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; } } @@ -1596,143 +1431,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 - * - *------------------------------------------------------------------------- - */ - - 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 ); + * + * Functions tested: + * + * H5TBget_field_info + * + *------------------------------------------------------------------------- + */ + + HL_TESTING2("getting field info"); + + /* allocate */ + 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 */ @@ -1743,5 +1575,3 @@ out: H5Fclose(fid); return 1; } - - |
