From 621014be2818eaf62393f3a03cb17f121f0bbf9a Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 27 Dec 2018 15:50:04 -0800 Subject: Added a simple test for registration of VOL connector plugins. Autotools only for right now, but this will be fleshed out in future work. --- MANIFEST | 15 +++--- configure.ac | 1 + test/Makefile.am | 16 +++--- test/echo_vol.c | 127 ------------------------------------------- test/null_vol_connector.c | 116 +++++++++++++++++++++++++++++++++++++++ test/null_vol_connector.h | 25 +++++++++ test/test_vol_plugin.sh.in | 84 +++++++++++++++++++++++++++++ test/vol_plugin.c | 132 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 375 insertions(+), 141 deletions(-) delete mode 100644 test/echo_vol.c create mode 100644 test/null_vol_connector.c create mode 100644 test/null_vol_connector.h create mode 100644 test/test_vol_plugin.sh.in create mode 100644 test/vol_plugin.c diff --git a/MANIFEST b/MANIFEST index 585d8cc..cd16b9e 100644 --- a/MANIFEST +++ b/MANIFEST @@ -972,7 +972,6 @@ ./test/dtypes.c ./test/dtransform.c ./test/earray.c -./test/echo_vol.c ./test/efc.c ./test/enc_dec_plist.c ./test/enc_dec_plist_cross_platform.c @@ -1020,6 +1019,7 @@ ./test/gen_deflate.c ./test/gen_file_image.c ./test/gen_filespace.c +./test/gen_filters.c ./test/gen_mergemsg.c ./test/gen_new_array.c ./test/gen_new_fill.c @@ -1063,6 +1063,8 @@ ./test/noencoder.h5 ./test/none.h5 ./test/ntypes.c +./test/null_vol_connector.c +./test/null_vol_connector.h ./test/ohdr.c ./test/objcopy.c ./test/page_buffer.c @@ -1103,12 +1105,15 @@ ./test/testlinks_env.sh.in ./test/test_filenotclosed.sh.in ./test/test_filter_plugin.sh.in +./test/test_filters_le.h5 +./test/test_filters_be.h5 ./test/testflushrefresh.sh.in ./test/testframe.c ./test/testhdf5.c ./test/testhdf5.h ./test/testlibinfo.sh.in ./test/test_usecases.sh.in +./test/test_vol_plugin.sh.in ./test/testmeta.c ./test/testswmr.sh.in ./test/testvdsswmr.sh.in @@ -1150,16 +1155,14 @@ ./test/use_common.c ./test/use_disable_mdc_flushes.c ./test/use.h -./test/vfd.c -./test/vol.c -./test/test_filters_le.h5 -./test/test_filters_be.h5 -./test/gen_filters.c ./test/vds.c ./test/vds_swmr.h ./test/vds_swmr_gen.c ./test/vds_swmr_reader.c ./test/vds_swmr_writer.c +./test/vfd.c +./test/vol.c +./test/vol_plugin.c ./test/testfiles/err_compat_1 ./test/testfiles/err_compat_2 diff --git a/configure.ac b/configure.ac index 0a1370f..6a88493 100644 --- a/configure.ac +++ b/configure.ac @@ -3443,6 +3443,7 @@ AC_CONFIG_FILES([src/libhdf5.settings test/test_filenotclosed.sh test/test_filter_plugin.sh test/test_usecases.sh + test/test_vol_plugin.sh testpar/Makefile tools/Makefile tools/lib/Makefile diff --git a/test/Makefile.am b/test/Makefile.am index 1526eca..3a8c64f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -41,8 +41,8 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) filen swmr_sparse_reader$(EXEEXT) swmr_sparse_writer$(EXEEXT) swmr_start_write$(EXEEXT) \ vds_swmr_gen$(EXEEXT) vds_swmr_reader$(EXEEXT) vds_swmr_writer$(EXEEXT) if HAVE_SHARED_CONDITIONAL - TEST_SCRIPT += test_filter_plugin.sh - SCRIPT_DEPEND += filter_plugin$(EXEEXT) + TEST_SCRIPT += test_filter_plugin.sh test_vol_plugin.sh + SCRIPT_DEPEND += filter_plugin$(EXEEXT) vol_plugin$(EXEEXT) endif check_SCRIPTS = $(TEST_SCRIPT) @@ -83,7 +83,7 @@ check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version \ swmr_remove_writer swmr_addrem_writer swmr_sparse_reader swmr_sparse_writer \ swmr_check_compat_vfd vds_swmr_gen vds_swmr_reader vds_swmr_writer if HAVE_SHARED_CONDITIONAL - check_PROGRAMS+= filter_plugin + check_PROGRAMS+= filter_plugin vol_plugin endif # These programs generate test files for the tests. They don't need to be @@ -106,9 +106,7 @@ if HAVE_SHARED_CONDITIONAL # The libh5test library provides common support code for the tests. # The filter_plugin* libraries are for use in filter_plugin.c. # Build them as shared libraries if that option was enabled in configure. - # - # echo_vol is used for testing VOL plugin functionality. - noinst_LTLIBRARIES=libh5test.la libfilter_plugin1_dsets.la libfilter_plugin2_dsets.la libfilter_plugin3_dsets.la libfilter_plugin4_groups.la echo_vol.la + noinst_LTLIBRARIES=libh5test.la libfilter_plugin1_dsets.la libfilter_plugin2_dsets.la libfilter_plugin3_dsets.la libfilter_plugin4_groups.la libnull_vol_connector.la libfilter_plugin1_dsets_la_SOURCES=filter_plugin1_dsets.c libfilter_plugin2_dsets_la_SOURCES=filter_plugin2_dsets.c libfilter_plugin3_dsets_la_SOURCES=filter_plugin3_dsets.c @@ -121,8 +119,10 @@ if HAVE_SHARED_CONDITIONAL libfilter_plugin4_groups_la_LIBADD=$(LIBHDF5) # VOL plugin test libraries - echo_vol_la_SOURCES=echo_vol.c - echo_vol_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere + # + # null_vol_connector is used for testing basic VOL plugin functionality. + libnull_vol_connector_la_SOURCES=null_vol_connector.c + libnull_vol_connector_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere else # The libh5test library provides common support code for the tests. diff --git a/test/echo_vol.c b/test/echo_vol.c deleted file mode 100644 index 7f59832..0000000 --- a/test/echo_vol.c +++ /dev/null @@ -1,127 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * 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 COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Purpose: A simple virtual object layer (VOL) plugin that just echoes - * the name of the API call. - */ - -#include "H5PLextern.h" - -/* The VOL class struct. - */ -static const H5VL_class_t echo_vol_g = { - 0, /* version */ - (H5VL_class_value_t)501, /* value */ - "echo", /* name */ - 0, /* capability flags */ - NULL, /* initialize */ - NULL, /* terminate */ - (size_t)0, /* info size */ - NULL, /* info copy */ - NULL, /* info compare */ - NULL, /* info free */ - NULL, /* info to str */ - NULL, /* str to info */ - NULL, /* get_object */ - NULL, /* get_wrap_ctx */ - NULL, /* wrap_object */ - NULL, /* free_wrap_ctx */ - { /* attribute_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* read */ - NULL, /* write */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ - }, - { /* dataset_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* read */ - NULL, /* write */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ - }, - { /* datatype_cls */ - NULL, /* commit */ - NULL, /* open */ - NULL, /* get_size */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ - }, - { /* file_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ - }, - { /* group_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ - }, - { /* link_cls */ - NULL, /* create */ - NULL, /* copy */ - NULL, /* move */ - NULL, /* get */ - NULL, /* specific */ - NULL /* optional */ - }, - { /* object_cls */ - NULL, /* open */ - NULL, /* copy */ - NULL, /* get */ - NULL, /* specific */ - NULL /* optional */ - }, - { /* request_cls */ - NULL, /* wait */ - NULL, /* notify */ - NULL, /* cancel */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* free */ - }, - NULL /* optional */ -}; - - - -/* These two functions are necessary to load this plugin using - * the HDF5 library. - */ - -H5PL_type_t -H5PLget_plugin_type(void) -{ - return H5PL_TYPE_VOL; -} - - -const void* -H5PLget_plugin_info(void) -{ - return &echo_vol_g; -} - diff --git a/test/null_vol_connector.c b/test/null_vol_connector.c new file mode 100644 index 0000000..b62b370 --- /dev/null +++ b/test/null_vol_connector.c @@ -0,0 +1,116 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Purpose: A simple virtual object layer (VOL) connector with almost no + * functionality that is used for testing basic plugin handling + * (registration, etc.). + */ + +#include "H5PLextern.h" + +#include "null_vol_connector.h" + +/* The VOL class struct */ +static const H5VL_class_t null_vol_g = { + 0, /* version */ + NULL_VOL_CONNECTOR_VALUE, /* value */ + NULL_VOL_CONNECTOR_NAME, /* name */ + 0, /* capability flags */ + NULL, /* initialize */ + NULL, /* terminate */ + (size_t)0, /* info size */ + NULL, /* info copy */ + NULL, /* info compare */ + NULL, /* info free */ + NULL, /* info to str */ + NULL, /* str to info */ + NULL, /* get_object */ + NULL, /* get_wrap_ctx */ + NULL, /* wrap_object */ + NULL, /* free_wrap_ctx */ + { /* attribute_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* read */ + NULL, /* write */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ + }, + { /* dataset_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* read */ + NULL, /* write */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ + }, + { /* datatype_cls */ + NULL, /* commit */ + NULL, /* open */ + NULL, /* get_size */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ + }, + { /* file_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ + }, + { /* group_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ + }, + { /* link_cls */ + NULL, /* create */ + NULL, /* copy */ + NULL, /* move */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ + }, + { /* object_cls */ + NULL, /* open */ + NULL, /* copy */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ + }, + { /* request_cls */ + NULL, /* wait */ + NULL, /* notify */ + NULL, /* cancel */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* free */ + }, + NULL /* optional */ +}; + +/* These two functions are necessary to load this plugin using + * the HDF5 library. + */ + +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_VOL;} +const void *H5PLget_plugin_info(void) {return &null_vol_g;} + diff --git a/test/null_vol_connector.h b/test/null_vol_connector.h new file mode 100644 index 0000000..11c8826 --- /dev/null +++ b/test/null_vol_connector.h @@ -0,0 +1,25 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Purpose: A simple virtual object layer (VOL) connector with almost no + * functionality that is used for testing basic plugin handling + * (registration, etc.). + */ + +#ifndef _null_vol_connector_H +#define _null_vol_connector_H + +#define NULL_VOL_CONNECTOR_VALUE ((H5VL_class_value_t)160) +#define NULL_VOL_CONNECTOR_NAME "null_vol_connector" + +#endif /* _null_vol_connector_H */ + diff --git a/test/test_vol_plugin.sh.in b/test/test_vol_plugin.sh.in new file mode 100644 index 0000000..38220ef --- /dev/null +++ b/test/test_vol_plugin.sh.in @@ -0,0 +1,84 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# 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 COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# This shell script is for testing VOL connector plugins. +# +srcdir=@srcdir@ +TOP_BUILDDIR=@top_builddir@ + +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + +nerrors=0 +verbose=yes +exit_code=$EXIT_SUCCESS + +TEST_NAME=vol_plugin +TEST_BIN=`pwd`/$TEST_NAME +FROM_DIR=`pwd`/.libs +case $(uname) in + CYGWIN* ) + NULL_VOL_PLUGIN="$FROM_DIR/cygnull_vol_connector*" + ;; + *) + NULL_VOL_PLUGIN="$FROM_DIR/libnull_vol_connector*" + ;; +esac +TEMP_PLUGIN_DIR=null_vol_plugin_dir +CP="cp -p" # Use -p to preserve mode,ownership, timestamps +RM="rm -rf" + +# Print a line-line message left justified in a field of 70 characters +# beginning with the word "Testing". +# +TESTING() { + SPACES=" " + echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' +} + +# Main Body +# Create test directory if necessary. +test -d $TEMP_PLUGIN_DIR || mkdir -p $TEMP_PLUGIN_DIR +if [ $? != 0 ]; then + echo "Failed to create VOL connector plugin test directory ($TEMP_PLUGIN_DIR)" + exit $EXIT_FAILURE +fi + +# Copy plugin for the tests. +$CP $NULL_VOL_PLUGIN $TEMP_PLUGIN_DIR +if [ $? != 0 ]; then + echo "Failed to copy NULL VOL plugin ($NULL_VOL_PLUGIN) to test directory." + exit $EXIT_FAILURE +fi + +# setup plugin path +ENVCMD="env HDF5_PLUGIN_PATH=${TEMP_PLUGIN_DIR}" + +# Run the test +$ENVCMD $TEST_BIN +if [ $? != 0 ]; then + nerrors=`expr $nerrors + 1` +fi + +# print results +if test $nerrors -ne 0 ; then + echo "$nerrors errors encountered" + exit_code=$EXIT_FAILURE +else + echo "All VOL plugin tests passed." + exit_code=$EXIT_SUCCESS +fi + +# Clean up temporary files/directories and leave +$RM $TEMP_PLUGIN_DIR + +exit $exit_code diff --git a/test/vol_plugin.c b/test/vol_plugin.c new file mode 100644 index 0000000..90583e0 --- /dev/null +++ b/test/vol_plugin.c @@ -0,0 +1,132 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Tests basic VOL plugin operations (registration, etc.). + */ + +#include "h5test.h" + +#include "null_vol_connector.h" + + +/*------------------------------------------------------------------------- + * Function: test_registration() + * + * Purpose: Tests if we can load, register, and close a VOL + * connector. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_registration(void) +{ + htri_t is_registered = FAIL; + hid_t vol_id = H5I_INVALID_HID; + + TESTING("VOL registration"); + + /* The null VOL connector should not be registered at the start of the test */ + if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); + + /* Register the connector by name */ + if((vol_id = H5VLregister_connector_by_name(NULL_VOL_CONNECTOR_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* The connector should be registered now */ + if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(FALSE == is_registered) + FAIL_PUTS_ERROR("NULL VOL connector was not registered"); + + /* Unregister the connector */ + if(H5VLunregister_connector(vol_id) < 0) + TEST_ERROR; + + /* The connector should not be registered now */ + if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); + + /* Register the connector by ID */ + if((vol_id = H5VLregister_connector_by_value(NULL_VOL_CONNECTOR_VALUE, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* The connector should be registered now */ + if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(FALSE == is_registered) + FAIL_PUTS_ERROR("NULL VOL connector was not registered"); + + /* XXX: Test get connector name/value here */ + /* XXX: Test double registration, too */ + + /* Unregister the connector */ + if(H5VLunregister_connector(vol_id) < 0) + TEST_ERROR; + + /* The connector should not be registered now */ + if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); + + PASSED(); + return SUCCEED; + +error: + H5E_BEGIN_TRY { + H5VLunregister_connector(vol_id); + } H5E_END_TRY; + return FAIL; + +} /* end test_registration() */ + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Tests VOL connector plugin operations + * + * Return: EXIT_SUCCESS/EXIT_FAILURE + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + int nerrors = 0; + + h5_reset(); + + HDputs("Testing VOL connector plugin functionality."); + + nerrors += test_registration() < 0 ? 1 : 0; + + if(nerrors) { + HDprintf("***** %d VOL connector plugin TEST%s FAILED! *****\n", + nerrors, nerrors > 1 ? "S" : ""); + HDexit(EXIT_FAILURE); + } + + HDputs("All VOL connector plugin tests passed."); + + HDexit(EXIT_SUCCESS); + +} /* end main() */ + -- cgit v0.12