Fixes warnings in the splitter VFD and tests

This commit is contained in:
Dana Robinson 2020-08-05 22:13:38 -07:00
parent 482ade4657
commit 8e7f3e38a7
2 changed files with 187 additions and 166 deletions

View File

@ -27,8 +27,6 @@
#include "H5FLprivate.h" /* Free Lists */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
#include "H5FDsec2.h" /* Generic Functions */
#include "H5FDstdio.h" /* Generic Functions */
#include "H5Pprivate.h" /* Property lists */
/* The driver identification number, initialized at runtime */
@ -93,7 +91,7 @@ typedef struct H5FD_splitter_t {
#if H5FD_SPLITTER_DEBUG_OP_CALLS
#define H5FD_SPLITTER_LOG_CALL(name) do { \
HDprintf("called %s()\n", (name)); \
fflush(stdout); \
HDfflush(stdout); \
} while (0)
#else
#define H5FD_SPLITTER_LOG_CALL(name) /* no-op */
@ -302,27 +300,22 @@ done:
herr_t
H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config)
{
H5FD_splitter_fapl_t info;
H5FD_splitter_fapl_t *info = NULL;
H5P_genplist_t *plist_ptr = NULL;
herr_t ret_value = SUCCEED;
H5Eclear2(H5E_DEFAULT);
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*Dr", fapl_id, vfd_config);
H5FD_SPLITTER_LOG_CALL("H5Pset_fapl_splitter");
if (H5FD_SPLITTER_MAGIC != vfd_config->magic) {
if (H5FD_SPLITTER_MAGIC != vfd_config->magic)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid configuration (magic number mismatch)")
}
if (H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION != vfd_config->version) {
if (H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION != vfd_config->version)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invlaid config (version number mismatch)")
}
if (NULL == (plist_ptr = (H5P_genplist_t *)H5I_object(fapl_id))) {
if (NULL == (plist_ptr = (H5P_genplist_t *)H5I_object(fapl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid property list")
}
/* Make sure that the W/O channel supports write-only capability.
@ -338,48 +331,46 @@ H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config)
unsigned long wo_driver_flags = 0;
wo_plist_ptr = (H5P_genplist_t *)H5I_object(vfd_config->wo_fapl_id);
if (NULL == wo_plist_ptr) {
if (NULL == wo_plist_ptr)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
}
if (H5P_peek(wo_plist_ptr, H5F_ACS_FILE_DRV_NAME, &wo_driver_prop) < 0) {
if (H5P_peek(wo_plist_ptr, H5F_ACS_FILE_DRV_NAME, &wo_driver_prop) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID & info")
}
wo_driver = (H5FD_class_t *)H5I_object(wo_driver_prop.driver_id);
if (NULL == wo_driver) {
if (NULL == wo_driver)
HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid driver ID in file access property list")
}
if (H5FD_driver_query(wo_driver, &wo_driver_flags) < 0) {
if (H5FD_driver_query(wo_driver, &wo_driver_flags) < 0)
HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't query VFD flags")
}
if (0 == (H5FD_FEAT_DEFAULT_VFD_COMPATIBLE & wo_driver_flags)) {
if (0 == (H5FD_FEAT_DEFAULT_VFD_COMPATIBLE & wo_driver_flags))
HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "unsuitable W/O driver")
}
} /* end if W/O VFD is non-default */
if (NULL == (info = H5MM_calloc(sizeof(H5FD_splitter_fapl_t))))
HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "can't allocate memory for splitter struct")
info.ignore_wo_errs = vfd_config->ignore_wo_errs;
HDstrncpy(info.wo_path, vfd_config->wo_path, H5FD_SPLITTER_PATH_MAX);
HDstrncpy(info.log_file_path, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX);
info.rw_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */
info.wo_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */
info->ignore_wo_errs = vfd_config->ignore_wo_errs;
HDstrncpy(info->wo_path, vfd_config->wo_path, H5FD_SPLITTER_PATH_MAX);
HDstrncpy(info->log_file_path, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX);
info->rw_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */
info->wo_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */
/* Set non-default channel FAPL IDs in splitter configuration info */
if (H5P_DEFAULT != vfd_config->rw_fapl_id) {
if (FALSE == H5P_isa_class(vfd_config->rw_fapl_id, H5P_FILE_ACCESS)) {
if (FALSE == H5P_isa_class(vfd_config->rw_fapl_id, H5P_FILE_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list")
}
info.rw_fapl_id = vfd_config->rw_fapl_id;
info->rw_fapl_id = vfd_config->rw_fapl_id;
}
if (H5P_DEFAULT != vfd_config->wo_fapl_id) {
if (FALSE == H5P_isa_class(vfd_config->wo_fapl_id, H5P_FILE_ACCESS)) {
if (FALSE == H5P_isa_class(vfd_config->wo_fapl_id, H5P_FILE_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list")
}
info.wo_fapl_id = vfd_config->wo_fapl_id;
info->wo_fapl_id = vfd_config->wo_fapl_id;
}
ret_value = H5P_set_driver(plist_ptr, H5FD_SPLITTER, &info);
if(H5P_set_driver(plist_ptr, H5FD_SPLITTER, info) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't set driver")
done:
H5MM_xfree(info);
FUNC_LEAVE_API(ret_value)
} /* end H5Pset_fapl_splitter() */
@ -409,45 +400,36 @@ H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config_out)
H5FD_SPLITTER_LOG_CALL("H5Pget_fapl_splitter");
/* Check arguments */
if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) {
if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
}
if (config_out == NULL) {
if (config_out == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "config_out pointer is null")
}
if (H5FD_SPLITTER_MAGIC != config_out->magic) {
if (H5FD_SPLITTER_MAGIC != config_out->magic)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "info-out pointer invalid (magic number mismatch)")
}
if (H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION != config_out->version) {
if (H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION != config_out->version)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "info-out pointer invalid (version unsafe)")
}
/* Pre-set out FAPL IDs with intent to replace these values */
config_out->rw_fapl_id = H5I_INVALID_HID;
config_out->wo_fapl_id = H5I_INVALID_HID;
/* Check and get the splitter fapl */
if (NULL == (plist_ptr = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) {
if (NULL == (plist_ptr = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
}
if (H5FD_SPLITTER != H5P_peek_driver(plist_ptr)) {
HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver")
}
if (NULL == (fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist_ptr))) {
HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unable to get specific-driver info")
}
if (H5FD_SPLITTER != H5P_peek_driver(plist_ptr))
HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "incorrect VFL driver")
if (NULL == (fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist_ptr)))
HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "unable to get specific-driver info")
HDstrncpy(config_out->wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX);
HDstrncpy(config_out->log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX);
config_out->ignore_wo_errs = fapl_ptr->ignore_wo_errs;
/* Copy R/W and W/O FAPLs */
if (H5FD__copy_plist(fapl_ptr->rw_fapl_id, &(config_out->rw_fapl_id)) < 0) {
HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't copy R/W FAPL");
}
if (H5FD__copy_plist(fapl_ptr->wo_fapl_id, &(config_out->wo_fapl_id)) < 0) {
HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't copy W/O FAPL");
}
if (H5FD__copy_plist(fapl_ptr->rw_fapl_id, &(config_out->rw_fapl_id)) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTCOPY, FAIL, "can't copy R/W FAPL");
if (H5FD__copy_plist(fapl_ptr->wo_fapl_id, &(config_out->wo_fapl_id)) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTCOPY, FAIL, "can't copy W/O FAPL");
done:
FUNC_LEAVE_API(ret_value)

View File

@ -2258,46 +2258,51 @@ static int
compare_splitter_config_info(hid_t fapl_id, H5FD_splitter_vfd_config_t *info)
{
int ret_value = 0;
H5FD_splitter_vfd_config_t fetched_info;
H5FD_splitter_vfd_config_t *fetched_info = NULL;
fetched_info.magic = H5FD_SPLITTER_MAGIC;
fetched_info.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION;
fetched_info.rw_fapl_id = H5I_INVALID_HID;
fetched_info.wo_fapl_id = H5I_INVALID_HID;
if (NULL == (fetched_info = HDcalloc(1, sizeof(H5FD_splitter_vfd_config_t))))
SPLITTER_TEST_FAULT("memory allocation for fetched_info struct failed");
if (H5Pget_fapl_splitter(fapl_id, &fetched_info) < 0) {
SPLITTER_TEST_FAULT("can't get splitter info\n");
fetched_info->magic = H5FD_SPLITTER_MAGIC;
fetched_info->version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION;
fetched_info->rw_fapl_id = H5I_INVALID_HID;
fetched_info->wo_fapl_id = H5I_INVALID_HID;
if (H5Pget_fapl_splitter(fapl_id, fetched_info) < 0) {
SPLITTER_TEST_FAULT("can't get splitter info");
}
if (info->rw_fapl_id == H5P_DEFAULT) {
if (H5Pget_driver(fetched_info.rw_fapl_id) != H5Pget_driver(H5P_FILE_ACCESS_DEFAULT)) {
if (H5Pget_driver(fetched_info->rw_fapl_id) != H5Pget_driver(H5P_FILE_ACCESS_DEFAULT)) {
SPLITTER_TEST_FAULT("Read-Write driver mismatch (default)\n");
}
}
else {
if (H5Pget_driver(fetched_info.rw_fapl_id) != H5Pget_driver(info->rw_fapl_id)) {
if (H5Pget_driver(fetched_info->rw_fapl_id) != H5Pget_driver(info->rw_fapl_id)) {
SPLITTER_TEST_FAULT("Read-Write driver mismatch\n");
}
}
if (info->wo_fapl_id == H5P_DEFAULT) {
if (H5Pget_driver(fetched_info.wo_fapl_id) != H5Pget_driver(H5P_FILE_ACCESS_DEFAULT)) {
if (H5Pget_driver(fetched_info->wo_fapl_id) != H5Pget_driver(H5P_FILE_ACCESS_DEFAULT)) {
SPLITTER_TEST_FAULT("Write-Only driver mismatch (default)\n");
}
}
else {
if (H5Pget_driver(fetched_info.wo_fapl_id) != H5Pget_driver(info->wo_fapl_id)) {
if (H5Pget_driver(fetched_info->wo_fapl_id) != H5Pget_driver(info->wo_fapl_id)) {
SPLITTER_TEST_FAULT("Write-Only driver mismatch\n");
}
}
if ( (HDstrlen(info->wo_path) != HDstrlen(fetched_info.wo_path)) ||
HDstrncmp(info->wo_path, fetched_info.wo_path, H5FD_SPLITTER_PATH_MAX))
if ( (HDstrlen(info->wo_path) != HDstrlen(fetched_info->wo_path)) ||
HDstrncmp(info->wo_path, fetched_info->wo_path, H5FD_SPLITTER_PATH_MAX))
{
HDfprintf(stderr, "MISMATCH: '%s' :: '%s'\n", info->wo_path, fetched_info.wo_path);
HDfprintf(stderr, "MISMATCH: '%s' :: '%s'\n", info->wo_path, fetched_info->wo_path);
HEXPRINT(H5FD_SPLITTER_PATH_MAX, info->wo_path);
HEXPRINT(H5FD_SPLITTER_PATH_MAX, fetched_info.wo_path);
HEXPRINT(H5FD_SPLITTER_PATH_MAX, fetched_info->wo_path);
SPLITTER_TEST_FAULT("Write-Only file path mismatch\n");
}
done:
HDfree(fetched_info);
return ret_value;
} /* end compare_splitter_config_info() */
@ -2331,37 +2336,42 @@ run_splitter_test(const struct splitter_dataset_def *data,
hid_t space_id = H5I_INVALID_HID;
hid_t fapl_id_out = H5I_INVALID_HID;
hid_t fapl_id_cpy = H5I_INVALID_HID;
H5FD_splitter_vfd_config_t vfd_config;
char filename_rw[H5FD_SPLITTER_PATH_MAX + 1];
H5FD_splitter_vfd_config_t *vfd_config = NULL;
char *filename_rw = NULL;
FILE *logfile = NULL;
int ret_value = 0;
vfd_config.magic = H5FD_SPLITTER_MAGIC;
vfd_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION;
vfd_config.ignore_wo_errs = ignore_wo_errors;
vfd_config.rw_fapl_id = sub_fapl_ids[0];
vfd_config.wo_fapl_id = sub_fapl_ids[1];
if (NULL == (vfd_config = HDcalloc(1, sizeof(H5FD_splitter_vfd_config_t))))
SPLITTER_TEST_FAULT("memory allocation for vfd_config struct failed");
if (NULL == (filename_rw = HDcalloc(H5FD_SPLITTER_PATH_MAX + 1, sizeof(char))))
SPLITTER_TEST_FAULT("memory allocation for filename_rw string failed");
if (splitter_prepare_file_paths(&vfd_config, filename_rw) < 0) {
vfd_config->magic = H5FD_SPLITTER_MAGIC;
vfd_config->version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION;
vfd_config->ignore_wo_errs = ignore_wo_errors;
vfd_config->rw_fapl_id = sub_fapl_ids[0];
vfd_config->wo_fapl_id = sub_fapl_ids[1];
if (splitter_prepare_file_paths(vfd_config, filename_rw) < 0) {
SPLITTER_TEST_FAULT("can't prepare file paths\n");
}
if (provide_logfile_path == FALSE) {
*vfd_config.log_file_path = '\0'; /* reset as empty string */
vfd_config->log_file_path[0] = '\0'; /* reset as empty string */
}
/* Create a new fapl to use the SPLITTER file driver */
if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == H5I_INVALID_HID) {
SPLITTER_TEST_FAULT("can't create FAPL ID\n");
}
if (H5Pset_fapl_splitter(fapl_id, &vfd_config) < 0) {
if (H5Pset_fapl_splitter(fapl_id, vfd_config) < 0) {
SPLITTER_TEST_FAULT("can't set splitter FAPL\n");
}
if (H5Pget_driver(fapl_id) != H5FD_SPLITTER) {
SPLITTER_TEST_FAULT("set FAPL not SPLITTER\n");
}
if (compare_splitter_config_info(fapl_id, &vfd_config) < 0) {
if (compare_splitter_config_info(fapl_id, vfd_config) < 0) {
SPLITTER_TEST_FAULT("information mismatch\n");
}
@ -2374,7 +2384,7 @@ run_splitter_test(const struct splitter_dataset_def *data,
if (H5I_INVALID_HID == fapl_id_cpy) {
SPLITTER_TEST_FAULT("can't copy FAPL\n");
}
if (compare_splitter_config_info(fapl_id_cpy, &vfd_config) < 0) {
if (compare_splitter_config_info(fapl_id_cpy, vfd_config) < 0) {
SPLITTER_TEST_FAULT("information mismatch\n");
}
if (H5Pclose(fapl_id_cpy) < 0) {
@ -2401,7 +2411,7 @@ run_splitter_test(const struct splitter_dataset_def *data,
if (H5Pget_driver(fapl_id_out) != H5FD_SPLITTER) {
SPLITTER_TEST_FAULT("wrong file FAPL driver\n");
}
if (compare_splitter_config_info(fapl_id_out, &vfd_config) < 0) {
if (compare_splitter_config_info(fapl_id_out, vfd_config) < 0) {
SPLITTER_TEST_FAULT("information mismatch\n");
}
if (H5Pclose(fapl_id_out) < 0) {
@ -2439,12 +2449,12 @@ run_splitter_test(const struct splitter_dataset_def *data,
}
/* Verify that the R/W and W/O files are identical */
if (h5_compare_file_bytes(filename_rw, vfd_config.wo_path) < 0) {
if (h5_compare_file_bytes(filename_rw, vfd_config->wo_path) < 0) {
SPLITTER_TEST_FAULT("files are not byte-for-byte equivalent\n");
}
/* Verify existence of logfile iff appropriate */
logfile = fopen(vfd_config.log_file_path, "r");
logfile = fopen(vfd_config->log_file_path, "r");
if ( (TRUE == provide_logfile_path && NULL == logfile) ||
(FALSE == provide_logfile_path && NULL != logfile) )
{
@ -2454,19 +2464,22 @@ run_splitter_test(const struct splitter_dataset_def *data,
done:
if (ret_value < 0) {
H5E_BEGIN_TRY {
(void)H5Dclose(dset_id);
(void)H5Sclose(space_id);
(void)H5Pclose(fapl_id_out);
(void)H5Pclose(fapl_id_cpy);
(void)H5Pclose(fapl_id);
(void)H5Fclose(file_id);
H5Dclose(dset_id);
H5Sclose(space_id);
H5Pclose(fapl_id_out);
H5Pclose(fapl_id_cpy);
H5Pclose(fapl_id);
H5Fclose(file_id);
} H5E_END_TRY;
}
if (logfile != NULL) {
fclose(logfile);
}
return ret_value;
if (logfile != NULL)
fclose(logfile);
HDfree(vfd_config);
HDfree(filename_rw);
return ret_value;
} /* end run_splitter_test() */
@ -2488,25 +2501,28 @@ done:
static int
driver_is_splitter_compatible(hid_t fapl_id)
{
H5FD_splitter_vfd_config_t vfd_config;
H5FD_splitter_vfd_config_t *vfd_config = NULL;
hid_t split_fapl_id = H5I_INVALID_HID;
herr_t ret = SUCCEED;
int ret_value = 0;
split_fapl_id = H5Pcreate(H5P_FILE_ACCESS);
if (H5I_INVALID_HID == split_fapl_id) {
if (NULL == (vfd_config = HDcalloc(1, sizeof(H5FD_splitter_vfd_config_t)))) {
FAIL_PUTS_ERROR("memory allocation for vfd_config struct failed");
}
if(H5I_INVALID_HID == (split_fapl_id = H5Pcreate(H5P_FILE_ACCESS))) {
FAIL_PUTS_ERROR("Can't create contained FAPL");
}
vfd_config.magic = H5FD_SPLITTER_MAGIC;
vfd_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION;
vfd_config.ignore_wo_errs = FALSE;
vfd_config.rw_fapl_id = H5P_DEFAULT;
vfd_config.wo_fapl_id = fapl_id;
HDstrncpy(vfd_config.wo_path, "nonesuch", H5FD_SPLITTER_PATH_MAX);
*vfd_config.log_file_path = '\0';
vfd_config->magic = H5FD_SPLITTER_MAGIC;
vfd_config->version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION;
vfd_config->ignore_wo_errs = FALSE;
vfd_config->rw_fapl_id = H5P_DEFAULT;
vfd_config->wo_fapl_id = fapl_id;
HDstrncpy(vfd_config->wo_path, "nonesuch", H5FD_SPLITTER_PATH_MAX);
vfd_config->log_file_path[0] = '\0';
H5E_BEGIN_TRY {
ret = H5Pset_fapl_splitter(split_fapl_id, &vfd_config);
ret = H5Pset_fapl_splitter(split_fapl_id, vfd_config);
} H5E_END_TRY;
if (SUCCEED == ret) {
ret_value = -1;
@ -2517,12 +2533,17 @@ driver_is_splitter_compatible(hid_t fapl_id)
}
split_fapl_id = H5I_INVALID_HID;
HDfree(vfd_config);
return ret_value;
error:
H5E_BEGIN_TRY {
(void)H5Pclose(split_fapl_id);
H5Pclose(split_fapl_id);
} H5E_END_TRY;
HDfree(vfd_config);
return -1;
} /* end driver_is_splitter_compatible() */
@ -2545,19 +2566,24 @@ splitter_RO_test(
const struct splitter_dataset_def *data,
hid_t child_fapl_id)
{
char filename_rw[H5FD_SPLITTER_PATH_MAX + 1];
H5FD_splitter_vfd_config_t vfd_config;
char *filename_rw = NULL;
H5FD_splitter_vfd_config_t *vfd_config = NULL;
hid_t fapl_id = H5I_INVALID_HID;
int ret_value = 0;
hid_t file_id = H5I_INVALID_HID;
int ret_value = 0;
vfd_config.magic = H5FD_SPLITTER_MAGIC;
vfd_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION;
vfd_config.ignore_wo_errs = FALSE;
vfd_config.rw_fapl_id = child_fapl_id;
vfd_config.wo_fapl_id = child_fapl_id;
if (NULL == (vfd_config = HDcalloc(1, sizeof(H5FD_splitter_vfd_config_t))))
SPLITTER_TEST_FAULT("memory allocation for vfd_config struct failed");
if (NULL == (filename_rw = HDcalloc(H5FD_SPLITTER_PATH_MAX + 1, sizeof(char))))
SPLITTER_TEST_FAULT("memory allocation for filename_rw string failed");
if (splitter_prepare_file_paths(&vfd_config, filename_rw) < 0) {
vfd_config->magic = H5FD_SPLITTER_MAGIC;
vfd_config->version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION;
vfd_config->ignore_wo_errs = FALSE;
vfd_config->rw_fapl_id = child_fapl_id;
vfd_config->wo_fapl_id = child_fapl_id;
if (splitter_prepare_file_paths(vfd_config, filename_rw) < 0) {
SPLITTER_TEST_FAULT("can't prepare splitter file paths\n");
}
@ -2566,7 +2592,7 @@ splitter_RO_test(
if (H5I_INVALID_HID == fapl_id) {
SPLITTER_TEST_FAULT("can't create FAPL ID\n");
}
if (H5Pset_fapl_splitter(fapl_id, &vfd_config) < 0) {
if (H5Pset_fapl_splitter(fapl_id, vfd_config) < 0) {
SPLITTER_TEST_FAULT("can't set splitter FAPL\n");
}
if (H5Pget_driver(fapl_id) != H5FD_SPLITTER) {
@ -2588,7 +2614,7 @@ splitter_RO_test(
* Should fail.
*/
if (splitter_create_single_file_at(vfd_config.wo_path, vfd_config.wo_fapl_id, data) < 0) {
if (splitter_create_single_file_at(vfd_config->wo_path, vfd_config->wo_fapl_id, data) < 0) {
SPLITTER_TEST_FAULT("can't write W/O file\n");
}
H5E_BEGIN_TRY {
@ -2597,13 +2623,13 @@ splitter_RO_test(
if (file_id >= 0) {
SPLITTER_TEST_FAULT("R/O open with extant W/O file unexpectedly successful\n");
}
HDremove(vfd_config.wo_path);
HDremove(vfd_config->wo_path);
/* Attempt R/O open when only R/W file exists
* Should fail.
*/
if (splitter_create_single_file_at(filename_rw, vfd_config.rw_fapl_id, data) < 0) {
if (splitter_create_single_file_at(filename_rw, vfd_config->rw_fapl_id, data) < 0) {
SPLITTER_TEST_FAULT("can't create R/W file\n");
}
H5E_BEGIN_TRY {
@ -2616,7 +2642,7 @@ splitter_RO_test(
/* Attempt R/O open when both R/W and W/O files exist
*/
if (splitter_create_single_file_at(vfd_config.wo_path, vfd_config.wo_fapl_id, data) < 0) {
if (splitter_create_single_file_at(vfd_config->wo_path, vfd_config->wo_fapl_id, data) < 0) {
SPLITTER_TEST_FAULT("can't create W/O file\n");
}
file_id = H5Fopen(filename_rw, H5F_ACC_RDONLY, fapl_id);
@ -2642,10 +2668,14 @@ splitter_RO_test(
done:
if (ret_value < 0) {
H5E_BEGIN_TRY {
(void)H5Pclose(fapl_id);
(void)H5Fclose(file_id);
H5Pclose(fapl_id);
H5Fclose(file_id);
} H5E_END_TRY;
} /* end if error */
}
HDfree(vfd_config);
HDfree(filename_rw);
return ret_value;
} /* end splitter_RO_test() */
@ -2784,9 +2814,9 @@ splitter_create_single_file_at(
done:
if (ret_value < 0) {
H5E_BEGIN_TRY {
(void)H5Dclose(dset_id);
(void)H5Sclose(space_id);
(void)H5Fclose(file_id);
H5Dclose(dset_id);
H5Sclose(space_id);
H5Fclose(file_id);
} H5E_END_TRY;
} /* end if error */
return ret_value;
@ -2847,7 +2877,7 @@ splitter_compare_expected_data(hid_t file_id,
done:
if (ret_value < 0) {
H5E_BEGIN_TRY {
(void)H5Dclose(dset_id);
H5Dclose(dset_id);
} H5E_END_TRY;
}
return ret_value;
@ -2880,9 +2910,9 @@ done:
static int
splitter_tentative_open_test(hid_t child_fapl_id)
{
const char filename_tmp[H5FD_SPLITTER_PATH_MAX + 1] = "splitter_tmp.h5";
char filename_rw[H5FD_SPLITTER_PATH_MAX + 1];
H5FD_splitter_vfd_config_t vfd_config;
const char *filename_tmp = "splitter_tmp.h5";
char *filename_rw = NULL;
H5FD_splitter_vfd_config_t *vfd_config = NULL;
hid_t fapl_id = H5I_INVALID_HID;
hid_t file_id = H5I_INVALID_HID;
int buf[SPLITTER_SIZE][SPLITTER_SIZE]; /* for comparison */
@ -2892,6 +2922,11 @@ splitter_tentative_open_test(hid_t child_fapl_id)
struct splitter_dataset_def data; /* for comparison */
int ret_value = 0;
if (NULL == (vfd_config = HDcalloc(1, sizeof(H5FD_splitter_vfd_config_t))))
SPLITTER_TEST_FAULT("memory allocation for vfd_config struct failed");
if (NULL == (filename_rw = HDcalloc(H5FD_SPLITTER_PATH_MAX + 1, sizeof(char))))
SPLITTER_TEST_FAULT("memory allocation for filename_rw string failed");
/* pre-fill data buffer to write */
for (i=0; i < SPLITTER_SIZE; i++) {
for (j=0; j < SPLITTER_SIZE; j++) {
@ -2906,13 +2941,13 @@ splitter_tentative_open_test(hid_t child_fapl_id)
data.n_dims = 2;
data.dset_name = SPLITTER_DATASET_NAME;
vfd_config.magic = H5FD_SPLITTER_MAGIC;
vfd_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION;
vfd_config.ignore_wo_errs = FALSE;
vfd_config.rw_fapl_id = child_fapl_id;
vfd_config.wo_fapl_id = child_fapl_id;
vfd_config->magic = H5FD_SPLITTER_MAGIC;
vfd_config->version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION;
vfd_config->ignore_wo_errs = FALSE;
vfd_config->rw_fapl_id = child_fapl_id;
vfd_config->wo_fapl_id = child_fapl_id;
if (splitter_prepare_file_paths(&vfd_config, filename_rw) < 0) {
if (splitter_prepare_file_paths(vfd_config, filename_rw) < 0) {
SPLITTER_TEST_FAULT("can't prepare splitter file paths\n");
}
@ -2920,7 +2955,7 @@ splitter_tentative_open_test(hid_t child_fapl_id)
if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == H5I_INVALID_HID) {
SPLITTER_TEST_FAULT("can't create FAPL ID\n");
}
if (H5Pset_fapl_splitter(fapl_id, &vfd_config) < 0) {
if (H5Pset_fapl_splitter(fapl_id, vfd_config) < 0) {
SPLITTER_TEST_FAULT("can't set splitter FAPL\n");
}
if (H5Pget_driver(fapl_id) != H5FD_SPLITTER) {
@ -2950,7 +2985,7 @@ splitter_tentative_open_test(hid_t child_fapl_id)
if (file_exists(filename_rw, child_fapl_id)) {
SPLITTER_TEST_FAULT("R/W file unexpectedly created\n");
}
if (file_exists(vfd_config.wo_path, child_fapl_id)) {
if (file_exists(vfd_config->wo_path, child_fapl_id)) {
SPLITTER_TEST_FAULT("W/O file unexpectedly created\n");
}
@ -2960,7 +2995,7 @@ splitter_tentative_open_test(hid_t child_fapl_id)
* Should fail.
*/
if (h5_duplicate_file_by_bytes(filename_tmp, vfd_config.wo_path) < 0) {
if (h5_duplicate_file_by_bytes(filename_tmp, vfd_config->wo_path) < 0) {
SPLITTER_TEST_FAULT("Can't create W/O file copy.\n");
}
H5E_BEGIN_TRY {
@ -2972,11 +3007,11 @@ splitter_tentative_open_test(hid_t child_fapl_id)
if (file_exists(filename_rw, child_fapl_id)) {
SPLITTER_TEST_FAULT("R/W file unexpectedly created\n");
}
if (!file_exists(vfd_config.wo_path, child_fapl_id)) {
if (!file_exists(vfd_config->wo_path, child_fapl_id)) {
SPLITTER_TEST_FAULT("W/O file mysteriously disappeared\n");
}
HDremove(vfd_config.wo_path);
if (file_exists(vfd_config.wo_path, child_fapl_id)) {
HDremove(vfd_config->wo_path);
if (file_exists(vfd_config->wo_path, child_fapl_id)) {
SPLITTER_TEST_FAULT("failed to remove W/O file\n");
}
@ -2998,7 +3033,7 @@ splitter_tentative_open_test(hid_t child_fapl_id)
if (!file_exists(filename_rw, child_fapl_id)) {
SPLITTER_TEST_FAULT("R/W file mysteriously disappeared\n");
}
if (file_exists(vfd_config.wo_path, child_fapl_id)) {
if (file_exists(vfd_config->wo_path, child_fapl_id)) {
SPLITTER_TEST_FAULT("W/O file unexpectedly created\n");
}
@ -3007,7 +3042,7 @@ splitter_tentative_open_test(hid_t child_fapl_id)
* Both files present.
*/
if (h5_duplicate_file_by_bytes(filename_tmp, vfd_config.wo_path) < 0) {
if (h5_duplicate_file_by_bytes(filename_tmp, vfd_config->wo_path) < 0) {
SPLITTER_TEST_FAULT("Can't create W/O file copy.\n");
}
file_id = H5Fopen(filename_rw, H5F_ACC_RDWR, fapl_id);
@ -3021,7 +3056,7 @@ splitter_tentative_open_test(hid_t child_fapl_id)
if (!file_exists(filename_rw, child_fapl_id)) {
SPLITTER_TEST_FAULT("R/W file mysteriously disappared\n");
}
if (!file_exists(vfd_config.wo_path, child_fapl_id)) {
if (!file_exists(vfd_config->wo_path, child_fapl_id)) {
SPLITTER_TEST_FAULT("W/O file mysteriously disappeared\n");
}
@ -3041,14 +3076,14 @@ splitter_tentative_open_test(hid_t child_fapl_id)
if (!file_exists(filename_rw, child_fapl_id)) {
SPLITTER_TEST_FAULT("R/W file mysteriously disappared\n");
}
if (!file_exists(vfd_config.wo_path, child_fapl_id)) {
if (!file_exists(vfd_config->wo_path, child_fapl_id)) {
SPLITTER_TEST_FAULT("W/O file mysteriously disappeared\n");
}
if (h5_compare_file_bytes(filename_rw, vfd_config.wo_path) < 0) {
if (h5_compare_file_bytes(filename_rw, vfd_config->wo_path) < 0) {
SPLITTER_TEST_FAULT("files are not byte-for-byte equivalent\n");
}
HDremove(filename_rw);
HDremove(vfd_config.wo_path);
HDremove(vfd_config->wo_path);
/*
* H5Fcreate() with TRUNC access.
@ -3058,7 +3093,7 @@ splitter_tentative_open_test(hid_t child_fapl_id)
if (h5_duplicate_file_by_bytes(filename_tmp, filename_rw) < 0) {
SPLITTER_TEST_FAULT("Can't create R/W file copy.\n");
}
if (file_exists(vfd_config.wo_path, child_fapl_id)) {
if (file_exists(vfd_config->wo_path, child_fapl_id)) {
SPLITTER_TEST_FAULT("failed to remove W/O file\n");
}
file_id = H5Fcreate(filename_rw, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
@ -3072,21 +3107,21 @@ splitter_tentative_open_test(hid_t child_fapl_id)
if (!file_exists(filename_rw, child_fapl_id)) {
SPLITTER_TEST_FAULT("R/W file mysteriously disappared\n");
}
if (!file_exists(vfd_config.wo_path, child_fapl_id)) {
if (!file_exists(vfd_config->wo_path, child_fapl_id)) {
SPLITTER_TEST_FAULT("W/O file mysteriously disappeared\n");
}
if (h5_compare_file_bytes(filename_rw, vfd_config.wo_path) < 0) {
if (h5_compare_file_bytes(filename_rw, vfd_config->wo_path) < 0) {
SPLITTER_TEST_FAULT("files are not byte-for-byte equivalent\n");
}
HDremove(filename_rw);
HDremove(vfd_config.wo_path);
HDremove(vfd_config->wo_path);
/*
* H5Fcreate() with TRUNC access.
* Only W/O present.
*/
if (h5_duplicate_file_by_bytes(filename_tmp, vfd_config.wo_path) < 0) {
if (h5_duplicate_file_by_bytes(filename_tmp, vfd_config->wo_path) < 0) {
SPLITTER_TEST_FAULT("Can't create W/O file copy.\n");
}
if (file_exists(filename_rw, child_fapl_id)) {
@ -3103,14 +3138,14 @@ splitter_tentative_open_test(hid_t child_fapl_id)
if (!file_exists(filename_rw, child_fapl_id)) {
SPLITTER_TEST_FAULT("R/W file mysteriously disappared\n");
}
if (!file_exists(vfd_config.wo_path, child_fapl_id)) {
if (!file_exists(vfd_config->wo_path, child_fapl_id)) {
SPLITTER_TEST_FAULT("W/O file mysteriously disappeared\n");
}
if (h5_compare_file_bytes(filename_rw, vfd_config.wo_path) < 0) {
if (h5_compare_file_bytes(filename_rw, vfd_config->wo_path) < 0) {
SPLITTER_TEST_FAULT("files are not byte-for-byte equivalent\n");
}
HDremove(filename_rw);
HDremove(vfd_config.wo_path);
HDremove(vfd_config->wo_path);
/* H5Fcreate with both files absent is tested elsewhere */
@ -3125,10 +3160,14 @@ splitter_tentative_open_test(hid_t child_fapl_id)
done:
if (ret_value < 0) {
H5E_BEGIN_TRY {
(void)H5Pclose(fapl_id);
(void)H5Fclose(file_id);
H5Pclose(fapl_id);
H5Fclose(file_id);
} H5E_END_TRY;
} /* end if error */
}
HDfree(vfd_config);
HDfree(filename_rw);
return ret_value;
} /* end splitter_tentative_open_test() */
@ -3165,7 +3204,7 @@ file_exists(const char *filename, hid_t fapl_id)
error:
H5E_BEGIN_TRY {
(void)H5Fclose(file_id);
H5Fclose(file_id);
} H5E_END_TRY;
return ret_value;
} /* end file_exists() */
@ -3272,9 +3311,9 @@ test_splitter(void)
return 0;
error:
if (child_fapl_id != H5I_INVALID_HID) {
(void)H5Pclose(child_fapl_id);
}
if (child_fapl_id != H5I_INVALID_HID)
H5Pclose(child_fapl_id);
return -1;
} /* end test_splitter() */
@ -3317,7 +3356,7 @@ main(void)
HDprintf("***** %d Virtual File Driver TEST%s FAILED! *****\n",
nerrors, nerrors > 1 ? "S" : "");
return EXIT_FAILURE;
} /* end if */
}
HDprintf("All Virtual File Driver tests passed.\n");