diff options
Diffstat (limited to 'test/titerate.c')
-rw-r--r-- | test/titerate.c | 348 |
1 files changed, 185 insertions, 163 deletions
diff --git a/test/titerate.c b/test/titerate.c index 4850db0..3241901 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -46,7 +46,8 @@ typedef enum { RET_ZERO, RET_TWO, - RET_CHANGE + RET_CHANGE, + RET_CHANGE2 } iter_enum; /* Custom group iteration callback data */ @@ -70,7 +71,7 @@ herr_t aiter_cb(hid_t loc_id, const char *name, void *op_data); ****************************************************************/ int iter_strcmp(const void *s1, const void *s2) { - return(strcmp(*(const char * const *)s1,*(const char * const *)s2)); + return(HDstrcmp(*(const char * const *)s1,*(const char * const *)s2)); } /**************************************************************** @@ -80,10 +81,11 @@ int iter_strcmp(const void *s1, const void *s2) ****************************************************************/ herr_t giter_cb(hid_t UNUSED group, const char *name, void *op_data) { - iter_info *info=(iter_info *)op_data; - static int count=0; + iter_info *info = (iter_info *)op_data; + static int count = 0; + static int count2 = 0; - strcpy(info->name,name); + HDstrcpy(info->name, name); switch(info->command) { case RET_ZERO: @@ -94,20 +96,24 @@ herr_t giter_cb(hid_t UNUSED group, const char *name, void *op_data) case RET_CHANGE: count++; - return(count>10 ? 1: 0); + return(count > 10 ? 1 : 0); + + case RET_CHANGE2: + count2++; + return(count2 > 10 ? 1 : 0); default: printf("invalid iteration command"); return(-1); } /* end switch */ -} +} /* end giter_cb() */ /**************************************************************** ** ** test_iter_group(): Test group iteration functionality ** ****************************************************************/ -static void test_iter_group(void) +static void test_iter_group(hid_t fapl, hbool_t new_format) { hid_t file; /* File ID */ hid_t dataset; /* Dataset ID */ @@ -117,7 +123,7 @@ static void test_iter_group(void) int i; /* counting variable */ int idx; /* Index in the group */ char name[NAMELEN]; /* temporary name buffer */ - char *dnames[NDATASETS];/* Names of the datasets created */ + char *lnames[NDATASETS + 2];/* Names of the links created */ char dataset_name[NAMELEN]; /* dataset name */ iter_info info; /* Custom iteration information */ hsize_t num_membs; /* Number of group members */ @@ -127,7 +133,7 @@ static void test_iter_group(void) MESSAGE(5, ("Testing Group Iteration Functionality\n")); /* Create the test file with the datasets */ - file = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); CHECK(file, FAIL, "H5Fcreate"); /* Test iterating over empty group */ @@ -148,12 +154,12 @@ static void test_iter_group(void) CHECK(dataset, FAIL, "H5Dcreate"); /* Keep a copy of the dataset names around for later */ - dnames[i]=HDstrdup(name); - CHECK(dnames[i], NULL, "strdup"); + lnames[i] = HDstrdup(name); + CHECK(lnames[i], NULL, "strdup"); - ret=H5Dclose(dataset); + ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); - } + } /* end for */ /* Create a group and named datatype under root group for testing * H5Gget_objtype_by_idx. @@ -161,9 +167,15 @@ static void test_iter_group(void) grp = H5Gcreate(file, "grp", 0); CHECK(ret, FAIL, "H5Gcreate"); + lnames[NDATASETS] = HDstrdup("grp"); + CHECK(lnames[NDATASETS], NULL, "strdup"); + ret = H5Tcommit(file, "dtype", datatype); CHECK(ret, FAIL, "H5Tcommit"); + lnames[NDATASETS + 1] = HDstrdup("dtype"); + CHECK(lnames[NDATASETS], NULL, "strdup"); + /* Close everything up */ ret=H5Tclose(datatype); CHECK(ret, FAIL, "H5Tclose"); @@ -178,11 +190,11 @@ static void test_iter_group(void) CHECK(ret, FAIL, "H5Fclose"); /* Sort the dataset names */ - HDqsort(dnames,NDATASETS,sizeof(char *),iter_strcmp); + HDqsort(lnames, NDATASETS + 2, sizeof(char *), iter_strcmp); /* Iterate through the datasets in the root group in various ways */ - file=H5Fopen(DATAFILE, H5F_ACC_RDONLY, H5P_DEFAULT); + file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl); CHECK(file, FAIL, "H5Fopen"); /* These two functions, H5Gget_num_objs and H5Gget_objname_by_idx, actually @@ -194,9 +206,9 @@ static void test_iter_group(void) ret = H5Gget_num_objs(root_group, &num_membs); CHECK(ret, FAIL, "H5Gget_num_objs"); - VERIFY(num_membs,NDATASETS+2,"H5Gget_num_objs"); + VERIFY(num_membs, (NDATASETS + 2), "H5Gget_num_objs"); - for(i=0; i< (int)num_membs; i++) { + for(i = 0; i< (int)num_membs; i++) { H5G_obj_t obj_type; /* Type of object in file */ ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, NAMELEN); @@ -204,7 +216,7 @@ static void test_iter_group(void) obj_type = H5Gget_objtype_by_idx(root_group, (hsize_t)i); CHECK(obj_type, H5G_UNKNOWN, "H5Gget_objtype_by_idx"); - } + } /* end for */ H5E_BEGIN_TRY { ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)(NDATASETS+3), dataset_name, NAMELEN); @@ -222,9 +234,9 @@ static void test_iter_group(void) { ret = H5Gget_num_objs(file, &num_membs); CHECK(ret, FAIL, "H5Gget_num_objs"); - VERIFY(num_membs,NDATASETS+2,"H5Gget_num_objs"); + VERIFY(num_membs, NDATASETS + 2, "H5Gget_num_objs"); - for(i=0; i< (int)num_membs; i++) { + for(i = 0; i< (int)num_membs; i++) { H5G_obj_t obj_type; /* Type of object in file */ ret = (herr_t)H5Gget_objname_by_idx(file, (hsize_t)i, dataset_name, NAMELEN); @@ -235,116 +247,95 @@ static void test_iter_group(void) } H5E_BEGIN_TRY { - ret = (herr_t)H5Gget_objname_by_idx(file, (hsize_t)(NDATASETS+3), dataset_name, NAMELEN); + ret = (herr_t)H5Gget_objname_by_idx(file, (hsize_t)(NDATASETS + 3), dataset_name, NAMELEN); } H5E_END_TRY; VERIFY(ret, FAIL, "H5Gget_objname_by_idx"); } /* Test invalid indices for starting iteration */ - info.command=RET_ZERO; - idx=-1; + info.command = RET_ZERO; + idx = -1; H5E_BEGIN_TRY { - ret=H5Giterate(file,"/",&idx,giter_cb,&info); + ret = H5Giterate(file, "/", &idx, giter_cb, &info); } H5E_END_TRY; VERIFY(ret, FAIL, "H5Giterate"); /* Test skipping exactly as many entries as in the group */ - idx=NDATASETS+2; + idx = NDATASETS + 2; H5E_BEGIN_TRY { - ret=H5Giterate(file,"/",&idx,giter_cb,&info); + ret = H5Giterate(file, "/", &idx, giter_cb, &info); } H5E_END_TRY; VERIFY(ret, FAIL, "H5Giterate"); /* Test skipping more entries than are in the group */ - idx=NDATASETS+3; + idx = NDATASETS + 3; H5E_BEGIN_TRY { - ret=H5Giterate(file,"/",&idx,giter_cb,&info); + ret = H5Giterate(file, "/", &idx, giter_cb, &info); } H5E_END_TRY; VERIFY(ret, FAIL, "H5Giterate"); /* Test all objects in group, when callback always returns 0 */ - info.command=RET_ZERO; - idx=0; - if((ret=H5Giterate(file,"/",&idx,giter_cb,&info))>0) + info.command = RET_ZERO; + idx = 0; + if((ret = H5Giterate(file, "/", &idx, giter_cb, &info)) > 0) TestErrPrintf("Group iteration function didn't return zero correctly!\n"); /* Test all objects in group, when callback always returns 1 */ /* This also tests the "restarting" ability, because the index changes */ - info.command=RET_TWO; - idx=i=0; - while((ret=H5Giterate(file,"/",&idx,giter_cb,&info))>0) { + info.command = RET_TWO; + idx = i = 0; + while((ret = H5Giterate(file, "/", &idx, giter_cb, &info)) > 0) { /* Verify return value from iterator gets propagated correctly */ - VERIFY(ret,2,"H5Giterate"); + VERIFY(ret, 2, "H5Giterate"); - /* Increment the number of times "1" is returned */ + /* Increment the number of times "2" is returned */ i++; /* Verify that the index is the correct value */ - VERIFY(idx,i,"H5Giterate"); + VERIFY(idx, i, "H5Giterate"); + if(idx > (NDATASETS + 2)) + TestErrPrintf("Group iteration function walked too far!\n"); /* Verify that the correct name is retrieved */ - if(idx<=NDATASETS) { - if(HDstrcmp(info.name,dnames[idx-1])!=0) - TestErrPrintf("Group iteration function didn't return one correctly for dataset #%d!\n",idx); - } /* end if */ - else if(idx==(NDATASETS+1)) { - if(HDstrcmp(info.name,"dtype")!=0) - TestErrPrintf("Group iteration function didn't return one correctly for group!\n"); - } /* end if */ - else if(idx==(NDATASETS+2)) { - if(HDstrcmp(info.name,"grp")!=0) - TestErrPrintf("Group iteration function didn't return one correctly for group!\n"); - } /* end if */ - else - TestErrPrintf("Group iteration function walked too far!\n"); - } - VERIFY(ret,-1,"H5Giterate"); + if(HDstrcmp(info.name, lnames[idx - 1]) != 0) + TestErrPrintf("Group iteration function didn't return name correctly for link - lnames[%u] = '%s'!\n", (idx - 1), lnames[idx - 1]); + } /* end while */ + VERIFY(ret, -1, "H5Giterate"); - if(i!=(NDATASETS+2)) + if(i != (NDATASETS + 2)) TestErrPrintf("Group iteration function didn't perform multiple iterations correctly!\n"); /* Test all objects in group, when callback changes return value */ /* This also tests the "restarting" ability, because the index changes */ - info.command=RET_CHANGE; - idx=i=0; - while((ret=H5Giterate(file,"/",&idx,giter_cb,&info))>=0) { + info.command = new_format ? RET_CHANGE2 : RET_CHANGE; + idx = i = 0; + while((ret = H5Giterate(file, "/", &idx, giter_cb, &info)) >= 0) { /* Verify return value from iterator gets propagated correctly */ - VERIFY(ret,1,"H5Giterate"); + VERIFY(ret, 1, "H5Giterate"); /* Increment the number of times "1" is returned */ i++; /* Verify that the index is the correct value */ - VERIFY(idx,i+10,"H5Giterate"); + VERIFY(idx, (i + 10), "H5Giterate"); + if(idx > (NDATASETS + 2)) + TestErrPrintf("Group iteration function walked too far!\n"); /* Verify that the correct name is retrieved */ - if(idx<=NDATASETS) { - if(HDstrcmp(info.name,dnames[idx-1])!=0) - TestErrPrintf("Group iteration function didn't return one correctly for dataset #%d!\n",idx); - } /* end if */ - else if(idx==(NDATASETS+1)) { - if(HDstrcmp(info.name,"dtype")!=0) - TestErrPrintf("Group iteration function didn't return one correctly for group!\n"); - } /* end if */ - else if(idx==(NDATASETS+2)) { - if(HDstrcmp(info.name,"grp")!=0) - TestErrPrintf("Group iteration function didn't return one correctly for group!\n"); - } /* end if */ - else - TestErrPrintf("Group iteration function walked too far!\n"); - } - VERIFY(ret,-1,"H5Giterate"); + if(HDstrcmp(info.name, lnames[idx - 1]) != 0) + TestErrPrintf("Group iteration function didn't return name correctly for link - lnames[%u] = '%s'!\n", (idx - 1), lnames[idx - 1]); + } /* end while */ + VERIFY(ret, -1, "H5Giterate"); - if(i!=42 || idx!=52) + if(i != 42 || idx != 52) TestErrPrintf("Group iteration function didn't perform multiple iterations correctly!\n"); - ret=H5Fclose(file); + ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); /* Free the dataset names */ - for(i=0; i< NDATASETS; i++) - HDfree(dnames[i]); - + for(i = 0; i< (NDATASETS + 2); i++) + HDfree(lnames[i]); } /* test_iter_group() */ /**************************************************************** @@ -352,12 +343,14 @@ static void test_iter_group(void) ** aiter_cb(): Custom group iteration callback routine. ** ****************************************************************/ -herr_t aiter_cb(hid_t UNUSED group, const char *name, void *op_data) +herr_t +aiter_cb(hid_t UNUSED group, const char *name, void *op_data) { - iter_info *info=(iter_info *)op_data; - static int count=0; + iter_info *info = (iter_info *)op_data; + static int count = 0; + static int count2 = 0; - strcpy(info->name,name); + HDstrcpy(info->name, name); switch(info->command) { case RET_ZERO: @@ -368,20 +361,24 @@ herr_t aiter_cb(hid_t UNUSED group, const char *name, void *op_data) case RET_CHANGE: count++; - return(count>10 ? 1: 0); + return(count > 10 ? 1: 0); + + case RET_CHANGE2: + count2++; + return(count2 > 10 ? 1: 0); default: printf("invalid iteration command"); return(-1); } /* end switch */ -} +} /* end aiter_cb() */ /**************************************************************** ** ** test_iter_attr(): Test attribute iteration functionality ** ****************************************************************/ -static void test_iter_attr(void) +static void test_iter_attr(hid_t fapl, hbool_t new_format) { hid_t file; /* File ID */ hid_t dataset; /* Common Dataset ID */ @@ -398,7 +395,7 @@ static void test_iter_attr(void) MESSAGE(5, ("Testing Attribute Iteration Functionality\n")); /* Create the test file with the datasets */ - file = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); CHECK(file, FAIL, "H5Fcreate"); filespace=H5Screate(H5S_SCALAR); @@ -432,7 +429,7 @@ static void test_iter_attr(void) /* Iterate through the attributes on the dataset in various ways */ - file=H5Fopen(DATAFILE, H5F_ACC_RDONLY, H5P_DEFAULT); + file=H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl); CHECK(file, FAIL, "H5Fopen"); dataset=H5Dopen(file, "Dataset"); @@ -486,7 +483,7 @@ static void test_iter_attr(void) /* Test all attributes on dataset, when callback changes return value */ /* This also tests the "restarting" ability, because the index changes */ - info.command=RET_CHANGE; + info.command = new_format ? RET_CHANGE2 : RET_CHANGE; idx=i=0; while((ret=H5Aiterate(dataset,&idx,aiter_cb,&info))>0) { /* Verify return value from iterator gets propagated correctly */ @@ -525,8 +522,8 @@ static void test_iter_attr(void) ****************************************************************/ int iter_strcmp2(const void *s1, const void *s2) { - return(strcmp((const char *)s1,(const char *)s2)); -} + return(HDstrcmp((const char *)s1,(const char *)s2)); +} /* end iter_strcmp2() */ /**************************************************************** ** @@ -535,23 +532,23 @@ int iter_strcmp2(const void *s1, const void *s2) ****************************************************************/ herr_t giter_cb2(hid_t loc_id, const char *name, void *opdata) { - const iter_info *test_info=(const iter_info *)opdata; - herr_t ret; /* Generic return value */ + const iter_info *test_info = (const iter_info *)opdata; H5G_stat_t statbuf; + herr_t ret; /* Generic return value */ - if(HDstrcmp(name,test_info->name)) { - TestErrPrintf("name=%s, test_info=%s\n",name,test_info->name); + if(HDstrcmp(name, test_info->name)) { + TestErrPrintf("name = '%s', test_info = '%s'\n", name, test_info->name); return(-1); } /* end if */ /* * Get type of the object and check it. */ - ret=H5Gget_objinfo(loc_id, name, FALSE, &statbuf); + ret = H5Gget_objinfo(loc_id, name, FALSE, &statbuf); CHECK(ret, FAIL, "H5Gget_objinfo"); - if(test_info->type!=statbuf.type) { - TestErrPrintf("test_info->type=%d, statbuf.type=%d\n",test_info->type,statbuf.type); + if(test_info->type != statbuf.type) { + TestErrPrintf("test_info->type = %d, statbuf.type = %d\n", test_info->type, statbuf.type); return(-1); } /* end if */ @@ -564,7 +561,7 @@ herr_t giter_cb2(hid_t loc_id, const char *name, void *opdata) ** for groups with large #'s of objects ** ****************************************************************/ -static void test_iter_group_large(void) +static void test_iter_group_large(hid_t fapl) { hid_t file; /* HDF5 File IDs */ hid_t dataset; /* Dataset ID */ @@ -585,13 +582,13 @@ static void test_iter_group_large(void) float c; } s1_t; - memset(names, 0, sizeof names); + HDmemset(names, 0, sizeof names); /* Output message about test being performed */ MESSAGE(5, ("Testing Large Group Iteration Functionality\n")); /* Create file */ - file = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); CHECK(file, FAIL, "H5Fcreate"); /* Create dataspace for datasets */ @@ -599,29 +596,29 @@ static void test_iter_group_large(void) CHECK(sid, FAIL, "H5Screate_simple"); /* Create a bunch of groups */ - for (i=0; i<ITER_NGROUPS; i++) { + for(i = 0; i < ITER_NGROUPS; i++) { sprintf(gname, "Group_%d", i); /* Add the name to the list of objects in the root group */ - strcpy(names[i].name,gname); - names[i].type=H5G_GROUP; + HDstrcpy(names[i].name, gname); + names[i].type = H5G_GROUP; /* Create a group */ - group=H5Gcreate(file,gname,0); + group = H5Gcreate(file, gname, 0); CHECK(group, FAIL, "H5Gcreate"); /* Close a group */ ret = H5Gclose(group); CHECK(ret, FAIL, "H5Gclose"); - } + } /* end for */ /* Create a dataset */ - dataset=H5Dcreate(file,"Dataset1",H5T_STD_U32LE,sid,H5P_DEFAULT); + dataset = H5Dcreate(file, "Dataset1", H5T_STD_U32LE, sid, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate"); /* Add the name to the list of objects in the root group */ - strcpy(names[ITER_NGROUPS].name,"Dataset1"); - names[ITER_NGROUPS].type=H5G_DATASET; + HDstrcpy(names[ITER_NGROUPS].name, "Dataset1"); + names[ITER_NGROUPS].type = H5G_DATASET; /* Close Dataset */ ret = H5Dclose(dataset); @@ -632,40 +629,42 @@ static void test_iter_group_large(void) CHECK(ret, FAIL, "H5Sclose"); /* Create a datatype */ - tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t)); + tid = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); CHECK(tid, FAIL, "H5Tcreate"); /* Insert fields */ - ret=H5Tinsert (tid, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT); + ret = H5Tinsert(tid, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret=H5Tinsert (tid, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT); + ret = H5Tinsert(tid, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret=H5Tinsert (tid, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT); + ret = H5Tinsert(tid, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT); CHECK(ret, FAIL, "H5Tinsert"); /* Save datatype for later */ - ret=H5Tcommit (file, "Datatype1", tid); + ret = H5Tcommit(file, "Datatype1", tid); CHECK(ret, FAIL, "H5Tcommit"); /* Add the name to the list of objects in the root group */ - strcpy(names[ITER_NGROUPS+1].name,"Datatype1"); - names[ITER_NGROUPS+1].type=H5G_TYPE; + HDstrcpy(names[ITER_NGROUPS + 1].name, "Datatype1"); + names[ITER_NGROUPS + 1].type = H5G_TYPE; /* Close datatype */ ret = H5Tclose(tid); CHECK(ret, FAIL, "H5Tclose"); /* Need to sort the names in the root group, cause that's what the library does */ - qsort(names,ITER_NGROUPS+2,sizeof(iter_info),iter_strcmp2); + HDqsort(names, (ITER_NGROUPS + 2), sizeof(iter_info), iter_strcmp2); /* Iterate through the file to see members of the root group */ - curr_name=&names[0]; - H5Giterate(file, "/", NULL, giter_cb2, curr_name); - for (i=1; i<100; ) { - curr_name=&names[i]; - H5Giterate(file, "/", &i, giter_cb2, curr_name); + curr_name = &names[0]; + ret = H5Giterate(file, "/", NULL, giter_cb2, curr_name); + CHECK(ret, FAIL, "H5Giterate"); + for(i = 1; i < 100; ) { + curr_name = &names[i]; + ret = H5Giterate(file, "/", &i, giter_cb2, curr_name); + CHECK(ret, FAIL, "H5Giterate"); } /* end for */ /* Close file */ @@ -679,7 +678,7 @@ static void test_iter_group_large(void) ** functionality ** ****************************************************************/ -static void test_grp_memb_funcs(void) +static void test_grp_memb_funcs(hid_t fapl) { hid_t file; /* File ID */ hid_t dataset; /* Dataset ID */ @@ -699,7 +698,7 @@ static void test_grp_memb_funcs(void) MESSAGE(5, ("Testing Group Member Information Functionality\n")); /* Create the test file with the datasets */ - file = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); CHECK(file, FAIL, "H5Fcreate"); datatype = H5Tcopy(H5T_NATIVE_INT); @@ -708,18 +707,18 @@ static void test_grp_memb_funcs(void) filespace=H5Screate(H5S_SCALAR); CHECK(filespace, FAIL, "H5Screate"); - for(i=0; i< NDATASETS; i++) { + for(i = 0; i< NDATASETS; i++) { sprintf(name,"Dataset %d",i); dataset = H5Dcreate(file, name, datatype, filespace, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate"); /* Keep a copy of the dataset names around for later */ - dnames[i]=HDstrdup(name); + dnames[i] = HDstrdup(name); CHECK(dnames[i], NULL, "strdup"); - ret=H5Dclose(dataset); + ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); - } + } /* end for */ /* Create a group and named datatype under root group for testing * H5Gget_objtype_by_idx. @@ -727,33 +726,33 @@ static void test_grp_memb_funcs(void) grp = H5Gcreate(file, "grp", 0); CHECK(ret, FAIL, "H5Gcreate"); - dnames[NDATASETS]=HDstrdup("grp"); + dnames[NDATASETS] = HDstrdup("grp"); CHECK(dnames[NDATASETS], NULL, "strdup"); ret = H5Tcommit(file, "dtype", datatype); CHECK(ret, FAIL, "H5Tcommit"); - dnames[NDATASETS+1]=HDstrdup("dtype"); + dnames[NDATASETS + 1] = HDstrdup("dtype"); CHECK(dnames[NDATASETS], NULL, "strdup"); /* Close everything up */ - ret=H5Tclose(datatype); + ret = H5Tclose(datatype); CHECK(ret, FAIL, "H5Tclose"); - ret=H5Gclose(grp); + ret = H5Gclose(grp); CHECK(ret, FAIL, "H5Gclose"); - ret=H5Sclose(filespace); + ret = H5Sclose(filespace); CHECK(ret, FAIL, "H5Sclose"); - ret=H5Fclose(file); + ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); /* Sort the dataset names */ - HDqsort(dnames,NDATASETS+2,sizeof(char *),iter_strcmp); + HDqsort(dnames, (NDATASETS + 2), sizeof(char *), iter_strcmp); /* Iterate through the datasets in the root group in various ways */ - file=H5Fopen(DATAFILE, H5F_ACC_RDONLY, H5P_DEFAULT); + file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl); CHECK(file, FAIL, "H5Fopen"); /* These two functions, H5Gget_num_objs and H5Gget_objname_by_idx, actually @@ -773,14 +772,14 @@ static void test_grp_memb_funcs(void) name_len = H5Gget_objname_by_idx(root_group, (hsize_t)i, NULL, NAMELEN); CHECK(name_len, FAIL, "H5Gget_objname_by_idx"); - ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, (size_t)(name_len+1)); + ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, (size_t)(name_len + 1)); CHECK(ret, FAIL, "H5Gget_objname_by_idx"); /* Double-check that the length is the same */ VERIFY(ret, name_len, "H5Gget_objname_by_idx"); /* Keep a copy of the dataset names around for later */ - obj_names[i]=HDstrdup(dataset_name); + obj_names[i] = HDstrdup(dataset_name); CHECK(obj_names[i], NULL, "strdup"); obj_type = H5Gget_objtype_by_idx(root_group, (hsize_t)i); @@ -792,7 +791,7 @@ static void test_grp_memb_funcs(void) VERIFY(obj_type, H5G_TYPE, "H5Gget_objname_by_idx"); if(!HDstrncmp(dataset_name, "Dataset", 7)) VERIFY(obj_type, H5G_DATASET, "H5Gget_objname_by_idx"); - } + } /* end for */ H5E_BEGIN_TRY { ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)(NDATASETS+3), dataset_name, NAMELEN); @@ -800,27 +799,26 @@ static void test_grp_memb_funcs(void) VERIFY(ret, FAIL, "H5Gget_objname_by_idx"); /* Sort the dataset names */ - qsort(obj_names,NDATASETS+2,sizeof(char *),iter_strcmp); + HDqsort(obj_names, (NDATASETS + 2), sizeof(char *), iter_strcmp); /* Compare object names */ - for(i=0; i< (int)num_membs; i++) { + for(i = 0; i< (int)num_membs; i++) { ret = HDstrcmp(dnames[i], obj_names[i]); VERIFY(ret, 0, "HDstrcmp"); - } + } /* end for */ ret = H5Gclose(root_group); CHECK(ret, FAIL, "H5Gclose"); - ret=H5Fclose(file); + ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); /* Free the dataset names */ - for(i=0; i< NDATASETS+2; i++) { - free(dnames[i]); - free(obj_names[i]); - } - + for(i = 0; i< (NDATASETS + 2); i++) { + HDfree(dnames[i]); + HDfree(obj_names[i]); + } /* end for */ } /* test_grp_memb_funcs() */ /**************************************************************** @@ -828,7 +826,7 @@ static void test_grp_memb_funcs(void) ** test_links(): Test soft and hard link iteration ** ****************************************************************/ -static void test_links(void) +static void test_links(hid_t fapl) { hid_t file; /* File ID */ char obj_name[NAMELEN]; /* Names of the object in group */ @@ -843,7 +841,7 @@ static void test_links(void) MESSAGE(5, ("Testing Soft and Hard Link Iteration Functionality\n")); /* Create the test file with the datasets */ - file = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); CHECK(file, FAIL, "H5Fcreate"); /* create groups */ @@ -854,10 +852,10 @@ static void test_links(void) CHECK(gid1, FAIL, "H5Gcreate"); /* create soft and hard links to the group "/g1". */ - ret = H5Glink (gid, H5L_LINK_SOFT, "something", "softlink"); + ret = H5Glink (gid, H5L_TYPE_SOFT, "something", "softlink"); CHECK(ret, FAIL, "H5Glink"); - ret = H5Glink (gid, H5L_LINK_HARD, "/g1", "hardlink"); + ret = H5Glink (gid, H5L_TYPE_HARD, "/g1", "hardlink"); CHECK(ret, FAIL, "H5Glink"); ret = H5Gget_num_objs(gid, &nobjs); @@ -865,7 +863,7 @@ static void test_links(void) VERIFY(nobjs,3,"H5Gget_num_objs"); /* Test these two functions, H5Gget_num_objs and H5Gget_objname_by_idx */ - for(i=0; i<nobjs; i++) { + for(i = 0; i < nobjs; i++) { /* Get object name */ name_len = H5Gget_objname_by_idx(gid, i, obj_name, NAMELEN); CHECK(name_len, FAIL, "H5Gget_objname_by_idx"); @@ -883,13 +881,13 @@ static void test_links(void) CHECK(0, 0, "unknown object name"); } - ret=H5Gclose(gid); + ret = H5Gclose(gid); CHECK(ret, FAIL, "H5Gclose"); - ret=H5Gclose(gid1); + ret = H5Gclose(gid1); CHECK(ret, FAIL, "H5Gclose"); - ret=H5Fclose(file); + ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); } /* test_links() */ @@ -901,15 +899,39 @@ static void test_links(void) void test_iterate(void) { + hid_t fapl, fapl2; /* File access property lists */ + hbool_t new_format; /* Whether to use the new format or not */ + herr_t ret; /* Generic return value */ + /* Output message about test being performed */ MESSAGE(5, ("Testing Iteration Operations\n")); + /* Get the default FAPL */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Copy the file access property list */ + fapl2 = H5Pcopy(fapl); + CHECK(fapl2, FAIL, "H5Pcopy"); + + /* Set the "use the latest version of the format" flag for creating objects in the file */ + ret = H5Pset_latest_format(fapl2, TRUE); + CHECK(ret, FAIL, "H5Pset_latest_format"); + /* These next tests use the same file */ - test_iter_group(); /* Test group iteration */ - test_iter_group_large(); /* Test group iteration for large # of objects */ - test_iter_attr(); /* Test attribute iteration */ - test_grp_memb_funcs(); /* Test group member information functions */ - test_links(); /* Test soft and hard link iteration */ + for(new_format = FALSE; new_format <= TRUE; new_format++) { + test_iter_group(new_format ? fapl2 : fapl, new_format); /* Test group iteration */ + test_iter_group_large(new_format ? fapl2 : fapl); /* Test group iteration for large # of objects */ + test_iter_attr(new_format ? fapl2 : fapl, new_format); /* Test attribute iteration */ + test_grp_memb_funcs(new_format ? fapl2 : fapl); /* Test group member information functions */ + test_links(new_format ? fapl2 : fapl); /* Test soft and hard link iteration */ + } /* end for */ + + /* Close FAPLs */ + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl2); + CHECK(ret, FAIL, "H5Pclose"); } /* test_iterate() */ |