summaryrefslogtreecommitdiffstats
path: root/test/plugin.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2015-03-09 08:47:16 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2015-03-09 08:47:16 (GMT)
commitce19753d87babcd578fbc9fb7b9329722e3a604c (patch)
treebefd99d086b9ad13476ba30ffd805d8f9b084bb3 /test/plugin.c
parent5b294640c003dac45c2cc489793950207bf63c8f (diff)
parent2a4ea9b24e5d28598b627fca39fb42a9baedfaa3 (diff)
downloadhdf5-ce19753d87babcd578fbc9fb7b9329722e3a604c.zip
hdf5-ce19753d87babcd578fbc9fb7b9329722e3a604c.tar.gz
hdf5-ce19753d87babcd578fbc9fb7b9329722e3a604c.tar.bz2
[svn-r26396] Merge of r26349-26392 from the trunk.
Tested on: h5committest
Diffstat (limited to 'test/plugin.c')
-rw-r--r--test/plugin.c93
1 files changed, 87 insertions, 6 deletions
diff --git a/test/plugin.c b/test/plugin.c
index 86bc952..3707411 100644
--- a/test/plugin.c
+++ b/test/plugin.c
@@ -456,14 +456,14 @@ error:
}
/*-------------------------------------------------------------------------
- * Function: test_read_with_filters
+ * Function: test_read_with_filters
*
- * Purpose: Tests reading dataset created with dynamically loaded filters
+ * Purpose: Tests reading dataset created with dynamically loaded filters
*
- * Return: Success: 0
- * Failure: -1
+ * Return: Success: 0
+ * Failure: -1
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* 14 March 2013
*
*-------------------------------------------------------------------------
@@ -471,7 +471,7 @@ error:
static herr_t
test_read_with_filters(hid_t file)
{
- hid_t dset; /* Dataset ID */
+ hid_t dset; /* Dataset ID */
/*----------------------------------------------------------
* STEP 1: Test deflation by itself.
@@ -526,6 +526,76 @@ error:
}
/*-------------------------------------------------------------------------
+ * Function: test_noread_data
+ *
+ * Purpose: Tests not reading data
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_noread_data(hid_t dataset, int *origin_data)
+{
+ int check[DSET_DIM1][DSET_DIM2];
+ const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */
+ int *data_p = origin_data;
+ size_t i, j; /* Local index variables */
+
+ /* Read the dataset back */
+ if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) >= 0)
+ TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ return -1;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: test_noread_with_filters
+ *
+ * Purpose: Tests reading dataset created with dynamically loaded filters disabled
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_noread_with_filters(hid_t file)
+{
+ hid_t dset; /* Dataset ID */
+ int plugin_state; /* status of plugins */
+ TESTING("Testing DYNLIB1 filter with plugins disabled");
+
+ /* disable filter plugin */
+ if(H5PLget_loading_state(&plugin_state) < 0) TEST_ERROR
+ plugin_state = plugin_state & ~H5PL_FILTER_PLUGIN;
+ if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR
+
+ if((dset = H5Dopen2(file,DSET_DYNLIB1_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
+
+ if(test_noread_data(dset, (int *)points_dynlib1) < 0) TEST_ERROR
+
+ if(H5Dclose(dset) < 0) TEST_ERROR
+
+ /* re-enable filter plugin */
+ plugin_state = plugin_state | H5PL_FILTER_PLUGIN;
+ if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR
+
+ return 0;
+
+error:
+ /* re-enable filter plugin */
+ plugin_state = plugin_state | H5PL_FILTER_PLUGIN;
+ if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR
+ return -1;
+}
+
+/*-------------------------------------------------------------------------
* Function: test_filters_for_groups
*
* Purpose: Tests creating group with dynamically loaded filters
@@ -713,6 +783,17 @@ main(void)
/* Open the groups with filters */
nerrors += (test_groups_with_filters(file) < 0 ? 1 : 0);
+ /* Close the library so that all loaded plugin libraries are unloaded */
+ h5_reset();
+ fapl = h5_fileaccess();
+
+ /* Reopen the file for testing data reading */
+ if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
+ TEST_ERROR
+
+ /* Read the data with disabled filters */
+ nerrors += (test_noread_with_filters(file) < 0 ? 1 : 0);
+
if(H5Fclose(file) < 0)
TEST_ERROR