summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@lbl.gov>2020-12-10 17:01:04 (GMT)
committerGitHub <noreply@github.com>2020-12-10 17:01:04 (GMT)
commit17a2e88769c15d8684bda4d8a6c9f53836f7b65b (patch)
treee11decdcdfdd7bf594475b3d9520a403d1478d49 /test
parent4713a6d23840ed222d90f3ca73f037cb20b5d444 (diff)
downloadhdf5-17a2e88769c15d8684bda4d8a6c9f53836f7b65b.zip
hdf5-17a2e88769c15d8684bda4d8a6c9f53836f7b65b.tar.gz
hdf5-17a2e88769c15d8684bda4d8a6c9f53836f7b65b.tar.bz2
Enforce VOL framework version compatibility when registering connectors. Also add a version for the connector itself, some refactoring on the register calls, and move the logic for matching / rejecting a VOL connector class from the plugin module to the VOL module. (#151)
Diffstat (limited to 'test')
-rw-r--r--test/h5test.c1
-rw-r--r--test/null_vol_connector.c3
-rw-r--r--test/vol.c22
3 files changed, 23 insertions, 3 deletions
diff --git a/test/h5test.c b/test/h5test.c
index 92534bd..9c59e77 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -2040,6 +2040,7 @@ h5_get_dummy_vol_class(void)
/* Fill in the minimum parameters to make a VOL connector class that
* can be registered.
*/
+ vol_class->version = H5VL_VERSION;
vol_class->name = "dummy";
return vol_class;
diff --git a/test/null_vol_connector.c b/test/null_vol_connector.c
index 095169c..9a382b7 100644
--- a/test/null_vol_connector.c
+++ b/test/null_vol_connector.c
@@ -26,9 +26,10 @@
/* The VOL class struct */
static const H5VL_class_t null_vol_g = {
- 0, /* version */
+ H5VL_VERSION, /* VOL class struct version */
NULL_VOL_CONNECTOR_VALUE, /* value */
NULL_VOL_CONNECTOR_NAME, /* name */
+ 0, /* connector version */
0, /* capability flags */
NULL, /* initialize */
NULL, /* terminate */
diff --git a/test/vol.c b/test/vol.c
index b662cb8..6c9da62 100644
--- a/test/vol.c
+++ b/test/vol.c
@@ -42,9 +42,10 @@ const char *FILENAME[] = {"native_vol_test", NULL};
* functionality.
*/
static const H5VL_class_t fake_vol_g = {
- 0, /* version */
+ H5VL_VERSION, /* VOL class struct version */
FAKE_VOL_VALUE, /* value */
FAKE_VOL_NAME, /* name */
+ 0, /* connector version */
0, /* capability flags */
NULL, /* initialize */
NULL, /* terminate */
@@ -181,6 +182,7 @@ test_vol_registration(void)
htri_t is_registered = FAIL;
hid_t vol_id = H5I_INVALID_HID;
hid_t vol_id2 = H5I_INVALID_HID;
+ H5VL_class_t *bad_fake_vol_class = NULL;
TESTING("VOL registration");
@@ -204,6 +206,19 @@ test_vol_registration(void)
if (H5Pclose(lapl_id) < 0)
TEST_ERROR;
+ /* Test registering a VOL connector with an incompatible version # */
+ if (NULL == (bad_fake_vol_class = HDmalloc(sizeof(H5VL_class_t))))
+ TEST_ERROR;
+ HDmemcpy(bad_fake_vol_class, &fake_vol_g, sizeof(H5VL_class_t));
+ bad_fake_vol_class->version = H5VL_VERSION + 1;
+ H5E_BEGIN_TRY {
+ vol_id = H5VLregister_connector(bad_fake_vol_class, H5P_DEFAULT);
+ } H5E_END_TRY;
+ if (H5I_INVALID_HID != vol_id)
+ FAIL_PUTS_ERROR("should not be able to register a connector with an incompatible version #");
+ HDfree(bad_fake_vol_class);
+ bad_fake_vol_class = NULL;
+
/* Load a VOL interface
* The vipl_id does nothing without a VOL that needs it, but we do need to
* test creating a property list of that class and passing it along as a
@@ -277,8 +292,11 @@ error:
H5Pclose(vipl_id);
}
H5E_END_TRY;
- return FAIL;
+ if (bad_fake_vol_class)
+ HDfree(bad_fake_vol_class);
+
+ return FAIL;
} /* end test_vol_registration() */
/*-------------------------------------------------------------------------