summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2013-03-29 20:59:15 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2013-03-29 20:59:15 (GMT)
commited621aae38837e90c7273087de22f1752eee7cc7 (patch)
tree9d4ccc718d360469fd99c793cd9526c8981efb9b
parent5e5e9e3987ddb5ce005f346e95e378e57ad5c762 (diff)
downloadhdf5-ed621aae38837e90c7273087de22f1752eee7cc7.zip
hdf5-ed621aae38837e90c7273087de22f1752eee7cc7.tar.gz
hdf5-ed621aae38837e90c7273087de22f1752eee7cc7.tar.bz2
[svn-r23494] I added another filter library dynlib2.c for plugin.c test. The test script moves the libdynlib2.so to /tmp then runs
plugin.c. Tested on jam and koala.
-rw-r--r--test/Makefile.am7
-rw-r--r--test/Makefile.in43
-rw-r--r--test/dynlib1.c7
-rw-r--r--test/dynlib2.c93
-rw-r--r--test/plugin.c55
-rw-r--r--test/test_plugin.sh.in8
6 files changed, 142 insertions, 71 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 6e1f845..ec0f416 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -79,13 +79,14 @@ if HAVE_SHARED_CONDITIONAL
# The libh5test library provides common support code for the tests.
noinst_LTLIBRARIES=libh5test.la
- # The libdynlib1 library for testing plugin module plugin.c.
+ # The libdynlib1 and libdynlib2 library for testing plugin module plugin.c.
# Build it as shared library if configure is enabled for shared library.
- lib_LTLIBRARIES=libdynlib1.la
+ lib_LTLIBRARIES=libdynlib1.la libdynlib2.la
libdynlib1_la_SOURCES=dynlib1.c
+ libdynlib2_la_SOURCES=dynlib2.c
install-data-local:
- $(RM) $(DESTDIR)$(libdir)/*dynlib1*
+ $(RM) $(DESTDIR)$(libdir)/*dynlib*
else
# The libh5test library provides common support code for the tests.
diff --git a/test/Makefile.in b/test/Makefile.in
index 958ec33..49b8d70 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -133,6 +133,12 @@ am__v_lt_0 = --silent
am__v_lt_1 =
@HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlib1_la_rpath = -rpath \
@HAVE_SHARED_CONDITIONAL_TRUE@ $(libdir)
+libdynlib2_la_LIBADD =
+am__libdynlib2_la_SOURCES_DIST = dynlib2.c
+@HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlib2_la_OBJECTS = dynlib2.lo
+libdynlib2_la_OBJECTS = $(am_libdynlib2_la_OBJECTS)
+@HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlib2_la_rpath = -rpath \
+@HAVE_SHARED_CONDITIONAL_TRUE@ $(libdir)
libh5test_la_LIBADD =
am_libh5test_la_OBJECTS = h5test.lo testframe.lo cache_common.lo
libh5test_la_OBJECTS = $(am_libh5test_la_OBJECTS)
@@ -510,13 +516,13 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
-SOURCES = $(libdynlib1_la_SOURCES) $(libh5test_la_SOURCES) accum.c \
- app_ref.c big.c bittests.c btree2.c cache.c cache_api.c \
- cache_tagging.c cmpd_dset.c cross_read.c dangle.c dsets.c \
- dt_arith.c dtransform.c dtypes.c earray.c efc.c \
- enc_dec_plist.c enc_dec_plist_with_endianess.c enum.c \
- err_compat.c error_test.c extend.c external.c farray.c fheap.c \
- file_image.c fillval.c filter_fail.c flush1.c flush2.c \
+SOURCES = $(libdynlib1_la_SOURCES) $(libdynlib2_la_SOURCES) \
+ $(libh5test_la_SOURCES) accum.c app_ref.c big.c bittests.c \
+ btree2.c cache.c cache_api.c cache_tagging.c cmpd_dset.c \
+ cross_read.c dangle.c dsets.c dt_arith.c dtransform.c dtypes.c \
+ earray.c efc.c enc_dec_plist.c enc_dec_plist_with_endianess.c \
+ enum.c err_compat.c error_test.c extend.c external.c farray.c \
+ fheap.c file_image.c fillval.c filter_fail.c flush1.c flush2.c \
freespace.c gen_bad_ohdr.c gen_bogus.c gen_cross.c \
gen_deflate.c gen_file_image.c gen_filespace.c gen_filters.c \
gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c \
@@ -528,12 +534,13 @@ SOURCES = $(libdynlib1_la_SOURCES) $(libh5test_la_SOURCES) accum.c \
tcheck_version.c $(testhdf5_SOURCES) testmeta.c \
$(ttsafe_SOURCES) unlink.c vfd.c
DIST_SOURCES = $(am__libdynlib1_la_SOURCES_DIST) \
- $(libh5test_la_SOURCES) accum.c app_ref.c big.c bittests.c \
- btree2.c cache.c cache_api.c cache_tagging.c cmpd_dset.c \
- cross_read.c dangle.c dsets.c dt_arith.c dtransform.c dtypes.c \
- earray.c efc.c enc_dec_plist.c enc_dec_plist_with_endianess.c \
- enum.c err_compat.c error_test.c extend.c external.c farray.c \
- fheap.c file_image.c fillval.c filter_fail.c flush1.c flush2.c \
+ $(am__libdynlib2_la_SOURCES_DIST) $(libh5test_la_SOURCES) \
+ accum.c app_ref.c big.c bittests.c btree2.c cache.c \
+ cache_api.c cache_tagging.c cmpd_dset.c cross_read.c dangle.c \
+ dsets.c dt_arith.c dtransform.c dtypes.c earray.c efc.c \
+ enc_dec_plist.c enc_dec_plist_with_endianess.c enum.c \
+ err_compat.c error_test.c extend.c external.c farray.c fheap.c \
+ file_image.c fillval.c filter_fail.c flush1.c flush2.c \
freespace.c gen_bad_ohdr.c gen_bogus.c gen_cross.c \
gen_deflate.c gen_file_image.c gen_filespace.c gen_filters.c \
gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c \
@@ -904,8 +911,9 @@ BUILD_ALL_PROGS = gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_n
@HAVE_SHARED_CONDITIONAL_FALSE@noinst_LTLIBRARIES = libh5test.la
@HAVE_SHARED_CONDITIONAL_TRUE@noinst_LTLIBRARIES = libh5test.la
-@HAVE_SHARED_CONDITIONAL_TRUE@lib_LTLIBRARIES = libdynlib1.la
+@HAVE_SHARED_CONDITIONAL_TRUE@lib_LTLIBRARIES = libdynlib1.la libdynlib2.la
@HAVE_SHARED_CONDITIONAL_TRUE@libdynlib1_la_SOURCES = dynlib1.c
+@HAVE_SHARED_CONDITIONAL_TRUE@libdynlib2_la_SOURCES = dynlib2.c
libh5test_la_SOURCES = h5test.c testframe.c cache_common.c
# Use libhd5test.la to compile all of the tests
@@ -1040,6 +1048,8 @@ clean-noinstLTLIBRARIES:
}
libdynlib1.la: $(libdynlib1_la_OBJECTS) $(libdynlib1_la_DEPENDENCIES) $(EXTRA_libdynlib1_la_DEPENDENCIES)
$(AM_V_CCLD)$(LINK) $(am_libdynlib1_la_rpath) $(libdynlib1_la_OBJECTS) $(libdynlib1_la_LIBADD) $(LIBS)
+libdynlib2.la: $(libdynlib2_la_OBJECTS) $(libdynlib2_la_DEPENDENCIES) $(EXTRA_libdynlib2_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(LINK) $(am_libdynlib2_la_rpath) $(libdynlib2_la_OBJECTS) $(libdynlib2_la_LIBADD) $(LIBS)
libh5test.la: $(libh5test_la_OBJECTS) $(libh5test_la_DEPENDENCIES) $(EXTRA_libh5test_la_DEPENDENCIES)
$(AM_V_CCLD)$(LINK) $(am_libh5test_la_rpath) $(libh5test_la_OBJECTS) $(libh5test_la_LIBADD) $(LIBS)
@@ -1309,6 +1319,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dtransform.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dtypes.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynlib1.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynlib2.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earray.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/efc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enc_dec_plist.Po@am__quote@
@@ -1668,11 +1679,11 @@ help:
@HAVE_SHARED_CONDITIONAL_TRUE@ # The libh5test library provides common support code for the tests.
-@HAVE_SHARED_CONDITIONAL_TRUE@ # The libdynlib1 library for testing plugin module plugin.c.
+@HAVE_SHARED_CONDITIONAL_TRUE@ # The libdynlib1 and libdynlib2 library for testing plugin module plugin.c.
@HAVE_SHARED_CONDITIONAL_TRUE@ # Build it as shared library if configure is enabled for shared library.
@HAVE_SHARED_CONDITIONAL_TRUE@install-data-local:
-@HAVE_SHARED_CONDITIONAL_TRUE@ $(RM) $(DESTDIR)$(libdir)/*dynlib1*
+@HAVE_SHARED_CONDITIONAL_TRUE@ $(RM) $(DESTDIR)$(libdir)/*dynlib*
@HAVE_SHARED_CONDITIONAL_FALSE@ # The libh5test library provides common support code for the tests.
diff --git a/test/dynlib1.c b/test/dynlib1.c
index b879ca2..2e0c593 100644
--- a/test/dynlib1.c
+++ b/test/dynlib1.c
@@ -44,14 +44,17 @@ const H5Z_class2_t* H5PL_get_plugin_info(void) {return H5Z_DYNLIB1;}
/*-------------------------------------------------------------------------
* Function: H5Z_filter_dynlib1
*
- * Purpose: A dynlib1 compression method that doesn't do anything.
+ * Purpose: A dynlib1 filter method that adds on and subtract from
+ * the original value with another value. It will be built
+ * as a shared library. plugin.c test will load and use
+ * this filter library.
*
* Return: Success: Data chunk size
*
* Failure: 0
*
* Programmer: Robb Matzke
- * Tuesday, April 21, 1998
+ * 29 March 2013
*
*-------------------------------------------------------------------------
*/
diff --git a/test/dynlib2.c b/test/dynlib2.c
new file mode 100644
index 0000000..b1c1707
--- /dev/null
+++ b/test/dynlib2.c
@@ -0,0 +1,93 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer: Raymond Lu
+ * 13 February 2013
+ *
+ * Purpose: Tests the plugin module (H5PL)
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <hdf5.h>
+
+static size_t H5Z_filter_dynlib2(unsigned int flags, size_t cd_nelmts,
+ const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
+
+/* This message derives from H5Z */
+const H5Z_class2_t H5Z_DYNLIB2[1] = {{
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
+ H5Z_FILTER_DYNLIB2, /* Filter id number */
+ 1, 1, /* Encoding and decoding enabled */
+ "dynlib2", /* Filter name for debugging */
+ NULL, /* The "can apply" callback */
+ NULL, /* The "set local" callback */
+ (H5Z_func_t)H5Z_filter_dynlib2, /* The actual filter function */
+}};
+
+const H5PL_type_t H5PL_get_plugin_type(void) {return H5PL_TYPE_FILTER;}
+const H5Z_class2_t* H5PL_get_plugin_info(void) {return H5Z_DYNLIB2;}
+
+/*-------------------------------------------------------------------------
+ * Function: H5Z_filter_dynlib2
+ *
+ * Purpose: A dynlib2 filter method that assigns the power of 2 of the
+ * original value during write and calculates the square root
+ * of the original value during read. It will be built as a
+ * shared library. plugin.c test will load and use this filter
+ * library.
+ *
+ * Return: Success: Data chunk size
+ *
+ * Failure: 0
+ *
+ * Programmer: Raymond Lu
+ * 29 March 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static size_t
+H5Z_filter_dynlib2(unsigned int flags, size_t cd_nelmts,
+ const unsigned int *cd_values, size_t nbytes,
+ size_t *buf_size, void **buf)
+{
+ int *int_ptr=(int *)*buf; /* Pointer to the data values */
+ size_t buf_left=*buf_size; /* Amount of data buffer left to process */
+
+ /* Check for the correct number of parameters */
+ if(cd_nelmts>0)
+ return(0);
+
+ if(flags & H5Z_FLAG_REVERSE) { /*read*/
+ /* Calculate and assign the square root for all the data values */
+ while(buf_left>0) {
+ *int_ptr = (int)sqrt((double)*int_ptr);
+ *int_ptr++;
+ buf_left -= sizeof(int);
+ } /* end while */
+ } /* end if */
+ else { /*write*/
+ /* Calculate and assign the power of 2 to all the data values */
+ while(buf_left>0) {
+ *int_ptr = (int)pow((double)*int_ptr, 2);
+ *int_ptr++;
+ buf_left -= sizeof(int);
+ } /* end while */
+ } /* end else */
+
+ return nbytes;
+}
diff --git a/test/plugin.c b/test/plugin.c
index d5a30f9..4fc8115 100644
--- a/test/plugin.c
+++ b/test/plugin.c
@@ -62,6 +62,9 @@ const char *FILENAME[] = {
#define DSET_DIM1 100
#define DSET_DIM2 200
+/* Limit random number within 20000 */
+#define RANDOM_LIMIT 20000
+
int points_deflate[DSET_DIM1][DSET_DIM2],
points_dynlib1[DSET_DIM1][DSET_DIM2],
points_dynlib2[DSET_DIM1][DSET_DIM2],
@@ -200,8 +203,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
for(i=0; i<size[0]; i++) {
for(j=0; j<size[1]/2; j++) {
- /*points[i][j] = (int)7;*/
- points[i][j] = (int)HDrandom ();
+ points[i][j] = (int)HDrandom () % RANDOM_LIMIT;
}
}
if(H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points) < 0)
@@ -263,7 +265,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
for(i=0; i<(size_t)hs_size[0]; i++) {
for(j=0; j<(size_t)hs_size[1]; j++) {
- points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j] = (int)HDrandom();
+ points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j] = (int)HDrandom() % RANDOM_LIMIT;
}
}
if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size,
@@ -348,7 +350,7 @@ test_filters(hid_t file, hid_t fapl)
unsigned int compress_level = 9;
/*----------------------------------------------------------
- * STEP 2: Test deflation by itself.
+ * STEP 1: Test deflation by itself.
*----------------------------------------------------------
*/
#ifdef H5_HAVE_FILTER_DEFLATE
@@ -385,15 +387,14 @@ test_filters(hid_t file, hid_t fapl)
* for this filter. */
if(H5Zunregister(H5Z_FILTER_DYNLIB1) < 0) goto error;
-#ifdef TMP
/*----------------------------------------------------------
- * STEP 2: Test Bogus2 by itself.
+ * STEP 3: Test DYNLIB2 by itself.
*----------------------------------------------------------
*/
puts("Testing DYNLIB2 filter");
if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error;
- if(H5Pset_filter (dc, H5Z_FILTER_DYNLIB2, H5Z_FLAG_MANDATORY, 1, &compress_level) < 0) goto error;
+ if(H5Pset_filter (dc, H5Z_FILTER_DYNLIB2, H5Z_FLAG_MANDATORY, 0, NULL) < 0) goto error;
if(test_filter_internal(file,DSET_DYNLIB2_NAME,dc) < 0) goto error;
@@ -405,27 +406,6 @@ test_filters(hid_t file, hid_t fapl)
* for this filter. */
if(H5Zunregister(H5Z_FILTER_DYNLIB2) < 0) goto error;
-
- /*----------------------------------------------------------
- * STEP 3: Test BZIP2 by itself.
- *----------------------------------------------------------
- */
- puts("Testing BZIP2 filter");
- if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
- if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error;
- if(H5Pset_filter (dc, H5Z_FILTER_BZIP2, H5Z_FLAG_MANDATORY, 1, &compress_level) < 0) goto error;
-
- if(test_filter_internal(file,DSET_BZIP2_NAME,dc) < 0) goto error;
-
- /* Clean up objects used for this test */
- if(H5Pclose (dc) < 0) goto error;
-
- /* Unregister the dynamic filter BOGUS 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_BZIP2) < 0) goto error;
-#endif
-
return 0;
error:
@@ -498,7 +478,7 @@ test_read_with_filters(hid_t file, hid_t fapl)
hid_t dset; /* Dataset ID */
/*----------------------------------------------------------
- * STEP 2: Test deflation by itself.
+ * STEP 1: Test deflation by itself.
*----------------------------------------------------------
*/
#ifdef H5_HAVE_FILTER_DEFLATE
@@ -531,9 +511,8 @@ test_read_with_filters(hid_t file, hid_t fapl)
if(H5Dclose(dset) < 0) TEST_ERROR
-#ifdef TMP
/*----------------------------------------------------------
- * STEP 2: Test Bogus2 by itself.
+ * STEP 3: Test Bogus2 by itself.
*----------------------------------------------------------
*/
TESTING("Testing DYNLIB2 filter");
@@ -544,20 +523,6 @@ test_read_with_filters(hid_t file, hid_t fapl)
if(H5Dclose(dset) < 0) TEST_ERROR
- /*----------------------------------------------------------
- * STEP 3: Test BZIP2 by itself.
- *----------------------------------------------------------
- */
- TESTING("Testing BZIP2 filter");
-
- if((dset = H5Dopen2(file,DSET_BZIP2_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
-
- if(test_read_data(dset, points_bzip2) < 0) TEST_ERROR
-
- if(H5Dclose(dset) < 0) TEST_ERROR
-
-#endif
-
return 0;
error:
diff --git a/test/test_plugin.sh.in b/test/test_plugin.sh.in
index 630a689..1d06956 100644
--- a/test/test_plugin.sh.in
+++ b/test/test_plugin.sh.in
@@ -21,9 +21,6 @@
srcdir=@srcdir@
TOP_BUILDDIR=@top_builddir@
-echo $srcdir
-echo $TOP_BUILDDIR
-
# Determine backward compatibility options enabled
DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@"
@@ -32,7 +29,8 @@ verbose=yes
TEST_NAME=plugin
TEST_BIN=`pwd`/$TEST_NAME
-ENVCMD="env HDF5_PLUGIN_PATH=`pwd`/.libs"
+CP="cp .libs/libdynlib2.so.* /tmp"
+ENVCMD="env HDF5_PLUGIN_PATH=/tmp:`pwd`/.libs"
# Print a line-line message left justified in a field of 70 characters
# beginning with the word "Testing".
@@ -44,7 +42,7 @@ TESTING() {
# Main Body
# Run the test
-$ENVCMD $TEST_BIN
+$CP; $ENVCMD $TEST_BIN
if [ $? != 0 ]; then
nerrors=`expr $nerrors + 1`
fi