summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMuqun Yang <myang6@hdfgroup.org>2021-08-18 21:04:38 (GMT)
committerMuqun Yang <myang6@hdfgroup.org>2021-08-18 21:04:38 (GMT)
commit79652fa099615b96350e59ed6150497a7b697015 (patch)
tree433da4c08526d67ceb1f326a55fba9c5c14d676b /test
parent2181a3d602268fd51de48c2502b477944122a265 (diff)
downloadhdf5-79652fa099615b96350e59ed6150497a7b697015.zip
hdf5-79652fa099615b96350e59ed6150497a7b697015.tar.gz
hdf5-79652fa099615b96350e59ed6150497a7b697015.tar.bz2
1. Add the VL string type test.
2. Remove the reader test. 3. Fix trivial bugs and remove some warnings.
Diffstat (limited to 'test')
-rw-r--r--test/vfd_swmr_gperf_writer.c2093
1 files changed, 118 insertions, 1975 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,1113 +1676,6 @@ error:
}
/*-------------------------------------------------------------------------
- * 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;
-
- /* 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;
- }
- }
-
- /* 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.
@@ -2831,11 +1773,7 @@ error:
*
* 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
+ * Parameters: hid_t g
* The ID of the group to be closed.
*
* Return: Success: true
@@ -2846,7 +1784,7 @@ error:
*/
static bool
-close_group_id(state_t *s, hid_t g)
+close_group_id(hid_t g)
{
if (H5Gclose(g) < 0) {
@@ -3385,7 +2323,7 @@ transit_storage_compact_to_dense(state_t *s, unsigned int which)
TEST_ERROR;
}
- if (close_group_id(s, g) == false) {
+ if (close_group_id(g) == false) {
printf("insert_one_link for dense storage failed\n");
TEST_ERROR;
}
@@ -3471,7 +2409,7 @@ transit_storage_dense_to_compact(state_t *s, unsigned int which)
TEST_ERROR;
}
- if (close_group_id(s, g) == false) {
+ if (close_group_id(g) == false) {
printf("insert_one_link for dense storage failed\n");
TEST_ERROR;
}
@@ -3546,782 +2484,6 @@ group_operations(state_t *s, unsigned int which)
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");
- 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;
- }
-
- return true;
-
-error:
-
- H5E_BEGIN_TRY
- {
- H5Gclose(g);
- }
- H5E_END_TRY;
-
- 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;
-
- 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);
-
- return g;
-
-error:
-
- H5E_BEGIN_TRY
- {
- H5Gclose(g);
- H5Pclose(gcpl);
- }
- H5E_END_TRY;
-
- 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)
-{
-
- if (H5Gclose(g) < 0) {
- printf("H5Gclose failed\n");
- TEST_ERROR;
- }
-
- return true;
-
-error:
-
- 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;
-
- 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;
- }
- }
- }
-
- return true;
-
-error:
-
- 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;
-
- 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;
- }
-
- return true;
-
-error:
-
- H5E_BEGIN_TRY
- {
- H5Gclose(g);
- }
- H5E_END_TRY;
-
- 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;
-}
-
static unsigned int grp_counter = 0;
static unsigned int
UI_Pow(unsigned int x, unsigned int n)
@@ -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");