diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2007-10-04 16:21:30 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2007-10-04 16:21:30 (GMT) |
commit | 3026ace6ae3873486664ef3f744dd803a323fe31 (patch) | |
tree | b197ef18d6dae60d8636e55d2cd5c9e75f5c4606 /tools | |
parent | b2c7d08ae0030b8a3893c21948c611dfb9cefe26 (diff) | |
download | hdf5-3026ace6ae3873486664ef3f744dd803a323fe31.zip hdf5-3026ace6ae3873486664ef3f744dd803a323fe31.tar.gz hdf5-3026ace6ae3873486664ef3f744dd803a323fe31.tar.bz2 |
[svn-r14182]
Added support for displaying several iteration orders on dataset attributes, 4 new tests in test script (name ascending, name descending, creation_order ascending, creation_order descending)
New h5 file is made on the generator program
Tested: windows, linux
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5dump/h5dump.c | 38 | ||||
-rw-r--r-- | tools/h5dump/h5dumpgentest.c | 106 | ||||
-rw-r--r-- | tools/h5dump/testh5dump.sh.in | 7 | ||||
-rw-r--r-- | tools/testfiles/torderattr.h5 | bin | 0 -> 1456 bytes | |||
-rw-r--r-- | tools/testfiles/torderattr1.ddl | 23 | ||||
-rw-r--r-- | tools/testfiles/torderattr2.ddl | 23 | ||||
-rw-r--r-- | tools/testfiles/torderattr3.ddl | 23 | ||||
-rw-r--r-- | tools/testfiles/torderattr4.ddl | 23 |
8 files changed, 217 insertions, 26 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 7a924de..ba72442 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -501,7 +501,7 @@ static void dump_named_datatype(hid_t, const char *); static void dump_dataset(hid_t, const char *, struct subset_t *); static void dump_dataspace(hid_t space); static void dump_datatype(hid_t type); -static herr_t dump_attr(hid_t, const char *, const H5A_info_t *, void *); +static herr_t dump_attr_cb(hid_t loc_id, const char *attr_name, const H5A_info_t *info, void *_op_data); static void dump_data(hid_t, int, struct subset_t *, int); static void dump_dcpl(hid_t dcpl, hid_t type_id, hid_t obj_id); static void dump_comment(hid_t obj_id); @@ -530,7 +530,7 @@ typedef struct dump_functions_t { void (*dump_dataset_function) (hid_t, const char *, struct subset_t *); void (*dump_dataspace_function) (hid_t); void (*dump_datatype_function) (hid_t); - herr_t (*dump_attribute_function) (hid_t, const char *, void *); + herr_t (*dump_attribute_function) (hid_t, const char *, const H5A_info_t *, void *); void (*dump_data_function) (hid_t, int, struct subset_t *, int); } dump_functions; @@ -541,7 +541,7 @@ static const dump_functions ddl_function_table = { dump_dataset, dump_dataspace, dump_datatype, - dump_attr, + dump_attr_cb, dump_data }; @@ -1207,8 +1207,9 @@ dump_dataspace(hid_t space) dump_header_format->dataspaceblockend); } + /*------------------------------------------------------------------------- - * Function: dump_attr + * Function: dump_attr_cb * * Purpose: dump the attribute * @@ -1218,13 +1219,13 @@ dump_dataspace(hid_t space) * * Programmer: Ruey-Hsia Li * - * Modifications: + * Modifications: Pedro Vicente, October 4, 2007 + * Added H5A_info_t parameter to conform with H5Aiterate2 * *------------------------------------------------------------------------- */ -static herr_t -dump_attr(hid_t oid, const char *attr_name, const H5A_info_t UNUSED *info, - void UNUSED *op_data) +static herr_t +dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t UNUSED *info, void UNUSED *_op_data) { hid_t attr_id; herr_t ret = SUCCEED; @@ -1260,8 +1261,7 @@ dump_attr(hid_t oid, const char *attr_name, const H5A_info_t UNUSED *info, H5Aclose(attr_id); indentation(indent); - end_obj(dump_header_format->attributeend, - dump_header_format->attributeblockend); + end_obj(dump_header_format->attributeend,dump_header_format->attributeblockend); } return ret; @@ -1818,7 +1818,7 @@ dump_named_datatype(hid_t type, const char *name) /* print attributes */ indent += COL; - H5Aiterate2(type, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_attr, NULL, H5P_DEFAULT); + H5Aiterate2(type, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_attr_cb, NULL, H5P_DEFAULT); indent -= COL; end_obj(dump_header_format->datatypeend, @@ -1895,11 +1895,11 @@ dump_group(hid_t gid, const char *name, H5_index_t idx_type, H5_iter_order_t ite printf("%s \"%s\"\n", HARDLINK, found_obj->objname); } else { found_obj->displayed = TRUE; - H5Aiterate2(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_attr, NULL, H5P_DEFAULT); + H5Aiterate2(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_attr_cb, NULL, H5P_DEFAULT); H5Literate(gid, ".", idx_type, iter_order, NULL, dump_all, NULL, H5P_DEFAULT); } } else { - H5Aiterate2(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_attr, NULL, H5P_DEFAULT); + H5Aiterate2(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_attr_cb, NULL, H5P_DEFAULT); H5Literate(gid, ".", idx_type, iter_order, NULL, dump_all, NULL, H5P_DEFAULT); } @@ -1918,7 +1918,10 @@ dump_group(hid_t gid, const char *name, H5_index_t idx_type, H5_iter_order_t ite * * Programmer: Ruey-Hsia Li * - * Modifications: pvn, 2004, added dcpl dump + * Modifications: + * Pedro Vicente, 2004, added dataset creation property list display + * Pedro Vicente, October 4, 2007, added parameters to H5Aiterate2() to allow for + * other iteration orders * *------------------------------------------------------------------------- */ @@ -1974,15 +1977,16 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) } /* end switch */ indent += COL; - H5Aiterate2(did, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_attr, NULL, H5P_DEFAULT); + + H5Aiterate2(did, ".", sort_by, sort_order, NULL, dump_attr_cb, NULL, H5P_DEFAULT); + indent -= COL; H5Tclose(type); H5Sclose(space); indentation(indent); - end_obj(dump_header_format->datasetend, - dump_header_format->datasetblockend); + end_obj(dump_header_format->datasetend,dump_header_format->datasetblockend); } /*------------------------------------------------------------------------- diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index 9d45e57..4bf7061 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -86,7 +86,7 @@ #define FILE56 "tbigdims.h5" #define FILE57 "thyperslab.h5" #define FILE58 "tordergr.h5" - +#define FILE59 "torderattr.h5" /*------------------------------------------------------------------------- @@ -5753,10 +5753,6 @@ gent_hyperslab(void) free(buf); } - - - - /*------------------------------------------------------------------------- * Function: gent_group_creation_order * @@ -5768,10 +5764,10 @@ gent_hyperslab(void) static void gent_group_creation_order() { - hid_t fid; /* file id */ - hid_t gid; /* group id */ - hid_t gcpl_id; /* group creation property list id */ - hid_t fcpl_id; /* file creation property list id (to set root group order) */ + hid_t fid; /* file ID */ + hid_t gid; /* group ID */ + hid_t gcpl_id; /* group creation property list ID */ + hid_t fcpl_id; /* file creation property list ID (to set root group order) */ if ((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) goto out; @@ -5897,6 +5893,97 @@ out: } +/*------------------------------------------------------------------------- + * Function: gent_attr_creation_order + * + * Purpose: generate a file with several objects with attributes with creation + * order set and not set + * + *------------------------------------------------------------------------- + */ +static void +gent_attr_creation_order() +{ + hid_t fid; /* file id */ + hid_t gid; /* group id */ + hid_t did; /* dataset id */ + hid_t sid; /* space id */ + hid_t aid; /* attribute id */ + hid_t gcpl_id; /* group creation property list ID */ + hid_t dcpl_id; /* dataset creation property list ID */ + int i; + char *attr_name[3] = {"c", "b", "a" }; + + if ((fid = H5Fcreate(FILE59, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + + /* create group creation property list */ + if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + goto out; + + /* create dataset creation property list */ + if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto out; + +#if 0 + /* enable creation order tracking on attributes */ + if(H5Pset_attr_creation_order(dcpl_id, H5P_CRT_ORDER_TRACKED) < 0) + goto out; +#endif +/*------------------------------------------------------------------------- + * create a dataset and atributes in it + *------------------------------------------------------------------------- + */ + + /* create dataspace for dataset */ + if ((sid = H5Screate(H5S_SCALAR)) < 0) + goto out; + + /* create a dataset */ + if ((did = H5Dcreate(fid, "dset", H5T_NATIVE_UCHAR, sid, dcpl_id)) < 0) + goto out; + + /* add attributes */ + for(i = 0; i < 3; i++) + { + if ((aid = H5Acreate(did, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT)) < 0) + goto out; + + /* close attribute */ + if (H5Aclose(aid) < 0) + goto out; + + } /* end for */ + + + /* close */ + if (H5Sclose(sid) < 0) + goto out; + if (H5Dclose(did) < 0) + goto out; + if (H5Pclose(dcpl_id) < 0) + goto out; + if (H5Pclose(gcpl_id) < 0) + goto out; + if (H5Fclose(fid) < 0) + goto out; + + return; + +out: + printf("Error.....\n"); + H5E_BEGIN_TRY { + H5Gclose(gid); + H5Dclose(did); + H5Sclose(sid); + H5Pclose(gcpl_id); + H5Pclose(dcpl_id); + H5Fclose(fid); + + } H5E_END_TRY; + return; + +} /*------------------------------------------------------------------------- @@ -5965,6 +6052,7 @@ int main(void) gent_bigdims(); gent_hyperslab(); gent_group_creation_order(); + gent_attr_creation_order(); return 0; diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index 76c5ba7..1dfa535 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -483,6 +483,13 @@ TOOLTEST tordergr3.ddl -g 2 -q name -z ascending tordergr.h5 TOOLTEST tordergr4.ddl -g 2 -q name -z descending tordergr.h5 TOOLTEST tordergr5.ddl -q creation_order tordergr.h5 +# tests for dataset attribute order +TOOLTEST torderattr1.ddl -H --sort_by=name --sort_order=ascending torderattr.h5 +TOOLTEST torderattr2.ddl -H --sort_by=name --sort_order=descending torderattr.h5 +TOOLTEST torderattr3.ddl -H --sort_by=creation_order --sort_order=ascending torderattr.h5 +TOOLTEST torderattr4.ddl -H --sort_by=creation_order --sort_order=descending torderattr.h5 + + if test $nerrors -eq 0 ; then echo "All $DUMPER tests passed." diff --git a/tools/testfiles/torderattr.h5 b/tools/testfiles/torderattr.h5 Binary files differnew file mode 100644 index 0000000..48217aa --- /dev/null +++ b/tools/testfiles/torderattr.h5 diff --git a/tools/testfiles/torderattr1.ddl b/tools/testfiles/torderattr1.ddl new file mode 100644 index 0000000..8521898 --- /dev/null +++ b/tools/testfiles/torderattr1.ddl @@ -0,0 +1,23 @@ +############################# +Expected output for 'h5dump -H --sort_by=name --sort_order=ascending torderattr.h5' +############################# +HDF5 "torderattr.h5" { +GROUP "/" { + DATASET "dset" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + ATTRIBUTE "a" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + ATTRIBUTE "b" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + ATTRIBUTE "c" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + } +} +} diff --git a/tools/testfiles/torderattr2.ddl b/tools/testfiles/torderattr2.ddl new file mode 100644 index 0000000..968b630 --- /dev/null +++ b/tools/testfiles/torderattr2.ddl @@ -0,0 +1,23 @@ +############################# +Expected output for 'h5dump -H --sort_by=name --sort_order=descending torderattr.h5' +############################# +HDF5 "torderattr.h5" { +GROUP "/" { + DATASET "dset" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + ATTRIBUTE "c" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + ATTRIBUTE "b" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + ATTRIBUTE "a" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + } +} +} diff --git a/tools/testfiles/torderattr3.ddl b/tools/testfiles/torderattr3.ddl new file mode 100644 index 0000000..15e370a --- /dev/null +++ b/tools/testfiles/torderattr3.ddl @@ -0,0 +1,23 @@ +############################# +Expected output for 'h5dump -H --sort_by=creation_order --sort_order=ascending torderattr.h5' +############################# +HDF5 "torderattr.h5" { +GROUP "/" { + DATASET "dset" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + ATTRIBUTE "c" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + ATTRIBUTE "b" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + ATTRIBUTE "a" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + } +} +} diff --git a/tools/testfiles/torderattr4.ddl b/tools/testfiles/torderattr4.ddl new file mode 100644 index 0000000..3e94ebd --- /dev/null +++ b/tools/testfiles/torderattr4.ddl @@ -0,0 +1,23 @@ +############################# +Expected output for 'h5dump -H --sort_by=creation_order --sort_order=descending torderattr.h5' +############################# +HDF5 "torderattr.h5" { +GROUP "/" { + DATASET "dset" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + ATTRIBUTE "a" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + ATTRIBUTE "b" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + ATTRIBUTE "c" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + } +} +} |