From ebb87d410590caf01e07a6f6e371722e4d09e018 Mon Sep 17 00:00:00 2001 From: Muqun Yang Date: Wed, 28 Apr 2021 14:45:04 -0500 Subject: Add skeleton of group operation test. The group operations include create/delete/move/add links/delete links/link storage. --- test/vfd_swmr_group_writer.c | 288 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 285 insertions(+), 3 deletions(-) diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index 2477c2e..f9146e9 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -37,6 +37,7 @@ typedef struct { bool use_vfd_swmr; bool old_style_grp; bool use_named_pipes; + char grp_op_pattern; char at_pattern; bool attr_test; uint32_t max_lag; @@ -55,6 +56,7 @@ typedef struct { .use_vfd_swmr = true, \ .old_style_grp = false, \ .use_named_pipes = true \ + , .grp_op_pattern = ' ' \ , .at_pattern = ' ' \ , .attr_test = false \ , .tick_len = 4 \ @@ -173,6 +175,27 @@ state_init(state_t *s, int argc, char **argv) case 'N': s->use_named_pipes = false; break; + case 'O': + if (strcmp(optarg, "grp-creation") == 0) + s->grp_op_pattern = 'c'; + else if (strcmp(optarg, "grp-deletion") == 0) + s->grp_op_pattern = 'd'; + else if (strcmp(optarg, "grp-move") == 0) + s->grp_op_pattern = 'm'; + else if (strcmp(optarg, "grp-insertion-links") == 0) + s->grp_op_pattern = 'i'; + else if (strcmp(optarg, "grp-deletion-links") == 0) + s->grp_op_pattern = 'D'; + else if (strcmp(optarg, "grp-compact-t-dense") == 0) + s->grp_op_pattern = 't'; + else if (strcmp(optarg, "grp-dense-t-compact") == 0) + s->grp_op_pattern = 'T'; + else { + H5_FAILED(); AT(); + printf("Invalid -O argument \"%s\"", optarg); + goto error; + } + break; case 'A': if (strcmp(optarg, "compact") == 0) s->at_pattern = 'c'; @@ -2821,6 +2844,265 @@ error2: return false; } +/*------------------------------------------------------------------------- + * Function: create_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 +create_group(state_t *s, unsigned int which) { + + + + return false; +} + +static bool +delete_group(state_t *s, unsigned int which) { + + + + return false; +} + +static bool +move_group(state_t *s, unsigned int which) { + + + + return false; +} + +static bool +insert_link(state_t *s, unsigned int which) { + + + + + return false; +} + +static bool +delete_link(state_t *s, unsigned int which) { + + + + + return false; +} + +static bool +transit_storage_compact_to_dense(state_t *s, unsigned int which) { + + + + + return false; +} + +static bool +transit_storage_dense_to_compact(state_t *s, unsigned int which) { + + + + + return false; +} + +/*------------------------------------------------------------------------- + * Function: group_operations + * + * 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 +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_link(s, which); + break; + case 'D': + ret_value = delete_link(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; + +} + +static bool +vrfy_create_group(state_t *s, unsigned int which){ + + + + return false; +} + +static bool +vrfy_delete_group(state_t *s, unsigned int which){ + + + + return false; +} + +static bool +vrfy_move_group(state_t *s, unsigned int which){ + + + + return false; +} + +static bool +vrfy_insert_link(state_t *s, unsigned int which){ + + + + return false; +} + +static bool +vrfy_delete_link(state_t *s, unsigned int which){ + + + + return false; +} + + +static bool +vrfy_transit_storage_compact_to_dense(state_t *s, unsigned int which){ + + + + return false; +} + +static bool +vrfy_transit_storage_dense_to_compact(state_t *s, unsigned int which){ + + + + 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_link(s, which); + break; + case 'D': + ret_value = vrfy_delete_link(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) @@ -2949,7 +3231,7 @@ main(int argc, char **argv) for (step = 0; step < s.nsteps; step++) { dbgf(2, "writer: step %d\n", step); - wg_ret = write_group(&s, step); + wg_ret = group_operations(&s, step); if(wg_ret == false) { H5_FAILED(); AT(); @@ -2989,11 +3271,11 @@ main(int argc, char **argv) if(s.use_named_pipes && s.attr_test== false) decisleep(config.tick_len * s.update_interval); - vg_ret = verify_group(&s, step); + vg_ret = verify_group_operations(&s, step); if (vg_ret == false) { - printf("verify_group failed\n"); + printf("verify_group_operations failed\n"); H5_FAILED(); AT(); /* At communication interval, tell the writer about the failure and exit */ -- cgit v0.12 From c1553a2156d33ca8f6b3bf04de2814c937efebb0 Mon Sep 17 00:00:00 2001 From: Kent Yang Date: Fri, 30 Apr 2021 12:24:07 -0500 Subject: Add group creation/deletion/move/link insertion --- test/vfd_swmr_group_writer.c | 667 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 635 insertions(+), 32 deletions(-) diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index f9146e9..0776b82 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -38,6 +38,7 @@ typedef struct { 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; @@ -57,6 +58,7 @@ typedef struct { .old_style_grp = false, \ .use_named_pipes = true \ , .grp_op_pattern = ' ' \ + , .grp_op_test = false \ , .at_pattern = ' ' \ , .attr_test = false \ , .tick_len = 4 \ @@ -67,7 +69,6 @@ typedef struct { , .np_verify = 0 } -//TODO: add at_pattern description static void usage(const char *progname) { @@ -132,7 +133,7 @@ state_init(state_t *s, int argc, char **argv) if (tfile) HDfree(tfile); - while ((ch = getopt(argc, argv, "SGa:bc:n:Nqu:A:")) != -1) { + while ((ch = getopt(argc, argv, "SGa:bc:n:Nqu:A:O:")) != -1) { switch (ch) { case 'S': s->use_vfd_swmr = false; @@ -182,9 +183,9 @@ state_init(state_t *s, int argc, char **argv) s->grp_op_pattern = 'd'; else if (strcmp(optarg, "grp-move") == 0) s->grp_op_pattern = 'm'; - else if (strcmp(optarg, "grp-insertion-links") == 0) + else if (strcmp(optarg, "grp-ins-links") == 0) s->grp_op_pattern = 'i'; - else if (strcmp(optarg, "grp-deletion-links") == 0) + else if (strcmp(optarg, "grp-del-links") == 0) s->grp_op_pattern = 'D'; else if (strcmp(optarg, "grp-compact-t-dense") == 0) s->grp_op_pattern = 't'; @@ -235,28 +236,41 @@ state_init(state_t *s, int argc, char **argv) argc -= optind; argv += optind; - /* space for attributes */ - if ((s->one_by_one_sid = H5Screate_simple(1, &dims, &dims)) < 0) { + if(s->grp_op_pattern != ' ') + s->grp_op_test = true; + if(s->at_pattern != ' ') + s->attr_test = true; + + if(!s->grp_op_test && !s->attr_test) { + if (s->asteps < 1 || s->asteps > s->nsteps) { H5_FAILED(); AT(); - printf("H5Screate_simple failed\n"); + printf("attribute interval is out of bounds\n"); goto 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) { + if (s->csteps < 1 || s->csteps > s->nsteps) { H5_FAILED(); AT(); printf("communication interval is out of bounds\n"); goto error; } - if( s->asteps < 1 || s->asteps > s->nsteps) { + if (argc > 0) { H5_FAILED(); AT(); - printf("attribute interval is out of bounds\n"); + printf("unexpected command-line arguments\n"); goto error; } - if (argc > 0) { + + /* space for attributes */ + if ((s->one_by_one_sid = H5Screate_simple(1, &dims, &dims)) < 0) { H5_FAILED(); AT(); - printf("unexpected command-line arguments\n"); + printf("H5Screate_simple failed\n"); goto error; } @@ -2844,6 +2858,8 @@ error2: return false; } + + /*------------------------------------------------------------------------- * Function: create_group * @@ -2868,43 +2884,331 @@ error2: 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) { + H5_FAILED(); AT(); + printf("Number of created groups is out of bounds\n"); + goto error; + } + + esnprintf(name, sizeof(name), "/group-%d", which); + if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) { + H5_FAILED(); AT(); + printf("H5Gcreate2 failed\n"); + goto error; + } + + if(H5Gget_info(g,&group_info) <0) { + H5_FAILED(); AT(); + printf("H5Gget_info failed\n"); + goto error; + } + + if(s->old_style_grp) { + if(group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { + H5_FAILED(); AT(); + printf("Old-styled group test: but the group is not in old-style. \n"); + goto error; + } + dbgf(2,"Writer: group is created with the old-style.\n"); + } + else { + if(group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { + H5_FAILED(); AT(); + printf("The created group should NOT be in old-style . \n"); + goto error; + } + dbgf(2,"Writer: group is created with the new-style.\n"); + + } + + if (H5Gclose(g) < 0) { + H5_FAILED(); AT(); + printf("H5Gclose failed\n"); + goto 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. + * 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->grp_op_test == true) { + dbgf(2, "CG 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 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: create_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 +delete_one_link(state_t *s, + hid_t obj_id, + const char *name, + unsigned int which) { + + if (which >= s->nsteps) { + H5_FAILED(); AT(); + printf("Number of created groups is out of bounds\n"); + goto error; + } + + if(H5Ldelete(obj_id,name,H5P_DEFAULT) <0) { + H5_FAILED(); AT(); + printf("H5Ldelete failed\n"); + goto 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. + * 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->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 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; + +} + + 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-%d", which); + ret_value = delete_one_link(s,s->file,name,which); + } + + return ret_value; + +} + +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) { + H5_FAILED(); AT(); + printf("Number of created groups is out of bounds\n"); + goto error; + } + if(H5Lmove(obj_id,name,obj_id,newname,H5P_DEFAULT,H5P_DEFAULT)<0){ + H5_FAILED(); AT(); + printf("H5Ldelete failed\n"); + goto 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. + * 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->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 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; + } + 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-%d", which); + esnprintf(new_name, sizeof(new_name), "/new-group-%d", which); + ret_value = move_one_group(s,s->file,name,new_name,which); + } + return ret_value; - return false; } + static bool -insert_link(state_t *s, unsigned int which) { +insert_one_link(state_t *s, + hid_t obj_id, + const char *name, + const char *newname, + bool is_hard, + unsigned int which) { + if (which >= s->nsteps) { + H5_FAILED(); AT(); + printf("Number of created groups is out of bounds\n"); + goto error; + } + if (is_hard) { + if(H5Lcreate_hard(obj_id,name,obj_id,newname,H5P_DEFAULT,H5P_DEFAULT)<0){ + printf("H5Lcreate_hard failed\n"); + goto error; + } + } + else { + if(H5Lcreate_soft(name,obj_id,newname,H5P_DEFAULT,H5P_DEFAULT)<0) { + H5_FAILED(); AT(); + printf("H5Lcreate_soft failed.\n"); + goto 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. + * 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->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 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; + } static bool -delete_link(state_t *s, unsigned int which) { +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-%d", which); + esnprintf(hd_name, sizeof(hd_name), "/hd-group-%d", which); + esnprintf(st_name, sizeof(st_name), "/st-group-%d", which); + ret_value = insert_one_link(s,s->file,name,hd_name,true,which); + if(ret_value == true) + ret_value = insert_one_link(s,s->file,name,st_name,false,which); + } + return ret_value; + +} + +static bool +delete_links(state_t *s, unsigned int which) { + + char name[sizeof("/group-9999999999")]; + bool ret_value = create_group(s,which); + if(ret_value == true) { + // TO DO + esnprintf(name, sizeof(name), "/group-%d", which); + ret_value = delete_one_link(s,s->file,name,which); + } + + return ret_value; - return false; } static bool @@ -2963,10 +3267,10 @@ group_operations(state_t *s, unsigned int which) ret_value = move_group(s, which); break; case 'i': - ret_value = insert_link(s, which); + ret_value = insert_links(s, which); break; case 'D': - ret_value = delete_link(s, which); + ret_value = delete_links(s, which); break; case 't': ret_value = transit_storage_compact_to_dense(s, which); @@ -2986,37 +3290,328 @@ group_operations(state_t *s, unsigned int which) 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, "CG 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) { + H5_FAILED(); AT(); + printf("Number of created groups is out of bounds\n"); + goto error; + } + + esnprintf(name, sizeof(name), "/group-%d", which); + + + if((g = H5Gopen(s->file, name, H5P_DEFAULT)) <0) { + H5_FAILED(); AT(); + printf("H5Gopen failed\n"); + goto error; + } + + if(H5Gget_info(g,&group_info) <0) { + H5_FAILED(); AT(); + printf("H5Gget_info failed\n"); + goto 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) { + H5_FAILED(); AT(); + printf("Reader - Old-styled group: but the group is not in old-style. \n"); + goto 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) { + H5_FAILED(); AT(); + printf("Reader - The created group should NOT be in old-style . \n"); + goto error; + } + dbgf(2,"Reader: verify that the group is created with the new-style.\n"); + + } + + if (H5Gclose(g) < 0) { + H5_FAILED(); AT(); + printf("H5Gclose failed\n"); + goto 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) + goto 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; } +static bool vrfy_one_link_exist(state_t *s, + hid_t obj_id, + const char* name, + bool expect_exist) { + + int link_exists = 0; + + dbgf(2, "LE 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) { + H5_FAILED(); AT(); + printf("H5Lexists error\n"); + goto error; + } + else if(link_exists == 1) { + if(expect_exist == false) { + H5_FAILED(); AT(); + printf("This link should be moved or deleted but it still exists.\n"); + goto error; + } + } + else if (link_exists == 0) { + if(expect_exist == true) { + H5_FAILED(); AT(); + printf("This link should exist but it is moved or deleted.\n"); + goto 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) + goto 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; + +} + 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-%d", which); + ret_value = vrfy_one_link_exist(s,s->file,name,false); + } + return ret_value; +} + +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, "CG 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) { + H5_FAILED(); AT(); + printf("Number of created groups is out of bounds\n"); + goto error; + } + + link_exists = H5Lexists(obj_id,name,H5P_DEFAULT); + if(link_exists<0) { + H5_FAILED(); AT(); + printf("H5Lexists error\n"); + goto error; + } + else if(link_exists == 1) { + H5_FAILED(); AT(); + printf("This link should be moved but it still exists.\n"); + goto error; + } + + + if((g = H5Gopen(obj_id, newname, H5P_DEFAULT)) <0) { + H5_FAILED(); AT(); + printf("H5Gopen failed\n"); + goto error; + } + + if(H5Gget_info(g,&group_info) <0) { + H5_FAILED(); AT(); + printf("H5Gget_info failed\n"); + goto 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) { + H5_FAILED(); AT(); + printf("Reader - Old-styled group: but the group is not in old-style. \n"); + goto 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) { + H5_FAILED(); AT(); + printf("Reader - The created group should NOT be in old-style . \n"); + goto error; + } + dbgf(2,"Reader: verify that the group is created with the new-style.\n"); + + } + + if (H5Gclose(g) < 0) { + H5_FAILED(); AT(); + printf("H5Gclose failed\n"); + goto 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) + goto 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; } + + 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-%d", which); + esnprintf(new_name, sizeof(new_name), "/new-group-%d", which); + ret_value = vrfy_move_one_group(s,s->file,name,new_name,which); + } + return ret_value; - return false; } static bool -vrfy_insert_link(state_t *s, unsigned int which){ +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-%d", which); + esnprintf(st_name, sizeof(st_name), "/st-group-%d", which); + ret_value = vrfy_one_link_exist(s,s->file,hd_name,true); + if(ret_value == true) + ret_value = vrfy_one_link_exist(s,s->file,st_name,true); + } + return ret_value; - return false; } static bool -vrfy_delete_link(state_t *s, unsigned int which){ +vrfy_delete_links(state_t *s, unsigned int which){ @@ -3080,10 +3675,10 @@ verify_group_operations(state_t *s, unsigned int which) ret_value = vrfy_move_group(s, which); break; case 'i': - ret_value = vrfy_insert_link(s, which); + ret_value = vrfy_insert_links(s, which); break; case 'D': - ret_value = vrfy_delete_link(s, which); + ret_value = vrfy_delete_links(s, which); break; case 't': ret_value = vrfy_transit_storage_compact_to_dense(s, which); @@ -3221,9 +3816,12 @@ main(int argc, char **argv) } /* For attribute test, force the named pipe to communicate in every step. */ - if (s.at_pattern != ' ') { - s.attr_test = true; - if(s.use_named_pipes) + 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; } @@ -3238,14 +3836,16 @@ main(int argc, char **argv) printf("write_group failed at step %d\n",step); /* At communication interval, notifies the reader about the failture and quit */ - if (s.use_named_pipes && s.attr_test !=true && step % s.csteps == 0) + if (s.use_named_pipes && s.attr_test !=true && + s.grp_op_test !=true && step % s.csteps == 0) np_send_error(&s,true); goto error; } else { /* At communication interval, notifies the reader and waits for its response */ - if (s.use_named_pipes && s.attr_test != true && step % s.csteps == 0) { + 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) { H5_FAILED(); AT(); @@ -3260,7 +3860,8 @@ main(int argc, char **argv) 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 && step % s.csteps == 0) { + if (s.use_named_pipes && s.attr_test != true && + s.grp_op_test !=true && step % s.csteps == 0) { if(false == np_rd_receive(&s)) { H5_FAILED(); AT(); goto error; @@ -3279,7 +3880,8 @@ main(int argc, char **argv) H5_FAILED(); AT(); /* At communication interval, tell the writer about the failure and exit */ - if (s.use_named_pipes && s.attr_test != true && step % s.csteps == 0) + if (s.use_named_pipes && s.attr_test != true && + s.grp_op_test != true && step % s.csteps == 0) np_send_error(&s,false); goto error; @@ -3288,7 +3890,8 @@ main(int argc, char **argv) /* 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 && step % s.csteps == 0) { + if (s.use_named_pipes && s.attr_test!=true && + s.grp_op_test != true && step % s.csteps == 0) { if(np_rd_send(&s)==false) goto error; } -- cgit v0.12 From ec5ce26bb3eb3991c2720d679744abf27b6e31a6 Mon Sep 17 00:00:00 2001 From: Muqun Yang Date: Thu, 6 May 2021 09:49:32 -0500 Subject: Add all the group operation tests. The tests include create_group,delete_group, move_group, insert_links, delete_links, link storage transition and old-styled group creation. --- test/testvfdswmr.sh.in | 121 +++- test/vfd_swmr_group_writer.c | 1461 +++++++++++++++++++++++++++++++++++++----- 2 files changed, 1415 insertions(+), 167 deletions(-) diff --git a/test/testvfdswmr.sh.in b/test/testvfdswmr.sh.in index 979f5a9..19d5ae0 100644 --- a/test/testvfdswmr.sh.in +++ b/test/testvfdswmr.sh.in @@ -56,13 +56,15 @@ BIGSET_few_s=20 # -s option: # of datasets (for few_big test BIGSET_many_s=500 # -s option: # of datasets (for many_small test) GROUP_n=40 # -n option: # of groups (for group test) GROUP_attr_n=1 # -n option: # of groups (for group attribute test) +GROUP_op_n=1 # -n option: # of groups (for group attribute test) if [[ "$HDF5TestExpress" -eq 0 ]] ; then # Setting for exhaustive run BIGSET_n=50 BIGSET_few_s=40 BIGSET_many_s=1000 GROUP_n=400 - GROUP_attr_n=4 + GROUP_attr_n=2 + GROUP_op_n=2 elif [[ "$HDF5TestExpress" -gt 1 ]]; then # Setting for quick run BIGSET_n=10 BIGSET_few_s=10 @@ -156,7 +158,7 @@ if [ $rc -ne 0 ] ; then fi all_tests="generator expand shrink expand_shrink sparse vlstr_null vlstr_oob zoo groups attrdset" -all_tests="${all_tests} groups_attrs os_groups_attrs few_big many_small" +all_tests="${all_tests} groups_attrs os_groups_attrs groups_ops os_groups_ops few_big many_small" tests=${all_tests} if [ $# -gt 0 ]; then @@ -849,6 +851,121 @@ for options in ${os_grp_attr_list[*]}; do rm -f vfd_swmr_group_reader.*.{out,rc} done +# The group operation test takes longer. +# So for the quick run, we +# shorten the number of tests. +# The essential features are covered. +grp_op_list=( + "grp-creation" + "grp-deletion" + "grp-move" + "grp-ins-links" + "grp-del-links" + "grp-compact-t-dense" + "grp-dense-t-compact" + ) +grp_sub_op_list=( + "grp-move" + "grp-dense-t-compact" + ) + + +if [[ "$HDF5TestExpress" -gt 1 ]] ; then #Setting for express run + grp_op_list=("${grp_sub_op_list[@]}") +fi + +for options in ${grp_op_list[*]}; do + if [ ${do_groups_ops:-no} = no ]; then + continue + fi + echo launch vfd_swmr_group operations: $options + catch_out_err_and_rc vfd_swmr_group_writer \ + ../vfd_swmr_group_writer -q -c 1 -n $GROUP_op_n -O $options & + pid_writer=$! + + catch_out_err_and_rc vfd_swmr_group_reader \ + ../vfd_swmr_group_reader -q -c 1 -n $GROUP_op_n -O $options & + pid_reader=$! + + # Wait for the reader to finish before signalling 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_group_reader.rc) -ne 0 ]; then + echo reader had error + nerrors=$((nerrors + 1)) + fi + + # 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} + rm -f vfd_swmr_group_reader.*.{out,rc} +done + +# Test the group operations for old-style +os_grp_op_list=( + "grp-creation" + "grp-deletion" + "grp-move" + "grp-ins-links" + "grp-del-links" + ) +os_grp_sub_op_list=( + "grp-move" + "grp-ins-links" + "grp-del-links" + ) + + +if [[ "$HDF5TestExpress" -gt 1 ]] ; then #Setting for express run + os_grp_op_list=("${os_grp_sub_op_list[@]}") +fi + +for options in ${os_grp_op_list[*]}; do + if [ ${do_os_groups_ops:-no} = no ]; then + continue + fi + echo launch vfd_swmr_group operations with old-style group: $options + catch_out_err_and_rc vfd_swmr_group_writer \ + ../vfd_swmr_group_writer -q -G -c 1 -n $GROUP_op_n -O $options & + pid_writer=$! + + catch_out_err_and_rc vfd_swmr_group_reader \ + ../vfd_swmr_group_reader -q -G -c 1 -n $GROUP_op_n -O $options & + pid_reader=$! + + # Wait for the reader to finish before signalling 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_group_reader.rc) -ne 0 ]; then + echo reader had error + nerrors=$((nerrors + 1)) + fi + + # 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} + rm -f vfd_swmr_group_reader.*.{out,rc} +done diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index fe7284f..03ff5b0 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -72,8 +72,8 @@ typedef struct { static void usage(const char *progname) { - fprintf(stderr, "usage: %s [-S] [-G] [-a steps] [-b] [-c]\n" - " [-n iterations] [-N] [-q] [-u numb_ticks] [-A at_pattern]\n" + 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" @@ -105,6 +105,29 @@ usage(const char *progname) " deleted\n" " `modify-vstr` - A VL string attribute added then \n" " modified \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); @@ -177,19 +200,19 @@ state_init(state_t *s, int argc, char **argv) s->use_named_pipes = false; break; case 'O': - if (strcmp(optarg, "grp-creation") == 0) + if (HDstrcmp(optarg, "grp-creation") == 0) s->grp_op_pattern = 'c'; - else if (strcmp(optarg, "grp-deletion") == 0) + else if (HDstrcmp(optarg, "grp-deletion") == 0) s->grp_op_pattern = 'd'; - else if (strcmp(optarg, "grp-move") == 0) + else if (HDstrcmp(optarg, "grp-move") == 0) s->grp_op_pattern = 'm'; - else if (strcmp(optarg, "grp-ins-links") == 0) + else if (HDstrcmp(optarg, "grp-ins-links") == 0) s->grp_op_pattern = 'i'; - else if (strcmp(optarg, "grp-del-links") == 0) + else if (HDstrcmp(optarg, "grp-del-links") == 0) s->grp_op_pattern = 'D'; - else if (strcmp(optarg, "grp-compact-t-dense") == 0) + else if (HDstrcmp(optarg, "grp-compact-t-dense") == 0) s->grp_op_pattern = 't'; - else if (strcmp(optarg, "grp-dense-t-compact") == 0) + else if (HDstrcmp(optarg, "grp-dense-t-compact") == 0) s->grp_op_pattern = 'T'; else { H5_FAILED(); AT(); @@ -241,12 +264,12 @@ state_init(state_t *s, int argc, char **argv) if(s->at_pattern != ' ') s->attr_test = true; - if(!s->grp_op_test && !s->attr_test) { - if (s->asteps < 1 || s->asteps > s->nsteps) { - H5_FAILED(); AT(); - printf("attribute interval is out of bounds\n"); - goto error; - } + if(!s->grp_op_test) { + if (s->asteps < 1 || s->asteps > s->nsteps) { + H5_FAILED(); AT(); + printf("attribute interval is out of bounds\n"); + goto error; + } } if(s->grp_op_test && s->attr_test) { @@ -490,10 +513,6 @@ add_attr(state_t *s, } attr_value = u+which; -#if 0 - // Just for debugging to check if error handling works. - attr_value = u+which+1; -#endif dbgf(1, "setting attribute %s on group %u to %u\n", attrname, g_which, u+which); @@ -1631,7 +1650,7 @@ write_group(state_t *s, unsigned int which) goto error; } - esnprintf(name, sizeof(name), "/group-%d", which); + esnprintf(name, sizeof(name), "/group-%u", which); if(s->old_style_grp) gcpl = H5P_DEFAULT; @@ -1818,8 +1837,8 @@ error: * a flag to indicate if the storage check is on * * bool is_compact - * true if the attribute is stored in compact storage - * false if the attribute is stored in dense storage + * 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. * @@ -1888,12 +1907,11 @@ vrfy_attr(state_t *s, if(read_which != which) { H5_FAILED(); AT(); - dbgf(2, "reader: the add_attribute verfication failed,expected value is %d\n", which); - dbgf(2, "reader: the add_attribute verfication failed, the value is %d\n", read_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"); goto error; } - if(!s->old_style_grp && check_storage == true) { if(false == check_attr_storage_type(g,is_compact)) { @@ -2052,8 +2070,8 @@ verify_modify_attr(state_t *s, hid_t g, unsigned int which) { /* verify the modified value */ if(read_which != (which+10000)) { H5_FAILED(); AT(); - dbgf(2, "reader: the modified_attr() expected value is %d\n", (-1)*(int)which); - dbgf(2, "reader: the modified_attr() actual value is %d\n", read_which); + 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"); goto error; } @@ -2187,8 +2205,8 @@ verify_group_vlstr_attr(state_t*s, hid_t g, unsigned int which, bool vrfy_mod) dbgf(1,"read attr is= %s\n",astr_val); if (HDstrcmp(astr_val, astr_val_exp) != 0) { H5_FAILED(); AT(); - dbgf(2, "reader: the vl add_attribute verfication failed,expected value is %s\n", astr_val_exp); - dbgf(2, "reader: the vl add_attribute verfication failed, the value is %s\n", astr_val); + 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"); goto error; } @@ -2240,7 +2258,7 @@ error2: /*------------------------------------------------------------------------- * Function: verify_del_one_attr * - * Purpose: verify if an attribute is successfully deleted. + * Purpose: Verify if an attribute is successfully deleted. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe @@ -2252,6 +2270,16 @@ error2: * 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 * @@ -2291,11 +2319,12 @@ verify_del_one_attr(state_t *s, dbgf(1," attribute %s is successfully deleted. \n",aname); } else if(attr_exists == TRUE) { - dbgf(1,"verify_del_attrs_compact() test failed \n"); + printf("The supposed deleted attribute %s still exists \n",aname); + printf("verify_del_attrs_compact() test failed \n"); goto error; } else{ - dbgf(1,"H5Aexists_by_name failed \n"); + printf("H5Aexists_by_name failed \n"); goto error; } @@ -2414,7 +2443,7 @@ verify_modify_vlstr_attr(state_t *s, hid_t g, unsigned int which){ /*------------------------------------------------------------------------- * Function: verify_attrs_compact * - * Purpose: verify if attributes are successfully added for the compact + * Purpose: Verify if attributes are successfully added for the compact * storage. * * Parameters: state_t *s @@ -2466,7 +2495,7 @@ verify_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which) { /*------------------------------------------------------------------------- * Function: verify_attrs_compact_dense * - * Purpose: verify if attributes are successfully added first in the + * Purpose: Verify if attributes are successfully added first in the * compact storage then in the dense storage. * * Parameters: state_t *s @@ -2508,8 +2537,6 @@ verify_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int whi * retrieved value is correct. */ HDsprintf(attrname, aname_format, max_c+which,0); ret = vrfy_attr(s,g,which+max_c,attrname,which,true,false); - if(ret == false) - dbgf(1,"verify_attrs_compact_dense failed \n"); } return ret; @@ -2518,7 +2545,7 @@ verify_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int whi /*------------------------------------------------------------------------- * Function: verify_del_attrs_compact * - * Purpose: verify if an attribute in compact storage is successfully + * Purpose: Verify if an attribute in compact storage is successfully * deleted. * * Parameters: state_t *s @@ -2568,7 +2595,7 @@ verify_del_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which /*------------------------------------------------------------------------- * Function: verify_del_attrs_compact_dense * - * Purpose: verify if an attribute in dense storage is successfully + * Purpose: Verify if an attribute in dense storage is successfully * deleted. * * Parameters: state_t *s @@ -2879,7 +2906,7 @@ verify_group(state_t *s, unsigned int which) goto error; } - esnprintf(name, sizeof(name), "/group-%d", which); + esnprintf(name, sizeof(name), "/group-%u", which); if((g = H5Gopen(s->file, name, H5P_DEFAULT)) <0) { @@ -2913,7 +2940,7 @@ verify_group(state_t *s, unsigned int which) } - /* Reader sends an OK message back to the reader */ + /* Reader sends an OK message back to the writer */ if(s->use_named_pipes && s->attr_test == true) { if(np_rd_send(s)==false) @@ -2952,12 +2979,185 @@ error2: } +/*------------------------------------------------------------------------- + * 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) { + H5_FAILED(); AT(); + printf("Number of created groups is out of bounds\n"); + goto error; + } + + gcpl = H5Pcreate(H5P_GROUP_CREATE); + if(gcpl <0) { + H5_FAILED(); AT(); + printf("H5Pcreate failed\n"); + goto error; + } + + if(dense_to_compact) { + if(H5Pset_link_phase_change(gcpl, 2, 2) <0) { + H5_FAILED(); AT(); + printf("H5Pset_link_phase_change failed for dense to compact.\n"); + goto error; + } + } + else { + if(H5Pset_link_phase_change(gcpl, 1, 1) <0) { + H5_FAILED(); AT(); + printf("H5Pset_attr_phase_change failed for compact to dense.\n"); + goto error; + } + } + + esnprintf(name, sizeof(name), "/group-%u", which); + if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, gcpl, + H5P_DEFAULT)) < 0) { + H5_FAILED(); AT(); + printf("H5Gcreate2 failed\n"); + goto error; + } + + if(H5Gget_info(g,&group_info) <0) { + H5_FAILED(); AT(); + printf("H5Gget_info failed\n"); + goto error; + } + + /* The storage type should always be compact when a group is created. */ + if(group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + H5_FAILED(); AT(); + printf("New-style group link storage test:. \n"); + printf(" still be compact after group creation. \n"); + goto error; + } + + if (H5Pclose(gcpl) < 0) { + H5_FAILED(); AT(); + printf("H5Pclose failed\n"); + goto 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) { + H5_FAILED(); AT(); + printf("H5Gclose failed\n"); + goto 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 and carry out attribute operations(add,delete etc.) - * according to the attribute test pattern. + * Purpose: Create a group * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe @@ -2965,7 +3165,7 @@ error2: * * unsigned int which * The number of iterations for group creation - * + * This is used to generate the group name. * * Return: Success: true * Failure: false @@ -2987,7 +3187,7 @@ create_group(state_t *s, unsigned int which) { goto error; } - esnprintf(name, sizeof(name), "/group-%d", which); + esnprintf(name, sizeof(name), "/group-%u", which); if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); AT(); @@ -3016,7 +3216,6 @@ create_group(state_t *s, unsigned int which) { goto error; } dbgf(2,"Writer: group is created with the new-style.\n"); - } if (H5Gclose(g) < 0) { @@ -3025,19 +3224,12 @@ create_group(state_t *s, unsigned int which) { goto 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. - * This will distinguish an attribute operation error from an - * group creation error. - * Writer sends a message to reader: an attribute is successfully generated. + /* 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, "CG writer: ready to send the message: %d\n", s->np_notify+1); + 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; } } @@ -3059,16 +3251,29 @@ error2: } + + /*------------------------------------------------------------------------- - * Function: create_group + * Function: delete_one_link * - * Purpose: Create a group and carry out attribute operations(add,delete etc.) - * according to the attribute test pattern. + * 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 * @@ -3076,7 +3281,7 @@ error2: * Return: Success: true * Failure: false * - * Note: This is called by the main() function. + * Note: This is used by delete_groups() and delete_links() functions. *------------------------------------------------------------------------- */ @@ -3084,8 +3289,11 @@ 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) { H5_FAILED(); AT(); printf("Number of created groups is out of bounds\n"); @@ -3098,19 +3306,44 @@ delete_one_link(state_t *s, goto 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. - * This will distinguish an attribute operation error from an - * group creation error. - * Writer sends a message to reader: an attribute is successfully generated. + if(link_storage >0) { + + if(s->old_style_grp) { + H5_FAILED(); AT(); + printf("Old style group doesn't support the indexed storage.\n"); + goto error; + } + + if(H5Gget_info(obj_id,&group_info) <0) { + H5_FAILED(); AT(); + printf("H5Gget_info failed\n"); + goto error; + } + + if(link_storage == 1) { + + if(group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + H5_FAILED(); AT(); + printf("The group link storage should be compact. \n"); + goto error; + } + } + else { + + if(group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { + H5_FAILED(); AT(); + printf("The group link storage should be dense. \n"); + goto 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(); - /* 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; } } @@ -3128,6 +3361,27 @@ error2: } +/*------------------------------------------------------------------------- + * 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) { @@ -3135,20 +3389,49 @@ 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-%d", which); - ret_value = delete_one_link(s,s->file,name,which); + 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) { + hid_t obj_id, + const char *name, + const char *newname, + unsigned int which) { if (which >= s->nsteps) { H5_FAILED(); AT(); @@ -3162,19 +3445,12 @@ move_one_group(state_t *s, goto 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. - * This will distinguish an attribute operation error from an - * group creation error. - * Writer sends a message to reader: an attribute is successfully generated. + /* 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(); - /* 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; } } @@ -3192,16 +3468,35 @@ error2: } - -static bool -move_group(state_t *s, unsigned int which) { - +/*------------------------------------------------------------------------- + * 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-%d", which); - esnprintf(new_name, sizeof(new_name), "/new-group-%d", which); + 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); } @@ -3209,14 +3504,54 @@ move_group(state_t *s, unsigned int which) { } +/*------------------------------------------------------------------------- + * 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, - unsigned int which) { + 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) { H5_FAILED(); AT(); @@ -3224,33 +3559,79 @@ insert_one_link(state_t *s, goto 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(H5Lcreate_hard(obj_id,name,obj_id,newname,H5P_DEFAULT,H5P_DEFAULT)<0){ - printf("H5Lcreate_hard failed\n"); - goto error; + if(link_storage >0) { + if(H5Lcreate_hard(s->file,name,obj_id,newname,H5P_DEFAULT,H5P_DEFAULT)<0){ + H5_FAILED(); AT(); + printf("H5Lcreate_hard failed\n"); + goto error; + } + } + else { + if(H5Lcreate_hard(obj_id,name,obj_id,newname,H5P_DEFAULT,H5P_DEFAULT)<0){ + H5_FAILED(); AT(); + printf("H5Lcreate_hard failed\n"); + goto error; + } } } else { - if(H5Lcreate_soft(name,obj_id,newname,H5P_DEFAULT,H5P_DEFAULT)<0) { + if(link_storage >0) { + if(H5Lcreate_soft("/",obj_id,newname,H5P_DEFAULT,H5P_DEFAULT)<0) { + H5_FAILED(); AT(); + printf("H5Lcreate_soft failed\n"); + goto error; + } + } + else { + if(H5Lcreate_soft(name,obj_id,newname,H5P_DEFAULT,H5P_DEFAULT)<0) { + H5_FAILED(); AT(); + printf("H5Lcreate_soft failed.\n"); + goto error; + } + } + } + + if(link_storage >0) { + + if(s->old_style_grp) { H5_FAILED(); AT(); - printf("H5Lcreate_soft failed.\n"); + printf("Old style group doesn't support dense or compact storage.\n"); goto error; } + + if(H5Gget_info(obj_id,&group_info) <0) { + H5_FAILED(); AT(); + printf("H5Gget_info failed\n"); + goto error; + } + + if(link_storage == 1) { + if(group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + H5_FAILED(); AT(); + printf("The group link storage should be compact. \n"); + goto error; + } + } + else { + if(group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { + H5_FAILED(); AT(); + printf("The group link storage should be dense. \n"); + goto 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. - * This will distinguish an attribute operation error from an - * group creation error. - * Writer sends a message to reader: an attribute is successfully generated. + /* 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(); - /* 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; } } @@ -3268,6 +3649,26 @@ error2: } +/*------------------------------------------------------------------------- + * 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) { @@ -3277,56 +3678,221 @@ insert_links(state_t *s, unsigned int which) { bool ret_value = create_group(s,which); if(ret_value == true) { - esnprintf(name, sizeof(name), "/group-%d", which); - esnprintf(hd_name, sizeof(hd_name), "/hd-group-%d", which); - esnprintf(st_name, sizeof(st_name), "/st-group-%d", which); - ret_value = insert_one_link(s,s->file,name,hd_name,true,which); + 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,which); + 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")]; - bool ret_value = create_group(s,which); + 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) { - // TO DO - esnprintf(name, sizeof(name), "/group-%d", which); - ret_value = delete_one_link(s,s->file,name,which); + 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) { + H5_FAILED(); AT(); + printf("create_group_id failed\n"); + goto 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) { + H5_FAILED(); AT(); + printf("insert_one_link for compact storage failed\n"); + goto 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) { + H5_FAILED(); AT(); + printf("insert_one_link for dense storage failed\n"); + goto error; + } + if(close_group_id(s,g) == false) { + H5_FAILED(); AT(); + printf("insert_one_link for dense storage failed\n"); + goto 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) { + H5_FAILED(); AT(); + printf("create_group_id failed\n"); + goto 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) { + H5_FAILED(); AT(); + printf("insert_one_link for compact storage failed\n"); + goto 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) { + H5_FAILED(); AT(); + printf("insert_one_link for compact storage failed\n"); + goto 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) { + H5_FAILED(); AT(); + printf("insert_one_link for dense storage failed\n"); + goto error; + } + + /* Delete a link, storage is still dense */ + if(delete_one_link(s, g, st_name,2, which) == false) { + H5_FAILED(); AT(); + printf("delete_one_link for dense storage failed\n"); + goto error; + } + + /* Delete another link, storage becomes compact */ + if(delete_one_link(s, g, st2_name,1, which) == false) { + H5_FAILED(); AT(); + printf("delete_one_link for compact storage failed\n"); + goto error; + } + + if(close_group_id(s,g) == false) { + H5_FAILED(); AT(); + printf("insert_one_link for dense storage failed\n"); + goto error; + } + return true; +error: + H5E_BEGIN_TRY { + H5Gclose(g); + } H5E_END_TRY; return false; + } /*------------------------------------------------------------------------- * Function: group_operations * - * Purpose: Create a group and carry out 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 @@ -3339,7 +3905,8 @@ transit_storage_dense_to_compact(state_t *s, unsigned int which) { * 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 @@ -3380,6 +3947,26 @@ group_operations(state_t *s, unsigned int which) } +/*------------------------------------------------------------------------- + * 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){ @@ -3387,7 +3974,8 @@ vrfy_create_group(state_t *s, unsigned int which){ hid_t g = H5I_INVALID_HID; H5G_info_t group_info; - dbgf(2, "CG reader: ready to send the message: \n"); + 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. @@ -3409,8 +3997,130 @@ vrfy_create_group(state_t *s, unsigned int which){ goto error; } - esnprintf(name, sizeof(name), "/group-%d", which); + esnprintf(name, sizeof(name), "/group-%u", which); + + if((g = H5Gopen(s->file, name, H5P_DEFAULT)) <0) { + H5_FAILED(); AT(); + printf("H5Gopen failed\n"); + goto error; + } + + if(H5Gget_info(g,&group_info) <0) { + H5_FAILED(); AT(); + printf("H5Gget_info failed\n"); + goto 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) { + H5_FAILED(); AT(); + printf("Reader - Old-styled group: but the group is not in old-style. \n"); + goto 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) { + H5_FAILED(); AT(); + printf("Reader - The created group should NOT be in old-style . \n"); + goto error; + } + dbgf(2,"Reader: verify that the group is created with the new-style.\n"); + + } + + if (H5Gclose(g) < 0) { + H5_FAILED(); AT(); + printf("H5Gclose failed\n"); + goto 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) + goto 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) { + H5_FAILED(); AT(); + printf("Number of the created groups is out of bounds\n"); + goto error; + } + + esnprintf(name, sizeof(name), "/group-%u", which); if((g = H5Gopen(s->file, name, H5P_DEFAULT)) <0) { H5_FAILED(); AT(); @@ -3418,28 +4128,134 @@ vrfy_create_group(state_t *s, unsigned int which){ goto error; } - if(H5Gget_info(g,&group_info) <0) { - H5_FAILED(); AT(); - printf("H5Gget_info failed\n"); - goto 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) { - H5_FAILED(); AT(); - printf("Reader - Old-styled group: but the group is not in old-style. \n"); - goto 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) { + if((gcpl = H5Gget_create_plist(g)) < 0) { + H5_FAILED(); AT(); + printf("H5Gget_create_plist failed\n"); + goto error; + } + + if (H5Pget_link_phase_change(gcpl,&max_compact,&min_dense) < 0) { + H5_FAILED(); AT(); + printf("H5Pget_link_phase_change failed\n"); + goto error; + } + + if(dense_to_compact) { + if(max_compact != 2) { + H5_FAILED(); AT(); + 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); + goto error; + } + else if (min_dense != 2) { + H5_FAILED(); AT(); + 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); + goto error; + } + } + else { + if(max_compact != 1) { + H5_FAILED(); AT(); + 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); + goto error; + } + else if (min_dense != 1) { + H5_FAILED(); AT(); + 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); + goto error; + } + + } + + if(H5Pclose(gcpl) < 0) { + H5_FAILED(); AT(); + printf("H5Pclose failed\n"); + goto error; + } + + if(H5Gget_info(g,&group_info) <0) { + H5_FAILED(); AT(); + printf("H5Gget_info failed\n"); + goto error; + } + + /* When the group is created, the storage type is always compact. */ + if(group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + H5_FAILED(); AT(); + printf("Old-styled group test: but the group is not in old-style. \n"); + goto 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) + goto 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(); - printf("Reader - The created group should NOT be in old-style . \n"); - goto error; + goto error2; } - dbgf(2,"Reader: verify that the group is created with the new-style.\n"); + decisleep(s->tick_len * s->update_interval); + dbgf(1, "reader: finish reading the message: %d\n",s->np_notify); } @@ -3449,7 +4265,6 @@ vrfy_create_group(state_t *s, unsigned int which){ goto error; } - /* Reader sends an OK message back to the reader */ if(s->use_named_pipes && s->grp_op_test == true) { @@ -3463,27 +4278,54 @@ vrfy_create_group(state_t *s, unsigned int which){ 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_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) { + bool expect_exist, + short link_storage) { int link_exists = 0; + H5G_info_t group_info; - dbgf(2, "LE reader: ready to send the message: \n"); + 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. @@ -3521,6 +4363,37 @@ static bool vrfy_one_link_exist(state_t *s, } } + if(link_storage >0) { + + if(s->old_style_grp) { + H5_FAILED(); AT(); + printf("Old style group doesn't support the indexed storage.\n"); + goto error; + } + + if(H5Gget_info(obj_id,&group_info) <0) { + H5_FAILED(); AT(); + printf("H5Gget_info failed\n"); + goto error; + } + + if(link_storage == 1) { + if(group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + H5_FAILED(); AT(); + printf("The group link storage should be compact. \n"); + goto error; + } + } + else { + if(group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { + H5_FAILED(); AT(); + printf("The group link storage should be dense. \n"); + goto 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) @@ -3543,19 +4416,69 @@ error2: } +/*------------------------------------------------------------------------- + * 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-%d", which); - ret_value = vrfy_one_link_exist(s,s->file,name,false); + 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, @@ -3567,7 +4490,7 @@ vrfy_move_one_group(state_t *s, H5G_info_t group_info; int link_exists = 0; - dbgf(2, "CG reader: ready to send the message: \n"); + 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. @@ -3666,7 +4589,25 @@ 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){ @@ -3675,8 +4616,8 @@ vrfy_move_group(state_t *s, unsigned int which){ char new_name[sizeof("/new-group-9999999999")]; bool ret_value = vrfy_create_group(s,which); if(ret_value == true) { - esnprintf(name, sizeof(name), "/group-%d", which); - esnprintf(new_name, sizeof(new_name), "/new-group-%d", which); + 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); } @@ -3684,6 +4625,27 @@ vrfy_move_group(state_t *s, unsigned int which){ } +/*------------------------------------------------------------------------- + * 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){ @@ -3692,40 +4654,212 @@ vrfy_insert_links(state_t *s, unsigned int which){ 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-%d", which); - esnprintf(st_name, sizeof(st_name), "/st-group-%d", which); - ret_value = vrfy_one_link_exist(s,s->file,hd_name,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); + 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 false; + 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) { + H5_FAILED(); AT(); + printf("verify create_group_id failed\n"); + goto error; + } + + esnprintf(hd_name, sizeof(hd_name), "hd-group-%u", which); + if(vrfy_one_link_exist(s,g,hd_name,true,1) == false) { + H5_FAILED(); AT(); + printf("verify the compact storage failed for 'link compact to dense' test\n"); + goto error; + } + + esnprintf(st_name, sizeof(st_name), "st-group-%u", which); + if(vrfy_one_link_exist(s,g,st_name,true,2) == false) { + H5_FAILED(); AT(); + printf("verify the dense link storage failed for 'link compact to dense' test\n"); + goto error; + } + if(vrfy_close_group_id(s, g) == false) { + H5_FAILED(); AT(); + printf("verify the group close for 'link compact to dense' test\n"); + goto 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) { + H5_FAILED(); AT(); + printf("verify create_group_id failed\n"); + goto 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) { + H5_FAILED(); AT(); + printf("verify the compact storage failed for 'link compact to dense' test\n"); + goto 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) { + H5_FAILED(); AT(); + printf("verify the compact link storage failed for 'link compact to dense' test\n"); + goto 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) { + H5_FAILED(); AT(); + printf("verify the dense link storage failed for 'link compact to dense' test\n"); + goto 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) { + H5_FAILED(); AT(); + printf("verify the dense link storage failed for 'link compact to dense' test\n"); + goto 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) { + H5_FAILED(); AT(); + printf("verify the compact link storage failed for 'link compact to dense' test\n"); + goto error; + } + if(vrfy_close_group_id(s, g) == false) { + H5_FAILED(); AT(); + printf("verify the group close for 'link compact to dense' test\n"); + goto error; + } + return true; +error: + H5E_BEGIN_TRY { + H5Gclose(g); + } H5E_END_TRY; return false; + } /*------------------------------------------------------------------------- @@ -3786,7 +4920,6 @@ verify_group_operations(state_t *s, unsigned int which) } return ret_value; - } @@ -3913,14 +5046,12 @@ main(int argc, char **argv) * 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) { + 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) { + if (s.grp_op_test && s.use_named_pipes) s.csteps = 1; - } if (writer) { for (step = 0; step < s.nsteps; step++) { @@ -3946,7 +5077,7 @@ main(int argc, char **argv) if(np_wr_send_receive(&s) == false) { H5_FAILED(); AT(); - dbgf(2, "writer: write group - verification failed.\n"); + printf("writer: write group - verification failed.\n"); goto error; } } @@ -3973,7 +5104,7 @@ main(int argc, char **argv) if (vg_ret == false) { - printf("verify_group_operations failed\n"); + printf("verify_group_operations failed\n"); H5_FAILED(); AT(); /* At communication interval, tell the writer about the failure and exit */ -- cgit v0.12 From fc4f1b5ecc7f065a7ab3009f755065f0c3c4afc2 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 6 May 2021 17:58:49 +0000 Subject: Committing clang-format changes --- test/vfd_swmr_group_writer.c | 1595 ++++++++++++++++++++++-------------------- 1 file changed, 837 insertions(+), 758 deletions(-) diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index 2f82404..2d98789 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -27,109 +27,101 @@ #define VS_ATTR_NAME_LEN 21 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; + 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; } 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 } - + .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 \ + } 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" - "-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", + 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" + "-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); } @@ -206,22 +198,23 @@ state_init(state_t *s, int argc, char **argv) s->use_named_pipes = false; break; case 'O': - if (HDstrcmp(optarg, "grp-creation") == 0) + if (HDstrcmp(optarg, "grp-creation") == 0) s->grp_op_pattern = 'c'; - else if (HDstrcmp(optarg, "grp-deletion") == 0) + else if (HDstrcmp(optarg, "grp-deletion") == 0) s->grp_op_pattern = 'd'; - else if (HDstrcmp(optarg, "grp-move") == 0) + else if (HDstrcmp(optarg, "grp-move") == 0) s->grp_op_pattern = 'm'; - else if (HDstrcmp(optarg, "grp-ins-links") == 0) + else if (HDstrcmp(optarg, "grp-ins-links") == 0) s->grp_op_pattern = 'i'; - else if (HDstrcmp(optarg, "grp-del-links") == 0) + else if (HDstrcmp(optarg, "grp-del-links") == 0) s->grp_op_pattern = 'D'; - else if (HDstrcmp(optarg, "grp-compact-t-dense") == 0) + else if (HDstrcmp(optarg, "grp-compact-t-dense") == 0) s->grp_op_pattern = 't'; - else if (HDstrcmp(optarg, "grp-dense-t-compact") == 0) + else if (HDstrcmp(optarg, "grp-dense-t-compact") == 0) s->grp_op_pattern = 'T'; else { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Invalid -O argument \"%s\"", optarg); goto error; } @@ -266,40 +259,43 @@ state_init(state_t *s, int argc, char **argv) argc -= optind; argv += optind; - if(s->grp_op_pattern != ' ') + if (s->grp_op_pattern != ' ') s->grp_op_test = true; - if(s->at_pattern != ' ') + if (s->at_pattern != ' ') s->attr_test = true; - if(!s->grp_op_test) { + if (!s->grp_op_test) { if (s->asteps < 1 || s->asteps > s->nsteps) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("attribute interval is out of bounds\n"); goto error; } } - if(s->grp_op_test && s->attr_test) { + 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) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("communication interval is out of bounds\n"); goto error; } if (argc > 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("unexpected command-line arguments\n"); goto error; } - /* space for attributes */ if ((s->one_by_one_sid = H5Screate_simple(1, &dims, &dims)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Screate_simple failed\n"); goto error; } @@ -534,7 +530,7 @@ add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const ch goto error; } - attr_value = u+which; + attr_value = u + which; dbgf(1, "setting attribute %s on group %u to %u\n", attrname, g_which, u + which); @@ -1899,8 +1895,8 @@ error: * 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 + * 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. * @@ -1967,17 +1963,19 @@ vrfy_attr(state_t *s, hid_t g, unsigned int which, const char *aname, unsigned i goto error; } - if(read_which != which) { - H5_FAILED(); AT(); + if (read_which != which) { + H5_FAILED(); + AT(); 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"); goto error; } - - if(!s->old_style_grp && check_storage == true) { - if(false == check_attr_storage_type(g,is_compact)) { - H5_FAILED(); AT(); + + if (!s->old_style_grp && check_storage == true) { + if (false == check_attr_storage_type(g, is_compact)) { + H5_FAILED(); + AT(); printf("The attribute storage type is wrong. \n"); goto error; } @@ -2136,9 +2134,10 @@ verify_modify_attr(state_t *s, hid_t g, unsigned int which) } /* verify the modified value */ - if(read_which != (which+10000)) { - H5_FAILED(); AT(); - printf("reader: the modified_attr() expected value is %d\n", which+10000); + if (read_which != (which + 10000)) { + H5_FAILED(); + AT(); + 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"); goto error; @@ -2277,7 +2276,8 @@ verify_group_vlstr_attr(state_t *s, hid_t g, unsigned int which, bool vrfy_mod) dbgf(1, "read attr is= %s\n", astr_val); if (HDstrcmp(astr_val, astr_val_exp) != 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); 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"); @@ -2355,7 +2355,7 @@ error2: * 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 * @@ -2390,12 +2390,12 @@ verify_del_one_attr(state_t *s, hid_t g, const char *aname, bool check_storage, 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); + else if (attr_exists == TRUE) { + printf("The supposed deleted attribute %s still exists \n", aname); printf("verify_del_attrs_compact() test failed \n"); goto error; } - else{ + else { printf("H5Aexists_by_name failed \n"); goto error; } @@ -2566,7 +2566,7 @@ verify_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which) /*------------------------------------------------------------------------- * Function: verify_attrs_compact_dense * - * Purpose: Verify if attributes are successfully added first in the + * Purpose: Verify if attributes are successfully added first in the * compact storage then in the dense storage. * * Parameters: state_t *s @@ -2606,9 +2606,8 @@ verify_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int whi /* 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); - + HDsprintf(attrname, aname_format, max_c + which, 0); + ret = vrfy_attr(s, g, which + max_c, attrname, which, true, false); } return ret; } @@ -2616,7 +2615,7 @@ verify_attrs_compact_dense(state_t *s, hid_t g, unsigned max_c, unsigned int whi /*------------------------------------------------------------------------- * Function: verify_del_attrs_compact * - * Purpose: Verify if an attribute in compact storage is successfully + * Purpose: Verify if an attribute in compact storage is successfully * deleted. * * Parameters: state_t *s @@ -2667,7 +2666,7 @@ verify_del_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which /*------------------------------------------------------------------------- * Function: verify_del_attrs_compact_dense * - * Purpose: Verify if an attribute in dense storage is successfully + * Purpose: Verify if an attribute in dense storage is successfully * deleted. * * Parameters: state_t *s @@ -3008,7 +3007,7 @@ 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 (s->use_named_pipes && s->attr_test == true) { if (np_rd_send(s) == false) goto error; @@ -3054,13 +3053,13 @@ error2: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * This is used to generate the group name. * - * bool dense_to_compact + * 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. * @@ -3069,102 +3068,112 @@ error2: * * 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) { +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; + 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) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Number of created groups is out of bounds\n"); goto error; } gcpl = H5Pcreate(H5P_GROUP_CREATE); - if(gcpl <0) { - H5_FAILED(); AT(); + if (gcpl < 0) { + H5_FAILED(); + AT(); printf("H5Pcreate failed\n"); goto error; } - if(dense_to_compact) { - if(H5Pset_link_phase_change(gcpl, 2, 2) <0) { - H5_FAILED(); AT(); + if (dense_to_compact) { + if (H5Pset_link_phase_change(gcpl, 2, 2) < 0) { + H5_FAILED(); + AT(); printf("H5Pset_link_phase_change failed for dense to compact.\n"); goto error; } } else { - if(H5Pset_link_phase_change(gcpl, 1, 1) <0) { - H5_FAILED(); AT(); + if (H5Pset_link_phase_change(gcpl, 1, 1) < 0) { + H5_FAILED(); + AT(); printf("H5Pset_attr_phase_change failed for compact to dense.\n"); goto error; } } esnprintf(name, sizeof(name), "/group-%u", which); - if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, gcpl, - H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); printf("H5Gcreate2 failed\n"); goto error; } - if(H5Gget_info(g,&group_info) <0) { - H5_FAILED(); AT(); + if (H5Gget_info(g, &group_info) < 0) { + H5_FAILED(); + AT(); printf("H5Gget_info failed\n"); goto error; } - + /* The storage type should always be compact when a group is created. */ - if(group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { - H5_FAILED(); AT(); + if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + H5_FAILED(); + AT(); printf("New-style group link storage test:. \n"); printf(" still be compact after group creation. \n"); goto error; } - + if (H5Pclose(gcpl) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Pclose failed\n"); goto 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. + * 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(); + 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); + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, true); -error2: +error2: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; - } /*------------------------------------------------------------------------- @@ -3174,65 +3183,65 @@ error2: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g - * The ID of the group to be closed. + * 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) { +close_group_id(state_t *s, hid_t g) +{ if (H5Gclose(g) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Gclose failed\n"); goto 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. + * 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(); + 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); + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, true); -error2: +error2: return false; - } - - /*------------------------------------------------------------------------- * Function: create_group * - * Purpose: Create a 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 + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * This is used to generate the group name. * * Return: Success: true @@ -3240,87 +3249,93 @@ error2: * * Note: This is called by the main() function. *------------------------------------------------------------------------- -*/ + */ static bool -create_group(state_t *s, unsigned int which) { +create_group(state_t *s, unsigned int which) +{ - char name[sizeof("/group-9999999999")]; - hid_t g = H5I_INVALID_HID; + char name[sizeof("/group-9999999999")]; + hid_t g = H5I_INVALID_HID; H5G_info_t group_info; if (which >= s->nsteps) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Number of created groups is out of bounds\n"); goto error; } esnprintf(name, sizeof(name), "/group-%u", which); - if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); printf("H5Gcreate2 failed\n"); goto error; } - if(H5Gget_info(g,&group_info) <0) { - H5_FAILED(); AT(); + if (H5Gget_info(g, &group_info) < 0) { + H5_FAILED(); + AT(); printf("H5Gget_info failed\n"); goto error; } - - if(s->old_style_grp) { - if(group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { - H5_FAILED(); AT(); + + if (s->old_style_grp) { + if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { + H5_FAILED(); + AT(); printf("Old-styled group test: but the group is not in old-style. \n"); goto error; } - dbgf(2,"Writer: 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) { - H5_FAILED(); AT(); + if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { + H5_FAILED(); + AT(); printf("The created group should NOT be in old-style . \n"); goto error; } - dbgf(2,"Writer: group is created with the new-style.\n"); + dbgf(2, "Writer: group is created with the new-style.\n"); } if (H5Gclose(g) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Gclose failed\n"); goto error; } - /* Writer sends a message to reader, + /* 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(); + 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); + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, true); -error2: +error2: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(g); - } H5E_END_TRY; + } + H5E_END_TRY; return false; - } - - /*------------------------------------------------------------------------- * Function: delete_one_link * @@ -3329,12 +3344,12 @@ error2: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * - * hid_t obj_id + * hid_t obj_id * The HDF5 object ID that the deleted link is attached to. * - * const char *name + * const char *name * The name of the link to be deleted. * * short link_storage @@ -3343,7 +3358,7 @@ error2: * >1: link storage should be dense after link deletion. * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * * * Return: Success: true @@ -3351,82 +3366,85 @@ error2: * * 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) { +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) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Number of created groups is out of bounds\n"); goto error; } - if(H5Ldelete(obj_id,name,H5P_DEFAULT) <0) { - H5_FAILED(); AT(); + if (H5Ldelete(obj_id, name, H5P_DEFAULT) < 0) { + H5_FAILED(); + AT(); printf("H5Ldelete failed\n"); goto error; } - if(link_storage >0) { - - if(s->old_style_grp) { - H5_FAILED(); AT(); + if (link_storage > 0) { + + if (s->old_style_grp) { + H5_FAILED(); + AT(); printf("Old style group doesn't support the indexed storage.\n"); goto error; } - if(H5Gget_info(obj_id,&group_info) <0) { - H5_FAILED(); AT(); + if (H5Gget_info(obj_id, &group_info) < 0) { + H5_FAILED(); + AT(); printf("H5Gget_info failed\n"); goto error; } - if(link_storage == 1) { + if (link_storage == 1) { - if(group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { - H5_FAILED(); AT(); + if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + H5_FAILED(); + AT(); printf("The group link storage should be compact. \n"); goto error; } } else { - if(group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { - H5_FAILED(); AT(); + if (group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { + H5_FAILED(); + AT(); printf("The group link storage should be dense. \n"); goto error; } } } - /* Writer sends a message to reader: + /* 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(); + 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); + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, true); -error2: +error2: return false; - } /*------------------------------------------------------------------------- @@ -3437,10 +3455,10 @@ error2: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * This is used to generate the group name * * @@ -3449,20 +3467,20 @@ error2: * * Note: This is called by the group_operations() function. *------------------------------------------------------------------------- -*/ + */ static bool -delete_group(state_t *s, unsigned int which) { - +delete_group(state_t *s, unsigned int which) +{ + char name[sizeof("/group-9999999999")]; - bool ret_value = create_group(s,which); - if(ret_value == true) { + 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); + ret_value = delete_one_link(s, s->file, name, 0, which); } return ret_value; - } /*------------------------------------------------------------------------- @@ -3472,19 +3490,19 @@ delete_group(state_t *s, unsigned int which) { * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t obj_id * ID of the object this group is attached to * - * const char *name + * const char *name * The original group name * - * const char *newname + * const char *newname * The new group name * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * * * Return: Success: true @@ -3492,48 +3510,47 @@ delete_group(state_t *s, unsigned int which) { * * 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) { +move_one_group(state_t *s, hid_t obj_id, const char *name, const char *newname, unsigned int which) +{ if (which >= s->nsteps) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Number of created groups is out of bounds\n"); goto error; } - if(H5Lmove(obj_id,name,obj_id,newname,H5P_DEFAULT,H5P_DEFAULT)<0){ - H5_FAILED(); AT(); + if (H5Lmove(obj_id, name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { + H5_FAILED(); + AT(); printf("H5Ldelete failed\n"); goto error; } - /* Writer sends a message to reader: + /* 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(); + 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); + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, true); -error2: +error2: return false; - } /*------------------------------------------------------------------------- @@ -3543,10 +3560,10 @@ error2: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * used to generate the group name. * * Return: Success: true @@ -3554,22 +3571,22 @@ error2: * * Note: This is called by the group_operations() function. *------------------------------------------------------------------------- -*/ + */ static bool -move_group(state_t *s, unsigned int which) { +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) { + 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); + ret_value = move_one_group(s, s->file, name, new_name, which); } return ret_value; - } /*------------------------------------------------------------------------- @@ -3579,15 +3596,15 @@ move_group(state_t *s, unsigned int which) { * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t obj_id * ID of the object this link is attached to * - * const char *name + * const char *name * The name of the target object used by creating links * - * const char *newname + * const char *newname * The name of the linked objects * * bool is_hard @@ -3598,9 +3615,9 @@ move_group(state_t *s, unsigned int which) { * <=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 + * The number of iterations for group creation * * Return: Success: true * Failure: false @@ -3608,21 +3625,18 @@ move_group(state_t *s, unsigned int which) { * 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) { +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) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Number of created groups is out of bounds\n"); goto error; } @@ -3631,90 +3645,97 @@ insert_one_link(state_t *s, * 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){ - H5_FAILED(); AT(); + if (link_storage > 0) { + if (H5Lcreate_hard(s->file, name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { + H5_FAILED(); + AT(); printf("H5Lcreate_hard failed\n"); goto error; } } else { - if(H5Lcreate_hard(obj_id,name,obj_id,newname,H5P_DEFAULT,H5P_DEFAULT)<0){ - H5_FAILED(); AT(); + if (H5Lcreate_hard(obj_id, name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { + H5_FAILED(); + AT(); printf("H5Lcreate_hard failed\n"); goto error; } } } else { - if(link_storage >0) { - if(H5Lcreate_soft("/",obj_id,newname,H5P_DEFAULT,H5P_DEFAULT)<0) { - H5_FAILED(); AT(); + if (link_storage > 0) { + if (H5Lcreate_soft("/", obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { + H5_FAILED(); + AT(); printf("H5Lcreate_soft failed\n"); goto error; } } else { - if(H5Lcreate_soft(name,obj_id,newname,H5P_DEFAULT,H5P_DEFAULT)<0) { - H5_FAILED(); AT(); + if (H5Lcreate_soft(name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { + H5_FAILED(); + AT(); printf("H5Lcreate_soft failed.\n"); goto error; } } } - if(link_storage >0) { + if (link_storage > 0) { - if(s->old_style_grp) { - H5_FAILED(); AT(); + if (s->old_style_grp) { + H5_FAILED(); + AT(); printf("Old style group doesn't support dense or compact storage.\n"); goto error; } - if(H5Gget_info(obj_id,&group_info) <0) { - H5_FAILED(); AT(); + if (H5Gget_info(obj_id, &group_info) < 0) { + H5_FAILED(); + AT(); printf("H5Gget_info failed\n"); goto error; } - if(link_storage == 1) { - if(group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { - H5_FAILED(); AT(); + if (link_storage == 1) { + if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + H5_FAILED(); + AT(); printf("The group link storage should be compact. \n"); goto error; } } else { - if(group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { - H5_FAILED(); AT(); + if (group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { + H5_FAILED(); + AT(); printf("The group link storage should be dense. \n"); goto error; } } - } - /* Writer sends a message to reader, + /* 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(); + 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); + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, true); -error2: +error2: return false; - } /*------------------------------------------------------------------------- @@ -3724,10 +3745,10 @@ error2: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations + * The number of iterations * used to generate the group name. * * Return: Success: true @@ -3735,27 +3756,27 @@ error2: * * Note: This is called by the group_operations() function. *------------------------------------------------------------------------- -*/ + */ static bool -insert_links(state_t *s, unsigned int which) { +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) { + 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); + 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; - } /*------------------------------------------------------------------------- @@ -3765,10 +3786,10 @@ insert_links(state_t *s, unsigned int which) { * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations + * The number of iterations * used to generate the group name. * * Return: Success: true @@ -3776,23 +3797,24 @@ insert_links(state_t *s, unsigned int which) { * * Note: This is called by the group_operations() function. *------------------------------------------------------------------------- -*/ + */ static bool -delete_links(state_t *s, unsigned int which) { +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) { + 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); + 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; @@ -3801,33 +3823,35 @@ delete_links(state_t *s, unsigned int which) { /*------------------------------------------------------------------------- * Function: transit_storage_compact_to_dense * - * Purpose: Add links so that the link storage transits from + * 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 + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations 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 group_operations() function. *------------------------------------------------------------------------- -*/ + */ static bool -transit_storage_compact_to_dense(state_t *s, unsigned int which) { +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) { - H5_FAILED(); AT(); + hid_t g = create_group_id(s, which, false); + if (g < 0) { + H5_FAILED(); + AT(); printf("create_group_id failed\n"); goto error; } @@ -3835,32 +3859,37 @@ transit_storage_compact_to_dense(state_t *s, unsigned int which) { /* 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) { - H5_FAILED(); AT(); + if (insert_one_link(s, g, name, hd_name, true, 1, which) == false) { + H5_FAILED(); + AT(); printf("insert_one_link for compact storage failed\n"); goto 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) { - H5_FAILED(); AT(); + if (insert_one_link(s, g, name, st_name, false, 2, which) == false) { + H5_FAILED(); + AT(); printf("insert_one_link for dense storage failed\n"); goto error; } - if(close_group_id(s,g) == false) { - H5_FAILED(); AT(); + if (close_group_id(s, g) == false) { + H5_FAILED(); + AT(); printf("insert_one_link for dense storage failed\n"); goto error; } return true; -error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Gclose(g); - } H5E_END_TRY; + } + H5E_END_TRY; return false; } @@ -3868,34 +3897,36 @@ error: /*------------------------------------------------------------------------- * Function: transit_storage_dense_to_compact * - * Purpose: Add or delete links so that the link storage transits from + * 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 + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations 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 group_operations() function. *------------------------------------------------------------------------- -*/ + */ static bool -transit_storage_dense_to_compact(state_t *s, unsigned int which) { +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) { - H5_FAILED(); AT(); + hid_t g = create_group_id(s, which, true); + if (g < 0) { + H5_FAILED(); + AT(); printf("create_group_id failed\n"); goto error; } @@ -3903,57 +3934,64 @@ transit_storage_dense_to_compact(state_t *s, unsigned int which) { /* 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) { - H5_FAILED(); AT(); + if (insert_one_link(s, g, name, hd_name, true, 1, which) == false) { + H5_FAILED(); + AT(); printf("insert_one_link for compact storage failed\n"); goto 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) { - H5_FAILED(); AT(); + if (insert_one_link(s, g, name, st_name, false, 1, which) == false) { + H5_FAILED(); + AT(); printf("insert_one_link for compact storage failed\n"); goto 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) { - H5_FAILED(); AT(); + if (insert_one_link(s, g, name, st2_name, false, 2, which) == false) { + H5_FAILED(); + AT(); printf("insert_one_link for dense storage failed\n"); goto error; } /* Delete a link, storage is still dense */ - if(delete_one_link(s, g, st_name,2, which) == false) { - H5_FAILED(); AT(); + if (delete_one_link(s, g, st_name, 2, which) == false) { + H5_FAILED(); + AT(); printf("delete_one_link for dense storage failed\n"); goto error; } /* Delete another link, storage becomes compact */ - if(delete_one_link(s, g, st2_name,1, which) == false) { - H5_FAILED(); AT(); + if (delete_one_link(s, g, st2_name, 1, which) == false) { + H5_FAILED(); + AT(); printf("delete_one_link for compact storage failed\n"); goto error; } - if(close_group_id(s,g) == false) { - H5_FAILED(); AT(); + if (close_group_id(s, g) == false) { + H5_FAILED(); + AT(); printf("insert_one_link for dense storage failed\n"); goto error; } return true; -error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Gclose(g); - } H5E_END_TRY; + } + H5E_END_TRY; return false; - } /*------------------------------------------------------------------------- @@ -3964,10 +4002,10 @@ error: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * * * Return: Success: true @@ -3976,12 +4014,12 @@ error: * 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; + bool ret_value = false; char test_pattern = s->grp_op_pattern; switch (test_pattern) { @@ -4012,7 +4050,6 @@ group_operations(state_t *s, unsigned int which) break; } return ret_value; - } /*------------------------------------------------------------------------- @@ -4022,10 +4059,10 @@ group_operations(state_t *s, unsigned int which) * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * used to generate the group name. * * Return: Success: true @@ -4033,98 +4070,104 @@ group_operations(state_t *s, unsigned int which) * * Note: This is called by the verify_group_operations() function. *------------------------------------------------------------------------- -*/ + */ static bool -vrfy_create_group(state_t *s, unsigned int which){ +vrfy_create_group(state_t *s, unsigned int which) +{ - char name[sizeof("/group-9999999999")]; - hid_t g = H5I_INVALID_HID; + 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 + * 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 (s->use_named_pipes && true == s->grp_op_test) { - if(false == np_rd_receive(s)) { - H5_FAILED(); AT(); + 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); - + dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); } if (which >= s->nsteps) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Number of created groups is out of bounds\n"); goto error; } esnprintf(name, sizeof(name), "/group-%u", which); - - if((g = H5Gopen(s->file, name, H5P_DEFAULT)) <0) { - H5_FAILED(); AT(); + + if ((g = H5Gopen(s->file, name, H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); printf("H5Gopen failed\n"); goto error; } - if(H5Gget_info(g,&group_info) <0) { - H5_FAILED(); AT(); + if (H5Gget_info(g, &group_info) < 0) { + H5_FAILED(); + AT(); printf("H5Gget_info failed\n"); goto 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) { - H5_FAILED(); AT(); + + 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) { + H5_FAILED(); + AT(); printf("Reader - Old-styled group: but the group is not in old-style. \n"); goto error; } - dbgf(2,"Reader: verify that the group is created with the old-style.\n"); + 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) { - H5_FAILED(); AT(); + if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { + H5_FAILED(); + AT(); printf("Reader - The created group should NOT be in old-style . \n"); goto error; } - dbgf(2,"Reader: verify that the group is created with the new-style.\n"); - + dbgf(2, "Reader: verify that the group is created with the new-style.\n"); } if (H5Gclose(g) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Gclose failed\n"); goto error; } - /* Reader sends an OK message back to the writer */ - if(s->use_named_pipes && s->grp_op_test == true) { + if (s->use_named_pipes && s->grp_op_test == true) { - if(np_rd_send(s)==false) + if (np_rd_send(s) == false) goto error; - dbgf(1, "Reader: finish sending back the message: %d\n",s->np_notify); - + dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); } return true; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(g); - } H5E_END_TRY; + } + 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); + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, false); error2: @@ -4135,17 +4178,17 @@ error2: * Function: vrfy_create_group_id * * Purpose: Verify if a group is created successfully and return the group - * ID. + * ID. * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * used to generate the group name. * - * bool dense_to_compact + * 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. * @@ -4154,136 +4197,148 @@ error2: * * 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){ +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; + 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; - + 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 + * 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 (s->use_named_pipes && true == s->grp_op_test) { - if(false == np_rd_receive(s)) { - H5_FAILED(); AT(); + 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); - + dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); } if (which >= s->nsteps) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Number of the created groups is out of bounds\n"); goto error; } esnprintf(name, sizeof(name), "/group-%u", which); - - if((g = H5Gopen(s->file, name, H5P_DEFAULT)) <0) { - H5_FAILED(); AT(); + + if ((g = H5Gopen(s->file, name, H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); printf("H5Gopen failed\n"); goto error; } - if((gcpl = H5Gget_create_plist(g)) < 0) { - H5_FAILED(); AT(); + if ((gcpl = H5Gget_create_plist(g)) < 0) { + H5_FAILED(); + AT(); printf("H5Gget_create_plist failed\n"); goto error; } - if (H5Pget_link_phase_change(gcpl,&max_compact,&min_dense) < 0) { - H5_FAILED(); AT(); + if (H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) { + H5_FAILED(); + AT(); printf("H5Pget_link_phase_change failed\n"); goto error; } - if(dense_to_compact) { - if(max_compact != 2) { - H5_FAILED(); AT(); + if (dense_to_compact) { + if (max_compact != 2) { + H5_FAILED(); + AT(); 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); + printf(" But the actual value is %d.\n", max_compact); goto error; } else if (min_dense != 2) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); 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); + printf(" But the actual value is %d.\n", min_dense); goto error; } } else { - if(max_compact != 1) { - H5_FAILED(); AT(); + if (max_compact != 1) { + H5_FAILED(); + AT(); 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); + printf(" But the actual value is %d.\n", max_compact); goto error; } else if (min_dense != 1) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); 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); + printf(" But the actual value is %d.\n", min_dense); goto error; } - } - if(H5Pclose(gcpl) < 0) { - H5_FAILED(); AT(); + if (H5Pclose(gcpl) < 0) { + H5_FAILED(); + AT(); printf("H5Pclose failed\n"); goto error; } - if(H5Gget_info(g,&group_info) <0) { - H5_FAILED(); AT(); + if (H5Gget_info(g, &group_info) < 0) { + H5_FAILED(); + AT(); printf("H5Gget_info failed\n"); goto error; } /* When the group is created, the storage type is always compact. */ - if(group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { - H5_FAILED(); AT(); + if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + H5_FAILED(); + AT(); printf("Old-styled group test: but the group is not in old-style. \n"); goto error; } - - dbgf(2,"Storage info is %d\n",group_info.storage_type); + + 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 (s->use_named_pipes && s->grp_op_test == true) { - if(np_rd_send(s)==false) + if (np_rd_send(s) == false) goto error; - dbgf(1, "Reader: finish sending back the message: %d\n",s->np_notify); - + dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); } return g; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(g); H5Pclose(gcpl); - } H5E_END_TRY; + } + 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); + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, false); error2: @@ -4297,49 +4352,50 @@ error2: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t g - * The ID of the group to be closed. + * 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) { +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 + * 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 (s->use_named_pipes && true == s->grp_op_test) { - if(false == np_rd_receive(s)) { - H5_FAILED(); AT(); + 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); - + dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); } if (H5Gclose(g) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Gclose failed\n"); goto error; } /* Reader sends an OK message back to the reader */ - if(s->use_named_pipes && s->grp_op_test == true) { + if (s->use_named_pipes && s->grp_op_test == true) { - if(np_rd_send(s)==false) + if (np_rd_send(s) == false) goto error; - dbgf(1, "Reader: finish sending back the message: %d\n",s->np_notify); - + dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); } return true; @@ -4347,12 +4403,11 @@ vrfy_close_group_id(state_t *s, hid_t g) { 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); + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, false); error2: return false; - } /*------------------------------------------------------------------------- @@ -4363,13 +4418,13 @@ error2: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * 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 + * A flag that indicates if this link is expected to exist * * short link_storage * <=0: link storage check is ignored. @@ -4382,92 +4437,95 @@ error2: * 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) { +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; + 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 + * 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 (s->use_named_pipes && true == s->grp_op_test) { - if(false == np_rd_receive(s)) { - H5_FAILED(); AT(); + 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); - + dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); } - link_exists = H5Lexists(obj_id,name,H5P_DEFAULT); + link_exists = H5Lexists(obj_id, name, H5P_DEFAULT); - if(link_exists<0) { - H5_FAILED(); AT(); + if (link_exists < 0) { + H5_FAILED(); + AT(); printf("H5Lexists error\n"); goto error; } - else if(link_exists == 1) { - if(expect_exist == false) { - H5_FAILED(); AT(); + else if (link_exists == 1) { + if (expect_exist == false) { + H5_FAILED(); + AT(); printf("This link should be moved or deleted but it still exists.\n"); goto error; - } + } } else if (link_exists == 0) { - if(expect_exist == true) { - H5_FAILED(); AT(); + if (expect_exist == true) { + H5_FAILED(); + AT(); printf("This link should exist but it is moved or deleted.\n"); goto error; - } + } } - if(link_storage >0) { - - if(s->old_style_grp) { - H5_FAILED(); AT(); + if (link_storage > 0) { + + if (s->old_style_grp) { + H5_FAILED(); + AT(); printf("Old style group doesn't support the indexed storage.\n"); goto error; } - if(H5Gget_info(obj_id,&group_info) <0) { - H5_FAILED(); AT(); + if (H5Gget_info(obj_id, &group_info) < 0) { + H5_FAILED(); + AT(); printf("H5Gget_info failed\n"); goto error; } - if(link_storage == 1) { - if(group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { - H5_FAILED(); AT(); + if (link_storage == 1) { + if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { + H5_FAILED(); + AT(); printf("The group link storage should be compact. \n"); goto error; } } else { - if(group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { - H5_FAILED(); AT(); + if (group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { + H5_FAILED(); + AT(); printf("The group link storage should be dense. \n"); goto 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) + if (s->use_named_pipes && s->grp_op_test == true) { + if (np_rd_send(s) == false) goto error; - dbgf(1, "Reader: finish sending back the message: %d\n",s->np_notify); - + dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); } return true; @@ -4475,13 +4533,12 @@ static bool vrfy_one_link_exist(state_t *s, 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); + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, false); error2: return false; - } /*------------------------------------------------------------------------- @@ -4491,10 +4548,10 @@ error2: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * used to generate the group name. * * Return: Success: true @@ -4502,18 +4559,19 @@ error2: * * Note: This is called by the verify_group_operations() function. *------------------------------------------------------------------------- -*/ + */ static bool -vrfy_delete_group(state_t *s, unsigned int which){ +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) { + 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); + ret_value = vrfy_one_link_exist(s, s->file, name, false, 0); } return ret_value; @@ -4526,131 +4584,134 @@ vrfy_delete_group(state_t *s, unsigned int which){ * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * hid_t obj_id * ID of the object this group is attached to * - * const char *name + * const char *name * The original group name * - * const char *newname + * const char *newname * The new group name * * unsigned int which - * The number of iterations for group creation + * 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){ +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; + hid_t g = H5I_INVALID_HID; H5G_info_t group_info; - int link_exists = 0; + 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 + * 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 (s->use_named_pipes && true == s->grp_op_test) { - if(false == np_rd_receive(s)) { - H5_FAILED(); AT(); + 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); - + dbgf(1, "reader: finish reading the message: %d\n", s->np_notify); } if (which >= s->nsteps) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("Number of created groups is out of bounds\n"); goto error; } - link_exists = H5Lexists(obj_id,name,H5P_DEFAULT); - if(link_exists<0) { - H5_FAILED(); AT(); + link_exists = H5Lexists(obj_id, name, H5P_DEFAULT); + if (link_exists < 0) { + H5_FAILED(); + AT(); printf("H5Lexists error\n"); goto error; } - else if(link_exists == 1) { - H5_FAILED(); AT(); + else if (link_exists == 1) { + H5_FAILED(); + AT(); printf("This link should be moved but it still exists.\n"); goto error; } - - if((g = H5Gopen(obj_id, newname, H5P_DEFAULT)) <0) { - H5_FAILED(); AT(); + if ((g = H5Gopen(obj_id, newname, H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); printf("H5Gopen failed\n"); goto error; } - if(H5Gget_info(g,&group_info) <0) { - H5_FAILED(); AT(); + if (H5Gget_info(g, &group_info) < 0) { + H5_FAILED(); + AT(); printf("H5Gget_info failed\n"); goto 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) { - H5_FAILED(); AT(); + + 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) { + H5_FAILED(); + AT(); printf("Reader - Old-styled group: but the group is not in old-style. \n"); goto error; } - dbgf(2,"Reader: verify that the group is created with the old-style.\n"); + 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) { - H5_FAILED(); AT(); + if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { + H5_FAILED(); + AT(); printf("Reader - The created group should NOT be in old-style . \n"); goto error; } - dbgf(2,"Reader: verify that the group is created with the new-style.\n"); - + dbgf(2, "Reader: verify that the group is created with the new-style.\n"); } if (H5Gclose(g) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Gclose failed\n"); goto error; } - /* Reader sends an OK message back to the reader */ - if(s->use_named_pipes && s->grp_op_test == true) { + if (s->use_named_pipes && s->grp_op_test == true) { - if(np_rd_send(s)==false) + if (np_rd_send(s) == false) goto error; - dbgf(1, "Reader: finish sending back the message: %d\n",s->np_notify); - + dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); } return true; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(g); - } H5E_END_TRY; + } + 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); + if (s->use_named_pipes && s->grp_op_test == true) + np_send_error(s, false); error2: @@ -4664,10 +4725,10 @@ error2: * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * used to generate the group name. * * Return: Success: true @@ -4675,22 +4736,22 @@ error2: * * Note: This is called by the verify_group_operations() function. *------------------------------------------------------------------------- -*/ + */ static bool -vrfy_move_group(state_t *s, unsigned int which){ +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) { + 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); + ret_value = vrfy_move_one_group(s, s->file, name, new_name, which); } return ret_value; - } /*------------------------------------------------------------------------- @@ -4700,10 +4761,10 @@ vrfy_move_group(state_t *s, unsigned int which){ * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * used to generate the group name. * * Return: Success: true @@ -4711,28 +4772,27 @@ vrfy_move_group(state_t *s, unsigned int which){ * * Note: This is called by the verify_group_operations() function. *------------------------------------------------------------------------- -*/ - + */ static bool -vrfy_insert_links(state_t *s, unsigned int which){ +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); + ret_value = vrfy_create_group(s, which); - if(ret_value == true) { + 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); + 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; - } /*------------------------------------------------------------------------- @@ -4742,10 +4802,10 @@ vrfy_insert_links(state_t *s, unsigned int which){ * * Parameters: state_t *s * The struct that stores information of HDF5 file, named pipe - * and some VFD SWMR configuration parameters + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * used to generate the group name. * * Return: Success: true @@ -4753,25 +4813,26 @@ vrfy_insert_links(state_t *s, unsigned int which){ * * Note: This is called by the verify_group_operations() function. *------------------------------------------------------------------------- -*/ + */ static bool -vrfy_delete_links(state_t *s, unsigned int which){ +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); + ret_value = vrfy_insert_links(s, which); /* Then if these links are deleted correctly. */ - if(ret_value == true) { + 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); + 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; @@ -4780,15 +4841,15 @@ vrfy_delete_links(state_t *s, unsigned int which){ /*------------------------------------------------------------------------- * Function: vrfy_transit_storage_compact_to_dense * - * Purpose: Verify if the link storage successfully transits from + * 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 + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * used to generate the group name. * * Return: Success: true @@ -4796,62 +4857,69 @@ vrfy_delete_links(state_t *s, unsigned int which){ * * Note: This is called by the verify_group_operations() function. *------------------------------------------------------------------------- -*/ + */ static bool -vrfy_transit_storage_compact_to_dense(state_t *s, unsigned int which){ +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")]; + 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) { - H5_FAILED(); AT(); + g = vrfy_create_group_id(s, which, false); + if (g < 0) { + H5_FAILED(); + AT(); printf("verify create_group_id failed\n"); goto error; } esnprintf(hd_name, sizeof(hd_name), "hd-group-%u", which); - if(vrfy_one_link_exist(s,g,hd_name,true,1) == false) { - H5_FAILED(); AT(); + if (vrfy_one_link_exist(s, g, hd_name, true, 1) == false) { + H5_FAILED(); + AT(); printf("verify the compact storage failed for 'link compact to dense' test\n"); goto error; } esnprintf(st_name, sizeof(st_name), "st-group-%u", which); - if(vrfy_one_link_exist(s,g,st_name,true,2) == false) { - H5_FAILED(); AT(); + if (vrfy_one_link_exist(s, g, st_name, true, 2) == false) { + H5_FAILED(); + AT(); printf("verify the dense link storage failed for 'link compact to dense' test\n"); goto error; } - if(vrfy_close_group_id(s, g) == false) { - H5_FAILED(); AT(); + if (vrfy_close_group_id(s, g) == false) { + H5_FAILED(); + AT(); printf("verify the group close for 'link compact to dense' test\n"); goto error; } return true; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(g); - } H5E_END_TRY; + } + H5E_END_TRY; return false; } /*------------------------------------------------------------------------- * Function: vrfy_transit_storage_dense_to_compact * - * Purpose: Verify if the link storage successfully transits from + * 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 + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * used to generate the group name. * * Return: Success: true @@ -4859,90 +4927,98 @@ error: * * Note: This is called by the verify_group_operations() function. *------------------------------------------------------------------------- -*/ - + */ static bool -vrfy_transit_storage_dense_to_compact(state_t *s, unsigned int which){ +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")]; + 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) { - H5_FAILED(); AT(); + g = vrfy_create_group_id(s, which, true); + if (g < 0) { + H5_FAILED(); + AT(); printf("verify create_group_id failed\n"); goto 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) { - H5_FAILED(); AT(); + if (vrfy_one_link_exist(s, g, hd_name, true, 1) == false) { + H5_FAILED(); + AT(); printf("verify the compact storage failed for 'link compact to dense' test\n"); goto 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) { - H5_FAILED(); AT(); + if (vrfy_one_link_exist(s, g, st_name, true, 1) == false) { + H5_FAILED(); + AT(); printf("verify the compact link storage failed for 'link compact to dense' test\n"); goto 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) { - H5_FAILED(); AT(); + if (vrfy_one_link_exist(s, g, st2_name, true, 2) == false) { + H5_FAILED(); + AT(); printf("verify the dense link storage failed for 'link compact to dense' test\n"); goto 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) { - H5_FAILED(); AT(); + if (vrfy_one_link_exist(s, g, st_name, false, 2) == false) { + H5_FAILED(); + AT(); printf("verify the dense link storage failed for 'link compact to dense' test\n"); goto 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) { - H5_FAILED(); AT(); + if (vrfy_one_link_exist(s, g, st2_name, false, 1) == false) { + H5_FAILED(); + AT(); printf("verify the compact link storage failed for 'link compact to dense' test\n"); goto error; } - if(vrfy_close_group_id(s, g) == false) { - H5_FAILED(); AT(); + if (vrfy_close_group_id(s, g) == false) { + H5_FAILED(); + AT(); printf("verify the group close for 'link compact to dense' test\n"); goto error; } return true; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(g); - } H5E_END_TRY; + } + H5E_END_TRY; return false; - } /*------------------------------------------------------------------------- * Function: verify_group_operations * - * Purpose: verify the success of group creation and + * 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 + * and some VFD SWMR configuration parameters * * unsigned int which - * The number of iterations for group creation + * The number of iterations for group creation * * * Return: Success: true @@ -4950,13 +5026,12 @@ error: * * Note: This is called by the main() function. *------------------------------------------------------------------------- -*/ - + */ static bool verify_group_operations(state_t *s, unsigned int which) { - bool ret_value = false; + bool ret_value = false; char test_pattern = s->grp_op_pattern; switch (test_pattern) { @@ -4987,44 +5062,40 @@ verify_group_operations(state_t *s, unsigned int 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; + 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; + 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)) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("state_init failed\n"); goto error; } personality = HDstrstr(s.progname, "vfd_swmr_group_"); - if (personality != NULL && - HDstrcmp(personality, "vfd_swmr_group_writer") == 0) + if (personality != NULL && HDstrcmp(personality, "vfd_swmr_group_writer") == 0) writer = true; - else if (personality != NULL && - HDstrcmp(personality, "vfd_swmr_group_reader") == 0) + else if (personality != NULL && HDstrcmp(personality, "vfd_swmr_group_reader") == 0) writer = false; else { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("unknown personality, expected vfd_swmr_group_{reader,writer}\n"); goto error; } @@ -5034,23 +5105,26 @@ main(int argc, char **argv) /* 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) + * 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) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("vfd_swmr_create_fapl failed\n"); goto error; } if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Pcreate failed\n"); goto error; } if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, false, 1) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Pset_file_space_strategy failed\n"); goto error; } @@ -5061,7 +5135,8 @@ main(int argc, char **argv) s.file = H5Fopen(s.filename, H5F_ACC_RDONLY, fapl); if (s.file < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("H5Fcreate/open failed\n"); goto error; } @@ -5073,53 +5148,56 @@ main(int argc, char **argv) if (s.use_named_pipes && writer) { /* Writer creates two named pipes(FIFO) */ if (HDmkfifo(fifo_writer_to_reader, 0600) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDmkfifo failed\n"); goto error; } if (HDmkfifo(fifo_reader_to_writer, 0600) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDmkfifo failed\n"); goto 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) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDopen failed\n"); goto error; } if (s.use_named_pipes && (fd_reader_to_writer = HDopen(fifo_reader_to_writer, O_RDWR)) < 0) { - H5_FAILED(); AT(); + H5_FAILED(); + AT(); printf("HDopen failed\n"); goto error; } /* Pass the named pipe information to the struct of state_t s, for attribute tests.*/ - if(s.use_named_pipes) { + 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; + 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. + /* 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; + 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 (s.grp_op_test && s.use_named_pipes) + s.csteps = 1; if (writer) { for (step = 0; step < s.nsteps; step++) { @@ -5133,19 +5211,19 @@ main(int argc, char **argv) printf("write_group failed at step %d\n", step); /* At communication interval, notifies the reader about the failture 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); + if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && step % s.csteps == 0) + np_send_error(&s, true); goto 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 (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && + step % s.csteps == 0) { - if(np_wr_send_receive(&s) == false) { - H5_FAILED(); AT(); + if (np_wr_send_receive(&s) == false) { + H5_FAILED(); + AT(); printf("writer: write group - verification failed.\n"); goto error; } @@ -5157,11 +5235,12 @@ main(int argc, char **argv) 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)) { - H5_FAILED(); AT(); + /* 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)) { + H5_FAILED(); + AT(); goto error; } } @@ -5175,21 +5254,21 @@ main(int argc, char **argv) if (vg_ret == false) { printf("verify_group_operations failed\n"); - H5_FAILED(); AT(); + H5_FAILED(); + AT(); /* 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); + if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && step % s.csteps == 0) + np_send_error(&s, false); goto 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) + if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && + step % s.csteps == 0) { + if (np_rd_send(&s) == false) goto error; } } -- cgit v0.12 From 8798c8cac9f98a54f64481d27bfef6b519cac0f6 Mon Sep 17 00:00:00 2001 From: Muqun Yang Date: Wed, 19 May 2021 14:36:08 -0500 Subject: Add the object header continuation block tests. --- test/testvfdswmr.sh.in | 9 +- test/vfd_swmr_group_writer.c | 276 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 276 insertions(+), 9 deletions(-) diff --git a/test/testvfdswmr.sh.in b/test/testvfdswmr.sh.in index 146523c..4885d94 100644 --- a/test/testvfdswmr.sh.in +++ b/test/testvfdswmr.sh.in @@ -732,12 +732,15 @@ grp_attr_list=( "add-vstr" "remove-vstr" "modify-vstr" + "add-ohr-block" + "del-ohr-block" ) grp_sub_attr_list=( "dense-del-to-compact" "modify" "remove-vstr" "modify-vstr" + "del-ohr-block" ) grp_short_sub_attr_list=( @@ -745,6 +748,7 @@ grp_short_sub_attr_list=( "modify" "remove-vstr" "modify-vstr" + "del-ohr-block" ) if [[ "$HDF5TestExpress" -eq 1 ]] ; then #Setting for standard run @@ -805,11 +809,14 @@ os_grp_attr_list=( "add-vstr" "remove-vstr" "modify-vstr" - ) + "add-ohr-block" + "del-ohr-block" + ) os_grp_sub_attr_list=( "modify" "remove-vstr" "modify-vstr" + "del-ohr-block" ) if [[ "$HDF5TestExpress" -gt 0 ]] ; then #Setting for standard run os_grp_attr_list=("${os_grp_sub_attr_list[@]}") diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index 2f82404..dea7e89 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -105,6 +105,15 @@ usage(const char *progname) " 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" @@ -247,6 +256,10 @@ state_init(state_t *s, int argc, char **argv) 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 { H5_FAILED(); AT(); @@ -470,6 +483,63 @@ np_send_error(state_t *s, bool writer) } /*------------------------------------------------------------------------- + * 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) { + H5_FAILED() + AT(); + printf("H5Oget_native_info failed\n"); + goto error; + } + + if(true == one_chunk_ohr) { + if (ninfo.hdr.nchunks != 1) { + H5_FAILED(); + AT(); + printf("Object header should have only one chunk,but it is not.\n"); + goto error; + } + } + else { + if (ninfo.hdr.nchunks <= 1) { + H5_FAILED(); + AT(); + printf("Object header should have more than one chunk,but it is not.\n"); + goto error; + } + } + + return true; + +error: + return false; +} + + +/*------------------------------------------------------------------------- * Function: add_attr * * Purpose: Add attributes to a group. @@ -554,6 +624,18 @@ add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const ch goto 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)) { + H5_FAILED(); + AT(); + printf("An object header continuation block should be created. \n"); + printf("But it is not.\n"); + goto 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) { @@ -618,7 +700,8 @@ error2: * Failure: false * * Note: This function is used for the "dense" storage test. - * It is also used by the group-only test. + * It is also used by the group-only, "add-ohr-block" + * and "del-ohr-block" tests. *------------------------------------------------------------------------- */ @@ -776,8 +859,9 @@ error2: * bool is_dense * if the deleted attribute is for checking the dense storage * - * bool is_vl - * if the deleted attribute is a VL string + * 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 @@ -795,7 +879,7 @@ error2: */ static bool -del_one_attr(state_t *s, hid_t obj_id, bool is_dense, bool is_vl, unsigned int which) +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]; @@ -806,7 +890,8 @@ del_one_attr(state_t *s, hid_t obj_id, bool is_dense, bool is_vl, unsigned int w /*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 operation */ + /*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"); @@ -814,7 +899,7 @@ del_one_attr(state_t *s, hid_t obj_id, bool is_dense, bool is_vl, unsigned int w /* Construct the attribute name */ if (is_dense == true) HDsprintf(attrname, aname_format_d, which, 0); - else if (is_vl == true) + else if (is_vl_or_ohrc == true) HDsprintf(attrname, aname_format_vl, which, 0); else HDsprintf(attrname, aname_format, which, 0); @@ -827,6 +912,16 @@ del_one_attr(state_t *s, hid_t obj_id, bool is_dense, bool is_vl, unsigned int w goto 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)) { + H5_FAILED(); + AT(); + printf("The object header chunk should not continue. \n"); + goto 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) { @@ -1580,7 +1675,7 @@ add_del_attrs_compact_dense_compact(state_t *s, hid_t g, hid_t gcpl, unsigned in * Return: Success: true * Failure: false * - * Note: This function is used for the "modify" storage test. + * Note: This function is used for the "modify" test. *------------------------------------------------------------------------- */ @@ -1597,6 +1692,45 @@ add_modify_default_group_attr(state_t *s, hid_t g, unsigned int which) } /*------------------------------------------------------------------------- + * 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 @@ -1659,6 +1793,10 @@ add_group_attribute(state_t *s, hid_t g, hid_t gcpl, unsigned int which) 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: @@ -1694,6 +1832,7 @@ 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; @@ -1736,6 +1875,15 @@ write_group(state_t *s, unsigned int which) goto error; } + /* We need to create a dummy dataset for the object header contiuation 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){ + H5_FAILED(); + AT(); + printf("H5Dcreate2 failed\n"); + goto error; + } + } if (H5Gget_info(g, &group_info) < 0) { H5_FAILED(); AT(); @@ -1761,6 +1909,19 @@ write_group(state_t *s, unsigned int which) } 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)) { + H5_FAILED(); + AT(); + printf("An object header continuation block should NOT be created. \n"); + printf("But it is created.\n"); + goto 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 @@ -1778,11 +1939,20 @@ write_group(state_t *s, unsigned int which) 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) { + H5_FAILED(); + AT(); + printf("H5Dclose failed\n"); + goto error; + } + } if (H5Gclose(g) < 0) { H5_FAILED(); AT(); @@ -1808,6 +1978,8 @@ error2: H5E_BEGIN_TRY { + if (s->at_pattern == 'a' || s->at_pattern == 'R') + H5Dclose(dummy_d); H5Gclose(g); if (!s->old_style_grp) H5Pclose(gcpl); @@ -1872,6 +2044,7 @@ error: return false; } + /*------------------------------------------------------------------------- * Function: vrfy_attr * @@ -1984,6 +2157,19 @@ vrfy_attr(state_t *s, hid_t g, unsigned int which, const char *aname, unsigned i 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)) { + H5_FAILED(); + AT(); + 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"); + goto 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) @@ -2028,7 +2214,8 @@ error2: * Failure: false * * Note: This function is used for the "dense" storage test. - * It is also used by the group-only test. + * It is also used by the group-only, "add-ohr-block" + * and "del-ohr-block" tests. *------------------------------------------------------------------------- */ @@ -2410,6 +2597,19 @@ verify_del_one_attr(state_t *s, hid_t g, const char *aname, bool check_storage, 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)) { + H5_FAILED(); + AT(); + 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"); + goto 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) @@ -2793,6 +2993,47 @@ verify_del_attrs_compact_dense_compact(state_t *s, hid_t g, unsigned max_c, unsi } /*------------------------------------------------------------------------- + * 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 @@ -2867,6 +3108,8 @@ verify_group_attribute(state_t *s, hid_t g, unsigned int which) case 'M': case 'm': case 'r': + case 'a': + case 'R': case ' ': default: break; @@ -2901,6 +3144,10 @@ verify_group_attribute(state_t *s, hid_t g, unsigned int which) 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: @@ -3007,6 +3254,19 @@ verify_group(state_t *s, unsigned int which) 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)) { + H5_FAILED(); + AT(); + 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"); + goto error; + } + } + /* Reader sends an OK message back to the writer */ if(s->use_named_pipes && s->attr_test == true) { -- cgit v0.12 From 2f2a75aefb348dacd6ac48dcdba5f6a16232ef6d Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 19 May 2021 19:47:11 +0000 Subject: Committing clang-format changes --- test/vfd_swmr_group_writer.c | 209 +++++++++++++++++++++---------------------- 1 file changed, 104 insertions(+), 105 deletions(-) diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index 96489e1..d0e35ee 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -63,73 +63,74 @@ typedef struct { 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", + 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); } @@ -488,9 +489,9 @@ np_send_error(state_t *s, bool writer) * bool one_chunk_ohr * flag to indicate if the object header chunk is 1 or greater * 1: true - * greater than 1: false + * greater than 1: false * - * Return: Success: true + * Return: Success: true * Failure: false * *------------------------------------------------------------------------- @@ -510,7 +511,7 @@ check_ohr_num_chunk(hid_t g, bool one_chunk_ohr) goto error; } - if(true == one_chunk_ohr) { + if (true == one_chunk_ohr) { if (ninfo.hdr.nchunks != 1) { H5_FAILED(); AT(); @@ -533,7 +534,6 @@ error: return false; } - /*------------------------------------------------------------------------- * Function: add_attr * @@ -621,8 +621,8 @@ add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const ch /* 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)) { + if (s->at_pattern == 'a' || s->at_pattern == 'R') { + if (false == check_ohr_num_chunk(oid, false)) { H5_FAILED(); AT(); printf("An object header continuation block should be created. \n"); @@ -855,7 +855,7 @@ error2: * 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 + * if the deleted attribute is a VL string or for object header * continuation check test * * unsigned int which @@ -885,7 +885,7 @@ del_one_attr(state_t *s, hid_t obj_id, bool is_dense, bool is_vl_or_ohrc, unsign /*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 + /*attribute name template used for VL string attribute deletion * or object header continuation check operations */ const char *aname_format_vl = "attr-%u"; @@ -910,7 +910,7 @@ del_one_attr(state_t *s, hid_t obj_id, bool is_dense, bool is_vl_or_ohrc, unsign /* 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)) { + if (false == check_ohr_num_chunk(obj_id, true)) { H5_FAILED(); AT(); printf("The object header chunk should not continue. \n"); @@ -1710,7 +1710,7 @@ add_modify_default_group_attr(state_t *s, hid_t g, unsigned int which) * Return: Success: true * Failure: false * - * Note: This function is used for the + * Note: This function is used for the * "deletion of object header continuation block" test. *------------------------------------------------------------------------- */ @@ -1719,10 +1719,10 @@ 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); + 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); + ret_value = del_one_attr(s, g, false, true, which); return ret_value; } /*------------------------------------------------------------------------- @@ -1826,10 +1826,10 @@ 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; + 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; if (which >= s->nsteps) { @@ -1871,8 +1871,9 @@ write_group(state_t *s, unsigned int which) } /* We need to create a dummy dataset for the object header contiuation 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){ + 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) { H5_FAILED(); AT(); printf("H5Dcreate2 failed\n"); @@ -1907,8 +1908,8 @@ write_group(state_t *s, unsigned int which) /* 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)) { + if (s->at_pattern == 'a' || s->at_pattern == 'R') { + if (false == check_ohr_num_chunk(g, true)) { H5_FAILED(); AT(); printf("An object header continuation block should NOT be created. \n"); @@ -1934,13 +1935,12 @@ write_group(state_t *s, unsigned int which) 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 (s->at_pattern == 'a' || s->at_pattern == 'R') { if (H5Dclose(dummy_d) < 0) { H5_FAILED(); AT(); @@ -2039,7 +2039,6 @@ error: return false; } - /*------------------------------------------------------------------------- * Function: vrfy_attr * @@ -2156,8 +2155,8 @@ vrfy_attr(state_t *s, hid_t g, unsigned int which, const char *aname, unsigned i /* 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)) { + if (s->at_pattern == 'a' || s->at_pattern == 'R') { + if (false == check_ohr_num_chunk(g, false)) { H5_FAILED(); AT(); printf("An object header continuation block should be created. \n"); @@ -2598,8 +2597,8 @@ verify_del_one_attr(state_t *s, hid_t g, const char *aname, bool check_storage, /* 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)) { + if (s->at_pattern == 'R') { + if (false == check_ohr_num_chunk(g, true)) { H5_FAILED(); AT(); printf("An object header continuation block should be removed. \n"); @@ -2993,10 +2992,10 @@ verify_del_attrs_compact_dense_compact(state_t *s, hid_t g, unsigned max_c, unsi /*------------------------------------------------------------------------- * 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 + * 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 @@ -3017,19 +3016,19 @@ verify_del_attrs_compact_dense_compact(state_t *s, hid_t g, unsigned max_c, unsi */ static bool -verify_del_ohr_block_attr(state_t *s, hid_t g, unsigned int which) { +verify_del_ohr_block_attr(state_t *s, hid_t g, unsigned int which) +{ - bool ret_value = false; + 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); + 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); + ret_value = verify_del_one_attr(s, g, attrname, false, true); } return ret_value; - } /*------------------------------------------------------------------------- * Function: verify_group_attribute @@ -3254,8 +3253,8 @@ verify_group(state_t *s, unsigned int which) /* 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)) { + if (s->at_pattern == 'a' || s->at_pattern == 'R') { + if (false == check_ohr_num_chunk(g, true)) { H5_FAILED(); AT(); printf("An object header continuation block should NOT be created. \n"); -- cgit v0.12 From 4658fef3a0ec416b40482dba3bf63e6c9d22aa47 Mon Sep 17 00:00:00 2001 From: Muqun Yang Date: Fri, 21 May 2021 14:43:48 -0500 Subject: use TEST_ERROR when possible --- test/vfd_swmr_group_writer.c | 885 ++++++++++++------------------------------- 1 file changed, 236 insertions(+), 649 deletions(-) diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index d0e35ee..56efae8 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -147,10 +147,8 @@ state_init(state_t *s, int argc, char **argv) *s = ALL_HID_INITIALIZER; if (H5_basename(argv[0], &tfile) < 0) { - H5_FAILED(); - AT(); printf("H5_basename failed\n"); - goto error; + TEST_ERROR; } esnprintf(s->progname, sizeof(s->progname), "%s", tfile); @@ -173,22 +171,16 @@ state_init(state_t *s, int argc, char **argv) errno = 0; tmp = HDstrtoul(optarg, &end, 0); if (end == optarg || *end != '\0') { - H5_FAILED(); - AT(); printf("couldn't parse `-%c` argument `%s`\n", ch, optarg); - goto error; + TEST_ERROR; } else if (errno != 0) { - H5_FAILED(); - AT(); printf("couldn't parse `-%c` argument `%s`\n", ch, optarg); - goto error; + TEST_ERROR; } else if (tmp > UINT_MAX) { - H5_FAILED(); - AT(); printf("`-%c` argument `%lu` too large\n", ch, tmp); - goto error; + TEST_ERROR; } if (ch == 'a') @@ -222,10 +214,8 @@ state_init(state_t *s, int argc, char **argv) else if (HDstrcmp(optarg, "grp-dense-t-compact") == 0) s->grp_op_pattern = 'T'; else { - H5_FAILED(); - AT(); printf("Invalid -O argument \"%s\"", optarg); - goto error; + TEST_ERROR; } break; case 'A': @@ -254,10 +244,8 @@ state_init(state_t *s, int argc, char **argv) else if (HDstrcmp(optarg, "del-ohr-block") == 0) s->at_pattern = 'R'; else { - H5_FAILED(); - AT(); printf("Invalid -A argument \"%s\"", optarg); - goto error; + TEST_ERROR; } break; case 'q': @@ -279,10 +267,8 @@ state_init(state_t *s, int argc, char **argv) if (!s->grp_op_test) { if (s->asteps < 1 || s->asteps > s->nsteps) { - H5_FAILED(); - AT(); printf("attribute interval is out of bounds\n"); - goto error; + TEST_ERROR; } } @@ -292,25 +278,19 @@ state_init(state_t *s, int argc, char **argv) } if (s->csteps < 1 || s->csteps > s->nsteps) { - H5_FAILED(); - AT(); printf("communication interval is out of bounds\n"); - goto error; + TEST_ERROR; } if (argc > 0) { - H5_FAILED(); - AT(); printf("unexpected command-line arguments\n"); - goto error; + TEST_ERROR; } /* space for attributes */ if ((s->one_by_one_sid = H5Screate_simple(1, &dims, &dims)) < 0) { - H5_FAILED(); - AT(); printf("H5Screate_simple failed\n"); - goto error; + TEST_ERROR; } esnprintf(s->filename, sizeof(s->filename), "vfd_swmr_group.h5"); @@ -343,10 +323,8 @@ np_wr_send_receive(state_t *s) /* 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) { - H5_FAILED(); - AT(); printf("HDwrite failed\n"); - goto error; + TEST_ERROR; } /* During the wait, writer makes repeated HDF5 API calls @@ -364,24 +342,18 @@ np_wr_send_receive(state_t *s) * going to the next step */ (s->np_verify)++; if (HDread(s->np_fd_r_to_w, &(s->np_notify), sizeof(int)) < 0) { - H5_FAILED(); - AT(); printf("HDread failed\n"); - goto error; + TEST_ERROR; } if (s->np_notify == -1) { - H5_FAILED(); - AT(); printf("reader failed to verify group or attribute operation.\n"); - goto error; + TEST_ERROR; } if (s->np_notify != s->np_verify) { - H5_FAILED(); - AT(); printf("received message %d, expecting %d\n", s->np_notify, s->np_verify); - goto error; + TEST_ERROR; } return true; @@ -412,24 +384,18 @@ np_rd_receive(state_t *s) /* Receive the notify that the writer bumped up the value */ if (HDread(s->np_fd_w_to_r, &(s->np_notify), sizeof(int)) < 0) { - H5_FAILED(); - AT(); printf("HDread failed\n"); - goto error; + TEST_ERROR; } if (s->np_notify == -1) { - H5_FAILED(); - AT(); printf("writer failed to create group or carry out an attribute operation.\n"); - goto error; + TEST_ERROR; } if (s->np_notify != s->np_verify) { - H5_FAILED(); - AT(); printf("received message %d, expecting %d\n", s->np_notify, s->np_verify); - goto error; + TEST_ERROR; } return true; @@ -505,26 +471,20 @@ check_ohr_num_chunk(hid_t g, bool one_chunk_ohr) /* Get the object information */ if (H5Oget_native_info(g, &ninfo, H5O_NATIVE_INFO_HDR) < 0) { - H5_FAILED() - AT(); printf("H5Oget_native_info failed\n"); - goto error; + TEST_ERROR; } if (true == one_chunk_ohr) { if (ninfo.hdr.nchunks != 1) { - H5_FAILED(); - AT(); printf("Object header should have only one chunk,but it is not.\n"); - goto error; + TEST_ERROR; } } else { if (ninfo.hdr.nchunks <= 1) { - H5_FAILED(); - AT(); printf("Object header should have more than one chunk,but it is not.\n"); - goto error; + TEST_ERROR; } } @@ -581,10 +541,8 @@ add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const ch /* Need to obtain native datatype for H5Aread */ if ((amtype = H5Tget_native_type(atype, H5T_DIR_ASCEND)) < 0) { - H5_FAILED(); - AT(); printf("H5Tget_native_type failed\n"); - goto error; + TEST_ERROR; } for (u = 0; u < num_attrs; u++) { @@ -593,10 +551,8 @@ add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const ch /* 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) { - H5_FAILED(); - AT(); printf("H5Acreate2 failed\n"); - goto error; + TEST_ERROR; } attr_value = u + which; @@ -605,29 +561,23 @@ add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const ch /* Write data into the attribute */ if (H5Awrite(aid, amtype, &attr_value) < 0) { - H5_FAILED(); - AT(); printf("H5Awrite failed\n"); - goto error; + TEST_ERROR; } /* Close attribute */ if (H5Aclose(aid) < 0) { - H5_FAILED(); - AT(); printf("H5Aclose failed\n"); - goto error; + 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)) { - H5_FAILED(); - AT(); printf("An object header continuation block should be created. \n"); printf("But it is not.\n"); - goto error; + TEST_ERROR; } } @@ -638,7 +588,7 @@ add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const ch if (np_wr_send_receive(s) == false) { H5_FAILED(); AT(); - dbgf(2, "writer: write attr - verification failed.\n"); + 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. */ @@ -649,9 +599,7 @@ add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const ch } /* end for */ if (H5Tclose(amtype) < 0) { - H5_FAILED(); - AT(); - goto error; + TEST_ERROR; } return true; @@ -750,10 +698,8 @@ add_vlstr_attr(state_t *s, hid_t g, unsigned int which) /* Allocate buffer for the VL string value */ astr_val = HDmalloc(VS_ATTR_NAME_LEN); if (astr_val == NULL) { - H5_FAILED(); - AT(); printf("Allocate memory for VL string failed.\n"); - goto error; + TEST_ERROR; } /* Assign the VL string value and the attribute name.. */ @@ -764,45 +710,33 @@ add_vlstr_attr(state_t *s, hid_t g, unsigned int which) /* Create a datatype to refer to. */ if ((atype = H5Tcopy(H5T_C_S1)) < 0) { - H5_FAILED(); - AT(); printf("Cannot create variable length datatype.\n"); - goto error; + TEST_ERROR; } if (H5Tset_size(atype, H5T_VARIABLE) < 0) { - H5_FAILED(); - AT(); printf("Cannot set variable length datatype.\n"); - goto error; + TEST_ERROR; } /* Generate the VL string attribute.*/ if ((aid = H5Acreate2(g, name, atype, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - AT(); printf("H5Acreate2 failed.\n"); - goto error; + TEST_ERROR; } if (H5Awrite(aid, atype, &astr_val) < 0) { - H5_FAILED(); - AT(); printf("H5Awrite failed.\n"); - goto error; + TEST_ERROR; } if (H5Tclose(atype) < 0) { - H5_FAILED(); - AT(); printf("H5Tclose() failed\n"); - goto error; + TEST_ERROR; } if (H5Aclose(aid) < 0) { - H5_FAILED(); - AT(); printf("H5Aclose() failed\n"); - goto error; + TEST_ERROR; } HDfree(astr_val); @@ -901,20 +835,16 @@ del_one_attr(state_t *s, hid_t obj_id, bool is_dense, bool is_vl_or_ohrc, unsign /* Delete the attribute */ if (H5Adelete(obj_id, attrname) < 0) { - H5_FAILED(); - AT(); printf("H5Adelete() failed\n"); - goto error; + 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)) { - H5_FAILED(); - AT(); printf("The object header chunk should not continue. \n"); - goto error; + TEST_ERROR; } } /* Writer sends a message to reader: an attribute is successfully generated. @@ -1017,37 +947,29 @@ modify_attr(state_t *s, hid_t g, const char *aname_fmt, unsigned int which) HDsprintf(attrname, aname_fmt, which, 0); if ((aid = H5Aopen(g, attrname, H5P_DEFAULT)) < 0) { - H5_FAILED(); - AT(); printf("H5Aopen failed\n"); - goto error; + TEST_ERROR; } if ((amtype = H5Tget_native_type(s->filetype, H5T_DIR_ASCEND)) < 0) { - H5_FAILED(); - AT(); printf("H5Tget_native_type failed\n"); - goto error; + TEST_ERROR; } /* Make a large number to verify the change easily */ modify_value = which + 10000; if (H5Awrite(aid, amtype, &modify_value) < 0) { - H5_FAILED(); - AT(); printf("H5Awrite failed\n"); - goto error; + TEST_ERROR; } if (H5Tclose(amtype) < 0) { - H5_FAILED(); - AT(); - goto error; + printf("H5Tclose failed\n"); + TEST_ERROR; } if (H5Aclose(aid) < 0) { - H5_FAILED(); - AT(); - goto error; + printf("H5Aclose failed\n"); + TEST_ERROR; } /* Writer sends a message to reader: an attribute is successfully modified. @@ -1115,10 +1037,8 @@ modify_vlstr_attr(state_t *s, hid_t g, unsigned int which) astr_val = HDmalloc(VS_ATTR_NAME_LEN); if (astr_val == NULL) { - H5_FAILED(); - AT(); printf("Allocate memory for VL string failed.\n"); - goto error; + TEST_ERROR; } /* Change the VL string value and create the attribute name. */ @@ -1129,48 +1049,36 @@ modify_vlstr_attr(state_t *s, hid_t g, unsigned int which) /* Create a datatype to refer to. */ if ((atype = H5Tcopy(H5T_C_S1)) < 0) { - H5_FAILED(); - AT(); printf("Cannot create variable length datatype.\n"); - goto error; + TEST_ERROR; } if (H5Tset_size(atype, H5T_VARIABLE) < 0) { - H5_FAILED(); - AT(); printf("Cannot set variable length datatype.\n"); - goto error; + TEST_ERROR; } /* Open this attribute. */ if ((aid = H5Aopen(g, name, H5P_DEFAULT)) < 0) { - H5_FAILED(); - AT(); printf("H5Aopen failed.\n"); - goto error; + TEST_ERROR; } dbgf(1, "The modified VL string value is %s \n", astr_val); if (H5Awrite(aid, atype, &astr_val) < 0) { - H5_FAILED(); - AT(); printf("H5Awrite failed.\n"); - goto error; + TEST_ERROR; } if (H5Tclose(atype) < 0) { - H5_FAILED(); - AT(); printf("H5Tclose() failed\n"); - goto error; + TEST_ERROR; } if (H5Aclose(aid) < 0) { - H5_FAILED(); - AT(); printf("H5Aclose() failed\n"); - goto error; + TEST_ERROR; } HDfree(astr_val); @@ -1294,10 +1202,8 @@ add_attrs_compact(state_t *s, hid_t g, hid_t gcpl, unsigned int which) * storage and the minimal number of attributes to be stored in * dense storage. */ if (H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { - H5_FAILED(); - AT(); printf("H5Pget_attr_phase_change() failed\n"); - goto error; + TEST_ERROR; } } @@ -1352,10 +1258,8 @@ add_attrs_compact_dense(state_t *s, hid_t g, hid_t gcpl, unsigned int which) bool ret_value = false; if (H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { - H5_FAILED(); - AT(); printf("H5Pget_attr_phase_change failed\n"); - goto error; + TEST_ERROR; } /* Add attributes, until just before converting to dense storage */ @@ -1421,10 +1325,8 @@ del_attrs_compact_dense_compact(state_t *s, hid_t obj_id, hid_t gcpl, unsigned i * storage and the minimal number of attributes to be stored in * dense storage. */ if (H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { - H5_FAILED(); - AT(); printf("H5Pget_attr_phase_change failed\n"); - goto error; + TEST_ERROR; } u = max_compact + 1; @@ -1432,10 +1334,8 @@ del_attrs_compact_dense_compact(state_t *s, hid_t obj_id, hid_t gcpl, unsigned i for (u--; u >= (min_dense - 1); u--) { HDsprintf(attrname, aname_format, which, max_compact - u); if (H5Adelete(obj_id, attrname) < 0) { - H5_FAILED(); - AT(); printf("H5Adelete failed\n"); - goto error; + TEST_ERROR; } /* For each attribute deletion, we want to ensure the verification @@ -1463,10 +1363,8 @@ del_attrs_compact_dense_compact(state_t *s, hid_t obj_id, hid_t gcpl, unsigned i HDsprintf(attrname, adname_format, max_compact + which, 0); if (H5Adelete(obj_id, attrname) < 0) { - H5_FAILED(); - AT(); printf("H5Adelete failed\n"); - goto error; + TEST_ERROR; } /* Again we need to notify the reader via Named pipe. */ if (s->use_named_pipes && s->attr_test == true) { @@ -1585,10 +1483,8 @@ add_del_attrs_compact_dense(state_t *s, hid_t g, hid_t gcpl, unsigned int which) unsigned min_dense = 0; if (H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { - H5_FAILED(); - AT(); printf("H5Pget_attr_phase_change failed\n"); - goto error; + TEST_ERROR; } ret_value = add_attrs_compact_dense(s, g, gcpl, which); @@ -1833,10 +1729,8 @@ write_group(state_t *s, unsigned int which) H5G_info_t group_info; if (which >= s->nsteps) { - H5_FAILED(); - AT(); printf("Number of created groups is out of bounds\n"); - goto error; + TEST_ERROR; } esnprintf(name, sizeof(name), "/group-%u", which); @@ -1846,62 +1740,48 @@ write_group(state_t *s, unsigned int which) else { gcpl = H5Pcreate(H5P_GROUP_CREATE); if (gcpl < 0) { - H5_FAILED(); - AT(); printf("H5Pcreate failed\n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("H5Pset_attr_phase_change failed for the dense storage.\n"); - goto error; + TEST_ERROR; } } } if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) { - H5_FAILED(); - AT(); printf("H5Gcreate2 failed\n"); - goto error; + TEST_ERROR; } - /* We need to create a dummy dataset for the object header contiuation block test. */ + /* 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) { - H5_FAILED(); - AT(); printf("H5Dcreate2 failed\n"); - goto error; + TEST_ERROR; } } if (H5Gget_info(g, &group_info) < 0) { - H5_FAILED(); - AT(); printf("H5Gget_info failed\n"); - goto error; + TEST_ERROR; } if (s->old_style_grp) { if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { - H5_FAILED(); - AT(); printf("Old-styled group test: but the group is not in old-style. \n"); - goto error; + TEST_ERROR; } dbgf(2, "Writer: group is created with the old-style.\n"); } else { if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { - H5_FAILED(); - AT(); printf("The created group should NOT be in old-style . \n"); - goto error; + TEST_ERROR; } dbgf(2, "Writer: group is created with the new-style.\n"); } @@ -1910,11 +1790,9 @@ write_group(state_t *s, unsigned int which) * 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)) { - H5_FAILED(); - AT(); printf("An object header continuation block should NOT be created. \n"); printf("But it is created.\n"); - goto error; + TEST_ERROR; } } @@ -1942,24 +1820,18 @@ write_group(state_t *s, unsigned int which) if (s->at_pattern == 'a' || s->at_pattern == 'R') { if (H5Dclose(dummy_d) < 0) { - H5_FAILED(); - AT(); printf("H5Dclose failed\n"); - goto error; + TEST_ERROR; } } if (H5Gclose(g) < 0) { - H5_FAILED(); - AT(); printf("H5Gclose failed\n"); - goto error; + TEST_ERROR; } if (!s->old_style_grp && H5Pclose(gcpl) < 0) { - H5_FAILED(); - AT(); printf("H5Pclose failed\n"); - goto error; + TEST_ERROR; } return result; @@ -2010,26 +1882,20 @@ check_attr_storage_type(hid_t g, bool is_compact) /* Get the object information */ if (H5Oget_native_info(g, &ninfo, H5O_NATIVE_INFO_HDR | H5O_NATIVE_INFO_META_SIZE) < 0) { - H5_FAILED(); - AT(); printf("H5Oget_native_info failed\n"); - goto error; + TEST_ERROR; } if (is_compact) { if (ninfo.meta_size.attr.index_size != 0 || ninfo.meta_size.attr.heap_size != 0) { - H5_FAILED(); - AT(); printf("Should be in compact storage,but it is not.\n"); - goto error; + TEST_ERROR; } } else { if (ninfo.meta_size.attr.index_size == 0 || ninfo.meta_size.attr.heap_size == 0) { - H5_FAILED(); - AT(); printf("Should be in dense storage,but it is not.\n"); - goto error; + TEST_ERROR; } } @@ -2107,48 +1973,36 @@ vrfy_attr(state_t *s, hid_t g, unsigned int which, const char *aname, unsigned i 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) { - H5_FAILED(); - AT(); printf("H5Tget_native_type failed\n"); - goto error; + TEST_ERROR; } if ((aid = H5Aopen(g, aname, H5P_DEFAULT)) < 0) { - H5_FAILED(); - AT(); printf("H5Aopen failed\n"); - goto error; + TEST_ERROR; } if (H5Aread(aid, amtype, &read_which) < 0) { - H5_FAILED(); - AT(); printf("H5Aread failed\n"); - goto error; + TEST_ERROR; } if (H5Aclose(aid) < 0) { - H5_FAILED(); - AT(); printf("H5Aclose failed\n"); - goto error; + TEST_ERROR; } if (read_which != which) { - H5_FAILED(); - AT(); 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"); - goto error; + TEST_ERROR; } if (!s->old_style_grp && check_storage == true) { if (false == check_attr_storage_type(g, is_compact)) { - H5_FAILED(); - AT(); printf("The attribute storage type is wrong. \n"); - goto error; + TEST_ERROR; } dbgf(2, "reader: finish checking the storage type: %d\n", s->np_notify); } @@ -2157,19 +2011,19 @@ vrfy_attr(state_t *s, hid_t g, unsigned int which, const char *aname, unsigned i * 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)) { - H5_FAILED(); - AT(); 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"); - goto error; + 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) - goto error; + 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; @@ -2284,48 +2138,36 @@ verify_modify_attr(state_t *s, hid_t g, unsigned int which) /* Go ahead to read the attribute. */ esnprintf(attrname, sizeof(attrname), aname_fmt, which); if ((amtype = H5Tget_native_type(s->filetype, H5T_DIR_ASCEND)) < 0) { - H5_FAILED(); - AT(); printf("H5Tget_native_type failed\n"); - goto error; + TEST_ERROR; } if ((aid = H5Aopen(g, attrname, H5P_DEFAULT)) < 0) { - H5_FAILED(); - AT(); printf("H5Aopen failed\n"); - goto error; + TEST_ERROR; } if (H5Aread(aid, amtype, &read_which) < 0) { - H5_FAILED(); - AT(); printf("H5Aread failed\n"); - goto error; + TEST_ERROR; } if (H5Tclose(amtype) < 0) { - H5_FAILED(); - AT(); printf("H5Tclose failed.\n"); - goto error; + TEST_ERROR; } if (H5Aclose(aid) < 0) { - H5_FAILED(); - AT(); printf("H5Aclose failed\n"); - goto error; + TEST_ERROR; } /* verify the modified value */ if (read_which != (which + 10000)) { - H5_FAILED(); - AT(); 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"); - goto error; + TEST_ERROR; } /* The reader sends an OK message back to the writer. */ @@ -2411,10 +2253,8 @@ verify_group_vlstr_attr(state_t *s, hid_t g, unsigned int which, bool vrfy_mod) /* Go ahead to read the VL string attribute. */ astr_val_exp = HDmalloc(VS_ATTR_NAME_LEN); if (astr_val_exp == NULL) { - H5_FAILED(); - AT(); printf("Allocate memory for expected buffer failed.\n"); - goto error; + TEST_ERROR; } esnprintf(name, sizeof(name), "attr-%u", which); @@ -2431,56 +2271,42 @@ verify_group_vlstr_attr(state_t *s, hid_t g, unsigned int which, bool vrfy_mod) dbgf(1, "expected vl attr is= %s\n", astr_val_exp); if ((aid = H5Aopen(g, name, H5P_DEFAULT)) < 0) { - H5_FAILED(); - AT(); printf("H5Aopen failed\n"); - goto error; + TEST_ERROR; } /* Create a VL string datatype */ if ((atype = H5Tcopy(H5T_C_S1)) < 0) { - H5_FAILED(); - AT(); printf("Cannot create variable length datatype.\n"); - goto error; + TEST_ERROR; } if (H5Tset_size(atype, H5T_VARIABLE) < 0) { - H5_FAILED(); - AT(); printf("Cannot set variable length datatype.\n"); - goto error; + TEST_ERROR; } if (H5Aread(aid, atype, &astr_val) < 0) { - H5_FAILED(); - AT(); printf("Cannot read the attribute.\n"); - goto error; + TEST_ERROR; } dbgf(1, "read attr is= %s\n", astr_val); if (HDstrcmp(astr_val, astr_val_exp) != 0) { - H5_FAILED(); - AT(); 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"); - goto error; + TEST_ERROR; } if (H5Tclose(atype) < 0) { - H5_FAILED(); - AT(); printf("H5Tclose failed.\n"); - goto error; + TEST_ERROR; } if (H5Aclose(aid) < 0) { - H5_FAILED(); - AT(); printf("H5Aclose failed.\n"); - goto error; + TEST_ERROR; } H5free_memory(astr_val); @@ -2578,19 +2404,17 @@ verify_del_one_attr(state_t *s, hid_t g, const char *aname, bool check_storage, else if (attr_exists == TRUE) { printf("The supposed deleted attribute %s still exists \n", aname); printf("verify_del_attrs_compact() test failed \n"); - goto error; + TEST_ERROR; } else { printf("H5Aexists_by_name failed \n"); - goto error; + TEST_ERROR; } if (!s->old_style_grp && check_storage == true) { if (false == check_attr_storage_type(g, is_compact)) { - H5_FAILED(); - AT(); printf("The attribute storage type is wrong. \n"); - goto error; + TEST_ERROR; } dbgf(2, "reader: finish checking the storage type: %d\n", s->np_notify); } @@ -2599,19 +2423,17 @@ verify_del_one_attr(state_t *s, hid_t g, const char *aname, bool check_storage, * we need to check if this test behaves as expected. */ if (s->at_pattern == 'R') { if (false == check_ohr_num_chunk(g, true)) { - H5_FAILED(); - AT(); 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"); - goto error; + 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) - goto error; + TEST_ERROR; dbgf(2, "reader: finish sending back the message: %d\n", s->np_notify); } @@ -3081,22 +2903,16 @@ verify_group_attribute(state_t *s, hid_t g, unsigned int which) max_compact = 2; else { if ((gcpl = H5Gget_create_plist(g)) < 0) { - H5_FAILED(); - AT(); printf("H5Gget_create_plist failed\n"); - goto error; + TEST_ERROR; } if (H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense) < 0) { - H5_FAILED(); - AT(); printf("H5Pget_attr_phase_change failed\n"); - goto error; + TEST_ERROR; } if (H5Pclose(gcpl) < 0) { - H5_FAILED(); - AT(); printf("H5Pclose failed\n"); - goto error; + TEST_ERROR; } } break; @@ -3209,44 +3025,34 @@ verify_group(state_t *s, unsigned int which) } if (which >= s->nsteps) { - H5_FAILED(); - AT(); printf("Number of created groups is out of bounds\n"); - goto error; + TEST_ERROR; } esnprintf(name, sizeof(name), "/group-%u", which); if ((g = H5Gopen(s->file, name, H5P_DEFAULT)) < 0) { - H5_FAILED(); - AT(); printf("H5Gopen failed\n"); - goto error; + TEST_ERROR; } if (H5Gget_info(g, &group_info) < 0) { - H5_FAILED(); - AT(); printf("H5Gget_info failed\n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("Reader - Old-styled group: but the group is not in old-style. \n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("Reader - The created group should NOT be in old-style . \n"); - goto error; + TEST_ERROR; } dbgf(2, "Reader: verify that the group is created with the new-style.\n"); } @@ -3255,12 +3061,10 @@ verify_group(state_t *s, unsigned int which) * 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)) { - H5_FAILED(); - AT(); 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"); - goto error; + TEST_ERROR; } } @@ -3268,7 +3072,7 @@ verify_group(state_t *s, unsigned int which) if (s->use_named_pipes && s->attr_test == true) { if (np_rd_send(s) == false) - goto error; + TEST_ERROR; dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); } @@ -3279,10 +3083,8 @@ verify_group(state_t *s, unsigned int which) result = true; if (H5Gclose(g) < 0) { - H5_FAILED(); - AT(); printf("H5Gclose failed\n"); - goto error; + TEST_ERROR; } return result; @@ -3338,66 +3140,50 @@ create_group_id(state_t *s, unsigned int which, bool dense_to_compact) H5G_info_t group_info; if (which >= s->nsteps) { - H5_FAILED(); - AT(); printf("Number of created groups is out of bounds\n"); - goto error; + TEST_ERROR; } gcpl = H5Pcreate(H5P_GROUP_CREATE); if (gcpl < 0) { - H5_FAILED(); - AT(); printf("H5Pcreate failed\n"); - goto error; + TEST_ERROR; } if (dense_to_compact) { if (H5Pset_link_phase_change(gcpl, 2, 2) < 0) { - H5_FAILED(); - AT(); printf("H5Pset_link_phase_change failed for dense to compact.\n"); - goto error; + TEST_ERROR; } } else { if (H5Pset_link_phase_change(gcpl, 1, 1) < 0) { - H5_FAILED(); - AT(); printf("H5Pset_attr_phase_change failed for compact to dense.\n"); - goto error; + TEST_ERROR; } } esnprintf(name, sizeof(name), "/group-%u", which); if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) { - H5_FAILED(); - AT(); printf("H5Gcreate2 failed\n"); - goto error; + TEST_ERROR; } if (H5Gget_info(g, &group_info) < 0) { - H5_FAILED(); - AT(); printf("H5Gget_info failed\n"); - goto error; + TEST_ERROR; } /* The storage type should always be compact when a group is created. */ if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { - H5_FAILED(); - AT(); printf("New-style group link storage test:. \n"); printf(" still be compact after group creation. \n"); - goto error; + TEST_ERROR; } if (H5Pclose(gcpl) < 0) { - H5_FAILED(); - AT(); printf("H5Pclose failed\n"); - goto error; + TEST_ERROR; } /* If a grp_op_test is turned on and named pipes are used, @@ -3458,10 +3244,8 @@ close_group_id(state_t *s, hid_t g) { if (H5Gclose(g) < 0) { - H5_FAILED(); - AT(); printf("H5Gclose failed\n"); - goto error; + TEST_ERROR; } /* If a grp_op_test is turned on and named pipes are used, for @@ -3518,51 +3302,39 @@ create_group(state_t *s, unsigned int which) H5G_info_t group_info; if (which >= s->nsteps) { - H5_FAILED(); - AT(); printf("Number of created groups is out of bounds\n"); - goto error; + TEST_ERROR; } esnprintf(name, sizeof(name), "/group-%u", which); if ((g = H5Gcreate2(s->file, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); - AT(); printf("H5Gcreate2 failed\n"); - goto error; + TEST_ERROR; } if (H5Gget_info(g, &group_info) < 0) { - H5_FAILED(); - AT(); printf("H5Gget_info failed\n"); - goto error; + TEST_ERROR; } if (s->old_style_grp) { if (group_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) { - H5_FAILED(); - AT(); printf("Old-styled group test: but the group is not in old-style. \n"); - goto error; + TEST_ERROR; } dbgf(2, "Writer: group is created with the old-style.\n"); } else { if (group_info.storage_type == H5G_STORAGE_TYPE_SYMBOL_TABLE) { - H5_FAILED(); - AT(); printf("The created group should NOT be in old-style . \n"); - goto error; + TEST_ERROR; } dbgf(2, "Writer: group is created with the new-style.\n"); } if (H5Gclose(g) < 0) { - H5_FAILED(); - AT(); printf("H5Gclose failed\n"); - goto error; + TEST_ERROR; } /* Writer sends a message to reader, @@ -3633,51 +3405,39 @@ delete_one_link(state_t *s, hid_t obj_id, const char *name, short link_storage, H5G_info_t group_info; if (which >= s->nsteps) { - H5_FAILED(); - AT(); printf("Number of created groups is out of bounds\n"); - goto error; + TEST_ERROR; } if (H5Ldelete(obj_id, name, H5P_DEFAULT) < 0) { - H5_FAILED(); - AT(); printf("H5Ldelete failed\n"); - goto error; + TEST_ERROR; } if (link_storage > 0) { if (s->old_style_grp) { - H5_FAILED(); - AT(); printf("Old style group doesn't support the indexed storage.\n"); - goto error; + TEST_ERROR; } if (H5Gget_info(obj_id, &group_info) < 0) { - H5_FAILED(); - AT(); printf("H5Gget_info failed\n"); - goto error; + TEST_ERROR; } if (link_storage == 1) { if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { - H5_FAILED(); - AT(); printf("The group link storage should be compact. \n"); - goto error; + TEST_ERROR; } } else { if (group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { - H5_FAILED(); - AT(); printf("The group link storage should be dense. \n"); - goto error; + TEST_ERROR; } } } @@ -3775,17 +3535,13 @@ move_one_group(state_t *s, hid_t obj_id, const char *name, const char *newname, { if (which >= s->nsteps) { - H5_FAILED(); - AT(); printf("Number of created groups is out of bounds\n"); - goto error; + TEST_ERROR; } if (H5Lmove(obj_id, name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { - H5_FAILED(); - AT(); printf("H5Ldelete failed\n"); - goto error; + TEST_ERROR; } /* Writer sends a message to reader: @@ -3893,10 +3649,8 @@ insert_one_link(state_t *s, hid_t obj_id, const char *name, const char *newname, H5G_info_t group_info; if (which >= s->nsteps) { - H5_FAILED(); - AT(); printf("Number of created groups is out of bounds\n"); - goto error; + TEST_ERROR; } /* For storage transit and insert_links cases, we @@ -3905,36 +3659,28 @@ insert_one_link(state_t *s, hid_t obj_id, const char *name, const char *newname, if (is_hard) { if (link_storage > 0) { if (H5Lcreate_hard(s->file, name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { - H5_FAILED(); - AT(); printf("H5Lcreate_hard failed\n"); - goto error; + TEST_ERROR; } } else { if (H5Lcreate_hard(obj_id, name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { - H5_FAILED(); - AT(); printf("H5Lcreate_hard failed\n"); - goto error; + TEST_ERROR; } } } else { if (link_storage > 0) { if (H5Lcreate_soft("/", obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { - H5_FAILED(); - AT(); printf("H5Lcreate_soft failed\n"); - goto error; + TEST_ERROR; } } else { if (H5Lcreate_soft(name, obj_id, newname, H5P_DEFAULT, H5P_DEFAULT) < 0) { - H5_FAILED(); - AT(); printf("H5Lcreate_soft failed.\n"); - goto error; + TEST_ERROR; } } } @@ -3942,33 +3688,25 @@ insert_one_link(state_t *s, hid_t obj_id, const char *name, const char *newname, if (link_storage > 0) { if (s->old_style_grp) { - H5_FAILED(); - AT(); printf("Old style group doesn't support dense or compact storage.\n"); - goto error; + TEST_ERROR; } if (H5Gget_info(obj_id, &group_info) < 0) { - H5_FAILED(); - AT(); printf("H5Gget_info failed\n"); - goto error; + TEST_ERROR; } if (link_storage == 1) { if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { - H5_FAILED(); - AT(); printf("The group link storage should be compact. \n"); - goto error; + TEST_ERROR; } } else { if (group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { - H5_FAILED(); - AT(); printf("The group link storage should be dense. \n"); - goto error; + TEST_ERROR; } } } @@ -4108,36 +3846,28 @@ transit_storage_compact_to_dense(state_t *s, unsigned int which) hid_t g = create_group_id(s, which, false); if (g < 0) { - H5_FAILED(); - AT(); printf("create_group_id failed\n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("insert_one_link for compact storage failed\n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("insert_one_link for dense storage failed\n"); - goto error; + TEST_ERROR; } if (close_group_id(s, g) == false) { - H5_FAILED(); - AT(); printf("insert_one_link for dense storage failed\n"); - goto error; + TEST_ERROR; } return true; @@ -4183,61 +3913,47 @@ transit_storage_dense_to_compact(state_t *s, unsigned int which) hid_t g = create_group_id(s, which, true); if (g < 0) { - H5_FAILED(); - AT(); printf("create_group_id failed\n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("insert_one_link for compact storage failed\n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("insert_one_link for compact storage failed\n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("insert_one_link for dense storage failed\n"); - goto error; + TEST_ERROR; } /* Delete a link, storage is still dense */ if (delete_one_link(s, g, st_name, 2, which) == false) { - H5_FAILED(); - AT(); printf("delete_one_link for dense storage failed\n"); - goto error; + TEST_ERROR; } /* Delete another link, storage becomes compact */ if (delete_one_link(s, g, st2_name, 1, which) == false) { - H5_FAILED(); - AT(); printf("delete_one_link for compact storage failed\n"); - goto error; + TEST_ERROR; } if (close_group_id(s, g) == false) { - H5_FAILED(); - AT(); printf("insert_one_link for dense storage failed\n"); - goto error; + TEST_ERROR; } return true; @@ -4356,60 +4072,48 @@ vrfy_create_group(state_t *s, unsigned int which) } if (which >= s->nsteps) { - H5_FAILED(); - AT(); printf("Number of created groups is out of bounds\n"); - goto error; + TEST_ERROR; } esnprintf(name, sizeof(name), "/group-%u", which); if ((g = H5Gopen(s->file, name, H5P_DEFAULT)) < 0) { - H5_FAILED(); - AT(); printf("H5Gopen failed\n"); - goto error; + TEST_ERROR; } if (H5Gget_info(g, &group_info) < 0) { - H5_FAILED(); - AT(); printf("H5Gget_info failed\n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("Reader - Old-styled group: but the group is not in old-style. \n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("Reader - The created group should NOT be in old-style . \n"); - goto error; + TEST_ERROR; } dbgf(2, "Reader: verify that the group is created with the new-style.\n"); } if (H5Gclose(g) < 0) { - H5_FAILED(); - AT(); printf("H5Gclose failed\n"); - goto error; + 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) - goto error; + TEST_ERROR; dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); } @@ -4485,92 +4189,70 @@ vrfy_create_group_id(state_t *s, unsigned int which, bool dense_to_compact) } if (which >= s->nsteps) { - H5_FAILED(); - AT(); printf("Number of the created groups is out of bounds\n"); - goto error; + TEST_ERROR; } esnprintf(name, sizeof(name), "/group-%u", which); if ((g = H5Gopen(s->file, name, H5P_DEFAULT)) < 0) { - H5_FAILED(); - AT(); printf("H5Gopen failed\n"); - goto error; + TEST_ERROR; } if ((gcpl = H5Gget_create_plist(g)) < 0) { - H5_FAILED(); - AT(); printf("H5Gget_create_plist failed\n"); - goto error; + TEST_ERROR; } if (H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) { - H5_FAILED(); - AT(); printf("H5Pget_link_phase_change failed\n"); - goto error; + TEST_ERROR; } if (dense_to_compact) { if (max_compact != 2) { - H5_FAILED(); - AT(); 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); - goto error; + TEST_ERROR; } else if (min_dense != 2) { - H5_FAILED(); - AT(); 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); - goto error; + TEST_ERROR; } } else { if (max_compact != 1) { - H5_FAILED(); - AT(); 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); - goto error; + TEST_ERROR; } else if (min_dense != 1) { - H5_FAILED(); - AT(); 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); - goto error; + TEST_ERROR; } } if (H5Pclose(gcpl) < 0) { - H5_FAILED(); - AT(); printf("H5Pclose failed\n"); - goto error; + TEST_ERROR; } if (H5Gget_info(g, &group_info) < 0) { - H5_FAILED(); - AT(); printf("H5Gget_info failed\n"); - goto error; + TEST_ERROR; } /* When the group is created, the storage type is always compact. */ if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { - H5_FAILED(); - AT(); printf("Old-styled group test: but the group is not in old-style. \n"); - goto error; + TEST_ERROR; } dbgf(2, "Storage info is %d\n", group_info.storage_type); @@ -4579,7 +4261,7 @@ vrfy_create_group_id(state_t *s, unsigned int which, bool dense_to_compact) if (s->use_named_pipes && s->grp_op_test == true) { if (np_rd_send(s) == false) - goto error; + TEST_ERROR; dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); } @@ -4642,17 +4324,15 @@ vrfy_close_group_id(state_t *s, hid_t g) } if (H5Gclose(g) < 0) { - H5_FAILED(); - AT(); printf("H5Gclose failed\n"); - goto error; + 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) - goto error; + TEST_ERROR; dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); } @@ -4723,66 +4403,53 @@ vrfy_one_link_exist(state_t *s, hid_t obj_id, const char *name, bool expect_exis link_exists = H5Lexists(obj_id, name, H5P_DEFAULT); if (link_exists < 0) { - H5_FAILED(); - AT(); printf("H5Lexists error\n"); - goto error; + TEST_ERROR; } else if (link_exists == 1) { if (expect_exist == false) { - H5_FAILED(); - AT(); printf("This link should be moved or deleted but it still exists.\n"); - goto error; + TEST_ERROR; } } else if (link_exists == 0) { if (expect_exist == true) { - H5_FAILED(); - AT(); printf("This link should exist but it is moved or deleted.\n"); - goto error; + TEST_ERROR; } } if (link_storage > 0) { if (s->old_style_grp) { - H5_FAILED(); - AT(); printf("Old style group doesn't support the indexed storage.\n"); - goto error; + TEST_ERROR; } if (H5Gget_info(obj_id, &group_info) < 0) { - H5_FAILED(); - AT(); printf("H5Gget_info failed\n"); - goto error; + TEST_ERROR; } if (link_storage == 1) { if (group_info.storage_type != H5G_STORAGE_TYPE_COMPACT) { - H5_FAILED(); - AT(); printf("The group link storage should be compact. \n"); - goto error; + TEST_ERROR; } } else { if (group_info.storage_type != H5G_STORAGE_TYPE_DENSE) { - H5_FAILED(); - AT(); printf("The group link storage should be dense. \n"); - goto error; + 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) - goto error; + if (np_rd_send(s) == false) { + TEST_ERROR; + } dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); } @@ -4888,72 +4555,57 @@ vrfy_move_one_group(state_t *s, hid_t obj_id, const char *name, const char *newn } if (which >= s->nsteps) { - H5_FAILED(); - AT(); printf("Number of created groups is out of bounds\n"); - goto error; + TEST_ERROR; } link_exists = H5Lexists(obj_id, name, H5P_DEFAULT); if (link_exists < 0) { - H5_FAILED(); - AT(); printf("H5Lexists error\n"); - goto error; + TEST_ERROR; } else if (link_exists == 1) { - H5_FAILED(); - AT(); printf("This link should be moved but it still exists.\n"); - goto error; + TEST_ERROR; } if ((g = H5Gopen(obj_id, newname, H5P_DEFAULT)) < 0) { - H5_FAILED(); - AT(); printf("H5Gopen failed\n"); - goto error; + TEST_ERROR; } if (H5Gget_info(g, &group_info) < 0) { - H5_FAILED(); - AT(); printf("H5Gget_info failed\n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("Reader - Old-styled group: but the group is not in old-style. \n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("Reader - The created group should NOT be in old-style . \n"); - goto error; + TEST_ERROR; } dbgf(2, "Reader: verify that the group is created with the new-style.\n"); } if (H5Gclose(g) < 0) { - H5_FAILED(); - AT(); printf("H5Gclose failed\n"); - goto error; + 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) - goto error; + if (np_rd_send(s) == false) { + TEST_ERROR; + } dbgf(1, "Reader: finish sending back the message: %d\n", s->np_notify); } @@ -5127,33 +4779,25 @@ vrfy_transit_storage_compact_to_dense(state_t *s, unsigned int which) g = vrfy_create_group_id(s, which, false); if (g < 0) { - H5_FAILED(); - AT(); printf("verify create_group_id failed\n"); - goto error; + TEST_ERROR; } esnprintf(hd_name, sizeof(hd_name), "hd-group-%u", which); if (vrfy_one_link_exist(s, g, hd_name, true, 1) == false) { - H5_FAILED(); - AT(); printf("verify the compact storage failed for 'link compact to dense' test\n"); - goto error; + TEST_ERROR; } esnprintf(st_name, sizeof(st_name), "st-group-%u", which); if (vrfy_one_link_exist(s, g, st_name, true, 2) == false) { - H5_FAILED(); - AT(); printf("verify the dense link storage failed for 'link compact to dense' test\n"); - goto error; + TEST_ERROR; } if (vrfy_close_group_id(s, g) == false) { - H5_FAILED(); - AT(); printf("verify the group close for 'link compact to dense' test\n"); - goto error; + TEST_ERROR; } return true; @@ -5198,60 +4842,46 @@ vrfy_transit_storage_dense_to_compact(state_t *s, unsigned int which) g = vrfy_create_group_id(s, which, true); if (g < 0) { - H5_FAILED(); - AT(); printf("verify create_group_id failed\n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("verify the compact storage failed for 'link compact to dense' test\n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("verify the compact link storage failed for 'link compact to dense' test\n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("verify the dense link storage failed for 'link compact to dense' test\n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("verify the dense link storage failed for 'link compact to dense' test\n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("verify the compact link storage failed for 'link compact to dense' test\n"); - goto error; + TEST_ERROR; } if (vrfy_close_group_id(s, g) == false) { - H5_FAILED(); - AT(); printf("verify the group close for 'link compact to dense' test\n"); - goto error; + TEST_ERROR; } return true; @@ -5339,10 +4969,8 @@ main(int argc, char **argv) bool vg_ret = false; if (!state_init(&s, argc, argv)) { - H5_FAILED(); - AT(); printf("state_init failed\n"); - goto error; + TEST_ERROR; } personality = HDstrstr(s.progname, "vfd_swmr_group_"); @@ -5352,10 +4980,8 @@ main(int argc, char **argv) else if (personality != NULL && HDstrcmp(personality, "vfd_swmr_group_reader") == 0) writer = false; else { - H5_FAILED(); - AT(); printf("unknown personality, expected vfd_swmr_group_{reader,writer}\n"); - goto error; + TEST_ERROR; } /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ @@ -5367,24 +4993,18 @@ main(int argc, char **argv) * 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) { - H5_FAILED(); - AT(); printf("vfd_swmr_create_fapl failed\n"); - goto error; + TEST_ERROR; } if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) { - H5_FAILED(); - AT(); printf("H5Pcreate failed\n"); - goto error; + TEST_ERROR; } if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, false, 1) < 0) { - H5_FAILED(); - AT(); printf("H5Pset_file_space_strategy failed\n"); - goto error; + TEST_ERROR; } if (writer) @@ -5393,10 +5013,8 @@ main(int argc, char **argv) s.file = H5Fopen(s.filename, H5F_ACC_RDONLY, fapl); if (s.file < 0) { - H5_FAILED(); - AT(); printf("H5Fcreate/open failed\n"); - goto error; + TEST_ERROR; } /* Use two named pipes(FIFO) to coordinate the writer and reader for @@ -5406,33 +5024,25 @@ main(int argc, char **argv) if (s.use_named_pipes && writer) { /* Writer creates two named pipes(FIFO) */ if (HDmkfifo(fifo_writer_to_reader, 0600) < 0) { - H5_FAILED(); - AT(); printf("HDmkfifo failed\n"); - goto error; + TEST_ERROR; } if (HDmkfifo(fifo_reader_to_writer, 0600) < 0) { - H5_FAILED(); - AT(); printf("HDmkfifo failed\n"); - goto error; + 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) { - H5_FAILED(); - AT(); printf("HDopen failed\n"); - goto error; + TEST_ERROR; } if (s.use_named_pipes && (fd_reader_to_writer = HDopen(fifo_reader_to_writer, O_RDWR)) < 0) { - H5_FAILED(); - AT(); printf("HDopen failed\n"); - goto error; + TEST_ERROR; } /* Pass the named pipe information to the struct of state_t s, for attribute tests.*/ @@ -5464,14 +5074,12 @@ main(int argc, char **argv) wg_ret = group_operations(&s, step); if (wg_ret == false) { - H5_FAILED(); - AT(); - printf("write_group failed at step %d\n", step); - /* At communication interval, notifies the reader about the failture and quit */ + /* 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); - goto error; + printf("write_group failed at step %d\n", step); + TEST_ERROR; } else { @@ -5480,10 +5088,8 @@ main(int argc, char **argv) step % s.csteps == 0) { if (np_wr_send_receive(&s) == false) { - H5_FAILED(); - AT(); printf("writer: write group - verification failed.\n"); - goto error; + TEST_ERROR; } } } @@ -5497,9 +5103,7 @@ main(int argc, char **argv) */ if (s.use_named_pipes && s.attr_test != true && s.grp_op_test != true && step % s.csteps == 0) { if (false == np_rd_receive(&s)) { - H5_FAILED(); - AT(); - goto error; + TEST_ERROR; } } @@ -5512,13 +5116,11 @@ main(int argc, char **argv) if (vg_ret == false) { printf("verify_group_operations failed\n"); - H5_FAILED(); - AT(); /* 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); - goto error; + TEST_ERROR; } else { @@ -5526,70 +5128,55 @@ main(int argc, char **argv) * 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) - goto error; + if (np_rd_send(&s) == false) { + TEST_ERROR; + } } } } } if (H5Pclose(fapl) < 0) { - H5_FAILED(); - AT(); printf("H5Pclose failed\n"); - goto error; + TEST_ERROR; } if (H5Pclose(fcpl) < 0) { - H5_FAILED(); - AT(); printf("H5Pclose failed\n"); - goto error; + TEST_ERROR; } if (H5Sclose(s.one_by_one_sid) < 0) { - H5_FAILED(); - AT(); printf("H5Sclose failed\n"); - goto error; + TEST_ERROR; } if (H5Fclose(s.file) < 0) { - H5_FAILED(); - AT(); printf("H5Fclose failed\n"); - goto error; + TEST_ERROR; } /* Both the writer and reader close the named pipes */ if (s.use_named_pipes && HDclose(fd_writer_to_reader) < 0) { - H5_FAILED(); - AT(); printf("HDclose failed\n"); - goto error; + TEST_ERROR; } if (s.use_named_pipes && HDclose(fd_reader_to_writer) < 0) { - H5_FAILED(); - AT(); printf("HDclose failed\n"); - goto error; + TEST_ERROR; } /* Reader finishes last and deletes the named pipes */ if (s.use_named_pipes && !writer) { if (HDremove(fifo_writer_to_reader) != 0) { - H5_FAILED(); - AT(); printf("HDremove failed\n"); - goto error; + TEST_ERROR; } if (HDremove(fifo_reader_to_writer) != 0) { - H5_FAILED(); - AT(); printf("HDremove failed\n"); - goto error; + TEST_ERROR; } } -- cgit v0.12 From c82c7abb2996bc70a89b30d3584e66922d2edc54 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 21 May 2021 20:00:12 +0000 Subject: Committing clang-format changes --- test/vfd_swmr_group_writer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index 56efae8..6d93125 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -588,7 +588,7 @@ add_attr(state_t *s, hid_t oid, unsigned int which, unsigned num_attrs, const ch if (np_wr_send_receive(s) == false) { H5_FAILED(); AT(); - dbgf(2,"writer: write attr - verification failed.\n"); + 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. */ @@ -2020,7 +2020,7 @@ 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){ + if (np_rd_send(s) == false) { printf("named pipe reader send message error\n"); TEST_ERROR; } -- cgit v0.12