summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2016-10-18 17:14:25 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2016-10-18 17:14:25 (GMT)
commit7ea09c9292e74a195a0c5909f9e3790f48e5a3a5 (patch)
treef159c99bd21aa1788e128720f13c1199d41ce0e2 /tools
parentb6bb7c123a02570a33f02257d738e50195dbeb3a (diff)
downloadhdf5-7ea09c9292e74a195a0c5909f9e3790f48e5a3a5.zip
hdf5-7ea09c9292e74a195a0c5909f9e3790f48e5a3a5.tar.gz
hdf5-7ea09c9292e74a195a0c5909f9e3790f48e5a3a5.tar.bz2
HDFFV-9996: Test file to verify that that multiple params are parsed
Diffstat (limited to 'tools')
-rw-r--r--tools/h5repack/CMakeLists.txt16
-rw-r--r--tools/h5repack/CMakeTests.cmake3
-rw-r--r--tools/h5repack/Makefile.am2
-rw-r--r--tools/h5repack/dynlib_vrpk.c115
-rw-r--r--tools/h5repack/h5repack_plugin.sh.in49
-rw-r--r--tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl158
-rw-r--r--tools/h5repack/testfiles/plugin_version_test.h5repack_layout.h5.tst14
7 files changed, 335 insertions, 22 deletions
diff --git a/tools/h5repack/CMakeLists.txt b/tools/h5repack/CMakeLists.txt
index 2f2e3e2..4a21605 100644
--- a/tools/h5repack/CMakeLists.txt
+++ b/tools/h5repack/CMakeLists.txt
@@ -51,6 +51,9 @@ 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})
@@ -59,6 +62,11 @@ if (BUILD_TESTING)
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})
+ 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")
#-----------------------------------------------------------------------------
@@ -72,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 666f28e..e8ee00f 100644
--- a/tools/h5repack/CMakeTests.cmake
+++ b/tools/h5repack/CMakeTests.cmake
@@ -116,6 +116,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/1_vds.h5-vds_dset_chunk20x10x5-v.ddl
${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/2_vds.h5-vds_chunk3x6x9-v.ddl
${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/3_1_vds.h5-vds_chunk2x5x8-v.ddl
@@ -1133,6 +1135,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..eddc989 100644
--- a/tools/h5repack/Makefile.am
+++ b/tools/h5repack/Makefile.am
@@ -65,6 +65,8 @@ if HAVE_SHARED_CONDITIONAL
# Build it as shared library if configure is enabled for shared library.
lib_LTLIBRARIES=libdynlibadd.la
libdynlibadd_la_SOURCES=dynlib_rpk.c
+ lib_LTLIBRARIES=libdynlibvers.la
+ 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_plugin.sh.in b/tools/h5repack/h5repack_plugin.sh.in
index a064db6..9d340ad 100644
--- a/tools/h5repack/h5repack_plugin.sh.in
+++ b/tools/h5repack/h5repack_plugin.sh.in
@@ -1,16 +1,16 @@
#! /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.
+# 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@
@@ -65,6 +65,8 @@ LIST_HDF5_TEST_FILES="
$SRC_H5REPACK_TESTFILES/h5repack_layout.h5
$SRC_H5REPACK_TESTFILES/h5repack_layout.h5-plugin_test.ddl
$SRC_H5REPACK_TESTFILES/plugin_test.h5repack_layout.h5.tst
+$SRC_H5REPACK_TESTFILES/h5repack_layout.h5-plugin_version_test.ddl
+$SRC_H5REPACK_TESTFILES/plugin_version_test.h5repack_layout.h5.tst
"
#$SRC_H5REPACK_TESTFILES/h5repack_layout.UD.h5
#$SRC_H5REPACK_TESTFILES/h5repack_layout.UD.h5-plugin_none.ddl
@@ -113,7 +115,7 @@ COPY_TESTFILES_TO_TESTDIR()
$CP -f $tstfile $TESTDIR
if [ $? -ne 0 ]; then
echo "Error: FAILED to copy $tstfile ."
-
+
# Comment out this to CREATE expected file
exit $EXIT_FAILURE
fi
@@ -168,11 +170,11 @@ STDOUT_FILTER() {
# cleanup
rm -f $tmp_file
}
-
+
# This runs h5repack comparing output with h5dump output
# from -pH option
#
-TOOLTEST_DUMP()
+TOOLTEST_DUMP()
{
echo $@
infile=$2
@@ -186,7 +188,7 @@ TOOLTEST_DUMP()
shift
shift
-
+
# Run test.
TESTING $H5REPACK $@
(
@@ -209,10 +211,10 @@ TOOLTEST_DUMP()
nerrors="`expr $nerrors + 1`"
test yes = "$verbose" && diff -c $expect1 $actual1 |sed 's/^/ /'
fi
- VERIFY h5dump output -pH $outfile
+ VERIFY h5dump output -pH $outfile
(
cd $TESTDIR
- $ENVCMD $H5DUMP_BIN -pH $outfile
+ $ENVCMD $H5DUMP_BIN -pH $outfile
) >$actual2 2>$actual2_err
RET=$?
cat $actual2_err >> $actual2
@@ -225,26 +227,29 @@ TOOLTEST_DUMP()
nerrors="`expr $nerrors + 1`"
test yes = "$verbose" && diff -c $expect2 $actual2 |sed 's/^/ /'
fi
-
+
fi
-
+
rm -f $actual1 $actual1_err $actual2 $actual2_err
rm -f $outfile
}
##############################################################################
-### T H E T E S T S
+### T H E T E S T S
##############################################################################
# prepare for test
COPY_TESTFILES_TO_TESTDIR
# Run the test
+arg="h5repack_layout.h5 -v -f UD=260,4,9,1,9,235"
+TOOLTEST_DUMP plugin_version_test $arg
+
arg="h5repack_layout.h5 -v -f UD=257,1,9"
-TOOLTEST_DUMP plugin_test $arg
+TOOLTEST_DUMP plugin_test $arg
#arg="h5repack_layout.UD.h5 -v -f NONE"
-#TOOLTEST_DUMP plugin_none $arg
+#TOOLTEST_DUMP plugin_none $arg
# print results
if test $nerrors -ne 0 ; then
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