diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/testvfdswmr.sh.in | 6 | ||||
-rw-r--r-- | test/vfd_swmr_group_writer.c | 171 |
2 files changed, 140 insertions, 37 deletions
diff --git a/test/testvfdswmr.sh.in b/test/testvfdswmr.sh.in index 06b1023..979f5a9 100644 --- a/test/testvfdswmr.sh.in +++ b/test/testvfdswmr.sh.in @@ -721,12 +721,12 @@ fi grp_attr_list=( "compact" "dense" - "compact-to-dense" "compact-del" "dense-del" + "compact-add-to-dense" "dense-del-to-compact" "modify" - "vstr" + "add-vstr" "remove-vstr" "modify-vstr" ) @@ -799,7 +799,7 @@ os_grp_attr_list=( "compact" "compact-del" "modify" - "vstr" + "add-vstr" "remove-vstr" "modify-vstr" ) diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index f9146e9..2bae176 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -67,7 +67,6 @@ typedef struct { , .np_verify = 0 } -//TODO: add at_pattern description static void usage(const char *progname) { @@ -87,19 +86,19 @@ usage(const char *progname) " 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-to-dense` - Attributes added first in compact\n" - " then 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" - " `vstr` - A VL string attribute added\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" @@ -145,7 +144,7 @@ state_init(state_t *s, int argc, char **argv) case 'n': case 'u': errno = 0; - tmp = strtoul(optarg, &end, 0); + tmp = HDstrtoul(optarg, &end, 0); if (end == optarg || *end != '\0') { H5_FAILED(); AT(); printf("couldn't parse `-%c` argument `%s`\n", ch, optarg); @@ -197,25 +196,25 @@ state_init(state_t *s, int argc, char **argv) } break; case 'A': - if (strcmp(optarg, "compact") == 0) + if (HDstrcmp(optarg, "compact") == 0) s->at_pattern = 'c'; - else if (strcmp(optarg, "dense") == 0) + else if (HDstrcmp(optarg, "dense") == 0) s->at_pattern = 'd'; - else if (strcmp(optarg, "compact-to-dense") == 0) + else if (HDstrcmp(optarg, "compact-add-to-dense") == 0) s->at_pattern = 't'; - else if (strcmp(optarg, "compact-del") == 0) + else if (HDstrcmp(optarg, "compact-del") == 0) s->at_pattern = 'C'; - else if (strcmp(optarg, "dense-del") == 0) + else if (HDstrcmp(optarg, "dense-del") == 0) s->at_pattern = 'D'; - else if (strcmp(optarg, "dense-del-to-compact") == 0) + else if (HDstrcmp(optarg, "dense-del-to-compact") == 0) s->at_pattern = 'T'; - else if (strcmp(optarg, "modify") == 0) + else if (HDstrcmp(optarg, "modify") == 0) s->at_pattern = 'M'; - else if (strcmp(optarg,"vstr") ==0) + else if (HDstrcmp(optarg,"add-vstr") ==0) s->at_pattern = 'v'; - else if (strcmp(optarg, "remove-vstr") == 0) + else if (HDstrcmp(optarg, "remove-vstr") == 0) s->at_pattern = 'r'; - else if (strcmp(optarg, "modify-vstr") == 0) + else if (HDstrcmp(optarg, "modify-vstr") == 0) s->at_pattern = 'm'; else { H5_FAILED(); AT(); @@ -1248,12 +1247,8 @@ del_attrs_compact_dense_compact(state_t *s, } u= max_compact +1; -#if 0 - if(max_compact < min_dense) - printf("Minimum number of attributes stored in dense storage should be less than maximum number of attributes stored in compact storage.\n"); -#endif - // delete a number of attributes so that the attribute storage just becomes dense. + /* delete a number of attributes so that the attribute storage just becomes dense.*/ for(u--;u>=(min_dense-1);u--) { HDsprintf(attrname, aname_format, which,max_compact-u); if (H5Adelete(obj_id,attrname) < 0) { @@ -1724,6 +1719,62 @@ error2: return false; } +/*------------------------------------------------------------------------- + * Function: check_attr_storage_type + * + * Purpose: Check if the attribute storage type is correct + * + * Parameters: hid_t oid + * HDF5 object ID (in this file: means group ID) + * + * bool is_compact + * true if the attribute is stored in compact storage + * false if the attribute is stored in dense storage + * + * + * Return: Success: true + * Failure: false + * + *------------------------------------------------------------------------- +*/ + +static bool +check_attr_storage_type(hid_t g, + bool is_compact) { + + H5O_native_info_t ninfo; + + /* Get the object information */ + if(H5Oget_native_info(g, &ninfo, H5O_NATIVE_INFO_HDR|H5O_NATIVE_INFO_META_SIZE) < 0) { + H5_FAILED(); AT(); + printf("H5Oget_native_info failed\n"); + goto 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; + } + } + 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; + } + } + + return true; + +error: + return false; + +} + /*------------------------------------------------------------------------- * Function: vrfy_attr @@ -1748,6 +1799,16 @@ error2: * This parameter is used to generate correct group name in a key * debugging message. * + * bool check_storage + * a flag to indicate if the storage check is on + * + * bool is_compact + * true if the attribute is stored in compact storage + * false if the attribute is stored in dense storage + * Note: this parameter is not used if the check_storage + * is set to false. + * + * * Return: Success: true * Failure: false * @@ -1759,7 +1820,9 @@ vrfy_attr(state_t *s, hid_t g, unsigned int which, const char* aname, - unsigned int g_which) { + unsigned int g_which, + bool check_storage, + bool is_compact) { unsigned int read_which; hid_t aid = H5I_INVALID_HID; @@ -1816,6 +1879,17 @@ vrfy_attr(state_t *s, goto 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; + } + dbgf(2, "reader: finish checking the storage type: %d\n", s->np_notify); + + } + /* 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) @@ -1869,7 +1943,7 @@ verify_default_group_attr(state_t*s,hid_t g, unsigned int which) char attrname[VS_ATTR_NAME_LEN]; const char* aname_format = "attr-%u"; HDsprintf(attrname, aname_format, which); - return vrfy_attr(s,g,which,attrname,which); + return vrfy_attr(s,g,which,attrname,which,false,true); } @@ -2173,7 +2247,12 @@ error2: static bool -verify_del_one_attr(state_t *s,hid_t g, const char *aname) { +verify_del_one_attr(state_t *s, + hid_t g, + const char *aname, + bool check_storage, + bool is_compact) { + htri_t attr_exists = FALSE; @@ -2205,6 +2284,16 @@ verify_del_one_attr(state_t *s,hid_t g, const char *aname) { goto 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; + } + dbgf(2, "reader: finish checking the storage type: %d\n", s->np_notify); + + } + /* Reader sends an OK message back to the reader */ if(s->use_named_pipes && s->attr_test == true) { if(np_rd_send(s)==false) @@ -2261,7 +2350,7 @@ verify_remove_vlstr_attr(state_t* s,hid_t g, unsigned int which) ret = verify_group_vlstr_attr(s,g,which,false); if(ret == true) { HDsprintf(attrname,aname_format,which); - ret = verify_del_one_attr(s,g,attrname); + ret = verify_del_one_attr(s,g,attrname,false,false); } return ret; } @@ -2349,7 +2438,7 @@ verify_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which) { for (u = 0; u < max_c; u++) { HDsprintf(attrname, aname_format, which,u); - if(false == vrfy_attr(s,g,u+which,attrname,which)) { + if(false == vrfy_attr(s,g,u+which,attrname,which,true,true)) { ret = false; break; } @@ -2403,7 +2492,7 @@ 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); + ret = vrfy_attr(s,g,which+max_c,attrname,which,true,false); if(ret == false) dbgf(1,"verify_attrs_compact_dense failed \n"); @@ -2455,7 +2544,7 @@ verify_del_attrs_compact(state_t *s, hid_t g, unsigned max_c, unsigned int which if(ret == true) { /* The writer only deletes the attribute attr-which-0 */ HDsprintf(attrname,aname_format,which,0); - ret = verify_del_one_attr(s,g,attrname); + ret = verify_del_one_attr(s,g,attrname,true,true); } return ret; @@ -2510,7 +2599,7 @@ verify_del_attrs_compact_dense(state_t *s, if(ret == true) { /* The writer only deletes the attribute attr-d-which-0 */ HDsprintf(attrname,aname_format,max_c+which,0); - ret = verify_del_one_attr(s,g,attrname); + ret = verify_del_one_attr(s,g,attrname,true,false); } return ret; @@ -2581,13 +2670,16 @@ verify_del_attrs_compact_dense_compact(state_t *s, u = max_c + 1; for(u--;u>=(min_d-1);u--) { HDsprintf(attrname, aname_format, which,max_c-u); - ret = verify_del_one_attr(s,g,attrname); + if(u==(min_d-1)) + ret = verify_del_one_attr(s,g,attrname,true,true); + else + ret = verify_del_one_attr(s,g,attrname,true,false); } /* Just verify one more deleted attribute by the writer. The storage is still compact. */ HDsprintf(attrname,aname_format,max_c+which,0); - ret = verify_del_one_attr(s,g,attrname); + ret = verify_del_one_attr(s,g,attrname,true,true); } return ret; @@ -3126,13 +3218,13 @@ main(int argc, char **argv) goto error; } - personality = strstr(s.progname, "vfd_swmr_group_"); + personality = HDstrstr(s.progname, "vfd_swmr_group_"); if (personality != NULL && - strcmp(personality, "vfd_swmr_group_writer") == 0) + HDstrcmp(personality, "vfd_swmr_group_writer") == 0) writer = true; else if (personality != NULL && - strcmp(personality, "vfd_swmr_group_reader") == 0) + HDstrcmp(personality, "vfd_swmr_group_reader") == 0) writer = false; else { H5_FAILED(); AT(); @@ -3220,7 +3312,11 @@ main(int argc, char **argv) s.max_lag = config.max_lag; } - /* For attribute test, force the named pipe to communicate in every step. */ + /* 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.at_pattern != ' ') { s.attr_test = true; if(s.use_named_pipes) @@ -3309,6 +3405,12 @@ main(int argc, char **argv) goto error; } + if (H5Sclose(s.one_by_one_sid) < 0) { + H5_FAILED(); AT(); + printf("H5Sclose failed\n"); + goto error; + } + if (H5Fclose(s.file) < 0) { H5_FAILED(); AT(); printf("H5Fclose failed\n"); @@ -3349,6 +3451,7 @@ error: H5E_BEGIN_TRY { H5Pclose(fapl); H5Pclose(fcpl); + H5Sclose(s.one_by_one_sid); H5Fclose(s.file); } H5E_END_TRY; |