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 From 544ab1c78a9f6e5d09b76ba134c0ac3164736fa7 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 27 Dec 2018 19:42:02 -0800 Subject: Added more sub-tests to the VOL plugin test. --- src/H5VL.c | 11 ++-- src/H5VLint.c | 2 +- test/vol_plugin.c | 185 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 177 insertions(+), 21 deletions(-) diff --git a/src/H5VL.c b/src/H5VL.c index bf1201f..88d3d70 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -11,7 +11,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Purpose: The Virtual Object Layer as described in documentation. + * Purpose: The Virtual Object Layer as described in documentation. * The pupose is to provide an abstraction on how to access the * underlying HDF5 container, whether in a local file with * a specific file format, or remotely on other machines, etc... @@ -486,14 +486,11 @@ done: /*--------------------------------------------------------------------------- * Function: H5VLcmp_connector_cls * - * Purpose: Compares two connector classes + * Purpose: Compares two connector classes (based on their value field) * - * Return: Success: Non-negative, with *cmp set to positive if - * connector_id1 is greater than connector_id2, negative if connector_id2 - * is greater than connector_id1 and zero if connector_id1 and connector_id2 - * are equal. + * Return: Success: Non-negative, *cmp set to a value like strcmp * - * Failure: Negative + * Failure: Negative, *cmp unset * *--------------------------------------------------------------------------- */ diff --git a/src/H5VLint.c b/src/H5VLint.c index d51be0c..8695a80 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -881,7 +881,7 @@ done: * * Return: Positive if VALUE1 is greater than VALUE2, negative if * VALUE2 is greater than VALUE1 and zero if VALUE1 and - * VALUE2 are equal. + * VALUE2 are equal (like strcmp). * *------------------------------------------------------------------------- */ diff --git a/test/vol_plugin.c b/test/vol_plugin.c index 90583e0..b4df14f 100644 --- a/test/vol_plugin.c +++ b/test/vol_plugin.c @@ -12,6 +12,11 @@ /* * Purpose: Tests basic VOL plugin operations (registration, etc.). + * Uses the null VOL connector (built with the testing code) + * which is loaded as a dynamic plugin. + * + * TO DO: Adapt the null VOL connector to do something interesting with + * the property list. */ #include "h5test.h" @@ -20,22 +25,22 @@ /*------------------------------------------------------------------------- - * Function: test_registration() + * Function: test_registration_by_value() * * Purpose: Tests if we can load, register, and close a VOL - * connector. + * connector by value. * * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ static herr_t -test_registration(void) +test_registration_by_value(void) { htri_t is_registered = FAIL; hid_t vol_id = H5I_INVALID_HID; - TESTING("VOL registration"); + TESTING("VOL registration by value"); /* 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) @@ -43,8 +48,8 @@ test_registration(void) 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) + /* Register the connector by value */ + if((vol_id = H5VLregister_connector_by_value(NULL_VOL_CONNECTOR_VALUE, H5P_DEFAULT)) < 0) TEST_ERROR; /* The connector should be registered now */ @@ -63,8 +68,44 @@ test_registration(void) 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) + PASSED(); + return SUCCEED; + +error: + H5E_BEGIN_TRY { + H5VLunregister_connector(vol_id); + } H5E_END_TRY; + return FAIL; + +} /* end test_registration_by_value() */ + + +/*------------------------------------------------------------------------- + * Function: test_registration_by_name() + * + * Purpose: Tests if we can load, register, and close a VOL + * connector by name. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_registration_by_name(void) +{ + htri_t is_registered = FAIL; + hid_t vol_id = H5I_INVALID_HID; + + TESTING("registering a VOL connector multiple times"); + + /* 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 */ @@ -73,9 +114,6 @@ test_registration(void) 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; @@ -95,7 +133,125 @@ error: } H5E_END_TRY; return FAIL; -} /* end test_registration() */ +} /* end test_registration_by_name() */ + + +/*------------------------------------------------------------------------- + * Function: test_multiple_registration() + * + * Purpose: Tests if we can register a VOL connector multiple times. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +#define N_REGISTRATIONS 10 +static herr_t +test_multiple_registration(void) +{ + htri_t is_registered = FAIL; + hid_t vol_ids[N_REGISTRATIONS]; + int i; + + TESTING("VOL registration by name"); + + /* 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 multiple times */ + for(i = 0; i < N_REGISTRATIONS; i++) { + if((vol_ids[i] = 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 */ + for(i = 0; i < N_REGISTRATIONS; i++) { + if(H5VLunregister_connector(vol_ids[i]) < 0) + TEST_ERROR; + /* Also test close on some of the IDs. This call currently works + * identically to unregister. + */ + i++; + if(H5VLclose(vol_ids[i]) < 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 { + for(i = 0; i < N_REGISTRATIONS; i++) + H5VLunregister_connector(vol_ids[i]); + } H5E_END_TRY; + return FAIL; + +} /* end test_multiple_registration() */ + + +/*------------------------------------------------------------------------- + * Function: test_getters() + * + * Purpose: Tests H5VL getters + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_getters(void) +{ + htri_t is_registered = FAIL; + hid_t vol_id = H5I_INVALID_HID; + hid_t vol_id_out = H5I_INVALID_HID; + + TESTING("VOL getters"); + + /* 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; + + /* Get the connector's ID */ + if((vol_id_out = H5VLget_connector_id(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(vol_id != vol_id_out) + FAIL_PUTS_ERROR("VOL connector IDs don't match"); + + /* Unregister the connector */ + if(H5VLunregister_connector(vol_id) < 0) + TEST_ERROR; + + PASSED(); + return SUCCEED; + +error: + H5E_BEGIN_TRY { + H5VLunregister_connector(vol_id); + } H5E_END_TRY; + return FAIL; + +} /* end test_getters() */ /*------------------------------------------------------------------------- @@ -116,7 +272,10 @@ main(void) HDputs("Testing VOL connector plugin functionality."); - nerrors += test_registration() < 0 ? 1 : 0; + nerrors += test_registration_by_name() < 0 ? 1 : 0; + nerrors += test_registration_by_value() < 0 ? 1 : 0; + nerrors += test_multiple_registration() < 0 ? 1 : 0; + nerrors += test_getters() < 0 ? 1 : 0; if(nerrors) { HDprintf("***** %d VOL connector plugin TEST%s FAILED! *****\n", -- cgit v0.12 From fafee5b8ae2fdac2aaf9300e25b4c5f43c4c5fb0 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 27 Dec 2018 19:56:21 -0800 Subject: Fixed a CMake build issue (CMake still doesn't run the VOL plugin tests) --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ed6bacc..69afb85 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -133,7 +133,7 @@ if (BUILD_SHARED_LIBS) # Define VOL Plugin Test Sources #----------------------------------------------------------------------------- set (VOL_PLUGIN_LIBS - echo_vol + null_vol_connector ) foreach (vol_lib ${VOL_PLUGIN_LIBS}) -- cgit v0.12 From 3a05e7109a74dafaaaa2fd404638fd6ddeaafd90 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 27 Dec 2018 21:42:51 -0800 Subject: Added test_vol_plugin.sh to the list of scripts to clean --- test/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Makefile.am b/test/Makefile.am index 3a8c64f..a581f9a 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -220,6 +220,7 @@ use_disable_mdc_flushes_SOURCES=use_disable_mdc_flushes.c # Temporary files. DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_filter_plugin.sh \ - testswmr.sh testvdsswmr.sh test_usecases.sh testflushrefresh.sh test_filenotclosed.sh + testswmr.sh testvdsswmr.sh test_usecases.sh testflushrefresh.sh test_filenotclosed.sh \ + test_vol_plugin.sh include $(top_srcdir)/config/conclude.am -- cgit v0.12 From 3ca19cca5395d79be69209f8d7d0a2b06834a648 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 28 Dec 2018 12:56:49 -0800 Subject: Flipped swapped testing strings. --- test/vol_plugin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/vol_plugin.c b/test/vol_plugin.c index b4df14f..236a67e 100644 --- a/test/vol_plugin.c +++ b/test/vol_plugin.c @@ -96,7 +96,7 @@ test_registration_by_name(void) htri_t is_registered = FAIL; hid_t vol_id = H5I_INVALID_HID; - TESTING("registering a VOL connector multiple times"); + TESTING("VOL registration by name"); /* 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) @@ -153,7 +153,7 @@ test_multiple_registration(void) hid_t vol_ids[N_REGISTRATIONS]; int i; - TESTING("VOL registration by name"); + TESTING("registering a VOL connector multiple times"); /* 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) -- cgit v0.12