From ed621aae38837e90c7273087de22f1752eee7cc7 Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Fri, 29 Mar 2013 15:59:15 -0500 Subject: [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. --- test/Makefile.am | 7 ++-- test/Makefile.in | 43 ++++++++++++++--------- test/dynlib1.c | 7 ++-- test/dynlib2.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++ test/plugin.c | 55 ++++++----------------------- test/test_plugin.sh.in | 8 ++--- 6 files changed, 142 insertions(+), 71 deletions(-) create mode 100644 test/dynlib2.c 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 +#include +#include +#include + +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