diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2016-08-01 18:17:36 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2016-08-01 18:17:36 (GMT) |
commit | 0e99aa203a9f5071940e04ec17922d7afe70cc78 (patch) | |
tree | f328a427e331d4e1100c73143c976367ca30fd1a /test | |
parent | bac4cf8e92b8cd033c40160bde0f2b27fa648a5c (diff) | |
download | hdf5-0e99aa203a9f5071940e04ec17922d7afe70cc78.zip hdf5-0e99aa203a9f5071940e04ec17922d7afe70cc78.tar.gz hdf5-0e99aa203a9f5071940e04ec17922d7afe70cc78.tar.bz2 |
[svn-r30240] JAVA-1920: Create a filter plugin test that has a filter which calls a HDF5 function.
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 1 | ||||
-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/plugin.c | 41 | ||||
-rw-r--r-- | test/test_plugin.sh.in | 10 |
4 files changed, 51 insertions, 6 deletions
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}" |