summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2018-12-28 03:42:02 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2018-12-28 03:42:02 (GMT)
commit544ab1c78a9f6e5d09b76ba134c0ac3164736fa7 (patch)
tree47b0e7ab5cc851e143d80ea8e4f931abb7246613
parent621014be2818eaf62393f3a03cb17f121f0bbf9a (diff)
downloadhdf5-544ab1c78a9f6e5d09b76ba134c0ac3164736fa7.zip
hdf5-544ab1c78a9f6e5d09b76ba134c0ac3164736fa7.tar.gz
hdf5-544ab1c78a9f6e5d09b76ba134c0ac3164736fa7.tar.bz2
Added more sub-tests to the VOL plugin test.
-rw-r--r--src/H5VL.c11
-rw-r--r--src/H5VLint.c2
-rw-r--r--test/vol_plugin.c185
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",