/*------------------------------------------------------------------------- * 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 */ unsigned 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) < 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_no_read_when_plugins_disabled * * Purpose: Ensures we can't read data from a dataset that requires a * filter located in a plugin. * * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ static herr_t test_no_read_when_plugins_disabled(hid_t fid) { hid_t did = -1; /* Dataset ID */ unsigned plugin_flags; /* Plugin access flags */ TESTING("filter plugin 1 with filter plugins disabled"); /* Get the existing plugin flags */ if (H5PLget_loading_state(&plugin_flags) < 0) TEST_ERROR; /* Disable filter plugins and use the new flags */ plugin_flags &= (unsigned)(~H5PL_FILTER_PLUGIN); if (H5PLset_loading_state(plugin_flags) < 0) TEST_ERROR; /* Open a dataset that requires a filter plugin to read the data */ if ((did = H5Dopen2(fid, DSET_FILTER1_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; /* Make sure we can't read the data */ if (ensure_data_read_fails(did) < 0) TEST_ERROR; /* Close down */ if (H5Dclose(did) < 0) TEST_ERROR; /* Re-enable filter plugins */ plugin_flags |= (unsigned)H5PL_FILTER_PLUGIN; if (H5PLset_loading_state(plugin_flags) < 0) TEST_ERROR; return SUCCEED; error: /* Clean up objects used for this test */ H5E_BEGIN_TRY { plugin_flags |= (unsigned)H5PL_FILTER_PLUGIN; H5PLset_loading_state(plugin_flags); H5Dclose(did); } H5E_END_TRY return FAIL; } /* end test_no_read_when_plugins_disabled() */
/* * Class: hdf_hdf5lib_H5 * Method: H5PLset_loading_state * Signature: (I)V */ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5PLset_1loading_1state (JNIEnv *env, jclass clss, jint plugin_flags) { if (H5PLset_loading_state((unsigned int)plugin_flags) < 0) { h5libraryError(env); } } /* end Java_hdf_hdf5lib_H5_H5PLset_1loading_1state */