From edec1f017d1ca7679058357bf01c62355a1120fd Mon Sep 17 00:00:00 2001 From: Jordan Henderson Date: Tue, 28 Jan 2020 18:18:38 -0600 Subject: Introduce new H5VL _by_value routines --- fortran/src/H5VLff.F90 | 98 +++++++++++++++++++++++--- fortran/src/hdf5_fortrandll.def.in | 4 +- fortran/test/vol_connector.F90 | 44 ++++++------ java/src/hdf/hdf5lib/H5.java | 4 +- java/src/jni/h5vlImp.c | 60 ++++++++++++++-- java/src/jni/h5vlImp.h | 22 +++++- java/test/TestH5VL.java | 26 +++++-- java/test/testfiles/JUnit-TestH5VL.txt | 3 +- src/H5VL.c | 109 ++++++++++++++++++++++++++--- src/H5VLconnector.h | 3 +- src/H5VLint.c | 124 ++++++++++++++++++++++++++++++--- src/H5VLpkg.h | 7 +- src/H5VLpublic.h | 9 ++- test/vol.c | 34 +++++++-- test/vol_plugin.c | 83 +++++++++++++++++++--- tools/lib/h5tools.c | 4 +- tools/lib/h5tools_utils.h | 2 +- 17 files changed, 545 insertions(+), 91 deletions(-) diff --git a/fortran/src/H5VLff.F90 b/fortran/src/H5VLff.F90 index eea9dfe..32dd7d7 100644 --- a/fortran/src/H5VLff.F90 +++ b/fortran/src/H5VLff.F90 @@ -124,13 +124,14 @@ CONTAINS END SUBROUTINE H5VLregister_connector_by_value_f ! -!****s* H5VL/H5VLis_connector_registered_f +!****s* H5VL/H5VLis_connector_registered_by_name_f ! ! NAME -! H5VLis_connector_registered_f +! H5VLis_connector_registered_by_name_f ! ! PURPOSE -! Tests whether a VOL class has been registered or not. +! Tests whether a VOL class has been registered or not +! according to a specified connector name. ! ! INPUTS ! name - Connector name @@ -139,7 +140,7 @@ CONTAINS ! hdferr - Returns 0 if successful and -1 if fails ! SOURCE - SUBROUTINE H5VLis_connector_registered_f(name, registered, hdferr) + SUBROUTINE H5VLis_connector_registered_by_name_f(name, registered, hdferr) IMPLICIT NONE CHARACTER(LEN=*), INTENT(IN) :: name LOGICAL, INTENT(OUT) :: registered @@ -149,22 +150,63 @@ CONTAINS INTEGER(C_INT) :: registered_c INTERFACE - INTEGER(C_INT) FUNCTION H5VLis_connector_registered(name) BIND(C,NAME='H5VLis_connector_registered') + INTEGER(C_INT) FUNCTION H5VLis_connector_registered_by_name(name) BIND(C,NAME='H5VLis_connector_registered_by_name') IMPORT :: C_CHAR IMPORT :: C_INT CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: name - END FUNCTION H5VLis_connector_registered + END FUNCTION H5VLis_connector_registered_by_name END INTERFACE c_name = TRIM(name)//C_NULL_CHAR - registered_c = H5VLis_connector_registered(c_name) + registered_c = H5VLis_connector_registered_by_name(c_name) hdferr = 0 registered = .FALSE. IF(registered_c .GT. 0) registered = .TRUE. IF(registered_c .LT. 0) hdferr = INT(registered_c) - END SUBROUTINE H5VLis_connector_registered_f + END SUBROUTINE H5VLis_connector_registered_by_name_f + +! +!****s* H5VL/H5VLis_connector_registered_by_value_f +! +! NAME +! H5VLis_connector_registered_by_value_f +! +! PURPOSE +! Tests whether a VOL class has been registered or not +! according to a specified connector value (ID). +! +! INPUTS +! value - Connector value +! OUTPUTS +! registered - state of VOL class registration +! hdferr - Returns 0 if successful and -1 if fails +! SOURCE + + SUBROUTINE H5VLis_connector_registered_by_value_f(value, registered, hdferr) + IMPLICIT NONE + INTEGER, INTENT(IN) :: value + LOGICAL, INTENT(OUT) :: registered + INTEGER, INTENT(OUT) :: hdferr +!***** + INTEGER(C_INT) :: registered_c + + INTERFACE + INTEGER(C_INT) FUNCTION H5VLis_connector_registered_by_value(value) BIND(C,NAME='H5VLis_connector_registered_by_value') + IMPORT :: C_INT + INTEGER(C_INT), VALUE :: value + END FUNCTION H5VLis_connector_registered_by_value + END INTERFACE + + registered_c = H5VLis_connector_registered_by_value(INT(value,C_INT)) + + hdferr = 0 + registered = .FALSE. + IF(registered_c .GT. 0) registered = .TRUE. + IF(registered_c .LT. 0) hdferr = INT(registered_c) + + END SUBROUTINE H5VLis_connector_registered_by_value_f ! !****s* H5VL/H5VLget_connector_id_f @@ -248,6 +290,46 @@ CONTAINS END SUBROUTINE H5VLget_connector_id_by_name_f +! +!****s* H5VL/H5VLget_connector_id_by_value_f +! +! NAME +! H5VLget_connector_id_by_value_f +! +! PURPOSE +! Retrieves the ID for a registered VOL connector. +! +! INPUTS +! value - Connector value +! OUTPUTS +! vol_id - Connector id +! hdferr - Returns 0 if successful and -1 if fails +! SOURCE + + SUBROUTINE H5VLget_connector_id_by_value_f(value, vol_id, hdferr) + IMPLICIT NONE + INTEGER, INTENT(IN) :: value + INTEGER(HID_T), INTENT(OUT) :: vol_id + INTEGER, INTENT(OUT) :: hdferr +!***** + INTERFACE + INTEGER(HID_T) FUNCTION H5VLget_connector_id_by_value(value) BIND(C,NAME='H5VLget_connector_id_by_value') + IMPORT :: C_INT + IMPORT :: HID_T + INTEGER(C_INT), VALUE :: value + END FUNCTION H5VLget_connector_id_by_value + END INTERFACE + + vol_id = H5VLget_connector_id_by_value(INT(value,C_INT)) + + hdferr = 0 + IF(vol_id.LT.0)THEN + hdferr = -1 + vol_id = H5I_INVALID_HID_F + ENDIF + + END SUBROUTINE H5VLget_connector_id_by_value_f + SUBROUTINE H5VLget_connector_name_f(obj_id, name, hdferr, name_len) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: obj_id diff --git a/fortran/src/hdf5_fortrandll.def.in b/fortran/src/hdf5_fortrandll.def.in index 7e8b611..c792232 100644 --- a/fortran/src/hdf5_fortrandll.def.in +++ b/fortran/src/hdf5_fortrandll.def.in @@ -458,9 +458,11 @@ H5T_mp_H5TENUM_INSERT_F03 ; H5VL H5VL_mp_H5VLREGISTER_CONNECTOR_BY_NAME_F H5VL_mp_H5VLREGISTER_CONNECTOR_BY_VALUE_F -H5VL_mp_H5VLIS_CONNECTOR_REGISTERED_F +H5VL_mp_H5VLIS_CONNECTOR_REGISTERED_BY_NAME_F +H5VL_mp_H5VLIS_CONNECTOR_REGISTERED_BY_VALUE_F H5VL_mp_H5VLGET_CONNECTOR_ID_F H5VL_mp_H5VLGET_CONNECTOR_ID_BY_NAME_F +H5VL_mp_H5VLGET_CONNECTOR_ID_BY_VALUE_F H5VL_mp_H5VLGET_CONNECTOR_NAME_F H5VL_mp_H5VLCLOSE_F H5VL_mp_H5VLUNREGISTER_CONNECTOR_F diff --git a/fortran/test/vol_connector.F90 b/fortran/test/vol_connector.F90 index cd05cb1..d346737 100644 --- a/fortran/test/vol_connector.F90 +++ b/fortran/test/vol_connector.F90 @@ -61,18 +61,18 @@ CONTAINS INTEGER(hid_t) :: file_id ! The null VOL connector should not be registered at the start of the test - CALL H5VLis_connector_registered_f( "FAKE_VOL_CONNECTOR_NAME", is_registered, error) - CALL check("H5VLis_connector_registered_f",error,total_error) - CALL VERIFY("H5VLis_connector_registered_f", is_registered, .FALSE., total_error) + CALL H5VLis_connector_registered_by_name_f( "FAKE_VOL_CONNECTOR_NAME", is_registered, error) + CALL check("H5VLis_connector_registered_by_name_f",error,total_error) + CALL VERIFY("H5VLis_connector_registered_by_name_f", is_registered, .FALSE., total_error) ! Register the connector by name CALL H5VLregister_connector_by_name_f(NATIVE_VOL_CONNECTOR_NAME, vol_id, error) CALL check("H5VLregister_connector_by_name_f",error,total_error) ! The connector should be registered now - CALL H5VLis_connector_registered_f(NATIVE_VOL_CONNECTOR_NAME, is_registered, error) - CALL check("H5VLis_connector_registered_f",error,total_error) - CALL VERIFY("H5VLis_connector_registered_f", is_registered, .TRUE., total_error) + CALL H5VLis_connector_registered_by_name_f(NATIVE_VOL_CONNECTOR_NAME, is_registered, error) + CALL check("H5VLis_connector_registered_by_name_f",error,total_error) + CALL VERIFY("H5VLis_connector_registered_by_name_f", is_registered, .TRUE., total_error) CALL H5VLget_connector_id_by_name_f(NATIVE_VOL_CONNECTOR_NAME, vol_id_out, error) CALL check("H5VLget_connector_id_by_name_f",error,total_error) @@ -118,24 +118,24 @@ CONTAINS INTEGER, INTENT(INOUT) :: total_error INTEGER :: error = 0 - + LOGICAL :: is_registered = .FALSE. INTEGER(hid_t) :: vol_id = 0 ! The null VOL connector should not be registered at the start of the test - CALL H5VLis_connector_registered_f( "FAKE_VOL_CONNECTOR_NAME", is_registered, error) - CALL check("H5VLis_connector_registered_f",error,total_error) - CALL VERIFY("H5VLis_connector_registered_f", is_registered, .FALSE., total_error) + CALL H5VLis_connector_registered_by_name_f( "FAKE_VOL_CONNECTOR_NAME", is_registered, error) + CALL check("H5VLis_connector_registered_by_name_f",error,total_error) + CALL VERIFY("H5VLis_connector_registered_by_name_f", is_registered, .FALSE., total_error) ! Register the connector by value CALL H5VLregister_connector_by_value_f(NATIVE_VOL_CONNECTOR_VALUE, vol_id, error) CALL check("H5VLregister_connector_by_value_f", error, total_error) ! The connector should be registered now - CALL H5VLis_connector_registered_f(NATIVE_VOL_CONNECTOR_NAME, is_registered, error) - CALL check("H5VLis_connector_registered_f",error,total_error) - CALL VERIFY("H5VLis_connector_registered_f", is_registered, .TRUE., total_error) + CALL H5VLis_connector_registered_by_name_f(NATIVE_VOL_CONNECTOR_NAME, is_registered, error) + CALL check("H5VLis_connector_registered_by_name_f",error,total_error) + CALL VERIFY("H5VLis_connector_registered_by_name_f", is_registered, .TRUE., total_error) END SUBROUTINE test_registration_by_value @@ -162,23 +162,23 @@ CONTAINS INTEGER(hid_t) :: fapl_id TYPE(C_PTR) :: f_ptr - CALL H5VLis_connector_registered_f( "FAKE_VOL_CONNECTOR_NAME", is_registered, error) + CALL H5VLis_connector_registered_by_name_f( "FAKE_VOL_CONNECTOR_NAME", is_registered, error) - CALL check("H5VLis_connector_registered_f",error,total_error) - CALL VERIFY("H5VLis_connector_registered_f", is_registered, .FALSE., total_error) + CALL check("H5VLis_connector_registered_by_name_f",error,total_error) + CALL VERIFY("H5VLis_connector_registered_by_name_f", is_registered, .FALSE., total_error) ! The null VOL connector should not be registered at the start of the test - CALL H5VLis_connector_registered_f( "FAKE_VOL_CONNECTOR_NAME", is_registered, error) - CALL check("H5VLis_connector_registered_f",error,total_error) - CALL VERIFY("H5VLis_connector_registered_f", is_registered, .FALSE., total_error) + CALL H5VLis_connector_registered_by_name_f( "FAKE_VOL_CONNECTOR_NAME", is_registered, error) + CALL check("H5VLis_connector_registered_by_name_f",error,total_error) + CALL VERIFY("H5VLis_connector_registered_by_name_f", is_registered, .FALSE., total_error) CALL H5VLregister_connector_by_name_f(NATIVE_VOL_CONNECTOR_NAME, vol_id, error) CALL check("H5VLregister_connector_by_name_f",error,total_error) ! The connector should be registered now - CALL H5VLis_connector_registered_f(NATIVE_VOL_CONNECTOR_NAME, is_registered, error) - CALL check("H5VLis_connector_registered_f",error,total_error) - CALL VERIFY("H5VLis_connector_registered_f", is_registered, .TRUE., total_error) + CALL H5VLis_connector_registered_by_name_f(NATIVE_VOL_CONNECTOR_NAME, is_registered, error) + CALL check("H5VLis_connector_registered_by_name_f",error,total_error) + CALL VERIFY("H5VLis_connector_registered_by_name_f", is_registered, .TRUE., total_error) ! Register the connector CALL H5Pcreate_f(H5P_FILE_ACCESS_F, fapl_id, error) diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index 1d23ecc..0f63f34 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -10895,9 +10895,11 @@ public class H5 implements java.io.Serializable { /// VOL Connector Functionality public synchronized static native long H5VLregister_connector_by_name(String connector_name, long vipl_id); public synchronized static native long H5VLregister_connector_by_value(int connector_value, long vipl_id); - public synchronized static native boolean H5VLis_connector_registered(String name); + public synchronized static native boolean H5VLis_connector_registered_by_name(String name); + public synchronized static native boolean H5VLis_connector_registered_by_value(int connector_value); public synchronized static native long H5VLget_connector_id(long object_id); public synchronized static native long H5VLget_connector_id_by_name(String name); + public synchronized static native long H5VLget_connector_id_by_value(int connector_value); public synchronized static native String H5VLget_connector_name(long object_id); public synchronized static native void H5VLclose(long connector_id); public synchronized static native void H5VLunregister_connector(long connector_id); diff --git a/java/src/jni/h5vlImp.c b/java/src/jni/h5vlImp.c index 0fee343..1ead30b 100644 --- a/java/src/jni/h5vlImp.c +++ b/java/src/jni/h5vlImp.c @@ -78,11 +78,11 @@ done: /* * Class: hdf_hdf5lib_H5 - * Method: H5VLis_connector_registered + * Method: H5VLis_connector_registered_by_name * Signature: (Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered +Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered_1by_1name (JNIEnv *env, jclass clss, jobject connector_name) { const char *volName = NULL; @@ -91,11 +91,11 @@ Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered UNUSED(clss); if (NULL == connector_name) - H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5VLis_connector_registered: VOL connector name is NULL"); + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5VLis_connector_registered_by_name: VOL connector name is NULL"); - PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLis_connector_registered: VOL connector name not pinned"); + PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLis_connector_registered_by_name: VOL connector name not pinned"); - if ((bval = H5VLis_connector_registered(volName)) < 0) + if ((bval = H5VLis_connector_registered_by_name(volName)) < 0) H5_LIBRARY_ERROR(ENVONLY); bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; @@ -105,7 +105,32 @@ done: UNPIN_JAVA_STRING(ENVONLY, connector_name, volName); return (jboolean)bval; -} /* end Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered */ +} /* end Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLis_connector_registered_by_value + * Signature: (I)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered_1by_1value + (JNIEnv *env, jclass clss, jint connector_value) +{ + htri_t bval = JNI_FALSE; + + UNUSED(clss); + + if (connector_value < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5VLis_connector_registered_by_value: VOL connector value < 0"); + + if ((bval = H5VLis_connector_registered_by_value((H5VL_class_value_t)connector_value)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; + +done: + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered_1by_1value */ /* * Class: hdf_hdf5lib_H5 @@ -158,6 +183,29 @@ done: /* * Class: hdf_hdf5lib_H5 + * Method: H5VLget_connector_id_by_value + * Signature: (I)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5VLget_1connector_1id_1by_1value + (JNIEnv *env, jclass clss, jint connector_value) +{ + hid_t status = H5I_INVALID_HID; + + UNUSED(clss); + + if (connector_value < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5VLget_connector_id_by_value: VOL connector value < 0"); + + if ((status = H5VLget_connector_id_by_value((H5VL_class_value_t)connector_value)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)status; +} /* end Java_hdf_hdf5lib_H5_H5VLget_1connector_1id_1by_1value */ + +/* + * Class: hdf_hdf5lib_H5 * Method: H5VLget_connector_name * Signature: (J)Ljava/lang/String; */ diff --git a/java/src/jni/h5vlImp.h b/java/src/jni/h5vlImp.h index 6dd7529..a58abef 100644 --- a/java/src/jni/h5vlImp.h +++ b/java/src/jni/h5vlImp.h @@ -40,15 +40,24 @@ Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value /* * Class: hdf_hdf5lib_H5 - * Method: H5VLis_connector_registered + * Method: H5VLis_connector_registered_by_name * Signature: (Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered +Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered_1by_1name (JNIEnv *, jclass, jobject); /* * Class: hdf_hdf5lib_H5 + * Method: H5VLis_connector_registered_by_value + * Signature: (I)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered_1by_1value + (JNIEnv *, jclass, jint); + +/* + * Class: hdf_hdf5lib_H5 * Method: H5VLget_connector_id * Signature: (J)J */ @@ -67,6 +76,15 @@ Java_hdf_hdf5lib_H5_H5VLget_1connector_1id_1by_1name /* * Class: hdf_hdf5lib_H5 + * Method: H5VLget_connector_id_by_value + * Signature: (I)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5VLget_1connector_1id_1by_1value + (JNIEnv *, jclass, jint); + +/* + * Class: hdf_hdf5lib_H5 * Method: H5VLget_connector_name * Signature: (J)Ljava/lang/String; */ diff --git a/java/test/TestH5VL.java b/java/test/TestH5VL.java index d774dbb..bd660d3 100644 --- a/java/test/TestH5VL.java +++ b/java/test/TestH5VL.java @@ -55,15 +55,18 @@ public class TestH5VL { try { boolean is_registered; - is_registered = H5.H5VLis_connector_registered(HDF5Constants.H5VL_NATIVE_NAME); - assertTrue("H5.H5VLis_connector_registered H5VL_NATIVE_NAME", is_registered); + is_registered = H5.H5VLis_connector_registered_by_name(HDF5Constants.H5VL_NATIVE_NAME); + assertTrue("H5.H5VLis_connector_registered_by_name H5VL_NATIVE_NAME", is_registered); - is_registered = H5.H5VLis_connector_registered("FAKE_VOL_NAME"); - assertFalse("H5.H5VLis_connector_registered FAKE_VOL_NAME", is_registered); + is_registered = H5.H5VLis_connector_registered_by_name("FAKE_VOL_NAME"); + assertFalse("H5.H5VLis_connector_registered_by_name FAKE_VOL_NAME", is_registered); + + is_registered = H5.H5VLis_connector_registered_by_value(HDF5Constants.H5VL_NATIVE_VALUE); + assertTrue("H5.H5VLis_connector_registered_by_value H5VL_NATIVE_VALUE", is_registered); } catch (Throwable err) { err.printStackTrace(); - fail("H5.H5VLis_connector_registered " + err); + fail("testH5VLnative_init(): " + err); } } @@ -113,6 +116,19 @@ public class TestH5VL { } @Test + public void testH5VLget_connector_id_by_value() { + try { + long native_id = H5.H5VLget_connector_id_by_value(HDF5Constants.H5VL_NATIVE_VALUE); + assertTrue("H5.H5VLget_connector_id_by_value H5VL_NATIVE_VALUE", native_id >= 0); + assertEquals(HDF5Constants.H5VL_NATIVE, native_id); + } + catch (Throwable err) { + err.printStackTrace(); + fail("H5.H5VLget_connector_id_by_value " + err); + } + } + + @Test public void testH5VLget_connector_name() { String H5_FILE = "testFvl.h5"; diff --git a/java/test/testfiles/JUnit-TestH5VL.txt b/java/test/testfiles/JUnit-TestH5VL.txt index f646009..ff94969 100644 --- a/java/test/testfiles/JUnit-TestH5VL.txt +++ b/java/test/testfiles/JUnit-TestH5VL.txt @@ -1,5 +1,6 @@ JUnit version 4.11 .testH5VLget_connector_id_by_name +.testH5VLget_connector_id_by_value .testH5VLget_connector_id .testH5VLnative_init .testH5VLget_connector_name @@ -8,5 +9,5 @@ JUnit version 4.11 Time: XXXX -OK (6 tests) +OK (7 tests) diff --git a/src/H5VL.c b/src/H5VL.c index 4ae51cb..bd34d4e 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -216,9 +216,10 @@ done: /*------------------------------------------------------------------------- - * Function: H5VLis_connector_registered + * Function: H5VLis_connector_registered_by_name * * Purpose: Tests whether a VOL class has been registered or not + * according to a supplied connector name. * * Return: >0 if a VOL connector with that name has been registered * 0 if a VOL connector with that name has NOT been registered @@ -230,7 +231,7 @@ done: *------------------------------------------------------------------------- */ htri_t -H5VLis_connector_registered(const char *name) +H5VLis_connector_registered_by_name(const char *name) { htri_t ret_value = FALSE; /* Return value */ @@ -238,12 +239,41 @@ H5VLis_connector_registered(const char *name) H5TRACE1("t", "*s", name); /* Check if connector with this name is registered */ - if((ret_value = H5VL__is_connector_registered(name)) < 0) + if((ret_value = H5VL__is_connector_registered_by_name(name)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't check for VOL") done: FUNC_LEAVE_API(ret_value) -} /* end H5VLis_connector_registered() */ +} /* end H5VLis_connector_registered_by_name() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLis_connector_registered_by_value + * + * Purpose: Tests whether a VOL class has been registered or not + * according to a supplied connector value (ID). + * + * Return: >0 if a VOL connector with that value has been registered + * 0 if a VOL connector with that value hasn't been registered + * <0 on errors + * + *------------------------------------------------------------------------- + */ +htri_t +H5VLis_connector_registered_by_value(H5VL_class_value_t connector_value) +{ + htri_t ret_value = FALSE; + + FUNC_ENTER_API(FAIL) + H5TRACE1("t", "VC", connector_value); + + /* Check if connector with this value is registered */ + if((ret_value = H5VL__is_connector_registered_by_value(connector_value)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't check for VOL") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLis_connector_registered_by_value() */ /*------------------------------------------------------------------------- @@ -313,7 +343,38 @@ done: /*------------------------------------------------------------------------- - * Function: H5VLpeek_connector_id + * Function: H5VLget_connector_id_by_value + * + * Purpose: Retrieves the ID for a registered VOL connector. + * + * Return: A valid VOL connector ID if a connector with that value has + * been registered. This ID will need to be closed using + * H5VLclose(). + * + * H5I_INVALID_HID on error or if a VOL connector with that + * value has not been registered. + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLget_connector_id_by_value(H5VL_class_value_t connector_value) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "VC", connector_value); + + /* Get connector ID with this value */ + if((ret_value = H5VL__get_connector_id_by_value(connector_value, TRUE)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLget_connector_id_by_value() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLpeek_connector_id_by_name * * Purpose: Retrieves the ID for a registered VOL connector. * @@ -328,7 +389,7 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VLpeek_connector_id(const char *name) +H5VLpeek_connector_id_by_name(const char *name) { hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -336,12 +397,44 @@ H5VLpeek_connector_id(const char *name) H5TRACE1("i", "*s", name); /* Get connector ID with this name */ - if((ret_value = H5VL__peek_connector_id(name)) < 0) + if((ret_value = H5VL__peek_connector_id_by_name(name)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLpeek_connector_id_by_name() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLpeek_connector_id_by_value + * + * Purpose: Retrieves the ID for a registered VOL connector. + * + * Return: A valid VOL connector ID if a connector with that value + * has been registered. This ID is *not* owned by the caller + * and H5VLclose() should not be called. Intended for use by + * VOL connectors to find their own ID. + * + * H5I_INVALID_HID on error or if a VOL connector with that + * value has not been registered. + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLpeek_connector_id_by_value(H5VL_class_value_t value) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "VC", value); + + /* Get connector ID with this value */ + if((ret_value = H5VL__peek_connector_id_by_value(value)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id") done: FUNC_LEAVE_API(ret_value) -} /* end H5VLpeek_connector_id() */ +} /* end H5VLpeek_connector_id_by_value() */ /*------------------------------------------------------------------------- diff --git a/src/H5VLconnector.h b/src/H5VLconnector.h index 9bc3a7b..baa4cca 100644 --- a/src/H5VLconnector.h +++ b/src/H5VLconnector.h @@ -512,7 +512,8 @@ H5_DLL hid_t H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id); H5_DLL void *H5VLobject(hid_t obj_id); H5_DLL hid_t H5VLget_file_type(void *file_obj, hid_t connector_id, hid_t dtype_id); -H5_DLL hid_t H5VLpeek_connector_id(const char *name); +H5_DLL hid_t H5VLpeek_connector_id_by_name(const char *name); +H5_DLL hid_t H5VLpeek_connector_id_by_value(H5VL_class_value_t value); #ifdef __cplusplus } diff --git a/src/H5VLint.c b/src/H5VLint.c index 2034f2b..572221a 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -421,7 +421,7 @@ H5VL__set_def_conn(void) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "VOL connector environment variable set empty?") /* First, check to see if the connector is already registered */ - if((connector_is_registered = H5VL__is_connector_registered(tok)) < 0) + if((connector_is_registered = H5VL__is_connector_registered_by_name(tok)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't check if VOL connector already registered") else if(connector_is_registered) { /* Retrieve the ID of the already-registered VOL connector */ @@ -1325,7 +1325,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5VL__is_connector_registered + * Function: H5VL__is_connector_registered_by_name * * Purpose: Checks if a connector with a particular name is registered. * @@ -1338,7 +1338,7 @@ done: *------------------------------------------------------------------------- */ htri_t -H5VL__is_connector_registered(const char *name) +H5VL__is_connector_registered_by_name(const char *name) { H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ htri_t ret_value = FALSE; /* Return value */ @@ -1360,7 +1360,44 @@ H5VL__is_connector_registered(const char *name) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__is_connector_registered() */ +} /* end H5VL__is_connector_registered_by_name() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__is_connector_registered_by_value + * + * Purpose: Checks if a connector with a particular value (ID) is + * registered. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +htri_t +H5VL__is_connector_registered_by_value(H5VL_class_value_t value) +{ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Set up op data for iteration */ + op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE; + op_data.u.value = value; + op_data.found_id = H5I_INVALID_HID; + + /* Find connector with value */ + if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "can't iterate over VOL connectors") + + /* Found a connector with that name */ + if(op_data.found_id != H5I_INVALID_HID) + ret_value = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__is_connector_registered_by_value() */ /*------------------------------------------------------------------------- @@ -1419,7 +1456,7 @@ H5VL__get_connector_id_by_name(const char *name, hbool_t is_api) FUNC_ENTER_PACKAGE /* Find connector with name */ - if((ret_value = H5VL__peek_connector_id(name)) < 0) + if((ret_value = H5VL__peek_connector_id_by_name(name)) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't find VOL connector") /* Found a connector with that name */ @@ -1432,18 +1469,50 @@ done: /*------------------------------------------------------------------------- - * Function: H5VL__peek_connector_id + * Function: H5VL__get_connector_id_by_value + * + * Purpose: Retrieves the ID for a registered VOL connector. + * + * Return: Positive if the VOL class has been registered + * Negative on error (if the class is not a valid class or + * not registered) + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL__get_connector_id_by_value(H5VL_class_value_t value, hbool_t is_api) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Find connector with value */ + if((ret_value = H5VL__peek_connector_id_by_value(value)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't find VOL connector") + + /* Found a connector with that value */ + if(H5I_inc_ref(ret_value, is_api) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__get_connector_id_by_value() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__peek_connector_id_by_name * * Purpose: Retrieves the ID for a registered VOL connector. Does not * increment the ref count * * Return: Positive if the VOL class has been registered - * Negative on error (if the class is not a valid class or not registered) + * Negative on error (if the class is not a valid class or + * not registered) * *------------------------------------------------------------------------- */ hid_t -H5VL__peek_connector_id(const char *name) +H5VL__peek_connector_id_by_name(const char *name) { H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -1464,7 +1533,44 @@ H5VL__peek_connector_id(const char *name) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__peek_connector_id() */ +} /* end H5VL__peek_connector_id_by_name() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__peek_connector_id_by_value + * + * Purpose: Retrieves the ID for a registered VOL connector. Does not + * increment the ref count + * + * Return: Positive if the VOL class has been registered + * Negative on error (if the class is not a valid class or + * not registered) + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL__peek_connector_id_by_value(H5VL_class_value_t value) +{ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Set up op data for iteration */ + op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE; + op_data.u.value = value; + op_data.found_id = H5I_INVALID_HID; + + /* Find connector with value */ + if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL connectors") + + /* Set return value */ + ret_value = op_data.found_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__peek_connector_id_by_value() */ /*------------------------------------------------------------------------- diff --git a/src/H5VLpkg.h b/src/H5VLpkg.h index 5965adc..4174732 100644 --- a/src/H5VLpkg.h +++ b/src/H5VLpkg.h @@ -53,10 +53,13 @@ H5_DLL hid_t H5VL__register_connector_by_name(const char *name, hbool_t app_ref, hid_t vipl_id); H5_DLL hid_t H5VL__register_connector_by_value(H5VL_class_value_t value, hbool_t app_ref, hid_t vipl_id); -H5_DLL htri_t H5VL__is_connector_registered(const char *name); +H5_DLL htri_t H5VL__is_connector_registered_by_name(const char *name); +H5_DLL htri_t H5VL__is_connector_registered_by_value(H5VL_class_value_t value); H5_DLL hid_t H5VL__get_connector_id(hid_t obj_id, hbool_t is_api); H5_DLL hid_t H5VL__get_connector_id_by_name(const char *name, hbool_t is_api); -H5_DLL hid_t H5VL__peek_connector_id(const char *name); +H5_DLL hid_t H5VL__get_connector_id_by_value(H5VL_class_value_t value, hbool_t is_api); +H5_DLL hid_t H5VL__peek_connector_id_by_name(const char *name); +H5_DLL hid_t H5VL__peek_connector_id_by_value(H5VL_class_value_t value); H5_DLL herr_t H5VL__connector_str_to_info(const char *str, hid_t connector_id, void **info); H5_DLL ssize_t H5VL__get_connector_name(hid_t id, char *name/*out*/, size_t size); diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index ab7de15..7c3c31e 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -43,7 +43,7 @@ /* * VOL connector identifiers. Values 0 through 255 are for connectors defined * by the HDF5 library. Values 256 through 511 are available for testing new - * filters. Subsequent values should be obtained from the HDF5 development + * connectors. Subsequent values should be obtained from the HDF5 development * team at help@hdfgroup.org. */ typedef int H5VL_class_value_t; @@ -61,14 +61,13 @@ typedef int H5VL_class_value_t; extern "C" { #endif -/* The H5VL types uses in the API calls are not opaque - they are defined in - * H5VLconnector.h, which is included at the top of this file. - */ H5_DLL hid_t H5VLregister_connector_by_name(const char *connector_name, hid_t vipl_id); H5_DLL hid_t H5VLregister_connector_by_value(H5VL_class_value_t connector_value, hid_t vipl_id); -H5_DLL htri_t H5VLis_connector_registered(const char *name); +H5_DLL htri_t H5VLis_connector_registered_by_name(const char *name); +H5_DLL htri_t H5VLis_connector_registered_by_value(H5VL_class_value_t connector_value); H5_DLL hid_t H5VLget_connector_id(hid_t obj_id); H5_DLL hid_t H5VLget_connector_id_by_name(const char *name); +H5_DLL hid_t H5VLget_connector_id_by_value(H5VL_class_value_t connector_value); H5_DLL ssize_t H5VLget_connector_name(hid_t id, char *name/*out*/, size_t size); H5_DLL herr_t H5VLclose(hid_t connector_id); H5_DLL herr_t H5VLunregister_connector(hid_t connector_id); diff --git a/test/vol.c b/test/vol.c index d26499e..88354e1 100644 --- a/test/vol.c +++ b/test/vol.c @@ -38,13 +38,14 @@ const char *FILENAME[] = { #define N_ELEMENTS 10 #define FAKE_VOL_NAME "fake" +#define FAKE_VOL_VALUE ((H5VL_class_value_t)501) /* A VOL class struct that describes a VOL class with no * functionality. */ static const H5VL_class_t fake_vol_g = { 0, /* version */ - (H5VL_class_value_t)501, /* value */ + FAKE_VOL_VALUE, /* value */ FAKE_VOL_NAME, /* name */ 0, /* capability flags */ NULL, /* initialize */ @@ -174,7 +175,11 @@ test_vol_registration(void) TESTING("VOL registration"); /* The test/fake VOL connector should not be registered at the start of the test */ - if ((is_registered = H5VLis_connector_registered(FAKE_VOL_NAME)) < 0) + if ((is_registered = H5VLis_connector_registered_by_name(FAKE_VOL_NAME)) < 0) + TEST_ERROR; + if (is_registered > 0) + FAIL_PUTS_ERROR("VOL connector is inappropriately registered"); + if ((is_registered = H5VLis_connector_registered_by_value(FAKE_VOL_VALUE)) < 0) TEST_ERROR; if (is_registered > 0) FAIL_PUTS_ERROR("VOL connector is inappropriately registered"); @@ -203,7 +208,11 @@ test_vol_registration(void) TEST_ERROR; /* The test/fake VOL connector should be registered now */ - if ((is_registered = H5VLis_connector_registered(FAKE_VOL_NAME)) < 0) + if ((is_registered = H5VLis_connector_registered_by_name(FAKE_VOL_NAME)) < 0) + TEST_ERROR; + if (0 == is_registered) + FAIL_PUTS_ERROR("VOL connector is un-registered"); + if ((is_registered = H5VLis_connector_registered_by_value(FAKE_VOL_VALUE)) < 0) TEST_ERROR; if (0 == is_registered) FAIL_PUTS_ERROR("VOL connector is un-registered"); @@ -213,7 +222,11 @@ test_vol_registration(void) TEST_ERROR; /* The test/fake VOL connector should still be registered now */ - if ((is_registered = H5VLis_connector_registered(FAKE_VOL_NAME)) < 0) + if ((is_registered = H5VLis_connector_registered_by_name(FAKE_VOL_NAME)) < 0) + TEST_ERROR; + if (0 == is_registered) + FAIL_PUTS_ERROR("VOL connector is un-registered"); + if ((is_registered = H5VLis_connector_registered_by_value(FAKE_VOL_VALUE)) < 0) TEST_ERROR; if (0 == is_registered) FAIL_PUTS_ERROR("VOL connector is un-registered"); @@ -223,7 +236,11 @@ test_vol_registration(void) TEST_ERROR; /* The test/fake VOL connector should still be registered now */ - if ((is_registered = H5VLis_connector_registered(FAKE_VOL_NAME)) < 0) + if ((is_registered = H5VLis_connector_registered_by_name(FAKE_VOL_NAME)) < 0) + TEST_ERROR; + if (0 == is_registered) + FAIL_PUTS_ERROR("VOL connector is un-registered"); + if ((is_registered = H5VLis_connector_registered_by_value(FAKE_VOL_VALUE)) < 0) TEST_ERROR; if (0 == is_registered) FAIL_PUTS_ERROR("VOL connector is un-registered"); @@ -272,7 +289,12 @@ test_native_vol_init(void) TESTING("Native VOL connector initialization"); /* The native VOL connector should always be registered */ - if ((is_registered = H5VLis_connector_registered(H5VL_NATIVE_NAME)) < 0) + if ((is_registered = H5VLis_connector_registered_by_name(H5VL_NATIVE_NAME)) < 0) + TEST_ERROR; + if (0 == is_registered) + FAIL_PUTS_ERROR("native VOL connector is un-registered"); + + if ((is_registered = H5VLis_connector_registered_by_value(H5VL_NATIVE_VALUE)) < 0) TEST_ERROR; if (0 == is_registered) FAIL_PUTS_ERROR("native VOL connector is un-registered"); diff --git a/test/vol_plugin.c b/test/vol_plugin.c index e4f171b..565c847 100644 --- a/test/vol_plugin.c +++ b/test/vol_plugin.c @@ -43,7 +43,7 @@ test_registration_by_value(void) 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) + if((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) TEST_ERROR; if(TRUE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); @@ -53,7 +53,7 @@ test_registration_by_value(void) TEST_ERROR; /* The connector should be registered now */ - if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + if((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) TEST_ERROR; if(FALSE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector was not registered"); @@ -63,7 +63,7 @@ test_registration_by_value(void) TEST_ERROR; /* The connector should not be registered now */ - if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + if((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) TEST_ERROR; if(TRUE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); @@ -99,7 +99,7 @@ test_registration_by_name(void) 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) + if((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) TEST_ERROR; if(TRUE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); @@ -109,7 +109,7 @@ test_registration_by_name(void) TEST_ERROR; /* The connector should be registered now */ - if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + if((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) TEST_ERROR; if(FALSE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector was not registered"); @@ -119,7 +119,7 @@ test_registration_by_name(void) TEST_ERROR; /* The connector should not be registered now */ - if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + if((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) TEST_ERROR; if(TRUE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); @@ -156,7 +156,7 @@ test_multiple_registration(void) 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) + if((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) TEST_ERROR; if(TRUE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); @@ -168,7 +168,7 @@ test_multiple_registration(void) } /* The connector should be registered now */ - if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + if((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) TEST_ERROR; if(FALSE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector was not registered"); @@ -186,7 +186,43 @@ test_multiple_registration(void) } /* The connector should not be registered now */ - if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + if((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); + + /* Repeat testing with the _by_value routines */ + if((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 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_value(NULL_VOL_CONNECTOR_VALUE, H5P_DEFAULT)) < 0) + TEST_ERROR; + } + + /* The connector should be registered now */ + if((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 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_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) TEST_ERROR; if(TRUE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); @@ -223,7 +259,7 @@ test_getters(void) 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) + if((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) TEST_ERROR; if(TRUE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); @@ -232,11 +268,35 @@ test_getters(void) if((vol_id = H5VLregister_connector_by_name(NULL_VOL_CONNECTOR_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; - /* Get the connector's ID */ + /* Get the connector's ID by name */ if((vol_id_out = H5VLget_connector_id_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) TEST_ERROR; if(vol_id != vol_id_out) FAIL_PUTS_ERROR("VOL connector IDs don't match"); + if(H5VLclose(vol_id_out) < 0) + TEST_ERROR; + + /* Unregister the connector */ + if(H5VLunregister_connector(vol_id) < 0) + TEST_ERROR; + + /* Repeat testing with the _by_value routines */ + if((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) + TEST_ERROR; + if(TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); + + /* Register the connector by value */ + if((vol_id = H5VLregister_connector_by_value(NULL_VOL_CONNECTOR_VALUE, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Get the connector's ID by value */ + if((vol_id_out = H5VLget_connector_id_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) + TEST_ERROR; + if(vol_id != vol_id_out) + FAIL_PUTS_ERROR("VOL connector IDs don't match"); + if(H5VLclose(vol_id_out) < 0) + TEST_ERROR; /* Unregister the connector */ if(H5VLunregister_connector(vol_id) < 0) @@ -247,6 +307,7 @@ test_getters(void) error: H5E_BEGIN_TRY { + H5VLclose(vol_id_out); H5VLunregister_connector(vol_id); } H5E_END_TRY; return FAIL; diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 47f6e3f..33f1e11 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -12,8 +12,8 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Purpose: A library for displaying the values of a dataset in a human - * readable format. + * Purpose: A library for routines that are common + * amongst the various HDF5 tools. */ #include "h5tools.h" diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h index 366800a..598930c 100644 --- a/tools/lib/h5tools_utils.h +++ b/tools/lib/h5tools_utils.h @@ -129,7 +129,7 @@ H5TOOLS_DLL void warn_msg(const char *fmt, ...); H5TOOLS_DLL void help_ref_msg(FILE *output); H5TOOLS_DLL void free_table(table_t *table); #ifdef H5DUMP_DEBUG -H5TOOLS_DLL void dump_tables(find_objs_t *info) +H5TOOLS_DLL void dump_tables(find_objs_t *info); #endif /* H5DUMP_DEBUG */ H5TOOLS_DLL herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, table_t **type_table); H5TOOLS_DLL obj_t *search_obj(table_t *temp, const H5O_token_t *obj_token); -- cgit v0.12