2003-04-01 01:59:04 +08:00
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
|
* Copyright by The HDF Group. *
|
2003-04-01 01:59:04 +08:00
|
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
|
* All rights reserved. *
|
|
|
|
|
* *
|
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
|
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
|
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
|
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
|
|
|
* is linked from the top-level documents page. It can also be found at *
|
2007-02-07 22:56:24 +08:00
|
|
|
|
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
|
* access to either file, you may request a copy from help@hdfgroup.org. *
|
2003-04-01 01:59:04 +08:00
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
/***********************************************************
|
|
|
|
|
*
|
|
|
|
|
* Test program: titerate
|
|
|
|
|
*
|
|
|
|
|
* Test the Group & Attribute functionality
|
|
|
|
|
*
|
|
|
|
|
*************************************************************/
|
|
|
|
|
|
2001-04-04 02:09:16 +08:00
|
|
|
|
#include "testhdf5.h"
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
2001-04-04 02:09:16 +08:00
|
|
|
|
#include "hdf5.h"
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
2001-04-01 11:25:53 +08:00
|
|
|
|
#define DATAFILE "titerate.h5"
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
/* Number of datasets for group iteration test */
|
|
|
|
|
#define NDATASETS 50
|
|
|
|
|
|
2003-06-23 21:25:06 +08:00
|
|
|
|
/* Number of attributes for attribute iteration test */
|
2000-04-06 04:51:44 +08:00
|
|
|
|
#define NATTR 50
|
|
|
|
|
|
2000-04-12 23:44:48 +08:00
|
|
|
|
/* Number of groups for second group iteration test */
|
2002-08-10 05:55:44 +08:00
|
|
|
|
#define ITER_NGROUPS 150
|
2000-04-12 23:44:48 +08:00
|
|
|
|
|
2000-04-06 04:51:44 +08:00
|
|
|
|
/* General maximum length of names used */
|
|
|
|
|
#define NAMELEN 80
|
|
|
|
|
|
2000-04-12 23:44:48 +08:00
|
|
|
|
/* 1-D dataset with fixed dimensions */
|
|
|
|
|
#define SPACE1_NAME "Space1"
|
|
|
|
|
#define SPACE1_RANK 1
|
|
|
|
|
#define SPACE1_DIM1 4
|
|
|
|
|
|
2001-09-26 01:46:32 +08:00
|
|
|
|
typedef enum {
|
|
|
|
|
RET_ZERO,
|
2003-06-23 21:25:06 +08:00
|
|
|
|
RET_TWO,
|
2006-10-02 18:24:03 +08:00
|
|
|
|
RET_CHANGE,
|
|
|
|
|
RET_CHANGE2
|
2001-09-26 01:46:32 +08:00
|
|
|
|
} iter_enum;
|
|
|
|
|
|
2000-04-06 04:51:44 +08:00
|
|
|
|
/* Custom group iteration callback data */
|
|
|
|
|
typedef struct {
|
2000-04-12 23:44:48 +08:00
|
|
|
|
char name[NAMELEN]; /* The name of the object */
|
|
|
|
|
int type; /* The type of the object */
|
2001-09-26 01:46:32 +08:00
|
|
|
|
iter_enum command; /* The type of return value */
|
2000-04-06 04:51:44 +08:00
|
|
|
|
} iter_info;
|
|
|
|
|
|
|
|
|
|
/* Local functions */
|
|
|
|
|
int iter_strcmp(const void *s1, const void *s2);
|
2000-04-12 23:44:48 +08:00
|
|
|
|
int iter_strcmp2(const void *s1, const void *s2);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
herr_t giter_cb(hid_t group, const char *name, void *op_data);
|
2000-04-12 23:44:48 +08:00
|
|
|
|
herr_t giter_cb2(hid_t group, const char *name, void *op_data);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
herr_t aiter_cb(hid_t loc_id, const char *name, void *op_data);
|
|
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
|
**
|
|
|
|
|
** iter_strcmp(): String comparison routine for qsort
|
2005-08-14 04:53:35 +08:00
|
|
|
|
**
|
2000-04-06 04:51:44 +08:00
|
|
|
|
****************************************************************/
|
|
|
|
|
int iter_strcmp(const void *s1, const void *s2)
|
|
|
|
|
{
|
2006-10-02 18:24:03 +08:00
|
|
|
|
return(HDstrcmp(*(const char * const *)s1,*(const char * const *)s2));
|
2000-04-06 04:51:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
|
**
|
|
|
|
|
** giter_cb(): Custom group iteration callback routine.
|
2005-08-14 04:53:35 +08:00
|
|
|
|
**
|
2000-04-06 04:51:44 +08:00
|
|
|
|
****************************************************************/
|
|
|
|
|
herr_t giter_cb(hid_t UNUSED group, const char *name, void *op_data)
|
|
|
|
|
{
|
2006-10-02 18:24:03 +08:00
|
|
|
|
iter_info *info = (iter_info *)op_data;
|
|
|
|
|
static int count = 0;
|
|
|
|
|
static int count2 = 0;
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
HDstrcpy(info->name, name);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
switch(info->command) {
|
|
|
|
|
case RET_ZERO:
|
|
|
|
|
return(0);
|
|
|
|
|
|
2003-06-23 21:25:06 +08:00
|
|
|
|
case RET_TWO:
|
|
|
|
|
return(2);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
case RET_CHANGE:
|
|
|
|
|
count++;
|
2006-10-02 18:24:03 +08:00
|
|
|
|
return(count > 10 ? 1 : 0);
|
|
|
|
|
|
|
|
|
|
case RET_CHANGE2:
|
|
|
|
|
count2++;
|
|
|
|
|
return(count2 > 10 ? 1 : 0);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
printf("invalid iteration command");
|
|
|
|
|
return(-1);
|
|
|
|
|
} /* end switch */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
} /* end giter_cb() */
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
|
**
|
|
|
|
|
** test_iter_group(): Test group iteration functionality
|
2005-08-14 04:53:35 +08:00
|
|
|
|
**
|
2000-04-06 04:51:44 +08:00
|
|
|
|
****************************************************************/
|
2006-10-02 18:24:03 +08:00
|
|
|
|
static void test_iter_group(hid_t fapl, hbool_t new_format)
|
2000-04-06 04:51:44 +08:00
|
|
|
|
{
|
|
|
|
|
hid_t file; /* File ID */
|
|
|
|
|
hid_t dataset; /* Dataset ID */
|
|
|
|
|
hid_t datatype; /* Common datatype ID */
|
|
|
|
|
hid_t filespace; /* Common dataspace ID */
|
2002-11-26 01:59:14 +08:00
|
|
|
|
hid_t root_group,grp; /* Root group ID */
|
2000-04-06 04:51:44 +08:00
|
|
|
|
int i; /* counting variable */
|
|
|
|
|
int idx; /* Index in the group */
|
|
|
|
|
char name[NAMELEN]; /* temporary name buffer */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
char *lnames[NDATASETS + 2];/* Names of the links created */
|
2003-08-27 02:35:37 +08:00
|
|
|
|
char dataset_name[NAMELEN]; /* dataset name */
|
2000-04-06 04:51:44 +08:00
|
|
|
|
iter_info info; /* Custom iteration information */
|
2002-11-26 01:59:14 +08:00
|
|
|
|
hsize_t num_membs; /* Number of group members */
|
|
|
|
|
herr_t ret; /* Generic return value */
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
|
MESSAGE(5, ("Testing Group Iteration Functionality\n"));
|
|
|
|
|
|
|
|
|
|
/* Create the test file with the datasets */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
file = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
CHECK(file, FAIL, "H5Fcreate");
|
|
|
|
|
|
2003-06-23 21:25:06 +08:00
|
|
|
|
/* Test iterating over empty group */
|
|
|
|
|
info.command=RET_ZERO;
|
|
|
|
|
idx=0;
|
|
|
|
|
ret=H5Giterate(file,"/",&idx,giter_cb,&info);
|
|
|
|
|
VERIFY(ret, SUCCEED, "H5Giterate");
|
|
|
|
|
|
2000-04-06 04:51:44 +08:00
|
|
|
|
datatype = H5Tcopy(H5T_NATIVE_INT);
|
|
|
|
|
CHECK(datatype, FAIL, "H5Tcopy");
|
|
|
|
|
|
|
|
|
|
filespace=H5Screate(H5S_SCALAR);
|
|
|
|
|
CHECK(filespace, FAIL, "H5Screate");
|
|
|
|
|
|
|
|
|
|
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 */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
lnames[i] = HDstrdup(name);
|
|
|
|
|
CHECK(lnames[i], NULL, "strdup");
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Dclose(dataset);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Dclose");
|
2006-10-02 18:24:03 +08:00
|
|
|
|
} /* end for */
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
|
/* Create a group and named datatype under root group for testing
|
2002-11-26 01:59:14 +08:00
|
|
|
|
* H5Gget_objtype_by_idx.
|
|
|
|
|
*/
|
2007-08-24 04:25:25 +08:00
|
|
|
|
grp = H5Gcreate2(file, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
|
|
|
|
CHECK(ret, FAIL, "H5Gcreate2");
|
2002-11-26 01:59:14 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
lnames[NDATASETS] = HDstrdup("grp");
|
|
|
|
|
CHECK(lnames[NDATASETS], NULL, "strdup");
|
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
|
ret = H5Tcommit(file, "dtype", datatype);
|
2002-11-26 01:59:14 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Tcommit");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
lnames[NDATASETS + 1] = HDstrdup("dtype");
|
|
|
|
|
CHECK(lnames[NDATASETS], NULL, "strdup");
|
|
|
|
|
|
2000-04-06 04:51:44 +08:00
|
|
|
|
/* Close everything up */
|
|
|
|
|
ret=H5Tclose(datatype);
|
|
|
|
|
CHECK(ret, FAIL, "H5Tclose");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2002-11-26 01:59:14 +08:00
|
|
|
|
ret=H5Gclose(grp);
|
|
|
|
|
CHECK(ret, FAIL, "H5Gclose");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2000-04-06 04:51:44 +08:00
|
|
|
|
ret=H5Sclose(filespace);
|
|
|
|
|
CHECK(ret, FAIL, "H5Sclose");
|
|
|
|
|
|
|
|
|
|
ret=H5Fclose(file);
|
|
|
|
|
CHECK(ret, FAIL, "H5Fclose");
|
|
|
|
|
|
|
|
|
|
/* Sort the dataset names */
|
2006-10-31 04:00:57 +08:00
|
|
|
|
HDqsort(lnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
2002-11-26 01:59:14 +08:00
|
|
|
|
|
2000-04-06 04:51:44 +08:00
|
|
|
|
/* Iterate through the datasets in the root group in various ways */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
CHECK(file, FAIL, "H5Fopen");
|
|
|
|
|
|
2003-06-23 21:25:06 +08:00
|
|
|
|
/* These two functions, H5Gget_num_objs and H5Gget_objname_by_idx, actually
|
2002-11-26 01:59:14 +08:00
|
|
|
|
* iterate through B-tree for group members in internal library design.
|
|
|
|
|
*/
|
|
|
|
|
{
|
2007-08-28 23:02:54 +08:00
|
|
|
|
root_group = H5Gopen2(file, "/", H5P_DEFAULT);
|
|
|
|
|
CHECK(root_group, FAIL, "H5Gopen2");
|
2002-11-26 01:59:14 +08:00
|
|
|
|
|
|
|
|
|
ret = H5Gget_num_objs(root_group, &num_membs);
|
|
|
|
|
CHECK(ret, FAIL, "H5Gget_num_objs");
|
2006-10-02 18:24:03 +08:00
|
|
|
|
VERIFY(num_membs, (NDATASETS + 2), "H5Gget_num_objs");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
for(i = 0; i< (int)num_membs; i++) {
|
2003-07-08 03:02:46 +08:00
|
|
|
|
H5G_obj_t obj_type; /* Type of object in file */
|
|
|
|
|
|
2006-10-31 04:00:57 +08:00
|
|
|
|
ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, (size_t)NAMELEN);
|
2003-08-27 02:35:37 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Gget_objname_by_idx");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2003-07-08 03:02:46 +08:00
|
|
|
|
obj_type = H5Gget_objtype_by_idx(root_group, (hsize_t)i);
|
2003-08-27 02:35:37 +08:00
|
|
|
|
CHECK(obj_type, H5G_UNKNOWN, "H5Gget_objtype_by_idx");
|
2006-10-02 18:24:03 +08:00
|
|
|
|
} /* end for */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2002-11-26 01:59:14 +08:00
|
|
|
|
H5E_BEGIN_TRY {
|
2006-10-31 04:00:57 +08:00
|
|
|
|
ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)(NDATASETS+3), dataset_name, (size_t)NAMELEN);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
} H5E_END_TRY;
|
2003-08-27 02:35:37 +08:00
|
|
|
|
VERIFY(ret, FAIL, "H5Gget_objname_by_idx");
|
2002-11-26 01:59:14 +08:00
|
|
|
|
|
|
|
|
|
ret = H5Gclose(root_group);
|
|
|
|
|
CHECK(ret, FAIL, "H5Gclose");
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-22 21:50:01 +08:00
|
|
|
|
/* These two functions, H5Gget_num_objs and H5Gget_objname_by_idx, actually
|
|
|
|
|
* iterate through B-tree for group members in internal library design.
|
|
|
|
|
* (Same as test above, but with the file ID instead of opening the root group)
|
|
|
|
|
*/
|
|
|
|
|
{
|
|
|
|
|
ret = H5Gget_num_objs(file, &num_membs);
|
|
|
|
|
CHECK(ret, FAIL, "H5Gget_num_objs");
|
2006-10-02 18:24:03 +08:00
|
|
|
|
VERIFY(num_membs, NDATASETS + 2, "H5Gget_num_objs");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
for(i = 0; i< (int)num_membs; i++) {
|
2003-08-22 21:50:01 +08:00
|
|
|
|
H5G_obj_t obj_type; /* Type of object in file */
|
|
|
|
|
|
2006-10-31 04:00:57 +08:00
|
|
|
|
ret = (herr_t)H5Gget_objname_by_idx(file, (hsize_t)i, dataset_name, (size_t)NAMELEN);
|
2003-08-27 02:35:37 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Gget_objname_by_idx");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2003-08-22 21:50:01 +08:00
|
|
|
|
obj_type = H5Gget_objtype_by_idx(file, (hsize_t)i);
|
2003-08-27 02:35:37 +08:00
|
|
|
|
CHECK(obj_type, H5G_UNKNOWN, "H5Gget_objtype_by_idx");
|
2003-08-22 21:50:01 +08:00
|
|
|
|
}
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2003-08-22 21:50:01 +08:00
|
|
|
|
H5E_BEGIN_TRY {
|
2006-10-31 04:00:57 +08:00
|
|
|
|
ret = (herr_t)H5Gget_objname_by_idx(file, (hsize_t)(NDATASETS + 3), dataset_name, (size_t)NAMELEN);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
} H5E_END_TRY;
|
2003-08-27 02:35:37 +08:00
|
|
|
|
VERIFY(ret, FAIL, "H5Gget_objname_by_idx");
|
2003-08-22 21:50:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-23 21:25:06 +08:00
|
|
|
|
/* Test invalid indices for starting iteration */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
info.command = RET_ZERO;
|
|
|
|
|
idx = -1;
|
2003-06-23 21:25:06 +08:00
|
|
|
|
H5E_BEGIN_TRY {
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Giterate(file, "/", &idx, giter_cb, &info);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
} H5E_END_TRY;
|
2003-06-23 21:25:06 +08:00
|
|
|
|
VERIFY(ret, FAIL, "H5Giterate");
|
|
|
|
|
|
|
|
|
|
/* Test skipping exactly as many entries as in the group */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
idx = NDATASETS + 2;
|
2003-06-23 21:25:06 +08:00
|
|
|
|
H5E_BEGIN_TRY {
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Giterate(file, "/", &idx, giter_cb, &info);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
} H5E_END_TRY;
|
2003-06-23 21:25:06 +08:00
|
|
|
|
VERIFY(ret, FAIL, "H5Giterate");
|
|
|
|
|
|
|
|
|
|
/* Test skipping more entries than are in the group */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
idx = NDATASETS + 3;
|
2003-06-23 21:25:06 +08:00
|
|
|
|
H5E_BEGIN_TRY {
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Giterate(file, "/", &idx, giter_cb, &info);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
} H5E_END_TRY;
|
2003-06-23 21:25:06 +08:00
|
|
|
|
VERIFY(ret, FAIL, "H5Giterate");
|
|
|
|
|
|
2000-04-06 04:51:44 +08:00
|
|
|
|
/* Test all objects in group, when callback always returns 0 */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
info.command = RET_ZERO;
|
|
|
|
|
idx = 0;
|
|
|
|
|
if((ret = H5Giterate(file, "/", &idx, giter_cb, &info)) > 0)
|
2004-01-10 09:41:13 +08:00
|
|
|
|
TestErrPrintf("Group iteration function didn't return zero correctly!\n");
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
/* Test all objects in group, when callback always returns 1 */
|
|
|
|
|
/* This also tests the "restarting" ability, because the index changes */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
info.command = RET_TWO;
|
|
|
|
|
idx = i = 0;
|
|
|
|
|
while((ret = H5Giterate(file, "/", &idx, giter_cb, &info)) > 0) {
|
2003-06-23 21:25:06 +08:00
|
|
|
|
/* Verify return value from iterator gets propagated correctly */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
VERIFY(ret, 2, "H5Giterate");
|
2003-06-23 21:25:06 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
/* Increment the number of times "2" is returned */
|
2000-04-06 04:51:44 +08:00
|
|
|
|
i++;
|
|
|
|
|
|
|
|
|
|
/* Verify that the index is the correct value */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
VERIFY(idx, i, "H5Giterate");
|
|
|
|
|
if(idx > (NDATASETS + 2))
|
|
|
|
|
TestErrPrintf("Group iteration function walked too far!\n");
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
/* Verify that the correct name is retrieved */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
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");
|
2003-06-23 21:25:06 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
if(i != (NDATASETS + 2))
|
2007-02-13 22:50:48 +08:00
|
|
|
|
TestErrPrintf("%u: Group iteration function didn't perform multiple iterations correctly!\n", __LINE__);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
/* Test all objects in group, when callback changes return value */
|
|
|
|
|
/* This also tests the "restarting" ability, because the index changes */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
info.command = new_format ? RET_CHANGE2 : RET_CHANGE;
|
|
|
|
|
idx = i = 0;
|
|
|
|
|
while((ret = H5Giterate(file, "/", &idx, giter_cb, &info)) >= 0) {
|
2003-06-23 21:25:06 +08:00
|
|
|
|
/* Verify return value from iterator gets propagated correctly */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
VERIFY(ret, 1, "H5Giterate");
|
2003-06-23 21:25:06 +08:00
|
|
|
|
|
2000-04-06 04:51:44 +08:00
|
|
|
|
/* Increment the number of times "1" is returned */
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
|
|
/* Verify that the index is the correct value */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
VERIFY(idx, (i + 10), "H5Giterate");
|
|
|
|
|
if(idx > (NDATASETS + 2))
|
|
|
|
|
TestErrPrintf("Group iteration function walked too far!\n");
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
/* Verify that the correct name is retrieved */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
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");
|
2003-06-23 21:25:06 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
if(i != 42 || idx != 52)
|
2007-02-13 22:50:48 +08:00
|
|
|
|
TestErrPrintf("%u: Group iteration function didn't perform multiple iterations correctly!\n", __LINE__);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Fclose(file);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Fclose");
|
|
|
|
|
|
|
|
|
|
/* Free the dataset names */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
for(i = 0; i< (NDATASETS + 2); i++)
|
|
|
|
|
HDfree(lnames[i]);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
} /* test_iter_group() */
|
|
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
|
**
|
|
|
|
|
** aiter_cb(): Custom group iteration callback routine.
|
2005-08-14 04:53:35 +08:00
|
|
|
|
**
|
2000-04-06 04:51:44 +08:00
|
|
|
|
****************************************************************/
|
2006-10-02 18:24:03 +08:00
|
|
|
|
herr_t
|
|
|
|
|
aiter_cb(hid_t UNUSED group, const char *name, void *op_data)
|
2000-04-06 04:51:44 +08:00
|
|
|
|
{
|
2006-10-02 18:24:03 +08:00
|
|
|
|
iter_info *info = (iter_info *)op_data;
|
|
|
|
|
static int count = 0;
|
|
|
|
|
static int count2 = 0;
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
HDstrcpy(info->name, name);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
switch(info->command) {
|
|
|
|
|
case RET_ZERO:
|
|
|
|
|
return(0);
|
|
|
|
|
|
2003-06-23 21:25:06 +08:00
|
|
|
|
case RET_TWO:
|
|
|
|
|
return(2);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
case RET_CHANGE:
|
|
|
|
|
count++;
|
2006-12-19 09:59:28 +08:00
|
|
|
|
return(count > 10 ? 1 : 0);
|
2006-10-02 18:24:03 +08:00
|
|
|
|
|
|
|
|
|
case RET_CHANGE2:
|
|
|
|
|
count2++;
|
2006-12-19 09:59:28 +08:00
|
|
|
|
return(count2 > 10 ? 1 : 0);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
printf("invalid iteration command");
|
|
|
|
|
return(-1);
|
|
|
|
|
} /* end switch */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
} /* end aiter_cb() */
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
|
**
|
|
|
|
|
** test_iter_attr(): Test attribute iteration functionality
|
2005-08-14 04:53:35 +08:00
|
|
|
|
**
|
2000-04-06 04:51:44 +08:00
|
|
|
|
****************************************************************/
|
2006-10-02 18:24:03 +08:00
|
|
|
|
static void test_iter_attr(hid_t fapl, hbool_t new_format)
|
2000-04-06 04:51:44 +08:00
|
|
|
|
{
|
|
|
|
|
hid_t file; /* File ID */
|
|
|
|
|
hid_t dataset; /* Common Dataset ID */
|
|
|
|
|
hid_t filespace; /* Common dataspace ID */
|
|
|
|
|
hid_t attribute; /* Attribute ID */
|
|
|
|
|
int i; /* counting variable */
|
|
|
|
|
unsigned 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 */
|
|
|
|
|
herr_t ret; /* Generic return value */
|
|
|
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
|
MESSAGE(5, ("Testing Attribute Iteration Functionality\n"));
|
|
|
|
|
|
|
|
|
|
/* Create the test file with the datasets */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
file = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
CHECK(file, FAIL, "H5Fcreate");
|
|
|
|
|
|
|
|
|
|
filespace=H5Screate(H5S_SCALAR);
|
|
|
|
|
CHECK(filespace, FAIL, "H5Screate");
|
|
|
|
|
|
2005-11-15 10:55:39 +08:00
|
|
|
|
dataset = H5Dcreate(file, "Dataset", H5T_NATIVE_INT, filespace, H5P_DEFAULT);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
CHECK(dataset, FAIL, "H5Dcreate");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2003-06-23 21:25:06 +08:00
|
|
|
|
for(i=0; i< NATTR; i++) {
|
2000-04-06 04:51:44 +08:00
|
|
|
|
sprintf(name,"Attribute %d",i);
|
2005-11-15 10:55:39 +08:00
|
|
|
|
attribute = H5Acreate(dataset, name, H5T_NATIVE_INT, filespace, H5P_DEFAULT);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
CHECK(attribute, FAIL, "H5Acreate");
|
|
|
|
|
|
|
|
|
|
/* Keep a copy of the attribute names around for later */
|
2001-06-29 23:27:15 +08:00
|
|
|
|
anames[i]=HDstrdup(name);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
CHECK(anames[i], NULL, "strdup");
|
|
|
|
|
|
|
|
|
|
ret=H5Aclose(attribute);
|
|
|
|
|
CHECK(ret, FAIL, "H5Aclose");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Close everything up */
|
|
|
|
|
ret=H5Dclose(dataset);
|
|
|
|
|
CHECK(ret, FAIL, "H5Dclose");
|
|
|
|
|
|
|
|
|
|
ret=H5Sclose(filespace);
|
|
|
|
|
CHECK(ret, FAIL, "H5Sclose");
|
|
|
|
|
|
|
|
|
|
ret=H5Fclose(file);
|
|
|
|
|
CHECK(ret, FAIL, "H5Fclose");
|
|
|
|
|
|
2005-11-15 10:55:39 +08:00
|
|
|
|
|
2000-04-06 04:51:44 +08:00
|
|
|
|
/* Iterate through the attributes on the dataset in various ways */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
file=H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
CHECK(file, FAIL, "H5Fopen");
|
|
|
|
|
|
|
|
|
|
dataset=H5Dopen(file, "Dataset");
|
|
|
|
|
CHECK(dataset, FAIL, "H5Dopen");
|
|
|
|
|
|
2003-06-23 21:25:06 +08:00
|
|
|
|
/* Test invalid indices for starting iteration */
|
|
|
|
|
info.command=RET_ZERO;
|
|
|
|
|
|
|
|
|
|
/* Test skipping exactly as many attributes as there are */
|
|
|
|
|
idx=NATTR;
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
ret=H5Aiterate(dataset,&idx,aiter_cb,&info);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
} H5E_END_TRY;
|
2003-06-23 21:25:06 +08:00
|
|
|
|
VERIFY(ret, FAIL, "H5Aiterate");
|
|
|
|
|
|
|
|
|
|
/* Test skipping more attributes than there are */
|
|
|
|
|
idx=NATTR+1;
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
ret=H5Aiterate(dataset,&idx,aiter_cb,&info);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
} H5E_END_TRY;
|
2003-06-23 21:25:06 +08:00
|
|
|
|
VERIFY(ret, FAIL, "H5Aiterate");
|
|
|
|
|
|
2000-04-06 04:51:44 +08:00
|
|
|
|
/* Test all attributes on dataset, when callback always returns 0 */
|
2007-02-13 22:50:48 +08:00
|
|
|
|
info.command = RET_ZERO;
|
|
|
|
|
idx = 0;
|
|
|
|
|
if((ret = H5Aiterate(dataset, &idx, aiter_cb, &info)) > 0)
|
2004-01-10 09:41:13 +08:00
|
|
|
|
TestErrPrintf("Attribute iteration function didn't return zero correctly!\n");
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
/* Test all attributes on dataset, when callback always returns 1 */
|
|
|
|
|
/* This also tests the "restarting" ability, because the index changes */
|
2007-02-13 22:50:48 +08:00
|
|
|
|
info.command = RET_TWO;
|
|
|
|
|
idx = i = 0;
|
|
|
|
|
while((ret = H5Aiterate(dataset, &idx, aiter_cb, &info)) > 0) {
|
2003-06-23 21:25:06 +08:00
|
|
|
|
/* Verify return value from iterator gets propagated correctly */
|
2007-02-13 22:50:48 +08:00
|
|
|
|
VERIFY(ret, 2, "H5Aiterate");
|
2003-06-23 21:25:06 +08:00
|
|
|
|
|
2006-12-07 06:19:52 +08:00
|
|
|
|
/* Increment the number of times "2" is returned */
|
2000-04-06 04:51:44 +08:00
|
|
|
|
i++;
|
|
|
|
|
|
|
|
|
|
/* Verify that the index is the correct value */
|
2007-02-13 22:50:48 +08:00
|
|
|
|
VERIFY(idx, (unsigned)i, "H5Aiterate");
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
2007-03-09 04:10:12 +08:00
|
|
|
|
/* 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]);
|
|
|
|
|
} /* end if */
|
2007-02-13 22:50:48 +08:00
|
|
|
|
} /* end while */
|
|
|
|
|
VERIFY(ret, -1, "H5Aiterate");
|
|
|
|
|
if(i != 50 || idx != 50)
|
|
|
|
|
TestErrPrintf("%u: Attribute iteration function didn't perform multiple iterations correctly!\n", __LINE__);
|
2003-06-23 21:25:06 +08:00
|
|
|
|
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
/* Test all attributes on dataset, when callback changes return value */
|
|
|
|
|
/* This also tests the "restarting" ability, because the index changes */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
info.command = new_format ? RET_CHANGE2 : RET_CHANGE;
|
2007-02-13 22:50:48 +08:00
|
|
|
|
idx = i = 0;
|
|
|
|
|
while((ret = H5Aiterate(dataset, &idx, aiter_cb, &info)) > 0) {
|
2003-06-23 21:25:06 +08:00
|
|
|
|
/* Verify return value from iterator gets propagated correctly */
|
2007-02-13 22:50:48 +08:00
|
|
|
|
VERIFY(ret, 1, "H5Aiterate");
|
2003-06-23 21:25:06 +08:00
|
|
|
|
|
2000-04-06 04:51:44 +08:00
|
|
|
|
/* Increment the number of times "1" is returned */
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
|
|
/* Verify that the index is the correct value */
|
2007-02-13 22:50:48 +08:00
|
|
|
|
VERIFY(idx, (unsigned)i + 10, "H5Aiterate");
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
2007-03-09 04:10:12 +08:00
|
|
|
|
/* 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]);
|
|
|
|
|
} /* end if */
|
2007-02-13 22:50:48 +08:00
|
|
|
|
} /* end while */
|
|
|
|
|
VERIFY(ret, -1, "H5Aiterate");
|
|
|
|
|
if(i != 40 || idx != 50)
|
|
|
|
|
TestErrPrintf("%u: Attribute iteration function didn't perform multiple iterations correctly!\n", __LINE__);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
ret=H5Fclose(file);
|
|
|
|
|
CHECK(ret, FAIL, "H5Fclose");
|
|
|
|
|
|
|
|
|
|
ret=H5Dclose(dataset);
|
|
|
|
|
CHECK(ret, FAIL, "H5Dclose");
|
|
|
|
|
|
|
|
|
|
/* Free the attribute names */
|
|
|
|
|
for(i=0; i< NATTR; i++)
|
2004-01-10 09:41:13 +08:00
|
|
|
|
HDfree(anames[i]);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
|
|
|
|
|
} /* test_iter_attr() */
|
|
|
|
|
|
2000-04-12 23:44:48 +08:00
|
|
|
|
/****************************************************************
|
|
|
|
|
**
|
|
|
|
|
** iter_strcmp2(): String comparison routine for qsort
|
2005-08-14 04:53:35 +08:00
|
|
|
|
**
|
2000-04-12 23:44:48 +08:00
|
|
|
|
****************************************************************/
|
|
|
|
|
int iter_strcmp2(const void *s1, const void *s2)
|
|
|
|
|
{
|
2006-12-07 06:19:52 +08:00
|
|
|
|
return(HDstrcmp((const char *)s1, (const char *)s2));
|
2006-10-02 18:24:03 +08:00
|
|
|
|
} /* end iter_strcmp2() */
|
2000-04-12 23:44:48 +08:00
|
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
|
**
|
|
|
|
|
** giter_cb2(): Custom group iteration callback routine.
|
2005-08-14 04:53:35 +08:00
|
|
|
|
**
|
2000-04-12 23:44:48 +08:00
|
|
|
|
****************************************************************/
|
|
|
|
|
herr_t giter_cb2(hid_t loc_id, const char *name, void *opdata)
|
|
|
|
|
{
|
2006-10-02 18:24:03 +08:00
|
|
|
|
const iter_info *test_info = (const iter_info *)opdata;
|
2000-04-12 23:44:48 +08:00
|
|
|
|
H5G_stat_t statbuf;
|
2006-10-02 18:24:03 +08:00
|
|
|
|
herr_t ret; /* Generic return value */
|
2000-04-12 23:44:48 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
if(HDstrcmp(name, test_info->name)) {
|
|
|
|
|
TestErrPrintf("name = '%s', test_info = '%s'\n", name, test_info->name);
|
2000-04-12 23:44:48 +08:00
|
|
|
|
return(-1);
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Get type of the object and check it.
|
|
|
|
|
*/
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Gget_objinfo(loc_id, name, FALSE, &statbuf);
|
2000-04-12 23:44:48 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Gget_objinfo");
|
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
if(test_info->type != statbuf.type) {
|
|
|
|
|
TestErrPrintf("test_info->type = %d, statbuf.type = %d\n", test_info->type, statbuf.type);
|
2000-04-12 23:44:48 +08:00
|
|
|
|
return(-1);
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
return(1);
|
|
|
|
|
} /* giter_cb2() */
|
|
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
|
**
|
|
|
|
|
** test_iter_group_large(): Test group iteration functionality
|
|
|
|
|
** for groups with large #'s of objects
|
2005-08-14 04:53:35 +08:00
|
|
|
|
**
|
2000-04-12 23:44:48 +08:00
|
|
|
|
****************************************************************/
|
2006-10-02 18:24:03 +08:00
|
|
|
|
static void test_iter_group_large(hid_t fapl)
|
2000-04-12 23:44:48 +08:00
|
|
|
|
{
|
|
|
|
|
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 */
|
2002-08-10 05:55:44 +08:00
|
|
|
|
iter_info names[ITER_NGROUPS+2]; /* Names of objects in the root group */
|
2000-04-12 23:44:48 +08:00
|
|
|
|
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;
|
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
HDmemset(names, 0, sizeof names);
|
2000-05-19 00:40:20 +08:00
|
|
|
|
|
2000-04-12 23:44:48 +08:00
|
|
|
|
/* Output message about test being performed */
|
|
|
|
|
MESSAGE(5, ("Testing Large Group Iteration Functionality\n"));
|
|
|
|
|
|
|
|
|
|
/* Create file */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
file = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
|
2000-04-12 23:44:48 +08:00
|
|
|
|
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 */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
for(i = 0; i < ITER_NGROUPS; i++) {
|
2005-08-14 04:53:35 +08:00
|
|
|
|
sprintf(gname, "Group_%d", i);
|
2000-04-12 23:44:48 +08:00
|
|
|
|
|
|
|
|
|
/* Add the name to the list of objects in the root group */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
HDstrcpy(names[i].name, gname);
|
|
|
|
|
names[i].type = H5G_GROUP;
|
2000-04-12 23:44:48 +08:00
|
|
|
|
|
|
|
|
|
/* Create a group */
|
2007-08-24 04:25:25 +08:00
|
|
|
|
group = H5Gcreate2(file, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
|
|
|
|
CHECK(group, FAIL, "H5Gcreate2");
|
2000-04-12 23:44:48 +08:00
|
|
|
|
|
|
|
|
|
/* Close a group */
|
|
|
|
|
ret = H5Gclose(group);
|
|
|
|
|
CHECK(ret, FAIL, "H5Gclose");
|
2006-10-02 18:24:03 +08:00
|
|
|
|
} /* end for */
|
2000-04-12 23:44:48 +08:00
|
|
|
|
|
|
|
|
|
/* Create a dataset */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
dataset = H5Dcreate(file, "Dataset1", H5T_STD_U32LE, sid, H5P_DEFAULT);
|
2000-04-12 23:44:48 +08:00
|
|
|
|
CHECK(dataset, FAIL, "H5Dcreate");
|
|
|
|
|
|
|
|
|
|
/* Add the name to the list of objects in the root group */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
HDstrcpy(names[ITER_NGROUPS].name, "Dataset1");
|
|
|
|
|
names[ITER_NGROUPS].type = H5G_DATASET;
|
2000-04-12 23:44:48 +08:00
|
|
|
|
|
|
|
|
|
/* Close Dataset */
|
|
|
|
|
ret = H5Dclose(dataset);
|
|
|
|
|
CHECK(ret, FAIL, "H5Dclose");
|
|
|
|
|
|
|
|
|
|
/* Close Dataspace */
|
|
|
|
|
ret = H5Sclose(sid);
|
|
|
|
|
CHECK(ret, FAIL, "H5Sclose");
|
|
|
|
|
|
|
|
|
|
/* Create a datatype */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
tid = H5Tcreate(H5T_COMPOUND, sizeof(s1_t));
|
2000-04-12 23:44:48 +08:00
|
|
|
|
CHECK(tid, FAIL, "H5Tcreate");
|
|
|
|
|
|
|
|
|
|
/* Insert fields */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Tinsert(tid, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT);
|
2000-04-12 23:44:48 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Tinsert");
|
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Tinsert(tid, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT);
|
2000-04-12 23:44:48 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Tinsert");
|
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Tinsert(tid, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT);
|
2000-04-12 23:44:48 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Tinsert");
|
|
|
|
|
|
|
|
|
|
/* Save datatype for later */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Tcommit(file, "Datatype1", tid);
|
2000-04-12 23:44:48 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Tcommit");
|
|
|
|
|
|
|
|
|
|
/* Add the name to the list of objects in the root group */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
HDstrcpy(names[ITER_NGROUPS + 1].name, "Datatype1");
|
|
|
|
|
names[ITER_NGROUPS + 1].type = H5G_TYPE;
|
2000-04-12 23:44:48 +08:00
|
|
|
|
|
|
|
|
|
/* 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 */
|
2006-10-31 04:00:57 +08:00
|
|
|
|
HDqsort(names, (size_t)(ITER_NGROUPS + 2), sizeof(iter_info), iter_strcmp2);
|
2000-04-12 23:44:48 +08:00
|
|
|
|
|
|
|
|
|
/* Iterate through the file to see members of the root group */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
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");
|
2000-04-12 23:44:48 +08:00
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
|
|
/* Close file */
|
|
|
|
|
ret = H5Fclose(file);
|
|
|
|
|
CHECK(ret, FAIL, "H5Fclose");
|
|
|
|
|
} /* test_iterate_group_large() */
|
|
|
|
|
|
2002-11-26 01:59:14 +08:00
|
|
|
|
/****************************************************************
|
|
|
|
|
**
|
2005-08-14 04:53:35 +08:00
|
|
|
|
** test_grp_memb_funcs(): Test group member information
|
2002-11-26 01:59:14 +08:00
|
|
|
|
** functionality
|
2005-08-14 04:53:35 +08:00
|
|
|
|
**
|
2002-11-26 01:59:14 +08:00
|
|
|
|
****************************************************************/
|
2006-10-02 18:24:03 +08:00
|
|
|
|
static void test_grp_memb_funcs(hid_t fapl)
|
2002-11-26 01:59:14 +08:00
|
|
|
|
{
|
|
|
|
|
hid_t file; /* File ID */
|
|
|
|
|
hid_t dataset; /* Dataset ID */
|
|
|
|
|
hid_t datatype; /* Common datatype ID */
|
|
|
|
|
hid_t filespace; /* Common dataspace ID */
|
|
|
|
|
hid_t root_group,grp; /* Root group ID */
|
|
|
|
|
int i; /* counting variable */
|
|
|
|
|
char name[NAMELEN]; /* temporary name buffer */
|
|
|
|
|
char *dnames[NDATASETS+2];/* Names of the datasets created */
|
|
|
|
|
char *obj_names[NDATASETS+2];/* Names of the objects in group */
|
2003-08-27 02:35:37 +08:00
|
|
|
|
char dataset_name[NAMELEN]; /* dataset name */
|
|
|
|
|
ssize_t name_len; /* Length of object's name */
|
2002-11-26 01:59:14 +08:00
|
|
|
|
hsize_t num_membs; /* Number of group members */
|
|
|
|
|
herr_t ret; /* Generic return value */
|
|
|
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
|
MESSAGE(5, ("Testing Group Member Information Functionality\n"));
|
|
|
|
|
|
|
|
|
|
/* Create the test file with the datasets */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
file = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
|
2002-11-26 01:59:14 +08:00
|
|
|
|
CHECK(file, FAIL, "H5Fcreate");
|
|
|
|
|
|
|
|
|
|
datatype = H5Tcopy(H5T_NATIVE_INT);
|
|
|
|
|
CHECK(datatype, FAIL, "H5Tcopy");
|
|
|
|
|
|
|
|
|
|
filespace=H5Screate(H5S_SCALAR);
|
|
|
|
|
CHECK(filespace, FAIL, "H5Screate");
|
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
for(i = 0; i< NDATASETS; i++) {
|
2002-11-26 01:59:14 +08:00
|
|
|
|
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 */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
dnames[i] = HDstrdup(name);
|
2002-11-26 01:59:14 +08:00
|
|
|
|
CHECK(dnames[i], NULL, "strdup");
|
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Dclose(dataset);
|
2002-11-26 01:59:14 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Dclose");
|
2006-10-02 18:24:03 +08:00
|
|
|
|
} /* end for */
|
2002-11-26 01:59:14 +08:00
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
|
/* Create a group and named datatype under root group for testing
|
2002-11-26 01:59:14 +08:00
|
|
|
|
* H5Gget_objtype_by_idx.
|
|
|
|
|
*/
|
2007-08-24 04:25:25 +08:00
|
|
|
|
grp = H5Gcreate2(file, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
|
|
|
|
CHECK(ret, FAIL, "H5Gcreate2");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
dnames[NDATASETS] = HDstrdup("grp");
|
2002-11-26 01:59:14 +08:00
|
|
|
|
CHECK(dnames[NDATASETS], NULL, "strdup");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
|
|
|
|
ret = H5Tcommit(file, "dtype", datatype);
|
2002-11-26 01:59:14 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Tcommit");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
dnames[NDATASETS + 1] = HDstrdup("dtype");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
CHECK(dnames[NDATASETS], NULL, "strdup");
|
|
|
|
|
|
2002-11-26 01:59:14 +08:00
|
|
|
|
/* Close everything up */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Tclose(datatype);
|
2002-11-26 01:59:14 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Tclose");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Gclose(grp);
|
2002-11-26 01:59:14 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Gclose");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Sclose(filespace);
|
2002-11-26 01:59:14 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Sclose");
|
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Fclose(file);
|
2002-11-26 01:59:14 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Fclose");
|
|
|
|
|
|
|
|
|
|
/* Sort the dataset names */
|
2006-10-31 04:00:57 +08:00
|
|
|
|
HDqsort(dnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);
|
2002-11-26 01:59:14 +08:00
|
|
|
|
|
|
|
|
|
/* Iterate through the datasets in the root group in various ways */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl);
|
2002-11-26 01:59:14 +08:00
|
|
|
|
CHECK(file, FAIL, "H5Fopen");
|
|
|
|
|
|
2004-06-23 05:08:56 +08:00
|
|
|
|
/* These two functions, H5Gget_num_objs and H5Gget_objname_by_idx, actually
|
2002-11-26 01:59:14 +08:00
|
|
|
|
* iterate through B-tree for group members in internal library design.
|
|
|
|
|
*/
|
2007-08-28 23:02:54 +08:00
|
|
|
|
root_group = H5Gopen2(file, "/", H5P_DEFAULT);
|
|
|
|
|
CHECK(root_group, FAIL, "H5Gopen2");
|
2002-11-26 01:59:14 +08:00
|
|
|
|
|
|
|
|
|
ret = H5Gget_num_objs(root_group, &num_membs);
|
|
|
|
|
CHECK(ret, FAIL, "H5Gget_num_objs");
|
|
|
|
|
VERIFY(num_membs,NDATASETS+2,"H5Gget_num_objs");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2002-12-02 21:15:36 +08:00
|
|
|
|
for(i=0; i< (int)num_membs; i++) {
|
2003-07-08 03:02:46 +08:00
|
|
|
|
H5G_obj_t obj_type; /* Type of object in file */
|
|
|
|
|
|
2003-08-27 02:35:37 +08:00
|
|
|
|
/* Test with NULL for name, to query length */
|
2006-10-31 04:00:57 +08:00
|
|
|
|
name_len = H5Gget_objname_by_idx(root_group, (hsize_t)i, NULL, (size_t)NAMELEN);
|
2003-08-27 02:35:37 +08:00
|
|
|
|
CHECK(name_len, FAIL, "H5Gget_objname_by_idx");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, (size_t)(name_len + 1));
|
2003-08-27 02:35:37 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Gget_objname_by_idx");
|
|
|
|
|
|
|
|
|
|
/* Double-check that the length is the same */
|
|
|
|
|
VERIFY(ret, name_len, "H5Gget_objname_by_idx");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2002-11-26 01:59:14 +08:00
|
|
|
|
/* Keep a copy of the dataset names around for later */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
obj_names[i] = HDstrdup(dataset_name);
|
2003-08-27 02:35:37 +08:00
|
|
|
|
CHECK(obj_names[i], NULL, "strdup");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2003-07-08 03:02:46 +08:00
|
|
|
|
obj_type = H5Gget_objtype_by_idx(root_group, (hsize_t)i);
|
2003-08-27 02:35:37 +08:00
|
|
|
|
CHECK(obj_type, H5G_UNKNOWN, "H5Gget_objtype_by_idx");
|
2002-11-26 01:59:14 +08:00
|
|
|
|
|
|
|
|
|
if(!HDstrcmp(dataset_name, "grp"))
|
2003-08-27 02:35:37 +08:00
|
|
|
|
VERIFY(obj_type, H5G_GROUP, "H5Gget_objname_by_idx");
|
2002-11-26 01:59:14 +08:00
|
|
|
|
if(!HDstrcmp(dataset_name, "dtype"))
|
2003-08-27 02:35:37 +08:00
|
|
|
|
VERIFY(obj_type, H5G_TYPE, "H5Gget_objname_by_idx");
|
2006-10-31 08:13:27 +08:00
|
|
|
|
if(!HDstrncmp(dataset_name, "Dataset", (size_t)7))
|
2003-08-27 02:35:37 +08:00
|
|
|
|
VERIFY(obj_type, H5G_DATASET, "H5Gget_objname_by_idx");
|
2006-10-02 18:24:03 +08:00
|
|
|
|
} /* end for */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2002-11-26 01:59:14 +08:00
|
|
|
|
H5E_BEGIN_TRY {
|
2006-10-31 04:00:57 +08:00
|
|
|
|
ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)(NDATASETS+3), dataset_name, (size_t)NAMELEN);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
} H5E_END_TRY;
|
2003-08-27 02:35:37 +08:00
|
|
|
|
VERIFY(ret, FAIL, "H5Gget_objname_by_idx");
|
2002-11-26 01:59:14 +08:00
|
|
|
|
|
|
|
|
|
/* Sort the dataset names */
|
2006-10-31 04:00:57 +08:00
|
|
|
|
HDqsort(obj_names, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2002-11-26 01:59:14 +08:00
|
|
|
|
/* Compare object names */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
for(i = 0; i< (int)num_membs; i++) {
|
2002-11-26 01:59:14 +08:00
|
|
|
|
ret = HDstrcmp(dnames[i], obj_names[i]);
|
|
|
|
|
VERIFY(ret, 0, "HDstrcmp");
|
2006-10-02 18:24:03 +08:00
|
|
|
|
} /* end for */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2002-11-26 01:59:14 +08:00
|
|
|
|
ret = H5Gclose(root_group);
|
|
|
|
|
CHECK(ret, FAIL, "H5Gclose");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2002-11-26 01:59:14 +08:00
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Fclose(file);
|
2002-11-26 01:59:14 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Fclose");
|
|
|
|
|
|
|
|
|
|
/* Free the dataset names */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
for(i = 0; i< (NDATASETS + 2); i++) {
|
|
|
|
|
HDfree(dnames[i]);
|
|
|
|
|
HDfree(obj_names[i]);
|
|
|
|
|
} /* end for */
|
2002-11-26 01:59:14 +08:00
|
|
|
|
} /* test_grp_memb_funcs() */
|
|
|
|
|
|
2004-06-23 05:08:56 +08:00
|
|
|
|
/****************************************************************
|
|
|
|
|
**
|
|
|
|
|
** test_links(): Test soft and hard link iteration
|
2005-08-14 04:53:35 +08:00
|
|
|
|
**
|
2004-06-23 05:08:56 +08:00
|
|
|
|
****************************************************************/
|
2006-10-02 18:24:03 +08:00
|
|
|
|
static void test_links(hid_t fapl)
|
2004-06-23 05:08:56 +08:00
|
|
|
|
{
|
|
|
|
|
hid_t file; /* File ID */
|
|
|
|
|
char obj_name[NAMELEN]; /* Names of the object in group */
|
|
|
|
|
ssize_t name_len; /* Length of object's name */
|
|
|
|
|
herr_t ret; /* Generic return value */
|
|
|
|
|
hid_t gid, gid1;
|
2004-07-17 04:48:40 +08:00
|
|
|
|
hsize_t i;
|
2004-06-23 05:08:56 +08:00
|
|
|
|
H5G_obj_t obj_type; /* Type of object */
|
|
|
|
|
hsize_t nobjs; /* Number of objects */
|
|
|
|
|
|
|
|
|
|
/* Output message about test being performed */
|
|
|
|
|
MESSAGE(5, ("Testing Soft and Hard Link Iteration Functionality\n"));
|
|
|
|
|
|
|
|
|
|
/* Create the test file with the datasets */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
file = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
|
2004-06-23 05:08:56 +08:00
|
|
|
|
CHECK(file, FAIL, "H5Fcreate");
|
|
|
|
|
|
|
|
|
|
/* create groups */
|
2007-08-24 04:25:25 +08:00
|
|
|
|
gid = H5Gcreate2(file, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
|
|
|
|
CHECK(gid, FAIL, "H5Gcreate2");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2007-08-24 04:25:25 +08:00
|
|
|
|
gid1 = H5Gcreate2(file, "/g1/g1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
|
|
|
|
CHECK(gid1, FAIL, "H5Gcreate2");
|
2004-06-23 05:08:56 +08:00
|
|
|
|
|
|
|
|
|
/* create soft and hard links to the group "/g1". */
|
2007-08-29 05:31:57 +08:00
|
|
|
|
ret = H5Lcreate_soft("something", gid, "softlink", H5P_DEFAULT, H5P_DEFAULT);
|
|
|
|
|
CHECK(ret, FAIL, "H5Lcreate_soft");
|
2004-06-23 05:08:56 +08:00
|
|
|
|
|
2007-08-29 05:31:57 +08:00
|
|
|
|
ret = H5Lcreate_hard(gid, "/g1", H5L_SAME_LOC, "hardlink", H5P_DEFAULT, H5P_DEFAULT);
|
|
|
|
|
CHECK(ret, FAIL, "H5Lcreate_hard");
|
2004-06-23 05:08:56 +08:00
|
|
|
|
|
|
|
|
|
ret = H5Gget_num_objs(gid, &nobjs);
|
|
|
|
|
CHECK(ret, FAIL, "H5Gget_num_objs");
|
|
|
|
|
VERIFY(nobjs,3,"H5Gget_num_objs");
|
|
|
|
|
|
|
|
|
|
/* Test these two functions, H5Gget_num_objs and H5Gget_objname_by_idx */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
for(i = 0; i < nobjs; i++) {
|
2004-06-23 05:08:56 +08:00
|
|
|
|
/* Get object name */
|
2006-10-31 04:00:57 +08:00
|
|
|
|
name_len = H5Gget_objname_by_idx(gid, i, obj_name, (size_t)NAMELEN);
|
2004-06-23 05:08:56 +08:00
|
|
|
|
CHECK(name_len, FAIL, "H5Gget_objname_by_idx");
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2004-07-17 04:48:40 +08:00
|
|
|
|
obj_type = H5Gget_objtype_by_idx(gid, i);
|
2004-06-23 05:08:56 +08:00
|
|
|
|
CHECK(obj_type, H5G_UNKNOWN, "H5Gget_objtype_by_idx");
|
|
|
|
|
|
|
|
|
|
if(!HDstrcmp(obj_name, "g1.1"))
|
|
|
|
|
VERIFY(obj_type, H5G_GROUP, "H5Gget_objname_by_idx");
|
|
|
|
|
else if(!HDstrcmp(obj_name, "hardlink"))
|
|
|
|
|
VERIFY(obj_type, H5G_GROUP, "H5Gget_objname_by_idx");
|
|
|
|
|
else if(!HDstrcmp(obj_name, "softlink"))
|
|
|
|
|
VERIFY(obj_type, H5G_LINK, "H5Gget_objname_by_idx");
|
|
|
|
|
else
|
|
|
|
|
CHECK(0, 0, "unknown object name");
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Gclose(gid);
|
2004-06-23 05:08:56 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Gclose");
|
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Gclose(gid1);
|
2004-06-23 05:08:56 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Gclose");
|
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
ret = H5Fclose(file);
|
2004-06-23 05:08:56 +08:00
|
|
|
|
CHECK(ret, FAIL, "H5Fclose");
|
|
|
|
|
} /* test_links() */
|
2004-07-17 04:48:40 +08:00
|
|
|
|
|
2000-04-06 04:51:44 +08:00
|
|
|
|
/****************************************************************
|
|
|
|
|
**
|
|
|
|
|
** test_iterate(): Main iteration testing routine.
|
2005-08-14 04:53:35 +08:00
|
|
|
|
**
|
2000-04-06 04:51:44 +08:00
|
|
|
|
****************************************************************/
|
2005-08-14 04:53:35 +08:00
|
|
|
|
void
|
2000-04-06 04:51:44 +08:00
|
|
|
|
test_iterate(void)
|
|
|
|
|
{
|
2006-10-02 18:24:03 +08:00
|
|
|
|
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 */
|
|
|
|
|
|
2000-04-06 04:51:44 +08:00
|
|
|
|
/* Output message about test being performed */
|
|
|
|
|
MESSAGE(5, ("Testing Iteration Operations\n"));
|
|
|
|
|
|
2006-10-02 18:24:03 +08:00
|
|
|
|
/* 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");
|
|
|
|
|
|
2000-04-06 04:51:44 +08:00
|
|
|
|
/* These next tests use the same file */
|
2006-10-02 18:24:03 +08:00
|
|
|
|
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");
|
2000-04-06 04:51:44 +08:00
|
|
|
|
} /* test_iterate() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: cleanup_iterate
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Cleanup temporary test files
|
|
|
|
|
*
|
|
|
|
|
* Return: none
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
|
* April 5, 2000
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
cleanup_iterate(void)
|
|
|
|
|
{
|
2001-04-01 11:25:53 +08:00
|
|
|
|
remove(DATAFILE);
|
2000-04-06 04:51:44 +08:00
|
|
|
|
}
|
|
|
|
|
|