From 83de84f88d1ac0f7960031c816857a62e0c6cee9 Mon Sep 17 00:00:00 2001 From: Muqun Yang Date: Tue, 29 Jun 2021 10:42:11 -0500 Subject: Add the Makefile.am for the performance. --- test/Makefile.am | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/Makefile.am b/test/Makefile.am index 2d76946..dcd1264 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -54,6 +54,7 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) \ vfd_swmr_group_reader$(EXEEXT) vfd_swmr_group_writer$(EXEEXT) \ vfd_swmr_vlstr_reader$(EXEEXT) vfd_swmr_vlstr_writer$(EXEEXT) \ vfd_swmr_zoo_reader$(EXEEXT) vfd_swmr_zoo_writer$(EXEEXT) \ + vfd_swmr_gperf_reader$(EXEEXT) vfd_swmr_gperf_writer$(EXEEXT) \ vds_env$(EXEEXT) \ vds_swmr_gen$(EXEEXT) vds_swmr_reader$(EXEEXT) vds_swmr_writer$(EXEEXT) if HAVE_SHARED_CONDITIONAL @@ -111,6 +112,7 @@ check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version \ vfd_swmr_vlstr_reader vfd_swmr_vlstr_writer \ vfd_swmr_zoo_reader vfd_swmr_zoo_writer \ vfd_swmr_attrdset_reader vfd_swmr_attrdset_writer \ + vfd_swmr_gperf_reader vfd_swmr_gperf_writer \ vfd_swmr_check_compat \ swmr_check_compat_vfd vds_env vds_swmr_gen vds_swmr_reader vds_swmr_writer \ mirror_vfd @@ -177,6 +179,7 @@ vfd_swmr_zoo_reader_SOURCES=vfd_swmr_zoo_writer.c genall5.c vfd_swmr_bigset_reader_SOURCES=vfd_swmr_bigset_writer.c vfd_swmr_group_reader_SOURCES=vfd_swmr_group_writer.c +vfd_swmr_gperf_reader_SOURCES=vfd_swmr_gperf_writer.c vfd_swmr_dsetops_reader_SOURCES=vfd_swmr_dsetops_writer.c vfd_swmr_attrdset_writer_SOURCES=vfd_swmr_attrdset_writer.c -- cgit v0.12 From b4cd03bd54f5eb09072f2e6d92948610778b4604 Mon Sep 17 00:00:00 2001 From: Muqun Yang Date: Tue, 29 Jun 2021 11:54:28 -0500 Subject: Add the first version of group performance code. --- test/vfd_swmr_gperf_writer.c | 5261 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 5261 insertions(+) create mode 100644 test/vfd_swmr_gperf_writer.c diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c new file mode 100644 index 0000000..9996798 --- /dev/null +++ b/test/vfd_swmr_gperf_writer.c @@ -0,0 +1,5261 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#define H5F_FRIEND /*suppress error about including H5Fpkg */ + +#include "hdf5.h" + +#include "H5Fpkg.h" +#include "H5HGprivate.h" +#include "H5VLprivate.h" + +#include "testhdf5.h" +#include "vfd_swmr_common.h" + +#ifndef H5_HAVE_WIN32_API + +#define READER_WAIT_TICKS 3 +#define VS_ATTR_NAME_LEN 21 + +#define TIME_PASSED(X,Y) \ + ((double)((Y.tv_sec - X.tv_sec) * 1000000000 + (Y.tv_nsec - X.tv_nsec))) / 1000000000.0 + +typedef struct { + hid_t file, filetype, one_by_one_sid; + char filename[PATH_MAX]; + char progname[PATH_MAX]; + unsigned int asteps; + unsigned int csteps; + unsigned int nsteps; + unsigned int update_interval; + bool use_vfd_swmr; + bool old_style_grp; + bool use_named_pipes; + char grp_op_pattern; + bool grp_op_test; + char at_pattern; + bool attr_test; + uint32_t max_lag; + uint32_t tick_len; + int np_fd_w_to_r; + int np_fd_r_to_w; + int np_notify; + int np_verify; + bool gperf; + double min_time; + double max_time; + double mean_time; + double total_time; + unsigned int num_attrs; +} state_t; + +#define ALL_HID_INITIALIZER \ + (state_t) \ + { \ + .file = H5I_INVALID_HID, .one_by_one_sid = H5I_INVALID_HID, .filename = "", \ + .filetype = H5T_NATIVE_UINT32, .asteps = 10, .csteps = 10, .nsteps = 100, \ + .update_interval = READER_WAIT_TICKS, .use_vfd_swmr = true, .old_style_grp = false, \ + .use_named_pipes = true, .grp_op_pattern = ' ', .grp_op_test = false, .at_pattern = ' ', \ + .attr_test = false, .tick_len = 4, .max_lag = 7, .np_fd_w_to_r = -1, .np_fd_r_to_w = -1, \ + .np_notify = 0, .np_verify = 0, .gperf = false, .min_time = 100., .max_time = 0.,.mean_time = 0., \ + .total_time = 0.,.num_attrs = 1 \ + } + +static void +usage(const char *progname) +{ + fprintf(stderr, + "usage: %s [-S] [-G] [-a steps] [-b] [-c] [-n iterations]\n" + " [-N] [-q] [-u numb_ticks] [-A at_pattern] [-O grp_op_pattern]\n" + "\n" + "-S: do not use VFD SWMR\n" + "-G: old-style type of group\n" + "-a steps: `steps` between adding attributes\n" + "-b: write data in big-endian byte order\n" + "-c steps: `steps` between communication between the writer and reader\n" + "-n ngroups: the number of groups\n" + "-N: do not use named pipes, \n" + " mainly for running the writer and reader seperately\n" + "-u numb_ticks: `numb_ticks` for the reader to wait before verification\n" + "-A at_pattern: `at_pattern' for different attribute tests\n" + " The value of `at_pattern` is one of the following:\n" + " `compact` - Attributes added in compact storage\n" + " `dense` - An attribute added in dense storage\n" + " `compact-del` - Attributes added and then one\n" + " attribute deleted, in compact \n" + " `dense-del` - Attributes added until the storage\n" + " is dense then an attribute deleted\n" + " the storge still in dense\n" + " `compact-add-to-dense` - Attributes added first in compact\n" + " then in dense storage\n" + " `dense-del-to-compact` - Attributes added until the storage\n" + " is dense, then several attributes \n" + " deleted, the storage changed to\n" + " compact\n" + " `modify` - An attribute added then modified\n" + " `add-vstr` - A VL string attribute added\n" + " `remove-vstr` - A VL string attribute added then\n" + " deleted\n" + " `modify-vstr` - A VL string attribute added then \n" + " modified \n" + " `add-ohr-block` - An attribute is added and this forces\n" + " the creation of object header\n" + " continuation block \n" + " `del-ohr-block` - An attribute is added and this forces\n" + " the creation of object header\n" + " continuation block and then this \n" + " attribute is deleted so the \n" + " object header continuation block is \n" + " removed. \n" + "-O grp_op_pattern: `grp_op_pattern' for different group operation tests\n" + " The value of `grp_op_pattern` is one of the following:\n" + " `grp-creation` - A group is created.\n" + " `grp-deletion` - An existing group is deleted.\n" + " `grp-move` - A group is moved to become \n" + " another group. \n" + " `grp-ins-links` - Links are inserted, including\n" + " both hard and soft links. \n" + " `grp-del-links` - Links are deleted, including\n" + " both hard ans soft links. \n" + " `grp-compact-t-dense` - Links are inserted to the group.\n" + " The link storage of this group \n" + " changed from compact to dense. \n" + " The links include both hard and\n" + " soft links. \n" + " `grp-dense-t-compact` - Links are inserted to the group\n" + " The link storage of this group \n" + " changed from compact to dense. \n" + " Then several links are deleted.\n" + " The link storage changed from \n" + " dense to compact again. \n" + " The links include both hard and\n" + " soft links. \n" + "-q: silence printouts, few messages\n" + "\n", + progname); + exit(EXIT_FAILURE); +} + +static bool +state_init(state_t *s, int argc, char **argv) +{ + unsigned long tmp; + int ch; + const hsize_t dims = 1; + char * tfile = NULL; + char * end; + + *s = ALL_HID_INITIALIZER; + + if (H5_basename(argv[0], &tfile) < 0) { + printf("H5_basename failed\n"); + TEST_ERROR; + } + + esnprintf(s->progname, sizeof(s->progname), "%s", tfile); + + if (tfile) + HDfree(tfile); + + while ((ch = getopt(argc, argv, "PSGa:bc:n:Nqu:A:O:")) != -1) { + switch (ch) { + case 'P': + s->gperf = true; + break; + case 'S': + s->use_vfd_swmr = false; + break; + case 'G': + s->old_style_grp = true; + break; + case 'a': + case 'c': + case 'n': + case 'u': + errno = 0; + tmp = HDstrtoul(optarg, &end, 0); + if (end == optarg || *end != '\0') { + printf("couldn't parse `-%c` argument `%s`\n", ch, optarg); + TEST_ERROR; + } + else if (errno != 0) { + printf("couldn't parse `-%c` argument `%s`\n", ch, optarg); + TEST_ERROR; + } + else if (tmp > UINT_MAX) { + printf("`-%c` argument `%lu` too large\n", ch, tmp); + TEST_ERROR; + } + + if (ch == 'a') + s->asteps = (unsigned)tmp; + else if (ch == 'c') + s->csteps = (unsigned)tmp; + else if (ch == 'n') + s->nsteps = (unsigned)tmp; + else if (ch == 'u') + s->update_interval = (unsigned)tmp; + break; + case 'b': + s->filetype = H5T_STD_U32BE; + break; + case 'N': + s->use_named_pipes = false; + break; + case 'O': + if (HDstrcmp(optarg, "grp-creation") == 0) + s->grp_op_pattern = 'c'; + else if (HDstrcmp(optarg, "grp-deletion") == 0) + s->grp_op_pattern = 'd'; + else if (HDstrcmp(optarg, "grp-move") == 0) + s->grp_op_pattern = 'm'; + else if (HDstrcmp(optarg, "grp-ins-links") == 0) + s->grp_op_pattern = 'i'; + else if (HDstrcmp(optarg, "grp-del-links") == 0) + s->grp_op_pattern = 'D'; + else if (HDstrcmp(optarg, "grp-compact-t-dense") == 0) + s->grp_op_pattern = 't'; + else if (HDstrcmp(optarg, "grp-dense-t-compact") == 0) + s->grp_op_pattern = 'T'; + else { + printf("Invalid -O argument \"%s\"", optarg); + TEST_ERROR; + } + break; + case 'A': + if (HDstrcmp(optarg, "compact") == 0) + s->at_pattern = 'c'; + else if (HDstrcmp(optarg, "dense") == 0) + s->at_pattern = 'd'; + else if (HDstrcmp(optarg, "compact-add-to-dense") == 0) + s->at_pattern = 't'; + else if (HDstrcmp(optarg, "compact-del") == 0) + s->at_pattern = 'C'; + else if (HDstrcmp(optarg, "dense-del") == 0) + s->at_pattern = 'D'; + else if (HDstrcmp(optarg, "dense-del-to-compact") == 0) + s->at_pattern = 'T'; + else if (HDstrcmp(optarg, "modify") == 0) + s->at_pattern = 'M'; + else if (HDstrcmp(optarg, "add-vstr") == 0) + s->at_pattern = 'v'; + else if (HDstrcmp(optarg, "remove-vstr") == 0) + s->at_pattern = 'r'; + else if (HDstrcmp(optarg, "modify-vstr") == 0) + s->at_pattern = 'm'; + else if (HDstrcmp(optarg, "add-ohr-block") == 0) + s->at_pattern = 'a'; + else if (HDstrcmp(optarg, "del-ohr-block") == 0) + s->at_pattern = 'R'; + else { + printf("Invalid -A argument \"%s\"", optarg); + TEST_ERROR; + } + break; + case 'q': + verbosity = 0; + break; + case '?': + default: + usage(s->progname); + break; + } + } + argc -= optind; + argv += optind; + + if (s->grp_op_pattern != ' ') + s->grp_op_test = true; + if (s->at_pattern != ' ') + s->attr_test = true; + + if (!s->grp_op_test) { + if (s->asteps < 1 || s->asteps > s->nsteps) { + printf("attribute interval is out of bounds\n"); + TEST_ERROR; + } + } + + if (s->grp_op_test && s->attr_test) { + printf("Cannot test both group operation and attribute tests!\n"); + printf("Attribute tests are ignored.\n"); + } + + if (s->csteps < 1 || s->csteps > s->nsteps) { + printf("communication interval is out of bounds\n"); + TEST_ERROR; + } + + if (argc > 0) { + printf("unexpected command-line arguments\n"); + TEST_ERROR; + } + + /* space for attributes */ + if ((s->one_by_one_sid = H5Screate_simple(1, &dims, &dims)) < 0) { + printf("H5Screate_simple failed\n"); + TEST_ERROR; + } + + esnprintf(s->filename, sizeof(s->filename), "vfd_swmr_group.h5"); + + return true; + +error: + if (tfile) + HDfree(tfile); + return false; +} + +/* Named Pipe Subroutine: np_wr_send_receive + * Description: + * The writer sends a message to the reader, + * then waits for max_lag ticks, + * then checks the returned message from the reader. + * Return: + * True if succeed + * False if an error occurs in any step above. + * An error is mostly caused by an unexpected + * notification number from the message sent + * by the reader. + */ +static bool +np_wr_send_receive(state_t *s) +{ + + unsigned int i; + /* Bump up the value of notify to notice the reader to start to read */ + s->np_notify++; + if (HDwrite(s->np_fd_w_to_r, &(s->np_notify), sizeof(int)) < 0) { + printf("HDwrite failed\n"); + TEST_ERROR; + } + + /* During the wait, writer makes repeated HDF5 API calls + * to trigger EOT at approximately the correct time */ + for (i = 0; i < s->max_lag + 1; i++) { + decisleep(s->tick_len); + H5E_BEGIN_TRY + { + H5Aexists(s->file, "nonexistent"); + } + H5E_END_TRY; + } + + /* Receive the same value from the reader and verify it before + * going to the next step */ + (s->np_verify)++; + if (HDread(s->np_fd_r_to_w, &(s->np_notify), sizeof(int)) < 0) { + printf("HDread failed\n"); + TEST_ERROR; + } + + if (s->np_notify == -1) { + printf("reader failed to verify group or attribute operation.\n"); + TEST_ERROR; + } + + if (s->np_notify != s->np_verify) { + printf("received message %d, expecting %d\n", s->np_notify, s->np_verify); + TEST_ERROR; + } + + return true; + +error: + return false; +} + +/* Named Pipe Subroutine: np_rd_receive + * Description: + * The reader receives a message from the writer, + * then checks if the notification number from + * the writer is expected. + * Return: + * True if succeed + * False if an error occurs in any step above. + * An error is mostly caused by an unexpected + * notification number from the message sent + * by the writer. + */ +static bool +np_rd_receive(state_t *s) +{ + + /* The writer should have bumped up the value of notify. + * Do the same with verify and confirm it */ + s->np_verify++; + + /* Receive the notify that the writer bumped up the value */ + if (HDread(s->np_fd_w_to_r, &(s->np_notify), sizeof(int)) < 0) { + printf("HDread failed\n"); + TEST_ERROR; + } + + if (s->np_notify == -1) { + printf("writer failed to create group or carry out an attribute operation.\n"); + TEST_ERROR; + } + + if (s->np_notify != s->np_verify) { + printf("received message %d, expecting %d\n", s->np_notify, s->np_verify); + TEST_ERROR; + } + + return true; + +error: + return false; +} + +/* Named Pipe Subroutine: np_rd_send + * Description: + * The reader sends an acknowledgement to the writer + * Return: + * True if succeed + * False if an error occurs in sending the message. + */ +static bool +np_rd_send(state_t *s) +{ + + if (HDwrite(s->np_fd_r_to_w, &(s->np_notify), sizeof(int)) < 0) { + H5_FAILED(); + AT(); + printf("HDwrite failed\n"); + return false; + } + else + return true; +} + +/* Named Pipe Subroutine: np_send_error + * Description: + * An error (notification number is 1) message is sent + * either from the reader or the writer. + * A boolean input parameter is used to choose + * either reader or writer. + * Return: + * None + */ +static void +np_send_error(state_t *s, bool writer) +{ + s->np_notify = -1; + if (writer) + HDwrite(s->np_fd_w_to_r, &(s->np_notify), sizeof(int)); + else + HDwrite(s->np_fd_r_to_w, &(s->np_notify), sizeof(int)); +} + +/*------------------------------------------------------------------------- + * Function: check_ohr_num_chunk + * + * Purpose: Check if the number of object header chunks is as expected. + * + * Parameters: hid_t oid + * HDF5 object ID (in this file: means group ID) + * + * bool one_chunk_ohr + * flag to indicate if the object header chunk is 1 or greater + * 1: true + * greater than 1: false + * + * Return: Success: true + * Failure: false + * + *------------------------------------------------------------------------- + */ + +static bool +check_ohr_num_chunk(hid_t g, bool one_chunk_ohr) +{ + + H5O_native_info_t ninfo; + + /* Get the object information */ + if (H5Oget_native_info(g, &ninfo, H5O_NATIVE_INFO_HDR) < 0) { + printf("H5Oget_native_info failed\n"); + TEST_ERROR; + } + + if (true == one_chunk_ohr) { + if (ninfo.hdr.nchunks != 1) { + printf("Object header should have only one chunk,but it is not.\n"); + TEST_ERROR; + } + } + else { + if (ninfo.hdr.nchunks <= 1) { + printf("Object header should have more than one chunk,but it is not.\n"); + TEST_ERROR; + } + } + + return true; + +error: + return false; +} + +/*------------------------------------------------------------------------- + * Function: add_attr + * + * Purpose: Add attributes to a group. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t oid + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group name. The group name is "group-which". + * + * unsigned num_attrs + * The number of attributes to be created + * + * const char*aname_fmt + * The attribute name template used to create unique attribute names. + * + * unsigned int g_which + * This parameter is used to generate correct group name in a key + * debugging message. + * + * Return: Success: true + * Failure: false + * + *------------------------------------------------------------------------- + */ + +static bool +add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const char *aname_fmt, + unsigned int g_which) +{ + + char attrname[VS_ATTR_NAME_LEN]; + unsigned u; + unsigned attr_value; + hid_t aid = H5I_INVALID_HID; + hid_t amtype = H5I_INVALID_HID; + hid_t atype = s->filetype; + hid_t sid = s->one_by_one_sid; + + /* Need to obtain native datatype for H5Aread */ + if ((amtype = H5Tget_native_type(atype, H5T_DIR_ASCEND)) < 0) { + printf("H5Tget_native_type failed\n"); + TEST_ERROR; + } + + for (u = 0; u < num_attrs; u++) { + + /* Create attribute */ + /* Construct attribute name like attr-0-0 */ + HDsprintf(attrname, aname_fmt, which, u); + if ((aid = H5Acreate2(oid, attrname, atype, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + printf("H5Acreate2 failed\n"); + TEST_ERROR; + } + + attr_value = u + which; + + dbgf(1, "setting attribute %s on group %u to %u\n", attrname, g_which, u + which); + + /* Write data into the attribute */ + if (H5Awrite(aid, amtype, &attr_value) < 0) { + printf("H5Awrite failed\n"); + TEST_ERROR; + } + + /* Close attribute */ + if (H5Aclose(aid) < 0) { + printf("H5Aclose failed\n"); + TEST_ERROR; + } + + /* If coming to an "object header continuation block" test, + * we need to check if this test behaves as expected. */ + if (s->at_pattern == 'a' || s->at_pattern == 'R') { + if (false == check_ohr_num_chunk(oid, false)) { + printf("An object header continuation block should be created. \n"); + printf("But it is not.\n"); + TEST_ERROR; + } + } + + /* Writer sends a message to reader: an attribute is successfully generated. + then wait for the reader to verify and send an acknowledgement message back.*/ + if (s->use_named_pipes && s->attr_test == true) { + dbgf(2, "writer: write attr - ready to send/receive message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); + dbgf(2, "writer: write attr - verification failed.\n"); + /* Note: This is (mostly) because the verification failure message + * from the reader. So don't send the error message back to + * the reader. Just stop the test. */ + goto error2; + } + } + + } /* end for */ + + if (H5Tclose(amtype) < 0) { + TEST_ERROR; + } + + return true; + +error: + /* Writer needs to send an error message to the reader to stop the test*/ + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); + +error2: + H5E_BEGIN_TRY + { + H5Aclose(aid); + H5Tclose(amtype); + } + H5E_END_TRY; + + return false; +} + +/*------------------------------------------------------------------------- + * Function: add_default_group_attr + * + * Purpose: Add an attribute to a group. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group and attribute names. + * The group name is "group-which" and the attribute name + * is "attr-which". + * + * + * Return: Success: true + * Failure: false + * + * Note: This function is used for the "dense" storage test. + * It is also used by the group-only, "add-ohr-block" + * and "del-ohr-block" tests. + *------------------------------------------------------------------------- + */ + +static bool +add_default_group_attr(state_t *s, hid_t g, unsigned int which) +{ + + const char *aname_format = "attr-%u"; + + /* Note: Since we only add one attribute, the parameter for + * the number of attributes is 1. */ + return add_attr(s, g, which, 1, aname_format, which); +} + +/*------------------------------------------------------------------------- + * Function: add_vlstr_attr + * + * Purpose: Add a variable length string attribute to a group. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group and attribute names. + * The group name is "group-which" and the attribute name + * is "attr-which". + * + * + * Return: Success: true + * Failure: false + * + * Note: This is for the "vstr" test. + *------------------------------------------------------------------------- + */ + +static bool +add_vlstr_attr(state_t *s, hid_t g, unsigned int which) +{ + + hid_t aid = H5I_INVALID_HID; + hid_t atype = H5I_INVALID_HID; + char name[VS_ATTR_NAME_LEN]; + char *astr_val = NULL; + hid_t sid = s->one_by_one_sid; + + /* Allocate buffer for the VL string value */ + astr_val = HDmalloc(VS_ATTR_NAME_LEN); + if (astr_val == NULL) { + printf("Allocate memory for VL string failed.\n"); + TEST_ERROR; + } + + /* Assign the VL string value and the attribute name.. */ + HDsprintf(astr_val, "%u", which); + esnprintf(name, sizeof(name), "attr-%u", which); + + dbgf(1, "setting attribute %s on group %u to %u\n", name, which, which); + + /* Create a datatype to refer to. */ + if ((atype = H5Tcopy(H5T_C_S1)) < 0) { + printf("Cannot create variable length datatype.\n"); + TEST_ERROR; + } + + if (H5Tset_size(atype, H5T_VARIABLE) < 0) { + printf("Cannot set variable length datatype.\n"); + TEST_ERROR; + } + + /* Generate the VL string attribute.*/ + if ((aid = H5Acreate2(g, name, atype, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + printf("H5Acreate2 failed.\n"); + TEST_ERROR; + } + + if (H5Awrite(aid, atype, &astr_val) < 0) { + printf("H5Awrite failed.\n"); + TEST_ERROR; + } + + if (H5Tclose(atype) < 0) { + printf("H5Tclose() failed\n"); + TEST_ERROR; + } + if (H5Aclose(aid) < 0) { + printf("H5Aclose() failed\n"); + TEST_ERROR; + } + + HDfree(astr_val); + + /* Writer sends a message to reader: a VL string attribute is successfully generated. + then wait for the reader to verify and send an acknowledgement message back. */ + if (s->use_named_pipes && s->attr_test == true) { + dbgf(2, "writer: write attr - ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); + dbgf(2, "writer: write attr - verification failed.\n"); + goto error2; + } + } + + return true; + +error: + /* Writer needs to send an error message to the reader to stop the test*/ + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); + H5E_BEGIN_TRY + { + H5Aclose(aid); + H5Tclose(atype); + } + H5E_END_TRY; + + if (astr_val) + HDfree(astr_val); + +error2: + return false; +} + +/*------------------------------------------------------------------------- + * Function: del_one_attr + * + * Purpose: delete one attribute in a group. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t obj_id + * HDF5 object ID (in this file: means group ID) + * + * bool is_dense + * if the deleted attribute is for checking the dense storage + * + * bool is_vl_or_ohrc + * if the deleted attribute is a VL string or for object header + * continuation check test + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group and attribute names. + * The group name is "group-which" and the attribute names + * according to if this attribute is a VL string or for checking + * the dense storage or the storage transition from dense to + * compact. + * + * + * Return: Success: true + * Failure: false + * + *------------------------------------------------------------------------- + */ + +static bool +del_one_attr(state_t *s, hid_t obj_id, bool is_dense, bool is_vl_or_ohrc, unsigned int which) +{ + + char attrname[VS_ATTR_NAME_LEN]; + + /*attribute name template for the dense storage related deletion operation */ + const char *aname_format_d = "attr-d-%u-%u"; + + /*attribute name template used for general attribute deletion operation */ + const char *aname_format = "attr-%u-%u"; + + /*attribute name template used for VL string attribute deletion + * or object header continuation check operations */ + const char *aname_format_vl = "attr-%u"; + + dbgf(2, "writer: coming to delete the attribute.\n"); + + /* Construct the attribute name */ + if (is_dense == true) + HDsprintf(attrname, aname_format_d, which, 0); + else if (is_vl_or_ohrc == true) + HDsprintf(attrname, aname_format_vl, which, 0); + else + HDsprintf(attrname, aname_format, which, 0); + + /* Delete the attribute */ + if (H5Adelete(obj_id, attrname) < 0) { + printf("H5Adelete() failed\n"); + TEST_ERROR; + } + + /* If coming to an "object header continuation block" test, + * we need to check if this test behaves as expected. */ + if (s->at_pattern == 'R') { + if (false == check_ohr_num_chunk(obj_id, true)) { + printf("The object header chunk should not continue. \n"); + TEST_ERROR; + } + } + /* Writer sends a message to reader: an attribute is successfully generated. + then wait for the reader to verify and send an acknowledgement message back. */ + if (s->use_named_pipes && s->attr_test == true) { + dbgf(2, "writer: delete attr - ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); + dbgf(2, "writer: delete attr - verification failed.\n"); + goto error2; + } + } + + return true; + +error: + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); + +error2: + return false; +} + +/*------------------------------------------------------------------------- + * Function: add_del_vlstr_attr + * + * Purpose: Add a variable length string attribute + * then delete this attribute in this a group. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group and attribute names. + * The group name is "group-which" and the attribute name + * is "attr-which". + * + * + * Return: Success: true + * Failure: false + * + * Note: This is for the "remove-vstr" test. + *------------------------------------------------------------------------- + */ + +static bool +add_del_vlstr_attr(state_t *s, hid_t g, unsigned int which) +{ + + bool ret_value = false; + + /* Add a VL string attribute then delete it. */ + ret_value = add_vlstr_attr(s, g, which); + if (ret_value == true) + ret_value = del_one_attr(s, g, false, true, which); + + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: modify_attr + * + * Purpose: Modify the value of an attribute in a group. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * const char*aname_fmt + * The attribute name template used to create unique attribute names. + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group name. The group name is "group-which". + * + * + * Return: Success: true + * Failure: false + * + *------------------------------------------------------------------------- + */ + +static bool +modify_attr(state_t *s, hid_t g, const char *aname_fmt, unsigned int which) +{ + + char attrname[VS_ATTR_NAME_LEN]; + hid_t aid = H5I_INVALID_HID; + hid_t amtype = H5I_INVALID_HID; + unsigned int modify_value; + + HDsprintf(attrname, aname_fmt, which, 0); + if ((aid = H5Aopen(g, attrname, H5P_DEFAULT)) < 0) { + printf("H5Aopen failed\n"); + TEST_ERROR; + } + + if ((amtype = H5Tget_native_type(s->filetype, H5T_DIR_ASCEND)) < 0) { + printf("H5Tget_native_type failed\n"); + TEST_ERROR; + } + + /* Make a large number to verify the change easily */ + modify_value = which + 10000; + + if (H5Awrite(aid, amtype, &modify_value) < 0) { + printf("H5Awrite failed\n"); + TEST_ERROR; + } + if (H5Tclose(amtype) < 0) { + printf("H5Tclose failed\n"); + TEST_ERROR; + } + if (H5Aclose(aid) < 0) { + printf("H5Aclose failed\n"); + TEST_ERROR; + } + + /* Writer sends a message to reader: an attribute is successfully modified. + then wait for the reader to verify and send an acknowledgement message back.*/ + if (s->use_named_pipes && s->attr_test == true) { + dbgf(2, "writer: modify attr - ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); + dbgf(2, "writer: write attr - verification failed.\n"); + /* Note: This is (mostly) because the verification failure message + * from the reader. So don't send the error message back to + * the reader. Just stop the test. */ + goto error2; + } + } + + return true; +error: + /* Writer needs to send an error message to the reader to stop the test*/ + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); + H5E_BEGIN_TRY + { + H5Aclose(aid); + H5Tclose(aid); + } + H5E_END_TRY; + +error2: + return false; +} + +/*------------------------------------------------------------------------- + * Function: modify_vlstr_attr + * + * Purpose: Modify the value of an VL string attribute in a group. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group name. The group name is "group-which". + * + * + * Return: Success: true + * Failure: false + * + *------------------------------------------------------------------------- + */ + +static bool +modify_vlstr_attr(state_t *s, hid_t g, unsigned int which) +{ + + hid_t aid = H5I_INVALID_HID; + hid_t atype = H5I_INVALID_HID; + char name[VS_ATTR_NAME_LEN]; + char *astr_val = NULL; + + astr_val = HDmalloc(VS_ATTR_NAME_LEN); + if (astr_val == NULL) { + printf("Allocate memory for VL string failed.\n"); + TEST_ERROR; + } + + /* Change the VL string value and create the attribute name. */ + HDsprintf(astr_val, "%u%c", which, 'A'); + esnprintf(name, sizeof(name), "attr-%u", which); + + dbgf(1, "setting attribute %s on group %u to %u\n", name, which, which); + + /* Create a datatype to refer to. */ + if ((atype = H5Tcopy(H5T_C_S1)) < 0) { + printf("Cannot create variable length datatype.\n"); + TEST_ERROR; + } + + if (H5Tset_size(atype, H5T_VARIABLE) < 0) { + printf("Cannot set variable length datatype.\n"); + TEST_ERROR; + } + + /* Open this attribute. */ + if ((aid = H5Aopen(g, name, H5P_DEFAULT)) < 0) { + printf("H5Aopen failed.\n"); + TEST_ERROR; + } + + dbgf(1, "The modified VL string value is %s \n", astr_val); + + if (H5Awrite(aid, atype, &astr_val) < 0) { + printf("H5Awrite failed.\n"); + TEST_ERROR; + } + + if (H5Tclose(atype) < 0) { + printf("H5Tclose() failed\n"); + TEST_ERROR; + } + + if (H5Aclose(aid) < 0) { + printf("H5Aclose() failed\n"); + TEST_ERROR; + } + + HDfree(astr_val); + + /* Writer sends a message to reader: a VL string attribute is successfully generated. + then wait for the reader to verify and send an acknowledgement message back. */ + if (s->use_named_pipes && s->attr_test == true) { + dbgf(2, "writer: modify vl attr - ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); + dbgf(2, "writer: write attr - verification failed.\n"); + goto error2; + } + } + + return true; + +error: + H5E_BEGIN_TRY + { + H5Aclose(aid); + H5Tclose(atype); + } + H5E_END_TRY; + + if (astr_val) + HDfree(astr_val); + + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); + +error2: + return false; +} + +/*------------------------------------------------------------------------- + * Function: add_modify_vlstr_attr + * + * Purpose: Add a variable length string attribute + * then modify this attribute in this a group. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group and attribute names. + * The group name is "group-which" and the attribute name + * is "attr-which". + * + * + * Return: Success: true + * Failure: false + * + * Note: This is for the "modify-vstr" test. + *------------------------------------------------------------------------- + */ + +static bool +add_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which) +{ + + bool ret_value = false; + ret_value = add_vlstr_attr(s, g, which); + if (true == ret_value) + ret_value = modify_vlstr_attr(s, g, which); + + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: add_attrs_compact + * + * Purpose: Add some attributes to the group. + * the number of attributes should be the maximal number of + * attributes that the compact storage can hold + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * hid_t gcpl + * Object creation property list ID + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group and attribute names. + * The group name is "group-which" and the attribute name + * is "attr-which". + * + * + * Return: Success: true + * Failure: false + * + * Note: This is for the "modify-vstr" test. + * For attribute compact/dense storage, check the reference + * manual of H5Pget_attr_phase_change. + *------------------------------------------------------------------------- + */ + +static bool +add_attrs_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which) +{ + + unsigned max_compact = 0; + unsigned min_dense = 0; + const char *aname_format = "attr-%u-%u"; + + if (s->old_style_grp) + max_compact = 2; + else { + /* Obtain the maximal number of attributes to be stored in compact + * storage and the minimal number of attributes to be stored in + * dense storage. */ + if (H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { + printf("H5Pget_attr_phase_change() failed\n"); + TEST_ERROR; + } + } + + /* Add max_compact attributes, these attributes are stored in + * compact storage. */ + return add_attr(s, g, which, max_compact, aname_format, which); + +error: + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); + return false; +} + +/*------------------------------------------------------------------------- + * Function: add_attrs_compact_dense + * + * Purpose: Add some attributes to the group. + * First, the number of attributes should be the maximal number + * of attributes that the compact storage can hold. + * Then, add another atribute, the storage becomes dense. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * hid_t gcpl + * Object creation property list ID + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group and attribute names. + * + * Return: Success: true + * Failure: false + * + * Note: This is for the "compact-to-dense" test. + * For attribute compact/dense storage, check the reference + * manual of H5Pget_attr_phase_change. + *------------------------------------------------------------------------- + */ + +static bool +add_attrs_compact_dense(state_t *s, hid_t g, hid_t gcpl, unsigned int which) +{ + + unsigned max_compact = 0; + unsigned min_dense = 0; + const char *aname_format = "attr-d-%u-%u"; + bool ret_value = false; + + if (H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { + printf("H5Pget_attr_phase_change failed\n"); + TEST_ERROR; + } + + /* Add attributes, until just before converting to dense storage */ + ret_value = add_attrs_compact(s, g, gcpl, which); + + /* Add another attribute, the storage becomes dense. */ + if (ret_value == true) + ret_value = add_attr(s, g, which + max_compact, 1, aname_format, which); + + return ret_value; + +error: + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); + return false; +} + +/*------------------------------------------------------------------------- + * Function: del_attrs_compact_dense_compact + * + * Purpose: delete some attributes in the group. + * The number of attributes are deleted in such a way + * that the attribute storage changes from compact to + * dense then to compact again. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * hid_t gcpl + * Object creation property list ID + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group and attribute names. + * + * Return: Success: true + * Failure: false + * + * Note: This is an internal function used by the + * "dense-del-to-compact" test. + * For attribute compact/dense storage, check the reference + * manual of H5Pget_attr_phase_change. + *------------------------------------------------------------------------- + */ + +static bool +del_attrs_compact_dense_compact(state_t *s, hid_t obj_id, hid_t gcpl, unsigned int which) +{ + + unsigned max_compact = 0; + unsigned min_dense = 0; + unsigned u = 0; + + char attrname[VS_ATTR_NAME_LEN]; + const char *aname_format = "attr-%u-%u"; + const char *adname_format = "attr-d-%u-%u"; + + /* Obtain the maximal number of attributes to be stored in compact + * storage and the minimal number of attributes to be stored in + * dense storage. */ + if (H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { + printf("H5Pget_attr_phase_change failed\n"); + TEST_ERROR; + } + u = max_compact + 1; + + /* delete a number of attributes so that the attribute storage just becomes dense.*/ + for (u--; u >= (min_dense - 1); u--) { + HDsprintf(attrname, aname_format, which, max_compact - u); + if (H5Adelete(obj_id, attrname) < 0) { + printf("H5Adelete failed\n"); + TEST_ERROR; + } + + /* For each attribute deletion, we want to ensure the verification + * from the reader. + * So writer sends a message to reader: an attribute is successfully deleted. + then wait for reader to verify and send an acknowledgement message back. */ + if (s->use_named_pipes && s->attr_test == true) { + dbgf(2, "writer: delete attr - ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); + dbgf(2, "writer: delete attr - verification failed.\n"); + goto error2; + } + } + } + + /* The writer deletes another attribute, the storage is + * still dense. However, the attribute to be deleted + * doesn't follow the previous for loop. It may be + * in different location in the object header. Just add + * a litter variation to check if this operation is successful. + * The attribute name to be deleted is attr-max_compact+which-0 + */ + + HDsprintf(attrname, adname_format, max_compact + which, 0); + if (H5Adelete(obj_id, attrname) < 0) { + printf("H5Adelete failed\n"); + TEST_ERROR; + } + /* Again we need to notify the reader via Named pipe. */ + if (s->use_named_pipes && s->attr_test == true) { + dbgf(2, "writer: delete attr - ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); + dbgf(2, "writer: delete attr - verification failed.\n"); + goto error2; + } + } + + /* The following comments are left here in case in the future we want to + * use HDF5 function to verify the attribute storage */ +#if 0 + // May H5Oget_info3 -- obtain the number of attributes. + //Check the number of attributes >=min_dense. + //We may use the internal function + //is_dense = H5O__is_attr_dense_test(dataset) to check if it is dense in the future. + // +#endif + + return true; + +error: + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); + +error2: + return false; +} + +/*------------------------------------------------------------------------- + * Function: add_del_attrs_compact + * + * Purpose: Add some attributes to the group and then delete one attribute. + * First, the number of attributes to be added should be the + * maximal number of attributes that the compact storage can hold. + * Then, delete one atribute, the storage is still compact. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * hid_t gcpl + * Object creation property list ID + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group and attribute names. + * + * Return: Success: true + * Failure: false + * + * Note: This is for the "compact-del" test. + * For attribute compact/dense storage, check the reference + * manual of H5Pget_attr_phase_change. + *------------------------------------------------------------------------- + */ + +static bool +add_del_attrs_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which) +{ + + bool ret_value = false; + ret_value = add_attrs_compact(s, g, gcpl, which); + if (ret_value == true) { + dbgf(2, "writer: before deleting the attribute.\n"); + ret_value = del_one_attr(s, g, false, false, which); + } + + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: add_del_attrs_compact_dense + * + * Purpose: Add some attributes to the group and then delete one attribute. + * First, the number of attributes to be added exceeds + * the maximal number of attributes that the compact storage can hold. + * The storage changes from compact to dense. + * Then, delete one atribute, the storage is still dense. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * hid_t gcpl + * Object creation property list ID + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group and attribute names. + * + * Return: Success: true + * Failure: false + * + * Note: This is for the "dense-del" test. + * For attribute compact/dense storage, check the reference + * manual of H5Pget_attr_phase_change. + *------------------------------------------------------------------------- + */ + +static bool +add_del_attrs_compact_dense(state_t *s, hid_t g, hid_t gcpl, unsigned int which) +{ + + bool ret_value = false; + unsigned max_compact = 0; + unsigned min_dense = 0; + + if (H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { + printf("H5Pget_attr_phase_change failed\n"); + TEST_ERROR; + } + + ret_value = add_attrs_compact_dense(s, g, gcpl, which); + if (ret_value == true) + ret_value = del_one_attr(s, g, true, false, which + max_compact); + + return ret_value; + +error: + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, true); + return false; +} + +/*------------------------------------------------------------------------- + * Function: add_del_attrs_compact_dense_compact + * + * Purpose: Add attributes to the group and then delete some of them. + * First, the number of attributes to be added exceeds + * the maximal number of attributes that the compact storage can hold. + * The storage changes from compact to dense. + * Then, delete some attributes, the storage changes from + * dense to compact again. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * hid_t gcpl + * Object creation property list ID + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group and attribute names. + * + * Return: Success: true + * Failure: false + * + * Note: This is for the "dense-del-to-compact" test. + * For attribute compact/dense storage, check the reference + * manual of H5Pget_attr_phase_change. + *------------------------------------------------------------------------- + */ + +static bool +add_del_attrs_compact_dense_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which) +{ + + bool ret_value = false; + ret_value = add_attrs_compact_dense(s, g, gcpl, which); + if (ret_value == true) + ret_value = del_attrs_compact_dense_compact(s, g, gcpl, which); + + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: add_modify_default_group_attr + * + * Purpose: Add an attribute then modify the value to a group. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group and attribute names. + * The group name is "group-which" and the attribute name + * is "attr-which". + * + * + * Return: Success: true + * Failure: false + * + * Note: This function is used for the "modify" test. + *------------------------------------------------------------------------- + */ + +static bool +add_modify_default_group_attr(state_t *s, hid_t g, unsigned int which) +{ + + bool ret_value = false; + const char *aname_format = "attr-%u"; + ret_value = add_default_group_attr(s, g, which); + if (ret_value == true) + ret_value = modify_attr(s, g, aname_format, which); + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: del_ohr_block_attr + * + * Purpose: Add an attribute to force creation of object header + * continuation block and remove this attribute to delete + * the object header continuation block + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group and attribute names. + * The group name is "group-which" and the attribute name + * is "attr-which". + * + * + * Return: Success: true + * Failure: false + * + * Note: This function is used for the + * "deletion of object header continuation block" test. + *------------------------------------------------------------------------- + */ + +static bool +del_ohr_block_attr(state_t *s, hid_t g, unsigned int which) +{ + + bool ret_value = false; + ret_value = add_default_group_attr(s, g, which); + if (ret_value == true) + ret_value = del_one_attr(s, g, false, true, which); + return ret_value; +} +/*------------------------------------------------------------------------- + * Function: add_group_attribute + * + * Purpose: Check the attribute test pattern and then call the + * correponding test function.. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * hid_t gcpl + * Object creation property list ID + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group and attribute names. + * + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the write_group() function. + *------------------------------------------------------------------------- + */ + +static bool +add_group_attribute(state_t *s, hid_t g, hid_t gcpl, unsigned int which) +{ + + bool ret_value = false; + char test_pattern = s->at_pattern; + + switch (test_pattern) { + case 'c': + ret_value = add_attrs_compact(s, g, gcpl, which); + break; + case 't': + ret_value = add_attrs_compact_dense(s, g, gcpl, which); + break; + case 'C': + ret_value = add_del_attrs_compact(s, g, gcpl, which); + break; + case 'D': + ret_value = add_del_attrs_compact_dense(s, g, gcpl, which); + break; + case 'T': + ret_value = add_del_attrs_compact_dense_compact(s, g, gcpl, which); + break; + case 'M': + ret_value = add_modify_default_group_attr(s, g, which); + break; + case 'v': + ret_value = add_vlstr_attr(s, g, which); + break; + case 'r': + ret_value = add_del_vlstr_attr(s, g, which); + break; + case 'm': + ret_value = add_modify_vlstr_attr(s, g, which); + break; + case 'R': + ret_value = del_ohr_block_attr(s, g, which); + break; + case 'a': + case 'd': + case ' ': + default: + ret_value = add_default_group_attr(s, g, which); + break; + } + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: write_group + * + * Purpose: Create a group and carry out attribute operations(add,delete etc.) + * according to the attribute test pattern. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations for group creation + * + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the main() function. + *------------------------------------------------------------------------- + */ + +static bool +write_group(state_t *s, unsigned int which) +{ + char name[sizeof("/group-9999999999")]; + hid_t g = H5I_INVALID_HID; + hid_t dummy_d = H5I_INVALID_HID; + hid_t gcpl = H5I_INVALID_HID; + bool result = true; + H5G_info_t group_info; + struct timespec start_time, end_time; + double temp_time; + + if (which >= s->nsteps) { + printf("Number of created groups is out of bounds\n"); + TEST_ERROR; + } + + esnprintf(name, sizeof(name), "/group-%u", which); + +#if 0 + if (s->old_style_grp) + gcpl = H5P_DEFAULT; + else { + gcpl = H5Pcreate(H5P_GROUP_CREATE); + if (gcpl < 0) { + printf("H5Pcreate failed\n"); + TEST_ERROR; + } + + /* If we test the dense storage, change the attribute phase. */ + if (s->at_pattern == 'd') { + if (H5Pset_attr_phase_change(gcpl, 0, 0) < 0) { + printf("H5Pset_attr_phase_change failed for the dense storage.\n"); + TEST_ERROR; + } + } + } +#endif + + if(s->gperf) { + + if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { + + fprintf(stderr, "HDclock_gettime failed"); + + TEST_ERROR; + + } + + + } + if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + printf("H5Gcreate2 failed\n"); + TEST_ERROR; + } + + if(s->gperf) { + + if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { + + fprintf(stderr, "HDclock_gettime failed"); + + TEST_ERROR; + + } + + + temp_time = TIME_PASSED(start_time,end_time); + if(temp_time < s->min_time) + s->min_time = temp_time; + if(temp_time > s->max_time) + s->max_time = temp_time; + s->total_time += temp_time; + } + + +#if 0 + /* We need to create a dummy dataset for the object header continuation block test. */ + if (s->at_pattern == 'a' || s->at_pattern == 'R') { + if ((dummy_d = H5Dcreate2(g, "Dataset", H5T_NATIVE_INT, s->one_by_one_sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) { + printf("H5Dcreate2 failed\n"); + TEST_ERROR; + } + } + if (H5Gget_info(g, &group_info) < 0) { + printf("H5Gget_info failed\n"); + TEST_ERROR; + } + + if (s->old_style_grp) { + if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { + printf("Old-styled group test: but the group is not in old-style. \n"); + TEST_ERROR; + } + dbgf(2, "Writer: group is created with the old-style.\n"); + } + else { + if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { + printf("The created group should NOT be in old-style . \n"); + TEST_ERROR; + } + dbgf(2, "Writer: group is created with the new-style.\n"); + } + + /* If coming to an "object header continuation block" test, + * we need to check if this test behaves as expected. */ + if (s->at_pattern == 'a' || s->at_pattern == 'R') { + if (false == check_ohr_num_chunk(g, true)) { + printf("An object header continuation block should NOT be created. \n"); + printf("But it is created.\n"); + TEST_ERROR; + } + } + + /* If an attribute test is turned on and named pipes are used, + * the writer should send and receive messages after the group creation. + * This will distinguish an attribute operation error from an + * group creation error. + * Writer sends a message to reader: an attribute is successfully generated. + * then wait for the reader to verify and send an acknowledgement message back.*/ + if (s->use_named_pipes && s->attr_test == true) { + dbgf(2, "writer: ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); + /* Note: This is (mostly) because the verification failure message + * from the reader. So don't send the error message back to + * the reader. Just stop the test. */ + goto error2; + } + } + + /* Then carry out the attribute operation. */ + if (s->asteps != 0 && which % s->asteps == 0) + result = add_group_attribute(s, g, gcpl, which); + + if (s->at_pattern == 'a' || s->at_pattern == 'R') { + if (H5Dclose(dummy_d) < 0) { + printf("H5Dclose failed\n"); + TEST_ERROR; + } + } +#endif + if (H5Gclose(g) < 0) { + printf("H5Gclose failed\n"); + TEST_ERROR; + } + + + return result; + +error: + + + H5E_BEGIN_TRY { + H5Gclose(g); + } + H5E_END_TRY; + + return false; +} +/*------------------------------------------------------------------------- + * Function: check_attr_storage_type + * + * Purpose: Check if the attribute storage type is correct + * + * Parameters: hid_t oid + * HDF5 object ID (in this file: means group ID) + * + * bool is_compact + * true if the attribute is stored in compact storage + * false if the attribute is stored in dense storage + * + * + * Return: Success: true + * Failure: false + * + *------------------------------------------------------------------------- + */ + +static bool +check_attr_storage_type(hid_t g, bool is_compact) +{ + + H5O_native_info_t ninfo; + + /* Get the object information */ + if (H5Oget_native_info(g, &ninfo, H5O_NATIVE_INFO_HDR | H5O_NATIVE_INFO_META_SIZE) < 0) { + printf("H5Oget_native_info failed\n"); + TEST_ERROR; + } + + if (is_compact) { + if (ninfo.meta_size.attr.index_size != 0 || ninfo.meta_size.attr.heap_size != 0) { + printf("Should be in compact storage,but it is not.\n"); + TEST_ERROR; + } + } + else { + if (ninfo.meta_size.attr.index_size == 0 || ninfo.meta_size.attr.heap_size == 0) { + printf("Should be in dense storage,but it is not.\n"); + TEST_ERROR; + } + } + + return true; + +error: + return false; +} + +/*------------------------------------------------------------------------- + * Function: vrfy_attr + * + * Purpose: Verify is a group attribute value is as expected. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t oid + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group name. The group name is "group-which". + * + * const char*aname + * The attribute name + * + * unsigned int g_which + * This parameter is used to generate correct group name in a key + * debugging message. + * + * bool check_storage + * a flag to indicate if the storage check is on + * + * bool is_compact + * true if the attribute storage should be in compact + * false if the attribute storage should be in dense + * Note: this parameter is not used if the check_storage + * is set to false. + * + * + * Return: Success: true + * Failure: false + * + *------------------------------------------------------------------------- + */ + +static bool +vrfy_attr(state_t *s, hid_t g, unsigned int which, const char *aname, unsigned int g_which, + bool check_storage, bool is_compact) +{ + + unsigned int read_which; + hid_t aid = H5I_INVALID_HID; + hid_t amtype = H5I_INVALID_HID; + + /* The reader receives a message from the writer.Then sleep + * for a few ticks or stop the test if receiving an error + * message. + */ + if (s->use_named_pipes && true == s->attr_test) { + if (false == np_rd_receive(s)) { + H5_FAILED(); + AT(); + /* Since receiving the error message from the writer, + * just stop the test. */ + goto error2; + } + decisleep(s->tick_len * s->update_interval); + dbgf(1, "Reader: finish reading the message: %d\n", s->np_notify); + } + + /* Go ahead to read the attribute. */ + dbgf(1, "verifying attribute %s on group %u equals %u\n", aname, g_which, which); + + if ((amtype = H5Tget_native_type(s->filetype, H5T_DIR_ASCEND)) < 0) { + printf("H5Tget_native_type failed\n"); + TEST_ERROR; + } + + if ((aid = H5Aopen(g, aname, H5P_DEFAULT)) < 0) { + printf("H5Aopen failed\n"); + TEST_ERROR; + } + + if (H5Aread(aid, amtype, &read_which) < 0) { + printf("H5Aread failed\n"); + TEST_ERROR; + } + + if (H5Aclose(aid) < 0) { + printf("H5Aclose failed\n"); + TEST_ERROR; + } + + if (read_which != which) { + printf("reader: the add_attribute verfication failed,expected value is %d\n", which); + printf("reader: the add_attribute verfication failed, the value is %d\n", read_which); + printf("The add_attribute verification failed\n"); + TEST_ERROR; + } + + if (!s->old_style_grp && check_storage == true) { + if (false == check_attr_storage_type(g, is_compact)) { + printf("The attribute storage type is wrong. \n"); + TEST_ERROR; + } + dbgf(2, "reader: finish checking the storage type: %d\n", s->np_notify); + } + + /* If coming to an "object header continuation block" test, + * we need to check if this test behaves as expected. */ + if (s->at_pattern == 'a' || s->at_pattern == 'R') { + if (false == check_ohr_num_chunk(g, false)) { + printf("An object header continuation block should be created. \n"); + printf("But it is not.\n"); + printf("Verification of 'object header continuation block test' failed.\n"); + TEST_ERROR; + } + } + + /* If the read value is expected, send back an OK message to the writer. */ + if (s->use_named_pipes && s->attr_test == true) { + if (np_rd_send(s) == false) { + printf("named pipe reader send message error\n"); + TEST_ERROR; + } + dbgf(2, "reader: finish sending back the message: %d\n", s->np_notify); + } + return true; + +error: + H5E_BEGIN_TRY + { + H5Tclose(amtype); + H5Aclose(aid); + } + H5E_END_TRY; + + /* Send back an error message to the writer so that the writer can stop. */ + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, false); +error2: + return false; +} + +/*------------------------------------------------------------------------- + * Function: verify_default_group_attr + * + * Purpose: Check if the reader can retrieve the correct value of a + * group attribute corrected by the writer. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * The expected attribute value. It is also used to construct the + * group name. + * + * Return: Success: true + * Failure: false + * + * Note: This function is used for the "dense" storage test. + * It is also used by the group-only, "add-ohr-block" + * and "del-ohr-block" tests. + *------------------------------------------------------------------------- + */ + +static bool +verify_default_group_attr(state_t *s, hid_t g, unsigned int which) +{ + char attrname[VS_ATTR_NAME_LEN]; + const char *aname_format = "attr-%u"; + HDsprintf(attrname, aname_format, which); + return vrfy_attr(s, g, which, attrname, which, false, true); +} + +/*------------------------------------------------------------------------- + * Function: verify_modify_attr + * + * Purpose: Check if the reader can retrieve the correct value of + * an attribute in a group, first the original value then + * the modified value. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * The expected attribute value. It is also used to construct the + * group name. The modified attribute value can be derived from + * the expected attribute value. + * + * Return: Success: true + * Failure: false + * + * Note: This function is used for the "modified" test. + *------------------------------------------------------------------------- + */ + +static bool +verify_modify_attr(state_t *s, hid_t g, unsigned int which) +{ + + bool ret = false; + const char * aname_fmt = "attr-%u"; + unsigned int read_which; + hid_t aid = H5I_INVALID_HID; + hid_t amtype = H5I_INVALID_HID; + char attrname[VS_ATTR_NAME_LEN]; + + /* First verify the original attribute value */ + ret = verify_default_group_attr(s, g, which); + + /* Then the modified value */ + if (ret == true) { + + /* The reader receives a message from the writer.Then sleep + * for a few ticks or stop the test if receiving an error + * message. + */ + if (s->use_named_pipes && true == s->attr_test) { + if (false == np_rd_receive(s)) { + H5_FAILED(); + AT(); + goto error2; + } + decisleep(s->tick_len * s->update_interval); + dbgf(1, "Reader: finish reading the message: %d\n", s->np_notify); + } + + /* Go ahead to read the attribute. */ + esnprintf(attrname, sizeof(attrname), aname_fmt, which); + if ((amtype = H5Tget_native_type(s->filetype, H5T_DIR_ASCEND)) < 0) { + printf("H5Tget_native_type failed\n"); + TEST_ERROR; + } + + if ((aid = H5Aopen(g, attrname, H5P_DEFAULT)) < 0) { + printf("H5Aopen failed\n"); + TEST_ERROR; + } + + if (H5Aread(aid, amtype, &read_which) < 0) { + printf("H5Aread failed\n"); + TEST_ERROR; + } + + if (H5Tclose(amtype) < 0) { + printf("H5Tclose failed.\n"); + TEST_ERROR; + } + + if (H5Aclose(aid) < 0) { + printf("H5Aclose failed\n"); + TEST_ERROR; + } + + /* verify the modified value */ + if (read_which != (which + 10000)) { + printf("reader: the modified_attr() expected value is %d\n", which + 10000); + printf("reader: the modified_attr() actual value is %d\n", read_which); + printf("The modify_attribute verification failed.\n"); + TEST_ERROR; + } + + /* The reader sends an OK message back to the writer. */ + if (s->use_named_pipes && s->attr_test == true) { + if (np_rd_send(s) == false) + goto error2; + dbgf(2, "reader: modify_attr finish sending back the message: %d\n", s->np_notify); + } + return true; + } + return false; + +error: + H5E_BEGIN_TRY + { + H5Aclose(aid); + H5Tclose(amtype); + } + H5E_END_TRY; + + /* The reader needs to send an error message back to the writer to stop the test.*/ + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, false); + +error2: + + return false; +} + +/*------------------------------------------------------------------------- + * Function: verify_group_vlstr_attr + * + * Purpose: Check if the reader can retrieve the correct value of + * a variable length string attribute created by the writer. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * Use to derieve the expected attribute value. It is also used + * to construct the group name. + * + * bool vrfy_mod + * true if this function is used for the modified VL string test. + * false if this function is just used for the VL string test. + * + * Return: Success: true + * Failure: false + * + * Note: This function is an internal function used by + * both the "vlstr" and the "modify-vstr" tests. + *------------------------------------------------------------------------- + */ + +static bool +verify_group_vlstr_attr(state_t *s, hid_t g, unsigned int which, bool vrfy_mod) +{ + hid_t aid = H5I_INVALID_HID; + hid_t atype = H5I_INVALID_HID; + char name[VS_ATTR_NAME_LEN]; + + char *astr_val_exp; + char *astr_val; + + /* The reader receives a message from the writer.Then sleep + * for a few ticks or stop the test if the received message + * is an error message. + */ + if (s->use_named_pipes && true == s->attr_test) { + if (false == np_rd_receive(s)) { + H5_FAILED(); + AT(); + goto error2; + } + decisleep(s->tick_len * s->update_interval); + dbgf(1, "Reader: finish reading the message: %d\n", s->np_notify); + } + + /* Go ahead to read the VL string attribute. */ + astr_val_exp = HDmalloc(VS_ATTR_NAME_LEN); + if (astr_val_exp == NULL) { + printf("Allocate memory for expected buffer failed.\n"); + TEST_ERROR; + } + + esnprintf(name, sizeof(name), "attr-%u", which); + + /* Construct the expected VL string value,depending if + * it is the modified value or the original value. */ + if (vrfy_mod == true) + HDsprintf(astr_val_exp, "%u%c", which, 'A'); + else + HDsprintf(astr_val_exp, "%u", which); + + dbgf(1, "verifying attribute %s on group %u equals %u\n", name, which, which); + + dbgf(1, "expected vl attr is= %s\n", astr_val_exp); + + if ((aid = H5Aopen(g, name, H5P_DEFAULT)) < 0) { + printf("H5Aopen failed\n"); + TEST_ERROR; + } + + /* Create a VL string datatype */ + if ((atype = H5Tcopy(H5T_C_S1)) < 0) { + printf("Cannot create variable length datatype.\n"); + TEST_ERROR; + } + + if (H5Tset_size(atype, H5T_VARIABLE) < 0) { + printf("Cannot set variable length datatype.\n"); + TEST_ERROR; + } + + if (H5Aread(aid, atype, &astr_val) < 0) { + printf("Cannot read the attribute.\n"); + TEST_ERROR; + } + + dbgf(1, "read attr is= %s\n", astr_val); + if (HDstrcmp(astr_val, astr_val_exp) != 0) { + printf("reader: the vl add_attribute verfication failed,expected value is %s\n", astr_val_exp); + printf("reader: the vl add_attribute verfication failed, the value is %s\n", astr_val); + printf("The vl add_attribute verification failed\n"); + TEST_ERROR; + } + + if (H5Tclose(atype) < 0) { + printf("H5Tclose failed.\n"); + TEST_ERROR; + } + + if (H5Aclose(aid) < 0) { + printf("H5Aclose failed.\n"); + TEST_ERROR; + } + + H5free_memory(astr_val); + HDfree(astr_val_exp); + + /* Reader sends an OK message back to the reader */ + if (s->use_named_pipes && s->attr_test == true) { + if (np_rd_send(s) == false) + goto error2; + dbgf(2, "reader: finish sending back the message: %d\n", s->np_notify); + } + + return true; + +error: + H5E_BEGIN_TRY + { + H5Aclose(aid); + H5Tclose(atype); + } + H5E_END_TRY; + if (astr_val) + H5free_memory(astr_val); + if (astr_val_exp) + HDfree(astr_val_exp); + + /* The reader sends an error message to the writer to stop the test.*/ + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, false); + +error2: + + return false; +} + +/*------------------------------------------------------------------------- + * Function: verify_del_one_attr + * + * Purpose: Verify if an attribute is successfully deleted. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * const char* aname + * The name of the attribute to be deleted. + * + * bool check_storage + * a flag to indicate if the storage check is on + * + * bool is_compact + * true if after this attribute is deleted, + * the storage should still be in compact, false + * if the storage should be in dense. + * Note: this parameter is not used if the check_storage + * is set to false. + + * Return: Success: true + * Failure: false + * + * Note: This is an internal function used by "remove-vlstr", + * "compact-del","dense-del",dense-del-to-compact" tests. + *------------------------------------------------------------------------- + */ + +static bool +verify_del_one_attr(state_t *s, hid_t g, const char *aname, bool check_storage, bool is_compact) +{ + + htri_t attr_exists = FALSE; + + /* The reader receives a message from the writer.Then sleep + * for a few ticks or stop the test if the received message + * is an error message. + */ + if (s->use_named_pipes && true == s->attr_test) { + if (false == np_rd_receive(s)) { + H5_FAILED(); + AT(); + goto error2; + } + decisleep(s->tick_len * s->update_interval); + dbgf(1, "Reader: finish reading the message: %d\n", s->np_notify); + } + + /* Check if the deleted attribute still exists. */ + attr_exists = H5Aexists_by_name(g, ".", aname, H5P_DEFAULT); + if (attr_exists == FALSE) { + dbgf(1, "verify_del_attrs_compact() test: \n"); + dbgf(1, " attribute %s is successfully deleted. \n", aname); + } + else if (attr_exists == TRUE) { + printf("The supposed deleted attribute %s still exists \n", aname); + printf("verify_del_attrs_compact() test failed \n"); + TEST_ERROR; + } + else { + printf("H5Aexists_by_name failed \n"); + TEST_ERROR; + } + + if (!s->old_style_grp && check_storage == true) { + if (false == check_attr_storage_type(g, is_compact)) { + printf("The attribute storage type is wrong. \n"); + TEST_ERROR; + } + dbgf(2, "reader: finish checking the storage type: %d\n", s->np_notify); + } + + /* If coming to an "object header continuation block" test, + * we need to check if this test behaves as expected. */ + if (s->at_pattern == 'R') { + if (false == check_ohr_num_chunk(g, true)) { + printf("An object header continuation block should be removed. \n"); + printf("But it is NOT.\n"); + printf("Verification of an 'object header continuation block test' failed.\n"); + TEST_ERROR; + } + } + + /* Reader sends an OK message back to the reader */ + if (s->use_named_pipes && s->attr_test == true) { + if (np_rd_send(s) == false) + TEST_ERROR; + dbgf(2, "reader: finish sending back the message: %d\n", s->np_notify); + } + + return true; +error: + /* The reader sends an error message to the writer to stop the test.*/ + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, false); + +error2: + return false; +} + +/*------------------------------------------------------------------------- + * Function: verify_remove_vlstr_attr + * + * Purpose: Verify if an variable length string attribute is + * successfully deleted by the writer. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * Use to derieve the expected attribute value added + * by the writer. It is also used to construct + * the attribute name. + * + * + * Return: Success: true + * Failure: false + * + * Note: This function is for the "remove-vstr" test. + * Also note this function first verifies if + * a variable length attribute is added then + * it verifies if it is deleted successfully. + *------------------------------------------------------------------------- + */ + +static bool +verify_remove_vlstr_attr(state_t *s, hid_t g, unsigned int which) +{ + bool ret = false; + char attrname[VS_ATTR_NAME_LEN]; + const char *aname_format = "attr-%u"; + + ret = verify_group_vlstr_attr(s, g, which, false); + if (ret == true) { + HDsprintf(attrname, aname_format, which); + ret = verify_del_one_attr(s, g, attrname, false, false); + } + return ret; +} + +/*------------------------------------------------------------------------- + * Function: verify_modify_vlstr_attr + * + * Purpose: Verify if an variable length string attribute is + * successfully modified by the writer. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * Use to derieve the expected attribute value added + * by the writer. It is also used to construct + * the attribute name. + * + * + * Return: Success: true + * Failure: false + * + * Note: This function is for the "modify-vstr" test. + * Also note this function first verifies if + * a variable length attribute is added then + * it verifies if it is modified successfully. + *------------------------------------------------------------------------- + */ + +static bool +verify_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which) +{ + + bool ret = false; + + ret = verify_group_vlstr_attr(s, g, which, false); + if (ret == true) + ret = verify_group_vlstr_attr(s, g, which, true); + return ret; +} + +/*------------------------------------------------------------------------- + * Function: verify_attrs_compact + * + * Purpose: Verify if attributes are successfully added for the compact + * storage. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigend max_c + * The maximal number of attributes the compact storage + * can hold + * + * unsigned int which + * Use to derieve the expected attribute value added + * by the writer. It is also used to construct the + * attribute names. + * + * + * Return: Success: true + * Failure: false + * + * Note: This function is used by the "compact" test. + *------------------------------------------------------------------------- + */ + +static bool +verify_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which) +{ + + unsigned u; + bool ret = true; + const char *aname_format = "attr-%u-%u"; + char attrname[VS_ATTR_NAME_LEN]; + + /* Need to verify the added attribute one by one. */ + for (u = 0; u < max_c; u++) { + + HDsprintf(attrname, aname_format, which, u); + if (false == vrfy_attr(s, g, u + which, attrname, which, true, true)) { + ret = false; + break; + } + } + return ret; +} + +/*------------------------------------------------------------------------- + * Function: verify_attrs_compact_dense + * + * Purpose: Verify if attributes are successfully added first in the + * compact storage then in the dense storage. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigend max_c + * The maximal number of attributes the compact storage + * can hold + * + * unsigned int which + * Use to derieve the expected attribute value added + * by the writer. It is also used to construct + * attribute names. + * + * + * Return: Success: true + * Failure: false + * + * Note: This function is used by the "compact-dense" test. + *------------------------------------------------------------------------- + */ + +static bool +verify_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int which) +{ + + const char *aname_format = "attr-d-%u-%u"; + char attrname[VS_ATTR_NAME_LEN]; + + bool ret = verify_attrs_compact(s, g, max_c, which); + + if (ret == true) { + + /* Now the storage is in dense. Verify if the + * retrieved value is correct. */ + HDsprintf(attrname, aname_format, max_c + which, 0); + ret = vrfy_attr(s, g, which + max_c, attrname, which, true, false); + } + return ret; +} + +/*------------------------------------------------------------------------- + * Function: verify_del_attrs_compact + * + * Purpose: Verify if an attribute in compact storage is successfully + * deleted. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigend max_c + * The maximal number of attributes the compact storage + * can hold + * + * unsigned int which + * Use to derieve the expected attribute value added + * by the writer. It is also used to construct + * attribute names. + * + * + * Return: Success: true + * Failure: false + * + * Note: This function is used by the "compact-del" test. + * Also note this function first verifies if + * attributes are successfully added in compact storage then + * it verifies if one added attribute is deleted successfully. + *------------------------------------------------------------------------- + */ + +static bool +verify_del_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which) +{ + + const char *aname_format = "attr-%u-%u"; + char attrname[VS_ATTR_NAME_LEN]; + + bool ret = verify_attrs_compact(s, g, max_c, which); + + if (ret == true) { + /* The writer only deletes the attribute attr-which-0 */ + HDsprintf(attrname, aname_format, which, 0); + ret = verify_del_one_attr(s, g, attrname, true, true); + } + + return ret; +} + +/*------------------------------------------------------------------------- + * Function: verify_del_attrs_compact_dense + * + * Purpose: Verify if an attribute in dense storage is successfully + * deleted. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigend max_c + * The maximal number of attributes the compact storage + * can hold + * + * unsigned int which + * Use to derieve the expected attribute value added + * by the writer. It is also used to construct + * attribute names. + * + * + * Return: Success: true + * Failure: false + * + * Note: This function is used by the "dense-del" test. + * Also note this function first verifies if + * attributes are successfully added in compact storage then + * in dense storage. Afterwards, + * it verifies if one added attribute is deleted successfully. + *------------------------------------------------------------------------- + */ + +static bool +verify_del_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int which) +{ + + const char *aname_format = "attr-d-%u-%u"; + char attrname[VS_ATTR_NAME_LEN]; + + bool ret = verify_attrs_compact_dense(s, g, max_c, which); + + if (ret == true) { + /* The writer only deletes the attribute attr-d-which-0 */ + HDsprintf(attrname, aname_format, max_c + which, 0); + ret = verify_del_one_attr(s, g, attrname, true, false); + } + + return ret; +} + +/*------------------------------------------------------------------------- + * Function: verify_del_attrs_compact_dense_compact + * + * Purpose: verify that the attributes are deleted successfully + * even the attribute storage changes from dense to + * compact. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigend max_c + * The maximal number of attributes the compact storage + * can hold + * + * unsigend min_d + * The minimal number of attributes to be stored in + * dense storage + * + * unsigned int which + * Use to derieve the expected attribute value added + * by the writer. It is also used to construct + * attribute names. + * + * + * Return: Success: true + * Failure: false + * + * Note: This function is used by the "dense-del-to-compact" test. + * Also note this function first verifies if + * attributes are successfully added in compact storage then + * in dense storage. Afterwards, + * it verifies if some added attributes are deleted successfully + * until the storage changes from dense to compact. + *------------------------------------------------------------------------- + */ + +static bool +verify_del_attrs_compact_dense_compact(state_t *s, hid_t g, unsigned max_c, unsigned min_d, + unsigned int which) +{ + + unsigned u; + const char *aname_format = "attr-%u-%u"; + char attrname[VS_ATTR_NAME_LEN]; + + /* Verify the attributes are added correctly from + * compact to dense storage*/ + bool ret = verify_attrs_compact_dense(s, g, max_c, which); + + if (ret == true) { + + /* Then verify the deletion of attributes + * from dense to compact. + */ + u = max_c + 1; + for (u--; u >= (min_d - 1); u--) { + HDsprintf(attrname, aname_format, which, max_c - u); + if (u == (min_d - 1)) + ret = verify_del_one_attr(s, g, attrname, true, true); + else + ret = verify_del_one_attr(s, g, attrname, true, false); + } + + /* Just verify one more deleted attribute by the writer. + The storage is still compact. */ + HDsprintf(attrname, aname_format, max_c + which, 0); + ret = verify_del_one_attr(s, g, attrname, true, true); + } + + return ret; +} + +/*------------------------------------------------------------------------- + * Function: verify_del_ohr_block_attr + * + * Purpose: Verify that an attribute is added to force creation of + * object header continuation block and remove this attribute + * to delete the object header continuation block + + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * The number of iterations for group creation, use to generate + * group and attribute names. + * + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the verify_group() function. + *------------------------------------------------------------------------- + */ + +static bool +verify_del_ohr_block_attr(state_t *s, hid_t g, unsigned int which) +{ + + bool ret_value = false; + char attrname[VS_ATTR_NAME_LEN]; + const char *aname_format = "attr-%u"; + + ret_value = verify_default_group_attr(s, g, which); + if (ret_value == true) { + HDsprintf(attrname, aname_format, which); + ret_value = verify_del_one_attr(s, g, attrname, false, true); + } + return ret_value; +} +/*------------------------------------------------------------------------- + * Function: verify_group_attribute + * + * Purpose: Check the attribute test pattern and then call the + * correponding verification function. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * The number of iterations for group creation, use to generate + * group and attribute names. + * + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the verify_group() function. + *------------------------------------------------------------------------- + */ + +static bool +verify_group_attribute(state_t *s, hid_t g, unsigned int which) +{ + char test_pattern = s->at_pattern; + bool ret = false; + unsigned max_compact = 0; + unsigned min_dense = 0; + hid_t gcpl = H5I_INVALID_HID; + + /* For tests "compact","compact-to-dense","compact-del", + * "dense-del", "dense-del-to-compact", + * the maximal number of attributes for the compact storage + * and the minimal number of attributes for the dense storage + * are needed. So obtain them here + * When testing the old-style group creation case, only max_compact + * matters. To reduce the testing time, we set max_compact to 2.*/ + switch (test_pattern) { + case 'c': + case 't': + case 'C': + case 'D': + case 'T': + if (s->old_style_grp) + max_compact = 2; + else { + if ((gcpl = H5Gget_create_plist(g)) < 0) { + printf("H5Gget_create_plist failed\n"); + TEST_ERROR; + } + if (H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { + printf("H5Pget_attr_phase_change failed\n"); + TEST_ERROR; + } + if (H5Pclose(gcpl) < 0) { + printf("H5Pclose failed\n"); + TEST_ERROR; + } + } + break; + case 'v': + case 'd': + case 'M': + case 'm': + case 'r': + case 'a': + case 'R': + case ' ': + default: + break; + } + + /* Distribute the verification test. */ + switch (test_pattern) { + case 'c': + ret = verify_attrs_compact(s, g, max_compact, which); + break; + case 't': + ret = verify_attrs_compact_dense(s, g, max_compact, which); + break; + case 'C': + ret = verify_del_attrs_compact(s, g, max_compact, which); + break; + case 'D': + ret = verify_del_attrs_compact_dense(s, g, max_compact, which); + break; + case 'T': + ret = verify_del_attrs_compact_dense_compact(s, g, max_compact, min_dense, which); + break; + case 'M': + ret = verify_modify_attr(s, g, which); + break; + case 'v': + ret = verify_group_vlstr_attr(s, g, which, false); + break; + case 'r': + ret = verify_remove_vlstr_attr(s, g, which); + break; + case 'm': + ret = verify_modify_vlstr_attr(s, g, which); + break; + case 'R': + ret = verify_del_ohr_block_attr(s, g, which); + break; + case 'a': + case 'd': + case ' ': + default: + ret = verify_default_group_attr(s, g, which); + break; + } + + return ret; + +error: + /* Still to finish the handshaking */ + if (s->use_named_pipes && s->attr_test == true) { + np_rd_receive(s); + np_send_error(s, false); + } + return false; +} + +/*------------------------------------------------------------------------- + * Function: verify_group + * + * Purpose: verify the success of group creation and + * carry out the test for attribute operations(add,delete etc.) + * according to the attribute test pattern. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations for group creation + * + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the main() function. + *------------------------------------------------------------------------- + */ + +static bool +verify_group(state_t *s, unsigned int which) +{ + char name[sizeof("/group-9999999999")]; + hid_t g = H5I_INVALID_HID; + bool result = true; + H5G_info_t group_info; + + /* The reader receives a message from the writer.Then sleep + * for a few ticks or stop the test if the received message + * is an error message. + */ + if (s->use_named_pipes && true == s->attr_test) { + + if (false == np_rd_receive(s)) { + H5_FAILED(); + AT(); + goto error2; + } + decisleep(s->tick_len * s->update_interval); + dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); + } + + if (which >= s->nsteps) { + printf("Number of created groups is out of bounds\n"); + TEST_ERROR; + } + + esnprintf(name, sizeof(name), "/group-%u", which); + + if ((g = H5Gopen(s->file, name, H5P_DEFAULT)) < 0) { + printf("H5Gopen failed\n"); + TEST_ERROR; + } + + if (H5Gget_info(g, &group_info) < 0) { + printf("H5Gget_info failed\n"); + TEST_ERROR; + } + + dbgf(2, "Storage info is %d\n", group_info.storage_type); + if (s->old_style_grp) { + if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { + printf("Reader - Old-styled group: but the group is not in old-style. \n"); + TEST_ERROR; + } + dbgf(2, "Reader: verify that the group is created with the old-style.\n"); + } + else { + if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { + printf("Reader - The created group should NOT be in old-style . \n"); + TEST_ERROR; + } + dbgf(2, "Reader: verify that the group is created with the new-style.\n"); + } + + /* If coming to an "object header continuation block" test, + * we need to check if this test behaves as expected. */ + if (s->at_pattern == 'a' || s->at_pattern == 'R') { + if (false == check_ohr_num_chunk(g, true)) { + printf("An object header continuation block should NOT be created. \n"); + printf("But it is created.\n"); + printf("Verification of an 'object header continuation block test' failed.\n"); + TEST_ERROR; + } + } + + /* Reader sends an OK message back to the writer */ + if (s->use_named_pipes && s->attr_test == true) { + + if (np_rd_send(s) == false) + TEST_ERROR; + dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); + } + + /* Check if we need to skip the attribute test for this group. */ + if (s->asteps != 0 && which % s->asteps == 0) + result = verify_group_attribute(s, g, which); + else + result = true; + + if (H5Gclose(g) < 0) { + printf("H5Gclose failed\n"); + TEST_ERROR; + } + + return result; + +error: + + H5E_BEGIN_TRY + { + H5Gclose(g); + } + H5E_END_TRY; + + /* The reader sends an error message to the writer to stop the test.*/ + if (s->use_named_pipes && s->attr_test == true) + np_send_error(s, false); + +error2: + + return false; +} + +/*------------------------------------------------------------------------- + * Function: create_group_id + * + * Purpose: Create a group and return the group ID. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations for group creation + * This is used to generate the group name. + * + * bool dense_to_compact + * true if this function is used to test the transition from dense to + * compact, false if the test is from compact to dense. + * + * Return: Success: the group ID + * Failure: -1 + * + * Note: Only used by testing the link storage transit functions. + *------------------------------------------------------------------------- + */ + +static hid_t +create_group_id(state_t *s, unsigned int which, bool dense_to_compact) +{ + + char name[sizeof("/group-9999999999")]; + hid_t g = H5I_INVALID_HID; + hid_t gcpl = H5I_INVALID_HID; + H5G_info_t group_info; + + if (which >= s->nsteps) { + printf("Number of created groups is out of bounds\n"); + TEST_ERROR; + } + + gcpl = H5Pcreate(H5P_GROUP_CREATE); + if (gcpl < 0) { + printf("H5Pcreate failed\n"); + TEST_ERROR; + } + + if (dense_to_compact) { + if (H5Pset_link_phase_change(gcpl, 2, 2) < 0) { + printf("H5Pset_link_phase_change failed for dense to compact.\n"); + TEST_ERROR; + } + } + else { + if (H5Pset_link_phase_change(gcpl, 1, 1) < 0) { + printf("H5Pset_attr_phase_change failed for compact to dense.\n"); + TEST_ERROR; + } + } + + esnprintf(name, sizeof(name), "/group-%u", which); + if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) { + printf("H5Gcreate2 failed\n"); + TEST_ERROR; + } + + if (H5Gget_info(g, &group_info) < 0) { + printf("H5Gget_info failed\n"); + TEST_ERROR; + } + + /* The storage type should always be compact when a group is created. */ + if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + printf("New-style group link storage test:. \n"); + printf(" still be compact after group creation. \n"); + TEST_ERROR; + } + + if (H5Pclose(gcpl) < 0) { + printf("H5Pclose failed\n"); + TEST_ERROR; + } + + /* If a grp_op_test is turned on and named pipes are used, + * the writer should send and receive messages after the group creation. + * Writer sends a message to reader: a group is successfully created. + * then wait for the reader to verify and send an acknowledgement message back.*/ + if (s->use_named_pipes && s->grp_op_test == true) { + dbgf(2, "Writer: ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); + /* Note: This is (mostly) because the verification failure message + * from the reader. So don't send the error message back to + * the reader. Just stop the test. */ + goto error2; + } + } + + return g; + +error: + /* Writer needs to send an error message to the reader to stop the test*/ + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, true); + +error2: + + H5E_BEGIN_TRY + { + H5Pclose(gcpl); + } + H5E_END_TRY; + + return -1; +} + +/*------------------------------------------------------------------------- + * Function: close_group_id + * + * Purpose: Verify is a group is closed successfully. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * The ID of the group to be closed. + * + * Return: Success: true + * Failure: false + * + * Note: This is used by the link storage transit functions. + *------------------------------------------------------------------------- + */ + +static bool +close_group_id(state_t *s, hid_t g) +{ + + if (H5Gclose(g) < 0) { + printf("H5Gclose failed\n"); + TEST_ERROR; + } + + /* If a grp_op_test is turned on and named pipes are used, for + * link storage test, + * Writer sends a message to reader: the group is successfully closed. + * then wait for the reader to verify and send an acknowledgement message back.*/ + if (s->use_named_pipes && s->grp_op_test == true) { + dbgf(2, "Writer: ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); + goto error2; + } + } + + return true; + +error: + /* Writer needs to send an error message to the reader to stop the test*/ + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, true); + +error2: + + return false; +} + +/*------------------------------------------------------------------------- + * Function: create_group + * + * Purpose: Create a group + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations for group creation + * This is used to generate the group name. + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the main() function. + *------------------------------------------------------------------------- + */ + +static bool +create_group(state_t *s, unsigned int which) +{ + + char name[sizeof("/group-9999999999")]; + hid_t g = H5I_INVALID_HID; + H5G_info_t group_info; + + if (which >= s->nsteps) { + printf("Number of created groups is out of bounds\n"); + TEST_ERROR; + } + + esnprintf(name, sizeof(name), "/group-%u", which); + if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + printf("H5Gcreate2 failed\n"); + TEST_ERROR; + } + + if (H5Gget_info(g, &group_info) < 0) { + printf("H5Gget_info failed\n"); + TEST_ERROR; + } + + if (s->old_style_grp) { + if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { + printf("Old-styled group test: but the group is not in old-style. \n"); + TEST_ERROR; + } + dbgf(2, "Writer: group is created with the old-style.\n"); + } + else { + if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { + printf("The created group should NOT be in old-style . \n"); + TEST_ERROR; + } + dbgf(2, "Writer: group is created with the new-style.\n"); + } + + if (H5Gclose(g) < 0) { + printf("H5Gclose failed\n"); + TEST_ERROR; + } + + /* Writer sends a message to reader, + * then wait for the reader to verify and send an acknowledgement message back.*/ + if (s->use_named_pipes && s->grp_op_test == true) { + dbgf(2, "Writer: ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); + goto error2; + } + } + + return true; + +error: + /* Writer needs to send an error message to the reader to stop the test*/ + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, true); + +error2: + + H5E_BEGIN_TRY + { + H5Gclose(g); + } + H5E_END_TRY; + + return false; +} + +/*------------------------------------------------------------------------- + * Function: delete_one_link + * + * Purpose: Delete a link(either hard/soft) in group operation tests. + * according to the group test pattern. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t obj_id + * The HDF5 object ID that the deleted link is attached to. + * + * const char *name + * The name of the link to be deleted. + * + * short link_storage + * <=0: link storage is ignored. + * 1: link storage should be compact after link deletion.. + * >1: link storage should be dense after link deletion. + * + * unsigned int which + * The number of iterations for group creation + * + * + * Return: Success: true + * Failure: false + * + * Note: This is used by delete_groups() and delete_links() functions. + *------------------------------------------------------------------------- + */ + +static bool +delete_one_link(state_t *s, hid_t obj_id, const char *name, short link_storage, unsigned int which) +{ + + H5G_info_t group_info; + + if (which >= s->nsteps) { + printf("Number of created groups is out of bounds\n"); + TEST_ERROR; + } + + if (H5Ldelete(obj_id, name, H5P_DEFAULT) < 0) { + printf("H5Ldelete failed\n"); + TEST_ERROR; + } + + if (link_storage > 0) { + + if (s->old_style_grp) { + printf("Old style group doesn't support the indexed storage.\n"); + TEST_ERROR; + } + + if (H5Gget_info(obj_id, &group_info) < 0) { + printf("H5Gget_info failed\n"); + TEST_ERROR; + } + + if (link_storage == 1) { + + if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + printf("The group link storage should be compact. \n"); + TEST_ERROR; + } + } + else { + + if (group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { + printf("The group link storage should be dense. \n"); + TEST_ERROR; + } + } + } + + /* Writer sends a message to reader: + * then wait for the reader to verify and send an acknowledgement message back.*/ + if (s->use_named_pipes && s->grp_op_test == true) { + dbgf(2, "writer: ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); + goto error2; + } + } + + return true; + +error: + /* Writer needs to send an error message to the reader to stop the test*/ + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, true); + +error2: + + return false; +} + +/*------------------------------------------------------------------------- + * Function: delete_group + * + * Purpose: Delete a group and carry out group operations(add,delete etc.) + * according to the group operation test pattern. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations for group creation + * This is used to generate the group name + * + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the group_operations() function. + *------------------------------------------------------------------------- + */ + +static bool +delete_group(state_t *s, unsigned int which) +{ + + char name[sizeof("/group-9999999999")]; + bool ret_value = create_group(s, which); + if (ret_value == true) { + esnprintf(name, sizeof(name), "/group-%u", which); + ret_value = delete_one_link(s, s->file, name, 0, which); + } + + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: move_one_group + * + * Purpose: A helper function used by the move_group operation. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t obj_id + * ID of the object this group is attached to + * + * const char *name + * The original group name + * + * const char *newname + * The new group name + * + * unsigned int which + * The number of iterations for group creation + * + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the move_group() function. + *------------------------------------------------------------------------- + */ + +static bool +move_one_group(state_t *s, hid_t obj_id, const char *name, const char *newname, unsigned int which) +{ + + if (which >= s->nsteps) { + printf("Number of created groups is out of bounds\n"); + TEST_ERROR; + } + + if (H5Lmove(obj_id, name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { + printf("H5Ldelete failed\n"); + TEST_ERROR; + } + + /* Writer sends a message to reader: + * then wait for the reader to verify and send an acknowledgement message back.*/ + if (s->use_named_pipes && s->grp_op_test == true) { + dbgf(2, "writer: ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); + goto error2; + } + } + + return true; + +error: + /* Writer needs to send an error message to the reader to stop the test*/ + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, true); + +error2: + + return false; +} + +/*------------------------------------------------------------------------- + * Function: move_group + * + * Purpose: Move a group to another group. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations for group creation + * used to generate the group name. + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the group_operations() function. + *------------------------------------------------------------------------- + */ + +static bool +move_group(state_t *s, unsigned int which) +{ + + char name[sizeof("/group-9999999999")]; + char new_name[sizeof("/new-group-9999999999")]; + bool ret_value = create_group(s, which); + if (ret_value == true) { + esnprintf(name, sizeof(name), "/group-%u", which); + esnprintf(new_name, sizeof(new_name), "/new-group-%u", which); + ret_value = move_one_group(s, s->file, name, new_name, which); + } + + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: insert_one_link + * + * Purpose: A helper function used to attach a link to a group. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t obj_id + * ID of the object this link is attached to + * + * const char *name + * The name of the target object used by creating links + * + * const char *newname + * The name of the linked objects + * + * bool is_hard + * true if inserting a hard link + * false if inserting a soft link + * + * short link_storage + * <=0: link storage is ignored. + * 1: link storage should be compact. + * >1: link storage should be dense. + + * unsigned int which + * The number of iterations for group creation + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the insert_links and link storage transit functions. + * For link storage, we test at both the writer and the reader. + *------------------------------------------------------------------------- +*/ + +static bool +insert_one_link(state_t *s, hid_t obj_id, const char *name, const char *newname, bool is_hard, + short link_storage, unsigned int which) +{ + + H5G_info_t group_info; + + if (which >= s->nsteps) { + printf("Number of created groups is out of bounds\n"); + TEST_ERROR; + } + + /* For storage transit and insert_links cases, we + * create links in different style, just add a little + * variation of the tests.*/ + if (is_hard) { + if (link_storage > 0) { + if (H5Lcreate_hard(s->file, name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { + printf("H5Lcreate_hard failed\n"); + TEST_ERROR; + } + } + else { + if (H5Lcreate_hard(obj_id, name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { + printf("H5Lcreate_hard failed\n"); + TEST_ERROR; + } + } + } + else { + if (link_storage > 0) { + if (H5Lcreate_soft("/", obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { + printf("H5Lcreate_soft failed\n"); + TEST_ERROR; + } + } + else { + if (H5Lcreate_soft(name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { + printf("H5Lcreate_soft failed.\n"); + TEST_ERROR; + } + } + } + + if (link_storage > 0) { + + if (s->old_style_grp) { + printf("Old style group doesn't support dense or compact storage.\n"); + TEST_ERROR; + } + + if (H5Gget_info(obj_id, &group_info) < 0) { + printf("H5Gget_info failed\n"); + TEST_ERROR; + } + + if (link_storage == 1) { + if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + printf("The group link storage should be compact. \n"); + TEST_ERROR; + } + } + else { + if (group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { + printf("The group link storage should be dense. \n"); + TEST_ERROR; + } + } + } + + /* Writer sends a message to reader, + * then wait for the reader to verify and send an acknowledgement message back.*/ + if (s->use_named_pipes && s->grp_op_test == true) { + dbgf(2, "writer: ready to send the message: %d\n", s->np_notify + 1); + if (np_wr_send_receive(s) == false) { + H5_FAILED(); + AT(); + goto error2; + } + } + + return true; + +error: + /* Writer needs to send an error message to the reader to stop the test*/ + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, true); + +error2: + + return false; +} + +/*------------------------------------------------------------------------- + * Function: insert_links + * + * Purpose: create links with a group. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations + * used to generate the group name. + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the group_operations() function. + *------------------------------------------------------------------------- + */ + +static bool +insert_links(state_t *s, unsigned int which) +{ + + char name[sizeof("/group-9999999999")]; + char hd_name[sizeof("/hd-group-9999999999")]; + char st_name[sizeof("/st-group-9999999999")]; + + bool ret_value = create_group(s, which); + if (ret_value == true) { + esnprintf(name, sizeof(name), "/group-%u", which); + esnprintf(hd_name, sizeof(hd_name), "/hd-group-%u", which); + esnprintf(st_name, sizeof(st_name), "/st-group-%u", which); + ret_value = insert_one_link(s, s->file, name, hd_name, true, 0, which); + if (ret_value == true) + ret_value = insert_one_link(s, s->file, name, st_name, false, 0, which); + } + + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: delete_links + * + * Purpose: create links with a group and then delete them successfully. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations + * used to generate the group name. + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the group_operations() function. + *------------------------------------------------------------------------- + */ + +static bool +delete_links(state_t *s, unsigned int which) +{ + + char name[sizeof("/group-9999999999")]; + char hd_name[sizeof("/hd-group-9999999999")]; + char st_name[sizeof("/st-group-9999999999")]; + + bool ret_value = insert_links(s, which); + if (ret_value == true) { + esnprintf(name, sizeof(name), "/group-%u", which); + esnprintf(hd_name, sizeof(hd_name), "/hd-group-%u", which); + esnprintf(st_name, sizeof(st_name), "/st-group-%u", which); + ret_value = delete_one_link(s, s->file, hd_name, 0, which); + if (ret_value == true) + ret_value = delete_one_link(s, s->file, st_name, 0, which); + } + + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: transit_storage_compact_to_dense + * + * Purpose: Add links so that the link storage transits from + * compact to dense. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations used to generate the group name. + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the group_operations() function. + *------------------------------------------------------------------------- + */ + +static bool +transit_storage_compact_to_dense(state_t *s, unsigned int which) +{ + + char name[sizeof("/group-9999999999")]; + char hd_name[sizeof("/hd-group-9999999999")]; + char st_name[sizeof("/st-group-9999999999")]; + + hid_t g = create_group_id(s, which, false); + if (g < 0) { + printf("create_group_id failed\n"); + TEST_ERROR; + } + + /* First insert a hard link, compact storage. */ + esnprintf(name, sizeof(name), "/group-%u", which); + esnprintf(hd_name, sizeof(hd_name), "hd-group-%u", which); + if (insert_one_link(s, g, name, hd_name, true, 1, which) == false) { + printf("insert_one_link for compact storage failed\n"); + TEST_ERROR; + } + + /* Then insert a soft link, the storage becomes dense. */ + esnprintf(st_name, sizeof(st_name), "st-group-%u", which); + if (insert_one_link(s, g, name, st_name, false, 2, which) == false) { + printf("insert_one_link for dense storage failed\n"); + TEST_ERROR; + } + + if (close_group_id(s, g) == false) { + printf("insert_one_link for dense storage failed\n"); + TEST_ERROR; + } + + return true; + +error: + H5E_BEGIN_TRY + { + H5Gclose(g); + } + H5E_END_TRY; + + return false; +} + +/*------------------------------------------------------------------------- + * Function: transit_storage_dense_to_compact + * + * Purpose: Add or delete links so that the link storage transits from + * compact to dense then to compact. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations used to generate the group name. + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the group_operations() function. + *------------------------------------------------------------------------- + */ + +static bool +transit_storage_dense_to_compact(state_t *s, unsigned int which) +{ + + char name[sizeof("/group-9999999999")]; + char hd_name[sizeof("/hd-group-9999999999")]; + char st_name[sizeof("st-group-9999999999")]; + char st2_name[sizeof("st2-group-9999999999")]; + + hid_t g = create_group_id(s, which, true); + if (g < 0) { + printf("create_group_id failed\n"); + TEST_ERROR; + } + + /* Insert a link, storage is compact. */ + esnprintf(name, sizeof(name), "/group-%u", which); + esnprintf(hd_name, sizeof(hd_name), "hd-group-%u", which); + if (insert_one_link(s, g, name, hd_name, true, 1, which) == false) { + printf("insert_one_link for compact storage failed\n"); + TEST_ERROR; + } + + /* Insert a link, storage is still compact. */ + esnprintf(st_name, sizeof(st_name), "st-group-%u", which); + if (insert_one_link(s, g, name, st_name, false, 1, which) == false) { + printf("insert_one_link for compact storage failed\n"); + TEST_ERROR; + } + + /* Insert a link, storage becomes dense. */ + esnprintf(st2_name, sizeof(st2_name), "st2-group-%u", which); + if (insert_one_link(s, g, name, st2_name, false, 2, which) == false) { + printf("insert_one_link for dense storage failed\n"); + TEST_ERROR; + } + + /* Delete a link, storage is still dense */ + if (delete_one_link(s, g, st_name, 2, which) == false) { + printf("delete_one_link for dense storage failed\n"); + TEST_ERROR; + } + + /* Delete another link, storage becomes compact */ + if (delete_one_link(s, g, st2_name, 1, which) == false) { + printf("delete_one_link for compact storage failed\n"); + TEST_ERROR; + } + + if (close_group_id(s, g) == false) { + printf("insert_one_link for dense storage failed\n"); + TEST_ERROR; + } + + return true; + +error: + H5E_BEGIN_TRY + { + H5Gclose(g); + } + H5E_END_TRY; + + return false; +} + +/*------------------------------------------------------------------------- + * Function: group_operations + * + * Purpose: Carry out group and attribute operations(add,delete etc.) + * according to the group operation and attribute test patterns. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations for group creation + * + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the main() function. The check of attribute + * operations is inside the write_group() function. + *------------------------------------------------------------------------- + */ +static bool +group_operations(state_t *s, unsigned int which) +{ + + bool ret_value = false; + char test_pattern = s->grp_op_pattern; + + switch (test_pattern) { + case 'c': + ret_value = create_group(s, which); + break; + case 'd': + ret_value = delete_group(s, which); + break; + case 'm': + ret_value = move_group(s, which); + break; + case 'i': + ret_value = insert_links(s, which); + break; + case 'D': + ret_value = delete_links(s, which); + break; + case 't': + ret_value = transit_storage_compact_to_dense(s, which); + break; + case 'T': + ret_value = transit_storage_dense_to_compact(s, which); + break; + case ' ': + default: + ret_value = write_group(s, which); + break; + } + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: vrfy_create_group + * + * Purpose: Verify if a group can be created successfully. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations for group creation + * used to generate the group name. + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the verify_group_operations() function. + *------------------------------------------------------------------------- + */ + +static bool +vrfy_create_group(state_t *s, unsigned int which) +{ + + char name[sizeof("/group-9999999999")]; + hid_t g = H5I_INVALID_HID; + H5G_info_t group_info; + + dbgf(2, "reader: ready to send the message: \n"); + + /* The reader receives a message from the writer.Then sleep + * for a few ticks or stop the test if the received message + * is an error message. + */ + if (s->use_named_pipes && true == s->grp_op_test) { + + if (false == np_rd_receive(s)) { + H5_FAILED(); + AT(); + goto error2; + } + decisleep(s->tick_len * s->update_interval); + dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); + } + + if (which >= s->nsteps) { + printf("Number of created groups is out of bounds\n"); + TEST_ERROR; + } + + esnprintf(name, sizeof(name), "/group-%u", which); + + if ((g = H5Gopen(s->file, name, H5P_DEFAULT)) < 0) { + printf("H5Gopen failed\n"); + TEST_ERROR; + } + + if (H5Gget_info(g, &group_info) < 0) { + printf("H5Gget_info failed\n"); + TEST_ERROR; + } + + dbgf(2, "Storage info is %d\n", group_info.storage_type); + if (s->old_style_grp) { + if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { + printf("Reader - Old-styled group: but the group is not in old-style. \n"); + TEST_ERROR; + } + dbgf(2, "Reader: verify that the group is created with the old-style.\n"); + } + else { + if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { + printf("Reader - The created group should NOT be in old-style . \n"); + TEST_ERROR; + } + dbgf(2, "Reader: verify that the group is created with the new-style.\n"); + } + + if (H5Gclose(g) < 0) { + printf("H5Gclose failed\n"); + TEST_ERROR; + } + + /* Reader sends an OK message back to the writer */ + if (s->use_named_pipes && s->grp_op_test == true) { + + if (np_rd_send(s) == false) + TEST_ERROR; + dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); + } + + return true; + +error: + + H5E_BEGIN_TRY + { + H5Gclose(g); + } + H5E_END_TRY; + + /* The reader sends an error message to the writer to stop the test.*/ + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, false); + +error2: + + return false; +} + +/*------------------------------------------------------------------------- + * Function: vrfy_create_group_id + * + * Purpose: Verify if a group is created successfully and return the group + * ID. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations for group creation + * used to generate the group name. + * + * bool dense_to_compact + * true if this function is used to test the transition from dense to + * compact, false if the test is from compact to dense. + * + * Return: Success: the group ID + * Failure: -1 + * + * Note: This function is used by the link storage transit functions. + *------------------------------------------------------------------------- + */ + +static hid_t +vrfy_create_group_id(state_t *s, unsigned int which, bool dense_to_compact) +{ + + char name[sizeof("/group-9999999999")]; + hid_t g = H5I_INVALID_HID; + hid_t gcpl = H5I_INVALID_HID; + H5G_info_t group_info; + unsigned max_compact = 0; + unsigned min_dense = 0; + + dbgf(2, "reader: ready to receive a message: \n"); + /* The reader receives a message from the writer.Then sleep + * for a few ticks or stop the test if the received message + * is an error message. + */ + if (s->use_named_pipes && true == s->grp_op_test) { + + if (false == np_rd_receive(s)) { + H5_FAILED(); + AT(); + goto error2; + } + decisleep(s->tick_len * s->update_interval); + dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); + } + + if (which >= s->nsteps) { + printf("Number of the created groups is out of bounds\n"); + TEST_ERROR; + } + + esnprintf(name, sizeof(name), "/group-%u", which); + + if ((g = H5Gopen(s->file, name, H5P_DEFAULT)) < 0) { + printf("H5Gopen failed\n"); + TEST_ERROR; + } + + if ((gcpl = H5Gget_create_plist(g)) < 0) { + printf("H5Gget_create_plist failed\n"); + TEST_ERROR; + } + + if (H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) { + printf("H5Pget_link_phase_change failed\n"); + TEST_ERROR; + } + + if (dense_to_compact) { + if (max_compact != 2) { + printf("For storage check from dense to compact:\n"); + printf(" The max_compact should be 2.\n"); + printf(" But the actual value is %d.\n", max_compact); + TEST_ERROR; + } + else if (min_dense != 2) { + printf("For storage check from dense to compact:\n"); + printf(" The min_dense should be 2.\n"); + printf(" But the actual value is %d.\n", min_dense); + TEST_ERROR; + } + } + else { + if (max_compact != 1) { + printf("For storage check from dense to compact:\n"); + printf(" The max_compact should be 1.\n"); + printf(" But the actual value is %d.\n", max_compact); + TEST_ERROR; + } + else if (min_dense != 1) { + printf("For storage check from dense to compact:\n"); + printf(" The min_dense should be 1.\n"); + printf(" But the actual value is %d.\n", min_dense); + TEST_ERROR; + } + } + + if (H5Pclose(gcpl) < 0) { + printf("H5Pclose failed\n"); + TEST_ERROR; + } + + if (H5Gget_info(g, &group_info) < 0) { + printf("H5Gget_info failed\n"); + TEST_ERROR; + } + + /* When the group is created, the storage type is always compact. */ + if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + printf("Old-styled group test: but the group is not in old-style. \n"); + TEST_ERROR; + } + + dbgf(2, "Storage info is %d\n", group_info.storage_type); + + /* Reader sends an OK message back to the reader */ + if (s->use_named_pipes && s->grp_op_test == true) { + + if (np_rd_send(s) == false) + TEST_ERROR; + dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); + } + + return g; + +error: + + H5E_BEGIN_TRY + { + H5Gclose(g); + H5Pclose(gcpl); + } + H5E_END_TRY; + + /* The reader sends an error message to the writer to stop the test.*/ + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, false); + +error2: + + return -1; +} + +/*------------------------------------------------------------------------- + * Function: vrfy_close_group_id + * + * Purpose: Verify if a group is closed successfully. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * The ID of the group to be closed. + * + * Return: Success: true + * Failure: false + * + * Note: This is used by the link storage transit functions. + *------------------------------------------------------------------------- + */ + +static bool +vrfy_close_group_id(state_t *s, hid_t g) +{ + + /* The reader receives a message from the writer.Then sleep + * for a few ticks or stop the test if the received message + * is an error message. + */ + if (s->use_named_pipes && true == s->grp_op_test) { + + if (false == np_rd_receive(s)) { + H5_FAILED(); + AT(); + goto error2; + } + decisleep(s->tick_len * s->update_interval); + dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); + } + + if (H5Gclose(g) < 0) { + printf("H5Gclose failed\n"); + TEST_ERROR; + } + + /* Reader sends an OK message back to the reader */ + if (s->use_named_pipes && s->grp_op_test == true) { + + if (np_rd_send(s) == false) + TEST_ERROR; + dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); + } + + return true; + +error: + + /* The reader sends an error message to the writer to stop the test.*/ + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, false); + +error2: + return false; +} + +/*------------------------------------------------------------------------- + * Function: vrfy_one_link_exist + * + * Purpose: Verify if a link exists or not. The link storage is + * also checked. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t obj_id + * The ID of the object the link is attached to + * + * bool expect_exist + * A flag that indicates if this link is expected to exist + * + * short link_storage + * <=0: link storage check is ignored. + * 1: link storage is expected to be compact. + * >1: link storage is expected to be dense. + * + * Return: Success: true + * Failure: false + * + * Note: Helper function to check if links are inserted or deleted. + * The link storage is also checked. + *------------------------------------------------------------------------- + */ + +static bool +vrfy_one_link_exist(state_t *s, hid_t obj_id, const char *name, bool expect_exist, short link_storage) +{ + + int link_exists = 0; + H5G_info_t group_info; + + dbgf(2, "reader: ready to send the message: \n"); + /* The reader receives a message from the writer.Then sleep + * for a few ticks or stop the test if the received message + * is an error message. + */ + if (s->use_named_pipes && true == s->grp_op_test) { + + if (false == np_rd_receive(s)) { + H5_FAILED(); + AT(); + goto error2; + } + decisleep(s->tick_len * s->update_interval); + dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); + } + + link_exists = H5Lexists(obj_id, name, H5P_DEFAULT); + + if (link_exists < 0) { + printf("H5Lexists error\n"); + TEST_ERROR; + } + else if (link_exists == 1) { + if (expect_exist == false) { + printf("This link should be moved or deleted but it still exists.\n"); + TEST_ERROR; + } + } + else if (link_exists == 0) { + if (expect_exist == true) { + printf("This link should exist but it is moved or deleted.\n"); + TEST_ERROR; + } + } + + if (link_storage > 0) { + + if (s->old_style_grp) { + printf("Old style group doesn't support the indexed storage.\n"); + TEST_ERROR; + } + + if (H5Gget_info(obj_id, &group_info) < 0) { + printf("H5Gget_info failed\n"); + TEST_ERROR; + } + + if (link_storage == 1) { + if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + printf("The group link storage should be compact. \n"); + TEST_ERROR; + } + } + else { + if (group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { + printf("The group link storage should be dense. \n"); + TEST_ERROR; + } + } + } + + /* Reader sends an OK message back to the reader */ + if (s->use_named_pipes && s->grp_op_test == true) { + if (np_rd_send(s) == false) { + TEST_ERROR; + } + dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); + } + + return true; + +error: + + /* The reader sends an error message to the writer to stop the test.*/ + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, false); + +error2: + + return false; +} + +/*------------------------------------------------------------------------- + * Function: vrfy_delete_group + * + * Purpose: Verify if a group can be deleted successfully. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations for group creation + * used to generate the group name. + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the verify_group_operations() function. + *------------------------------------------------------------------------- + */ + +static bool +vrfy_delete_group(state_t *s, unsigned int which) +{ + + bool ret_value = false; + char name[sizeof("/group-9999999999")]; + + ret_value = vrfy_create_group(s, which); + if (ret_value == true) { + esnprintf(name, sizeof(name), "/group-%u", which); + ret_value = vrfy_one_link_exist(s, s->file, name, false, 0); + } + + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: vrfy_move_one_group + * + * Purpose: A helper function to verify the move_group operation successfully. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t obj_id + * ID of the object this group is attached to + * + * const char *name + * The original group name + * + * const char *newname + * The new group name + * + * unsigned int which + * The number of iterations for group creation + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the verify_move_group() function. + *------------------------------------------------------------------------- + */ + +static bool +vrfy_move_one_group(state_t *s, hid_t obj_id, const char *name, const char *newname, unsigned int which) +{ + + hid_t g = H5I_INVALID_HID; + H5G_info_t group_info; + int link_exists = 0; + + dbgf(2, "reader: ready to send the message: \n"); + /* The reader receives a message from the writer.Then sleep + * for a few ticks or stop the test if the received message + * is an error message. + */ + if (s->use_named_pipes && true == s->grp_op_test) { + + if (false == np_rd_receive(s)) { + H5_FAILED(); + AT(); + goto error2; + } + decisleep(s->tick_len * s->update_interval); + dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); + } + + if (which >= s->nsteps) { + printf("Number of created groups is out of bounds\n"); + TEST_ERROR; + } + + link_exists = H5Lexists(obj_id, name, H5P_DEFAULT); + if (link_exists < 0) { + printf("H5Lexists error\n"); + TEST_ERROR; + } + else if (link_exists == 1) { + printf("This link should be moved but it still exists.\n"); + TEST_ERROR; + } + + if ((g = H5Gopen(obj_id, newname, H5P_DEFAULT)) < 0) { + printf("H5Gopen failed\n"); + TEST_ERROR; + } + + if (H5Gget_info(g, &group_info) < 0) { + printf("H5Gget_info failed\n"); + TEST_ERROR; + } + + dbgf(2, "Storage info is %d\n", group_info.storage_type); + if (s->old_style_grp) { + if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { + printf("Reader - Old-styled group: but the group is not in old-style. \n"); + TEST_ERROR; + } + dbgf(2, "Reader: verify that the group is created with the old-style.\n"); + } + else { + if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { + printf("Reader - The created group should NOT be in old-style . \n"); + TEST_ERROR; + } + dbgf(2, "Reader: verify that the group is created with the new-style.\n"); + } + + if (H5Gclose(g) < 0) { + printf("H5Gclose failed\n"); + TEST_ERROR; + } + + /* Reader sends an OK message back to the reader */ + if (s->use_named_pipes && s->grp_op_test == true) { + + if (np_rd_send(s) == false) { + TEST_ERROR; + } + dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); + } + + return true; + +error: + + H5E_BEGIN_TRY + { + H5Gclose(g); + } + H5E_END_TRY; + + /* The reader sends an error message to the writer to stop the test.*/ + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, false); + +error2: + + return false; +} + +/*------------------------------------------------------------------------- + * Function: vrfy_move_group + * + * Purpose: Verify if a group can be moved successfully. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations for group creation + * used to generate the group name. + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the verify_group_operations() function. + *------------------------------------------------------------------------- + */ + +static bool +vrfy_move_group(state_t *s, unsigned int which) +{ + + char name[sizeof("/group-9999999999")]; + char new_name[sizeof("/new-group-9999999999")]; + bool ret_value = vrfy_create_group(s, which); + if (ret_value == true) { + esnprintf(name, sizeof(name), "/group-%u", which); + esnprintf(new_name, sizeof(new_name), "/new-group-%u", which); + ret_value = vrfy_move_one_group(s, s->file, name, new_name, which); + } + + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: vrfy_insert_links + * + * Purpose: Verify if the links are inserted successfully. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations for group creation + * used to generate the group name. + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the verify_group_operations() function. + *------------------------------------------------------------------------- + */ + +static bool +vrfy_insert_links(state_t *s, unsigned int which) +{ + + bool ret_value = false; + char hd_name[sizeof("/hd-group-9999999999")]; + char st_name[sizeof("/st-group-9999999999")]; + + ret_value = vrfy_create_group(s, which); + + if (ret_value == true) { + esnprintf(hd_name, sizeof(hd_name), "/hd-group-%u", which); + esnprintf(st_name, sizeof(st_name), "/st-group-%u", which); + ret_value = vrfy_one_link_exist(s, s->file, hd_name, true, 0); + if (ret_value == true) + ret_value = vrfy_one_link_exist(s, s->file, st_name, true, 0); + } + + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: vrfy_delete_links + * + * Purpose: Verify if the links created with a group are deleted successfully. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations for group creation + * used to generate the group name. + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the verify_group_operations() function. + *------------------------------------------------------------------------- + */ + +static bool +vrfy_delete_links(state_t *s, unsigned int which) +{ + + bool ret_value = false; + char hd_name[sizeof("/hd-group-9999999999")]; + char st_name[sizeof("/st-group-9999999999")]; + + /* First verify if the links are inserted correctly */ + ret_value = vrfy_insert_links(s, which); + + /* Then if these links are deleted correctly. */ + if (ret_value == true) { + esnprintf(hd_name, sizeof(hd_name), "/hd-group-%u", which); + esnprintf(st_name, sizeof(st_name), "/st-group-%u", which); + ret_value = vrfy_one_link_exist(s, s->file, hd_name, false, 0); + if (ret_value == true) + ret_value = vrfy_one_link_exist(s, s->file, st_name, false, 0); + } + + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: vrfy_transit_storage_compact_to_dense + * + * Purpose: Verify if the link storage successfully transits from + * compact to dense. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations for group creation + * used to generate the group name. + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the verify_group_operations() function. + *------------------------------------------------------------------------- + */ + +static bool +vrfy_transit_storage_compact_to_dense(state_t *s, unsigned int which) +{ + + hid_t g = H5I_INVALID_HID; + char hd_name[sizeof("hd-group-9999999999")]; + char st_name[sizeof("st-group-9999999999")]; + + g = vrfy_create_group_id(s, which, false); + if (g < 0) { + printf("verify create_group_id failed\n"); + TEST_ERROR; + } + + esnprintf(hd_name, sizeof(hd_name), "hd-group-%u", which); + if (vrfy_one_link_exist(s, g, hd_name, true, 1) == false) { + printf("verify the compact storage failed for 'link compact to dense' test\n"); + TEST_ERROR; + } + + esnprintf(st_name, sizeof(st_name), "st-group-%u", which); + if (vrfy_one_link_exist(s, g, st_name, true, 2) == false) { + printf("verify the dense link storage failed for 'link compact to dense' test\n"); + TEST_ERROR; + } + + if (vrfy_close_group_id(s, g) == false) { + printf("verify the group close for 'link compact to dense' test\n"); + TEST_ERROR; + } + return true; + +error: + H5E_BEGIN_TRY + { + H5Gclose(g); + } + H5E_END_TRY; + return false; +} + +/*------------------------------------------------------------------------- + * Function: vrfy_transit_storage_dense_to_compact + * + * Purpose: Verify if the link storage successfully transits from + * compact to dense then to compact. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations for group creation + * used to generate the group name. + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the verify_group_operations() function. + *------------------------------------------------------------------------- + */ + +static bool +vrfy_transit_storage_dense_to_compact(state_t *s, unsigned int which) +{ + + hid_t g = H5I_INVALID_HID; + char hd_name[sizeof("hd-group-9999999999")]; + char st_name[sizeof("st-group-9999999999")]; + char st2_name[sizeof("st2-group-9999999999")]; + + g = vrfy_create_group_id(s, which, true); + if (g < 0) { + printf("verify create_group_id failed\n"); + TEST_ERROR; + } + + /* Add a link, verify it is still the compact storage */ + esnprintf(hd_name, sizeof(hd_name), "hd-group-%u", which); + if (vrfy_one_link_exist(s, g, hd_name, true, 1) == false) { + printf("verify the compact storage failed for 'link compact to dense' test\n"); + TEST_ERROR; + } + + /* Add another link, verify it is still the compact storage */ + esnprintf(st_name, sizeof(st_name), "st-group-%u", which); + if (vrfy_one_link_exist(s, g, st_name, true, 1) == false) { + printf("verify the compact link storage failed for 'link compact to dense' test\n"); + TEST_ERROR; + } + + /* Add the third link, verify it becomes the dense storage */ + esnprintf(st2_name, sizeof(st2_name), "st2-group-%u", which); + if (vrfy_one_link_exist(s, g, st2_name, true, 2) == false) { + printf("verify the dense link storage failed for 'link compact to dense' test\n"); + TEST_ERROR; + } + + /* Remove a link, verify the link doesn't exist and still dense storage */ + if (vrfy_one_link_exist(s, g, st_name, false, 2) == false) { + printf("verify the dense link storage failed for 'link compact to dense' test\n"); + TEST_ERROR; + } + + /* Remove a link, verify the link doesn't exist and it becomes compact storage */ + if (vrfy_one_link_exist(s, g, st2_name, false, 1) == false) { + printf("verify the compact link storage failed for 'link compact to dense' test\n"); + TEST_ERROR; + } + + if (vrfy_close_group_id(s, g) == false) { + printf("verify the group close for 'link compact to dense' test\n"); + TEST_ERROR; + } + return true; + +error: + H5E_BEGIN_TRY + { + H5Gclose(g); + } + H5E_END_TRY; + return false; +} + +/*------------------------------------------------------------------------- + * Function: verify_group_operations + * + * Purpose: verify the success of group creation and + * carry out the test for attribute operations(add,delete etc.) + * according to the attribute test pattern. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int which + * The number of iterations for group creation + * + * + * Return: Success: true + * Failure: false + * + * Note: This is called by the main() function. + *------------------------------------------------------------------------- + */ + +static bool +verify_group_operations(state_t *s, unsigned int which) +{ + bool ret_value = false; + char test_pattern = s->grp_op_pattern; + + switch (test_pattern) { + case 'c': + ret_value = vrfy_create_group(s, which); + break; + case 'd': + ret_value = vrfy_delete_group(s, which); + break; + case 'm': + ret_value = vrfy_move_group(s, which); + break; + case 'i': + ret_value = vrfy_insert_links(s, which); + break; + case 'D': + ret_value = vrfy_delete_links(s, which); + break; + case 't': + ret_value = vrfy_transit_storage_compact_to_dense(s, which); + break; + case 'T': + ret_value = vrfy_transit_storage_dense_to_compact(s, which); + break; + case ' ': + default: + ret_value = verify_group(s, which); + break; + } + return ret_value; +} + +int +main(int argc, char **argv) +{ + hid_t fapl = H5I_INVALID_HID, fcpl = H5I_INVALID_HID; + unsigned step; + bool writer = false; + state_t s; + const char * personality; + H5F_vfd_swmr_config_t config; + const char * fifo_writer_to_reader = "./fifo_group_writer_to_reader"; + const char * fifo_reader_to_writer = "./fifo_group_reader_to_writer"; + int fd_writer_to_reader = -1, fd_reader_to_writer = -1; + int notify = 0, verify = 0; + bool wg_ret = false; + bool vg_ret = false; + + if (!state_init(&s, argc, argv)) { + printf("state_init failed\n"); + TEST_ERROR; + } + + personality = HDstrstr(s.progname, "vfd_swmr_gperf_"); + + if (personality != NULL && HDstrcmp(personality, "vfd_swmr_gperf_writer") == 0) + writer = true; + else if (personality != NULL && HDstrcmp(personality, "vfd_swmr_gperf_reader") == 0) + writer = false; + else { + printf("unknown personality, expected vfd_swmr_gperf_{reader,writer}\n"); + TEST_ERROR; + } + + /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ + init_vfd_swmr_config(&config, 4, 7, writer, FALSE, 128, "./group-shadow"); + + /* If old-style option is chosen, use the earliest file format(H5F_LIBVER_EARLIEST) + * as the second parameter of H5Pset_libver_bound() that is called by + * vfd_swmr_create_fapl. Otherwise, the latest file format(H5F_LIBVER_LATEST) + * should be used as the second parameter of H5Pset_libver_bound(). + * Also pass the use_vfd_swmr, only_meta_page, config to vfd_swmr_create_fapl().*/ + if ((fapl = vfd_swmr_create_fapl(!s.old_style_grp, s.use_vfd_swmr, true, &config)) < 0) { + printf("vfd_swmr_create_fapl failed\n"); + TEST_ERROR; + } + + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) { + printf("H5Pcreate failed\n"); + TEST_ERROR; + } + + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, false, 1) < 0) { + printf("H5Pset_file_space_strategy failed\n"); + TEST_ERROR; + } + + if (writer) + s.file = H5Fcreate(s.filename, H5F_ACC_TRUNC, fcpl, fapl); + else + s.file = H5Fopen(s.filename, H5F_ACC_RDONLY, fapl); + + if (s.file < 0) { + printf("H5Fcreate/open failed\n"); + TEST_ERROR; + } + + /* Use two named pipes(FIFO) to coordinate the writer and reader for + * two-way communication so that the two sides can move forward together. + * One is for the writer to write to the reader. + * The other one is for the reader to signal the writer. */ + if (s.use_named_pipes && writer) { + /* Writer creates two named pipes(FIFO) */ + if (HDmkfifo(fifo_writer_to_reader, 0600) < 0) { + printf("HDmkfifo failed\n"); + TEST_ERROR; + } + + if (HDmkfifo(fifo_reader_to_writer, 0600) < 0) { + printf("HDmkfifo failed\n"); + TEST_ERROR; + } + } + + /* Both the writer and reader open the pipes */ + if (s.use_named_pipes && (fd_writer_to_reader = HDopen(fifo_writer_to_reader, O_RDWR)) < 0) { + printf("HDopen failed\n"); + TEST_ERROR; + } + + if (s.use_named_pipes && (fd_reader_to_writer = HDopen(fifo_reader_to_writer, O_RDWR)) < 0) { + printf("HDopen failed\n"); + TEST_ERROR; + } + + /* Pass the named pipe information to the struct of state_t s, for attribute tests.*/ + if (s.use_named_pipes) { + s.np_fd_w_to_r = fd_writer_to_reader; + s.np_fd_r_to_w = fd_reader_to_writer; + s.np_notify = notify; + s.np_verify = verify; + s.tick_len = config.tick_len; + s.max_lag = config.max_lag; + } + + /* For attribute test, force the named pipe to communicate in every step. + * This will avoid the fake verification error from the reader when using the named pipe. + * If the named pipe is not forced to communicate in every step, the reader may go ahead + * to verify the group and the attribute operations before the writer has a chance to + * carry out the corresponding operations. */ + if (s.attr_test && s.use_named_pipes) + s.csteps = 1; + + /* For group operation test, force the named pipe to communicate in every step. */ + if (s.grp_op_test && s.use_named_pipes) + s.csteps = 1; + + if (writer) { + for (step = 0; step < s.nsteps; step++) { + dbgf(2, "writer: step %d\n", step); + + wg_ret = group_operations(&s, step); + + if (wg_ret == false) { + + /* At communication interval, notifies the reader about the failure and quit */ + if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && step % s.csteps == 0) + np_send_error(&s, true); + printf("write_group failed at step %d\n", step); + TEST_ERROR; + } + else { + + /* At communication interval, notifies the reader and waits for its response */ + if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && + step % s.csteps == 0) { + + if (np_wr_send_receive(&s) == false) { + printf("writer: write group - verification failed.\n"); + TEST_ERROR; + } + } + } + } + s.mean_time = s.total_time/s.nsteps; + fprintf(stdout, "group creation min. time = %lf\n", s.min_time); + fprintf(stdout, "group creation max. time = %lf\n", s.max_time); + fprintf(stdout, "group creation mean time = %lf\n", s.mean_time); + fprintf(stdout, "group creation total time = %lf\n", s.total_time); + } + else { + for (step = 0; step < s.nsteps; step++) { + dbgf(1, "reader: step %d\n", step); + + /* At communication interval, waits for the writer to finish creation before starting verification + */ + if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && step % s.csteps == 0) { + if (false == np_rd_receive(&s)) { + TEST_ERROR; + } + } + + /* For the default test, wait for a few ticks for the update to happen */ + if (s.use_named_pipes && s.attr_test == false) + decisleep(config.tick_len * s.update_interval); + + vg_ret = verify_group_operations(&s, step); + + if (vg_ret == false) { + + printf("verify_group_operations failed\n"); + + /* At communication interval, tell the writer about the failure and exit */ + if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && step % s.csteps == 0) + np_send_error(&s, false); + TEST_ERROR; + } + else { + + /* Send back the same nofity value for acknowledgement to tell the writer + * move to the next step. */ + if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && + step % s.csteps == 0) { + if (np_rd_send(&s) == false) { + TEST_ERROR; + } + } + } + } + } + + if (H5Pclose(fapl) < 0) { + printf("H5Pclose failed\n"); + TEST_ERROR; + } + + if (H5Pclose(fcpl) < 0) { + printf("H5Pclose failed\n"); + TEST_ERROR; + } + + if (H5Sclose(s.one_by_one_sid) < 0) { + printf("H5Sclose failed\n"); + TEST_ERROR; + } + + if (H5Fclose(s.file) < 0) { + printf("H5Fclose failed\n"); + TEST_ERROR; + } + + /* Both the writer and reader close the named pipes */ + if (s.use_named_pipes && HDclose(fd_writer_to_reader) < 0) { + printf("HDclose failed\n"); + TEST_ERROR; + } + + if (s.use_named_pipes && HDclose(fd_reader_to_writer) < 0) { + printf("HDclose failed\n"); + TEST_ERROR; + } + + /* Reader finishes last and deletes the named pipes */ + if (s.use_named_pipes && !writer) { + if (HDremove(fifo_writer_to_reader) != 0) { + printf("HDremove failed\n"); + TEST_ERROR; + } + + if (HDremove(fifo_reader_to_writer) != 0) { + printf("HDremove failed\n"); + TEST_ERROR; + } + } + + return EXIT_SUCCESS; + +error: + H5E_BEGIN_TRY + { + H5Pclose(fapl); + H5Pclose(fcpl); + H5Sclose(s.one_by_one_sid); + H5Fclose(s.file); + } + H5E_END_TRY; + + if (s.use_named_pipes && fd_writer_to_reader >= 0) + HDclose(fd_writer_to_reader); + + if (s.use_named_pipes && fd_reader_to_writer >= 0) + HDclose(fd_reader_to_writer); + + if (s.use_named_pipes && !writer) { + HDremove(fifo_writer_to_reader); + HDremove(fifo_reader_to_writer); + } + + return EXIT_FAILURE; +} + +#else /* H5_HAVE_WIN32_API */ + +int +main(void) +{ + HDfprintf(stderr, "Non-POSIX platform. Skipping.\n"); + return EXIT_SUCCESS; +} /* end main() */ + +#endif /* H5_HAVE_WIN32_API */ -- cgit v0.12 From 3dc6265bae206cd0705a0a5dfb9c5bd2f67c57ed Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 29 Jun 2021 16:57:20 +0000 Subject: Committing clang-format changes --- test/vfd_swmr_gperf_writer.c | 71 ++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index 9996798..f030db9 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -26,8 +26,8 @@ #define READER_WAIT_TICKS 3 #define VS_ATTR_NAME_LEN 21 -#define TIME_PASSED(X,Y) \ - ((double)((Y.tv_sec - X.tv_sec) * 1000000000 + (Y.tv_nsec - X.tv_nsec))) / 1000000000.0 +#define TIME_PASSED(X, Y) \ + ((double)((Y.tv_sec - X.tv_sec) * 1000000000 + (Y.tv_nsec - X.tv_nsec))) / 1000000000.0 typedef struct { hid_t file, filetype, one_by_one_sid; @@ -66,8 +66,8 @@ typedef struct { .update_interval = READER_WAIT_TICKS, .use_vfd_swmr = true, .old_style_grp = false, \ .use_named_pipes = true, .grp_op_pattern = ' ', .grp_op_test = false, .at_pattern = ' ', \ .attr_test = false, .tick_len = 4, .max_lag = 7, .np_fd_w_to_r = -1, .np_fd_r_to_w = -1, \ - .np_notify = 0, .np_verify = 0, .gperf = false, .min_time = 100., .max_time = 0.,.mean_time = 0., \ - .total_time = 0.,.num_attrs = 1 \ + .np_notify = 0, .np_verify = 0, .gperf = false, .min_time = 100., .max_time = 0., .mean_time = 0., \ + .total_time = 0., .num_attrs = 1 \ } static void @@ -1734,14 +1734,14 @@ add_group_attribute(state_t *s, hid_t g, hid_t gcpl, unsigned int which) static bool write_group(state_t *s, unsigned int which) { - char name[sizeof("/group-9999999999")]; - hid_t g = H5I_INVALID_HID; - hid_t dummy_d = H5I_INVALID_HID; - hid_t gcpl = H5I_INVALID_HID; - bool result = true; - H5G_info_t group_info; + char name[sizeof("/group-9999999999")]; + hid_t g = H5I_INVALID_HID; + hid_t dummy_d = H5I_INVALID_HID; + hid_t gcpl = H5I_INVALID_HID; + bool result = true; + H5G_info_t group_info; struct timespec start_time, end_time; - double temp_time; + double temp_time; if (which >= s->nsteps) { printf("Number of created groups is out of bounds\n"); @@ -1770,42 +1770,36 @@ write_group(state_t *s, unsigned int which) } #endif - if(s->gperf) { - - if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { + if (s->gperf) { - fprintf(stderr, "HDclock_gettime failed"); - - TEST_ERROR; - - } + if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { + fprintf(stderr, "HDclock_gettime failed"); + TEST_ERROR; + } } if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { printf("H5Gcreate2 failed\n"); TEST_ERROR; } - if(s->gperf) { + if (s->gperf) { - if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { + if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { - fprintf(stderr, "HDclock_gettime failed"); - - TEST_ERROR; - - } + fprintf(stderr, "HDclock_gettime failed"); + TEST_ERROR; + } - temp_time = TIME_PASSED(start_time,end_time); - if(temp_time < s->min_time) + temp_time = TIME_PASSED(start_time, end_time); + if (temp_time < s->min_time) s->min_time = temp_time; - if(temp_time > s->max_time) + if (temp_time > s->max_time) s->max_time = temp_time; - s->total_time += temp_time; + s->total_time += temp_time; } - #if 0 /* We need to create a dummy dataset for the object header continuation block test. */ @@ -1880,13 +1874,12 @@ write_group(state_t *s, unsigned int which) TEST_ERROR; } - return result; error: - - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(g); } H5E_END_TRY; @@ -5132,11 +5125,11 @@ main(int argc, char **argv) } } } - s.mean_time = s.total_time/s.nsteps; - fprintf(stdout, "group creation min. time = %lf\n", s.min_time); - fprintf(stdout, "group creation max. time = %lf\n", s.max_time); - fprintf(stdout, "group creation mean time = %lf\n", s.mean_time); - fprintf(stdout, "group creation total time = %lf\n", s.total_time); + s.mean_time = s.total_time / s.nsteps; + fprintf(stdout, "group creation min. time = %lf\n", s.min_time); + fprintf(stdout, "group creation max. time = %lf\n", s.max_time); + fprintf(stdout, "group creation mean time = %lf\n", s.mean_time); + fprintf(stdout, "group creation total time = %lf\n", s.total_time); } else { for (step = 0; step < s.nsteps; step++) { -- cgit v0.12 From 9d07011f4e2d8c5fd870c61e855d13a688940a18 Mon Sep 17 00:00:00 2001 From: Muqun Yang Date: Fri, 2 Jul 2021 13:02:33 -0500 Subject: More code to performance check. --- test/vfd_swmr_gperf_writer.c | 62 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index 9996798..cf12585 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -55,6 +55,8 @@ typedef struct { double max_time; double mean_time; double total_time; + double fo_total_time; + double fc_total_time; unsigned int num_attrs; } state_t; @@ -66,8 +68,9 @@ typedef struct { .update_interval = READER_WAIT_TICKS, .use_vfd_swmr = true, .old_style_grp = false, \ .use_named_pipes = true, .grp_op_pattern = ' ', .grp_op_test = false, .at_pattern = ' ', \ .attr_test = false, .tick_len = 4, .max_lag = 7, .np_fd_w_to_r = -1, .np_fd_r_to_w = -1, \ - .np_notify = 0, .np_verify = 0, .gperf = false, .min_time = 100., .max_time = 0.,.mean_time = 0., \ - .total_time = 0.,.num_attrs = 1 \ + .np_notify = 0, .np_verify = 0, .gperf = false, .min_time = 100., .max_time = 0.,.mean_time = 0., \ + .total_time = 0., .fo_total_time = 0., \ + .fc_total_time = 0., .num_attrs = 1 \ } static void @@ -5005,6 +5008,7 @@ main(int argc, char **argv) int notify = 0, verify = 0; bool wg_ret = false; bool vg_ret = false; + struct timespec start_time, end_time; if (!state_init(&s, argc, argv)) { printf("state_init failed\n"); @@ -5045,11 +5049,38 @@ main(int argc, char **argv) TEST_ERROR; } + if(s.gperf) { + + if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { + + fprintf(stderr, "HDclock_gettime failed"); + + TEST_ERROR; + + } + } + + if (writer) s.file = H5Fcreate(s.filename, H5F_ACC_TRUNC, fcpl, fapl); else s.file = H5Fopen(s.filename, H5F_ACC_RDONLY, fapl); + if(s.gperf) { + + if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { + + fprintf(stderr, "HDclock_gettime failed"); + + TEST_ERROR; + + } + + + s.fo_total_time = TIME_PASSED(start_time,end_time); + fprintf(stdout, "H5Fopen time = %lf\n", s.fo_total_time); + } + if (s.file < 0) { printf("H5Fcreate/open failed\n"); TEST_ERROR; @@ -5194,11 +5225,38 @@ main(int argc, char **argv) TEST_ERROR; } + if(s.gperf) { + + if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { + + fprintf(stderr, "HDclock_gettime failed"); + + TEST_ERROR; + + } + + } + if (H5Fclose(s.file) < 0) { printf("H5Fclose failed\n"); TEST_ERROR; } + if(s.gperf) { + + if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { + + fprintf(stderr, "HDclock_gettime failed"); + + TEST_ERROR; + + } + + s.fc_total_time = TIME_PASSED(start_time,end_time); + fprintf(stdout, "H5Fclose time = %lf\n", s.fc_total_time); + } + + /* Both the writer and reader close the named pipes */ if (s.use_named_pipes && HDclose(fd_writer_to_reader) < 0) { printf("HDclose failed\n"); -- cgit v0.12 From b1e75e7816b6d0fdfa9842156dd6ae5d6d816823 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 2 Jul 2021 18:14:04 +0000 Subject: Committing clang-format changes --- test/vfd_swmr_gperf_writer.c | 65 +++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index a3b5455..ab0fd57 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -68,9 +68,8 @@ typedef struct { .update_interval = READER_WAIT_TICKS, .use_vfd_swmr = true, .old_style_grp = false, \ .use_named_pipes = true, .grp_op_pattern = ' ', .grp_op_test = false, .at_pattern = ' ', \ .attr_test = false, .tick_len = 4, .max_lag = 7, .np_fd_w_to_r = -1, .np_fd_r_to_w = -1, \ - .np_notify = 0, .np_verify = 0, .gperf = false, .min_time = 100., .max_time = 0.,.mean_time = 0., \ - .total_time = 0., .fo_total_time = 0., \ - .fc_total_time = 0., .num_attrs = 1 \ + .np_notify = 0, .np_verify = 0, .gperf = false, .min_time = 100., .max_time = 0., .mean_time = 0., \ + .total_time = 0., .fo_total_time = 0., .fc_total_time = 0., .num_attrs = 1 \ } static void @@ -5001,7 +5000,7 @@ main(int argc, char **argv) int notify = 0, verify = 0; bool wg_ret = false; bool vg_ret = false; - struct timespec start_time, end_time; + struct timespec start_time, end_time; if (!state_init(&s, argc, argv)) { printf("state_init failed\n"); @@ -5042,38 +5041,34 @@ main(int argc, char **argv) TEST_ERROR; } - if(s.gperf) { - - if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { + if (s.gperf) { - fprintf(stderr, "HDclock_gettime failed"); + if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { - TEST_ERROR; + fprintf(stderr, "HDclock_gettime failed"); - } + TEST_ERROR; + } } - if (writer) s.file = H5Fcreate(s.filename, H5F_ACC_TRUNC, fcpl, fapl); else s.file = H5Fopen(s.filename, H5F_ACC_RDONLY, fapl); - if(s.gperf) { - - if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { + if (s.gperf) { - fprintf(stderr, "HDclock_gettime failed"); - - TEST_ERROR; + if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { - } + fprintf(stderr, "HDclock_gettime failed"); + TEST_ERROR; + } - s.fo_total_time = TIME_PASSED(start_time,end_time); - fprintf(stdout, "H5Fopen time = %lf\n", s.fo_total_time); + s.fo_total_time = TIME_PASSED(start_time, end_time); + fprintf(stdout, "H5Fopen time = %lf\n", s.fo_total_time); } - + if (s.file < 0) { printf("H5Fcreate/open failed\n"); TEST_ERROR; @@ -5218,16 +5213,14 @@ main(int argc, char **argv) TEST_ERROR; } - if(s.gperf) { + if (s.gperf) { - if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { - - fprintf(stderr, "HDclock_gettime failed"); - - TEST_ERROR; + if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { - } + fprintf(stderr, "HDclock_gettime failed"); + TEST_ERROR; + } } if (H5Fclose(s.file) < 0) { @@ -5235,21 +5228,19 @@ main(int argc, char **argv) TEST_ERROR; } - if(s.gperf) { + if (s.gperf) { - if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { - - fprintf(stderr, "HDclock_gettime failed"); + if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { - TEST_ERROR; + fprintf(stderr, "HDclock_gettime failed"); - } + TEST_ERROR; + } - s.fc_total_time = TIME_PASSED(start_time,end_time); - fprintf(stdout, "H5Fclose time = %lf\n", s.fc_total_time); + s.fc_total_time = TIME_PASSED(start_time, end_time); + fprintf(stdout, "H5Fclose time = %lf\n", s.fc_total_time); } - /* Both the writer and reader close the named pipes */ if (s.use_named_pipes && HDclose(fd_writer_to_reader) < 0) { printf("HDclose failed\n"); -- cgit v0.12 From a9e8b12a0a7aaf7fe0ffe0a103db2d8d4471c58b Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Fri, 16 Jul 2021 17:44:37 -0700 Subject: VFD SWMR: Removes dedup callback + cleanup (#842) * HDF5-ification of dedup calls * Removes dedup callback from VFD struct * VFD SWMR library code cleanup * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- src/H5FD.c | 119 +++++----- src/H5FDcore.c | 1 - src/H5FDdevelop.h | 1 - src/H5FDdirect.c | 1 - src/H5FDfamily.c | 1 - src/H5FDhdfs.c | 1 - src/H5FDlog.c | 1 - src/H5FDmirror.c | 1 - src/H5FDmpio.c | 1 - src/H5FDmulti.c | 1 - src/H5FDprivate.h | 1 + src/H5FDros3.c | 1 - src/H5FDsec2.c | 1 - src/H5FDsplitter.c | 1 - src/H5FDstdio.c | 1 - src/H5FDvfd_swmr.c | 645 ++++++++++++++++++++++++++--------------------------- src/H5FDvfd_swmr.h | 6 +- src/H5Fint.c | 11 +- test/h5test.c | 1 - 19 files changed, 386 insertions(+), 410 deletions(-) diff --git a/src/H5FD.c b/src/H5FD.c index fcf39f5..2cae1a8 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -60,7 +60,7 @@ typedef struct H5FD_wrap_t { /********************/ /* Local Prototypes */ /********************/ -static herr_t H5FD__free_cls(H5FD_class_t *cls); +static herr_t H5FD__free_cls(H5FD_class_t *cls, void **request); static herr_t H5FD__query(const H5FD_t *f, unsigned long *flags /*out*/); /*********************/ @@ -180,7 +180,7 @@ H5FD_term_package(void) *------------------------------------------------------------------------- */ static herr_t -H5FD__free_cls(H5FD_class_t *cls) +H5FD__free_cls(H5FD_class_t *cls, void H5_ATTR_UNUSED **request) { herr_t ret_value = SUCCEED; @@ -668,68 +668,81 @@ done: FUNC_LEAVE_API(ret_value) } -/* Helper routine for H5FD_deduplicate(): compare `self` and `other` using - * the deduplication method of `self`, if it has one; otherwise compare using - * `H5FDcmp()`. +/*------------------------------------------------------------------------- + * Function: H5FD__dedup + * + * Purpose: Helper routine for H5FD_deduplicate + * + * Compares `self` and `other` using the dedup callback of + * `self` (if it has one); otherwise compares using `H5FDcmp()`. + * + * No `dedup' callback: + * + * If `self` has no de-duplication method, compare `self` and + * `other` using `H5FDcmp()` and return `self` if they're equal + * and `other` if unequal. + * + * `dedup' callback present: + * + * If `self` does have a de-duplication callback, invoke it and + * return the method's result: `other` if it duplicates `self`, + * `self` if `other` does NOT duplicate it, NULL if `other` + * conflicts with `self` or if there is an error. * - * If `self` has no de-duplication method, compare `self` and `other` - * using `H5FDcmp()` and return `self` if they're equal and `other` if - * unequal. + * Return: Success: `self' or `other', as described above * - * If `self` does have a de-duplication method, call it and return the - * method's result: `other` if it duplicates `self`, `self` if `other` - * does NOT duplicate it, NULL if `other` conflicts with `self` or if - * there is an error. + * Failure: NULL + * + * Note: Unlike H5FD_deduplicate(), this routine does not free `self` + * under any circumstances. + * + *------------------------------------------------------------------------- * - * Unlike H5FD_deduplicate(), this routine does not free `self` under any - * circumstances. */ -static H5FD_t * -H5FD_dedup(H5FD_t *self, H5FD_t *other, hid_t fapl) -{ - H5FD_t *(*dedup)(H5FD_t *, H5FD_t *, hid_t); - - if ((dedup = self->cls->dedup) != NULL) - return (*dedup)(self, other, fapl); - - if (H5FDcmp(self, other) == 0) - return self; - return other; -} - -/* Search the already-opened VFD instances for an instance similar to the - * instance `file` newly-opened using file-access properties given by `fapl`. +/*------------------------------------------------------------------------- + * Function: H5FD_deduplicate + * + * Purpose: Search the already-opened VFD instances for an instance + * similar to the instance `file` newly-opened using file access + * properties given by `fapl_id`. * - * If there is an already-open instance that is functionally - * identical to `file`, close `file` and return the already-open instance. + * Return: It's complicated... * - * If there is an already-open instance that conflicts with `file` because, - * for example, its file-access properties are incompatible with `fapl`'s - * or, for another example, it is under exclusive control by a third VFD - * instance, then close `file` and return `NULL`. + * If there is an already-open instance that is functionally + * identical to `file`, close `file` and return the already + * open instance. * - * Otherwise, return `file` to indicate that there are no identical or - * conflicting VFD instances already open. + * If there is an already open instance that conflicts with + * `file` because, for example, its file-access properties are + * incompatible with `fapl_id`'s or, for another example, it is + * under exclusive control by a third VFD instance, then close + * `file` and return `NULL`. + * + * Otherwise, return `file` to indicate that there are no + * identical or conflicting VFD instances already open. + *------------------------------------------------------------------------- */ H5FD_t * -H5FD_deduplicate(H5FD_t *file, hid_t fapl) +H5FD_deduplicate(H5FD_t *file, hid_t fapl_id) { - H5FD_t * deduped = file; H5FD_wrap_t *item; + H5FD_t * ret_value = file; + + FUNC_ENTER_NOAPI(NULL) TAILQ_FOREACH(item, &all_vfds, link) { - /* skip "self" */ + /* Skip "self" */ if (item->file == file) continue; - /* skip files with exclusive owners, for now */ + /* Skip files with exclusive owners, for now */ if (item->file->exc_owner != NULL) continue; - if ((deduped = H5FD_dedup(item->file, file, fapl)) != file) - goto finish; + if ((ret_value = H5FD_vfd_swmr_dedup(item->file, file, fapl_id)) != file) + goto done; } /* If we reach this stage, then we identified neither a conflict nor a @@ -741,19 +754,17 @@ H5FD_deduplicate(H5FD_t *file, hid_t fapl) if (item->file == file || item->file->exc_owner == NULL) continue; - if (H5FDcmp(file, item->file) == 0) { - deduped = NULL; - break; - } + if (H5FD_cmp(file, item->file) == 0) + HGOTO_ERROR(H5E_VFL, H5E_FILEOPEN, NULL, + "found a conflicting open file when searching for duplicates") } -finish: - if (deduped != file && H5FD_close(file) < 0) { - HERROR(H5E_FILE, H5E_CANTOPENFILE, "could not close file"); - return NULL; - } - return deduped; -} +done: + if (ret_value != file && H5FD_close(file) < 0) + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "could not close file") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_deduplicate() */ /*------------------------------------------------------------------------- * Function: H5FD_open diff --git a/src/H5FDcore.c b/src/H5FDcore.c index f405200..50288c4 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -183,7 +183,6 @@ static const H5FD_class_t H5FD_core_g = { H5FD__core_lock, /* lock */ H5FD__core_unlock, /* unlock */ H5FD__core_delete, /* del */ - NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; diff --git a/src/H5FDdevelop.h b/src/H5FDdevelop.h index 5cf30ff..a723a1d 100644 --- a/src/H5FDdevelop.h +++ b/src/H5FDdevelop.h @@ -192,7 +192,6 @@ typedef struct H5FD_class_t { herr_t (*lock)(H5FD_t *file, hbool_t rw); herr_t (*unlock)(H5FD_t *file); herr_t (*del)(const char *name, hid_t fapl); - H5FD_t *(*dedup)(H5FD_t *, H5FD_t *, hid_t); H5FD_mem_t fl_map[H5FD_MEM_NTYPES]; } H5FD_class_t; diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 2a51883..a1b7b7e 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -172,7 +172,6 @@ static const H5FD_class_t H5FD_direct_g = { H5FD__direct_lock, /* lock */ H5FD__direct_unlock, /* unlock */ H5FD__direct_delete, /* del */ - NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 2356309..b265e1d 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -137,7 +137,6 @@ static const H5FD_class_t H5FD_family_g = { H5FD__family_lock, /* lock */ H5FD__family_unlock, /* unlock */ H5FD__family_delete, /* del */ - NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; diff --git a/src/H5FDhdfs.c b/src/H5FDhdfs.c index b308f17..102a3ab 100644 --- a/src/H5FDhdfs.c +++ b/src/H5FDhdfs.c @@ -310,7 +310,6 @@ static const H5FD_class_t H5FD_hdfs_g = { NULL, /* lock */ NULL, /* unlock */ NULL, /* del */ - NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 4fd5e27..707c97b 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -212,7 +212,6 @@ static const H5FD_class_t H5FD_log_g = { H5FD__log_lock, /* lock */ H5FD__log_unlock, /* unlock */ H5FD__log_delete, /* del */ - NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; diff --git a/src/H5FDmirror.c b/src/H5FDmirror.c index 1886714..cf14c90 100644 --- a/src/H5FDmirror.c +++ b/src/H5FDmirror.c @@ -192,7 +192,6 @@ static const H5FD_class_t H5FD_mirror_g = { H5FD__mirror_lock, /* lock */ H5FD__mirror_unlock, /* unlock */ NULL, /* del */ - NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index 2d86eed..dd40399 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -127,7 +127,6 @@ static const H5FD_class_mpi_t H5FD_mpio_g = { NULL, /* lock */ NULL, /* unlock */ H5FD__mpio_delete, /* del */ - NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }, /* End of superclass information */ H5FD__mpio_mpi_rank, /* get_rank */ diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index 1b5815a..86f7664 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -201,7 +201,6 @@ static const H5FD_class_t H5FD_multi_g = { H5FD_multi_lock, /* lock */ H5FD_multi_unlock, /* unlock */ H5FD_multi_delete, /* del */ - NULL, /* dedup */ H5FD_FLMAP_DEFAULT /* fl_map */ }; diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index 2e3d270..0a8850f 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -367,6 +367,7 @@ H5_DLL H5FD_vfd_swmr_idx_entry_t *vfd_swmr_enlarge_shadow_index(struct H5F_t *); H5_DLL void H5FD_vfd_swmr_dump_status(H5FD_t *, uint64_t); H5_DLL void H5FD_vfd_swmr_set_pb_configured(H5FD_t *_file); H5_DLL void H5FD_vfd_swmr_record_elapsed_ticks(H5FD_t *, uint64_t); +H5_DLL H5FD_t *H5FD_vfd_swmr_dedup(H5FD_t *_self, H5FD_t *_other, hid_t fapl_id); /* Function prototypes for MPI based VFDs*/ #ifdef H5_HAVE_PARALLEL diff --git a/src/H5FDros3.c b/src/H5FDros3.c index 0303b50..6e116ee 100644 --- a/src/H5FDros3.c +++ b/src/H5FDros3.c @@ -267,7 +267,6 @@ static const H5FD_class_t H5FD_ros3_g = { NULL, /* lock */ NULL, /* unlock */ NULL, /* del */ - NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index c694190..d823e3c 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -173,7 +173,6 @@ static const H5FD_class_t H5FD_sec2_g = { H5FD__sec2_lock, /* lock */ H5FD__sec2_unlock, /* unlock */ H5FD__sec2_delete, /* del */ - NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; diff --git a/src/H5FDsplitter.c b/src/H5FDsplitter.c index 91a8e84..c27cd1b 100644 --- a/src/H5FDsplitter.c +++ b/src/H5FDsplitter.c @@ -163,7 +163,6 @@ static const H5FD_class_t H5FD_splitter_g = { H5FD__splitter_lock, /* lock */ H5FD__splitter_unlock, /* unlock */ NULL, /* del */ - NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index f9faf53..6631325 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -215,7 +215,6 @@ static const H5FD_class_t H5FD_stdio_g = { H5FD_stdio_lock, /* lock */ H5FD_stdio_unlock, /* unlock */ H5FD_stdio_delete, /* del */ - NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; diff --git a/src/H5FDvfd_swmr.c b/src/H5FDvfd_swmr.c index 316ca6d..568f5d9 100644 --- a/src/H5FDvfd_swmr.c +++ b/src/H5FDvfd_swmr.c @@ -24,71 +24,64 @@ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ -#include "H5retry_private.h" /* Retry loops. */ +#include "H5retry_private.h" /* Retry loops. */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_VFD_SWMR_g = 0; +/* The description of a file belonging to this driver */ typedef struct H5FD_vfd_swmr_t { - H5FD_t pub; /* public stuff, must be */ - /* first */ + H5FD_t pub; /* public stuff, must be first */ /* HDF5 file */ - char hdf5_filename[H5FD_MAX_FILENAME_LEN]; /* Name of the HDF5 file from */ - /* open */ - H5FD_t *hdf5_file_lf; /* Driver info for the HDF5 */ - /* file */ + char hdf5_filename[H5FD_MAX_FILENAME_LEN]; /* Name of the HDF5 file from open */ + H5FD_t *hdf5_file_lf; /* Driver info for the HDF5 file */ /* Metadata file */ - int md_fd; /* File descriptor for the */ - /* metadata file */ - uint32_t md_pages_reserved; /* # of pages reserved at the */ - /* head of the metadata file */ - char md_file_path[H5FD_MAX_FILENAME_LEN]; /* Name of the metadate file */ - H5FD_vfd_swmr_md_header md_header; /* Metadata file header */ - H5FD_vfd_swmr_md_index md_index; /* Metadata file index */ - - uint64_t *api_elapsed_ticks; /* Histogram of ticks elapsed - * inside the API (reader only). - * api_elapsed_ticks[elapsed] is - * the number of times `elapsed` - * ticks passed in an API call - * during the program lifetime. - */ - uint32_t api_elapsed_nbuckets; /* Number of histogram buckets. */ - - hbool_t pb_configured; /* boolean flag set to TRUE */ - /* when the page buffer is */ - /* and to FALSE otherwise. */ - /* Used for sanity checking. */ - H5F_vfd_swmr_config_t config; - hbool_t writer; /* True iff configured to write. - * All methods on a write-mode - * SWMR VFD instance are passed - * to the lower VFD instance. - */ + int md_fd; /* File descriptor for the metadata file */ + uint32_t md_pages_reserved; /* # of pages reserved at the head of the metadata file */ + char md_file_path[H5FD_MAX_FILENAME_LEN]; /* Name of the metadate file */ + H5FD_vfd_swmr_md_header md_header; /* Metadata file header */ + H5FD_vfd_swmr_md_index md_index; /* Metadata file index */ + + /* Histogram of ticks elapsed inside the API (reader only). + * api_elapsed_ticks[elapsed] is the number of times + * `elapsed' ticks passed during an API call in the + * program's lifetime. + */ + uint64_t *api_elapsed_ticks; /* Array of histogram buckets */ + uint32_t api_elapsed_nbuckets; /* Number of histogram buckets. */ + + hbool_t pb_configured; /* Sanity-checking flag set when page buffer is configured */ + H5F_vfd_swmr_config_t config; /* VFD SWMR configuration */ + + /* Flag set if the file is a SWMR writer. + * All methods on a write-mode SWMR VFD instance are passed + * to the lower VFD instance. + */ + hbool_t writer; + } H5FD_vfd_swmr_t; #define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) /* Prototypes */ -static herr_t H5FD_vfd_swmr_term(void); -static H5FD_t *H5FD_vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_vfd_swmr_close(H5FD_t *_file); -static int H5FD_vfd_swmr_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static H5FD_t *H5FD_vfd_swmr_dedup(H5FD_t *, H5FD_t *, hid_t); -static herr_t H5FD_vfd_swmr_query(const H5FD_t *_f1, unsigned long *flags); -static haddr_t H5FD_vfd_swmr_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_vfd_swmr_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); -static haddr_t H5FD_vfd_swmr_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_vfd_swmr_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); -static herr_t H5FD_vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, - void *buf); -static herr_t H5FD_vfd_swmr_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, - const void *buf); -static herr_t H5FD_vfd_swmr_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_vfd_swmr_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_vfd_swmr_unlock(H5FD_t *_file); +static herr_t H5FD__vfd_swmr_term(void); +static H5FD_t *H5FD__vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD__vfd_swmr_close(H5FD_t *_file); +static int H5FD__vfd_swmr_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD__vfd_swmr_query(const H5FD_t *_f1, unsigned long *flags); +static haddr_t H5FD__vfd_swmr_get_eoa(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__vfd_swmr_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static haddr_t H5FD__vfd_swmr_get_eof(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__vfd_swmr_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD__vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__vfd_swmr_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__vfd_swmr_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__vfd_swmr_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD__vfd_swmr_unlock(H5FD_t *_file); /* VFD SWMR */ static htri_t H5FD__vfd_swmr_header_deserialize(H5FD_vfd_swmr_t *, H5FD_vfd_swmr_md_header *); @@ -97,40 +90,39 @@ static htri_t H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, H5FD static herr_t H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *, hbool_t); static const H5FD_class_t H5FD_vfd_swmr_g = { - "vfd_swmr", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_vfd_swmr_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - 0, /* fapl_size */ - NULL, /* fapl_get */ - NULL, /* fapl_copy */ - NULL, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD_vfd_swmr_open, /* open */ - H5FD_vfd_swmr_close, /* close */ - H5FD_vfd_swmr_cmp, /* cmp */ - H5FD_vfd_swmr_query, /* query */ - NULL, /* get_type_map */ - NULL, /* alloc */ - NULL, /* free */ - H5FD_vfd_swmr_get_eoa, /* get_eoa */ - H5FD_vfd_swmr_set_eoa, /* set_eoa */ - H5FD_vfd_swmr_get_eof, /* get_eof */ - H5FD_vfd_swmr_get_handle, /* get_handle */ - H5FD_vfd_swmr_read, /* read */ - H5FD_vfd_swmr_write, /* write */ - NULL, /* flush */ - H5FD_vfd_swmr_truncate, /* truncate */ - H5FD_vfd_swmr_lock, /* lock */ - H5FD_vfd_swmr_unlock, /* unlock */ - NULL, /* del */ - H5FD_vfd_swmr_dedup, /* dedup */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + "vfd_swmr", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD__vfd_swmr_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + 0, /* fapl_size */ + NULL, /* fapl_get */ + NULL, /* fapl_copy */ + NULL, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD__vfd_swmr_open, /* open */ + H5FD__vfd_swmr_close, /* close */ + H5FD__vfd_swmr_cmp, /* cmp */ + H5FD__vfd_swmr_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD__vfd_swmr_get_eoa, /* get_eoa */ + H5FD__vfd_swmr_set_eoa, /* set_eoa */ + H5FD__vfd_swmr_get_eof, /* get_eof */ + H5FD__vfd_swmr_get_handle, /* get_handle */ + H5FD__vfd_swmr_read, /* read */ + H5FD__vfd_swmr_write, /* write */ + NULL, /* flush */ + H5FD__vfd_swmr_truncate, /* truncate */ + H5FD__vfd_swmr_lock, /* lock */ + H5FD__vfd_swmr_unlock, /* unlock */ + NULL, /* del */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Declare a free list to manage the H5FD_vfd_swmr_t struct */ @@ -195,7 +187,7 @@ done: } /* end H5FD_vfd_swmr_init() */ /*--------------------------------------------------------------------------- - * Function: H5FD_vfd_swmr_term + * Function: H5FD__vfd_swmr_term * * Purpose: Shut down the VFD * @@ -207,15 +199,15 @@ done: *--------------------------------------------------------------------------- */ static herr_t -H5FD_vfd_swmr_term(void) +H5FD__vfd_swmr_term(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Reset VFL ID */ H5FD_VFD_SWMR_g = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_vfd_swmr_term() */ +} /* end H5FD__vfd_swmr_term() */ /*------------------------------------------------------------------------- * Function: H5Pset_fapl_vfd_swmr (Not yet) @@ -255,15 +247,15 @@ H5FD__swmr_reader_open(H5FD_vfd_swmr_t *file) h5_retry_t retry; hbool_t do_try; /* more tries remain */ herr_t ret_value = SUCCEED; + FUNC_ENTER_STATIC file->api_elapsed_nbuckets = file->config.max_lag + 1; file->api_elapsed_ticks = H5MM_calloc(file->api_elapsed_nbuckets * sizeof(*file->api_elapsed_ticks)); - if (file->api_elapsed_ticks == NULL) { - HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "could not allocate API elapsed ticks"); - } + if (file->api_elapsed_ticks == NULL) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "could not allocate API elapsed ticks") /* Retry on opening the metadata file */ for (do_try = h5_retry_init(&retry, H5FD_VFD_SWMR_MD_FILE_RETRY_MAX, H5_RETRY_DEFAULT_MINIVAL, @@ -286,10 +278,10 @@ H5FD__swmr_reader_open(H5FD_vfd_swmr_t *file) done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD__swmr_reader_open() */ /*------------------------------------------------------------------------- - * Function: H5FD_vfd_swmr_open + * Function: H5FD__vfd_swmr_open * * Purpose: Open the metadata file and the underlying HDF5 file * @@ -301,7 +293,7 @@ done: *------------------------------------------------------------------------- */ static H5FD_t * -H5FD_vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) +H5FD__vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { H5FD_vfd_swmr_t * file = NULL; size_t page_buf_size; @@ -309,35 +301,31 @@ H5FD_vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxa H5F_vfd_swmr_config_t *vfd_swmr_config; H5FD_t * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Get file access property list */ - if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) { - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list"); - } + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") if (H5P_get(plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &page_buf_size) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get page buffer size"); + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get page buffer size"); /* Paged allocation, too, has to be enabled, but the page buffer * initialization (H5PB_create) will detect a conflicting configuration * and return an error. */ - if (page_buf_size == 0) { - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "page buffering must be enabled"); - } + if (page_buf_size == 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "page buffering must be enabled") /* Create the new driver struct */ - if (NULL == (file = H5FL_CALLOC(H5FD_vfd_swmr_t))) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct"); - } + if (NULL == (file = H5FL_CALLOC(H5FD_vfd_swmr_t))) + HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, NULL, "unable to allocate file struct") vfd_swmr_config = &file->config; /* Get VFD SWMR configuration */ - if (H5P_get(plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, vfd_swmr_config) < 0) { - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get VFD SWMR config info"); - } + if (H5P_get(plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, vfd_swmr_config) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get VFD SWMR config info") file->md_fd = -1; file->hdf5_file_lf = NULL; @@ -354,9 +342,8 @@ H5FD_vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxa file->writer = vfd_swmr_config->writer; /* Ensure that this is the reader */ - if (!vfd_swmr_config->writer && H5FD__swmr_reader_open(file) < 0) { - HGOTO_ERROR(H5E_VFL, H5E_OPENERROR, NULL, "perform reader-specific opening steps failed"); - } + if (!vfd_swmr_config->writer && H5FD__swmr_reader_open(file) < 0) + HGOTO_ERROR(H5E_VFL, H5E_OPENERROR, NULL, "perform reader-specific opening steps failed") /* Hard-wired to open the underlying HDF5 file with SEC2 */ if ((file->hdf5_file_lf = H5FD_open(name, flags, H5P_FILE_ACCESS_DEFAULT, maxaddr)) == NULL) @@ -380,23 +367,19 @@ H5FD_vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxa done: /* Handle closing if error */ - if (NULL == ret_value && file) { - - if (H5FD_vfd_swmr_close(&file->pub) < 0) - - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "error from closing") - - } /* end if */ + if (NULL == ret_value && file) + if (H5FD__vfd_swmr_close(&file->pub) < 0) + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "error from closing") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_vfd_swmr_open() */ +} /* end H5FD__vfd_swmr_open() */ /* Perform the reader-only aspects of closing in VFD SWMR mode: optionally * log and always release the histogram of ticks spent in API calls, * close the shadow file, release the shadow index. */ static void -swmr_reader_close(H5FD_vfd_swmr_t *file) +H5FD__swmr_reader_close(H5FD_vfd_swmr_t *file) { vfd_swmr_reader_did_increase_tick_to(0); @@ -404,18 +387,17 @@ swmr_reader_close(H5FD_vfd_swmr_t *file) H5MM_xfree(file->api_elapsed_ticks); /* Close the metadata file */ - if (file->md_fd >= 0 && HDclose(file->md_fd) < 0) { + if (file->md_fd >= 0 && HDclose(file->md_fd) < 0) /* Push error, but keep going */ - HERROR(H5E_FILE, H5E_CANTCLOSEFILE, "unable to close the metadata file"); - } + HERROR(H5E_VFL, H5E_CANTCLOSEFILE, "unable to close the metadata file"); /* Free the index entries */ if (file->md_index.num_entries && file->md_index.entries) file->md_index.entries = H5FL_SEQ_FREE(H5FD_vfd_swmr_idx_entry_t, file->md_index.entries); -} +} /* end H5FD__swmr_reader_close() */ /*------------------------------------------------------------------------- - * Function: H5FD_vfd_swmr_close + * Function: H5FD__vfd_swmr_close * * Purpose: Handle closing for VFD SWMR driver * --close the underlying HDF5 file @@ -428,12 +410,12 @@ swmr_reader_close(H5FD_vfd_swmr_t *file) *------------------------------------------------------------------------- */ static herr_t -H5FD_vfd_swmr_close(H5FD_t *_file) +H5FD__vfd_swmr_close(H5FD_t *_file) { H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if (file->hdf5_file_lf != NULL) { if (file->hdf5_file_lf->exc_owner != NULL) { @@ -444,21 +426,21 @@ H5FD_vfd_swmr_close(H5FD_t *_file) /* Close the underlying file */ if (H5FD_close(file->hdf5_file_lf) < 0) /* Push error, but keep going */ - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close the HDF5 file") + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close the HDF5 file") } if (!file->writer) - (void)swmr_reader_close(file); + H5FD__swmr_reader_close(file); /* Release the driver info */ file = H5FL_FREE(H5FD_vfd_swmr_t, file); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_vfd_swmr_close() */ +} /* end H5FD__vfd_swmr_close() */ /*------------------------------------------------------------------------- - * Function: H5FD_vfd_swmr_cmp + * Function: H5FD__vfd_swmr_cmp * * Purpose: Compares two files belonging to this driver using an * arbitrary (but consistent) ordering. @@ -470,58 +452,78 @@ H5FD_vfd_swmr_close(H5FD_t *_file) *------------------------------------------------------------------------- */ static int -H5FD_vfd_swmr_cmp(const H5FD_t *_f1, const H5FD_t *_f2) +H5FD__vfd_swmr_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { const H5FD_vfd_swmr_t *f1 = (const H5FD_vfd_swmr_t *)_f1; const H5FD_vfd_swmr_t *f2 = (const H5FD_vfd_swmr_t *)_f2; int ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR ret_value = H5FD_cmp(f1->hdf5_file_lf, f2->hdf5_file_lf); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_vfd_swmr_cmp() */ +} /* end H5FD_vfd__swmr_cmp() */ -/* Compare the already-opened VFD instance `_self` with the - * VFD instance `_other` newly-opened with file-access properties `fapl` - * and indicate whether the instances duplicate each other, if they conflict - * with each other, or if they are dissimilar. +/*------------------------------------------------------------------------- + * Function: H5FD_vfd_swmr_dedup + * + * Purpose: Compare the already-opened VFD instance `_self` with the + * VFD instance `_other` newly-opened with file-access properties + * `fapl_id` and indicate whether the instances duplicate each + * other, if they conflict with each other, or if they are + * dissimilar. * - * If `_self` duplicates `_other`, return `_self`. + * If `_self` duplicates `_other`, return `_self`. * - * Return NULL on error, or if `_other` and `_self` refer to the same file - * but the file-access properties, `fapl`, conflict with the properties of - * `_self`. + * Return NULL on error, or if `_other` and `_self` refer to the + * same file but the file-access properties, `fapl_id`, conflict + * with the properties of `_self`. * - * If `_other` neither duplicates nor conflicts with `_self`, then return - * `_other`. + * If `_other` neither duplicates nor conflicts with `_self`, + * then return `_other`. * - * # Judging duplicate/conflicting/dissimilar VFD instances + * NOTE: Judging duplicate/conflicting/dissimilar VFD instances * - * `_self` duplicates `_other` if `_other` is also an instance of SWMR - * class, the instances' lower files are equal under `H5FD_cmp()`, and - * the file-access properties of `_self` match `fapl`. - * The wildcard `fapl` value, `H5P_FILE_ACCESS_ANY_VFD`, matches all. + * `_self` DUPLICATES `_other` if `_other` is also an instance + * of SWMR class, the instances' lower files are equal under + * `H5FD_cmp()`, and the file-access properties of `_self` match + * `fapl_id`. The wildcard `fapl_id` value, + * `H5P_FILE_ACCESS_ANY_VFD`, matches all. * - * `_self` also duplicates `_other` if `_other` is not a SWMR instance, but - * it equals the lower file of `_self` under `H5FD_cmp()`, and `fapl` is - * `H5P_FILE_ACCESS_ANY_VFD`. + * `_self` also DUPLICATES `_other` if `_other` is not a SWMR + * instance, but it equals the lower file of `_self` under + * `H5FD_cmp()`, and `fapl_id` is `H5P_FILE_ACCESS_ANY_VFD`. * - * `_self` and `_other` conflict if both are SWMR instances referring to - * the same lower file, and their file-access properties differ. + * `_self` and `_other` CONFLICT if both are SWMR instances + * referring to the same lower file, and their file-access + * properties differ. * - * `_self` and `_other` conflict if `_other` is not a SWMR instance, it - * equals the lower file of `_self`, and `fapl` is not equal to - * `H5P_FILE_ACCESS_ANY_VFD`. + * `_self` and `_other` CONFLICT if `_other` is not a SWMR + * instance, it equals the lower file of `_self`, and `fapl_id` + * is not equal to `H5P_FILE_ACCESS_ANY_VFD`. + * + * Return: Success: `_self' or `_other', as described above + * Failure: NULL + *------------------------------------------------------------------------- */ -static H5FD_t * -H5FD_vfd_swmr_dedup(H5FD_t *_self, H5FD_t *_other, hid_t fapl) +H5FD_t * +H5FD_vfd_swmr_dedup(H5FD_t *_self, H5FD_t *_other, hid_t fapl_id) { - H5FD_vfd_swmr_t *self = (H5FD_vfd_swmr_t *)_self; + H5FD_vfd_swmr_t *self = (H5FD_vfd_swmr_t *)_self; + H5FD_t * ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL); - HDassert(_self->driver_id == H5FD_VFD_SWMR_g); + /* Not VFD SWMR */ + if (_self->driver_id != H5FD_VFD_SWMR_g) { + if (H5FD_cmp(_self, _other) == 0) + HGOTO_DONE(_self) + else + HGOTO_DONE(_other) + } + /* VFD SWMR */ if (_self->cls == _other->cls) { H5FD_vfd_swmr_t * other = (H5FD_vfd_swmr_t *)_other; H5P_genplist_t * plist; @@ -529,53 +531,47 @@ H5FD_vfd_swmr_dedup(H5FD_t *_self, H5FD_t *_other, hid_t fapl) hbool_t equal_configs; if (H5FD_cmp(self->hdf5_file_lf, other->hdf5_file_lf) != 0) - return _other; + HGOTO_DONE(_other) - /* If fapl == _ANY_VFD, then the match between lower files is + /* If fapl_id == _ANY_VFD, then the match between lower files is * sufficient. */ - if (fapl == H5P_FILE_ACCESS_ANY_VFD) - return _self; + if (fapl_id == H5P_FILE_ACCESS_ANY_VFD) + HGOTO_DONE(_self) - /* If fapl != _ANY_VFD, then we have either a duplicate or + /* If fapl_id != _ANY_VFD, then we have either a duplicate or * a conflict. If the VFD SWMR parameters match, then * return `self` to indicate a duplicate. Otherwise, return * NULL to indicate a mismatch. */ - if (NULL == (plist = H5I_object(fapl))) { - HERROR(H5E_ARGS, H5E_BADTYPE, "could not get fapl"); - return NULL; - } + if (NULL == (plist = H5I_object(fapl_id))) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "could not get fapl") - if ((config = H5MM_malloc(sizeof(*config))) == NULL) { - HERROR(H5E_ARGS, H5E_BADTYPE, "could not allocate config"); - return NULL; - } - if (H5P_get(plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, config) < 0) { - HERROR(H5E_PLIST, H5E_CANTGET, "cannot get VFD SWMR config"); - return NULL; - } + if ((config = H5MM_malloc(sizeof(*config))) == NULL) + HGOTO_ERROR(H5E_VFL, H5E_BADTYPE, NULL, "could not allocate config") + if (H5P_get(plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, config) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "cannot get VFD SWMR config") equal_configs = HDmemcmp(&self->config, config, sizeof(*config)) == 0; H5MM_xfree(config); if (equal_configs) - return _self; + HGOTO_DONE(_self) - HERROR(H5E_PLIST, H5E_CANTGET, "inconsistent VFD SWMR config"); - return NULL; + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "inconsistent VFD SWMR config") } - else if (H5FD_cmp(self->hdf5_file_lf, _other) == 0) { - return (fapl == H5P_FILE_ACCESS_ANY_VFD) ? _self : NULL; - } - else { - return _other; - } -} + else if (H5FD_cmp(self->hdf5_file_lf, _other) == 0) + ret_value = (fapl_id == H5P_FILE_ACCESS_ANY_VFD) ? _self : NULL; + else + ret_value = _other; + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5FD_vfd_swmr_dedup() */ /*------------------------------------------------------------------------- - * Function: H5FD_vfd_swmr_query + * Function: H5FD__vfd_swmr_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) @@ -585,49 +581,45 @@ H5FD_vfd_swmr_dedup(H5FD_t *_self, H5FD_t *_other, hid_t fapl) *------------------------------------------------------------------------- */ static herr_t -H5FD_vfd_swmr_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* out */) +H5FD__vfd_swmr_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* out */) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Set the VFL feature flags that this driver supports */ if (flags) { *flags = 0; - *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate */ - /* metadata allocations */ - *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate */ - /* metadata for faster */ - /* writes */ + /* OK to aggregate metadata allocations */ + *flags |= H5FD_FEAT_AGGREGATE_METADATA; - *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data */ - /* sieving for faster */ - /* raw data reads & */ - /* writes */ + /* OK to accumulate metadata for faster writes */ + *flags |= H5FD_FEAT_ACCUMULATE_METADATA; - *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate */ - /* "small" raw data */ - /* allocations */ + /* OK to perform data sieving for faster raw data reads & writes */ + *flags |= H5FD_FEAT_DATA_SIEVE; - *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* get_handle callback */ - /* returns a POSIX file */ - /* descriptor */ + /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; - *flags |= H5FD_FEAT_SUPPORTS_SWMR_IO; /* VFD supports the */ - /* single-writer/ */ - /* multiple-readers */ - /* (SWMR) pattern */ + /* get_handle callback returns a POSIX file descriptor */ + *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; - *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file */ - /* which can be opened */ - /* with the default VFD */ + /* VFD supports the single-writer / multiple readers (SWMR) pattern */ + *flags |= H5FD_FEAT_SUPPORTS_SWMR_IO; - } /* end if */ + /* VFD creates a file that can be opened with the default VFD + * + * NOTE: When this VFD becomes a true passthrough, this flag will + * probably need to go away. + */ + *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; + } FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_vfd_swmr_query() */ +} /* end H5FD__vfd_swmr_query() */ /*------------------------------------------------------------------------- - * Function: H5FD_vfd_swmr_get_eoa + * Function: H5FD__vfd_swmr_get_eoa * * Purpose: Gets the end-of-address marker for the file for the * underlying HDF5 file. The EOA marker is the first address @@ -638,51 +630,49 @@ H5FD_vfd_swmr_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* *------------------------------------------------------------------------- */ static haddr_t -H5FD_vfd_swmr_get_eoa(const H5FD_t *_file, H5FD_mem_t type) +H5FD__vfd_swmr_get_eoa(const H5FD_t *_file, H5FD_mem_t type) { const H5FD_vfd_swmr_t *file = (const H5FD_vfd_swmr_t *)_file; haddr_t ret_value = HADDR_UNDEF; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if ((ret_value = H5FD_get_eoa(file->hdf5_file_lf, type)) == HADDR_UNDEF) - - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, HADDR_UNDEF, "unable to get HDF5 file eoa") + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to get HDF5 file eoa") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_vfd_swmr_get_eoa() */ +} /* end H5FD__vfd_swmr_get_eoa() */ /*------------------------------------------------------------------------- - * Function: H5FD_vfd_swmr_set_eoa + * Function: H5FD__vfd_swmr_set_eoa * * Purpose: Set the end-of-address marker for the underlying HDF5 file. * This function is called shortly after an existing HDF5 file * is opened in order to tell the driver where the end of the * HDF5 data is located. * - * Return: SUCCEED (Can't fail) + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ static herr_t -H5FD_vfd_swmr_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) +H5FD__vfd_swmr_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) { H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if (H5FD_set_eoa(file->hdf5_file_lf, type, addr) < 0) - - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to set HDF5 file eoa") + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to set HDF5 file eoa") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_vfd_swmr_set_eoa() */ +} /* end H5FD__vfd_swmr_set_eoa() */ /*------------------------------------------------------------------------- - * Function: H5FD_vfd_swmr_get_eof + * Function: H5FD__vfd_swmr_get_eof * * Purpose: Returns the end-of-file marker, which is the greater of * either the filesystem end-of-file or the HDF5 end-of-address @@ -694,38 +684,37 @@ done: *------------------------------------------------------------------------- */ static haddr_t -H5FD_vfd_swmr_get_eof(const H5FD_t *_file, H5FD_mem_t type) +H5FD__vfd_swmr_get_eof(const H5FD_t *_file, H5FD_mem_t type) { const H5FD_vfd_swmr_t *file = (const H5FD_vfd_swmr_t *)_file; haddr_t ret_value = HADDR_UNDEF; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* LATER: need to determine the metadata file or underlying HDF5 file ? */ if ((ret_value = H5FD_get_eof(file->hdf5_file_lf, type)) == HADDR_UNDEF) - - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, HADDR_UNDEF, "unable to set file eoa") + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to set file eoa") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_vfd_swmr_get_eof() */ +} /* end H5FD__vfd_swmr_get_eof() */ /*------------------------------------------------------------------------- - * Function: H5FD_vfd_swmr_get_handle + * Function: H5FD__vfd_swmr_get_handle * - * Purpose: Returns the file handle for the underling HDF5 file + * Purpose: Returns the file handle for the underling HDF5 file * - * Returns: SUCCEED/FAIL + * Returns: SUCCEED/FAIL * *------------------------------------------------------------------------- */ static herr_t -H5FD_vfd_swmr_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) +H5FD__vfd_swmr_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) { H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") @@ -738,10 +727,10 @@ H5FD_vfd_swmr_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_vfd_swmr_get_handle() */ +} /* end H5FD__vfd_swmr_get_handle() */ /*------------------------------------------------------------------------- - * Function: H5FD_vfd_swmr_read + * Function: H5FD__vfd_swmr_read * * Purpose: If the target page or multi-page metadata entry is * defined in the current metadata file index, satisfy @@ -776,8 +765,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, const haddr_t addr, - size_t size, void *const buf /*out*/) +H5FD__vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, const haddr_t addr, + size_t size, void *const buf /*out*/) { const size_t init_size = size; haddr_t target_page; @@ -792,7 +781,7 @@ H5FD_vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, if (file->writer) return H5FD_read(file->hdf5_file_lf, type, addr, size, buf); - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file && file->pub.cls); HDassert(buf); @@ -808,9 +797,9 @@ H5FD_vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, if (entry == NULL) { /* Cannot find addr in index, read from the underlying hdf5 file */ - if (H5FD_read(file->hdf5_file_lf, type, addr, size, buf) < 0) { - HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "file read request failed"); - } + if (H5FD_read(file->hdf5_file_lf, type, addr, size, buf) < 0) + HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "file read request failed") + HGOTO_DONE(SUCCEED); } @@ -848,7 +837,7 @@ H5FD_vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, } while (-1 == bytes_read && EINTR == errno); if (-1 == bytes_read) - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, + HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "error reading the page/multi-page entry from the md file") HDassert(0 <= bytes_read && (size_t)bytes_read <= size); @@ -871,30 +860,30 @@ H5FD_vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, H5_checksum_metadata(buf, entry->length, 0) != entry->chksum) { H5FD_vfd_swmr_md_header tmp_header; - if (H5FD__vfd_swmr_header_deserialize(file, &tmp_header) != TRUE) { + if (H5FD__vfd_swmr_header_deserialize(file, &tmp_header) != TRUE) HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, - "checksum error in shadow file entry; could not load header"); - } + "checksum error in shadow file entry; could not load header") - HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, "checksum error in shadow file entry"); + HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, "checksum error in shadow file entry") } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_vfd_swmr_read() */ +} /* end H5FD__vfd_swmr_read() */ -/* - * Function: H5FD_vfd_swmr_write +/*------------------------------------------------------------------------- + * Function: H5FD__vfd_swmr_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF according to data transfer properties in * DXPL_ID. * * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- */ static herr_t -H5FD_vfd_swmr_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, - const void *buf) +H5FD__vfd_swmr_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, + const void *buf) { H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; @@ -904,7 +893,7 @@ H5FD_vfd_swmr_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id HDassert(file->writer); return H5FD_write(file->hdf5_file_lf, type, addr, size, buf); -} +} /* end H5FD__vfd_swmr_write() */ /*------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_truncate @@ -917,20 +906,22 @@ H5FD_vfd_swmr_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id *------------------------------------------------------------------------- */ static herr_t -H5FD_vfd_swmr_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) +H5FD__vfd_swmr_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; /* VFD SWMR file struct */ + FUNC_ENTER_STATIC_NOERR + /* This routine should only be called if the VFD instance is opened * for writing. */ HDassert(file->writer); - return H5FD_truncate(file->hdf5_file_lf, closing); + FUNC_LEAVE_NOAPI(H5FD_truncate(file->hdf5_file_lf, closing)) } /*------------------------------------------------------------------------- - * Function: H5FD_vfd_swmr_lock + * Function: H5FD__vfd_swmr_lock * * Purpose: To place an advisory lock on the underlying HDF5 file. * @@ -939,25 +930,24 @@ H5FD_vfd_swmr_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t clos *------------------------------------------------------------------------- */ static herr_t -H5FD_vfd_swmr_lock(H5FD_t *_file, hbool_t rw) +H5FD__vfd_swmr_lock(H5FD_t *_file, hbool_t rw) { H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; /* VFD SWMR file struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file); if (H5FD_lock(file->hdf5_file_lf, rw) < 0) - - HGOTO_ERROR(H5E_IO, H5E_CANTLOCK, FAIL, "unable to lock the HDF5 file") + HGOTO_ERROR(H5E_VFL, H5E_CANTLOCK, FAIL, "unable to lock the HDF5 file") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_vfd_swmr_lock() */ +} /* end H5FD__vfd_swmr_lock() */ /*------------------------------------------------------------------------- - * Function: H5FD_vfd_swmr_unlock + * Function: H5FD__vfd_swmr_unlock * * Purpose: To remove the existing lock on the underlying HDF5 file * @@ -966,26 +956,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_vfd_swmr_unlock(H5FD_t *_file) +H5FD__vfd_swmr_unlock(H5FD_t *_file) { H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; /* VFD SWMR file struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file); if (H5FD_unlock(file->hdf5_file_lf) < 0) - - HGOTO_ERROR(H5E_IO, H5E_CANTUNLOCK, FAIL, "unable to unlock the HDF5 file") + HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCK, FAIL, "unable to unlock the HDF5 file") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_vfd_swmr_unlock() */ +} /* end H5FD__vfd_swmr_unlock() */ -/* +/*------------------------------------------------------------------------- * Function: H5FD__vfd_swmr_load_hdr_and_idx() * * Purpose: Load and decode the header and index in the metadata file @@ -1029,18 +1018,19 @@ done: * Return: Success: SUCCEED * Failure: FAIL * + *------------------------------------------------------------------------- */ static herr_t H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *file, hbool_t open) { hbool_t do_try; h5_retry_t retry; - H5FD_vfd_swmr_md_header md_header; /* Metadata file header, take 1 */ - H5FD_vfd_swmr_md_header md_header_two; /* Metadata file header, take 2 */ - H5FD_vfd_swmr_md_index md_index; /* Metadata file index */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_vfd_swmr_md_header md_header; /* Metadata file header, take 1 */ + H5FD_vfd_swmr_md_header md_header_two; /* Metadata file header, take 2 */ + H5FD_vfd_swmr_md_index md_index; /* Metadata file index */ htri_t rc; static uint64_t last_index_offset = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1058,7 +1048,7 @@ H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *file, hbool_t open) continue; if (rc != TRUE) - HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "could not read header"); + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "could not read header") if (md_header.index_offset != last_index_offset) last_index_offset = md_header.index_offset; @@ -1070,12 +1060,11 @@ H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *file, hbool_t open) * time, then there is not a complete new index to read, so * get out. */ - HGOTO_DONE(SUCCEED); + HGOTO_DONE(SUCCEED) } - else if (md_header.tick_num < file->md_header.tick_num) { + else if (md_header.tick_num < file->md_header.tick_num) /* The tick number must not move backward. */ - HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "tick number in header moved backwards"); - } + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "tick number in header moved backwards") HDassert(md_header.tick_num > file->md_header.tick_num || open); @@ -1088,7 +1077,7 @@ H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *file, hbool_t open) continue; if (rc != TRUE) - HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "could not read index"); + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "could not read index") /* If the tick_num is the same in both header and index, * and the header reads the same the second time as the first time, @@ -1108,18 +1097,16 @@ H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *file, hbool_t open) (H5FD_vfd_swmr_idx_entry_t *)H5FL_SEQ_FREE(H5FD_vfd_swmr_idx_entry_t, md_index.entries); } - if (rc == FAIL) { - HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "could not re-read header"); - } + if (rc == FAIL) + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "could not re-read header") } /* Exhaust all retries for loading and decoding the md file header * and index */ - if (!do_try) { + if (!do_try) HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, "error in loading/decoding the metadata file header and index") - } /* Free VFD local entries */ if (file->md_index.entries != NULL) { @@ -1170,30 +1157,28 @@ H5FD__vfd_swmr_header_deserialize(H5FD_vfd_swmr_t *file, H5FD_vfd_swmr_md_header FUNC_ENTER_STATIC /* Set file pointer to the beginning the file */ - if (HDlseek(file->md_fd, H5FD_MD_HEADER_OFF, SEEK_SET) < 0) { - HGOTO_ERROR(H5E_VFL, H5E_SEEKERROR, FAIL, "unable to seek in metadata file"); - } + if (HDlseek(file->md_fd, H5FD_MD_HEADER_OFF, SEEK_SET) < 0) + HGOTO_ERROR(H5E_VFL, H5E_SEEKERROR, FAIL, "unable to seek in metadata file") /* Read the header */ nread = HDread(file->md_fd, image, H5FD_MD_HEADER_SIZE); /* Try again if a signal interrupted the read. */ if (nread == -1 && errno == EINTR) - HGOTO_DONE(FALSE); + HGOTO_DONE(FALSE) /* We cannot recover from any other error by trying again, * so bail out. */ - if (nread == -1) { - HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "error in reading the shadow header"); - } + if (nread == -1) + HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "error in reading the shadow header") if ((uint64_t)nread < H5FD_MD_HEADER_SIZE) - HGOTO_DONE(FALSE); + HGOTO_DONE(FALSE) /* Verify magic number */ if (HDmemcmp(image, H5FD_MD_HEADER_MAGIC, H5_SIZEOF_MAGIC) != 0) - HGOTO_DONE(FALSE); + HGOTO_DONE(FALSE) /* Verify stored and computed checksums are equal */ H5F_get_checksums(image, H5FD_MD_HEADER_SIZE, &stored_chksum, &computed_chksum); @@ -1208,9 +1193,8 @@ H5FD__vfd_swmr_header_deserialize(H5FD_vfd_swmr_t *file, H5FD_vfd_swmr_md_header UINT32DECODE(p, md_header->fs_page_size); UINT64DECODE(p, md_header->tick_num); UINT64DECODE(p, md_header->index_offset); - if ((index_length = uint64_decode(&p)) > SIZE_MAX) { - HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "index is too large to hold in core"); - } + if ((index_length = uint64_decode(&p)) > SIZE_MAX) + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "index is too large to hold in core") md_header->index_length = (size_t)index_length; @@ -1266,28 +1250,24 @@ H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, H5FD_vfd_swmr_md_i FUNC_ENTER_STATIC /* Allocate buffer for reading index */ - if (NULL == (image = H5MM_malloc(md_header->index_length))) { - HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, - "memory allocation failed for index's on disk image buffer"); - } + if (NULL == (image = H5MM_malloc(md_header->index_length))) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "memory allocation failed for index's on disk image buffer") /* We may seek past EOF. That's ok, the read(2) will catch that. */ - if (HDlseek(file->md_fd, (HDoff_t)md_header->index_offset, SEEK_SET) < 0) { - HGOTO_ERROR(H5E_VFL, H5E_SEEKERROR, FAIL, "unable to seek in metadata file"); - } + if (HDlseek(file->md_fd, (HDoff_t)md_header->index_offset, SEEK_SET) < 0) + HGOTO_ERROR(H5E_VFL, H5E_SEEKERROR, FAIL, "unable to seek in metadata file") nread = HDread(file->md_fd, image, md_header->index_length); /* Try again if a signal interrupted the read. */ if (nread == -1 && errno == EINTR) - HGOTO_DONE(FALSE); + HGOTO_DONE(FALSE) /* We cannot recover from any other error by trying again, * so bail out. */ - if (nread == -1) { - HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "error in reading the header in metadata file"); - } + if (nread == -1) + HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "error in reading the header in metadata file") /* Try again if the read was not full. * @@ -1302,7 +1282,7 @@ H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, H5FD_vfd_swmr_md_i * like an unrecoverable error instead of retrying. */ if ((size_t)nread < md_header->index_length) - HGOTO_DONE(FALSE); + HGOTO_DONE(FALSE) /* If the index magic is incorrect, then assume that is a * temporary error and try again. @@ -1323,7 +1303,7 @@ H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, H5FD_vfd_swmr_md_i * re-reading the header. */ if (HDmemcmp(image, H5FD_MD_INDEX_MAGIC, H5_SIZEOF_MAGIC) != 0) - HGOTO_DONE(FALSE); + HGOTO_DONE(FALSE) /* Verify stored and computed checksums are equal */ H5F_get_checksums(image, md_header->index_length, &stored_chksum, &computed_chksum); @@ -1343,9 +1323,8 @@ H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, H5FD_vfd_swmr_md_i if (md_index->num_entries) { /* Allocate memory for index entries */ md_index->entries = H5FL_SEQ_CALLOC(H5FD_vfd_swmr_idx_entry_t, md_index->num_entries); - if (NULL == md_index->entries) { - HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "memory allocation failed for index entries"); - } + if (NULL == md_index->entries) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "memory allocation failed for index entries") /* Decode index entries */ for (i = 0; i < md_index->num_entries; i++) { @@ -1419,9 +1398,8 @@ H5FD_vfd_swmr_get_tick_and_idx(H5FD_t *_file, hbool_t reload_hdr_and_index, uint FUNC_ENTER_NOAPI(FAIL) /* Load and decode the header and index as indicated */ - if (reload_hdr_and_index && H5FD__vfd_swmr_load_hdr_and_idx(file, FALSE) < 0) { + if (reload_hdr_and_index && H5FD__vfd_swmr_load_hdr_and_idx(file, FALSE) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, "unable to load/decode md header and index") - } /* Return tick_num */ if (tick_ptr != NULL) @@ -1429,9 +1407,8 @@ H5FD_vfd_swmr_get_tick_and_idx(H5FD_t *_file, hbool_t reload_hdr_and_index, uint if (index != NULL) { - if (*num_entries_ptr < file->md_index.num_entries) { - HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, "not enough space to copy index"); - } + if (*num_entries_ptr < file->md_index.num_entries) + HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, "not enough space to copy index") HDmemcpy(index, file->md_index.entries, (file->md_index.num_entries * sizeof(file->md_index.entries[0]))); @@ -1475,10 +1452,8 @@ H5FD_vfd_swmr_dump_status(H5FD_t *_file, uint64_t page) while ((!in_index) && (i < (int)num_entries)) { - if (index[i].hdf5_page_offset == page) { - + if (index[i].hdf5_page_offset == page) in_index = TRUE; - } HDassert((i == 0) || (index[i - 1].hdf5_page_offset < index[i].hdf5_page_offset)); @@ -1527,15 +1502,29 @@ H5FD_vfd_swmr_set_pb_configured(H5FD_t *_file) } /* H5FD_vfd_swmr_set_pb_configured() */ -/* In the histogram of ticks spent in API calls, increase the bucket - * for `elapsed` ticks by one. +/*------------------------------------------------------------------------- + * Function: H5FD_vfd_swmr_record_elapsed_ticks + * + * Purpose: In the histogram of ticks spent in API calls, increase + * the bucket for `elapsed` ticks by one. + * + * Return: VOID + * + * Programmer: JRM -- 1/29/19 + * + *------------------------------------------------------------------------- + * */ void H5FD_vfd_swmr_record_elapsed_ticks(H5FD_t *_file, uint64_t elapsed) { + FUNC_ENTER_NOAPI_NOINIT_NOERR + H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; uint32_t elapsed_idx = MIN(elapsed, file->api_elapsed_nbuckets); file->api_elapsed_ticks[elapsed_idx]++; -} + + FUNC_LEAVE_NOAPI_VOID +} /* end H5FD_vfd_swmr_record_elapsed_ticks() */ diff --git a/src/H5FDvfd_swmr.h b/src/H5FDvfd_swmr.h index d85cc95..096d5fb 100644 --- a/src/H5FDvfd_swmr.h +++ b/src/H5FDvfd_swmr.h @@ -16,10 +16,6 @@ #ifndef H5FDvfd_swmr_H #define H5FDvfd_swmr_H -#include "H5api_adpt.h" /* H5_DLL */ -#include "H5public.h" /* uint64_t *ahem* */ -#include "H5Ipublic.h" /* hid_t */ - #define H5FD_VFD_SWMR (H5FD_vfd_swmr_init()) #ifdef __cplusplus @@ -33,4 +29,4 @@ H5_DLL herr_t H5Pset_fapl_vfd_swmr(hid_t fapl_id); } #endif -#endif /* H5FDvfd_swmr_H */ +#endif diff --git a/src/H5Fint.c b/src/H5Fint.c index 44506b6..247a047 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -1575,12 +1575,6 @@ H5F__dest(H5F_t *f, hbool_t flush) /* Push error, but keep going*/ HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "vfd swmr prep for flush or close failed") - if ((f->shared->vfd_swmr) && (!f->shared->vfd_swmr_writer)) - HDfprintf(stdout, - "The maximum jump in ticks is %" PRIu64 - "; The maximum expected lag configured is %" PRIu32 "\n", - f->shared->max_jump_ticks, f->shared->vfd_swmr_config.max_lag); - /* Shutdown the page buffer cache */ if (H5PB_dest(f->shared) < 0) /* Push error, but keep going*/ @@ -1932,9 +1926,8 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) /* Avoid reusing a virtual file opened exclusively by a second virtual * file, or opening the same file twice with different parameters. */ - if ((lf = H5FD_deduplicate(lf, fapl_id)) == NULL) { - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "an already-open file conflicts with '%s'", name); - } + if ((lf = H5FD_deduplicate(lf, fapl_id)) == NULL) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "an already-open file conflicts with '%s'", name) /* Is the file already open? */ if ((shared = H5F__sfile_search(lf)) != NULL) { diff --git a/test/h5test.c b/test/h5test.c index 9ec29ed..755ae93 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -1925,7 +1925,6 @@ static const H5FD_class_t H5FD_dummy_g = { NULL, /* lock */ NULL, /* unlock */ NULL, /* del */ - NULL, /* dedup */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; -- cgit v0.12 From 3ba79265098f6154a5ce3c0124df465be1ed69e3 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Wed, 21 Jul 2021 14:47:31 -0700 Subject: Updates user's guide (#845) --- doc/vfd-swmr-user-guide.md | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/doc/vfd-swmr-user-guide.md b/doc/vfd-swmr-user-guide.md index 6a14487..e498cf9 100644 --- a/doc/vfd-swmr-user-guide.md +++ b/doc/vfd-swmr-user-guide.md @@ -69,30 +69,30 @@ the writer makes HDF5 library API calls with sufficient regularity, and that both reader and writer avoid long running HDF5 API calls. For further details on VFD SWMR design and implementation, see -VFD_SWMR_RFC_200916.pdf or VFD_SWMR_RFC_200916.docx in the -doc directory. +`VFD_SWMR_RFC_2020-02-03.docx` in the doc directory. # Quick start Follow these instructions to download, configure, and build the -VFD SWMR project in a jiffy. Then install the HDF5 library and +VFD SWMR project, then install the HDF5 library and utilities built by the VFD SWMR project. ## Download Clone the HDF5 repository in a new directory, then switch to the -features/vfd_swmr_alpa_1 branch as follows: +`feature/vfd_swmr_beta_1` branch as follows: ``` -% git clone https://@bitbucket.hdfgroup.org/scm/hdffv/hdf5.git swmr +% git clone https://github.com/HDFGroup/hdf5 swmr % cd swmr -% git checkout feature/vfd_swmr_alpha_1 +% git checkout feature/vfd_swmr_beta_1 ``` ## Build Create a build directory, change to that directory, and run the -configure script: +configure script (The Autotools are shown here. VFD SWMR can also +be built using CMake.): ``` % mkdir -p ../build/swmr @@ -100,6 +100,10 @@ configure script: % ../../swmr/configure ``` +Note that the mirror VFD tests require some rework, so enabling that feature +will cause the build step to fail. This will be fixed in a future beta release. + + Build the project: ``` @@ -115,6 +119,9 @@ SWMR works correctly on your system. To test the library, utilities, run % make check ``` +This will take some time to run, particularly the VFD SWMR shell script tests. +Note that CMake currently does not run the shell script tests. + If the tests don't pass, please let the developers know! Note that due to reader and writer process drifting out of sync, you @@ -191,8 +198,8 @@ The reader and writer programs support several command-line options: ## The VFD SWMR demos -The VFD SWMR demos are in a [separate -repository](https://bitbucket.hdfgroup.org/scm/~dyoung/swmr-demo.git). +The VFD SWMR demos are located in the `examples` directory of this source +tree. Before you build the demos, you will need to install the HDF5 library and utilities built from the VFD SWMR branch in your home directory @@ -564,7 +571,7 @@ seconds. # Reporting bugs -VFD SWMR is still under development, so we expect that you will encounter +VFD SWMR is still under development, so it is possible that you will encounter bugs. Please report them, along with any performance or design issues you encounter. -- cgit v0.12 From dbd850ccc1a5b210fc94c35b88b81069e4239ae7 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Thu, 22 Jul 2021 10:47:44 -0700 Subject: VFD SWMR: Fixes for using base versions of versioned API calls (#850) * Fixes for using base versions of versioned API calls * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- test/vfd_swmr.c | 30 +++++++++++++++--------------- test/vfd_swmr_group_writer.c | 16 ++++++++-------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/test/vfd_swmr.c b/test/vfd_swmr.c index 09dee38..3ed73c1 100644 --- a/test/vfd_swmr.c +++ b/test/vfd_swmr.c @@ -884,7 +884,7 @@ test_writer_md(void) hid_t sid = -1; /* Dataspace ID */ hid_t did = -1; /* Dataset ID */ int * rwbuf = NULL; /* Data buffer for writing */ - H5O_info_t oinfo; /* Object metadata information */ + H5O_info2_t oinfo; /* Object metadata information */ char dname[100]; /* Name of dataset */ hsize_t dims[2] = {50, 20}; /* Dataset dimension sizes */ hsize_t max_dims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */ @@ -961,7 +961,7 @@ test_writer_md(void) FAIL_STACK_ERROR /* Get dataset object header address */ - if (H5Oget_info(did, &oinfo, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did, &oinfo, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR /* Close the dataset */ @@ -998,7 +998,7 @@ test_writer_md(void) FAIL_STACK_ERROR /* Get dataset object info */ - if (H5Oget_info(did, &oinfo, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did, &oinfo, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR /* Close the dataset */ @@ -1032,7 +1032,7 @@ test_writer_md(void) FAIL_STACK_ERROR /* Get dataset object info */ - if (H5Oget_info(did, &oinfo, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did, &oinfo, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR /* Close the dataset */ @@ -1166,16 +1166,16 @@ test_file_end_tick_concur(void) static unsigned test_reader_md_concur(void) { - unsigned i = 0; /* Local index variables */ - uint8_t * buf = NULL; /* Data page from the page buffer */ - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - int * rwbuf = NULL; /* Data buffer for writing */ - H5O_info_t oinfo; /* Object metadata information */ - char dname[100]; /* Name of dataset */ - hsize_t dims[2] = {50, 20}; /* Dataset dimension sizes */ - hsize_t max_dims[2] = /* Dataset maximum dimension sizes */ + unsigned i = 0; /* Local index variables */ + uint8_t * buf = NULL; /* Data page from the page buffer */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + int * rwbuf = NULL; /* Data buffer for writing */ + H5O_info2_t oinfo; /* Object metadata information */ + char dname[100]; /* Name of dataset */ + hsize_t dims[2] = {50, 20}; /* Dataset dimension sizes */ + hsize_t max_dims[2] = /* Dataset maximum dimension sizes */ {H5S_UNLIMITED, H5S_UNLIMITED}; hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */ unsigned num_entries = 0; /* Number of entries in the index */ @@ -1519,7 +1519,7 @@ test_reader_md_concur(void) FAIL_STACK_ERROR /* Get dataset object header address */ - if (H5Oget_info(did, &oinfo, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did, &oinfo, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR /* Close the dataset */ diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index f491353..c758781 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -3031,8 +3031,8 @@ verify_group(state_t *s, unsigned int which) esnprintf(name, sizeof(name), "/group-%u", which); - if ((g = H5Gopen(s->file, name, H5P_DEFAULT)) < 0) { - HDprintf("H5Gopen failed\n"); + if ((g = H5Gopen2(s->file, name, H5P_DEFAULT)) < 0) { + HDprintf("H5Gopen2 failed\n"); TEST_ERROR; } @@ -4078,8 +4078,8 @@ vrfy_create_group(state_t *s, unsigned int which) esnprintf(name, sizeof(name), "/group-%u", which); - if ((g = H5Gopen(s->file, name, H5P_DEFAULT)) < 0) { - HDprintf("H5Gopen failed\n"); + if ((g = H5Gopen2(s->file, name, H5P_DEFAULT)) < 0) { + HDprintf("H5Gopen2 failed\n"); TEST_ERROR; } @@ -4195,8 +4195,8 @@ vrfy_create_group_id(state_t *s, unsigned int which, bool dense_to_compact) esnprintf(name, sizeof(name), "/group-%u", which); - if ((g = H5Gopen(s->file, name, H5P_DEFAULT)) < 0) { - HDprintf("H5Gopen failed\n"); + if ((g = H5Gopen2(s->file, name, H5P_DEFAULT)) < 0) { + HDprintf("H5Gopen2 failed\n"); TEST_ERROR; } @@ -4569,8 +4569,8 @@ vrfy_move_one_group(state_t *s, hid_t obj_id, const char *name, const char *newn TEST_ERROR; } - if ((g = H5Gopen(obj_id, newname, H5P_DEFAULT)) < 0) { - HDprintf("H5Gopen failed\n"); + if ((g = H5Gopen2(obj_id, newname, H5P_DEFAULT)) < 0) { + HDprintf("H5Gopen2 failed\n"); TEST_ERROR; } -- cgit v0.12 From a93e5420fa69d745dfa056eb73020cbab0baead8 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Mon, 26 Jul 2021 13:58:17 -0700 Subject: Updated the VFD SWMR user's guide (#855) --- doc/vfd-swmr-user-guide.md | 258 +++++++++++++++------------------------------ 1 file changed, 85 insertions(+), 173 deletions(-) diff --git a/doc/vfd-swmr-user-guide.md b/doc/vfd-swmr-user-guide.md index e498cf9..ee7df64 100644 --- a/doc/vfd-swmr-user-guide.md +++ b/doc/vfd-swmr-user-guide.md @@ -35,7 +35,7 @@ with results that become visible to the VFD SWMR readers. In particular, VFD SWMR allows the writer to create and delete both groups and datasets, and to create and delete attributes on both groups and datasets while operating in VFD SWMR mode -- -which is not possible in the original SWMR. +which is not possible using the original SWMR implementation. We say that VFD SWMR is almost "full SWMR" because there are a few limitations -- most notably: @@ -69,7 +69,7 @@ the writer makes HDF5 library API calls with sufficient regularity, and that both reader and writer avoid long running HDF5 API calls. For further details on VFD SWMR design and implementation, see -`VFD_SWMR_RFC_2020-02-03.docx` in the doc directory. +`VFD_SWMR_RFC_200916.pdf` in the doc directory. # Quick start @@ -90,54 +90,16 @@ Clone the HDF5 repository in a new directory, then switch to the ## Build -Create a build directory, change to that directory, and run the -configure script (The Autotools are shown here. VFD SWMR can also -be built using CMake.): +There are no special instructions for building VFD SWMR. Simply follow +the usual build procedure for CMake or the Autotools using the guides +in the `release_docs` directory. -``` -% mkdir -p ../build/swmr -% cd ../build/swmr -% ../../swmr/configure -``` - -Note that the mirror VFD tests require some rework, so enabling that feature -will cause the build step to fail. This will be fixed in a future beta release. - - -Build the project: +Some notes: -``` -% make -``` - -## Test - -We recommend that you run the full HDF5 test suite to make sure that VFD -SWMR works correctly on your system. To test the library, utilities, run - -``` -% make check -``` - -This will take some time to run, particularly the VFD SWMR shell script tests. -Note that CMake currently does not run the shell script tests. - -If the tests don't pass, please let the developers know! - -Note that due to reader and writer process drifting out of sync, you -are likely to see several messages such as: - -``` - vfd_swmr_zoo_reader: tend_zoo: vrfy_ns_grp_c: H5Gopen2() failed -``` -or -``` - vfd_swmr_zoo_reader: tend_zoo: H5Lexists unexpectedly true. -``` - -These are expected transient failues. In addition, there will be -expected errors in the variable length data tests until we are able -to re-implement variable length data storage in HDF5. +- The mirror VFD tests require some rework, so enabling that feature will cause the build step to fail. This will be fixed in a future beta release. +- The VFD SWMR tests can take some time to run. +- The VFD SWMR acceptance tests will typically emit some output about "expected errors" that you can ignore. Real errors are clearly flagged. +- If the tests do not pass on your system, please let the developers know via the email address given at the end of this document. # Sample programs @@ -177,48 +139,51 @@ and in the other window, run the reader: % ./vfd_swmr_bigset_reader -n 50 -d 2 -W ``` -The writer will wait for a signal before it quits. You may tap -Control-C to make it quit. +The writer will wait for a signal before it quits. You can tap CTRL-C to make +it quit. The reader and writer programs support several command-line options: -* `-h`: show program usage - -* `-W`: stop the program from waiting for a signal before it quits. - -* `-q`: suppress the progress messages that the programs write to the - standard error stream. - -* `-V`: create a virtual dataset with content in three source datasets - in the same HDF5 file---only available when the writer creates a - dataset extensible in one dimension (`-d 1`) - -* `-M`: like `-V`, the writer creates the virtual dataset on three - source datasets, but each source dataset is in a different HDF5 file. +``` +usage: vfd_swmr_bigset_writer [-F] [-M] [-S] [-V] [-W] [-a steps] [-b] [-c cols] + [-d dims] + [-n iterations] [-r rows] [-s datasets] + [-u milliseconds] + +-F: fixed maximal dimension for the chunked datasets +-M: use virtual datasets and many source files +-S: do not use VFD SWMR +-V: use virtual datasets and a single source file +-W: do not wait for a signal before exiting +-a steps: `steps` between adding attributes +-b: write data in big-endian byte order +-c cols: `cols` columns per chunk +-d 1|one|2|two|both: select dataset expansion in one or + both dimensions +-n iterations: how many times to expand each dataset +-r rows: `rows` rows per chunk +-s datasets: number of datasets to create +-u ms: milliseconds interval between updates + to vfd_swmr_bigset_writer.h5 +``` ## The VFD SWMR demos The VFD SWMR demos are located in the `examples` directory of this source -tree. - -Before you build the demos, you will need to install the HDF5 library -and utilities built from the VFD SWMR branch in your home directory -somewhere. In the ./configure step, use the command-line option -`--prefix=$HOME/path/for/library` to set the directory you prefer. -In the demo Makefiles, update the `H5CC` variable with the path to -the `h5cc` installed from the VFD SWMR branch. Then you should be -able to `make` and `make clean` the demos. - -Under `gaussians/`, two programs are built, `wgaussians` and -`rgaussians`. If you start both from the same directory in different -terminals, you should see the "bouncing 2-D Gaussian distributions" -in the `rgaussians` terminal. This demo uses curses, so you may need -to install the curses developers library to build. +tree. Instructions for building the example programs are given in the README +file in that directory. These programs are NOT installed via `make install` +and have to built by hand with h5cc as described in the README. + +Two Gaussian programs are built, `wgaussians` and `rgaussians`. If you start +both from the same directory in different terminals, you should see the +"bouncing 2-D Gaussian distributions" in the `rgaussians` terminal. This demo +uses curses, so you may need to install the curses developers library to build +(and this is probably not going to be easy to build on Windows). The creation-deletion (`credel`) demo is also run in two terminals. -The two command lines are given in `credel/README.md`. You need -to use the `h5ls` installed from the VFD SWMR branch, since only -that version has the `--poll` option. +The two command lines are given in the README. You need to use the `h5ls` +installed from the VFD SWMR branch, since only that version has the `--poll` +option. Be careful to not use a non-VFD-SWMR system h5ls here. # Developer tips @@ -226,7 +191,7 @@ that version has the `--poll` option. ### File-creation properties -To use VFD SWMR, creating your HDF5 file with paged allocation strategy +To use VFD SWMR, creating your HDF5 file with a paged allocation strategy is mandatory. This call enables the paged allocation strategy: ``` @@ -240,74 +205,40 @@ allocation strategy. ### File-access properties -In this section we dissect `vfd_swmr_create_fapl()`, a helper routine in -the VFD SWMR tests, to show how to configure your application to use VFD +In this section we show how to configure your application to use VFD SWMR. -``` -hid_t -vfd_swmr_create_fapl(bool writer, bool only_meta_pages, bool use_vfd_swmr) -{ - H5F_vfd_swmr_config_t config; - hid_t fapl; - -``` - -`h5_fileaccess()` is also a helper routine for the tests. In your -program, you can replace the `h5_fileaccess()` call with a call to -`H5Pcreate(H5P_FILE_ACCESS)`. - -``` - /* Create file access property list */ - if((fapl = h5_fileaccess()) < 0) { - warnx("h5_fileaccess"); - return badhid; - } -``` - - -VFD SWMR has only been tested with the latest file format. It may -malfunction with older formats, we just don't know. We force the -latest version here. - -``` - /* FOR NOW: set to use latest format, the "old" parameter is not used */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { - warnx("H5Pset_libver_bounds"); - return badhid; - } - - /* - * Set up to open the file with VFD SWMR configured. - */ -``` +1. Create a file access property list using `H5Pcreate(H5P_FILE_ACCESS)`. +2. Set the latest file format using `H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)`. +3. Enable page buffering using `H5Pset_page_buffer_size()`. +4. Set any VFD SWMR configuration properties using `H5Pset_vfd_swmr_config()`. The struct is documented in H5Fpublic.h, with some additional documentation below. (In the near future, this struct will be documented in the library's Doxygen documentation.) VFD SWMR relies on metadata reads and writes to go through the -page buffer. Note that the default page size is 4096 bytes. This -call sets the total page buffer size to 4096 bytes. So we have -effectively created a one-page page buffer! That is adequate for -testing, but it may not be best for your application. - -If `only_meta_pages` is true, then the entire page buffer is -dedicated to metadata. That's fine for VFD SWMR. +page buffer. Note that the default page size is 4096 bytes. Finding good +values for `buf_size` may take some experimentation. We use 4096 (giving a +single page buffer) for `buf_size` in our test code. *Note well*: when VFD SWMR is enabled, the meta-/raw-data pages proportion set by `H5Pset_page_buffer_size()` does not actually control the pages reserved for raw data. *All* pages are dedicated to buffering metadata. +### `H5F_vfd_swmr_config_t` fields discussion + +Example code: ``` - /* Enable page buffering */ - if(H5Pset_page_buffer_size(fapl, 4096, only_meta_pages ? 100 : 0, 0) < 0) { - warnx("H5Pset_page_buffer_size"); - return badhid; - } -``` + memset(&config, 0, sizeof(config)); + config.version = H5F__CURR_VFD_SWMR_CONFIG_VERSION; + config.tick_len = 4; + config.max_lag = 7; + config.writer = true; + config.md_pages_reserved = 128; + strcpy(config.md_file_path, "./my_md_file"); -Add VFD SWMR-specific configuration to the file-access property list -(`fapl`) using an `H5Pset_vfd_swmr_config()` call. + H5Pset_vfd_swmr_config(fapl, &config); +``` When VFD SWMR is enabled, changes to the HDF5 metadata accumulate in RAM until a configurable unit of time known as a *tick* has passed. @@ -315,11 +246,11 @@ At the end of each tick, a snapshot of the metadata at the end of the tick is "published"---that is, made visible to the readers. The length of a *tick* is configurable in units of 100 milliseconds -using the `tick_len` parameter. Below, `tick_len` is set to `4` to +using the `tick_len` parameter. Here, `tick_len` is set to `4` to select a tick length of 400ms. A snapshot does not persist forever, but it expires after a number -of ticks, given by the *maximum lag*, has passed. Below, `max_lag` +of ticks, given by the *maximum lag*, has passed. Here, `max_lag` is set to `7` to select a maximum lag of 7 ticks. After a snapshot has expired, the writer may overwrite it. @@ -359,25 +290,6 @@ The `version` parameter tells what version of VFD SWMR configuration the parameter struct `config` contains. For now, it should be initialized to `H5F__CURR_VFD_SWMR_CONFIG_VERSION`. -``` - memset(&config, 0, sizeof(config)); - - config.version = H5F__CURR_VFD_SWMR_CONFIG_VERSION; - config.tick_len = 4; - config.max_lag = 7; - config.writer = writer; - config.md_pages_reserved = 128; - HDstrcpy(config.md_file_path, "./my_md_file"); - - /* Enable VFD SWMR configuration */ - if(use_vfd_swmr && H5Pset_vfd_swmr_config(fapl, &config) < 0) { - warnx("H5Pset_vfd_swmr_config"); - return badhid; - } - return fapl; -} -``` - ## Using virtual datasets (VDS) An application may want to use VFD SWMR to create, read, or write @@ -419,14 +331,14 @@ user configurable in the first production release. With the currently hard coded flush of raw data at the end of each tick, it should not be necessary to call H5Fflush(). In fact, when VFD SWMR is -active, H5Fflush() may require up to 'max_lag' ticks to complete due to +active, H5Fflush() may require up to `max_lag` ticks to complete due to metadata consistency issues. Instead, a writer can make its last changes to HDF5 file visible to all readers immediately using the new call, `H5Fvfd_swmr_end_tick()`. Note that this call should be used sparingly, as it terminates the current -tick early, thus effectively reducing 'max_lag'. Repeated calls in -quick succession can force a reader to overrun 'max_lag', and +tick early, thus effectively reducing `max_lag`. Repeated calls in +quick succession can force a reader to overrun `max_lag`, and read stale metadata. When the flush of raw data at end of tick is disabled (not possible at present), @@ -534,14 +446,6 @@ object---while the writer deletes it, then reading content through the handle may yield corrupted data or the data from some other object, or the library may crash. -## Microsoft Windows - -VFD SWMR is not officially supported on Microsoft Windows at this time. The -feature should in theory work on Windows and NTFS, however it has not been -tested as the existing VFD SWMR tests rely on shell scripts. Note that Windows -file shares are not supported as there is no write ordering guarantee (as with -NFS, et al.). - ## Supported filesystems A VFD SWMR writer and readers share a couple of files, the HDF5 (`.h5`) @@ -554,12 +458,20 @@ ordering should take effect, regardless of the underlying filesystem. If the VFD SWMR reader and the writer run on *different* hosts, then the write-ordering rules depend on the shared filesystem. VFD SWMR is -not generally expected to work with NFS at this time. GPFS is reputed -to order writes according to POSIX convention, so we expect VFD SWMR -to work with GPFS. (Caveat: we are still looking for an authoritative -description of GPFS I/O semantics.) +not generally expected to work with NFS at this time. Parallel file systems +like GPFS and Lustre should order writes according to POSIX convention, so we +expect VFD SWMR to work on those file systems but we have not tested this. + +The HDF Group plans to add support for networked file systems like NFS and +Windows SMB to VFD SWMR in the future. -The HDF Group plans to add support for NFS to VFD SWMR in the future. +## Microsoft Windows + +VFD SWMR is not officially supported on Microsoft Windows at this time. The +feature should in theory work on Windows and NTFS, however it has not been +tested as the existing VFD SWMR tests rely on shell scripts. Note that Windows +file shares are not supported as there is no write ordering guarantee (as with +NFS, et al.). ## File-opening order -- cgit v0.12 From da7fec09b999949a0272e28c17ccc9eb01b025d0 Mon Sep 17 00:00:00 2001 From: Muqun Yang Date: Tue, 3 Aug 2021 15:20:37 -0500 Subject: 1)remove named pipe from the program. 2) make the number of attributes for each group configuratable. The attribute datatype is 32-bit integer. --- test/vfd_swmr_gperf_writer.c | 919 +++---------------------------------------- 1 file changed, 60 insertions(+), 859 deletions(-) diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index a3b5455..e0f0bdb 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -10,6 +10,17 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* Description of this program: + * This program checks the performance of group creations for VFD SWMR. + * Currently the group creation time, H5Fopen and H5Fclose time are measured. + * After compiling the program, + * ./vfd_swmr_gperf_writer -n 1000 -P -N 5 -a 1 -q + * will generate 1000 groups, each group has 5 attributes. + * ./vfd_swmr_gperf_writer -n 1000 -P -N 0 -q + * will generate 1000 empty groups. + * ./vfd_swmr_gperf_writer -n 1000 -P -q + * will generate 1000 groups,for every ten groups, an attribute is generated. +*/ #define H5F_FRIEND /*suppress error about including H5Fpkg */ #include "hdf5.h" @@ -23,7 +34,6 @@ #ifndef H5_HAVE_WIN32_API -#define READER_WAIT_TICKS 3 #define VS_ATTR_NAME_LEN 21 #define TIME_PASSED(X, Y) \ @@ -34,22 +44,15 @@ typedef struct { char filename[PATH_MAX]; char progname[PATH_MAX]; unsigned int asteps; - unsigned int csteps; unsigned int nsteps; - unsigned int update_interval; bool use_vfd_swmr; bool old_style_grp; - bool use_named_pipes; char grp_op_pattern; bool grp_op_test; char at_pattern; bool attr_test; uint32_t max_lag; uint32_t tick_len; - int np_fd_w_to_r; - int np_fd_r_to_w; - int np_notify; - int np_verify; bool gperf; double min_time; double max_time; @@ -64,11 +67,11 @@ typedef struct { (state_t) \ { \ .file = H5I_INVALID_HID, .one_by_one_sid = H5I_INVALID_HID, .filename = "", \ - .filetype = H5T_NATIVE_UINT32, .asteps = 10, .csteps = 10, .nsteps = 100, \ - .update_interval = READER_WAIT_TICKS, .use_vfd_swmr = true, .old_style_grp = false, \ - .use_named_pipes = true, .grp_op_pattern = ' ', .grp_op_test = false, .at_pattern = ' ', \ - .attr_test = false, .tick_len = 4, .max_lag = 7, .np_fd_w_to_r = -1, .np_fd_r_to_w = -1, \ - .np_notify = 0, .np_verify = 0, .gperf = false, .min_time = 100., .max_time = 0.,.mean_time = 0., \ + .filetype = H5T_NATIVE_UINT32, .asteps = 10, .nsteps = 100, \ + .use_vfd_swmr = true, .old_style_grp = false, \ + .grp_op_pattern = ' ', .grp_op_test = false, .at_pattern = ' ', \ + .attr_test = false, .tick_len = 4, .max_lag = 7, \ + .gperf = false, .min_time = 100., .max_time = 0.,.mean_time = 0., \ .total_time = 0., .fo_total_time = 0., \ .fc_total_time = 0., .num_attrs = 1 \ } @@ -77,18 +80,15 @@ static void usage(const char *progname) { fprintf(stderr, - "usage: %s [-S] [-G] [-a steps] [-b] [-c] [-n iterations]\n" - " [-N] [-q] [-u numb_ticks] [-A at_pattern] [-O grp_op_pattern]\n" + "usage: %s [-S] [-G] [-a steps] [-b] [-n iterations]\n" + " [-N num_attrs] [-q] [-A at_pattern] [-O grp_op_pattern]\n" "\n" "-S: do not use VFD SWMR\n" "-G: old-style type of group\n" "-a steps: `steps` between adding attributes\n" "-b: write data in big-endian byte order\n" - "-c steps: `steps` between communication between the writer and reader\n" "-n ngroups: the number of groups\n" - "-N: do not use named pipes, \n" - " mainly for running the writer and reader seperately\n" - "-u numb_ticks: `numb_ticks` for the reader to wait before verification\n" + "-N: the number of attributes \n" "-A at_pattern: `at_pattern' for different attribute tests\n" " The value of `at_pattern` is one of the following:\n" " `compact` - Attributes added in compact storage\n" @@ -169,7 +169,7 @@ state_init(state_t *s, int argc, char **argv) if (tfile) HDfree(tfile); - while ((ch = getopt(argc, argv, "PSGa:bc:n:Nqu:A:O:")) != -1) { + while ((ch = getopt(argc, argv, "PSGa:bn:qA:N:O:")) != -1) { switch (ch) { case 'P': s->gperf = true; @@ -181,9 +181,8 @@ state_init(state_t *s, int argc, char **argv) s->old_style_grp = true; break; case 'a': - case 'c': case 'n': - case 'u': + case 'N': errno = 0; tmp = HDstrtoul(optarg, &end, 0); if (end == optarg || *end != '\0') { @@ -201,19 +200,14 @@ state_init(state_t *s, int argc, char **argv) if (ch == 'a') s->asteps = (unsigned)tmp; - else if (ch == 'c') - s->csteps = (unsigned)tmp; else if (ch == 'n') s->nsteps = (unsigned)tmp; - else if (ch == 'u') - s->update_interval = (unsigned)tmp; + else if (ch == 'N') + s->num_attrs = (unsigned)tmp; break; case 'b': s->filetype = H5T_STD_U32BE; break; - case 'N': - s->use_named_pipes = false; - break; case 'O': if (HDstrcmp(optarg, "grp-creation") == 0) s->grp_op_pattern = 'c'; @@ -293,11 +287,6 @@ state_init(state_t *s, int argc, char **argv) printf("Attribute tests are ignored.\n"); } - if (s->csteps < 1 || s->csteps > s->nsteps) { - printf("communication interval is out of bounds\n"); - TEST_ERROR; - } - if (argc > 0) { printf("unexpected command-line arguments\n"); TEST_ERROR; @@ -319,147 +308,6 @@ error: return false; } -/* Named Pipe Subroutine: np_wr_send_receive - * Description: - * The writer sends a message to the reader, - * then waits for max_lag ticks, - * then checks the returned message from the reader. - * Return: - * True if succeed - * False if an error occurs in any step above. - * An error is mostly caused by an unexpected - * notification number from the message sent - * by the reader. - */ -static bool -np_wr_send_receive(state_t *s) -{ - - unsigned int i; - /* Bump up the value of notify to notice the reader to start to read */ - s->np_notify++; - if (HDwrite(s->np_fd_w_to_r, &(s->np_notify), sizeof(int)) < 0) { - printf("HDwrite failed\n"); - TEST_ERROR; - } - - /* During the wait, writer makes repeated HDF5 API calls - * to trigger EOT at approximately the correct time */ - for (i = 0; i < s->max_lag + 1; i++) { - decisleep(s->tick_len); - H5E_BEGIN_TRY - { - H5Aexists(s->file, "nonexistent"); - } - H5E_END_TRY; - } - - /* Receive the same value from the reader and verify it before - * going to the next step */ - (s->np_verify)++; - if (HDread(s->np_fd_r_to_w, &(s->np_notify), sizeof(int)) < 0) { - printf("HDread failed\n"); - TEST_ERROR; - } - - if (s->np_notify == -1) { - printf("reader failed to verify group or attribute operation.\n"); - TEST_ERROR; - } - - if (s->np_notify != s->np_verify) { - printf("received message %d, expecting %d\n", s->np_notify, s->np_verify); - TEST_ERROR; - } - - return true; - -error: - return false; -} - -/* Named Pipe Subroutine: np_rd_receive - * Description: - * The reader receives a message from the writer, - * then checks if the notification number from - * the writer is expected. - * Return: - * True if succeed - * False if an error occurs in any step above. - * An error is mostly caused by an unexpected - * notification number from the message sent - * by the writer. - */ -static bool -np_rd_receive(state_t *s) -{ - - /* The writer should have bumped up the value of notify. - * Do the same with verify and confirm it */ - s->np_verify++; - - /* Receive the notify that the writer bumped up the value */ - if (HDread(s->np_fd_w_to_r, &(s->np_notify), sizeof(int)) < 0) { - printf("HDread failed\n"); - TEST_ERROR; - } - - if (s->np_notify == -1) { - printf("writer failed to create group or carry out an attribute operation.\n"); - TEST_ERROR; - } - - if (s->np_notify != s->np_verify) { - printf("received message %d, expecting %d\n", s->np_notify, s->np_verify); - TEST_ERROR; - } - - return true; - -error: - return false; -} - -/* Named Pipe Subroutine: np_rd_send - * Description: - * The reader sends an acknowledgement to the writer - * Return: - * True if succeed - * False if an error occurs in sending the message. - */ -static bool -np_rd_send(state_t *s) -{ - - if (HDwrite(s->np_fd_r_to_w, &(s->np_notify), sizeof(int)) < 0) { - H5_FAILED(); - AT(); - printf("HDwrite failed\n"); - return false; - } - else - return true; -} - -/* Named Pipe Subroutine: np_send_error - * Description: - * An error (notification number is 1) message is sent - * either from the reader or the writer. - * A boolean input parameter is used to choose - * either reader or writer. - * Return: - * None - */ -static void -np_send_error(state_t *s, bool writer) -{ - s->np_notify = -1; - if (writer) - HDwrite(s->np_fd_w_to_r, &(s->np_notify), sizeof(int)); - else - HDwrite(s->np_fd_r_to_w, &(s->np_notify), sizeof(int)); -} - /*------------------------------------------------------------------------- * Function: check_ohr_num_chunk * @@ -597,20 +445,6 @@ add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const ch } } - /* Writer sends a message to reader: an attribute is successfully generated. - then wait for the reader to verify and send an acknowledgement message back.*/ - if (s->use_named_pipes && s->attr_test == true) { - dbgf(2, "writer: write attr - ready to send/receive message: %d\n", s->np_notify + 1); - if (np_wr_send_receive(s) == false) { - H5_FAILED(); - AT(); - dbgf(2, "writer: write attr - verification failed.\n"); - /* Note: This is (mostly) because the verification failure message - * from the reader. So don't send the error message back to - * the reader. Just stop the test. */ - goto error2; - } - } } /* end for */ @@ -621,11 +455,6 @@ add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const ch return true; error: - /* Writer needs to send an error message to the reader to stop the test*/ - if (s->use_named_pipes && s->attr_test == true) - np_send_error(s, true); - -error2: H5E_BEGIN_TRY { H5Aclose(aid); @@ -668,11 +497,12 @@ static bool add_default_group_attr(state_t *s, hid_t g, unsigned int which) { - const char *aname_format = "attr-%u"; + const char *aname_format = "attr-%u-%u"; - /* Note: Since we only add one attribute, the parameter for - * the number of attributes is 1. */ - return add_attr(s, g, which, 1, aname_format, which); + /* Note: the number of attributes can be configurable, + * the default number of attribute is 1. + */ + return add_attr(s, g, which, s->num_attrs, aname_format, which); } /*------------------------------------------------------------------------- @@ -757,24 +587,9 @@ add_vlstr_attr(state_t *s, hid_t g, unsigned int which) HDfree(astr_val); - /* Writer sends a message to reader: a VL string attribute is successfully generated. - then wait for the reader to verify and send an acknowledgement message back. */ - if (s->use_named_pipes && s->attr_test == true) { - dbgf(2, "writer: write attr - ready to send the message: %d\n", s->np_notify + 1); - if (np_wr_send_receive(s) == false) { - H5_FAILED(); - AT(); - dbgf(2, "writer: write attr - verification failed.\n"); - goto error2; - } - } - return true; error: - /* Writer needs to send an error message to the reader to stop the test*/ - if (s->use_named_pipes && s->attr_test == true) - np_send_error(s, true); H5E_BEGIN_TRY { H5Aclose(aid); @@ -785,7 +600,6 @@ error: if (astr_val) HDfree(astr_val); -error2: return false; } @@ -863,25 +677,9 @@ del_one_attr(state_t *s, hid_t obj_id, bool is_dense, bool is_vl_or_ohrc, unsign TEST_ERROR; } } - /* Writer sends a message to reader: an attribute is successfully generated. - then wait for the reader to verify and send an acknowledgement message back. */ - if (s->use_named_pipes && s->attr_test == true) { - dbgf(2, "writer: delete attr - ready to send the message: %d\n", s->np_notify + 1); - if (np_wr_send_receive(s) == false) { - H5_FAILED(); - AT(); - dbgf(2, "writer: delete attr - verification failed.\n"); - goto error2; - } - } - return true; error: - if (s->use_named_pipes && s->attr_test == true) - np_send_error(s, true); - -error2: return false; } @@ -988,26 +786,8 @@ modify_attr(state_t *s, hid_t g, const char *aname_fmt, unsigned int which) TEST_ERROR; } - /* Writer sends a message to reader: an attribute is successfully modified. - then wait for the reader to verify and send an acknowledgement message back.*/ - if (s->use_named_pipes && s->attr_test == true) { - dbgf(2, "writer: modify attr - ready to send the message: %d\n", s->np_notify + 1); - if (np_wr_send_receive(s) == false) { - H5_FAILED(); - AT(); - dbgf(2, "writer: write attr - verification failed.\n"); - /* Note: This is (mostly) because the verification failure message - * from the reader. So don't send the error message back to - * the reader. Just stop the test. */ - goto error2; - } - } - return true; error: - /* Writer needs to send an error message to the reader to stop the test*/ - if (s->use_named_pipes && s->attr_test == true) - np_send_error(s, true); H5E_BEGIN_TRY { H5Aclose(aid); @@ -1015,7 +795,6 @@ error: } H5E_END_TRY; -error2: return false; } @@ -1099,18 +878,6 @@ modify_vlstr_attr(state_t *s, hid_t g, unsigned int which) HDfree(astr_val); - /* Writer sends a message to reader: a VL string attribute is successfully generated. - then wait for the reader to verify and send an acknowledgement message back. */ - if (s->use_named_pipes && s->attr_test == true) { - dbgf(2, "writer: modify vl attr - ready to send the message: %d\n", s->np_notify + 1); - if (np_wr_send_receive(s) == false) { - H5_FAILED(); - AT(); - dbgf(2, "writer: write attr - verification failed.\n"); - goto error2; - } - } - return true; error: @@ -1124,10 +891,6 @@ error: if (astr_val) HDfree(astr_val); - if (s->use_named_pipes && s->attr_test == true) - np_send_error(s, true); - -error2: return false; } @@ -1228,8 +991,6 @@ add_attrs_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which) return add_attr(s, g, which, max_compact, aname_format, which); error: - if (s->use_named_pipes && s->attr_test == true) - np_send_error(s, true); return false; } @@ -1288,8 +1049,6 @@ add_attrs_compact_dense(state_t *s, hid_t g, hid_t gcpl, unsigned int which) return ret_value; error: - if (s->use_named_pipes && s->attr_test == true) - np_send_error(s, true); return false; } @@ -1353,20 +1112,6 @@ del_attrs_compact_dense_compact(state_t *s, hid_t obj_id, hid_t gcpl, unsigned i printf("H5Adelete failed\n"); TEST_ERROR; } - - /* For each attribute deletion, we want to ensure the verification - * from the reader. - * So writer sends a message to reader: an attribute is successfully deleted. - then wait for reader to verify and send an acknowledgement message back. */ - if (s->use_named_pipes && s->attr_test == true) { - dbgf(2, "writer: delete attr - ready to send the message: %d\n", s->np_notify + 1); - if (np_wr_send_receive(s) == false) { - H5_FAILED(); - AT(); - dbgf(2, "writer: delete attr - verification failed.\n"); - goto error2; - } - } } /* The writer deletes another attribute, the storage is @@ -1382,34 +1127,10 @@ del_attrs_compact_dense_compact(state_t *s, hid_t obj_id, hid_t gcpl, unsigned i printf("H5Adelete failed\n"); TEST_ERROR; } - /* Again we need to notify the reader via Named pipe. */ - if (s->use_named_pipes && s->attr_test == true) { - dbgf(2, "writer: delete attr - ready to send the message: %d\n", s->np_notify + 1); - if (np_wr_send_receive(s) == false) { - H5_FAILED(); - AT(); - dbgf(2, "writer: delete attr - verification failed.\n"); - goto error2; - } - } - - /* The following comments are left here in case in the future we want to - * use HDF5 function to verify the attribute storage */ -#if 0 - // May H5Oget_info3 -- obtain the number of attributes. - //Check the number of attributes >=min_dense. - //We may use the internal function - //is_dense = H5O__is_attr_dense_test(dataset) to check if it is dense in the future. - // -#endif return true; error: - if (s->use_named_pipes && s->attr_test == true) - np_send_error(s, true); - -error2: return false; } @@ -1510,8 +1231,6 @@ add_del_attrs_compact_dense(state_t *s, hid_t g, hid_t gcpl, unsigned int which) return ret_value; error: - if (s->use_named_pipes && s->attr_test == true) - np_send_error(s, true); return false; } @@ -1753,7 +1472,6 @@ write_group(state_t *s, unsigned int which) esnprintf(name, sizeof(name), "/group-%u", which); -#if 0 if (s->old_style_grp) gcpl = H5P_DEFAULT; else { @@ -1771,7 +1489,6 @@ write_group(state_t *s, unsigned int which) } } } -#endif if (s->gperf) { @@ -1782,7 +1499,8 @@ write_group(state_t *s, unsigned int which) TEST_ERROR; } } - if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + + if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) { printf("H5Gcreate2 failed\n"); TEST_ERROR; } @@ -1804,7 +1522,6 @@ write_group(state_t *s, unsigned int which) s->total_time += temp_time; } -#if 0 /* We need to create a dummy dataset for the object header continuation block test. */ if (s->at_pattern == 'a' || s->at_pattern == 'R') { if ((dummy_d = H5Dcreate2(g, "Dataset", H5T_NATIVE_INT, s->one_by_one_sid, H5P_DEFAULT, H5P_DEFAULT, @@ -1843,23 +1560,6 @@ write_group(state_t *s, unsigned int which) } } - /* If an attribute test is turned on and named pipes are used, - * the writer should send and receive messages after the group creation. - * This will distinguish an attribute operation error from an - * group creation error. - * Writer sends a message to reader: an attribute is successfully generated. - * then wait for the reader to verify and send an acknowledgement message back.*/ - if (s->use_named_pipes && s->attr_test == true) { - dbgf(2, "writer: ready to send the message: %d\n", s->np_notify + 1); - if (np_wr_send_receive(s) == false) { - H5_FAILED(); - AT(); - /* Note: This is (mostly) because the verification failure message - * from the reader. So don't send the error message back to - * the reader. Just stop the test. */ - goto error2; - } - } /* Then carry out the attribute operation. */ if (s->asteps != 0 && which % s->asteps == 0) @@ -1871,12 +1571,17 @@ write_group(state_t *s, unsigned int which) TEST_ERROR; } } -#endif + if (H5Gclose(g) < 0) { printf("H5Gclose failed\n"); TEST_ERROR; } + if (!s->old_style_grp && H5Pclose(gcpl) < 0) { + printf("H5Pclose failed\n"); + TEST_ERROR; + } + return result; error: @@ -1884,11 +1589,16 @@ error: H5E_BEGIN_TRY { H5Gclose(g); + if (s->at_pattern == 'a' || s->at_pattern == 'R') + H5Dclose(dummy_d); + if (!s->old_style_grp) + H5Pclose(gcpl); } H5E_END_TRY; return false; } + /*------------------------------------------------------------------------- * Function: check_attr_storage_type * @@ -1987,22 +1697,6 @@ vrfy_attr(state_t *s, hid_t g, unsigned int which, const char *aname, unsigned i hid_t aid = H5I_INVALID_HID; hid_t amtype = H5I_INVALID_HID; - /* The reader receives a message from the writer.Then sleep - * for a few ticks or stop the test if receiving an error - * message. - */ - if (s->use_named_pipes && true == s->attr_test) { - if (false == np_rd_receive(s)) { - H5_FAILED(); - AT(); - /* Since receiving the error message from the writer, - * just stop the test. */ - goto error2; - } - decisleep(s->tick_len * s->update_interval); - dbgf(1, "Reader: finish reading the message: %d\n", s->np_notify); - } - /* Go ahead to read the attribute. */ dbgf(1, "verifying attribute %s on group %u equals %u\n", aname, g_which, which); @@ -2038,7 +1732,6 @@ vrfy_attr(state_t *s, hid_t g, unsigned int which, const char *aname, unsigned i printf("The attribute storage type is wrong. \n"); TEST_ERROR; } - dbgf(2, "reader: finish checking the storage type: %d\n", s->np_notify); } /* If coming to an "object header continuation block" test, @@ -2052,14 +1745,6 @@ vrfy_attr(state_t *s, hid_t g, unsigned int which, const char *aname, unsigned i } } - /* If the read value is expected, send back an OK message to the writer. */ - if (s->use_named_pipes && s->attr_test == true) { - if (np_rd_send(s) == false) { - printf("named pipe reader send message error\n"); - TEST_ERROR; - } - dbgf(2, "reader: finish sending back the message: %d\n", s->np_notify); - } return true; error: @@ -2069,11 +1754,6 @@ error: H5Aclose(aid); } H5E_END_TRY; - - /* Send back an error message to the writer so that the writer can stop. */ - if (s->use_named_pipes && s->attr_test == true) - np_send_error(s, false); -error2: return false; } @@ -2155,20 +1835,6 @@ verify_modify_attr(state_t *s, hid_t g, unsigned int which) /* Then the modified value */ if (ret == true) { - /* The reader receives a message from the writer.Then sleep - * for a few ticks or stop the test if receiving an error - * message. - */ - if (s->use_named_pipes && true == s->attr_test) { - if (false == np_rd_receive(s)) { - H5_FAILED(); - AT(); - goto error2; - } - decisleep(s->tick_len * s->update_interval); - dbgf(1, "Reader: finish reading the message: %d\n", s->np_notify); - } - /* Go ahead to read the attribute. */ esnprintf(attrname, sizeof(attrname), aname_fmt, which); if ((amtype = H5Tget_native_type(s->filetype, H5T_DIR_ASCEND)) < 0) { @@ -2204,12 +1870,6 @@ verify_modify_attr(state_t *s, hid_t g, unsigned int which) TEST_ERROR; } - /* The reader sends an OK message back to the writer. */ - if (s->use_named_pipes && s->attr_test == true) { - if (np_rd_send(s) == false) - goto error2; - dbgf(2, "reader: modify_attr finish sending back the message: %d\n", s->np_notify); - } return true; } return false; @@ -2222,12 +1882,6 @@ error: } H5E_END_TRY; - /* The reader needs to send an error message back to the writer to stop the test.*/ - if (s->use_named_pipes && s->attr_test == true) - np_send_error(s, false); - -error2: - return false; } @@ -2270,20 +1924,6 @@ verify_group_vlstr_attr(state_t *s, hid_t g, unsigned int which, bool vrfy_mod) char *astr_val_exp; char *astr_val; - /* The reader receives a message from the writer.Then sleep - * for a few ticks or stop the test if the received message - * is an error message. - */ - if (s->use_named_pipes && true == s->attr_test) { - if (false == np_rd_receive(s)) { - H5_FAILED(); - AT(); - goto error2; - } - decisleep(s->tick_len * s->update_interval); - dbgf(1, "Reader: finish reading the message: %d\n", s->np_notify); - } - /* Go ahead to read the VL string attribute. */ astr_val_exp = HDmalloc(VS_ATTR_NAME_LEN); if (astr_val_exp == NULL) { @@ -2346,13 +1986,6 @@ verify_group_vlstr_attr(state_t *s, hid_t g, unsigned int which, bool vrfy_mod) H5free_memory(astr_val); HDfree(astr_val_exp); - /* Reader sends an OK message back to the reader */ - if (s->use_named_pipes && s->attr_test == true) { - if (np_rd_send(s) == false) - goto error2; - dbgf(2, "reader: finish sending back the message: %d\n", s->np_notify); - } - return true; error: @@ -2367,12 +2000,6 @@ error: if (astr_val_exp) HDfree(astr_val_exp); - /* The reader sends an error message to the writer to stop the test.*/ - if (s->use_named_pipes && s->attr_test == true) - np_send_error(s, false); - -error2: - return false; } @@ -2415,20 +2042,6 @@ verify_del_one_attr(state_t *s, hid_t g, const char *aname, bool check_storage, htri_t attr_exists = FALSE; - /* The reader receives a message from the writer.Then sleep - * for a few ticks or stop the test if the received message - * is an error message. - */ - if (s->use_named_pipes && true == s->attr_test) { - if (false == np_rd_receive(s)) { - H5_FAILED(); - AT(); - goto error2; - } - decisleep(s->tick_len * s->update_interval); - dbgf(1, "Reader: finish reading the message: %d\n", s->np_notify); - } - /* Check if the deleted attribute still exists. */ attr_exists = H5Aexists_by_name(g, ".", aname, H5P_DEFAULT); if (attr_exists == FALSE) { @@ -2450,7 +2063,6 @@ verify_del_one_attr(state_t *s, hid_t g, const char *aname, bool check_storage, printf("The attribute storage type is wrong. \n"); TEST_ERROR; } - dbgf(2, "reader: finish checking the storage type: %d\n", s->np_notify); } /* If coming to an "object header continuation block" test, @@ -2464,20 +2076,8 @@ verify_del_one_attr(state_t *s, hid_t g, const char *aname, bool check_storage, } } - /* Reader sends an OK message back to the reader */ - if (s->use_named_pipes && s->attr_test == true) { - if (np_rd_send(s) == false) - TEST_ERROR; - dbgf(2, "reader: finish sending back the message: %d\n", s->np_notify); - } - return true; error: - /* The reader sends an error message to the writer to stop the test.*/ - if (s->use_named_pipes && s->attr_test == true) - np_send_error(s, false); - -error2: return false; } @@ -3005,11 +2605,6 @@ verify_group_attribute(state_t *s, hid_t g, unsigned int which) return ret; error: - /* Still to finish the handshaking */ - if (s->use_named_pipes && s->attr_test == true) { - np_rd_receive(s); - np_send_error(s, false); - } return false; } @@ -3043,21 +2638,6 @@ verify_group(state_t *s, unsigned int which) bool result = true; H5G_info_t group_info; - /* The reader receives a message from the writer.Then sleep - * for a few ticks or stop the test if the received message - * is an error message. - */ - if (s->use_named_pipes && true == s->attr_test) { - - if (false == np_rd_receive(s)) { - H5_FAILED(); - AT(); - goto error2; - } - decisleep(s->tick_len * s->update_interval); - dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); - } - if (which >= s->nsteps) { printf("Number of created groups is out of bounds\n"); TEST_ERROR; @@ -3102,14 +2682,6 @@ verify_group(state_t *s, unsigned int which) } } - /* Reader sends an OK message back to the writer */ - if (s->use_named_pipes && s->attr_test == true) { - - if (np_rd_send(s) == false) - TEST_ERROR; - dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); - } - /* Check if we need to skip the attribute test for this group. */ if (s->asteps != 0 && which % s->asteps == 0) result = verify_group_attribute(s, g, which); @@ -3131,12 +2703,6 @@ error: } H5E_END_TRY; - /* The reader sends an error message to the writer to stop the test.*/ - if (s->use_named_pipes && s->attr_test == true) - np_send_error(s, false); - -error2: - return false; } @@ -3220,30 +2786,9 @@ create_group_id(state_t *s, unsigned int which, bool dense_to_compact) TEST_ERROR; } - /* If a grp_op_test is turned on and named pipes are used, - * the writer should send and receive messages after the group creation. - * Writer sends a message to reader: a group is successfully created. - * then wait for the reader to verify and send an acknowledgement message back.*/ - if (s->use_named_pipes && s->grp_op_test == true) { - dbgf(2, "Writer: ready to send the message: %d\n", s->np_notify + 1); - if (np_wr_send_receive(s) == false) { - H5_FAILED(); - AT(); - /* Note: This is (mostly) because the verification failure message - * from the reader. So don't send the error message back to - * the reader. Just stop the test. */ - goto error2; - } - } - return g; error: - /* Writer needs to send an error message to the reader to stop the test*/ - if (s->use_named_pipes && s->grp_op_test == true) - np_send_error(s, true); - -error2: H5E_BEGIN_TRY { @@ -3282,28 +2827,9 @@ close_group_id(state_t *s, hid_t g) TEST_ERROR; } - /* If a grp_op_test is turned on and named pipes are used, for - * link storage test, - * Writer sends a message to reader: the group is successfully closed. - * then wait for the reader to verify and send an acknowledgement message back.*/ - if (s->use_named_pipes && s->grp_op_test == true) { - dbgf(2, "Writer: ready to send the message: %d\n", s->np_notify + 1); - if (np_wr_send_receive(s) == false) { - H5_FAILED(); - AT(); - goto error2; - } - } - return true; error: - /* Writer needs to send an error message to the reader to stop the test*/ - if (s->use_named_pipes && s->grp_op_test == true) - np_send_error(s, true); - -error2: - return false; } @@ -3371,25 +2897,9 @@ create_group(state_t *s, unsigned int which) TEST_ERROR; } - /* Writer sends a message to reader, - * then wait for the reader to verify and send an acknowledgement message back.*/ - if (s->use_named_pipes && s->grp_op_test == true) { - dbgf(2, "Writer: ready to send the message: %d\n", s->np_notify + 1); - if (np_wr_send_receive(s) == false) { - H5_FAILED(); - AT(); - goto error2; - } - } - return true; error: - /* Writer needs to send an error message to the reader to stop the test*/ - if (s->use_named_pipes && s->grp_op_test == true) - np_send_error(s, true); - -error2: H5E_BEGIN_TRY { @@ -3476,26 +2986,9 @@ delete_one_link(state_t *s, hid_t obj_id, const char *name, short link_storage, } } - /* Writer sends a message to reader: - * then wait for the reader to verify and send an acknowledgement message back.*/ - if (s->use_named_pipes && s->grp_op_test == true) { - dbgf(2, "writer: ready to send the message: %d\n", s->np_notify + 1); - if (np_wr_send_receive(s) == false) { - H5_FAILED(); - AT(); - goto error2; - } - } - return true; error: - /* Writer needs to send an error message to the reader to stop the test*/ - if (s->use_named_pipes && s->grp_op_test == true) - np_send_error(s, true); - -error2: - return false; } @@ -3578,26 +3071,9 @@ move_one_group(state_t *s, hid_t obj_id, const char *name, const char *newname, TEST_ERROR; } - /* Writer sends a message to reader: - * then wait for the reader to verify and send an acknowledgement message back.*/ - if (s->use_named_pipes && s->grp_op_test == true) { - dbgf(2, "writer: ready to send the message: %d\n", s->np_notify + 1); - if (np_wr_send_receive(s) == false) { - H5_FAILED(); - AT(); - goto error2; - } - } - return true; error: - /* Writer needs to send an error message to the reader to stop the test*/ - if (s->use_named_pipes && s->grp_op_test == true) - np_send_error(s, true); - -error2: - return false; } @@ -3745,26 +3221,9 @@ insert_one_link(state_t *s, hid_t obj_id, const char *name, const char *newname, } } - /* Writer sends a message to reader, - * then wait for the reader to verify and send an acknowledgement message back.*/ - if (s->use_named_pipes && s->grp_op_test == true) { - dbgf(2, "writer: ready to send the message: %d\n", s->np_notify + 1); - if (np_wr_send_receive(s) == false) { - H5_FAILED(); - AT(); - goto error2; - } - } - return true; error: - /* Writer needs to send an error message to the reader to stop the test*/ - if (s->use_named_pipes && s->grp_op_test == true) - np_send_error(s, true); - -error2: - return false; } @@ -4088,23 +3547,6 @@ vrfy_create_group(state_t *s, unsigned int which) hid_t g = H5I_INVALID_HID; H5G_info_t group_info; - dbgf(2, "reader: ready to send the message: \n"); - - /* The reader receives a message from the writer.Then sleep - * for a few ticks or stop the test if the received message - * is an error message. - */ - if (s->use_named_pipes && true == s->grp_op_test) { - - if (false == np_rd_receive(s)) { - H5_FAILED(); - AT(); - goto error2; - } - decisleep(s->tick_len * s->update_interval); - dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); - } - if (which >= s->nsteps) { printf("Number of created groups is out of bounds\n"); TEST_ERROR; @@ -4143,13 +3585,6 @@ vrfy_create_group(state_t *s, unsigned int which) TEST_ERROR; } - /* Reader sends an OK message back to the writer */ - if (s->use_named_pipes && s->grp_op_test == true) { - - if (np_rd_send(s) == false) - TEST_ERROR; - dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); - } return true; @@ -4161,12 +3596,6 @@ error: } H5E_END_TRY; - /* The reader sends an error message to the writer to stop the test.*/ - if (s->use_named_pipes && s->grp_op_test == true) - np_send_error(s, false); - -error2: - return false; } @@ -4206,22 +3635,6 @@ vrfy_create_group_id(state_t *s, unsigned int which, bool dense_to_compact) unsigned max_compact = 0; unsigned min_dense = 0; - dbgf(2, "reader: ready to receive a message: \n"); - /* The reader receives a message from the writer.Then sleep - * for a few ticks or stop the test if the received message - * is an error message. - */ - if (s->use_named_pipes && true == s->grp_op_test) { - - if (false == np_rd_receive(s)) { - H5_FAILED(); - AT(); - goto error2; - } - decisleep(s->tick_len * s->update_interval); - dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); - } - if (which >= s->nsteps) { printf("Number of the created groups is out of bounds\n"); TEST_ERROR; @@ -4291,14 +3704,6 @@ vrfy_create_group_id(state_t *s, unsigned int which, bool dense_to_compact) dbgf(2, "Storage info is %d\n", group_info.storage_type); - /* Reader sends an OK message back to the reader */ - if (s->use_named_pipes && s->grp_op_test == true) { - - if (np_rd_send(s) == false) - TEST_ERROR; - dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); - } - return g; error: @@ -4310,12 +3715,6 @@ error: } H5E_END_TRY; - /* The reader sends an error message to the writer to stop the test.*/ - if (s->use_named_pipes && s->grp_op_test == true) - np_send_error(s, false); - -error2: - return -1; } @@ -4342,43 +3741,16 @@ static bool vrfy_close_group_id(state_t *s, hid_t g) { - /* The reader receives a message from the writer.Then sleep - * for a few ticks or stop the test if the received message - * is an error message. - */ - if (s->use_named_pipes && true == s->grp_op_test) { - - if (false == np_rd_receive(s)) { - H5_FAILED(); - AT(); - goto error2; - } - decisleep(s->tick_len * s->update_interval); - dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); - } - if (H5Gclose(g) < 0) { printf("H5Gclose failed\n"); TEST_ERROR; } - /* Reader sends an OK message back to the reader */ - if (s->use_named_pipes && s->grp_op_test == true) { - - if (np_rd_send(s) == false) - TEST_ERROR; - dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); - } return true; error: - /* The reader sends an error message to the writer to stop the test.*/ - if (s->use_named_pipes && s->grp_op_test == true) - np_send_error(s, false); - -error2: return false; } @@ -4418,21 +3790,6 @@ vrfy_one_link_exist(state_t *s, hid_t obj_id, const char *name, bool expect_exis int link_exists = 0; H5G_info_t group_info; - dbgf(2, "reader: ready to send the message: \n"); - /* The reader receives a message from the writer.Then sleep - * for a few ticks or stop the test if the received message - * is an error message. - */ - if (s->use_named_pipes && true == s->grp_op_test) { - - if (false == np_rd_receive(s)) { - H5_FAILED(); - AT(); - goto error2; - } - decisleep(s->tick_len * s->update_interval); - dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); - } link_exists = H5Lexists(obj_id, name, H5P_DEFAULT); @@ -4479,24 +3836,10 @@ vrfy_one_link_exist(state_t *s, hid_t obj_id, const char *name, bool expect_exis } } - /* Reader sends an OK message back to the reader */ - if (s->use_named_pipes && s->grp_op_test == true) { - if (np_rd_send(s) == false) { - TEST_ERROR; - } - dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); - } - return true; error: - /* The reader sends an error message to the writer to stop the test.*/ - if (s->use_named_pipes && s->grp_op_test == true) - np_send_error(s, false); - -error2: - return false; } @@ -4572,22 +3915,6 @@ vrfy_move_one_group(state_t *s, hid_t obj_id, const char *name, const char *newn H5G_info_t group_info; int link_exists = 0; - dbgf(2, "reader: ready to send the message: \n"); - /* The reader receives a message from the writer.Then sleep - * for a few ticks or stop the test if the received message - * is an error message. - */ - if (s->use_named_pipes && true == s->grp_op_test) { - - if (false == np_rd_receive(s)) { - H5_FAILED(); - AT(); - goto error2; - } - decisleep(s->tick_len * s->update_interval); - dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); - } - if (which >= s->nsteps) { printf("Number of created groups is out of bounds\n"); TEST_ERROR; @@ -4634,15 +3961,6 @@ vrfy_move_one_group(state_t *s, hid_t obj_id, const char *name, const char *newn TEST_ERROR; } - /* Reader sends an OK message back to the reader */ - if (s->use_named_pipes && s->grp_op_test == true) { - - if (np_rd_send(s) == false) { - TEST_ERROR; - } - dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); - } - return true; error: @@ -4653,12 +3971,6 @@ error: } H5E_END_TRY; - /* The reader sends an error message to the writer to stop the test.*/ - if (s->use_named_pipes && s->grp_op_test == true) - np_send_error(s, false); - -error2: - return false; } @@ -4986,6 +4298,7 @@ verify_group_operations(state_t *s, unsigned int which) return ret_value; } + int main(int argc, char **argv) { @@ -4995,10 +4308,6 @@ main(int argc, char **argv) state_t s; const char * personality; H5F_vfd_swmr_config_t config; - const char * fifo_writer_to_reader = "./fifo_group_writer_to_reader"; - const char * fifo_reader_to_writer = "./fifo_group_reader_to_writer"; - int fd_writer_to_reader = -1, fd_reader_to_writer = -1; - int notify = 0, verify = 0; bool wg_ret = false; bool vg_ret = false; struct timespec start_time, end_time; @@ -5079,127 +4388,55 @@ main(int argc, char **argv) TEST_ERROR; } - /* Use two named pipes(FIFO) to coordinate the writer and reader for - * two-way communication so that the two sides can move forward together. - * One is for the writer to write to the reader. - * The other one is for the reader to signal the writer. */ - if (s.use_named_pipes && writer) { - /* Writer creates two named pipes(FIFO) */ - if (HDmkfifo(fifo_writer_to_reader, 0600) < 0) { - printf("HDmkfifo failed\n"); - TEST_ERROR; - } - if (HDmkfifo(fifo_reader_to_writer, 0600) < 0) { - printf("HDmkfifo failed\n"); - TEST_ERROR; - } - } + if (writer) { + if (s.gperf) { - /* Both the writer and reader open the pipes */ - if (s.use_named_pipes && (fd_writer_to_reader = HDopen(fifo_writer_to_reader, O_RDWR)) < 0) { - printf("HDopen failed\n"); - TEST_ERROR; - } + if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { - if (s.use_named_pipes && (fd_reader_to_writer = HDopen(fifo_reader_to_writer, O_RDWR)) < 0) { - printf("HDopen failed\n"); - TEST_ERROR; - } + fprintf(stderr, "HDclock_gettime failed"); - /* Pass the named pipe information to the struct of state_t s, for attribute tests.*/ - if (s.use_named_pipes) { - s.np_fd_w_to_r = fd_writer_to_reader; - s.np_fd_r_to_w = fd_reader_to_writer; - s.np_notify = notify; - s.np_verify = verify; - s.tick_len = config.tick_len; - s.max_lag = config.max_lag; + TEST_ERROR; + } } - /* For attribute test, force the named pipe to communicate in every step. - * This will avoid the fake verification error from the reader when using the named pipe. - * If the named pipe is not forced to communicate in every step, the reader may go ahead - * to verify the group and the attribute operations before the writer has a chance to - * carry out the corresponding operations. */ - if (s.attr_test && s.use_named_pipes) - s.csteps = 1; - - /* For group operation test, force the named pipe to communicate in every step. */ - if (s.grp_op_test && s.use_named_pipes) - s.csteps = 1; - - if (writer) { for (step = 0; step < s.nsteps; step++) { dbgf(2, "writer: step %d\n", step); wg_ret = group_operations(&s, step); if (wg_ret == false) { - - /* At communication interval, notifies the reader about the failure and quit */ - if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && step % s.csteps == 0) - np_send_error(&s, true); printf("write_group failed at step %d\n", step); TEST_ERROR; } - else { + } + if (s.gperf) { + + if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { - /* At communication interval, notifies the reader and waits for its response */ - if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && - step % s.csteps == 0) { + fprintf(stderr, "HDclock_gettime failed"); - if (np_wr_send_receive(&s) == false) { - printf("writer: write group - verification failed.\n"); - TEST_ERROR; - } - } - } + TEST_ERROR; } + + s.total_time = TIME_PASSED(start_time, end_time); s.mean_time = s.total_time / s.nsteps; - fprintf(stdout, "group creation min. time = %lf\n", s.min_time); - fprintf(stdout, "group creation max. time = %lf\n", s.max_time); - fprintf(stdout, "group creation mean time = %lf\n", s.mean_time); - fprintf(stdout, "group creation total time = %lf\n", s.total_time); + fprintf(stdout, "group creation +5 attrs total time = %lf\n", s.total_time); + fprintf(stdout, "group creation +5 attrs mean time = %lf\n", s.mean_time); + } + } else { for (step = 0; step < s.nsteps; step++) { dbgf(1, "reader: step %d\n", step); - /* At communication interval, waits for the writer to finish creation before starting verification - */ - if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && step % s.csteps == 0) { - if (false == np_rd_receive(&s)) { - TEST_ERROR; - } - } - - /* For the default test, wait for a few ticks for the update to happen */ - if (s.use_named_pipes && s.attr_test == false) - decisleep(config.tick_len * s.update_interval); - vg_ret = verify_group_operations(&s, step); if (vg_ret == false) { printf("verify_group_operations failed\n"); - - /* At communication interval, tell the writer about the failure and exit */ - if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && step % s.csteps == 0) - np_send_error(&s, false); TEST_ERROR; } - else { - - /* Send back the same nofity value for acknowledgement to tell the writer - * move to the next step. */ - if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && - step % s.csteps == 0) { - if (np_rd_send(&s) == false) { - TEST_ERROR; - } - } - } } } @@ -5249,31 +4486,6 @@ main(int argc, char **argv) fprintf(stdout, "H5Fclose time = %lf\n", s.fc_total_time); } - - /* Both the writer and reader close the named pipes */ - if (s.use_named_pipes && HDclose(fd_writer_to_reader) < 0) { - printf("HDclose failed\n"); - TEST_ERROR; - } - - if (s.use_named_pipes && HDclose(fd_reader_to_writer) < 0) { - printf("HDclose failed\n"); - TEST_ERROR; - } - - /* Reader finishes last and deletes the named pipes */ - if (s.use_named_pipes && !writer) { - if (HDremove(fifo_writer_to_reader) != 0) { - printf("HDremove failed\n"); - TEST_ERROR; - } - - if (HDremove(fifo_reader_to_writer) != 0) { - printf("HDremove failed\n"); - TEST_ERROR; - } - } - return EXIT_SUCCESS; error: @@ -5286,17 +4498,6 @@ error: } H5E_END_TRY; - if (s.use_named_pipes && fd_writer_to_reader >= 0) - HDclose(fd_writer_to_reader); - - if (s.use_named_pipes && fd_reader_to_writer >= 0) - HDclose(fd_reader_to_writer); - - if (s.use_named_pipes && !writer) { - HDremove(fifo_writer_to_reader); - HDremove(fifo_reader_to_writer); - } - return EXIT_FAILURE; } -- cgit v0.12 From 84b8db9485acfc764bb9380721d1464a30771888 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Aug 2021 20:28:31 +0000 Subject: Committing clang-format changes --- test/vfd_swmr_gperf_writer.c | 59 ++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 35 deletions(-) diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index ac56ee4..389749f 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -10,17 +10,17 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Description of this program: +/* Description of this program: * This program checks the performance of group creations for VFD SWMR. * Currently the group creation time, H5Fopen and H5Fclose time are measured. - * After compiling the program, + * After compiling the program, * ./vfd_swmr_gperf_writer -n 1000 -P -N 5 -a 1 -q - * will generate 1000 groups, each group has 5 attributes. + * will generate 1000 groups, each group has 5 attributes. * ./vfd_swmr_gperf_writer -n 1000 -P -N 0 -q * will generate 1000 empty groups. * ./vfd_swmr_gperf_writer -n 1000 -P -q * will generate 1000 groups,for every ten groups, an attribute is generated. -*/ + */ #define H5F_FRIEND /*suppress error about including H5Fpkg */ #include "hdf5.h" @@ -34,7 +34,7 @@ #ifndef H5_HAVE_WIN32_API -#define VS_ATTR_NAME_LEN 21 +#define VS_ATTR_NAME_LEN 21 #define TIME_PASSED(X, Y) \ ((double)((Y.tv_sec - X.tv_sec) * 1000000000 + (Y.tv_nsec - X.tv_nsec))) / 1000000000.0 @@ -67,13 +67,10 @@ typedef struct { (state_t) \ { \ .file = H5I_INVALID_HID, .one_by_one_sid = H5I_INVALID_HID, .filename = "", \ - .filetype = H5T_NATIVE_UINT32, .asteps = 10, .nsteps = 100, \ - .use_vfd_swmr = true, .old_style_grp = false, \ - .grp_op_pattern = ' ', .grp_op_test = false, .at_pattern = ' ', \ - .attr_test = false, .tick_len = 4, .max_lag = 7, \ - .gperf = false, .min_time = 100., .max_time = 0.,.mean_time = 0., \ - .total_time = 0., .fo_total_time = 0., \ - .fc_total_time = 0., .num_attrs = 1 \ + .filetype = H5T_NATIVE_UINT32, .asteps = 10, .nsteps = 100, .use_vfd_swmr = true, \ + .old_style_grp = false, .grp_op_pattern = ' ', .grp_op_test = false, .at_pattern = ' ', \ + .attr_test = false, .tick_len = 4, .max_lag = 7, .gperf = false, .min_time = 100., .max_time = 0., \ + .mean_time = 0., .total_time = 0., .fo_total_time = 0., .fc_total_time = 0., .num_attrs = 1 \ } static void @@ -445,7 +442,6 @@ add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const ch } } - } /* end for */ if (H5Tclose(amtype) < 0) { @@ -1560,7 +1556,6 @@ write_group(state_t *s, unsigned int which) } } - /* Then carry out the attribute operation. */ if (s->asteps != 0 && which % s->asteps == 0) result = add_group_attribute(s, g, gcpl, which); @@ -3585,7 +3580,6 @@ vrfy_create_group(state_t *s, unsigned int which) TEST_ERROR; } - return true; error: @@ -3746,7 +3740,6 @@ vrfy_close_group_id(state_t *s, hid_t g) TEST_ERROR; } - return true; error: @@ -3790,7 +3783,6 @@ vrfy_one_link_exist(state_t *s, hid_t obj_id, const char *name, bool expect_exis int link_exists = 0; H5G_info_t group_info; - link_exists = H5Lexists(obj_id, name, H5P_DEFAULT); if (link_exists < 0) { @@ -4298,7 +4290,6 @@ verify_group_operations(state_t *s, unsigned int which) return ret_value; } - int main(int argc, char **argv) { @@ -4384,17 +4375,16 @@ main(int argc, char **argv) TEST_ERROR; } - if (writer) { - if (s.gperf) { + if (s.gperf) { - if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { + if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { - fprintf(stderr, "HDclock_gettime failed"); + fprintf(stderr, "HDclock_gettime failed"); - TEST_ERROR; + TEST_ERROR; + } } - } for (step = 0; step < s.nsteps; step++) { dbgf(2, "writer: step %d\n", step); @@ -4406,21 +4396,20 @@ main(int argc, char **argv) TEST_ERROR; } } - if (s.gperf) { + if (s.gperf) { - if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { + if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { - fprintf(stderr, "HDclock_gettime failed"); + fprintf(stderr, "HDclock_gettime failed"); - TEST_ERROR; - } - - s.total_time = TIME_PASSED(start_time, end_time); - s.mean_time = s.total_time / s.nsteps; - fprintf(stdout, "group creation +5 attrs total time = %lf\n", s.total_time); - fprintf(stdout, "group creation +5 attrs mean time = %lf\n", s.mean_time); - } + TEST_ERROR; + } + s.total_time = TIME_PASSED(start_time, end_time); + s.mean_time = s.total_time / s.nsteps; + fprintf(stdout, "group creation +5 attrs total time = %lf\n", s.total_time); + fprintf(stdout, "group creation +5 attrs mean time = %lf\n", s.mean_time); + } } else { for (step = 0; step < s.nsteps; step++) { -- cgit v0.12 From 3082cd226e7affcf693cc9f4e0380880c029a141 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Wed, 4 Aug 2021 10:05:13 -0700 Subject: VFD SWMR: Fixes naked basename() call on MacOS (#874) * Fixes naked basename() call on MacOS * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- test/vfd_swmr_dsetchks_writer.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/vfd_swmr_dsetchks_writer.c b/test/vfd_swmr_dsetchks_writer.c index 1d9bc4c..a02a042 100644 --- a/test/vfd_swmr_dsetchks_writer.c +++ b/test/vfd_swmr_dsetchks_writer.c @@ -265,10 +265,14 @@ state_init(state_t *s, int argc, char **argv) int ch; char tfile[PATH_MAX]; char * end; + char * base; + + if (H5_basename(tfile, base) < 0) + TEST_ERROR *s = ALL_HID_INITIALIZER; esnprintf(tfile, sizeof(tfile), "%s", argv[0]); - esnprintf(s->progname, sizeof(s->progname), "%s", basename(tfile)); + esnprintf(s->progname, sizeof(s->progname), "%s", base); while ((ch = getopt(argc, argv, "siferom:n:x:y:g:p:t:l:bqSNu:c:")) != -1) { switch (ch) { @@ -370,6 +374,8 @@ state_init(state_t *s, int argc, char **argv) argc -= optind; argv += optind; + HDfree(base); + /* Require to specify at least -s or -i or -f or -e or -r option */ if (!s->single_index && !s->implicit_index && !s->fa_index && !s->ea_index && !s->bt2_index) { printf("Require to specify at least -s or -i or -f or -e or -r option\n"); -- cgit v0.12 From a7f3feee8718450c3e32fcbb2f90065240b6b9b5 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Wed, 4 Aug 2021 10:07:21 -0700 Subject: VFD SWMR: UG updates from beta 1 (#878) * Brings MacOS basename fix from feature/vfd_swmr (#875) * Updated the user's guide with a note about debug builds --- doc/vfd-swmr-user-guide.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/vfd-swmr-user-guide.md b/doc/vfd-swmr-user-guide.md index ee7df64..a4375b3 100644 --- a/doc/vfd-swmr-user-guide.md +++ b/doc/vfd-swmr-user-guide.md @@ -94,6 +94,13 @@ There are no special instructions for building VFD SWMR. Simply follow the usual build procedure for CMake or the Autotools using the guides in the `release_docs` directory. +IMPORTANT: + +The VFD SWMR branches are maintenance branches and will default to a debug +build. They also do not come with generated files, so Perl will be required +when building with CMake and Perl and the Autotools (autoconf, etc.) will +be required when building with the Autotools. + Some notes: - The mirror VFD tests require some rework, so enabling that feature will cause the build step to fail. This will be fixed in a future beta release. -- cgit v0.12 From 3cdef1e84c78d3fd776916928547f3adb3d4167b Mon Sep 17 00:00:00 2001 From: Muqun Yang Date: Thu, 5 Aug 2021 07:51:44 -0500 Subject: Add the group level support. --- test/vfd_swmr_gperf_writer.c | 217 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 192 insertions(+), 25 deletions(-) diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index ac56ee4..04a35ad 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -61,6 +61,7 @@ typedef struct { double fo_total_time; double fc_total_time; unsigned int num_attrs; + unsigned int nglevels; } state_t; #define ALL_HID_INITIALIZER \ @@ -73,15 +74,17 @@ typedef struct { .attr_test = false, .tick_len = 4, .max_lag = 7, \ .gperf = false, .min_time = 100., .max_time = 0.,.mean_time = 0., \ .total_time = 0., .fo_total_time = 0., \ - .fc_total_time = 0., .num_attrs = 1 \ + .fc_total_time = 0., .num_attrs = 1, .nglevels = 0 \ } + + static void usage(const char *progname) { fprintf(stderr, "usage: %s [-S] [-G] [-a steps] [-b] [-n iterations]\n" - " [-N num_attrs] [-q] [-A at_pattern] [-O grp_op_pattern]\n" + " [-N num_attrs] [-l nested group levels] [-q] [-A at_pattern] [-O grp_op_pattern]\n" "\n" "-S: do not use VFD SWMR\n" "-G: old-style type of group\n" @@ -89,6 +92,9 @@ usage(const char *progname) "-b: write data in big-endian byte order\n" "-n ngroups: the number of groups\n" "-N: the number of attributes \n" + "-l: the number of level of nested groups. \n" + " If all the groups are under the root group, \n" + " this number should be 0.\n" "-A at_pattern: `at_pattern' for different attribute tests\n" " The value of `at_pattern` is one of the following:\n" " `compact` - Attributes added in compact storage\n" @@ -166,10 +172,14 @@ state_init(state_t *s, int argc, char **argv) esnprintf(s->progname, sizeof(s->progname), "%s", tfile); - if (tfile) + if (tfile) { HDfree(tfile); + tfile = NULL; + } - while ((ch = getopt(argc, argv, "PSGa:bn:qA:N:O:")) != -1) { + if(argc == 1) + usage(s->progname); + while ((ch = getopt(argc, argv, "PSGa:bn:qA:N:l:O:")) != -1) { switch (ch) { case 'P': s->gperf = true; @@ -183,6 +193,7 @@ state_init(state_t *s, int argc, char **argv) case 'a': case 'n': case 'N': + case 'l': errno = 0; tmp = HDstrtoul(optarg, &end, 0); if (end == optarg || *end != '\0') { @@ -204,6 +215,8 @@ state_init(state_t *s, int argc, char **argv) s->nsteps = (unsigned)tmp; else if (ch == 'N') s->num_attrs = (unsigned)tmp; + else if (ch == 'l') + s->nglevels = (unsigned)tmp; break; case 'b': s->filetype = H5T_STD_U32BE; @@ -1599,6 +1612,7 @@ error: return false; } + /*------------------------------------------------------------------------- * Function: check_attr_storage_type * @@ -4298,6 +4312,126 @@ verify_group_operations(state_t *s, unsigned int which) return ret_value; } +static unsigned int grp_counter = 0; +static unsigned int UI_Pow(unsigned int x,unsigned int n) +{ + unsigned int i; /* Variable used in loop grp_counter */ + unsigned int number = 1; + + for (i = 0; i < n; ++i) + number *= x; + + return(number); +} + +static unsigned int obtain_tree_level_elems(unsigned int total_ele,unsigned int level) { + + assert(level <=total_ele); + if(level == 0) + return total_ele; + else { + unsigned int test_elems_level = 0; + unsigned total = 0; + unsigned int i = 1; + while (total 0 && grp_counter nsteps) { + + for(i = 0; i < ne_per_level; i++) { + esnprintf(name, sizeof(name), "group-%u", grp_counter); + if(grp_counter ==s->nsteps) + break; + /* For each i a group is created. + Use grp_counter to generate the group name. + printf("id: %u,level: %u, index: %u\n",id,level,i); + */ + if ((grp_id = H5Gcreate2(pgrp_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + printf("H5Gcreate2 failed\n"); + TEST_ERROR; + } + + /* Just check the first group information. */ + if(grp_counter == 0) { + if (H5Gget_info(grp_id, &group_info) < 0) { + printf("H5Gget_info failed\n"); + TEST_ERROR; + } + + if (s->old_style_grp) { + if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { + printf("Old-styled group test: but the group is not in old-style. \n"); + TEST_ERROR; + } + dbgf(2, "Writer: group is created with the old-style.\n"); + } + else { + if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { + printf("The created group should NOT be in old-style . \n"); + TEST_ERROR; + } + dbgf(2, "Writer: group is created with the new-style.\n"); + } + } + + + /* Then carry out the attribute operation. */ + if (s->asteps != 0 && grp_counter % s->asteps == 0) + result = add_default_group_attr(s, grp_id, grp_counter); + + if (result == false) { + printf("Cannot create group attributes. \n"); + TEST_ERROR; + } + grp_counter++; + result = gen_tree_struct(s,level-1,ne_per_level,grp_id); + if (result == false) { + printf("Cannot create nested groups. \n"); + TEST_ERROR; + } + + /* close the group ID. No problem. */ + if(H5Gclose(grp_id)<0) { + printf("H5Gclose failed. \n"); + TEST_ERROR; + } + } + } + + return true; + +error: + + H5E_BEGIN_TRY + { + H5Gclose(grp_id); + } + H5E_END_TRY; + + return false; +} + + + int main(int argc, char **argv) @@ -4311,6 +4445,7 @@ main(int argc, char **argv) bool wg_ret = false; bool vg_ret = false; struct timespec start_time, end_time; + unsigned int num_elems_per_level; if (!state_init(&s, argc, argv)) { printf("state_init failed\n"); @@ -4351,6 +4486,14 @@ main(int argc, char **argv) TEST_ERROR; } + if(s.nglevels >0) { + if(s.grp_op_pattern!=' ' || s.at_pattern!=' '){ + printf("For nested group creation test, only the default option is supported.\n"); + printf("Please re-run the tests with the appopriate option.\n"); + TEST_ERROR; + } + } + if (s.gperf) { if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { @@ -4386,43 +4529,67 @@ main(int argc, char **argv) if (writer) { - if (s.gperf) { + if (s.gperf) { - if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { + if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { - fprintf(stderr, "HDclock_gettime failed"); + fprintf(stderr, "HDclock_gettime failed"); - TEST_ERROR; - } - } + TEST_ERROR; + } - for (step = 0; step < s.nsteps; step++) { - dbgf(2, "writer: step %d\n", step); + } - wg_ret = group_operations(&s, step); + if (s.nglevels >0) { - if (wg_ret == false) { - printf("write_group failed at step %d\n", step); + num_elems_per_level = obtain_tree_level_elems(s.nsteps,s.nglevels); + //wg_ret = gen_tree_struct(&s,s.nsteps,s.nglevels,num_elems_per_level,s.file); + /* for the recursive call, the groups under the root is treated as one level */ + wg_ret = gen_tree_struct(&s,s.nglevels+1,num_elems_per_level,s.file); + if(wg_ret == false) { + printf("write nested group failed at group counter %u\n", grp_counter); TEST_ERROR; } } - if (s.gperf) { + else { + for (step = 0; step < s.nsteps; step++) { - if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { + dbgf(2, "writer: step %d\n", step); + wg_ret = group_operations(&s, step); + if (wg_ret == false) { + printf("write_group failed at step %d\n", step); + TEST_ERROR; + } + } + } - fprintf(stderr, "HDclock_gettime failed"); + if (s.gperf) { - TEST_ERROR; - } + if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { - s.total_time = TIME_PASSED(start_time, end_time); - s.mean_time = s.total_time / s.nsteps; - fprintf(stdout, "group creation +5 attrs total time = %lf\n", s.total_time); - fprintf(stdout, "group creation +5 attrs mean time = %lf\n", s.mean_time); - } + fprintf(stderr, "HDclock_gettime failed"); + TEST_ERROR; + } + + s.total_time = TIME_PASSED(start_time, end_time); + s.mean_time = s.total_time / s.nsteps; + fprintf(stdout, "group creation +5 attrs total time = %lf\n", s.total_time); + fprintf(stdout, "group creation +5 attrs mean time = %lf\n", s.mean_time); + } } else { + + if (s.nglevels > 0) { + printf("Reader: The nested group creation test is not implemented. Stop!\n"); + TEST_ERROR; + } + if(s.num_attrs >1) { + printf("Reader: number of attribute must be 1 for the default group test. Stop!\n"); + printf("The current number of attributes per group is %u\n",s.num_attrs); + TEST_ERROR; + } + for (step = 0; step < s.nsteps; step++) { dbgf(1, "reader: step %d\n", step); -- cgit v0.12 From 5bf08f0dd7295194b06dacb3f413211c1a90a417 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 Aug 2021 13:05:01 +0000 Subject: Committing clang-format changes --- test/vfd_swmr_gperf_writer.c | 110 ++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 58 deletions(-) diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index 86a5f70..c1844d4 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -68,17 +68,13 @@ typedef struct { (state_t) \ { \ .file = H5I_INVALID_HID, .one_by_one_sid = H5I_INVALID_HID, .filename = "", \ - .filetype = H5T_NATIVE_UINT32, .asteps = 10, .nsteps = 100, \ - .use_vfd_swmr = true, .old_style_grp = false, \ - .grp_op_pattern = ' ', .grp_op_test = false, .at_pattern = ' ', \ - .attr_test = false, .tick_len = 4, .max_lag = 7, \ - .gperf = false, .min_time = 100., .max_time = 0.,.mean_time = 0., \ - .total_time = 0., .fo_total_time = 0., \ - .fc_total_time = 0., .num_attrs = 1, .nglevels = 0 \ + .filetype = H5T_NATIVE_UINT32, .asteps = 10, .nsteps = 100, .use_vfd_swmr = true, \ + .old_style_grp = false, .grp_op_pattern = ' ', .grp_op_test = false, .at_pattern = ' ', \ + .attr_test = false, .tick_len = 4, .max_lag = 7, .gperf = false, .min_time = 100., .max_time = 0., \ + .mean_time = 0., .total_time = 0., .fo_total_time = 0., .fc_total_time = 0., .num_attrs = 1, \ + .nglevels = 0 \ } - - static void usage(const char *progname) { @@ -177,7 +173,7 @@ state_init(state_t *s, int argc, char **argv) tfile = NULL; } - if(argc == 1) + if (argc == 1) usage(s->progname); while ((ch = getopt(argc, argv, "PSGa:bn:qA:N:l:O:")) != -1) { switch (ch) { @@ -1610,7 +1606,6 @@ error: return false; } - /*------------------------------------------------------------------------- * Function: check_attr_storage_type * @@ -4308,7 +4303,8 @@ verify_group_operations(state_t *s, unsigned int which) } static unsigned int grp_counter = 0; -static unsigned int UI_Pow(unsigned int x,unsigned int n) +static unsigned int +UI_Pow(unsigned int x, unsigned int n) { unsigned int i; /* Variable used in loop grp_counter */ unsigned int number = 1; @@ -4316,45 +4312,47 @@ static unsigned int UI_Pow(unsigned int x,unsigned int n) for (i = 0; i < n; ++i) number *= x; - return(number); + return (number); } -static unsigned int obtain_tree_level_elems(unsigned int total_ele,unsigned int level) { +static unsigned int +obtain_tree_level_elems(unsigned int total_ele, unsigned int level) +{ - assert(level <=total_ele); - if(level == 0) - return total_ele; - else { + assert(level <= total_ele); + if (level == 0) + return total_ele; + else { unsigned int test_elems_level = 0; - unsigned total = 0; - unsigned int i = 1; - while (total 0 && grp_counter nsteps) { + if (level > 0 && grp_counter < s->nsteps) { - for(i = 0; i < ne_per_level; i++) { + for (i = 0; i < ne_per_level; i++) { esnprintf(name, sizeof(name), "group-%u", grp_counter); - if(grp_counter ==s->nsteps) + if (grp_counter == s->nsteps) break; /* For each i a group is created. Use grp_counter to generate the group name. @@ -4366,7 +4364,7 @@ static bool gen_tree_struct(state_t *s, unsigned int level, unsigned ne_per_leve } /* Just check the first group information. */ - if(grp_counter == 0) { + if (grp_counter == 0) { if (H5Gget_info(grp_id, &group_info) < 0) { printf("H5Gget_info failed\n"); TEST_ERROR; @@ -4388,7 +4386,6 @@ static bool gen_tree_struct(state_t *s, unsigned int level, unsigned ne_per_leve } } - /* Then carry out the attribute operation. */ if (s->asteps != 0 && grp_counter % s->asteps == 0) result = add_default_group_attr(s, grp_id, grp_counter); @@ -4398,14 +4395,14 @@ static bool gen_tree_struct(state_t *s, unsigned int level, unsigned ne_per_leve TEST_ERROR; } grp_counter++; - result = gen_tree_struct(s,level-1,ne_per_level,grp_id); + result = gen_tree_struct(s, level - 1, ne_per_level, grp_id); if (result == false) { printf("Cannot create nested groups. \n"); TEST_ERROR; } - + /* close the group ID. No problem. */ - if(H5Gclose(grp_id)<0) { + if (H5Gclose(grp_id) < 0) { printf("H5Gclose failed. \n"); TEST_ERROR; } @@ -4425,9 +4422,6 @@ error: return false; } - - - int main(int argc, char **argv) { @@ -4481,14 +4475,14 @@ main(int argc, char **argv) TEST_ERROR; } - if(s.nglevels >0) { - if(s.grp_op_pattern!=' ' || s.at_pattern!=' '){ + if (s.nglevels > 0) { + if (s.grp_op_pattern != ' ' || s.at_pattern != ' ') { printf("For nested group creation test, only the default option is supported.\n"); printf("Please re-run the tests with the appopriate option.\n"); TEST_ERROR; } } - + if (s.gperf) { if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { @@ -4533,13 +4527,13 @@ main(int argc, char **argv) } } - if (s.nglevels >0) { + if (s.nglevels > 0) { - num_elems_per_level = obtain_tree_level_elems(s.nsteps,s.nglevels); - //wg_ret = gen_tree_struct(&s,s.nsteps,s.nglevels,num_elems_per_level,s.file); + num_elems_per_level = obtain_tree_level_elems(s.nsteps, s.nglevels); + // wg_ret = gen_tree_struct(&s,s.nsteps,s.nglevels,num_elems_per_level,s.file); /* for the recursive call, the groups under the root is treated as one level */ - wg_ret = gen_tree_struct(&s,s.nglevels+1,num_elems_per_level,s.file); - if(wg_ret == false) { + wg_ret = gen_tree_struct(&s, s.nglevels + 1, num_elems_per_level, s.file); + if (wg_ret == false) { printf("write nested group failed at group counter %u\n", grp_counter); TEST_ERROR; } @@ -4565,7 +4559,7 @@ main(int argc, char **argv) } s.total_time = TIME_PASSED(start_time, end_time); - s.mean_time = s.total_time / s.nsteps; + s.mean_time = s.total_time / s.nsteps; fprintf(stdout, "group creation +5 attrs total time = %lf\n", s.total_time); fprintf(stdout, "group creation +5 attrs mean time = %lf\n", s.mean_time); } @@ -4576,9 +4570,9 @@ main(int argc, char **argv) printf("Reader: The nested group creation test is not implemented. Stop!\n"); TEST_ERROR; } - if(s.num_attrs >1) { + if (s.num_attrs > 1) { printf("Reader: number of attribute must be 1 for the default group test. Stop!\n"); - printf("The current number of attributes per group is %u\n",s.num_attrs); + printf("The current number of attributes per group is %u\n", s.num_attrs); TEST_ERROR; } -- cgit v0.12 From 94ca861b4ee46ef81edbd31df325a33d5681b7dd Mon Sep 17 00:00:00 2001 From: vchoi Date: Thu, 5 Aug 2021 17:34:11 -0500 Subject: Fix the segmentation fault that occurs when running test/vfd_swmr_group_writer with one million old style groups. (A) src/vfd_swmr_enlarge_shadow_index(): --When enlarging the metadata file index entries, HDmalloc() is used to allocate space for the index entries, but they are later freed at file close via H5MM_xfree() in H5F__dest(). This is corrected to use H5MM_calloc() instead to be consistent. Note that entries are initially allocated also via H5MM_calloc() in H5F__vfd_swmr_create_index(). --If the pointer to the old metadata file index entries exists (shared->old_mdf_idx), need to free the old entries via H5MM_xfree(). (B) test/testvfdswmr.sh.in: --The test is added to verify that the bug is resolved. --- src/H5Fvfd_swmr.c | 8 +++++++- test/testvfdswmr.sh.in | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c index 13170af..ebb57d6 100644 --- a/src/H5Fvfd_swmr.c +++ b/src/H5Fvfd_swmr.c @@ -1756,7 +1756,7 @@ vfd_swmr_enlarge_shadow_index(H5F_t *f) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "shadow-file allocation failed for index") } - new_mdf_idx = HDmalloc(new_mdf_idx_len * sizeof(new_mdf_idx[0])); + new_mdf_idx = H5MM_calloc(new_mdf_idx_len * sizeof(new_mdf_idx[0])); if (new_mdf_idx == NULL) { (void)H5MV_free(f, idx_addr, idx_size); @@ -1774,6 +1774,12 @@ vfd_swmr_enlarge_shadow_index(H5F_t *f) ret_value = shared->mdf_idx = new_mdf_idx; shared->mdf_idx_len = new_mdf_idx_len; + if(shared->old_mdf_idx) + H5MM_xfree(f->shared->old_mdf_idx); + + shared->old_mdf_idx = old_mdf_idx; + f->shared->old_mdf_idx_len = old_mdf_idx_len; + /* Postpone reclamation of the old index until max_lag ticks from now. * It's only necessary to wait until after the new index is in place, * so it's possible that some disused shadow storage will build up diff --git a/test/testvfdswmr.sh.in b/test/testvfdswmr.sh.in index b0ab785..7ef14be 100644 --- a/test/testvfdswmr.sh.in +++ b/test/testvfdswmr.sh.in @@ -145,9 +145,9 @@ all_tests="generator expand shrink expand_shrink sparse vlstr_null vlstr_oob zoo all_tests="${all_tests} groups groups_attrs groups_ops few_big many_small attrdset" tests=${all_tests} -# For exhaustive run, add: os_groups_attrs, os_groups_ops, dsetops, dsetchks +# For exhaustive run, add: os_groups_attrs, os_groups_ops, os_groups_seg, dsetops, dsetchks if [[ "$HDF5TestExpress" -eq 0 ]] ; then # exhaustive run - all_tests="${all_tests} os_groups_attrs os_groups_ops dsetops dsetchks" + all_tests="${all_tests} os_groups_attrs os_groups_ops os_groups_seg dsetops dsetchks" fi if [ $# -gt 0 ]; then @@ -1009,6 +1009,36 @@ done ############################################################################### # +# Setting for "os_groups_seg" test +# +# Only for exhaustive run +# +# Verify the segmentation fault is fixed when running with: +# --1,000,000 groups +# --as writer only +# +############################################################################### +# +# +GROUP_seg_n=1000000 # Number of groups when segmentation fault occurs +if [ ${do_os_groups_seg:-no} = no ]; then + continue +fi +echo launch vfd_swmr_group operations with old-style group: $GROUP_seg_n groups ......may take some time...... +catch_out_err_and_rc vfd_swmr_group_writer \ + ../vfd_swmr_group_writer -q -N -G -n $GROUP_seg_n -a $GROUP_seg_n + +# Collect exit code of the writer +if [ $(cat vfd_swmr_group_writer.rc) -ne 0 ]; then + echo writer had error + nerrors=$((nerrors + 1)) +fi + +# Clean up output files +rm -f vfd_swmr_group_writer.{out,rc} + +############################################################################### +# # Setting for bigset (few_big and many_small) tests # ############################################################################### -- cgit v0.12 From acaabcba4320bf46eea0f0508c5f61ab6fe91469 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 Aug 2021 22:36:58 +0000 Subject: Committing clang-format changes --- src/H5Fvfd_swmr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c index ebb57d6..c57bb5f 100644 --- a/src/H5Fvfd_swmr.c +++ b/src/H5Fvfd_swmr.c @@ -1774,11 +1774,11 @@ vfd_swmr_enlarge_shadow_index(H5F_t *f) ret_value = shared->mdf_idx = new_mdf_idx; shared->mdf_idx_len = new_mdf_idx_len; - if(shared->old_mdf_idx) - H5MM_xfree(f->shared->old_mdf_idx); + if (shared->old_mdf_idx) + H5MM_xfree(f->shared->old_mdf_idx); - shared->old_mdf_idx = old_mdf_idx; - f->shared->old_mdf_idx_len = old_mdf_idx_len; + shared->old_mdf_idx = old_mdf_idx; + f->shared->old_mdf_idx_len = old_mdf_idx_len; /* Postpone reclamation of the old index until max_lag ticks from now. * It's only necessary to wait until after the new index is in place, -- cgit v0.12 From cf4a523ab7e6041837cafab2ca2c78a6a01fbb61 Mon Sep 17 00:00:00 2001 From: vchoi Date: Mon, 9 Aug 2021 11:59:03 -0500 Subject: Modifications based on PR feedback. --- src/H5Fvfd_swmr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c index ebb57d6..e2e7568 100644 --- a/src/H5Fvfd_swmr.c +++ b/src/H5Fvfd_swmr.c @@ -1774,8 +1774,7 @@ vfd_swmr_enlarge_shadow_index(H5F_t *f) ret_value = shared->mdf_idx = new_mdf_idx; shared->mdf_idx_len = new_mdf_idx_len; - if(shared->old_mdf_idx) - H5MM_xfree(f->shared->old_mdf_idx); + H5MM_xfree(f->shared->old_mdf_idx); shared->old_mdf_idx = old_mdf_idx; f->shared->old_mdf_idx_len = old_mdf_idx_len; -- cgit v0.12 From 0bb13dcf92a309d7668e8cda85f248b420934f29 Mon Sep 17 00:00:00 2001 From: vchoi Date: Tue, 10 Aug 2021 14:25:06 -0500 Subject: (1) src/H5Fvfd_swmr.c --enable or disable raw data flush depending on configuration (2) vfd_swmr_dsetchks_writer.c vfd_swmr_dsetops_writer.c --modifications to test/verify when flushing of raw data is enabled/disabled --refactor coding (3) testvfdswmr.sh.in --add testing with/without flush of raw data to tests: dsetchks and dsetops (4) vfd_swmr_attrdset_writer.c --pass true for flushing raw data to the common routine init_vfd_swmr_config() --refactor coding so that it has similar format as the other two tests: dsetops and dsetchks (5) vfd_swmr_addrem_writer.c vfd_swmr_bigset_writer.c vfd_swmr_generator.c vfd_swmr_group_writer.c vfd_swmr_reader.c vfd_swmr_remove_reader.c vfd_swmr_remove_writer.c vfd_swmr_sparse_reader.c vfd_swmr_sparse_writer.c vfd_swmr_vlstr_reader.c vfd_swmr_vlstr_writer.c vfd_swmr_writer.c vfd_swmr_zoo_writer.c --pass true for flushing raw data to the common routine init_vfd_swmr_config() --- src/H5Fvfd_swmr.c | 45 +-- test/testvfdswmr.sh.in | 181 ++++++------ test/vfd_swmr_addrem_writer.c | 2 +- test/vfd_swmr_attrdset_writer.c | 357 ++++++++++++++---------- test/vfd_swmr_bigset_writer.c | 2 +- test/vfd_swmr_dsetchks_writer.c | 317 +++++++++++++++------ test/vfd_swmr_dsetops_writer.c | 600 ++++++++++++++++++++++++++-------------- test/vfd_swmr_generator.c | 2 +- test/vfd_swmr_group_writer.c | 2 +- test/vfd_swmr_reader.c | 2 +- test/vfd_swmr_remove_reader.c | 2 +- test/vfd_swmr_remove_writer.c | 2 +- test/vfd_swmr_sparse_reader.c | 2 +- test/vfd_swmr_sparse_writer.c | 2 +- test/vfd_swmr_vlstr_reader.c | 2 +- test/vfd_swmr_vlstr_writer.c | 2 +- test/vfd_swmr_writer.c | 2 +- test/vfd_swmr_zoo_writer.c | 2 +- 18 files changed, 953 insertions(+), 573 deletions(-) diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c index 13170af..3220443 100644 --- a/src/H5Fvfd_swmr.c +++ b/src/H5Fvfd_swmr.c @@ -768,26 +768,26 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, hbool_t wait_for_reader) /* 1) If requested, flush all raw data to the HDF5 file. * - * (Not for first cut.) - */ - HDassert(!shared->vfd_swmr_config.flush_raw_data); - -#if 1 - /* Test to see if b-tree corruption seen in VFD SWMR tests - * is caused by client hiding data from the metadata cache. Do - * this by calling H5D_flush_all(), which flushes any cached - * dataset storage. Eventually, we will do this regardless - * when the above flush_raw_data flag is set. */ + if(shared->vfd_swmr_config.flush_raw_data) { + + /* Test to see if b-tree corruption seen in VFD SWMR tests + * is caused by client hiding data from the metadata cache. Do + * this by calling H5D_flush_all(), which flushes any cached + * dataset storage. Eventually, we will do this regardless + * when the above flush_raw_data flag is set. + */ - if (H5D_flush_all(f) < 0) + if (H5D_flush_all(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush dataset cache") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush dataset cache") - if (H5MF_free_aggrs(f) < 0) + if (H5MF_free_aggrs(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file space") + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file space") + } + /* 2) If it exists, flush the metadata cache to the page buffer. */ if (shared->cache) { if (H5AC_prep_for_file_flush(f) < 0) @@ -806,23 +806,6 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, hbool_t wait_for_reader) if (H5FD_truncate(shared->lf, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "low level truncate failed") -#endif - - /* 2) If it exists, flush the metadata cache to the page buffer. */ - if (shared->cache) { - - if (H5AC_prep_for_file_flush(f) < 0) - - HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "prep for MDC flush failed") - - if (H5AC_flush(f) < 0) - - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush metadata cache to the page buffer") - - if (H5AC_secure_from_file_flush(f) < 0) - - HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "secure from MDC flush failed") - } /* 3) If this is the first tick (i.e. tick == 1), create the * in memory version of the metadata file index. diff --git a/test/testvfdswmr.sh.in b/test/testvfdswmr.sh.in index b0ab785..1e870de 100644 --- a/test/testvfdswmr.sh.in +++ b/test/testvfdswmr.sh.in @@ -1211,51 +1211,55 @@ done ############################################################################### # # -for options in "-p -e 20 -t -q" "-g -m 5 -n 2 -s 10 -w 7 -q" "-k -m 10 -n 5 -r 5 -l 10 -q"; do - # - # - if [ ${do_dsetops:-no} = no ]; then - continue - fi - # Clean up any existing fifo files from previous runs - if [ -e ./$DSETOPS_FIFO_WRITER_TO_READER ]; then # If writer fifo file is found - rm -f ./$DSETOPS_FIFO_WRITER_TO_READER - fi - if [ -e ./$DSETOPS_FIFO_READER_TO_WRITER ]; then # If reader fifo file is found - rm -f ./$DSETOPS_FIFO_READER_TO_WRITER - fi - # - echo launch vfd_swmr_dsetops_writer dsetops, options $options ......may take some time...... - catch_out_err_and_rc vfd_swmr_dsetops_writer \ - ../vfd_swmr_dsetops_writer $options & - pid_writer=$! - - catch_out_err_and_rc vfd_swmr_dsetops_reader \ - ../vfd_swmr_dsetops_reader $options & - pid_reader=$! - - # Wait for the reader to finish before signaling the - # writer to quit: the writer holds the file open so that the - # reader will find the shadow file when it opens - # the .h5 file. - wait $pid_reader - wait $pid_writer +# Loop with flushing of raw data and then without +for flush in "" "-U"; do + # Loop with different operations + for options in "-p -e 20 -t -q" "-g -m 5 -n 2 -s 10 -w 7 -q" "-k -m 10 -n 5 -r 5 -l 10 -q"; do + # + # + if [ ${do_dsetops:-no} = no ]; then + continue + fi + # Clean up any existing fifo files from previous runs + if [ -e ./$DSETOPS_FIFO_WRITER_TO_READER ]; then # If writer fifo file is found + rm -f ./$DSETOPS_FIFO_WRITER_TO_READER + fi + if [ -e ./$DSETOPS_FIFO_READER_TO_WRITER ]; then # If reader fifo file is found + rm -f ./$DSETOPS_FIFO_READER_TO_WRITER + fi + # + echo launch vfd_swmr_dsetops_writer dsetops, options $options $flush......may take some time...... + catch_out_err_and_rc vfd_swmr_dsetops_writer \ + ../vfd_swmr_dsetops_writer $options $flush & + pid_writer=$! + + catch_out_err_and_rc vfd_swmr_dsetops_reader \ + ../vfd_swmr_dsetops_reader $options $flush & + pid_reader=$! + + # Wait for the reader to finish before signaling the + # writer to quit: the writer holds the file open so that the + # reader will find the shadow file when it opens + # the .h5 file. + wait $pid_reader + wait $pid_writer + + # Collect exit code of the reader + if [ $(cat vfd_swmr_dsetops_reader.rc) -ne 0 ]; then + echo reader had error + nerrors=$((nerrors + 1)) + fi - # Collect exit code of the reader - if [ $(cat vfd_swmr_dsetops_reader.rc) -ne 0 ]; then - echo reader had error - nerrors=$((nerrors + 1)) - fi + # Collect exit code of the writer + if [ $(cat vfd_swmr_dsetops_writer.rc) -ne 0 ]; then + echo writer had error + nerrors=$((nerrors + 1)) + fi - # Collect exit code of the writer - if [ $(cat vfd_swmr_dsetops_writer.rc) -ne 0 ]; then - echo writer had error - nerrors=$((nerrors + 1)) - fi - - # Clean up output files - rm -f vfd_swmr_dsetops_writer.{out,rc} - rm -f vfd_swmr_dsetops_reader.*.{out,rc} + # Clean up output files + rm -f vfd_swmr_dsetops_writer.{out,rc} + rm -f vfd_swmr_dsetops_reader.*.{out,rc} + done done ############################################################################### @@ -1275,51 +1279,56 @@ dsetchks_list=( "-r -m 11 -n 5 -l 7 -q" "-f -x 5 -y 2 -q" ) -for options in "${dsetchks_list[@]}"; do - # - # - if [ ${do_dsetchks:-no} = no ]; then - continue - fi - # Clean up any existing fifo files from previous runs - if [ -e ./$DSETCHKS_FIFO_WRITER_TO_READER ]; then # If writer fifo file is found - rm -f ./$DSETCHKS_FIFO_WRITER_TO_READER - fi - if [ -e ./$DSETCHKS_FIFO_READER_TO_WRITER ]; then # If reader fifo file is found - rm -f ./$DSETCHKS_FIFO_READER_TO_WRITER - fi - # - echo launch vfd_swmr_dsetchks_writer dsetchks, options $options ......may take some time...... - catch_out_err_and_rc vfd_swmr_dsetchks_writer \ - ../vfd_swmr_dsetchks_writer $options & - pid_writer=$! - - catch_out_err_and_rc vfd_swmr_dsetchks_reader \ - ../vfd_swmr_dsetchks_reader $options & - pid_reader=$! - - # Wait for the reader to finish before signaling the - # writer to quit: the writer holds the file open so that the - # reader will find the shadow file when it opens - # the .h5 file. - wait $pid_reader - wait $pid_writer - - # Collect exit code of the reader - if [ $(cat vfd_swmr_dsetchks_reader.rc) -ne 0 ]; then - echo reader had error - nerrors=$((nerrors + 1)) - fi +# +# +# Loop with flushing of raw data and then without +for flush in "" "-U"; do + for options in "${dsetchks_list[@]}"; do + # + # + if [ ${do_dsetchks:-no} = no ]; then + continue + fi + # Clean up any existing fifo files from previous runs + if [ -e ./$DSETCHKS_FIFO_WRITER_TO_READER ]; then # If writer fifo file is found + rm -f ./$DSETCHKS_FIFO_WRITER_TO_READER + fi + if [ -e ./$DSETCHKS_FIFO_READER_TO_WRITER ]; then # If reader fifo file is found + rm -f ./$DSETCHKS_FIFO_READER_TO_WRITER + fi + # + echo launch vfd_swmr_dsetchks_writer dsetchks, options $options $flush ......may take some time...... + catch_out_err_and_rc vfd_swmr_dsetchks_writer \ + ../vfd_swmr_dsetchks_writer $options $flush & + pid_writer=$! + + catch_out_err_and_rc vfd_swmr_dsetchks_reader \ + ../vfd_swmr_dsetchks_reader $options $flush & + pid_reader=$! + + # Wait for the reader to finish before signaling the + # writer to quit: the writer holds the file open so that the + # reader will find the shadow file when it opens + # the .h5 file. + wait $pid_reader + wait $pid_writer + + # Collect exit code of the reader + if [ $(cat vfd_swmr_dsetchks_reader.rc) -ne 0 ]; then + echo reader had error + nerrors=$((nerrors + 1)) + fi - # Collect exit code of the writer - if [ $(cat vfd_swmr_dsetchks_writer.rc) -ne 0 ]; then - echo writer had error - nerrors=$((nerrors + 1)) - fi + # Collect exit code of the writer + if [ $(cat vfd_swmr_dsetchks_writer.rc) -ne 0 ]; then + echo writer had error + nerrors=$((nerrors + 1)) + fi - # Clean up output files - rm -f vfd_swmr_dsetchks_writer.{out,rc} - rm -f vfd_swmr_dsetchks_reader.*.{out,rc} + # Clean up output files + rm -f vfd_swmr_dsetchks_writer.{out,rc} + rm -f vfd_swmr_dsetchks_reader.*.{out,rc} + done done ############################################################################### diff --git a/test/vfd_swmr_addrem_writer.c b/test/vfd_swmr_addrem_writer.c index 7f13cec..f115d2e 100644 --- a/test/vfd_swmr_addrem_writer.c +++ b/test/vfd_swmr_addrem_writer.c @@ -95,7 +95,7 @@ open_skeleton(const char *filename, unsigned verbose) goto error; /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(config, 4, 5, TRUE, FALSE, 128, "./rw-shadow"); + init_vfd_swmr_config(config, 4, 5, TRUE, TRUE, 128, "./rw-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, 4096, config)) < 0) diff --git a/test/vfd_swmr_attrdset_writer.c b/test/vfd_swmr_attrdset_writer.c index 27a23e6..630b071 100644 --- a/test/vfd_swmr_attrdset_writer.c +++ b/test/vfd_swmr_attrdset_writer.c @@ -150,12 +150,16 @@ static bool open_dset_real(hid_t fid, hid_t *did, const char *name, unsigned *ma unsigned *min_dense); static bool close_dsets(const dsets_state_t *ds); +static bool perform_dsets_operations(state_t *s, dsets_state_t *ds, + H5F_vfd_swmr_config_t *config, np_state_t *np); static bool attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which); static bool attr_action(unsigned action, const state_t *s, hid_t did, unsigned which); static bool add_attr(const state_t *s, hid_t did, unsigned int which); static bool modify_attr(const state_t *s, hid_t did, unsigned int which); static bool delete_attr(hid_t did, unsigned int which); +static bool verify_dsets_operations(state_t *s, dsets_state_t *ds, + H5F_vfd_swmr_config_t *config, np_state_t *np); static bool verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which); static bool verify_attr_action(unsigned action, hid_t did, unsigned which); @@ -223,12 +227,20 @@ state_init(state_t *s, int argc, char **argv) unsigned long tmp; int ch; const hsize_t dims = 1; - char tfile[PATH_MAX]; + char *tfile = NULL; char * end; *s = ALL_HID_INITIALIZER; - esnprintf(tfile, sizeof(tfile), "%s", argv[0]); - esnprintf(s->progname, sizeof(s->progname), "%s", basename(tfile)); + + if (H5_basename(argv[0], &tfile) < 0) { + HDprintf("H5_basename failed\n"); + TEST_ERROR; + } + + esnprintf(s->progname, sizeof(s->progname), "%s", tfile); + + if (tfile) + HDfree(tfile); while ((ch = getopt(argc, argv, "pgkvmbqSNa:d:u:c:")) != -1) { switch (ch) { @@ -340,6 +352,9 @@ state_init(state_t *s, int argc, char **argv) return true; error: + if (tfile) + HDfree(tfile); + return false; } /* state_init() */ @@ -892,16 +907,90 @@ error: } /* close_dsets() */ /* - * Attribute handling by the writer + * Writer */ /* - * Perform the "action" for each of the datasets specified on the command line. + * Perform the attribute operations specified on the command line. * ADD_ATTR : -a option * MODIFY_ATTR : -m option * DELETE_ATTR : -d option */ static bool +perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np) +{ + unsigned step; + bool result; + unsigned dd; + bool ret = true; + + for (step = 0; step < s->asteps; step++) { + dbgf(2, "Adding attribute %d\n", step); + + result = attr_dsets_action(ADD_ATTR, s, ds, step); + + if (s->use_np && !np_writer(result, step, s, np, config)) { + printf("np_writer() for addition failed\n"); + TEST_ERROR; + } + } + + if (s->mod_attr) { + + /* Need to sync up writer/reader before moving onto the next phase */ + if (s->use_np && !np_writer(true, 0, s, np, config)) { + printf("np_writer() for modification failed\n"); + TEST_ERROR; + } + + /* Start modification */ + for (step = 0; step < s->asteps; step++) { + dbgf(2, "Modifying attribute %d\n", step); + + result = attr_dsets_action(MODIFY_ATTR, s, ds, step); + + if (s->use_np && !np_writer(result, step, s, np, config)) { + printf("np_writer() for modification failed\n"); + TEST_ERROR; + } + } + } + + if (s->dattrs) { + + /* Need to sync up writer/reader before moving onto the next phase */ + if (s->use_np && !np_writer(true, 0, s, np, config)) { + printf("np_writer() for deletion failed\n"); + TEST_ERROR; + } + + /* Start deletion */ + for (dd = 0, step = s->asteps - 1; dd < s->dattrs; dd++, --step) { + dbgf(2, "Deleting attribute %d\n", step); + + result = attr_dsets_action(DELETE_ATTR, s, ds, step); + + if (s->use_np && !np_writer(result, step, s, np, config)) { + printf("np_writer() for deletion failed\n"); + TEST_ERROR; + } + } + } + + return true; + +error: + return false; + +} /* perform_dsets_operations() */ + +/* + * Perform the "action" for each of the datasets specified on the command line. + * -p: compact dataset + * -g: contiguous dataset + * -k: 5 chunked datasets with 5 indexing types + */ +static bool attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which) { int nerrors = 0; @@ -1181,14 +1270,111 @@ error: */ /* - * Verify the action on each of the datasets specified: + * Verify the attribute operations specified on the command line: * ADD_ATTR : -a option * MODIFY_ATTR : -m option * DELETE_ATTR : -d option * * Also verify continuation block and compact<->dense storage if: * --[-c ] is 1 - * --not -m option + * --not appliable for -m option + */ +static bool +verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np) +{ + unsigned step; + bool result; + unsigned dd; + + /* Start verifying addition */ + for (step = 0; step < s->asteps; step++) { + dbgf(2, "Verifying...attribute %d\n", step); + + if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { + printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + TEST_ERROR; + } + + /* Wait for a few ticks for the update to happen */ + decisleep(config->tick_len * s->update_interval); + + result = verify_attr_dsets_action(ADD_ATTR, s, ds, step); + + if (s->use_np && !np_reader(result, step, s, np)) { + printf("np_reader() for verifying addition failed\n"); + TEST_ERROR; + } + } + + if (s->mod_attr) { + /* Need to sync up writer/reader before moving onto the next phase */ + if (!np_reader_no_verification(s, np, config)) { + printf("np_reader_no_verification() for verifying modification failed\n"); + TEST_ERROR; + } + + /* Start verifying modification */ + for (step = 0; step < s->asteps; step++) { + dbgf(2, "Verifying...modify attribute %d\n", step); + + if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { + printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + TEST_ERROR; + } + + /* Wait for a few ticks for the update to happen */ + decisleep(config->tick_len * s->update_interval); + + result = verify_attr_dsets_action(MODIFY_ATTR, s, ds, step); + + if (s->use_np && !np_reader(result, step, s, np)) { + printf("np_reader() for verifying modification failed\n"); + TEST_ERROR; + } + } + } + + if (s->dattrs) { + + /* Need to sync up writer/reader before moving onto the next phase */ + if (!np_reader_no_verification(s, np, config)) { + printf("np_reader_no_verification() for verifying modification failed\n"); + TEST_ERROR; + } + + /* Start verifying deletion */ + for (dd = 0, step = s->asteps - 1; dd < s->dattrs; dd++, --step) { + dbgf(2, "Verifying...delete attribute %d\n", step); + + if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { + printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + TEST_ERROR; + } + + /* Wait for a few ticks for the update to happen */ + decisleep(config->tick_len * s->update_interval); + + result = verify_attr_dsets_action(DELETE_ATTR, s, ds, step); + + if (s->use_np && !np_reader(result, step, s, np)) { + printf("np_reader() for verifying deletion failed\n"); + TEST_ERROR; + } + } + } + + return true; + +error: + + return false; +} /* verify_dsets_operations() */ + +/* + * Verify the "action" for each of the datasets specified on the command line. + * -p: compact dataset + * -g: contiguous dataset + * -k: 5 chunked datasets with 5 indexing types */ static bool verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which) @@ -1317,7 +1503,8 @@ static bool verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned int which) { unsigned int read_which; - char vl_which[sizeof("attr-9999999999")]; + unsigned int tmp_val; + char tmp_vl_val[sizeof("attr-9999999999")]; char * read_vl_which = NULL; bool is_vl = false; hid_t aid = H5I_INVALID_HID; @@ -1339,14 +1526,19 @@ verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned if ((is_vl = H5Tis_variable_str(atid))) { if (action == ADD_ATTR) - HDsprintf(vl_which, "%u", which); + HDsprintf(tmp_vl_val, "%u", which); else - HDsprintf(vl_which, "%u %c", which, 'M'); + HDsprintf(tmp_vl_val, "%u %c", which, 'M'); if ((read_vl_which = HDmalloc(sizeof("9999999999"))) == NULL) { HDprintf("HDmalloc failed\n"); TEST_ERROR; } + } else { + if (action == MODIFY_ATTR) + tmp_val = which + 1; + else + tmp_val = which; } if (H5Aread(aid, atid, is_vl ? (void *)&read_vl_which : (void *)&read_which) < 0) { @@ -1365,11 +1557,14 @@ verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned } if (is_vl) { - if (!HDstrcmp(vl_which, read_vl_which)) + dbgf(2, "read_vl_which = %s, tmp_vl_val= %s\n", read_vl_which, tmp_vl_val); + if (!HDstrcmp(read_vl_which, tmp_vl_val)) ret = true; } - else - ret = (read_which == which); + else { + dbgf(2, "read_which = %u, tmp_val = %u\n", read_which, tmp_val); + ret = (read_which == tmp_val); + } if (read_vl_which) HDfree(read_vl_which); @@ -1452,9 +1647,8 @@ verify_storage_cont(unsigned action, hid_t did, unsigned int which, unsigned max /* Verify dense storage & no cont */ else if (which == max_compact) ret = verify_storage_cont_real(did, which, max_compact); - - /* For deletion */ } + /* For deletion */ else if (action == DELETE_ATTR) { /* Verify compact storage & cont */ @@ -1792,7 +1986,7 @@ main(int argc, char **argv) } /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(&config, 4, 7, writer, FALSE, 128, "./attrdset-shadow"); + init_vfd_swmr_config(&config, 4, 7, writer, true, 128, "./attrdset-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(true, s.use_vfd_swmr, true, 4096, &config)) < 0) { @@ -1835,137 +2029,18 @@ main(int argc, char **argv) } if (writer) { - for (step = 0; step < s.asteps; step++) { - dbgf(2, "Adding attribute %d\n", step); - - result = attr_dsets_action(ADD_ATTR, &s, &ds, step); - - if (s.use_np && !np_writer(result, step, &s, &np, &config)) { - HDprintf("np_writer() for addition failed\n"); - TEST_ERROR; - } - } - - if (s.mod_attr) { - - /* Need to sync up writer/reader before moving onto the next phase */ - if (s.use_np && !np_writer(true, 0, &s, &np, &config)) { - HDprintf("np_writer() for modification failed\n"); - TEST_ERROR; - } - - /* Start modification */ - for (step = 0; step < s.asteps; step++) { - dbgf(2, "Modifying attribute %d\n", step); - - result = attr_dsets_action(MODIFY_ATTR, &s, &ds, step); - - if (s.use_np && !np_writer(result, step, &s, &np, &config)) { - HDprintf("np_writer() for modification failed\n"); - TEST_ERROR; - } - } + if(!perform_dsets_operations(&s, &ds, &config, &np)) { + printf("perform_dsets_operations() failed\n"); + TEST_ERROR; } - if (s.dattrs) { - - /* Need to sync up writer/reader before moving onto the next phase */ - if (s.use_np && !np_writer(true, 0, &s, &np, &config)) { - HDprintf("np_writer() for deletion failed\n"); - TEST_ERROR; - } - - /* Start deletion */ - for (dd = 0, step = s.asteps - 1; dd < s.dattrs; dd++, --step) { - dbgf(2, "Deleting attribute %d\n", step); - - result = attr_dsets_action(DELETE_ATTR, &s, &ds, step); - - if (s.use_np && !np_writer(result, step, &s, &np, &config)) { - HDprintf("np_writer() for deletion failed\n"); - TEST_ERROR; - } - } - } } else { - - /* Start verifying addition */ - for (step = 0; step < s.asteps; step++) { - dbgf(2, "Verifying...attribute %d\n", step); - - if (s.use_np && !np_confirm_verify_notify(np.fd_writer_to_reader, step, &s, &np)) { - HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); - TEST_ERROR; - } - - /* Wait for a few ticks for the update to happen */ - decisleep(config.tick_len * s.update_interval); - - result = verify_attr_dsets_action(ADD_ATTR, &s, &ds, step); - - if (s.use_np && !np_reader(result, step, &s, &np)) { - HDprintf("np_reader() for verifying addition failed\n"); - TEST_ERROR; - } - } - - if (s.mod_attr) { - /* Need to sync up writer/reader before moving onto the next phase */ - if (!np_reader_no_verification(&s, &np, &config)) { - HDprintf("np_reader_no_verification() for verifying modification failed\n"); - TEST_ERROR; - } - - /* Start verifying modification */ - for (step = 0; step < s.asteps; step++) { - dbgf(2, "Verifying...modify attribute %d\n", step); - - if (s.use_np && !np_confirm_verify_notify(np.fd_writer_to_reader, step, &s, &np)) { - HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); - TEST_ERROR; - } - - /* Wait for a few ticks for the update to happen */ - decisleep(config.tick_len * s.update_interval); - - result = verify_attr_dsets_action(MODIFY_ATTR, &s, &ds, step); - - if (s.use_np && !np_reader(result, step, &s, &np)) { - HDprintf("np_reader() for verifying modification failed\n"); - TEST_ERROR; - } - } + if(!verify_dsets_operations(&s, &ds, &config, &np)) { + printf("verify_dsets_operations() failed\n"); + TEST_ERROR; } - if (s.dattrs) { - - /* Need to sync up writer/reader before moving onto the next phase */ - if (!np_reader_no_verification(&s, &np, &config)) { - HDprintf("np_reader_no_verification() for verifying modification failed\n"); - TEST_ERROR; - } - - /* Start verifying deletion */ - for (dd = 0, step = s.asteps - 1; dd < s.dattrs; dd++, --step) { - dbgf(2, "Verifying...delete attribute %d\n", step); - - if (s.use_np && !np_confirm_verify_notify(np.fd_writer_to_reader, step, &s, &np)) { - HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); - TEST_ERROR; - } - - /* Wait for a few ticks for the update to happen */ - decisleep(config.tick_len * s.update_interval); - - result = verify_attr_dsets_action(DELETE_ATTR, &s, &ds, step); - - if (s.use_np && !np_reader(result, step, &s, &np)) { - HDprintf("np_reader() for verifying deletion failed\n"); - TEST_ERROR; - } - } - } } if (!close_dsets(&ds)) { diff --git a/test/vfd_swmr_bigset_writer.c b/test/vfd_swmr_bigset_writer.c index e6fd0a8..d3a9ce8 100644 --- a/test/vfd_swmr_bigset_writer.c +++ b/test/vfd_swmr_bigset_writer.c @@ -1094,7 +1094,7 @@ main(int argc, char **argv) } /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(&config, 4, 7, s.writer, FALSE, 128, "./bigset-shadow-%zu", i); + init_vfd_swmr_config(&config, 4, 7, s.writer, TRUE, 128, "./bigset-shadow-%zu", i); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ fapl = vfd_swmr_create_fapl(true, s.use_vfd_swmr, true, 4096, &config); diff --git a/test/vfd_swmr_dsetchks_writer.c b/test/vfd_swmr_dsetchks_writer.c index a02a042..1496fcd 100644 --- a/test/vfd_swmr_dsetchks_writer.c +++ b/test/vfd_swmr_dsetchks_writer.c @@ -74,6 +74,7 @@ typedef struct { bool use_np; /* For -N option */ bool use_vfd_swmr; /* For -S option */ bool use_filter; /* For -o option */ + bool flush_raw_data; /* For -U option */ bool single_index; /* -s option: create a chunked dataset with single chunk index */ bool implicit_index; /* -i option: create a chunked datasets with implicit chunk index */ @@ -99,9 +100,9 @@ typedef struct { { \ .filename = "", .file = H5I_INVALID_HID, .filetype = H5T_NATIVE_UINT32, \ .update_interval = READER_WAIT_TICKS, .csteps = 1, .use_np = true, .use_vfd_swmr = true, \ - .use_filter = false, .single_index = false, .implicit_index = false, .fa_index = false, \ - .ea_index = false, .bt2_index = false, .rows = 10, .cols = 5, .gwrites = 0, .pwrites = 0, \ - .twrites = 0, .lwrites = 0, .xincrs = 0, .ydecrs = 0 \ + .use_filter = false, .flush_raw_data = true, .single_index = false, .implicit_index = false, \ + .fa_index = false, .ea_index = false, .bt2_index = false, .rows = 10, .cols = 5, .gwrites = 0, \ + .pwrites = 0, .twrites = 0, .lwrites = 0, .xincrs = 0, .ydecrs = 0 \ } /* Structure to hold info for different dataset types */ @@ -166,7 +167,7 @@ static void setup_selection(unsigned action, unsigned which, const state_t *s, c static void check_set_edge_block(const state_t *s, const dsets_state_t *ds, unsigned i, unsigned j, hsize_t *block); static void check_set_partial_block(unsigned action, const hsize_t *dims, hsize_t *block, hsize_t *start); -static bool write_dset(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *stride, hsize_t *count, +static bool write_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *stride, hsize_t *count, hsize_t *block); static bool write_dset_single(unsigned action, const state_t *s, const dsets_state_t *ds); @@ -174,12 +175,12 @@ static bool dsets_extent(unsigned action, const state_t *s, const dsets_state_t static bool dset_extent_real(unsigned action, hid_t did, const hsize_t *chunk_dims); static bool verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, - np_state_t *np); + np_state_t *np, bool fileclosed); -static bool verify_dsets_chunks(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which); -static bool verify_read_dset(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *stride, - hsize_t *count, hsize_t *block); -static bool verify_read_dset_single(unsigned action, const state_t *s, const dsets_state_t *ds); +static bool verify_dsets_chunks(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which, bool fileclosed); +static bool verify_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *stride, + hsize_t *count, hsize_t *block, bool fileclosed, bool flush_raw_data); +static bool verify_dset_single(unsigned action, const state_t *s, const dsets_state_t *ds, bool fileclosed); static bool verify_dsets_extent(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which); static bool verify_dset_extent_real(unsigned action, hid_t did, unsigned rows, unsigned cols, unsigned which); @@ -195,7 +196,7 @@ usage(const char *progname) " [-m rows] [-n cols]\n" " [-g gwrites] [-p pwrites] [-t twrites] [-l lwrites]\n" " [-x xincrs] [-y decrs]\n" - " [-u nticks] [-c csteps] [-S] [-N] [-q] [-b] [-o]\n", + " [-u nticks] [-c csteps] [-U] [-S] [-N] [-q] [-b] [-o]\n", progname); fprintf( @@ -218,6 +219,7 @@ usage(const char *progname) " (default is 4)\n" "-c csteps: `csteps` steps communication interval between reader and writer\n" " (default is 1)\n" + "-U: disable flush of raw data (default is flushing raw data)\n" "-S: do not use VFD SWMR\n" "-N: do not use named pipes for test synchronization\n" "-q: silence printouts, few messages\n" @@ -263,18 +265,22 @@ state_init(state_t *s, int argc, char **argv) { unsigned long tmp; int ch; - char tfile[PATH_MAX]; + char *tfile = NULL; char * end; - char * base; - if (H5_basename(tfile, base) < 0) + *s = ALL_HID_INITIALIZER; + + if (H5_basename(argv[0], &tfile) < 0) { + HDprintf("H5_basename failed\n"); TEST_ERROR + } - *s = ALL_HID_INITIALIZER; - esnprintf(tfile, sizeof(tfile), "%s", argv[0]); - esnprintf(s->progname, sizeof(s->progname), "%s", base); + esnprintf(s->progname, sizeof(s->progname), "%s", tfile); - while ((ch = getopt(argc, argv, "siferom:n:x:y:g:p:t:l:bqSNu:c:")) != -1) { + if (tfile) + HDfree(tfile); + + while ((ch = getopt(argc, argv, "siferom:n:x:y:g:p:t:l:bqSNUu:c:")) != -1) { switch (ch) { case 's': /* A chunked dataset with single index */ @@ -313,6 +319,10 @@ state_init(state_t *s, int argc, char **argv) s->use_vfd_swmr = false; break; + case 'U': /* Disable flush of raw data */ + s->flush_raw_data = false; + break; + case 'N': /* Disable named pipes synchronization */ s->use_np = false; break; @@ -374,8 +384,6 @@ state_init(state_t *s, int argc, char **argv) argc -= optind; argv += optind; - HDfree(base); - /* Require to specify at least -s or -i or -f or -e or -r option */ if (!s->single_index && !s->implicit_index && !s->fa_index && !s->ea_index && !s->bt2_index) { printf("Require to specify at least -s or -i or -f or -e or -r option\n"); @@ -444,6 +452,8 @@ state_init(state_t *s, int argc, char **argv) return true; error: + if (tfile) + HDfree(tfile); return false; } /* state_init() */ @@ -1010,28 +1020,28 @@ write_dsets_chunks(unsigned action, const state_t *s, const dsets_state_t *ds, u setup_selection(action, which, s, ds, start, stride, count, block); if (s->implicit_index) { - if (!write_dset(action, ds->implicit_did, s->filetype, start, stride, count, block)) { + if (!write_chunks(action, ds->implicit_did, s->filetype, start, stride, count, block)) { printf("H5Dwrite to chunked dataset: implicit index dataset failed\n"); TEST_ERROR; } } if (s->fa_index) { - if (!write_dset(action, ds->fa_did, s->filetype, start, stride, count, block)) { + if (!write_chunks(action, ds->fa_did, s->filetype, start, stride, count, block)) { printf("H5Dwrite to chunked dataset: fa index dataset failed\n"); TEST_ERROR; } } if (s->ea_index) { - if (!write_dset(action, ds->ea_did, s->filetype, start, stride, count, block)) { + if (!write_chunks(action, ds->ea_did, s->filetype, start, stride, count, block)) { printf("H5Dwrite to chunked dataset: ea index dataset failed\n"); TEST_ERROR; } } if (s->bt2_index) { - if (!write_dset(action, ds->bt2_did, s->filetype, start, stride, count, block)) { + if (!write_chunks(action, ds->bt2_did, s->filetype, start, stride, count, block)) { printf("H5Dwrite to chunked dataset: bt2 index dataset failed\n"); TEST_ERROR; } @@ -1169,7 +1179,7 @@ check_set_partial_block(unsigned action, const hsize_t *chunk_dims, hsize_t *blo * Make the selection and then write to the dataset. */ static bool -write_dset(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *stride, hsize_t *count, +write_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *stride, hsize_t *count, hsize_t *block) { hid_t sid = badhid; @@ -1238,7 +1248,7 @@ error: return false; -} /* write_dset() */ +} /* write_chunks() */ /* * Increase or decrease the dimenion sizes for the specified datasets. @@ -1370,7 +1380,7 @@ write_dset_single(unsigned action, const state_t *s, const dsets_state_t *ds) if (action == PWRITES || action == LWRITES) check_set_partial_block(action, block, block, start); - if (!write_dset(action, ds->single_did, s->filetype, start, stride, count, block)) { + if (!write_chunks(action, ds->single_did, s->filetype, start, stride, count, block)) { printf("H5Dwrite to dataset with single index dataset failed\n"); TEST_ERROR; } @@ -1403,7 +1413,7 @@ error: * --DECR_EXT: verify the decrease to dataset dimensions sizes */ static bool -verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np) +verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np, bool fileclosed) { unsigned step; unsigned allowed_writes; @@ -1423,14 +1433,16 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co } /* Wait for a few ticks for the update to happen */ - decisleep(config->tick_len * s->update_interval); + if (!fileclosed) + decisleep(config->tick_len * s->update_interval); - result = verify_read_dset_single(GWRITES, s, ds); + result = verify_dset_single(GWRITES, s, ds, fileclosed); if (s->use_np && !np_reader(result, 0, s, np)) { printf("np_reader() for verifying addition failed\n"); TEST_ERROR; - } + } else if (!result) + TEST_ERROR; } /* Verify a single partial chunk write to dataset with single index */ @@ -1439,19 +1451,22 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co if (s->pwrites || s->lwrites) { dbgf(2, "Verify single partial chunk write to dataset with single index; only verify 1 write\n"); - if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, 0, s, np)) { + if(s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, 0, s, np)) { printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } + /* Wait for a few ticks for the update to happen */ - decisleep(config->tick_len * s->update_interval); + if (!fileclosed) + decisleep(config->tick_len * s->update_interval); - result = verify_read_dset_single(PWRITES, s, ds); + result = verify_dset_single(PWRITES, s, ds, fileclosed); if (s->use_np && !np_reader(result, 0, s, np)) { printf("np_reader() for verifying addition failed\n"); TEST_ERROR; - } + } if (!result) + TEST_ERROR; } } @@ -1471,15 +1486,18 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } + /* Wait for a few ticks for the update to happen */ - decisleep(config->tick_len * s->update_interval); + if(!fileclosed) + decisleep(config->tick_len * s->update_interval); - result = verify_dsets_chunks(GWRITES, s, ds, step); + result = verify_dsets_chunks(GWRITES, s, ds, step, fileclosed); if (s->use_np && !np_reader(result, step, s, np)) { printf("np_reader() for verification failed\n"); TEST_ERROR; - } + } else if (!result) + TEST_ERROR; } } @@ -1496,15 +1514,18 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } + /* Wait for a few ticks for the update to happen */ - decisleep(config->tick_len * s->update_interval); + if(!fileclosed) + decisleep(config->tick_len * s->update_interval); - result = verify_dsets_chunks(PWRITES, s, ds, step); + result = verify_dsets_chunks(PWRITES, s, ds, step, fileclosed); if (s->use_np && !np_reader(result, step, s, np)) { printf("np_reader() for verification failed\n"); TEST_ERROR; - } + } else if (!result) + TEST_ERROR; } } @@ -1521,15 +1542,18 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } + /* Wait for a few ticks for the update to happen */ - decisleep(config->tick_len * s->update_interval); + if(!fileclosed) + decisleep(config->tick_len * s->update_interval); - result = verify_dsets_chunks(TWRITES, s, ds, step); + result = verify_dsets_chunks(TWRITES, s, ds, step, fileclosed); if (s->use_np && !np_reader(result, step, s, np)) { printf("np_reader() for verification failed\n"); TEST_ERROR; - } + } else if (!result) + TEST_ERROR; } } @@ -1547,15 +1571,18 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } + /* Wait for a few ticks for the update to happen */ - decisleep(config->tick_len * s->update_interval); + if(!fileclosed) + decisleep(config->tick_len * s->update_interval); - result = verify_dsets_chunks(LWRITES, s, ds, step); + result = verify_dsets_chunks(LWRITES, s, ds, step, fileclosed); if (s->use_np && !np_reader(result, step, s, np)) { printf("np_reader() for verification failed\n"); TEST_ERROR; - } + } else if (!result) + TEST_ERROR; } } @@ -1569,6 +1596,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } + /* Wait for a few ticks for the update to happen */ decisleep(config->tick_len * s->update_interval); @@ -1577,7 +1605,8 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co if (s->use_np && !np_reader(result, step, s, np)) { printf("np_reader() for failed\n"); TEST_ERROR; - } + } else if (!result) + TEST_ERROR; } } @@ -1596,10 +1625,11 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_dsets_extent(DECR_EXT, s, ds, step + 1); - if (s->use_np && !np_reader(result, step, s, np)) { + if (s->use_np && !np_reader(result, step, s, np)) { printf("np_reader() for verification failed\n"); TEST_ERROR; - } + } else if (!result) + TEST_ERROR; } } } @@ -1620,7 +1650,7 @@ error: * LWRITEs: verify `which` write that covers multiple partial chunks */ static bool -verify_dsets_chunks(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which) +verify_dsets_chunks(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which, bool fileclosed) { hsize_t start[2] = {0, 0}; hsize_t stride[2] = {0, 0}; @@ -1633,29 +1663,29 @@ verify_dsets_chunks(unsigned action, const state_t *s, const dsets_state_t *ds, setup_selection(action, which, s, ds, start, stride, count, block); if (s->implicit_index) { - if (!verify_read_dset(action, ds->implicit_did, s->filetype, start, stride, count, block)) { - printf("verify_read_dset() to dataset with implicit index failed\n"); + if (!verify_chunks(action, ds->implicit_did, s->filetype, start, stride, count, block, fileclosed, s->flush_raw_data)) { + printf("verify_chunks() to dataset with implicit index failed\n"); TEST_ERROR; } } if (s->fa_index) { - if (!verify_read_dset(action, ds->fa_did, s->filetype, start, stride, count, block)) { - printf("verify_read_dset() to dataset with fixed array index failed\n"); + if (!verify_chunks(action, ds->fa_did, s->filetype, start, stride, count, block, fileclosed, s->flush_raw_data)) { + printf("verify_chunks() to dataset with fixed array index failed\n"); TEST_ERROR; } } if (s->ea_index) { - if (!verify_read_dset(action, ds->ea_did, s->filetype, start, stride, count, block)) { - printf("verify_read_dset() to dataset with extensible array index failed\n"); + if (!verify_chunks(action, ds->ea_did, s->filetype, start, stride, count, block, fileclosed, s->flush_raw_data)) { + printf("verify_chunks() to dataset with extensible array index failed\n"); TEST_ERROR; } } if (s->bt2_index) { - if (!verify_read_dset(action, ds->bt2_did, s->filetype, start, stride, count, block)) { - printf("verify_read_dset() to dataset with bt2 index failed\n"); + if (!verify_chunks(action, ds->bt2_did, s->filetype, start, stride, count, block, fileclosed, s->flush_raw_data)) { + printf("verify_chunks() to dataset with bt2 index failed\n"); TEST_ERROR; } } @@ -1672,8 +1702,8 @@ error: * Verify the data read from the dataset is as expected. */ static bool -verify_read_dset(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *stride, hsize_t *count, - hsize_t *block) +verify_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *stride, hsize_t *count, + hsize_t *block, bool fileclosed, bool flush_raw_data) { hid_t mem_sid = badhid; hid_t sid = badhid; @@ -1719,17 +1749,32 @@ verify_read_dset(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t /* Verify the data read in `rbuf` is as the fill value expected */ for (i = 0; i < block[0] * block[1]; i++) { - if (action == GWRITES || action == TWRITES) { - if (rbuf[i] != FILL_FULL) { - printf("Invalid value for dataset for GWRITES/TWRITES\n"); - TEST_ERROR; + if(flush_raw_data || fileclosed) { + if (action == GWRITES || action == TWRITES) { + if (rbuf[i] != FILL_FULL) { + printf("Invalid value for dataset for GWRITES/TWRITES: %d\n", rbuf[i]); + TEST_ERROR; + } } - } - else { - HDassert(action == PWRITES || action == LWRITES); - if (rbuf[i] != FILL_PARTIAL) { - printf("Invalid value for dataset for GWRITES/TWRITES\n"); - TEST_ERROR; + else { + HDassert(action == PWRITES || action == LWRITES); + if (rbuf[i] != FILL_PARTIAL) { + printf("Invalid value for dataset for GWRITES/TWRITES: %d\n", rbuf[i]); + TEST_ERROR; + } + } + } else { /* No flush && not closing file */ + if (action == GWRITES || action == TWRITES) { + if (rbuf[i] != FILL_FULL && rbuf[i] != FILL_INIT) { + printf("Invalid value for dataset for GWRITES/TWRITES\n"); + TEST_ERROR; + } + } + else { + if (rbuf[i] != FILL_PARTIAL && rbuf[i] != FILL_INIT) { + printf("Invalid value for dataset for GWRITES/TWRITES\n"); + TEST_ERROR; + } } } } @@ -1762,7 +1807,7 @@ error: return false; -} /* verify_read_dset() */ +} /* verify_chunks() */ /* * Verify the increase or decrease of dimenion sizes for the specified datasets. @@ -1877,7 +1922,7 @@ error: * Verify that the data read from the dataset with single index is as unexpected. */ static bool -verify_read_dset_single(unsigned action, const state_t *s, const dsets_state_t *ds) +verify_dset_single(unsigned action, const state_t *s, const dsets_state_t *ds, bool fileclosed) { hsize_t block[2] = {s->rows, s->cols}; hsize_t count[2] = {1, 1}; @@ -1890,7 +1935,7 @@ verify_read_dset_single(unsigned action, const state_t *s, const dsets_state_t * if (action == PWRITES) check_set_partial_block(action, block, block, start); - if (!verify_read_dset(action, ds->single_did, s->filetype, start, stride, count, block)) { + if (!verify_chunks(action, ds->single_did, s->filetype, start, stride, count, block, fileclosed, s->flush_raw_data)) { printf("verify_read_dset() to dataset with single index failed\n"); TEST_ERROR; } @@ -1900,7 +1945,7 @@ verify_read_dset_single(unsigned action, const state_t *s, const dsets_state_t * error: return false; -} /* verify_read_dset_single() */ +} /* verify_dset_single() */ /* * Named pipes handling @@ -2126,6 +2171,90 @@ error: } /* np_confirm_verify_notify() */ /* + * When flush of raw data is disabled, the following is done by the writer and reader: + * Writer: + * Close the file + * Notify the reader that the file is closed + * Reader: + * Confirm the message from the writer that the file is closed + * Verify the data + */ +static bool +closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np) +{ + HDassert(s->use_np); + + if(writer) { + if (!close_dsets(ds)) { + printf("close_dsets() failed\n"); + TEST_ERROR; + } + + dbgf(2, "Writer closes the file (flush of raw data is disabled)\n"); + if (H5Fclose(s->file) < 0) { + printf("H5Fclose failed\n"); + TEST_ERROR; + } + + /* Bump up the value of notify to tell the reader the file is closed */ + dbgf(2, "Writer notifies reader that the file is closed (flush of raw data is disabled)\n"); + np->notify++; + if (HDwrite(np->fd_writer_to_reader, &np->notify, sizeof(int)) < 0) { + printf("HDwrite failed\n"); + TEST_ERROR; + } + + if (!np_close(np, writer)) { + printf("np_close() failed\n"); + TEST_ERROR; + } + + } else { + /* Wait for a few ticks for the file to close in writer */ + decisleep(config->tick_len * s->update_interval); + + dbgf(2, "Reader checks notify value from writer (flush of raw data is disabled)\n"); + if (!np_confirm_verify_notify(np->fd_writer_to_reader, 0, s, np)) { + printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + TEST_ERROR; + } + + /* Close the named pipes */ + if (!np_close(np, writer)) { + printf("np_close() failed\n"); + TEST_ERROR; + } + + /* Turn off named pipes */ + s->use_np = false; + + /* Verify the dataset again without named pipes */ + dbgf(2, "Reader verifies data after writer closes the file (flush of raw data is disabled)\n"); + if(!verify_dsets_operations(s, ds, config, np, true)) { + printf("verify_dsets_operations() failed\n"); + TEST_ERROR + } + + if (!close_dsets(ds)) { + printf("close_dsets() failed\n"); + TEST_ERROR; + } + + dbgf(2, "Reader closes the file (flush of raw data is disabled)\n"); + if (H5Fclose(s->file) < 0) { + printf("H5Fclose failed\n"); + TEST_ERROR; + } + + } + + return true; + +error: + return false; + +} /* closing_on_noflush() */ +/* * Main */ int @@ -2156,7 +2285,7 @@ main(int argc, char **argv) } /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(&config, 4, 7, writer, FALSE, 128, "./dsetchks-shadow"); + init_vfd_swmr_config(&config, 4, 7, writer, s.flush_raw_data, 128, "./dsetchks-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(true, s.use_vfd_swmr, true, 4096, &config)) < 0) { @@ -2207,17 +2336,12 @@ main(int argc, char **argv) } else { - if (!verify_dsets_operations(&s, &ds, &config, &np)) { + if (!verify_dsets_operations(&s, &ds, &config, &np, false)) { printf("perform_dsets_operations() failed\n"); TEST_ERROR; } } - if (!close_dsets(&ds)) { - printf("close_dsets() failed\n"); - TEST_ERROR; - } - if (H5Pclose(fapl) < 0) { printf("H5Pclose failed\n"); TEST_ERROR; @@ -2228,14 +2352,31 @@ main(int argc, char **argv) TEST_ERROR; } - if (H5Fclose(s.file) < 0) { - printf("H5Fclose failed\n"); - TEST_ERROR; - } + /* When flush of raw data is disabled, special handling is performed + * via closing_on_noflush() when closing the file. + * Nothing needs to be done for -x or -y options + * (increase and decrease dataset dimension sizes). + */ + if(!s.flush_raw_data && !s.xincrs && !s.ydecrs && s.use_np) { - if (s.use_np && !np_close(&np, writer)) { - printf("np_close() failed\n"); - TEST_ERROR; + if(!closing_on_noflush(writer, &s, &ds, &config, &np)) + TEST_ERROR + } else { + + if (!close_dsets(&ds)) { + printf("close_dsets() failed\n"); + TEST_ERROR; + } + + if (H5Fclose(s.file) < 0) { + printf("H5Fclose failed\n"); + TEST_ERROR; + } + + if (s.use_np && !np_close(&np, writer)) { + printf("np_close() failed\n"); + TEST_ERROR; + } } return EXIT_SUCCESS; diff --git a/test/vfd_swmr_dsetops_writer.c b/test/vfd_swmr_dsetops_writer.c index 26f8977..9aded9b 100644 --- a/test/vfd_swmr_dsetops_writer.c +++ b/test/vfd_swmr_dsetops_writer.c @@ -46,8 +46,9 @@ typedef struct { unsigned int csteps; /* For -c option */ bool use_np; /* For -N option */ bool use_vfd_swmr; /* For -S option */ + bool flush_raw_data; /* For -U option */ bool compact; /* -p option: create compact dataset */ - bool compact_write; /* -o option: write to the whole compact dataset */ + bool compact_write; /* -t option: write to the whole compact dataset */ unsigned int compact_elmts; /* -e option: # of elments for the compact dataset */ bool contig; /* -g option: create contiguous dataset */ bool chunked; /* -k option: create chunked datasets with 5 indexing types */ @@ -57,6 +58,7 @@ typedef struct { unsigned int rwrites; /* -r option: random writes to contiguous and/or chunked datasets */ unsigned int lwrites; /* -l option: hyperslab writes to contiguous and/or chunked datasets */ unsigned int wwrites; /* -w option: modify raw data to contiguous and/or chunked datasets */ + unsigned int lastwrite; /* The last operation (-s, -r, -l or -w) performed. */ } state_t; /* Initializations for state_t */ @@ -65,8 +67,9 @@ typedef struct { { \ .filename = "", .file = H5I_INVALID_HID, .filetype = H5T_NATIVE_UINT32, \ .update_interval = READER_WAIT_TICKS, .csteps = 1, .use_np = true, .use_vfd_swmr = true, \ - .compact = false, .compact_write = false, .compact_elmts = MAX_COMPACT_ELMS, .contig = false, \ - .rows = 256, .cols = 512, .swrites = 0, .rwrites = 0, .lwrites = 0, .wwrites = 0 \ + .flush_raw_data = true, .compact = false, .compact_write = false, \ + .compact_elmts = MAX_COMPACT_ELMS, .contig = false, .rows = 10, .cols = 5, .swrites = 0, \ + .rwrites = 0, .lwrites = 0, .wwrites = 0, .lastwrite = 0 \ } /* Structure to hold info for different dataset types */ @@ -132,8 +135,7 @@ static bool open_dset_real(const state_t *s, hid_t *did, hid_t *sid, const char static bool close_dsets(const dsets_state_t *ds); static bool close_dset_real(hid_t did, hid_t sid); -static bool write_dset_contig_chunked(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, - np_state_t *np); +static bool perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np); static bool dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned step); static bool dset_setup(unsigned action, unsigned which, const state_t *s, hsize_t *start, hsize_t *stride, hsize_t *count, hsize_t *block, hid_t *mem_sid, unsigned int **buf); @@ -141,12 +143,15 @@ static bool write_dset(hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hsiz hsize_t *count, hsize_t *block, unsigned int *buf); static bool write_dset_compact(const state_t *s, const dsets_state_t *ds); -static bool verify_write_dset_contig_chunked(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, - np_state_t *np); -static bool verify_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which); -static bool verify_read_dset(hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hsize_t *start, - hsize_t *stride, hsize_t *count, hsize_t *block, unsigned int *vbuf); -static bool verify_read_dset_compact(const state_t *s, const dsets_state_t *ds); +static bool verify_dsets_operations(state_t *s, dsets_state_t *ds, + H5F_vfd_swmr_config_t *config, np_state_t *np, bool fileclosed); +static bool verify_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, + unsigned which, bool fileclosed); +static bool verify_dset(hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hsize_t *start, hsize_t *stride, + size_t *count, hsize_t *block, unsigned int *vbuf, bool fileclosed, bool flush_raw_data); +static bool verify_dset_compact(const state_t *s, const dsets_state_t *ds, bool fileclosed, bool flush_raw_data); + +static bool closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np); static const hid_t badhid = H5I_INVALID_HID; @@ -174,7 +179,7 @@ usage(const char *progname) " [-p] [-e elmts] [-o]\n" " [-g] [-k] [-m rows] [-n cols]\n" " [-s swrites] [-r rwrites] [-l lwrites] [-w writes]\n" - " [-u nticks] [-c csteps] [-S] [-N] [-q] [-b]\n" + " [-u nticks] [-c csteps] [-U] [-S] [-N] [-q] [-b]\n" "\n" "-p: create a dataset with compact layout\n" "-e elmts: # of for the compact dataset\n" @@ -193,6 +198,7 @@ usage(const char *progname) " (default is 4)\n" "-c csteps: `csteps` steps communication interval between reader and writer\n" " (default is 1)\n" + "-U: disable flush of raw data (default is flushing raw data)\n" "-S: do not use VFD SWMR\n" "-N: do not use named pipes for test synchronization\n" "-q: silence printouts, few messages\n" @@ -215,7 +221,7 @@ state_init(state_t *s, int argc, char **argv) { unsigned long tmp; int ch; - char * tfile; + char * tfile = NULL; char * end; *s = ALL_HID_INITIALIZER; @@ -227,7 +233,10 @@ state_init(state_t *s, int argc, char **argv) esnprintf(s->progname, sizeof(s->progname), "%s", tfile); - while ((ch = getopt(argc, argv, "pte:gkm:n:s:r:l:w:bqSNu:c:")) != -1) { + if (tfile) + HDfree(tfile); + + while ((ch = getopt(argc, argv, "pte:gkm:n:s:r:l:w:bqSNUu:c:")) != -1) { switch (ch) { case 'p': /* compact dataset */ @@ -246,6 +255,10 @@ state_init(state_t *s, int argc, char **argv) s->chunked = true; break; + case 'U': /* Disable flush of raw data */ + s->flush_raw_data = false; + break; + case 'q': verbosity = 0; break; @@ -329,6 +342,20 @@ state_init(state_t *s, int argc, char **argv) TEST_ERROR; } + /* Enable compact write (-t) without compact dataset (-p) */ + if (s->compact_write && !s->compact) { + printf("Enable compact write without compact dataset\n"); + usage(s->progname); + goto error; + } + + /* Enable sequential/random/hyperslab/raw data writes (-s/-r/-l/-w) without contiguous/chunked dataset (-g/-k) */ + if ((s->swrites || s->rwrites || s->lwrites || s->wwrites) && !(s->contig || s->chunked)) { + printf("Enable sequential/random/hypuerslab/raw data writes without contiguous/chunked dataset\n"); + usage(s->progname); + goto error; + } + /* -c cannot be zero */ if (!s->csteps) { HDprintf("communication interval cannot be zero\n"); @@ -365,6 +392,9 @@ state_init(state_t *s, int argc, char **argv) return true; error: + if (tfile) + HDfree(tfile); + return false; } /* state_init() */ @@ -818,6 +848,8 @@ error: */ /* + * Write to whole compact dataset + * * Perform writes for contiguous and chunked datasets: * --SEQ_WRITE: sequential writes * --RANDOM_WRITE: random writes @@ -825,86 +857,105 @@ error: * --MODIFY_DATA: raw data modifications */ static bool -write_dset_contig_chunked(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np) +perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np) { unsigned step; bool result; + + /* Perform writes to the whole compact dataset */ + if (s->compact) { - HDassert(s->contig || s->chunked); - - /* Perform sequential writes for contiguous and/or chunked datasets */ - if (s->swrites) { - - for (step = 0; (step < s->swrites && step < (s->rows * s->cols)); step++) { - dbgf(2, "Sequential writes %u to dataset\n", step); + if(s->compact_write) { + dbgf(2, "Writes all to compact dataset\n"); - result = dsets_action(SEQ_WRITE, s, ds, step); + result = write_dset_compact(s, ds); - if (s->use_np && !np_writer(result, step, s, np, config)) { - HDprintf("np_writer() for sequential writes failed\n"); + if (s->use_np && !np_writer(result, 0, s, np, config)) { + printf("np_writer() for addition failed\n"); TEST_ERROR; } } } - /* Perform random writes for contiguous and/or chunked datasets */ - if (s->rwrites) { - unsigned newstep; + /* Perform writes for contiguous and/or chunked datasets */ + if (s->contig || s->chunked) { - /* Set up random seed which will be the same for both writer and reader */ - HDsrandom(RANDOM_SEED); + /* Perform sequential writes */ + if (s->swrites) { - for (step = 0; (step < s->rwrites && step < (s->rows * s->cols)); step++) { - dbgf(2, "Random writes %u to dataset\n", step); + for (step = 0; (step < s->swrites && step < (s->rows * s->cols)); step++) { + dbgf(2, "Sequential writes %u to dataset\n", step); - newstep = (unsigned int)HDrandom() % (s->rows * s->cols); - HDprintf("Random step is %u\n", newstep); - result = dsets_action(RANDOM_WRITE, s, ds, newstep); + result = dsets_action(SEQ_WRITE, s, ds, step); - if (s->use_np && !np_writer(result, step, s, np, config)) { - HDprintf("np_writer() for random writes failed\n"); - TEST_ERROR; + if (s->use_np && !np_writer(result, step, s, np, config)) { + printf("np_writer() for sequential writes failed\n"); + TEST_ERROR; + } } } - } - /* Perform hyperslab writes for contiguous and/or chunked datasets */ - if (s->lwrites) { - unsigned k; + /* Perform random writes */ + if (s->rwrites) { + unsigned newstep; - for (step = 0, k = 0; (step < s->lwrites && k < (s->rows * s->cols)); step++, k += s->cols) { - dbgf(2, "Hyperslab writes %u to dataset\n", step); + /* Set up random seed which will be the same for both writer and reader */ + HDsrandom(RANDOM_SEED); - result = dsets_action(HYPER_WRITE, s, ds, k); + for (step = 0; (step < s->rwrites && step < (s->rows * s->cols)); step++) { + dbgf(2, "Random writes %u to dataset\n", step); - if (s->use_np && !np_writer(result, step, s, np, config)) { - HDprintf("np_writer() for hyperslab writes failed\n"); - TEST_ERROR; + newstep = (unsigned int)HDrandom() % (s->rows * s->cols); + dbgf(2, "Random step is %u\n", newstep); + result = dsets_action(RANDOM_WRITE, s, ds, newstep); + + if (s->use_np && !np_writer(result, step, s, np, config)) { + printf("np_writer() for random writes failed\n"); + TEST_ERROR; + } } } - } - /* Perform raw data modifications for contiguous and/or chunked datasets */ - if (s->wwrites) { + /* Perform hyperslab writes */ + if (s->lwrites) { + unsigned k; - for (step = 0; (step < s->wwrites && step < (s->rows * s->cols)); step++) { - dbgf(2, "Modify raw data %u to dataset\n", step); + for (step = 0, k = 0; (step < s->lwrites && k < (s->rows * s->cols)); step++, k += s->cols) { + dbgf(2, "Hyperslab writes %u to dataset\n", step); - result = dsets_action(MODIFY_DATA, s, ds, step); + result = dsets_action(HYPER_WRITE, s, ds, k); - if (s->use_np && !np_writer(result, step, s, np, config)) { - HDprintf("np_writer() for modify raw data failed\n"); - TEST_ERROR; + if (s->use_np && !np_writer(result, step, s, np, config)) { + printf("np_writer() for hyperslab writes failed\n"); + TEST_ERROR; + } } } - } + /* Perform raw data modifications */ + if (s->wwrites) { + + for (step = 0; (step < s->wwrites && step < (s->rows * s->cols)); step++) { + dbgf(2, "Modify raw data %u to dataset\n", step); + + result = dsets_action(MODIFY_DATA, s, ds, step); + + if (s->use_np && !np_writer(result, step, s, np, config)) { + printf("np_writer() for modify raw data failed\n"); + TEST_ERROR; + } + } + } + + } + return true; error: + return false; -} /* write_dset_contig_chunked() */ +} /* perform_dsets_operations() */ /* * Perform the "action" for each of the datasets specified on the command line: @@ -1128,6 +1179,8 @@ error: */ /* + * Verify writes to the compact dataset. + * * Verify writes for contiguous and chunked datasets: * --SEQ_WRITE: sequential writes * --RANDOM_WRITE: random writes @@ -1135,109 +1188,156 @@ error: * --MODIFY_DATA: raw data modifications */ static bool -verify_write_dset_contig_chunked(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np) +verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np, bool fileclosed) { unsigned step; bool result; - HDassert(s->contig || s->chunked); - - /* Start verifying sequential writes for contiguous and/or chunked datasets */ - if (s->swrites) { + /* Start verifying data written to the compact dataset */ + if (s->compact) { - for (step = 0; (step < s->swrites && step < (s->rows * s->cols)); step++) { - dbgf(2, "Verify sequential writes %u to dataset\n", step); + if(s->compact_write) { + dbgf(2, "Verify writes to compact dataset\n"); - if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { - HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, 0, s, np)) { + printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } /* Wait for a few ticks for the update to happen */ - decisleep(config->tick_len * s->update_interval); + if(!fileclosed) + decisleep(config->tick_len * s->update_interval); - result = verify_dsets_action(SEQ_WRITE, s, ds, step); + result = verify_dset_compact(s, ds, fileclosed, config->flush_raw_data); - if (s->use_np && !np_reader(result, step, s, np)) { - HDprintf("np_reader() for verifying addition failed\n"); + if (s->use_np && !np_reader(result, 0, s, np)) { + printf("np_reader() for verifying addition failed\n"); + TEST_ERROR; + } else if (!result) TEST_ERROR; - } } } - /* Start verifying random writes for contiguous and/or chunked datasets */ - if (s->rwrites) { - unsigned newstep; + /* Verify writes for contiguous and/or chunked datasets */ + if (s->contig || s->chunked) { - /* Set up random seed which will be the same for both writer and reader */ - HDsrandom(RANDOM_SEED); + /* Start verifying sequential writes */ + /* When flush of raw data is disabled, only verify data for the last write operation on file close */ + if ((s->swrites && !fileclosed) || (fileclosed && s->lastwrite == SEQ_WRITE)) { - for (step = 0; (step < s->rwrites && step < (s->rows * s->cols)); step++) { - dbgf(2, "Verify random writes %u to dataset\n", step); + s->lastwrite = SEQ_WRITE; - newstep = (unsigned int)HDrandom() % (s->rows * s->cols); - HDprintf("Random step is %u\n", newstep); + for (step = 0; (step < s->swrites && step < (s->rows * s->cols)); step++) { + dbgf(2, "Verify sequential writes %u to dataset\n", step); - if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { - HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); - TEST_ERROR; - } + if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { + printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + TEST_ERROR; + } - /* Wait for a few ticks for the update to happen */ - decisleep(config->tick_len * s->update_interval); + /* Wait for a few ticks for the update to happen */ + if(!fileclosed) + decisleep(config->tick_len * s->update_interval); - result = verify_dsets_action(RANDOM_WRITE, s, ds, newstep); + result = verify_dsets_action(SEQ_WRITE, s, ds, step, fileclosed); - if (s->use_np && !np_reader(result, step, s, np)) { - HDprintf("np_reader() for verifying addition failed\n"); - TEST_ERROR; + if (s->use_np && !np_reader(result, step, s, np)) { + printf("np_reader() for verifying addition failed\n"); + TEST_ERROR; + } else if (!result) + TEST_ERROR; } } - } - /* Start verifying hyperslab writes for contiguous and/or chunked datasets */ - if (s->lwrites) { - unsigned k; + /* Start verifying random writes */ + /* When flush of raw data is disabled, only verify data for the last write operation on file close */ + if ((s->rwrites && !fileclosed) || (fileclosed && s->lastwrite == RANDOM_WRITE)) { + unsigned newstep; - for (step = 0, k = 0; (step < s->lwrites && k < (s->rows * s->cols)); step++, k += s->cols) { - dbgf(2, "Verify hyperslab writes %u to dataset\n", step); + s->lastwrite = RANDOM_WRITE; - if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { - HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); - TEST_ERROR; - } + /* Set up random seed which will be the same for both writer and reader */ + HDsrandom(RANDOM_SEED); - /* Wait for a few ticks for the update to happen */ - decisleep(config->tick_len * s->update_interval); + for (step = 0; (step < s->rwrites && step < (s->rows * s->cols)); step++) { + dbgf(2, "Verify random writes %u to dataset\n", step); - result = verify_dsets_action(HYPER_WRITE, s, ds, k); + newstep = (unsigned int)HDrandom() % (s->rows * s->cols); + dbgf(2, "Random step is %u\n", newstep); - if (s->use_np && !np_reader(result, step, s, np)) { - HDprintf("np_reader() for verifying addition failed\n"); - TEST_ERROR; + if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { + printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + TEST_ERROR; + } + + /* Wait for a few ticks for the update to happen */ + if(!fileclosed) + decisleep(config->tick_len * s->update_interval); + + result = verify_dsets_action(RANDOM_WRITE, s, ds, newstep, fileclosed); + + if (s->use_np && !np_reader(result, step, s, np)) { + printf("np_reader() for verifying addition failed\n"); + TEST_ERROR; + } else if (!result) + TEST_ERROR; } } - } - /* Start verifying raw data modifications for contiguous and/or chunked datasets */ - if (s->wwrites) { + /* Start verifying hyperslab writes */ + /* When flush of raw data is disabled, only verify data for the last write operation on file close */ + if ((s->lwrites && !fileclosed) || (fileclosed && s->lastwrite == HYPER_WRITE)) { + unsigned k; - for (step = 0; (step < s->wwrites && step < (s->rows * s->cols)); step++) { - dbgf(2, "Verify raw data modification %u to dataset\n", step); + s->lastwrite = HYPER_WRITE; - if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { - HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); - TEST_ERROR; + for (step = 0, k = 0; (step < s->lwrites && k < (s->rows * s->cols)); step++, k += s->cols) { + dbgf(2, "Verify hyperslab writes %u to dataset\n", step); + + if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { + printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + TEST_ERROR; + } + + /* Wait for a few ticks for the update to happen */ + if(!fileclosed) + decisleep(config->tick_len * s->update_interval); + + result = verify_dsets_action(HYPER_WRITE, s, ds, k, fileclosed); + + if (s->use_np && !np_reader(result, step, s, np)) { + printf("np_reader() for verifying addition failed\n"); + TEST_ERROR; + } else if (!result) + TEST_ERROR; } + } - /* Wait for a few ticks for the update to happen */ - decisleep(config->tick_len * s->update_interval); + /* Start verifying raw data modifications */ + /* When flush of raw data is disabled, only verify data for the last write operation on file close */ + if ((s->wwrites && !fileclosed) || (fileclosed && s->lastwrite == MODIFY_DATA)) { - result = verify_dsets_action(MODIFY_DATA, s, ds, step); + s->lastwrite = MODIFY_DATA; - if (s->use_np && !np_reader(result, step, s, np)) { - HDprintf("np_reader() for verifying addition failed\n"); - TEST_ERROR; + for (step = 0; (step < s->wwrites && step < (s->rows * s->cols)); step++) { + dbgf(2, "Verify raw data modification %u to dataset\n", step); + + if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { + printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + TEST_ERROR; + } + + /* Wait for a few ticks for the update to happen */ + if(!fileclosed) + decisleep(config->tick_len * s->update_interval); + + result = verify_dsets_action(MODIFY_DATA, s, ds, step, fileclosed); + + if (s->use_np && !np_reader(result, step, s, np)) { + printf("np_reader() for verifying addition failed\n"); + TEST_ERROR; + } else if (!result) + TEST_ERROR; } } } @@ -1247,7 +1347,7 @@ verify_write_dset_contig_chunked(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_con error: return false; -} /* verify_write_dset_contig_chunked() */ +} /* Verify_dsets_operations() */ /* * Verify the data read from each of the datasets specified on the command line @@ -1258,7 +1358,7 @@ error: * MODIFY_DATA: `which` raw data modification */ static bool -verify_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which) +verify_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which, bool fileclosed) { hsize_t start[2]; hsize_t stride[2]; @@ -1275,9 +1375,9 @@ verify_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, /* Verify the data read for the contiguous dataset */ if (s->contig) { - if (!verify_read_dset(ds->contig_did, s->filetype, mem_sid, ds->contig_sid, start, stride, count, - block, vbuf)) { - HDprintf("H5Dwrite to contiguous dataset failed\n"); + if (!verify_dset(ds->contig_did, s->filetype, mem_sid, ds->contig_sid, start, stride, count, + block, vbuf, fileclosed, s->flush_raw_data)) { + printf("verify_dset() to contiguous dataset failed\n"); TEST_ERROR; } } @@ -1285,33 +1385,33 @@ verify_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, /* Verify the data read for the chunked datasets */ if (s->chunked) { - if (!verify_read_dset(ds->single_did, s->filetype, mem_sid, ds->single_sid, start, stride, count, - block, vbuf)) { - HDprintf("H5Dwrite to chunked dataset: single index dataset failed\n"); + if (!verify_dset(ds->single_did, s->filetype, mem_sid, ds->single_sid, start, stride, count, + block, vbuf, fileclosed, s->flush_raw_data)) { + printf("verify_dset() to chunked dataset: single index dataset failed\n"); TEST_ERROR; } - if (!verify_read_dset(ds->implicit_did, s->filetype, mem_sid, ds->implicit_sid, start, stride, count, - block, vbuf)) { - HDprintf("H5Dwrite to chunked dataset: implicit index dataset failed\n"); + if (!verify_dset(ds->implicit_did, s->filetype, mem_sid, ds->implicit_sid, start, stride, count, + block, vbuf, fileclosed, s->flush_raw_data)) { + printf("verify_dset() to chunked dataset: implicit index dataset failed\n"); TEST_ERROR; } - if (!verify_read_dset(ds->fa_did, s->filetype, mem_sid, ds->fa_sid, start, stride, count, block, - vbuf)) { - HDprintf("H5Dwrite to chunked dataset: fa index dataset failed\n"); + if (!verify_dset(ds->fa_did, s->filetype, mem_sid, ds->fa_sid, start, stride, count, block, + vbuf, fileclosed, s->flush_raw_data)) { + printf("verify_dset() to chunked dataset: fa index dataset failed\n"); TEST_ERROR; } - if (!verify_read_dset(ds->ea_did, s->filetype, mem_sid, ds->ea_sid, start, stride, count, block, - vbuf)) { - HDprintf("H5Dwrite to chunked dataset: ea index dataset failed\n"); + if (!verify_dset(ds->ea_did, s->filetype, mem_sid, ds->ea_sid, start, stride, count, block, + vbuf, fileclosed, s->flush_raw_data)) { + printf("verify_dset() to chunked dataset: ea index dataset failed\n"); TEST_ERROR; } - if (!verify_read_dset(ds->bt2_did, s->filetype, mem_sid, ds->bt2_sid, start, stride, count, block, - vbuf)) { - HDprintf("H5Dwrite to chunked dataset: bt2 index dataset failed\n"); + if (!verify_dset(ds->bt2_did, s->filetype, mem_sid, ds->bt2_sid, start, stride, count, block, + vbuf, fileclosed, s->flush_raw_data)) { + printf("verify_dset() to chunked dataset: bt2 index dataset failed\n"); TEST_ERROR; } } @@ -1329,13 +1429,14 @@ error: } /* verify_dsets_action() */ + /* * Verify the data read from the dataset is as expected. * `vbuf` contains the data expected from the read. */ static bool -verify_read_dset(hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hsize_t *start, hsize_t *stride, - hsize_t *count, hsize_t *block, unsigned int *vbuf) +verify_dset(hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hsize_t *start, hsize_t *stride, + hsize_t *count, hsize_t *block, unsigned int *vbuf, bool fileclosed, bool flush_raw_data) { unsigned int *rbuf = NULL; unsigned i; @@ -1365,9 +1466,15 @@ verify_read_dset(hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hsize_t *s } /* Verify the data read in `rbuf` is as `vbuf` */ - for (i = 0; i < count[1]; i++) - if (rbuf[i] != vbuf[i]) - TEST_ERROR; + for (i = 0; i < count[1]; i++) { + if(flush_raw_data || fileclosed) { + if (rbuf[i] != vbuf[i]) + TEST_ERROR; + } else { /* No flush && not closing file */ + if (rbuf[i] != vbuf[i] && rbuf[0] != 0) /* FILL VALUE ?? */ + TEST_ERROR; + } + } if (rbuf) HDfree(rbuf); @@ -1379,17 +1486,23 @@ error: HDfree(rbuf); return false; -} /* verify_read_dset() */ +} /* verify_dset() */ /* * Verify that the data read from the compact dataset is as unexpected. */ static bool -verify_read_dset_compact(const state_t *s, const dsets_state_t *ds) +verify_dset_compact(const state_t *s, const dsets_state_t *ds, bool fileclosed, bool flush_raw_data) { unsigned int *rbuf; unsigned i; + /* Refresh the dataset */ + if (H5Drefresh(ds->compact_did) < 0) { + printf("H5Drefresh dataset failed\n"); + TEST_ERROR; + } + if ((rbuf = HDmalloc(s->compact_elmts * sizeof(unsigned int))) == NULL) { HDprintf("HDmalloc buffer for compact dataset failed\n"); goto error; @@ -1400,11 +1513,18 @@ verify_read_dset_compact(const state_t *s, const dsets_state_t *ds) TEST_ERROR; } - for (i = 0; i < s->compact_elmts; i++) - if (rbuf[i] != (i + 1)) { - HDprintf("Invalid value for compact dataset element\n"); - TEST_ERROR; + for (i = 0; i < s->compact_elmts; i++) { + if(flush_raw_data || fileclosed) { + if (rbuf[i] != (i + 1)) { + printf("Invalid value for compact dataset element\n"); + TEST_ERROR; + } + } else { /* No flush && not closing file */ + if (rbuf[i] != (i + 1) && rbuf[0] != 0) /* FILL VALUE ?? */ + TEST_ERROR; + } + } if (rbuf) HDfree(rbuf); @@ -1416,7 +1536,7 @@ error: HDfree(rbuf); return false; -} /* verify_read_dset_compact() */ +} /* verify_dset_compact() */ /* * Named pipes handling @@ -1535,9 +1655,8 @@ np_writer(bool result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd_ HDwrite(np->fd_writer_to_reader, &np->notify, sizeof(int)); goto error; } - /* The action succeeds */ } - else { + else { /* The action succeeds */ /* At communication interval, notify the reader and wait for its response */ if (step % s->csteps == 0) { /* Bump up the value of notify to tell the reader to start reading */ @@ -1642,6 +1761,91 @@ error: } /* np_confirm_verify_notify() */ /* + * When flush of raw data is disabled, the following is done by the writer and reader: + * Writer: + * Close the file + * Notify the reader that the file is closed + * Reader: + * Confirm the message from the writer that the file is closed + * Verify the data + */ +static bool +closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np) +{ + HDassert(s->use_np); + + if(writer) { + if (!close_dsets(ds)) { + printf("close_dsets() failed\n"); + TEST_ERROR; + } + + dbgf(2, "Writer closes the file (flush of raw data is disabled)\n"); + if (H5Fclose(s->file) < 0) { + printf("H5Fclose failed\n"); + TEST_ERROR; + } + + /* Bump up the value of notify to tell the reader the file is closed */ + dbgf(2, "Writer notifies reader that the file is closed (flush of raw data is disabled)\n"); + np->notify++; + if (HDwrite(np->fd_writer_to_reader, &np->notify, sizeof(int)) < 0) { + printf("HDwrite failed\n"); + TEST_ERROR; + } + + if (!np_close(np, writer)) { + printf("np_close() failed\n"); + TEST_ERROR; + } + + } else { + /* Wait for a few ticks for the file to close in writer ?? need to this or not? */ + decisleep(config->tick_len * s->update_interval); + + dbgf(2, "Reader checks notify value from writer (flush of raw data is disabled)\n"); + if (!np_confirm_verify_notify(np->fd_writer_to_reader, 0, s, np)) { + printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + TEST_ERROR; + } + + /* Close the named pipes */ + if (!np_close(np, writer)) { + printf("np_close() failed\n"); + TEST_ERROR; + } + + /* Turn off named pipes */ + s->use_np = false; + + /* Verify the dataset again without named pipes */ + dbgf(2, "Reader verifies data after writer closes the file (flush of raw data is disabled)\n"); + if(!verify_dsets_operations(s, ds, config, np, true)) { + printf("verify_dsets_operations() failed\n"); + TEST_ERROR + } + + if (!close_dsets(ds)) { + printf("close_dsets() failed\n"); + TEST_ERROR; + } + + dbgf(2, "Reader closes the file (flush of raw data is disabled)\n"); + if (H5Fclose(s->file) < 0) { + printf("H5Fclose failed\n"); + TEST_ERROR; + } + + } + + return true; + +error: + return false; + +} /* closing_on_noflush() */ + +/* * Main */ int @@ -1655,7 +1859,6 @@ main(int argc, char **argv) H5F_vfd_swmr_config_t config; np_state_t np; dsets_state_t ds; - bool result; if (!state_init(&s, argc, argv)) { HDprintf("state_init() failed\n"); @@ -1674,7 +1877,7 @@ main(int argc, char **argv) } /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(&config, 4, 7, writer, FALSE, 128, "./dsetops-shadow"); + init_vfd_swmr_config(&config, 4, 7, writer, s.flush_raw_data, 128, "./dsetops-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(true, s.use_vfd_swmr, true, 4096, &config)) < 0) { @@ -1718,62 +1921,19 @@ main(int argc, char **argv) if (writer) { - /* Perform writes to the whole compact dataset */ - if (s.compact && s.compact_write) { - dbgf(2, "Writes all to compact dataset\n"); - - result = write_dset_compact(&s, &ds); - - if (s.use_np && !np_writer(result, 0, &s, &np, &config)) { - HDprintf("np_writer() for addition failed\n"); - TEST_ERROR; - } - } - - if (s.contig || s.chunked) { - /* Perform writes for contiguous and/or chunked datasets */ - if (!write_dset_contig_chunked(&s, &ds, &config, &np)) { - HDprintf("write_dset_contig_chunked() failed\n"); - TEST_ERROR; - } + if(!perform_dsets_operations(&s, &ds, &config, &np)) { + printf("perform_dsets_operations() failed\n"); + TEST_ERROR; } } else { - /* Start verifying data written to the compact dataset */ - if (s.compact && s.compact_write) { - dbgf(2, "Verify writes to compact dataset\n"); - - if (s.use_np && !np_confirm_verify_notify(np.fd_writer_to_reader, 0, &s, &np)) { - HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); - TEST_ERROR; - } - /* Wait for a few ticks for the update to happen */ - decisleep(config.tick_len * s.update_interval); - - result = verify_read_dset_compact(&s, &ds); - - if (s.use_np && !np_reader(result, 0, &s, &np)) { - HDprintf("np_reader() for verifying addition failed\n"); - TEST_ERROR; - } - } - - if (s.contig || s.chunked) { - - /* Verify writes for contiguous and/or chunked datasets */ - if (!verify_write_dset_contig_chunked(&s, &ds, &config, &np)) { - HDprintf("verify_write_dset_contig_chunked() failed\n"); - TEST_ERROR; - } + if(!verify_dsets_operations(&s, &ds, &config, &np, false)) { + printf("perform_dsets_operations() failed\n"); + TEST_ERROR; } } - if (!close_dsets(&ds)) { - HDprintf("close_dsets() failed\n"); - TEST_ERROR; - } - if (H5Pclose(fapl) < 0) { HDprintf("H5Pclose failed\n"); TEST_ERROR; @@ -1784,14 +1944,26 @@ main(int argc, char **argv) TEST_ERROR; } - if (H5Fclose(s.file) < 0) { - HDprintf("H5Fclose failed\n"); - TEST_ERROR; - } + if(!s.flush_raw_data && s.use_np) { - if (s.use_np && !np_close(&np, writer)) { - HDprintf("np_close() failed\n"); - TEST_ERROR; + if(!closing_on_noflush(writer, &s, &ds, &config, &np)) + TEST_ERROR + } else { + + if (!close_dsets(&ds)) { + printf("close_dsets() failed\n"); + TEST_ERROR; + } + + if (H5Fclose(s.file) < 0) { + printf("H5Fclose failed\n"); + TEST_ERROR; + } + + if (s.use_np && !np_close(&np, writer)) { + printf("np_close() failed\n"); + TEST_ERROR; + } } return EXIT_SUCCESS; diff --git a/test/vfd_swmr_generator.c b/test/vfd_swmr_generator.c index 4b87072..16b1d4b 100644 --- a/test/vfd_swmr_generator.c +++ b/test/vfd_swmr_generator.c @@ -126,7 +126,7 @@ gen_skeleton(const char *filename, hbool_t verbose, hbool_t vfd_swmr_write, int return -1; /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(config, 4, 10, vfd_swmr_write, FALSE, 128, "generator-shadow"); + init_vfd_swmr_config(config, 4, 10, vfd_swmr_write, TRUE, 128, "generator-shadow"); } /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index c758781..55ea314 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -4985,7 +4985,7 @@ main(int argc, char **argv) } /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(&config, 4, 7, writer, FALSE, 128, "./group-shadow"); + init_vfd_swmr_config(&config, 4, 7, writer, TRUE, 128, "./group-shadow"); /* If old-style option is chosen, use the earliest file format(H5F_LIBVER_EARLIEST) * as the second parameter of H5Pset_libver_bound() that is called by diff --git a/test/vfd_swmr_reader.c b/test/vfd_swmr_reader.c index cc4d918..6265cae 100644 --- a/test/vfd_swmr_reader.c +++ b/test/vfd_swmr_reader.c @@ -320,7 +320,7 @@ read_records(const char *filename, hbool_t verbose, FILE *verbose_file, unsigned } /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(config, 4, 5, FALSE, FALSE, 128, "./rw-shadow"); + init_vfd_swmr_config(config, 4, 5, FALSE, TRUE, 128, "./rw-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config)) < 0) { diff --git a/test/vfd_swmr_remove_reader.c b/test/vfd_swmr_remove_reader.c index b729ee4..4389b05 100644 --- a/test/vfd_swmr_remove_reader.c +++ b/test/vfd_swmr_remove_reader.c @@ -304,7 +304,7 @@ read_records(const char *filename, unsigned verbose, unsigned long nseconds, uns goto error; /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(config, 4, 5, FALSE, FALSE, 128, "./rw-shadow"); + init_vfd_swmr_config(config, 4, 5, FALSE, TRUE, 128, "./rw-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config)) < 0) { diff --git a/test/vfd_swmr_remove_writer.c b/test/vfd_swmr_remove_writer.c index b8b1303..8df8fa8 100644 --- a/test/vfd_swmr_remove_writer.c +++ b/test/vfd_swmr_remove_writer.c @@ -87,7 +87,7 @@ open_skeleton(const char *filename, unsigned verbose, unsigned old H5_ATTR_UNUSE goto error; /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(config, 4, 5, TRUE, FALSE, 128, "./rw-shadow"); + init_vfd_swmr_config(config, 4, 5, TRUE, TRUE, 128, "./rw-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, 4096, config)) < 0) diff --git a/test/vfd_swmr_sparse_reader.c b/test/vfd_swmr_sparse_reader.c index a39b357..943c375 100644 --- a/test/vfd_swmr_sparse_reader.c +++ b/test/vfd_swmr_sparse_reader.c @@ -208,7 +208,7 @@ read_records(const char *filename, unsigned verbose, unsigned long nrecords, uns goto error; /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(config, 4, 5, FALSE, FALSE, 128, "./rw-shadow"); + init_vfd_swmr_config(config, 4, 5, FALSE, TRUE, 128, "./rw-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config)) < 0) { diff --git a/test/vfd_swmr_sparse_writer.c b/test/vfd_swmr_sparse_writer.c index 53b6ec9..56d19f3 100644 --- a/test/vfd_swmr_sparse_writer.c +++ b/test/vfd_swmr_sparse_writer.c @@ -87,7 +87,7 @@ open_skeleton(const char *filename, unsigned verbose) goto error; /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(config, 4, 5, TRUE, FALSE, 128, "./rw-shadow"); + init_vfd_swmr_config(config, 4, 5, TRUE, TRUE, 128, "./rw-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, 4096, config)) < 0) diff --git a/test/vfd_swmr_vlstr_reader.c b/test/vfd_swmr_vlstr_reader.c index 5a112cd..c3ee2ed 100644 --- a/test/vfd_swmr_vlstr_reader.c +++ b/test/vfd_swmr_vlstr_reader.c @@ -116,7 +116,7 @@ main(int argc, char **argv) errx(EXIT_FAILURE, "unexpected command-line arguments"); /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(&config, 4, 7, false, FALSE, 128, "./vlstr-shadow"); + init_vfd_swmr_config(&config, 4, 7, false, TRUE, 128, "./vlstr-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ fapl = vfd_swmr_create_fapl(true, use_vfd_swmr, sel == TEST_OOB, 4096, &config); diff --git a/test/vfd_swmr_vlstr_writer.c b/test/vfd_swmr_vlstr_writer.c index f338428..4f7376e 100644 --- a/test/vfd_swmr_vlstr_writer.c +++ b/test/vfd_swmr_vlstr_writer.c @@ -185,7 +185,7 @@ main(int argc, char **argv) errx(EXIT_FAILURE, "unexpected command-line arguments"); /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(&config, 4, 7, true, FALSE, 128, "./vlstr-shadow"); + init_vfd_swmr_config(&config, 4, 7, true, TRUE, 128, "./vlstr-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ fapl = vfd_swmr_create_fapl(true, use_vfd_swmr, sel == TEST_OOB, 4096, &config); diff --git a/test/vfd_swmr_writer.c b/test/vfd_swmr_writer.c index c5b62c8..4693554 100644 --- a/test/vfd_swmr_writer.c +++ b/test/vfd_swmr_writer.c @@ -89,7 +89,7 @@ open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, unsigne return -1; /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(config, 4, 5, TRUE, FALSE, 128, "./rw-shadow"); + init_vfd_swmr_config(config, 4, 5, TRUE, TRUE, 128, "./rw-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, 4096, config)) < 0) diff --git a/test/vfd_swmr_zoo_writer.c b/test/vfd_swmr_zoo_writer.c index d89fd16..13794d9 100644 --- a/test/vfd_swmr_zoo_writer.c +++ b/test/vfd_swmr_zoo_writer.c @@ -474,7 +474,7 @@ main(int argc, char **argv) parse_command_line_options(argc, argv); /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(&vfd_swmr_config, TICK_LEN, 7, writer, FALSE, 128, "./zoo-shadow"); + init_vfd_swmr_config(&vfd_swmr_config, TICK_LEN, 7, writer, TRUE, 128, "./zoo-shadow"); /* ? turn off use latest format argument via 1st argument? since later on it reset to early format */ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ -- cgit v0.12 From 4a35f8480b29a1b55ccec81f4a0df9e776b76070 Mon Sep 17 00:00:00 2001 From: vchoi Date: Thu, 12 Aug 2021 11:40:58 -0500 Subject: Modifications based on PR feedback. --- test/vfd_swmr_attrdset_writer.c | 34 +++-- test/vfd_swmr_dsetchks_writer.c | 324 ++++++++++++++++++++-------------------- test/vfd_swmr_dsetops_writer.c | 82 +++++----- 3 files changed, 223 insertions(+), 217 deletions(-) diff --git a/test/vfd_swmr_attrdset_writer.c b/test/vfd_swmr_attrdset_writer.c index 630b071..e10184f 100644 --- a/test/vfd_swmr_attrdset_writer.c +++ b/test/vfd_swmr_attrdset_writer.c @@ -239,8 +239,10 @@ state_init(state_t *s, int argc, char **argv) esnprintf(s->progname, sizeof(s->progname), "%s", tfile); - if (tfile) + if (tfile) { HDfree(tfile); + tfile = NULL; + } while ((ch = getopt(argc, argv, "pgkvmbqSNa:d:u:c:")) != -1) { switch (ch) { @@ -930,7 +932,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c result = attr_dsets_action(ADD_ATTR, s, ds, step); if (s->use_np && !np_writer(result, step, s, np, config)) { - printf("np_writer() for addition failed\n"); + HDprintf("np_writer() for addition failed\n"); TEST_ERROR; } } @@ -939,7 +941,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c /* Need to sync up writer/reader before moving onto the next phase */ if (s->use_np && !np_writer(true, 0, s, np, config)) { - printf("np_writer() for modification failed\n"); + HDprintf("np_writer() for modification failed\n"); TEST_ERROR; } @@ -950,7 +952,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c result = attr_dsets_action(MODIFY_ATTR, s, ds, step); if (s->use_np && !np_writer(result, step, s, np, config)) { - printf("np_writer() for modification failed\n"); + HDprintf("np_writer() for modification failed\n"); TEST_ERROR; } } @@ -960,7 +962,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c /* Need to sync up writer/reader before moving onto the next phase */ if (s->use_np && !np_writer(true, 0, s, np, config)) { - printf("np_writer() for deletion failed\n"); + HDprintf("np_writer() for deletion failed\n"); TEST_ERROR; } @@ -971,7 +973,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c result = attr_dsets_action(DELETE_ATTR, s, ds, step); if (s->use_np && !np_writer(result, step, s, np, config)) { - printf("np_writer() for deletion failed\n"); + HDprintf("np_writer() for deletion failed\n"); TEST_ERROR; } } @@ -1291,7 +1293,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co dbgf(2, "Verifying...attribute %d\n", step); if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1301,7 +1303,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_attr_dsets_action(ADD_ATTR, s, ds, step); if (s->use_np && !np_reader(result, step, s, np)) { - printf("np_reader() for verifying addition failed\n"); + HDprintf("np_reader() for verifying addition failed\n"); TEST_ERROR; } } @@ -1309,7 +1311,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co if (s->mod_attr) { /* Need to sync up writer/reader before moving onto the next phase */ if (!np_reader_no_verification(s, np, config)) { - printf("np_reader_no_verification() for verifying modification failed\n"); + HDprintf("np_reader_no_verification() for verifying modification failed\n"); TEST_ERROR; } @@ -1318,7 +1320,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co dbgf(2, "Verifying...modify attribute %d\n", step); if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1328,7 +1330,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_attr_dsets_action(MODIFY_ATTR, s, ds, step); if (s->use_np && !np_reader(result, step, s, np)) { - printf("np_reader() for verifying modification failed\n"); + HDprintf("np_reader() for verifying modification failed\n"); TEST_ERROR; } } @@ -1338,7 +1340,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co /* Need to sync up writer/reader before moving onto the next phase */ if (!np_reader_no_verification(s, np, config)) { - printf("np_reader_no_verification() for verifying modification failed\n"); + HDprintf("np_reader_no_verification() for verifying modification failed\n"); TEST_ERROR; } @@ -1347,7 +1349,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co dbgf(2, "Verifying...delete attribute %d\n", step); if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1357,7 +1359,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_attr_dsets_action(DELETE_ATTR, s, ds, step); if (s->use_np && !np_reader(result, step, s, np)) { - printf("np_reader() for verifying deletion failed\n"); + HDprintf("np_reader() for verifying deletion failed\n"); TEST_ERROR; } } @@ -2030,14 +2032,14 @@ main(int argc, char **argv) if (writer) { if(!perform_dsets_operations(&s, &ds, &config, &np)) { - printf("perform_dsets_operations() failed\n"); + HDprintf("perform_dsets_operations() failed\n"); TEST_ERROR; } } else { if(!verify_dsets_operations(&s, &ds, &config, &np)) { - printf("verify_dsets_operations() failed\n"); + HDprintf("verify_dsets_operations() failed\n"); TEST_ERROR; } diff --git a/test/vfd_swmr_dsetchks_writer.c b/test/vfd_swmr_dsetchks_writer.c index 1496fcd..d39ebf8 100644 --- a/test/vfd_swmr_dsetchks_writer.c +++ b/test/vfd_swmr_dsetchks_writer.c @@ -190,7 +190,7 @@ static const hid_t badhid = H5I_INVALID_HID; static void usage(const char *progname) { - fprintf(stderr, + HDfprintf(stderr, "usage: %s \n" " [-s] [-i] [-f] [-e] [-r]\n" " [-m rows] [-n cols]\n" @@ -199,7 +199,7 @@ usage(const char *progname) " [-u nticks] [-c csteps] [-U] [-S] [-N] [-q] [-b] [-o]\n", progname); - fprintf( + HDfprintf( stderr, "\n" "-s: create a 2-d chunked dataset with single index\n" @@ -227,7 +227,7 @@ usage(const char *progname) " (default is H5T_NATIVE_UINT32)\n\n" "-o: enable compression (deflate filter) for the datasets\n"); - fprintf( + HDfprintf( stderr, "\n" "Note:\n" @@ -277,8 +277,10 @@ state_init(state_t *s, int argc, char **argv) esnprintf(s->progname, sizeof(s->progname), "%s", tfile); - if (tfile) + if (tfile) { HDfree(tfile); + tfile = NULL; + } while ((ch = getopt(argc, argv, "siferom:n:x:y:g:p:t:l:bqSNUu:c:")) != -1) { switch (ch) { @@ -340,15 +342,15 @@ state_init(state_t *s, int argc, char **argv) errno = 0; tmp = strtoul(optarg, &end, 0); if (end == optarg || *end != '\0') { - printf("couldn't parse `-%c` argument `%s`\n", ch, optarg); + HDprintf("couldn't parse `-%c` argument `%s`\n", ch, optarg); TEST_ERROR; } else if (errno != 0) { - printf("couldn't parse `-%c` argument `%s`\n", ch, optarg); + HDprintf("couldn't parse `-%c` argument `%s`\n", ch, optarg); TEST_ERROR; } else if (tmp > UINT_MAX) { - printf("`-%c` argument `%lu` too large\n", ch, tmp); + HDprintf("`-%c` argument `%lu` too large\n", ch, tmp); TEST_ERROR; } @@ -386,63 +388,63 @@ state_init(state_t *s, int argc, char **argv) /* Require to specify at least -s or -i or -f or -e or -r option */ if (!s->single_index && !s->implicit_index && !s->fa_index && !s->ea_index && !s->bt2_index) { - printf("Require to specify at least -s or -i or -f or -e or -r option\n"); + HDprintf("Require to specify at least -s or -i or -f or -e or -r option\n"); usage(s->progname); goto error; } /* -x or -y option only apply to dataset with fixed/extensible array/v2 btree index */ if ((s->single_index || s->implicit_index) && (s->xincrs || s->ydecrs)) { - printf("-x or -y option not applicable to dataset with single or implicit index\n"); + HDprintf("-x or -y option not applicable to dataset with single or implicit index\n"); usage(s->progname); goto error; } /* rows and cols cannot be zero */ if (s->rows == 0 || s->cols == 0) { - printf("-m or -n cannot be zero\n"); + HDprintf("-m or -n cannot be zero\n"); TEST_ERROR; } /* -c cannot be zero */ if (!s->csteps) { - printf("communication interval cannot be zero\n"); + HDprintf("communication interval cannot be zero\n"); TEST_ERROR; } /* -c and -g options */ if (s->gwrites && s->csteps > s->gwrites) { - printf("communication interval with -g is out of bounds\n"); + HDprintf("communication interval with -g is out of bounds\n"); TEST_ERROR; } /* -c and -p options */ if (s->pwrites && s->csteps > s->pwrites) { - printf("communication interval with -p is out of bounds\n"); + HDprintf("communication interval with -p is out of bounds\n"); TEST_ERROR; } /* -c and -t options */ if (s->twrites && s->csteps > s->twrites) { - printf("communication interval with -t is out of bounds\n"); + HDprintf("communication interval with -t is out of bounds\n"); TEST_ERROR; } /* -c and -l options */ if (s->lwrites && s->csteps > s->lwrites) { - printf("communication interval with -l is out of bounds\n"); + HDprintf("communication interval with -l is out of bounds\n"); TEST_ERROR; } /* -c and -x options */ if (s->xincrs && s->csteps > s->xincrs) { - printf("communication interval with -x is out of bounds\n"); + HDprintf("communication interval with -x is out of bounds\n"); TEST_ERROR; } /* -c and -y options */ if (s->ydecrs && s->csteps > s->ydecrs) { - printf("communication interval with -y is out of bounds\n"); + HDprintf("communication interval with -y is out of bounds\n"); TEST_ERROR; } @@ -488,26 +490,26 @@ create_dsets(const state_t *s, dsets_state_t *ds) /* Create dataset creation property list */ /* Set properties in dcpl that are common for all the datasets */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { - printf("H5Pcreate failed\n"); + HDprintf("H5Pcreate failed\n"); TEST_ERROR; } /* Set to chunked layout */ if (H5Pset_layout(dcpl, H5D_CHUNKED) < 0) { - printf("H5Pset_layout failed\n"); + HDprintf("H5Pset_layout failed\n"); TEST_ERROR; } /* Set fill value to FILL_INIT */ if (H5Pset_fill_value(dcpl, s->filetype, &fillval) < 0) { - printf("H5Pset_fill_value failed\n"); + HDprintf("H5Pset_fill_value failed\n"); goto error; } /* Set to use filter as specified */ if (s->use_filter) { if (H5Pset_deflate(dcpl, 5) < 0) { - printf("H5Pset_deflate failed\n"); + HDprintf("H5Pset_deflate failed\n"); goto error; } } @@ -517,41 +519,41 @@ create_dsets(const state_t *s, dsets_state_t *ds) if (s->single_index) { if ((dcpl2 = H5Pcopy(dcpl)) < 0) { - printf("H5Tcopy failed\n"); + HDprintf("H5Tcopy failed\n"); TEST_ERROR; } if (H5Pset_chunk(dcpl2, 2, dims) < 0) { - printf("H5Pset_chunk failed\n"); + HDprintf("H5Pset_chunk failed\n"); TEST_ERROR; } if ((sid = H5Screate_simple(2, dims, dims)) < 0) { - printf("H5Screate_simple failed\n"); + HDprintf("H5Screate_simple failed\n"); TEST_ERROR; } /* Create the chunked dataset: single index */ if ((ds->single_did = H5Dcreate2(s->file, DSET_SINGLE_NAME, s->filetype, sid, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0) { - printf("H5Dcreate2 chunked dataset:single index failed\n"); + HDprintf("H5Dcreate2 chunked dataset:single index failed\n"); TEST_ERROR; } if (H5Pclose(dcpl2) < 0) { - printf("H5Pclose failed\n"); + HDprintf("H5Pclose failed\n"); TEST_ERROR; } if (H5Sclose(sid) < 0) { - printf("H5Sclose failed\n"); + HDprintf("H5Sclose failed\n"); TEST_ERROR; } } /* Chunk size is common for datasets with implicit/fa/ea/bt2 index */ if (H5Pset_chunk(dcpl, 2, ds->chunk_dims) < 0) { - printf("H5Pset_chunk failed\n"); + HDprintf("H5Pset_chunk failed\n"); TEST_ERROR; } @@ -560,34 +562,34 @@ create_dsets(const state_t *s, dsets_state_t *ds) if (s->implicit_index) { if ((dcpl2 = H5Pcopy(dcpl)) < 0) { - printf("H5Pcopy failed\n"); + HDprintf("H5Pcopy failed\n"); TEST_ERROR; } if (H5Pset_alloc_time(dcpl2, H5D_ALLOC_TIME_EARLY) < 0) { - printf("H5Pset_alloc_time\n"); + HDprintf("H5Pset_alloc_time\n"); TEST_ERROR; } if ((sid = H5Screate_simple(2, dims, dims)) < 0) { - printf("H5Screate_simple failed\n"); + HDprintf("H5Screate_simple failed\n"); TEST_ERROR; } /* Create the chunked dataset: implicit index */ if ((ds->implicit_did = H5Dcreate2(s->file, DSET_IMPLICIT_NAME, s->filetype, sid, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0) { - printf("H5Dcreate2 chunked dataset:implicit index failed\n"); + HDprintf("H5Dcreate2 chunked dataset:implicit index failed\n"); TEST_ERROR; } if (H5Pclose(dcpl2) < 0) { - printf("H5Pclose failed\n"); + HDprintf("H5Pclose failed\n"); TEST_ERROR; } if (H5Sclose(sid) < 0) { - printf("H5Sclose failed\n"); + HDprintf("H5Sclose failed\n"); TEST_ERROR; } } @@ -601,19 +603,19 @@ create_dsets(const state_t *s, dsets_state_t *ds) max_dims[1] = dims[1] * 2; if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) { - printf("H5Screate_simple failed\n"); + HDprintf("H5Screate_simple failed\n"); TEST_ERROR; } /* Create the chunked dataset (fixed array index) with the named datatype */ if ((ds->fa_did = H5Dcreate2(s->file, DSET_FA_NAME, s->filetype, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { - printf("H5Dcreate2 chunked dataset: fa index failed\n"); + HDprintf("H5Dcreate2 chunked dataset: fa index failed\n"); TEST_ERROR; } if (H5Sclose(sid) < 0) { - printf("H5Sclose failed\n"); + HDprintf("H5Sclose failed\n"); TEST_ERROR; } } @@ -627,19 +629,19 @@ create_dsets(const state_t *s, dsets_state_t *ds) max_dims[1] = H5S_UNLIMITED; if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) { - printf("H5Screate_simple failed\n"); + HDprintf("H5Screate_simple failed\n"); TEST_ERROR; } /* Create the chunked dataset (extensible array index) with the named datatype */ if ((ds->ea_did = H5Dcreate2(s->file, DSET_EA_NAME, s->filetype, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { - printf("H5Dcreate2 chunked dataset: ea index failed\n"); + HDprintf("H5Dcreate2 chunked dataset: ea index failed\n"); TEST_ERROR; } if (H5Sclose(sid) < 0) { - printf("H5Sclose failed\n"); + HDprintf("H5Sclose failed\n"); TEST_ERROR; } } @@ -652,25 +654,25 @@ create_dsets(const state_t *s, dsets_state_t *ds) max_dims[0] = max_dims[1] = H5S_UNLIMITED; if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) { - printf("H5Screate_simple failed\n"); + HDprintf("H5Screate_simple failed\n"); TEST_ERROR; } /* Create the chunked dataset (btree2 index) with the named datatype */ if ((ds->bt2_did = H5Dcreate2(s->file, DSET_BT2_NAME, s->filetype, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { - printf("H5Dcreate2 chunked dataset: bt2 index failed\n"); + HDprintf("H5Dcreate2 chunked dataset: bt2 index failed\n"); TEST_ERROR; } if (H5Sclose(sid) < 0) { - printf("H5Sclose failed\n"); + HDprintf("H5Sclose failed\n"); TEST_ERROR; } } if (H5Pclose(dcpl) < 0) { - printf("H5Pclose failed\n"); + HDprintf("H5Pclose failed\n"); TEST_ERROR; } @@ -706,7 +708,7 @@ open_dsets(const state_t *s, dsets_state_t *ds) /* Dataset with single index */ if (s->single_index) { if ((ds->single_did = H5Dopen2(s->file, DSET_SINGLE_NAME, H5P_DEFAULT)) < 0) { - printf("H5Dopen dataset with single index failed\n"); + HDprintf("H5Dopen dataset with single index failed\n"); TEST_ERROR; } } @@ -714,7 +716,7 @@ open_dsets(const state_t *s, dsets_state_t *ds) /* Dataset with implicit index */ if (s->implicit_index) { if ((ds->implicit_did = H5Dopen2(s->file, DSET_IMPLICIT_NAME, H5P_DEFAULT)) < 0) { - printf("H5Dopen dataset with implicit index failed\n"); + HDprintf("H5Dopen dataset with implicit index failed\n"); TEST_ERROR; } } @@ -722,7 +724,7 @@ open_dsets(const state_t *s, dsets_state_t *ds) /* Dataset with fixed array index */ if (s->fa_index) { if ((ds->fa_did = H5Dopen2(s->file, DSET_FA_NAME, H5P_DEFAULT)) < 0) { - printf("H5Dopen dataset with fa index failed\n"); + HDprintf("H5Dopen dataset with fa index failed\n"); TEST_ERROR; } } @@ -730,7 +732,7 @@ open_dsets(const state_t *s, dsets_state_t *ds) /* Dataset with extensible array index */ if (s->ea_index) { if ((ds->ea_did = H5Dopen2(s->file, DSET_EA_NAME, H5P_DEFAULT)) < 0) { - printf("H5Dopen dataset with ea index failed\n"); + HDprintf("H5Dopen dataset with ea index failed\n"); TEST_ERROR; } } @@ -738,7 +740,7 @@ open_dsets(const state_t *s, dsets_state_t *ds) /* Dataset with v2 btree index */ if (s->bt2_index) { if ((ds->bt2_did = H5Dopen2(s->file, DSET_BT2_NAME, H5P_DEFAULT)) < 0) { - printf("H5Dopen dataset with ea index failed\n"); + HDprintf("H5Dopen dataset with ea index failed\n"); TEST_ERROR; } } @@ -781,31 +783,31 @@ close_dsets(const dsets_state_t *ds) { /* Close dataset with single index */ if (ds->single_did != badhid && H5Dclose(ds->single_did) < 0) { - printf("close_dset_real() dataset: single index failed\n"); + HDprintf("close_dset_real() dataset: single index failed\n"); TEST_ERROR; } /* Close dataset with implicit index */ if (ds->implicit_did != badhid && H5Dclose(ds->implicit_did) < 0) { - printf("close_dset_real() dataset: implicit index failed\n"); + HDprintf("close_dset_real() dataset: implicit index failed\n"); TEST_ERROR; } /* Close dataset with fixed array index */ if (ds->fa_did != badhid && H5Dclose(ds->fa_did) < 0) { - printf("close_dset_real() dataset: fa index failed\n"); + HDprintf("close_dset_real() dataset: fa index failed\n"); TEST_ERROR; } /* Close dataset with extensible array index */ if (ds->ea_did != badhid && H5Dclose(ds->ea_did) < 0) { - printf("close_dset_real() : ea index failed\n"); + HDprintf("close_dset_real() : ea index failed\n"); TEST_ERROR; } /* Close dataset with v2 btree index */ if (ds->bt2_did != badhid && H5Dclose(ds->bt2_did) < 0) { - printf("close_dset_real() dataset: bt2 index failed\n"); + HDprintf("close_dset_real() dataset: bt2 index failed\n"); TEST_ERROR; } @@ -864,7 +866,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c result = write_dset_single(GWRITES, s, ds); if (s->use_np && !np_writer(result, 0, s, np, config)) { - printf("np_writer() for addition failed\n"); + HDprintf("np_writer() for addition failed\n"); TEST_ERROR; } } @@ -879,7 +881,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c result = write_dset_single(PWRITES, s, ds); if (s->use_np && !np_writer(result, 0, s, np, config)) { - printf("np_writer() for addition failed\n"); + HDprintf("np_writer() for addition failed\n"); TEST_ERROR; } } @@ -900,7 +902,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c result = write_dsets_chunks(GWRITES, s, ds, step); if (s->use_np && !np_writer(result, step, s, np, config)) { - printf("np_writer() for single full chunk writes failed\n"); + HDprintf("np_writer() for single full chunk writes failed\n"); TEST_ERROR; } } @@ -918,7 +920,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c result = write_dsets_chunks(PWRITES, s, ds, step); if (s->use_np && !np_writer(result, step, s, np, config)) { - printf("np_writer() for partial single chunk writes failed\n"); + HDprintf("np_writer() for partial single chunk writes failed\n"); TEST_ERROR; } } @@ -936,7 +938,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c result = write_dsets_chunks(TWRITES, s, ds, step); if (s->use_np && !np_writer(result, step, s, np, config)) { - printf("np_writer() for multiple full chunk writes failed\n"); + HDprintf("np_writer() for multiple full chunk writes failed\n"); TEST_ERROR; } } @@ -955,7 +957,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c result = write_dsets_chunks(LWRITES, s, ds, step); if (s->use_np && !np_writer(result, step, s, np, config)) { - printf("np_writer() for multiple partial chunk writes failed\n"); + HDprintf("np_writer() for multiple partial chunk writes failed\n"); TEST_ERROR; } } @@ -970,7 +972,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c result = dsets_extent(INCR_EXT, s, ds); if (s->use_np && !np_writer(result, step, s, np, config)) { - printf("np_writer() for increasing dimension sizes failed\n"); + HDprintf("np_writer() for increasing dimension sizes failed\n"); TEST_ERROR; } } @@ -985,7 +987,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c result = dsets_extent(DECR_EXT, s, ds); if (s->use_np && !np_writer(result, step, s, np, config)) { - printf("np_writer() for decreasing dimension sizes failed\n"); + HDprintf("np_writer() for decreasing dimension sizes failed\n"); TEST_ERROR; } } @@ -1021,28 +1023,28 @@ write_dsets_chunks(unsigned action, const state_t *s, const dsets_state_t *ds, u if (s->implicit_index) { if (!write_chunks(action, ds->implicit_did, s->filetype, start, stride, count, block)) { - printf("H5Dwrite to chunked dataset: implicit index dataset failed\n"); + HDprintf("H5Dwrite to chunked dataset: implicit index dataset failed\n"); TEST_ERROR; } } if (s->fa_index) { if (!write_chunks(action, ds->fa_did, s->filetype, start, stride, count, block)) { - printf("H5Dwrite to chunked dataset: fa index dataset failed\n"); + HDprintf("H5Dwrite to chunked dataset: fa index dataset failed\n"); TEST_ERROR; } } if (s->ea_index) { if (!write_chunks(action, ds->ea_did, s->filetype, start, stride, count, block)) { - printf("H5Dwrite to chunked dataset: ea index dataset failed\n"); + HDprintf("H5Dwrite to chunked dataset: ea index dataset failed\n"); TEST_ERROR; } } if (s->bt2_index) { if (!write_chunks(action, ds->bt2_did, s->filetype, start, stride, count, block)) { - printf("H5Dwrite to chunked dataset: bt2 index dataset failed\n"); + HDprintf("H5Dwrite to chunked dataset: bt2 index dataset failed\n"); TEST_ERROR; } } @@ -1189,12 +1191,12 @@ write_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *str unsigned i; if ((sid = H5Dget_space(did)) < 0) { - printf("H5Sget_space failed\n"); + HDprintf("H5Sget_space failed\n"); TEST_ERROR; } if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block) < 0) { - printf("H5Sselect_hyperslab failed\n"); + HDprintf("H5Sselect_hyperslab failed\n"); TEST_ERROR; } @@ -1202,13 +1204,13 @@ write_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *str mem_dims[1] = block[1]; if ((mem_sid = H5Screate_simple(2, mem_dims, NULL)) < 0) { - printf("H5Screate_simple failed\n"); + HDprintf("H5Screate_simple failed\n"); TEST_ERROR; } /* Allocate the buffer for writing */ if ((buf = HDmalloc(block[0] * block[1] * sizeof(unsigned int))) == NULL) { - printf("HDmalloc failed\n"); + HDprintf("HDmalloc failed\n"); TEST_ERROR; } @@ -1221,12 +1223,12 @@ write_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *str } if (H5Dwrite(did, tid, mem_sid, sid, H5P_DEFAULT, buf) < 0) { - printf("H5Dwrite failed\n"); + HDprintf("H5Dwrite failed\n"); TEST_ERROR; } if (H5Sclose(sid) < 0) { - printf("H5Sclose failed\n"); + HDprintf("H5Sclose failed\n"); TEST_ERROR; } @@ -1300,12 +1302,12 @@ dset_extent_real(unsigned action, hid_t did, const hsize_t *chunk_dims) hid_t sid = badhid; if ((sid = H5Dget_space(did)) < 0) { - printf("H5Sget_space failed\n"); + HDprintf("H5Sget_space failed\n"); TEST_ERROR; } if (H5Sget_simple_extent_dims(sid, dims, max_dims) < 0) { - printf("H5Sget_simple_extent_dims failed\n"); + HDprintf("H5Sget_simple_extent_dims failed\n"); TEST_ERROR; } @@ -1319,7 +1321,7 @@ dset_extent_real(unsigned action, hid_t did, const hsize_t *chunk_dims) /* Cannot increase to more than maximum dimension (dim 0) for EA dataset */ if ((max_dims[0] != H5S_UNLIMITED && new[0] > max_dims[0]) || (max_dims[1] != H5S_UNLIMITED && new[1] > max_dims[1])) { - printf("Cannot exceed maximum dimension for dataset\n"); + HDprintf("Cannot exceed maximum dimension for dataset\n"); TEST_ERROR; } @@ -1330,7 +1332,7 @@ dset_extent_real(unsigned action, hid_t did, const hsize_t *chunk_dims) new[1] = dims[1] - 1; if (new[0] < chunk_dims[0] || new[1] < chunk_dims[1]) { - printf("Cannot decrease to less than chunk dimension\n"); + HDprintf("Cannot decrease to less than chunk dimension\n"); TEST_ERROR; } break; @@ -1341,12 +1343,12 @@ dset_extent_real(unsigned action, hid_t did, const hsize_t *chunk_dims) } /* end switch */ if (H5Dset_extent(did, new) < 0) { - printf("H5Dset_extent for dataset failed\n"); + HDprintf("H5Dset_extent for dataset failed\n"); TEST_ERROR; } if (H5Sclose(sid) < 0) { - printf("H5Sclose failed\n"); + HDprintf("H5Sclose failed\n"); TEST_ERROR; } @@ -1381,7 +1383,7 @@ write_dset_single(unsigned action, const state_t *s, const dsets_state_t *ds) check_set_partial_block(action, block, block, start); if (!write_chunks(action, ds->single_did, s->filetype, start, stride, count, block)) { - printf("H5Dwrite to dataset with single index dataset failed\n"); + HDprintf("H5Dwrite to dataset with single index dataset failed\n"); TEST_ERROR; } @@ -1428,7 +1430,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co dbgf(2, "Verify single full chunk write to dataset with single index; only verify 1 write\n"); if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, 0, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1439,7 +1441,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_dset_single(GWRITES, s, ds, fileclosed); if (s->use_np && !np_reader(result, 0, s, np)) { - printf("np_reader() for verifying addition failed\n"); + HDprintf("np_reader() for verifying addition failed\n"); TEST_ERROR; } else if (!result) TEST_ERROR; @@ -1452,7 +1454,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co dbgf(2, "Verify single partial chunk write to dataset with single index; only verify 1 write\n"); if(s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, 0, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1463,7 +1465,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_dset_single(PWRITES, s, ds, fileclosed); if (s->use_np && !np_reader(result, 0, s, np)) { - printf("np_reader() for verifying addition failed\n"); + HDprintf("np_reader() for verifying addition failed\n"); TEST_ERROR; } if (!result) TEST_ERROR; @@ -1483,7 +1485,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co step); if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1494,7 +1496,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_dsets_chunks(GWRITES, s, ds, step, fileclosed); if (s->use_np && !np_reader(result, step, s, np)) { - printf("np_reader() for verification failed\n"); + HDprintf("np_reader() for verification failed\n"); TEST_ERROR; } else if (!result) TEST_ERROR; @@ -1511,7 +1513,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co step); if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1522,7 +1524,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_dsets_chunks(PWRITES, s, ds, step, fileclosed); if (s->use_np && !np_reader(result, step, s, np)) { - printf("np_reader() for verification failed\n"); + HDprintf("np_reader() for verification failed\n"); TEST_ERROR; } else if (!result) TEST_ERROR; @@ -1539,7 +1541,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co step); if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1550,7 +1552,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_dsets_chunks(TWRITES, s, ds, step, fileclosed); if (s->use_np && !np_reader(result, step, s, np)) { - printf("np_reader() for verification failed\n"); + HDprintf("np_reader() for verification failed\n"); TEST_ERROR; } else if (!result) TEST_ERROR; @@ -1568,7 +1570,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co step); if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1579,7 +1581,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_dsets_chunks(LWRITES, s, ds, step, fileclosed); if (s->use_np && !np_reader(result, step, s, np)) { - printf("np_reader() for verification failed\n"); + HDprintf("np_reader() for verification failed\n"); TEST_ERROR; } else if (!result) TEST_ERROR; @@ -1593,7 +1595,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co step + 1); if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1603,7 +1605,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_dsets_extent(INCR_EXT, s, ds, step + 1); if (s->use_np && !np_reader(result, step, s, np)) { - printf("np_reader() for failed\n"); + HDprintf("np_reader() for failed\n"); TEST_ERROR; } else if (!result) TEST_ERROR; @@ -1617,7 +1619,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co step + 1); if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } /* Wait for a few ticks for the update to happen */ @@ -1626,7 +1628,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_dsets_extent(DECR_EXT, s, ds, step + 1); if (s->use_np && !np_reader(result, step, s, np)) { - printf("np_reader() for verification failed\n"); + HDprintf("np_reader() for verification failed\n"); TEST_ERROR; } else if (!result) TEST_ERROR; @@ -1664,28 +1666,28 @@ verify_dsets_chunks(unsigned action, const state_t *s, const dsets_state_t *ds, if (s->implicit_index) { if (!verify_chunks(action, ds->implicit_did, s->filetype, start, stride, count, block, fileclosed, s->flush_raw_data)) { - printf("verify_chunks() to dataset with implicit index failed\n"); + HDprintf("verify_chunks() to dataset with implicit index failed\n"); TEST_ERROR; } } if (s->fa_index) { if (!verify_chunks(action, ds->fa_did, s->filetype, start, stride, count, block, fileclosed, s->flush_raw_data)) { - printf("verify_chunks() to dataset with fixed array index failed\n"); + HDprintf("verify_chunks() to dataset with fixed array index failed\n"); TEST_ERROR; } } if (s->ea_index) { if (!verify_chunks(action, ds->ea_did, s->filetype, start, stride, count, block, fileclosed, s->flush_raw_data)) { - printf("verify_chunks() to dataset with extensible array index failed\n"); + HDprintf("verify_chunks() to dataset with extensible array index failed\n"); TEST_ERROR; } } if (s->bt2_index) { if (!verify_chunks(action, ds->bt2_did, s->filetype, start, stride, count, block, fileclosed, s->flush_raw_data)) { - printf("verify_chunks() to dataset with bt2 index failed\n"); + HDprintf("verify_chunks() to dataset with bt2 index failed\n"); TEST_ERROR; } } @@ -1713,37 +1715,37 @@ verify_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *st /* Refresh the dataset */ if (H5Drefresh(did) < 0) { - printf("H5Drefresh dataset failed\n"); + HDprintf("H5Drefresh dataset failed\n"); TEST_ERROR; } if ((sid = H5Dget_space(did)) < 0) { - printf("H5Dget_space dataset failed\n"); + HDprintf("H5Dget_space dataset failed\n"); TEST_ERROR; } /* Make the selection the file dataspace */ if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block) < 0) { - printf("H5Sselect to dataset failed\n"); + HDprintf("H5Sselect to dataset failed\n"); TEST_ERROR; } mem_dims[0] = block[0]; mem_dims[1] = block[1]; if ((mem_sid = H5Screate_simple(2, mem_dims, NULL)) < 0) { - printf("H5Screate_simple failed\n"); + HDprintf("H5Screate_simple failed\n"); TEST_ERROR; } /* Allocate the buffer for reading */ if ((rbuf = HDmalloc(block[0] * block[1] * sizeof(unsigned int))) == NULL) { - printf("HDmalloc failed\n"); + HDprintf("HDmalloc failed\n"); TEST_ERROR; } /* Read the data from the dataset into `rbuf` */ if (H5Dread(did, tid, mem_sid, sid, H5P_DEFAULT, rbuf) < 0) { - printf("H5Dread from dataset failed\n"); + HDprintf("H5Dread from dataset failed\n"); TEST_ERROR; } @@ -1752,27 +1754,27 @@ verify_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *st if(flush_raw_data || fileclosed) { if (action == GWRITES || action == TWRITES) { if (rbuf[i] != FILL_FULL) { - printf("Invalid value for dataset for GWRITES/TWRITES: %d\n", rbuf[i]); + HDprintf("Invalid value for dataset for GWRITES/TWRITES: %d\n", rbuf[i]); TEST_ERROR; } } else { HDassert(action == PWRITES || action == LWRITES); if (rbuf[i] != FILL_PARTIAL) { - printf("Invalid value for dataset for GWRITES/TWRITES: %d\n", rbuf[i]); + HDprintf("Invalid value for dataset for GWRITES/TWRITES: %d\n", rbuf[i]); TEST_ERROR; } } } else { /* No flush && not closing file */ if (action == GWRITES || action == TWRITES) { if (rbuf[i] != FILL_FULL && rbuf[i] != FILL_INIT) { - printf("Invalid value for dataset for GWRITES/TWRITES\n"); + HDprintf("Invalid value for dataset for GWRITES/TWRITES\n"); TEST_ERROR; } } else { if (rbuf[i] != FILL_PARTIAL && rbuf[i] != FILL_INIT) { - printf("Invalid value for dataset for GWRITES/TWRITES\n"); + HDprintf("Invalid value for dataset for GWRITES/TWRITES\n"); TEST_ERROR; } } @@ -1780,12 +1782,12 @@ verify_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *st } if (H5Sclose(sid) < 0) { - printf("H5Sclose failed\n"); + HDprintf("H5Sclose failed\n"); TEST_ERROR; } if (H5Sclose(mem_sid) < 0) { - printf("H5Sclose failed\n"); + HDprintf("H5Sclose failed\n"); TEST_ERROR; } @@ -1830,7 +1832,7 @@ verify_dsets_extent(unsigned action, const state_t *s, const dsets_state_t *ds, if (s->fa_index) { dbgf(2, "Verify dataset extent for FA dataset\n"); if (!verify_dset_extent_real(action, ds->fa_did, rows, cols, which)) { - printf("verify_read_dset() to dataset with fixed array index failed\n"); + HDprintf("verify_read_dset() to dataset with fixed array index failed\n"); TEST_ERROR; } } @@ -1838,7 +1840,7 @@ verify_dsets_extent(unsigned action, const state_t *s, const dsets_state_t *ds, if (s->ea_index) { dbgf(2, "Verify dataset extent for EA dataset\n"); if (!verify_dset_extent_real(action, ds->fa_did, rows, cols, which)) { - printf("verify_read_dset() to dataset with fixed array index failed\n"); + HDprintf("verify_read_dset() to dataset with fixed array index failed\n"); TEST_ERROR; } } @@ -1846,7 +1848,7 @@ verify_dsets_extent(unsigned action, const state_t *s, const dsets_state_t *ds, if (s->bt2_index) { dbgf(2, "Verify dataset extent for BT2 dataset\n"); if (!verify_dset_extent_real(action, ds->bt2_did, rows, cols, which)) { - printf("verify_read_dset() to dataset with fixed array index failed\n"); + HDprintf("verify_read_dset() to dataset with fixed array index failed\n"); TEST_ERROR; } } @@ -1869,17 +1871,17 @@ verify_dset_extent_real(unsigned action, hid_t did, unsigned rows, unsigned cols /* Refresh the dataset */ if (H5Drefresh(did) < 0) { - printf("H5Drefresh dataset failed\n"); + HDprintf("H5Drefresh dataset failed\n"); TEST_ERROR; } if ((sid = H5Dget_space(did)) < 0) { - printf("H5Dget_space dataset failed\n"); + HDprintf("H5Dget_space dataset failed\n"); TEST_ERROR; } if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) { - printf("H5Sget_simple_extent_dims() failed\n"); + HDprintf("H5Sget_simple_extent_dims() failed\n"); TEST_ERROR; } @@ -1902,7 +1904,7 @@ verify_dset_extent_real(unsigned action, hid_t did, unsigned rows, unsigned cols } /* end switch */ if (H5Sclose(sid) < 0) { - printf("H5Sclose failed\n"); + HDprintf("H5Sclose failed\n"); TEST_ERROR; } @@ -1936,7 +1938,7 @@ verify_dset_single(unsigned action, const state_t *s, const dsets_state_t *ds, b check_set_partial_block(action, block, block, start); if (!verify_chunks(action, ds->single_did, s->filetype, start, stride, count, block, fileclosed, s->flush_raw_data)) { - printf("verify_read_dset() to dataset with single index failed\n"); + HDprintf("verify_read_dset() to dataset with single index failed\n"); TEST_ERROR; } @@ -1969,36 +1971,36 @@ np_init(np_state_t *np, bool writer) /* If the named pipes are present at the start of the test, remove them */ if (HDaccess(np->fifo_writer_to_reader, F_OK) == 0) if (HDremove(np->fifo_writer_to_reader) != 0) { - printf("HDremove fifo_writer_to_reader failed\n"); + HDprintf("HDremove fifo_writer_to_reader failed\n"); TEST_ERROR; } if (HDaccess(np->fifo_reader_to_writer, F_OK) == 0) if (HDremove(np->fifo_reader_to_writer) != 0) { - printf("HDremove fifo_reader_to_writer failed\n"); + HDprintf("HDremove fifo_reader_to_writer failed\n"); TEST_ERROR; } /* Writer creates two named pipes(FIFO) */ if (HDmkfifo(np->fifo_writer_to_reader, 0600) < 0) { - printf("HDmkfifo fifo_writer_to_reader failed\n"); + HDprintf("HDmkfifo fifo_writer_to_reader failed\n"); TEST_ERROR; } if (HDmkfifo(np->fifo_reader_to_writer, 0600) < 0) { - printf("HDmkfifo fifo_reader_to_writer failed\n"); + HDprintf("HDmkfifo fifo_reader_to_writer failed\n"); TEST_ERROR; } } /* Both the writer and reader open the pipes */ if ((np->fd_writer_to_reader = HDopen(np->fifo_writer_to_reader, O_RDWR)) < 0) { - printf("HDopen fifo_writer_to_reader failed\n"); + HDprintf("HDopen fifo_writer_to_reader failed\n"); TEST_ERROR; } if ((np->fd_reader_to_writer = HDopen(np->fifo_reader_to_writer, O_RDWR)) < 0) { - printf("HDopen fifo_reader_to_writer failed\n"); + HDprintf("HDopen fifo_reader_to_writer failed\n"); TEST_ERROR; } @@ -2017,24 +2019,24 @@ np_close(np_state_t *np, bool writer) { /* Both the writer and reader close the named pipes */ if (HDclose(np->fd_writer_to_reader) < 0) { - printf("HDclose fd_writer_to_reader failed\n"); + HDprintf("HDclose fd_writer_to_reader failed\n"); TEST_ERROR; } if (HDclose(np->fd_reader_to_writer) < 0) { - printf("HDclose fd_reader_to_writer failed\n"); + HDprintf("HDclose fd_reader_to_writer failed\n"); TEST_ERROR; } /* Reader finishes last and deletes the named pipes */ if (!writer) { if (HDremove(np->fifo_writer_to_reader) != 0) { - printf("HDremove fifo_writer_to_reader failed\n"); + HDprintf("HDremove fifo_writer_to_reader failed\n"); TEST_ERROR; } if (HDremove(np->fifo_reader_to_writer) != 0) { - printf("HDremove fifo_reader_to_writer failed\n"); + HDprintf("HDremove fifo_reader_to_writer failed\n"); TEST_ERROR; } } @@ -2054,7 +2056,7 @@ np_writer(bool result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd_ /* The action fails */ if (!result) { - printf("action failed\n"); + HDprintf("action failed\n"); H5_FAILED(); AT(); @@ -2072,7 +2074,7 @@ np_writer(bool result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd_ /* Bump up the value of notify to tell the reader to start reading */ np->notify++; if (HDwrite(np->fd_writer_to_reader, &np->notify, sizeof(int)) < 0) { - printf("HDwrite failed\n"); + HDprintf("HDwrite failed\n"); TEST_ERROR; } @@ -2089,7 +2091,7 @@ np_writer(bool result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd_ /* Handshake between writer and reader */ if (!np_confirm_verify_notify(np->fd_reader_to_writer, step, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } } @@ -2110,7 +2112,7 @@ np_reader(bool result, unsigned step, const state_t *s, np_state_t *np) { /* The verification fails */ if (!result) { - printf("verify action failed\n"); + HDprintf("verify action failed\n"); H5_FAILED(); AT(); @@ -2127,7 +2129,7 @@ np_reader(bool result, unsigned step, const state_t *s, np_state_t *np) /* Send back the same notify value for acknowledgement: * --inform the writer to move to the next step */ if (HDwrite(np->fd_reader_to_writer, &np->notify, sizeof(int)) < 0) { - printf("HDwrite failed\n"); + HDprintf("HDwrite failed\n"); TEST_ERROR; } } @@ -2149,17 +2151,17 @@ np_confirm_verify_notify(int fd, unsigned step, const state_t *s, np_state_t *np if (step % s->csteps == 0) { np->verify++; if (HDread(fd, &np->notify, sizeof(int)) < 0) { - printf("HDread failed\n"); + HDprintf("HDread failed\n"); TEST_ERROR; } if (np->notify == -1) { - printf("reader/writer failed to verify\n"); + HDprintf("reader/writer failed to verify\n"); TEST_ERROR; } if (np->notify != np->verify) { - printf("received message %d, expecting %d\n", np->notify, np->verify); + HDprintf("received message %d, expecting %d\n", np->notify, np->verify); TEST_ERROR; } } @@ -2186,13 +2188,13 @@ closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_conf if(writer) { if (!close_dsets(ds)) { - printf("close_dsets() failed\n"); + HDprintf("close_dsets() failed\n"); TEST_ERROR; } dbgf(2, "Writer closes the file (flush of raw data is disabled)\n"); if (H5Fclose(s->file) < 0) { - printf("H5Fclose failed\n"); + HDprintf("H5Fclose failed\n"); TEST_ERROR; } @@ -2200,12 +2202,12 @@ closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_conf dbgf(2, "Writer notifies reader that the file is closed (flush of raw data is disabled)\n"); np->notify++; if (HDwrite(np->fd_writer_to_reader, &np->notify, sizeof(int)) < 0) { - printf("HDwrite failed\n"); + HDprintf("HDwrite failed\n"); TEST_ERROR; } if (!np_close(np, writer)) { - printf("np_close() failed\n"); + HDprintf("np_close() failed\n"); TEST_ERROR; } @@ -2215,13 +2217,13 @@ closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_conf dbgf(2, "Reader checks notify value from writer (flush of raw data is disabled)\n"); if (!np_confirm_verify_notify(np->fd_writer_to_reader, 0, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } /* Close the named pipes */ if (!np_close(np, writer)) { - printf("np_close() failed\n"); + HDprintf("np_close() failed\n"); TEST_ERROR; } @@ -2231,18 +2233,18 @@ closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_conf /* Verify the dataset again without named pipes */ dbgf(2, "Reader verifies data after writer closes the file (flush of raw data is disabled)\n"); if(!verify_dsets_operations(s, ds, config, np, true)) { - printf("verify_dsets_operations() failed\n"); + HDprintf("verify_dsets_operations() failed\n"); TEST_ERROR } if (!close_dsets(ds)) { - printf("close_dsets() failed\n"); + HDprintf("close_dsets() failed\n"); TEST_ERROR; } dbgf(2, "Reader closes the file (flush of raw data is disabled)\n"); if (H5Fclose(s->file) < 0) { - printf("H5Fclose failed\n"); + HDprintf("H5Fclose failed\n"); TEST_ERROR; } @@ -2269,7 +2271,7 @@ main(int argc, char **argv) dsets_state_t ds; if (!state_init(&s, argc, argv)) { - printf("state_init() failed\n"); + HDprintf("state_init() failed\n"); TEST_ERROR; } @@ -2280,7 +2282,7 @@ main(int argc, char **argv) else if (personality != NULL && HDstrcmp(personality, "vfd_swmr_dsetchks_reader") == 0) writer = false; else { - printf("unknown personality, expected vfd_swmr_dsetchks_{reader,writer}\n"); + HDprintf("unknown personality, expected vfd_swmr_dsetchks_{reader,writer}\n"); TEST_ERROR; } @@ -2289,7 +2291,7 @@ main(int argc, char **argv) /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(true, s.use_vfd_swmr, true, 4096, &config)) < 0) { - printf("vfd_swmr_create_fapl() failed\n"); + HDprintf("vfd_swmr_create_fapl() failed\n"); TEST_ERROR; } @@ -2301,54 +2303,54 @@ main(int argc, char **argv) if (writer) { if ((s.file = H5Fcreate(s.filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) { - printf("H5Fcreate failed\n"); + HDprintf("H5Fcreate failed\n"); TEST_ERROR; } if (!create_dsets(&s, &ds)) { - printf("create_dsets() failed\n"); + HDprintf("create_dsets() failed\n"); TEST_ERROR; } } else { if ((s.file = H5Fopen(s.filename, H5F_ACC_RDONLY, fapl)) < 0) { - printf("H5Fopen failed\n"); + HDprintf("H5Fopen failed\n"); TEST_ERROR; } if (!open_dsets(&s, &ds)) { - printf("open_dsets() failed\n"); + HDprintf("open_dsets() failed\n"); TEST_ERROR; } } /* Initiailze named pipes */ if (s.use_np && !np_init(&np, writer)) { - printf("np_init() failed\n"); + HDprintf("np_init() failed\n"); TEST_ERROR; } if (writer) { if (!perform_dsets_operations(&s, &ds, &config, &np)) { - printf("perform_dsets_operations() failed\n"); + HDprintf("perform_dsets_operations() failed\n"); TEST_ERROR; } } else { if (!verify_dsets_operations(&s, &ds, &config, &np, false)) { - printf("perform_dsets_operations() failed\n"); + HDprintf("perform_dsets_operations() failed\n"); TEST_ERROR; } } if (H5Pclose(fapl) < 0) { - printf("H5Pclose failed\n"); + HDprintf("H5Pclose failed\n"); TEST_ERROR; } if (H5Pclose(fcpl) < 0) { - printf("H5Pclose failed\n"); + HDprintf("H5Pclose failed\n"); TEST_ERROR; } @@ -2364,17 +2366,17 @@ main(int argc, char **argv) } else { if (!close_dsets(&ds)) { - printf("close_dsets() failed\n"); + HDprintf("close_dsets() failed\n"); TEST_ERROR; } if (H5Fclose(s.file) < 0) { - printf("H5Fclose failed\n"); + HDprintf("H5Fclose failed\n"); TEST_ERROR; } if (s.use_np && !np_close(&np, writer)) { - printf("np_close() failed\n"); + HDprintf("np_close() failed\n"); TEST_ERROR; } } diff --git a/test/vfd_swmr_dsetops_writer.c b/test/vfd_swmr_dsetops_writer.c index 9aded9b..0b346f6 100644 --- a/test/vfd_swmr_dsetops_writer.c +++ b/test/vfd_swmr_dsetops_writer.c @@ -233,8 +233,10 @@ state_init(state_t *s, int argc, char **argv) esnprintf(s->progname, sizeof(s->progname), "%s", tfile); - if (tfile) + if (tfile) { HDfree(tfile); + tfile = NULL; + } while ((ch = getopt(argc, argv, "pte:gkm:n:s:r:l:w:bqSNUu:c:")) != -1) { switch (ch) { @@ -344,14 +346,14 @@ state_init(state_t *s, int argc, char **argv) /* Enable compact write (-t) without compact dataset (-p) */ if (s->compact_write && !s->compact) { - printf("Enable compact write without compact dataset\n"); + HDprintf("Enable compact write without compact dataset\n"); usage(s->progname); goto error; } /* Enable sequential/random/hyperslab/raw data writes (-s/-r/-l/-w) without contiguous/chunked dataset (-g/-k) */ if ((s->swrites || s->rwrites || s->lwrites || s->wwrites) && !(s->contig || s->chunked)) { - printf("Enable sequential/random/hypuerslab/raw data writes without contiguous/chunked dataset\n"); + HDprintf("Enable sequential/random/hypuerslab/raw data writes without contiguous/chunked dataset\n"); usage(s->progname); goto error; } @@ -871,7 +873,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c result = write_dset_compact(s, ds); if (s->use_np && !np_writer(result, 0, s, np, config)) { - printf("np_writer() for addition failed\n"); + HDprintf("np_writer() for addition failed\n"); TEST_ERROR; } } @@ -889,7 +891,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c result = dsets_action(SEQ_WRITE, s, ds, step); if (s->use_np && !np_writer(result, step, s, np, config)) { - printf("np_writer() for sequential writes failed\n"); + HDprintf("np_writer() for sequential writes failed\n"); TEST_ERROR; } } @@ -910,7 +912,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c result = dsets_action(RANDOM_WRITE, s, ds, newstep); if (s->use_np && !np_writer(result, step, s, np, config)) { - printf("np_writer() for random writes failed\n"); + HDprintf("np_writer() for random writes failed\n"); TEST_ERROR; } } @@ -926,7 +928,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c result = dsets_action(HYPER_WRITE, s, ds, k); if (s->use_np && !np_writer(result, step, s, np, config)) { - printf("np_writer() for hyperslab writes failed\n"); + HDprintf("np_writer() for hyperslab writes failed\n"); TEST_ERROR; } } @@ -941,7 +943,7 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c result = dsets_action(MODIFY_DATA, s, ds, step); if (s->use_np && !np_writer(result, step, s, np, config)) { - printf("np_writer() for modify raw data failed\n"); + HDprintf("np_writer() for modify raw data failed\n"); TEST_ERROR; } } @@ -1200,7 +1202,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co dbgf(2, "Verify writes to compact dataset\n"); if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, 0, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1211,7 +1213,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_dset_compact(s, ds, fileclosed, config->flush_raw_data); if (s->use_np && !np_reader(result, 0, s, np)) { - printf("np_reader() for verifying addition failed\n"); + HDprintf("np_reader() for verifying addition failed\n"); TEST_ERROR; } else if (!result) TEST_ERROR; @@ -1231,7 +1233,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co dbgf(2, "Verify sequential writes %u to dataset\n", step); if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1242,7 +1244,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_dsets_action(SEQ_WRITE, s, ds, step, fileclosed); if (s->use_np && !np_reader(result, step, s, np)) { - printf("np_reader() for verifying addition failed\n"); + HDprintf("np_reader() for verifying addition failed\n"); TEST_ERROR; } else if (!result) TEST_ERROR; @@ -1266,7 +1268,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co dbgf(2, "Random step is %u\n", newstep); if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1277,7 +1279,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_dsets_action(RANDOM_WRITE, s, ds, newstep, fileclosed); if (s->use_np && !np_reader(result, step, s, np)) { - printf("np_reader() for verifying addition failed\n"); + HDprintf("np_reader() for verifying addition failed\n"); TEST_ERROR; } else if (!result) TEST_ERROR; @@ -1295,7 +1297,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co dbgf(2, "Verify hyperslab writes %u to dataset\n", step); if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1306,7 +1308,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_dsets_action(HYPER_WRITE, s, ds, k, fileclosed); if (s->use_np && !np_reader(result, step, s, np)) { - printf("np_reader() for verifying addition failed\n"); + HDprintf("np_reader() for verifying addition failed\n"); TEST_ERROR; } else if (!result) TEST_ERROR; @@ -1323,7 +1325,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co dbgf(2, "Verify raw data modification %u to dataset\n", step); if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, step, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } @@ -1334,7 +1336,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_dsets_action(MODIFY_DATA, s, ds, step, fileclosed); if (s->use_np && !np_reader(result, step, s, np)) { - printf("np_reader() for verifying addition failed\n"); + HDprintf("np_reader() for verifying addition failed\n"); TEST_ERROR; } else if (!result) TEST_ERROR; @@ -1377,7 +1379,7 @@ verify_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, if (s->contig) { if (!verify_dset(ds->contig_did, s->filetype, mem_sid, ds->contig_sid, start, stride, count, block, vbuf, fileclosed, s->flush_raw_data)) { - printf("verify_dset() to contiguous dataset failed\n"); + HDprintf("verify_dset() to contiguous dataset failed\n"); TEST_ERROR; } } @@ -1387,31 +1389,31 @@ verify_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, if (!verify_dset(ds->single_did, s->filetype, mem_sid, ds->single_sid, start, stride, count, block, vbuf, fileclosed, s->flush_raw_data)) { - printf("verify_dset() to chunked dataset: single index dataset failed\n"); + HDprintf("verify_dset() to chunked dataset: single index dataset failed\n"); TEST_ERROR; } if (!verify_dset(ds->implicit_did, s->filetype, mem_sid, ds->implicit_sid, start, stride, count, block, vbuf, fileclosed, s->flush_raw_data)) { - printf("verify_dset() to chunked dataset: implicit index dataset failed\n"); + HDprintf("verify_dset() to chunked dataset: implicit index dataset failed\n"); TEST_ERROR; } if (!verify_dset(ds->fa_did, s->filetype, mem_sid, ds->fa_sid, start, stride, count, block, vbuf, fileclosed, s->flush_raw_data)) { - printf("verify_dset() to chunked dataset: fa index dataset failed\n"); + HDprintf("verify_dset() to chunked dataset: fa index dataset failed\n"); TEST_ERROR; } if (!verify_dset(ds->ea_did, s->filetype, mem_sid, ds->ea_sid, start, stride, count, block, vbuf, fileclosed, s->flush_raw_data)) { - printf("verify_dset() to chunked dataset: ea index dataset failed\n"); + HDprintf("verify_dset() to chunked dataset: ea index dataset failed\n"); TEST_ERROR; } if (!verify_dset(ds->bt2_did, s->filetype, mem_sid, ds->bt2_sid, start, stride, count, block, vbuf, fileclosed, s->flush_raw_data)) { - printf("verify_dset() to chunked dataset: bt2 index dataset failed\n"); + HDprintf("verify_dset() to chunked dataset: bt2 index dataset failed\n"); TEST_ERROR; } } @@ -1499,7 +1501,7 @@ verify_dset_compact(const state_t *s, const dsets_state_t *ds, bool fileclosed, /* Refresh the dataset */ if (H5Drefresh(ds->compact_did) < 0) { - printf("H5Drefresh dataset failed\n"); + HDprintf("H5Drefresh dataset failed\n"); TEST_ERROR; } @@ -1516,7 +1518,7 @@ verify_dset_compact(const state_t *s, const dsets_state_t *ds, bool fileclosed, for (i = 0; i < s->compact_elmts; i++) { if(flush_raw_data || fileclosed) { if (rbuf[i] != (i + 1)) { - printf("Invalid value for compact dataset element\n"); + HDprintf("Invalid value for compact dataset element\n"); TEST_ERROR; } } else { /* No flush && not closing file */ @@ -1776,13 +1778,13 @@ closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_conf if(writer) { if (!close_dsets(ds)) { - printf("close_dsets() failed\n"); + HDprintf("close_dsets() failed\n"); TEST_ERROR; } dbgf(2, "Writer closes the file (flush of raw data is disabled)\n"); if (H5Fclose(s->file) < 0) { - printf("H5Fclose failed\n"); + HDprintf("H5Fclose failed\n"); TEST_ERROR; } @@ -1790,12 +1792,12 @@ closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_conf dbgf(2, "Writer notifies reader that the file is closed (flush of raw data is disabled)\n"); np->notify++; if (HDwrite(np->fd_writer_to_reader, &np->notify, sizeof(int)) < 0) { - printf("HDwrite failed\n"); + HDprintf("HDwrite failed\n"); TEST_ERROR; } if (!np_close(np, writer)) { - printf("np_close() failed\n"); + HDprintf("np_close() failed\n"); TEST_ERROR; } @@ -1805,13 +1807,13 @@ closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_conf dbgf(2, "Reader checks notify value from writer (flush of raw data is disabled)\n"); if (!np_confirm_verify_notify(np->fd_writer_to_reader, 0, s, np)) { - printf("np_confirm_verify_notify() verify/notify not in sync failed\n"); + HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } /* Close the named pipes */ if (!np_close(np, writer)) { - printf("np_close() failed\n"); + HDprintf("np_close() failed\n"); TEST_ERROR; } @@ -1821,18 +1823,18 @@ closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_conf /* Verify the dataset again without named pipes */ dbgf(2, "Reader verifies data after writer closes the file (flush of raw data is disabled)\n"); if(!verify_dsets_operations(s, ds, config, np, true)) { - printf("verify_dsets_operations() failed\n"); + HDprintf("verify_dsets_operations() failed\n"); TEST_ERROR } if (!close_dsets(ds)) { - printf("close_dsets() failed\n"); + HDprintf("close_dsets() failed\n"); TEST_ERROR; } dbgf(2, "Reader closes the file (flush of raw data is disabled)\n"); if (H5Fclose(s->file) < 0) { - printf("H5Fclose failed\n"); + HDprintf("H5Fclose failed\n"); TEST_ERROR; } @@ -1922,14 +1924,14 @@ main(int argc, char **argv) if (writer) { if(!perform_dsets_operations(&s, &ds, &config, &np)) { - printf("perform_dsets_operations() failed\n"); + HDprintf("perform_dsets_operations() failed\n"); TEST_ERROR; } } else { if(!verify_dsets_operations(&s, &ds, &config, &np, false)) { - printf("perform_dsets_operations() failed\n"); + HDprintf("perform_dsets_operations() failed\n"); TEST_ERROR; } } @@ -1951,17 +1953,17 @@ main(int argc, char **argv) } else { if (!close_dsets(&ds)) { - printf("close_dsets() failed\n"); + HDprintf("close_dsets() failed\n"); TEST_ERROR; } if (H5Fclose(s.file) < 0) { - printf("H5Fclose failed\n"); + HDprintf("H5Fclose failed\n"); TEST_ERROR; } if (s.use_np && !np_close(&np, writer)) { - printf("np_close() failed\n"); + HDprintf("np_close() failed\n"); TEST_ERROR; } } -- cgit v0.12 From 139142cb79aa3e0ba0f2275654f8edd8376302fe Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 12 Aug 2021 16:43:22 +0000 Subject: Committing clang-format changes --- src/H5Fvfd_swmr.c | 4 +- test/vfd_swmr_attrdset_writer.c | 45 ++++++------ test/vfd_swmr_dsetchks_writer.c | 121 +++++++++++++++++++-------------- test/vfd_swmr_dsetops_writer.c | 147 +++++++++++++++++++++------------------- 4 files changed, 172 insertions(+), 145 deletions(-) diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c index 7294494..d7cb830 100644 --- a/src/H5Fvfd_swmr.c +++ b/src/H5Fvfd_swmr.c @@ -769,7 +769,7 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, hbool_t wait_for_reader) /* 1) If requested, flush all raw data to the HDF5 file. * */ - if(shared->vfd_swmr_config.flush_raw_data) { + if (shared->vfd_swmr_config.flush_raw_data) { /* Test to see if b-tree corruption seen in VFD SWMR tests * is caused by client hiding data from the metadata cache. Do @@ -778,7 +778,7 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, hbool_t wait_for_reader) * when the above flush_raw_data flag is set. */ - if (H5D_flush_all(f) < 0) + if (H5D_flush_all(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush dataset cache") diff --git a/test/vfd_swmr_attrdset_writer.c b/test/vfd_swmr_attrdset_writer.c index e10184f..67eeb2c 100644 --- a/test/vfd_swmr_attrdset_writer.c +++ b/test/vfd_swmr_attrdset_writer.c @@ -150,16 +150,16 @@ static bool open_dset_real(hid_t fid, hid_t *did, const char *name, unsigned *ma unsigned *min_dense); static bool close_dsets(const dsets_state_t *ds); -static bool perform_dsets_operations(state_t *s, dsets_state_t *ds, - H5F_vfd_swmr_config_t *config, np_state_t *np); +static bool perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, + np_state_t *np); static bool attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which); static bool attr_action(unsigned action, const state_t *s, hid_t did, unsigned which); static bool add_attr(const state_t *s, hid_t did, unsigned int which); static bool modify_attr(const state_t *s, hid_t did, unsigned int which); static bool delete_attr(hid_t did, unsigned int which); -static bool verify_dsets_operations(state_t *s, dsets_state_t *ds, - H5F_vfd_swmr_config_t *config, np_state_t *np); +static bool verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, + np_state_t *np); static bool verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which); static bool verify_attr_action(unsigned action, hid_t did, unsigned which); @@ -226,8 +226,8 @@ state_init(state_t *s, int argc, char **argv) { unsigned long tmp; int ch; - const hsize_t dims = 1; - char *tfile = NULL; + const hsize_t dims = 1; + char * tfile = NULL; char * end; *s = ALL_HID_INITIALIZER; @@ -919,12 +919,12 @@ error: * DELETE_ATTR : -d option */ static bool -perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np) +perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np) { - unsigned step; - bool result; - unsigned dd; - bool ret = true; + unsigned step; + bool result; + unsigned dd; + bool ret = true; for (step = 0; step < s->asteps; step++) { dbgf(2, "Adding attribute %d\n", step); @@ -956,9 +956,9 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c TEST_ERROR; } } - } + } - if (s->dattrs) { + if (s->dattrs) { /* Need to sync up writer/reader before moving onto the next phase */ if (s->use_np && !np_writer(true, 0, s, np, config)) { @@ -1282,11 +1282,11 @@ error: * --not appliable for -m option */ static bool -verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np) +verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np) { - unsigned step; - bool result; - unsigned dd; + unsigned step; + bool result; + unsigned dd; /* Start verifying addition */ for (step = 0; step < s->asteps; step++) { @@ -1536,10 +1536,11 @@ verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned HDprintf("HDmalloc failed\n"); TEST_ERROR; } - } else { + } + else { if (action == MODIFY_ATTR) tmp_val = which + 1; - else + else tmp_val = which; } @@ -2031,18 +2032,16 @@ main(int argc, char **argv) } if (writer) { - if(!perform_dsets_operations(&s, &ds, &config, &np)) { + if (!perform_dsets_operations(&s, &ds, &config, &np)) { HDprintf("perform_dsets_operations() failed\n"); TEST_ERROR; } - } else { - if(!verify_dsets_operations(&s, &ds, &config, &np)) { + if (!verify_dsets_operations(&s, &ds, &config, &np)) { HDprintf("verify_dsets_operations() failed\n"); TEST_ERROR; } - } if (!close_dsets(&ds)) { diff --git a/test/vfd_swmr_dsetchks_writer.c b/test/vfd_swmr_dsetchks_writer.c index d39ebf8..d264ca9 100644 --- a/test/vfd_swmr_dsetchks_writer.c +++ b/test/vfd_swmr_dsetchks_writer.c @@ -167,8 +167,8 @@ static void setup_selection(unsigned action, unsigned which, const state_t *s, c static void check_set_edge_block(const state_t *s, const dsets_state_t *ds, unsigned i, unsigned j, hsize_t *block); static void check_set_partial_block(unsigned action, const hsize_t *dims, hsize_t *block, hsize_t *start); -static bool write_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *stride, hsize_t *count, - hsize_t *block); +static bool write_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *stride, + hsize_t *count, hsize_t *block); static bool write_dset_single(unsigned action, const state_t *s, const dsets_state_t *ds); static bool dsets_extent(unsigned action, const state_t *s, const dsets_state_t *ds); @@ -177,9 +177,10 @@ static bool dset_extent_real(unsigned action, hid_t did, const hsize_t *chunk_di static bool verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np, bool fileclosed); -static bool verify_dsets_chunks(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which, bool fileclosed); +static bool verify_dsets_chunks(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which, + bool fileclosed); static bool verify_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *stride, - hsize_t *count, hsize_t *block, bool fileclosed, bool flush_raw_data); + hsize_t *count, hsize_t *block, bool fileclosed, bool flush_raw_data); static bool verify_dset_single(unsigned action, const state_t *s, const dsets_state_t *ds, bool fileclosed); static bool verify_dsets_extent(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which); @@ -191,13 +192,13 @@ static void usage(const char *progname) { HDfprintf(stderr, - "usage: %s \n" - " [-s] [-i] [-f] [-e] [-r]\n" - " [-m rows] [-n cols]\n" - " [-g gwrites] [-p pwrites] [-t twrites] [-l lwrites]\n" - " [-x xincrs] [-y decrs]\n" - " [-u nticks] [-c csteps] [-U] [-S] [-N] [-q] [-b] [-o]\n", - progname); + "usage: %s \n" + " [-s] [-i] [-f] [-e] [-r]\n" + " [-m rows] [-n cols]\n" + " [-g gwrites] [-p pwrites] [-t twrites] [-l lwrites]\n" + " [-x xincrs] [-y decrs]\n" + " [-u nticks] [-c csteps] [-U] [-S] [-N] [-q] [-b] [-o]\n", + progname); HDfprintf( stderr, @@ -265,13 +266,13 @@ state_init(state_t *s, int argc, char **argv) { unsigned long tmp; int ch; - char *tfile = NULL; + char * tfile = NULL; char * end; *s = ALL_HID_INITIALIZER; if (H5_basename(argv[0], &tfile) < 0) { - HDprintf("H5_basename failed\n"); + HDprintf("H5_basename failed\n"); TEST_ERROR } @@ -321,7 +322,7 @@ state_init(state_t *s, int argc, char **argv) s->use_vfd_swmr = false; break; - case 'U': /* Disable flush of raw data */ + case 'U': /* Disable flush of raw data */ s->flush_raw_data = false; break; @@ -1182,7 +1183,7 @@ check_set_partial_block(unsigned action, const hsize_t *chunk_dims, hsize_t *blo */ static bool write_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *stride, hsize_t *count, - hsize_t *block) + hsize_t *block) { hid_t sid = badhid; hid_t mem_sid = badhid; @@ -1415,7 +1416,8 @@ error: * --DECR_EXT: verify the decrease to dataset dimensions sizes */ static bool -verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np, bool fileclosed) +verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np, + bool fileclosed) { unsigned step; unsigned allowed_writes; @@ -1435,7 +1437,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co } /* Wait for a few ticks for the update to happen */ - if (!fileclosed) + if (!fileclosed) decisleep(config->tick_len * s->update_interval); result = verify_dset_single(GWRITES, s, ds, fileclosed); @@ -1443,7 +1445,8 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co if (s->use_np && !np_reader(result, 0, s, np)) { HDprintf("np_reader() for verifying addition failed\n"); TEST_ERROR; - } else if (!result) + } + else if (!result) TEST_ERROR; } @@ -1453,11 +1456,11 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co if (s->pwrites || s->lwrites) { dbgf(2, "Verify single partial chunk write to dataset with single index; only verify 1 write\n"); - if(s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, 0, s, np)) { + if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, 0, s, np)) { HDprintf("np_confirm_verify_notify() verify/notify not in sync failed\n"); TEST_ERROR; } - + /* Wait for a few ticks for the update to happen */ if (!fileclosed) decisleep(config->tick_len * s->update_interval); @@ -1467,7 +1470,8 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co if (s->use_np && !np_reader(result, 0, s, np)) { HDprintf("np_reader() for verifying addition failed\n"); TEST_ERROR; - } if (!result) + } + if (!result) TEST_ERROR; } } @@ -1490,7 +1494,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co } /* Wait for a few ticks for the update to happen */ - if(!fileclosed) + if (!fileclosed) decisleep(config->tick_len * s->update_interval); result = verify_dsets_chunks(GWRITES, s, ds, step, fileclosed); @@ -1498,7 +1502,8 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co if (s->use_np && !np_reader(result, step, s, np)) { HDprintf("np_reader() for verification failed\n"); TEST_ERROR; - } else if (!result) + } + else if (!result) TEST_ERROR; } } @@ -1518,7 +1523,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co } /* Wait for a few ticks for the update to happen */ - if(!fileclosed) + if (!fileclosed) decisleep(config->tick_len * s->update_interval); result = verify_dsets_chunks(PWRITES, s, ds, step, fileclosed); @@ -1526,7 +1531,8 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co if (s->use_np && !np_reader(result, step, s, np)) { HDprintf("np_reader() for verification failed\n"); TEST_ERROR; - } else if (!result) + } + else if (!result) TEST_ERROR; } } @@ -1546,7 +1552,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co } /* Wait for a few ticks for the update to happen */ - if(!fileclosed) + if (!fileclosed) decisleep(config->tick_len * s->update_interval); result = verify_dsets_chunks(TWRITES, s, ds, step, fileclosed); @@ -1554,7 +1560,8 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co if (s->use_np && !np_reader(result, step, s, np)) { HDprintf("np_reader() for verification failed\n"); TEST_ERROR; - } else if (!result) + } + else if (!result) TEST_ERROR; } } @@ -1575,7 +1582,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co } /* Wait for a few ticks for the update to happen */ - if(!fileclosed) + if (!fileclosed) decisleep(config->tick_len * s->update_interval); result = verify_dsets_chunks(LWRITES, s, ds, step, fileclosed); @@ -1583,7 +1590,8 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co if (s->use_np && !np_reader(result, step, s, np)) { HDprintf("np_reader() for verification failed\n"); TEST_ERROR; - } else if (!result) + } + else if (!result) TEST_ERROR; } } @@ -1607,7 +1615,8 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co if (s->use_np && !np_reader(result, step, s, np)) { HDprintf("np_reader() for failed\n"); TEST_ERROR; - } else if (!result) + } + else if (!result) TEST_ERROR; } } @@ -1627,10 +1636,11 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co result = verify_dsets_extent(DECR_EXT, s, ds, step + 1); - if (s->use_np && !np_reader(result, step, s, np)) { + if (s->use_np && !np_reader(result, step, s, np)) { HDprintf("np_reader() for verification failed\n"); TEST_ERROR; - } else if (!result) + } + else if (!result) TEST_ERROR; } } @@ -1652,7 +1662,8 @@ error: * LWRITEs: verify `which` write that covers multiple partial chunks */ static bool -verify_dsets_chunks(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which, bool fileclosed) +verify_dsets_chunks(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which, + bool fileclosed) { hsize_t start[2] = {0, 0}; hsize_t stride[2] = {0, 0}; @@ -1665,28 +1676,32 @@ verify_dsets_chunks(unsigned action, const state_t *s, const dsets_state_t *ds, setup_selection(action, which, s, ds, start, stride, count, block); if (s->implicit_index) { - if (!verify_chunks(action, ds->implicit_did, s->filetype, start, stride, count, block, fileclosed, s->flush_raw_data)) { + if (!verify_chunks(action, ds->implicit_did, s->filetype, start, stride, count, block, fileclosed, + s->flush_raw_data)) { HDprintf("verify_chunks() to dataset with implicit index failed\n"); TEST_ERROR; } } if (s->fa_index) { - if (!verify_chunks(action, ds->fa_did, s->filetype, start, stride, count, block, fileclosed, s->flush_raw_data)) { + if (!verify_chunks(action, ds->fa_did, s->filetype, start, stride, count, block, fileclosed, + s->flush_raw_data)) { HDprintf("verify_chunks() to dataset with fixed array index failed\n"); TEST_ERROR; } } if (s->ea_index) { - if (!verify_chunks(action, ds->ea_did, s->filetype, start, stride, count, block, fileclosed, s->flush_raw_data)) { + if (!verify_chunks(action, ds->ea_did, s->filetype, start, stride, count, block, fileclosed, + s->flush_raw_data)) { HDprintf("verify_chunks() to dataset with extensible array index failed\n"); TEST_ERROR; } } if (s->bt2_index) { - if (!verify_chunks(action, ds->bt2_did, s->filetype, start, stride, count, block, fileclosed, s->flush_raw_data)) { + if (!verify_chunks(action, ds->bt2_did, s->filetype, start, stride, count, block, fileclosed, + s->flush_raw_data)) { HDprintf("verify_chunks() to dataset with bt2 index failed\n"); TEST_ERROR; } @@ -1705,7 +1720,7 @@ error: */ static bool verify_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *stride, hsize_t *count, - hsize_t *block, bool fileclosed, bool flush_raw_data) + hsize_t *block, bool fileclosed, bool flush_raw_data) { hid_t mem_sid = badhid; hid_t sid = badhid; @@ -1751,7 +1766,7 @@ verify_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *st /* Verify the data read in `rbuf` is as the fill value expected */ for (i = 0; i < block[0] * block[1]; i++) { - if(flush_raw_data || fileclosed) { + if (flush_raw_data || fileclosed) { if (action == GWRITES || action == TWRITES) { if (rbuf[i] != FILL_FULL) { HDprintf("Invalid value for dataset for GWRITES/TWRITES: %d\n", rbuf[i]); @@ -1765,7 +1780,8 @@ verify_chunks(unsigned action, hid_t did, hid_t tid, hsize_t *start, hsize_t *st TEST_ERROR; } } - } else { /* No flush && not closing file */ + } + else { /* No flush && not closing file */ if (action == GWRITES || action == TWRITES) { if (rbuf[i] != FILL_FULL && rbuf[i] != FILL_INIT) { HDprintf("Invalid value for dataset for GWRITES/TWRITES\n"); @@ -1937,7 +1953,8 @@ verify_dset_single(unsigned action, const state_t *s, const dsets_state_t *ds, b if (action == PWRITES) check_set_partial_block(action, block, block, start); - if (!verify_chunks(action, ds->single_did, s->filetype, start, stride, count, block, fileclosed, s->flush_raw_data)) { + if (!verify_chunks(action, ds->single_did, s->filetype, start, stride, count, block, fileclosed, + s->flush_raw_data)) { HDprintf("verify_read_dset() to dataset with single index failed\n"); TEST_ERROR; } @@ -2186,7 +2203,7 @@ closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_conf { HDassert(s->use_np); - if(writer) { + if (writer) { if (!close_dsets(ds)) { HDprintf("close_dsets() failed\n"); TEST_ERROR; @@ -2210,8 +2227,8 @@ closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_conf HDprintf("np_close() failed\n"); TEST_ERROR; } - - } else { + } + else { /* Wait for a few ticks for the file to close in writer */ decisleep(config->tick_len * s->update_interval); @@ -2229,10 +2246,10 @@ closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_conf /* Turn off named pipes */ s->use_np = false; - + /* Verify the dataset again without named pipes */ dbgf(2, "Reader verifies data after writer closes the file (flush of raw data is disabled)\n"); - if(!verify_dsets_operations(s, ds, config, np, true)) { + if (!verify_dsets_operations(s, ds, config, np, true)) { HDprintf("verify_dsets_operations() failed\n"); TEST_ERROR } @@ -2247,7 +2264,6 @@ closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_conf HDprintf("H5Fclose failed\n"); TEST_ERROR; } - } return true; @@ -2354,16 +2370,17 @@ main(int argc, char **argv) TEST_ERROR; } - /* When flush of raw data is disabled, special handling is performed + /* When flush of raw data is disabled, special handling is performed * via closing_on_noflush() when closing the file. - * Nothing needs to be done for -x or -y options + * Nothing needs to be done for -x or -y options * (increase and decrease dataset dimension sizes). */ - if(!s.flush_raw_data && !s.xincrs && !s.ydecrs && s.use_np) { + if (!s.flush_raw_data && !s.xincrs && !s.ydecrs && s.use_np) { - if(!closing_on_noflush(writer, &s, &ds, &config, &np)) + if (!closing_on_noflush(writer, &s, &ds, &config, &np)) TEST_ERROR - } else { + } + else { if (!close_dsets(&ds)) { HDprintf("close_dsets() failed\n"); diff --git a/test/vfd_swmr_dsetops_writer.c b/test/vfd_swmr_dsetops_writer.c index 0b346f6..f98843d 100644 --- a/test/vfd_swmr_dsetops_writer.c +++ b/test/vfd_swmr_dsetops_writer.c @@ -54,11 +54,11 @@ typedef struct { bool chunked; /* -k option: create chunked datasets with 5 indexing types */ unsigned int rows; /* -m option for contiguous and/or chunked datasets */ unsigned int cols; /* -n option: sequential writes to contiguous and/or chunked datasets */ - unsigned int rwrites; /* -r option: random writes to contiguous and/or chunked datasets */ - unsigned int lwrites; /* -l option: hyperslab writes to contiguous and/or chunked datasets */ - unsigned int wwrites; /* -w option: modify raw data to contiguous and/or chunked datasets */ - unsigned int lastwrite; /* The last operation (-s, -r, -l or -w) performed. */ + unsigned int swrites; /* -s option: sequential writes to contiguous and/or chunked datasets */ + unsigned int rwrites; /* -r option: random writes to contiguous and/or chunked datasets */ + unsigned int lwrites; /* -l option: hyperslab writes to contiguous and/or chunked datasets */ + unsigned int wwrites; /* -w option: modify raw data to contiguous and/or chunked datasets */ + unsigned int lastwrite; /* The last operation (-s, -r, -l or -w) performed. */ } state_t; /* Initializations for state_t */ @@ -67,9 +67,9 @@ typedef struct { { \ .filename = "", .file = H5I_INVALID_HID, .filetype = H5T_NATIVE_UINT32, \ .update_interval = READER_WAIT_TICKS, .csteps = 1, .use_np = true, .use_vfd_swmr = true, \ - .flush_raw_data = true, .compact = false, .compact_write = false, \ - .compact_elmts = MAX_COMPACT_ELMS, .contig = false, .rows = 10, .cols = 5, .swrites = 0, \ - .rwrites = 0, .lwrites = 0, .wwrites = 0, .lastwrite = 0 \ + .flush_raw_data = true, .compact = false, .compact_write = false, .compact_elmts = MAX_COMPACT_ELMS, \ + .contig = false, .rows = 10, .cols = 5, .swrites = 0, .rwrites = 0, .lwrites = 0, .wwrites = 0, \ + .lastwrite = 0 \ } /* Structure to hold info for different dataset types */ @@ -135,7 +135,8 @@ static bool open_dset_real(const state_t *s, hid_t *did, hid_t *sid, const char static bool close_dsets(const dsets_state_t *ds); static bool close_dset_real(hid_t did, hid_t sid); -static bool perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np); +static bool perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, + np_state_t *np); static bool dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned step); static bool dset_setup(unsigned action, unsigned which, const state_t *s, hsize_t *start, hsize_t *stride, hsize_t *count, hsize_t *block, hid_t *mem_sid, unsigned int **buf); @@ -143,15 +144,18 @@ static bool write_dset(hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hsiz hsize_t *count, hsize_t *block, unsigned int *buf); static bool write_dset_compact(const state_t *s, const dsets_state_t *ds); -static bool verify_dsets_operations(state_t *s, dsets_state_t *ds, - H5F_vfd_swmr_config_t *config, np_state_t *np, bool fileclosed); -static bool verify_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, - unsigned which, bool fileclosed); -static bool verify_dset(hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hsize_t *start, hsize_t *stride, - size_t *count, hsize_t *block, unsigned int *vbuf, bool fileclosed, bool flush_raw_data); -static bool verify_dset_compact(const state_t *s, const dsets_state_t *ds, bool fileclosed, bool flush_raw_data); +static bool verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, + np_state_t *np, bool fileclosed); +static bool verify_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which, + bool fileclosed); +static bool verify_dset(hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hsize_t *start, hsize_t *stride, + size_t *count, hsize_t *block, unsigned int *vbuf, bool fileclosed, + bool flush_raw_data); +static bool verify_dset_compact(const state_t *s, const dsets_state_t *ds, bool fileclosed, + bool flush_raw_data); -static bool closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np); +static bool closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, + np_state_t *np); static const hid_t badhid = H5I_INVALID_HID; @@ -257,7 +261,7 @@ state_init(state_t *s, int argc, char **argv) s->chunked = true; break; - case 'U': /* Disable flush of raw data */ + case 'U': /* Disable flush of raw data */ s->flush_raw_data = false; break; @@ -351,7 +355,8 @@ state_init(state_t *s, int argc, char **argv) goto error; } - /* Enable sequential/random/hyperslab/raw data writes (-s/-r/-l/-w) without contiguous/chunked dataset (-g/-k) */ + /* Enable sequential/random/hyperslab/raw data writes (-s/-r/-l/-w) without contiguous/chunked dataset + * (-g/-k) */ if ((s->swrites || s->rwrites || s->lwrites || s->wwrites) && !(s->contig || s->chunked)) { HDprintf("Enable sequential/random/hypuerslab/raw data writes without contiguous/chunked dataset\n"); usage(s->progname); @@ -863,11 +868,11 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c { unsigned step; bool result; - + /* Perform writes to the whole compact dataset */ if (s->compact) { - if(s->compact_write) { + if (s->compact_write) { dbgf(2, "Writes all to compact dataset\n"); result = write_dset_compact(s, ds); @@ -948,9 +953,8 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c } } } - } - + return true; error: @@ -1190,7 +1194,8 @@ error: * --MODIFY_DATA: raw data modifications */ static bool -verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np, bool fileclosed) +verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np, + bool fileclosed) { unsigned step; bool result; @@ -1198,7 +1203,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co /* Start verifying data written to the compact dataset */ if (s->compact) { - if(s->compact_write) { + if (s->compact_write) { dbgf(2, "Verify writes to compact dataset\n"); if (s->use_np && !np_confirm_verify_notify(np->fd_writer_to_reader, 0, s, np)) { @@ -1207,7 +1212,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co } /* Wait for a few ticks for the update to happen */ - if(!fileclosed) + if (!fileclosed) decisleep(config->tick_len * s->update_interval); result = verify_dset_compact(s, ds, fileclosed, config->flush_raw_data); @@ -1215,7 +1220,8 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co if (s->use_np && !np_reader(result, 0, s, np)) { HDprintf("np_reader() for verifying addition failed\n"); TEST_ERROR; - } else if (!result) + } + else if (!result) TEST_ERROR; } } @@ -1238,7 +1244,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co } /* Wait for a few ticks for the update to happen */ - if(!fileclosed) + if (!fileclosed) decisleep(config->tick_len * s->update_interval); result = verify_dsets_action(SEQ_WRITE, s, ds, step, fileclosed); @@ -1246,7 +1252,8 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co if (s->use_np && !np_reader(result, step, s, np)) { HDprintf("np_reader() for verifying addition failed\n"); TEST_ERROR; - } else if (!result) + } + else if (!result) TEST_ERROR; } } @@ -1273,7 +1280,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co } /* Wait for a few ticks for the update to happen */ - if(!fileclosed) + if (!fileclosed) decisleep(config->tick_len * s->update_interval); result = verify_dsets_action(RANDOM_WRITE, s, ds, newstep, fileclosed); @@ -1281,7 +1288,8 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co if (s->use_np && !np_reader(result, step, s, np)) { HDprintf("np_reader() for verifying addition failed\n"); TEST_ERROR; - } else if (!result) + } + else if (!result) TEST_ERROR; } } @@ -1302,7 +1310,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co } /* Wait for a few ticks for the update to happen */ - if(!fileclosed) + if (!fileclosed) decisleep(config->tick_len * s->update_interval); result = verify_dsets_action(HYPER_WRITE, s, ds, k, fileclosed); @@ -1310,7 +1318,8 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co if (s->use_np && !np_reader(result, step, s, np)) { HDprintf("np_reader() for verifying addition failed\n"); TEST_ERROR; - } else if (!result) + } + else if (!result) TEST_ERROR; } } @@ -1330,7 +1339,7 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co } /* Wait for a few ticks for the update to happen */ - if(!fileclosed) + if (!fileclosed) decisleep(config->tick_len * s->update_interval); result = verify_dsets_action(MODIFY_DATA, s, ds, step, fileclosed); @@ -1338,7 +1347,8 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co if (s->use_np && !np_reader(result, step, s, np)) { HDprintf("np_reader() for verifying addition failed\n"); TEST_ERROR; - } else if (!result) + } + else if (!result) TEST_ERROR; } } @@ -1360,7 +1370,8 @@ error: * MODIFY_DATA: `which` raw data modification */ static bool -verify_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which, bool fileclosed) +verify_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which, + bool fileclosed) { hsize_t start[2]; hsize_t stride[2]; @@ -1377,8 +1388,8 @@ verify_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, /* Verify the data read for the contiguous dataset */ if (s->contig) { - if (!verify_dset(ds->contig_did, s->filetype, mem_sid, ds->contig_sid, start, stride, count, - block, vbuf, fileclosed, s->flush_raw_data)) { + if (!verify_dset(ds->contig_did, s->filetype, mem_sid, ds->contig_sid, start, stride, count, block, + vbuf, fileclosed, s->flush_raw_data)) { HDprintf("verify_dset() to contiguous dataset failed\n"); TEST_ERROR; } @@ -1387,32 +1398,32 @@ verify_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, /* Verify the data read for the chunked datasets */ if (s->chunked) { - if (!verify_dset(ds->single_did, s->filetype, mem_sid, ds->single_sid, start, stride, count, - block, vbuf, fileclosed, s->flush_raw_data)) { + if (!verify_dset(ds->single_did, s->filetype, mem_sid, ds->single_sid, start, stride, count, block, + vbuf, fileclosed, s->flush_raw_data)) { HDprintf("verify_dset() to chunked dataset: single index dataset failed\n"); TEST_ERROR; } if (!verify_dset(ds->implicit_did, s->filetype, mem_sid, ds->implicit_sid, start, stride, count, - block, vbuf, fileclosed, s->flush_raw_data)) { + block, vbuf, fileclosed, s->flush_raw_data)) { HDprintf("verify_dset() to chunked dataset: implicit index dataset failed\n"); TEST_ERROR; } - if (!verify_dset(ds->fa_did, s->filetype, mem_sid, ds->fa_sid, start, stride, count, block, - vbuf, fileclosed, s->flush_raw_data)) { + if (!verify_dset(ds->fa_did, s->filetype, mem_sid, ds->fa_sid, start, stride, count, block, vbuf, + fileclosed, s->flush_raw_data)) { HDprintf("verify_dset() to chunked dataset: fa index dataset failed\n"); TEST_ERROR; } - if (!verify_dset(ds->ea_did, s->filetype, mem_sid, ds->ea_sid, start, stride, count, block, - vbuf, fileclosed, s->flush_raw_data)) { + if (!verify_dset(ds->ea_did, s->filetype, mem_sid, ds->ea_sid, start, stride, count, block, vbuf, + fileclosed, s->flush_raw_data)) { HDprintf("verify_dset() to chunked dataset: ea index dataset failed\n"); TEST_ERROR; } - if (!verify_dset(ds->bt2_did, s->filetype, mem_sid, ds->bt2_sid, start, stride, count, block, - vbuf, fileclosed, s->flush_raw_data)) { + if (!verify_dset(ds->bt2_did, s->filetype, mem_sid, ds->bt2_sid, start, stride, count, block, vbuf, + fileclosed, s->flush_raw_data)) { HDprintf("verify_dset() to chunked dataset: bt2 index dataset failed\n"); TEST_ERROR; } @@ -1431,14 +1442,13 @@ error: } /* verify_dsets_action() */ - /* * Verify the data read from the dataset is as expected. * `vbuf` contains the data expected from the read. */ static bool verify_dset(hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hsize_t *start, hsize_t *stride, - hsize_t *count, hsize_t *block, unsigned int *vbuf, bool fileclosed, bool flush_raw_data) + hsize_t *count, hsize_t *block, unsigned int *vbuf, bool fileclosed, bool flush_raw_data) { unsigned int *rbuf = NULL; unsigned i; @@ -1469,11 +1479,12 @@ verify_dset(hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hsize_t *start, /* Verify the data read in `rbuf` is as `vbuf` */ for (i = 0; i < count[1]; i++) { - if(flush_raw_data || fileclosed) { + if (flush_raw_data || fileclosed) { if (rbuf[i] != vbuf[i]) TEST_ERROR; - } else { /* No flush && not closing file */ - if (rbuf[i] != vbuf[i] && rbuf[0] != 0) /* FILL VALUE ?? */ + } + else { /* No flush && not closing file */ + if (rbuf[i] != vbuf[i] && rbuf[0] != 0) /* FILL VALUE ?? */ TEST_ERROR; } } @@ -1516,15 +1527,15 @@ verify_dset_compact(const state_t *s, const dsets_state_t *ds, bool fileclosed, } for (i = 0; i < s->compact_elmts; i++) { - if(flush_raw_data || fileclosed) { + if (flush_raw_data || fileclosed) { if (rbuf[i] != (i + 1)) { HDprintf("Invalid value for compact dataset element\n"); TEST_ERROR; } - } else { /* No flush && not closing file */ + } + else { /* No flush && not closing file */ if (rbuf[i] != (i + 1) && rbuf[0] != 0) /* FILL VALUE ?? */ TEST_ERROR; - } } @@ -1658,7 +1669,7 @@ np_writer(bool result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd_ goto error; } } - else { /* The action succeeds */ + else { /* The action succeeds */ /* At communication interval, notify the reader and wait for its response */ if (step % s->csteps == 0) { /* Bump up the value of notify to tell the reader to start reading */ @@ -1769,14 +1780,14 @@ error: * Notify the reader that the file is closed * Reader: * Confirm the message from the writer that the file is closed - * Verify the data + * Verify the data */ static bool closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np) { HDassert(s->use_np); - if(writer) { + if (writer) { if (!close_dsets(ds)) { HDprintf("close_dsets() failed\n"); TEST_ERROR; @@ -1800,8 +1811,8 @@ closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_conf HDprintf("np_close() failed\n"); TEST_ERROR; } - - } else { + } + else { /* Wait for a few ticks for the file to close in writer ?? need to this or not? */ decisleep(config->tick_len * s->update_interval); @@ -1819,10 +1830,10 @@ closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_conf /* Turn off named pipes */ s->use_np = false; - + /* Verify the dataset again without named pipes */ dbgf(2, "Reader verifies data after writer closes the file (flush of raw data is disabled)\n"); - if(!verify_dsets_operations(s, ds, config, np, true)) { + if (!verify_dsets_operations(s, ds, config, np, true)) { HDprintf("verify_dsets_operations() failed\n"); TEST_ERROR } @@ -1837,7 +1848,6 @@ closing_on_noflush(bool writer, state_t *s, dsets_state_t *ds, H5F_vfd_swmr_conf HDprintf("H5Fclose failed\n"); TEST_ERROR; } - } return true; @@ -1923,14 +1933,14 @@ main(int argc, char **argv) if (writer) { - if(!perform_dsets_operations(&s, &ds, &config, &np)) { + if (!perform_dsets_operations(&s, &ds, &config, &np)) { HDprintf("perform_dsets_operations() failed\n"); TEST_ERROR; } } else { - if(!verify_dsets_operations(&s, &ds, &config, &np, false)) { + if (!verify_dsets_operations(&s, &ds, &config, &np, false)) { HDprintf("perform_dsets_operations() failed\n"); TEST_ERROR; } @@ -1946,11 +1956,12 @@ main(int argc, char **argv) TEST_ERROR; } - if(!s.flush_raw_data && s.use_np) { + if (!s.flush_raw_data && s.use_np) { - if(!closing_on_noflush(writer, &s, &ds, &config, &np)) + if (!closing_on_noflush(writer, &s, &ds, &config, &np)) TEST_ERROR - } else { + } + else { if (!close_dsets(&ds)) { HDprintf("close_dsets() failed\n"); -- cgit v0.12 From b815aecb857966c2c4eb88e77a5da8f2bbc2a46a Mon Sep 17 00:00:00 2001 From: vchoi Date: Tue, 17 Aug 2021 12:01:39 -0500 Subject: Modifications as indicated by valgrind --tool=memcheck for the following files: (1) test/vfd_swmr_attrdset_writer.c Free memory for variable length string + cleanup (2) test/vfd_swmr_bigset_writer.c Free memory for s.dataset and s.sources (3) test/vfd_swmr_vlstr_reader.c Free memory for content[] Also fix a bug in test/testvfdswmr.sh.in so that os_groups_seg test will only be executed when specified. --- test/testvfdswmr.sh.in | 28 ++++++++++++++-------------- test/vfd_swmr_attrdset_writer.c | 21 ++++++--------------- test/vfd_swmr_bigset_writer.c | 13 +++++++++---- test/vfd_swmr_vlstr_reader.c | 7 ++++++- 4 files changed, 35 insertions(+), 34 deletions(-) diff --git a/test/testvfdswmr.sh.in b/test/testvfdswmr.sh.in index 1401da1..bafdc2c 100644 --- a/test/testvfdswmr.sh.in +++ b/test/testvfdswmr.sh.in @@ -1021,21 +1021,21 @@ done # # GROUP_seg_n=1000000 # Number of groups when segmentation fault occurs -if [ ${do_os_groups_seg:-no} = no ]; then - continue -fi -echo launch vfd_swmr_group operations with old-style group: $GROUP_seg_n groups ......may take some time...... -catch_out_err_and_rc vfd_swmr_group_writer \ - ../vfd_swmr_group_writer -q -N -G -n $GROUP_seg_n -a $GROUP_seg_n - -# Collect exit code of the writer -if [ $(cat vfd_swmr_group_writer.rc) -ne 0 ]; then - echo writer had error - nerrors=$((nerrors + 1)) -fi +# +if [ ${do_os_groups_seg:-no} != no ]; then + echo launch vfd_swmr_group operations with old-style group: $GROUP_seg_n groups ......may take some time...... + catch_out_err_and_rc vfd_swmr_group_writer \ + ../vfd_swmr_group_writer -q -N -G -n $GROUP_seg_n -a $GROUP_seg_n + + # Collect exit code of the writer + if [ $(cat vfd_swmr_group_writer.rc) -ne 0 ]; then + echo writer had error + nerrors=$((nerrors + 1)) + fi -# Clean up output files -rm -f vfd_swmr_group_writer.{out,rc} + # Clean up output files + rm -f vfd_swmr_group_writer.{out,rc} +fi ############################################################################### # diff --git a/test/vfd_swmr_attrdset_writer.c b/test/vfd_swmr_attrdset_writer.c index 67eeb2c..8eeadaf 100644 --- a/test/vfd_swmr_attrdset_writer.c +++ b/test/vfd_swmr_attrdset_writer.c @@ -924,7 +924,6 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c unsigned step; bool result; unsigned dd; - bool ret = true; for (step = 0; step < s->asteps; step++) { dbgf(2, "Adding attribute %d\n", step); @@ -1507,7 +1506,7 @@ verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned unsigned int read_which; unsigned int tmp_val; char tmp_vl_val[sizeof("attr-9999999999")]; - char * read_vl_which = NULL; + char * read_vl_which; bool is_vl = false; hid_t aid = H5I_INVALID_HID; hid_t atid = H5I_INVALID_HID; @@ -1531,11 +1530,6 @@ verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned HDsprintf(tmp_vl_val, "%u", which); else HDsprintf(tmp_vl_val, "%u %c", which, 'M'); - - if ((read_vl_which = HDmalloc(sizeof("9999999999"))) == NULL) { - HDprintf("HDmalloc failed\n"); - TEST_ERROR; - } } else { if (action == MODIFY_ATTR) @@ -1544,7 +1538,7 @@ verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned tmp_val = which; } - if (H5Aread(aid, atid, is_vl ? (void *)&read_vl_which : (void *)&read_which) < 0) { + if (H5Aread(aid, atid, is_vl ? &read_vl_which : (void *)&read_which) < 0) { HDprintf("H5Aread failed\n"); TEST_ERROR; } @@ -1569,8 +1563,8 @@ verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned ret = (read_which == tmp_val); } - if (read_vl_which) - HDfree(read_vl_which); + if (is_vl) + H5free_memory(read_vl_which); return ret; @@ -1582,8 +1576,8 @@ error: } H5E_END_TRY; - if (read_vl_which) - HDfree(read_vl_which); + if (is_vl) + H5free_memory(read_vl_which); return false; @@ -1962,15 +1956,12 @@ main(int argc, char **argv) { hid_t fapl = H5I_INVALID_HID; hid_t fcpl = H5I_INVALID_HID; - unsigned step; bool writer = FALSE; state_t s; const char * personality; H5F_vfd_swmr_config_t config; np_state_t np; dsets_state_t ds; - unsigned dd; - bool result; if (!state_init(&s, argc, argv)) { HDprintf("state_init() failed\n"); diff --git a/test/vfd_swmr_bigset_writer.c b/test/vfd_swmr_bigset_writer.c index d3a9ce8..6280af5 100644 --- a/test/vfd_swmr_bigset_writer.c +++ b/test/vfd_swmr_bigset_writer.c @@ -192,10 +192,10 @@ newmat(unsigned rows, unsigned cols) { mat_t *mat; - mat = malloc(sizeof(*mat) + (rows * cols - 1) * sizeof(mat->elt[0])); + mat = HDmalloc(sizeof(*mat) + (rows * cols - 1) * sizeof(mat->elt[0])); if (mat == NULL) - err(EXIT_FAILURE, "%s: malloc", __func__); + err(EXIT_FAILURE, "%s: HDmalloc", __func__); mat->rows = rows; mat->cols = cols; @@ -463,11 +463,11 @@ state_init(state_t *s, int argc, char **argv) if ((s->one_by_one_sid = H5Screate_simple(1, &dims, &dims)) < 0) errx(EXIT_FAILURE, "H5Screate_simple failed"); - s->dataset = malloc(sizeof(*s->dataset) * s->ndatasets); + s->dataset = HDmalloc(sizeof(*s->dataset) * s->ndatasets); if (s->dataset == NULL) err(EXIT_FAILURE, "could not allocate dataset handles"); - s->sources = malloc(sizeof(*s->sources) * s->ndatasets); + s->sources = HDmalloc(sizeof(*s->sources) * s->ndatasets); if (s->sources == NULL) err(EXIT_FAILURE, "could not allocate quadrant dataset handles"); @@ -1174,6 +1174,11 @@ main(int argc, char **argv) free(mat); + if (s.dataset) + HDfree(s.dataset); + if (s.sources) + HDfree(s.sources); + return EXIT_SUCCESS; } diff --git a/test/vfd_swmr_vlstr_reader.c b/test/vfd_swmr_vlstr_reader.c index c3ee2ed..d0ac0a9 100644 --- a/test/vfd_swmr_vlstr_reader.c +++ b/test/vfd_swmr_vlstr_reader.c @@ -140,7 +140,7 @@ main(int argc, char **argv) if (fid == badhid) errx(EXIT_FAILURE, "H5Fcreate"); - /* content 1 seq 1 short + /* content 0 seq 1 short * content 1 seq 1 long long long long long long long long * content 1 seq 1 medium medium medium */ @@ -178,6 +178,11 @@ main(int argc, char **argv) dbgf(2, ": read which %d seq %d tail %s\n", scanned_content.which, scanned_content.seq, scanned_content.tail); H5Dclose(dset[which]); + + if(content[which] != NULL) { + HDfree(content[which]); + content[which] = NULL; + } } if (caught_out_of_bounds) -- cgit v0.12 From 6eaa6012ff6edfa6db2cd0975649067b48eb3b00 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 17 Aug 2021 17:05:16 +0000 Subject: Committing clang-format changes --- test/vfd_swmr_attrdset_writer.c | 12 ++++++------ test/vfd_swmr_vlstr_reader.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/vfd_swmr_attrdset_writer.c b/test/vfd_swmr_attrdset_writer.c index 8eeadaf..f445321 100644 --- a/test/vfd_swmr_attrdset_writer.c +++ b/test/vfd_swmr_attrdset_writer.c @@ -1507,10 +1507,10 @@ verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned unsigned int tmp_val; char tmp_vl_val[sizeof("attr-9999999999")]; char * read_vl_which; - bool is_vl = false; - hid_t aid = H5I_INVALID_HID; - hid_t atid = H5I_INVALID_HID; - bool ret = FALSE; + bool is_vl = false; + hid_t aid = H5I_INVALID_HID; + hid_t atid = H5I_INVALID_HID; + bool ret = FALSE; HDassert(did != badhid); HDassert(action == ADD_ATTR || action == MODIFY_ATTR); @@ -1954,8 +1954,8 @@ error: int main(int argc, char **argv) { - hid_t fapl = H5I_INVALID_HID; - hid_t fcpl = H5I_INVALID_HID; + hid_t fapl = H5I_INVALID_HID; + hid_t fcpl = H5I_INVALID_HID; bool writer = FALSE; state_t s; const char * personality; diff --git a/test/vfd_swmr_vlstr_reader.c b/test/vfd_swmr_vlstr_reader.c index d0ac0a9..fa9d7b4 100644 --- a/test/vfd_swmr_vlstr_reader.c +++ b/test/vfd_swmr_vlstr_reader.c @@ -179,7 +179,7 @@ main(int argc, char **argv) scanned_content.tail); H5Dclose(dset[which]); - if(content[which] != NULL) { + if (content[which] != NULL) { HDfree(content[which]); content[which] = NULL; } -- cgit v0.12 From 2b62f2a2638913ed783cd10a049b3e1b1d6c3447 Mon Sep 17 00:00:00 2001 From: Muqun Yang Date: Tue, 17 Aug 2021 16:12:58 -0500 Subject: Add options fo max_lag, tick_len and page_size. --- test/vfd_swmr_gperf_writer.c | 45 ++++++++++++++++++++++++++++++++++++-------- test/vfd_swmr_group_writer.c | 4 +++- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index c1844d4..fb3cd0c 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -61,6 +61,8 @@ typedef struct { double fo_total_time; double fc_total_time; unsigned int num_attrs; + unsigned int ps; + unsigned int pbs; unsigned int nglevels; } state_t; @@ -72,23 +74,30 @@ typedef struct { .old_style_grp = false, .grp_op_pattern = ' ', .grp_op_test = false, .at_pattern = ' ', \ .attr_test = false, .tick_len = 4, .max_lag = 7, .gperf = false, .min_time = 100., .max_time = 0., \ .mean_time = 0., .total_time = 0., .fo_total_time = 0., .fc_total_time = 0., .num_attrs = 1, \ - .nglevels = 0 \ + .ps=4096, .pbs = 4096, .nglevels = 0 \ } static void usage(const char *progname) { fprintf(stderr, - "usage: %s [-S] [-G] [-a steps] [-b] [-n iterations]\n" - " [-N num_attrs] [-l nested group levels] [-q] [-A at_pattern] [-O grp_op_pattern]\n" + "usage: %s [-S] [-G] [-a steps] [-t tick_len] [-m max_lag][-B pbs] [-s ps]\n" + " [-b] [-n iterations]\n" + " [-N num_attrs] [-l ng_levels] [-q] [-A at_pattern] [-O grp_op_pattern]\n" "\n" "-S: do not use VFD SWMR\n" "-G: old-style type of group\n" "-a steps: `steps` between adding attributes\n" + "-t tick_len: length of a tick in tenths of a second.\n" + "-m max_lag: maximum expected lag(in ticks) between writer and readers\n" + "-B pbs: Page Buffer Size in bytes:\n" + " The default value is 4K(4096).\n" + "-s ps: Page size used by page aggregation, page buffer and \n" + " the metadata file. \n" "-b: write data in big-endian byte order\n" "-n ngroups: the number of groups\n" - "-N: the number of attributes \n" - "-l: the number of level of nested groups. \n" + "-N num_attrs: the number of attributes \n" + "-l ng_levels: the number of level of nested groups. \n" " If all the groups are under the root group, \n" " this number should be 0.\n" "-A at_pattern: `at_pattern' for different attribute tests\n" @@ -175,7 +184,7 @@ state_init(state_t *s, int argc, char **argv) if (argc == 1) usage(s->progname); - while ((ch = getopt(argc, argv, "PSGa:bn:qA:N:l:O:")) != -1) { + while ((ch = getopt(argc, argv, "PSGa:bt:m:B:s:n:qA:N:l:O:")) != -1) { switch (ch) { case 'P': s->gperf = true; @@ -190,6 +199,9 @@ state_init(state_t *s, int argc, char **argv) case 'n': case 'N': case 'l': + case 't': + case 'm': + case 'B': errno = 0; tmp = HDstrtoul(optarg, &end, 0); if (end == optarg || *end != '\0') { @@ -213,6 +225,14 @@ state_init(state_t *s, int argc, char **argv) s->num_attrs = (unsigned)tmp; else if (ch == 'l') s->nglevels = (unsigned)tmp; + else if (ch == 't') + s->tick_len = (unsigned)tmp; + else if (ch == 'm') + s->max_lag = (unsigned)tmp; + else if (ch == 's') + s->ps = (unsigned)tmp; + else if (ch == 'B') + s->pbs = (unsigned)tmp; break; case 'b': s->filetype = H5T_STD_U32BE; @@ -4453,18 +4473,20 @@ main(int argc, char **argv) } /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(&config, 4, 7, writer, FALSE, 128, "./group-shadow"); + //init_vfd_swmr_config(&config, 4, 7, writer, FALSE, 128, "./group-shadow"); + init_vfd_swmr_config(&config, s.tick_len, s.max_lag, writer, FALSE, 128, "./group-shadow"); /* If old-style option is chosen, use the earliest file format(H5F_LIBVER_EARLIEST) * as the second parameter of H5Pset_libver_bound() that is called by * vfd_swmr_create_fapl. Otherwise, the latest file format(H5F_LIBVER_LATEST) * should be used as the second parameter of H5Pset_libver_bound(). * Also pass the use_vfd_swmr, only_meta_page, config to vfd_swmr_create_fapl().*/ - if ((fapl = vfd_swmr_create_fapl(!s.old_style_grp, s.use_vfd_swmr, true, &config)) < 0) { + if ((fapl = vfd_swmr_create_fapl(!s.old_style_grp, s.use_vfd_swmr, true, s.pbs, &config)) < 0) { printf("vfd_swmr_create_fapl failed\n"); TEST_ERROR; } +#if 0 if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) { printf("H5Pcreate failed\n"); TEST_ERROR; @@ -4474,6 +4496,13 @@ main(int argc, char **argv) printf("H5Pset_file_space_strategy failed\n"); TEST_ERROR; } +#endif + + /* Set fs_strategy (file space strategy) and fs_page_size (file space page size) */ + if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, s.ps)) < 0) { + HDprintf("vfd_swmr_create_fcpl() failed"); + TEST_ERROR; + } if (s.nglevels > 0) { if (s.grp_op_pattern != ' ' || s.at_pattern != ' ') { diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index c758781..6a3230e 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -153,8 +153,10 @@ state_init(state_t *s, int argc, char **argv) esnprintf(s->progname, sizeof(s->progname), "%s", tfile); - if (tfile) + if (tfile) { HDfree(tfile); + tfile = NULL; + } while ((ch = getopt(argc, argv, "SGa:bc:n:Nqu:A:O:")) != -1) { switch (ch) { -- cgit v0.12 From 4d368b7b5be882b4432b1d9dbdb3741b992ac784 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 17 Aug 2021 21:17:42 +0000 Subject: Committing clang-format changes --- test/vfd_swmr_gperf_writer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index fb3cd0c..c23c9fd 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -74,7 +74,7 @@ typedef struct { .old_style_grp = false, .grp_op_pattern = ' ', .grp_op_test = false, .at_pattern = ' ', \ .attr_test = false, .tick_len = 4, .max_lag = 7, .gperf = false, .min_time = 100., .max_time = 0., \ .mean_time = 0., .total_time = 0., .fo_total_time = 0., .fc_total_time = 0., .num_attrs = 1, \ - .ps=4096, .pbs = 4096, .nglevels = 0 \ + .ps = 4096, .pbs = 4096, .nglevels = 0 \ } static void @@ -90,7 +90,7 @@ usage(const char *progname) "-a steps: `steps` between adding attributes\n" "-t tick_len: length of a tick in tenths of a second.\n" "-m max_lag: maximum expected lag(in ticks) between writer and readers\n" - "-B pbs: Page Buffer Size in bytes:\n" + "-B pbs: Page Buffer Size in bytes:\n" " The default value is 4K(4096).\n" "-s ps: Page size used by page aggregation, page buffer and \n" " the metadata file. \n" @@ -4473,7 +4473,7 @@ main(int argc, char **argv) } /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - //init_vfd_swmr_config(&config, 4, 7, writer, FALSE, 128, "./group-shadow"); + // init_vfd_swmr_config(&config, 4, 7, writer, FALSE, 128, "./group-shadow"); init_vfd_swmr_config(&config, s.tick_len, s.max_lag, writer, FALSE, 128, "./group-shadow"); /* If old-style option is chosen, use the earliest file format(H5F_LIBVER_EARLIEST) @@ -4498,7 +4498,7 @@ main(int argc, char **argv) } #endif - /* Set fs_strategy (file space strategy) and fs_page_size (file space page size) */ + /* Set fs_strategy (file space strategy) and fs_page_size (file space page size) */ if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, s.ps)) < 0) { HDprintf("vfd_swmr_create_fcpl() failed"); TEST_ERROR; -- cgit v0.12 From 79652fa099615b96350e59ed6150497a7b697015 Mon Sep 17 00:00:00 2001 From: Muqun Yang Date: Wed, 18 Aug 2021 16:04:38 -0500 Subject: 1. Add the VL string type test. 2. Remove the reader test. 3. Fix trivial bugs and remove some warnings. --- test/vfd_swmr_gperf_writer.c | 2783 +++++++----------------------------------- 1 file changed, 463 insertions(+), 2320 deletions(-) diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index c23c9fd..15f9522 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -61,6 +61,7 @@ typedef struct { double fo_total_time; double fc_total_time; unsigned int num_attrs; + bool vlstr_test; unsigned int ps; unsigned int pbs; unsigned int nglevels; @@ -74,17 +75,18 @@ typedef struct { .old_style_grp = false, .grp_op_pattern = ' ', .grp_op_test = false, .at_pattern = ' ', \ .attr_test = false, .tick_len = 4, .max_lag = 7, .gperf = false, .min_time = 100., .max_time = 0., \ .mean_time = 0., .total_time = 0., .fo_total_time = 0., .fc_total_time = 0., .num_attrs = 1, \ - .ps = 4096, .pbs = 4096, .nglevels = 0 \ + .vlstr_test = false, .ps = 4096, .pbs = 4096, .nglevels = 0 \ } static void usage(const char *progname) { fprintf(stderr, - "usage: %s [-S] [-G] [-a steps] [-t tick_len] [-m max_lag][-B pbs] [-s ps]\n" - " [-b] [-n iterations]\n" + "usage: %s [-P] [-S] [-G] [-a steps] [-t tick_len] [-m max_lag][-B pbs] [-s ps]\n" + " [-b] [-n ngroups]\n" " [-N num_attrs] [-l ng_levels] [-q] [-A at_pattern] [-O grp_op_pattern]\n" "\n" + "-P: carry out the performance test\n" "-S: do not use VFD SWMR\n" "-G: old-style type of group\n" "-a steps: `steps` between adding attributes\n" @@ -97,6 +99,7 @@ usage(const char *progname) "-b: write data in big-endian byte order\n" "-n ngroups: the number of groups\n" "-N num_attrs: the number of attributes \n" + "-V vlstr attrs: Use variable length string attribute in the performance test. \n" "-l ng_levels: the number of level of nested groups. \n" " If all the groups are under the root group, \n" " this number should be 0.\n" @@ -184,7 +187,7 @@ state_init(state_t *s, int argc, char **argv) if (argc == 1) usage(s->progname); - while ((ch = getopt(argc, argv, "PSGa:bt:m:B:s:n:qA:N:l:O:")) != -1) { + while ((ch = getopt(argc, argv, "PSGa:bVt:m:B:s:n:qA:N:l:O:")) != -1) { switch (ch) { case 'P': s->gperf = true; @@ -202,6 +205,7 @@ state_init(state_t *s, int argc, char **argv) case 't': case 'm': case 'B': + case 's': errno = 0; tmp = HDstrtoul(optarg, &end, 0); if (end == optarg || *end != '\0') { @@ -237,6 +241,9 @@ state_init(state_t *s, int argc, char **argv) case 'b': s->filetype = H5T_STD_U32BE; break; + case 'V': + s->vlstr_test = true; + break; case 'O': if (HDstrcmp(optarg, "grp-creation") == 0) s->grp_op_pattern = 'c'; @@ -494,46 +501,6 @@ error: } /*------------------------------------------------------------------------- - * Function: add_default_group_attr - * - * Purpose: Add an attribute to a group. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t g - * HDF5 object ID (in this file: means group ID) - * - * unsigned int which - * The number of iterations for group creation, use to generate - * newly created group and attribute names. - * The group name is "group-which" and the attribute name - * is "attr-which". - * - * - * Return: Success: true - * Failure: false - * - * Note: This function is used for the "dense" storage test. - * It is also used by the group-only, "add-ohr-block" - * and "del-ohr-block" tests. - *------------------------------------------------------------------------- - */ - -static bool -add_default_group_attr(state_t *s, hid_t g, unsigned int which) -{ - - const char *aname_format = "attr-%u-%u"; - - /* Note: the number of attributes can be configurable, - * the default number of attribute is 1. - */ - return add_attr(s, g, which, s->num_attrs, aname_format, which); -} - -/*------------------------------------------------------------------------- * Function: add_vlstr_attr * * Purpose: Add a variable length string attribute to a group. @@ -631,6 +598,95 @@ error: return false; } + + +/*------------------------------------------------------------------------- + * Function: add_vlstr_attrs + * + * Purpose: Add variable length string attributes to a group. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group and attribute names. + * The group name is "group-which". The attribute names + * are "attr-which","attr-which+1".... + * + * + * Return: Success: true + * Failure: false + * + * Note: This is for the performance test that has the VL string type. + *------------------------------------------------------------------------- + */ + +static bool +add_vlstr_attrs(state_t *s, hid_t g, unsigned int which, unsigned int num_attrs) +{ + unsigned u; + bool ret_value = true; + for (u = 0; u < num_attrs; u++) { + ret_value = add_vlstr_attr(s, g, u+which); + if(ret_value == false) + break; + } + + return ret_value; +} + + + +/*------------------------------------------------------------------------- + * Function: add_default_group_attr + * + * Purpose: Add an attribute to a group. + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * hid_t g + * HDF5 object ID (in this file: means group ID) + * + * unsigned int which + * The number of iterations for group creation, use to generate + * newly created group and attribute names. + * The group name is "group-which" and the attribute name + * is "attr-which". + * + * + * Return: Success: true + * Failure: false + * + * Note: This function is used for the "dense" storage test. + * It is also used by the group-only, "add-ohr-block" + * and "del-ohr-block" tests. + *------------------------------------------------------------------------- + */ + +static bool +add_default_group_attr(state_t *s, hid_t g, unsigned int which) +{ + + const char *aname_format = "attr-%u-%u"; + + /* Note: the number of attributes can be configurable, + * the default number of attribute is 1. + */ + /* If the vl string attribute type is chosen. */ + if(s->vlstr_test == true) + return add_vlstr_attrs(s, g, which, s->num_attrs); + else + return add_attr(s, g, which, s->num_attrs, aname_format, which); +} + + /*------------------------------------------------------------------------- * Function: del_one_attr * @@ -831,10 +887,7 @@ error: * * Purpose: Modify the value of an VL string attribute in a group. * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * + * Parameters: * hid_t g * HDF5 object ID (in this file: means group ID) * @@ -850,7 +903,7 @@ error: */ static bool -modify_vlstr_attr(state_t *s, hid_t g, unsigned int which) +modify_vlstr_attr(hid_t g, unsigned int which) { hid_t aid = H5I_INVALID_HID; @@ -956,7 +1009,7 @@ add_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which) bool ret_value = false; ret_value = add_vlstr_attr(s, g, which); if (true == ret_value) - ret_value = modify_vlstr_attr(s, g, which); + ret_value = modify_vlstr_attr(g, which); return ret_value; } @@ -1088,11 +1141,7 @@ error: * that the attribute storage changes from compact to * dense then to compact again. * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t g + * Parameters: hid_t g * HDF5 object ID (in this file: means group ID) * * hid_t gcpl @@ -1113,7 +1162,7 @@ error: */ static bool -del_attrs_compact_dense_compact(state_t *s, hid_t obj_id, hid_t gcpl, unsigned int which) +del_attrs_compact_dense_compact(hid_t obj_id, hid_t gcpl, unsigned int which) { unsigned max_compact = 0; @@ -1302,7 +1351,7 @@ add_del_attrs_compact_dense_compact(state_t *s, hid_t g, hid_t gcpl, unsigned in bool ret_value = false; ret_value = add_attrs_compact_dense(s, g, gcpl, which); if (ret_value == true) - ret_value = del_attrs_compact_dense_compact(s, g, gcpl, which); + ret_value = del_attrs_compact_dense_compact(g, gcpl, which); return ret_value; } @@ -1627,49 +1676,122 @@ error: } /*------------------------------------------------------------------------- - * Function: check_attr_storage_type + * Function: create_group_id * - * Purpose: Check if the attribute storage type is correct + * Purpose: Create a group and return the group ID. * - * Parameters: hid_t oid - * HDF5 object ID (in this file: means group ID) + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters * - * bool is_compact - * true if the attribute is stored in compact storage - * false if the attribute is stored in dense storage + * unsigned int which + * The number of iterations for group creation + * This is used to generate the group name. * + * bool dense_to_compact + * true if this function is used to test the transition from dense to + * compact, false if the test is from compact to dense. * - * Return: Success: true - * Failure: false + * Return: Success: the group ID + * Failure: -1 * + * Note: Only used by testing the link storage transit functions. *------------------------------------------------------------------------- */ -static bool -check_attr_storage_type(hid_t g, bool is_compact) +static hid_t +create_group_id(state_t *s, unsigned int which, bool dense_to_compact) { - H5O_native_info_t ninfo; + char name[sizeof("/group-9999999999")]; + hid_t g = H5I_INVALID_HID; + hid_t gcpl = H5I_INVALID_HID; + H5G_info_t group_info; - /* Get the object information */ - if (H5Oget_native_info(g, &ninfo, H5O_NATIVE_INFO_HDR | H5O_NATIVE_INFO_META_SIZE) < 0) { - printf("H5Oget_native_info failed\n"); + if (which >= s->nsteps) { + printf("Number of created groups is out of bounds\n"); + TEST_ERROR; + } + + gcpl = H5Pcreate(H5P_GROUP_CREATE); + if (gcpl < 0) { + printf("H5Pcreate failed\n"); TEST_ERROR; } - if (is_compact) { - if (ninfo.meta_size.attr.index_size != 0 || ninfo.meta_size.attr.heap_size != 0) { - printf("Should be in compact storage,but it is not.\n"); + if (dense_to_compact) { + if (H5Pset_link_phase_change(gcpl, 2, 2) < 0) { + printf("H5Pset_link_phase_change failed for dense to compact.\n"); TEST_ERROR; } } else { - if (ninfo.meta_size.attr.index_size == 0 || ninfo.meta_size.attr.heap_size == 0) { - printf("Should be in dense storage,but it is not.\n"); + if (H5Pset_link_phase_change(gcpl, 1, 1) < 0) { + printf("H5Pset_attr_phase_change failed for compact to dense.\n"); TEST_ERROR; } } + esnprintf(name, sizeof(name), "/group-%u", which); + if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) { + printf("H5Gcreate2 failed\n"); + TEST_ERROR; + } + + if (H5Gget_info(g, &group_info) < 0) { + printf("H5Gget_info failed\n"); + TEST_ERROR; + } + + /* The storage type should always be compact when a group is created. */ + if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + printf("New-style group link storage test:. \n"); + printf(" still be compact after group creation. \n"); + TEST_ERROR; + } + + if (H5Pclose(gcpl) < 0) { + printf("H5Pclose failed\n"); + TEST_ERROR; + } + + return g; + +error: + + H5E_BEGIN_TRY + { + H5Pclose(gcpl); + } + H5E_END_TRY; + + return -1; +} + +/*------------------------------------------------------------------------- + * Function: close_group_id + * + * Purpose: Verify is a group is closed successfully. + * + * Parameters: hid_t g + * The ID of the group to be closed. + * + * Return: Success: true + * Failure: false + * + * Note: This is used by the link storage transit functions. + *------------------------------------------------------------------------- + */ + +static bool +close_group_id(hid_t g) +{ + + if (H5Gclose(g) < 0) { + printf("H5Gclose failed\n"); + TEST_ERROR; + } + return true; error: @@ -1677,1912 +1799,41 @@ error: } /*------------------------------------------------------------------------- - * Function: vrfy_attr + * Function: create_group * - * Purpose: Verify is a group attribute value is as expected. + * Purpose: Create a group * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe * and some VFD SWMR configuration parameters * - * hid_t oid - * HDF5 object ID (in this file: means group ID) - * * unsigned int which - * The number of iterations for group creation, use to generate - * newly created group name. The group name is "group-which". - * - * const char*aname - * The attribute name - * - * unsigned int g_which - * This parameter is used to generate correct group name in a key - * debugging message. - * - * bool check_storage - * a flag to indicate if the storage check is on - * - * bool is_compact - * true if the attribute storage should be in compact - * false if the attribute storage should be in dense - * Note: this parameter is not used if the check_storage - * is set to false. - * + * The number of iterations for group creation + * This is used to generate the group name. * * Return: Success: true * Failure: false * + * Note: This is called by the main() function. *------------------------------------------------------------------------- */ static bool -vrfy_attr(state_t *s, hid_t g, unsigned int which, const char *aname, unsigned int g_which, - bool check_storage, bool is_compact) +create_group(state_t *s, unsigned int which) { - unsigned int read_which; - hid_t aid = H5I_INVALID_HID; - hid_t amtype = H5I_INVALID_HID; - - /* Go ahead to read the attribute. */ - dbgf(1, "verifying attribute %s on group %u equals %u\n", aname, g_which, which); + char name[sizeof("/group-9999999999")]; + hid_t g = H5I_INVALID_HID; + H5G_info_t group_info; - if ((amtype = H5Tget_native_type(s->filetype, H5T_DIR_ASCEND)) < 0) { - printf("H5Tget_native_type failed\n"); + if (which >= s->nsteps) { + printf("Number of created groups is out of bounds\n"); TEST_ERROR; } - if ((aid = H5Aopen(g, aname, H5P_DEFAULT)) < 0) { - printf("H5Aopen failed\n"); - TEST_ERROR; - } - - if (H5Aread(aid, amtype, &read_which) < 0) { - printf("H5Aread failed\n"); - TEST_ERROR; - } - - if (H5Aclose(aid) < 0) { - printf("H5Aclose failed\n"); - TEST_ERROR; - } - - if (read_which != which) { - printf("reader: the add_attribute verfication failed,expected value is %d\n", which); - printf("reader: the add_attribute verfication failed, the value is %d\n", read_which); - printf("The add_attribute verification failed\n"); - TEST_ERROR; - } - - if (!s->old_style_grp && check_storage == true) { - if (false == check_attr_storage_type(g, is_compact)) { - printf("The attribute storage type is wrong. \n"); - TEST_ERROR; - } - } - - /* If coming to an "object header continuation block" test, - * we need to check if this test behaves as expected. */ - if (s->at_pattern == 'a' || s->at_pattern == 'R') { - if (false == check_ohr_num_chunk(g, false)) { - printf("An object header continuation block should be created. \n"); - printf("But it is not.\n"); - printf("Verification of 'object header continuation block test' failed.\n"); - TEST_ERROR; - } - } - - return true; - -error: - H5E_BEGIN_TRY - { - H5Tclose(amtype); - H5Aclose(aid); - } - H5E_END_TRY; - return false; -} - -/*------------------------------------------------------------------------- - * Function: verify_default_group_attr - * - * Purpose: Check if the reader can retrieve the correct value of a - * group attribute corrected by the writer. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t g - * HDF5 object ID (in this file: means group ID) - * - * unsigned int which - * The expected attribute value. It is also used to construct the - * group name. - * - * Return: Success: true - * Failure: false - * - * Note: This function is used for the "dense" storage test. - * It is also used by the group-only, "add-ohr-block" - * and "del-ohr-block" tests. - *------------------------------------------------------------------------- - */ - -static bool -verify_default_group_attr(state_t *s, hid_t g, unsigned int which) -{ - char attrname[VS_ATTR_NAME_LEN]; - const char *aname_format = "attr-%u"; - HDsprintf(attrname, aname_format, which); - return vrfy_attr(s, g, which, attrname, which, false, true); -} - -/*------------------------------------------------------------------------- - * Function: verify_modify_attr - * - * Purpose: Check if the reader can retrieve the correct value of - * an attribute in a group, first the original value then - * the modified value. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t g - * HDF5 object ID (in this file: means group ID) - * - * unsigned int which - * The expected attribute value. It is also used to construct the - * group name. The modified attribute value can be derived from - * the expected attribute value. - * - * Return: Success: true - * Failure: false - * - * Note: This function is used for the "modified" test. - *------------------------------------------------------------------------- - */ - -static bool -verify_modify_attr(state_t *s, hid_t g, unsigned int which) -{ - - bool ret = false; - const char * aname_fmt = "attr-%u"; - unsigned int read_which; - hid_t aid = H5I_INVALID_HID; - hid_t amtype = H5I_INVALID_HID; - char attrname[VS_ATTR_NAME_LEN]; - - /* First verify the original attribute value */ - ret = verify_default_group_attr(s, g, which); - - /* Then the modified value */ - if (ret == true) { - - /* Go ahead to read the attribute. */ - esnprintf(attrname, sizeof(attrname), aname_fmt, which); - if ((amtype = H5Tget_native_type(s->filetype, H5T_DIR_ASCEND)) < 0) { - printf("H5Tget_native_type failed\n"); - TEST_ERROR; - } - - if ((aid = H5Aopen(g, attrname, H5P_DEFAULT)) < 0) { - printf("H5Aopen failed\n"); - TEST_ERROR; - } - - if (H5Aread(aid, amtype, &read_which) < 0) { - printf("H5Aread failed\n"); - TEST_ERROR; - } - - if (H5Tclose(amtype) < 0) { - printf("H5Tclose failed.\n"); - TEST_ERROR; - } - - if (H5Aclose(aid) < 0) { - printf("H5Aclose failed\n"); - TEST_ERROR; - } - - /* verify the modified value */ - if (read_which != (which + 10000)) { - printf("reader: the modified_attr() expected value is %d\n", which + 10000); - printf("reader: the modified_attr() actual value is %d\n", read_which); - printf("The modify_attribute verification failed.\n"); - TEST_ERROR; - } - - return true; - } - return false; - -error: - H5E_BEGIN_TRY - { - H5Aclose(aid); - H5Tclose(amtype); - } - H5E_END_TRY; - - return false; -} - -/*------------------------------------------------------------------------- - * Function: verify_group_vlstr_attr - * - * Purpose: Check if the reader can retrieve the correct value of - * a variable length string attribute created by the writer. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t g - * HDF5 object ID (in this file: means group ID) - * - * unsigned int which - * Use to derieve the expected attribute value. It is also used - * to construct the group name. - * - * bool vrfy_mod - * true if this function is used for the modified VL string test. - * false if this function is just used for the VL string test. - * - * Return: Success: true - * Failure: false - * - * Note: This function is an internal function used by - * both the "vlstr" and the "modify-vstr" tests. - *------------------------------------------------------------------------- - */ - -static bool -verify_group_vlstr_attr(state_t *s, hid_t g, unsigned int which, bool vrfy_mod) -{ - hid_t aid = H5I_INVALID_HID; - hid_t atype = H5I_INVALID_HID; - char name[VS_ATTR_NAME_LEN]; - - char *astr_val_exp; - char *astr_val; - - /* Go ahead to read the VL string attribute. */ - astr_val_exp = HDmalloc(VS_ATTR_NAME_LEN); - if (astr_val_exp == NULL) { - printf("Allocate memory for expected buffer failed.\n"); - TEST_ERROR; - } - - esnprintf(name, sizeof(name), "attr-%u", which); - - /* Construct the expected VL string value,depending if - * it is the modified value or the original value. */ - if (vrfy_mod == true) - HDsprintf(astr_val_exp, "%u%c", which, 'A'); - else - HDsprintf(astr_val_exp, "%u", which); - - dbgf(1, "verifying attribute %s on group %u equals %u\n", name, which, which); - - dbgf(1, "expected vl attr is= %s\n", astr_val_exp); - - if ((aid = H5Aopen(g, name, H5P_DEFAULT)) < 0) { - printf("H5Aopen failed\n"); - TEST_ERROR; - } - - /* Create a VL string datatype */ - if ((atype = H5Tcopy(H5T_C_S1)) < 0) { - printf("Cannot create variable length datatype.\n"); - TEST_ERROR; - } - - if (H5Tset_size(atype, H5T_VARIABLE) < 0) { - printf("Cannot set variable length datatype.\n"); - TEST_ERROR; - } - - if (H5Aread(aid, atype, &astr_val) < 0) { - printf("Cannot read the attribute.\n"); - TEST_ERROR; - } - - dbgf(1, "read attr is= %s\n", astr_val); - if (HDstrcmp(astr_val, astr_val_exp) != 0) { - printf("reader: the vl add_attribute verfication failed,expected value is %s\n", astr_val_exp); - printf("reader: the vl add_attribute verfication failed, the value is %s\n", astr_val); - printf("The vl add_attribute verification failed\n"); - TEST_ERROR; - } - - if (H5Tclose(atype) < 0) { - printf("H5Tclose failed.\n"); - TEST_ERROR; - } - - if (H5Aclose(aid) < 0) { - printf("H5Aclose failed.\n"); - TEST_ERROR; - } - - H5free_memory(astr_val); - HDfree(astr_val_exp); - - return true; - -error: - H5E_BEGIN_TRY - { - H5Aclose(aid); - H5Tclose(atype); - } - H5E_END_TRY; - if (astr_val) - H5free_memory(astr_val); - if (astr_val_exp) - HDfree(astr_val_exp); - - return false; -} - -/*------------------------------------------------------------------------- - * Function: verify_del_one_attr - * - * Purpose: Verify if an attribute is successfully deleted. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t g - * HDF5 object ID (in this file: means group ID) - * - * const char* aname - * The name of the attribute to be deleted. - * - * bool check_storage - * a flag to indicate if the storage check is on - * - * bool is_compact - * true if after this attribute is deleted, - * the storage should still be in compact, false - * if the storage should be in dense. - * Note: this parameter is not used if the check_storage - * is set to false. - - * Return: Success: true - * Failure: false - * - * Note: This is an internal function used by "remove-vlstr", - * "compact-del","dense-del",dense-del-to-compact" tests. - *------------------------------------------------------------------------- - */ - -static bool -verify_del_one_attr(state_t *s, hid_t g, const char *aname, bool check_storage, bool is_compact) -{ - - htri_t attr_exists = FALSE; - - /* Check if the deleted attribute still exists. */ - attr_exists = H5Aexists_by_name(g, ".", aname, H5P_DEFAULT); - if (attr_exists == FALSE) { - dbgf(1, "verify_del_attrs_compact() test: \n"); - dbgf(1, " attribute %s is successfully deleted. \n", aname); - } - else if (attr_exists == TRUE) { - printf("The supposed deleted attribute %s still exists \n", aname); - printf("verify_del_attrs_compact() test failed \n"); - TEST_ERROR; - } - else { - printf("H5Aexists_by_name failed \n"); - TEST_ERROR; - } - - if (!s->old_style_grp && check_storage == true) { - if (false == check_attr_storage_type(g, is_compact)) { - printf("The attribute storage type is wrong. \n"); - TEST_ERROR; - } - } - - /* If coming to an "object header continuation block" test, - * we need to check if this test behaves as expected. */ - if (s->at_pattern == 'R') { - if (false == check_ohr_num_chunk(g, true)) { - printf("An object header continuation block should be removed. \n"); - printf("But it is NOT.\n"); - printf("Verification of an 'object header continuation block test' failed.\n"); - TEST_ERROR; - } - } - - return true; -error: - return false; -} - -/*------------------------------------------------------------------------- - * Function: verify_remove_vlstr_attr - * - * Purpose: Verify if an variable length string attribute is - * successfully deleted by the writer. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t g - * HDF5 object ID (in this file: means group ID) - * - * unsigned int which - * Use to derieve the expected attribute value added - * by the writer. It is also used to construct - * the attribute name. - * - * - * Return: Success: true - * Failure: false - * - * Note: This function is for the "remove-vstr" test. - * Also note this function first verifies if - * a variable length attribute is added then - * it verifies if it is deleted successfully. - *------------------------------------------------------------------------- - */ - -static bool -verify_remove_vlstr_attr(state_t *s, hid_t g, unsigned int which) -{ - bool ret = false; - char attrname[VS_ATTR_NAME_LEN]; - const char *aname_format = "attr-%u"; - - ret = verify_group_vlstr_attr(s, g, which, false); - if (ret == true) { - HDsprintf(attrname, aname_format, which); - ret = verify_del_one_attr(s, g, attrname, false, false); - } - return ret; -} - -/*------------------------------------------------------------------------- - * Function: verify_modify_vlstr_attr - * - * Purpose: Verify if an variable length string attribute is - * successfully modified by the writer. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t g - * HDF5 object ID (in this file: means group ID) - * - * unsigned int which - * Use to derieve the expected attribute value added - * by the writer. It is also used to construct - * the attribute name. - * - * - * Return: Success: true - * Failure: false - * - * Note: This function is for the "modify-vstr" test. - * Also note this function first verifies if - * a variable length attribute is added then - * it verifies if it is modified successfully. - *------------------------------------------------------------------------- - */ - -static bool -verify_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which) -{ - - bool ret = false; - - ret = verify_group_vlstr_attr(s, g, which, false); - if (ret == true) - ret = verify_group_vlstr_attr(s, g, which, true); - return ret; -} - -/*------------------------------------------------------------------------- - * Function: verify_attrs_compact - * - * Purpose: Verify if attributes are successfully added for the compact - * storage. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t g - * HDF5 object ID (in this file: means group ID) - * - * unsigend max_c - * The maximal number of attributes the compact storage - * can hold - * - * unsigned int which - * Use to derieve the expected attribute value added - * by the writer. It is also used to construct the - * attribute names. - * - * - * Return: Success: true - * Failure: false - * - * Note: This function is used by the "compact" test. - *------------------------------------------------------------------------- - */ - -static bool -verify_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which) -{ - - unsigned u; - bool ret = true; - const char *aname_format = "attr-%u-%u"; - char attrname[VS_ATTR_NAME_LEN]; - - /* Need to verify the added attribute one by one. */ - for (u = 0; u < max_c; u++) { - - HDsprintf(attrname, aname_format, which, u); - if (false == vrfy_attr(s, g, u + which, attrname, which, true, true)) { - ret = false; - break; - } - } - return ret; -} - -/*------------------------------------------------------------------------- - * Function: verify_attrs_compact_dense - * - * Purpose: Verify if attributes are successfully added first in the - * compact storage then in the dense storage. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t g - * HDF5 object ID (in this file: means group ID) - * - * unsigend max_c - * The maximal number of attributes the compact storage - * can hold - * - * unsigned int which - * Use to derieve the expected attribute value added - * by the writer. It is also used to construct - * attribute names. - * - * - * Return: Success: true - * Failure: false - * - * Note: This function is used by the "compact-dense" test. - *------------------------------------------------------------------------- - */ - -static bool -verify_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int which) -{ - - const char *aname_format = "attr-d-%u-%u"; - char attrname[VS_ATTR_NAME_LEN]; - - bool ret = verify_attrs_compact(s, g, max_c, which); - - if (ret == true) { - - /* Now the storage is in dense. Verify if the - * retrieved value is correct. */ - HDsprintf(attrname, aname_format, max_c + which, 0); - ret = vrfy_attr(s, g, which + max_c, attrname, which, true, false); - } - return ret; -} - -/*------------------------------------------------------------------------- - * Function: verify_del_attrs_compact - * - * Purpose: Verify if an attribute in compact storage is successfully - * deleted. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t g - * HDF5 object ID (in this file: means group ID) - * - * unsigend max_c - * The maximal number of attributes the compact storage - * can hold - * - * unsigned int which - * Use to derieve the expected attribute value added - * by the writer. It is also used to construct - * attribute names. - * - * - * Return: Success: true - * Failure: false - * - * Note: This function is used by the "compact-del" test. - * Also note this function first verifies if - * attributes are successfully added in compact storage then - * it verifies if one added attribute is deleted successfully. - *------------------------------------------------------------------------- - */ - -static bool -verify_del_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which) -{ - - const char *aname_format = "attr-%u-%u"; - char attrname[VS_ATTR_NAME_LEN]; - - bool ret = verify_attrs_compact(s, g, max_c, which); - - if (ret == true) { - /* The writer only deletes the attribute attr-which-0 */ - HDsprintf(attrname, aname_format, which, 0); - ret = verify_del_one_attr(s, g, attrname, true, true); - } - - return ret; -} - -/*------------------------------------------------------------------------- - * Function: verify_del_attrs_compact_dense - * - * Purpose: Verify if an attribute in dense storage is successfully - * deleted. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t g - * HDF5 object ID (in this file: means group ID) - * - * unsigend max_c - * The maximal number of attributes the compact storage - * can hold - * - * unsigned int which - * Use to derieve the expected attribute value added - * by the writer. It is also used to construct - * attribute names. - * - * - * Return: Success: true - * Failure: false - * - * Note: This function is used by the "dense-del" test. - * Also note this function first verifies if - * attributes are successfully added in compact storage then - * in dense storage. Afterwards, - * it verifies if one added attribute is deleted successfully. - *------------------------------------------------------------------------- - */ - -static bool -verify_del_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int which) -{ - - const char *aname_format = "attr-d-%u-%u"; - char attrname[VS_ATTR_NAME_LEN]; - - bool ret = verify_attrs_compact_dense(s, g, max_c, which); - - if (ret == true) { - /* The writer only deletes the attribute attr-d-which-0 */ - HDsprintf(attrname, aname_format, max_c + which, 0); - ret = verify_del_one_attr(s, g, attrname, true, false); - } - - return ret; -} - -/*------------------------------------------------------------------------- - * Function: verify_del_attrs_compact_dense_compact - * - * Purpose: verify that the attributes are deleted successfully - * even the attribute storage changes from dense to - * compact. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t g - * HDF5 object ID (in this file: means group ID) - * - * unsigend max_c - * The maximal number of attributes the compact storage - * can hold - * - * unsigend min_d - * The minimal number of attributes to be stored in - * dense storage - * - * unsigned int which - * Use to derieve the expected attribute value added - * by the writer. It is also used to construct - * attribute names. - * - * - * Return: Success: true - * Failure: false - * - * Note: This function is used by the "dense-del-to-compact" test. - * Also note this function first verifies if - * attributes are successfully added in compact storage then - * in dense storage. Afterwards, - * it verifies if some added attributes are deleted successfully - * until the storage changes from dense to compact. - *------------------------------------------------------------------------- - */ - -static bool -verify_del_attrs_compact_dense_compact(state_t *s, hid_t g, unsigned max_c, unsigned min_d, - unsigned int which) -{ - - unsigned u; - const char *aname_format = "attr-%u-%u"; - char attrname[VS_ATTR_NAME_LEN]; - - /* Verify the attributes are added correctly from - * compact to dense storage*/ - bool ret = verify_attrs_compact_dense(s, g, max_c, which); - - if (ret == true) { - - /* Then verify the deletion of attributes - * from dense to compact. - */ - u = max_c + 1; - for (u--; u >= (min_d - 1); u--) { - HDsprintf(attrname, aname_format, which, max_c - u); - if (u == (min_d - 1)) - ret = verify_del_one_attr(s, g, attrname, true, true); - else - ret = verify_del_one_attr(s, g, attrname, true, false); - } - - /* Just verify one more deleted attribute by the writer. - The storage is still compact. */ - HDsprintf(attrname, aname_format, max_c + which, 0); - ret = verify_del_one_attr(s, g, attrname, true, true); - } - - return ret; -} - -/*------------------------------------------------------------------------- - * Function: verify_del_ohr_block_attr - * - * Purpose: Verify that an attribute is added to force creation of - * object header continuation block and remove this attribute - * to delete the object header continuation block - - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t g - * HDF5 object ID (in this file: means group ID) - * - * unsigned int which - * The number of iterations for group creation, use to generate - * group and attribute names. - * - * - * Return: Success: true - * Failure: false - * - * Note: This is called by the verify_group() function. - *------------------------------------------------------------------------- - */ - -static bool -verify_del_ohr_block_attr(state_t *s, hid_t g, unsigned int which) -{ - - bool ret_value = false; - char attrname[VS_ATTR_NAME_LEN]; - const char *aname_format = "attr-%u"; - - ret_value = verify_default_group_attr(s, g, which); - if (ret_value == true) { - HDsprintf(attrname, aname_format, which); - ret_value = verify_del_one_attr(s, g, attrname, false, true); - } - return ret_value; -} -/*------------------------------------------------------------------------- - * Function: verify_group_attribute - * - * Purpose: Check the attribute test pattern and then call the - * correponding verification function. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t g - * HDF5 object ID (in this file: means group ID) - * - * unsigned int which - * The number of iterations for group creation, use to generate - * group and attribute names. - * - * - * Return: Success: true - * Failure: false - * - * Note: This is called by the verify_group() function. - *------------------------------------------------------------------------- - */ - -static bool -verify_group_attribute(state_t *s, hid_t g, unsigned int which) -{ - char test_pattern = s->at_pattern; - bool ret = false; - unsigned max_compact = 0; - unsigned min_dense = 0; - hid_t gcpl = H5I_INVALID_HID; - - /* For tests "compact","compact-to-dense","compact-del", - * "dense-del", "dense-del-to-compact", - * the maximal number of attributes for the compact storage - * and the minimal number of attributes for the dense storage - * are needed. So obtain them here - * When testing the old-style group creation case, only max_compact - * matters. To reduce the testing time, we set max_compact to 2.*/ - switch (test_pattern) { - case 'c': - case 't': - case 'C': - case 'D': - case 'T': - if (s->old_style_grp) - max_compact = 2; - else { - if ((gcpl = H5Gget_create_plist(g)) < 0) { - printf("H5Gget_create_plist failed\n"); - TEST_ERROR; - } - if (H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { - printf("H5Pget_attr_phase_change failed\n"); - TEST_ERROR; - } - if (H5Pclose(gcpl) < 0) { - printf("H5Pclose failed\n"); - TEST_ERROR; - } - } - break; - case 'v': - case 'd': - case 'M': - case 'm': - case 'r': - case 'a': - case 'R': - case ' ': - default: - break; - } - - /* Distribute the verification test. */ - switch (test_pattern) { - case 'c': - ret = verify_attrs_compact(s, g, max_compact, which); - break; - case 't': - ret = verify_attrs_compact_dense(s, g, max_compact, which); - break; - case 'C': - ret = verify_del_attrs_compact(s, g, max_compact, which); - break; - case 'D': - ret = verify_del_attrs_compact_dense(s, g, max_compact, which); - break; - case 'T': - ret = verify_del_attrs_compact_dense_compact(s, g, max_compact, min_dense, which); - break; - case 'M': - ret = verify_modify_attr(s, g, which); - break; - case 'v': - ret = verify_group_vlstr_attr(s, g, which, false); - break; - case 'r': - ret = verify_remove_vlstr_attr(s, g, which); - break; - case 'm': - ret = verify_modify_vlstr_attr(s, g, which); - break; - case 'R': - ret = verify_del_ohr_block_attr(s, g, which); - break; - case 'a': - case 'd': - case ' ': - default: - ret = verify_default_group_attr(s, g, which); - break; - } - - return ret; - -error: - return false; -} - -/*------------------------------------------------------------------------- - * Function: verify_group - * - * Purpose: verify the success of group creation and - * carry out the test for attribute operations(add,delete etc.) - * according to the attribute test pattern. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * unsigned int which - * The number of iterations for group creation - * - * - * Return: Success: true - * Failure: false - * - * Note: This is called by the main() function. - *------------------------------------------------------------------------- - */ - -static bool -verify_group(state_t *s, unsigned int which) -{ - char name[sizeof("/group-9999999999")]; - hid_t g = H5I_INVALID_HID; - bool result = true; - H5G_info_t group_info; - - if (which >= s->nsteps) { - printf("Number of created groups is out of bounds\n"); - TEST_ERROR; - } - - esnprintf(name, sizeof(name), "/group-%u", which); - - if ((g = H5Gopen(s->file, name, H5P_DEFAULT)) < 0) { - printf("H5Gopen failed\n"); - TEST_ERROR; - } - - if (H5Gget_info(g, &group_info) < 0) { - printf("H5Gget_info failed\n"); - TEST_ERROR; - } - - dbgf(2, "Storage info is %d\n", group_info.storage_type); - if (s->old_style_grp) { - if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { - printf("Reader - Old-styled group: but the group is not in old-style. \n"); - TEST_ERROR; - } - dbgf(2, "Reader: verify that the group is created with the old-style.\n"); - } - else { - if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { - printf("Reader - The created group should NOT be in old-style . \n"); - TEST_ERROR; - } - dbgf(2, "Reader: verify that the group is created with the new-style.\n"); - } - - /* If coming to an "object header continuation block" test, - * we need to check if this test behaves as expected. */ - if (s->at_pattern == 'a' || s->at_pattern == 'R') { - if (false == check_ohr_num_chunk(g, true)) { - printf("An object header continuation block should NOT be created. \n"); - printf("But it is created.\n"); - printf("Verification of an 'object header continuation block test' failed.\n"); - TEST_ERROR; - } - } - - /* Check if we need to skip the attribute test for this group. */ - if (s->asteps != 0 && which % s->asteps == 0) - result = verify_group_attribute(s, g, which); - else - result = true; - - if (H5Gclose(g) < 0) { - printf("H5Gclose failed\n"); - TEST_ERROR; - } - - return result; - -error: - - H5E_BEGIN_TRY - { - H5Gclose(g); - } - H5E_END_TRY; - - return false; -} - -/*------------------------------------------------------------------------- - * Function: create_group_id - * - * Purpose: Create a group and return the group ID. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * unsigned int which - * The number of iterations for group creation - * This is used to generate the group name. - * - * bool dense_to_compact - * true if this function is used to test the transition from dense to - * compact, false if the test is from compact to dense. - * - * Return: Success: the group ID - * Failure: -1 - * - * Note: Only used by testing the link storage transit functions. - *------------------------------------------------------------------------- - */ - -static hid_t -create_group_id(state_t *s, unsigned int which, bool dense_to_compact) -{ - - char name[sizeof("/group-9999999999")]; - hid_t g = H5I_INVALID_HID; - hid_t gcpl = H5I_INVALID_HID; - H5G_info_t group_info; - - if (which >= s->nsteps) { - printf("Number of created groups is out of bounds\n"); - TEST_ERROR; - } - - gcpl = H5Pcreate(H5P_GROUP_CREATE); - if (gcpl < 0) { - printf("H5Pcreate failed\n"); - TEST_ERROR; - } - - if (dense_to_compact) { - if (H5Pset_link_phase_change(gcpl, 2, 2) < 0) { - printf("H5Pset_link_phase_change failed for dense to compact.\n"); - TEST_ERROR; - } - } - else { - if (H5Pset_link_phase_change(gcpl, 1, 1) < 0) { - printf("H5Pset_attr_phase_change failed for compact to dense.\n"); - TEST_ERROR; - } - } - - esnprintf(name, sizeof(name), "/group-%u", which); - if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) { - printf("H5Gcreate2 failed\n"); - TEST_ERROR; - } - - if (H5Gget_info(g, &group_info) < 0) { - printf("H5Gget_info failed\n"); - TEST_ERROR; - } - - /* The storage type should always be compact when a group is created. */ - if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { - printf("New-style group link storage test:. \n"); - printf(" still be compact after group creation. \n"); - TEST_ERROR; - } - - if (H5Pclose(gcpl) < 0) { - printf("H5Pclose failed\n"); - TEST_ERROR; - } - - return g; - -error: - - H5E_BEGIN_TRY - { - H5Pclose(gcpl); - } - H5E_END_TRY; - - return -1; -} - -/*------------------------------------------------------------------------- - * Function: close_group_id - * - * Purpose: Verify is a group is closed successfully. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t g - * The ID of the group to be closed. - * - * Return: Success: true - * Failure: false - * - * Note: This is used by the link storage transit functions. - *------------------------------------------------------------------------- - */ - -static bool -close_group_id(state_t *s, hid_t g) -{ - - if (H5Gclose(g) < 0) { - printf("H5Gclose failed\n"); - TEST_ERROR; - } - - return true; - -error: - return false; -} - -/*------------------------------------------------------------------------- - * Function: create_group - * - * Purpose: Create a group - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * unsigned int which - * The number of iterations for group creation - * This is used to generate the group name. - * - * Return: Success: true - * Failure: false - * - * Note: This is called by the main() function. - *------------------------------------------------------------------------- - */ - -static bool -create_group(state_t *s, unsigned int which) -{ - - char name[sizeof("/group-9999999999")]; - hid_t g = H5I_INVALID_HID; - H5G_info_t group_info; - - if (which >= s->nsteps) { - printf("Number of created groups is out of bounds\n"); - TEST_ERROR; - } - - esnprintf(name, sizeof(name), "/group-%u", which); - if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - printf("H5Gcreate2 failed\n"); - TEST_ERROR; - } - - if (H5Gget_info(g, &group_info) < 0) { - printf("H5Gget_info failed\n"); - TEST_ERROR; - } - - if (s->old_style_grp) { - if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { - printf("Old-styled group test: but the group is not in old-style. \n"); - TEST_ERROR; - } - dbgf(2, "Writer: group is created with the old-style.\n"); - } - else { - if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { - printf("The created group should NOT be in old-style . \n"); - TEST_ERROR; - } - dbgf(2, "Writer: group is created with the new-style.\n"); - } - - if (H5Gclose(g) < 0) { - printf("H5Gclose failed\n"); - TEST_ERROR; - } - - return true; - -error: - - H5E_BEGIN_TRY - { - H5Gclose(g); - } - H5E_END_TRY; - - return false; -} - -/*------------------------------------------------------------------------- - * Function: delete_one_link - * - * Purpose: Delete a link(either hard/soft) in group operation tests. - * according to the group test pattern. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t obj_id - * The HDF5 object ID that the deleted link is attached to. - * - * const char *name - * The name of the link to be deleted. - * - * short link_storage - * <=0: link storage is ignored. - * 1: link storage should be compact after link deletion.. - * >1: link storage should be dense after link deletion. - * - * unsigned int which - * The number of iterations for group creation - * - * - * Return: Success: true - * Failure: false - * - * Note: This is used by delete_groups() and delete_links() functions. - *------------------------------------------------------------------------- - */ - -static bool -delete_one_link(state_t *s, hid_t obj_id, const char *name, short link_storage, unsigned int which) -{ - - H5G_info_t group_info; - - if (which >= s->nsteps) { - printf("Number of created groups is out of bounds\n"); - TEST_ERROR; - } - - if (H5Ldelete(obj_id, name, H5P_DEFAULT) < 0) { - printf("H5Ldelete failed\n"); - TEST_ERROR; - } - - if (link_storage > 0) { - - if (s->old_style_grp) { - printf("Old style group doesn't support the indexed storage.\n"); - TEST_ERROR; - } - - if (H5Gget_info(obj_id, &group_info) < 0) { - printf("H5Gget_info failed\n"); - TEST_ERROR; - } - - if (link_storage == 1) { - - if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { - printf("The group link storage should be compact. \n"); - TEST_ERROR; - } - } - else { - - if (group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { - printf("The group link storage should be dense. \n"); - TEST_ERROR; - } - } - } - - return true; - -error: - return false; -} - -/*------------------------------------------------------------------------- - * Function: delete_group - * - * Purpose: Delete a group and carry out group operations(add,delete etc.) - * according to the group operation test pattern. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * unsigned int which - * The number of iterations for group creation - * This is used to generate the group name - * - * - * Return: Success: true - * Failure: false - * - * Note: This is called by the group_operations() function. - *------------------------------------------------------------------------- - */ - -static bool -delete_group(state_t *s, unsigned int which) -{ - - char name[sizeof("/group-9999999999")]; - bool ret_value = create_group(s, which); - if (ret_value == true) { - esnprintf(name, sizeof(name), "/group-%u", which); - ret_value = delete_one_link(s, s->file, name, 0, which); - } - - return ret_value; -} - -/*------------------------------------------------------------------------- - * Function: move_one_group - * - * Purpose: A helper function used by the move_group operation. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t obj_id - * ID of the object this group is attached to - * - * const char *name - * The original group name - * - * const char *newname - * The new group name - * - * unsigned int which - * The number of iterations for group creation - * - * - * Return: Success: true - * Failure: false - * - * Note: This is called by the move_group() function. - *------------------------------------------------------------------------- - */ - -static bool -move_one_group(state_t *s, hid_t obj_id, const char *name, const char *newname, unsigned int which) -{ - - if (which >= s->nsteps) { - printf("Number of created groups is out of bounds\n"); - TEST_ERROR; - } - - if (H5Lmove(obj_id, name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { - printf("H5Ldelete failed\n"); - TEST_ERROR; - } - - return true; - -error: - return false; -} - -/*------------------------------------------------------------------------- - * Function: move_group - * - * Purpose: Move a group to another group. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * unsigned int which - * The number of iterations for group creation - * used to generate the group name. - * - * Return: Success: true - * Failure: false - * - * Note: This is called by the group_operations() function. - *------------------------------------------------------------------------- - */ - -static bool -move_group(state_t *s, unsigned int which) -{ - - char name[sizeof("/group-9999999999")]; - char new_name[sizeof("/new-group-9999999999")]; - bool ret_value = create_group(s, which); - if (ret_value == true) { - esnprintf(name, sizeof(name), "/group-%u", which); - esnprintf(new_name, sizeof(new_name), "/new-group-%u", which); - ret_value = move_one_group(s, s->file, name, new_name, which); - } - - return ret_value; -} - -/*------------------------------------------------------------------------- - * Function: insert_one_link - * - * Purpose: A helper function used to attach a link to a group. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * hid_t obj_id - * ID of the object this link is attached to - * - * const char *name - * The name of the target object used by creating links - * - * const char *newname - * The name of the linked objects - * - * bool is_hard - * true if inserting a hard link - * false if inserting a soft link - * - * short link_storage - * <=0: link storage is ignored. - * 1: link storage should be compact. - * >1: link storage should be dense. - - * unsigned int which - * The number of iterations for group creation - * - * Return: Success: true - * Failure: false - * - * Note: This is called by the insert_links and link storage transit functions. - * For link storage, we test at both the writer and the reader. - *------------------------------------------------------------------------- -*/ - -static bool -insert_one_link(state_t *s, hid_t obj_id, const char *name, const char *newname, bool is_hard, - short link_storage, unsigned int which) -{ - - H5G_info_t group_info; - - if (which >= s->nsteps) { - printf("Number of created groups is out of bounds\n"); - TEST_ERROR; - } - - /* For storage transit and insert_links cases, we - * create links in different style, just add a little - * variation of the tests.*/ - if (is_hard) { - if (link_storage > 0) { - if (H5Lcreate_hard(s->file, name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { - printf("H5Lcreate_hard failed\n"); - TEST_ERROR; - } - } - else { - if (H5Lcreate_hard(obj_id, name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { - printf("H5Lcreate_hard failed\n"); - TEST_ERROR; - } - } - } - else { - if (link_storage > 0) { - if (H5Lcreate_soft("/", obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { - printf("H5Lcreate_soft failed\n"); - TEST_ERROR; - } - } - else { - if (H5Lcreate_soft(name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { - printf("H5Lcreate_soft failed.\n"); - TEST_ERROR; - } - } - } - - if (link_storage > 0) { - - if (s->old_style_grp) { - printf("Old style group doesn't support dense or compact storage.\n"); - TEST_ERROR; - } - - if (H5Gget_info(obj_id, &group_info) < 0) { - printf("H5Gget_info failed\n"); - TEST_ERROR; - } - - if (link_storage == 1) { - if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { - printf("The group link storage should be compact. \n"); - TEST_ERROR; - } - } - else { - if (group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { - printf("The group link storage should be dense. \n"); - TEST_ERROR; - } - } - } - - return true; - -error: - return false; -} - -/*------------------------------------------------------------------------- - * Function: insert_links - * - * Purpose: create links with a group. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * unsigned int which - * The number of iterations - * used to generate the group name. - * - * Return: Success: true - * Failure: false - * - * Note: This is called by the group_operations() function. - *------------------------------------------------------------------------- - */ - -static bool -insert_links(state_t *s, unsigned int which) -{ - - char name[sizeof("/group-9999999999")]; - char hd_name[sizeof("/hd-group-9999999999")]; - char st_name[sizeof("/st-group-9999999999")]; - - bool ret_value = create_group(s, which); - if (ret_value == true) { - esnprintf(name, sizeof(name), "/group-%u", which); - esnprintf(hd_name, sizeof(hd_name), "/hd-group-%u", which); - esnprintf(st_name, sizeof(st_name), "/st-group-%u", which); - ret_value = insert_one_link(s, s->file, name, hd_name, true, 0, which); - if (ret_value == true) - ret_value = insert_one_link(s, s->file, name, st_name, false, 0, which); - } - - return ret_value; -} - -/*------------------------------------------------------------------------- - * Function: delete_links - * - * Purpose: create links with a group and then delete them successfully. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * unsigned int which - * The number of iterations - * used to generate the group name. - * - * Return: Success: true - * Failure: false - * - * Note: This is called by the group_operations() function. - *------------------------------------------------------------------------- - */ - -static bool -delete_links(state_t *s, unsigned int which) -{ - - char name[sizeof("/group-9999999999")]; - char hd_name[sizeof("/hd-group-9999999999")]; - char st_name[sizeof("/st-group-9999999999")]; - - bool ret_value = insert_links(s, which); - if (ret_value == true) { - esnprintf(name, sizeof(name), "/group-%u", which); - esnprintf(hd_name, sizeof(hd_name), "/hd-group-%u", which); - esnprintf(st_name, sizeof(st_name), "/st-group-%u", which); - ret_value = delete_one_link(s, s->file, hd_name, 0, which); - if (ret_value == true) - ret_value = delete_one_link(s, s->file, st_name, 0, which); - } - - return ret_value; -} - -/*------------------------------------------------------------------------- - * Function: transit_storage_compact_to_dense - * - * Purpose: Add links so that the link storage transits from - * compact to dense. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * unsigned int which - * The number of iterations used to generate the group name. - * - * Return: Success: true - * Failure: false - * - * Note: This is called by the group_operations() function. - *------------------------------------------------------------------------- - */ - -static bool -transit_storage_compact_to_dense(state_t *s, unsigned int which) -{ - - char name[sizeof("/group-9999999999")]; - char hd_name[sizeof("/hd-group-9999999999")]; - char st_name[sizeof("/st-group-9999999999")]; - - hid_t g = create_group_id(s, which, false); - if (g < 0) { - printf("create_group_id failed\n"); - TEST_ERROR; - } - - /* First insert a hard link, compact storage. */ - esnprintf(name, sizeof(name), "/group-%u", which); - esnprintf(hd_name, sizeof(hd_name), "hd-group-%u", which); - if (insert_one_link(s, g, name, hd_name, true, 1, which) == false) { - printf("insert_one_link for compact storage failed\n"); - TEST_ERROR; - } - - /* Then insert a soft link, the storage becomes dense. */ - esnprintf(st_name, sizeof(st_name), "st-group-%u", which); - if (insert_one_link(s, g, name, st_name, false, 2, which) == false) { - printf("insert_one_link for dense storage failed\n"); - TEST_ERROR; - } - - if (close_group_id(s, g) == false) { - printf("insert_one_link for dense storage failed\n"); - TEST_ERROR; - } - - return true; - -error: - H5E_BEGIN_TRY - { - H5Gclose(g); - } - H5E_END_TRY; - - return false; -} - -/*------------------------------------------------------------------------- - * Function: transit_storage_dense_to_compact - * - * Purpose: Add or delete links so that the link storage transits from - * compact to dense then to compact. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * unsigned int which - * The number of iterations used to generate the group name. - * - * Return: Success: true - * Failure: false - * - * Note: This is called by the group_operations() function. - *------------------------------------------------------------------------- - */ - -static bool -transit_storage_dense_to_compact(state_t *s, unsigned int which) -{ - - char name[sizeof("/group-9999999999")]; - char hd_name[sizeof("/hd-group-9999999999")]; - char st_name[sizeof("st-group-9999999999")]; - char st2_name[sizeof("st2-group-9999999999")]; - - hid_t g = create_group_id(s, which, true); - if (g < 0) { - printf("create_group_id failed\n"); - TEST_ERROR; - } - - /* Insert a link, storage is compact. */ - esnprintf(name, sizeof(name), "/group-%u", which); - esnprintf(hd_name, sizeof(hd_name), "hd-group-%u", which); - if (insert_one_link(s, g, name, hd_name, true, 1, which) == false) { - printf("insert_one_link for compact storage failed\n"); - TEST_ERROR; - } - - /* Insert a link, storage is still compact. */ - esnprintf(st_name, sizeof(st_name), "st-group-%u", which); - if (insert_one_link(s, g, name, st_name, false, 1, which) == false) { - printf("insert_one_link for compact storage failed\n"); - TEST_ERROR; - } - - /* Insert a link, storage becomes dense. */ - esnprintf(st2_name, sizeof(st2_name), "st2-group-%u", which); - if (insert_one_link(s, g, name, st2_name, false, 2, which) == false) { - printf("insert_one_link for dense storage failed\n"); - TEST_ERROR; - } - - /* Delete a link, storage is still dense */ - if (delete_one_link(s, g, st_name, 2, which) == false) { - printf("delete_one_link for dense storage failed\n"); - TEST_ERROR; - } - - /* Delete another link, storage becomes compact */ - if (delete_one_link(s, g, st2_name, 1, which) == false) { - printf("delete_one_link for compact storage failed\n"); - TEST_ERROR; - } - - if (close_group_id(s, g) == false) { - printf("insert_one_link for dense storage failed\n"); - TEST_ERROR; - } - - return true; - -error: - H5E_BEGIN_TRY - { - H5Gclose(g); - } - H5E_END_TRY; - - return false; -} - -/*------------------------------------------------------------------------- - * Function: group_operations - * - * Purpose: Carry out group and attribute operations(add,delete etc.) - * according to the group operation and attribute test patterns. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * unsigned int which - * The number of iterations for group creation - * - * - * Return: Success: true - * Failure: false - * - * Note: This is called by the main() function. The check of attribute - * operations is inside the write_group() function. - *------------------------------------------------------------------------- - */ -static bool -group_operations(state_t *s, unsigned int which) -{ - - bool ret_value = false; - char test_pattern = s->grp_op_pattern; - - switch (test_pattern) { - case 'c': - ret_value = create_group(s, which); - break; - case 'd': - ret_value = delete_group(s, which); - break; - case 'm': - ret_value = move_group(s, which); - break; - case 'i': - ret_value = insert_links(s, which); - break; - case 'D': - ret_value = delete_links(s, which); - break; - case 't': - ret_value = transit_storage_compact_to_dense(s, which); - break; - case 'T': - ret_value = transit_storage_dense_to_compact(s, which); - break; - case ' ': - default: - ret_value = write_group(s, which); - break; - } - return ret_value; -} - -/*------------------------------------------------------------------------- - * Function: vrfy_create_group - * - * Purpose: Verify if a group can be created successfully. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * unsigned int which - * The number of iterations for group creation - * used to generate the group name. - * - * Return: Success: true - * Failure: false - * - * Note: This is called by the verify_group_operations() function. - *------------------------------------------------------------------------- - */ - -static bool -vrfy_create_group(state_t *s, unsigned int which) -{ - - char name[sizeof("/group-9999999999")]; - hid_t g = H5I_INVALID_HID; - H5G_info_t group_info; - - if (which >= s->nsteps) { - printf("Number of created groups is out of bounds\n"); - TEST_ERROR; - } - - esnprintf(name, sizeof(name), "/group-%u", which); - - if ((g = H5Gopen(s->file, name, H5P_DEFAULT)) < 0) { - printf("H5Gopen failed\n"); + esnprintf(name, sizeof(name), "/group-%u", which); + if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + printf("H5Gcreate2 failed\n"); TEST_ERROR; } @@ -3591,20 +1842,19 @@ vrfy_create_group(state_t *s, unsigned int which) TEST_ERROR; } - dbgf(2, "Storage info is %d\n", group_info.storage_type); if (s->old_style_grp) { if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { - printf("Reader - Old-styled group: but the group is not in old-style. \n"); + printf("Old-styled group test: but the group is not in old-style. \n"); TEST_ERROR; } - dbgf(2, "Reader: verify that the group is created with the old-style.\n"); + dbgf(2, "Writer: group is created with the old-style.\n"); } else { if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { - printf("Reader - The created group should NOT be in old-style . \n"); + printf("The created group should NOT be in old-style . \n"); TEST_ERROR; } - dbgf(2, "Reader: verify that the group is created with the new-style.\n"); + dbgf(2, "Writer: group is created with the new-style.\n"); } if (H5Gclose(g) < 0) { @@ -3626,251 +1876,176 @@ error: } /*------------------------------------------------------------------------- - * Function: vrfy_create_group_id + * Function: delete_one_link * - * Purpose: Verify if a group is created successfully and return the group - * ID. + * Purpose: Delete a link(either hard/soft) in group operation tests. + * according to the group test pattern. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe * and some VFD SWMR configuration parameters * + * hid_t obj_id + * The HDF5 object ID that the deleted link is attached to. + * + * const char *name + * The name of the link to be deleted. + * + * short link_storage + * <=0: link storage is ignored. + * 1: link storage should be compact after link deletion.. + * >1: link storage should be dense after link deletion. + * * unsigned int which * The number of iterations for group creation - * used to generate the group name. * - * bool dense_to_compact - * true if this function is used to test the transition from dense to - * compact, false if the test is from compact to dense. * - * Return: Success: the group ID - * Failure: -1 + * Return: Success: true + * Failure: false * - * Note: This function is used by the link storage transit functions. + * Note: This is used by delete_groups() and delete_links() functions. *------------------------------------------------------------------------- */ -static hid_t -vrfy_create_group_id(state_t *s, unsigned int which, bool dense_to_compact) +static bool +delete_one_link(state_t *s, hid_t obj_id, const char *name, short link_storage, unsigned int which) { - char name[sizeof("/group-9999999999")]; - hid_t g = H5I_INVALID_HID; - hid_t gcpl = H5I_INVALID_HID; H5G_info_t group_info; - unsigned max_compact = 0; - unsigned min_dense = 0; if (which >= s->nsteps) { - printf("Number of the created groups is out of bounds\n"); - TEST_ERROR; - } - - esnprintf(name, sizeof(name), "/group-%u", which); - - if ((g = H5Gopen(s->file, name, H5P_DEFAULT)) < 0) { - printf("H5Gopen failed\n"); + printf("Number of created groups is out of bounds\n"); TEST_ERROR; } - if ((gcpl = H5Gget_create_plist(g)) < 0) { - printf("H5Gget_create_plist failed\n"); + if (H5Ldelete(obj_id, name, H5P_DEFAULT) < 0) { + printf("H5Ldelete failed\n"); TEST_ERROR; } - if (H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) { - printf("H5Pget_link_phase_change failed\n"); - TEST_ERROR; - } + if (link_storage > 0) { - if (dense_to_compact) { - if (max_compact != 2) { - printf("For storage check from dense to compact:\n"); - printf(" The max_compact should be 2.\n"); - printf(" But the actual value is %d.\n", max_compact); - TEST_ERROR; - } - else if (min_dense != 2) { - printf("For storage check from dense to compact:\n"); - printf(" The min_dense should be 2.\n"); - printf(" But the actual value is %d.\n", min_dense); - TEST_ERROR; - } - } - else { - if (max_compact != 1) { - printf("For storage check from dense to compact:\n"); - printf(" The max_compact should be 1.\n"); - printf(" But the actual value is %d.\n", max_compact); + if (s->old_style_grp) { + printf("Old style group doesn't support the indexed storage.\n"); TEST_ERROR; } - else if (min_dense != 1) { - printf("For storage check from dense to compact:\n"); - printf(" The min_dense should be 1.\n"); - printf(" But the actual value is %d.\n", min_dense); + + if (H5Gget_info(obj_id, &group_info) < 0) { + printf("H5Gget_info failed\n"); TEST_ERROR; } - } - if (H5Pclose(gcpl) < 0) { - printf("H5Pclose failed\n"); - TEST_ERROR; - } + if (link_storage == 1) { - if (H5Gget_info(g, &group_info) < 0) { - printf("H5Gget_info failed\n"); - TEST_ERROR; - } + if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + printf("The group link storage should be compact. \n"); + TEST_ERROR; + } + } + else { - /* When the group is created, the storage type is always compact. */ - if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { - printf("Old-styled group test: but the group is not in old-style. \n"); - TEST_ERROR; + if (group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { + printf("The group link storage should be dense. \n"); + TEST_ERROR; + } + } } - dbgf(2, "Storage info is %d\n", group_info.storage_type); - - return g; + return true; error: - - H5E_BEGIN_TRY - { - H5Gclose(g); - H5Pclose(gcpl); - } - H5E_END_TRY; - - return -1; + return false; } /*------------------------------------------------------------------------- - * Function: vrfy_close_group_id + * Function: delete_group * - * Purpose: Verify if a group is closed successfully. + * Purpose: Delete a group and carry out group operations(add,delete etc.) + * according to the group operation test pattern. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe * and some VFD SWMR configuration parameters * - * hid_t g - * The ID of the group to be closed. + * unsigned int which + * The number of iterations for group creation + * This is used to generate the group name + * * * Return: Success: true * Failure: false * - * Note: This is used by the link storage transit functions. + * Note: This is called by the group_operations() function. *------------------------------------------------------------------------- */ static bool -vrfy_close_group_id(state_t *s, hid_t g) +delete_group(state_t *s, unsigned int which) { - if (H5Gclose(g) < 0) { - printf("H5Gclose failed\n"); - TEST_ERROR; + char name[sizeof("/group-9999999999")]; + bool ret_value = create_group(s, which); + if (ret_value == true) { + esnprintf(name, sizeof(name), "/group-%u", which); + ret_value = delete_one_link(s, s->file, name, 0, which); } - return true; - -error: - - return false; + return ret_value; } /*------------------------------------------------------------------------- - * Function: vrfy_one_link_exist + * Function: move_one_group * - * Purpose: Verify if a link exists or not. The link storage is - * also checked. + * Purpose: A helper function used by the move_group operation. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe * and some VFD SWMR configuration parameters * * hid_t obj_id - * The ID of the object the link is attached to + * ID of the object this group is attached to + * + * const char *name + * The original group name + * + * const char *newname + * The new group name * - * bool expect_exist - * A flag that indicates if this link is expected to exist + * unsigned int which + * The number of iterations for group creation * - * short link_storage - * <=0: link storage check is ignored. - * 1: link storage is expected to be compact. - * >1: link storage is expected to be dense. * * Return: Success: true * Failure: false * - * Note: Helper function to check if links are inserted or deleted. - * The link storage is also checked. + * Note: This is called by the move_group() function. *------------------------------------------------------------------------- */ static bool -vrfy_one_link_exist(state_t *s, hid_t obj_id, const char *name, bool expect_exist, short link_storage) +move_one_group(state_t *s, hid_t obj_id, const char *name, const char *newname, unsigned int which) { - int link_exists = 0; - H5G_info_t group_info; - - link_exists = H5Lexists(obj_id, name, H5P_DEFAULT); - - if (link_exists < 0) { - printf("H5Lexists error\n"); - TEST_ERROR; - } - else if (link_exists == 1) { - if (expect_exist == false) { - printf("This link should be moved or deleted but it still exists.\n"); - TEST_ERROR; - } - } - else if (link_exists == 0) { - if (expect_exist == true) { - printf("This link should exist but it is moved or deleted.\n"); - TEST_ERROR; - } - } - - if (link_storage > 0) { - - if (s->old_style_grp) { - printf("Old style group doesn't support the indexed storage.\n"); - TEST_ERROR; - } - - if (H5Gget_info(obj_id, &group_info) < 0) { - printf("H5Gget_info failed\n"); - TEST_ERROR; - } - - if (link_storage == 1) { - if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { - printf("The group link storage should be compact. \n"); - TEST_ERROR; - } - } - else { - if (group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { - printf("The group link storage should be dense. \n"); - TEST_ERROR; - } - } + if (which >= s->nsteps) { + printf("Number of created groups is out of bounds\n"); + TEST_ERROR; + } + + if (H5Lmove(obj_id, name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { + printf("H5Ldelete failed\n"); + TEST_ERROR; } return true; error: - return false; } /*------------------------------------------------------------------------- - * Function: vrfy_delete_group + * Function: move_group * - * Purpose: Verify if a group can be deleted successfully. + * Purpose: Move a group to another group. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe @@ -3883,245 +2058,226 @@ error: * Return: Success: true * Failure: false * - * Note: This is called by the verify_group_operations() function. + * Note: This is called by the group_operations() function. *------------------------------------------------------------------------- */ static bool -vrfy_delete_group(state_t *s, unsigned int which) +move_group(state_t *s, unsigned int which) { - bool ret_value = false; char name[sizeof("/group-9999999999")]; - - ret_value = vrfy_create_group(s, which); + char new_name[sizeof("/new-group-9999999999")]; + bool ret_value = create_group(s, which); if (ret_value == true) { esnprintf(name, sizeof(name), "/group-%u", which); - ret_value = vrfy_one_link_exist(s, s->file, name, false, 0); + esnprintf(new_name, sizeof(new_name), "/new-group-%u", which); + ret_value = move_one_group(s, s->file, name, new_name, which); } return ret_value; } /*------------------------------------------------------------------------- - * Function: vrfy_move_one_group + * Function: insert_one_link * - * Purpose: A helper function to verify the move_group operation successfully. + * Purpose: A helper function used to attach a link to a group. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe * and some VFD SWMR configuration parameters * * hid_t obj_id - * ID of the object this group is attached to + * ID of the object this link is attached to * * const char *name - * The original group name + * The name of the target object used by creating links * * const char *newname - * The new group name + * The name of the linked objects + * + * bool is_hard + * true if inserting a hard link + * false if inserting a soft link * + * short link_storage + * <=0: link storage is ignored. + * 1: link storage should be compact. + * >1: link storage should be dense. + * unsigned int which * The number of iterations for group creation * * Return: Success: true * Failure: false * - * Note: This is called by the verify_move_group() function. + * Note: This is called by the insert_links and link storage transit functions. + * For link storage, we test at both the writer and the reader. *------------------------------------------------------------------------- - */ +*/ static bool -vrfy_move_one_group(state_t *s, hid_t obj_id, const char *name, const char *newname, unsigned int which) +insert_one_link(state_t *s, hid_t obj_id, const char *name, const char *newname, bool is_hard, + short link_storage, unsigned int which) { - hid_t g = H5I_INVALID_HID; H5G_info_t group_info; - int link_exists = 0; if (which >= s->nsteps) { printf("Number of created groups is out of bounds\n"); TEST_ERROR; } - link_exists = H5Lexists(obj_id, name, H5P_DEFAULT); - if (link_exists < 0) { - printf("H5Lexists error\n"); - TEST_ERROR; - } - else if (link_exists == 1) { - printf("This link should be moved but it still exists.\n"); - TEST_ERROR; + /* For storage transit and insert_links cases, we + * create links in different style, just add a little + * variation of the tests.*/ + if (is_hard) { + if (link_storage > 0) { + if (H5Lcreate_hard(s->file, name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { + printf("H5Lcreate_hard failed\n"); + TEST_ERROR; + } + } + else { + if (H5Lcreate_hard(obj_id, name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { + printf("H5Lcreate_hard failed\n"); + TEST_ERROR; + } + } } - - if ((g = H5Gopen(obj_id, newname, H5P_DEFAULT)) < 0) { - printf("H5Gopen failed\n"); - TEST_ERROR; + else { + if (link_storage > 0) { + if (H5Lcreate_soft("/", obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { + printf("H5Lcreate_soft failed\n"); + TEST_ERROR; + } + } + else { + if (H5Lcreate_soft(name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { + printf("H5Lcreate_soft failed.\n"); + TEST_ERROR; + } + } } - if (H5Gget_info(g, &group_info) < 0) { - printf("H5Gget_info failed\n"); - TEST_ERROR; - } + if (link_storage > 0) { - dbgf(2, "Storage info is %d\n", group_info.storage_type); - if (s->old_style_grp) { - if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { - printf("Reader - Old-styled group: but the group is not in old-style. \n"); + if (s->old_style_grp) { + printf("Old style group doesn't support dense or compact storage.\n"); TEST_ERROR; } - dbgf(2, "Reader: verify that the group is created with the old-style.\n"); - } - else { - if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { - printf("Reader - The created group should NOT be in old-style . \n"); + + if (H5Gget_info(obj_id, &group_info) < 0) { + printf("H5Gget_info failed\n"); TEST_ERROR; } - dbgf(2, "Reader: verify that the group is created with the new-style.\n"); - } - if (H5Gclose(g) < 0) { - printf("H5Gclose failed\n"); - TEST_ERROR; + if (link_storage == 1) { + if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + printf("The group link storage should be compact. \n"); + TEST_ERROR; + } + } + else { + if (group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { + printf("The group link storage should be dense. \n"); + TEST_ERROR; + } + } } return true; error: - - H5E_BEGIN_TRY - { - H5Gclose(g); - } - H5E_END_TRY; - return false; } /*------------------------------------------------------------------------- - * Function: vrfy_move_group + * Function: insert_links * - * Purpose: Verify if a group can be moved successfully. + * Purpose: create links with a group. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations * used to generate the group name. * * Return: Success: true * Failure: false * - * Note: This is called by the verify_group_operations() function. + * Note: This is called by the group_operations() function. *------------------------------------------------------------------------- */ static bool -vrfy_move_group(state_t *s, unsigned int which) +insert_links(state_t *s, unsigned int which) { char name[sizeof("/group-9999999999")]; - char new_name[sizeof("/new-group-9999999999")]; - bool ret_value = vrfy_create_group(s, which); - if (ret_value == true) { - esnprintf(name, sizeof(name), "/group-%u", which); - esnprintf(new_name, sizeof(new_name), "/new-group-%u", which); - ret_value = vrfy_move_one_group(s, s->file, name, new_name, which); - } - - return ret_value; -} - -/*------------------------------------------------------------------------- - * Function: vrfy_insert_links - * - * Purpose: Verify if the links are inserted successfully. - * - * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters - * - * unsigned int which - * The number of iterations for group creation - * used to generate the group name. - * - * Return: Success: true - * Failure: false - * - * Note: This is called by the verify_group_operations() function. - *------------------------------------------------------------------------- - */ - -static bool -vrfy_insert_links(state_t *s, unsigned int which) -{ - - bool ret_value = false; char hd_name[sizeof("/hd-group-9999999999")]; char st_name[sizeof("/st-group-9999999999")]; - ret_value = vrfy_create_group(s, which); - + bool ret_value = create_group(s, which); if (ret_value == true) { + esnprintf(name, sizeof(name), "/group-%u", which); esnprintf(hd_name, sizeof(hd_name), "/hd-group-%u", which); esnprintf(st_name, sizeof(st_name), "/st-group-%u", which); - ret_value = vrfy_one_link_exist(s, s->file, hd_name, true, 0); + ret_value = insert_one_link(s, s->file, name, hd_name, true, 0, which); if (ret_value == true) - ret_value = vrfy_one_link_exist(s, s->file, st_name, true, 0); + ret_value = insert_one_link(s, s->file, name, st_name, false, 0, which); } return ret_value; } /*------------------------------------------------------------------------- - * Function: vrfy_delete_links + * Function: delete_links * - * Purpose: Verify if the links created with a group are deleted successfully. + * Purpose: create links with a group and then delete them successfully. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations * used to generate the group name. * * Return: Success: true * Failure: false * - * Note: This is called by the verify_group_operations() function. + * Note: This is called by the group_operations() function. *------------------------------------------------------------------------- */ static bool -vrfy_delete_links(state_t *s, unsigned int which) +delete_links(state_t *s, unsigned int which) { - bool ret_value = false; + char name[sizeof("/group-9999999999")]; char hd_name[sizeof("/hd-group-9999999999")]; char st_name[sizeof("/st-group-9999999999")]; - /* First verify if the links are inserted correctly */ - ret_value = vrfy_insert_links(s, which); - - /* Then if these links are deleted correctly. */ + bool ret_value = insert_links(s, which); if (ret_value == true) { + esnprintf(name, sizeof(name), "/group-%u", which); esnprintf(hd_name, sizeof(hd_name), "/hd-group-%u", which); esnprintf(st_name, sizeof(st_name), "/st-group-%u", which); - ret_value = vrfy_one_link_exist(s, s->file, hd_name, false, 0); + ret_value = delete_one_link(s, s->file, hd_name, 0, which); if (ret_value == true) - ret_value = vrfy_one_link_exist(s, s->file, st_name, false, 0); + ret_value = delete_one_link(s, s->file, st_name, 0, which); } return ret_value; } /*------------------------------------------------------------------------- - * Function: vrfy_transit_storage_compact_to_dense + * Function: transit_storage_compact_to_dense * - * Purpose: Verify if the link storage successfully transits from + * Purpose: Add links so that the link storage transits from * compact to dense. * * Parameters: state_t *s @@ -4129,46 +2285,49 @@ vrfy_delete_links(state_t *s, unsigned int which) * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation - * used to generate the group name. + * The number of iterations used to generate the group name. * * Return: Success: true * Failure: false * - * Note: This is called by the verify_group_operations() function. + * Note: This is called by the group_operations() function. *------------------------------------------------------------------------- */ static bool -vrfy_transit_storage_compact_to_dense(state_t *s, unsigned int which) +transit_storage_compact_to_dense(state_t *s, unsigned int which) { - hid_t g = H5I_INVALID_HID; - char hd_name[sizeof("hd-group-9999999999")]; - char st_name[sizeof("st-group-9999999999")]; + char name[sizeof("/group-9999999999")]; + char hd_name[sizeof("/hd-group-9999999999")]; + char st_name[sizeof("/st-group-9999999999")]; - g = vrfy_create_group_id(s, which, false); + hid_t g = create_group_id(s, which, false); if (g < 0) { - printf("verify create_group_id failed\n"); + printf("create_group_id failed\n"); TEST_ERROR; } + /* First insert a hard link, compact storage. */ + esnprintf(name, sizeof(name), "/group-%u", which); esnprintf(hd_name, sizeof(hd_name), "hd-group-%u", which); - if (vrfy_one_link_exist(s, g, hd_name, true, 1) == false) { - printf("verify the compact storage failed for 'link compact to dense' test\n"); + if (insert_one_link(s, g, name, hd_name, true, 1, which) == false) { + printf("insert_one_link for compact storage failed\n"); TEST_ERROR; } + /* Then insert a soft link, the storage becomes dense. */ esnprintf(st_name, sizeof(st_name), "st-group-%u", which); - if (vrfy_one_link_exist(s, g, st_name, true, 2) == false) { - printf("verify the dense link storage failed for 'link compact to dense' test\n"); + if (insert_one_link(s, g, name, st_name, false, 2, which) == false) { + printf("insert_one_link for dense storage failed\n"); TEST_ERROR; } - if (vrfy_close_group_id(s, g) == false) { - printf("verify the group close for 'link compact to dense' test\n"); + if (close_group_id(g) == false) { + printf("insert_one_link for dense storage failed\n"); TEST_ERROR; } + return true; error: @@ -4177,13 +2336,14 @@ error: H5Gclose(g); } H5E_END_TRY; + return false; } /*------------------------------------------------------------------------- - * Function: vrfy_transit_storage_dense_to_compact + * Function: transit_storage_dense_to_compact * - * Purpose: Verify if the link storage successfully transits from + * Purpose: Add or delete links so that the link storage transits from * compact to dense then to compact. * * Parameters: state_t *s @@ -4191,68 +2351,69 @@ error: * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation - * used to generate the group name. + * The number of iterations used to generate the group name. * * Return: Success: true * Failure: false * - * Note: This is called by the verify_group_operations() function. + * Note: This is called by the group_operations() function. *------------------------------------------------------------------------- */ static bool -vrfy_transit_storage_dense_to_compact(state_t *s, unsigned int which) +transit_storage_dense_to_compact(state_t *s, unsigned int which) { - hid_t g = H5I_INVALID_HID; - char hd_name[sizeof("hd-group-9999999999")]; - char st_name[sizeof("st-group-9999999999")]; - char st2_name[sizeof("st2-group-9999999999")]; + char name[sizeof("/group-9999999999")]; + char hd_name[sizeof("/hd-group-9999999999")]; + char st_name[sizeof("st-group-9999999999")]; + char st2_name[sizeof("st2-group-9999999999")]; - g = vrfy_create_group_id(s, which, true); + hid_t g = create_group_id(s, which, true); if (g < 0) { - printf("verify create_group_id failed\n"); + printf("create_group_id failed\n"); TEST_ERROR; } - /* Add a link, verify it is still the compact storage */ + /* Insert a link, storage is compact. */ + esnprintf(name, sizeof(name), "/group-%u", which); esnprintf(hd_name, sizeof(hd_name), "hd-group-%u", which); - if (vrfy_one_link_exist(s, g, hd_name, true, 1) == false) { - printf("verify the compact storage failed for 'link compact to dense' test\n"); + if (insert_one_link(s, g, name, hd_name, true, 1, which) == false) { + printf("insert_one_link for compact storage failed\n"); TEST_ERROR; } - /* Add another link, verify it is still the compact storage */ + /* Insert a link, storage is still compact. */ esnprintf(st_name, sizeof(st_name), "st-group-%u", which); - if (vrfy_one_link_exist(s, g, st_name, true, 1) == false) { - printf("verify the compact link storage failed for 'link compact to dense' test\n"); + if (insert_one_link(s, g, name, st_name, false, 1, which) == false) { + printf("insert_one_link for compact storage failed\n"); TEST_ERROR; } - /* Add the third link, verify it becomes the dense storage */ + /* Insert a link, storage becomes dense. */ esnprintf(st2_name, sizeof(st2_name), "st2-group-%u", which); - if (vrfy_one_link_exist(s, g, st2_name, true, 2) == false) { - printf("verify the dense link storage failed for 'link compact to dense' test\n"); + if (insert_one_link(s, g, name, st2_name, false, 2, which) == false) { + printf("insert_one_link for dense storage failed\n"); TEST_ERROR; } - /* Remove a link, verify the link doesn't exist and still dense storage */ - if (vrfy_one_link_exist(s, g, st_name, false, 2) == false) { - printf("verify the dense link storage failed for 'link compact to dense' test\n"); + /* Delete a link, storage is still dense */ + if (delete_one_link(s, g, st_name, 2, which) == false) { + printf("delete_one_link for dense storage failed\n"); TEST_ERROR; } - /* Remove a link, verify the link doesn't exist and it becomes compact storage */ - if (vrfy_one_link_exist(s, g, st2_name, false, 1) == false) { - printf("verify the compact link storage failed for 'link compact to dense' test\n"); + /* Delete another link, storage becomes compact */ + if (delete_one_link(s, g, st2_name, 1, which) == false) { + printf("delete_one_link for compact storage failed\n"); TEST_ERROR; } - if (vrfy_close_group_id(s, g) == false) { - printf("verify the group close for 'link compact to dense' test\n"); + if (close_group_id(g) == false) { + printf("insert_one_link for dense storage failed\n"); TEST_ERROR; } + return true; error: @@ -4261,15 +2422,15 @@ error: H5Gclose(g); } H5E_END_TRY; + return false; } /*------------------------------------------------------------------------- - * Function: verify_group_operations + * Function: group_operations * - * Purpose: verify the success of group creation and - * carry out the test for attribute operations(add,delete etc.) - * according to the attribute test pattern. + * Purpose: Carry out group and attribute operations(add,delete etc.) + * according to the group operation and attribute test patterns. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe @@ -4282,41 +2443,42 @@ error: * Return: Success: true * Failure: false * - * Note: This is called by the main() function. + * Note: This is called by the main() function. The check of attribute + * operations is inside the write_group() function. *------------------------------------------------------------------------- */ - static bool -verify_group_operations(state_t *s, unsigned int which) +group_operations(state_t *s, unsigned int which) { + bool ret_value = false; char test_pattern = s->grp_op_pattern; switch (test_pattern) { case 'c': - ret_value = vrfy_create_group(s, which); + ret_value = create_group(s, which); break; case 'd': - ret_value = vrfy_delete_group(s, which); + ret_value = delete_group(s, which); break; case 'm': - ret_value = vrfy_move_group(s, which); + ret_value = move_group(s, which); break; case 'i': - ret_value = vrfy_insert_links(s, which); + ret_value = insert_links(s, which); break; case 'D': - ret_value = vrfy_delete_links(s, which); + ret_value = delete_links(s, which); break; case 't': - ret_value = vrfy_transit_storage_compact_to_dense(s, which); + ret_value = transit_storage_compact_to_dense(s, which); break; case 'T': - ret_value = vrfy_transit_storage_dense_to_compact(s, which); + ret_value = transit_storage_dense_to_compact(s, which); break; case ' ': default: - ret_value = verify_group(s, which); + ret_value = write_group(s, which); break; } return ret_value; @@ -4452,7 +2614,6 @@ main(int argc, char **argv) const char * personality; H5F_vfd_swmr_config_t config; bool wg_ret = false; - bool vg_ret = false; struct timespec start_time, end_time; unsigned int num_elems_per_level; @@ -4472,8 +2633,12 @@ main(int argc, char **argv) TEST_ERROR; } + if(writer == false) { + printf("Reader is skipped for the performance tests.\n"); + return EXIT_SUCCESS; + } + /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - // init_vfd_swmr_config(&config, 4, 7, writer, FALSE, 128, "./group-shadow"); init_vfd_swmr_config(&config, s.tick_len, s.max_lag, writer, FALSE, 128, "./group-shadow"); /* If old-style option is chosen, use the earliest file format(H5F_LIBVER_EARLIEST) @@ -4559,7 +2724,6 @@ main(int argc, char **argv) if (s.nglevels > 0) { num_elems_per_level = obtain_tree_level_elems(s.nsteps, s.nglevels); - // wg_ret = gen_tree_struct(&s,s.nsteps,s.nglevels,num_elems_per_level,s.file); /* for the recursive call, the groups under the root is treated as one level */ wg_ret = gen_tree_struct(&s, s.nglevels + 1, num_elems_per_level, s.file); if (wg_ret == false) { @@ -4593,30 +2757,9 @@ main(int argc, char **argv) fprintf(stdout, "group creation +5 attrs mean time = %lf\n", s.mean_time); } } - else { - - if (s.nglevels > 0) { - printf("Reader: The nested group creation test is not implemented. Stop!\n"); - TEST_ERROR; - } - if (s.num_attrs > 1) { - printf("Reader: number of attribute must be 1 for the default group test. Stop!\n"); - printf("The current number of attributes per group is %u\n", s.num_attrs); - TEST_ERROR; - } - - for (step = 0; step < s.nsteps; step++) { - dbgf(1, "reader: step %d\n", step); - - vg_ret = verify_group_operations(&s, step); - - if (vg_ret == false) { - - printf("verify_group_operations failed\n"); - TEST_ERROR; - } - } - } + else + printf("Reader is skipped for the performance tests.\n"); + if (H5Pclose(fapl) < 0) { printf("H5Pclose failed\n"); -- cgit v0.12 From ee86255610d4db64921ab18cc21fc16c94859067 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 18 Aug 2021 21:09:46 +0000 Subject: Committing clang-format changes --- test/vfd_swmr_gperf_writer.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index 15f9522..a64af45 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -99,7 +99,7 @@ usage(const char *progname) "-b: write data in big-endian byte order\n" "-n ngroups: the number of groups\n" "-N num_attrs: the number of attributes \n" - "-V vlstr attrs: Use variable length string attribute in the performance test. \n" + "-V vlstr attrs: Use variable length string attribute in the performance test. \n" "-l ng_levels: the number of level of nested groups. \n" " If all the groups are under the root group, \n" " this number should be 0.\n" @@ -598,8 +598,6 @@ error: return false; } - - /*------------------------------------------------------------------------- * Function: add_vlstr_attrs * @@ -630,18 +628,16 @@ static bool add_vlstr_attrs(state_t *s, hid_t g, unsigned int which, unsigned int num_attrs) { unsigned u; - bool ret_value = true; + bool ret_value = true; for (u = 0; u < num_attrs; u++) { - ret_value = add_vlstr_attr(s, g, u+which); - if(ret_value == false) + ret_value = add_vlstr_attr(s, g, u + which); + if (ret_value == false) break; } return ret_value; } - - /*------------------------------------------------------------------------- * Function: add_default_group_attr * @@ -680,13 +676,12 @@ add_default_group_attr(state_t *s, hid_t g, unsigned int which) * the default number of attribute is 1. */ /* If the vl string attribute type is chosen. */ - if(s->vlstr_test == true) + if (s->vlstr_test == true) return add_vlstr_attrs(s, g, which, s->num_attrs); - else + else return add_attr(s, g, which, s->num_attrs, aname_format, which); } - /*------------------------------------------------------------------------- * Function: del_one_attr * @@ -887,7 +882,7 @@ error: * * Purpose: Modify the value of an VL string attribute in a group. * - * Parameters: + * Parameters: * hid_t g * HDF5 object ID (in this file: means group ID) * @@ -2633,7 +2628,7 @@ main(int argc, char **argv) TEST_ERROR; } - if(writer == false) { + if (writer == false) { printf("Reader is skipped for the performance tests.\n"); return EXIT_SUCCESS; } @@ -2757,9 +2752,8 @@ main(int argc, char **argv) fprintf(stdout, "group creation +5 attrs mean time = %lf\n", s.mean_time); } } - else + else printf("Reader is skipped for the performance tests.\n"); - if (H5Pclose(fapl) < 0) { printf("H5Pclose failed\n"); -- cgit v0.12 From 49c9cea3a89232d4cc94bc72de4f54b4d2998cd7 Mon Sep 17 00:00:00 2001 From: Muqun Yang Date: Thu, 19 Aug 2021 15:45:55 -0500 Subject: Add statistics information, comments. Also clean up code a bit. --- test/vfd_swmr_gperf_writer.c | 334 ++++++++++++++++++++++++++++++------------- 1 file changed, 238 insertions(+), 96 deletions(-) diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index 15f9522..61b9217 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -54,10 +54,12 @@ typedef struct { uint32_t max_lag; uint32_t tick_len; bool gperf; - double min_time; - double max_time; - double mean_time; + double min_gc_time; + double max_gc_time; + double mean_gc_time; + double total_gc_time; double total_time; + double mean_time; double fo_total_time; double fc_total_time; unsigned int num_attrs; @@ -71,38 +73,41 @@ typedef struct { (state_t) \ { \ .file = H5I_INVALID_HID, .one_by_one_sid = H5I_INVALID_HID, .filename = "", \ - .filetype = H5T_NATIVE_UINT32, .asteps = 10, .nsteps = 100, .use_vfd_swmr = true, \ + .filetype = H5T_NATIVE_UINT32, .asteps = 1, .nsteps = 100, .use_vfd_swmr = true, \ .old_style_grp = false, .grp_op_pattern = ' ', .grp_op_test = false, .at_pattern = ' ', \ - .attr_test = false, .tick_len = 4, .max_lag = 7, .gperf = false, .min_time = 100., .max_time = 0., \ - .mean_time = 0., .total_time = 0., .fo_total_time = 0., .fc_total_time = 0., .num_attrs = 1, \ - .vlstr_test = false, .ps = 4096, .pbs = 4096, .nglevels = 0 \ + .attr_test = false, .tick_len = 4, .max_lag = 7, .gperf = false, .min_gc_time = 100., \ + .max_gc_time = 0., .mean_gc_time = 0., .total_gc_time = 0., .total_time = 0., .mean_time = 0., \ + .fo_total_time = 0., .fc_total_time = 0., .num_attrs = 1, .vlstr_test = false, \ + .ps = 4096, .pbs = 4096, .nglevels =0 \ } static void usage(const char *progname) { fprintf(stderr, - "usage: %s [-P] [-S] [-G] [-a steps] [-t tick_len] [-m max_lag][-B pbs] [-s ps]\n" - " [-b] [-n ngroups]\n" - " [-N num_attrs] [-l ng_levels] [-q] [-A at_pattern] [-O grp_op_pattern]\n" + "usage: ./%s -P -n 1000 -N 5 -q (create 1000 groups, each group has 5 attributes)\n" + "Options: \n" + " [-P] [-S] [-G] [-t tick_len] [-m max_lag][-B pbs] [-s ps]\n" + " [-n ngroups] [-l ng_levels] [-O grp_op_pattern]\n" + " [-N num_attrs] [-V] [-b] [-A at_pattern] [-a steps] [-q]\n" "\n" "-P: carry out the performance test\n" "-S: do not use VFD SWMR\n" "-G: old-style type of group\n" - "-a steps: `steps` between adding attributes\n" "-t tick_len: length of a tick in tenths of a second.\n" "-m max_lag: maximum expected lag(in ticks) between writer and readers\n" - "-B pbs: Page Buffer Size in bytes:\n" + "-B pbs: page Buffer Size in bytes:\n" " The default value is 4K(4096).\n" - "-s ps: Page size used by page aggregation, page buffer and \n" + "-s ps: page size used by page aggregation, page buffer and \n" " the metadata file. \n" - "-b: write data in big-endian byte order\n" "-n ngroups: the number of groups\n" - "-N num_attrs: the number of attributes \n" - "-V vlstr attrs: Use variable length string attribute in the performance test. \n" "-l ng_levels: the number of level of nested groups. \n" " If all the groups are under the root group, \n" " this number should be 0.\n" + "-N num_attrs: the number of attributes \n" + "-V use variable length string attributes for performance test\n" + "-b: write data in big-endian byte order\n" + " (For the performance test, -V overwrites -b)\n" "-A at_pattern: `at_pattern' for different attribute tests\n" " The value of `at_pattern` is one of the following:\n" " `compact` - Attributes added in compact storage\n" @@ -156,6 +161,8 @@ usage(const char *progname) " dense to compact again. \n" " The links include both hard and\n" " soft links. \n" + "-a steps: `steps` between adding attributes\n" + " (Don't recommend to use this option for performance test.)\n" "-q: silence printouts, few messages\n" "\n", progname); @@ -1592,11 +1599,11 @@ write_group(state_t *s, unsigned int which) } temp_time = TIME_PASSED(start_time, end_time); - if (temp_time < s->min_time) - s->min_time = temp_time; - if (temp_time > s->max_time) - s->max_time = temp_time; - s->total_time += temp_time; + if (temp_time < s->min_gc_time) + s->min_gc_time = temp_time; + if (temp_time > s->max_gc_time) + s->max_gc_time = temp_time; + s->total_gc_time += temp_time; } /* We need to create a dummy dataset for the object header continuation block test. */ @@ -1607,24 +1614,27 @@ write_group(state_t *s, unsigned int which) TEST_ERROR; } } - if (H5Gget_info(g, &group_info) < 0) { - printf("H5Gget_info failed\n"); - TEST_ERROR; - } - - if (s->old_style_grp) { - if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { - printf("Old-styled group test: but the group is not in old-style. \n"); + /* We only need to check the first group */ + if(which == 0) { + if (H5Gget_info(g, &group_info) < 0) { + printf("H5Gget_info failed\n"); TEST_ERROR; } - dbgf(2, "Writer: group is created with the old-style.\n"); - } - else { - if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { - printf("The created group should NOT be in old-style . \n"); - TEST_ERROR; + + if (s->old_style_grp) { + if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { + printf("Old-styled group test: but the group is not in old-style. \n"); + TEST_ERROR; + } + dbgf(2, "Writer: group is created with the old-style.\n"); + } + else { + if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { + printf("The created group should NOT be in old-style . \n"); + TEST_ERROR; + } + dbgf(2, "Writer: group is created with the new-style.\n"); } - dbgf(2, "Writer: group is created with the new-style.\n"); } /* If coming to an "object header continuation block" test, @@ -2485,6 +2495,24 @@ group_operations(state_t *s, unsigned int which) } static unsigned int grp_counter = 0; + +/*------------------------------------------------------------------------- + * Function: UI_Pow + * + * Purpose: Helper function to obtain the power 'n' of + * an unsigned integer 'x' + * Similar to pow(x,y) but for an unsigned integer. + * + * Parameters: unsigned int x + * unsigned int n + * + * Return: Return an unsigned integer of value of pow(x,n) + * Note: If the returned value is > 2^32-1, an overflow + * may occur. For our testing purpose, this may never happen. + * + *------------------------------------------------------------------------- + */ + static unsigned int UI_Pow(unsigned int x, unsigned int n) { @@ -2497,17 +2525,55 @@ UI_Pow(unsigned int x, unsigned int n) return (number); } +/*------------------------------------------------------------------------- + * Function: obtain_tree_level_elems + * + * Purpose: Helper function to obtain the maximum number of elements + * at one level. + * + * Parameters: unsigned int total_ele + * The total number of elements of a tree(excluding the root) + * + * unsigned int level + * The number of nested levels + * (If every element of the tree is under the root, + * the level is 0.) + * + * Return: Return the maximum number of elements at one level + * + * Example: If the total number of elements is 6 and level is 1, + * the maximum number of elements is 2.The tree is + * a perfectly balanced tree. + * Such as: + * 0 + * 1 2 + * 3 4 5 6 + * + * If the total number of elements is 5 and level is 1, + * the maximum number of elements is still 2. The + * tree is not balanced, there is no element on the + * right-most leaf but the level is still 1. + * Such as: + * 0 + * 1 2 + * 3 4 5 + * + *------------------------------------------------------------------------- + */ + static unsigned int obtain_tree_level_elems(unsigned int total_ele, unsigned int level) { assert(level <= total_ele); + /* if every element is under the root, just return the total number of elements. */ if (level == 0) return total_ele; else { unsigned int test_elems_level = 0; unsigned total = 0; unsigned int i = 1; + /* Obtain the maximum number of elements for a level with the brutal force way. */ while (total < total_ele) { test_elems_level++; total = 0; @@ -2515,11 +2581,32 @@ obtain_tree_level_elems(unsigned int total_ele, unsigned int level) total += UI_Pow(test_elems_level, i); } if (total == total_ele) - printf("Perfectly match: Number of elements per level is %u\n", test_elems_level); + dbgf(2, "Perfectly match: Number of elements per level is %u\n", test_elems_level); return test_elems_level; } } +/*------------------------------------------------------------------------- + * Function: gen_tree_struct + * + * Purpose: Generate the nested groups + * + * Parameters: state_t *s + * The struct that stores information of HDF5 file, named pipe + * and some VFD SWMR configuration parameters + * + * unsigned int level + * The number of nested levels +1 + * (Note: If every element of the tree is under the root, + * the level is 1 in this function.) + * unsigned num_elems_per_level + * The maximum number of element in a level + * hid_t group_id + * The ID of the parent group + * + * Return: Success: true + * Failure: false + */ static bool gen_tree_struct(state_t *s, unsigned int level, unsigned ne_per_level, hid_t pgrp_id) { @@ -2529,6 +2616,9 @@ gen_tree_struct(state_t *s, unsigned int level, unsigned ne_per_level, hid_t pgr hid_t grp_id; bool result = true; H5G_info_t group_info; + struct timespec start_time, end_time; + double temp_time; + if (level > 0 && grp_counter < s->nsteps) { @@ -2536,6 +2626,16 @@ gen_tree_struct(state_t *s, unsigned int level, unsigned ne_per_level, hid_t pgr esnprintf(name, sizeof(name), "group-%u", grp_counter); if (grp_counter == s->nsteps) break; + + dbgf(2, "writer in nested group: step %d\n", grp_counter); + if (s->gperf) { + + if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { + fprintf(stderr, "HDclock_gettime failed"); + TEST_ERROR; + } + } + /* For each i a group is created. Use grp_counter to generate the group name. printf("id: %u,level: %u, index: %u\n",id,level,i); @@ -2545,6 +2645,23 @@ gen_tree_struct(state_t *s, unsigned int level, unsigned ne_per_level, hid_t pgr TEST_ERROR; } + if (s->gperf) { + + if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { + + fprintf(stderr, "HDclock_gettime failed"); + + TEST_ERROR; + } + + temp_time = TIME_PASSED(start_time, end_time); + if (temp_time < s->min_gc_time) + s->min_gc_time = temp_time; + if (temp_time > s->max_gc_time) + s->max_gc_time = temp_time; + s->total_gc_time += temp_time; + } + /* Just check the first group information. */ if (grp_counter == 0) { if (H5Gget_info(grp_id, &group_info) < 0) { @@ -2645,24 +2762,12 @@ main(int argc, char **argv) * as the second parameter of H5Pset_libver_bound() that is called by * vfd_swmr_create_fapl. Otherwise, the latest file format(H5F_LIBVER_LATEST) * should be used as the second parameter of H5Pset_libver_bound(). - * Also pass the use_vfd_swmr, only_meta_page, config to vfd_swmr_create_fapl().*/ + * Also pass the use_vfd_swmr, only_meta_page, page buffer size, config to vfd_swmr_create_fapl().*/ if ((fapl = vfd_swmr_create_fapl(!s.old_style_grp, s.use_vfd_swmr, true, s.pbs, &config)) < 0) { printf("vfd_swmr_create_fapl failed\n"); TEST_ERROR; } -#if 0 - if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) { - printf("H5Pcreate failed\n"); - TEST_ERROR; - } - - if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, false, 1) < 0) { - printf("H5Pset_file_space_strategy failed\n"); - TEST_ERROR; - } -#endif - /* Set fs_strategy (file space strategy) and fs_page_size (file space page size) */ if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, s.ps)) < 0) { HDprintf("vfd_swmr_create_fcpl() failed"); @@ -2680,87 +2785,76 @@ main(int argc, char **argv) if (s.gperf) { if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { - fprintf(stderr, "HDclock_gettime failed"); - TEST_ERROR; } } - if (writer) - s.file = H5Fcreate(s.filename, H5F_ACC_TRUNC, fcpl, fapl); - else - s.file = H5Fopen(s.filename, H5F_ACC_RDONLY, fapl); + s.file = H5Fcreate(s.filename, H5F_ACC_TRUNC, fcpl, fapl); if (s.gperf) { if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { - fprintf(stderr, "HDclock_gettime failed"); - TEST_ERROR; } s.fo_total_time = TIME_PASSED(start_time, end_time); - fprintf(stdout, "H5Fopen time = %lf\n", s.fo_total_time); } - if (s.file < 0) { - printf("H5Fcreate/open failed\n"); + printf("H5Fcreate failed\n"); TEST_ERROR; } - if (writer) { - if (s.gperf) { + /* If generating nested groups, calculate the maximum number of + elements per level. */ + if (s.nglevels > 0) + num_elems_per_level = obtain_tree_level_elems(s.nsteps, s.nglevels); - if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { - fprintf(stderr, "HDclock_gettime failed"); + if (s.gperf) { - TEST_ERROR; - } + if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { + fprintf(stderr, "HDclock_gettime failed"); + TEST_ERROR; } + } - if (s.nglevels > 0) { + /* If generating nested groups */ + if (s.nglevels > 0) { - num_elems_per_level = obtain_tree_level_elems(s.nsteps, s.nglevels); - /* for the recursive call, the groups under the root is treated as one level */ - wg_ret = gen_tree_struct(&s, s.nglevels + 1, num_elems_per_level, s.file); - if (wg_ret == false) { - printf("write nested group failed at group counter %u\n", grp_counter); - TEST_ERROR; - } + /* for the recursive call, the groups under the root is treated as one level */ + wg_ret = gen_tree_struct(&s, s.nglevels + 1, num_elems_per_level, s.file); + if (wg_ret == false) { + printf("write nested group failed at group counter %u\n", grp_counter); + TEST_ERROR; } - else { - for (step = 0; step < s.nsteps; step++) { + } + else { + for (step = 0; step < s.nsteps; step++) { - dbgf(2, "writer: step %d\n", step); - wg_ret = group_operations(&s, step); - if (wg_ret == false) { - printf("write_group failed at step %d\n", step); - TEST_ERROR; - } + dbgf(2, "writer: step %d\n", step); + wg_ret = group_operations(&s, step); + if (wg_ret == false) { + printf("write_group failed at step %d\n", step); + TEST_ERROR; } } + } - if (s.gperf) { - - if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { + if (s.gperf) { - fprintf(stderr, "HDclock_gettime failed"); - TEST_ERROR; - } + if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { - s.total_time = TIME_PASSED(start_time, end_time); - s.mean_time = s.total_time / s.nsteps; - fprintf(stdout, "group creation +5 attrs total time = %lf\n", s.total_time); - fprintf(stdout, "group creation +5 attrs mean time = %lf\n", s.mean_time); + fprintf(stderr, "HDclock_gettime failed"); + TEST_ERROR; } + + s.total_time = TIME_PASSED(start_time, end_time); + s.mean_time = s.total_time / s.nsteps; + s.mean_gc_time = s.total_gc_time/s.nsteps; } - else - printf("Reader is skipped for the performance tests.\n"); - if (H5Pclose(fapl) < 0) { printf("H5Pclose failed\n"); TEST_ERROR; @@ -2801,7 +2895,55 @@ main(int argc, char **argv) } s.fc_total_time = TIME_PASSED(start_time, end_time); + } + + /* Performance statistics summary */ + if(s.gperf) { + + if (verbosity !=0) { + + fprintf(stdout, "\nPerformance Test Configuration: "); + if(s.use_vfd_swmr) + fprintf(stdout, " Using VFD SWMR \n"); + else + fprintf(stdout, " Not using VFD SWMR \n"); + + if(s.old_style_grp) + fprintf(stdout, " Groups: Created via the earlist file format(old-style) \n"); + else + fprintf(stdout, " Groups: Created via the latest file format(new-style) \n"); + + fprintf(stdout, "\n"); + + fprintf(stdout, "The length of a tick = %u\n",s.tick_len); + fprintf(stdout, "The maximum expected log(in ticks)= %u\n",s.max_lag); + fprintf(stdout, "The page size(in bytes) = %u\n",s.ps); + fprintf(stdout, "The page buffer size(in bytes) = %u\n",s.pbs); + fprintf(stdout, "\n"); + fprintf(stdout, "Number of groups = %u\n" ,s.nsteps); + fprintf(stdout, "Group Nested levels = %u\n", s.nglevels); + fprintf(stdout, "Number of attributes = %u\n", s.num_attrs); + fprintf(stdout, "Number of element per attribute = 1\n"); + if(s.vlstr_test) + fprintf(stdout, "Attribute datatype is variable length string. \n"); + else if(s.filetype == H5T_STD_U32BE) + fprintf(stdout, "Attribute datatype is big-endian unsigned 32-bit integer.\n"); + else + fprintf(stdout, "Attribute datatype is native unsigned 32-bit integer.\n"); + + fprintf(stdout, "\n"); + fprintf(stdout, "(If the nested level is 0, all the groups are created directly under the root.)\n\n"); + fprintf(stdout, "group creation maximum time =%lf\n", s.max_gc_time); + fprintf(stdout, "group creation minimum time =%lf\n", s.min_gc_time); + } + + fprintf(stdout, "group creation total time = %lf\n", s.total_gc_time); + fprintf(stdout, "group creation mean time(per group) = %lf\n", s.mean_gc_time); + fprintf(stdout, "group creation and attributes generation total time = %lf\n", s.total_time); + fprintf(stdout, "group creation and attributes generation mean time(per group) = %lf\n",s.mean_time); + fprintf(stdout, "H5Fcreate time = %lf\n", s.fo_total_time); fprintf(stdout, "H5Fclose time = %lf\n", s.fc_total_time); + } return EXIT_SUCCESS; -- cgit v0.12 From 55caf37315100c76193c1e49d94cb85d9eecec96 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 19 Aug 2021 20:54:04 +0000 Subject: Committing clang-format changes --- test/vfd_swmr_gperf_writer.c | 114 +++++++++++++++++++++---------------------- 1 file changed, 56 insertions(+), 58 deletions(-) diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index e0a9b43..d0dd4d9 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -73,12 +73,12 @@ typedef struct { (state_t) \ { \ .file = H5I_INVALID_HID, .one_by_one_sid = H5I_INVALID_HID, .filename = "", \ - .filetype = H5T_NATIVE_UINT32, .asteps = 1, .nsteps = 100, .use_vfd_swmr = true, \ + .filetype = H5T_NATIVE_UINT32, .asteps = 1, .nsteps = 100, .use_vfd_swmr = true, \ .old_style_grp = false, .grp_op_pattern = ' ', .grp_op_test = false, .at_pattern = ' ', \ .attr_test = false, .tick_len = 4, .max_lag = 7, .gperf = false, .min_gc_time = 100., \ .max_gc_time = 0., .mean_gc_time = 0., .total_gc_time = 0., .total_time = 0., .mean_time = 0., \ - .fo_total_time = 0., .fc_total_time = 0., .num_attrs = 1, .vlstr_test = false, \ - .ps = 4096, .pbs = 4096, .nglevels =0 \ + .fo_total_time = 0., .fc_total_time = 0., .num_attrs = 1, .vlstr_test = false, .ps = 4096, \ + .pbs = 4096, .nglevels = 0 \ } static void @@ -105,7 +105,7 @@ usage(const char *progname) " If all the groups are under the root group, \n" " this number should be 0.\n" "-N num_attrs: the number of attributes \n" - "-V use variable length string attributes for performance test\n" + "-V use variable length string attributes for performance test\n" "-b: write data in big-endian byte order\n" " (For the performance test, -V overwrites -b)\n" "-A at_pattern: `at_pattern' for different attribute tests\n" @@ -1610,12 +1610,12 @@ write_group(state_t *s, unsigned int which) } } /* We only need to check the first group */ - if(which == 0) { + if (which == 0) { if (H5Gget_info(g, &group_info) < 0) { printf("H5Gget_info failed\n"); TEST_ERROR; } - + if (s->old_style_grp) { if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { printf("Old-styled group test: but the group is not in old-style. \n"); @@ -2494,11 +2494,11 @@ static unsigned int grp_counter = 0; /*------------------------------------------------------------------------- * Function: UI_Pow * - * Purpose: Helper function to obtain the power 'n' of + * Purpose: Helper function to obtain the power 'n' of * an unsigned integer 'x' * Similar to pow(x,y) but for an unsigned integer. * - * Parameters: unsigned int x + * Parameters: unsigned int x * unsigned int n * * Return: Return an unsigned integer of value of pow(x,n) @@ -2523,35 +2523,35 @@ UI_Pow(unsigned int x, unsigned int n) /*------------------------------------------------------------------------- * Function: obtain_tree_level_elems * - * Purpose: Helper function to obtain the maximum number of elements + * Purpose: Helper function to obtain the maximum number of elements * at one level. * - * Parameters: unsigned int total_ele + * Parameters: unsigned int total_ele * The total number of elements of a tree(excluding the root) * * unsigned int level * The number of nested levels - * (If every element of the tree is under the root, + * (If every element of the tree is under the root, * the level is 0.) * * Return: Return the maximum number of elements at one level * * Example: If the total number of elements is 6 and level is 1, * the maximum number of elements is 2.The tree is - * a perfectly balanced tree. - * Such as: + * a perfectly balanced tree. + * Such as: * 0 - * 1 2 + * 1 2 * 3 4 5 6 * * If the total number of elements is 5 and level is 1, - * the maximum number of elements is still 2. The - * tree is not balanced, there is no element on the - * right-most leaf but the level is still 1. - * Such as: + * the maximum number of elements is still 2. The + * tree is not balanced, there is no element on the + * right-most leaf but the level is still 1. + * Such as: * 0 - * 1 2 - * 3 4 5 + * 1 2 + * 3 4 5 * *------------------------------------------------------------------------- */ @@ -2584,7 +2584,7 @@ obtain_tree_level_elems(unsigned int total_ele, unsigned int level) /*------------------------------------------------------------------------- * Function: gen_tree_struct * - * Purpose: Generate the nested groups + * Purpose: Generate the nested groups * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe @@ -2592,7 +2592,7 @@ obtain_tree_level_elems(unsigned int total_ele, unsigned int level) * * unsigned int level * The number of nested levels +1 - * (Note: If every element of the tree is under the root, + * (Note: If every element of the tree is under the root, * the level is 1 in this function.) * unsigned num_elems_per_level * The maximum number of element in a level @@ -2606,15 +2606,14 @@ static bool gen_tree_struct(state_t *s, unsigned int level, unsigned ne_per_level, hid_t pgrp_id) { - char name[sizeof("group-9999999999")]; - unsigned int i; - hid_t grp_id; - bool result = true; - H5G_info_t group_info; + char name[sizeof("group-9999999999")]; + unsigned int i; + hid_t grp_id; + bool result = true; + H5G_info_t group_info; struct timespec start_time, end_time; double temp_time; - if (level > 0 && grp_counter < s->nsteps) { for (i = 0; i < ne_per_level; i++) { @@ -2624,7 +2623,7 @@ gen_tree_struct(state_t *s, unsigned int level, unsigned ne_per_level, hid_t pgr dbgf(2, "writer in nested group: step %d\n", grp_counter); if (s->gperf) { - + if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { fprintf(stderr, "HDclock_gettime failed"); TEST_ERROR; @@ -2641,14 +2640,14 @@ gen_tree_struct(state_t *s, unsigned int level, unsigned ne_per_level, hid_t pgr } if (s->gperf) { - + if (HDclock_gettime(CLOCK_MONOTONIC, &end_time) == -1) { - + fprintf(stderr, "HDclock_gettime failed"); - + TEST_ERROR; } - + temp_time = TIME_PASSED(start_time, end_time); if (temp_time < s->min_gc_time) s->min_gc_time = temp_time; @@ -2801,12 +2800,11 @@ main(int argc, char **argv) TEST_ERROR; } - /* If generating nested groups, calculate the maximum number of + /* If generating nested groups, calculate the maximum number of elements per level. */ - if (s.nglevels > 0) + if (s.nglevels > 0) num_elems_per_level = obtain_tree_level_elems(s.nsteps, s.nglevels); - if (s.gperf) { if (HDclock_gettime(CLOCK_MONOTONIC, &start_time) == -1) { @@ -2845,11 +2843,11 @@ main(int argc, char **argv) TEST_ERROR; } - s.total_time = TIME_PASSED(start_time, end_time); - s.mean_time = s.total_time / s.nsteps; - s.mean_gc_time = s.total_gc_time/s.nsteps; + s.total_time = TIME_PASSED(start_time, end_time); + s.mean_time = s.total_time / s.nsteps; + s.mean_gc_time = s.total_gc_time / s.nsteps; } - + if (H5Pclose(fapl) < 0) { printf("H5Pclose failed\n"); TEST_ERROR; @@ -2893,41 +2891,42 @@ main(int argc, char **argv) } /* Performance statistics summary */ - if(s.gperf) { + if (s.gperf) { - if (verbosity !=0) { + if (verbosity != 0) { fprintf(stdout, "\nPerformance Test Configuration: "); - if(s.use_vfd_swmr) + if (s.use_vfd_swmr) fprintf(stdout, " Using VFD SWMR \n"); - else + else fprintf(stdout, " Not using VFD SWMR \n"); - if(s.old_style_grp) + if (s.old_style_grp) fprintf(stdout, " Groups: Created via the earlist file format(old-style) \n"); else fprintf(stdout, " Groups: Created via the latest file format(new-style) \n"); fprintf(stdout, "\n"); - - fprintf(stdout, "The length of a tick = %u\n",s.tick_len); - fprintf(stdout, "The maximum expected log(in ticks)= %u\n",s.max_lag); - fprintf(stdout, "The page size(in bytes) = %u\n",s.ps); - fprintf(stdout, "The page buffer size(in bytes) = %u\n",s.pbs); + + fprintf(stdout, "The length of a tick = %u\n", s.tick_len); + fprintf(stdout, "The maximum expected log(in ticks)= %u\n", s.max_lag); + fprintf(stdout, "The page size(in bytes) = %u\n", s.ps); + fprintf(stdout, "The page buffer size(in bytes) = %u\n", s.pbs); fprintf(stdout, "\n"); - fprintf(stdout, "Number of groups = %u\n" ,s.nsteps); + fprintf(stdout, "Number of groups = %u\n", s.nsteps); fprintf(stdout, "Group Nested levels = %u\n", s.nglevels); fprintf(stdout, "Number of attributes = %u\n", s.num_attrs); fprintf(stdout, "Number of element per attribute = 1\n"); - if(s.vlstr_test) + if (s.vlstr_test) fprintf(stdout, "Attribute datatype is variable length string. \n"); - else if(s.filetype == H5T_STD_U32BE) + else if (s.filetype == H5T_STD_U32BE) fprintf(stdout, "Attribute datatype is big-endian unsigned 32-bit integer.\n"); - else + else fprintf(stdout, "Attribute datatype is native unsigned 32-bit integer.\n"); - + fprintf(stdout, "\n"); - fprintf(stdout, "(If the nested level is 0, all the groups are created directly under the root.)\n\n"); + fprintf(stdout, + "(If the nested level is 0, all the groups are created directly under the root.)\n\n"); fprintf(stdout, "group creation maximum time =%lf\n", s.max_gc_time); fprintf(stdout, "group creation minimum time =%lf\n", s.min_gc_time); } @@ -2935,10 +2934,9 @@ main(int argc, char **argv) fprintf(stdout, "group creation total time = %lf\n", s.total_gc_time); fprintf(stdout, "group creation mean time(per group) = %lf\n", s.mean_gc_time); fprintf(stdout, "group creation and attributes generation total time = %lf\n", s.total_time); - fprintf(stdout, "group creation and attributes generation mean time(per group) = %lf\n",s.mean_time); + fprintf(stdout, "group creation and attributes generation mean time(per group) = %lf\n", s.mean_time); fprintf(stdout, "H5Fcreate time = %lf\n", s.fo_total_time); fprintf(stdout, "H5Fclose time = %lf\n", s.fc_total_time); - } return EXIT_SUCCESS; -- cgit v0.12 From 404784189cd069f3eaad0884b73c862318a156ff Mon Sep 17 00:00:00 2001 From: Muqun Yang Date: Fri, 20 Aug 2021 13:51:25 -0500 Subject: Add more description. --- test/vfd_swmr_gperf_writer.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index d0dd4d9..bb0a98c 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -14,12 +14,21 @@ * This program checks the performance of group creations for VFD SWMR. * Currently the group creation time, H5Fopen and H5Fclose time are measured. * After compiling the program, - * ./vfd_swmr_gperf_writer -n 1000 -P -N 5 -a 1 -q + * ./vfd_swmr_gperf_writer -n 1000 -P -N 5 -q * will generate 1000 groups, each group has 5 attributes. * ./vfd_swmr_gperf_writer -n 1000 -P -N 0 -q * will generate 1000 empty groups. - * ./vfd_swmr_gperf_writer -n 1000 -P -q - * will generate 1000 groups,for every ten groups, an attribute is generated. + * ./vfd_swmr_gperf_writer -n 1000 -P -l 1 -q + * will generate 1000 groups with 1 level of nested groups,(like /g1/g2) + * each group has one attribute. + * ./vfd_swmr_gperf_writer -n 1000 -P -S -G -V -N 5 -l 1 -m 8 -t 4 -B 16384 -s 8192 + * will generate 1000 groups with 1 level of nested groups,(like /g1/g2) + * each group has 5 attributes and the attribute type is variable length string. + * The groups is created without using VFD SWMR; + * The groups are created with the earliest file format(old-styled) + * The program is run with max_lag = 8, tick_len = 4; + * The page buffer size is 16384 bytes. The page size is 8192 bytes. + * */ #define H5F_FRIEND /*suppress error about including H5Fpkg */ @@ -2617,6 +2626,11 @@ gen_tree_struct(state_t *s, unsigned int level, unsigned ne_per_level, hid_t pgr if (level > 0 && grp_counter < s->nsteps) { for (i = 0; i < ne_per_level; i++) { + + /* For each i a group is created. + Use grp_counter to generate the group name. + printf("id: %u,level: %u, index: %u\n",id,level,i); + */ esnprintf(name, sizeof(name), "group-%u", grp_counter); if (grp_counter == s->nsteps) break; @@ -2630,10 +2644,6 @@ gen_tree_struct(state_t *s, unsigned int level, unsigned ne_per_level, hid_t pgr } } - /* For each i a group is created. - Use grp_counter to generate the group name. - printf("id: %u,level: %u, index: %u\n",id,level,i); - */ if ((grp_id = H5Gcreate2(pgrp_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { printf("H5Gcreate2 failed\n"); TEST_ERROR; @@ -2688,6 +2698,8 @@ gen_tree_struct(state_t *s, unsigned int level, unsigned ne_per_level, hid_t pgr TEST_ERROR; } grp_counter++; + + /* Generate groups in the next level */ result = gen_tree_struct(s, level - 1, ne_per_level, grp_id); if (result == false) { printf("Cannot create nested groups. \n"); @@ -2795,6 +2807,7 @@ main(int argc, char **argv) s.fo_total_time = TIME_PASSED(start_time, end_time); } + if (s.file < 0) { printf("H5Fcreate failed\n"); TEST_ERROR; @@ -2936,7 +2949,7 @@ main(int argc, char **argv) fprintf(stdout, "group creation and attributes generation total time = %lf\n", s.total_time); fprintf(stdout, "group creation and attributes generation mean time(per group) = %lf\n", s.mean_time); fprintf(stdout, "H5Fcreate time = %lf\n", s.fo_total_time); - fprintf(stdout, "H5Fclose time = %lf\n", s.fc_total_time); + fprintf(stdout, "H5Fclose time = %lf\n", s.fc_total_time); } return EXIT_SUCCESS; -- cgit v0.12 From 25c8ea101aabb70e92b46297d401caf7a0d7cc2a Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 20 Aug 2021 18:55:19 +0000 Subject: Committing clang-format changes --- test/vfd_swmr_gperf_writer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index bb0a98c..15b52c1 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -19,11 +19,11 @@ * ./vfd_swmr_gperf_writer -n 1000 -P -N 0 -q * will generate 1000 empty groups. * ./vfd_swmr_gperf_writer -n 1000 -P -l 1 -q - * will generate 1000 groups with 1 level of nested groups,(like /g1/g2) - * each group has one attribute. + * will generate 1000 groups with 1 level of nested groups,(like /g1/g2) + * each group has one attribute. * ./vfd_swmr_gperf_writer -n 1000 -P -S -G -V -N 5 -l 1 -m 8 -t 4 -B 16384 -s 8192 * will generate 1000 groups with 1 level of nested groups,(like /g1/g2) - * each group has 5 attributes and the attribute type is variable length string. + * each group has 5 attributes and the attribute type is variable length string. * The groups is created without using VFD SWMR; * The groups are created with the earliest file format(old-styled) * The program is run with max_lag = 8, tick_len = 4; @@ -2698,7 +2698,7 @@ gen_tree_struct(state_t *s, unsigned int level, unsigned ne_per_level, hid_t pgr TEST_ERROR; } grp_counter++; - + /* Generate groups in the next level */ result = gen_tree_struct(s, level - 1, ne_per_level, grp_id); if (result == false) { -- cgit v0.12 From 8555ac9f1958ab7d20adefd5e378294226055693 Mon Sep 17 00:00:00 2001 From: Muqun Yang Date: Fri, 20 Aug 2021 14:19:55 -0500 Subject: Add vfd_gperf_writer.c to MANIFEST. --- MANIFEST | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST b/MANIFEST index a183dc5..328d35d 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1420,6 +1420,7 @@ ./test/vfd_swmr_common.h ./test/vfd_swmr_generator.c ./test/vfd_swmr_group_writer.c +./test/vfd_swmr_gperf_writer.c ./test/vfd_swmr_reader.c ./test/vfd_swmr_remove_reader.c ./test/vfd_swmr_remove_writer.c -- cgit v0.12 From 6e2a2fed3a68085fca170065a3d191f4f946ba1e Mon Sep 17 00:00:00 2001 From: Muqun Yang Date: Thu, 26 Aug 2021 12:59:04 -0500 Subject: fixed comment issues. --- test/vfd_swmr_gperf_writer.c | 64 ++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index 15b52c1..e21f931 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -416,7 +416,7 @@ error: * Purpose: Add attributes to a group. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t oid @@ -522,7 +522,7 @@ error: * Purpose: Add a variable length string attribute to a group. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t g @@ -620,7 +620,7 @@ error: * Purpose: Add variable length string attributes to a group. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t g @@ -660,7 +660,7 @@ add_vlstr_attrs(state_t *s, hid_t g, unsigned int which, unsigned int num_attrs) * Purpose: Add an attribute to a group. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t g @@ -704,7 +704,7 @@ add_default_group_attr(state_t *s, hid_t g, unsigned int which) * Purpose: delete one attribute in a group. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t obj_id @@ -785,7 +785,7 @@ error: * then delete this attribute in this a group. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t g @@ -825,7 +825,7 @@ add_del_vlstr_attr(state_t *s, hid_t g, unsigned int which) * Purpose: Modify the value of an attribute in a group. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t g @@ -990,10 +990,10 @@ error: * Function: add_modify_vlstr_attr * * Purpose: Add a variable length string attribute - * then modify this attribute in this a group. + * then modify this attribute in the group. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t g @@ -1033,7 +1033,7 @@ add_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which) * attributes that the compact storage can hold * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t g @@ -1095,7 +1095,7 @@ error: * Then, add another atribute, the storage becomes dense. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t g @@ -1231,7 +1231,7 @@ error: * Then, delete one atribute, the storage is still compact. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t g @@ -1277,7 +1277,7 @@ add_del_attrs_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which) * Then, delete one atribute, the storage is still dense. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t g @@ -1333,7 +1333,7 @@ error: * dense to compact again. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t g @@ -1373,7 +1373,7 @@ add_del_attrs_compact_dense_compact(state_t *s, hid_t g, hid_t gcpl, unsigned in * Purpose: Add an attribute then modify the value to a group. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t g @@ -1413,7 +1413,7 @@ add_modify_default_group_attr(state_t *s, hid_t g, unsigned int which) * the object header continuation block * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t g @@ -1451,7 +1451,7 @@ del_ohr_block_attr(state_t *s, hid_t g, unsigned int which) * correponding test function.. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t g @@ -1527,7 +1527,7 @@ add_group_attribute(state_t *s, hid_t g, hid_t gcpl, unsigned int which) * according to the attribute test pattern. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * unsigned int which @@ -1695,7 +1695,7 @@ error: * Purpose: Create a group and return the group ID. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * unsigned int which @@ -1818,7 +1818,7 @@ error: * Purpose: Create a group * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * unsigned int which @@ -1896,7 +1896,7 @@ error: * according to the group test pattern. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t obj_id @@ -1978,7 +1978,7 @@ error: * according to the group operation test pattern. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * unsigned int which @@ -2013,7 +2013,7 @@ delete_group(state_t *s, unsigned int which) * Purpose: A helper function used by the move_group operation. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t obj_id @@ -2062,7 +2062,7 @@ error: * Purpose: Move a group to another group. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * unsigned int which @@ -2098,7 +2098,7 @@ move_group(state_t *s, unsigned int which) * Purpose: A helper function used to attach a link to a group. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * hid_t obj_id @@ -2212,7 +2212,7 @@ error: * Purpose: create links with a group. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * unsigned int which @@ -2253,7 +2253,7 @@ insert_links(state_t *s, unsigned int which) * Purpose: create links with a group and then delete them successfully. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * unsigned int which @@ -2295,7 +2295,7 @@ delete_links(state_t *s, unsigned int which) * compact to dense. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * unsigned int which @@ -2361,7 +2361,7 @@ error: * compact to dense then to compact. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * unsigned int which @@ -2447,7 +2447,7 @@ error: * according to the group operation and attribute test patterns. * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * unsigned int which @@ -2596,7 +2596,7 @@ obtain_tree_level_elems(unsigned int total_ele, unsigned int level) * Purpose: Generate the nested groups * * Parameters: state_t *s - * The struct that stores information of HDF5 file, named pipe + * The struct that stores information of HDF5 file * and some VFD SWMR configuration parameters * * unsigned int level @@ -2922,7 +2922,7 @@ main(int argc, char **argv) fprintf(stdout, "\n"); fprintf(stdout, "The length of a tick = %u\n", s.tick_len); - fprintf(stdout, "The maximum expected log(in ticks)= %u\n", s.max_lag); + fprintf(stdout, "The maximum expected lag(in ticks)= %u\n", s.max_lag); fprintf(stdout, "The page size(in bytes) = %u\n", s.ps); fprintf(stdout, "The page buffer size(in bytes) = %u\n", s.pbs); fprintf(stdout, "\n"); -- cgit v0.12