summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MANIFEST1
-rw-r--r--test/Makefile.am5
-rw-r--r--test/Makefile.in47
-rw-r--r--test/dynlib1.c2
-rw-r--r--test/dynlib3.c102
-rw-r--r--test/plugin.c111
6 files changed, 243 insertions, 25 deletions
diff --git a/MANIFEST b/MANIFEST
index 246d1a3..786f5a6 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -850,6 +850,7 @@
./test/dtransform.c
./test/dynlib1.c
./test/dynlib2.c
+./test/dynlib3.c
./test/efc.c
./test/enum.c
./test/extend.c
diff --git a/test/Makefile.am b/test/Makefile.am
index 74f72d2..15a2668 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -79,11 +79,12 @@ 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.
+ # The libdynlib1, libdynlib2, and libdynlib3 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
+ 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*
diff --git a/test/Makefile.in b/test/Makefile.in
index da4432b..5d21a16 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -139,6 +139,12 @@ am__libdynlib2_la_SOURCES_DIST = dynlib2.c
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)
@@ -485,23 +491,24 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libdynlib1_la_SOURCES) $(libdynlib2_la_SOURCES) \
- $(libh5test_la_SOURCES) accum.c app_ref.c big.c bittests.c \
- btree2.c cache.c cache_api.c cmpd_dset.c cross_read.c dangle.c \
- dsets.c dt_arith.c dtransform.c dtypes.c efc.c enum.c \
- err_compat.c error_test.c extend.c external.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_filters.c gen_idx.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_sizes_lheap.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 \
- vfd.c
+ $(libdynlib3_la_SOURCES) $(libh5test_la_SOURCES) accum.c \
+ app_ref.c big.c bittests.c btree2.c cache.c cache_api.c \
+ cmpd_dset.c cross_read.c dangle.c dsets.c dt_arith.c \
+ dtransform.c dtypes.c efc.c enum.c err_compat.c error_test.c \
+ extend.c external.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_filters.c gen_idx.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_sizes_lheap.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 vfd.c
DIST_SOURCES = $(am__libdynlib1_la_SOURCES_DIST) \
- $(am__libdynlib2_la_SOURCES_DIST) $(libh5test_la_SOURCES) \
+ $(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 cmpd_dset.c cross_read.c dangle.c dsets.c \
dt_arith.c dtransform.c dtypes.c efc.c enum.c err_compat.c \
@@ -877,9 +884,10 @@ BUILD_ALL_PROGS = gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_i
@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
+@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
@@ -1016,6 +1024,8 @@ libdynlib1.la: $(libdynlib1_la_OBJECTS) $(libdynlib1_la_DEPENDENCIES) $(EXTRA_li
$(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) $(am_libh5test_la_rpath) $(libh5test_la_OBJECTS) $(libh5test_la_LIBADD) $(LIBS)
@@ -1264,6 +1274,7 @@ distclean-compile:
@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)/efc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enum.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err_compat.Po@am__quote@
@@ -1618,7 +1629,7 @@ help:
@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@ # The libdynlib1, libdynlib2, and libdynlib3 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:
diff --git a/test/dynlib1.c b/test/dynlib1.c
index e252623..69d0bdd 100644
--- a/test/dynlib1.c
+++ b/test/dynlib1.c
@@ -55,7 +55,7 @@ const H5Z_class2_t* H5PL_get_plugin_info(void) {return H5Z_DYNLIB1;}
*
* Failure: 0
*
- * Programmer: Robb Matzke
+ * Programmer: Raymond Lu
* 29 March 2013
*
*-------------------------------------------------------------------------
diff --git a/test/dynlib3.c b/test/dynlib3.c
new file mode 100644
index 0000000..e040052
--- /dev/null
+++ b/test/dynlib3.c
@@ -0,0 +1,102 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer: Raymond Lu
+ * 1 April 2013
+ *
+ * Purpose: Tests the plugin module (H5PL)
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <hdf5.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 */
+}};
+
+const H5PL_type_t H5PL_get_plugin_type(void) {return H5PL_TYPE_FILTER;}
+const H5Z_class2_t* H5PL_get_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;
+ } else { /*write*/
+ void *outbuf = NULL; /* Pointer to new buffer */
+ unsigned char *dst; /* Temporary pointer to destination buffer */
+
+ dst=outbuf=malloc(nbytes+SUFFIX_LEN);
+
+ /* Copy raw data */
+ memcpy((void*)dst, (void*)(*buf), nbytes);
+
+ /* Append suffix to raw data for storage */
+ dst += nbytes;
+ memcpy((void*)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;
+}
diff --git a/test/plugin.c b/test/plugin.c
index 4fc8115..92be6ce 100644
--- a/test/plugin.c
+++ b/test/plugin.c
@@ -34,6 +34,7 @@
/* Filters for HDF5 internal test */
#define H5Z_FILTER_DYNLIB1 257
#define H5Z_FILTER_DYNLIB2 258
+#define H5Z_FILTER_DYNLIB3 259
/* Bzip2 filter */
#define H5Z_FILTER_BZIP2 307
@@ -65,6 +66,8 @@ const char *FILENAME[] = {
/* 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],
@@ -329,7 +332,7 @@ error:
}
/*-------------------------------------------------------------------------
- * Function: test_filters
+ * Function: test_filters_for_datasets
*
* Purpose: Tests creating datasets and writing data with dynamically
* loaded filters
@@ -343,7 +346,7 @@ error:
*-------------------------------------------------------------------------
*/
static herr_t
-test_filters(hid_t file, hid_t fapl)
+test_filters_for_datasets(hid_t file, hid_t fapl)
{
hid_t dc; /* Dataset creation property list ID */
const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */
@@ -529,6 +532,100 @@ 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 fapl)
+{
+ 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 fapl)
+{
+ hid_t gcpl, 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
@@ -593,8 +690,11 @@ main(void)
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0)
TEST_ERROR
- /* Test dynamically loaded filters */
- nerrors += (test_filters(file, my_fapl) < 0 ? 1 : 0);
+ /* Test dynamically loaded filters for chunked dataset */
+ nerrors += (test_filters_for_datasets(file, my_fapl) < 0 ? 1 : 0);
+
+ /* Test dynamically loaded filters for groups */
+ nerrors += (test_filters_for_groups(file, my_fapl) < 0 ? 1 : 0);
if(H5Fclose(file) < 0)
TEST_ERROR
@@ -617,6 +717,9 @@ main(void)
/* Read the data with filters */
nerrors += (test_read_with_filters(file, fapl) < 0 ? 1 : 0);
+ /* Open the groups with filters */
+ nerrors += (test_groups_with_filters(file, fapl) < 0 ? 1 : 0);
+
if(H5Fclose(file) < 0)
TEST_ERROR