diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/tattr.c | 100 | ||||
-rw-r--r-- | test/titerate.c | 70 |
2 files changed, 91 insertions, 79 deletions
diff --git a/test/tattr.c b/test/tattr.c index 8a07cae..6800269 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -142,7 +142,8 @@ typedef struct { hbool_t *visited; /* Pointer to array of "visited attribute" flags */ } attr_iter_info_t; -static herr_t attr_op1(hid_t loc_id, const char *name, void *op_data); +static herr_t attr_op1(hid_t loc_id, const char *name, const H5A_info_t *ainfo, + void *op_data); @@ -1362,32 +1363,34 @@ test_attr_mult_read(hid_t fapl) ** attr_op1(): Attribute operator ** ****************************************************************/ -herr_t attr_op1(hid_t UNUSED loc_id, const char *name, void *op_data) +static herr_t +attr_op1(hid_t UNUSED loc_id, const char *name, const H5A_info_t UNUSED *ainfo, + void *op_data) { - int *count=(int *)op_data; - herr_t ret=0; + int *count = (int *)op_data; + herr_t ret = 0; switch(*count) { case 0: - if(HDstrcmp(name,ATTR1_NAME)) - TestErrPrintf("attribute name different: name=%s, should be %s\n",name,ATTR1_NAME); + if(HDstrcmp(name, ATTR1_NAME)) + TestErrPrintf("attribute name different: name=%s, should be %s\n", name, ATTR1_NAME); (*count)++; break; case 1: - if(HDstrcmp(name,ATTR2_NAME)) - TestErrPrintf("attribute name different: name=%s, should be %s\n",name,ATTR2_NAME); + if(HDstrcmp(name, ATTR2_NAME)) + TestErrPrintf("attribute name different: name=%s, should be %s\n", name, ATTR2_NAME); (*count)++; break; case 2: - if(HDstrcmp(name,ATTR3_NAME)) - TestErrPrintf("attribute name different: name=%s, should be %s\n",name,ATTR3_NAME); + if(HDstrcmp(name, ATTR3_NAME)) + TestErrPrintf("attribute name different: name=%s, should be %s\n", name, ATTR3_NAME); (*count)++; break; default: - ret=-1; + ret = -1; break; } /* end switch() */ @@ -1406,7 +1409,6 @@ test_attr_iterate(hid_t fapl) hid_t file; /* HDF5 File ID */ hid_t dataset; /* Dataset ID */ hid_t sid; /* Dataspace ID */ - unsigned start; /* Starting attribute to look up */ int count; /* operator data for the iterator */ herr_t ret; /* Generic return value */ @@ -1418,11 +1420,11 @@ test_attr_iterate(hid_t fapl) CHECK(file, FAIL, "H5Fopen"); /* Create a dataspace */ - sid=H5Screate(H5S_SCALAR); + sid = H5Screate(H5S_SCALAR); CHECK(sid, FAIL, "H5Screate"); /* Create a new dataset */ - dataset=H5Dcreate(file,DSET2_NAME,H5T_NATIVE_INT,sid,H5P_DEFAULT); + dataset = H5Dcreate(file, DSET2_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate"); /* Close dataspace */ @@ -1430,32 +1432,30 @@ test_attr_iterate(hid_t fapl) CHECK(ret, FAIL, "H5Sclose"); /* Verify the correct number of attributes */ - ret=H5Aget_num_attrs(dataset); + ret = H5Aget_num_attrs(dataset); VERIFY(ret, 0, "H5Aget_num_attrs"); /* Iterate over attributes on dataset */ - start = 0; count = 0; - ret = H5Aiterate(dataset, &start, attr_op1, &count); - VERIFY(ret, 0, "H5Aiterate"); + ret = H5Aiterate2(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, attr_op1, &count, H5P_DEFAULT); + VERIFY(ret, 0, "H5Aiterate2"); /* Close dataset */ ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); /* Open existing dataset w/attributes */ - dataset=H5Dopen(file,DSET1_NAME); + dataset = H5Dopen(file, DSET1_NAME); CHECK(dataset, FAIL, "H5Dopen"); /* Verify the correct number of attributes */ - ret=H5Aget_num_attrs(dataset); + ret = H5Aget_num_attrs(dataset); VERIFY(ret, 3, "H5Aget_num_attrs"); /* Iterate over attributes on dataset */ - start=0; - count=0; - ret = H5Aiterate(dataset,&start,attr_op1,&count); - VERIFY(ret, 0, "H5Aiterate"); + count = 0; + ret = H5Aiterate2(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, attr_op1, &count, H5P_DEFAULT); + VERIFY(ret, 0, "H5Aiterate2"); /* Close dataset */ ret = H5Dclose(dataset); @@ -5608,17 +5608,19 @@ HDfprintf(stderr, "op_data->curr = %Hd\n", op_data->curr); return(H5_ITER_CONT); } /* end attr_iterate2_cb() */ +#ifndef H5_NO_DEPRECATED_SYMBOLS /**************************************************************** ** -** attr_iterate_cb(): Attribute operator +** attr_iterate1_cb(): Attribute operator ** ****************************************************************/ static herr_t -attr_iterate_cb(hid_t loc_id, const char *attr_name, void *_op_data) +attr_iterate1_cb(hid_t loc_id, const char *attr_name, void *_op_data) { return(attr_iterate2_cb(loc_id, attr_name, NULL, _op_data)); -} /* end attr_iterate_cb() */ +} /* end attr_iterate1_cb() */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /*------------------------------------------------------------------------- @@ -5662,7 +5664,9 @@ attr_iterate_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, { unsigned v; /* Local index variable */ hsize_t skip; /* # of attributes to skip on object */ - unsigned oskip; /* # of attributes to skip on object, with H5Aiterate */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + unsigned oskip; /* # of attributes to skip on object, with H5Aiterate1 */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ int old_nerrs; /* Number of errors when entering this check */ herr_t ret; /* Generic return value */ @@ -5685,20 +5689,22 @@ attr_iterate_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, VERIFY(iter_info->visited[v], TRUE, "H5Aiterate2"); - /* Iterate over attributes on object, with H5Aiterate */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + /* Iterate over attributes on object, with H5Aiterate1 */ iter_info->nskipped = oskip = 0; iter_info->order = order; iter_info->stop = -1; iter_info->ncalled = 0; iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - ret = H5Aiterate(obj_id, &oskip, attr_iterate_cb, iter_info); - CHECK(ret, FAIL, "H5Aiterate"); + ret = H5Aiterate1(obj_id, &oskip, attr_iterate1_cb, iter_info); + CHECK(ret, FAIL, "H5Aiterate1"); /* Verify that we visited all the attributes */ - VERIFY(skip, max_attrs, "H5Aiterate"); + VERIFY(skip, max_attrs, "H5Aiterate1"); for(v = 0; v < max_attrs; v++) - VERIFY(iter_info->visited[v], TRUE, "H5Aiterate"); + VERIFY(iter_info->visited[v], TRUE, "H5Aiterate1"); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Skip over some attributes on object */ @@ -5733,25 +5739,26 @@ attr_iterate_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, } /* end else */ - /* Skip over some attributes on object, with H5Aiterate */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + /* Skip over some attributes on object, with H5Aiterate1 */ iter_info->nskipped = oskip = max_attrs / 2; iter_info->order = order; iter_info->stop = -1; iter_info->ncalled = 0; iter_info->curr = order != H5_ITER_DEC ? (unsigned)oskip : ((max_attrs - 1) - oskip); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - ret = H5Aiterate(obj_id, &oskip, attr_iterate_cb, iter_info); - CHECK(ret, FAIL, "H5Aiterate"); + ret = H5Aiterate1(obj_id, &oskip, attr_iterate1_cb, iter_info); + CHECK(ret, FAIL, "H5Aiterate1"); /* Verify that we visited all the links */ - VERIFY(oskip, max_attrs, "H5Aiterate"); + VERIFY(oskip, max_attrs, "H5Aiterate1"); if(order == H5_ITER_INC) { for(v = 0; v < (max_attrs / 2); v++) - VERIFY(iter_info->visited[v + (max_attrs / 2)], TRUE, "H5Aiterate"); + VERIFY(iter_info->visited[v + (max_attrs / 2)], TRUE, "H5Aiterate1"); } /* end if */ else if(order == H5_ITER_DEC) { for(v = 0; v < (max_attrs / 2); v++) - VERIFY(iter_info->visited[v], TRUE, "H5Aiterate"); + VERIFY(iter_info->visited[v], TRUE, "H5Aiterate1"); } /* end if */ else { unsigned nvisit = 0; /* # of links visited */ @@ -5761,8 +5768,9 @@ attr_iterate_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, if(iter_info->visited[v] == TRUE) nvisit++; - VERIFY(skip, (max_attrs / 2), "H5Aiterate"); + VERIFY(skip, (max_attrs / 2), "H5Aiterate1"); } /* end else */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Iterate over attributes on object, stopping in the middle */ @@ -5778,17 +5786,19 @@ attr_iterate_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, VERIFY(iter_info->ncalled, 3, "H5Aiterate2"); - /* Iterate over attributes on object, stopping in the middle, with H5Aiterate() */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + /* Iterate over attributes on object, stopping in the middle, with H5Aiterate1() */ iter_info->nskipped = oskip = 0; iter_info->order = order; iter_info->stop = 3; iter_info->ncalled = 0; iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - ret = H5Aiterate(obj_id, &oskip, attr_iterate_cb, iter_info); - CHECK(ret, FAIL, "H5Aiterate"); - VERIFY(ret, CORDER_ITER_STOP, "H5Aiterate2"); - VERIFY(iter_info->ncalled, 3, "H5Aiterate2"); + ret = H5Aiterate1(obj_id, &oskip, attr_iterate1_cb, iter_info); + CHECK(ret, FAIL, "H5Aiterate1"); + VERIFY(ret, CORDER_ITER_STOP, "H5Aiterate1"); + VERIFY(iter_info->ncalled, 3, "H5Aiterate1"); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Check for iteration routine indicating failure */ diff --git a/test/titerate.c b/test/titerate.c index 175a5a9..81c5c78 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -65,7 +65,8 @@ static herr_t liter_cb(hid_t group, const char *name, const H5L_info_t *info, void *op_data); static herr_t liter_cb2(hid_t group, const char *name, const H5L_info_t *info, void *op_data); -herr_t aiter_cb(hid_t loc_id, const char *name, void *op_data); +herr_t aiter_cb(hid_t group, const char *name, const H5A_info_t *ainfo, + void *op_data); /**************************************************************** ** @@ -344,7 +345,8 @@ test_iter_group(hid_t fapl, hbool_t new_format) ** ****************************************************************/ herr_t -aiter_cb(hid_t UNUSED group, const char *name, void *op_data) +aiter_cb(hid_t UNUSED group, const char *name, const H5A_info_t UNUSED *ainfo, + void *op_data) { iter_info *info = (iter_info *)op_data; static int count = 0; @@ -385,7 +387,7 @@ static void test_iter_attr(hid_t fapl, hbool_t new_format) hid_t filespace; /* Common dataspace ID */ hid_t attribute; /* Attribute ID */ int i; /* counting variable */ - unsigned idx; /* Index in the attribute list */ + hsize_t idx; /* Index in the attribute list */ char name[NAMELEN]; /* temporary name buffer */ char *anames[NATTR]; /* Names of the attributes created */ iter_info info; /* Custom iteration information */ @@ -398,88 +400,88 @@ static void test_iter_attr(hid_t fapl, hbool_t new_format) file = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); CHECK(file, FAIL, "H5Fcreate"); - filespace=H5Screate(H5S_SCALAR); + filespace = H5Screate(H5S_SCALAR); CHECK(filespace, FAIL, "H5Screate"); dataset = H5Dcreate(file, "Dataset", H5T_NATIVE_INT, filespace, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate"); - for(i=0; i< NATTR; i++) { - sprintf(name,"Attribute %d",i); + for(i = 0; i < NATTR; i++) { + sprintf(name, "Attribute %02d", i); attribute = H5Acreate(dataset, name, H5T_NATIVE_INT, filespace, H5P_DEFAULT); CHECK(attribute, FAIL, "H5Acreate"); /* Keep a copy of the attribute names around for later */ - anames[i]=HDstrdup(name); + anames[i] = HDstrdup(name); CHECK(anames[i], NULL, "strdup"); - ret=H5Aclose(attribute); + ret = H5Aclose(attribute); CHECK(ret, FAIL, "H5Aclose"); - } + } /* end for */ /* Close everything up */ - ret=H5Dclose(dataset); + ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); - ret=H5Sclose(filespace); + ret = H5Sclose(filespace); CHECK(ret, FAIL, "H5Sclose"); - ret=H5Fclose(file); + ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); /* Iterate through the attributes on the dataset in various ways */ - file=H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl); + file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl); CHECK(file, FAIL, "H5Fopen"); - dataset=H5Dopen(file, "Dataset"); + dataset = H5Dopen(file, "Dataset"); CHECK(dataset, FAIL, "H5Dopen"); /* Test invalid indices for starting iteration */ - info.command=RET_ZERO; + info.command = RET_ZERO; /* Test skipping exactly as many attributes as there are */ - idx=NATTR; + idx = NATTR; H5E_BEGIN_TRY { - ret=H5Aiterate(dataset,&idx,aiter_cb,&info); + ret = H5Aiterate2(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info, H5P_DEFAULT); } H5E_END_TRY; - VERIFY(ret, FAIL, "H5Aiterate"); + VERIFY(ret, FAIL, "H5Aiterate2"); /* Test skipping more attributes than there are */ - idx=NATTR+1; + idx = NATTR + 1; H5E_BEGIN_TRY { - ret=H5Aiterate(dataset,&idx,aiter_cb,&info); + ret = H5Aiterate2(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info, H5P_DEFAULT); } H5E_END_TRY; - VERIFY(ret, FAIL, "H5Aiterate"); + VERIFY(ret, FAIL, "H5Aiterate2"); /* Test all attributes on dataset, when callback always returns 0 */ info.command = RET_ZERO; idx = 0; - if((ret = H5Aiterate(dataset, &idx, aiter_cb, &info)) > 0) + if((ret = H5Aiterate2(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info, H5P_DEFAULT)) > 0) TestErrPrintf("Attribute iteration function didn't return zero correctly!\n"); /* Test all attributes on dataset, when callback always returns 1 */ /* This also tests the "restarting" ability, because the index changes */ info.command = RET_TWO; idx = i = 0; - while((ret = H5Aiterate(dataset, &idx, aiter_cb, &info)) > 0) { + while((ret = H5Aiterate2(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info, H5P_DEFAULT)) > 0) { /* Verify return value from iterator gets propagated correctly */ - VERIFY(ret, 2, "H5Aiterate"); + VERIFY(ret, 2, "H5Aiterate2"); /* Increment the number of times "2" is returned */ i++; /* Verify that the index is the correct value */ - VERIFY(idx, (unsigned)i, "H5Aiterate"); + VERIFY(idx, (unsigned)i, "H5Aiterate2"); /* Don't check name when new format is used */ if(!new_format) { /* Verify that the correct name is retrieved */ - if(HDstrcmp(info.name, anames[idx - 1]) != 0) - TestErrPrintf("%u: Attribute iteration function didn't set names correctly, info.name = '%s', anames[idx - 1] = '%s'!\n", __LINE__, info.name, anames[idx - 1]); + if(HDstrcmp(info.name, anames[(size_t)idx - 1]) != 0) + TestErrPrintf("%u: Attribute iteration function didn't set names correctly, info.name = '%s', anames[%u] = '%s'!\n", __LINE__, info.name, (unsigned)(idx - 1), anames[(size_t)idx - 1]); } /* end if */ } /* end while */ - VERIFY(ret, -1, "H5Aiterate"); + VERIFY(ret, -1, "H5Aiterate2"); if(i != 50 || idx != 50) TestErrPrintf("%u: Attribute iteration function didn't perform multiple iterations correctly!\n", __LINE__); @@ -488,24 +490,24 @@ static void test_iter_attr(hid_t fapl, hbool_t new_format) /* This also tests the "restarting" ability, because the index changes */ info.command = new_format ? RET_CHANGE2 : RET_CHANGE; idx = i = 0; - while((ret = H5Aiterate(dataset, &idx, aiter_cb, &info)) > 0) { + while((ret = H5Aiterate2(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info, H5P_DEFAULT)) > 0) { /* Verify return value from iterator gets propagated correctly */ - VERIFY(ret, 1, "H5Aiterate"); + VERIFY(ret, 1, "H5Aiterate2"); /* Increment the number of times "1" is returned */ i++; /* Verify that the index is the correct value */ - VERIFY(idx, (unsigned)i + 10, "H5Aiterate"); + VERIFY(idx, (unsigned)i + 10, "H5Aiterate2"); /* Don't check name when new format is used */ if(!new_format) { /* Verify that the correct name is retrieved */ - if(HDstrcmp(info.name, anames[idx - 1]) != 0) - TestErrPrintf("%u: Attribute iteration function didn't set names correctly, info.name = '%s', anames[idx - 1] = '%s'!\n", __LINE__, info.name, anames[idx - 1]); + if(HDstrcmp(info.name, anames[(size_t)idx - 1]) != 0) + TestErrPrintf("%u: Attribute iteration function didn't set names correctly, info.name = '%s', anames[%u] = '%s'!\n", __LINE__, info.name, (unsigned)(idx - 1), anames[(size_t)idx - 1]); } /* end if */ } /* end while */ - VERIFY(ret, -1, "H5Aiterate"); + VERIFY(ret, -1, "H5Aiterate2"); if(i != 40 || idx != 50) TestErrPrintf("%u: Attribute iteration function didn't perform multiple iterations correctly!\n", __LINE__); |