diff options
author | Scot Breitenfeld <brtnfld@hdfgroup.org> | 2017-11-28 22:15:38 (GMT) |
---|---|---|
committer | Scot Breitenfeld <brtnfld@hdfgroup.org> | 2017-11-28 22:15:38 (GMT) |
commit | 585cf69c56ea3411c0e661ad71b208ecac7732a7 (patch) | |
tree | 845277b869e384540f4207bd631a01f4a04e77b9 /test | |
parent | e1dd55be8538ee0ebd1c46be3df4b306a3ac6f3f (diff) | |
parent | 8d462d5102295359090297c707a20eaaf76ec965 (diff) | |
download | hdf5-585cf69c56ea3411c0e661ad71b208ecac7732a7.zip hdf5-585cf69c56ea3411c0e661ad71b208ecac7732a7.tar.gz hdf5-585cf69c56ea3411c0e661ad71b208ecac7732a7.tar.bz2 |
Merge pull request #805 in HDFFV/hdf5 from ~BRTNFLD/hdf5_msb:hdf5_1_10 to hdf5_1_10
* commit '8d462d5102295359090297c707a20eaaf76ec965': (34 commits)
Update macros
Changed casts to const void *
Casted pointers to void to quiet warnings on Linux.
Added CHECK_PTR_EQ macro to testhdf5 to quiet cast warnings on Windows.
Fixed misc Warnings flagged by VS2017.
Made a dcpl layout struct in H5Z.c dynamic to quiet a stack size warning.
Fixed an uninitialized filter callback struct in H5Dchunk.c and unified the naming and initialization of said struct throughout the library. This was causing a crash on VS2015 in debug mode when the debug heap complained. Fixes HDFFV-10330.
Fixed Windows code in H5PLpath.c
Brings H5Z and H5PL packages in sync with VOL integration branch.
HDFFV-10328 - fix typos
HDFFV-10328 remove allocation note
HDFFV-10328 - remove allocation changes
Fix typo
HDFFV-10328 merge allocation changes from 1.8
Fix some of the whitespace
Add note for plugins
Correct linkage of filters and other libs
Changed ar to always use -cr instead of the autotools default of cru.
Minor warning fixes
Moved code from H5O.c to H5Oint.c
...
Diffstat (limited to 'test')
35 files changed, 2826 insertions, 2455 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4e6b0e5..fca864b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -70,73 +70,73 @@ if (BUILD_SHARED_LIBS) endif () #----------------------------------------------------------------------------- -# If plugin library tests can be tested +# If filter plugin tests can be tested #----------------------------------------------------------------------------- # make plugins dir - file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/testdir1") - file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/testdir2") + file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/filter_plugin_dir1") + file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/filter_plugin_dir2") #----------------------------------------------------------------------------- - # Define Plugin Test Sources + # Define Filter Plugin Test Sources #----------------------------------------------------------------------------- - set (TEST_PLUGIN_LIBS - dynlib1 - dynlib3 + set (FILTER_PLUGINS_FOR_DIR1 + filter_plugin1_dsets + filter_plugin3_dsets ) - set (TEST2_PLUGIN_LIBS - dynlib2 - dynlib4 + set (FILTER_PLUGINS_FOR_DIR2 + filter_plugin2_dsets + filter_plugin4_groups ) - foreach (test_lib ${TEST_PLUGIN_LIBS}) - set (HDF5_TEST_PLUGIN_LIB_CORENAME "${test_lib}") - set (HDF5_TEST_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TEST_PLUGIN_LIB_CORENAME}") - set (HDF5_TEST_PLUGIN_LIB_TARGET ${HDF5_TEST_PLUGIN_LIB_CORENAME}) + foreach (plugin_name ${FILTER_PLUGINS_FOR_DIR1}) + set (HDF5_TEST_PLUGIN_CORENAME "${plugin_name}") + set (HDF5_TEST_PLUGIN_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TEST_PLUGIN_CORENAME}") + set (HDF5_TEST_PLUGIN_TARGET ${HDF5_TEST_PLUGIN_CORENAME}) add_definitions (${HDF_EXTRA_C_FLAGS}) INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) - add_library (${HDF5_TEST_PLUGIN_LIB_TARGET} SHARED ${HDF5_TEST_SOURCE_DIR}/${test_lib}.c) - TARGET_C_PROPERTIES (${HDF5_TEST_PLUGIN_LIB_TARGET} SHARED " " " ") - target_link_libraries (${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) - H5_SET_LIB_OPTIONS (${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_PLUGIN_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION}) - set_target_properties (${HDF5_TEST_PLUGIN_LIB_TARGET} PROPERTIES FOLDER libraries/TEST_PLUGIN) + add_library (${HDF5_TEST_PLUGIN_TARGET} SHARED ${HDF5_TEST_SOURCE_DIR}/${plugin_name}.c) + TARGET_C_PROPERTIES (${HDF5_TEST_PLUGIN_TARGET} SHARED " " " ") + target_link_libraries (${HDF5_TEST_PLUGIN_TARGET} ${HDF5_TEST_LIB_TARGET}) + H5_SET_LIB_OPTIONS (${HDF5_TEST_PLUGIN_TARGET} ${HDF5_TEST_PLUGIN_NAME} SHARED ${HDF5_PACKAGE_SOVERSION}) + set_target_properties (${HDF5_TEST_PLUGIN_TARGET} PROPERTIES FOLDER libraries/TEST_PLUGIN) #----------------------------------------------------------------------------- - # Copy plugin library to a plugins folder + # Copy the filter plugin to a plugins folder #----------------------------------------------------------------------------- add_custom_command ( - TARGET ${HDF5_TEST_PLUGIN_LIB_TARGET} + TARGET ${HDF5_TEST_PLUGIN_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different - "$<TARGET_FILE:${HDF5_TEST_PLUGIN_LIB_TARGET}>" - "${CMAKE_BINARY_DIR}/testdir1/$<TARGET_FILE_NAME:${HDF5_TEST_PLUGIN_LIB_TARGET}>" + "$<TARGET_FILE:${HDF5_TEST_PLUGIN_TARGET}>" + "${CMAKE_BINARY_DIR}/filter_plugin_dir1/$<TARGET_FILE_NAME:${HDF5_TEST_PLUGIN_TARGET}>" ) endforeach () - foreach (test_lib ${TEST2_PLUGIN_LIBS}) - set (HDF5_TEST_PLUGIN_LIB_CORENAME "${test_lib}") - set (HDF5_TEST_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TEST_PLUGIN_LIB_CORENAME}") - set (HDF5_TEST_PLUGIN_LIB_TARGET ${HDF5_TEST_PLUGIN_LIB_CORENAME}) + foreach ( plugin_name ${FILTER_PLUGINS_FOR_DIR2}) + set (HDF5_TEST_PLUGIN_CORENAME "${plugin_name}") + set (HDF5_TEST_PLUGIN_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TEST_PLUGIN_CORENAME}") + set (HDF5_TEST_PLUGIN_TARGET ${HDF5_TEST_PLUGIN_CORENAME}) add_definitions (${HDF_EXTRA_C_FLAGS}) INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) - add_library (${HDF5_TEST_PLUGIN_LIB_TARGET} SHARED ${HDF5_TEST_SOURCE_DIR}/${test_lib}.c) - TARGET_C_PROPERTIES (${HDF5_TEST_PLUGIN_LIB_TARGET} SHARED " " " ") - target_link_libraries (${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) - H5_SET_LIB_OPTIONS (${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_PLUGIN_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION}) - set_target_properties (${HDF5_TEST_PLUGIN_LIB_TARGET} PROPERTIES FOLDER libraries/TEST_PLUGIN) + add_library (${HDF5_TEST_PLUGIN_TARGET} SHARED ${HDF5_TEST_SOURCE_DIR}/${plugin_name}.c) + TARGET_C_PROPERTIES (${HDF5_TEST_PLUGIN_TARGET} SHARED " " " ") + target_link_libraries (${HDF5_TEST_PLUGIN_TARGET} ${HDF5_TEST_LIB_TARGET}) + H5_SET_LIB_OPTIONS (${HDF5_TEST_PLUGIN_TARGET} ${HDF5_TEST_PLUGIN_NAME} SHARED ${HDF5_PACKAGE_SOVERSION}) + set_target_properties (${HDF5_TEST_PLUGIN_TARGET} PROPERTIES FOLDER libraries/TEST_PLUGIN) #----------------------------------------------------------------------------- - # Copy plugin library to a plugins folder + # Copy the filter plugin to a plugins folder #----------------------------------------------------------------------------- add_custom_command ( - TARGET ${HDF5_TEST_PLUGIN_LIB_TARGET} + TARGET ${HDF5_TEST_PLUGIN_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different - "$<TARGET_FILE:${HDF5_TEST_PLUGIN_LIB_TARGET}>" - "${CMAKE_BINARY_DIR}/testdir2/$<TARGET_FILE_NAME:${HDF5_TEST_PLUGIN_LIB_TARGET}>" + "$<TARGET_FILE:${HDF5_TEST_PLUGIN_TARGET}>" + "${CMAKE_BINARY_DIR}/filter_plugin_dir2/$<TARGET_FILE_NAME:${HDF5_TEST_PLUGIN_TARGET}>" ) endforeach () @@ -411,17 +411,17 @@ endif () ### P L U G I N T E S T S ############################################################################## if (BUILD_SHARED_LIBS) - add_executable (plugin ${HDF5_TEST_SOURCE_DIR}/plugin.c) - TARGET_NAMING (plugin SHARED) - TARGET_C_PROPERTIES (plugin SHARED " " " ") - target_link_libraries (plugin ${HDF5_TEST_LIB_TARGET}) - set_target_properties (plugin PROPERTIES FOLDER test) + add_executable (filter_plugin ${HDF5_TEST_SOURCE_DIR}/filter_plugin.c) + TARGET_NAMING (filter_plugin SHARED) + TARGET_C_PROPERTIES (filter_plugin SHARED " " " ") + target_link_libraries (filter_plugin ${HDF5_TEST_LIB_TARGET}) + set_target_properties (filter_plugin PROPERTIES FOLDER test) else () - add_executable (plugin ${HDF5_TEST_SOURCE_DIR}/plugin.c) - TARGET_NAMING (plugin STATIC) - TARGET_C_PROPERTIES (plugin STATIC " " " ") - target_link_libraries (plugin ${HDF5_TEST_LIB_TARGET}) - set_target_properties (plugin PROPERTIES FOLDER test) + add_executable (filter_plugin ${HDF5_TEST_SOURCE_DIR}/filter_plugin.c) + TARGET_NAMING (filter_plugin STATIC) + TARGET_C_PROPERTIES (filter_plugin STATIC " " " ") + target_link_libraries (filter_plugin ${HDF5_TEST_LIB_TARGET}) + set_target_properties (filter_plugin PROPERTIES FOLDER test) endif () ############################################################################## diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index 61ac3d2..973d389 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -1,4 +1,4 @@ -# + # Copyright by The HDF Group. # All rights reserved. # @@ -520,7 +520,7 @@ set (test_CLEANFILES multi_file-r.h5 multi_file-s.h5 core_file - plugin.h5 + filter_plugin.h5 new_move_a.h5 new_move_b.h5 ntypes.h5 @@ -1013,7 +1013,7 @@ if (BUILD_SHARED_LIBS) endif () ############################################################################## -### P L U G I N T E S T S +### F I L T E R P L U G I N T E S T S ############################################################################## if (WIN32) set (CMAKE_SEP "\;") @@ -1023,9 +1023,9 @@ else () set (BIN_REL_PATH "../") endif () -add_test (NAME H5PLUGIN-plugin COMMAND $<TARGET_FILE:plugin>) -set_tests_properties (H5PLUGIN-plugin PROPERTIES - ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/testdir1${CMAKE_SEP}${CMAKE_BINARY_DIR}/testdir2;srcdir=${HDF5_TEST_BINARY_DIR}" +add_test (NAME H5PLUGIN-filter_plugin COMMAND $<TARGET_FILE:filter_plugin>) +set_tests_properties (H5PLUGIN-filter_plugin PROPERTIES + ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/filter_plugin_dir1${CMAKE_SEP}${CMAKE_BINARY_DIR}/filter_plugin_dir2;srcdir=${HDF5_TEST_BINARY_DIR}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR} ) diff --git a/test/Makefile.am b/test/Makefile.am index ba2d79b..efdc1ca 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -26,11 +26,12 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_builddir)/src # testlibinfo.sh: # testcheck_version.sh: tcheck_version # testlinks_env.sh: links_env -# test_filenotclosed.sh: filenotclosed.c # testflushrefresh.sh: flushrefresh -# test_usecases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes # testswmr.sh: swmr* # testvdsswmr.sh: vds_swmr* +# test_filenotclosed.sh: filenotclosed.c +# test_filter_plugin.sh: filter_plugin.c +# test_usecases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_filenotclosed.sh\ testswmr.sh testvdsswmr.sh testflushrefresh.sh test_usecases.sh SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) test_filenotclosed$(EXEEXT) \ @@ -40,8 +41,8 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) test_ swmr_sparse_reader$(EXEEXT) swmr_sparse_writer$(EXEEXT) swmr_start_write$(EXEEXT) \ vds_swmr_gen$(EXEEXT) vds_swmr_reader$(EXEEXT) vds_swmr_writer$(EXEEXT) if HAVE_SHARED_CONDITIONAL - TEST_SCRIPT += test_plugin.sh - SCRIPT_DEPEND += plugin$(EXEEXT) + TEST_SCRIPT += test_filter_plugin.sh + SCRIPT_DEPEND += filter_plugin$(EXEEXT) endif check_SCRIPTS = $(TEST_SCRIPT) @@ -81,7 +82,7 @@ check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version \ swmr_remove_writer swmr_addrem_writer swmr_sparse_reader swmr_sparse_writer \ swmr_check_compat_vfd vds_swmr_gen vds_swmr_reader vds_swmr_writer if HAVE_SHARED_CONDITIONAL - check_PROGRAMS+= plugin + check_PROGRAMS+= filter_plugin endif # These programs generate test files for the tests. They don't need to be @@ -102,29 +103,17 @@ endif if HAVE_SHARED_CONDITIONAL # The libh5test library provides common support code for the tests. - # The libdynlib1, libdynlib2, libdynlib3, and libdynlib4 library for testing plugin module plugin.c. - # Build them as shared libraries if configure is enabled for shared library. - noinst_LTLIBRARIES=libh5test.la libdynlib1.la libdynlib2.la libdynlib3.la libdynlib4.la - libdynlib1_la_SOURCES=dynlib1.c - libdynlib2_la_SOURCES=dynlib2.c - libdynlib3_la_SOURCES=dynlib3.c - libdynlib4_la_SOURCES=dynlib4.c - libdynlib1_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere - libdynlib2_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere - libdynlib3_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere - libdynlib4_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere - - libdynlib1.la: $(libdynlib1_la_OBJECTS) $(libdynlib1_la_DEPENDENCIES) $(EXTRA_libdynlib1_la_DEPENDENCIES) - $(AM_V_CCLD)$(libdynlib1_la_LINK) $(am_libdynlib1_la_rpath) $(libdynlib1_la_OBJECTS) $(libdynlib1_la_LIBADD) - - libdynlib2.la: $(libdynlib2_la_OBJECTS) $(libdynlib2_la_DEPENDENCIES) $(EXTRA_libdynlib2_la_DEPENDENCIES) - $(AM_V_CCLD)$(libdynlib2_la_LINK) $(am_libdynlib2_la_rpath) $(libdynlib2_la_OBJECTS) $(libdynlib2_la_LIBADD) - - libdynlib3.la: $(libdynlib3_la_OBJECTS) $(libdynlib3_la_DEPENDENCIES) $(EXTRA_libdynlib3_la_DEPENDENCIES) - $(AM_V_CCLD)$(libdynlib3_la_LINK) $(am_libdynlib3_la_rpath) $(libdynlib3_la_OBJECTS) $(libdynlib3_la_LIBADD) - - libdynlib4.la: $(libdynlib4_la_OBJECTS) $(libdynlib4_la_DEPENDENCIES) $(EXTRA_libdynlib4_la_DEPENDENCIES) - $(AM_V_CCLD)$(libdynlib4_la_LINK) $(am_libdynlib4_la_rpath) $(libdynlib4_la_OBJECTS) $(libdynlib4_la_LIBADD) + # The filter_plugin* libraries are for use in filter_plugin.c. + # Build them as shared libraries if that option was enabled in configure. + noinst_LTLIBRARIES=libh5test.la libfilter_plugin1_dsets.la libfilter_plugin2_dsets.la libfilter_plugin3_dsets.la libfilter_plugin4_groups.la + libfilter_plugin1_dsets_la_SOURCES=filter_plugin1_dsets.c + libfilter_plugin2_dsets_la_SOURCES=filter_plugin2_dsets.c + libfilter_plugin3_dsets_la_SOURCES=filter_plugin3_dsets.c + libfilter_plugin4_groups_la_SOURCES=filter_plugin4_groups.c + libfilter_plugin1_dsets_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere + libfilter_plugin2_dsets_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere + libfilter_plugin3_dsets_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere + libfilter_plugin4_groups_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere else # The libh5test library provides common support code for the tests. noinst_LTLIBRARIES=libh5test.la @@ -185,7 +174,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse tmisc[0-9]*.h5 set_extent[1-5].h5 ext[12].bin \ getname.h5 getname[1-3].h5 sec2_file.h5 direct_file.h5 \ family_file000[0-3][0-9].h5 new_family_v16_000[0-3][0-9].h5 \ - multi_file-[rs].h5 core_file plugin.h5 \ + multi_file-[rs].h5 core_file filter_plugin.h5 \ new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \ dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ unlink_chunked.h5 btree2.h5 btree2_tmp.h5 objcopy_src.h5 objcopy_dst.h5 \ @@ -215,7 +204,7 @@ use_append_mchunks_SOURCES=use_append_mchunks.c use_common.c use_disable_mdc_flushes_SOURCES=use_disable_mdc_flushes.c # Temporary files. -DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_plugin.sh \ +DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_filter_plugin.sh \ testswmr.sh testvdsswmr.sh test_usecases.sh testflushrefresh.sh test_filenotclosed.sh include $(top_srcdir)/config/conclude.am diff --git a/test/cache_tagging.c b/test/cache_tagging.c index 99ab49c..9c79968 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -3631,11 +3631,14 @@ error: static unsigned check_invalid_tag_application(void) { +#if H5C_DO_TAGGING_SANITY_CHECKS /* Variables */ H5F_t * f = NULL; - hid_t fid, dxpl_id = -1; + hid_t fid = -1; + hid_t dxpl_id = -1; haddr_t addr; H5HL_t * lheap = NULL; +#endif /* H5C_DO_TAGGING_SANITY_CHECKS */ /* Testing Macro */ TESTING("failure on invalid tag application"); @@ -3683,8 +3686,8 @@ check_invalid_tag_application(void) PASSED(); #else SKIPPED(); - printf(" test skipped because sanity checking on tag value is disabled.\n"); -#endif + HDprintf(" test skipped because sanity checking on tag value is disabled.\n"); +#endif /* H5C_DO_TAGGING_SANITY_CHECKS */ return 0; @@ -3791,10 +3794,10 @@ main(void) HDremove(FILENAME2); /* Return Errors */ - return(nerrs > 0); + return nerrs > 0; error: /* Return with Error */ - return(1); + return 1; } /* main */ diff --git a/test/cross_read.c b/test/cross_read.c index 5d5ef07..2219151 100644 --- a/test/cross_read.c +++ b/test/cross_read.c @@ -226,7 +226,9 @@ check_file(char *filename) const char *pathname = H5_get_srcdir_filename(filename); /* Corrected test file name */ hid_t fid = -1; /* file ID */ int nerrors = 0; /* # of datasets with errors */ +#if !defined(H5_HAVE_FILTER_DEFLATE) || !defined(H5_HAVE_FILTER_SZIP) const char *not_supported= " filter is not enabled."; /* no filter message */ +#endif /* Open the file. */ if((fid = H5Fopen(pathname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) diff --git a/test/dynlib1.c b/test/dynlib1.c deleted file mode 100644 index e9137fb..0000000 --- a/test/dynlib1.c +++ /dev/null @@ -1,95 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Programmer: Raymond Lu - * 13 February 2013 - * - * Purpose: Tests the plugin module (H5PL) - */ - -#include <stdlib.h> -#include <stdio.h> -#include "H5PLextern.h" - -#define H5Z_FILTER_DYNLIB1 257 - -static size_t H5Z_filter_dynlib1(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_DYNLIB1[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_DYNLIB1, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "dynlib1", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlib1, /* The actual filter function */ -}}; - -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB1;} - -/*------------------------------------------------------------------------- - * Function: H5Z_filter_dynlib1 - * - * Purpose: A dynlib1 filter method that adds on and subtract from - * the original value with another value. It will be built - * as a shared library. plugin.c test will load and use - * this filter library. - * - * Return: Success: Data chunk size - * - * Failure: 0 - * - * Programmer: Raymond Lu - * 29 March 2013 - * - *------------------------------------------------------------------------- - */ -static size_t -H5Z_filter_dynlib1(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) -{ - int *int_ptr = (int *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ - int add_on = 0; - - /* Check for the correct number of parameters */ - if(cd_nelmts == 0) - return(0); - - /* Check that permanent parameters are set correctly */ - if(cd_values[0] > 9) - return(0); - - add_on = (int)cd_values[0]; - - if(flags & H5Z_FLAG_REVERSE) { /*read*/ - /* Substract the "add on" value to all the data values */ - while(buf_left > 0) { - *int_ptr++ -= add_on; - buf_left -= sizeof(int); - } /* end while */ - } /* end if */ - else { /*write*/ - /* Add the "add on" value to all the data values */ - while(buf_left > 0) { - *int_ptr++ += add_on; - buf_left -= sizeof(int); - } /* end while */ - } /* end else */ - - return nbytes; -} /* end H5Z_filter_dynlib1() */ - diff --git a/test/dynlib2.c b/test/dynlib2.c deleted file mode 100644 index 2574d4d..0000000 --- a/test/dynlib2.c +++ /dev/null @@ -1,92 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Programmer: Raymond Lu - * 13 February 2013 - * - * Purpose: Tests the plugin module (H5PL) - */ - -#include <stdlib.h> -#include <stdio.h> -#include "H5PLextern.h" - -#define H5Z_FILTER_DYNLIB2 258 -#define MULTIPLIER 3 - -static size_t H5Z_filter_dynlib2(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_DYNLIB2[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_DYNLIB2, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "dynlib2", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlib2, /* The actual filter function */ -}}; - -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB2;} - -/*------------------------------------------------------------------------- - * Function: H5Z_filter_dynlib2 - * - * Purpose: A dynlib2 filter method that multiplies the original value - * during write and divide the original value during read. It - * will be built as a shared library. plugin.c test will load - * and use this filter library. - * - * Return: Success: Data chunk size - * - * Failure: 0 - * - * Programmer: Raymond Lu - * 29 March 2013 - * - *------------------------------------------------------------------------- - */ -static size_t -H5Z_filter_dynlib2(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) -{ - int *int_ptr = (int *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ - - /* Check for the correct number of parameters */ - if(cd_nelmts > 0) - return(0); - - /* Assignment to eliminate unused parameter warning. */ - cd_values = cd_values; - - if(flags & H5Z_FLAG_REVERSE) { /*read*/ - /* Divide the original value with MULTIPLIER */ - while(buf_left > 0) { - *int_ptr++ /= MULTIPLIER; - buf_left -= sizeof(int); - } /* end while */ - } /* end if */ - else { /*write*/ - /* Multiply the original value with MULTIPLIER */ - while(buf_left > 0) { - *int_ptr++ *= MULTIPLIER; - buf_left -= sizeof(int); - } /* end while */ - } /* end else */ - - return nbytes; -} /* end H5Z_filter_dynlib2() */ - diff --git a/test/dynlib3.c b/test/dynlib3.c deleted file mode 100644 index 8871321..0000000 --- a/test/dynlib3.c +++ /dev/null @@ -1,103 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Programmer: Raymond Lu - * 1 April 2013 - * - * Purpose: Tests the plugin module (H5PL) - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include "H5PLextern.h" - -#define H5Z_FILTER_DYNLIB3 259 -#define SUFFIX_LEN 8 -#define GROUP_SUFFIX ".h5group" - -static size_t H5Z_filter_dynlib3(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_DYNLIB3[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_DYNLIB3, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "dynlib3", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlib3, /* The actual filter function */ -}}; - -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB3;} - -/*------------------------------------------------------------------------- - * Function: H5Z_filter_dynlib3 - * - * Purpose: A dynlib3 filter method that is used to test groups. It - * appends the suffix ".h5group" to each group name during - * write and takes it out during read. - * - * Return: Success: Data chunk size - * - * Failure: 0 - * - * Programmer: Raymond Lu - * 1 April 2013 - * - *------------------------------------------------------------------------- - */ -static size_t -H5Z_filter_dynlib3(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) -{ - size_t ret_value; /* Return value */ - - /* Check for the correct number of parameters */ - if(cd_nelmts > 0) - return(0); - - /* Assignment to eliminate unused parameter warning. */ - cd_values = cd_values; - - if(flags & H5Z_FLAG_REVERSE) { /*read*/ - ret_value = *buf_size = nbytes - SUFFIX_LEN; - } /* end if */ - else { /*write*/ - void *outbuf = NULL; /* Pointer to new buffer */ - unsigned char *dst; /* Temporary pointer to destination buffer */ - - dst = (unsigned char *)(outbuf = H5allocate_memory(nbytes + SUFFIX_LEN, 0)); - - /* Copy raw data */ - memcpy((void*)dst, (void*)(*buf), nbytes); - - /* Append suffix to raw data for storage */ - dst += nbytes; - memcpy(dst, (void*)GROUP_SUFFIX, SUFFIX_LEN); - - /* Free input buffer */ - H5free_memory(*buf); - - /* Set return values */ - *buf_size = nbytes + SUFFIX_LEN; - *buf = outbuf; - outbuf = NULL; - ret_value = *buf_size; - } /* end else */ - - return ret_value; -} /* H5Z_filter_dynlib3() */ - diff --git a/test/dynlib4.c b/test/dynlib4.c deleted file mode 100644 index 06d90ff..0000000 --- a/test/dynlib4.c +++ /dev/null @@ -1,102 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Purpose: Tests the plugin module (H5PL) - */ - -#include <stdlib.h> -#include <stdio.h> -#include "H5PLextern.h" - -#define H5Z_FILTER_DYNLIB4 260 - -#define PUSH_ERR(func, minor, str) H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, H5E_ERR_CLS, H5E_PLUGIN, minor, str) - -static size_t H5Z_filter_dynlib4(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_DYNLIB4[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_DYNLIB4, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "dynlib4", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlib4, /* The actual filter function */ -}}; - -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB4;} - -/*------------------------------------------------------------------------- - * Function: H5Z_filter_dynlib4 - * - * Purpose: A dynlib4 filter method that adds on and subtract from - * the original value with another value. It will be built - * as a shared library. plugin.c test will load and use - * this filter library. Designed to call a HDF function. - * - * Return: Success: Data chunk size - * - * Failure: 0 - * - *------------------------------------------------------------------------- - */ -static size_t -H5Z_filter_dynlib4(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) -{ - int *int_ptr = (int *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ - int add_on = 0; - unsigned ver_info[3]; - - /* Check for the library version */ - if(H5get_libversion(&ver_info[0], &ver_info[1], &ver_info[2]) < 0) { - PUSH_ERR("dynlib4", H5E_CALLBACK, "H5get_libversion"); - return(0); - } - /* Check for the correct number of parameters */ - if(cd_nelmts == 0) - return(0); - - /* Check that permanent parameters are set correctly */ - if(cd_values[0] > 9) - return(0); - - if(ver_info[0] != cd_values[1] || ver_info[1] != cd_values[2]) { - PUSH_ERR("dynlib4", H5E_CALLBACK, "H5get_libversion does not match"); - return(0); - } - - add_on = (int)cd_values[0]; - - if(flags & H5Z_FLAG_REVERSE) { /*read*/ - /* Substract the "add on" value to all the data values */ - while(buf_left > 0) { - *int_ptr++ -= add_on; - buf_left -= sizeof(int); - } /* end while */ - } /* end if */ - else { /*write*/ - /* Add the "add on" value to all the data values */ - while(buf_left > 0) { - *int_ptr++ += add_on; - buf_left -= sizeof(int); - } /* end while */ - } /* end else */ - - return nbytes; -} /* end H5Z_filter_dynlib4() */ - diff --git a/test/error_test.c b/test/error_test.c index 9c39065..5356fa7 100644 --- a/test/error_test.c +++ b/test/error_test.c @@ -82,35 +82,33 @@ static herr_t custom_print_cb(unsigned n, const H5E_error2_t *err_desc, /*------------------------------------------------------------------------- - * Function: test_error + * Function: test_error * - * Purpose: Test error API functions + * Purpose: Test error API functions * - * Return: Success: 0 - * - * Failure: -1 - * - * Programmer: Raymond Lu - * July 10, 2003 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ static herr_t test_error(hid_t file) { - hid_t dataset, space; - hid_t estack_id; + hid_t dataset = -1; + hid_t space = -1; + hid_t estack_id = -1; hsize_t dims[2]; const char *FUNC_test_error = "test_error"; H5E_auto2_t old_func; - void *old_data; + void *old_data = NULL; HDfprintf(stderr, "\nTesting error API based on data I/O\n"); /* Create the data space */ dims[0] = DIM0; dims[1] = DIM1; - if ((space = H5Screate_simple(2, dims, NULL))<0) TEST_ERROR; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR; /* Test H5E_BEGIN_TRY */ H5E_BEGIN_TRY { @@ -118,40 +116,40 @@ test_error(hid_t file) } H5E_END_TRY; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + if ((dataset = H5Dcreate2(file, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5Epush(H5E_DEFAULT, __FILE__, FUNC_test_error, __LINE__, ERR_CLS, ERR_MAJ_IO, ERR_MIN_CREATE, "H5Dcreate2 failed"); goto error; - } /* end if */ + } /* Test enabling and disabling default printing */ - if(H5Eget_auto2(H5E_DEFAULT, &old_func, &old_data) < 0) - TEST_ERROR; - if(old_data != NULL) - TEST_ERROR; + if (H5Eget_auto2(H5E_DEFAULT, &old_func, &old_data) < 0) + TEST_ERROR; + if (old_data != NULL) + TEST_ERROR; #ifdef H5_USE_16_API if (old_func != (H5E_auto_t)H5Eprint) - TEST_ERROR; + TEST_ERROR; #else /* H5_USE_16_API */ if (old_func != (H5E_auto2_t)H5Eprint2) - TEST_ERROR; + TEST_ERROR; #endif /* H5_USE_16_API */ - if(H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) + if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) TEST_ERROR; /* Make H5Dwrite fail, verify default print is disabled */ - if(H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2) >= 0) { + if (H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2) >= 0) { H5Epush(H5E_DEFAULT, __FILE__, FUNC_test_error, __LINE__, ERR_CLS, ERR_MAJ_IO, ERR_MIN_WRITE, "H5Dwrite shouldn't succeed"); goto error; - } /* end if */ + } - if(H5Eset_auto2(H5E_DEFAULT, old_func, old_data) < 0) + if (H5Eset_auto2(H5E_DEFAULT, old_func, old_data) < 0) TEST_ERROR; /* Test saving and restoring the current error stack */ - if(H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2) < 0) { + if (H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2) < 0) { H5Epush(H5E_DEFAULT, __FILE__, FUNC_test_error, __LINE__, ERR_CLS, ERR_MAJ_IO, ERR_MIN_WRITE, "H5Dwrite failed as supposed to"); estack_id = H5Eget_current_stack(); @@ -159,10 +157,11 @@ test_error(hid_t file) H5Sclose(space); H5Eset_current_stack(estack_id); goto error; - } /* end if */ + } /* In case program comes to this point, close dataset */ - if(H5Dclose(dataset) < 0) TEST_ERROR; + if(H5Dclose(dataset) < 0) + TEST_ERROR; TEST_ERROR; @@ -172,16 +171,12 @@ test_error(hid_t file) /*------------------------------------------------------------------------- - * Function: init_error + * Function: init_error * - * Purpose: Initialize error information. + * Purpose: Initialize error information. * - * Return: Success: 0 - * - * Failure: -1 - * - * Programmer: Raymond Lu - * July 10, 2003 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -194,46 +189,46 @@ init_error(void) char *msg = NULL; H5E_type_t msg_type; - if(NULL == (cls_name = (char *)HDmalloc(HDstrlen(ERR_CLS_NAME) + 1))) + if (NULL == (cls_name = (char *)HDmalloc(HDstrlen(ERR_CLS_NAME) + 1))) TEST_ERROR - if(NULL == (msg = (char *)HDmalloc(HDstrlen(ERR_MIN_SUBROUTINE_MSG) + 1))) + if (NULL == (msg = (char *)HDmalloc(HDstrlen(ERR_MIN_SUBROUTINE_MSG) + 1))) TEST_ERROR - if((ERR_CLS = H5Eregister_class(ERR_CLS_NAME, PROG_NAME, PROG_VERS)) < 0) + if ((ERR_CLS = H5Eregister_class(ERR_CLS_NAME, PROG_NAME, PROG_VERS)) < 0) TEST_ERROR; - if(cls_size != H5Eget_class_name(ERR_CLS, cls_name, (size_t)cls_size) + 1) + if (cls_size != H5Eget_class_name(ERR_CLS, cls_name, (size_t)cls_size) + 1) TEST_ERROR; - if(HDstrcmp(ERR_CLS_NAME, cls_name)) + if (HDstrcmp(ERR_CLS_NAME, cls_name)) TEST_ERROR; - if((ERR_MAJ_TEST = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_TEST_MSG)) < 0) + if ((ERR_MAJ_TEST = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_TEST_MSG)) < 0) TEST_ERROR; - if((ERR_MAJ_IO = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_IO_MSG)) < 0) + if ((ERR_MAJ_IO = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_IO_MSG)) < 0) TEST_ERROR; - if((ERR_MAJ_API = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_API_MSG)) < 0) + if ((ERR_MAJ_API = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_API_MSG)) < 0) TEST_ERROR; - if((ERR_MIN_SUBROUTINE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_SUBROUTINE_MSG)) < 0) + if ((ERR_MIN_SUBROUTINE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_SUBROUTINE_MSG)) < 0) TEST_ERROR; - if((ERR_MIN_ERRSTACK = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_ERRSTACK_MSG)) < 0) + if ((ERR_MIN_ERRSTACK = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_ERRSTACK_MSG)) < 0) TEST_ERROR; - if((ERR_MIN_CREATE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_CREATE_MSG)) < 0) + if ((ERR_MIN_CREATE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_CREATE_MSG)) < 0) TEST_ERROR; - if((ERR_MIN_WRITE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_WRITE_MSG)) < 0) + if ((ERR_MIN_WRITE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_WRITE_MSG)) < 0) TEST_ERROR; - if((ERR_MIN_GETNUM = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_GETNUM_MSG)) < 0) + if ((ERR_MIN_GETNUM = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_GETNUM_MSG)) < 0) TEST_ERROR; - if(msg_size != H5Eget_msg(ERR_MIN_SUBROUTINE, &msg_type, msg, (size_t)msg_size) + 1) + if (msg_size != H5Eget_msg(ERR_MIN_SUBROUTINE, &msg_type, msg, (size_t)msg_size) + 1) TEST_ERROR; - if(msg_type != H5E_MINOR) + if (msg_type != H5E_MINOR) TEST_ERROR; - if(HDstrcmp(msg, ERR_MIN_SUBROUTINE_MSG)) + if (HDstrcmp(msg, ERR_MIN_SUBROUTINE_MSG)) TEST_ERROR; /* Register another class for later testing. */ - if((ERR_CLS2 = H5Eregister_class(ERR_CLS2_NAME, PROG2_NAME, PROG_VERS)) < 0) + if ((ERR_CLS2 = H5Eregister_class(ERR_CLS2_NAME, PROG2_NAME, PROG_VERS)) < 0) TEST_ERROR; HDfree(cls_name); @@ -242,9 +237,9 @@ init_error(void) return 0; error: - if(cls_name) + if (cls_name) HDfree(cls_name); - if(msg) + if (msg) HDfree(msg); return -1; @@ -252,16 +247,12 @@ error: /*------------------------------------------------------------------------- - * Function: error_stack - * - * Purpose: Manipulates current error stack. + * Function: error_stack * - * Return: Success: 0 + * Purpose: Manipulates current error stack. * - * Failure: -1 - * - * Programmer: Raymond Lu - * July 14, 2003 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -271,23 +262,23 @@ error_stack(void) ssize_t err_num; const char *FUNC_error_stack = "error_stack"; - if((err_num = H5Eget_num(H5E_DEFAULT)) < 0) + if ((err_num = H5Eget_num(H5E_DEFAULT)) < 0) TEST_ERROR; - if(err_num) + if (err_num) TEST_ERROR; - if((ERR_STACK = H5Eget_current_stack()) < 0) + if ((ERR_STACK = H5Eget_current_stack()) < 0) TEST_ERROR; /* Make it push error, force this function to fail */ - if((err_num = H5Eget_num(ERR_STACK)) == 0) { + if ((err_num = H5Eget_num(ERR_STACK)) == 0) { H5Epush(ERR_STACK, __FILE__, FUNC_error_stack, __LINE__, ERR_CLS, ERR_MAJ_API, ERR_MIN_GETNUM, "Get number test failed, returned %d", (int)err_num); goto error; - } /* end if */ + } /* In case program falls through here, close the stack and let it fail. */ - if(H5Eclose_stack(ERR_STACK) < 0) + if (H5Eclose_stack(ERR_STACK) < 0) TEST_ERROR; return -1; @@ -300,14 +291,10 @@ error: /*------------------------------------------------------------------------- * Function: long_desc_cb * - * Purpose: Callback function to help test long description handling - * - * Return: Success: 0 + * Purpose: Callback function to help test long description handling * - * Failure: -1 - * - * Programmer: Quincey Koziol - * January 19, 2005 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -316,24 +303,20 @@ long_desc_cb(unsigned H5_ATTR_UNUSED n, const H5E_error2_t *err_desc, void *clie { char *real_desc = (char *)client_data; - if(err_desc->desc != NULL && HDstrcmp(err_desc->desc, real_desc) == 0) - return(0); + if (err_desc->desc != NULL && HDstrcmp(err_desc->desc, real_desc) == 0) + return 0; else - return(-1); + return -1; } /* end long_desc_cb() */ /*------------------------------------------------------------------------- - * Function: test_long_desc + * Function: test_long_desc * - * Purpose: Test long error description handling + * Purpose: Test long error description handling * - * Return: Success: 0 - * - * Failure: -1 - * - * Programmer: Quincey Koziol - * January 19, 2005 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -347,56 +330,59 @@ test_long_desc(void) const char *test_FUNC = "test_long_desc"; /* Allocate space for the error description info */ - if(NULL == (long_desc = (char*)HDmalloc(LONG_DESC_SIZE))) TEST_ERROR; - if(NULL == (full_desc = (char*)HDmalloc(LONG_DESC_SIZE + 128))) TEST_ERROR; + if (NULL == (long_desc = (char *)HDmalloc(LONG_DESC_SIZE))) + TEST_ERROR; + if (NULL == (full_desc = (char *)HDmalloc(LONG_DESC_SIZE + 128))) + TEST_ERROR; /* Create the long part of the error description */ - for(u = 0; u < LONG_DESC_SIZE; u++) + for (u = 0; u < LONG_DESC_SIZE; u++) long_desc[u] = (char)('A' + (u % 26)); long_desc[LONG_DESC_SIZE - 1] = '\0'; /* Clear the default error stack */ - if(H5Eclear2(H5E_DEFAULT) < 0) TEST_ERROR; + if (H5Eclear2(H5E_DEFAULT) < 0) + TEST_ERROR; /* Push an error with a long description */ - if(H5Epush(H5E_DEFAULT, __FILE__, test_FUNC, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, format, long_desc) < 0) TEST_ERROR; + if (H5Epush(H5E_DEFAULT, __FILE__, test_FUNC, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, format, long_desc) < 0) + TEST_ERROR; /* Create the string that should be in the description. Must use HDsnprintf here - * because snprintf is _snprintf on Windows */ + * because snprintf is _snprintf on Windows + */ HDsnprintf(full_desc, (size_t)(LONG_DESC_SIZE + 128), format, long_desc); /* Make certain that the description is correct */ - if(H5Ewalk2(H5E_DEFAULT, H5E_WALK_UPWARD, long_desc_cb, full_desc) < 0) TEST_ERROR; + if (H5Ewalk2(H5E_DEFAULT, H5E_WALK_UPWARD, long_desc_cb, full_desc) < 0) + TEST_ERROR; /* Clear the default error stack again */ - if(H5Eclear2(H5E_DEFAULT) < 0) TEST_ERROR; + if (H5Eclear2(H5E_DEFAULT) < 0) + TEST_ERROR; HDfree(long_desc); HDfree(full_desc); - return(0); + return 0; error: - if(long_desc) + if (long_desc) HDfree(long_desc); - if(full_desc) + if (full_desc) HDfree(full_desc); - return(-1); + return -1; } /* end test_long_desc() */ /*------------------------------------------------------------------------- * Function: dump_error * - * Purpose: Prints error stack in default and customized ways. + * Purpose: Prints error stack in default and customized ways. * - * Return: Success: 0 - * - * Failure: -1 - * - * Programmer: Raymond Lu - * July 17, 2003 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -405,12 +391,12 @@ dump_error(hid_t estack) { /* Print errors in library default way */ HDfprintf(stderr, "********* Print error stack in HDF5 default way *********\n"); - if(H5Eprint2(estack, stderr) < 0) + if (H5Eprint2(estack, stderr) < 0) TEST_ERROR; /* Customized way to print errors */ HDfprintf(stderr, "\n********* Print error stack in customized way *********\n"); - if(H5Ewalk2(estack, H5E_WALK_UPWARD, custom_print_cb, stderr) < 0) + if (H5Ewalk2(estack, H5E_WALK_UPWARD, custom_print_cb, stderr) < 0) TEST_ERROR; return 0; @@ -423,34 +409,30 @@ error: /*------------------------------------------------------------------------- * Function: custom_print_cb * - * Purpose: Callback function to print error stack in customized way. - * - * Return: Success: 0 + * Purpose: Callback function to print error stack in customized way. * - * Failure: -1 - * - * Programmer: Raymond Lu - * July 17, 2003 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ static herr_t custom_print_cb(unsigned n, const H5E_error2_t *err_desc, void* client_data) { - FILE *stream = (FILE *)client_data; + FILE *stream = (FILE *)client_data; char maj[MSG_SIZE]; char min[MSG_SIZE]; char cls[MSG_SIZE]; - const int indent = 4; + const int indent = 4; /* Get descriptions for the major and minor error numbers */ - if(H5Eget_class_name(err_desc->cls_id, cls, MSG_SIZE) < 0) + if (H5Eget_class_name(err_desc->cls_id, cls, MSG_SIZE) < 0) TEST_ERROR; - if(H5Eget_msg(err_desc->maj_num, NULL, maj, MSG_SIZE) < 0) + if (H5Eget_msg(err_desc->maj_num, NULL, maj, MSG_SIZE) < 0) TEST_ERROR; - if(H5Eget_msg(err_desc->min_num, NULL, min, MSG_SIZE) < 0) + if (H5Eget_msg(err_desc->min_num, NULL, min, MSG_SIZE) < 0) TEST_ERROR; HDfprintf(stream, "%*serror #%03d: %s in %s(): line %u\n", @@ -468,54 +450,58 @@ error: /*------------------------------------------------------------------------- - * Function: test_create - * - * Purpose: Test creating an empty error stack + * Function: test_create * - * Return: Success: 0 - * Failure: -1 + * Purpose: Test creating an empty error stack * - * Programmer: Quincey Koziol - * November 1, 2007 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ static herr_t test_create(void) { - const char *err_func = "test_create"; /* Function name for pushing error */ - const char *err_msg = "Error message"; /* Error message for pushing error */ - ssize_t err_num; /* Number of errors on stack */ - hid_t estack_id; /* Error stack ID */ + const char *err_func = "test_create"; /* Function name for pushing error */ + const char *err_msg = "Error message"; /* Error message for pushing error */ + ssize_t err_num; /* Number of errors on stack */ + hid_t estack_id = -1; /* Error stack ID */ /* Create an empty error stack */ - if((estack_id = H5Ecreate_stack()) < 0) TEST_ERROR + if ((estack_id = H5Ecreate_stack()) < 0) + TEST_ERROR /* Check the number of errors on stack */ err_num = H5Eget_num(estack_id); - if(err_num != 0) TEST_ERROR + if (err_num != 0) + TEST_ERROR /* Push an error with a long description */ - if(H5Epush(estack_id, __FILE__, err_func, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, "%s", err_msg) < 0) TEST_ERROR; + if (H5Epush(estack_id, __FILE__, err_func, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, "%s", err_msg) < 0) + TEST_ERROR; /* Check the number of errors on stack */ err_num = H5Eget_num(estack_id); - if(err_num != 1) TEST_ERROR + if (err_num != 1) + TEST_ERROR /* Clear the error stack */ - if(H5Eclear2(estack_id) < 0) TEST_ERROR + if (H5Eclear2(estack_id) < 0) + TEST_ERROR /* Check the number of errors on stack */ err_num = H5Eget_num(estack_id); - if(err_num != 0) TEST_ERROR + if (err_num != 0) + TEST_ERROR /* Close error stack */ - if(H5Eclose_stack(estack_id) < 0) TEST_ERROR + if(H5Eclose_stack(estack_id) < 0) + TEST_ERROR - return(0); + return 0; error: - return(-1); + return -1; } /* end test_create() */ /*------------------------------------------------------------------------- @@ -526,70 +512,72 @@ error: * Return: Success: 0 * Failure: -1 * - * Programmer: Allen Byrne - * February 18, 2010 - * *------------------------------------------------------------------------- */ static herr_t test_copy(void) { - const char *err_func = "test_copy"; /* Function name for pushing error */ - const char *err_msg = "Error message"; /* Error message for pushing error */ - ssize_t err_num; /* Number of errors on stack */ - hid_t estack_id; /* Error stack ID */ - herr_t ret; /* Generic return value */ + const char *err_func = "test_copy"; /* Function name for pushing error */ + const char *err_msg = "Error message"; /* Error message for pushing error */ + ssize_t err_num; /* Number of errors on stack */ + hid_t estack_id = -1; /* Error stack ID */ + herr_t ret; /* Generic return value */ /* Push an error with a long description */ - if(H5Epush(H5E_DEFAULT, __FILE__, err_func, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, "%s", err_msg) < 0) TEST_ERROR; + if (H5Epush(H5E_DEFAULT, __FILE__, err_func, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, "%s", err_msg) < 0) + TEST_ERROR; /* Check the number of errors on stack */ err_num = H5Eget_num(H5E_DEFAULT); - if(err_num != 1) TEST_ERROR + if (err_num != 1) + TEST_ERROR /* Copy error stack, which clears the original */ - if((estack_id = H5Eget_current_stack()) < 0) TEST_ERROR + if ((estack_id = H5Eget_current_stack()) < 0) + TEST_ERROR /* Check the number of errors on stack copy */ err_num = H5Eget_num(estack_id); - if(err_num != 1) TEST_ERROR + if (err_num != 1) + TEST_ERROR /* Check the number of errors on original stack */ err_num = H5Eget_num(H5E_DEFAULT); - if(err_num != 0) TEST_ERROR + if (err_num != 0) + TEST_ERROR /* Put the stack copy as the default. It closes the stack copy, too. */ - if(H5Eset_current_stack(estack_id) < 0) TEST_ERROR + if (H5Eset_current_stack(estack_id) < 0) + TEST_ERROR /* Check the number of errors on default stack */ err_num = H5Eget_num(H5E_DEFAULT); - if(err_num != 1) TEST_ERROR + if (err_num != 1) + TEST_ERROR /* Try to close error stack copy. Should fail because - * the current H5Eset_current_stack closes the stack to be set.*/ + * the current H5Eset_current_stack closes the stack to be set. + */ H5E_BEGIN_TRY { ret = H5Eclose_stack(estack_id); } H5E_END_TRY - if(ret >= 0) TEST_ERROR + if (ret >= 0) + TEST_ERROR - return(0); + return 0; error: - return(-1); + return -1; } /* end test_copy() */ /*------------------------------------------------------------------------- - * Function: close_error + * Function: close_error * - * Purpose: Closes error information. + * Purpose: Closes error information. * - * Return: Success: 0 - * - * Failure: -1 - * - * Programmer: Raymond Lu - * July 10, 2003 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -597,19 +585,19 @@ static herr_t close_error(void) { /* Close major errors, let H5Eunregister_class close minor errors */ - if(H5Eclose_msg(ERR_MAJ_TEST) < 0) + if (H5Eclose_msg(ERR_MAJ_TEST) < 0) TEST_ERROR; - if(H5Eclose_msg(ERR_MAJ_IO) < 0) + if (H5Eclose_msg(ERR_MAJ_IO) < 0) TEST_ERROR; - if(H5Eclose_msg(ERR_MAJ_API) < 0) + if (H5Eclose_msg(ERR_MAJ_API) < 0) TEST_ERROR; - if(H5Eunregister_class(ERR_CLS) < 0) + if (H5Eunregister_class(ERR_CLS) < 0) TEST_ERROR; - if(H5Eunregister_class(ERR_CLS2) < 0) + if (H5Eunregister_class(ERR_CLS2) < 0) TEST_ERROR; return 0; @@ -620,19 +608,15 @@ error: /*------------------------------------------------------------------------- - * Function: test_filter_error + * Function: test_filter_error * - * Purpose: Make sure the error message prints out the filter name + * Purpose: Make sure the error message prints out the filter name * when the existent file is opened but the filter isn't * registered. The existent file was created with * gen_filters.c. * - * Return: Success: 0 - * - * Failure: -1 - * - * Programmer: Raymond Lu - * 2 June 2011 + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -640,71 +624,72 @@ static herr_t test_filter_error(const char *fname) { const char *pathname = H5_get_srcdir_filename(fname); /* Corrected test file name */ - hid_t file, dataset; /* handles */ + hid_t file = -1; + hid_t dataset = -1; int buf[20]; HDfprintf(stderr, "\nTesting error message during data reading when filter isn't registered\n"); /* Open the file */ - if((file = H5Fopen(pathname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((file = H5Fopen(pathname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR; /* Open the regular dataset */ - if((dataset = H5Dopen2(file, DSET_FILTER_NAME, H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DSET_FILTER_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) >= 0) - TEST_ERROR; + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) >= 0) + TEST_ERROR; /* Close/release resources */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR return 0; error: return -1; -} +} /* end test_filter_error() */ /*------------------------------------------------------------------------- - * Function: main + * Function: main * - * Purpose: Test error API. - * - * Programmer: Raymond Lu - * July 10, 2003 + * Purpose: Test error API. * *------------------------------------------------------------------------- */ int main(void) { - hid_t file, fapl; - hid_t estack_id; - char filename[1024]; - const char *FUNC_main = "main"; + hid_t file = -1; + hid_t fapl = -1; + hid_t estack_id = -1; + char filename[1024]; + const char *FUNC_main = "main"; HDfprintf(stderr, " This program tests the Error API. There're supposed to be some error messages\n"); /* Initialize errors */ - if(init_error() < 0) + if (init_error() < 0) TEST_ERROR; - fapl = h5_fileaccess(); + if ((fapl = h5_fileaccess()) < 0) + TEST_ERROR; - h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR; + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; /* Test error stack */ - if(error_stack() < 0) { + if (error_stack() < 0) { /* Push an error onto error stack */ - if(H5Epush(ERR_STACK, __FILE__, FUNC_main, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_ERRSTACK, - "Error stack test failed") < 0) TEST_ERROR; + if (H5Epush(ERR_STACK, __FILE__, FUNC_main, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_ERRSTACK, + "Error stack test failed") < 0) + TEST_ERROR; /* Delete an error from the top of error stack */ H5Epop(ERR_STACK, 1); @@ -724,34 +709,39 @@ main(void) } /* end if */ /* Test error API */ - if(test_error(file) < 0) { + if (test_error(file) < 0) { H5Epush(H5E_DEFAULT, __FILE__, FUNC_main, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, "Error test failed, %s", "it's wrong"); estack_id = H5Eget_current_stack(); H5Eprint2(estack_id, stderr); H5Eclose_stack(estack_id); - } /* end if */ + } /* Test pushing a very long error description */ - if(test_long_desc() < 0) TEST_ERROR; + if (test_long_desc() < 0) + TEST_ERROR; /* Test creating a new error stack */ - if(test_create() < 0) TEST_ERROR; + if (test_create() < 0) + TEST_ERROR; /* Test copying a new error stack */ - if(test_copy() < 0) TEST_ERROR; + if (test_copy() < 0) + TEST_ERROR; - if(H5Fclose(file) < 0) TEST_ERROR; + if (H5Fclose(file) < 0) + TEST_ERROR; /* Close error information */ - if(close_error() < 0) + if (close_error() < 0) TEST_ERROR; /* Test error message during data reading when filter isn't registered * Use default FAPL to avoid some VFD drivers by the check-vfd test because - * the test file was pre-generated. */ + * the test file was pre-generated. + */ h5_fixname(DATAFILE, H5P_DEFAULT, filename, sizeof filename); - if(test_filter_error(filename) < 0) + if (test_filter_error(filename) < 0) TEST_ERROR; h5_clean_files(FILENAME, fapl); diff --git a/test/filenotclosed.c b/test/filenotclosed.c index d1f468a..2c5c8dc 100644 --- a/test/filenotclosed.c +++ b/test/filenotclosed.c @@ -19,8 +19,8 @@ #include "h5test.h" -#define FILENAME "filenotclosed" -#define DATASET "dset" +#define FILENAME "filenotclosed" +#define DATASET_NAME "dset" /*------------------------------------------------------------------------- * Function: catch_signal @@ -114,7 +114,7 @@ main(void) TEST_ERROR /* Create the dataset */ - if((did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if((did = H5Dcreate2(fid, DATASET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Write to the dataset */ diff --git a/test/filter_plugin.c b/test/filter_plugin.c new file mode 100644 index 0000000..8b7e0e4 --- /dev/null +++ b/test/filter_plugin.c @@ -0,0 +1,1511 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * Purpose: Tests the plugin module (H5PL) + */ + +#include "h5test.h" +#include "H5srcdir.h" + +/* + * This file needs to access private datatypes from the H5Z and H5PL package. + */ +#define H5PL_FRIEND +#include "H5PLpkg.h" +#define H5Z_FRIEND +#include "H5Zpkg.h" + +/* Filters IDs for test filter plugins */ +#define FILTER1_ID 257 +#define FILTER2_ID 258 +#define FILTER3_ID 259 +#define FILTER4_ID 260 + +const char *FILENAME[] = { + "filter_plugin", + NULL +}; +#define FILENAME_BUF_SIZE 1024 + +/* Dataset names */ +#define DSET_DEFLATE_NAME "deflate dset" +#define DSET_FILTER1_NAME "filter 1 dset" +#define DSET_FILTER2_NAME "filter 2 dset" +#define DSET_FILTER3_NAME "filter 3 dset" + +/* Array sizes used throughout the test */ +#define DSET_DIM1 100 +#define DSET_DIM2 200 +#define CHUNK_DIM1 2 +#define CHUNK_DIM2 25 +#define HYPERSLAB_OFFSET1 7 +#define HYPERSLAB_OFFSET2 30 +#define HYPERSLAB_SIZE1 4 +#define HYPERSLAB_SIZE2 50 + +/* Global size arrays */ +const hsize_t sizes_g[2] = {DSET_DIM1, DSET_DIM2}; /* Dataset dimensions */ +const hsize_t hs_sizes_g[2] = {HYPERSLAB_SIZE1, HYPERSLAB_SIZE2}; /* Hyperslab sizes */ +const hsize_t hs_offsets_g[2] = {HYPERSLAB_OFFSET1, HYPERSLAB_OFFSET2}; /* Hyperslab offsets */ +const hsize_t chunk_sizes_g[2] = {CHUNK_DIM1, CHUNK_DIM2}; /* Chunk dimensions */ + +/* Limit random number within 20000 */ +#define RANDOM_LIMIT 20000 + +/* Things used in the groups + filter plugins test */ +#define N_SUBGROUPS 1000 +#define SUBGROUP_PREFIX "subgroup_" +#define TOP_LEVEL_GROUP_NAME "top-level group" + +/* Global arrays in which to save data */ +int **orig_deflate_g = NULL; +int **orig_dynlib1_g = NULL; +int **orig_dynlib2_g = NULL; +int **orig_dynlib4_g = NULL; + + + +/*------------------------------------------------------------------------- + * Function: free_2D_array + * + * Purpose: Free up a dynamic 2D pseudo array and set the pointer to NULL + * Designed to be callable in error conditions so NULLs are okay + * + * Return: SUCCEED (always) + * + *------------------------------------------------------------------------- + */ +static herr_t +free_2D_array(int ***arr) { + + if (arr && *arr && (*arr)[0]) + HDfree((*arr)[0]); + if (arr && *arr) + HDfree(*arr); + *arr = NULL; + + return SUCCEED; +} /* end free_2D_array() */ + + +/*------------------------------------------------------------------------- + * Function: allocate_and_init_2D_array + * + * Purpose: Initialize an array as a pseudo 2D array and copy in some + * initial values. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +allocate_and_init_2D_array(int ***arr, const hsize_t *sizes, int **initial_values) { + + size_t r, c; /* Data rows and columns */ + size_t i; /* Iterator */ + size_t n_bytes; /* # of bytes to copy */ + + r = (size_t)sizes[0]; + c = (size_t)sizes[1]; + + /* Allocate and set up pseudo-2D array */ + if (NULL == (*arr = (int **)HDcalloc(r, sizeof(int *)))) + TEST_ERROR; + if (NULL == ((*arr)[0] = (int *)HDcalloc(r * c, sizeof(int)))) + TEST_ERROR; + for (i = 0; i < r; i++) + (*arr)[i] = (**arr + c * i); + + /* Copy over the data elements */ + if (initial_values) { + n_bytes = r * c * sizeof(int); + HDmemcpy((*arr)[0], initial_values[0], n_bytes); + } + + return SUCCEED; +error: + free_2D_array(arr); + + return FAIL; +} /* end allocate_and_init_2D_array() */ + + +/*------------------------------------------------------------------------- + * Function: compare_2D_arrays + * + * Purpose: Compare two pseudo 2D arrays + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +compare_2D_arrays(int **dset1, int **dset2, const hsize_t *sizes, /*OUT*/ hbool_t *are_same) { + hsize_t i, j; /* index variables */ + + *are_same = TRUE; + + /* Check all the array values. This could optionally emit any + * bad data, but it's not clear how that would help debugging. + */ + for (i = 0; i < sizes[0]; i++) + for (j = 0; j < sizes[1]; j++) + if (dset1[i][j] != dset2[i][j]) { + *are_same = FALSE; + return SUCCEED; + } + + return SUCCEED; + +} /* end compare_2D_arrays() */ + + +/*------------------------------------------------------------------------- + * Function: ensure_filter_works + * + * Purpose: Tests writing entire data and partial data with filters + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +ensure_filter_works(hid_t fid, const char *name, hid_t dcpl_id) +{ + hid_t did = -1; /* Dataset ID */ + hid_t dxpl_id = -1; /* Dataset xfer property list ID */ + hid_t write_dxpl_id = -1; /* Dataset xfer property list ID for writing */ + hid_t sid = -1; /* Dataspace ID */ + void *tconv_buf = NULL; /* Temporary conversion buffer */ + int **orig = NULL; /* Data written to the dataset */ + int **read = NULL; /* Data read from the dataset */ + size_t r, c; /* Data rows and columns */ + size_t hs_r, hs_c, hs_offr, hs_offc; /* Hypserslab sizes and offsets */ + size_t i, j; /* Local index variables */ + int n = 0; /* Value written to point array */ + hbool_t are_same; /* Output from dataset compare function */ + int ***save_array = NULL; /* (Global) array where the final data go */ + + /* initialize */ + r = (size_t)sizes_g[0]; + c = (size_t)sizes_g[1]; + + /* Create the data space */ + if ((sid = H5Screate_simple(2, sizes_g, NULL)) < 0) + TEST_ERROR; + + /* Allocate memory for the data buffers + * We're using the hacky way of doing 2D arrays that uses a + * single data buffer but which allows normal 2D access. + */ + if (allocate_and_init_2D_array(&orig, sizes_g, NULL) < 0) + TEST_ERROR; + if (allocate_and_init_2D_array(&read, sizes_g, NULL) < 0) + TEST_ERROR; + + /* Create a small conversion buffer to test strip mining. We + * might as well test all we can! + */ + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR; + if (NULL == (tconv_buf = HDcalloc((size_t)1000, sizeof(char)))) + TEST_ERROR; + if (H5Pset_buffer(dxpl_id, (size_t)1000, tconv_buf, NULL) < 0) + TEST_ERROR; + if ((write_dxpl_id = H5Pcopy(dxpl_id)) < 0) + TEST_ERROR; + + TESTING(" filters (setup)"); + + /* Check if all the filters are available */ + if (H5Pall_filters_avail(dcpl_id) != TRUE) + TEST_ERROR; + + /* Create the dataset */ + if ((did = H5Dcreate2(fid, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR; + + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 1: Read uninitialized data. It should be zero. + *---------------------------------------------------------------------- + */ + TESTING(" filters (uninitialized read)"); + + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, *read) < 0) + TEST_ERROR; + + /* The input buffer was calloc'd and has not been initialized yet */ + if (compare_2D_arrays(orig, read, sizes_g, &are_same) < 0) + TEST_ERROR; + if (FALSE == are_same) + TEST_ERROR; + + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 2: Test filters by setting up a chunked dataset and writing + * to it. + *---------------------------------------------------------------------- + */ + TESTING(" filters (write)"); + + n = 0; + for (i = 0; i < r; i++) + for (j = 0; j < c; j++) + orig[i][j] = n++; + + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl_id, *orig) < 0) + TEST_ERROR; + + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 3: Try to read the data we just wrote. + *---------------------------------------------------------------------- + */ + TESTING(" filters (read)"); + + /* Read the dataset back */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, *read) < 0) + TEST_ERROR; + + /* Check that the values read are the same as the values written */ + if (compare_2D_arrays(orig, read, sizes_g, &are_same) < 0) + TEST_ERROR; + if (FALSE == are_same) + TEST_ERROR; + + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 4: Write new data over the top of the old data. The new data is + * random thus not very compressible, and will cause the chunks to move + * around as they grow. We only change values for the left half of the + * dataset although we rewrite the whole thing. + *---------------------------------------------------------------------- + */ + TESTING(" filters (modify)"); + + for (i = 0; i < r; i++) + for (j = 0; j < c / 2; j++) + orig[i][j] = (int)HDrandom() % RANDOM_LIMIT; + + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl_id, *orig) < 0) + TEST_ERROR; + + /* Read the dataset back and check it */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, *read) < 0) + TEST_ERROR; + + /* Check that the values read are the same as the values written */ + if (compare_2D_arrays(orig, read, sizes_g, &are_same) < 0) + TEST_ERROR; + if (FALSE == are_same) + TEST_ERROR; + + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 5: Close the dataset and then open it and read it again. This + * insures that the filters message is picked up properly from the + * object header. + *---------------------------------------------------------------------- + */ + TESTING(" filters (re-open)"); + + if (H5Dclose(did) < 0) + TEST_ERROR; + if ((did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, *read) < 0) + TEST_ERROR; + + /* Check that the values read are the same as the values written */ + if (compare_2D_arrays(orig, read, sizes_g, &are_same) < 0) + TEST_ERROR; + if (FALSE == are_same) + TEST_ERROR; + + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 6: Test partial I/O by writing to and then reading from a + * hyperslab of the dataset. The hyperslab does not line up on chunk + * boundaries (we know that case already works from above tests). + *---------------------------------------------------------------------- + */ + TESTING(" filters (partial I/O)"); + + hs_r = (size_t)hs_sizes_g[0]; + hs_c = (size_t)hs_sizes_g[1]; + hs_offr = (size_t)hs_offsets_g[0]; + hs_offc = (size_t)hs_offsets_g[1]; + for (i = 0; i < hs_r; i++) + for (j = 0; j < hs_c; j++) + orig[hs_offr + i][hs_offc + j] = (int)HDrandom() % RANDOM_LIMIT; + + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offsets_g, NULL, hs_sizes_g, NULL) < 0) + TEST_ERROR; + + /* Use the "read" DXPL because partial I/O on corrupted data test + * needs to ignore errors during writing + */ + if (H5Dwrite(did, H5T_NATIVE_INT, sid, sid, dxpl_id, *orig) < 0) + TEST_ERROR; + + if (H5Dread(did, H5T_NATIVE_INT, sid, sid, dxpl_id, *read) < 0) + TEST_ERROR; + + /* Check that the values read are the same as the values written */ + if (compare_2D_arrays(orig, read, sizes_g, &are_same) < 0) + TEST_ERROR; + if (FALSE == are_same) + TEST_ERROR; + + PASSED(); + + /* Save the data written to the file for later comparison when the file + * is reopened for read test. + */ + if (!HDstrcmp(name, DSET_DEFLATE_NAME)) + save_array = &orig_deflate_g; + else if (!HDstrcmp(name, DSET_FILTER1_NAME)) + save_array = &orig_dynlib1_g; + else if (!HDstrcmp(name, DSET_FILTER2_NAME)) + save_array = &orig_dynlib2_g; + else if (!HDstrcmp(name, DSET_FILTER3_NAME)) + save_array = &orig_dynlib4_g; + else + TEST_ERROR; + if (allocate_and_init_2D_array(save_array, sizes_g, orig) < 0) + TEST_ERROR; + + /* Clean up and exit */ + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Sclose(sid) < 0) + TEST_ERROR; + if (H5Pclose(dxpl_id) < 0) + TEST_ERROR; + if (H5Pclose(write_dxpl_id) < 0) + TEST_ERROR; + + free_2D_array(&orig); + free_2D_array(&read); + + HDfree(tconv_buf); + + return SUCCEED; + +error: + /* Clean up objects used for this test */ + H5E_BEGIN_TRY { + H5Dclose(did); + H5Sclose(sid); + H5Pclose(dxpl_id); + H5Pclose(write_dxpl_id); + } H5E_END_TRY + + /* NULLs are okay here */ + free_2D_array(&orig); + free_2D_array(&read); + + if (tconv_buf) + HDfree(tconv_buf); + + return FAIL; +} /* end ensure_filter_works() */ + + +/*------------------------------------------------------------------------- + * Function: test_dataset_write_with_filters + * + * Purpose: Tests creating datasets and writing data with dynamically loaded filters + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_dataset_write_with_filters(hid_t fid) +{ + hid_t dcpl_id = -1; /* Dataset creation property list ID */ + unsigned int compress_level; /* Deflate compression level */ + unsigned int filter1_data; /* Data used by filter 1 */ + unsigned int libver_values[4]; /* Used w/ the filter that makes HDF5 calls */ + + /*---------------------------------------------------------- + * STEP 1: Test deflation by itself. + *---------------------------------------------------------- + */ + HDputs("Testing dataset writes with deflate filter"); +#ifdef H5_HAVE_FILTER_DEFLATE + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; + if (H5Pset_chunk(dcpl_id, 2, chunk_sizes_g) < 0) + TEST_ERROR; + compress_level = 6; + if (H5Pset_deflate(dcpl_id, compress_level) < 0) + TEST_ERROR; + + /* Ensure the filter works */ + if (ensure_filter_works(fid, DSET_DEFLATE_NAME, dcpl_id) < 0) + TEST_ERROR; + + /* Clean up objects used for this test */ + if (H5Pclose(dcpl_id) < 0) + TEST_ERROR; +#else /* H5_HAVE_FILTER_DEFLATE */ + SKIPPED(); + HDputs(" Deflate filter not enabled"); +#endif /* H5_HAVE_FILTER_DEFLATE */ + + /*---------------------------------------------------------- + * STEP 2: Test filter plugin 1 by itself. + *---------------------------------------------------------- + */ + HDputs(" dataset writes with filter plugin 1"); + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; + if (H5Pset_chunk(dcpl_id, 2, chunk_sizes_g) < 0) + TEST_ERROR; + + /* Set up the filter, passing in the amount the filter will add and subtract + * from each data element. Note that this value has an arbitrary max of 9. + */ + filter1_data = 9; + if (H5Pset_filter(dcpl_id, FILTER1_ID, H5Z_FLAG_MANDATORY, (size_t)1, &filter1_data) < 0) + TEST_ERROR; + + /* Ensure the filter works */ + if (ensure_filter_works(fid, DSET_FILTER1_NAME, dcpl_id) < 0) + TEST_ERROR; + + /* Clean up objects used for this test */ + if (H5Pclose(dcpl_id) < 0) + TEST_ERROR; + + /* Unregister the dynamic filter for testing purpose. The next time when this test is run for + * the new file format, the library's H5PL code has to search in the table of loaded plugin libraries + * for this filter. + */ + if (H5Zunregister(FILTER1_ID) < 0) + TEST_ERROR; + + /*---------------------------------------------------------- + * STEP 3: Test filter plugin 2 by itself. + *---------------------------------------------------------- + */ + HDputs(" dataset writes with filter plugin 2"); + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; + if (H5Pset_chunk(dcpl_id, 2, chunk_sizes_g) < 0) + TEST_ERROR; + if (H5Pset_filter(dcpl_id, FILTER2_ID, H5Z_FLAG_MANDATORY, 0, NULL) < 0) + TEST_ERROR; + + /* Ensure the filter works */ + if (ensure_filter_works(fid, DSET_FILTER2_NAME, dcpl_id) < 0) + TEST_ERROR; + + /* Clean up objects used for this test */ + if (H5Pclose(dcpl_id) < 0) + TEST_ERROR; + + /* Unregister the dynamic filter for testing purpose. The next time when this test is run for + * the new file format, the library's H5PL code has to search in the table of loaded plugin libraries + * for this filter. + */ + if (H5Zunregister(FILTER2_ID) < 0) + TEST_ERROR; + + /*---------------------------------------------------------- + * STEP 4: Test filter plugin 3 by itself. + * (This filter plugin makes HDF5 API calls) + *---------------------------------------------------------- + */ + HDputs(" dataset writes with filter plugin 3"); + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; + if (H5Pset_chunk(dcpl_id, 2, chunk_sizes_g) < 0) + TEST_ERROR; + + /* Set the add/subtract value for the filter */ + libver_values[0] = 9; + + /* Get the library bounds and add to the filter data */ + if (H5get_libversion(&libver_values[1], &libver_values[2], &libver_values[3]) < 0) + TEST_ERROR; + if (H5Pset_filter(dcpl_id, FILTER3_ID, H5Z_FLAG_MANDATORY, (size_t)4, libver_values) < 0) + TEST_ERROR; + + /* Ensure the filter works */ + if (ensure_filter_works(fid, DSET_FILTER3_NAME, dcpl_id) < 0) + TEST_ERROR; + + /* Clean up objects used for this test */ + if (H5Pclose(dcpl_id) < 0) + TEST_ERROR; + + /* Unregister the dynamic filter for testing purpose. The next time when this test is run for + * the new file format, the library's H5PL code has to search in the table of loaded plugin libraries + * for this filter. + */ + if (H5Zunregister(FILTER3_ID) < 0) + TEST_ERROR; + + return SUCCEED; + +error: + /* Clean up objects used for this test */ + H5E_BEGIN_TRY { + H5Pclose(dcpl_id); + } H5E_END_TRY + + return FAIL; +} /* end test_dataset_write_with_filters() */ + + +/*------------------------------------------------------------------------- + * Function: test_read_data + * + * Purpose: Tests reading data and compares values + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_read_data(hid_t did, int *origin_data) +{ + int **check = NULL; + int *data_p = origin_data; + size_t i, j; /* Local index variables */ + + if (allocate_and_init_2D_array(&check, sizes_g, NULL) < 0) + TEST_ERROR; + + /* Read the dataset back */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, *check) < 0) + TEST_ERROR; + + /* Check that the values read are the same as the values written */ + for(i = 0; i < sizes_g[0]; i++) + for(j = 0; j < sizes_g[1]; j++) { + if(*data_p != check[i][j]) + TEST_ERROR + data_p++; + } + + free_2D_array(&check); + + PASSED(); + + return SUCCEED; + +error: + free_2D_array(&check); + + return FAIL; +} /* end test_read_data() */ + + + +/*------------------------------------------------------------------------- + * Function: test_dataset_read_with_filters + * + * Purpose: Tests reading datasets created with dynamically-loaded + * filter plugins. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_dataset_read_with_filters(hid_t fid) +{ + hid_t did = -1; /* Dataset ID */ + + /*---------------------------------------------------------- + * STEP 1: Test deflation by itself. + *---------------------------------------------------------- + */ + TESTING("dataset read I/O with deflate filter"); + +#ifdef H5_HAVE_FILTER_DEFLATE + if (H5Zfilter_avail(H5Z_FILTER_DEFLATE) != TRUE) + TEST_ERROR; + + if ((did = H5Dopen2(fid, DSET_DEFLATE_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if (test_read_data(did, orig_deflate_g[0]) < 0) + TEST_ERROR; + + if (H5Dclose(did) < 0) + TEST_ERROR; + +#else /* H5_HAVE_FILTER_DEFLATE */ + SKIPPED(); + HDputs(" Deflate filter not enabled"); +#endif /* H5_HAVE_FILTER_DEFLATE */ + + /*---------------------------------------------------------- + * STEP 2: Test filter plugin 1 by itself. + *---------------------------------------------------------- + */ + TESTING(" dataset reads with filter plugin 1"); + + if ((did = H5Dopen2(fid, DSET_FILTER1_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if (test_read_data(did, orig_dynlib1_g[0]) < 0) + TEST_ERROR; + + if (H5Dclose(did) < 0) + TEST_ERROR; + + /*---------------------------------------------------------- + * STEP 3: Test filter plugin 2 by itself. + *---------------------------------------------------------- + */ + TESTING(" dataset reads with filter plugin 2"); + + if ((did = H5Dopen2(fid, DSET_FILTER2_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if (test_read_data(did, orig_dynlib2_g[0]) < 0) + TEST_ERROR; + + if (H5Dclose(did) < 0) + TEST_ERROR; + + /*---------------------------------------------------------- + * STEP 4: Test filter plugin 3 by itself. + *---------------------------------------------------------- + */ + TESTING(" dataset reads with filter plugin 3"); + + if ((did = H5Dopen2(fid, DSET_FILTER3_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if (test_read_data(did, orig_dynlib4_g[0]) < 0) + TEST_ERROR; + + if (H5Dclose(did) < 0) + TEST_ERROR; + + return SUCCEED; + +error: + /* Clean up objects used for this test */ + H5E_BEGIN_TRY { + H5Dclose(did); + } H5E_END_TRY + + return FAIL; +} /* end test_dataset_read_with_filters() */ + + +/*------------------------------------------------------------------------- + * Function: ensure_data_read_fails + * + * Purpose: Tests not reading data + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +ensure_data_read_fails(hid_t did) +{ + int **check = NULL; + herr_t ret = FAIL; + + if (allocate_and_init_2D_array(&check, sizes_g, NULL) < 0) + TEST_ERROR; + + /* Read the dataset back (should fail) */ + H5E_BEGIN_TRY { + ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, *check); + } H5E_END_TRY + if(ret >= 0) + TEST_ERROR; + + free_2D_array(&check); + + PASSED(); + + return SUCCEED; + +error: + free_2D_array(&check); + return FAIL; +} /* end ensure_data_read_fails() */ + + +/*------------------------------------------------------------------------- + * Function: test_no_read_when_plugins_disabled + * + * Purpose: Ensures we can't read data from a dataset that requires a + * filter located in a plugin. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_no_read_when_plugins_disabled(hid_t fid) +{ + hid_t did = -1; /* Dataset ID */ + unsigned plugin_flags; /* Plugin access flags */ + + TESTING("filter plugin 1 with filter plugins disabled"); + + /* Get the existing plugin flags */ + if (H5PLget_loading_state(&plugin_flags) < 0) + TEST_ERROR; + + /* Disable filter plugins and use the new flags */ + plugin_flags &= (unsigned)(~H5PL_FILTER_PLUGIN); + if (H5PLset_loading_state(plugin_flags) < 0) + TEST_ERROR; + + /* Open a dataset that requires a filter plugin to read the data */ + if ((did = H5Dopen2(fid, DSET_FILTER1_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Make sure we can't read the data */ + if (ensure_data_read_fails(did) < 0) + TEST_ERROR; + + /* Close down */ + if (H5Dclose(did) < 0) + TEST_ERROR; + + /* Re-enable filter plugins */ + plugin_flags |= (unsigned)H5PL_FILTER_PLUGIN; + if (H5PLset_loading_state(plugin_flags) < 0) + TEST_ERROR; + + return SUCCEED; + +error: + /* Clean up objects used for this test */ + H5E_BEGIN_TRY { + plugin_flags |= (unsigned)H5PL_FILTER_PLUGIN; + H5PLset_loading_state(plugin_flags); + H5Dclose(did); + } H5E_END_TRY + + return FAIL; +} /* end test_no_read_when_plugins_disabled() */ + + +/*------------------------------------------------------------------------- + * Function: test_creating_groups_using_plugins + * + * Purpose: Tests creating group with dynamically loaded filters + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_creating_groups_using_plugins(hid_t fid) +{ + hid_t gcpl_id = -1; + hid_t gid = -1; + hid_t sub_gid = -1; + int i; + char subgroup_name[256]; + + TESTING("creating groups with filter plugin 4"); + + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR; + + /* Use a filter plugin for creating groups */ + if (H5Pset_filter(gcpl_id, FILTER4_ID, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) + TEST_ERROR; + + /* Create a group using this filter */ + if ((gid = H5Gcreate2(fid, TOP_LEVEL_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Create multiple groups under the top-level group */ + for (i = 0; i < N_SUBGROUPS; i++) { + char *sp = subgroup_name; + + sp += HDsprintf(subgroup_name, SUBGROUP_PREFIX); + HDsprintf(sp, "%d", i); + + if ((sub_gid = H5Gcreate2(gid, subgroup_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Gclose(sub_gid) < 0) + TEST_ERROR; + } + + /* Close everything */ + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR; + + PASSED(); + + return SUCCEED; + +error: + /* Clean up objects used for this test */ + H5E_BEGIN_TRY { + H5Gclose(sub_gid); + H5Gclose(gid); + H5Pclose(gcpl_id); + } H5E_END_TRY + + return FAIL; +} /* end test_creating_groups_using_plugins() */ + + +/*------------------------------------------------------------------------- + * Function: test_opening_groups_using_plugins + * + * Purpose: Tests opening group with dynamically loaded filters + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_opening_groups_using_plugins(hid_t fid) +{ + hid_t gid = -1; + hid_t sub_gid = -1; + int i; + char subgroup_name[256]; + + TESTING("opening groups with filter plugin 4"); + + /* Open the top group */ + if ((gid = H5Gopen2(fid, TOP_LEVEL_GROUP_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Open all the sub-groups under the top-level group */ + for (i = 0; i < N_SUBGROUPS; i++) { + char *sp = subgroup_name; + + sp += HDsprintf(subgroup_name, SUBGROUP_PREFIX); + HDsprintf(sp, "%d", i); + + if ((sub_gid = H5Gopen2(gid, subgroup_name, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Gclose(sub_gid) < 0) + TEST_ERROR; + } + + /* Close the top-level group */ + if (H5Gclose(gid) < 0) + TEST_ERROR; + + PASSED(); + + return SUCCEED; + +error: + /* Clean up objects used for this test */ + H5E_BEGIN_TRY { + H5Gclose(gid); + H5Gclose(sub_gid); + } H5E_END_TRY + + return FAIL; +} /* end test_opening_groups_using_plugins() */ + + + +/*------------------------------------------------------------------------- + * Function: test_path_api_calls + * + * Purpose: Tests the H5PL API calls that manipulate the plugin search + * paths. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_path_api_calls(void) +{ + unsigned int n_starting_paths; + unsigned int u; + unsigned int n_paths; + herr_t ret; + ssize_t path_len = -1; + char path[256]; + char temp_name[256]; + + HDputs("Testing access to the filter path table"); + + if (H5Zfilter_avail(FILTER1_ID) != TRUE) + TEST_ERROR; + + /* Set the number of paths to create for this test. + * + * This should be set high enough to ensure that at least one array + * expansion will take place. See H5PLpath.c for details. + */ + n_starting_paths = 42; + + /* Check that initialization is correct */ + TESTING(" initialize"); + + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + if (n_paths != 2) + TEST_ERROR; + + PASSED(); + + /****************/ + /* H5PLremove() */ + /****************/ + + /* Remove all the current paths */ + TESTING(" remove"); + + /* Get the current size */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + + /* Remove all existing paths */ + for (u = n_paths; u > 0; u--) + if (H5PLremove(u-1) < 0) { + HDfprintf(stderr," at %u: %s\n", u, path); + TEST_ERROR; + } + + /* Verify the table is empty */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + if (n_paths > 0) + TEST_ERROR; + + PASSED(); + + + TESTING(" remove (index 0 in empty table)"); + + /* Try to remove index zero in an empty list (SHOULD FAIL) */ + H5E_BEGIN_TRY { + ret = H5PLremove(0); + } H5E_END_TRY + if (ret >= 0) + TEST_ERROR; + + PASSED(); + + + /****************/ + /* H5PLappend() */ + /****************/ + + TESTING(" append"); + + /* Add a bunch of paths to the path table */ + for (u = 0; u < n_starting_paths; u++) { + HDsprintf(path, "a_path_%u", u); + if (H5PLappend(path) < 0) { + HDfprintf(stderr," at %u: %s\n", u, path); + TEST_ERROR; + } + } + + PASSED(); + + + /**********************/ + /* H5PLremove() again */ + /**********************/ + + TESTING(" remove (index too high)"); + + /* Try to remove a path where the index is beyond the table capacity (SHOULD FAIL) */ + H5E_BEGIN_TRY { + ret = H5PLremove(n_starting_paths); + } H5E_END_TRY + + if (ret >= 0) + TEST_ERROR + + PASSED(); + + + /*************/ + /* H5PLget() */ + /*************/ + + TESTING(" get (path name)"); + + /* Get the path length by passing in NULL */ + if ((path_len = H5PLget(0, NULL, 0)) <= 0) { + HDfprintf(stderr," get path 0 length failed\n"); + TEST_ERROR; + } + if (path_len != 8) + TEST_ERROR; + + /* Get the path */ + if ((path_len = H5PLget(0, path, 256)) <= 0) { + HDfprintf(stderr," get 0 len: %u : %s\n", path_len, path); + TEST_ERROR; + } + if (HDstrcmp(path, "a_path_0") != 0) { + HDfprintf(stderr," get 0: %s\n", path); + TEST_ERROR; + } + + PASSED(); + + + TESTING(" get (high and low indices)"); + + /* Get path at index 1 */ + if ((path_len = H5PLget(1, path, 256)) <= 0) + TEST_ERROR; + if (HDstrcmp(path, "a_path_1") != 0) { + HDfprintf(stderr," get 1: %s\n", path); + TEST_ERROR; + } + + /* Get path at the last index */ + if ((path_len = H5PLget(n_starting_paths - 1, path, 256)) <= 0) + TEST_ERROR; + HDsprintf(temp_name, "a_path_%u", n_starting_paths - 1); + if (HDstrcmp(path, temp_name) != 0) { + HDfprintf(stderr," get %u: %s\n", n_starting_paths - 1, path); + TEST_ERROR; + } + + PASSED(); + + + TESTING(" get (index too high)"); + + /* Get path at the last + 1 index (SHOULD FAIL) */ + H5E_BEGIN_TRY { + path_len = H5PLget(n_starting_paths, NULL, 0); + } H5E_END_TRY + if (path_len > 0) + TEST_ERROR; + + PASSED(); + + + /*****************/ + /* H5PLprepend() */ + /*****************/ + + /* We'll remove a path at an arbitrary index and then + * prepend a new path. + */ + + TESTING(" remove (arbitrary index 1)"); + + /* Remove one path */ + if (H5PLremove(8) < 0) + TEST_ERROR; + + /* Verify that the entries were moved */ + if ((path_len = H5PLget(8, path, 256)) <= 0) + TEST_ERROR; + if (HDstrcmp(path, "a_path_9") != 0) { + HDfprintf(stderr," get 8: %s\n", path); + TEST_ERROR; + } + + /* Verify the table shrank */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + if (n_paths != n_starting_paths - 1) + TEST_ERROR; + + PASSED(); + + + TESTING(" prepend"); + + /* Prepend one path */ + HDsprintf(path, "a_path_%d", n_starting_paths + 1); + if (H5PLprepend(path) < 0) { + HDfprintf(stderr," prepend %u: %s\n", n_starting_paths + 1, path); + TEST_ERROR; + } + + /* Verify the table increased */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + if (n_paths != n_starting_paths) + TEST_ERROR; + + /* Verify that the entries were moved */ + if (H5PLget(8, path, 256) <= 0) + TEST_ERROR; + if (HDstrcmp(path, "a_path_7") != 0) { + HDfprintf(stderr," get 8: %s\n", path); + TEST_ERROR; + } + + /* Verify that the path was inserted at index zero */ + if (H5PLget(0, path, 256) <= 0) + TEST_ERROR; + HDsprintf(temp_name, "a_path_%d", n_starting_paths + 1); + if (HDstrcmp(path, temp_name) != 0) { + HDfprintf(stderr," get 0: %s\n", path); + TEST_ERROR; + } + + PASSED(); + + + /*****************/ + /* H5PLreplace() */ + /*****************/ + + TESTING(" replace"); + + /* Replace one path at index 1 */ + HDsprintf(path, "a_path_%u", n_starting_paths + 4); + if (H5PLreplace(path, 1) < 0) { + HDfprintf(stderr," replace 1: %s\n", path); + TEST_ERROR; + } + + /* Verify the table size remained the same */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + if (n_paths != n_starting_paths) + TEST_ERROR; + + /* Verify that the entries were not moved by + * inspecting the paths at indices +/- 1. + */ + + /* Check path at index 0 */ + if (H5PLget(0, path, 256) <= 0) + TEST_ERROR; + HDsprintf(temp_name, "a_path_%u", n_starting_paths + 1); + if (HDstrcmp(path, temp_name) != 0) { + HDfprintf(stderr," get 0: %s\n", path); + TEST_ERROR; + } + + /* Check path at index 2 */ + if (H5PLget(2, path, 256) <= 0) + TEST_ERROR; + if (HDstrcmp(path, "a_path_1") != 0) { + HDfprintf(stderr," get 2: %s\n", path); + TEST_ERROR; + } + + PASSED(); + + + /****************/ + /* H5PLinsert() */ + /****************/ + + /* We'll remove a path at an arbitrary index and then + * insert a new path. + */ + + TESTING(" remove (arbitrary index 2)"); + + /* Remove one path */ + if (H5PLremove(4) < 0) + TEST_ERROR; + + /* Verify that the entries were moved */ + if (H5PLget(4, path, 256) <= 0) + TEST_ERROR; + if (HDstrcmp(path, "a_path_4") != 0) { + HDfprintf(stderr," get 4: %s\n", path); + TEST_ERROR; + } + + /* Verify the table size */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + if (n_paths != n_starting_paths - 1) + TEST_ERROR; + PASSED(); + + + TESTING(" insert"); + + /* Insert one path at index 3*/ + HDsprintf(path, "a_path_%d", n_starting_paths + 5); + if (H5PLinsert(path, 3) < 0) { + HDfprintf(stderr," insert 3: %s\n", path); + TEST_ERROR; + } + + /* Verify that the entries were moved */ + if (H5PLget(4, path, 256) <= 0) + TEST_ERROR; + if (HDstrcmp(path, "a_path_2") != 0) { + HDfprintf(stderr," get 4: %s\n", path); + TEST_ERROR; + } + + /* Verify the table size increased */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + if (n_paths != n_starting_paths) + TEST_ERROR; + + PASSED(); + + + /****************/ + /* H5PLremove() */ + /****************/ + + /* Remove all the current paths */ + TESTING(" remove (all)"); + + /* Get the current size */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + + /* Remove all existing paths */ + for (u = n_paths; u > 0; u--) + if (H5PLremove(u-1) < 0) { + HDfprintf(stderr," at %u: %s\n", u, path); + TEST_ERROR; + } + + /* Verify the table is empty */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + if (n_paths > 0) + TEST_ERROR; + + PASSED(); + + + return SUCCEED; + +error: + return FAIL; +} /* end test_path_api_calls() */ + + +/*------------------------------------------------------------------------- + * Function: disable_chunk_cache + * + * Purpose: Turns the chunk cache off + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +disable_chunk_cache(hid_t fapl_id) { + int mdc_nelmts; + size_t rdcc_nelmts; + size_t rdcc_nbytes; + double rdcc_w0; + + if (H5Pget_cache(fapl_id, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0) + TEST_ERROR; + rdcc_nbytes = 0; + if (H5Pset_cache(fapl_id, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) + TEST_ERROR; + + return SUCCEED; +error: + return FAIL; +} /* end disable_chunk_cache() */ + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Tests the plugin module (H5PL) + * + * Return: EXIT_SUCCESS/EXIT_FAILURE + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + char filename[FILENAME_BUF_SIZE]; + hid_t fid = -1; + hid_t old_ff_fapl_id = -1; + hid_t new_ff_fapl_id = -1; + unsigned new_format; + int nerrors = 0; + + /* Testing setup */ + h5_reset(); + + /*******************************************************************/ + /* ENSURE THAT WRITING TO DATASETS AND CREATING GROUPS WORKS */ + /*******************************************************************/ + + /* Get a VFD-dependent filename */ + if ((old_ff_fapl_id = h5_fileaccess()) < 0) + TEST_ERROR; + + /* Turn off the chunk cache, so all the chunks are immediately written to disk */ + if (disable_chunk_cache(old_ff_fapl_id) < 0) + TEST_ERROR; + + /* Copy the file access property list and set the latest file format on it */ + if ((new_ff_fapl_id = H5Pcopy(old_ff_fapl_id)) < 0) + TEST_ERROR; + if (H5Pset_libver_bounds(new_ff_fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR; + + /* Fix up the filename for the VFD */ + h5_fixname(FILENAME[0], old_ff_fapl_id, filename, sizeof(filename)); + + /* Test with old & new format groups */ + for (new_format = FALSE; new_format <= TRUE; new_format++) { + hid_t my_fapl_id; + + /* Set the FAPL for the type of format */ + if (new_format) { + HDputs("\nTesting with new file format:"); + my_fapl_id = new_ff_fapl_id; + } + else { + HDputs("Testing with old file format:"); + my_fapl_id = old_ff_fapl_id; + } + + /* Create the file for this test */ + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl_id)) < 0) + TEST_ERROR; + + /* Test creating datasets and writing to them using plugin filters */ + nerrors += (test_dataset_write_with_filters(fid) < 0 ? 1 : 0); + + /* Test creating groups using dynamically-loaded plugin filters */ + nerrors += (test_creating_groups_using_plugins(fid) < 0 ? 1 : 0); + + if (H5Fclose(fid) < 0) + TEST_ERROR; + } /* end for */ + + /* Close FAPLs */ + if (H5Pclose(old_ff_fapl_id) < 0) + TEST_ERROR; + if (H5Pclose(new_ff_fapl_id) < 0) + TEST_ERROR; + + /* Restore the default error handler (set in h5_reset()) */ + h5_restore_err(); + + /*******************************************************************/ + /* ENSURE THAT READING FROM DATASETS AND OPENING GROUPS WORKS */ + /*******************************************************************/ + + HDputs("\nTesting reading data with with dynamic plugin filters:"); + + /* Close the library so that all loaded plugin libraries are unloaded */ + h5_reset(); + if ((old_ff_fapl_id = h5_fileaccess()) < 0) + TEST_ERROR; + + /* Reopen the file for testing data reading */ + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, old_ff_fapl_id)) < 0) + TEST_ERROR; + + /* Read the data with filters */ + nerrors += (test_dataset_read_with_filters(fid) < 0 ? 1 : 0); + + /* Test creating groups using dynamically-loaded plugin filters */ + nerrors += (test_opening_groups_using_plugins(fid) < 0 ? 1 : 0); + + /* Restore the default error handler (set in h5_reset()) */ + h5_restore_err(); + + /*******************************************************************/ + /* ENSURE THAT DISABLING FILTER PLUGINS VIA THE FILTER FLAGS WORKS */ + /*******************************************************************/ + + /* Close the library so that all loaded plugin libraries are unloaded */ + h5_reset(); + if ((old_ff_fapl_id = h5_fileaccess()) < 0) + TEST_ERROR; + + /* Reopen the file for testing data reading */ + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, old_ff_fapl_id)) < 0) + TEST_ERROR; + + /* When filters are disabled, make sure we can't read data from a + * dataset that requires a filter plugin. + */ + nerrors += (test_no_read_when_plugins_disabled(fid) < 0 ? 1 : 0); + + if (H5Fclose(fid) < 0) + TEST_ERROR; + + /************************************/ + /* TEST THE FILTER PLUGIN API CALLS */ + /************************************/ + + /* Test the APIs for access to the filter plugin path table */ + nerrors += (test_path_api_calls() < 0 ? 1 : 0); + + /*********************/ + /* CLEAN UP AND EXIT */ + /*********************/ + + /* Free up saved arrays */ + free_2D_array(&orig_deflate_g); + free_2D_array(&orig_dynlib1_g); + free_2D_array(&orig_dynlib2_g); + free_2D_array(&orig_dynlib4_g); + + if (nerrors) + TEST_ERROR; + + HDprintf("All plugin tests passed.\n"); + h5_cleanup(FILENAME, old_ff_fapl_id); + + HDexit(EXIT_SUCCESS); + +error: + H5E_BEGIN_TRY { + H5Fclose(fid); + H5Pclose(old_ff_fapl_id); + H5Pclose(new_ff_fapl_id); + } H5E_END_TRY + + /* Free up saved arrays (NULLs okay) */ + free_2D_array(&orig_deflate_g); + free_2D_array(&orig_dynlib1_g); + free_2D_array(&orig_dynlib2_g); + free_2D_array(&orig_dynlib4_g); + + nerrors = MAX(1, nerrors); + HDprintf("***** %d PLUGIN TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); + HDexit(EXIT_FAILURE); +} /* end main() */ + diff --git a/test/filter_plugin1_dsets.c b/test/filter_plugin1_dsets.c new file mode 100644 index 0000000..b74e086 --- /dev/null +++ b/test/filter_plugin1_dsets.c @@ -0,0 +1,93 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Test dataset filter plugin for the filter_pluging.c test. + */ + + +#include <stdlib.h> +#include <stdio.h> + +#include "H5PLextern.h" + +#define FILTER1_ID 257 + +static size_t add_sub_value(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); + +/* Filter class struct */ +const H5Z_class2_t FILTER_INFO[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER1_ID, /* Filter ID number */ + 1, /* Encoding enabled */ + 1, /* Decoding enabled */ + "test filter plugin 1", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)add_sub_value, /* The actual filter function */ +}}; + +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} +const void *H5PLget_plugin_info(void) {return FILTER_INFO;} + + +/*------------------------------------------------------------------------- + * Function: add_sub_value + * + * Purpose: On write: + * Adds a caller-supplied value to the element + * On read: + * Subtracts a caller-supplied value from the element + * + * Return: Success: Data chunk size in bytes + * Failure: 0 + * + *------------------------------------------------------------------------- + */ +static size_t +add_sub_value(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf) +{ + int *int_ptr = (int *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + int value = 0; /* Data value to add/subtract */ + + /* Check for the correct number of parameters */ + if (0 == cd_nelmts) + return 0; + + /* Check that permanent parameters are set correctly */ + if (cd_values[0] > 9) + return 0; + + value = (int)cd_values[0]; + + if (flags & H5Z_FLAG_REVERSE) { + /* READ - Substract the given value from all the data values */ + while (buf_left > 0) { + *int_ptr++ -= value; + buf_left -= sizeof(int); + } + } + else { + /* WRITE - Add the given value to all the data values */ + while (buf_left > 0) { + *int_ptr++ += value; + buf_left -= sizeof(int); + } + } + + return nbytes; + +} /* end add_sub_value() */ + diff --git a/test/filter_plugin2_dsets.c b/test/filter_plugin2_dsets.c new file mode 100644 index 0000000..6a79148 --- /dev/null +++ b/test/filter_plugin2_dsets.c @@ -0,0 +1,88 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Test dataset filter plugin for the filter_pluging.c test. + */ + +#include <stdlib.h> +#include <stdio.h> + +#include "H5PLextern.h" + +#define FILTER2_ID 258 +#define MULTIPLIER 3 + +static size_t mult_div_value(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); + +/* Filter class struct */ +const H5Z_class2_t FILTER_INFO[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER2_ID, /* Filter ID number */ + 1, /* Encoding enabled */ + 1, /* Decoding enabled */ + "test filter plugin 2", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)mult_div_value, /* The actual filter function */ +}}; + +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} +const void *H5PLget_plugin_info(void) {return FILTER_INFO;} + + +/*------------------------------------------------------------------------- + * Function: mult_div_value + * + * Purpose: On write: + * Multiplies an element by a constant value. + * On read: + * Divides an element by a constant value. + * + * Return: Success: Data chunk size in bytes + * Failure: 0 + * + *------------------------------------------------------------------------- + */ +static size_t +mult_div_value(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf) +{ + int *int_ptr = (int *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + + /* Check for the correct number of parameters */ + if (cd_nelmts > 0) + return 0; + + /* Assignment to eliminate unused parameter warning */ + cd_values = cd_values; + + if (flags & H5Z_FLAG_REVERSE) { + /* READ - Divide the original value by MULTIPLIER */ + while (buf_left > 0) { + *int_ptr++ /= MULTIPLIER; + buf_left -= sizeof(int); + } + } + else { + /* WRITE - Multiply the original value by MULTIPLIER */ + while (buf_left > 0) { + *int_ptr++ *= MULTIPLIER; + buf_left -= sizeof(int); + } + } + + return nbytes; +} /* end mult_div_value() */ + diff --git a/test/filter_plugin3_dsets.c b/test/filter_plugin3_dsets.c new file mode 100644 index 0000000..b43020f --- /dev/null +++ b/test/filter_plugin3_dsets.c @@ -0,0 +1,119 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Test dataset filter plugin for the filter_pluging.c test. + * This filter makes an HDF5 API call to ensure that works correctly. + */ + +#include <stdlib.h> +#include <stdio.h> + +#include "H5PLextern.h" + +#define FILTER3_ID 259 + +#define PUSH_ERR(func, minor, str) H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, H5E_ERR_CLS, H5E_PLUGIN, minor, str) + +static size_t add_sub_value_hdf5(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); + +/* Filter class struct */ +const H5Z_class2_t FILTER_INFO[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER3_ID, /* Filter ID number */ + 1, /* Encoding enabled */ + 1, /* Decoding enabled */ + "test filter plugin 3", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)add_sub_value_hdf5, /* The actual filter function */ +}}; + +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} +const void *H5PLget_plugin_info(void) {return FILTER_INFO;} + + +/*------------------------------------------------------------------------- + * Function: add_sub_value_hdf5 + * + * Purpose: On write: + * Adds a caller-supplied value to the element + * On read: + * Subtracts a caller-supplied value from the element + * + * NOTE: This filter is identical to filter #1 only it makes + * an HDF5 library call to ensure doing that doesn't + * cause problems. + * + * Return: Success: Data chunk size in bytes + * Failure: 0 + * + *------------------------------------------------------------------------- + */ +static size_t +add_sub_value_hdf5(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf) +{ + int *int_ptr = (int *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + int value = 0; /* Data value to add/subtract */ + unsigned majnum = 0; /* Output data from the HDF5 library call */ + unsigned minnum = 0; + unsigned relnum = 0; + + /* Check for the library version. + * We don't do anything with this information - it's just to ensure that + * HDF5 library calls work properly from inside filter plugins. + */ + if (H5get_libversion(&majnum, &minnum, &relnum) < 0) { + PUSH_ERR("filter plugin 3", H5E_CALLBACK, "H5get_libversion"); + return 0; + } + + /* Check for the correct number of parameters */ + if (cd_nelmts == 0) + return 0; + + /* Check that permanent parameters are set correctly */ + if (cd_values[0] > 9) + return 0; + + /* Ensure that the version numbers match what was passed in. + * Again, this is trivial work, just to ensure that the library calls are + * working properly. + */ + if (majnum != cd_values[1] || minnum != cd_values[2]) { + PUSH_ERR("filter plugin 3", H5E_CALLBACK, "library versions do not match"); + return 0; + } + + value = (int)cd_values[0]; + + if (flags & H5Z_FLAG_REVERSE) { + /* READ - Substract the given value from all the data values */ + while (buf_left > 0) { + *int_ptr++ -= value; + buf_left -= sizeof(int); + } + } + else { + /* WRITE - Add the given value to all the data values */ + while (buf_left > 0) { + *int_ptr++ += value; + buf_left -= sizeof(int); + } + } + + return nbytes; +} /* end add_sub_value_hdf5() */ + diff --git a/test/filter_plugin4_groups.c b/test/filter_plugin4_groups.c new file mode 100644 index 0000000..88ea20d --- /dev/null +++ b/test/filter_plugin4_groups.c @@ -0,0 +1,106 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Test group filter plugin for the filter_pluging.c test. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "H5PLextern.h" + +#define FILTER4_ID 260 +#define SUFFIX_LEN 8 +#define GROUP_SUFFIX ".h5group" + +static size_t append_to_group_name(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); + +/* Filter class struct */ +const H5Z_class2_t FILTER_INFO[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER4_ID, /* Filter ID number */ + 1, /* Encoding enabled */ + 1, /* Decoding enabled */ + "test filter plugin 4", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)append_to_group_name, /* The actual filter function */ +}}; + +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} +const void *H5PLget_plugin_info(void) {return FILTER_INFO;} + + +/*------------------------------------------------------------------------- + * Function: append_to_group_name + * + * Purpose: On write: + * Appends the suffix ".h5group" to the group name + * On read: + * Removes the ".h5group" suffix from the group name + * + * Return: Success: Data size in bytes + * Failure: 0 + * + *------------------------------------------------------------------------- + */ +static size_t +append_to_group_name(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf) +{ + size_t new_name_size = 0; /* Return value */ + + /* Check for the correct number of parameters */ + if (cd_nelmts > 0) + return 0; + + /* Assignment to eliminate unused parameter warning. */ + cd_values = cd_values; + + if (flags & H5Z_FLAG_REVERSE) { + /* READ - Remove the suffix from the group name */ + new_name_size = *buf_size = nbytes - SUFFIX_LEN; + } + else { + /* WRITE - Append the suffix to the group name */ + void *outbuf = NULL; /* Pointer to new buffer */ + unsigned char *dst = NULL; /* Temporary pointer to destination buffer */ + + /* Get memory for the new, larger string buffer using the + * library's memory allocator. + */ + if (NULL == (dst = (unsigned char *)(outbuf = H5allocate_memory(nbytes + SUFFIX_LEN, 0)))) + return 0; + + /* Copy raw data */ + memcpy((void *)dst, (const void *)(*buf), nbytes); + + /* Append suffix to raw data for storage */ + dst += nbytes; + memcpy((void *)dst, (const void *)GROUP_SUFFIX, SUFFIX_LEN); + + /* Free the passed-in buffer using the library's allocator */ + H5free_memory(*buf); + + /* Set return values */ + *buf_size = nbytes + SUFFIX_LEN; + *buf = outbuf; + outbuf = NULL; + new_name_size = *buf_size; + } + + return new_name_size; +} /* append_to_group_name() */ + diff --git a/test/plugin.c b/test/plugin.c deleted file mode 100644 index ea199f6..0000000 --- a/test/plugin.c +++ /dev/null @@ -1,1217 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Purpose: Tests the plugin module (H5PL) - */ - -#include "h5test.h" -#include "H5srcdir.h" - -/* - * This file needs to access private datatypes from the H5Z and H5PL package. - */ -#define H5PL_FRIEND -#include "H5PLpkg.h" -#define H5Z_FRIEND -#include "H5Zpkg.h" - -/* Filters for HDF5 internal test */ -#define H5Z_FILTER_DYNLIB1 257 -#define H5Z_FILTER_DYNLIB2 258 -#define H5Z_FILTER_DYNLIB3 259 -#define H5Z_FILTER_DYNLIB4 260 - -const char *FILENAME[] = { - "plugin", - NULL -}; -#define FILENAME_BUF_SIZE 1024 - -/* Dataset names for testing filters */ -#define DSET_DEFLATE_NAME "deflate" -#define DSET_DYNLIB1_NAME "dynlib1" -#define DSET_DYNLIB2_NAME "dynlib2" -#define DSET_DYNLIB4_NAME "dynlib4" - -/* Parameters for internal filter test */ -#define FILTER_CHUNK_DIM1 2 -#define FILTER_CHUNK_DIM2 25 -#define FILTER_HS_OFFSET1 7 -#define FILTER_HS_OFFSET2 30 -#define FILTER_HS_SIZE1 4 -#define FILTER_HS_SIZE2 50 - -/* Shared global arrays */ -#define DSET_DIM1 100 -#define DSET_DIM2 200 - -/* Limit random number within 20000 */ -#define RANDOM_LIMIT 20000 - -#define GROUP_ITERATION 1000 - -int points_deflate[DSET_DIM1][DSET_DIM2], - points_dynlib1[DSET_DIM1][DSET_DIM2], - points_dynlib2[DSET_DIM1][DSET_DIM2], - points_dynlib4[DSET_DIM1][DSET_DIM2], - points_bzip2[DSET_DIM1][DSET_DIM2]; - - -/*------------------------------------------------------------------------- - * Function: test_filter_internal - * - * Purpose: Tests writing entire data and partial data with filters - * - * Return: Success: 0 - * Failure: -1 - *------------------------------------------------------------------------- - */ -static herr_t -test_filter_internal(hid_t fid, const char *name, hid_t dcpl) -{ - herr_t ret_value = -1; - hid_t dataset = -1; /* Dataset ID */ - hid_t dxpl = -1; /* Dataset xfer property list ID */ - hid_t write_dxpl = -1; /* Dataset xfer property list ID for writing */ - hid_t sid = -1; /* Dataspace ID */ - const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */ - const hsize_t hs_offset[2] = {FILTER_HS_OFFSET1, FILTER_HS_OFFSET2}; /* Hyperslab offset */ - const hsize_t hs_size[2] = {FILTER_HS_SIZE1, FILTER_HS_SIZE2}; /* Hyperslab size */ - void *tconv_buf = NULL; /* Temporary conversion buffer */ - int points[DSET_DIM1][DSET_DIM2], check[DSET_DIM1][DSET_DIM2]; - size_t i, j; /* Local index variables */ - int n = 0; - - /* Create the data space */ - if((sid = H5Screate_simple(2, size, NULL)) < 0) TEST_ERROR - - /* - * Create a small conversion buffer to test strip mining. We - * might as well test all we can! - */ - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR - tconv_buf = HDmalloc((size_t)1000); - if(H5Pset_buffer(dxpl, (size_t)1000, tconv_buf, NULL) < 0) TEST_ERROR - if((write_dxpl = H5Pcopy(dxpl)) < 0) TEST_ERROR; - - TESTING(" filters (setup)"); - - /* Check if all the filters are available */ - if(H5Pall_filters_avail(dcpl) != TRUE) { - H5_FAILED(); - HDprintf(" Line %d: Incorrect filter availability\n", __LINE__); - TEST_ERROR - } /* end if */ - - /* Create the dataset */ - if((dataset = H5Dcreate2(fid, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR - - PASSED(); - - /*---------------------------------------------------------------------- - * STEP 1: Read uninitialized data. It should be zero. - *---------------------------------------------------------------------- - */ - TESTING(" filters (uninitialized read)"); - - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) TEST_ERROR; - - for(i=0; i<(size_t)size[0]; i++) - for(j=0; j<(size_t)size[1]; j++) - if(0 != check[i][j]) { - H5_FAILED(); - HDprintf(" Read a non-zero value.\n"); - HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); - TEST_ERROR - } /* end if */ - PASSED(); - - /*---------------------------------------------------------------------- - * STEP 2: Test filters by setting up a chunked dataset and writing - * to it. - *---------------------------------------------------------------------- - */ - TESTING(" filters (write)"); - - n = 0; - for(i=0; i<size[0]; i++) - for(j=0; j<size[1]; j++) - points[i][j] = (int)(n++); - - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points) < 0) TEST_ERROR; - - PASSED(); - - /*---------------------------------------------------------------------- - * STEP 3: Try to read the data we just wrote. - *---------------------------------------------------------------------- - */ - TESTING(" filters (read)"); - - /* Read the dataset back */ - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) TEST_ERROR; - - /* Check that the values read are the same as the values written */ - for(i=0; i<size[0]; i++) - for(j=0; j<size[1]; j++) - if(points[i][j] != check[i][j]) { - H5_FAILED(); - HDfprintf(stderr," Read different values than written.\n"); - HDfprintf(stderr," At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); - HDfprintf(stderr," At original: %d\n", (int)points[i][j]); - HDfprintf(stderr," At returned: %d\n", (int)check[i][j]); - TEST_ERROR - } /* end if */ - - PASSED(); - - /*---------------------------------------------------------------------- - * STEP 4: Write new data over the top of the old data. The new data is - * random thus not very compressible, and will cause the chunks to move - * around as they grow. We only change values for the left half of the - * dataset although we rewrite the whole thing. - *---------------------------------------------------------------------- - */ - TESTING(" filters (modify)"); - - for(i=0; i<size[0]; i++) - for(j=0; j<size[1]/2; j++) - points[i][j] = (int)HDrandom () % RANDOM_LIMIT; - - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points) < 0) TEST_ERROR; - - /* Read the dataset back and check it */ - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) TEST_ERROR; - - /* Check that the values read are the same as the values written */ - for(i=0; i<size[0]; i++) - for(j=0; j<size[1]; j++) - if(points[i][j] != check[i][j]) { - H5_FAILED(); - HDprintf(" Read different values than written.\n"); - HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); - TEST_ERROR - } /* end if */ - - PASSED(); - - /*---------------------------------------------------------------------- - * STEP 5: Close the dataset and then open it and read it again. This - * insures that the filters message is picked up properly from the - * object header. - *---------------------------------------------------------------------- - */ - TESTING(" filters (re-open)"); - - if(H5Dclose(dataset) < 0) TEST_ERROR; - if((dataset = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) TEST_ERROR; - - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) TEST_ERROR; - - /* Check that the values read are the same as the values written */ - for(i = 0; i < size[0]; i++) - for(j = 0; j < size[1]; j++) - if(points[i][j] != check[i][j]) { - H5_FAILED(); - HDprintf(" Read different values than written.\n"); - HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); - TEST_ERROR - } /* end if */ - - PASSED(); - - /*---------------------------------------------------------------------- - * STEP 6: Test partial I/O by writing to and then reading from a - * hyperslab of the dataset. The hyperslab does not line up on chunk - * boundaries (we know that case already works from above tests). - *---------------------------------------------------------------------- - */ - TESTING(" filters (partial I/O)"); - - for(i=0; i<(size_t)hs_size[0]; i++) - for(j=0; j<(size_t)hs_size[1]; j++) - points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j] = (int)HDrandom() % RANDOM_LIMIT; - - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) TEST_ERROR; - /* (Use the "read" DXPL because partial I/O on corrupted data test needs to ignore errors during writing) */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, sid, sid, dxpl, points) < 0) TEST_ERROR; - - if(H5Dread(dataset, H5T_NATIVE_INT, sid, sid, dxpl, check) < 0) TEST_ERROR; - - /* Check that the values read are the same as the values written */ - for(i=0; i<(size_t)hs_size[0]; i++) - for(j=0; j<(size_t)hs_size[1]; j++) - if(points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j] != check[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]) { - H5_FAILED(); - HDfprintf(stderr," Read different values than written.\n"); - HDfprintf(stderr," At index %lu,%lu\n", (unsigned long)((size_t)hs_offset[0]+i), (unsigned long)((size_t)hs_offset[1]+j)); - HDfprintf(stderr," At original: %d\n", (int)points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]); - HDfprintf(stderr," At returned: %d\n", (int)check[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]); - TEST_ERROR - } /* end if */ - - PASSED(); - - /* Save the data written to the file for later comparison when the file - * is reopened for read test */ - for(i=0; i<size[0]; i++) - for(j=0; j<size[1]; j++) - if(!HDstrcmp(name, DSET_DEFLATE_NAME)) - points_deflate[i][j] = points[i][j]; - else if(!HDstrcmp(name, DSET_DYNLIB1_NAME)) - points_dynlib1[i][j] = points[i][j]; - else if(!HDstrcmp(name, DSET_DYNLIB2_NAME)) - points_dynlib2[i][j] = points[i][j]; - else if(!HDstrcmp(name, DSET_DYNLIB4_NAME)) - points_dynlib4[i][j] = points[i][j]; - - ret_value = 0; - -error: - /* Clean up objects used for this test */ - H5E_BEGIN_TRY { - H5Dclose(dataset); - H5Sclose(sid); - H5Pclose(dxpl); - } H5E_END_TRY - - if(tconv_buf) - HDfree(tconv_buf); - return ret_value; -} - -/*------------------------------------------------------------------------- - * Function: test_filters_for_datasets - * - * Purpose: Tests creating datasets and writing data with dynamically loaded filters - * - * Return: Success: 0 - * Failure: -1 - *------------------------------------------------------------------------- - */ -static herr_t -test_filters_for_datasets(hid_t file) -{ - herr_t ret_value = -1; - hid_t dc = -1; /* Dataset creation property list ID */ - const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */ - unsigned int compress_level = 9; - unsigned int dynlib4_values[4]; - - /*---------------------------------------------------------- - * STEP 1: Test deflation by itself. - *---------------------------------------------------------- - */ - HDputs("Testing deflate filter"); -#ifdef H5_HAVE_FILTER_DEFLATE - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(dc, 2, chunk_size) < 0) TEST_ERROR - if(H5Pset_deflate(dc, 6) < 0) TEST_ERROR - - if(test_filter_internal(file, DSET_DEFLATE_NAME, dc) < 0) TEST_ERROR - /* Clean up objects used for this test */ - if(H5Pclose(dc) < 0) TEST_ERROR -#else /* H5_HAVE_FILTER_DEFLATE */ - SKIPPED(); - HDputs(" Deflate filter not enabled"); -#endif /* H5_HAVE_FILTER_DEFLATE */ - - /*---------------------------------------------------------- - * STEP 2: Test DYNLIB1 by itself. - *---------------------------------------------------------- - */ - HDputs(" DYNLIB1 filter"); - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(dc, 2, chunk_size) < 0) TEST_ERROR - if(H5Pset_filter(dc, H5Z_FILTER_DYNLIB1, H5Z_FLAG_MANDATORY, (size_t)1, &compress_level) < 0) TEST_ERROR - - if(test_filter_internal(file, DSET_DYNLIB1_NAME, dc) < 0) TEST_ERROR - - /* Clean up objects used for this test */ - if(H5Pclose(dc) < 0) TEST_ERROR - - /* Unregister the dynamic filter DYNLIB1 for testing purpose. The next time when this test is run for - * the new file format, the library's H5PL code has to search in the table of loaded plugin libraries - * for this filter. */ - if(H5Zunregister(H5Z_FILTER_DYNLIB1) < 0) TEST_ERROR - - /*---------------------------------------------------------- - * STEP 3: Test DYNLIB2 by itself. - *---------------------------------------------------------- - */ - HDputs(" DYNLIB2 filter"); - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(dc, 2, chunk_size) < 0) TEST_ERROR - if(H5Pset_filter(dc, H5Z_FILTER_DYNLIB2, H5Z_FLAG_MANDATORY, 0, NULL) < 0) TEST_ERROR - - if(test_filter_internal(file,DSET_DYNLIB2_NAME,dc) < 0) TEST_ERROR - - /* Clean up objects used for this test */ - if(H5Pclose(dc) < 0) TEST_ERROR - - /* Unregister the dynamic filter DYNLIB2 for testing purpose. The next time when this test is run for - * the new file format, the library's H5PL code has to search in the table of loaded plugin libraries - * for this filter. */ - if(H5Zunregister(H5Z_FILTER_DYNLIB2) < 0) TEST_ERROR - - /*---------------------------------------------------------- - * STEP 4: Test DYNLIB4 by itself. - *---------------------------------------------------------- - */ - HDputs(" DYNLIB4 filter"); - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(dc, 2, chunk_size) < 0) TEST_ERROR - dynlib4_values[0] = 9; - if(H5get_libversion(&dynlib4_values[1], &dynlib4_values[2], &dynlib4_values[3]) < 0) TEST_ERROR - if(H5Pset_filter(dc, H5Z_FILTER_DYNLIB4, H5Z_FLAG_MANDATORY, (size_t)4, dynlib4_values) < 0) TEST_ERROR - - if(test_filter_internal(file, DSET_DYNLIB4_NAME, dc) < 0) TEST_ERROR - - /* Clean up objects used for this test */ - if(H5Pclose(dc) < 0) TEST_ERROR - - /* Unregister the dynamic filter DYNLIB4 for testing purpose. The next time when this test is run for - * the new file format, the library's H5PL code has to search in the table of loaded plugin libraries - * for this filter. */ - if(H5Zunregister(H5Z_FILTER_DYNLIB4) < 0) TEST_ERROR - - ret_value = 0; - -error: - /* Clean up objects used for this test */ - H5E_BEGIN_TRY { - H5Pclose(dc); - } H5E_END_TRY - - return ret_value; -} - -/*------------------------------------------------------------------------- - * Function: test_read_data - * - * Purpose: Tests reading data and compares values - * - * Return: Success: 0 - * Failure: -1 - *------------------------------------------------------------------------- - */ -static herr_t -test_read_data(hid_t dataset, int *origin_data) -{ - herr_t ret_value = -1; - int check[DSET_DIM1][DSET_DIM2]; - const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */ - int *data_p = origin_data; - size_t i, j; /* Local index variables */ - - /* Read the dataset back */ - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0) TEST_ERROR; - - /* Check that the values read are the same as the values written */ - for(i=0; i<size[0]; i++) - for(j=0; j<size[1]; j++) { - if(*data_p != check[i][j]) { - H5_FAILED(); - HDfprintf(stderr," Read different values than written.\n"); - HDfprintf(stderr," At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); - HDfprintf(stderr," At original: %d\n", *data_p); - HDfprintf(stderr," At returned: %d\n", (int)check[i][j]); - TEST_ERROR - } /* end if */ - data_p++; - } - - PASSED(); - ret_value = 0; - -error: - return ret_value; -} - -/*------------------------------------------------------------------------- - * Function: test_read_with_filters - * - * Purpose: Tests reading dataset created with dynamically loaded filters - * - * Return: Success: 0 - * Failure: -1 - *------------------------------------------------------------------------- - */ -static herr_t -test_read_with_filters(hid_t file) -{ - herr_t ret_value = -1; - hid_t dset = -1; /* Dataset ID */ - - /*---------------------------------------------------------- - * STEP 1: Test deflation by itself. - *---------------------------------------------------------- - */ - TESTING("deflate filter"); - -#ifdef H5_HAVE_FILTER_DEFLATE - if(H5Zfilter_avail(H5Z_FILTER_DEFLATE) != TRUE) TEST_ERROR - - if((dset = H5Dopen2(file,DSET_DEFLATE_NAME,H5P_DEFAULT)) < 0) TEST_ERROR - - if(test_read_data(dset, (int *)points_deflate) < 0) TEST_ERROR - - if(H5Dclose(dset) < 0) TEST_ERROR - - /* Clean up objects used for this test */ -#else /* H5_HAVE_FILTER_DEFLATE */ - SKIPPED(); - HDputs(" Deflate filter not enabled"); -#endif /* H5_HAVE_FILTER_DEFLATE */ - - /*---------------------------------------------------------- - * STEP 2: Test DYNLIB1 by itself. - *---------------------------------------------------------- - */ - TESTING(" DYNLIB1 filter"); - - if((dset = H5Dopen2(file, DSET_DYNLIB1_NAME, H5P_DEFAULT)) < 0) TEST_ERROR - - if(test_read_data(dset, (int *)points_dynlib1) < 0) TEST_ERROR - - if(H5Dclose(dset) < 0) TEST_ERROR - - /*---------------------------------------------------------- - * STEP 3: Test Bogus2 by itself. - *---------------------------------------------------------- - */ - TESTING(" DYNLIB2 filter"); - - if((dset = H5Dopen2(file, DSET_DYNLIB2_NAME, H5P_DEFAULT)) < 0) TEST_ERROR - - if(test_read_data(dset, (int *)points_dynlib2) < 0) TEST_ERROR - - if(H5Dclose(dset) < 0) TEST_ERROR - - /*---------------------------------------------------------- - * STEP 4: Test DYNLIB4 by itself. - *---------------------------------------------------------- - */ - TESTING(" DYNLIB4 filter"); - - if((dset = H5Dopen2(file,DSET_DYNLIB4_NAME,H5P_DEFAULT)) < 0) TEST_ERROR - - if(test_read_data(dset, (int *)points_dynlib4) < 0) TEST_ERROR - - if(H5Dclose(dset) < 0) TEST_ERROR - - ret_value = 0; - -error: - /* Clean up objects used for this test */ - H5E_BEGIN_TRY { - H5Dclose(dset); - } H5E_END_TRY - - return ret_value; -} - -/*------------------------------------------------------------------------- - * Function: test_noread_data - * - * Purpose: Tests not reading data - * - * Return: Success: 0 - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -static herr_t -test_noread_data(hid_t dataset) -{ - herr_t ret_value = -1; - int check[DSET_DIM1][DSET_DIM2]; - herr_t ret = -1; - - /* Read the dataset back */ - H5E_BEGIN_TRY { - ret = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check); - } H5E_END_TRY - if(ret >= 0) - TEST_ERROR - - PASSED(); - ret_value = 0; - -error: - return ret_value; -} - -/*------------------------------------------------------------------------- - * Function: test_noread_with_filters - * - * Purpose: Tests reading dataset created with dynamically loaded filters disabled - * - * Return: Success: 0 - * Failure: -1 - *------------------------------------------------------------------------- - */ -static herr_t -test_noread_with_filters(hid_t file) -{ - herr_t ret_value = -1; - hid_t dset = -1; /* Dataset ID */ - unsigned plugin_state; /* status of plugins */ - - TESTING("DYNLIB1 filter with plugins disabled"); - - /* disable filter plugin */ - if(H5PLget_loading_state(&plugin_state) < 0) TEST_ERROR - - plugin_state = plugin_state & (unsigned)(~H5PL_FILTER_PLUGIN); - - if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR - - if((dset = H5Dopen2(file, DSET_DYNLIB1_NAME, H5P_DEFAULT)) < 0) TEST_ERROR - - if(test_noread_data(dset) < 0) TEST_ERROR - - if(H5Dclose(dset) < 0) TEST_ERROR - - ret_value = 0; - -error: - /* re-enable filter plugin */ - plugin_state = plugin_state | H5PL_FILTER_PLUGIN; - H5PLset_loading_state(plugin_state); - - /* Clean up objects used for this test */ - H5E_BEGIN_TRY { - H5Dclose(dset); - } H5E_END_TRY - - return ret_value; -} - -/*------------------------------------------------------------------------- - * Function: test_filters_for_groups - * - * Purpose: Tests creating group with dynamically loaded filters - * - * Return: Success: 0 - * Failure: -1 - *------------------------------------------------------------------------- - */ -static herr_t -test_filters_for_groups(hid_t file) -{ - herr_t ret_value = -1; - hid_t gcpl = -1; - hid_t gid = -1; - hid_t group = -1; - int i; - char gname[256]; - - TESTING("DYNLIB3 filter for group"); - - if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR - - /* Use DYNLIB3 for creating groups */ - if(H5Pset_filter (gcpl, H5Z_FILTER_DYNLIB3, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) TEST_ERROR - - /* Create a group using this filter */ - if((gid = H5Gcreate2(file, "group1", H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR - - /* Create multiple groups under "group1" */ - for(i=0; i < GROUP_ITERATION; i++) { - HDsprintf(gname, "group_%d", i); - if((group = H5Gcreate2(gid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group) < 0) TEST_ERROR - } - - /* Close the group */ - if(H5Gclose(gid) < 0) TEST_ERROR - - /* Clean up objects used for this test */ - if(H5Pclose(gcpl) < 0) TEST_ERROR - - PASSED(); - - ret_value = 0; - -error: - /* Clean up objects used for this test */ - H5E_BEGIN_TRY { - H5Gclose(group); - H5Gclose(gid); - H5Pclose(gcpl); - } H5E_END_TRY - - return ret_value; -} - -/*------------------------------------------------------------------------- - * Function: test_groups_with_filters - * - * Purpose: Tests opening group with dynamically loaded filters - * - * Return: Success: 0 - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -static herr_t -test_groups_with_filters(hid_t file) -{ - herr_t ret_value = -1; - hid_t gid = -1; - hid_t group = -1; - int i; - char gname[256]; - - TESTING("opening groups with DYNLIB3 filter"); - - /* Open the top group */ - if((gid = H5Gopen2(file, "group1", H5P_DEFAULT)) < 0) TEST_ERROR - - /* Create multiple groups under "group1" */ - for(i=0; i < GROUP_ITERATION; i++) { - HDsprintf(gname, "group_%d", i); - if((group = H5Gopen2(gid, gname, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group) < 0) TEST_ERROR - } - - /* Close the group */ - if(H5Gclose(gid) < 0) TEST_ERROR - - PASSED(); - - ret_value = 0; - -error: - /* Clean up objects used for this test */ - H5E_BEGIN_TRY { - H5Gclose(group); - H5Gclose(gid); - } H5E_END_TRY - - return ret_value; -} - - -/*------------------------------------------------------------------------- - * Function: test_path_api_calls - * - * Purpose: Tests the H5PL API calls that manipulate the plugin search - * paths. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -test_path_api_calls(void) -{ - unsigned int n_starting_paths; - unsigned int u; - unsigned int n_paths; - herr_t ret; - ssize_t path_len = -1; - char path[256]; - char temp_name[256]; - - HDputs("Testing access to the filter path table"); - - if(H5Zfilter_avail(H5Z_FILTER_DYNLIB1) != TRUE) - TEST_ERROR - - /* Set the number of paths to create for this test. - * - * This should be set high enough to ensure that at least one array - * expansion will take place. See H5PLpath.c for details. - */ - n_starting_paths = 42; - - /* Check that initialization is correct */ - TESTING(" initialize"); - - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - if(n_paths != 2) - TEST_ERROR - - PASSED(); - - /****************/ - /* H5PLremove() */ - /****************/ - - /* Remove all the current paths */ - TESTING(" remove"); - - /* Get the current size */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - - /* Remove all existing paths */ - for(u = n_paths; u > 0; u--) - if(H5PLremove(u-1) < 0) { - HDfprintf(stderr," at %u: %s\n", u, path); - TEST_ERROR - } - - /* Verify the table is empty */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - if(n_paths > 0) - TEST_ERROR - - PASSED(); - - - TESTING(" remove (index 0 in empty table)"); - - /* Try to remove index zero in an empty list (SHOULD FAIL) */ - H5E_BEGIN_TRY { - ret = H5PLremove(0); - } H5E_END_TRY - if(ret >= 0) - TEST_ERROR - - PASSED(); - - - /****************/ - /* H5PLappend() */ - /****************/ - - TESTING(" append"); - - /* Add a bunch of paths to the path table */ - for(u = 0; u < n_starting_paths; u++) { - HDsprintf(path, "a_path_%u", u); - if(H5PLappend(path) < 0) { - HDfprintf(stderr," at %u: %s\n", u, path); - TEST_ERROR - } - } - - PASSED(); - - - /**********************/ - /* H5PLremove() again */ - /**********************/ - - TESTING(" remove (index too high)"); - - /* Try to remove a path where the index is beyond the table capacity (SHOULD FAIL) */ - H5E_BEGIN_TRY { - ret = H5PLremove(n_starting_paths); - } H5E_END_TRY - - if(ret >= 0) - TEST_ERROR - - PASSED(); - - - /*************/ - /* H5PLget() */ - /*************/ - - TESTING(" get (path name)"); - - /* Get the path length by passing in NULL */ - if((path_len = H5PLget(0, NULL, 0)) <= 0) { - HDfprintf(stderr," get path 0 length failed\n"); - TEST_ERROR - } - if(path_len != 8) - TEST_ERROR - - /* Get the path */ - if((path_len = H5PLget(0, path, 256)) <= 0) { - HDfprintf(stderr," get 0 len: %u : %s\n", path_len, path); - TEST_ERROR - } - if(HDstrcmp(path, "a_path_0") != 0) { - HDfprintf(stderr," get 0: %s\n", path); - TEST_ERROR - } - - PASSED(); - - - TESTING(" get (high and low indices)"); - - /* Get path at index 1 */ - if((path_len = H5PLget(1, path, 256)) <= 0) - TEST_ERROR - if(HDstrcmp(path, "a_path_1") != 0) { - HDfprintf(stderr," get 1: %s\n", path); - TEST_ERROR - } - - /* Get path at the last index */ - if((path_len = H5PLget(n_starting_paths - 1, path, 256)) <= 0) - TEST_ERROR - HDsprintf(temp_name, "a_path_%u", n_starting_paths - 1); - if(HDstrcmp(path, temp_name) != 0) { - HDfprintf(stderr," get %u: %s\n", n_starting_paths - 1, path); - TEST_ERROR - } - - PASSED(); - - - TESTING(" get (index too high)"); - - /* Get path at the last + 1 index (SHOULD FAIL) */ - H5E_BEGIN_TRY { - path_len = H5PLget(n_starting_paths, NULL, 0); - } H5E_END_TRY - if(path_len > 0) - TEST_ERROR - - PASSED(); - - - /*****************/ - /* H5PLprepend() */ - /*****************/ - - /* We'll remove a path at an arbitrary index and then - * prepend a new path. - */ - - TESTING(" remove (arbitrary index 1)"); - - /* Remove one path */ - if(H5PLremove(8) < 0) - TEST_ERROR - - /* Verify that the entries were moved */ - if((path_len = H5PLget(8, path, 256)) <= 0) - TEST_ERROR - if(HDstrcmp(path, "a_path_9") != 0) { - HDfprintf(stderr," get 8: %s\n", path); - TEST_ERROR - } - - /* Verify the table shrank */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - if(n_paths != n_starting_paths - 1) - TEST_ERROR - - PASSED(); - - - TESTING(" prepend"); - - /* Prepend one path */ - HDsprintf(path, "a_path_%d", n_starting_paths + 1); - if(H5PLprepend(path) < 0) { - HDfprintf(stderr," prepend %u: %s\n", n_starting_paths + 1, path); - TEST_ERROR - } - - /* Verify the table increased */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - if(n_paths != n_starting_paths) - TEST_ERROR - - /* Verify that the entries were moved */ - if(H5PLget(8, path, 256) <= 0) - TEST_ERROR - if(HDstrcmp(path, "a_path_7") != 0) { - HDfprintf(stderr," get 8: %s\n", path); - TEST_ERROR - } - - /* Verify that the path was inserted at index zero */ - if(H5PLget(0, path, 256) <= 0) - TEST_ERROR - HDsprintf(temp_name, "a_path_%d", n_starting_paths + 1); - if(HDstrcmp(path, temp_name) != 0) { - HDfprintf(stderr," get 0: %s\n", path); - TEST_ERROR - } - - PASSED(); - - - /*****************/ - /* H5PLreplace() */ - /*****************/ - - TESTING(" replace"); - - /* Replace one path at index 1 */ - HDsprintf(path, "a_path_%u", n_starting_paths + 4); - if(H5PLreplace(path, 1) < 0) { - HDfprintf(stderr," replace 1: %s\n", path); - TEST_ERROR - } - - /* Verify the table size remained the same */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - if(n_paths != n_starting_paths) - TEST_ERROR - - /* Verify that the entries were not moved by - * inspecting the paths at indices +/- 1. - */ - - /* Check path at index 0 */ - if(H5PLget(0, path, 256) <= 0) - TEST_ERROR - HDsprintf(temp_name, "a_path_%u", n_starting_paths + 1); - if(HDstrcmp(path, temp_name) != 0) { - HDfprintf(stderr," get 0: %s\n", path); - TEST_ERROR - } - - /* Check path at index 2 */ - if(H5PLget(2, path, 256) <= 0) - TEST_ERROR - if(HDstrcmp(path, "a_path_1") != 0) { - HDfprintf(stderr," get 2: %s\n", path); - TEST_ERROR - } - - PASSED(); - - - /****************/ - /* H5PLinsert() */ - /****************/ - - /* We'll remove a path at an arbitrary index and then - * insert a new path. - */ - - TESTING(" remove (arbitrary index 2)"); - - /* Remove one path */ - if(H5PLremove(4) < 0) - TEST_ERROR - - /* Verify that the entries were moved */ - if(H5PLget(4, path, 256) <= 0) - TEST_ERROR - if(HDstrcmp(path, "a_path_4") != 0) { - HDfprintf(stderr," get 4: %s\n", path); - TEST_ERROR - } - - /* Verify the table size */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - if(n_paths != n_starting_paths - 1) - TEST_ERROR - PASSED(); - - - TESTING(" insert"); - - /* Insert one path at index 3*/ - HDsprintf(path, "a_path_%d", n_starting_paths + 5); - if(H5PLinsert(path, 3) < 0) { - HDfprintf(stderr," insert 3: %s\n", path); - TEST_ERROR - } - - /* Verify that the entries were moved */ - if(H5PLget(4, path, 256) <= 0) - TEST_ERROR - if(HDstrcmp(path, "a_path_2") != 0) { - HDfprintf(stderr," get 4: %s\n", path); - TEST_ERROR - } - - /* Verify the table size increased */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - if(n_paths != n_starting_paths) - TEST_ERROR - - PASSED(); - - - /****************/ - /* H5PLremove() */ - /****************/ - - /* Remove all the current paths */ - TESTING(" remove (all)"); - - /* Get the current size */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - - /* Remove all existing paths */ - for(u = n_paths; u > 0; u--) - if(H5PLremove(u-1) < 0) { - HDfprintf(stderr," at %u: %s\n", u, path); - TEST_ERROR - } - - /* Verify the table is empty */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - if(n_paths > 0) - TEST_ERROR - - PASSED(); - - - return SUCCEED; - -error: - return FAIL; -} /* end test_path_api_calls() */ - - -/*------------------------------------------------------------------------- - * Function: main - * - * Purpose: Tests the plugin module (H5PL) - * - * Return: EXIT_SUCCESS/EXIT_FAILURE - * - *------------------------------------------------------------------------- - */ -int -main(void) -{ - char filename[FILENAME_BUF_SIZE]; - hid_t file = -1; - hid_t fapl = -1; - hid_t fapl2 = -1; - unsigned new_format; - int mdc_nelmts; - size_t rdcc_nelmts; - size_t rdcc_nbytes; - double rdcc_w0; - int nerrors = 0; - - /* Testing setup */ - h5_reset(); - - if ((fapl = h5_fileaccess()) < 0) - TEST_ERROR - - /* Turn off the chunk cache, so all the chunks are immediately written to disk */ - if (H5Pget_cache(fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0) - TEST_ERROR - rdcc_nbytes = 0; - if (H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) - TEST_ERROR - - /* Copy the file access property list */ - if ((fapl2 = H5Pcopy(fapl)) < 0) - TEST_ERROR - - /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if (H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - TEST_ERROR - - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Test with old & new format groups */ - for (new_format = FALSE; new_format <= TRUE; new_format++) { - hid_t my_fapl; - - /* Set the FAPL for the type of format */ - if (new_format) { - HDputs("\nTesting with new file format:"); - my_fapl = fapl2; - } - else { - HDputs("Testing with old file format:"); - my_fapl = fapl; - } - - /* Create the file for this test */ - if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR - - /* Test dynamically loaded filters for chunked dataset */ - nerrors += (test_filters_for_datasets(file) < 0 ? 1 : 0); - - /* Test dynamically loaded filters for groups */ - nerrors += (test_filters_for_groups(file) < 0 ? 1 : 0); - - if (H5Fclose(file) < 0) - TEST_ERROR - } /* end for */ - - /* Close FAPL */ - if (H5Pclose(fapl2) < 0) - TEST_ERROR - if (H5Pclose(fapl) < 0) - TEST_ERROR - - /* Restore the default error handler (set in h5_reset()) */ - h5_restore_err(); - - HDputs("\nTesting reading data with with dynamic plugin filters:"); - - /* Close the library so that all loaded plugin libraries are unloaded */ - h5_reset(); - if ((fapl = h5_fileaccess()) < 0) - TEST_ERROR - - /* Reopen the file for testing data reading */ - if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) - TEST_ERROR - - /* Read the data with filters */ - nerrors += (test_read_with_filters(file) < 0 ? 1 : 0); - - /* Open the groups with filters */ - nerrors += (test_groups_with_filters(file) < 0 ? 1 : 0); - - /* Restore the default error handler (set in h5_reset()) */ - h5_restore_err(); - - /* Close the library so that all loaded plugin libraries are unloaded */ - h5_reset(); - if ((fapl = h5_fileaccess()) < 0) - TEST_ERROR - - /* Reopen the file for testing data reading */ - if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) - TEST_ERROR - - /* Read the data with disabled filters */ - nerrors += (test_noread_with_filters(file) < 0 ? 1 : 0); - - if (H5Fclose(file) < 0) - TEST_ERROR - - /* Test the APIs for access to the filter plugin path table */ - nerrors += (test_path_api_calls() < 0 ? 1 : 0); - - if (nerrors) - TEST_ERROR - - HDprintf("All plugin tests passed.\n"); - h5_cleanup(FILENAME, fapl); - - HDexit(EXIT_SUCCESS); - -error: - nerrors = MAX(1, nerrors); - HDprintf("***** %d PLUGIN TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); - HDexit(EXIT_FAILURE); -} /* end main() */ - diff --git a/test/tarray.c b/test/tarray.c index a35b8a3..b2e0ee7 100644 --- a/test/tarray.c +++ b/test/tarray.c @@ -679,7 +679,7 @@ test_array_compound_atomic(void) /* Check the 1st field's name */ mname = H5Tget_member_name(tid2, 0); - CHECK(mname, NULL, "H5Tget_member_name"); + CHECK_PTR(mname, "H5Tget_member_name"); if(HDstrcmp(mname, "i") != 0) TestErrPrintf("Compound field name doesn't match!, mname=%s\n", mname); H5free_memory(mname); @@ -698,7 +698,7 @@ test_array_compound_atomic(void) /* Check the 2nd field's name */ mname = H5Tget_member_name(tid2, 1); - CHECK(mname, NULL, "H5Tget_member_name"); + CHECK_PTR(mname, "H5Tget_member_name"); if(HDstrcmp(mname, "f") != 0) TestErrPrintf("Compound field name doesn't match!, mname=%s\n", mname); H5free_memory(mname); @@ -897,7 +897,7 @@ test_array_compound_array(void) /* Check the 1st field's name */ mname=H5Tget_member_name(tid2,0); - CHECK(mname, NULL, "H5Tget_member_name"); + CHECK_PTR(mname, "H5Tget_member_name"); if(HDstrcmp(mname,"i")!=0) TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname); H5free_memory(mname); @@ -916,7 +916,7 @@ test_array_compound_array(void) /* Check the 2nd field's name */ mname=H5Tget_member_name(tid2,1); - CHECK(mname, NULL, "H5Tget_member_name"); + CHECK_PTR(mname, "H5Tget_member_name"); if(HDstrcmp(mname,"f")!=0) TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname); H5free_memory(mname); @@ -1604,7 +1604,7 @@ test_array_bkg(void) /* Initialize the data */ /* ------------------- */ dtsinfo = (CmpDTSinfo *)HDmalloc(sizeof(CmpDTSinfo)); - CHECK(dtsinfo, NULL, "HDmalloc"); + CHECK_PTR(dtsinfo, "HDmalloc"); HDmemset(dtsinfo, 0, sizeof(CmpDTSinfo)); for (i = 0; i < LENGTH; i++) { for (j = 0; j < ALEN; j++) { @@ -1927,7 +1927,7 @@ test_compat(void) /* Check the 1st field's name */ mname=H5Tget_member_name(tid1,0); - CHECK(mname, NULL, "H5Tget_member_name"); + CHECK_PTR(mname, "H5Tget_member_name"); if(HDstrcmp(mname,"i")!=0) TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname); H5free_memory(mname); @@ -1946,7 +1946,7 @@ test_compat(void) /* Check the 2nd field's name */ mname=H5Tget_member_name(tid1,1); - CHECK(mname, NULL, "H5Tget_member_name"); + CHECK_PTR(mname, "H5Tget_member_name"); if(HDstrcmp(mname,"f")!=0) TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname); H5free_memory(mname); @@ -1965,7 +1965,7 @@ test_compat(void) /* Check the 3rd field's name */ mname=H5Tget_member_name(tid1,2); - CHECK(mname, NULL, "H5Tget_member_name"); + CHECK_PTR(mname, "H5Tget_member_name"); if(HDstrcmp(mname,"l")!=0) TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname); H5free_memory(mname); @@ -2009,7 +2009,7 @@ test_compat(void) /* Check the 1st field's name */ mname=H5Tget_member_name(tid1,0); - CHECK(mname, NULL, "H5Tget_member_name"); + CHECK_PTR(mname, "H5Tget_member_name"); if(mname && HDstrcmp(mname,"i")!=0) TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname); if(mname) H5free_memory(mname); @@ -2028,7 +2028,7 @@ test_compat(void) /* Check the 2nd field's name */ mname=H5Tget_member_name(tid1,1); - CHECK(mname, NULL, "H5Tget_member_name"); + CHECK_PTR(mname, "H5Tget_member_name"); if(mname && HDstrcmp(mname,"f")!=0) TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname); if(mname) H5free_memory(mname); @@ -2073,7 +2073,7 @@ test_compat(void) /* Check the 3rd field's name */ mname=H5Tget_member_name(tid1,2); - CHECK(mname, NULL, "H5Tget_member_name"); + CHECK_PTR(mname, "H5Tget_member_name"); if(mname && HDstrcmp(mname,"l")!=0) TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname); if(mname) H5free_memory(mname); @@ -2118,7 +2118,7 @@ test_compat(void) /* Check the 4th field's name */ mname=H5Tget_member_name(tid1,3); - CHECK(mname, NULL, "H5Tget_member_name"); + CHECK_PTR(mname, "H5Tget_member_name"); if(mname && HDstrcmp(mname,"d")!=0) TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname); if(mname) H5free_memory(mname); diff --git a/test/tattr.c b/test/tattr.c index 3786d0d..2d333e9 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -277,7 +277,7 @@ test_attr_basic_write(hid_t fapl) if(attr_name_size > 0) { attr_name = (char*)HDcalloc((size_t)(attr_name_size + 1), sizeof(char)); - CHECK(attr_name, NULL, "HDcalloc"); + CHECK_PTR(attr_name, "HDcalloc"); if(attr_name) { ret = (herr_t)H5Aget_name(attr, (size_t)(attr_name_size + 1), attr_name); @@ -313,7 +313,7 @@ test_attr_basic_write(hid_t fapl) if(attr_name_size > 0) { attr_name = (char*)HDcalloc((size_t)(attr_name_size+1), sizeof(char)); - CHECK(attr_name, NULL, "HDcalloc"); + CHECK_PTR(attr_name, "HDcalloc"); if(attr_name) { ret = (herr_t)H5Aget_name(attr2, (size_t)(attr_name_size + 1), attr_name); @@ -6862,7 +6862,7 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) /* Allocate the "visited link" array */ iter_info.max_visit = max_compact * 2; visited = (hbool_t*)HDmalloc(sizeof(hbool_t) * iter_info.max_visit); - CHECK(visited, NULL, "HDmalloc"); + CHECK_PTR(visited, "HDmalloc"); iter_info.visited = visited; /* Loop over operating on different indices on link fields */ @@ -8040,7 +8040,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) /* Allocate & initialize "big" attribute data */ big_value = (unsigned *)HDmalloc((size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3) * sizeof(unsigned)); - CHECK(big_value, NULL, "HDmalloc"); + CHECK_PTR(big_value, "HDmalloc"); HDmemset(big_value, 1, sizeof(unsigned) * (size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3)); /* Create dataspace for dataset */ @@ -8371,7 +8371,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) /* Allocate & initialize "big" attribute data */ big_value = (unsigned *)HDmalloc((size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3) * sizeof(unsigned)); - CHECK(big_value, NULL, "HDmalloc"); + CHECK_PTR(big_value, "HDmalloc"); HDmemset(big_value, 1, sizeof(unsigned) * (size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3)); /* Create dataspace for dataset */ @@ -8817,7 +8817,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) /* Allocate & initialize "big" attribute data */ big_value = (unsigned *)HDmalloc((size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3) * sizeof(unsigned)); - CHECK(big_value, NULL, "HDmalloc"); + CHECK_PTR(big_value, "HDmalloc"); HDmemset(big_value, 1, sizeof(unsigned) * (size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3)); /* Create dataspace for dataset */ @@ -9186,7 +9186,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) /* Allocate & initialize "big" attribute data */ big_value = (unsigned *)HDmalloc((size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3) * sizeof(unsigned)); - CHECK(big_value, NULL, "HDmalloc"); + CHECK_PTR(big_value, "HDmalloc"); HDmemset(big_value, 1, sizeof(unsigned) * (size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3)); /* Create dataspace for dataset */ diff --git a/test/tchecksum.c b/test/tchecksum.c index febaacc..ffbab45 100644 --- a/test/tchecksum.c +++ b/test/tchecksum.c @@ -187,7 +187,7 @@ test_chksum_large(void) /* Allocate the buffer */ large_buf = (uint8_t *)HDmalloc((size_t)BUF_LEN); - CHECK(large_buf, NULL, "HDmalloc"); + CHECK_PTR(large_buf, "HDmalloc"); /* Initialize buffer w/known data */ for(u = 0; u < BUF_LEN; u++) diff --git a/test/tcoords.c b/test/tcoords.c index d729d4b..f639d4b 100644 --- a/test/tcoords.c +++ b/test/tcoords.c @@ -669,22 +669,22 @@ static void test_multiple_ends(hid_t file, hbool_t is_chunked) void test_coords(void) { hid_t fid; + hbool_t is_chunk[2] = {TRUE, FALSE}; int i; - hbool_t is_chunk; herr_t ret; /* Generic error return */ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); - for(i=0, is_chunk=FALSE; i<2; i++, is_chunk++) { + for (i = 0; i < 2; i++) { /* Test H5Sselect_elements with selection of one block of data */ - test_singleEnd_selElements(fid, is_chunk); + test_singleEnd_selElements(fid, is_chunk[i]); /* Test H5Sselect_hyperslab with selection of one block of data */ - test_singleEnd_selHyperslab(fid, is_chunk); + test_singleEnd_selHyperslab(fid, is_chunk[i]); /* Test H5Sselect_hyperslab with selection of multiple blocks of data */ - test_multiple_ends(fid, is_chunk); + test_multiple_ends(fid, is_chunk[i]); } ret = H5Fclose(fid); diff --git a/test/test_plugin.sh.in b/test/test_filter_plugin.sh.in index c90a978..0a45c0f 100644 --- a/test/test_plugin.sh.in +++ b/test/test_filter_plugin.sh.in @@ -13,7 +13,7 @@ srcdir=@srcdir@ TOP_BUILDDIR=@top_builddir@ -# Determine backward compatibility options enabled +# Determine if backward compatibility options enabled DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@" EXIT_SUCCESS=0 @@ -23,21 +23,21 @@ nerrors=0 verbose=yes exit_code=$EXIT_SUCCESS -TEST_NAME=plugin +TEST_NAME=filter_plugin TEST_BIN=`pwd`/$TEST_NAME FROM_DIR=`pwd`/.libs case $(uname) in CYGWIN* ) - PLUGIN_LIB1="$FROM_DIR/cygdynlib1* $FROM_DIR/cygdynlib3*" - PLUGIN_LIB2="$FROM_DIR/cygdynlib2* $FROM_DIR/cygdynlib4*" + PLUGINS_FOR_DIR1="$FROM_DIR/cygfilter_plugin1* $FROM_DIR/cygfilter_plugin3*" + PLUGINS_FOR_DIR2="$FROM_DIR/cygfilter_plugin2* $FROM_DIR/cygfilter_plugin4*" ;; *) - PLUGIN_LIB1="$FROM_DIR/libdynlib1.* $FROM_DIR/libdynlib3.*" - PLUGIN_LIB2="$FROM_DIR/libdynlib2.* $FROM_DIR/libdynlib4.*" + PLUGINS_FOR_DIR1="$FROM_DIR/libfilter_plugin1* $FROM_DIR/libfilter_plugin3*" + PLUGINS_FOR_DIR2="$FROM_DIR/libfilter_plugin2* $FROM_DIR/libfilter_plugin4*" ;; esac -PLUGIN_LIBDIR1=testdir1 -PLUGIN_LIBDIR2=testdir2 +PLUGIN_DIR1=filter_plugin_dir1 +PLUGIN_DIR2=filter_plugin_dir2 CP="cp -p" # Use -p to preserve mode,ownership,timestamps RM="rm -rf" @@ -50,34 +50,34 @@ TESTING() { } # Main Body -# Create test directories if not exists yet. -test -d $PLUGIN_LIBDIR1 || mkdir -p $PLUGIN_LIBDIR1 +# Create test directories if necessary. +test -d $PLUGIN_DIR1 || mkdir -p $PLUGIN_DIR1 if [ $? != 0 ]; then - echo "Failed to create test directory($PLUGIN_LIBDIR1)" + echo "Failed to create filter plugin test directory ($PLUGIN_DIR1)" exit $EXIT_FAILURE fi -test -d $PLUGIN_LIBDIR2 || mkdir -p $PLUGIN_LIBDIR2 +test -d $PLUGIN_DIR2 || mkdir -p $PLUGIN_DIR2 if [ $? != 0 ]; then - echo "Failed to create test directory($PLUGIN_LIBDIR2)" + echo "Failed to create filter plugin test directory ($PLUGIN_DIR2)" exit $EXIT_FAILURE fi -# copy plugin library for test -$CP $PLUGIN_LIB1 $PLUGIN_LIBDIR1 +# Copy plugins for the tests. +$CP $PLUGINS_FOR_DIR1 $PLUGIN_DIR1 if [ $? != 0 ]; then - echo "Failed to copy plugin library ($PLUGIN_LIB1) for test." + echo "Failed to copy filter plugins ($PLUGINS_FOR_DIR1) to test directory." exit $EXIT_FAILURE fi -$CP $PLUGIN_LIB2 $PLUGIN_LIBDIR2 +$CP $PLUGINS_FOR_DIR2 $PLUGIN_DIR2 if [ $? != 0 ]; then - echo "Failed to copy plugin library ($PLUGIN_LIB2) for test." + echo "Failed to copy filter plugins ($PLUGINS_FOR_DIR2) to test directory." exit $EXIT_FAILURE fi # setup plugin path -ENVCMD="env HDF5_PLUGIN_PATH=${PLUGIN_LIBDIR1}:${PLUGIN_LIBDIR2}" +ENVCMD="env HDF5_PLUGIN_PATH=${PLUGIN_DIR1}:${PLUGIN_DIR2}" # Run the test $ENVCMD $TEST_BIN @@ -87,9 +87,9 @@ fi ############################################ # HDFFV-9655 test for relative path disabled -# setup plugin path relative to test +# setup filter plugin path relative to test # actual executable is in the .libs folder -#ENVCMD="env HDF5_PLUGIN_PATH=@/../${PLUGIN_LIBDIR1}:@/../${PLUGIN_LIBDIR2}" +#ENVCMD="env HDF5_PLUGIN_PATH=@/../${PLUGIN_DIR1}:@/../${PLUGIN_DIR2}" # # Run the test #$ENVCMD $TEST_BIN @@ -103,11 +103,11 @@ if test $nerrors -ne 0 ; then echo "$nerrors errors encountered" exit_code=$EXIT_FAILURE else - echo "All Plugin API tests passed." + echo "All filter plugin tests passed." exit_code=$EXIT_SUCCESS fi # Clean up temporary files/directories and leave -$RM $PLUGIN_LIBDIR1 $PLUGIN_LIBDIR2 +$RM $PLUGIN_DIR1 $PLUGIN_DIR2 exit $exit_code diff --git a/test/testfiles/error_test_1 b/test/testfiles/error_test_1 index 0acd288..5b68002 100644 --- a/test/testfiles/error_test_1 +++ b/test/testfiles/error_test_1 @@ -53,7 +53,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #004: (file name) line (number) in H5Z_pipeline(): required filter 'bogus' is not registered major: Data filters minor: Read failed - #005: (file name) line (number) in H5PL_load(): required dynamically loaded plugin filter '305' is not available + #005: (file name) line (number) in H5PL_load(): filter plugins disabled major: Plugin for dynamically loaded library minor: Unable to load metadata into cache diff --git a/test/testhdf5.h b/test/testhdf5.h index 2cbe6c6..127c687 100644 --- a/test/testhdf5.h +++ b/test/testhdf5.h @@ -30,130 +30,147 @@ /* Use %ld to print the value because long should cover most cases. */ /* Used to make certain a return value _is_not_ a value */ -#define CHECK(ret, val, where) do { \ - if (VERBOSE_HI) print_func(" Call to routine: %15s at line %4d " \ - "in %s returned %ld \n", \ - where, (int)__LINE__, __FILE__, \ - (long)(ret)); \ - if ((ret) == (val)) { \ - TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ - "in %s\n", where, (long)(ret), (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ - } \ +#define CHECK(ret, val, where) do { \ + if (VERBOSE_HI) { \ + print_func(" Call to routine: %15s at line %4d " \ + "in %s returned %ld \n", \ + where, (int)__LINE__, __FILE__, \ + (long)(ret)); \ + } \ + if ((ret) == (val)) { \ + TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ + "in %s\n", where, (long)(ret), (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ } while(0) -#define CHECK_I(ret,where) { \ - if (VERBOSE_HI) { \ - print_func(" Call to routine: %15s at line %4d in %s returned %ld\n", \ - (where), (int)__LINE__, __FILE__, (long)(ret)); \ - } \ - if ((ret)<0) { \ - TestErrPrintf ("*** UNEXPECTED RETURN from %s is %ld line %4d in %s\n", \ - (where), (long)(ret), (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ - } \ +#define CHECK_I(ret,where) { \ + if (VERBOSE_HI) { \ + print_func(" Call to routine: %15s at line %4d in %s returned %ld\n", \ + (where), (int)__LINE__, __FILE__, (long)(ret)); \ + } \ + if ((ret)<0) { \ + TestErrPrintf ("*** UNEXPECTED RETURN from %s is %ld line %4d in %s\n", \ + (where), (long)(ret), (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ } -#define CHECK_PTR(ret,where) { \ - if (VERBOSE_HI) { \ - print_func(" Call to routine: %15s at line %4d in %s returned %p\n", \ - (where), (int)__LINE__, __FILE__, (ret)); \ - } \ - if (!(ret)) { \ - TestErrPrintf ("*** UNEXPECTED RETURN from %s is NULL line %4d in %s\n", \ - (where), (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ - } \ +/* Check that a pointer is valid (i.e.: not NULL) */ +#define CHECK_PTR(ret,where) { \ + if (VERBOSE_HI) { \ + print_func(" Call to routine: %15s at line %4d in %s returned %p\n", \ + (where), (int)__LINE__, __FILE__, (ret)); \ + } \ + if (!(ret)) { \ + TestErrPrintf ("*** UNEXPECTED RETURN from %s is NULL line %4d in %s\n", \ + (where), (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ } -#define CHECK_PTR_NULL(ret,where) { \ - if (VERBOSE_HI) { \ - print_func(" Call to routine: %15s at line %4d in %s returned %p\n", \ - (where), (int)__LINE__, __FILE__, (ret)); \ - } \ - if (ret) { \ - TestErrPrintf ("*** UNEXPECTED RETURN from %s is not NULL line %4d in %s\n", \ - (where), (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ - } \ +/* Check that a pointer is NULL */ +#define CHECK_PTR_NULL(ret,where) { \ + if (VERBOSE_HI) { \ + print_func(" Call to routine: %15s at line %4d in %s returned %p\n", \ + (where), (int)__LINE__, __FILE__, (ret)); \ + } \ + if (ret) { \ + TestErrPrintf ("*** UNEXPECTED RETURN from %s is not NULL line %4d in %s\n", \ + (where), (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ +} + +/* Check that two pointers are equal */ +#define CHECK_PTR_EQ(ret, val, where) { \ + if (VERBOSE_HI) { \ + print_func(" Call to routine: %15s at line %4d in %s returned %p\n", \ + (where), (int)__LINE__, __FILE__, (const void *)(ret)); \ + } \ + if (ret != val) { \ + TestErrPrintf ("*** UNEXPECTED RETURN from %s: returned value of %p is not equal to %p line %4d in %s\n", \ + (where), (const void *)(ret), (const void *)(val), (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ } /* Used to make certain a return value _is_ a value */ -#define VERIFY(_x, _val, where) do { \ - long __x = (long)_x, __val = (long)_val; \ - if(VERBOSE_HI) { \ - print_func(" Call to routine: %15s at line %4d in %s had value " \ - "%ld \n", (where), (int)__LINE__, __FILE__, __x); \ - } \ - if((__x) != (__val)) { \ - TestErrPrintf("*** UNEXPECTED VALUE from %s should be %ld, but is %ld at line %4d " \ - "in %s\n", (where), __val, __x, (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ - } \ +#define VERIFY(_x, _val, where) do { \ + long __x = (long)_x, __val = (long)_val; \ + if(VERBOSE_HI) { \ + print_func(" Call to routine: %15s at line %4d in %s had value " \ + "%ld \n", (where), (int)__LINE__, __FILE__, __x); \ + } \ + if((__x) != (__val)) { \ + TestErrPrintf("*** UNEXPECTED VALUE from %s should be %ld, but is %ld at line %4d " \ + "in %s\n", (where), __val, __x, (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ } while(0) /* Used to make certain a (non-'long' type's) return value _is_ a value */ -#define VERIFY_TYPE(_x, _val, _type, _format, where) do { \ - _type __x = (_type)_x, __val = (_type)_val; \ - if(VERBOSE_HI) { \ - print_func(" Call to routine: %15s at line %4d in %s had value " \ - _format " \n", (where), (int)__LINE__, __FILE__, __x); \ - } \ - if((__x) != (__val)) { \ - TestErrPrintf("*** UNEXPECTED VALUE from %s should be " _format ", but is " _format " at line %4d " \ - "in %s\n", (where), __val, __x, (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ - } \ +#define VERIFY_TYPE(_x, _val, _type, _format, where) do { \ + _type __x = (_type)_x, __val = (_type)_val; \ + if(VERBOSE_HI) { \ + print_func(" Call to routine: %15s at line %4d in %s had value " \ + _format " \n", (where), (int)__LINE__, __FILE__, __x); \ + } \ + if((__x) != (__val)) { \ + TestErrPrintf("*** UNEXPECTED VALUE from %s should be " _format ", but is " _format " at line %4d " \ + "in %s\n", (where), __val, __x, (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ } while(0) /* Used to make certain a string return value _is_ a value */ -#define VERIFY_STR(x, val, where) do { \ - if (VERBOSE_HI) { \ - print_func(" Call to routine: %15s at line %4d in %s had value " \ - "%s \n", (where), (int)__LINE__, __FILE__, x); \ - } \ - if (HDstrcmp(x, val)) { \ - TestErrPrintf("*** UNEXPECTED VALUE from %s should be %s, but is %s at line %4d " \ - "in %s\n", where, val, x, (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ - } \ +#define VERIFY_STR(x, val, where) do { \ + if (VERBOSE_HI) { \ + print_func(" Call to routine: %15s at line %4d in %s had value " \ + "%s \n", (where), (int)__LINE__, __FILE__, x); \ + } \ + if (HDstrcmp(x, val)) { \ + TestErrPrintf("*** UNEXPECTED VALUE from %s should be %s, but is %s at line %4d " \ + "in %s\n", where, val, x, (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ } while(0) /* Used to document process through a test and to check for errors */ -#define RESULT(ret,func) do { \ - if (VERBOSE_MED) { \ - print_func(" Call to routine: %15s at line %4d in %s returned " \ - "%ld\n", func, (int)__LINE__, __FILE__, (long)(ret)); \ - } \ - if (VERBOSE_HI) \ - H5Eprint2(H5E_DEFAULT, stdout); \ - if ((ret) == FAIL) { \ - TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ - "in %s\n", func, (long)(ret), (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ - } \ +#define RESULT(ret,func) do { \ + if (VERBOSE_MED) { \ + print_func(" Call to routine: %15s at line %4d in %s returned " \ + "%ld\n", func, (int)__LINE__, __FILE__, (long)(ret)); \ + } \ + if (VERBOSE_HI) \ + H5Eprint2(H5E_DEFAULT, stdout); \ + if ((ret) == FAIL) { \ + TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ + "in %s\n", func, (long)(ret), (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ } while(0) /* Used to document process through a test */ #if defined(H5_HAVE_PARALLEL) && defined(H5_PARALLEL_TEST) -#define MESSAGE(V,A) { \ - int mpi_rank; \ - \ - MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); \ - if(mpi_rank == 0 && HDGetTestVerbosity() > (V)) \ - print_func A ; \ +#define MESSAGE(V,A) { \ + int mpi_rank; \ + \ + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); \ + if(mpi_rank == 0 && HDGetTestVerbosity() > (V)) \ + print_func A ; \ } #else /* H5_HAVE_PARALLEL */ #define MESSAGE(V,A) {if (HDGetTestVerbosity() > (V)) print_func A;} #endif /* H5_HAVE_PARALLEL */ /* Used to indicate an error that is complex to check for */ -#define ERROR(where) do { \ - if(VERBOSE_HI) \ - print_func(" Call to routine: %15s at line %4d in %s returned " \ - "invalid result\n", where, (int)__LINE__, __FILE__); \ - TestErrPrintf("*** UNEXPECTED RESULT from %s at line %4d in %s\n", \ - where, (int)__LINE__, __FILE__); \ +#define ERROR(where) do { \ + if(VERBOSE_HI) \ + print_func(" Call to routine: %15s at line %4d in %s returned " \ + "invalid result\n", where, (int)__LINE__, __FILE__); \ + TestErrPrintf("*** UNEXPECTED RESULT from %s at line %4d in %s\n", \ + where, (int)__LINE__, __FILE__); \ } while(0) /* definitions for command strings */ diff --git a/test/tfile.c b/test/tfile.c index 027ad62..80ba4da 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1072,7 +1072,7 @@ test_get_obj_ids(void) VERIFY(oid_count, (NGROUPS + NDSETS + 1), "H5Fget_obj_count"); oid_list = (hid_t *)HDcalloc((size_t)oid_list_size, sizeof(hid_t)); - CHECK(oid_list, NULL, "HDcalloc"); + CHECK_PTR(oid_list, "HDcalloc"); /* Call the public function H5F_get_obj_ids to use H5F_get_objects. User reported having problem here. * that the returned size (ret_count) from H5Fget_obj_ids is one greater than the size passed in @@ -1135,7 +1135,7 @@ test_get_obj_ids(void) VERIFY(oid_count, NDSETS, "H5Fget_obj_count"); oid_list = (hid_t *)HDcalloc((size_t)oid_count, sizeof(hid_t)); - CHECK(oid_list, NULL, "HDcalloc"); + CHECK_PTR(oid_list, "HDcalloc"); /* Get the list of all opened objects */ ret_count = H5Fget_obj_ids((hid_t)H5F_OBJ_ALL, H5F_OBJ_ALL, (size_t)oid_count, oid_list); @@ -2667,7 +2667,7 @@ cal_chksum(const char *file, uint32_t *chksum) /* Allocate space for the file data */ file_data = HDmalloc((size_t)sb.st_size); - CHECK(file_data, NULL, "HDmalloc"); + CHECK_PTR(file_data, "HDmalloc"); if(file_data) { /* Read file's data into memory */ diff --git a/test/th5o.c b/test/th5o.c index 4baac20..144ea4c 100644 --- a/test/th5o.c +++ b/test/th5o.c @@ -783,9 +783,9 @@ test_h5o_link(void) /* Allocate memory buffers */ /* (These are treated as 2-D buffers) */ wdata = (int *)HDmalloc((size_t)(TEST6_DIM1 * TEST6_DIM2) * sizeof(int)); - CHECK(wdata, NULL, "HDmalloc"); + CHECK_PTR(wdata, "HDmalloc"); rdata = (int *)HDmalloc((size_t)(TEST6_DIM1 * TEST6_DIM2) * sizeof(int)); - CHECK(rdata, NULL, "HDmalloc"); + CHECK_PTR(rdata, "HDmalloc"); /* Initialize the raw data */ for(i = n = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++) diff --git a/test/theap.c b/test/theap.c index 3c23025..7b2fadb 100644 --- a/test/theap.c +++ b/test/theap.c @@ -88,11 +88,11 @@ test_heap_init(void) /* Allocate arrays */ rand_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS); - CHECK(rand_num, NULL, "HDmalloc"); + CHECK_PTR(rand_num, "HDmalloc"); inc_sort_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS); - CHECK(inc_sort_num, NULL, "HDmalloc"); + CHECK_PTR(inc_sort_num, "HDmalloc"); dec_sort_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS); - CHECK(dec_sort_num, NULL, "HDmalloc"); + CHECK_PTR(dec_sort_num, "HDmalloc"); /* Create randomized set of numbers */ curr_time = HDtime(NULL); @@ -127,7 +127,7 @@ test_heap_create(void) /* Try creating a maximum Heap */ heap=H5HP_create(H5HP_MAX_HEAP); - CHECK(heap, NULL, "H5HP_create"); + CHECK_PTR(heap, "H5HP_create"); /* Try closing the heap */ ret=H5HP_close(heap); @@ -135,7 +135,7 @@ test_heap_create(void) /* Try creating a minimum Heap */ heap=H5HP_create(H5HP_MIN_HEAP); - CHECK(heap, NULL, "H5HP_create"); + CHECK_PTR(heap, "H5HP_create"); /* Try closing the heap */ ret=H5HP_close(heap); @@ -163,7 +163,7 @@ test_heap_insert_min(void) /* Create a Heap */ heap=H5HP_create(H5HP_MIN_HEAP); - CHECK(heap, NULL, "H5HP_create"); + CHECK_PTR(heap, "H5HP_create"); /* Check that the heap has no elements */ num=H5HP_count(heap); @@ -237,7 +237,7 @@ test_heap_insert_max(void) /* Create a Heap */ heap=H5HP_create(H5HP_MAX_HEAP); - CHECK(heap, NULL, "H5HP_create"); + CHECK_PTR(heap, "H5HP_create"); /* Check that the heap has no elements */ num=H5HP_count(heap); @@ -325,7 +325,7 @@ test_heap_insert_many_core(H5HP_type_t heap_type, test_obj *arr, size_t nelem, i /* Create a Heap */ heap=H5HP_create(heap_type); - CHECK(heap, NULL, "H5HP_create"); + CHECK_PTR(heap, "H5HP_create"); /* Check that the heap has no elements */ num=H5HP_count(heap); @@ -405,7 +405,7 @@ test_heap_remove_min(void) /* Create a Heap */ heap=H5HP_create(H5HP_MIN_HEAP); - CHECK(heap, NULL, "H5HP_create"); + CHECK_PTR(heap, "H5HP_create"); /* Check that the heap has no elements */ num=H5HP_count(heap); @@ -434,19 +434,19 @@ test_heap_remove_min(void) ret=H5HP_remove(heap,&val,&ptr); CHECK(ret, FAIL, "H5HP_remove"); VERIFY(val, 5, "H5HP_remove"); - VERIFY(ptr, &obj2, "H5HP_remove"); + CHECK_PTR_EQ(ptr, &obj2, "H5HP_remove"); /* Remove second maximum value from heap */ ret=H5HP_remove(heap,&val,&ptr); CHECK(ret, FAIL, "H5HP_remove"); VERIFY(val, 10, "H5HP_remove"); - VERIFY(ptr, &obj1, "H5HP_remove"); + CHECK_PTR_EQ(ptr, &obj1, "H5HP_remove"); /* Remove third maximum value from heap */ ret=H5HP_remove(heap,&val,&ptr); CHECK(ret, FAIL, "H5HP_remove"); VERIFY(val, 20, "H5HP_remove"); - VERIFY(ptr, &obj3, "H5HP_remove"); + CHECK_PTR_EQ(ptr, &obj3, "H5HP_remove"); /* Try removing an object from an empty heap */ ret=H5HP_remove(heap,&val,&ptr); @@ -479,7 +479,7 @@ test_heap_remove_max(void) /* Create a Heap */ heap=H5HP_create(H5HP_MAX_HEAP); - CHECK(heap, NULL, "H5HP_create"); + CHECK_PTR(heap, "H5HP_create"); /* Check that the heap has no elements */ num=H5HP_count(heap); @@ -508,19 +508,19 @@ test_heap_remove_max(void) ret=H5HP_remove(heap,&val,&ptr); CHECK(ret, FAIL, "H5HP_remove"); VERIFY(val, 20, "H5HP_remove"); - VERIFY(ptr, &obj3, "H5HP_remove"); + CHECK_PTR_EQ(ptr, &obj3, "H5HP_remove"); /* Remove second maximum value from heap */ ret=H5HP_remove(heap,&val,&ptr); CHECK(ret, FAIL, "H5HP_remove"); VERIFY(val, 10, "H5HP_remove"); - VERIFY(ptr, &obj1, "H5HP_remove"); + CHECK_PTR_EQ(ptr, &obj1, "H5HP_remove"); /* Remove third maximum value from heap */ ret=H5HP_remove(heap,&val,&ptr); CHECK(ret, FAIL, "H5HP_remove"); VERIFY(val, 5, "H5HP_remove"); - VERIFY(ptr, &obj2, "H5HP_remove"); + CHECK_PTR_EQ(ptr, &obj2, "H5HP_remove"); /* Try removing an object from an empty heap */ ret=H5HP_remove(heap,&val,&ptr); @@ -567,7 +567,7 @@ static void test_heap_remove_many_core(H5HP_type_t heap_type, test_obj *arr, siz /* Create a Heap */ heap=H5HP_create(heap_type); - CHECK(heap, NULL, "H5HP_create"); + CHECK_PTR(heap, "H5HP_create"); /* Check that the heap has no elements */ num=H5HP_count(heap); @@ -714,7 +714,7 @@ test_heap_change_min(void) /* Create a Heap */ heap=H5HP_create(H5HP_MIN_HEAP); - CHECK(heap, NULL, "H5HP_create"); + CHECK_PTR(heap, "H5HP_create"); /* Check that the heap has no elements */ num=H5HP_count(heap); @@ -788,7 +788,7 @@ test_heap_change_max(void) /* Create a Heap */ heap=H5HP_create(H5HP_MAX_HEAP); - CHECK(heap, NULL, "H5HP_create"); + CHECK_PTR(heap, "H5HP_create"); /* Check that the heap has no elements */ num=H5HP_count(heap); @@ -880,7 +880,7 @@ test_heap_incdec_min(void) /* Create a Heap */ heap=H5HP_create(H5HP_MIN_HEAP); - CHECK(heap, NULL, "H5HP_create"); + CHECK_PTR(heap, "H5HP_create"); /* Check that the heap has no elements */ num=H5HP_count(heap); @@ -955,7 +955,7 @@ test_heap_incdec_max(void) /* Create a Heap */ heap=H5HP_create(H5HP_MAX_HEAP); - CHECK(heap, NULL, "H5HP_create"); + CHECK_PTR(heap, "H5HP_create"); /* Check that the heap has no elements */ num=H5HP_count(heap); @@ -16,223 +16,225 @@ #include "testhdf5.h" #include "hdf5.h" - /* Include H5Ipkg.h to calculate max number of groups */ +/* Include H5Ipkg.h to calculate max number of groups */ #define H5I_FRIEND /*suppress error about including H5Ipkg */ #include "H5Ipkg.h" - /* Test basic functionality of registering and deleting types and IDs */ +/* Test basic functionality of registering and deleting types and IDs */ static int basic_id_test(void) { - H5I_type_t myType = H5I_BADID; - hid_t arrayID = H5I_INVALID_HID; - void* testObj = NULL; - void* testPtr = NULL; - char nameString[10]; - hid_t testID; - ssize_t testSize = -1; - herr_t err; - int num_ref; - hsize_t num_members; - + H5I_type_t myType = H5I_BADID; + hid_t arrayID = H5I_INVALID_HID; + void* testObj = NULL; + void* testPtr = NULL; + char nameString[10]; + hid_t testID; + ssize_t testSize = -1; + herr_t err; + int num_ref; + hsize_t num_members; + + + /* Try to register an ID with ficticious types */ + H5E_BEGIN_TRY + arrayID = H5Iregister((H5I_type_t) 420, testObj); + H5E_END_TRY - /* Try to register an ID with ficticious types */ - H5E_BEGIN_TRY - arrayID = H5Iregister((H5I_type_t) 420, testObj); - H5E_END_TRY + VERIFY(arrayID, H5I_INVALID_HID, "H5Iregister"); + if(arrayID != H5I_INVALID_HID) + goto out; - VERIFY(arrayID, H5I_INVALID_HID, "H5Iregister"); - if(arrayID != H5I_INVALID_HID) - goto out; + H5E_BEGIN_TRY + arrayID = H5Iregister((H5I_type_t) -1, testObj); + H5E_END_TRY - H5E_BEGIN_TRY - arrayID = H5Iregister((H5I_type_t) -1, testObj); - H5E_END_TRY + VERIFY(arrayID, H5I_INVALID_HID, "H5Iregister"); + if(arrayID != H5I_INVALID_HID) + goto out; - VERIFY(arrayID, H5I_INVALID_HID, "H5Iregister"); - if(arrayID != H5I_INVALID_HID) - goto out; + /* Try to access IDs with ficticious types */ + H5E_BEGIN_TRY + testPtr = H5Iobject_verify((hid_t)100, (H5I_type_t) 0); + H5E_END_TRY - /* Try to access IDs with ficticious types */ - H5E_BEGIN_TRY - testPtr = H5Iobject_verify((hid_t)100, (H5I_type_t) 0); - H5E_END_TRY + CHECK_PTR_NULL(testPtr, "H5Iobject_verify"); + if(testPtr != NULL) + goto out; - VERIFY(testPtr, NULL, "H5Iobject_verify"); - if(testPtr != NULL) - goto out; + H5E_BEGIN_TRY + testPtr = H5Iobject_verify((hid_t)700, (H5I_type_t) 700); + H5E_END_TRY - H5E_BEGIN_TRY - testPtr = H5Iobject_verify((hid_t)700, (H5I_type_t) 700); - H5E_END_TRY + CHECK_PTR_NULL(testPtr, "H5Iobject_verify"); + if(testPtr != NULL) + goto out; - VERIFY(testPtr, NULL, "H5Iobject_verify"); - if(testPtr != NULL) - goto out; + /* Register a type */ + myType = H5Iregister_type((size_t)64, 0, (H5I_free_t) free ); - /* Register a type */ - myType = H5Iregister_type((size_t)64, 0, (H5I_free_t) free ); + CHECK(myType, H5I_BADID, "H5Iregister_type"); + if(myType == H5I_BADID) + goto out; - CHECK(myType, H5I_BADID, "H5Iregister_type"); - if(myType == H5I_BADID) - goto out; + /* Register an ID and retrieve the object it points to. + * Once the ID has been registered, testObj will be freed when + * its ID type is destroyed. + */ + testObj = HDmalloc(7 * sizeof(int)); + arrayID = H5Iregister(myType, testObj); - /* Register an ID and retrieve the object it points to. - * Once the ID has been registered, testObj will be freed when - * its ID type is destroyed. */ - testObj = HDmalloc(7 * sizeof(int)); - arrayID = H5Iregister(myType, testObj); + CHECK(arrayID, H5I_INVALID_HID, "H5Iregister"); + if(arrayID == H5I_INVALID_HID) { + HDfree(testObj); + goto out; + } - CHECK(arrayID, H5I_INVALID_HID, "H5Iregister"); - if(arrayID == H5I_INVALID_HID) - { - HDfree(testObj); - goto out; - } + testPtr = (int *)H5Iobject_verify(arrayID, myType); - testPtr = (int *) H5Iobject_verify(arrayID, myType); + CHECK_PTR_EQ(testPtr, testObj, "H5Iobject_verify"); + if(testPtr != testObj) + goto out; - VERIFY(testPtr, testObj, "H5Iobject_verify"); - if(testPtr != testObj) - goto out; + /* Ensure that H5Iget_file_id and H5Iget_name() fail, since this + * is an hid_t for the wrong kind of object + */ + H5E_BEGIN_TRY + testID = H5Iget_file_id(arrayID); + H5E_END_TRY - /* Ensure that H5Iget_file_id and H5Iget_name() fail, since this - * is an hid_t for the wrong kind of object */ - H5E_BEGIN_TRY - testID = H5Iget_file_id(arrayID); - H5E_END_TRY + VERIFY(testID, H5I_INVALID_HID, "H5Iget_file_id"); + if(testID != H5I_INVALID_HID) + goto out; - VERIFY(testID, H5I_INVALID_HID, "H5Iget_file_id"); - if(testID != H5I_INVALID_HID) - goto out; + H5E_BEGIN_TRY + testSize = H5Iget_name(arrayID, nameString, (size_t)9); + H5E_END_TRY - H5E_BEGIN_TRY - testSize = H5Iget_name(arrayID, nameString, (size_t)9); - H5E_END_TRY + VERIFY(testSize, -1, "H5Iget_name"); + if(testSize != -1) + goto out; - VERIFY(testSize, -1, "H5Iget_name"); - if(testSize != -1) - goto out; + /* Make sure H5Iremove_verify catches objects of the wrong type */ + H5E_BEGIN_TRY + testPtr = (int*) H5Iremove_verify(arrayID, (H5I_type_t) 0); + H5E_END_TRY - /* Make sure H5Iremove_verify catches objects of the wrong type */ - H5E_BEGIN_TRY - testPtr = (int*) H5Iremove_verify(arrayID, (H5I_type_t) 0); - H5E_END_TRY + CHECK_PTR_NULL(testPtr, "H5Iremove_verify"); + if(testPtr != NULL) + goto out; - VERIFY(testPtr, NULL, "H5Iremove_verify"); - if(testPtr != NULL) - goto out; + H5E_BEGIN_TRY + testPtr = (int*) H5Iremove_verify(arrayID, (H5I_type_t) ((int) myType-1)); + H5E_END_TRY - H5E_BEGIN_TRY - testPtr = (int*) H5Iremove_verify(arrayID, (H5I_type_t) ((int) myType-1)); - H5E_END_TRY + CHECK_PTR_NULL(testPtr, "H5Iremove_verify"); + if(testPtr != NULL) + goto out; - VERIFY(testPtr, NULL, "H5Iremove_verify"); - if(testPtr != NULL) - goto out; + /* Remove an ID and make sure we can't access it */ + testPtr = (int*) H5Iremove_verify(arrayID, myType); - /* Remove an ID and make sure we can't access it */ - testPtr = (int*) H5Iremove_verify(arrayID, myType); + CHECK_PTR(testPtr, "H5Iremove_verify"); + if(testPtr == NULL) + goto out; - CHECK(testPtr, NULL, "H5Iremove_verify"); - if(testPtr == NULL) - goto out; + H5E_BEGIN_TRY + testPtr = (int*) H5Iobject_verify(arrayID, myType); + H5E_END_TRY - H5E_BEGIN_TRY - testPtr = (int*) H5Iobject_verify(arrayID, myType); - H5E_END_TRY + CHECK_PTR_NULL(testPtr, "H5Iobject_verify"); + if(testPtr != NULL) + goto out; - VERIFY(testPtr, NULL, "H5Iobject_verify"); - if(testPtr != NULL) - goto out; + /* Delete the type and make sure we can't access objects within it */ + arrayID = H5Iregister(myType, testObj); - /* Delete the type and make sure we can't access objects within it */ - arrayID = H5Iregister(myType, testObj); + err = H5Idestroy_type(myType); + VERIFY(err, 0, "H5Idestroy_type"); + if( err != 0) + goto out; + VERIFY(H5Itype_exists(myType), 0, "H5Itype_exists"); + if(H5Itype_exists(myType) != 0) + goto out; - err = H5Idestroy_type(myType); - VERIFY(err, 0, "H5Idestroy_type"); - if( err != 0) - goto out; - VERIFY(H5Itype_exists(myType), 0, "H5Itype_exists"); - if(H5Itype_exists(myType) != 0) + H5E_BEGIN_TRY + VERIFY(H5Inmembers(myType, NULL), -1, "H5Inmembers"); + if(H5Inmembers(myType, NULL) != -1) goto out; + H5E_END_TRY - H5E_BEGIN_TRY - VERIFY(H5Inmembers(myType, NULL), -1, "H5Inmembers"); - if(H5Inmembers(myType, NULL) != -1) - goto out; - H5E_END_TRY - - /* Register another type and another object in that type */ - myType = H5Iregister_type((size_t)64, 0, (H5I_free_t) free ); + /* Register another type and another object in that type */ + myType = H5Iregister_type((size_t)64, 0, (H5I_free_t) free ); - CHECK(myType, H5I_BADID, "H5Iregister_type"); - if(myType == H5I_BADID) - goto out; + CHECK(myType, H5I_BADID, "H5Iregister_type"); + if(myType == H5I_BADID) + goto out; - /* The memory that testObj pointed to should already have been - * freed when the previous type was destroyed. Allocate new - * memory for it. - */ - testObj = HDmalloc(7 * sizeof(int)); - arrayID = H5Iregister(myType, testObj); + /* The memory that testObj pointed to should already have been + * freed when the previous type was destroyed. Allocate new + * memory for it. + */ + testObj = HDmalloc(7 * sizeof(int)); + arrayID = H5Iregister(myType, testObj); - CHECK(arrayID, H5I_INVALID_HID, "H5Iregister"); - if(arrayID == H5I_INVALID_HID) - { - HDfree(testObj); - goto out; - } + CHECK(arrayID, H5I_INVALID_HID, "H5Iregister"); + if(arrayID == H5I_INVALID_HID) { + HDfree(testObj); + goto out; + } - err = H5Inmembers(myType, &num_members); - CHECK(err, -1, "H5Inmembers"); - if (err < 0) - goto out; - VERIFY(num_members, 1, "H5Inmembers"); - if(num_members != 1) - goto out; + err = H5Inmembers(myType, &num_members); + CHECK(err, -1, "H5Inmembers"); + if (err < 0) + goto out; + VERIFY(num_members, 1, "H5Inmembers"); + if(num_members != 1) + goto out; - /* Increment references to type and ensure that dec_type_ref - doesn't destroy the type */ - num_ref = H5Iinc_type_ref(myType); - VERIFY(num_ref, 2, "H5Iinc_type_ref"); - if( num_ref != 2) - goto out; - num_ref = H5Idec_type_ref(myType); - VERIFY(num_ref, 1, "H5Idec_type_ref"); - if(num_ref != 1) - goto out; - err = H5Inmembers(myType, &num_members); - CHECK(err, -1, "H5Inmembers"); - if (err < 0) - goto out; - VERIFY(num_members, 1, "H5Inmembers"); - if(num_members != 1) - goto out; + /* Increment references to type and ensure that dec_type_ref + * doesn't destroy the type + */ + num_ref = H5Iinc_type_ref(myType); + VERIFY(num_ref, 2, "H5Iinc_type_ref"); + if( num_ref != 2) + goto out; + num_ref = H5Idec_type_ref(myType); + VERIFY(num_ref, 1, "H5Idec_type_ref"); + if(num_ref != 1) + goto out; + err = H5Inmembers(myType, &num_members); + CHECK(err, -1, "H5Inmembers"); + if (err < 0) + goto out; + VERIFY(num_members, 1, "H5Inmembers"); + if(num_members != 1) + goto out; - /* This call to dec_type_ref should destroy the type */ - num_ref = H5Idec_type_ref(myType); - VERIFY(num_ref, 0, "H5Idec_type_ref"); - if(num_ref != 0) - goto out; - VERIFY(H5Itype_exists(myType), 0, "H5Itype_exists"); - if (H5Itype_exists(myType) != 0) - goto out; + /* This call to dec_type_ref should destroy the type */ + num_ref = H5Idec_type_ref(myType); + VERIFY(num_ref, 0, "H5Idec_type_ref"); + if(num_ref != 0) + goto out; + VERIFY(H5Itype_exists(myType), 0, "H5Itype_exists"); + if (H5Itype_exists(myType) != 0) + goto out; - H5E_BEGIN_TRY + H5E_BEGIN_TRY err = H5Inmembers(myType, &num_members); - if(err >= 0) - goto out; - H5E_END_TRY + if(err >= 0) + goto out; + H5E_END_TRY - return 0; + return 0; out: - /* Clean up type if it has been allocated and free memory used - * by testObj */ - if(myType >= 0) - H5Idestroy_type(myType); + /* Clean up type if it has been allocated and free memory used + * by testObj + */ + if(myType >= 0) + H5Idestroy_type(myType); - return -1; + return -1; } @@ -263,7 +265,7 @@ static int id_predefined_test(void ) testPtr = H5Isearch(H5I_GENPROP_LST, (H5I_search_func_t) test_search_func, testObj); H5E_END_TRY - VERIFY(testPtr, NULL, "H5Isearch"); + CHECK_PTR_NULL(testPtr, "H5Isearch"); if(testPtr != NULL) goto out; @@ -301,7 +303,7 @@ static int id_predefined_test(void ) testPtr = H5Iremove_verify(typeID, H5I_DATATYPE); H5E_END_TRY - VERIFY(testPtr, NULL, "H5Iremove_verify"); + CHECK_PTR_NULL(testPtr, "H5Iremove_verify"); if(testPtr != NULL) goto out; @@ -309,7 +311,7 @@ static int id_predefined_test(void ) testPtr = H5Iobject_verify(typeID, H5I_DATATYPE); H5E_END_TRY - VERIFY(testPtr, NULL, "H5Iobject_verify"); + CHECK_PTR_NULL(testPtr, "H5Iobject_verify"); if(testPtr != NULL) goto out; diff --git a/test/titerate.c b/test/titerate.c index aad62c9..231bd2e 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -159,7 +159,7 @@ test_iter_group(hid_t fapl, hbool_t new_format) /* Keep a copy of the dataset names around for later */ lnames[i] = HDstrdup(name); - CHECK(lnames[i], NULL, "strdup"); + CHECK_PTR(lnames[i], "strdup"); ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); @@ -170,13 +170,13 @@ test_iter_group(hid_t fapl, hbool_t new_format) CHECK(ret, FAIL, "H5Gcreate2"); lnames[NDATASETS] = HDstrdup("grp"); - CHECK(lnames[NDATASETS], NULL, "strdup"); + CHECK_PTR(lnames[NDATASETS], "strdup"); ret = H5Tcommit2(file, "dtype", datatype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(ret, FAIL, "H5Tcommit2"); lnames[NDATASETS + 1] = HDstrdup("dtype"); - CHECK(lnames[NDATASETS], NULL, "strdup"); + CHECK_PTR(lnames[NDATASETS], "strdup"); /* Close everything up */ ret = H5Tclose(datatype); @@ -412,7 +412,7 @@ static void test_iter_attr(hid_t fapl, hbool_t new_format) /* Keep a copy of the attribute names around for later */ anames[i] = HDstrdup(name); - CHECK(anames[i], NULL, "strdup"); + CHECK_PTR(anames[i], "strdup"); ret = H5Aclose(attribute); CHECK(ret, FAIL, "H5Aclose"); @@ -596,7 +596,7 @@ test_iter_group_large(hid_t fapl) /* Allocate & initialize array */ names = (iter_info *)HDcalloc(sizeof(iter_info), (ITER_NGROUPS + 2)); - CHECK(names, NULL, "HDcalloc"); + CHECK_PTR(names, "HDcalloc"); /* Output message about test being performed */ MESSAGE(5, ("Testing Large Group Iteration Functionality\n")); @@ -733,7 +733,7 @@ static void test_grp_memb_funcs(hid_t fapl) /* Keep a copy of the dataset names around for later */ dnames[i] = HDstrdup(name); - CHECK(dnames[i], NULL, "strdup"); + CHECK_PTR(dnames[i], "strdup"); ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); @@ -744,13 +744,13 @@ static void test_grp_memb_funcs(hid_t fapl) CHECK(ret, FAIL, "H5Gcreate2"); dnames[NDATASETS] = HDstrdup("grp"); - CHECK(dnames[NDATASETS], NULL, "strdup"); + CHECK_PTR(dnames[NDATASETS], "strdup"); ret = H5Tcommit2(file, "dtype", datatype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(ret, FAIL, "H5Tcommit2"); dnames[NDATASETS + 1] = HDstrdup("dtype"); - CHECK(dnames[NDATASETS], NULL, "strdup"); + CHECK_PTR(dnames[NDATASETS], "strdup"); /* Close everything up */ ret = H5Tclose(datatype); @@ -797,7 +797,7 @@ static void test_grp_memb_funcs(hid_t fapl) /* Keep a copy of the dataset names around for later */ obj_names[i] = HDstrdup(dataset_name); - CHECK(obj_names[i], NULL, "strdup"); + CHECK_PTR(obj_names[i], "strdup"); ret = H5Oget_info_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_info_by_idx"); diff --git a/test/tmisc.c b/test/tmisc.c index 102325a..f0e595b 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -30,6 +30,7 @@ #include "testhdf5.h" #include "H5srcdir.h" #include "H5Dpkg.h" /* Datasets */ +#include "H5MMprivate.h" /* Memory */ /* Definitions for misc. test #1 */ #define MISC1_FILE "tmisc1.h5" @@ -722,7 +723,7 @@ create_struct3(void) herr_t ret; /* For error checking */ str3hndl = (misc5_struct3_hndl *)HDmalloc(sizeof(misc5_struct3_hndl)); - CHECK(str3hndl,NULL,"malloc"); + CHECK_PTR(str3hndl, "malloc"); str3hndl->st3h_base = H5Tcreate(H5T_COMPOUND, sizeof(misc5_struct3)); CHECK(str3hndl->st3h_base, FAIL, "H5Tcreate"); @@ -765,7 +766,7 @@ create_struct2(void) herr_t ret; /* For error checking */ str2hndl = (misc5_struct2_hndl *)HDmalloc(sizeof(misc5_struct2_hndl)); - CHECK(str2hndl, NULL, "malloc"); + CHECK_PTR(str2hndl, "HDmalloc"); str2hndl->st2h_base = H5Tcreate(H5T_COMPOUND, sizeof(misc5_struct2)); CHECK(str2hndl->st2h_base, FAIL, "H5Tcreate"); @@ -774,7 +775,7 @@ create_struct2(void) CHECK(ret, FAIL, "H5Tinsert"); str2hndl->st2h_st3hndl = create_struct3(); - CHECK(str2hndl->st2h_st3hndl,NULL,"create_struct3"); + CHECK_PTR(str2hndl->st2h_st3hndl, "create_struct3"); ret = H5Tinsert(str2hndl->st2h_base, "st2_el2", HOFFSET(misc5_struct2, st2_el2), str2hndl->st2h_st3hndl->st3h_id); CHECK(ret,FAIL,"H5Tinsert"); @@ -810,7 +811,7 @@ set_struct2(misc5_struct2 *buf) buf->st2_el2.len = MISC5_DBGNELM3; buf->st2_el2.p = HDmalloc((buf->st2_el2.len)*sizeof(misc5_struct3)); - CHECK(buf->st2_el2.p,NULL,"malloc"); + CHECK_PTR(buf->st2_el2.p, "HDmalloc"); for(i=0; i<(buf->st2_el2.len); i++) set_struct3(&(((misc5_struct3 *)(buf->st2_el2.p))[i])); @@ -831,7 +832,7 @@ create_struct1(void) herr_t ret; /* For error checking */ str1hndl = (misc5_struct1_hndl *)HDmalloc(sizeof(misc5_struct1_hndl)); - CHECK(str1hndl, NULL, "malloc"); + CHECK_PTR(str1hndl, "HDmalloc"); str1hndl->st1h_base = H5Tcreate(H5T_COMPOUND, sizeof(misc5_struct1)); CHECK(str1hndl->st1h_base, FAIL, "H5Tcreate"); @@ -840,7 +841,7 @@ create_struct1(void) CHECK(ret, FAIL, "H5Tinsert"); str1hndl->st1h_st2hndl=create_struct2(); - CHECK(str1hndl->st1h_st2hndl,NULL,"create_struct2"); + CHECK_PTR(str1hndl->st1h_st2hndl, "create_struct2"); ret = H5Tinsert(str1hndl->st1h_base, "st1_el2", HOFFSET(misc5_struct1, st1_el2), str1hndl->st1h_st2hndl->st2h_id); CHECK(ret,FAIL,"H5Tinsert"); @@ -876,7 +877,7 @@ set_struct1(misc5_struct1 *buf) buf->st1_el2.len=MISC5_DBGNELM2; buf->st1_el2.p=HDmalloc((buf->st1_el2.len)*sizeof(misc5_struct2)); - CHECK(buf->st1_el2.p,NULL,"malloc"); + CHECK_PTR(buf->st1_el2.p, "HDmalloc"); for(i=0; i<(buf->st1_el2.len); i++) set_struct2(&(((misc5_struct2 *)(buf->st1_el2.p))[i])); @@ -912,7 +913,7 @@ test_misc5(void) /* Create the memory structure to write */ str1hndl = create_struct1(); - CHECK(str1hndl, NULL, "create_struct1"); + CHECK_PTR(str1hndl, "create_struct1"); /* Create the dataspace */ dims[0] = MISC5_NELMTOPLVL; @@ -926,7 +927,7 @@ test_misc5(void) /* Create the variable-length buffer */ buf.len = MISC5_DBGNELM1; buf.p = HDmalloc((buf.len) * sizeof(misc5_struct1)); - CHECK(buf.p, NULL, "malloc"); + CHECK_PTR(buf.p, "HDmalloc"); /* Create the top-level VL information */ for(i = 0; i < MISC5_DBGNELM1; i++) @@ -1252,10 +1253,10 @@ test_misc8(void) /* Allocate space for the data to write & read */ wdata = (int *)HDmalloc(sizeof(int) * MISC8_DIM0 * MISC8_DIM1); - CHECK(wdata,NULL,"malloc"); + CHECK_PTR(wdata, "HDmalloc"); #ifdef VERIFY_DATA rdata = (int *)HDmalloc(sizeof(int) * MISC8_DIM0 * MISC8_DIM1); - CHECK(rdata,NULL,"malloc"); + CHECK_PTR(rdata, "HDmalloc"); #endif /* VERIFY_DATA */ /* Initialize values */ @@ -2143,7 +2144,7 @@ misc13_verify_dataset(hid_t loc_id, const char *name, const unsigned *data) /* Create a data buffer for the dataset read */ read_data = (unsigned *)HDcalloc(MISC13_DIM1, sizeof(unsigned)); - CHECK(read_data, NULL, "HDcalloc"); + CHECK_PTR(read_data, "HDcalloc"); /* Open the contiguous dataset in the root group */ dsid = H5Dopen2(loc_id, name, H5P_DEFAULT); @@ -2269,14 +2270,14 @@ misc13_insert_user_block(const char *old_name, const char *new_name, const char /* Allocate space for the user block */ user_block = HDcalloc(size, (size_t)1); - CHECK(user_block, NULL, "HDcalloc"); + CHECK_PTR(user_block, "HDcalloc"); /* Copy in the user block data */ HDmemcpy(user_block, str, strlen(str)); /* Open the new file */ new_fp = HDfopen(new_name,"wb"); - CHECK(new_fp, NULL, "HDfopen"); + CHECK_PTR(new_fp, "HDfopen"); /* Write the user block to the new file */ written = HDfwrite(user_block, (size_t)1, size, new_fp); @@ -2284,11 +2285,11 @@ misc13_insert_user_block(const char *old_name, const char *new_name, const char /* Open the old file */ old_fp = HDfopen(old_name,"rb"); - CHECK(old_fp, NULL, "HDfopen"); + CHECK_PTR(old_fp, "HDfopen"); /* Allocate space for the copy buffer */ copy_buf = HDmalloc((size_t)MISC13_COPY_BUF_SIZE); - CHECK(copy_buf, NULL, "HDmalloc"); + CHECK_PTR(copy_buf, "HDmalloc"); /* Copy data from the old file to the new file */ while((read_in = HDfread(copy_buf, (size_t)1, (size_t)MISC13_COPY_BUF_SIZE, old_fp)) > 0) { @@ -2438,7 +2439,7 @@ test_misc13(void) /* Create a data buffer for the datasets */ data = (unsigned *)HDcalloc(MISC13_DIM1, sizeof(unsigned)); - CHECK(data, NULL, "HDcalloc"); + CHECK_PTR(data, "HDcalloc"); /* Initialize data to write */ misc13_init_data(data); @@ -3445,7 +3446,7 @@ test_misc19(void) /* Get a VFD class to register */ vfd_cls = h5_get_dummy_vfd_class(); - CHECK(vfd_cls, NULL, "h5_get_dummy_vfd_class"); + CHECK_PTR(vfd_cls, "h5_get_dummy_vfd_class"); /* Register a virtual file driver */ vfdid = H5FDregister(vfd_cls); @@ -5526,6 +5527,64 @@ test_misc33(void) } /* end test_misc33() */ +/**************************************************************** +** +** test_misc34(): Ensure zero-size memory allocations work +** +****************************************************************/ +static void +test_misc34(void) +{ + void *mem = NULL; /* allocated buffer */ + char *dup = NULL; /* 'duplicated' string */ + size_t sz = 0; /* buffer size */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing O and NULL behavior in H5MM API calls")); + + /* H5MM_xfree(): Ensure that passing NULL is allowed and returns NULL */ + mem = H5MM_xfree(mem); + CHECK_PTR_NULL(mem, "H5MM_xfree"); + + /* H5MM_malloc(): Ensure that size 0 returns NULL */ + mem = H5MM_malloc(sz); + CHECK_PTR_NULL(mem, "H5MM_malloc"); + mem = H5MM_xfree(mem); + + /* H5MM_calloc(): Ensure that size 0 returns NULL */ + mem = H5MM_calloc(sz); + CHECK_PTR_NULL(mem, "H5MM_calloc"); + mem = H5MM_xfree(mem); + + /* H5MM_realloc(): Check behavior: + * + * H5MM_realloc(NULL, size) <==> H5MM_malloc(size) + * H5MM_realloc(ptr, 0) <==> H5MM_xfree(ptr) + * H5MM_realloc(NULL, 0) <==> NULL + */ + mem = H5MM_xfree(mem); + + sz = 1024; + mem = H5MM_realloc(mem, sz); + CHECK_PTR(mem, "H5MM_realloc (case 1)"); + /* Don't free mem here! */ + + sz = 0; + mem = H5MM_realloc(mem, sz); + CHECK_PTR_NULL(mem, "H5MM_realloc (case 2)"); + mem = H5MM_xfree(mem); + + mem = H5MM_realloc(mem, sz); + CHECK_PTR_NULL(mem, "H5MM_realloc (case 3)"); + mem = H5MM_xfree(mem); + + /* H5MM_xstrdup(): Ensure NULL returns NULL */ + dup = H5MM_xstrdup((const char *)mem); + CHECK_PTR_NULL(dup, "H5MM_xstrdup"); + dup = (char *)H5MM_xfree((void *)dup); + +} /* end test_misc34() */ + /**************************************************************** ** @@ -5575,6 +5634,7 @@ test_misc(void) test_misc31(); /* Test Reentering library through deprecated routines after H5close() */ test_misc32(); /* Test filter memory allocation functions */ test_misc33(); /* Test to verify that H5HL_offset_into() returns error if offset exceeds heap block */ + test_misc34(); /* Test behavior of 0 and NULL in H5MM API calls */ } /* test_misc() */ @@ -5632,5 +5692,5 @@ cleanup_misc(void) HDremove(MISC29_COPY_FILE); HDremove(MISC30_FILE); HDremove(MISC31_FILE); -} +} /* end cleanup_misc() */ diff --git a/test/trefstr.c b/test/trefstr.c index 40ce344..83e2951 100644 --- a/test/trefstr.c +++ b/test/trefstr.c @@ -67,7 +67,7 @@ test_refstr_create(void) /* Try creating a ref-counted string */ rs=H5RS_create("foo"); - CHECK(rs, NULL, "H5RS_create"); + CHECK_PTR(rs, "H5RS_create"); /* Get the reference count on the string */ count=H5RS_get_count(rs); @@ -97,7 +97,7 @@ test_refstr_count(void) /* Try creating a ref-counted string */ rs=H5RS_create("foo"); - CHECK(rs, NULL, "H5RS_create"); + CHECK_PTR(rs, "H5RS_create"); /* Get the reference count on the string */ count=H5RS_get_count(rs); @@ -144,7 +144,7 @@ test_refstr_dup(void) /* Try creating a ref-counted string */ rs1=H5RS_create("foo"); - CHECK(rs1, NULL, "H5RS_create"); + CHECK_PTR(rs1, "H5RS_create"); /* Get the reference count on the string */ count=H5RS_get_count(rs1); @@ -152,7 +152,7 @@ test_refstr_dup(void) /* Duplicate r-string */ rs2=H5RS_dup(rs1); - CHECK(rs2, NULL, "H5RS_dup"); + CHECK_PTR(rs2, "H5RS_dup"); /* Get the reference count on the strings */ count=H5RS_get_count(rs1); @@ -194,11 +194,11 @@ test_refstr_cmp(void) /* Create first reference counted string */ rs1=H5RS_create("foo"); - CHECK(rs1, NULL, "H5RS_create"); + CHECK_PTR(rs1, "H5RS_create"); /* Create second reference counted string */ rs2=H5RS_create("foo2"); - CHECK(rs2, NULL, "H5RS_create"); + CHECK_PTR(rs2, "H5RS_create"); /* Compare the strings in various ways */ cmp=H5RS_cmp(rs1,rs1); @@ -246,12 +246,12 @@ test_refstr_wrap(void) /* Wrap ref-counted string around existing buffer */ rs=H5RS_wrap(buf); - CHECK(rs, NULL, "H5RS_wrap"); + CHECK_PTR(rs, "H5RS_wrap"); /* Get pointer to raw string in ref-counted string */ s=H5RS_get_str(rs); - CHECK(s, NULL, "H5RS_get_str"); - VERIFY(s, buf, "wrapping"); + CHECK_PTR(s, "H5RS_get_str"); + CHECK_PTR_EQ(s, buf, "wrapping"); cmp=HDstrcmp(s,buf); VERIFY(cmp, 0, "HDstrcmp"); @@ -264,7 +264,7 @@ test_refstr_wrap(void) /* Get pointer to raw string in ref-counted string */ s=H5RS_get_str(rs); - CHECK(s, NULL, "H5RS_get_str"); + CHECK_PTR(s, "H5RS_get_str"); CHECK(s, buf, "wrapping"); cmp=HDstrcmp(s,buf); if(cmp<=0) @@ -299,17 +299,17 @@ test_refstr_own(void) /* Initialize buffer */ s = (char *)H5FL_BLK_MALLOC(str_buf,HDstrlen("foo") + 1); - CHECK(s, NULL, "H5FL_BLK_MALLOC"); + CHECK_PTR(s, "H5FL_BLK_MALLOC"); HDstrcpy(s, "foo"); /* Transfer ownership of dynamically allocated string to ref-counted string */ rs=H5RS_own(s); - CHECK(rs, NULL, "H5RS_own"); + CHECK_PTR(rs, "H5RS_own"); /* Get pointer to raw string in ref-counted string */ t=H5RS_get_str(rs); - CHECK(t, NULL, "H5RS_get_str"); - VERIFY(t, s, "transferring"); + CHECK_PTR(t, "H5RS_get_str"); + CHECK_PTR_EQ(t, s, "transferring"); cmp=HDstrcmp(s,t); VERIFY(cmp, 0, "HDstrcmp"); @@ -322,8 +322,8 @@ test_refstr_own(void) /* Get pointer to raw string in ref-counted string */ t=H5RS_get_str(rs); - CHECK(t, NULL, "H5RS_get_str"); - VERIFY(t, s, "transferring"); + CHECK_PTR(t, "H5RS_get_str"); + CHECK_PTR_EQ(t, s, "transferring"); cmp=HDstrcmp(t,s); VERIFY(cmp, 0, "HDstrcmp"); diff --git a/test/tselect.c b/test/tselect.c index 85c21bb..2022a11 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -228,9 +228,9 @@ test_select_hyper(hid_t xfer_plist) /* Allocate write & read buffers */ wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++) @@ -432,9 +432,9 @@ test_select_point(hid_t xfer_plist) /* Allocate write & read buffers */ wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++) @@ -710,9 +710,9 @@ test_select_all(hid_t xfer_plist) /* Allocate write & read buffers */ wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE4_DIM1 * SPACE4_DIM2 * SPACE4_DIM3); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE4_DIM1 * SPACE4_DIM2 * SPACE4_DIM3)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE4_DIM1; i++) @@ -797,9 +797,9 @@ test_select_all_hyper(hid_t xfer_plist) /* Allocate write & read buffers */ wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++) @@ -939,9 +939,9 @@ test_select_combo(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++) @@ -1106,9 +1106,9 @@ test_select_hyper_stride(hid_t xfer_plist) /* Allocate write & read buffers */ wbuf = (uint16_t *)HDmalloc(sizeof(uint16_t) * SPACE2_DIM1 * SPACE2_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint16_t *)HDcalloc(sizeof(uint16_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++) @@ -1234,9 +1234,9 @@ test_select_hyper_contig(hid_t dset_type, hid_t xfer_plist) /* Allocate write & read buffers */ wbuf = (uint16_t *)HDmalloc(sizeof(uint16_t) * SPACE2_DIM1 * SPACE2_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint16_t *)HDcalloc(sizeof(uint16_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++) @@ -1364,9 +1364,9 @@ test_select_hyper_contig2(hid_t dset_type, hid_t xfer_plist) /* Allocate write & read buffers */ wbuf = (uint16_t *)HDmalloc(sizeof(uint16_t) * SPACE8_DIM1 * SPACE8_DIM2 * SPACE8_DIM3 * SPACE8_DIM4); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint16_t *)HDcalloc(sizeof(uint16_t), (size_t)(SPACE8_DIM1 * SPACE8_DIM2 * SPACE8_DIM3 * SPACE8_DIM4)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE8_DIM1; i++) @@ -1491,9 +1491,9 @@ test_select_hyper_contig3(hid_t dset_type, hid_t xfer_plist) /* Allocate write & read buffers */ wbuf = (uint16_t *)HDmalloc(sizeof(uint16_t) * SPACE8_DIM1 * SPACE8_DIM2 * SPACE8_DIM3 * SPACE8_DIM4); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint16_t *)HDcalloc(sizeof(uint16_t), (size_t)(SPACE8_DIM1 * SPACE8_DIM2 * SPACE8_DIM3 * SPACE8_DIM4)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE8_DIM4; i++) @@ -1735,9 +1735,9 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, /* Allocate buffers */ small_cube_buf_1 = (uint16_t *)HDcalloc(sizeof(uint16_t), small_cube_size); - CHECK(small_cube_buf_1, NULL, "HDcalloc"); + CHECK_PTR(small_cube_buf_1, "HDcalloc"); large_cube_buf_1 = (uint16_t *)HDcalloc(sizeof(uint16_t), large_cube_size); - CHECK(large_cube_buf_1, NULL, "HDcalloc"); + CHECK_PTR(large_cube_buf_1, "HDcalloc"); /* Create a dataset transfer property list */ fapl = H5Pcreate(H5P_FILE_ACCESS); @@ -2342,7 +2342,7 @@ test_select_hyper_contig_dr(hid_t dset_type, hid_t xfer_plist) /* Allocate cube buffer for writing values */ cube_buf = (uint16_t *)HDmalloc(sizeof(uint16_t) * max_cube_size); - CHECK(cube_buf, NULL, "HDmalloc"); + CHECK_PTR(cube_buf, "HDmalloc"); /* Initialize the cube buffer */ cube_ptr = cube_buf; @@ -2351,7 +2351,7 @@ test_select_hyper_contig_dr(hid_t dset_type, hid_t xfer_plist) /* Allocate cube buffer for zeroing values on disk */ zero_buf = (uint16_t *)HDcalloc(sizeof(uint16_t), max_cube_size); - CHECK(zero_buf, NULL, "HDcalloc"); + CHECK_PTR(zero_buf, "HDcalloc"); for(large_rank = 1; large_rank <= max_rank; large_rank++) { for(small_rank = 1; small_rank < large_rank; small_rank++) { @@ -2811,9 +2811,9 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ /* Allocate & initialize buffers */ small_cube_buf_1 = (uint16_t *)HDcalloc(sizeof(uint16_t), small_cube_size); - CHECK(small_cube_buf_1, NULL, "HDcalloc"); + CHECK_PTR(small_cube_buf_1, "HDcalloc"); large_cube_buf_1 = (uint16_t *)HDcalloc(sizeof(uint16_t), large_cube_size); - CHECK(large_cube_buf_1, NULL, "HDcalloc"); + CHECK_PTR(large_cube_buf_1, "HDcalloc"); /* Create a dataset transfer property list */ @@ -3574,7 +3574,7 @@ test_select_hyper_checker_board_dr(hid_t dset_type, hid_t xfer_plist) /* Allocate cube buffer for writing values */ cube_buf = (uint16_t *)HDmalloc(sizeof(uint16_t) * max_cube_size); - CHECK(cube_buf, NULL, "HDmalloc"); + CHECK_PTR(cube_buf, "HDmalloc"); /* Initialize the cube buffer */ cube_ptr = cube_buf; @@ -3583,7 +3583,7 @@ test_select_hyper_checker_board_dr(hid_t dset_type, hid_t xfer_plist) /* Allocate cube buffer for zeroing values on disk */ zero_buf = (uint16_t *)HDcalloc(sizeof(uint16_t), max_cube_size); - CHECK(zero_buf, NULL, "HDcalloc"); + CHECK_PTR(zero_buf, "HDcalloc"); for(large_rank = 1; large_rank <= max_rank; large_rank++) { for(small_rank = 1; small_rank < large_rank; small_rank++) { @@ -3651,11 +3651,11 @@ test_select_hyper_copy(void) /* Allocate write & read buffers */ wbuf = (uint16_t *)HDmalloc(sizeof(uint16_t) * SPACE2_DIM1 * SPACE2_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint16_t *)HDcalloc(sizeof(uint16_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); rbuf2 = (uint16_t *)HDcalloc(sizeof(uint16_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); - CHECK(rbuf2, NULL, "HDcalloc"); + CHECK_PTR(rbuf2, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++) @@ -3813,11 +3813,11 @@ test_select_point_copy(void) /* Allocate write & read buffers */ wbuf = (uint16_t *)HDmalloc(sizeof(uint16_t) * SPACE2_DIM1 * SPACE2_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint16_t *)HDcalloc(sizeof(uint16_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); rbuf2 = (uint16_t *)HDcalloc(sizeof(uint16_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); - CHECK(rbuf2, NULL, "HDcalloc"); + CHECK_PTR(rbuf2, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++) @@ -3991,9 +3991,9 @@ test_select_hyper_offset(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++) @@ -4149,9 +4149,9 @@ test_select_hyper_offset2(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE7_DIM1 * SPACE7_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE7_DIM1 * SPACE7_DIM2)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++) @@ -4272,9 +4272,9 @@ test_select_point_offset(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++) @@ -4452,9 +4452,9 @@ test_select_hyper_union(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++) @@ -5319,9 +5319,9 @@ test_select_hyper_and_2d(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++) @@ -5448,9 +5448,9 @@ test_select_hyper_xor_2d(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++) @@ -5579,9 +5579,9 @@ test_select_hyper_notb_2d(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++) @@ -5709,9 +5709,9 @@ test_select_hyper_nota_2d(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++) @@ -5869,9 +5869,9 @@ test_select_hyper_union_random_5d(hid_t read_plist) /* Allocate write & read buffers */ wbuf = (int *)HDmalloc(sizeof(int) * SPACE5_DIM1 * SPACE5_DIM2 * SPACE5_DIM3 * SPACE5_DIM4 * SPACE5_DIM5); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (int *)HDcalloc(sizeof(int), (size_t)(SPACE5_DIM1 * SPACE5_DIM2 * SPACE5_DIM3 * SPACE5_DIM4 * SPACE5_DIM5)); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE5_DIM1; i++) @@ -6061,9 +6061,9 @@ test_select_hyper_chunk(hid_t fapl_plist, hid_t xfer_plist) /* Allocate the transfer buffers */ data = (short *)HDmalloc(sizeof(short) * X * Y * Z); - CHECK(data, NULL, "HDmalloc"); + CHECK_PTR(data, "HDmalloc"); data_out = (short *)HDcalloc((size_t)(NX * NY * NZ), sizeof(short)); - CHECK(data_out, NULL, "HDcalloc"); + CHECK_PTR(data_out, "HDcalloc"); /* * Data buffer initialization. @@ -6296,9 +6296,9 @@ test_select_point_chunk(void) /* Allocate the transfer buffers */ data = (unsigned *)HDmalloc(sizeof(unsigned) * SPACE7_DIM1 * SPACE7_DIM2); - CHECK(data, NULL, "HDmalloc"); + CHECK_PTR(data, "HDmalloc"); data_out = (unsigned *)HDcalloc((size_t)(SPACE7_DIM1 * SPACE7_DIM2), sizeof(unsigned)); - CHECK(data_out, NULL, "HDcalloc"); + CHECK_PTR(data_out, "HDcalloc"); /* * Data buffer initialization. @@ -7057,7 +7057,7 @@ test_select_fill_all(void) /* Allocate memory buffer */ wbuf = (unsigned *)HDmalloc(sizeof(unsigned) * SPACE7_DIM1 * SPACE7_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); /* Initialize memory buffer */ for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) @@ -7133,7 +7133,7 @@ test_select_fill_point(hssize_t *offset) /* Allocate memory buffer */ wbuf = (unsigned *)HDmalloc(sizeof(unsigned) * SPACE7_DIM1 * SPACE7_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); /* Initialize memory buffer */ for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) @@ -7230,7 +7230,7 @@ test_select_fill_hyper_simple(hssize_t *offset) /* Allocate memory buffer */ wbuf = (unsigned *)HDmalloc(sizeof(unsigned) * SPACE7_DIM1 * SPACE7_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); /* Initialize memory buffer */ for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) @@ -7337,7 +7337,7 @@ test_select_fill_hyper_regular(hssize_t *offset) /* Allocate memory buffer */ wbuf = (unsigned *)HDmalloc(sizeof(unsigned) * SPACE7_DIM1 * SPACE7_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); /* Initialize memory buffer */ for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) @@ -7456,7 +7456,7 @@ test_select_fill_hyper_irregular(hssize_t *offset) /* Allocate memory buffer */ wbuf = (unsigned *)HDmalloc(sizeof(unsigned) * SPACE7_DIM1 * SPACE7_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); /* Initialize memory buffer */ for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) @@ -7558,9 +7558,9 @@ test_select_none(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE7_DIM1 * SPACE7_DIM2); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), SPACE7_DIM1 * SPACE7_DIM2); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++) @@ -7661,9 +7661,9 @@ test_scalar_select(void) /* Allocate write & read buffers */ wbuf_uint8 = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE7_DIM1 * SPACE7_DIM2); - CHECK(wbuf_uint8, NULL, "HDmalloc"); + CHECK_PTR(wbuf_uint8, "HDmalloc"); wbuf_ushort = (unsigned short *)HDmalloc(sizeof(unsigned short) * SPACE7_DIM1 * SPACE7_DIM2); - CHECK(wbuf_ushort, NULL, "HDmalloc"); + CHECK_PTR(wbuf_ushort, "HDmalloc"); /* Initialize write buffers */ for(i=0, tbuf_uint8=wbuf_uint8, tbuf_ushort=wbuf_ushort; i<SPACE7_DIM1; i++) @@ -12581,9 +12581,9 @@ test_select_hyper_chunk_offset(void) /* Allocate buffers */ wbuf = (int *)HDmalloc(sizeof(int) * SPACE10_DIM1); - CHECK(wbuf, NULL, "HDmalloc"); + CHECK_PTR(wbuf, "HDmalloc"); rbuf = (int *)HDcalloc(sizeof(int), SPACE10_DIM1); - CHECK(rbuf, NULL, "HDcalloc"); + CHECK_PTR(rbuf, "HDcalloc"); /* Initialize the write buffer */ for(i=0; i<SPACE10_DIM1; i++) diff --git a/test/tskiplist.c b/test/tskiplist.c index b9b00df..2806afe 100644 --- a/test/tskiplist.c +++ b/test/tskiplist.c @@ -66,11 +66,11 @@ test_skiplist_init(void) /* Allocate arrays */ rand_num = (int *)HDmalloc(sizeof(int) * NUM_ELEMS); - CHECK(rand_num, NULL, "HDmalloc"); + CHECK_PTR(rand_num, "HDmalloc"); sort_rand_num = (int *)HDmalloc(sizeof(int) * NUM_ELEMS); - CHECK(sort_rand_num, NULL, "HDmalloc"); + CHECK_PTR(sort_rand_num, "HDmalloc"); rev_sort_rand_num = (int *)HDmalloc(sizeof(int) * NUM_ELEMS); - CHECK(rev_sort_rand_num, NULL, "HDmalloc"); + CHECK_PTR(rev_sort_rand_num, "HDmalloc"); /* Initialize random number seed */ curr_time = HDtime(NULL); @@ -125,7 +125,7 @@ test_skiplist_create(void) /* Try creating a skip list */ slist = H5SL_create(H5SL_TYPE_INT, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Try closing the skip list */ ret=H5SL_close(slist); @@ -155,7 +155,7 @@ test_skiplist_insert(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_INT, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Check that the skip list has no elements */ num=H5SL_count(slist); @@ -164,7 +164,7 @@ test_skiplist_insert(void) /* Try searching for item in empty skip list */ key=37; found_item=(int *)H5SL_search(slist,&key); - VERIFY(found_item, NULL, "H5SL_search"); + CHECK_PTR_NULL(found_item, "H5SL_search"); /* Insert an object into the skip list */ key=2; item=10; @@ -177,13 +177,13 @@ test_skiplist_insert(void) /* Search for the item just inserted */ found_item=(int *)H5SL_search(slist,&key); - CHECK(found_item, NULL, "H5SL_search"); - VERIFY(*found_item,item,"H5SL_search"); + CHECK_PTR(found_item, "H5SL_search"); + VERIFY(*found_item, item, "H5SL_search"); /* Search for an item not in list */ search_key=37; found_item=(int *)H5SL_search(slist,&search_key); - VERIFY(found_item, NULL, "H5SL_search"); + CHECK_PTR_NULL(found_item, "H5SL_search"); /* Attempt to insert duplicate key (should fail) */ search_key=2; @@ -216,7 +216,7 @@ test_skiplist_insert_many(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_INT, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Check that the skip list has no elements */ num=H5SL_count(slist); @@ -235,7 +235,7 @@ test_skiplist_insert_many(void) /* Search for all objects in the skip list */ for(u=0; u<NUM_ELEMS; u++) { found_item=(int *)H5SL_search(slist,&rand_num[u]); - CHECK(found_item, NULL, "H5SL_search"); + CHECK_PTR(found_item, "H5SL_search"); VERIFY(*found_item,rand_num[u],"H5SL_search"); } /* end for */ @@ -290,7 +290,7 @@ test_skiplist_remove(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_INT, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Check that the skip list has no elements */ num=H5SL_count(slist); @@ -299,7 +299,7 @@ test_skiplist_remove(void) /* Try removing an item in empty skip list */ search_key=37; found_item=(int *)H5SL_remove(slist,&search_key); - VERIFY(found_item, NULL, "H5SL_remove"); + CHECK_PTR_NULL(found_item, "H5SL_remove"); /* Insert three objects into the skip list */ key1=15; @@ -321,18 +321,18 @@ test_skiplist_remove(void) /* Try removing items from skip list */ search_key=key1; found_item=(int *)H5SL_remove(slist,&search_key); - CHECK(found_item, NULL, "H5SL_remove"); - VERIFY(found_item, &key1, "H5SL_remove"); + CHECK_PTR(found_item, "H5SL_remove"); + CHECK_PTR_EQ(found_item, &key1, "H5SL_remove"); search_key=key2; found_item=(int *)H5SL_remove(slist,&search_key); - CHECK(found_item, NULL, "H5SL_remove"); - VERIFY(found_item, &key2, "H5SL_remove"); + CHECK_PTR(found_item, "H5SL_remove"); + CHECK_PTR_EQ(found_item, &key2, "H5SL_remove"); search_key=key3; found_item=(int *)H5SL_remove(slist,&search_key); - CHECK(found_item, NULL, "H5SL_remove"); - VERIFY(found_item, &key3, "H5SL_remove"); + CHECK_PTR(found_item, "H5SL_remove"); + CHECK_PTR_EQ(found_item, &key3, "H5SL_remove"); /* Check that the skip list has no elements */ num=H5SL_count(slist); @@ -341,7 +341,7 @@ test_skiplist_remove(void) /* Try removing items from empty skip list (after its been worked on) */ search_key=key1; found_item=(int *)H5SL_remove(slist,&search_key); - VERIFY(found_item, NULL, "H5SL_remove"); + CHECK_PTR_NULL(found_item, "H5SL_remove"); /* Close the skip list */ ret=H5SL_close(slist); @@ -369,7 +369,7 @@ test_skiplist_remove_many(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_INT, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Check that the skip list has no elements */ num=H5SL_count(slist); @@ -388,7 +388,7 @@ test_skiplist_remove_many(void) /* Remove all objects from the skip list (in random order) */ for(u=0; u<NUM_ELEMS; u++) { found_item=(int *)H5SL_remove(slist,&rand_num[u]); - CHECK(found_item, NULL, "H5SL_remove"); + CHECK_PTR(found_item, "H5SL_remove"); VERIFY(*found_item,rand_num[u],"H5SL_remove"); } /* end for */ @@ -411,7 +411,7 @@ test_skiplist_remove_many(void) /* Remove all objects from the skip list */ for(u=0; u<NUM_ELEMS; u++) { found_item=(int *)H5SL_remove(slist,&sort_rand_num[u]); - CHECK(found_item, NULL, "H5SL_remove"); + CHECK_PTR(found_item, "H5SL_remove"); VERIFY(*found_item,sort_rand_num[u],"H5SL_remove"); } /* end for */ @@ -434,7 +434,7 @@ test_skiplist_remove_many(void) /* Remove all objects from the skip list */ for(u=0; u<NUM_ELEMS; u++) { found_item=(int *)H5SL_remove(slist,&rev_sort_rand_num[u]); - CHECK(found_item, NULL, "H5SL_remove"); + CHECK_PTR(found_item, "H5SL_remove"); VERIFY(*found_item,rev_sort_rand_num[u],"H5SL_remove"); } /* end for */ @@ -469,7 +469,7 @@ test_skiplist_firstnext(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_INT, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Check that the skip list has no elements */ num=H5SL_count(slist); @@ -477,7 +477,7 @@ test_skiplist_firstnext(void) VERIFY(num, 0, "H5SL_count"); /* Check that the list appears empty */ node=H5SL_first(slist); - VERIFY(node, NULL, "H5SL_first"); + CHECK_PTR_NULL(node, "H5SL_first"); /* Insert many objects into the skip list */ for(u=0; u<NUM_ELEMS; u++) { @@ -491,7 +491,7 @@ test_skiplist_firstnext(void) /* Iterate over all the nodes in the skip list */ node=H5SL_first(slist); - CHECK(node, NULL, "H5SL_first"); + CHECK_PTR(node, "H5SL_first"); u=0; while(node!=NULL) { found_item=(int *)H5SL_item(node); @@ -506,7 +506,7 @@ test_skiplist_firstnext(void) /* Check that the list appears empty again */ node=H5SL_first(slist); - VERIFY(node, NULL, "H5SL_first"); + CHECK_PTR_NULL(node, "H5SL_first"); /* Close the skip list */ ret=H5SL_close(slist); @@ -562,7 +562,7 @@ test_skiplist_string(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_STR, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Check that the skip list has no elements */ num=H5SL_count(slist); @@ -624,7 +624,7 @@ test_skiplist_iterate(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_INT, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Check that the skip list has no elements */ num=H5SL_count(slist); @@ -674,7 +674,7 @@ test_skiplist_hsize(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_HSIZE, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Check that the skip list has no elements */ num=H5SL_count(slist); @@ -729,7 +729,7 @@ test_skiplist_unsigned(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Check that the skip list has no elements */ num=H5SL_count(slist); @@ -784,7 +784,7 @@ test_skiplist_obj(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_OBJ, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Check that the skip list has no elements */ num=H5SL_count(slist); @@ -862,7 +862,7 @@ test_skiplist_generic(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_GENERIC, test_skiplist_generic_cmp); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Check that the skip list has no elements */ num=H5SL_count(slist); @@ -916,7 +916,7 @@ test_skiplist_lastprev(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_INT, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Check that the skip list has no elements */ num=H5SL_count(slist); @@ -924,7 +924,7 @@ test_skiplist_lastprev(void) /* Check that the list appears empty */ node=H5SL_last(slist); - VERIFY(node, NULL, "H5SL_last"); + CHECK_PTR_NULL(node, "H5SL_last"); /* Insert many objects into the skip list */ for(u=0; u<NUM_ELEMS; u++) { @@ -938,7 +938,7 @@ test_skiplist_lastprev(void) /* Iterate over all the nodes in the skip list */ node=H5SL_last(slist); - CHECK(node, NULL, "H5SL_last"); + CHECK_PTR(node, "H5SL_last"); u=NUM_ELEMS-1; while(node!=NULL) { found_item=(int *)H5SL_item(node); @@ -953,7 +953,7 @@ test_skiplist_lastprev(void) /* Check that the list appears empty again */ node=H5SL_last(slist); - VERIFY(node, NULL, "H5SL_last"); + CHECK_PTR_NULL(node, "H5SL_last"); /* Close the skip list */ ret=H5SL_close(slist); @@ -984,7 +984,7 @@ test_skiplist_find(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Insert objects into the skip list */ for(u=0; u<10; u++) { @@ -995,7 +995,7 @@ test_skiplist_find(void) /* Find the element with key==30 in the skip list */ find_item=30; node=H5SL_find(slist,&find_item); - CHECK(node, NULL, "H5SL_find"); + CHECK_PTR(node, "H5SL_find"); /* Iterate over the rest of the nodes in the skip list */ u=4; @@ -1009,7 +1009,7 @@ test_skiplist_find(void) /* Check for trying to locate non-existent item */ find_item=81; node=H5SL_find(slist,&find_item); - VERIFY(node, NULL, "H5SL_find"); + CHECK_PTR_NULL(node, "H5SL_find"); /* Close the skip list */ ret=H5SL_close(slist); @@ -1040,7 +1040,7 @@ test_skiplist_add(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Insert objects into the skip list */ for(u=0; u<10; u++) { @@ -1051,11 +1051,11 @@ test_skiplist_add(void) /* Add the element with key==12 in the skip list */ new_item=12; node=H5SL_add(slist,&new_item,&new_item); - CHECK(node, NULL, "H5SL_add"); + CHECK_PTR(node, "H5SL_add"); /* Advance to next node in list */ node=H5SL_next(node); - CHECK(node, NULL, "H5SL_next"); + CHECK_PTR(node, "H5SL_next"); /* Iterate over the rest of the nodes in the skip list */ u=2; @@ -1102,7 +1102,7 @@ test_skiplist_destroy(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_INT, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Insert objects into the skip list */ for(u=0; u<NUM_ELEMS; u++) { @@ -1138,7 +1138,7 @@ test_skiplist_free(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_INT, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Insert objects into the skip list */ for(u=0; u<NUM_ELEMS; u++) { @@ -1210,8 +1210,8 @@ static herr_t test_tfs_iter(void *_obj, void *key, void *_udata) { test_tfs_it_ud_t *udata = (test_tfs_it_ud_t *)_udata; /* Check consistency */ - VERIFY((void *)&obj->idx, key, "obj->idx"); - VERIFY(obj, &udata->obj_list->list[obj->idx], "obj_list->list[obj->idx]"); + CHECK_PTR_EQ((void *)&obj->idx, key, "obj->idx"); + CHECK_PTR_EQ(obj, &udata->obj_list->list[obj->idx], "obj_list->list[obj->idx]"); /* Increment number of calls */ udata->ncalls++; @@ -1236,8 +1236,8 @@ static htri_t test_tfs_free(void *_obj, void *key, void *_obj_list) { htri_t ret_value; /* Check consistency */ - VERIFY((void *)&obj->idx, key, "obj->idx"); - VERIFY(obj, &obj_list->list[obj->idx], "obj_list->list[obj->idx]"); + CHECK_PTR_EQ((void *)&obj->idx, key, "obj->idx"); + CHECK_PTR_EQ(obj, &obj_list->list[obj->idx], "obj_list->list[obj->idx]"); /* Mark this object as freed (to make sure it isn't recursively freed, that * is not something we support, we will undo this if we decide later not to @@ -1269,7 +1269,7 @@ static htri_t test_tfs_free(void *_obj, void *key, void *_obj_list) { else { /* Remove the object */ obj_ret = (test_tfs_obj_t *)H5SL_remove(obj_list->slist, &j); - CHECK(obj_ret, NULL, "H5SL_remove"); + CHECK_PTR(obj_ret, "H5SL_remove"); obj_ret->nfrees++; obj_list->nobjs_rem--; } /* end else */ @@ -1324,7 +1324,7 @@ test_skiplist_try_free_safe(void) /* Create a skip list */ obj_list.slist = H5SL_create(H5SL_TYPE_INT, NULL); - CHECK(obj_list.slist, NULL, "H5SL_create"); + CHECK_PTR(obj_list.slist, "H5SL_create"); /* Init obj_list.list */ obj_list.list = list; @@ -1396,7 +1396,7 @@ test_skiplist_less(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Insert objects into the skip list */ for(u=0; u<10; u++) { @@ -1430,7 +1430,7 @@ test_skiplist_less(void) VERIFY(*found_item,5,"H5SL_less"); find_item=4; found_item=(unsigned *)H5SL_less(slist,&find_item); - VERIFY(found_item,NULL,"H5SL_less"); + CHECK_PTR_NULL(found_item, "H5SL_less"); /* Close the skip list */ ret=H5SL_close(slist); @@ -1460,7 +1460,7 @@ test_skiplist_greater(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Insert objects into the skip list */ for(u = 0; u < 10; u++) { @@ -1488,7 +1488,7 @@ test_skiplist_greater(void) VERIFY(*found_item, 90, "H5SL_greater"); find_item = 100; found_item = (unsigned *)H5SL_greater(slist, &find_item); - VERIFY(found_item, NULL, "H5SL_greater"); + CHECK_PTR_NULL(found_item, "H5SL_greater"); find_item = 6; found_item = (unsigned *)H5SL_greater(slist, &find_item); VERIFY(*found_item, 10, "H5SL_greater"); @@ -1525,7 +1525,7 @@ test_skiplist_below(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Insert objects into the skip list */ for(u = 0; u < 10; u++) { @@ -1536,44 +1536,44 @@ test_skiplist_below(void) /* Check for exact match of items in various positions */ find_item = 20; node = H5SL_below(slist, &find_item); - CHECK(node, NULL, "H5SL_below"); + CHECK_PTR(node, "H5SL_below"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_below"); find_item = 90; node = H5SL_below(slist, &find_item); - CHECK(node, NULL, "H5SL_below"); + CHECK_PTR(node, "H5SL_below"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_below"); find_item = 5; node = H5SL_below(slist, &find_item); - CHECK(node, NULL, "H5SL_below"); + CHECK_PTR(node, "H5SL_below"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_below"); /* Find item less than a missing key, in various positions */ find_item = 19; node = H5SL_below(slist, &find_item); - CHECK(node, NULL, "H5SL_below"); + CHECK_PTR(node, "H5SL_below"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 15, "H5SL_below"); find_item = 89; node = H5SL_below(slist, &find_item); - CHECK(node, NULL, "H5SL_below"); + CHECK_PTR(node, "H5SL_below"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 80, "H5SL_below"); find_item = 100; node = H5SL_below(slist, &find_item); - CHECK(node, NULL, "H5SL_below"); + CHECK_PTR(node, "H5SL_below"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 90, "H5SL_below"); find_item = 9; node = H5SL_below(slist, &find_item); - CHECK(node, NULL, "H5SL_below"); + CHECK_PTR(node, "H5SL_below"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 5, "H5SL_below"); find_item = 4; node = (H5SL_node_t *)H5SL_less(slist, &find_item); - VERIFY(node, NULL, "H5SL_below"); + CHECK_PTR_NULL(node, "H5SL_below"); /* Close the skip list */ ret = H5SL_close(slist); @@ -1604,7 +1604,7 @@ test_skiplist_above(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Insert objects into the skip list */ for(u = 0; u < 10; u++) { @@ -1615,42 +1615,42 @@ test_skiplist_above(void) /* Check for exact match of items in various positions */ find_item = 20; node = H5SL_above(slist, &find_item); - CHECK(node, NULL, "H5SL_above"); + CHECK_PTR(node, "H5SL_above"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_above"); find_item = 90; node = H5SL_above(slist, &find_item); - CHECK(node, NULL, "H5SL_above"); + CHECK_PTR(node, "H5SL_above"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_above"); find_item = 5; node = H5SL_above(slist, &find_item); - CHECK(node, NULL, "H5SL_above"); + CHECK_PTR(node, "H5SL_above"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_above"); /* Find item greater than a missing key, in various positions */ find_item = 19; node = H5SL_above(slist, &find_item); - CHECK(node, NULL, "H5SL_above"); + CHECK_PTR(node, "H5SL_above"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 20, "H5SL_above"); find_item = 89; node = H5SL_above(slist, &find_item); - CHECK(node, NULL, "H5SL_above"); + CHECK_PTR(node, "H5SL_above"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 90, "H5SL_above"); find_item = 100; node = H5SL_above(slist, &find_item); - VERIFY(node, NULL, "H5SL_above"); + CHECK_PTR_NULL(node, "H5SL_above"); find_item = 6; node = H5SL_above(slist, &find_item); - CHECK(node, NULL, "H5SL_above"); + CHECK_PTR(node, "H5SL_above"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 10, "H5SL_above"); find_item = 4; node = H5SL_above(slist, &find_item); - CHECK(node, NULL, "H5SL_above"); + CHECK_PTR(node, "H5SL_above"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 5, "H5SL_above"); @@ -1681,7 +1681,7 @@ test_skiplist_remove_first(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Insert objects into the skip list */ for(u = 0; u < 10; u++) { @@ -1697,7 +1697,7 @@ test_skiplist_remove_first(void) /* Check for removing object from empty list */ found_item = (unsigned *)H5SL_remove_first(slist); - VERIFY(found_item, NULL, "H5SL_remove_first"); + CHECK_PTR_NULL(found_item, "H5SL_remove_first"); /* Close the skip list */ ret = H5SL_close(slist); @@ -1725,7 +1725,7 @@ test_skiplist_remove_first_many(void) /* Create a skip list */ slist = H5SL_create(H5SL_TYPE_INT, NULL); - CHECK(slist, NULL, "H5SL_create"); + CHECK_PTR(slist, "H5SL_create"); /* Insert objects into the skip list */ for(u = 0; u < NUM_ELEMS; u++) { @@ -1742,7 +1742,7 @@ test_skiplist_remove_first_many(void) /* Check for removing object from empty list */ found_item = (int *)H5SL_remove_first(slist); - VERIFY(found_item, NULL, "H5SL_remove_first"); + CHECK_PTR_NULL(found_item, "H5SL_remove_first"); /* Close the skip list */ ret = H5SL_close(slist); diff --git a/test/ttst.c b/test/ttst.c index b26d582..c5912c5 100644 --- a/test/ttst.c +++ b/test/ttst.c @@ -157,7 +157,7 @@ test_tst_create(void) /* Try creating a TST */ tree=H5ST_create(); - CHECK(tree, NULL, "H5ST_create"); + CHECK_PTR(tree, "H5ST_create"); /* Try closing a real tree */ ret=H5ST_close(tree); @@ -186,7 +186,7 @@ test_tst_insert(void) /* Create the TST */ tree=H5ST_create(); - CHECK(tree, NULL, "H5ST_create"); + CHECK_PTR(tree, "H5ST_create"); /* Insert unique words into TST, in random order */ for(u=0; u<num_uniq_words; u++) { @@ -202,13 +202,13 @@ test_tst_insert(void) /* Check that the value "payloads" are correct */ found=H5ST_find(tree,uniq_words[u]); - CHECK(found, NULL, "H5ST_find"); + CHECK_PTR(found, "H5ST_find"); if(HDstrcmp((const char *)found->eqkid,uniq_words[u])) TestErrPrintf("%d: TST node values don't match!, found->eqkid=%s, uniq_words[%u]=%s\n",__LINE__,(char *)found->eqkid,(unsigned)u,uniq_words[u]); obj=H5ST_locate(tree,uniq_words[u]); - CHECK(obj, NULL, "H5ST_locate"); + CHECK_PTR(obj, "H5ST_locate"); if(HDstrcmp((const char *)obj,uniq_words[u])) TestErrPrintf("%d: TST objects don't match!, obj=%s, uniq_words[%u]=%s\n",__LINE__,(char *)obj,(unsigned)u,uniq_words[u]); @@ -246,7 +246,7 @@ test_tst_iterate(void) /* Create the TST */ tree=H5ST_create(); - CHECK(tree, NULL, "H5ST_create"); + CHECK_PTR(tree, "H5ST_create"); /* Insert unique words into TST, in random order */ for(u=0; u<num_uniq_words; u++) { @@ -256,7 +256,7 @@ test_tst_iterate(void) /* Use findfirst/findnext calls to iterate through TST */ found=H5ST_findfirst(tree); - CHECK(found, NULL, "H5ST_findfirst"); + CHECK_PTR(found, "H5ST_findfirst"); u=0; do { /* Check that the strings in the TST are in the correct order */ @@ -294,7 +294,7 @@ test_tst_remove(void) /* Create the TST */ tree=H5ST_create(); - CHECK(tree, NULL, "H5ST_create"); + CHECK_PTR(tree, "H5ST_create"); /* Insert unique words into TST, in random order */ for(u=0; u<num_uniq_words; u++) { @@ -305,7 +305,7 @@ test_tst_remove(void) /* Remove strings from TST in random order */ for(u=0; u<num_uniq_words; u++) { obj=H5ST_remove(tree,rand_uniq_words[u]); - CHECK(obj, NULL, "H5ST_remove"); + CHECK_PTR(obj, "H5ST_remove"); /* Check that the correct string was removed from TST */ if(HDstrcmp((const char *)obj,rand_uniq_words[u])) @@ -326,7 +326,7 @@ test_tst_remove(void) for(u=0; u<num_uniq_words; u++) { /* Get the pointer to the node to delete */ found=H5ST_find(tree,rand_uniq_words[u]); - CHECK(found, NULL, "H5ST_find"); + CHECK_PTR(found, "H5ST_find"); /* Check that the correct object will be removed from TST */ if(HDstrcmp((const char *)found->eqkid,rand_uniq_words[u])) diff --git a/test/tvltypes.c b/test/tvltypes.c index 5121a66..0c4cb9d 100644 --- a/test/tvltypes.c +++ b/test/tvltypes.c @@ -1015,9 +1015,9 @@ test_vltypes_compound_vlen_vlen(void) /* Allocate and initialize VL data to write */ wdata = (s1 *)HDmalloc(sizeof(s1) * SPACE3_DIM1); - CHECK(wdata, NULL, "HDmalloc"); + CHECK_PTR(wdata, "HDmalloc"); rdata = (s1 *)HDmalloc(sizeof(s1) * SPACE3_DIM1); - CHECK(rdata, NULL, "HDmalloc"); + CHECK_PTR(rdata, "HDmalloc"); for(i = 0; i < SPACE3_DIM1; i++) { wdata[i].i = (int)(i * 10); wdata[i].f = (float)(i * 20) / 3.0F; @@ -2503,7 +2503,7 @@ test_vltypes_fill_value(void) /* Allocate space for the buffer to read data */ rbuf = (dtype1_struct *)HDmalloc(SPACE4_DIM_LARGE * sizeof(dtype1_struct)); - CHECK(rbuf, NULL, "HDmalloc"); + CHECK_PTR(rbuf, "HDmalloc"); /* Create the small & large dataspaces to use */ |