diff options
author | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2013-05-10 19:38:53 (GMT) |
---|---|---|
committer | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2013-05-10 19:38:53 (GMT) |
commit | 68a20c3f56f30e62e062eba2f4c8f782fa604cd3 (patch) | |
tree | db86db14954362b093891cf311ce514cf87fe051 /test | |
parent | 0a3191e36d4ee22c383de9b0917990149c1f2df2 (diff) | |
parent | 5ecebe5b9bc161153a3391bf32eb64687f675172 (diff) | |
download | hdf5-68a20c3f56f30e62e062eba2f4c8f782fa604cd3.zip hdf5-68a20c3f56f30e62e062eba2f4c8f782fa604cd3.tar.gz hdf5-68a20c3f56f30e62e062eba2f4c8f782fa604cd3.tar.bz2 |
[svn-r23694] merge from trunk
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 127 | ||||
-rw-r--r-- | test/Makefile.am | 46 | ||||
-rw-r--r-- | test/Makefile.in | 280 | ||||
-rw-r--r-- | test/dynlib1.c | 97 | ||||
-rw-r--r-- | test/dynlib2.c | 91 | ||||
-rw-r--r-- | test/dynlib3.c | 102 | ||||
-rw-r--r-- | test/file_image.c | 3 | ||||
-rw-r--r-- | test/fillval.c | 262 | ||||
-rw-r--r-- | test/plugin.c | 732 | ||||
-rw-r--r-- | test/test_plugin.sh.in | 93 | ||||
-rw-r--r-- | test/testerror.sh.in | 9 | ||||
-rw-r--r-- | test/testframe.c | 4 | ||||
-rw-r--r-- | test/unregister.c | 256 |
13 files changed, 2009 insertions, 93 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6af1e94..766ed7b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,7 +7,14 @@ PROJECT (HDF5_TEST) ADD_DEFINITIONS (${HDF5_EXTRA_C_FLAGS}) #----------------------------------------------------------------------------- -# Define Sources +# Generate the H5srcdir_str.h file containing user settings needed by compilation +#----------------------------------------------------------------------------- +SET (srcdir ${CMAKE_CURRENT_SOURCE_DIR}) +CONFIGURE_FILE (${HDF5_TEST_SOURCE_DIR}/H5srcdir_str.h.in H5srcdir_str.h @ONLY) +INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR}) + +#----------------------------------------------------------------------------- +# Define Test Library Sources #----------------------------------------------------------------------------- SET (TEST_LIB_SRCS ${HDF5_TEST_SOURCE_DIR}/h5test.c @@ -19,13 +26,6 @@ SET (TEST_LIB_HEADERS ${HDF5_TEST_SOURCE_DIR}/h5test.h ) -#----------------------------------------------------------------------------- -# Generate the H5srcdir_str.h file containing user settings needed by compilation -#----------------------------------------------------------------------------- -SET (srcdir ${CMAKE_CURRENT_SOURCE_DIR}) -CONFIGURE_FILE (${HDF5_TEST_SOURCE_DIR}/H5srcdir_str.h.in H5srcdir_str.h @ONLY) -INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR}) - ADD_LIBRARY (${HDF5_TEST_LIB_TARGET} ${LIB_TYPE} ${TEST_LIB_SRCS} ${TEST_LIB_HEADERS}) IF (MSVC) TARGET_LINK_LIBRARIES (${HDF5_TEST_LIB_TARGET} "ws2_32.lib") @@ -37,6 +37,86 @@ TARGET_LINK_LIBRARIES (${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) H5_SET_LIB_OPTIONS (${HDF5_TEST_LIB_TARGET} ${HDF5_TEST_LIB_NAME} ${LIB_TYPE}) SET_TARGET_PROPERTIES (${HDF5_TEST_LIB_TARGET} PROPERTIES FOLDER libraries/test) +#----------------------------------------------------------------------------- +# If plugin library tests can be tested +#----------------------------------------------------------------------------- +IF (BUILD_SHARED_LIBS) + # make plugins dir + FILE (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/testdir1") + FILE (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/testdir2") + + #----------------------------------------------------------------------------- + # Define Test Library Sources + #----------------------------------------------------------------------------- + SET (TEST_PLUGIN_LIBS + dynlib1 + dynlib3 + ) + SET (TEST2_PLUGIN_LIBS + dynlib2 + ) + + 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}) + ADD_DEFINITIONS (${HDF5_EXTRA_C_FLAGS}) + INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) + + ADD_LIBRARY (${HDF5_TEST_PLUGIN_LIB_TARGET} ${LIB_TYPE} ${HDF5_TEST_SOURCE_DIR}/${test_lib}.c) + 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} + ${LIB_TYPE} + HDF5_TEST_PLUGIN_LIB_NAME_RELEASE + HDF5_TEST_PLUGIN_LIB_NAME_DEBUG + ) + SET_TARGET_PROPERTIES (${HDF5_TEST_PLUGIN_LIB_TARGET} PROPERTIES FOLDER libraries/TEST_PLUGIN) + + #----------------------------------------------------------------------------- + # Copy plugin library to a plugins folder + #----------------------------------------------------------------------------- + ADD_CUSTOM_COMMAND ( + TARGET ${HDF5_TEST_PLUGIN_LIB_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}>" + ) + ENDFOREACH (test_lib ${TEST_PLUGIN_LIBS}) + + 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}) + ADD_DEFINITIONS (${HDF5_EXTRA_C_FLAGS}) + INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) + + ADD_LIBRARY (${HDF5_TEST_PLUGIN_LIB_TARGET} ${LIB_TYPE} ${HDF5_TEST_SOURCE_DIR}/${test_lib}.c) + 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} + ${LIB_TYPE} + HDF5_TEST_PLUGIN_LIB_NAME_RELEASE + HDF5_TEST_PLUGIN_LIB_NAME_DEBUG + ) + SET_TARGET_PROPERTIES (${HDF5_TEST_PLUGIN_LIB_TARGET} PROPERTIES FOLDER libraries/TEST_PLUGIN) + + #----------------------------------------------------------------------------- + # Copy plugin library to a plugins folder + #----------------------------------------------------------------------------- + ADD_CUSTOM_COMMAND ( + TARGET ${HDF5_TEST_PLUGIN_LIB_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}>" + ) + ENDFOREACH (test_lib ${TEST2_PLUGIN_LIBS}) +ENDIF (BUILD_SHARED_LIBS) + # -------------------------------------------------------------------- # Copy all the HDF5 files from the test directory into the source directory # -------------------------------------------------------------------- @@ -317,6 +397,8 @@ ADD_TEST ( testmeta.h5 tstint1.h5 tstint2.h5 + unregister_filter_1.h5 + unregister_filter_2.h5 ) SET (H5_TESTS @@ -373,6 +455,7 @@ SET (H5_TESTS file_image enc_dec_plist enc_dec_plist_with_endianess + unregister ) FOREACH (test ${H5_TESTS}) @@ -508,6 +591,7 @@ ADD_TEST (NAME error_test COMMAND "${CMAKE_COMMAND}" -P "${HDF5_RESOURCES_DIR}/runTest.cmake" ) SET_TESTS_PROPERTIES(error_test PROPERTIES DEPENDS h5test-clear-error_test-objects) +SET_TESTS_PROPERTIES (error_test PROPERTIES ENVIRONMENT "HDF5_PLUGIN_PRELOAD=::") #-- Adding test for links_env ADD_EXECUTABLE (links_env ${HDF5_TEST_SOURCE_DIR}/links_env.c) @@ -553,6 +637,32 @@ ENDIF (\${TEST_RESULT} STREQUAL \"0\") ADD_TEST (NAME testlibinfo COMMAND ${CMAKE_COMMAND} -D "TEST_PROGRAM=$<TARGET_FILE:${HDF5_LIB_TARGET}>" -P "${GREP_RUNNER}") ############################################################################## +### P L U G I N T E S T S +############################################################################## +IF (BUILD_SHARED_LIBS) + + IF (WIN32 AND NOT CYGWIN) + SET(CMAKE_SEP "\;") + ELSE (WIN32 AND NOT CYGWIN) + SET(CMAKE_SEP ":") + ENDIF(WIN32 AND NOT CYGWIN) + + ADD_EXECUTABLE (plugin ${HDF5_TEST_SOURCE_DIR}/plugin.c) + TARGET_NAMING (plugin ${LIB_TYPE}) + TARGET_LINK_LIBRARIES (plugin ${HDF5_TEST_PLUGIN_LIB_TARGET}) + SET_TARGET_PROPERTIES (plugin PROPERTIES FOLDER test) + + 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") +ELSE (BUILD_SHARED_LIBS) + MESSAGE (STATUS " **** Plugins libraries must be built as shared libraries **** ") + ADD_TEST ( + NAME H5PLUGIN-SKIPPED + COMMAND ${CMAKE_COMMAND} -E echo "SKIP H5PLUGIN TESTING" + ) +ENDIF (BUILD_SHARED_LIBS) + +############################################################################## ############################################################################## ### V F D T E S T S ### ############################################################################## @@ -621,6 +731,7 @@ IF (HDF5_TEST_VFD) tcheck_version testmeta links_env + unregister ) IF (DIRECT_VFD) diff --git a/test/Makefile.am b/test/Makefile.am index f1f98f1..b7fd1a9 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -26,9 +26,13 @@ INCLUDES=-I$(top_srcdir)/src -I$(top_builddir)/src # Test script for error_test and err_compat #TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh TEST_SCRIPT = testlibinfo.sh testcheck_version.sh testlinks_env.sh -check_SCRIPTS = $(TEST_SCRIPT) SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) +if HAVE_SHARED_CONDITIONAL + TEST_SCRIPT += test_plugin.sh + SCRIPT_DEPEND += plugin$(EXEEXT) +endif +check_SCRIPTS = $(TEST_SCRIPT) # These are our main targets. They should be listed in the order to be # executed, generally most specific tests to least specific tests. @@ -43,7 +47,7 @@ TEST_PROG= testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \ big mtime fillval mount flush1 flush2 app_ref enum \ set_extent ttsafe enc_dec_plist enc_dec_plist_with_endianess\ getname vfd ntypes dangle dtransform reserved cross_read \ - freespace mf farray earray btree2 fheap file_image + freespace mf farray earray btree2 fheap file_image unregister # List programs to be built when testing here. error_test and err_compat are # built at the same time as the other tests, but executed by testerror.sh. @@ -52,7 +56,9 @@ TEST_PROG= testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \ # Also build testmeta, which is used for timings test. It builds quickly, # and this lets automake keep all its test programs in one place. check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version testmeta links_env - +if HAVE_SHARED_CONDITIONAL + check_PROGRAMS+= plugin +endif # These programs generate test files for the tests. They don't need to be # compiled every time we want to test the library. However, putting @@ -70,8 +76,25 @@ if BUILD_ALL_CONDITIONAL noinst_PROGRAMS=$(BUILD_ALL_PROGS) endif -# The libh5test library provides common support code for the tests. -noinst_LTLIBRARIES=libh5test.la +if HAVE_SHARED_CONDITIONAL + # The libh5test library provides common support code for the tests. + noinst_LTLIBRARIES=libh5test.la + + # The libdynlib1 and libdynlib2 library for testing plugin module plugin.c. + # Build it as shared library if configure is enabled for shared library. + lib_LTLIBRARIES=libdynlib1.la libdynlib2.la libdynlib3.la + libdynlib1_la_SOURCES=dynlib1.c + libdynlib2_la_SOURCES=dynlib2.c + libdynlib3_la_SOURCES=dynlib3.c + +install-exec-hook: + $(RM) $(DESTDIR)$(libdir)/*dynlib* + +else + # The libh5test library provides common support code for the tests. + noinst_LTLIBRARIES=libh5test.la +endif + libh5test_la_SOURCES=h5test.c testframe.c cache_common.c # Use libhd5test.la to compile all of the tests @@ -81,10 +104,9 @@ LDADD=libh5test.la $(LIBHDF5) ttsafe_SOURCES=ttsafe.c ttsafe_dcreate.c ttsafe_error.c ttsafe_cancel.c \ ttsafe_acreate.c +VFD_LIST = sec2 stdio core split multi family if DIRECT_VFD_CONDITIONAL - VFD_LIST = sec2 stdio core split multi family direct -else - VFD_LIST = sec2 stdio core split multi family + VFD_LIST += direct endif # Additional target for running timing test @@ -121,7 +143,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 \ + multi_file-[rs].h5 core_file 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 objcopy_src.h5 objcopy_dst.h5 \ @@ -129,7 +151,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse earray.h5 efc[0-5].h5 log_vfd_out.log \ new_multi_file_v16-r.h5 new_multi_file_v16-s.h5 \ split_get_file_image_test-m.h5 split_get_file_image_test-r.h5 \ - file_image_core_test.h5.copy + file_image_core_test.h5.copy unregister_filter_1.h5 unregister_filter_2.h5 # Sources for testhdf5 executable testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \ @@ -138,7 +160,7 @@ testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \ tvlstr.c tvltypes.c # Temporary files. -#DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh -DISTCLEANFILES=testlibinfo.sh testcheck_version.sh testlinks_env.sh +#DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_plugin.sh +DISTCLEANFILES=testlibinfo.sh testcheck_version.sh testlinks_env.sh test_plugin.sh include $(top_srcdir)/config/conclude.am diff --git a/test/Makefile.in b/test/Makefile.in index e736e59..2ba8975 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -70,16 +70,20 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ DIST_COMMON = $(srcdir)/H5srcdir_str.h.in $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in $(srcdir)/testcheck_version.sh.in \ - $(srcdir)/testerror.sh.in $(srcdir)/testlibinfo.sh.in \ - $(srcdir)/testlinks_env.sh.in $(top_srcdir)/bin/depcomp \ - $(top_srcdir)/bin/mkinstalldirs \ + $(srcdir)/Makefile.in $(srcdir)/test_plugin.sh.in \ + $(srcdir)/testcheck_version.sh.in $(srcdir)/testerror.sh.in \ + $(srcdir)/testlibinfo.sh.in $(srcdir)/testlinks_env.sh.in \ + $(top_srcdir)/bin/depcomp $(top_srcdir)/bin/mkinstalldirs \ $(top_srcdir)/config/commence.am \ $(top_srcdir)/config/conclude.am COPYING +@HAVE_SHARED_CONDITIONAL_TRUE@am__append_1 = test_plugin.sh +@HAVE_SHARED_CONDITIONAL_TRUE@am__append_2 = plugin$(EXEEXT) check_PROGRAMS = $(am__EXEEXT_1) error_test$(EXEEXT) \ err_compat$(EXEEXT) tcheck_version$(EXEEXT) testmeta$(EXEEXT) \ - links_env$(EXEEXT) -@BUILD_ALL_CONDITIONAL_TRUE@noinst_PROGRAMS = $(am__EXEEXT_2) + links_env$(EXEEXT) $(am__EXEEXT_2) +@HAVE_SHARED_CONDITIONAL_TRUE@am__append_3 = plugin +@BUILD_ALL_CONDITIONAL_TRUE@noinst_PROGRAMS = $(am__EXEEXT_3) +@DIRECT_VFD_CONDITIONAL_TRUE@am__append_4 = direct TESTS = $(am__EXEEXT_1) $(TEST_SCRIPT) subdir = test ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -89,15 +93,63 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ mkinstalldirs = $(SHELL) $(top_srcdir)/bin/mkinstalldirs CONFIG_HEADER = $(top_builddir)/src/H5config.h CONFIG_CLEAN_FILES = testcheck_version.sh testerror.sh H5srcdir_str.h \ - testlibinfo.sh testlinks_env.sh + testlibinfo.sh testlinks_env.sh test_plugin.sh CONFIG_CLEAN_VPATH_FILES = -LTLIBRARIES = $(noinst_LTLIBRARIES) -libh5test_la_LIBADD = -am_libh5test_la_OBJECTS = h5test.lo testframe.lo cache_common.lo -libh5test_la_OBJECTS = $(am_libh5test_la_OBJECTS) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(libdir)" +LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) +libdynlib1_la_LIBADD = +am__libdynlib1_la_SOURCES_DIST = dynlib1.c +@HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlib1_la_OBJECTS = dynlib1.lo +libdynlib1_la_OBJECTS = $(am_libdynlib1_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent +@HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlib1_la_rpath = -rpath \ +@HAVE_SHARED_CONDITIONAL_TRUE@ $(libdir) +libdynlib2_la_LIBADD = +am__libdynlib2_la_SOURCES_DIST = dynlib2.c +@HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlib2_la_OBJECTS = dynlib2.lo +libdynlib2_la_OBJECTS = $(am_libdynlib2_la_OBJECTS) +@HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlib2_la_rpath = -rpath \ +@HAVE_SHARED_CONDITIONAL_TRUE@ $(libdir) +libdynlib3_la_LIBADD = +am__libdynlib3_la_SOURCES_DIST = dynlib3.c +@HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlib3_la_OBJECTS = dynlib3.lo +libdynlib3_la_OBJECTS = $(am_libdynlib3_la_OBJECTS) +@HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlib3_la_rpath = -rpath \ +@HAVE_SHARED_CONDITIONAL_TRUE@ $(libdir) +libh5test_la_LIBADD = +am_libh5test_la_OBJECTS = h5test.lo testframe.lo cache_common.lo +libh5test_la_OBJECTS = $(am_libh5test_la_OBJECTS) +@HAVE_SHARED_CONDITIONAL_FALSE@am_libh5test_la_rpath = +@HAVE_SHARED_CONDITIONAL_TRUE@am_libh5test_la_rpath = am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \ stab$(EXEEXT) gheap$(EXEEXT) cache$(EXEEXT) cache_api$(EXEEXT) \ cache_tagging$(EXEEXT) pool$(EXEEXT) accum$(EXEEXT) \ @@ -113,8 +165,10 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \ vfd$(EXEEXT) ntypes$(EXEEXT) dangle$(EXEEXT) \ dtransform$(EXEEXT) reserved$(EXEEXT) cross_read$(EXEEXT) \ freespace$(EXEEXT) mf$(EXEEXT) farray$(EXEEXT) earray$(EXEEXT) \ - btree2$(EXEEXT) fheap$(EXEEXT) file_image$(EXEEXT) -am__EXEEXT_2 = gen_bad_ohdr$(EXEEXT) gen_bogus$(EXEEXT) \ + btree2$(EXEEXT) fheap$(EXEEXT) file_image$(EXEEXT) \ + unregister$(EXEEXT) +@HAVE_SHARED_CONDITIONAL_TRUE@am__EXEEXT_2 = plugin$(EXEEXT) +am__EXEEXT_3 = gen_bad_ohdr$(EXEEXT) gen_bogus$(EXEEXT) \ gen_cross$(EXEEXT) gen_deflate$(EXEEXT) gen_filters$(EXEEXT) \ gen_new_array$(EXEEXT) gen_new_fill$(EXEEXT) \ gen_new_group$(EXEEXT) gen_new_mtime$(EXEEXT) \ @@ -377,6 +431,10 @@ ohdr_SOURCES = ohdr.c ohdr_OBJECTS = ohdr.$(OBJEXT) ohdr_LDADD = $(LDADD) ohdr_DEPENDENCIES = libh5test.la $(LIBHDF5) +plugin_SOURCES = plugin.c +plugin_OBJECTS = plugin.$(OBJEXT) +plugin_LDADD = $(LDADD) +plugin_DEPENDENCIES = libh5test.la $(LIBHDF5) pool_SOURCES = pool.c pool_OBJECTS = pool.$(OBJEXT) pool_LDADD = $(LDADD) @@ -427,6 +485,10 @@ unlink_SOURCES = unlink.c unlink_OBJECTS = unlink.$(OBJEXT) unlink_LDADD = $(LDADD) unlink_DEPENDENCIES = libh5test.la $(LIBHDF5) +unregister_SOURCES = unregister.c +unregister_OBJECTS = unregister.$(OBJEXT) +unregister_LDADD = $(LDADD) +unregister_DEPENDENCIES = libh5test.la $(LIBHDF5) vfd_SOURCES = vfd.c vfd_OBJECTS = vfd.$(OBJEXT) vfd_LDADD = $(LDADD) @@ -457,38 +519,43 @@ am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; -SOURCES = $(libh5test_la_SOURCES) accum.c app_ref.c big.c bittests.c \ - btree2.c cache.c cache_api.c cache_tagging.c cmpd_dset.c \ - cross_read.c dangle.c dsets.c dt_arith.c dtransform.c dtypes.c \ - earray.c efc.c enc_dec_plist.c enc_dec_plist_with_endianess.c \ - enum.c err_compat.c error_test.c extend.c external.c farray.c \ - fheap.c file_image.c fillval.c filter_fail.c flush1.c flush2.c \ +SOURCES = $(libdynlib1_la_SOURCES) $(libdynlib2_la_SOURCES) \ + $(libdynlib3_la_SOURCES) $(libh5test_la_SOURCES) accum.c \ + app_ref.c big.c bittests.c btree2.c cache.c cache_api.c \ + cache_tagging.c cmpd_dset.c cross_read.c dangle.c dsets.c \ + dt_arith.c dtransform.c dtypes.c earray.c efc.c \ + enc_dec_plist.c enc_dec_plist_with_endianess.c enum.c \ + err_compat.c error_test.c extend.c external.c farray.c fheap.c \ + file_image.c fillval.c filter_fail.c flush1.c flush2.c \ freespace.c gen_bad_ohdr.c gen_bogus.c gen_cross.c \ gen_deflate.c gen_file_image.c gen_filespace.c gen_filters.c \ gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c \ gen_new_super.c gen_noencoder.c gen_nullspace.c gen_plist.c \ gen_sizes_lheap.c gen_specmetaread.c gen_udlinks.c getname.c \ gheap.c hyperslab.c istore.c lheap.c links.c links_env.c mf.c \ - mount.c mtime.c ntypes.c objcopy.c ohdr.c pool.c reserved.c \ - set_extent.c space_overflow.c stab.c tcheck_version.c \ - $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \ - vfd.c -DIST_SOURCES = $(libh5test_la_SOURCES) accum.c app_ref.c big.c \ - bittests.c btree2.c cache.c cache_api.c cache_tagging.c \ - cmpd_dset.c cross_read.c dangle.c dsets.c dt_arith.c \ - dtransform.c dtypes.c earray.c efc.c enc_dec_plist.c \ - enc_dec_plist_with_endianess.c enum.c err_compat.c \ - error_test.c extend.c external.c farray.c fheap.c file_image.c \ - fillval.c filter_fail.c flush1.c flush2.c freespace.c \ - gen_bad_ohdr.c gen_bogus.c gen_cross.c gen_deflate.c \ - gen_file_image.c gen_filespace.c gen_filters.c gen_new_array.c \ - gen_new_fill.c gen_new_group.c gen_new_mtime.c gen_new_super.c \ - gen_noencoder.c gen_nullspace.c gen_plist.c gen_sizes_lheap.c \ - gen_specmetaread.c gen_udlinks.c getname.c gheap.c hyperslab.c \ - istore.c lheap.c links.c links_env.c mf.c mount.c mtime.c \ - ntypes.c objcopy.c ohdr.c pool.c reserved.c set_extent.c \ - space_overflow.c stab.c tcheck_version.c $(testhdf5_SOURCES) \ - testmeta.c $(ttsafe_SOURCES) unlink.c vfd.c + mount.c mtime.c ntypes.c objcopy.c ohdr.c plugin.c pool.c \ + reserved.c set_extent.c space_overflow.c stab.c \ + tcheck_version.c $(testhdf5_SOURCES) testmeta.c \ + $(ttsafe_SOURCES) unlink.c unregister.c vfd.c +DIST_SOURCES = $(am__libdynlib1_la_SOURCES_DIST) \ + $(am__libdynlib2_la_SOURCES_DIST) \ + $(am__libdynlib3_la_SOURCES_DIST) $(libh5test_la_SOURCES) \ + accum.c app_ref.c big.c bittests.c btree2.c cache.c \ + cache_api.c cache_tagging.c cmpd_dset.c cross_read.c dangle.c \ + dsets.c dt_arith.c dtransform.c dtypes.c earray.c efc.c \ + enc_dec_plist.c enc_dec_plist_with_endianess.c enum.c \ + err_compat.c error_test.c extend.c external.c farray.c fheap.c \ + file_image.c fillval.c filter_fail.c flush1.c flush2.c \ + freespace.c gen_bad_ohdr.c gen_bogus.c gen_cross.c \ + gen_deflate.c gen_file_image.c gen_filespace.c gen_filters.c \ + gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c \ + gen_new_super.c gen_noencoder.c gen_nullspace.c gen_plist.c \ + gen_sizes_lheap.c gen_specmetaread.c gen_udlinks.c getname.c \ + gheap.c hyperslab.c istore.c lheap.c links.c links_env.c mf.c \ + mount.c mtime.c ntypes.c objcopy.c ohdr.c plugin.c pool.c \ + reserved.c set_extent.c space_overflow.c stab.c \ + tcheck_version.c $(testhdf5_SOURCES) testmeta.c \ + $(ttsafe_SOURCES) unlink.c unregister.c vfd.c am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -802,21 +869,24 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog accum.h5 cmpd_dset.h5 \ 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 new_move_[ab].h5 ntypes.h5 \ - dangle.h5 error_test.h5 err_compat.h5 dtransform.h5 \ + multi_file-[rs].h5 core_file 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 objcopy_src.h5 objcopy_dst.h5 \ objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 \ earray.h5 efc[0-5].h5 log_vfd_out.log new_multi_file_v16-r.h5 \ new_multi_file_v16-s.h5 split_get_file_image_test-m.h5 \ - split_get_file_image_test-r.h5 file_image_core_test.h5.copy + split_get_file_image_test-r.h5 file_image_core_test.h5.copy \ + unregister_filter_1.h5 unregister_filter_2.h5 INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src # Test script for error_test and err_compat #TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh -TEST_SCRIPT = testlibinfo.sh testcheck_version.sh testlinks_env.sh +TEST_SCRIPT = testlibinfo.sh testcheck_version.sh testlinks_env.sh \ + $(am__append_1) +SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) \ + links_env$(EXEEXT) $(am__append_2) check_SCRIPTS = $(TEST_SCRIPT) -SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) # These are our main targets. They should be listed in the order to be # executed, generally most specific tests to least specific tests. @@ -831,7 +901,7 @@ TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \ big mtime fillval mount flush1 flush2 app_ref enum \ set_extent ttsafe enc_dec_plist enc_dec_plist_with_endianess\ getname vfd ntypes dangle dtransform reserved cross_read \ - freespace mf farray earray btree2 fheap file_image + freespace mf farray earray btree2 fheap file_image unregister # These programs generate test files for the tests. They don't need to be @@ -846,9 +916,12 @@ BUILD_ALL_PROGS = gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_n gen_nullspace gen_udlinks space_overflow gen_filespace gen_specmetaread \ gen_sizes_lheap gen_file_image gen_plist - -# The libh5test library provides common support code for the tests. -noinst_LTLIBRARIES = libh5test.la +@HAVE_SHARED_CONDITIONAL_FALSE@noinst_LTLIBRARIES = libh5test.la +@HAVE_SHARED_CONDITIONAL_TRUE@noinst_LTLIBRARIES = libh5test.la +@HAVE_SHARED_CONDITIONAL_TRUE@lib_LTLIBRARIES = libdynlib1.la libdynlib2.la libdynlib3.la +@HAVE_SHARED_CONDITIONAL_TRUE@libdynlib1_la_SOURCES = dynlib1.c +@HAVE_SHARED_CONDITIONAL_TRUE@libdynlib2_la_SOURCES = dynlib2.c +@HAVE_SHARED_CONDITIONAL_TRUE@libdynlib3_la_SOURCES = dynlib3.c libh5test_la_SOURCES = h5test.c testframe.c cache_common.c # Use libhd5test.la to compile all of the tests @@ -858,8 +931,7 @@ LDADD = libh5test.la $(LIBHDF5) ttsafe_SOURCES = ttsafe.c ttsafe_dcreate.c ttsafe_error.c ttsafe_cancel.c \ ttsafe_acreate.c -@DIRECT_VFD_CONDITIONAL_FALSE@VFD_LIST = sec2 stdio core split multi family -@DIRECT_VFD_CONDITIONAL_TRUE@VFD_LIST = sec2 stdio core split multi family direct +VFD_LIST = sec2 stdio core split multi family $(am__append_4) # Sources for testhdf5 executable testhdf5_SOURCES = testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \ @@ -869,8 +941,8 @@ testhdf5_SOURCES = testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \ # Temporary files. -#DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh -DISTCLEANFILES = testlibinfo.sh testcheck_version.sh testlinks_env.sh +#DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_plugin.sh +DISTCLEANFILES = testlibinfo.sh testcheck_version.sh testlinks_env.sh test_plugin.sh # Automake needs to be taught how to build lib, progs, and tests targets. # These will be filled in automatically for the most part (e.g., @@ -936,6 +1008,42 @@ testlibinfo.sh: $(top_builddir)/config.status $(srcdir)/testlibinfo.sh.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ testlinks_env.sh: $(top_builddir)/config.status $(srcdir)/testlinks_env.sh.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +test_plugin.sh: $(top_builddir)/config.status $(srcdir)/test_plugin.sh.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @@ -947,8 +1055,14 @@ clean-noinstLTLIBRARIES: echo rm -f $${locs}; \ rm -f $${locs}; \ } +libdynlib1.la: $(libdynlib1_la_OBJECTS) $(libdynlib1_la_DEPENDENCIES) $(EXTRA_libdynlib1_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(am_libdynlib1_la_rpath) $(libdynlib1_la_OBJECTS) $(libdynlib1_la_LIBADD) $(LIBS) +libdynlib2.la: $(libdynlib2_la_OBJECTS) $(libdynlib2_la_DEPENDENCIES) $(EXTRA_libdynlib2_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(am_libdynlib2_la_rpath) $(libdynlib2_la_OBJECTS) $(libdynlib2_la_LIBADD) $(LIBS) +libdynlib3.la: $(libdynlib3_la_OBJECTS) $(libdynlib3_la_DEPENDENCIES) $(EXTRA_libdynlib3_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(am_libdynlib3_la_rpath) $(libdynlib3_la_OBJECTS) $(libdynlib3_la_LIBADD) $(LIBS) libh5test.la: $(libh5test_la_OBJECTS) $(libh5test_la_DEPENDENCIES) $(EXTRA_libh5test_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(libh5test_la_OBJECTS) $(libh5test_la_LIBADD) $(LIBS) + $(AM_V_CCLD)$(LINK) $(am_libh5test_la_rpath) $(libh5test_la_OBJECTS) $(libh5test_la_LIBADD) $(LIBS) clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ @@ -1156,6 +1270,9 @@ objcopy$(EXEEXT): $(objcopy_OBJECTS) $(objcopy_DEPENDENCIES) $(EXTRA_objcopy_DEP ohdr$(EXEEXT): $(ohdr_OBJECTS) $(ohdr_DEPENDENCIES) $(EXTRA_ohdr_DEPENDENCIES) @rm -f ohdr$(EXEEXT) $(AM_V_CCLD)$(LINK) $(ohdr_OBJECTS) $(ohdr_LDADD) $(LIBS) +plugin$(EXEEXT): $(plugin_OBJECTS) $(plugin_DEPENDENCIES) $(EXTRA_plugin_DEPENDENCIES) + @rm -f plugin$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(plugin_OBJECTS) $(plugin_LDADD) $(LIBS) pool$(EXEEXT): $(pool_OBJECTS) $(pool_DEPENDENCIES) $(EXTRA_pool_DEPENDENCIES) @rm -f pool$(EXEEXT) $(AM_V_CCLD)$(LINK) $(pool_OBJECTS) $(pool_LDADD) $(LIBS) @@ -1186,6 +1303,9 @@ ttsafe$(EXEEXT): $(ttsafe_OBJECTS) $(ttsafe_DEPENDENCIES) $(EXTRA_ttsafe_DEPENDE unlink$(EXEEXT): $(unlink_OBJECTS) $(unlink_DEPENDENCIES) $(EXTRA_unlink_DEPENDENCIES) @rm -f unlink$(EXEEXT) $(AM_V_CCLD)$(LINK) $(unlink_OBJECTS) $(unlink_LDADD) $(LIBS) +unregister$(EXEEXT): $(unregister_OBJECTS) $(unregister_DEPENDENCIES) $(EXTRA_unregister_DEPENDENCIES) + @rm -f unregister$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(unregister_OBJECTS) $(unregister_LDADD) $(LIBS) vfd$(EXEEXT): $(vfd_OBJECTS) $(vfd_DEPENDENCIES) $(EXTRA_vfd_DEPENDENCIES) @rm -f vfd$(EXEEXT) $(AM_V_CCLD)$(LINK) $(vfd_OBJECTS) $(vfd_LDADD) $(LIBS) @@ -1212,6 +1332,9 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dt_arith.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dtransform.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dtypes.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynlib1.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynlib2.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynlib3.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earray.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/efc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enc_dec_plist.Po@am__quote@ @@ -1261,6 +1384,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntypes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/objcopy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ohdr.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reserved.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_extent.Po@am__quote@ @@ -1300,6 +1424,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tvlstr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tvltypes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unlink.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unregister.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vfd.Po@am__quote@ .c.o: @@ -1431,6 +1556,9 @@ check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) all-local installdirs: + for dir in "$(DESTDIR)$(libdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done install: install-am install-exec: install-exec-am install-data: install-data-am @@ -1462,10 +1590,12 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." +@HAVE_SHARED_CONDITIONAL_FALSE@install-exec-hook: clean: clean-am -clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ - clean-noinstLTLIBRARIES clean-noinstPROGRAMS mostlyclean-am +clean-am: clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \ + clean-libtool clean-noinstLTLIBRARIES clean-noinstPROGRAMS \ + mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) @@ -1491,8 +1621,9 @@ install-dvi: install-dvi-am install-dvi-am: -install-exec-am: - +install-exec-am: install-libLTLIBRARIES + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-exec-hook install-html: install-html-am install-html-am: @@ -1531,24 +1662,25 @@ ps: ps-am ps-am: -uninstall-am: +uninstall-am: uninstall-libLTLIBRARIES -.MAKE: check-am install-am install-strip +.MAKE: check-am install-am install-exec-am install-strip .PHONY: CTAGS GTAGS all all-am all-local check check-TESTS check-am \ - clean clean-checkPROGRAMS clean-generic clean-libtool \ - clean-noinstLTLIBRARIES clean-noinstPROGRAMS cscopelist ctags \ - distclean distclean-compile distclean-generic \ + clean clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \ + clean-libtool clean-noinstLTLIBRARIES clean-noinstPROGRAMS \ + cscopelist ctags distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool mostlyclean-local pdf \ - pdf-am ps ps-am tags uninstall uninstall-am + install-exec-am install-exec-hook install-html install-html-am \ + install-info install-info-am install-libLTLIBRARIES \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool mostlyclean-local pdf pdf-am ps ps-am tags \ + uninstall uninstall-am uninstall-libLTLIBRARIES # List all build rules defined by HDF5 Makefiles as "PHONY" targets here. @@ -1562,6 +1694,16 @@ uninstall-am: help: @$(top_srcdir)/bin/makehelp +@HAVE_SHARED_CONDITIONAL_TRUE@ # The libh5test library provides common support code for the tests. + +@HAVE_SHARED_CONDITIONAL_TRUE@ # The libdynlib1 and libdynlib2 library for testing plugin module plugin.c. +@HAVE_SHARED_CONDITIONAL_TRUE@ # Build it as shared library if configure is enabled for shared library. + +@HAVE_SHARED_CONDITIONAL_TRUE@install-exec-hook: +@HAVE_SHARED_CONDITIONAL_TRUE@ $(RM) $(DESTDIR)$(libdir)/*dynlib* + +@HAVE_SHARED_CONDITIONAL_FALSE@ # The libh5test library provides common support code for the tests. + # Additional target for running timing test timings _timings: testmeta @for timing in $(TIMINGS) dummy; do \ diff --git a/test/dynlib1.c b/test/dynlib1.c new file mode 100644 index 0000000..1ccc33a --- /dev/null +++ b/test/dynlib1.c @@ -0,0 +1,97 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic document set and is * + * linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have access * + * to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * 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 new file mode 100644 index 0000000..a853ed0 --- /dev/null +++ b/test/dynlib2.c @@ -0,0 +1,91 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic document set and is * + * linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have access * + * to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * 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); + + 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 new file mode 100644 index 0000000..9560b86 --- /dev/null +++ b/test/dynlib3.c @@ -0,0 +1,102 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic document set and is * + * linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have access * + * to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * 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); + + 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 = malloc(nbytes + SUFFIX_LEN)); + + /* 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 */ + free(*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/file_image.c b/test/file_image.c index c734db8..d4056a7 100644 --- a/test/file_image.c +++ b/test/file_image.c @@ -1207,6 +1207,9 @@ test_get_file_image_error_rejection(void) err = H5Fclose(file_id); VERIFY(err == SUCCEED, "H5Fclose(2) failed."); + /* tidy up */ + result = h5_cleanup(FILENAME2, fapl_id); + VERIFY(result != 0, "h5_cleanup(2 failed."); /************************** Test #4 **********************************/ /* set up a family file driver test file, and try to get its image diff --git a/test/fillval.c b/test/fillval.c index 847dfbd..9271f80 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -37,6 +37,7 @@ const char *FILENAME[] = { "fillval_6", "fillval_7", "fillval_8", + "fillval_9", NULL }; @@ -2085,6 +2086,266 @@ error: return 1; } +/*------------------------------------------------------------------------- + * Function: test_partalloc_cases + * + * Purpose: Tests fill values read and write for datasets. + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Joel Plutchak + * April 15, 2013 + * + * Modifications: + * This function is called by test_rdwr to write and read + * dataset for different cases of chunked datasets with + * unallocated chunks. + * + *------------------------------------------------------------------------- + */ + +static int +test_partalloc_cases(hid_t file, hid_t dcpl, const char *dname, H5D_fill_time_t fill_time) +{ + hid_t fspace=-1, dset1=-1, rspace = -1; + herr_t ret; + hsize_t ds_size[2] = {4, 4}; + hsize_t max_size[2] = {H5S_UNLIMITED,4}; + hsize_t chunk_size[2] = {1, 4}; + int fillval=(-1); + int w_values[] = {42}; /* New value to be written */ + int f_values[4] = {88,88,88,88}; /* pre-seed read buffer with known values */ + int r_values[4] = {88,88,88,88}; /* pre-seed read buffer with known values */ + hsize_t coord[1][2]; /* coordinate(s) of point to write */ + hsize_t start[2], count[2]; + + fillval = 0; /* default fill value is zero */ + + /* Create dataset with 4x4 integer dataset */ + if((fspace = H5Screate_simple(2, ds_size, max_size)) < 0) + goto error; + if((dset1 = H5Dcreate2(file, dname, H5T_NATIVE_INT, fspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + + /* + * Select a point in the file dataspace. + */ + coord[0][0]=0; coord[0][1]=0; + if (H5Sselect_elements( fspace, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord)) + goto error; + + /* + * Write single data point to the dataset. + */ + if ((ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, fspace, H5P_DEFAULT, w_values))< 0) { + goto error; + } + + /* Read a line/chunk and make sure values are right */ + rspace = H5Screate_simple(2, chunk_size, NULL); + + /* Read the first row of elements: one known plus three fill */ + start[0] = 0; + start[1] = 0; + count[0] = 1; + count[1] = 4; + if ((ret = H5Sselect_hyperslab(fspace, H5S_SELECT_SET, start, NULL, count, NULL)) < 0) + goto error; + if ((ret = H5Sselect_all(rspace)) < 0) + goto error; + if(H5Dread(dset1, H5T_NATIVE_INT, rspace, fspace, H5P_DEFAULT, &r_values) < 0) + goto error; + + /* Read the third row of elements: all fill */ + start[0] = 2; + start[1] = 0; + count[0] = 1; + count[1] = 4; + if ((ret = H5Sselect_hyperslab(fspace, H5S_SELECT_SET, start, NULL, count, NULL)) < 0) + goto error; + if(H5Dread(dset1, H5T_NATIVE_INT, rspace, fspace, H5P_DEFAULT, &f_values) < 0) + goto error; + + if(fill_time != H5D_FILL_TIME_NEVER) { + /* check allocated chunk */ + if ((r_values[0] != w_values[0]) || + (r_values[1] != fillval) || + (r_values[2] != fillval) || + (r_values[3] != fillval)) { + H5_FAILED(); + HDfprintf(stdout, "%u: Allocated chunk value read was not correct.\n", (unsigned)__LINE__); + printf(" {%ld,%ld,%ld,%ld} should be {%ld,%ld,%ld,%ld}\n", + (long)r_values[0], (long)r_values[1], + (long)r_values[2], (long)r_values[3], + (long)w_values[0], (long)fillval, + (long)fillval, (long)fillval ); + goto error; + } + /* check unallocated chunk */ + if ((f_values[0] != fillval) || + (f_values[1] != fillval) || + (f_values[2] != fillval) || + (f_values[3] != fillval)) { + H5_FAILED(); + HDfprintf(stdout, "%u: Unallocated chunk value read was not correct.\n", (unsigned)__LINE__); + printf(" {%ld,%ld,%ld,%ld} should be {%ld,%ld,%ld,%ld}\n", + (long)f_values[0], (long)f_values[1], + (long)f_values[2], (long)f_values[3], + (long)fillval, (long)fillval, + (long)fillval, (long)fillval ); + goto error; + } + /* for the "never fill" case expect to get trash values, so skip */ + } + else if(fill_time == H5D_FILL_TIME_NEVER) { + } + + if(H5Sclose(rspace) < 0) goto error; + if(H5Dclose(dset1) < 0) goto error; + if(H5Sclose(fspace) < 0) goto error; + return 0; + + error: + H5E_BEGIN_TRY { + H5Dclose(dset1); + H5Sclose(fspace); + H5Sclose(rspace); + } H5E_END_TRY; + + return 1; +} + + +/*------------------------------------------------------------------------- + * Function: test_partalloc + * + * Purpose: Tests fill values for chunked, partially-allocated datasets. + * Regression test for HDFFV-8247. + * + * Return: Success: 0 + * + * Failure: number of errors + * + * Programmer: Joel Plutchak + * April 15, 2013 + * + *------------------------------------------------------------------------- + */ +static int +test_partalloc(hid_t fapl, const char *base_name) +{ + char filename[1024]; + hid_t file=-1, dcpl=-1; + hsize_t ch_size[2] = {1, 4}; + int nerrors=0; + + TESTING("chunked dataset partially allocated I/O"); + + h5_fixname(base_name, fapl, filename, sizeof filename); + if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; + + if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + if(H5Pset_chunk(dcpl, 2, ch_size) < 0) goto error; + + /* I. Test H5D_ALLOC_TIME_LATE space allocation cases */ + if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) goto error; +#ifdef DEBUG + fprintf( stdout, "\nALLOC_TIME_LATE\n" ); +#endif + + /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value to be default */ + if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; +#ifdef DEBUG + fprintf( stdout, " FILL_TIME_ALLOC\n" ); +#endif + nerrors += test_partalloc_cases(file, dcpl, "dset1", H5D_FILL_TIME_ALLOC); + + /* case for H5D_FILL_TIME_NEVER as fill write time and fill value to be default */ + if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) goto error; +#ifdef DEBUG + fprintf( stdout, " FILL_TIME_NEVER\n" ); +#endif + nerrors += test_partalloc_cases(file, dcpl, "dset2", H5D_FILL_TIME_NEVER ); + + /* case for H5D_FILL_TIME_IFSET as fill write time and fill value to be default */ + if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) goto error; +#ifdef DEBUG + fprintf( stdout, " FILL_TIME_IFSET\n" ); +#endif + nerrors += test_partalloc_cases(file, dcpl, "dset3", H5D_FILL_TIME_IFSET ); + + /* II. Test H5D_ALLOC_TIME_INCR space allocation cases */ + if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_INCR) < 0) goto error; +#ifdef DEBUG + fprintf( stdout, "\nALLOC_TIME_INCR\n" ); +#endif + + /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value to be default */ + if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; +#ifdef DEBUG + fprintf( stdout, " FILL_TIME_ALLOC\n" ); +#endif + nerrors += test_partalloc_cases(file, dcpl, "dset4", H5D_FILL_TIME_ALLOC ); + + /* case for H5D_FILL_TIME_NEVER as fill write time and fill value to be default */ + if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) goto error; +#ifdef DEBUG + fprintf( stdout, " FILL_TIME_NEVER\n" ); +#endif + nerrors += test_partalloc_cases(file, dcpl, "dset5", H5D_FILL_TIME_NEVER ); + + /* case for H5D_FILL_TIME_IFSET as fill write time and fill value to be default */ + if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) goto error; +#ifdef DEBUG + fprintf( stdout, " FILL_TIME_IFSET\n" ); +#endif + nerrors += test_partalloc_cases(file, dcpl, "dset6", H5D_FILL_TIME_IFSET ); + + /* III. Test H5D_ALLOC_TIME_EARLY space allocation cases */ + if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) goto error; +#ifdef DEBUG + fprintf( stdout, "\nALLOC_TIME_EARLY\n" ); +#endif + + /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value to be default */ + if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; +#ifdef DEBUG + fprintf( stdout, " FILL_TIME_ALLOC\n" ); +#endif + nerrors += test_partalloc_cases(file, dcpl, "dset7", H5D_FILL_TIME_ALLOC ); + + /* case for H5D_FILL_TIME_NEVER as fill write time and fill value to be default */ + if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) goto error; +#ifdef DEBUG + fprintf( stdout, " FILL_TIME_NEVER\n" ); +#endif + nerrors += test_partalloc_cases(file, dcpl, "dset8", H5D_FILL_TIME_NEVER ); + + /* case for H5D_FILL_TIME_IFSET as fill write time and fill value to be default */ + if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) goto error; +#ifdef DEBUG + fprintf( stdout, " FILL_TIME_IFSET\n" ); +#endif + nerrors += test_partalloc_cases(file, dcpl, "dset9", H5D_FILL_TIME_IFSET ); + + if(nerrors) + goto error; + if(H5Pclose(dcpl) < 0) goto error; + if(H5Fclose(file) < 0) goto error; + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Pclose(dcpl); + H5Fclose(file); + } H5E_END_TRY; + return nerrors; +} + /*------------------------------------------------------------------------- * Function: main @@ -2157,6 +2418,7 @@ main(int argc, char *argv[]) nerrors += test_create(my_fapl, FILENAME[0], H5D_CHUNKED); nerrors += test_rdwr (my_fapl, FILENAME[2], H5D_CHUNKED); nerrors += test_extend(my_fapl, FILENAME[4], H5D_CHUNKED); + nerrors += test_partalloc(my_fapl, FILENAME[8]); } /* end if */ /* Contiguous storage layout tests */ diff --git a/test/plugin.c b/test/plugin.c new file mode 100644 index 0000000..86bc952 --- /dev/null +++ b/test/plugin.c @@ -0,0 +1,732 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic document set and is * + * linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have access * + * to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * Programmer: Raymond Lu + * 13 February 2013 + * + * Purpose: Tests the plugin module (H5PL) + */ +#include <stdlib.h> +#include <time.h> + +#include "h5test.h" +#include "H5srcdir.h" + +/* + * This file needs to access private datatypes from the H5Z package. + */ +#define H5Z_PACKAGE +#include "H5Zpkg.h" + +/* Filters for HDF5 internal test */ +#define H5Z_FILTER_DYNLIB1 257 +#define H5Z_FILTER_DYNLIB2 258 +#define H5Z_FILTER_DYNLIB3 259 + +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" + +/* 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_bzip2[DSET_DIM1][DSET_DIM2]; + + +/*------------------------------------------------------------------------- + * Function: test_filter_internal + * + * Purpose: Tests writing entire data and partial data with filters + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Raymond Lu + * 27 February 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_filter_internal(hid_t fid, const char *name, hid_t dcpl) +{ + hid_t dataset; /* Dataset ID */ + hid_t dxpl; /* Dataset xfer property list ID */ + hid_t write_dxpl; /* Dataset xfer property list ID for writing */ + hid_t sid; /* 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) goto 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) goto error; + tconv_buf = HDmalloc((size_t)1000); + if(H5Pset_buffer(dxpl, (size_t)1000, tconv_buf, NULL) < 0) goto 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(); + printf(" Line %d: Incorrect filter availability\n",__LINE__); + goto error; + } /* end if */ + + /* Create the dataset */ + if((dataset = H5Dcreate2(fid, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, + dcpl, H5P_DEFAULT)) < 0) goto 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(); + printf(" Read a non-zero value.\n"); + printf(" At index %lu,%lu\n", + (unsigned long)i, (unsigned long)j); + goto 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<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(); + fprintf(stderr," Read different values than written.\n"); + fprintf(stderr," At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); + fprintf(stderr," At original: %d\n", (int)points[i][j]); + fprintf(stderr," At returned: %d\n", (int)check[i][j]); + goto 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<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(); + printf(" Read different values than written.\n"); + printf(" At index %lu,%lu\n", + (unsigned long)i, (unsigned long)j); + goto 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(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(); + printf(" Read different values than written.\n"); + printf(" At index %lu,%lu\n", + (unsigned long)i, (unsigned long)j); + goto 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(); + fprintf(stderr," Read different values than written.\n"); + fprintf(stderr," At index %lu,%lu\n", + (unsigned long)((size_t)hs_offset[0]+i), + (unsigned long)((size_t)hs_offset[1]+j)); + fprintf(stderr," At original: %d\n", + (int)points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]); + fprintf(stderr," At returned: %d\n", + (int)check[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]); + goto error; + } + } + } + + 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]; + } + } + } + + /* Clean up objects used for this test */ + if(H5Dclose (dataset) < 0) goto error; + if(H5Sclose (sid) < 0) goto error; + if(H5Pclose (dxpl) < 0) goto error; + free (tconv_buf); + + return(0); + +error: + if(tconv_buf) + free (tconv_buf); + return -1; +} + +/*------------------------------------------------------------------------- + * Function: test_filters_for_datasets + * + * Purpose: Tests creating datasets and writing data with dynamically + * loaded filters + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Raymond Lu + * 14 March 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_filters_for_datasets(hid_t file) +{ + hid_t dc; /* Dataset creation property list ID */ + const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */ + unsigned int compress_level = 9; + + /*---------------------------------------------------------- + * STEP 1: Test deflation by itself. + *---------------------------------------------------------- + */ +#ifdef H5_HAVE_FILTER_DEFLATE + puts("Testing deflate filter"); + if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error; + if(H5Pset_deflate (dc, 6) < 0) goto error; + + if(test_filter_internal(file,DSET_DEFLATE_NAME,dc) < 0) goto error; + /* Clean up objects used for this test */ + if(H5Pclose (dc) < 0) goto error; +#else /* H5_HAVE_FILTER_DEFLATE */ + TESTING("deflate filter"); + SKIPPED(); + puts(" Deflate filter not enabled"); +#endif /* H5_HAVE_FILTER_DEFLATE */ + + /*---------------------------------------------------------- + * STEP 2: Test DYNLIB1 by itself. + *---------------------------------------------------------- + */ + puts("Testing DYNLIB1 filter"); + if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error; + if(H5Pset_filter (dc, H5Z_FILTER_DYNLIB1, H5Z_FLAG_MANDATORY, (size_t)1, &compress_level) < 0) goto error; + + if(test_filter_internal(file,DSET_DYNLIB1_NAME,dc) < 0) goto error; + + /* Clean up objects used for this test */ + if(H5Pclose (dc) < 0) goto 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) goto error; + + /*---------------------------------------------------------- + * STEP 3: Test DYNLIB2 by itself. + *---------------------------------------------------------- + */ + puts("Testing DYNLIB2 filter"); + if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error; + if(H5Pset_filter (dc, H5Z_FILTER_DYNLIB2, H5Z_FLAG_MANDATORY, 0, NULL) < 0) goto error; + + if(test_filter_internal(file,DSET_DYNLIB2_NAME,dc) < 0) goto error; + + /* Clean up objects used for this test */ + if(H5Pclose (dc) < 0) goto 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) goto error; + + return 0; + +error: + return -1; +} + +/*------------------------------------------------------------------------- + * Function: test_read_data + * + * Purpose: Tests reading data and compares values + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Raymond Lu + * 14 March 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_read_data(hid_t dataset, int *origin_data) +{ + 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(); + fprintf(stderr," Read different values than written.\n"); + fprintf(stderr," At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); + fprintf(stderr," At original: %d\n", *data_p); + fprintf(stderr," At returned: %d\n", (int)check[i][j]); + goto error; + } + data_p++; + } + } + + PASSED(); + return 0; + +error: + return -1; +} + +/*------------------------------------------------------------------------- + * Function: test_read_with_filters + * + * Purpose: Tests reading dataset created with dynamically loaded filters + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Raymond Lu + * 14 March 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_read_with_filters(hid_t file) +{ + hid_t dset; /* Dataset ID */ + + /*---------------------------------------------------------- + * STEP 1: Test deflation by itself. + *---------------------------------------------------------- + */ +#ifdef H5_HAVE_FILTER_DEFLATE + TESTING("Testing deflate filter"); + + 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 */ + TESTING("deflate filter"); + SKIPPED(); + puts(" Deflate filter not enabled"); +#endif /* H5_HAVE_FILTER_DEFLATE */ + + /*---------------------------------------------------------- + * STEP 2: Test DYNLIB1 by itself. + *---------------------------------------------------------- + */ + TESTING("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("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 + + return 0; + +error: + return -1; +} + +/*------------------------------------------------------------------------- + * Function: test_filters_for_groups + * + * Purpose: Tests creating group with dynamically loaded filters + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Raymond Lu + * 1 April 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_filters_for_groups(hid_t file) +{ + hid_t gcpl, gid, group; + int i; + char gname[256]; + + TESTING("Testing DYNLIB3 filter for group"); + + if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) goto error; + + /* Use DYNLIB3 for creating groups */ + if(H5Pset_filter (gcpl, H5Z_FILTER_DYNLIB3, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) goto error; + + /* Create a group using this filter */ + if((gid = H5Gcreate2(file, "group1", H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) goto error; + + /* Create multiple groups under "group1" */ + for (i=0; i < GROUP_ITERATION; i++) { + sprintf(gname, "group_%d", i); + if((group = H5Gcreate2(gid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if(H5Gclose(group) < 0) goto error; + } + + /* Close the group */ + if(H5Gclose(gid) < 0) goto error; + + /* Clean up objects used for this test */ + if(H5Pclose (gcpl) < 0) goto error; + + PASSED(); + + return 0; + +error: + return -1; +} + +/*------------------------------------------------------------------------- + * Function: test_groups_with_filters + * + * Purpose: Tests opening group with dynamically loaded filters + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Raymond Lu + * 1 April 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_groups_with_filters(hid_t file) +{ + hid_t gid, group; + int i; + char gname[256]; + + TESTING("Testing opening groups with DYNLIB3 filter"); + + /* Open the top group */ + if((gid = H5Gopen2(file, "group1", H5P_DEFAULT)) < 0) goto error; + + /* Create multiple groups under "group1" */ + for (i=0; i < GROUP_ITERATION; i++) { + sprintf(gname, "group_%d", i); + if((group = H5Gopen2(gid, gname, H5P_DEFAULT)) < 0) goto error; + if(H5Gclose(group) < 0) goto error; + } + + /* Close the group */ + if(H5Gclose(gid) < 0) goto error; + + PASSED(); + + return 0; + +error: + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Tests the plugin module (H5PL) + * + * Return: Success: exit(0) + * + * Failure: exit(1) + * + * Programmer: Raymond Lu + * 14 March 2013 + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + char filename[FILENAME_BUF_SIZE]; + hid_t file, fapl, fapl2; + hbool_t new_format; + int mdc_nelmts; + size_t rdcc_nelmts; + size_t rdcc_nbytes; + double rdcc_w0; + int nerrors = 0; + + /* Testing setup */ + h5_reset(); + fapl = h5_fileaccess(); + + /* 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) { + puts("\nTesting with new file format:"); + my_fapl = fapl2; + } /* end if */ + else { + puts("Testing with old file format:"); + my_fapl = fapl; + } /* end else */ + + /* 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 + + puts("\nTesting reading data with with dynamic plugin filters:"); + + /* Close the library so that all loaded plugin libraries are unloaded */ + h5_reset(); + fapl = h5_fileaccess(); + + /* 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); + + if(H5Fclose(file) < 0) + TEST_ERROR + + if(nerrors) + TEST_ERROR + printf("All plugin tests passed.\n"); + h5_cleanup(FILENAME, fapl); + + return 0; + +error: + nerrors = MAX(1, nerrors); + printf("***** %d PLUGIN TEST%s FAILED! *****\n", + nerrors, 1 == nerrors ? "" : "S"); + return 1; +} + diff --git a/test/test_plugin.sh.in b/test/test_plugin.sh.in new file mode 100644 index 0000000..569e938 --- /dev/null +++ b/test/test_plugin.sh.in @@ -0,0 +1,93 @@ +#! /bin/sh +# +# 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 files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic document set and is +# linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have access +# to either file, you may request a copy from help@hdfgroup.org. +# +srcdir=@srcdir@ +TOP_BUILDDIR=@top_builddir@ + +# Determine backward compatibility options enabled +DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@" + +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + +nerrors=0 +verbose=yes +exit_code=$EXIT_SUCCESS + +TEST_NAME=plugin +TEST_BIN=`pwd`/$TEST_NAME +FROM_DIR=`pwd`/.libs +PLUGIN_LIB1="$FROM_DIR/libdynlib1.* $FROM_DIR/libdynlib3.*" +PLUGIN_LIB2="$FROM_DIR/libdynlib2.*" +PLUGIN_LIBDIR1=testdir1 +PLUGIN_LIBDIR2=testdir2 +CP="cp -p" # Use -p to preserve mode,ownership,timestamps +RM="rm -rf" + +# Print a line-line message left justified in a field of 70 characters +# beginning with the word "Testing". +# +TESTING() { + SPACES=" " + echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' +} + +# Main Body +# Create test directories if not exists yet. +test -d $PLUGIN_LIBDIR1 || mkdir -p $PLUGIN_LIBDIR1 +if [ $? != 0 ]; then + echo "Failed to create test directory($PLUGIN_LIBDIR1)" + exit $EXIT_FAILURE +fi + +test -d $PLUGIN_LIBDIR2 || mkdir -p $PLUGIN_LIBDIR2 +if [ $? != 0 ]; then + echo "Failed to create test directory($PLUGIN_LIBDIR2)" + exit $EXIT_FAILURE +fi + +# copy plugin library for test +$CP $PLUGIN_LIB1 $PLUGIN_LIBDIR1 +if [ $? != 0 ]; then + echo "Failed to copy plugin library ($PLUGIN_LIB1) for test." + exit $EXIT_FAILURE +fi + +$CP $PLUGIN_LIB2 $PLUGIN_LIBDIR2 +if [ $? != 0 ]; then + echo "Failed to copy plugin library ($PLUGIN_LIB2) for test." + exit $EXIT_FAILURE +fi + +# setup plugin path +ENVCMD="env HDF5_PLUGIN_PATH=${PLUGIN_LIBDIR1}:${PLUGIN_LIBDIR2}" + +# Run the test +$ENVCMD $TEST_BIN +if [ $? != 0 ]; then + nerrors=`expr $nerrors + 1` +fi + +# print results +if test $nerrors -ne 0 ; then + echo "$nerrors errors encountered" + exit_code=$EXIT_FAILURE +else + echo "All Plugin API tests passed." + exit_code=$EXIT_SUCCESS +fi + +# Clean up temporary files/directories and leave +$RM $PLUGIN_LIBDIR2 +exit $exit_code diff --git a/test/testerror.sh.in b/test/testerror.sh.in index b68fa7e..eb01fb1 100644 --- a/test/testerror.sh.in +++ b/test/testerror.sh.in @@ -23,6 +23,9 @@ DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@" CMP='cmp -s' DIFF='diff -c' +# Skip plugin module to test missing filter +ENVCMD="env HDF5_PLUGIN_PRELOAD=::" + nerrors=0 verbose=yes @@ -61,7 +64,9 @@ TEST() { echo "#############################" echo "Expected output for $TEST_ERR" echo "#############################" - $RUNSERIAL $TEST_ERR_BIN + + # Skip the plugin for testing missing filter. + $ENVCMD $RUNSERIAL $TEST_ERR_BIN ) >$actual 2>$actual_err # Extract file name, line number, version and thread IDs because they may be different sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \ @@ -109,7 +114,7 @@ else TEST err_compat fi -# test for error_test +# test for error_test. Skip the plugin for testing missing filter. TEST error_test if test $nerrors -eq 0 ; then diff --git a/test/testframe.c b/test/testframe.c index 8ab7a5b..af6e975 100644 --- a/test/testframe.c +++ b/test/testframe.c @@ -26,7 +26,7 @@ /* * Definitions for the testing structure. */ -#define MAXNUMOFTESTS 50 +#define MAXNUMOFTESTS 60 #define MAXTESTNAME 16 #define MAXTESTDESC 64 @@ -73,7 +73,7 @@ AddTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), con { /* Sanity checking */ if (Index >= MAXNUMOFTESTS) { - printf("Too many tests added, increase MAXNUMOFTEST(%d).\n", + printf("Too many tests added, increase MAXNUMOFTESTS(%d).\n", MAXNUMOFTESTS); exit(-1); } /* end if */ diff --git a/test/unregister.c b/test/unregister.c new file mode 100644 index 0000000..383958d --- /dev/null +++ b/test/unregister.c @@ -0,0 +1,256 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic document set and is * + * linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have access * + * to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * Programmer: Raymond Lu + * 24 April 2013 + * + * Purpose: Tests H5Zunregister function + */ +#include "h5test.h" + +const char *FILENAME[] = { + "unregister_filter_1", + "unregister_filter_2", + NULL +}; + +#define GROUP_NAME "group" +#define DSET_NAME "dataset" +#define FILENAME_BUF_SIZE 1024 +#define DSET_DIM1 100 +#define DSET_DIM2 200 +#define FILTER_CHUNK_DIM1 2 +#define FILTER_CHUNK_DIM2 25 +#define GROUP_ITERATION 1000 + +#define H5Z_FILTER_DUMMY 312 + +static size_t filter_dummy(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); + +/* Dummy filter for test_unregister_filters only */ +const H5Z_class2_t H5Z_DUMMY[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_DUMMY, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "dummy", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + filter_dummy, /* The actual filter function */ +}}; + + +/*------------------------------------------------------------------------- + * Function: filter_dummy + * + * Purpose: A dummy compression method that doesn't do anything. This + * filter is only for test_unregister_filters. Please don't + * use it for other tests because it may mess up this test. + * + * Return: Success: Data chunk size + * + * Failure: 0 + * + * Programmer: Raymond Lu + * April 24, 2013 + * + *------------------------------------------------------------------------- + */ +static size_t +filter_dummy(unsigned int UNUSED flags, size_t UNUSED cd_nelmts, + const unsigned int UNUSED *cd_values, size_t nbytes, + size_t UNUSED *buf_size, void UNUSED **buf) +{ + return nbytes; +} + +/*------------------------------------------------------------------------- + * Function: test_unregister_filters + * + * Purpose: Tests unregistering filter before closing the file + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Raymond Lu + * 11 April 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_unregister_filters(hid_t my_fapl) +{ + hid_t file1, file2; + hid_t dc; + hid_t gcpl, gid, group; + hid_t dataset, space; + int i, j, n; + char gname[256]; + char filename[FILENAME_BUF_SIZE]; + const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */ + hsize_t dims[2]; + int points[DSET_DIM1][DSET_DIM2]; + herr_t ret; + + TESTING("Unregistering filter"); + + /* Create first file */ + h5_fixname(FILENAME[0], my_fapl, filename, sizeof filename); + if((file1 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) goto error; + + /* Create second file */ + h5_fixname(FILENAME[1], my_fapl, filename, sizeof filename); + if((file2 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) goto error; + + /* Register DUMMY filter */ + if(H5Zregister(H5Z_DUMMY) < 0) goto error; + + if(H5Zfilter_avail(H5Z_FILTER_DUMMY)!=TRUE) goto error; + + if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) goto error; + + /* Use DUMMY filter for creating groups */ + if(H5Pset_filter (gcpl, H5Z_FILTER_DUMMY, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) goto error; + + /* Create a group using this filter */ + if((gid = H5Gcreate2(file1, GROUP_NAME, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) goto error; + + /* Create multiple groups under the main group */ + for (i=0; i < GROUP_ITERATION; i++) { + sprintf(gname, "group_%d", i); + if((group = H5Gcreate2(gid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if(H5Gclose(group) < 0) goto error; + } + + if(H5Fflush(file1, H5F_SCOPE_GLOBAL) < 0) goto error; + + /* Unregister the filter before closing the group. It should fail */ + H5E_BEGIN_TRY { + ret = H5Zunregister(H5Z_FILTER_DUMMY); + } H5E_END_TRY; + if(ret>=0) { + H5_FAILED(); + printf(" Line %d: Should not be able to unregister filter\n", __LINE__); + goto error; + } /* end if */ + + /* Close the group */ + if(H5Gclose(gid) < 0) goto error; + + /* Clean up objects used for this test */ + if(H5Pclose (gcpl) < 0) goto error; + + if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error; + + if(H5Pset_filter(dc, H5Z_FILTER_DUMMY, 0, (size_t)0, NULL) < 0) goto error; + + /* Initialize the dataset */ + for(i = n = 0; i < DSET_DIM1; i++) + for(j = 0; j < DSET_DIM2; j++) + points[i][j] = n++; + + /* Create the data space */ + dims[0] = DSET_DIM1; + dims[1] = DSET_DIM2; + if((space = H5Screate_simple(2, dims, NULL)) < 0) goto error; + + /* Create a dataset in the first file */ + if((dataset = H5Dcreate2(file1, DSET_NAME, H5T_NATIVE_INT, space, + H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error; + + /* Write the data to the dataset */ + if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) + goto error; + + /* Unregister the filter before closing the dataset. It should fail */ + H5E_BEGIN_TRY { + ret = H5Zunregister(H5Z_FILTER_DUMMY); + } H5E_END_TRY; + if(ret>=0) { + H5_FAILED(); + printf(" Line %d: Should not be able to unregister filter\n", __LINE__); + goto error; + } /* end if */ + + if(H5Dclose(dataset) < 0) goto error; + + /* Create a dataset in the second file */ + if((dataset = H5Dcreate2(file2, DSET_NAME, H5T_NATIVE_INT, space, + H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error; + + /* Write the data to the dataset */ + if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) + goto error; + + if(H5Dclose(dataset) < 0) goto error; + + /* Unregister the filter after closing all objects but before closing files. + * It should flush all files. */ + if(H5Zunregister(H5Z_FILTER_DUMMY) < 0) goto error; + + /* Clean up objects used for this test */ + if(H5Pclose (dc) < 0) goto error; + if(H5Fclose(file1) < 0) goto error; + if(H5Fclose(file2) < 0) goto error; + + PASSED(); + return 0; + +error: + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Tests unregistering filter with H5Zunregister + * + * Return: Success: exit(0) + * + * Failure: exit(1) + * + * Programmer: Raymond Lu + * 11 April 2013 + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + hid_t fapl; + int nerrors = 0; + + /* Testing setup */ + h5_reset(); + fapl = h5_fileaccess(); + + /* Test unregistering filter in its own file */ + nerrors += (test_unregister_filters(fapl) < 0 ? 1 : 0); + + if(nerrors) + goto error; + printf("All filter unregistration tests passed.\n"); + h5_cleanup(FILENAME, fapl); + + return 0; + +error: + nerrors = MAX(1, nerrors); + printf("***** %d FILTER UNREGISTRATION TEST%s FAILED! *****\n", + nerrors, 1 == nerrors ? "" : "S"); + return 1; +} + |