summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2013-04-02 16:12:20 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2013-04-02 16:12:20 (GMT)
commitb8c258a9700e6633b681891794458e57598d55ae (patch)
tree0ef6436d1bcbaedd58401495488fb6a033750d04
parentfc4c7a05f644fe1183bf8e7944dd7f66c9eb9e85 (diff)
downloadhdf5-b8c258a9700e6633b681891794458e57598d55ae.zip
hdf5-b8c258a9700e6633b681891794458e57598d55ae.tar.gz
hdf5-b8c258a9700e6633b681891794458e57598d55ae.tar.bz2
[svn-r23519] I used H5Gcreate instead of H5Gcreate2 in plugin.c. I corrected it and added some real operation in the dummy filter library dynlib3.c.
Tested on jam and koala.
-rw-r--r--test/dynlib1.c2
-rw-r--r--test/dynlib3.c41
-rw-r--r--test/plugin.c62
3 files changed, 86 insertions, 19 deletions
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
index d1c57d2..e040052 100644
--- a/test/dynlib3.c
+++ b/test/dynlib3.c
@@ -22,9 +22,12 @@
#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);
@@ -46,16 +49,15 @@ const H5Z_class2_t* H5PL_get_plugin_info(void) {return H5Z_DYNLIB3;}
/*-------------------------------------------------------------------------
* Function: H5Z_filter_dynlib3
*
- * Purpose: A dynlib3 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.
+ * 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: Robb Matzke
+ * Programmer: Raymond Lu
* 1 April 2013
*
*-------------------------------------------------------------------------
@@ -65,19 +67,36 @@ H5Z_filter_dynlib3(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;
+ 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 nbytes;
+ return ret_value;
}
diff --git a/test/plugin.c b/test/plugin.c
index 6f85dd4..4f28520 100644
--- a/test/plugin.c
+++ b/test/plugin.c
@@ -66,7 +66,7 @@ const char *FILENAME[] = {
/* Limit random number within 20000 */
#define RANDOM_LIMIT 20000
-#define ITER 100
+#define GROUP_ITERATION 1000
int points_deflate[DSET_DIM1][DSET_DIM2],
points_dynlib1[DSET_DIM1][DSET_DIM2],
@@ -550,20 +550,22 @@ test_filters_for_groups(hid_t file, hid_t fapl)
{
hid_t gcpl, gid, group;
int i;
- char name[256];
+ char gname[256];
- puts("Testing DYNLIB3 filter for group");
+ 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;
- for (i=0; i < ITER; i++) {
- sprintf(name, "group_%d", i);
- if((group = H5Gcreate (gid, name, H5P_DEFAULT, H5P_DEFAULT, 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;
}
@@ -581,6 +583,49 @@ 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
@@ -671,6 +716,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