From 99f5644383b7426c3ae2c5252ce957634291e75f Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 12 Apr 2000 10:44:48 -0500 Subject: [svn-r2118] Added test for error in which groups with more than one level of B-tree nodes and callback functions which returned non-zero were not working correctly. --- test/titerate.c | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 169 insertions(+), 2 deletions(-) diff --git a/test/titerate.c b/test/titerate.c index 8727d95..751f090 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -36,18 +36,29 @@ static char RcsId[] = "$Revision$"; /* Number of attributes for group iteration test */ #define NATTR 50 +/* Number of groups for second group iteration test */ +#define NGROUPS 150 + /* General maximum length of names used */ #define NAMELEN 80 +/* 1-D dataset with fixed dimensions */ +#define SPACE1_NAME "Space1" +#define SPACE1_RANK 1 +#define SPACE1_DIM1 4 + /* Custom group iteration callback data */ typedef struct { - enum {RET_ZERO, RET_ONE, RET_CHANGE} command; - char name[NAMELEN]; + char name[NAMELEN]; /* The name of the object */ + int type; /* The type of the object */ + enum {RET_ZERO, RET_ONE, RET_CHANGE} command; /* The type of return value */ } iter_info; /* Local functions */ int iter_strcmp(const void *s1, const void *s2); +int iter_strcmp2(const void *s1, const void *s2); herr_t giter_cb(hid_t group, const char *name, void *op_data); +herr_t giter_cb2(hid_t group, const char *name, void *op_data); herr_t aiter_cb(hid_t loc_id, const char *name, void *op_data); /**************************************************************** @@ -358,6 +369,161 @@ static void test_iter_attr(void) /**************************************************************** ** +** iter_strcmp2(): String comparison routine for qsort +** +****************************************************************/ +int iter_strcmp2(const void *s1, const void *s2) +{ + return(strcmp((const char *)s1,(const char *)s2)); +} + +/**************************************************************** +** +** giter_cb2(): Custom group iteration callback routine. +** +****************************************************************/ +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 */ + H5G_stat_t statbuf; + + if(strcmp(name,test_info->name)) { + num_errs++; + printf("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); + CHECK(ret, FAIL, "H5Gget_objinfo"); + + if(test_info->type!=statbuf.type) { + num_errs++; + printf("test_info->type=%d, statbuf.type=%d\n",test_info->type,statbuf.type); + return(-1); + } /* end if */ + + return(1); +} /* giter_cb2() */ + +/**************************************************************** +** +** test_iter_group_large(): Test group iteration functionality +** for groups with large #'s of objects +** +****************************************************************/ +static void test_iter_group_large(void) +{ + hid_t file; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t group; /* Group ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid; /* Datatype ID */ + hsize_t dims[] = {SPACE1_DIM1}; + herr_t ret; /* Generic return value */ + char gname[20]; /* Temporary group name */ + iter_info names[NGROUPS+2]={0}; /* Names of objects in the root group */ + iter_info *curr_name; /* Pointer to the current name in the root group */ + int i; + + /* Compound datatype */ + typedef struct s1_t { + unsigned int a; + unsigned int b; + float c; + } s1_t; + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Large Group Iteration Functionality\n")); + + /* Create file */ + file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(file, FAIL, "H5Fcreate"); + + /* Create dataspace for datasets */ + sid = H5Screate_simple(SPACE1_RANK, dims, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + + /* Create a bunch of groups */ + for (i=0; i