summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MANIFEST1
-rw-r--r--java/test/JUnit-interface.txt3
-rw-r--r--java/test/TestH5PL.java122
-rw-r--r--test/CMakeLists.txt1
-rw-r--r--test/Makefile.am5
-rw-r--r--test/plugin.c41
-rw-r--r--test/test_plugin.sh.in10
7 files changed, 176 insertions, 7 deletions
diff --git a/MANIFEST b/MANIFEST
index 687f0f5..bc5ecb6 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -894,6 +894,7 @@
./test/dynlib1.c
./test/dynlib2.c
./test/dynlib3.c
+./test/dynlib4.c
./test/earray.c
./test/efc.c
./test/enc_dec_plist.c
diff --git a/java/test/JUnit-interface.txt b/java/test/JUnit-interface.txt
index cbd93e0..9765d08 100644
--- a/java/test/JUnit-interface.txt
+++ b/java/test/JUnit-interface.txt
@@ -628,13 +628,14 @@ JUnit version 4.11
.testH5Ocomment_clear
.testH5Ocopy_cur_not_exists
.TestH5PLplugins
+.TestH5PLdlopen
.testH5Zfilter_avail
.testH5Zunregister_predefined
.testH5Zget_filter_info
Time: XXXX
-OK (632 tests)
+OK (633 tests)
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#000: (file name) line (number) in H5Fopen(): can't set access and transfer property lists
diff --git a/java/test/TestH5PL.java b/java/test/TestH5PL.java
index afcb88a..6a3324a 100644
--- a/java/test/TestH5PL.java
+++ b/java/test/TestH5PL.java
@@ -29,6 +29,15 @@ import org.junit.rules.TestName;
public class TestH5PL {
@Rule public TestName testname = new TestName();
+ private static String FILENAME = "h5_dlopenChunk.h5";
+ private static String DATASETNAME = "DS1";
+ private static final int DIM_X = 6;
+ private static final int DIM_Y = 8;
+ private static final int CHUNK_X = 4;
+ private static final int CHUNK_Y = 4;
+ private static final int RANK = 2;
+ private static final int NDIMS = 2;
+ private static final int H5Z_FILTER_DYNLIB4 = 260;
@Before
public void checkOpenIDs() {
@@ -58,4 +67,117 @@ public class TestH5PL {
fail("TestH5PLplugins " + err);
}
}
+
+ @Test
+ public void TestH5PLdlopen() {
+ try {
+ long file_id = -1;
+ long filespace_id = -1;
+ long dataset_id = -1;
+ long fapl_id = -1;
+ long dcpl_id = -1;
+ int[] cd_values = {9, 0, 0, 0};
+ int[] libversion = {0, 0, 0};
+ long[] dims = { DIM_X, DIM_Y };
+ long[] chunk_dims = { CHUNK_X, CHUNK_Y };
+ int[][] dset_data = new int[DIM_X][DIM_Y];
+ int[] mdc_nelmts = {0};
+ long[] rdcc_nelmts = {0};
+ long[] rdcc_nbytes = {0};
+ double[] rdcc_w0 = {0};
+
+ // Initialize data to "1", to make it easier to see the selections.
+ for (int indx = 0; indx < DIM_X; indx++)
+ for (int jndx = 0; jndx < DIM_Y; jndx++)
+ dset_data[indx][jndx] = 1;
+
+ // Create a new file using default properties.
+ try {
+ file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
+ HDF5Constants.H5P_DEFAULT);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail("TestH5PLdlopen H5Fcreate:" + e);
+ }
+
+ // Create dataspace. Setting maximum size to NULL sets the maximum
+ // size to be the current size.
+ try {
+ filespace_id = H5.H5Screate_simple(RANK, dims, null);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail("TestH5PLdlopen H5Screate_simple:" + e);
+ }
+
+ // Create the dataset creation property list.
+ try {
+ dcpl_id = H5.H5Pcreate(HDF5Constants.H5P_DATASET_CREATE);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail("TestH5PLdlopen H5Pcreate:" + e);
+ }
+
+ // Set the chunk size.
+ try {
+ if (dcpl_id >= 0)
+ H5.H5Pset_chunk(dcpl_id, NDIMS, chunk_dims);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail("TestH5PLdlopen H5Pset_chunk:" + e);
+ }
+
+ try {
+ H5.H5get_libversion(libversion);
+ cd_values[1] = libversion[0];
+ cd_values[2] = libversion[1];
+ cd_values[3] = libversion[2];
+ if (dcpl_id >= 0)
+ H5.H5Pset_filter(dcpl_id, H5Z_FILTER_DYNLIB4, HDF5Constants.H5Z_FLAG_MANDATORY, 4, cd_values);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail("TestH5PLdlopen H5Pset_filter:" + e);
+ }
+
+ // Create the chunked dataset.
+ try {
+ if ((file_id >= 0) && (filespace_id >= 0) && (dcpl_id >= 0))
+ dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_NATIVE_INT, filespace_id,
+ HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail("TestH5PLdlopen H5Dcreate:" + e);
+ }
+
+ try {
+ if (dataset_id >= 0)
+ H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
+ HDF5Constants.H5S_ALL, dset_data);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail("TestH5PLdlopen H5Dwrite:" + e);
+ }
+ finally {
+ // End access to the dataset and release resources used by it.
+ if (dcpl_id >= 0)
+ try {H5.H5Pclose_class(dcpl_id);} catch (Throwable err) {}
+ if (dataset_id >= 0)
+ try {H5.H5Dclose(dataset_id);} catch (Throwable err) {}
+ if (filespace_id >= 0)
+ try {H5.H5Sclose(filespace_id);} catch (Throwable err) {}
+ if (file_id >= 0)
+ try {H5.H5Fclose(file_id);} catch (Throwable err) {}
+ }
+ }
+ catch (Throwable err) {
+ err.printStackTrace();
+ fail("TestH5PLdlopen " + err);
+ }
+ }
}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 97471d1..1ab4165 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -83,6 +83,7 @@ endif (BUILD_SHARED_LIBS)
)
set (TEST2_PLUGIN_LIBS
dynlib2
+ dynlib4
)
foreach (test_lib ${TEST_PLUGIN_LIBS})
diff --git a/test/Makefile.am b/test/Makefile.am
index 37bf539..9e0f9c5 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -84,12 +84,13 @@ 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, libdynlib3, and libdynlib4 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 libdynlib3.la
+ lib_LTLIBRARIES=libdynlib1.la libdynlib2.la libdynlib3.la libdynlib4.la
libdynlib1_la_SOURCES=dynlib1.c
libdynlib2_la_SOURCES=dynlib2.c
libdynlib3_la_SOURCES=dynlib3.c
+ libdynlib4_la_SOURCES=dynlib4.c
install-exec-hook:
$(RM) $(DESTDIR)$(libdir)/*dynlib*
diff --git a/test/plugin.c b/test/plugin.c
index a3082d2..3086e90 100644
--- a/test/plugin.c
+++ b/test/plugin.c
@@ -17,8 +17,6 @@
*
* Purpose: Tests the plugin module (H5PL)
*/
-#include <stdlib.h>
-#include <time.h>
#include "h5test.h"
#include "H5srcdir.h"
@@ -33,6 +31,7 @@
#define H5Z_FILTER_DYNLIB1 257
#define H5Z_FILTER_DYNLIB2 258
#define H5Z_FILTER_DYNLIB3 259
+#define H5Z_FILTER_DYNLIB4 260
const char *FILENAME[] = {
"plugin",
@@ -44,6 +43,7 @@ const char *FILENAME[] = {
#define DSET_DEFLATE_NAME "deflate"
#define DSET_DYNLIB1_NAME "dynlib1"
#define DSET_DYNLIB2_NAME "dynlib2"
+#define DSET_DYNLIB4_NAME "dynlib4"
/* Parameters for internal filter test */
#define FILTER_CHUNK_DIM1 2
@@ -65,6 +65,7 @@ const char *FILENAME[] = {
int points_deflate[DSET_DIM1][DSET_DIM2],
points_dynlib1[DSET_DIM1][DSET_DIM2],
points_dynlib2[DSET_DIM1][DSET_DIM2],
+ points_dynlib4[DSET_DIM1][DSET_DIM2],
points_bzip2[DSET_DIM1][DSET_DIM2];
@@ -306,6 +307,8 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
points_dynlib1[i][j] = points[i][j];
} else if(!HDstrcmp(name, DSET_DYNLIB2_NAME)) {
points_dynlib2[i][j] = points[i][j];
+ } else if(!HDstrcmp(name, DSET_DYNLIB4_NAME)) {
+ points_dynlib4[i][j] = points[i][j];
}
}
}
@@ -344,6 +347,7 @@ test_filters_for_datasets(hid_t file)
hid_t dc; /* Dataset creation property list ID */
const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */
unsigned int compress_level = 9;
+ unsigned int dynlib4_values[4];
/*----------------------------------------------------------
* STEP 1: Test deflation by itself.
@@ -402,6 +406,27 @@ test_filters_for_datasets(hid_t file)
* for this filter. */
if(H5Zunregister(H5Z_FILTER_DYNLIB2) < 0) goto error;
+ /*----------------------------------------------------------
+ * STEP 4: Test DYNLIB4 by itself.
+ *----------------------------------------------------------
+ */
+ puts("Testing DYNLIB4 filter");
+ if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
+ if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error;
+ dynlib4_values[0] = 9;
+ if(H5get_libversion(&dynlib4_values[1], &dynlib4_values[2], &dynlib4_values[3]) < 0) goto error;
+ if(H5Pset_filter (dc, H5Z_FILTER_DYNLIB4, H5Z_FLAG_MANDATORY, (size_t)4, dynlib4_values) < 0) goto error;
+
+ if(test_filter_internal(file,DSET_DYNLIB4_NAME,dc) < 0) goto error;
+
+ /* Clean up objects used for this test */
+ if(H5Pclose (dc) < 0) goto error;
+
+ /* Unregister the dynamic filter DYNLIB4 for testing purpose. The next time when this test is run for
+ * the new file format, the library's H5PL code has to search in the table of loaded plugin libraries
+ * for this filter. */
+ if(H5Zunregister(H5Z_FILTER_DYNLIB4) < 0) goto error;
+
return 0;
error:
@@ -519,6 +544,18 @@ test_read_with_filters(hid_t file)
if(H5Dclose(dset) < 0) TEST_ERROR
+ /*----------------------------------------------------------
+ * STEP 4: Test DYNLIB4 by itself.
+ *----------------------------------------------------------
+ */
+ TESTING("Testing DYNLIB4 filter");
+
+ if((dset = H5Dopen2(file,DSET_DYNLIB4_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
+
+ if(test_read_data(dset, (int *)points_dynlib4) < 0) TEST_ERROR
+
+ if(H5Dclose(dset) < 0) TEST_ERROR
+
return 0;
error:
diff --git a/test/test_plugin.sh.in b/test/test_plugin.sh.in
index 43e76c4..d1472fc 100644
--- a/test/test_plugin.sh.in
+++ b/test/test_plugin.sh.in
@@ -31,11 +31,11 @@ FROM_DIR=`pwd`/.libs
case $(uname) in
CYGWIN* )
PLUGIN_LIB1="$FROM_DIR/cygdynlib1* $FROM_DIR/cygdynlib3*"
- PLUGIN_LIB2="$FROM_DIR/cygdynlib2*"
+ PLUGIN_LIB2="$FROM_DIR/cygdynlib2* $FROM_DIR/cygdynlib4*"
;;
*)
PLUGIN_LIB1="$FROM_DIR/libdynlib1.* $FROM_DIR/libdynlib3.*"
- PLUGIN_LIB2="$FROM_DIR/libdynlib2.*"
+ PLUGIN_LIB2="$FROM_DIR/libdynlib2.* $FROM_DIR/libdynlib4.*"
;;
esac
PLUGIN_LIBDIR1=testdir1
@@ -78,6 +78,12 @@ if [ $? != 0 ]; then
exit $EXIT_FAILURE
fi
+$CP $PLUGIN_LIB4 $PLUGIN_LIBDIR2
+if [ $? != 0 ]; then
+ echo "Failed to copy plugin library ($PLUGIN_LIB4) for test."
+ exit $EXIT_FAILURE
+fi
+
# setup plugin path
ENVCMD="env HDF5_PLUGIN_PATH=${PLUGIN_LIBDIR1}:${PLUGIN_LIBDIR2}"