diff options
-rw-r--r-- | MANIFEST | 3 | ||||
-rw-r--r-- | tools/h5repack/CMakeLists.txt | 21 | ||||
-rw-r--r-- | tools/h5repack/CMakeTests.cmake | 3 | ||||
-rw-r--r-- | tools/h5repack/Makefile.am | 3 | ||||
-rw-r--r-- | tools/h5repack/dynlib_vrpk.c | 115 | ||||
-rw-r--r-- | tools/h5repack/h5repack.sh.in | 2 | ||||
-rw-r--r-- | tools/h5repack/testfiles/h5repack_layout.h5-plugin_test.ddl | 2 | ||||
-rw-r--r-- | tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl | 158 | ||||
-rw-r--r-- | tools/h5repack/testfiles/plugin_version_test.h5repack_layout.h5.tst | 14 |
9 files changed, 314 insertions, 7 deletions
@@ -1106,6 +1106,7 @@ ./tools/h5repack/Makefile.am ./tools/h5repack/Makefile.in ./tools/h5repack/dynlib_rpk.c +./tools/h5repack/dynlib_vrpk.c ./tools/h5repack/h5repack.sh.in ./tools/h5repack/h5repack_plugin.sh.in ./tools/h5repack/h5repack.c @@ -2027,12 +2028,14 @@ ./tools/h5repack/testfiles/deflate_limit.h5repack_layout.h5.ddl ./tools/h5repack/testfiles/plugin_none.h5repack_layout.UD.h5.tst ./tools/h5repack/testfiles/plugin_test.h5repack_layout.h5.tst +./tools/h5repack/testfiles/plugin_version_test.h5repack_layout.h5.tst ./tools/h5repack/testfiles/h5repack-help.txt ./tools/h5repack/testfiles/h5repack_filters.h5.tst ./tools/h5repack/testfiles/h5repack_filters.h5-gzip_verbose_filters.tst ./tools/h5repack/testfiles/h5repack_layout.h5.ddl ./tools/h5repack/testfiles/h5repack_layout.UD.h5-plugin_none.ddl ./tools/h5repack/testfiles/h5repack_layout.h5-plugin_test.ddl +./tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl ./tools/h5repack/testfiles/h5repack_layout.h5-plugin_zero.tst # jam utility and tests diff --git a/tools/h5repack/CMakeLists.txt b/tools/h5repack/CMakeLists.txt index 0e9c28f..f4f48b7 100644 --- a/tools/h5repack/CMakeLists.txt +++ b/tools/h5repack/CMakeLists.txt @@ -51,16 +51,21 @@ if (BUILD_TESTING) set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibadd") set (HDF5_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_CORENAME}") set (HDF5_TOOL_PLUGIN_LIB_TARGET ${HDF5_TOOL_PLUGIN_LIB_CORENAME}) + set (HDF5_TOOL_PLUGIN_LIB_VCORENAME "dynlibvers") + set (HDF5_TOOL_PLUGIN_LIB_VNAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_VCORENAME}") + set (HDF5_TOOL_PLUGIN_LIB_VTARGET ${HDF5_TOOL_PLUGIN_LIB_VCORENAME}) add_definitions (${HDF_EXTRA_C_FLAGS}) INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_rpk.c) TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED " " " ") target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) - H5_SET_LIB_OPTIONS ( - ${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TOOL_PLUGIN_LIB_NAME} - SHARED ${HDF5_PACKAGE_SOVERSION} - ) + H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TOOL_PLUGIN_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION}) + + add_library (${HDF5_TOOL_PLUGIN_LIB_VTARGET} SHARED dynlib_vrpk.c) + TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_VTARGET} SHARED " " " ") + target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_VTARGET} ${HDF5_TEST_LIB_TARGET}) + H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_VTARGET} ${HDF5_TOOL_PLUGIN_LIB_VNAME} SHARED ${HDF5_PACKAGE_SOVERSION}) # make plugins dir file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") @@ -75,6 +80,14 @@ if (BUILD_TESTING) "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" ) + add_custom_command ( + TARGET ${HDF5_TOOL_PLUGIN_LIB_VTARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_VTARGET}>" + "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_VTARGET}>" + ) include (CMakeTests.cmake) diff --git a/tools/h5repack/CMakeTests.cmake b/tools/h5repack/CMakeTests.cmake index c7171d8..367a61f 100644 --- a/tools/h5repack/CMakeTests.cmake +++ b/tools/h5repack/CMakeTests.cmake @@ -92,6 +92,8 @@ ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/plugin_test.h5repack_layout.h5.tst ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layout.UD.h5-plugin_none.ddl ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/plugin_none.h5repack_layout.UD.h5.tst + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layout.h5-plugin_version_test.ddl + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/plugin_version_test.h5repack_layout.h5.tst ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layout.h5-plugin_zero.tst ) @@ -988,6 +990,7 @@ ############################################################################## ### P L U G I N T E S T S ############################################################################## + ADD_H5_UD_TEST (plugin_version_test 0 h5repack_layout.h5 -v -f UD=260,4,9,1,9,235) ADD_H5_UD_TEST (plugin_test 0 h5repack_layout.h5 -v -f UD=257,1,9) ADD_H5_UD_TEST (plugin_none 0 h5repack_layout.UD.h5 -v -f NONE) # check for no parameters diff --git a/tools/h5repack/Makefile.am b/tools/h5repack/Makefile.am index 21ac362..5f32d73 100644 --- a/tools/h5repack/Makefile.am +++ b/tools/h5repack/Makefile.am @@ -63,8 +63,9 @@ h5repack.sh.chkexe_: h5repacktst.chkexe_ if HAVE_SHARED_CONDITIONAL # Build it as shared library if configure is enabled for shared library. - lib_LTLIBRARIES=libdynlibadd.la + lib_LTLIBRARIES=libdynlibadd.la libdynlibvers.la libdynlibadd_la_SOURCES=dynlib_rpk.c + libdynlibvers_la_SOURCES=dynlib_vrpk.c install-exec-hook: $(RM) $(DESTDIR)$(libdir)/*dynlib* diff --git a/tools/h5repack/dynlib_vrpk.c b/tools/h5repack/dynlib_vrpk.c new file mode 100644 index 0000000..63ceaec --- /dev/null +++ b/tools/h5repack/dynlib_vrpk.c @@ -0,0 +1,115 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * Purpose: Tests the plugin module (H5PL) + */ + +#include <stdlib.h> +#include <stdio.h> +#include "H5PLextern.h" + +#define H5Z_FILTER_DYNLIB4 260 + +/* gcc attribute support from H5private.h */ +#ifdef __cplusplus +# define H5_ATTR_CONST /*void*/ +#else /* __cplusplus */ +#if defined(H5_HAVE_ATTRIBUTE) && !defined(__SUNPRO_C) +# define H5_ATTR_CONST __attribute__((const)) +#else +# define H5_ATTR_CONST /*void*/ +#endif +#endif /* __cplusplus */ + +#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 */ +}}; + +H5_ATTR_CONST H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} +H5_ATTR_CONST 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/tools/h5repack/h5repack.sh.in b/tools/h5repack/h5repack.sh.in index 4a32491..de55f20 100644 --- a/tools/h5repack/h5repack.sh.in +++ b/tools/h5repack/h5repack.sh.in @@ -1034,7 +1034,7 @@ TOOLTEST add_alignment $arg # Check repacking file with old version of layout message (should get upgraded # to new version and be readable, etc.) -TOOLTEST pgrade_layout h5repack_layouto.h5 +TOOLTEST upgrade_layout h5repack_layouto.h5 # test for datum size > H5TOOLS_MALLOCSIZE TOOLTEST gt_mallocsize h5repack_objs.h5 -f GZIP=1 diff --git a/tools/h5repack/testfiles/h5repack_layout.h5-plugin_test.ddl b/tools/h5repack/testfiles/h5repack_layout.h5-plugin_test.ddl index 87b133d..a8b4562 100644 --- a/tools/h5repack/testfiles/h5repack_layout.h5-plugin_test.ddl +++ b/tools/h5repack/testfiles/h5repack_layout.h5-plugin_test.ddl @@ -90,7 +90,7 @@ GROUP "/" { } DATASET "dset_chunk" { DATATYPE H5T_STD_I32LE - DATASPACE SIMPLE { ( 40, 20 ) / ( 40, H5S_UNLIMITED ) } + DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } STORAGE_LAYOUT { CHUNKED ( 20, 10 ) SIZE 3200 (1.000:1 COMPRESSION) diff --git a/tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl b/tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl new file mode 100644 index 0000000..3d09e14 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl @@ -0,0 +1,158 @@ +HDF5 "out-plugin_version_test.h5repack_layout.h5" { +GROUP "/" { + DATASET "dset1" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } + STORAGE_LAYOUT { + CHUNKED ( 40, 20 ) + SIZE 3200 (1.000:1 COMPRESSION) + } + FILTERS { + USER_DEFINED_FILTER { + FILTER_ID 260 + COMMENT dynlib4 + PARAMS { 9 1 9 235 } + } + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } + DATASET "dset2" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } + STORAGE_LAYOUT { + CHUNKED ( 40, 20 ) + SIZE 3200 (1.000:1 COMPRESSION) + } + FILTERS { + USER_DEFINED_FILTER { + FILTER_ID 260 + COMMENT dynlib4 + PARAMS { 9 1 9 235 } + } + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } + DATASET "dset3" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } + STORAGE_LAYOUT { + CHUNKED ( 40, 20 ) + SIZE 3200 (1.000:1 COMPRESSION) + } + FILTERS { + USER_DEFINED_FILTER { + FILTER_ID 260 + COMMENT dynlib4 + PARAMS { 9 1 9 235 } + } + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } + DATASET "dset4" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } + STORAGE_LAYOUT { + CHUNKED ( 40, 20 ) + SIZE 3200 (1.000:1 COMPRESSION) + } + FILTERS { + USER_DEFINED_FILTER { + FILTER_ID 260 + COMMENT dynlib4 + PARAMS { 9 1 9 235 } + } + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } + DATASET "dset_chunk" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } + STORAGE_LAYOUT { + CHUNKED ( 20, 10 ) + SIZE 3200 (1.000:1 COMPRESSION) + } + FILTERS { + USER_DEFINED_FILTER { + FILTER_ID 260 + COMMENT dynlib4 + PARAMS { 9 1 9 235 } + } + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } + DATASET "dset_compact" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } + STORAGE_LAYOUT { + CHUNKED ( 40, 20 ) + SIZE 3200 (1.000:1 COMPRESSION) + } + FILTERS { + USER_DEFINED_FILTER { + FILTER_ID 260 + COMMENT dynlib4 + PARAMS { 9 1 9 235 } + } + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } + DATASET "dset_contiguous" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } + STORAGE_LAYOUT { + CHUNKED ( 40, 20 ) + SIZE 3200 (1.000:1 COMPRESSION) + } + FILTERS { + USER_DEFINED_FILTER { + FILTER_ID 260 + COMMENT dynlib4 + PARAMS { 9 1 9 235 } + } + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } +} +} diff --git a/tools/h5repack/testfiles/plugin_version_test.h5repack_layout.h5.tst b/tools/h5repack/testfiles/plugin_version_test.h5repack_layout.h5.tst new file mode 100644 index 0000000..1a496c6 --- /dev/null +++ b/tools/h5repack/testfiles/plugin_version_test.h5repack_layout.h5.tst @@ -0,0 +1,14 @@ +Objects to modify layout are... +Objects to apply filter are... + User Defined 260 +----------------------------------------- + Type Filter (Compression) Name +----------------------------------------- + group / + dset UD (1.000:1) /dset1 + dset UD (1.000:1) /dset2 + dset UD (1.000:1) /dset3 + dset UD (1.000:1) /dset4 + dset UD (1.000:1) /dset_chunk + dset UD (1.000:1) /dset_compact + dset UD (1.000:1) /dset_contiguous |