summaryrefslogtreecommitdiffstats
path: root/test/plugin.c
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2013-04-02 16:44:31 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2013-04-02 16:44:31 (GMT)
commit4da796299b0e86eb93dd7f45761696415ae8af58 (patch)
treea416c6170e837428de4bb5b245299c45dcf004fb /test/plugin.c
parent8b04aa4c87fe7657d1a1dad62c2a95ab19e41083 (diff)
downloadhdf5-4da796299b0e86eb93dd7f45761696415ae8af58.zip
hdf5-4da796299b0e86eb93dd7f45761696415ae8af58.tar.gz
hdf5-4da796299b0e86eb93dd7f45761696415ae8af58.tar.bz2
[svn-r23521] I merged the changes for testing groups with filter into this branch.
Tested on jam and koala.
Diffstat (limited to 'test/plugin.c')
-rw-r--r--test/plugin.c111
1 files changed, 107 insertions, 4 deletions
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