From 594cd935435d36801bee3dbb7fc531df7d398bcc Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 13 Mar 2019 10:20:30 -0500 Subject: HDFFV-10658: setting and getting properties in API context: 1. external file prefix and VDS prefix. 2. the datatype, dataspace, and LCPL of the dataset for VOL connector. --- src/H5CX.c | 342 ++++++++++++++++++++++++++++++++++++++++++++++- src/H5CXprivate.h | 12 ++ src/H5D.c | 21 +-- src/H5Ddeprec.c | 12 +- src/H5Dint.c | 36 ++--- src/H5VLnative_dataset.c | 10 +- 6 files changed, 391 insertions(+), 42 deletions(-) diff --git a/src/H5CX.c b/src/H5CX.c index b56d66d..2bfe559 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -189,6 +189,10 @@ typedef struct H5CX_t { hid_t dcpl_id; /* DCPL ID for API operation */ H5P_genplist_t *dcpl; /* Dataset Creation Property List */ + /* DAPL */ + hid_t dapl_id; /* DAPL ID for API operation */ + H5P_genplist_t *dapl; /* Dataset Access Property List */ + /* Internal: Object tagging info */ haddr_t tag; /* Current object's tag (ohdr chunk #0 address) */ @@ -275,8 +279,20 @@ typedef struct H5CX_t { hbool_t nlinks_valid; /* Whether number of soft / UD links to traverse is valid */ /* Cached DCPL properties */ - hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ - hbool_t do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */ + hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ + hbool_t do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */ + hid_t vl_prop_dset_type_id; + hbool_t vl_prop_dset_type_id_valid; + hid_t vl_prop_dset_space_id; + hbool_t vl_prop_dset_space_id_valid; + hid_t vl_prop_dset_lcpl_id; + hbool_t vl_prop_dset_lcpl_id_valid; + + /* Cached DAPL properties */ + char *extfile_prefix; + hbool_t extfile_prefix_valid; + char *vds_prefix; + hbool_t vds_prefix_valid; /* Cached VOL settings */ H5VL_connector_prop_t vol_connector_prop; /* Property for VOL connector ID & info */ @@ -336,8 +352,17 @@ typedef struct H5CX_lapl_cache_t { /* (Same as the cached DXPL struct, above, except for the default DCPL) */ typedef struct H5CX_dcpl_cache_t { hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ + hid_t vl_prop_dset_type_id; + hid_t vl_prop_dset_space_id; + hid_t vl_prop_dset_lcpl_id; } H5CX_dcpl_cache_t; +/* Typedef for cached default dataset access property list information */ +/* (Same as the cached DXPL struct, above, except for the default DXPL) */ +typedef struct H5CX_dapl_cache_t { + char *extfile_prefix; + char *vds_prefix; +} H5CX_dapl_cache_t; /********************/ /* Local Prototypes */ @@ -374,6 +399,9 @@ static H5CX_lapl_cache_t H5CX_def_lapl_cache; /* Define a "default" dataset creation property list cache structure to use for default DCPLs */ static H5CX_dcpl_cache_t H5CX_def_dcpl_cache; +/* Define a "default" dataset access property list cache structure to use for default DAPLs */ +static H5CX_dapl_cache_t H5CX_def_dapl_cache; + /* Declare a static free list to manage H5CX_node_t structs */ H5FL_DEFINE_STATIC(H5CX_node_t); @@ -398,6 +426,7 @@ H5CX__init_package(void) H5P_genplist_t *dx_plist; /* Data transfer property list */ H5P_genplist_t *la_plist; /* Link access property list */ H5P_genplist_t *dc_plist; /* Dataset creation property list */ + H5P_genplist_t *da_plist; /* Dataset access property list */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -511,6 +540,32 @@ H5CX__init_package(void) if(H5P_get(dc_plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &H5CX_def_dcpl_cache.do_min_dset_ohdr) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve dataset minimize flag") + if(H5P_get(dc_plist, H5VL_PROP_DSET_TYPE_ID, &H5CX_def_dcpl_cache.vl_prop_dset_type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for datatype id") + if(H5P_get(dc_plist, H5VL_PROP_DSET_SPACE_ID, &H5CX_def_dcpl_cache.vl_prop_dset_space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for space id") + if(H5P_get(dc_plist, H5VL_PROP_DSET_LCPL_ID, &H5CX_def_dcpl_cache.vl_prop_dset_lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for lcpl id") + + + + /* Reset the "default DAPL cache" information */ + HDmemset(&H5CX_def_dapl_cache, 0, sizeof(H5CX_dapl_cache_t)); + + /* Get the default DAPL cache information */ + + /* Get the default dataset access property list */ + if(NULL == (da_plist = (H5P_genplist_t *)H5I_object(H5P_DATASET_ACCESS_DEFAULT))) + HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a dataset create property list") + + /* Get the prefix for the external file */ + if(H5P_peek(da_plist, H5D_ACS_EFILE_PREFIX_NAME, &H5CX_def_dapl_cache.extfile_prefix) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve prefix for external file") + + /* Get the prefix for the VDS file */ + if(H5P_peek(da_plist, H5D_ACS_VDS_PREFIX_NAME, &H5CX_def_dapl_cache.vds_prefix) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve prefix for VDS") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX__init_package() */ @@ -634,6 +689,8 @@ H5CX__push_common(H5CX_node_t *cnode) /* Set non-zero context info */ cnode->ctx.dxpl_id = H5P_DATASET_XFER_DEFAULT; + cnode->ctx.dcpl_id = H5P_DATASET_CREATE_DEFAULT; + cnode->ctx.dapl_id = H5P_DATASET_ACCESS_DEFAULT; cnode->ctx.lapl_id = H5P_LINK_ACCESS_DEFAULT; cnode->ctx.tag = H5AC__INVALID_TAG; cnode->ctx.ring = H5AC_RING_USER; @@ -1083,6 +1140,7 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, *acspl_id = *libclass->def_plist_id; else { htri_t is_lapl; /* Whether the access property list is (or is derived from) a link access property list */ + htri_t is_dapl; /* Whether the access property list is (or is derived from) a dataset access property list */ #ifdef H5CX_DEBUG /* Sanity check the access property list class */ @@ -1096,6 +1154,12 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, else if(is_lapl) (*head)->ctx.lapl_id = *acspl_id; + /* Check for dataset access property and set API context if so */ + if((is_dapl = H5P_class_isa(*libclass->pclass, *H5P_CLS_DACC->pclass)) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't check for dataset access class") + else if(is_dapl) + (*head)->ctx.dapl_id = *acspl_id; + #ifdef H5_HAVE_PARALLEL /* If this routine is not guaranteed to be collective (i.e. it doesn't * modify the structural metadata in a file), check if the application @@ -2324,6 +2388,180 @@ done: /*------------------------------------------------------------------------- + * Function: H5CX_get_vl_prop_dset_type_id + * + * Purpose: Retrieves the datatype ID of the dataset for VOL connector + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Raymond Lu + * March 12, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_get_vl_prop_dset_type_id(hid_t *dset_type_id) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(dset_type_id); + HDassert(head && *head); + HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); + + H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5VL_PROP_DSET_TYPE_ID, vl_prop_dset_type_id); + + /* Get the value */ + *dset_type_id = (*head)->ctx.vl_prop_dset_type_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_get_vl_prop_dset_type_id */ + + +/*------------------------------------------------------------------------- + * Function: H5CX_get_vl_prop_dset_space_id + * + * Purpose: Retrieves the space ID of the dataset for VOL connector + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Raymond Lu + * March 12, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_get_vl_prop_dset_space_id(hid_t *dset_space_id) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(dset_space_id); + HDassert(head && *head); + HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); + + H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5VL_PROP_DSET_SPACE_ID, vl_prop_dset_space_id); + + /* Get the value */ + *dset_space_id = (*head)->ctx.vl_prop_dset_space_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_get_vl_prop_dset_space_id */ + + +/*------------------------------------------------------------------------- + * Function: H5CX_get_vl_prop_dset_space_id + * + * Purpose: Retrieves the LCPL ID of the dataset for VOL connector + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Raymond Lu + * March 12, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_get_vl_prop_dset_lcpl_id(hid_t *dset_lcpl_id) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(dset_lcpl_id); + HDassert(head && *head); + HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); + + H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5VL_PROP_DSET_TYPE_ID, vl_prop_dset_lcpl_id); + + /* Get the value */ + *dset_lcpl_id = (*head)->ctx.vl_prop_dset_lcpl_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_get_vl_prop_dset_lcpl_id */ + + + +/*------------------------------------------------------------------------- + * Function: H5CX_get_ext_file_prefix + * + * Purpose: Retrieves the prefix for external file + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Raymond Lu + * March 6, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_get_ext_file_prefix(char **extfile_prefix) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(extfile_prefix); + HDassert(head && *head); + HDassert(H5P_DEFAULT != (*head)->ctx.dapl_id); + + H5CX_RETRIEVE_PROP_VALID(dapl, H5P_DATASET_ACCESS_DEFAULT, H5D_ACS_EFILE_PREFIX_NAME, extfile_prefix); + + /* Get the value */ + *extfile_prefix = (*head)->ctx.extfile_prefix; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_get_ext_file_prefix */ + + +/*------------------------------------------------------------------------- + * Function: H5CX_get_vds_prefix + * + * Purpose: Retrieves the prefix for VDS + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Raymond Lu + * March 6, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_get_vds_prefix(char **vds_prefix) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(vds_prefix); + HDassert(head && *head); + HDassert(H5P_DEFAULT != (*head)->ctx.dapl_id); + + H5CX_RETRIEVE_PROP_VALID(dapl, H5P_DATASET_ACCESS_DEFAULT, H5D_ACS_VDS_PREFIX_NAME, vds_prefix); + + /* Get the value */ + *vds_prefix = (*head)->ctx.vds_prefix; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_get_vds_prefix */ + + +/*------------------------------------------------------------------------- * Function: H5CX_set_tag * * Purpose: Sets the object tag for the current API call context. @@ -2639,6 +2877,106 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_nlinks() */ + +/*------------------------------------------------------------------------- + * Function: H5CX_set_vl_prop_dset_type_id + * + * Purpose: Sets the datatype ID of the dataset for the current API call context. + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Raymond Lu + * March 12, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_set_vl_prop_dset_type_id(hid_t dset_type_id) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(head && *head); + + /* Set the API context value */ + (*head)->ctx.vl_prop_dset_type_id = dset_type_id; + + /* Mark the value as valid */ + (*head)->ctx.vl_prop_dset_type_id_valid = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_set_vl_prop_dset_type_id */ + +/*------------------------------------------------------------------------- + * Function: H5CX_set_vl_prop_dset_space_id + * + * Purpose: Sets the data space ID of the dataset for the current API call context. + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Raymond Lu + * March 12, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_set_vl_prop_dset_space_id(hid_t dset_space_id) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(head && *head); + + /* Set the API context value */ + (*head)->ctx.vl_prop_dset_space_id = dset_space_id; + + /* Mark the value as valid */ + (*head)->ctx.vl_prop_dset_space_id_valid = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_set_vl_prop_dset_space_id */ + +/*------------------------------------------------------------------------- + * Function: H5CX_set_vl_prop_dset_lcpl_id + * + * Purpose: Sets the LCPL ID of the dataset for the current API call context. + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Raymond Lu + * March 12, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_set_vl_prop_dset_lcpl_id(hid_t dset_lcpl_id) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(head && *head); + + /* Set the API context value */ + (*head)->ctx.vl_prop_dset_lcpl_id = dset_lcpl_id; + + /* Mark the value as valid */ + (*head)->ctx.vl_prop_dset_lcpl_id_valid = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} + #ifdef H5_HAVE_PARALLEL /*------------------------------------------------------------------------- diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h index 80f1ac4..f022d8e 100644 --- a/src/H5CXprivate.h +++ b/src/H5CXprivate.h @@ -126,6 +126,13 @@ H5_DLL herr_t H5CX_get_nlinks(size_t *nlinks); /* "Getter" routines for DCPL properties cached in API context */ H5_DLL herr_t H5CX_get_dset_min_ohdr_flag(hbool_t *dset_min_ohdr_flag); +H5_DLL herr_t H5CX_get_vl_prop_dset_type_id(hid_t *dset_type_id); +H5_DLL herr_t H5CX_get_vl_prop_dset_space_id(hid_t *dset_space_id); +H5_DLL herr_t H5CX_get_vl_prop_dset_lcpl_id(hid_t *dset_lcpl_id); + +/* "Getter" routines for DAPL properties cached in API context */ +H5_DLL herr_t H5CX_get_ext_file_prefix(char **prefix_extfile); +H5_DLL herr_t H5CX_get_vds_prefix(char **prefix_vds); /* "Setter" routines for API context info */ H5_DLL void H5CX_set_tag(haddr_t tag); @@ -145,6 +152,11 @@ H5_DLL herr_t H5CX_set_io_xfer_mode(H5FD_mpio_xfer_t io_xfer_mode); H5_DLL herr_t H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info); +/* "Setter" routines for DCPL properties cached in API context */ +H5_DLL herr_t H5CX_set_vl_prop_dset_type_id(hid_t dset_type_id); +H5_DLL herr_t H5CX_set_vl_prop_dset_space_id(hid_t dset_space_id); +H5_DLL herr_t H5CX_set_vl_prop_dset_lcpl_id(hid_t dset_lcpl_id); + /* "Setter" routines for LAPL properties cached in API context */ H5_DLL herr_t H5CX_set_nlinks(size_t nlinks); diff --git a/src/H5D.c b/src/H5D.c index fc350f2..a50518d 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -135,6 +135,9 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "dcpl_id is not a dataset create property list ID") + /* Set the DCPL for the API context */ + H5CX_set_dcpl(dcpl_id); + /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") @@ -148,12 +151,9 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set creation properties */ - if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") - if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") - if(H5P_set(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for lcpl id") + H5CX_set_vl_prop_dset_type_id(type_id); + H5CX_set_vl_prop_dset_space_id(space_id); + H5CX_set_vl_prop_dset_lcpl_id(lcpl_id); /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; @@ -228,6 +228,9 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset create property list ID") + /* Set the DCPL for the API context */ + H5CX_set_dcpl(dcpl_id); + /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") @@ -241,10 +244,8 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") /* set creation properties */ - if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") - if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") + H5CX_set_vl_prop_dset_type_id(type_id); + H5CX_set_vl_prop_dset_space_id(space_id); /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index 76827b4..70e6f70 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -136,6 +136,9 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset create property list ID") + /* Set the DCPL for the API context */ + H5CX_set_dcpl(dcpl_id); + /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") @@ -145,12 +148,9 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") /* set creation properties */ - if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") - if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") - if(H5P_set(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for lcpl id") + H5CX_set_vl_prop_dset_type_id(type_id); + H5CX_set_vl_prop_dset_space_id(space_id); + H5CX_set_vl_prop_dset_lcpl_id(lcpl_id); /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; diff --git a/src/H5Dint.c b/src/H5Dint.c index 384c66b..ae9a40e 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -488,9 +488,6 @@ H5D__new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type) new_dset->dcpl_id = H5P_copy_plist(plist, FALSE); } /* end else */ - /* Set the DCPL for the API context */ - H5CX_set_dcpl(new_dset->dcpl_id); - /* Set return value */ ret_value = new_dset; @@ -1083,8 +1080,7 @@ done: *-------------------------------------------------------------------------- */ static herr_t -H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type, - char **file_prefix /*out*/) +H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type, char **file_prefix /*out*/) { char *prefix = NULL; /* prefix used to look for the file */ char *filepath = NULL; /* absolute path of directory the HDF5 file is in */ @@ -1105,20 +1101,22 @@ H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type /* XXX: Future thread-safety note - getenv is not required * to be reentrant. */ - if(HDstrcmp(prefix_type, H5D_ACS_VDS_PREFIX_NAME) == 0) + if(HDstrcmp(prefix_type, H5D_ACS_VDS_PREFIX_NAME) == 0) { prefix = HDgetenv("HDF5_VDS_PREFIX"); - else if(HDstrcmp(prefix_type, H5D_ACS_EFILE_PREFIX_NAME) == 0) + + if(prefix == NULL || *prefix == '\0') { + if(H5CX_get_vds_prefix(&prefix) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for vds file") + } + } else if(HDstrcmp(prefix_type, H5D_ACS_EFILE_PREFIX_NAME) == 0) { prefix = HDgetenv("HDF5_EXTFILE_PREFIX"); - else - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "prefix name is not sensible") - if(prefix == NULL || *prefix == '\0') { - /* Set prefix to value of prefix_type property */ - if(NULL == (plist = H5P_object_verify(dapl_id, H5P_DATASET_ACCESS))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_peek(plist, prefix_type, &prefix) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file prefix") - } /* end if */ + if(prefix == NULL || *prefix == '\0') { + if(H5CX_get_ext_file_prefix(&prefix) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for the external file") + } + } else + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "prefix name is not sensible") /* Prefix has to be checked for NULL / empty string again because the * code above might have updated it. @@ -1552,8 +1550,10 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) ret_value = dataset; done: - extfile_prefix = (char *)H5MM_xfree(extfile_prefix); - vds_prefix = (char *)H5MM_xfree(vds_prefix); + if(extfile_prefix) + extfile_prefix = (char *)H5MM_xfree(extfile_prefix); + if(vds_prefix) + vds_prefix = (char *)H5MM_xfree(vds_prefix); if(ret_value == NULL) { /* Free the location--casting away const*/ diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c index 8f7351c..ac25c55 100644 --- a/src/H5VLnative_dataset.c +++ b/src/H5VLnative_dataset.c @@ -18,6 +18,7 @@ #define H5D_FRIEND /* Suppress error about including H5Dpkg */ #include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ @@ -62,12 +63,9 @@ H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") /* Get creation properties */ - if(H5P_get(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") - if(H5P_get(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") - if(H5P_get(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") + H5CX_get_vl_prop_dset_type_id(&type_id); + H5CX_get_vl_prop_dset_space_id(&space_id); + H5CX_get_vl_prop_dset_lcpl_id(&lcpl_id); /* Check arguments */ if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) -- cgit v0.12 From 9622aac313d38196b7f879f87bd0a3920e4af103 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Fri, 22 Mar 2019 09:53:15 -0500 Subject: HDFFV-10658: 1. moving HDgetenv to dataset initialization stage to reduce the overhead; 2. restoring the retrieval of three vol properties to H5P_get instead of using API context to prepare for Quincey's upcoming refactoring work. --- src/H5CX.c | 223 ------------------------------------------------------ src/H5CXprivate.h | 8 -- src/H5D.c | 15 ++-- src/H5Ddeprec.c | 9 ++- src/H5Dint.c | 40 ++++++---- 5 files changed, 42 insertions(+), 253 deletions(-) diff --git a/src/H5CX.c b/src/H5CX.c index 2bfe559..08e8c3f 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -281,12 +281,6 @@ typedef struct H5CX_t { /* Cached DCPL properties */ hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ hbool_t do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */ - hid_t vl_prop_dset_type_id; - hbool_t vl_prop_dset_type_id_valid; - hid_t vl_prop_dset_space_id; - hbool_t vl_prop_dset_space_id_valid; - hid_t vl_prop_dset_lcpl_id; - hbool_t vl_prop_dset_lcpl_id_valid; /* Cached DAPL properties */ char *extfile_prefix; @@ -352,9 +346,6 @@ typedef struct H5CX_lapl_cache_t { /* (Same as the cached DXPL struct, above, except for the default DCPL) */ typedef struct H5CX_dcpl_cache_t { hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ - hid_t vl_prop_dset_type_id; - hid_t vl_prop_dset_space_id; - hid_t vl_prop_dset_lcpl_id; } H5CX_dcpl_cache_t; /* Typedef for cached default dataset access property list information */ @@ -540,14 +531,6 @@ H5CX__init_package(void) if(H5P_get(dc_plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &H5CX_def_dcpl_cache.do_min_dset_ohdr) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve dataset minimize flag") - if(H5P_get(dc_plist, H5VL_PROP_DSET_TYPE_ID, &H5CX_def_dcpl_cache.vl_prop_dset_type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for datatype id") - if(H5P_get(dc_plist, H5VL_PROP_DSET_SPACE_ID, &H5CX_def_dcpl_cache.vl_prop_dset_space_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for space id") - if(H5P_get(dc_plist, H5VL_PROP_DSET_LCPL_ID, &H5CX_def_dcpl_cache.vl_prop_dset_lcpl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for lcpl id") - - /* Reset the "default DAPL cache" information */ HDmemset(&H5CX_def_dapl_cache, 0, sizeof(H5CX_dapl_cache_t)); @@ -2388,112 +2371,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5CX_get_vl_prop_dset_type_id - * - * Purpose: Retrieves the datatype ID of the dataset for VOL connector - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_get_vl_prop_dset_type_id(hid_t *dset_type_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(dset_type_id); - HDassert(head && *head); - HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); - - H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5VL_PROP_DSET_TYPE_ID, vl_prop_dset_type_id); - - /* Get the value */ - *dset_type_id = (*head)->ctx.vl_prop_dset_type_id; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_vl_prop_dset_type_id */ - - -/*------------------------------------------------------------------------- - * Function: H5CX_get_vl_prop_dset_space_id - * - * Purpose: Retrieves the space ID of the dataset for VOL connector - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_get_vl_prop_dset_space_id(hid_t *dset_space_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(dset_space_id); - HDassert(head && *head); - HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); - - H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5VL_PROP_DSET_SPACE_ID, vl_prop_dset_space_id); - - /* Get the value */ - *dset_space_id = (*head)->ctx.vl_prop_dset_space_id; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_vl_prop_dset_space_id */ - - -/*------------------------------------------------------------------------- - * Function: H5CX_get_vl_prop_dset_space_id - * - * Purpose: Retrieves the LCPL ID of the dataset for VOL connector - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_get_vl_prop_dset_lcpl_id(hid_t *dset_lcpl_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(dset_lcpl_id); - HDassert(head && *head); - HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); - - H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5VL_PROP_DSET_TYPE_ID, vl_prop_dset_lcpl_id); - - /* Get the value */ - *dset_lcpl_id = (*head)->ctx.vl_prop_dset_lcpl_id; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_vl_prop_dset_lcpl_id */ - - - -/*------------------------------------------------------------------------- * Function: H5CX_get_ext_file_prefix * * Purpose: Retrieves the prefix for external file @@ -2877,106 +2754,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_nlinks() */ - -/*------------------------------------------------------------------------- - * Function: H5CX_set_vl_prop_dset_type_id - * - * Purpose: Sets the datatype ID of the dataset for the current API call context. - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_set_vl_prop_dset_type_id(hid_t dset_type_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(head && *head); - - /* Set the API context value */ - (*head)->ctx.vl_prop_dset_type_id = dset_type_id; - - /* Mark the value as valid */ - (*head)->ctx.vl_prop_dset_type_id_valid = TRUE; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_set_vl_prop_dset_type_id */ - -/*------------------------------------------------------------------------- - * Function: H5CX_set_vl_prop_dset_space_id - * - * Purpose: Sets the data space ID of the dataset for the current API call context. - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_set_vl_prop_dset_space_id(hid_t dset_space_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(head && *head); - - /* Set the API context value */ - (*head)->ctx.vl_prop_dset_space_id = dset_space_id; - - /* Mark the value as valid */ - (*head)->ctx.vl_prop_dset_space_id_valid = TRUE; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_set_vl_prop_dset_space_id */ - -/*------------------------------------------------------------------------- - * Function: H5CX_set_vl_prop_dset_lcpl_id - * - * Purpose: Sets the LCPL ID of the dataset for the current API call context. - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_set_vl_prop_dset_lcpl_id(hid_t dset_lcpl_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(head && *head); - - /* Set the API context value */ - (*head)->ctx.vl_prop_dset_lcpl_id = dset_lcpl_id; - - /* Mark the value as valid */ - (*head)->ctx.vl_prop_dset_lcpl_id_valid = TRUE; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - #ifdef H5_HAVE_PARALLEL /*------------------------------------------------------------------------- diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h index f022d8e..2248ac9 100644 --- a/src/H5CXprivate.h +++ b/src/H5CXprivate.h @@ -126,9 +126,6 @@ H5_DLL herr_t H5CX_get_nlinks(size_t *nlinks); /* "Getter" routines for DCPL properties cached in API context */ H5_DLL herr_t H5CX_get_dset_min_ohdr_flag(hbool_t *dset_min_ohdr_flag); -H5_DLL herr_t H5CX_get_vl_prop_dset_type_id(hid_t *dset_type_id); -H5_DLL herr_t H5CX_get_vl_prop_dset_space_id(hid_t *dset_space_id); -H5_DLL herr_t H5CX_get_vl_prop_dset_lcpl_id(hid_t *dset_lcpl_id); /* "Getter" routines for DAPL properties cached in API context */ H5_DLL herr_t H5CX_get_ext_file_prefix(char **prefix_extfile); @@ -152,11 +149,6 @@ H5_DLL herr_t H5CX_set_io_xfer_mode(H5FD_mpio_xfer_t io_xfer_mode); H5_DLL herr_t H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info); -/* "Setter" routines for DCPL properties cached in API context */ -H5_DLL herr_t H5CX_set_vl_prop_dset_type_id(hid_t dset_type_id); -H5_DLL herr_t H5CX_set_vl_prop_dset_space_id(hid_t dset_space_id); -H5_DLL herr_t H5CX_set_vl_prop_dset_lcpl_id(hid_t dset_lcpl_id); - /* "Setter" routines for LAPL properties cached in API context */ H5_DLL herr_t H5CX_set_nlinks(size_t nlinks); diff --git a/src/H5D.c b/src/H5D.c index a50518d..413be37 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -151,9 +151,12 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set creation properties */ - H5CX_set_vl_prop_dset_type_id(type_id); - H5CX_set_vl_prop_dset_space_id(space_id); - H5CX_set_vl_prop_dset_lcpl_id(lcpl_id); + if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") + if(H5P_set(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for lcpl id") /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; @@ -244,8 +247,10 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") /* set creation properties */ - H5CX_set_vl_prop_dset_type_id(type_id); - H5CX_set_vl_prop_dset_space_id(space_id); + if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index 70e6f70..85371ae 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -148,9 +148,12 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") /* set creation properties */ - H5CX_set_vl_prop_dset_type_id(type_id); - H5CX_set_vl_prop_dset_space_id(space_id); - H5CX_set_vl_prop_dset_lcpl_id(lcpl_id); + if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") + if(H5P_set(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for lcpl id") /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; diff --git a/src/H5Dint.c b/src/H5Dint.c index ae9a40e..7367613 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -43,6 +43,12 @@ /* Local Typedefs */ /******************/ +/* Type of prefix for file */ +typedef enum { + H5D_PREFIX_TYPE_UNKNOWN=0, + H5D_PREFIX_TYPE_EXT=1, + H5D_PREFIX_TYPE_VDS=2 +} H5D_prefix_type_t; /********************/ /* Local Prototypes */ @@ -54,7 +60,7 @@ static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, cons static herr_t H5D__cache_dataspace_info(const H5D_t *dset); static herr_t H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space); static herr_t H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id); -static herr_t H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type, char **file_prefix); +static herr_t H5D__build_file_prefix(const H5D_t *dset, H5D_prefix_type_t prefix_type, char **file_prefix); static herr_t H5D__open_oid(H5D_t *dataset, hid_t dapl_id); static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t old_dim[]); @@ -112,6 +118,10 @@ static const H5I_class_t H5I_DATASET_CLS[1] = {{ /* Flag indicating "top" of interface has been initialized */ static hbool_t H5D_top_package_initialize_s = FALSE; +/* Prefixes of VDS and external file from the environment variables + * HDF5_EXTFILE_PREFIX and HDF5_VDS_PREFIX */ +static char *H5D_prefix_ext_env = NULL; +static char *H5D_prefix_vds_env = NULL; /*------------------------------------------------------------------------- @@ -188,6 +198,10 @@ H5D__init_package(void) /* Mark "top" of interface as initialized, too */ H5D_top_package_initialize_s = TRUE; + /* Retrieve the prefixes of VDS and external file from the environment variable */ + H5D_prefix_vds_env = HDgetenv("HDF5_VDS_PREFIX"); + H5D_prefix_ext_env = HDgetenv("HDF5_EXTFILE_PREFIX"); + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__init_package() */ @@ -1080,7 +1094,7 @@ done: *-------------------------------------------------------------------------- */ static herr_t -H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type, char **file_prefix /*out*/) +H5D__build_file_prefix(const H5D_t *dset, H5D_prefix_type_t prefix_type, char **file_prefix /*out*/) { char *prefix = NULL; /* prefix used to look for the file */ char *filepath = NULL; /* absolute path of directory the HDF5 file is in */ @@ -1101,15 +1115,15 @@ H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type /* XXX: Future thread-safety note - getenv is not required * to be reentrant. */ - if(HDstrcmp(prefix_type, H5D_ACS_VDS_PREFIX_NAME) == 0) { - prefix = HDgetenv("HDF5_VDS_PREFIX"); + if(H5D_PREFIX_TYPE_VDS == prefix_type) { + prefix = H5D_prefix_vds_env; if(prefix == NULL || *prefix == '\0') { if(H5CX_get_vds_prefix(&prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for vds file") } - } else if(HDstrcmp(prefix_type, H5D_ACS_EFILE_PREFIX_NAME) == 0) { - prefix = HDgetenv("HDF5_EXTFILE_PREFIX"); + } else if(H5D_PREFIX_TYPE_EXT == prefix_type) { + prefix = H5D_prefix_ext_env; if(prefix == NULL || *prefix == '\0') { if(H5CX_get_ext_file_prefix(&prefix) < 0) @@ -1324,11 +1338,11 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set up flush append property") /* Set the external file prefix */ - if(H5D__build_file_prefix(new_dset, dapl_id, H5D_ACS_EFILE_PREFIX_NAME, &new_dset->shared->extfile_prefix) < 0) + if(H5D__build_file_prefix(new_dset, H5D_PREFIX_TYPE_EXT, &new_dset->shared->extfile_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix") /* Set the VDS file prefix */ - if(H5D__build_file_prefix(new_dset, dapl_id, H5D_ACS_VDS_PREFIX_NAME, &new_dset->shared->vds_prefix) < 0) + if(H5D__build_file_prefix(new_dset, H5D_PREFIX_TYPE_VDS, &new_dset->shared->vds_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix") /* Add the dataset to the list of opened objects in the file */ @@ -1483,11 +1497,11 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy path") /* Get the external file prefix */ - if(H5D__build_file_prefix(dataset, dapl_id, H5D_ACS_EFILE_PREFIX_NAME, &extfile_prefix) < 0) + if(H5D__build_file_prefix(dataset, H5D_PREFIX_TYPE_EXT, &extfile_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix") /* Get the VDS prefix */ - if(H5D__build_file_prefix(dataset, dapl_id, H5D_ACS_VDS_PREFIX_NAME, &vds_prefix) < 0) + if(H5D__build_file_prefix(dataset, H5D_PREFIX_TYPE_VDS, &vds_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix") /* Check if dataset was already open */ @@ -1550,10 +1564,8 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) ret_value = dataset; done: - if(extfile_prefix) - extfile_prefix = (char *)H5MM_xfree(extfile_prefix); - if(vds_prefix) - vds_prefix = (char *)H5MM_xfree(vds_prefix); + extfile_prefix = (char *)H5MM_xfree(extfile_prefix); + vds_prefix = (char *)H5MM_xfree(vds_prefix); if(ret_value == NULL) { /* Free the location--casting away const*/ -- cgit v0.12 From e09e2fc4ad7aadef1a99573ee6d3cec9bea3becb Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Fri, 22 Mar 2019 10:03:06 -0500 Subject: HDFFV-10658: I left out this file in my previous commit. --- src/H5VLnative_dataset.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c index ac25c55..aa65e54 100644 --- a/src/H5VLnative_dataset.c +++ b/src/H5VLnative_dataset.c @@ -18,7 +18,6 @@ #define H5D_FRIEND /* Suppress error about including H5Dpkg */ #include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ @@ -62,10 +61,12 @@ H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") - /* Get creation properties */ - H5CX_get_vl_prop_dset_type_id(&type_id); - H5CX_get_vl_prop_dset_space_id(&space_id); - H5CX_get_vl_prop_dset_lcpl_id(&lcpl_id); + if(H5P_get(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") + if(H5P_get(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") + if(H5P_get(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") /* Check arguments */ if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) -- cgit v0.12 From 50d9a397ab4bcbeaa6466eabe1c2ec6e2cf61f89 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Thu, 4 Apr 2019 11:03:05 -0500 Subject: This commit basically has the following changes: 1. restored the datatype, dataspace, and LCPL of the dataset for VOL connector back to the properties. 2. splitted external.c and vds.c because they called HDsetenv in the program, instead using shell scripts to set the environment variables. 3. changed H5CX_get_vds_prefix and H5CX_get_ext_file_prefix to use H5P_peek instead of H5P_get. --- configure.ac | 2 + src/H5CX.c | 54 +++++++- src/H5Dint.c | 8 +- test/Makefile.am | 18 ++- test/external.c | 231 +------------------------------ test/external.h | 144 +++++++++++++++++++ test/external_env.c | 219 +++++++++++++++++++++++++++++ test/testexternal_env.sh.in | 42 ++++++ test/testvds_env.sh.in | 44 ++++++ test/vds.c | 198 +-------------------------- test/vds_env.c | 326 ++++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 848 insertions(+), 438 deletions(-) create mode 100644 test/external.h create mode 100644 test/external_env.c create mode 100644 test/testexternal_env.sh.in create mode 100644 test/testvds_env.sh.in create mode 100644 test/vds_env.c diff --git a/configure.ac b/configure.ac index 30fe725..6cc97e2 100644 --- a/configure.ac +++ b/configure.ac @@ -3477,10 +3477,12 @@ AC_CONFIG_FILES([src/libhdf5.settings test/testabort_fail.sh test/testcheck_version.sh test/testerror.sh + test/testexternal_env.sh test/testflushrefresh.sh test/testlibinfo.sh test/testlinks_env.sh test/testswmr.sh + test/testvds_env.sh test/testvdsswmr.sh test/test_filter_plugin.sh test/test_usecases.sh diff --git a/src/H5CX.c b/src/H5CX.c index 08e8c3f..94d1f32 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -2390,18 +2390,41 @@ H5CX_get_ext_file_prefix(char **extfile_prefix) FUNC_ENTER_NOAPI(FAIL) + /* Sanity check */ HDassert(extfile_prefix); HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dapl_id); - H5CX_RETRIEVE_PROP_VALID(dapl, H5P_DATASET_ACCESS_DEFAULT, H5D_ACS_EFILE_PREFIX_NAME, extfile_prefix); + /* Check if the value has been retrieved already */ + if(!(*head)->ctx.extfile_prefix_valid) { + /* Check for default DAPL */ + if((*head)->ctx.dapl_id == H5P_DATASET_ACCESS_DEFAULT) + (*head)->ctx.extfile_prefix = H5CX_def_dapl_cache.extfile_prefix; + else { + /* Check if the property list is already available */ + if(NULL == (*head)->ctx.dapl) + /* Get the dataset access property list pointer */ + if(NULL == ((*head)->ctx.dapl = (H5P_genplist_t *)H5I_object((*head)->ctx.dapl_id))) + HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "can't get default dataset access property list") + + /* Get the prefix for the external file */ + /* (Note: 'peek', not 'get' - if this turns out to be a problem, we may need + * to copy it and free this in the H5CX pop routine. -QAK) + */ + if(H5P_peek((*head)->ctx.dapl, H5D_ACS_EFILE_PREFIX_NAME, &(*head)->ctx.extfile_prefix) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve external file prefix") + } /* end else */ + + /* Mark the value as valid */ + (*head)->ctx.extfile_prefix_valid = TRUE; + } /* end if */ /* Get the value */ *extfile_prefix = (*head)->ctx.extfile_prefix; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_ext_file_prefix */ +} /* end H5CX_get_ext_file_prefix() */ /*------------------------------------------------------------------------- @@ -2424,18 +2447,41 @@ H5CX_get_vds_prefix(char **vds_prefix) FUNC_ENTER_NOAPI(FAIL) + /* Sanity check */ HDassert(vds_prefix); HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dapl_id); - H5CX_RETRIEVE_PROP_VALID(dapl, H5P_DATASET_ACCESS_DEFAULT, H5D_ACS_VDS_PREFIX_NAME, vds_prefix); + /* Check if the value has been retrieved already */ + if(!(*head)->ctx.vds_prefix_valid) { + /* Check for default DAPL */ + if((*head)->ctx.dapl_id == H5P_DATASET_ACCESS_DEFAULT) + (*head)->ctx.vds_prefix = H5CX_def_dapl_cache.vds_prefix; + else { + /* Check if the property list is already available */ + if(NULL == (*head)->ctx.dapl) + /* Get the dataset access property list pointer */ + if(NULL == ((*head)->ctx.dapl = (H5P_genplist_t *)H5I_object((*head)->ctx.dapl_id))) + HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "can't get default dataset access property list") + + /* Get the prefix for the VDS */ + /* (Note: 'peek', not 'get' - if this turns out to be a problem, we may need + * to copy it and free this in the H5CX pop routine. -QAK) + */ + if(H5P_peek((*head)->ctx.dapl, H5D_ACS_VDS_PREFIX_NAME, &(*head)->ctx.vds_prefix) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VDS prefix") + } /* end else */ + + /* Mark the value as valid */ + (*head)->ctx.vds_prefix_valid = TRUE; + } /* end if */ /* Get the value */ *vds_prefix = (*head)->ctx.vds_prefix; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_vds_prefix */ +} /* end H5CX_get_vds_prefix() */ /*------------------------------------------------------------------------- diff --git a/src/H5Dint.c b/src/H5Dint.c index 7367613..bdd43cf 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -120,8 +120,8 @@ static hbool_t H5D_top_package_initialize_s = FALSE; /* Prefixes of VDS and external file from the environment variables * HDF5_EXTFILE_PREFIX and HDF5_VDS_PREFIX */ -static char *H5D_prefix_ext_env = NULL; -static char *H5D_prefix_vds_env = NULL; +const static char *H5D_prefix_ext_env = NULL; +const static char *H5D_prefix_vds_env = NULL; /*------------------------------------------------------------------------- @@ -1116,14 +1116,14 @@ H5D__build_file_prefix(const H5D_t *dset, H5D_prefix_type_t prefix_type, char ** * to be reentrant. */ if(H5D_PREFIX_TYPE_VDS == prefix_type) { - prefix = H5D_prefix_vds_env; + prefix = (char *)H5D_prefix_vds_env; if(prefix == NULL || *prefix == '\0') { if(H5CX_get_vds_prefix(&prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for vds file") } } else if(H5D_PREFIX_TYPE_EXT == prefix_type) { - prefix = H5D_prefix_ext_env; + prefix = (char *)H5D_prefix_ext_env; if(prefix == NULL || *prefix == '\0') { if(H5CX_get_ext_file_prefix(&prefix) < 0) diff --git a/test/Makefile.am b/test/Makefile.am index 88dc542..68b9394 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -26,21 +26,23 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_builddir)/src # testlibinfo.sh: # testcheck_version.sh: tcheck_version # testlinks_env.sh: links_env +# testexternal_env.sh: external_env # testflushrefresh.sh: flushrefresh +# testvds_env.sh: vds_env # testswmr.sh: swmr* # testvdsswmr.sh: vds_swmr* # testabort_fail.sh: filenotclosed.c and del_many_dense_attrs.c # test_filter_plugin.sh: filter_plugin.c # test_usecases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes -TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh \ - testswmr.sh testvdsswmr.sh testflushrefresh.sh test_usecases.sh testabort_fail.sh +TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh testexternal_env.sh \ + testswmr.sh testvds_env.sh testvdsswmr.sh testflushrefresh.sh test_usecases.sh testabort_fail.sh SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) \ - filenotclosed$(EXEEXT) del_many_dense_attrs$(EXEEXT) \ + external_env$(EXEEXT) filenotclosed$(EXEEXT) del_many_dense_attrs$(EXEEXT) \ flushrefresh$(EXEEXT) use_append_chunk$(EXEEXT) use_append_mchunks$(EXEEXT) use_disable_mdc_flushes$(EXEEXT) \ swmr_generator$(EXEEXT) swmr_reader$(EXEEXT) swmr_writer$(EXEEXT) \ swmr_remove_reader$(EXEEXT) swmr_remove_writer$(EXEEXT) swmr_addrem_writer$(EXEEXT) \ swmr_sparse_reader$(EXEEXT) swmr_sparse_writer$(EXEEXT) swmr_start_write$(EXEEXT) \ - vds_swmr_gen$(EXEEXT) vds_swmr_reader$(EXEEXT) vds_swmr_writer$(EXEEXT) + vds_env$(EXEEXT) vds_swmr_gen$(EXEEXT) vds_swmr_reader$(EXEEXT) vds_swmr_writer$(EXEEXT) if HAVE_SHARED_CONDITIONAL TEST_SCRIPT += test_filter_plugin.sh test_vol_plugin.sh SCRIPT_DEPEND += filter_plugin$(EXEEXT) vol_plugin$(EXEEXT) @@ -69,21 +71,23 @@ TEST_PROG= testhdf5 \ # accum_swmr_reader is used by accum.c. # atomic_writer and atomic_reader are standalone programs. # links_env is used by testlinks_env.sh +# external_env is used by testexternal_env.sh # filenotclosed and del_many_dense_attrs are used by testabort_fail.sh # flushrefresh is used by testflushrefresh.sh. # use_append_chunk, use_append_mchunks and use_disable_mdc_flushes are used by test_usecases.sh # swmr_* files (besides swmr.c) are used by testswmr.sh. # vds_swmr_* files are used by testvdsswmr.sh +# vds_env is used by testvds_env.sh # 'make check' doesn't run them directly, so they are not included in TEST_PROG. # Also build testmeta, which is used for timings test. It builds quickly, # and this lets automake keep all its test programs in one place. check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version \ - testmeta accum_swmr_reader atomic_writer atomic_reader \ + testmeta accum_swmr_reader atomic_writer atomic_reader external_env \ links_env filenotclosed del_many_dense_attrs flushrefresh \ use_append_chunk use_append_mchunks use_disable_mdc_flushes \ swmr_generator swmr_start_write swmr_reader swmr_writer swmr_remove_reader \ 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 + swmr_check_compat_vfd vds_env vds_swmr_gen vds_swmr_reader vds_swmr_writer if HAVE_SHARED_CONDITIONAL check_PROGRAMS+= filter_plugin vol_plugin endif @@ -223,7 +227,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 testabort_fail.sh \ + testexternal_env.sh testswmr.sh testvds_env.sh testvdsswmr.sh test_usecases.sh testflushrefresh.sh testabort_fail.sh \ test_vol_plugin.sh include $(top_srcdir)/config/conclude.am diff --git a/test/external.c b/test/external.c index 20a9ed8..5ff65e6 100644 --- a/test/external.c +++ b/test/external.c @@ -18,24 +18,7 @@ * Purpose: Tests datasets stored in external raw files. */ #include "h5test.h" - -const char *FILENAME[] = { - "extern_1", - "extern_2", - "extern_3", - "extern_4", - "extern_dir/file_1", - "extern_5", - NULL -}; - -/* A similar collection of files is used for the tests that - * perform file I/O. - */ -#define N_EXT_FILES 4 -#define PART_SIZE 25 -#define TOTAL_SIZE 100 -#define GARBAGE_PER_FILE 10 +#include "external.h" /*------------------------------------------------------------------------- @@ -99,106 +82,6 @@ out: /*------------------------------------------------------------------------- - * Function: reset_raw_data_files - * - * Purpose: Resets the data in the raw data files for tests that - * perform dataset I/O on a set of files. - * - * Return: SUCCEED/FAIL - * - * Programmer: Dana Robinson - * February 2016 - * - *------------------------------------------------------------------------- - */ -static herr_t -reset_raw_data_files(void) -{ - int fd = 0; /* external file descriptor */ - size_t i, j; /* iterators */ - hssize_t n; /* bytes of I/O */ - char filename[1024]; /* file name */ - int data[PART_SIZE]; /* raw data buffer */ - uint8_t *garbage = NULL; /* buffer of garbage data */ - size_t garbage_count; /* size of garbage buffer */ - size_t garbage_bytes; /* # of garbage bytes written to file */ - - /* Set up garbage buffer */ - garbage_count = N_EXT_FILES * GARBAGE_PER_FILE; - if(NULL == (garbage = (uint8_t *)HDcalloc(garbage_count, sizeof(uint8_t)))) - goto error; - for(i = 0; i < garbage_count; i++) - garbage[i] = 0xFF; - - /* The *r files are pre-filled with data and are used to - * verify that read operations work correctly. - */ - for(i = 0; i < N_EXT_FILES; i++) { - - /* Open file */ - HDsprintf(filename, "extern_%lur.raw", (unsigned long)i + 1); - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) - goto error; - - /* Write garbage data to the file. This allows us to test the - * the ability to set an offset in the raw data file. - */ - garbage_bytes = i * 10; - n = HDwrite(fd, garbage, garbage_bytes); - if(n < 0 || (size_t)n != garbage_bytes) - goto error; - - /* Fill array with data */ - for(j = 0; j < PART_SIZE; j++) { - data[j] = (int)(i * 25 + j); - } /* end for */ - - /* Write raw data to the file. */ - n = HDwrite(fd, data, sizeof(data)); - if(n != sizeof(data)) - goto error; - - /* Close this file */ - HDclose(fd); - - } /* end for */ - - /* The *w files are only pre-filled with the garbage data and are - * used to verify that write operations work correctly. The individual - * tests fill in the actual data. - */ - for(i = 0; i < N_EXT_FILES; i++) { - - /* Open file */ - HDsprintf(filename, "extern_%luw.raw", (unsigned long)i + 1); - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) - goto error; - - /* Write garbage data to the file. This allows us to test the - * the ability to set an offset in the raw data file. - */ - garbage_bytes = i * 10; - n = HDwrite(fd, garbage, garbage_bytes); - if(n < 0 || (size_t)n != garbage_bytes) - goto error; - - /* Close this file */ - HDclose(fd); - - } /* end for */ - HDfree(garbage); - return SUCCEED; - -error: - if(fd) - HDclose(fd); - if(garbage) - HDfree(garbage); - return FAIL; -} /* end reset_raw_data_files() */ - - -/*------------------------------------------------------------------------- * Function: test_non_extendible * * Purpose: Tests a non-extendible dataset with a single external file. @@ -1297,116 +1180,6 @@ error: /*------------------------------------------------------------------------- - * Function: test_path_env - * - * Purpose: Test whether the value of HDF5_EXTFILE_PREFIX will overwrite - * the efile_prefix dataset access property. - * This will create an HDF5 file in a subdirectory which will - * refer to ../extern_*a.raw - * The files are then accessed by setting the HDF5_EXTFILE_PREFIX - * environment variable to "${ORIGIN}". - * The efile_prefix dataset access property is set to "someprefix", - * which will cause an error if the value is not overwritten by - * the environment variable. - * - * Return: Success: 0 - * Failure: 1 - * - * Programmer: Steffen Kiess - * March 10, 2015 - * - *------------------------------------------------------------------------- - */ -static int -test_path_env(hid_t fapl) -{ - hid_t file = -1; /* file to write to */ - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dapl = -1; /* dataset access property list */ - hid_t dset = -1; /* dataset */ - size_t i; /* miscellaneous counters */ - char cwdpath[1024]; /* working directory */ - char filename[1024]; /* file name */ - int part[PART_SIZE]; /* raw data buffer (partial) */ - int whole[TOTAL_SIZE]; /* raw data buffer (total) */ - hsize_t cur_size; /* current data space size */ - char buffer[1024]; /* buffer to read efile_prefix */ - - TESTING("prefix in HDF5_EXTFILE_PREFIX"); - - if(HDsetenv("HDF5_EXTFILE_PREFIX", "${ORIGIN}", 1)) - TEST_ERROR - - if(HDmkdir("extern_dir", (mode_t)0755) < 0 && errno != EEXIST) - TEST_ERROR; - - h5_fixname(FILENAME[4], fapl, filename, sizeof(filename)); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - FAIL_STACK_ERROR - - /* Reset the raw data files */ - if(reset_raw_data_files() < 0) - TEST_ERROR - - /* Create the dataset */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - FAIL_STACK_ERROR - if(NULL == HDgetcwd(cwdpath, sizeof(cwdpath))) - TEST_ERROR - for(i = 0; i < N_EXT_FILES; i++) { - HDsnprintf(filename, sizeof(filename), "..%sextern_%dr.raw", H5_DIR_SEPS, (int) i + 1); - if(H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) - FAIL_STACK_ERROR - } /* end for */ - - cur_size = TOTAL_SIZE; - if((space = H5Screate_simple(1, &cur_size, NULL)) < 0) - FAIL_STACK_ERROR - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) - FAIL_STACK_ERROR - - /* Set prefix to a nonexistent directory, will be overwritten by environment variable */ - if(H5Pset_efile_prefix(dapl, "someprefix") < 0) - FAIL_STACK_ERROR - if(H5Pget_efile_prefix(dapl, buffer, sizeof(buffer)) < 0) - FAIL_STACK_ERROR - if(HDstrcmp(buffer, "someprefix") != 0) - FAIL_PUTS_ERROR("efile prefix not set correctly"); - - /* Create dataset */ - if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, dapl)) < 0) - FAIL_STACK_ERROR - - /* Read the entire dataset and compare with the original */ - HDmemset(whole, 0, sizeof(whole)); - if(H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) - FAIL_STACK_ERROR - for(i = 0; i < TOTAL_SIZE; i++) - if(whole[i] != (signed)i) - FAIL_PUTS_ERROR("Incorrect value(s) read."); - - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - if(H5Pclose(dapl) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED(); - return 0; - -error: - H5E_BEGIN_TRY { - H5Pclose(dapl); - H5Dclose(dset); - H5Pclose(dcpl); - H5Sclose(space); - H5Fclose(file); - } H5E_END_TRY; - return 1; -} /* end test_path_env() */ - - -/*------------------------------------------------------------------------- * Function: test_h5d_get_access_plist * * Purpose: Ensure that H5Dget_access_plist returns correct values. @@ -1585,7 +1358,6 @@ main(void) nerrors += test_path_absolute(current_fapl_id); nerrors += test_path_relative(current_fapl_id); nerrors += test_path_relative_cwd(current_fapl_id); - nerrors += test_path_env(current_fapl_id); /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, current_fapl_id) < 0 ? 1 : 0); @@ -1630,4 +1402,3 @@ error: printf("%d TEST%s FAILED.\n", nerrors, 1 == nerrors ? "" : "s"); return EXIT_FAILURE; } /* end main() */ - diff --git a/test/external.h b/test/external.h new file mode 100644 index 0000000..1c660e1 --- /dev/null +++ b/test/external.h @@ -0,0 +1,144 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol + * Wednesday, March 17, 2010 + * + * Purpose: srcdir querying support. + */ +#ifndef _EXTERNAL_H +#define _EXTERNAL_H + +/* Include test header files */ +#include "h5test.h" + +const char *FILENAME[] = { + "extern_1", + "extern_2", + "extern_3", + "extern_4", + "extern_dir/file_1", + "extern_5", + NULL +}; + +/* A similar collection of files is used for the tests that + * perform file I/O. + */ +#define N_EXT_FILES 4 +#define PART_SIZE 25 +#define TOTAL_SIZE 100 +#define GARBAGE_PER_FILE 10 + + +/*------------------------------------------------------------------------- + * Function: reset_raw_data_files + * + * Purpose: Resets the data in the raw data files for tests that + * perform dataset I/O on a set of files. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * February 2016 + * + *------------------------------------------------------------------------- + */ +static herr_t +reset_raw_data_files(void) +{ + int fd = 0; /* external file descriptor */ + size_t i, j; /* iterators */ + hssize_t n; /* bytes of I/O */ + char filename[1024]; /* file name */ + int data[PART_SIZE]; /* raw data buffer */ + uint8_t *garbage = NULL; /* buffer of garbage data */ + size_t garbage_count; /* size of garbage buffer */ + size_t garbage_bytes; /* # of garbage bytes written to file */ + + /* Set up garbage buffer */ + garbage_count = N_EXT_FILES * GARBAGE_PER_FILE; + if(NULL == (garbage = (uint8_t *)HDcalloc(garbage_count, sizeof(uint8_t)))) + goto error; + for(i = 0; i < garbage_count; i++) + garbage[i] = 0xFF; + + /* The *r files are pre-filled with data and are used to + * verify that read operations work correctly. + */ + for(i = 0; i < N_EXT_FILES; i++) { + + /* Open file */ + HDsprintf(filename, "extern_%lur.raw", (unsigned long)i + 1); + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) + goto error; + + /* Write garbage data to the file. This allows us to test the + * the ability to set an offset in the raw data file. + */ + garbage_bytes = i * 10; + n = HDwrite(fd, garbage, garbage_bytes); + if(n < 0 || (size_t)n != garbage_bytes) + goto error; + + /* Fill array with data */ + for(j = 0; j < PART_SIZE; j++) { + data[j] = (int)(i * 25 + j); + } /* end for */ + + /* Write raw data to the file. */ + n = HDwrite(fd, data, sizeof(data)); + if(n != sizeof(data)) + goto error; + + /* Close this file */ + HDclose(fd); + + } /* end for */ + + /* The *w files are only pre-filled with the garbage data and are + * used to verify that write operations work correctly. The individual + * tests fill in the actual data. + */ + for(i = 0; i < N_EXT_FILES; i++) { + + /* Open file */ + HDsprintf(filename, "extern_%luw.raw", (unsigned long)i + 1); + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) + goto error; + + /* Write garbage data to the file. This allows us to test the + * the ability to set an offset in the raw data file. + */ + garbage_bytes = i * 10; + n = HDwrite(fd, garbage, garbage_bytes); + if(n < 0 || (size_t)n != garbage_bytes) + goto error; + + /* Close this file */ + HDclose(fd); + + } /* end for */ + HDfree(garbage); + return SUCCEED; + +error: + if(fd) + HDclose(fd); + if(garbage) + HDfree(garbage); + return FAIL; +} /* end reset_raw_data_files() */ +#endif /* _EXTERNAL_H */ + diff --git a/test/external_env.c b/test/external_env.c new file mode 100644 index 0000000..97daef2 --- /dev/null +++ b/test/external_env.c @@ -0,0 +1,219 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Robb Matzke + * Tuesday, March 3, 1998 + * + * Purpose: Tests datasets stored in external raw files. + */ +#include "h5test.h" +#include "external.h" + + +/*------------------------------------------------------------------------- + * Function: test_path_env + * + * Purpose: Test whether the value of HDF5_EXTFILE_PREFIX will overwrite + * the efile_prefix dataset access property. + * This will create an HDF5 file in a subdirectory which will + * refer to ../extern_*a.raw + * The files are then accessed by setting the HDF5_EXTFILE_PREFIX + * environment variable to "${ORIGIN}". + * The efile_prefix dataset access property is set to "someprefix", + * which will cause an error if the value is not overwritten by + * the environment variable. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Steffen Kiess + * March 10, 2015 + * + *------------------------------------------------------------------------- + */ +static int +test_path_env(hid_t fapl) +{ + hid_t file = -1; /* file to write to */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dapl = -1; /* dataset access property list */ + hid_t dset = -1; /* dataset */ + size_t i; /* miscellaneous counters */ + char cwdpath[1024]; /* working directory */ + char filename[1024]; /* file name */ + int part[PART_SIZE]; /* raw data buffer (partial) */ + int whole[TOTAL_SIZE]; /* raw data buffer (total) */ + hsize_t cur_size; /* current data space size */ + char buffer[1024]; /* buffer to read efile_prefix */ + + TESTING("prefix in HDF5_EXTFILE_PREFIX"); + + if(HDmkdir("extern_dir", (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR; + + h5_fixname(FILENAME[4], fapl, filename, sizeof(filename)); + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + /* Reset the raw data files */ + if(reset_raw_data_files() < 0) + TEST_ERROR + + /* Create the dataset */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + if(NULL == HDgetcwd(cwdpath, sizeof(cwdpath))) + TEST_ERROR + for(i = 0; i < N_EXT_FILES; i++) { + HDsnprintf(filename, sizeof(filename), "..%sextern_%dr.raw", H5_DIR_SEPS, (int) i + 1); + if(H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) + FAIL_STACK_ERROR + } /* end for */ + + cur_size = TOTAL_SIZE; + if((space = H5Screate_simple(1, &cur_size, NULL)) < 0) + FAIL_STACK_ERROR + if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR + + /* Set prefix to a nonexistent directory, will be overwritten by environment variable */ + if(H5Pset_efile_prefix(dapl, "someprefix") < 0) + FAIL_STACK_ERROR + if(H5Pget_efile_prefix(dapl, buffer, sizeof(buffer)) < 0) + FAIL_STACK_ERROR + if(HDstrcmp(buffer, "someprefix") != 0) + FAIL_PUTS_ERROR("efile prefix not set correctly"); + + /* Create dataset */ + if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, dapl)) < 0) + FAIL_STACK_ERROR + + /* Read the entire dataset and compare with the original */ + HDmemset(whole, 0, sizeof(whole)); + if(H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) + FAIL_STACK_ERROR + for(i = 0; i < TOTAL_SIZE; i++) + if(whole[i] != (signed)i) + FAIL_PUTS_ERROR("Incorrect value(s) read."); + + if(H5Dclose(dset) < 0) FAIL_STACK_ERROR + if(H5Pclose(dapl) < 0) FAIL_STACK_ERROR + if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if(H5Sclose(space) < 0) FAIL_STACK_ERROR + if(H5Fclose(file) < 0) FAIL_STACK_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(dapl); + H5Dclose(dset); + H5Pclose(dcpl); + H5Sclose(space); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* end test_path_env() */ + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Runs external dataset tests. + * + * Return: EXIT_SUCCESS/EXIT_FAILURE + * + * Programmer: Robb Matzke + * Tuesday, March 3, 1998 + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + hid_t fapl_id_old = -1; /* file access properties (old format) */ + hid_t fapl_id_new = -1; /* file access properties (new format) */ + hid_t fid = -1; /* file for test_1* functions */ + hid_t gid = -1; /* group to emit diagnostics */ + char filename[1024]; /* file name for test_1* funcs */ + unsigned latest_format; /* default or latest file format */ + int nerrors = 0; /* number of errors */ + + h5_reset(); + + /* Get a fapl for the old (default) file format */ + fapl_id_old = h5_fileaccess(); + h5_fixname(FILENAME[0], fapl_id_old, filename, sizeof(filename)); + + /* Copy and set up a fapl for the latest file format */ + if((fapl_id_new = H5Pcopy(fapl_id_old)) < 0) + FAIL_STACK_ERROR + if(H5Pset_libver_bounds(fapl_id_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + FAIL_STACK_ERROR + + /* Test with old & new format groups */ + for(latest_format = FALSE; latest_format <= TRUE; latest_format++) { + hid_t current_fapl_id = -1; + + /* Set the fapl for different file formats */ + if(latest_format) { + HDputs("\nTesting with the latest file format:"); + current_fapl_id = fapl_id_new; + } /* end if */ + else { + HDputs("Testing with the default file format:"); + current_fapl_id = fapl_id_old; + } /* end else */ + + nerrors += test_path_env(current_fapl_id); + } /* end for */ + + if(nerrors > 0) goto error; + + /* Close the new ff fapl. h5_cleanup will take care of the old ff fapl */ + if(H5Pclose(fapl_id_new) < 0) FAIL_STACK_ERROR + + HDputs("All external storage tests passed."); + + /* Clean up files used by file set tests */ + if(h5_cleanup(FILENAME, fapl_id_old)) { + HDremove("extern_1r.raw"); + HDremove("extern_2r.raw"); + HDremove("extern_3r.raw"); + HDremove("extern_4r.raw"); + + HDremove("extern_1w.raw"); + HDremove("extern_2w.raw"); + HDremove("extern_3w.raw"); + HDremove("extern_4w.raw"); + + HDrmdir("extern_dir"); + } /* end if */ + + return EXIT_SUCCESS; + +error: + H5E_BEGIN_TRY { + H5Fclose(fid); + H5Pclose(fapl_id_old); + H5Pclose(fapl_id_new); + H5Gclose(gid); + } H5E_END_TRY; + nerrors = MAX(1, nerrors); + printf("%d TEST%s FAILED.\n", nerrors, 1 == nerrors ? "" : "s"); + return EXIT_FAILURE; +} /* end main() */ + diff --git a/test/testexternal_env.sh.in b/test/testexternal_env.sh.in new file mode 100644 index 0000000..dff3851 --- /dev/null +++ b/test/testexternal_env.sh.in @@ -0,0 +1,42 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# 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. +# +# Test for external file with environment variable: HDF5_EXTFILE_PREFIX + +srcdir=@srcdir@ + +nerrors=0 + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + +# test for external file with HDF5_EXTFILE_PREFIX +echo "Testing external file with HDF5_EXTFILE_PREFIX" +TEST_NAME=external_env # The test name +TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary +ENVCMD="env HDF5_EXTFILE_PREFIX=\${ORIGIN}" # The environment variable & value +# +# Run the test +# echo "$ENVCMD $RUNSERIAL $TEST_BIN" +$ENVCMD $RUNSERIAL $TEST_BIN +exitcode=$? +if [ $exitcode -eq 0 ]; then + echo "Test prefix for HDF5_EXTFILE_PREFIX PASSED" + else + nerrors="`expr $nerrors + 1`" + echo "***Error encountered for HDF5_EXTFILE_PREFIX test***" +fi +exit $nerrors diff --git a/test/testvds_env.sh.in b/test/testvds_env.sh.in new file mode 100644 index 0000000..870f2eb --- /dev/null +++ b/test/testvds_env.sh.in @@ -0,0 +1,44 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# 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. +# +# Test for external file with environment variable: HDF5_VDS_PREFIX + +srcdir=@srcdir@ + +nerrors=0 + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + +# test for VDS with HDF5_VDS_PREFIX +echo "Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix" +TEST_NAME=vds_env # The test name +TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary +ENVCMD="env HDF5_VDS_PREFIX=\${ORIGIN}/tmp" # Set the environment variable & value +UNENVCMD="unset HDF5_VDS_PREFIX" # Unset the environment variable & value +# +# Run the test +# echo "$ENVCMD $RUNSERIAL $TEST_BIN" +$ENVCMD $RUNSERIAL $TEST_BIN +exitcode=$? +if [ $exitcode -eq 0 ]; then + echo "Test prefix for HDF5_VDS_PREFIX PASSED" + else + nerrors="`expr $nerrors + 1`" + echo "***Error encountered for HDF5_VDS_PREFIX test***" +fi +$UNENVCMD +exit $nerrors diff --git a/test/vds.c b/test/vds.c index 67af8e3..ad77030 100644 --- a/test/vds.c +++ b/test/vds.c @@ -1119,7 +1119,7 @@ error: } /* end test_api() */ /*------------------------------------------------------------------------- - * Function: vds_link_prefix + * Function: test_vds_prefix_first * * Purpose: Set up vds link prefix via H5Pset_virtual_prefix() to be "tmp" * Should be able to access the target source files in tmp directory via the prefix set @@ -1130,18 +1130,16 @@ error: *------------------------------------------------------------------------- */ static int -test_vds_prefix(unsigned config, hid_t fapl) +test_vds_prefix_first(unsigned config, hid_t fapl) { char srcfilename[FILENAME_BUF_SIZE]; char srcfilename_map[FILENAME_BUF_SIZE]; char vfilename[FILENAME_BUF_SIZE]; - char vfilename2[FILENAME_BUF_SIZE]; char srcfilenamepct[FILENAME_BUF_SIZE]; char srcfilenamepct_map[FILENAME_BUF_SIZE]; const char *srcfilenamepct_map_orig = "vds%%%%_src"; hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ hid_t vfile = -1; /* File with virtual dset */ - hid_t vfile2 = -1; /* File with copied virtual dset */ hid_t dcpl = -1; /* Dataset creation property list */ hid_t dapl = -1; /* Dataset access property list */ hid_t srcspace[4] = {-1, -1, -1, -1}; /* Source dataspaces */ @@ -1156,10 +1154,9 @@ test_vds_prefix(unsigned config, hid_t fapl) int i, j; char buffer[1024]; /* buffer to read vds_prefix */ - TESTING("basic virtual dataset I/O via H5Pset_vds_prefix()") + TESTING("basic virtual dataset I/O via H5Pset_vds_prefix(): all selection") h5_fixname(FILENAME[0], fapl, vfilename, sizeof vfilename); - h5_fixname(FILENAME[7], fapl, vfilename2, sizeof vfilename2); h5_fixname(FILENAME[8], fapl, srcfilename, sizeof srcfilename); h5_fixname_printf(FILENAME[8], fapl, srcfilename_map, sizeof srcfilename_map); h5_fixname(FILENAME[10], fapl, srcfilenamepct, sizeof srcfilenamepct); @@ -1189,9 +1186,6 @@ test_vds_prefix(unsigned config, hid_t fapl) if(HDstrcmp(buffer, TMPDIR) != 0) FAIL_PUTS_ERROR("vds prefix not set correctly"); - /* - * Test 1: All - all selection - */ /* Create source dataspace */ if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR @@ -1344,187 +1338,6 @@ test_vds_prefix(unsigned config, hid_t fapl) TEST_ERROR dcpl = -1; - /* - * Test 2: All - all selection with ENV prefix - */ - if(HDsetenv("HDF5_VDS_PREFIX", "${ORIGIN}/tmp", 1)) - TEST_ERROR - - /* Create DCPL */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - TEST_ERROR - - /* Set fill value */ - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) - TEST_ERROR - - /* Set prefix to a nonexistent directory, will be overwritten by environment variable */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) - TEST_ERROR - - if(H5Pset_virtual_prefix(dapl, "someprefix") < 0) - TEST_ERROR - if(H5Pget_virtual_prefix(dapl, buffer, sizeof(buffer)) < 0) - TEST_ERROR - - if(HDstrcmp(buffer, "someprefix") != 0) - FAIL_PUTS_ERROR("vds prefix not set correctly"); - - /* Create source dataspace */ - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) - TEST_ERROR - - /* Create virtual dataspace */ - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) - TEST_ERROR - - /* Select all (should not be necessary, but just to be sure) */ - if(H5Sselect_all(srcspace[0]) < 0) - TEST_ERROR - if(H5Sselect_all(vspace[0]) < 0) - TEST_ERROR - - /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset", srcspace[0]) < 0) - TEST_ERROR - - /* Create virtual file */ - if((vfile = H5Fcreate(vfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - HDgetcwd(buffer, 1024); - HDchdir(TMPDIR); - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - HDchdir(buffer); - } - else { - srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) - TEST_ERROR - } - - /* Create source dataset */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - TEST_ERROR - - /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) - TEST_ERROR - - /* Populate write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; - - /* Write data directly to source dataset */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) - TEST_ERROR - - /* Close srcdset and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) - TEST_ERROR - srcdset[0] = -1; - - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) - TEST_ERROR - srcfile[0] = -1; - } - } - - /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) - TEST_ERROR - vdset = -1; - if(H5Fclose(vfile) < 0) - TEST_ERROR - vfile = -1; - if((vfile = H5Fopen(vfilename2, H5F_ACC_RDWR, fapl)) < 0) - TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) - TEST_ERROR - } - - /* Read data through virtual dataset */ - HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) - TEST_ERROR - - /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) { - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) { - TEST_ERROR - } - } - - /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); - - /* Write data through virtual dataset */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) - TEST_ERROR - - /* Reopen srcdset and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) { - HDgetcwd(buffer, 1024); - HDchdir(TMPDIR); - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) - TEST_ERROR - HDchdir(buffer); - } - if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset", H5P_DEFAULT)) < 0) - TEST_ERROR - } - - /* Read data directly from source dataset */ - HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) - TEST_ERROR - - /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) - TEST_ERROR - - /* Close */ - if(H5Dclose(vdset) < 0) - TEST_ERROR - vdset = -1; - if(H5Dclose(srcdset[0]) < 0) - TEST_ERROR - srcdset[0] = -1; - if(H5Fclose(srcfile[0]) < 0) - TEST_ERROR - srcfile[0] = -1; - if(H5Fclose(vfile) < 0) - TEST_ERROR - vfile = -1; - if(H5Sclose(srcspace[0]) < 0) - TEST_ERROR - srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) - TEST_ERROR - vspace[0] = -1; - if(H5Pclose(dapl) < 0) - TEST_ERROR - dapl = -1; - if(H5Pclose(dcpl) < 0) - TEST_ERROR - dcpl = -1; - - if(HDsetenv("HDF5_VDS_PREFIX", "", 1) < 0) - TEST_ERROR - PASSED(); return 0; @@ -1536,7 +1349,6 @@ test_vds_prefix(unsigned config, hid_t fapl) for(i = 0; i < (int)(sizeof(srcfile) / sizeof(srcfile[0])); i++) H5Fclose(srcfile[i]); H5Fclose(vfile); - H5Fclose(vfile2); for(i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) H5Sclose(srcspace[i]); for(i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) @@ -1550,7 +1362,7 @@ test_vds_prefix(unsigned config, hid_t fapl) TEST_ERROR return 1; -} /* end vds_link_prefix() */ +} /* end test_vds_prefix */ /*------------------------------------------------------------------------- @@ -11621,7 +11433,7 @@ main(void) for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); nerrors += test_basic_io(bit_config, fapl); - nerrors += test_vds_prefix(bit_config, fapl); + nerrors += test_vds_prefix_first(bit_config, fapl); nerrors += test_unlim(bit_config, fapl); nerrors += test_printf(bit_config, fapl); nerrors += test_all(bit_config, fapl); diff --git a/test/vds_env.c b/test/vds_env.c new file mode 100644 index 0000000..d73336d --- /dev/null +++ b/test/vds_env.c @@ -0,0 +1,326 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Neil Fortner + * Monday, February 16, 2015 + * + * Purpose: Tests datasets with virtual layout. + */ +#include "h5test.h" + +const char *FILENAME[] = { + "vds_virt_0", + "vds_virt_3", + "vds_src_2", + "vds%%_src2", + NULL +}; + +/* I/O test config flags */ +#define TEST_IO_CLOSE_SRC 0x01u +#define TEST_IO_DIFFERENT_FILE 0x02u +#define TEST_IO_REOPEN_VIRT 0x04u +#define TEST_IO_NTESTS 0x08u + +#define FILENAME_BUF_SIZE 1024 + +#define TMPDIR "tmp/" + +/*------------------------------------------------------------------------- + * Function: test_vds_prefix_second + * + * Purpose: Set up vds link prefix via H5Pset_virtual_prefix() to be "tmp" + * Should be able to access the target source files in tmp directory via the prefix set + * by H5Pset_virtual_prefix() + * + * Return: Success: 0 + * Failure: -1 + *------------------------------------------------------------------------- + */ +static int +test_vds_prefix_second(unsigned config, hid_t fapl) +{ + char srcfilename[FILENAME_BUF_SIZE]; + char srcfilename_map[FILENAME_BUF_SIZE]; + char vfilename[FILENAME_BUF_SIZE]; + char vfilename2[FILENAME_BUF_SIZE]; + char srcfilenamepct[FILENAME_BUF_SIZE]; + char srcfilenamepct_map[FILENAME_BUF_SIZE]; + const char *srcfilenamepct_map_orig = "vds%%%%_src"; + hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ + hid_t vfile = -1; /* File with virtual dset */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t dapl = -1; /* Dataset access property list */ + hid_t srcspace[4] = {-1, -1, -1, -1}; /* Source dataspaces */ + hid_t vspace[4] = {-1, -1, -1, -1}; /* Virtual dset dataspaces */ + hid_t memspace = -1; /* Memory dataspace */ + hid_t srcdset[4] = {-1, -1, -1, -1}; /* Source datsets */ + hid_t vdset = -1; /* Virtual dataset */ + hsize_t dims[4] = {10, 26, 0, 0}; /* Data space current size */ + int buf[10][26]; /* Write and expected read buffer */ + int rbuf[10][26]; /* Read buffer */ + int fill = -1; /* Fill value */ + int i, j; + char buffer[1024]; /* buffer to read vds_prefix */ + + TESTING("basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix") + + h5_fixname(FILENAME[0], fapl, vfilename, sizeof vfilename); + h5_fixname(FILENAME[1], fapl, vfilename2, sizeof vfilename2); + h5_fixname(FILENAME[2], fapl, srcfilename, sizeof srcfilename); + h5_fixname_printf(FILENAME[2], fapl, srcfilename_map, sizeof srcfilename_map); + h5_fixname(FILENAME[3], fapl, srcfilenamepct, sizeof srcfilenamepct); + h5_fixname_printf(srcfilenamepct_map_orig, fapl, srcfilenamepct_map, sizeof srcfilenamepct_map); + + /* create tmp directory and get current working directory path */ + if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + + /* Create DCPL */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + + /* Set fill value */ + if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) + TEST_ERROR + + /* Set prefix to a nonexistent directory, will be overwritten by environment variable */ + if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + TEST_ERROR + + if(H5Pset_virtual_prefix(dapl, "someprefix") < 0) + TEST_ERROR + if(H5Pget_virtual_prefix(dapl, buffer, sizeof(buffer)) < 0) + TEST_ERROR + + if(HDstrcmp(buffer, "someprefix") != 0) + FAIL_PUTS_ERROR("vds prefix not set correctly"); + + /* Create source dataspace */ + if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR + + /* Create virtual dataspace */ + if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR + + /* Select all (should not be necessary, but just to be sure) */ + if(H5Sselect_all(srcspace[0]) < 0) + TEST_ERROR + if(H5Sselect_all(vspace[0]) < 0) + TEST_ERROR + + /* Add virtual layout mapping */ + if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset", srcspace[0]) < 0) + TEST_ERROR + + /* Create virtual file */ + if((vfile = H5Fcreate(vfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + + /* Create source file if requested */ + if(config & TEST_IO_DIFFERENT_FILE) { + HDgetcwd(buffer, 1024); + HDchdir(TMPDIR); + if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + HDchdir(buffer); + } + else { + srcfile[0] = vfile; + if(H5Iinc_ref(srcfile[0]) < 0) + TEST_ERROR + } + + /* Create source dataset */ + if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Create virtual dataset */ + if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR + + /* Populate write buffer */ + for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; + + /* Write data directly to source dataset */ + if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + TEST_ERROR + + /* Close srcdset and srcfile if config option specified */ + if(config & TEST_IO_CLOSE_SRC) { + if(H5Dclose(srcdset[0]) < 0) + TEST_ERROR + srcdset[0] = -1; + + if(config & TEST_IO_DIFFERENT_FILE) { + if(H5Fclose(srcfile[0]) < 0) + TEST_ERROR + srcfile[0] = -1; + } + } + + /* Reopen virtual dataset and file if config option specified */ + if(config & TEST_IO_REOPEN_VIRT) { + if(H5Dclose(vdset) < 0) + TEST_ERROR + vdset = -1; + if(H5Fclose(vfile) < 0) + TEST_ERROR + vfile = -1; + if((vfile = H5Fopen(vfilename2, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR + if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + TEST_ERROR + } + + /* Read data through virtual dataset */ + HDmemset(rbuf[0], 0, sizeof(rbuf)); + if(H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + TEST_ERROR + + /* Verify read data */ + for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) { + for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if(rbuf[i][j] != buf[i][j]) { + TEST_ERROR + } + } + + /* Adjust write buffer */ + for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); + + /* Write data through virtual dataset */ + if(H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + TEST_ERROR + + /* Reopen srcdset and srcfile if config option specified */ + if(config & TEST_IO_CLOSE_SRC) { + if(config & TEST_IO_DIFFERENT_FILE) { + HDgetcwd(buffer, 1024); + HDchdir(TMPDIR); + if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR + HDchdir(buffer); + } + if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset", H5P_DEFAULT)) < 0) + TEST_ERROR + } + + /* Read data directly from source dataset */ + HDmemset(rbuf[0], 0, sizeof(rbuf)); + if(H5Dread(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + TEST_ERROR + + /* Verify read data */ + for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if(rbuf[i][j] != buf[i][j]) + TEST_ERROR + + /* Close */ + if(H5Dclose(vdset) < 0) + TEST_ERROR + vdset = -1; + if(H5Dclose(srcdset[0]) < 0) + TEST_ERROR + srcdset[0] = -1; + if(H5Fclose(srcfile[0]) < 0) + TEST_ERROR + srcfile[0] = -1; + if(H5Fclose(vfile) < 0) + TEST_ERROR + vfile = -1; + if(H5Sclose(srcspace[0]) < 0) + TEST_ERROR + srcspace[0] = -1; + if(H5Sclose(vspace[0]) < 0) + TEST_ERROR + vspace[0] = -1; + if(H5Pclose(dapl) < 0) + TEST_ERROR + dapl = -1; + if(H5Pclose(dcpl) < 0) + TEST_ERROR + dcpl = -1; + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + for(i = 0; i < (int)(sizeof(srcdset) / sizeof(srcdset[0])); i++) + H5Dclose(srcdset[i]); + H5Dclose(vdset); + for(i = 0; i < (int)(sizeof(srcfile) / sizeof(srcfile[0])); i++) + H5Fclose(srcfile[i]); + H5Fclose(vfile); + for(i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) + H5Sclose(srcspace[i]); + for(i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) + H5Sclose(vspace[i]); + H5Sclose(memspace); + H5Pclose(dapl); + H5Pclose(dcpl); + } H5E_END_TRY; + + return 1; +} /* end test_vds_prefix2 */ + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Tests datasets with virtual layout + * + * Return: EXIT_SUCCESS/EXIT_FAILURE + *------------------------------------------------------------------------- + */ +int +main(void) +{ + char filename[FILENAME_BUF_SIZE]; + hid_t fapl; + int test_api_config; + unsigned bit_config; + int nerrors = 0; + + /* Testing setup */ + h5_reset(); + fapl = h5_fileaccess(); + + for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { + HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); + nerrors += test_vds_prefix_second(bit_config, fapl); + } + + /* Verify symbol table messages are cached */ + nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); + + if(nerrors) + goto error; + HDprintf("All virtual dataset tests passed.\n"); + h5_cleanup(FILENAME, fapl); + + return EXIT_SUCCESS; + +error: + nerrors = MAX(1, nerrors); + HDprintf("***** %d VIRTUAL DATASET TEST%s FAILED! *****\n", + nerrors, 1 == nerrors ? "" : "S"); + return EXIT_FAILURE; +} /* end main() */ -- cgit v0.12 From 477dda3c0daea39cdf409684e7dad0fd9367dd45 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Tue, 9 Apr 2019 16:20:19 -0500 Subject: HDFFV-10658 - setting and getting properties in API context: 1. switched to use the existing H5F_prefix_open_t for enum type; 2. put the common private function used by external.c and external_env.c into external_common.c --- MANIFEST | 4 ++ src/H5Dint.c | 22 +++----- src/H5Fprivate.h | 7 ++- src/H5VLnative_dataset.c | 1 + test/Makefile.am | 4 +- test/external.h | 144 ----------------------------------------------- test/external_common.c | 121 +++++++++++++++++++++++++++++++++++++++ test/external_common.h | 45 +++++++++++++++ test/external_env.c | 9 ++- 9 files changed, 190 insertions(+), 167 deletions(-) delete mode 100644 test/external.h create mode 100644 test/external_common.c create mode 100644 test/external_common.h diff --git a/MANIFEST b/MANIFEST index 7cb2cfd..0a389a1 100644 --- a/MANIFEST +++ b/MANIFEST @@ -991,6 +991,9 @@ ./test/evict_on_close.c ./test/extend.c ./test/external.c +./test/external_common.c +./test/external_common.h +./test/external_env.c ./test/error_test.c ./test/err_compat.c ./test/filter_error.h5 @@ -1115,6 +1118,7 @@ ./test/tcoords.c ./test/testabort_fail.sh.in ./test/testcheck_version.sh.in +./test/testexternal_env.sh.in ./test/testerror.sh.in ./test/testlinks_env.sh.in ./test/test_filter_plugin.sh.in diff --git a/src/H5Dint.c b/src/H5Dint.c index 6ace085..208d879 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -43,12 +43,6 @@ /* Local Typedefs */ /******************/ -/* Type of prefix for file */ -typedef enum { - H5D_PREFIX_TYPE_UNKNOWN=0, - H5D_PREFIX_TYPE_EXT=1, - H5D_PREFIX_TYPE_VDS=2 -} H5D_prefix_type_t; /********************/ /* Local Prototypes */ @@ -60,7 +54,7 @@ static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, cons static herr_t H5D__cache_dataspace_info(const H5D_t *dset); static herr_t H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space); static herr_t H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id); -static herr_t H5D__build_file_prefix(const H5D_t *dset, H5D_prefix_type_t prefix_type, char **file_prefix); +static herr_t H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char **file_prefix); static herr_t H5D__open_oid(H5D_t *dataset, hid_t dapl_id); static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t old_dim[]); @@ -1094,7 +1088,7 @@ done: *-------------------------------------------------------------------------- */ static herr_t -H5D__build_file_prefix(const H5D_t *dset, H5D_prefix_type_t prefix_type, char **file_prefix /*out*/) +H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char **file_prefix /*out*/) { char *prefix = NULL; /* prefix used to look for the file */ char *filepath = NULL; /* absolute path of directory the HDF5 file is in */ @@ -1115,14 +1109,14 @@ H5D__build_file_prefix(const H5D_t *dset, H5D_prefix_type_t prefix_type, char ** /* XXX: Future thread-safety note - getenv is not required * to be reentrant. */ - if(H5D_PREFIX_TYPE_VDS == prefix_type) { + if(H5F_PREFIX_VDS == prefix_type) { prefix = (char *)H5D_prefix_vds_env; if(prefix == NULL || *prefix == '\0') { if(H5CX_get_vds_prefix(&prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for vds file") } - } else if(H5D_PREFIX_TYPE_EXT == prefix_type) { + } else if(H5F_PREFIX_EFILE == prefix_type) { prefix = (char *)H5D_prefix_ext_env; if(prefix == NULL || *prefix == '\0') { @@ -1338,11 +1332,11 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set up flush append property") /* Set the external file prefix */ - if(H5D__build_file_prefix(new_dset, H5D_PREFIX_TYPE_EXT, &new_dset->shared->extfile_prefix) < 0) + if(H5D__build_file_prefix(new_dset, H5F_PREFIX_EFILE, &new_dset->shared->extfile_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix") /* Set the VDS file prefix */ - if(H5D__build_file_prefix(new_dset, H5D_PREFIX_TYPE_VDS, &new_dset->shared->vds_prefix) < 0) + if(H5D__build_file_prefix(new_dset, H5F_PREFIX_VDS, &new_dset->shared->vds_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix") /* Add the dataset to the list of opened objects in the file */ @@ -1497,11 +1491,11 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy path") /* Get the external file prefix */ - if(H5D__build_file_prefix(dataset, H5D_PREFIX_TYPE_EXT, &extfile_prefix) < 0) + if(H5D__build_file_prefix(dataset, H5F_PREFIX_EFILE, &extfile_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix") /* Get the VDS prefix */ - if(H5D__build_file_prefix(dataset, H5D_PREFIX_TYPE_VDS, &vds_prefix) < 0) + if(H5D__build_file_prefix(dataset, H5F_PREFIX_VDS, &vds_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix") /* Check if dataset was already open */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index e3860a0..553e16b 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -702,8 +702,11 @@ typedef enum H5F_mem_page_t { /* Type of prefix for opening prefixed files */ typedef enum H5F_prefix_open_t { - H5F_PREFIX_VDS, /* Virtual dataset prefix */ - H5F_PREFIX_ELINK /* External link prefix */ + H5D_PREFIX_ERROR = -1, /* Error */ + H5F_PREFIX_VDS = 0, /* Virtual dataset prefix */ + H5F_PREFIX_ELINK = 1, /* External link prefix */ + H5F_PREFIX_EFILE = 2, /* External file prefix */ + H5F_PREFIX_NONE = 3 /* Must be the last */ } H5F_prefix_open_t; diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c index aa65e54..8f7351c 100644 --- a/src/H5VLnative_dataset.c +++ b/src/H5VLnative_dataset.c @@ -61,6 +61,7 @@ H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") + /* Get creation properties */ if(H5P_get(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") if(H5P_get(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) diff --git a/test/Makefile.am b/test/Makefile.am index 68b9394..55b5a88 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -63,7 +63,7 @@ TEST_PROG= testhdf5 \ flush1 flush2 app_ref enum set_extent ttsafe enc_dec_plist \ enc_dec_plist_cross_platform getname vfd ntypes dangle dtransform \ reserved cross_read freespace mf vds file_image unregister \ - cache_logging cork swmr vol + cache_logging cork swmr vol_tst # List programs to be built when testing here. # error_test and err_compat are built at the same time as the other tests, but executed by testerror.sh. @@ -135,7 +135,7 @@ else noinst_LTLIBRARIES=libh5test.la endif -libh5test_la_SOURCES=h5test.c testframe.c cache_common.c swmr_common.c +libh5test_la_SOURCES=h5test.c testframe.c cache_common.c swmr_common.c external_common.c # Use libhd5test.la to compile all of the tests LDADD=libh5test.la $(LIBHDF5) diff --git a/test/external.h b/test/external.h deleted file mode 100644 index 1c660e1..0000000 --- a/test/external.h +++ /dev/null @@ -1,144 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * 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. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Programmer: Quincey Koziol - * Wednesday, March 17, 2010 - * - * Purpose: srcdir querying support. - */ -#ifndef _EXTERNAL_H -#define _EXTERNAL_H - -/* Include test header files */ -#include "h5test.h" - -const char *FILENAME[] = { - "extern_1", - "extern_2", - "extern_3", - "extern_4", - "extern_dir/file_1", - "extern_5", - NULL -}; - -/* A similar collection of files is used for the tests that - * perform file I/O. - */ -#define N_EXT_FILES 4 -#define PART_SIZE 25 -#define TOTAL_SIZE 100 -#define GARBAGE_PER_FILE 10 - - -/*------------------------------------------------------------------------- - * Function: reset_raw_data_files - * - * Purpose: Resets the data in the raw data files for tests that - * perform dataset I/O on a set of files. - * - * Return: SUCCEED/FAIL - * - * Programmer: Dana Robinson - * February 2016 - * - *------------------------------------------------------------------------- - */ -static herr_t -reset_raw_data_files(void) -{ - int fd = 0; /* external file descriptor */ - size_t i, j; /* iterators */ - hssize_t n; /* bytes of I/O */ - char filename[1024]; /* file name */ - int data[PART_SIZE]; /* raw data buffer */ - uint8_t *garbage = NULL; /* buffer of garbage data */ - size_t garbage_count; /* size of garbage buffer */ - size_t garbage_bytes; /* # of garbage bytes written to file */ - - /* Set up garbage buffer */ - garbage_count = N_EXT_FILES * GARBAGE_PER_FILE; - if(NULL == (garbage = (uint8_t *)HDcalloc(garbage_count, sizeof(uint8_t)))) - goto error; - for(i = 0; i < garbage_count; i++) - garbage[i] = 0xFF; - - /* The *r files are pre-filled with data and are used to - * verify that read operations work correctly. - */ - for(i = 0; i < N_EXT_FILES; i++) { - - /* Open file */ - HDsprintf(filename, "extern_%lur.raw", (unsigned long)i + 1); - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) - goto error; - - /* Write garbage data to the file. This allows us to test the - * the ability to set an offset in the raw data file. - */ - garbage_bytes = i * 10; - n = HDwrite(fd, garbage, garbage_bytes); - if(n < 0 || (size_t)n != garbage_bytes) - goto error; - - /* Fill array with data */ - for(j = 0; j < PART_SIZE; j++) { - data[j] = (int)(i * 25 + j); - } /* end for */ - - /* Write raw data to the file. */ - n = HDwrite(fd, data, sizeof(data)); - if(n != sizeof(data)) - goto error; - - /* Close this file */ - HDclose(fd); - - } /* end for */ - - /* The *w files are only pre-filled with the garbage data and are - * used to verify that write operations work correctly. The individual - * tests fill in the actual data. - */ - for(i = 0; i < N_EXT_FILES; i++) { - - /* Open file */ - HDsprintf(filename, "extern_%luw.raw", (unsigned long)i + 1); - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) - goto error; - - /* Write garbage data to the file. This allows us to test the - * the ability to set an offset in the raw data file. - */ - garbage_bytes = i * 10; - n = HDwrite(fd, garbage, garbage_bytes); - if(n < 0 || (size_t)n != garbage_bytes) - goto error; - - /* Close this file */ - HDclose(fd); - - } /* end for */ - HDfree(garbage); - return SUCCEED; - -error: - if(fd) - HDclose(fd); - if(garbage) - HDfree(garbage); - return FAIL; -} /* end reset_raw_data_files() */ -#endif /* _EXTERNAL_H */ - diff --git a/test/external_common.c b/test/external_common.c new file mode 100644 index 0000000..e43a713 --- /dev/null +++ b/test/external_common.c @@ -0,0 +1,121 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Raymond Lu + * April, 2019 + * + * Purpose: Private function for external.c and external_env.c + */ + +#include "external_common.h" + + +/*------------------------------------------------------------------------- + * Function: reset_raw_data_files + * + * Purpose: Resets the data in the raw data files for tests that + * perform dataset I/O on a set of files. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * February 2016 + * + *------------------------------------------------------------------------- + */ +herr_t +reset_raw_data_files(void) +{ + int fd = 0; /* external file descriptor */ + size_t i, j; /* iterators */ + hssize_t n; /* bytes of I/O */ + char filename[1024]; /* file name */ + int data[PART_SIZE]; /* raw data buffer */ + uint8_t *garbage = NULL; /* buffer of garbage data */ + size_t garbage_count; /* size of garbage buffer */ + size_t garbage_bytes; /* # of garbage bytes written to file */ + + /* Set up garbage buffer */ + garbage_count = N_EXT_FILES * GARBAGE_PER_FILE; + if(NULL == (garbage = (uint8_t *)HDcalloc(garbage_count, sizeof(uint8_t)))) + goto error; + for(i = 0; i < garbage_count; i++) + garbage[i] = 0xFF; + + /* The *r files are pre-filled with data and are used to + * verify that read operations work correctly. + */ + for(i = 0; i < N_EXT_FILES; i++) { + + /* Open file */ + HDsprintf(filename, "extern_%lur.raw", (unsigned long)i + 1); + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) + goto error; + + /* Write garbage data to the file. This allows us to test the + * the ability to set an offset in the raw data file. + */ + garbage_bytes = i * 10; + n = HDwrite(fd, garbage, garbage_bytes); + if(n < 0 || (size_t)n != garbage_bytes) + goto error; + + /* Fill array with data */ + for(j = 0; j < PART_SIZE; j++) { + data[j] = (int)(i * 25 + j); + } /* end for */ + + /* Write raw data to the file. */ + n = HDwrite(fd, data, sizeof(data)); + if(n != sizeof(data)) + goto error; + + /* Close this file */ + HDclose(fd); + + } /* end for */ + + /* The *w files are only pre-filled with the garbage data and are + * used to verify that write operations work correctly. The individual + * tests fill in the actual data. + */ + for(i = 0; i < N_EXT_FILES; i++) { + + /* Open file */ + HDsprintf(filename, "extern_%luw.raw", (unsigned long)i + 1); + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) + goto error; + + /* Write garbage data to the file. This allows us to test the + * the ability to set an offset in the raw data file. + */ + garbage_bytes = i * 10; + n = HDwrite(fd, garbage, garbage_bytes); + if(n < 0 || (size_t)n != garbage_bytes) + goto error; + + /* Close this file */ + HDclose(fd); + + } /* end for */ + HDfree(garbage); + return SUCCEED; + +error: + if(fd) + HDclose(fd); + if(garbage) + HDfree(garbage); + return FAIL; +} diff --git a/test/external_common.h b/test/external_common.h new file mode 100644 index 0000000..f1a15b5 --- /dev/null +++ b/test/external_common.h @@ -0,0 +1,45 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Raymond Lu + * April, 2019 + * + * Purpose: Private function for external.c and external_env.c + */ +#ifndef _EXTERNAL_COMMON_H +#define _EXTERNAL_COMMON_H + +/* Include test header files */ +#include "h5test.h" + +static const char *EXT_FNAME[] = { + "extern_1", + "extern_2", + "extern_3", + "extern_4", + "extern_dir/file_1", + "extern_5", + NULL +}; + +/* A similar collection of files is used for the tests that + * perform file I/O. + */ +#define N_EXT_FILES 4 +#define PART_SIZE 25 +#define TOTAL_SIZE 100 +#define GARBAGE_PER_FILE 10 + +herr_t reset_raw_data_files(void); +#endif /* _EXTERNAL_COMMON_H */ diff --git a/test/external_env.c b/test/external_env.c index 97daef2..2f5f838 100644 --- a/test/external_env.c +++ b/test/external_env.c @@ -17,8 +17,7 @@ * * Purpose: Tests datasets stored in external raw files. */ -#include "h5test.h" -#include "external.h" +#include "external_common.h" /*------------------------------------------------------------------------- @@ -63,7 +62,7 @@ test_path_env(hid_t fapl) if(HDmkdir("extern_dir", (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR; - h5_fixname(FILENAME[4], fapl, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[4], fapl, filename, sizeof(filename)); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR @@ -156,7 +155,7 @@ main(void) /* Get a fapl for the old (default) file format */ fapl_id_old = h5_fileaccess(); - h5_fixname(FILENAME[0], fapl_id_old, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[0], fapl_id_old, filename, sizeof(filename)); /* Copy and set up a fapl for the latest file format */ if((fapl_id_new = H5Pcopy(fapl_id_old)) < 0) @@ -189,7 +188,7 @@ main(void) HDputs("All external storage tests passed."); /* Clean up files used by file set tests */ - if(h5_cleanup(FILENAME, fapl_id_old)) { + if(h5_cleanup(EXT_FNAME, fapl_id_old)) { HDremove("extern_1r.raw"); HDremove("extern_2r.raw"); HDremove("extern_3r.raw"); -- cgit v0.12 From 04d07d967a12f6aeeb4fa5bee99526ab328b509a Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Tue, 9 Apr 2019 17:40:24 -0500 Subject: Left out this file in previous commit. --- test/external.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/test/external.c b/test/external.c index 5ff65e6..af45445 100644 --- a/test/external.c +++ b/test/external.c @@ -17,8 +17,7 @@ * * Purpose: Tests datasets stored in external raw files. */ -#include "h5test.h" -#include "external.h" +#include "external_common.h" /*------------------------------------------------------------------------- @@ -643,7 +642,7 @@ test_read_file_set(hid_t fapl) * debugging to be emitted before we start playing games with what the * output looks like. */ - h5_fixname(FILENAME[1], fapl, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[1], fapl, filename, sizeof(filename)); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR if((grp = H5Gcreate2(file, "emit-diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -754,7 +753,7 @@ test_write_file_set(hid_t fapl) TEST_ERROR /* Create another file */ - h5_fixname(FILENAME[2], fapl, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[2], fapl, filename, sizeof(filename)); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR @@ -872,7 +871,7 @@ test_path_absolute(hid_t fapl) TESTING("absolute filenames for external file"); - h5_fixname(FILENAME[3], fapl, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[3], fapl, filename, sizeof(filename)); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR @@ -968,7 +967,7 @@ test_path_relative(hid_t fapl) if (HDmkdir("extern_dir", (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR; - h5_fixname(FILENAME[4], fapl, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[4], fapl, filename, sizeof(filename)); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR; @@ -1063,7 +1062,7 @@ test_path_relative_cwd(hid_t fapl) if(HDmkdir("extern_dir", (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR; - h5_fixname(FILENAME[4], fapl, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[4], fapl, filename, sizeof(filename)); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR; @@ -1214,7 +1213,7 @@ test_h5d_get_access_plist(hid_t fapl_id) TEST_ERROR /* Create the file */ - h5_fixname(FILENAME[5], fapl_id, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[5], fapl_id, filename, sizeof(filename)); if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) FAIL_STACK_ERROR @@ -1305,7 +1304,7 @@ main(void) /* Get a fapl for the old (default) file format */ fapl_id_old = h5_fileaccess(); - h5_fixname(FILENAME[0], fapl_id_old, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[0], fapl_id_old, filename, sizeof(filename)); /* Copy and set up a fapl for the latest file format */ if((fapl_id_new = H5Pcopy(fapl_id_old)) < 0) @@ -1360,7 +1359,7 @@ main(void) nerrors += test_path_relative_cwd(current_fapl_id); /* Verify symbol table messages are cached */ - nerrors += (h5_verify_cached_stabs(FILENAME, current_fapl_id) < 0 ? 1 : 0); + nerrors += (h5_verify_cached_stabs(EXT_FNAME, current_fapl_id) < 0 ? 1 : 0); /* Close the common file */ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR @@ -1375,7 +1374,7 @@ main(void) HDputs("All external storage tests passed."); /* Clean up files used by file set tests */ - if(h5_cleanup(FILENAME, fapl_id_old)) { + if(h5_cleanup(EXT_FNAME, fapl_id_old)) { HDremove("extern_1r.raw"); HDremove("extern_2r.raw"); HDremove("extern_3r.raw"); -- cgit v0.12 From 06002f8c22b46d69cf4951eba0bbca946955c0d0 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 10 Apr 2019 10:21:38 -0500 Subject: Minor fixes: updating the test vds_env.c according to the set up of vds.c. --- src/H5Fprivate.h | 2 +- test/vds_env.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 553e16b..80d7229 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -702,7 +702,7 @@ typedef enum H5F_mem_page_t { /* Type of prefix for opening prefixed files */ typedef enum H5F_prefix_open_t { - H5D_PREFIX_ERROR = -1, /* Error */ + H5F_PREFIX_ERROR = -1, /* Error */ H5F_PREFIX_VDS = 0, /* Virtual dataset prefix */ H5F_PREFIX_ELINK = 1, /* External link prefix */ H5F_PREFIX_EFILE = 2, /* External file prefix */ diff --git a/test/vds_env.c b/test/vds_env.c index d73336d..b42bb00 100644 --- a/test/vds_env.c +++ b/test/vds_env.c @@ -294,22 +294,62 @@ int main(void) { char filename[FILENAME_BUF_SIZE]; - hid_t fapl; + hid_t fapl, my_fapl; int test_api_config; unsigned bit_config; + H5F_libver_t low, high; /* Low and high bounds */ + unsigned latest = FALSE; /* Using the latest library version bound */ int nerrors = 0; /* Testing setup */ h5_reset(); fapl = h5_fileaccess(); - for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { - HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); - nerrors += test_vds_prefix_second(bit_config, fapl); - } + /* Set to use the latest file format */ + if((my_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR + + /* Loop through all the combinations of low/high version bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + char msg[80]; /* Message for file version bounds */ + char *low_string; /* The low bound string */ + char *high_string; /* The high bound string */ + + /* Invalid combinations, just continue */ + if(high == H5F_LIBVER_EARLIEST || high < low) + continue; + + /* Test virtual dataset only for V110 and above */ + if(high < H5F_LIBVER_V110) + continue; + + /* Whether to use latest hyperslab/point selection version */ + if(low >= H5F_LIBVER_V112) + latest = TRUE; + + /* Set the low/high version bounds */ + if(H5Pset_libver_bounds(my_fapl, low, high) < 0) + TEST_ERROR - /* Verify symbol table messages are cached */ - nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); + /* Display testing info */ + low_string = h5_get_version_string(low); + high_string = h5_get_version_string(high); + HDsprintf(msg, "Testing virtual dataset with file version bounds: (%s, %s):", low_string, high_string); + HDputs(msg); + + for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { + HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); + nerrors += test_vds_prefix_second(bit_config, fapl); + } + + /* Verify symbol table messages are cached */ + nerrors += (h5_verify_cached_stabs(FILENAME, my_fapl) < 0 ? 1 : 0); + + } /* end for high */ + } /* end for low */ + + if(H5Pclose(my_fapl) < 0) + TEST_ERROR if(nerrors) goto error; -- cgit v0.12 From bf6479fcee4cb05302f5733d6e81667b0c3d4273 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 10 Apr 2019 11:22:24 -0500 Subject: Minor fix: removal of unnecessary enum values. --- src/H5Fprivate.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 80d7229..0fa2214 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -702,11 +702,9 @@ typedef enum H5F_mem_page_t { /* Type of prefix for opening prefixed files */ typedef enum H5F_prefix_open_t { - H5F_PREFIX_ERROR = -1, /* Error */ H5F_PREFIX_VDS = 0, /* Virtual dataset prefix */ H5F_PREFIX_ELINK = 1, /* External link prefix */ - H5F_PREFIX_EFILE = 2, /* External file prefix */ - H5F_PREFIX_NONE = 3 /* Must be the last */ + H5F_PREFIX_EFILE = 2 /* External file prefix */ } H5F_prefix_open_t; -- cgit v0.12 From 417cd9da87a7854148c1db1755531af6818a613e Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 10 Apr 2019 16:02:28 -0500 Subject: Updated CMake for the splitting of external.c and vds.c. --- test/CMakeLists.txt | 2 + test/CMakeTests.cmake | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 772f790..f335fa2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -236,6 +236,7 @@ set (H5_TESTS extend direct_chunk # compression lib link external + external_env efc objcopy links @@ -255,6 +256,7 @@ set (H5_TESTS enc_dec_plist_cross_platform getname vfd + vfd_env ntypes dangle dtransform diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index c606eb1..40984b5 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -542,8 +542,10 @@ set (H5TEST_SEPARATE_TESTS testhdf5 cache cache_image + external_env flush1 flush2 + vds_env ) foreach (h5_test ${H5_TESTS}) if (NOT h5_test IN_LIST H5TEST_SEPARATE_TESTS) @@ -679,6 +681,49 @@ set_tests_properties (H5TEST-cache_image PROPERTIES ) endif () +#-- Adding test for external_env +add_test ( + NAME H5TEST-clear-external_env-objects + COMMAND ${CMAKE_COMMAND} + -E remove + extern_1r.raw + extern_2r.raw + extern_3r.raw + extern_4r.raw + extern_1w.raw + extern_2w.raw + extern_3w.raw + extern_4w.raw + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST +) +set_tests_properties (H5TEST-clear-external_env-objects PROPERTIES FIXTURES_SETUP external_env_clear_objects) +add_test (NAME H5TEST-external_env COMMAND $) +set_tests_properties (H5TEST-external_env PROPERTIES + FIXTURES_REQUIRED external_env_clear_objects + ENVIRONMENT "HDF5_EXTFILE_PREFIX=\${ORIGIN}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST +) + +#-- Adding test for vds_env +add_test ( + NAME H5TEST-clear-vds_env-objects + COMMAND ${CMAKE_COMMAND} + -E remove + vds_virt_0.h5 + vds_virt_3.h5 + vds_src_2.h5 + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST +) +set_tests_properties (H5TEST-clear-vds_env-objects PROPERTIES FIXTURES_SETUP vds_env_clear_objects) +add_test (NAME H5TEST-vds_env COMMAND $) +set_tests_properties (H5TEST-vds_env PROPERTIES + FIXTURES_REQUIRED vds_env_clear_objects + ENVIRONMENT "HDF5_VDS_PREFIX=\${ORIGIN}/tmp" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST +) + if (BUILD_SHARED_LIBS) #-- Adding test for cache if (NOT CYGWIN AND NOT WIN32) @@ -1041,6 +1086,67 @@ if (BUILD_SHARED_LIBS) WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared ) + #-- Adding test for external_env + add_test (NAME H5TEST-shared-clear-external_env-objects + COMMAND ${CMAKE_COMMAND} + -E remove + extern_1r.raw + extern_2r.raw + extern_3r.raw + extern_4r.raw + extern_1w.raw + extern_2w.raw + extern_3w.raw + extern_4w.raw + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + set_tests_properties (H5TEST-shared-clear-external_env-objects PROPERTIES FIXTURES_SETUP shared_external_env_clear_objects) + add_test (NAME H5TEST-shared-external_env COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_ENV_VAR:STRING=HDF5_EXTFILE_PREFIX" + -D "TEST_ENV_VALUE:STRING=\${ORIGIN}" + -D "TEST_EXPECT=0" + -D "TEST_OUTPUT=external_env.txt" + -D "TEST_REFERENCE=external_env.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST-shared" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5TEST-shared-external_env PROPERTIES + FIXTURES_REQUIRED shared_external_env_clear_objects + ENVIRONMENT "HDF5_EXTFILE_PREFIX=\${ORIGIN}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + + #-- Adding test for vds_env + add_test (NAME H5TEST-shared-clear-vds_env-objects + COMMAND ${CMAKE_COMMAND} + -E remove + vds_virt_0.h5 + vds_virt_3.h5 + vds_src_2.h5 + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + set_tests_properties (H5TEST-shared-clear-vds_env-objects PROPERTIES FIXTURES_SETUP shared_vds_env_clear_objects) + add_test (NAME H5TEST-shared-vds_env COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_ENV_VAR:STRING=HDF5_VDS_PREFIX" + -D "TEST_ENV_VALUE:STRING=\${ORIGIN}/tmp" + -D "TEST_EXPECT=0" + -D "TEST_OUTPUT=vds_env.txt" + -D "TEST_REFERENCE=vds_env.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST-shared" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5TEST-shared-vds_env PROPERTIES + FIXTURES_REQUIRED shared_vds_env_clear_objects + ENVIRONMENT "HDF5_VDS_PREFIX=\${ORIGIN}/tmp" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + #-- Adding test for libinfo add_test (NAME H5TEST-shared-testlibinfo COMMAND ${CMAKE_COMMAND} -D "TEST_PROGRAM=$" -P "${GREP_RUNNER}" -- cgit v0.12 From c0e05f07470df35b5ceeebdf242cb830058713ab Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 10 Apr 2019 16:48:42 -0500 Subject: Forgot to add external_common.c and external_common.h. --- test/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f335fa2..8437e72 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -14,12 +14,14 @@ set (TEST_LIB_SOURCES ${HDF5_TEST_SOURCE_DIR}/h5test.c ${HDF5_TEST_SOURCE_DIR}/testframe.c ${HDF5_TEST_SOURCE_DIR}/cache_common.c + ${HDF5_TEST_SOURCE_DIR}/external_common.c ${HDF5_TEST_SOURCE_DIR}/swmr_common.c ) set (TEST_LIB_HEADERS ${HDF5_TEST_SOURCE_DIR}/h5test.h ${HDF5_TEST_SOURCE_DIR}/cache_common.h + ${HDF5_TEST_SOURCE_DIR}/external_common.h ${HDF5_TEST_SOURCE_DIR}/swmr_common.h ) -- cgit v0.12 From a58c01aac18bc68be22296c51c3d327d1220ce28 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Thu, 11 Apr 2019 10:19:45 -0500 Subject: Small correction for my previous commit. --- test/CMakeTests.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index 40984b5..b5120d8 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -1115,7 +1115,7 @@ if (BUILD_SHARED_LIBS) ) set_tests_properties (H5TEST-shared-external_env PROPERTIES FIXTURES_REQUIRED shared_external_env_clear_objects - ENVIRONMENT "HDF5_EXTFILE_PREFIX=\${ORIGIN}" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared ) @@ -1143,7 +1143,7 @@ if (BUILD_SHARED_LIBS) ) set_tests_properties (H5TEST-shared-vds_env PROPERTIES FIXTURES_REQUIRED shared_vds_env_clear_objects - ENVIRONMENT "HDF5_VDS_PREFIX=\${ORIGIN}/tmp" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared ) -- cgit v0.12 From c3c3c1e1426e4f2b8229ad8fe5cc4416a1156da5 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Thu, 11 Apr 2019 12:59:07 -0500 Subject: Adding the standard output files for the external_env.c and vds_env.c tests. --- test/CMakeTests.cmake | 26 ++++++++- test/testfiles/external_env.out | 8 +++ test/testfiles/vds_env.out | 122 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 test/testfiles/external_env.out create mode 100644 test/testfiles/vds_env.out diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index b5120d8..4a35c15 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -685,6 +685,15 @@ endif () add_test ( NAME H5TEST-clear-external_env-objects COMMAND ${CMAKE_COMMAND} + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_ENV_VAR:STRING=HDF5_EXTFILE_PREFIX" + -D "TEST_ENV_VALUE:STRING=\${ORIGIN}" + -D "TEST_EXPECT=0" + -D "TEST_OUTPUT=external_env.txt" + -D "TEST_REFERENCE=external_env.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" -E remove extern_1r.raw extern_2r.raw @@ -694,6 +703,8 @@ add_test ( extern_2w.raw extern_3w.raw extern_4w.raw + external_env.txt + external_env.out WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) @@ -701,7 +712,7 @@ set_tests_properties (H5TEST-clear-external_env-objects PROPERTIES FIXTURES_SETU add_test (NAME H5TEST-external_env COMMAND $) set_tests_properties (H5TEST-external_env PROPERTIES FIXTURES_REQUIRED external_env_clear_objects - ENVIRONMENT "HDF5_EXTFILE_PREFIX=\${ORIGIN}" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) @@ -709,10 +720,21 @@ set_tests_properties (H5TEST-external_env PROPERTIES add_test ( NAME H5TEST-clear-vds_env-objects COMMAND ${CMAKE_COMMAND} + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_ENV_VAR:STRING=HDF5_VDS_PREFIX" + -D "TEST_ENV_VALUE:STRING=\${ORIGIN}/tmp" + -D "TEST_EXPECT=0" + -D "TEST_OUTPUT=vds_env.txt" + -D "TEST_REFERENCE=vds_env.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" -E remove vds_virt_0.h5 vds_virt_3.h5 vds_src_2.h5 + vds_env.txt + vds_env.out WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) @@ -720,7 +742,7 @@ set_tests_properties (H5TEST-clear-vds_env-objects PROPERTIES FIXTURES_SETUP vds add_test (NAME H5TEST-vds_env COMMAND $) set_tests_properties (H5TEST-vds_env PROPERTIES FIXTURES_REQUIRED vds_env_clear_objects - ENVIRONMENT "HDF5_VDS_PREFIX=\${ORIGIN}/tmp" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) diff --git a/test/testfiles/external_env.out b/test/testfiles/external_env.out new file mode 100644 index 0000000..9c64982 --- /dev/null +++ b/test/testfiles/external_env.out @@ -0,0 +1,8 @@ +Testing external file with HDF5_EXTFILE_PREFIX +Testing with the default file format: +Testing prefix in HDF5_EXTFILE_PREFIX PASSED + +Testing with the latest file format: +Testing prefix in HDF5_EXTFILE_PREFIX PASSED +All external storage tests passed. +Test prefix for HDF5_EXTFILE_PREFIX PASSED diff --git a/test/testfiles/vds_env.out b/test/testfiles/vds_env.out new file mode 100644 index 0000000..834cdd8 --- /dev/null +++ b/test/testfiles/vds_env.out @@ -0,0 +1,122 @@ +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix +Testing virtual dataset with file version bounds: (earliest, v110): +Config: same source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, same source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: different source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, different source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: same source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, same source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: different source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, different source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Testing virtual dataset with file version bounds: (earliest, latest): +Config: same source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, same source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: different source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, different source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: same source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, same source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: different source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, different source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Testing virtual dataset with file version bounds: (v18, v110): +Config: same source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, same source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: different source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, different source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: same source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, same source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: different source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, different source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Testing virtual dataset with file version bounds: (v18, latest): +Config: same source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, same source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: different source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, different source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: same source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, same source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: different source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, different source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Testing virtual dataset with file version bounds: (v110, v110): +Config: same source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, same source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: different source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, different source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: same source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, same source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: different source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, different source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Testing virtual dataset with file version bounds: (v110, latest): +Config: same source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, same source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: different source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, different source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: same source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, same source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: different source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, different source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Testing virtual dataset with file version bounds: (latest, latest): +Config: same source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, same source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: different source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, different source file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: same source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, same source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: different source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +Config: closed source dataset, different source file, reopen virtual file +Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED +All virtual dataset tests passed. +Test prefix for HDF5_VDS_PREFIX PASSED -- cgit v0.12 From 1d1e96f1dd7a6f7272260ad6f0e1b3a426e5c54c Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Thu, 11 Apr 2019 15:51:21 -0500 Subject: Some coding style changes. --- MANIFEST | 2 ++ test/Makefile.am | 4 ++-- test/external_env.c | 3 --- test/testexternal_env.sh.in | 6 +++--- test/testvds_env.sh.in | 8 ++++---- test/vds_env.c | 2 +- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/MANIFEST b/MANIFEST index 358eeb6..4e66abf 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1135,6 +1135,7 @@ ./test/testmeta.c ./test/testswmr.sh.in ./test/testvdsswmr.sh.in +./test/testvds_env.sh.in ./test/tfile.c ./test/tgenprop.c ./test/th5o.c @@ -1174,6 +1175,7 @@ ./test/use_disable_mdc_flushes.c ./test/use.h ./test/vds.c +./test/vds_env.c ./test/vds_swmr.h ./test/vds_swmr_gen.c ./test/vds_swmr_reader.c diff --git a/test/Makefile.am b/test/Makefile.am index 55b5a88..1b82aa4 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -28,7 +28,7 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_builddir)/src # testlinks_env.sh: links_env # testexternal_env.sh: external_env # testflushrefresh.sh: flushrefresh -# testvds_env.sh: vds_env +# testvds_env.sh: vds_env # testswmr.sh: swmr* # testvdsswmr.sh: vds_swmr* # testabort_fail.sh: filenotclosed.c and del_many_dense_attrs.c @@ -63,7 +63,7 @@ TEST_PROG= testhdf5 \ flush1 flush2 app_ref enum set_extent ttsafe enc_dec_plist \ enc_dec_plist_cross_platform getname vfd ntypes dangle dtransform \ reserved cross_read freespace mf vds file_image unregister \ - cache_logging cork swmr vol_tst + cache_logging cork swmr vol # List programs to be built when testing here. # error_test and err_compat are built at the same time as the other tests, but executed by testerror.sh. diff --git a/test/external_env.c b/test/external_env.c index 2f5f838..0f8c9ec 100644 --- a/test/external_env.c +++ b/test/external_env.c @@ -12,9 +12,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke - * Tuesday, March 3, 1998 - * * Purpose: Tests datasets stored in external raw files. */ #include "external_common.h" diff --git a/test/testexternal_env.sh.in b/test/testexternal_env.sh.in index dff3851..3cc140d 100644 --- a/test/testexternal_env.sh.in +++ b/test/testexternal_env.sh.in @@ -25,9 +25,9 @@ nerrors=0 # test for external file with HDF5_EXTFILE_PREFIX echo "Testing external file with HDF5_EXTFILE_PREFIX" -TEST_NAME=external_env # The test name -TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary -ENVCMD="env HDF5_EXTFILE_PREFIX=\${ORIGIN}" # The environment variable & value +TEST_NAME=external_env # The test name +TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary +ENVCMD="env HDF5_EXTFILE_PREFIX=\${ORIGIN}" # The environment variable & value # # Run the test # echo "$ENVCMD $RUNSERIAL $TEST_BIN" diff --git a/test/testvds_env.sh.in b/test/testvds_env.sh.in index 870f2eb..894e52e 100644 --- a/test/testvds_env.sh.in +++ b/test/testvds_env.sh.in @@ -25,10 +25,10 @@ nerrors=0 # test for VDS with HDF5_VDS_PREFIX echo "Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix" -TEST_NAME=vds_env # The test name -TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary -ENVCMD="env HDF5_VDS_PREFIX=\${ORIGIN}/tmp" # Set the environment variable & value -UNENVCMD="unset HDF5_VDS_PREFIX" # Unset the environment variable & value +TEST_NAME=vds_env # The test name +TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary +ENVCMD="env HDF5_VDS_PREFIX=\${ORIGIN}/tmp" # Set the environment variable & value +UNENVCMD="unset HDF5_VDS_PREFIX" # Unset the environment variable & value # # Run the test # echo "$ENVCMD $RUNSERIAL $TEST_BIN" diff --git a/test/vds_env.c b/test/vds_env.c index b42bb00..4ee8096 100644 --- a/test/vds_env.c +++ b/test/vds_env.c @@ -309,7 +309,7 @@ main(void) if((my_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR /* Loop through all the combinations of low/high version bounds */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; H5_INC_ENUM(H5F_libver_t, low)) { for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { char msg[80]; /* Message for file version bounds */ char *low_string; /* The low bound string */ -- cgit v0.12 From 6e8bd1280ad1582c126d64d880f858251add1251 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Thu, 11 Apr 2019 16:10:54 -0500 Subject: Adding some comments. --- src/H5CX.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/H5CX.c b/src/H5CX.c index c78d508..5474b63 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -287,10 +287,10 @@ typedef struct H5CX_t { hbool_t do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */ /* Cached DAPL properties */ - char *extfile_prefix; - hbool_t extfile_prefix_valid; - char *vds_prefix; - hbool_t vds_prefix_valid; + char *extfile_prefix; /* Prefix for external file */ + hbool_t extfile_prefix_valid; /* Whether the prefix for external file is valid */ + char *vds_prefix; /* Prefix for VDS */ + hbool_t vds_prefix_valid; /* Whether the prefix for VDS is valid */ /* Cached FAPL properties */ H5F_libver_t low_bound; /* low_bound property for H5Pset_libver_bounds() */ @@ -361,8 +361,8 @@ typedef struct H5CX_dcpl_cache_t { /* Typedef for cached default dataset access property list information */ /* (Same as the cached DXPL struct, above, except for the default DXPL) */ typedef struct H5CX_dapl_cache_t { - char *extfile_prefix; - char *vds_prefix; + char *extfile_prefix; /* Prefix for external file */ + char *vds_prefix; /* Prefix for VDS */ } H5CX_dapl_cache_t; /* Typedef for cached default file access property list information */ -- cgit v0.12 From d6ada6ff1f263a66ecd6510044160b36c58126eb Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Thu, 11 Apr 2019 16:50:06 -0500 Subject: Taking out unnecessary diff files for output. --- test/testfiles/links_env.out | 3 -- test/testfiles/vds_env.out | 122 ------------------------------------------- test/vds_env.c | 2 +- 3 files changed, 1 insertion(+), 126 deletions(-) delete mode 100644 test/testfiles/links_env.out delete mode 100644 test/testfiles/vds_env.out diff --git a/test/testfiles/links_env.out b/test/testfiles/links_env.out deleted file mode 100644 index 3f10fc6..0000000 --- a/test/testfiles/links_env.out +++ /dev/null @@ -1,3 +0,0 @@ -Testing external links via environment variable PASSED -Testing external links via environment variable (w/new group format) PASSED -All external Link (HDF5_EXT_PREFIX) tests passed. diff --git a/test/testfiles/vds_env.out b/test/testfiles/vds_env.out deleted file mode 100644 index 834cdd8..0000000 --- a/test/testfiles/vds_env.out +++ /dev/null @@ -1,122 +0,0 @@ -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix -Testing virtual dataset with file version bounds: (earliest, v110): -Config: same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Testing virtual dataset with file version bounds: (earliest, latest): -Config: same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Testing virtual dataset with file version bounds: (v18, v110): -Config: same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Testing virtual dataset with file version bounds: (v18, latest): -Config: same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Testing virtual dataset with file version bounds: (v110, v110): -Config: same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Testing virtual dataset with file version bounds: (v110, latest): -Config: same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Testing virtual dataset with file version bounds: (latest, latest): -Config: same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -All virtual dataset tests passed. -Test prefix for HDF5_VDS_PREFIX PASSED diff --git a/test/vds_env.c b/test/vds_env.c index 4ee8096..55e4c85 100644 --- a/test/vds_env.c +++ b/test/vds_env.c @@ -310,7 +310,7 @@ main(void) /* Loop through all the combinations of low/high version bounds */ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; H5_INC_ENUM(H5F_libver_t, low)) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; H5_INC_ENUM(H5F_libver_t, high)) { char msg[80]; /* Message for file version bounds */ char *low_string; /* The low bound string */ char *high_string; /* The high bound string */ -- cgit v0.12 From 02434491883d389344f2d67ec7a0251a844cb6af Mon Sep 17 00:00:00 2001 From: songyulu Date: Thu, 11 Apr 2019 17:23:04 -0500 Subject: Taking out two unnecessary diff output files. --- test/testfiles/external_env.out | 8 --- test/testfiles/vds_env.out | 122 ---------------------------------------- test/vds_env.c | 2 +- 3 files changed, 1 insertion(+), 131 deletions(-) delete mode 100644 test/testfiles/external_env.out delete mode 100644 test/testfiles/vds_env.out diff --git a/test/testfiles/external_env.out b/test/testfiles/external_env.out deleted file mode 100644 index 9c64982..0000000 --- a/test/testfiles/external_env.out +++ /dev/null @@ -1,8 +0,0 @@ -Testing external file with HDF5_EXTFILE_PREFIX -Testing with the default file format: -Testing prefix in HDF5_EXTFILE_PREFIX PASSED - -Testing with the latest file format: -Testing prefix in HDF5_EXTFILE_PREFIX PASSED -All external storage tests passed. -Test prefix for HDF5_EXTFILE_PREFIX PASSED diff --git a/test/testfiles/vds_env.out b/test/testfiles/vds_env.out deleted file mode 100644 index 834cdd8..0000000 --- a/test/testfiles/vds_env.out +++ /dev/null @@ -1,122 +0,0 @@ -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix -Testing virtual dataset with file version bounds: (earliest, v110): -Config: same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Testing virtual dataset with file version bounds: (earliest, latest): -Config: same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Testing virtual dataset with file version bounds: (v18, v110): -Config: same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Testing virtual dataset with file version bounds: (v18, latest): -Config: same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Testing virtual dataset with file version bounds: (v110, v110): -Config: same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Testing virtual dataset with file version bounds: (v110, latest): -Config: same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Testing virtual dataset with file version bounds: (latest, latest): -Config: same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, same source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -Config: closed source dataset, different source file, reopen virtual file -Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix PASSED -All virtual dataset tests passed. -Test prefix for HDF5_VDS_PREFIX PASSED diff --git a/test/vds_env.c b/test/vds_env.c index 4ee8096..55e4c85 100644 --- a/test/vds_env.c +++ b/test/vds_env.c @@ -310,7 +310,7 @@ main(void) /* Loop through all the combinations of low/high version bounds */ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; H5_INC_ENUM(H5F_libver_t, low)) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; H5_INC_ENUM(H5F_libver_t, high)) { char msg[80]; /* Message for file version bounds */ char *low_string; /* The low bound string */ char *high_string; /* The high bound string */ -- cgit v0.12 From 6fdf7008c102aa22cf5a1ff66720f46035686bf3 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Mon, 15 Apr 2019 09:39:57 -0500 Subject: Adding back links_env.out which I accidentally removed in my previous commit. --- test/testfiles/links_env.out | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 test/testfiles/links_env.out diff --git a/test/testfiles/links_env.out b/test/testfiles/links_env.out new file mode 100644 index 0000000..3f10fc6 --- /dev/null +++ b/test/testfiles/links_env.out @@ -0,0 +1,3 @@ +Testing external links via environment variable PASSED +Testing external links via environment variable (w/new group format) PASSED +All external Link (HDF5_EXT_PREFIX) tests passed. -- cgit v0.12 From 1c6bce2f9bacd25fe78e1d63cf85e62e499aacab Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 17 Apr 2019 11:16:51 -0500 Subject: Replacing string operation strdup with assignment for empty string. --- src/H5Dint.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/H5Dint.c b/src/H5Dint.c index 208d879..d4bd9c1 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -1124,7 +1124,7 @@ H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char ** HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for the external file") } } else - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "prefix name is not sensible") + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "prefix name is not sensible") /* Prefix has to be checked for NULL / empty string again because the * code above might have updated it. @@ -1133,8 +1133,7 @@ H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char ** /* filename is interpreted as relative to the current directory, * does not need to be expanded */ - if(NULL == (*file_prefix = (char *)H5MM_strdup(""))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + *file_prefix = ""; } /* end if */ else { if(HDstrncmp(prefix, "${ORIGIN}", HDstrlen("${ORIGIN}")) == 0) { @@ -1383,8 +1382,10 @@ done: } /* end if */ if(new_dset->shared->dcpl_id != 0 && H5I_dec_ref(new_dset->shared->dcpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list") - new_dset->shared->extfile_prefix = (char *)H5MM_xfree(new_dset->shared->extfile_prefix); - new_dset->shared->vds_prefix = (char *)H5MM_xfree(new_dset->shared->vds_prefix); + if(new_dset->shared->extfile_prefix != "") + new_dset->shared->extfile_prefix = (char *)H5MM_xfree(new_dset->shared->extfile_prefix); + if(new_dset->shared->vds_prefix != "") + new_dset->shared->vds_prefix = (char *)H5MM_xfree(new_dset->shared->vds_prefix); new_dset->shared = H5FL_FREE(H5D_shared_t, new_dset->shared); } /* end if */ new_dset->oloc.file = NULL; @@ -1558,15 +1559,19 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) ret_value = dataset; done: - extfile_prefix = (char *)H5MM_xfree(extfile_prefix); - vds_prefix = (char *)H5MM_xfree(vds_prefix); + if(extfile_prefix != "") + extfile_prefix = (char *)H5MM_xfree(extfile_prefix); + if(vds_prefix != "") + vds_prefix = (char *)H5MM_xfree(vds_prefix); if(ret_value == NULL) { /* Free the location--casting away const*/ if(dataset) { if(shared_fo == NULL && dataset->shared) { /* Need to free shared fo */ - dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix); - dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix); + if(dataset->shared->extfile_prefix != "") + dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix); + if(dataset->shared->vds_prefix != "") + dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix); dataset->shared = H5FL_FREE(H5D_shared_t, dataset->shared); } @@ -1945,10 +1950,12 @@ H5D_close(H5D_t *dataset) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") /* Free the external file prefix */ - dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix); + if(dataset->shared->extfile_prefix != "") + dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix); /* Free the vds file prefix */ - dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix); + if(dataset->shared->vds_prefix != "") + dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix); /* Release layout, fill-value, efl & pipeline messages */ if(dataset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT) -- cgit v0.12 From b90b5be59bd7f38b92d575c7e6ce380ca15f10f7 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 17 Apr 2019 12:35:44 -0500 Subject: Improving the condition checking of empty string. --- src/H5Dint.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/H5Dint.c b/src/H5Dint.c index d4bd9c1..15a2050 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -1382,9 +1382,9 @@ done: } /* end if */ if(new_dset->shared->dcpl_id != 0 && H5I_dec_ref(new_dset->shared->dcpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list") - if(new_dset->shared->extfile_prefix != "") + if(new_dset->shared->extfile_prefix && new_dset->shared->extfile_prefix[0] != '\0') new_dset->shared->extfile_prefix = (char *)H5MM_xfree(new_dset->shared->extfile_prefix); - if(new_dset->shared->vds_prefix != "") + if(new_dset->shared->vds_prefix && new_dset->shared->vds_prefix[0] != '\0') new_dset->shared->vds_prefix = (char *)H5MM_xfree(new_dset->shared->vds_prefix); new_dset->shared = H5FL_FREE(H5D_shared_t, new_dset->shared); } /* end if */ @@ -1559,18 +1559,18 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) ret_value = dataset; done: - if(extfile_prefix != "") + if(extfile_prefix && extfile_prefix[0] != '\0') extfile_prefix = (char *)H5MM_xfree(extfile_prefix); - if(vds_prefix != "") + if(vds_prefix && vds_prefix[0] != '\0') vds_prefix = (char *)H5MM_xfree(vds_prefix); if(ret_value == NULL) { /* Free the location--casting away const*/ if(dataset) { if(shared_fo == NULL && dataset->shared) { /* Need to free shared fo */ - if(dataset->shared->extfile_prefix != "") + if(dataset->shared->extfile_prefix && dataset->shared->extfile_prefix[0] != '\0') dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix); - if(dataset->shared->vds_prefix != "") + if(dataset->shared->vds_prefix && dataset->shared->vds_prefix[0] != '\0') dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix); dataset->shared = H5FL_FREE(H5D_shared_t, dataset->shared); } @@ -1950,11 +1950,11 @@ H5D_close(H5D_t *dataset) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") /* Free the external file prefix */ - if(dataset->shared->extfile_prefix != "") + if(dataset->shared->extfile_prefix && dataset->shared->extfile_prefix[0] != '\0') dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix); /* Free the vds file prefix */ - if(dataset->shared->vds_prefix != "") + if(dataset->shared->vds_prefix && dataset->shared->vds_prefix[0] != '\0') dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix); /* Release layout, fill-value, efl & pipeline messages */ -- cgit v0.12 From fc47e2e07a252f9421c6d11e88cfd63e5a337183 Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 17 Apr 2019 16:53:40 -0500 Subject: Changing the prefix of external file and VDS from empty string to null for performance improvement. --- src/H5Defl.c | 20 ++++++++++++++------ src/H5Dint.c | 35 ++++++++++++++++------------------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/H5Defl.c b/src/H5Defl.c index 19f3a00..eef758c 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -287,8 +287,13 @@ H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "read past logical end of file") if(H5F_OVERFLOW_HSIZET2OFFT((hsize_t)efl->slot[u].offset + skip)) HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed") - if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) - HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") + if(dset->shared->extfile_prefix) { + if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) + HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") + } else { + if(H5_combine_path("", efl->slot[u].name, &full_name) < 0) + HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") + } if((fd = HDopen(full_name, O_RDONLY)) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file") if(HDlseek(fd, (HDoff_t)(efl->slot[u].offset + (HDoff_t)skip), SEEK_SET) < 0) @@ -379,8 +384,13 @@ H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t siz HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "write past logical end of file") if(H5F_OVERFLOW_HSIZET2OFFT((hsize_t)efl->slot[u].offset + skip)) HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed") - if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) - HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") + if(dset->shared->extfile_prefix) { + if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) + HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") + } else { + if(H5_combine_path("", efl->slot[u].name, &full_name) < 0) + HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") + } if((fd = HDopen(full_name, O_CREAT | O_RDWR, H5_POSIX_CREATE_MODE_RW)) < 0) { if(HDaccess(full_name, F_OK) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "external raw data file does not exist") @@ -477,7 +487,6 @@ H5D__efl_readvv(const H5D_io_info_t *io_info, HDassert(io_info->u.rbuf); HDassert(io_info->dset); HDassert(io_info->dset->shared); - HDassert(io_info->dset->shared->extfile_prefix); HDassert(dset_curr_seq); HDassert(dset_len_arr); HDassert(dset_off_arr); @@ -561,7 +570,6 @@ H5D__efl_writevv(const H5D_io_info_t *io_info, HDassert(io_info->u.wbuf); HDassert(io_info->dset); HDassert(io_info->dset->shared); - HDassert(io_info->dset->shared->extfile_prefix); HDassert(dset_curr_seq); HDassert(dset_len_arr); HDassert(dset_off_arr); diff --git a/src/H5Dint.c b/src/H5Dint.c index 15a2050..736f17c 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -1133,7 +1133,7 @@ H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char ** /* filename is interpreted as relative to the current directory, * does not need to be expanded */ - *file_prefix = ""; + *file_prefix = NULL; } /* end if */ else { if(HDstrncmp(prefix, "${ORIGIN}", HDstrlen("${ORIGIN}")) == 0) { @@ -1382,10 +1382,8 @@ done: } /* end if */ if(new_dset->shared->dcpl_id != 0 && H5I_dec_ref(new_dset->shared->dcpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list") - if(new_dset->shared->extfile_prefix && new_dset->shared->extfile_prefix[0] != '\0') - new_dset->shared->extfile_prefix = (char *)H5MM_xfree(new_dset->shared->extfile_prefix); - if(new_dset->shared->vds_prefix && new_dset->shared->vds_prefix[0] != '\0') - new_dset->shared->vds_prefix = (char *)H5MM_xfree(new_dset->shared->vds_prefix); + new_dset->shared->extfile_prefix = (char *)H5MM_xfree(new_dset->shared->extfile_prefix); + new_dset->shared->vds_prefix = (char *)H5MM_xfree(new_dset->shared->vds_prefix); new_dset->shared = H5FL_FREE(H5D_shared_t, new_dset->shared); } /* end if */ new_dset->oloc.file = NULL; @@ -1540,8 +1538,13 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) /* Check whether the external file prefix of the already open dataset * matches the new external file prefix */ - if(HDstrcmp(extfile_prefix, dataset->shared->extfile_prefix) != 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "new external file prefix does not match external file prefix of already open dataset") + if(extfile_prefix && dataset->shared->extfile_prefix) { + if(HDstrcmp(extfile_prefix, dataset->shared->extfile_prefix) != 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "new external file prefix does not match external file prefix of already open dataset") + } else { + if(extfile_prefix || dataset->shared->extfile_prefix) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "new external file prefix does not match external file prefix of already open dataset") + } /* Check if the object has been opened through the top file yet */ if(H5FO_top_count(dataset->oloc.file, dataset->oloc.addr) == 0) { @@ -1559,19 +1562,15 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) ret_value = dataset; done: - if(extfile_prefix && extfile_prefix[0] != '\0') - extfile_prefix = (char *)H5MM_xfree(extfile_prefix); - if(vds_prefix && vds_prefix[0] != '\0') - vds_prefix = (char *)H5MM_xfree(vds_prefix); + extfile_prefix = (char *)H5MM_xfree(extfile_prefix); + vds_prefix = (char *)H5MM_xfree(vds_prefix); if(ret_value == NULL) { /* Free the location--casting away const*/ if(dataset) { if(shared_fo == NULL && dataset->shared) { /* Need to free shared fo */ - if(dataset->shared->extfile_prefix && dataset->shared->extfile_prefix[0] != '\0') - dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix); - if(dataset->shared->vds_prefix && dataset->shared->vds_prefix[0] != '\0') - dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix); + dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix); + dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix); dataset->shared = H5FL_FREE(H5D_shared_t, dataset->shared); } @@ -1950,12 +1949,10 @@ H5D_close(H5D_t *dataset) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") /* Free the external file prefix */ - if(dataset->shared->extfile_prefix && dataset->shared->extfile_prefix[0] != '\0') - dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix); + dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix); /* Free the vds file prefix */ - if(dataset->shared->vds_prefix && dataset->shared->vds_prefix[0] != '\0') - dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix); + dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix); /* Release layout, fill-value, efl & pipeline messages */ if(dataset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT) -- cgit v0.12 From b5ef82a1786605ae86502bc82086047720b7d4ca Mon Sep 17 00:00:00 2001 From: Songyu Lu Date: Wed, 17 Apr 2019 17:42:01 -0500 Subject: Moving the handling of null prefix into H5_combine_path. --- src/H5Defl.c | 18 ++++-------------- src/H5system.c | 6 +++--- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/H5Defl.c b/src/H5Defl.c index eef758c..91caa61 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -287,13 +287,8 @@ H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "read past logical end of file") if(H5F_OVERFLOW_HSIZET2OFFT((hsize_t)efl->slot[u].offset + skip)) HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed") - if(dset->shared->extfile_prefix) { - if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) - HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") - } else { - if(H5_combine_path("", efl->slot[u].name, &full_name) < 0) - HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") - } + if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) + HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") if((fd = HDopen(full_name, O_RDONLY)) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file") if(HDlseek(fd, (HDoff_t)(efl->slot[u].offset + (HDoff_t)skip), SEEK_SET) < 0) @@ -384,13 +379,8 @@ H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t siz HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "write past logical end of file") if(H5F_OVERFLOW_HSIZET2OFFT((hsize_t)efl->slot[u].offset + skip)) HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed") - if(dset->shared->extfile_prefix) { - if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) - HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") - } else { - if(H5_combine_path("", efl->slot[u].name, &full_name) < 0) - HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") - } + if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) + HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") if((fd = HDopen(full_name, O_CREAT | O_RDWR, H5_POSIX_CREATE_MODE_RW)) < 0) { if(HDaccess(full_name, F_OK) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "external raw data file does not exist") diff --git a/src/H5system.c b/src/H5system.c index 2ddc29a..35123db 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -1256,13 +1256,13 @@ H5_combine_path(const char* path1, const char* path2, char **full_name /*out*/) FUNC_ENTER_NOAPI_NOINIT - HDassert(path1); HDassert(path2); - path1_len = HDstrlen(path1); + if(path1) + path1_len = HDstrlen(path1); path2_len = HDstrlen(path2); - if(*path1 == '\0' || H5_CHECK_ABSOLUTE(path2)) { + if(path1 == NULL || *path1 == '\0' || H5_CHECK_ABSOLUTE(path2)) { /* If path1 is empty or path2 is absolute, simply use path2 */ if(NULL == (*full_name = (char *)H5MM_strdup(path2))) -- cgit v0.12