diff options
-rw-r--r-- | tools/h5dump/h5dump.c | 13 | ||||
-rw-r--r-- | tools/h5dump/h5dumpgentest.c | 278 | ||||
-rw-r--r-- | tools/testfiles/tattr-2.ddl | 8 | ||||
-rw-r--r-- | tools/testfiles/thlink-1.ddl | 6 | ||||
-rw-r--r-- | tools/testfiles/thlink-2.ddl | 4 | ||||
-rw-r--r-- | tools/testfiles/thlink-3.ddl | 4 | ||||
-rw-r--r-- | tools/testfiles/thlink-4.ddl | 2 | ||||
-rw-r--r-- | tools/testfiles/tloop-1.ddl | 4 |
8 files changed, 179 insertions, 140 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index cfc4955..931f283 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -1232,7 +1232,7 @@ dump_selected_attr(hid_t loc_id, const char *name) dump_oid(attr_id); if (display_data || display_attr_data) - dump_data(attr_id, ATTRIBUTE_DATA, NULL, 0); + dump_data(attr_id, ATTRIBUTE_DATA, NULL, display_ai); H5Tclose(type); H5Sclose(space); @@ -1510,10 +1510,7 @@ dump_all(hid_t group, const char *name, void * op_data) goto done; } else { dset_table->objs[i].displayed = 1; - strcat(tmp, "/"); - strcat(tmp, name); - free(dset_table->objs[i].objname); - dset_table->objs[i].objname = HDstrdup(tmp); + } } @@ -1643,8 +1640,7 @@ dump_group(hid_t gid, const char *name) indentation(indent); printf("%s \"%s\"\n", HARDLINK, group_table->objs[i].objname); } else { - free(group_table->objs[i].objname); - group_table->objs[i].objname = HDstrdup(prefix); + group_table->objs[i].displayed = 1; H5Aiterate(gid, NULL, dump_attr, NULL); H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype); @@ -2874,8 +2870,7 @@ handle_datasets(hid_t fid, char *dset, void *data) end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend); } else { - free(dset_table->objs[idx].objname); - dset_table->objs[idx].objname = HDstrdup(dset); + dset_table->objs[idx].displayed = 1; dump_dataset(dsetid, dset, sset); } diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index fdd4e5a..806f3db 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -77,7 +77,7 @@ #define FILE45 "tnullspace.h5" #define FILE46 "tfcontents1.h5" #define FILE47 "tfcontents2.h5" - +#define FILE48 "tfvalues.h5" /*------------------------------------------------------------------------- @@ -4359,6 +4359,41 @@ static void gent_named_dtype_attr(void) /*------------------------------------------------------------------------- + * Function: gent_null_space + * + * Purpose: generates dataset and attribute of null dataspace + *------------------------------------------------------------------------- + */ +static void gent_null_space(void) +{ + hid_t fid, root, dataset, space, attr; + int dset_buf = 10; + int point = 4; + + fid = H5Fcreate(FILE45, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + root = H5Gopen (fid, "/"); + + /* null space */ + space = H5Screate(H5S_NULL); + + /* dataset */ + dataset = H5Dcreate(fid, "dset", H5T_STD_I32BE, space, H5P_DEFAULT); + /* nothing should be written */ + H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &dset_buf); + + /* attribute */ + attr = H5Acreate (root, "attr", H5T_NATIVE_UINT, space, H5P_DEFAULT); + H5Awrite(attr, H5T_NATIVE_INT, &point); /* Nothing can be written */ + + H5Dclose(dataset); + H5Aclose(attr); + H5Gclose(root); + H5Sclose(space); + H5Fclose(fid); +} + + +/*------------------------------------------------------------------------- * Function: make_dset * * Purpose: utility function to create and write a dataset in LOC_ID @@ -4550,16 +4585,16 @@ static void gent_filters(void) *------------------------------------------------------------------------- */ #if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) - /* remove the filters from the dcpl */ - ret=H5Premove_filter(dcpl,H5Z_FILTER_ALL); - assert(ret>=0); + /* remove the filters from the dcpl */ + ret=H5Premove_filter(dcpl,H5Z_FILTER_ALL); + assert(ret>=0); - /* set szip data */ - ret=H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block); - assert(ret>=0); + /* set szip data */ + ret=H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block); + assert(ret>=0); - ret=make_dset(fid,"szip",sid,dcpl,buf1); - assert(ret>=0); + ret=make_dset(fid,"szip",sid,dcpl,buf1); + assert(ret>=0); #endif /*------------------------------------------------------------------------- @@ -4630,10 +4665,10 @@ static void gent_filters(void) #endif #if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE) - szip_options_mask=H5_SZIP_CHIP_OPTION_MASK | H5_SZIP_EC_OPTION_MASK; - /* set szip data */ - ret=H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block); - assert(ret>=0); + szip_options_mask=H5_SZIP_CHIP_OPTION_MASK | H5_SZIP_EC_OPTION_MASK; + /* set szip data */ + ret=H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block); + assert(ret>=0); #endif #if defined (H5_HAVE_FILTER_DEFLATE) @@ -4677,8 +4712,6 @@ static void gent_filters(void) ret=H5Premove_filter(dcpl,H5Z_FILTER_ALL); assert(ret>=0); - - /*------------------------------------------------------------------------- * make an external dataset *------------------------------------------------------------------------- @@ -4686,59 +4719,11 @@ static void gent_filters(void) make_external(fid); /*------------------------------------------------------------------------- - * make datasets with fill value combinations - * H5D_FILL_TIME_IFSET - *------------------------------------------------------------------------- - */ - ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET); - assert(ret>=0); - - ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval); - assert(ret>=0); - - ret=make_dset(fid,"fill_time_ifset",sid,dcpl,buf1); - assert(ret>=0); - -/*------------------------------------------------------------------------- - * H5D_FILL_TIME_ALLOC - *------------------------------------------------------------------------- - */ - ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC); - assert(ret>=0); - - ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval); - assert(ret>=0); - - ret=make_dset(fid,"fill_time_alloc",sid,dcpl,buf1); - assert(ret>=0); - -/*------------------------------------------------------------------------- - * H5D_FILL_TIME_NEVER - *------------------------------------------------------------------------- - */ - ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER); - assert(ret>=0); - - ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval); - assert(ret>=0); - - ret=make_dset(fid,"fill_time_never",sid,dcpl,buf1); - assert(ret>=0); - -/*------------------------------------------------------------------------- * H5D_ALLOC_TIME_EARLY *------------------------------------------------------------------------- */ - - ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET); - assert(ret>=0); - ret=H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY); assert(ret>=0); - - ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval); - assert(ret>=0); - ret=make_dset(fid,"alloc_time_early",sid,dcpl,buf1); assert(ret>=0); @@ -4748,10 +4733,6 @@ static void gent_filters(void) */ ret=H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_INCR); assert(ret>=0); - - ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval); - assert(ret>=0); - ret=make_dset(fid,"alloc_time_incr",sid,dcpl,buf1); assert(ret>=0); @@ -4761,10 +4742,6 @@ static void gent_filters(void) */ ret=H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE); assert(ret>=0); - - ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval); - assert(ret>=0); - ret=make_dset(fid,"alloc_time_late",sid,dcpl,buf1); assert(ret>=0); @@ -4891,6 +4868,7 @@ static void gent_filters(void) assert(ret>=0); } + /*------------------------------------------------------------------------- * Function: myfilter * @@ -4947,57 +4925,78 @@ set_local_myfilter(hid_t dcpl_id, hid_t UNUSED type_id, hid_t UNUSED space_id) * *------------------------------------------------------------------------- */ +/*------------------------------------------------------------------------- + * Function: gent_fcontents + * + * Purpose: generate several files to list its contents + * + *------------------------------------------------------------------------- + */ static void gent_fcontents(void) { hid_t fid; /* file id */ hid_t gid1; /* group ID */ - hid_t gid2; /* group ID */ - hid_t gid3; /* group ID */ hid_t tid; /* datatype ID */ hsize_t dims[1]={4}; int buf[4]={1,2,3,4}; int ret; - + + /* create a file */ fid = H5Fcreate(FILE46, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); assert(fid>=0); + write_dset(fid,1,dims,"dset",H5T_NATIVE_INT,buf); + /*------------------------------------------------------------------------- * links *------------------------------------------------------------------------- */ - /* soft link to "dset" */ - ret=H5Glink (fid, H5G_LINK_SOFT, "dset", "softlink"); + + /* hard link to "dset" */ + gid1 = H5Gcreate (fid, "/g1", 0); + H5Glink (gid1, H5G_LINK_HARD, "/dset", "dset1"); + H5Gclose(gid1); + + + /* hard link to "dset" */ + gid1 = H5Gcreate (fid, "/g2", 0); + H5Glink (gid1, H5G_LINK_HARD, "/dset", "dset2"); + H5Gclose(gid1); + + + /* hard link to "g2" */ + gid1 = H5Gopen(fid, "/g1"); + H5Glink (gid1, H5G_LINK_HARD, "/g2", "g1.1"); + H5Gclose(gid1); + + + /* hard link to "dset" */ + ret=H5Glink (fid, H5G_LINK_HARD, "/dset", "dset3"); assert(ret>=0); + /* hard link to "dset" */ - ret=H5Glink (fid, H5G_LINK_HARD, "dset", "dset1"); + ret=H5Glink (fid, H5G_LINK_HARD, "/dset", "dset4"); assert(ret>=0); + /* soft link to itself */ ret=H5Glink (fid, H5G_LINK_SOFT, "mylink", "mylink"); assert(ret>=0); -/*------------------------------------------------------------------------- - * groups - *------------------------------------------------------------------------- - */ - gid1 = H5Gcreate(fid,"g1",0); - gid2 = H5Gcreate(gid1,"g2",0); - gid3 = H5Gcreate(gid2,"g3",0); - write_dset(gid3,1,dims,"dset",H5T_NATIVE_INT,buf); - ret = H5Gclose(gid1); - assert(ret>=0); - ret = H5Gclose(gid2); - assert(ret>=0); - ret = H5Gclose(gid3); + + /* soft link to "dset" */ + ret=H5Glink (fid, H5G_LINK_SOFT, "/dset", "softlink"); assert(ret>=0); + + /*------------------------------------------------------------------------- - * datatypes + * datatypes *------------------------------------------------------------------------- */ tid=H5Tcopy(H5T_NATIVE_INT); @@ -5006,6 +5005,7 @@ static void gent_fcontents(void) ret=H5Tclose(tid); assert(ret>=0); + /* no name datatype */ tid=H5Tcopy(H5T_NATIVE_INT); ret=H5Tcommit(fid, "mytype2", tid); @@ -5016,61 +5016,105 @@ static void gent_fcontents(void) ret=H5Tclose(tid); assert(ret>=0); + /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- */ + ret=H5Fclose(fid); assert(ret>=0); + /* create a file for the bootblock test */ fid = H5Fcreate(FILE47, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); assert(fid>=0); + ret=H5Fclose(fid); assert(ret>=0); } +/*------------------------------------------------------------------------- + * Function: gent_fvalues + * + * Purpose: generate a file for the fill values test + * + *------------------------------------------------------------------------- + */ +static void gent_fvalues(void) +{ + hid_t fid; /* file id */ + hid_t dcpl; /* dataset creation property list */ + hid_t sid; /* dataspace ID */ + hsize_t dims[1]={4}; + int buf[4]={1,2,3,4}; + int ret, fillval = -99; + /* create a file */ + fid = H5Fcreate(FILE48, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + assert(fid>=0); + + /* create a space */ + sid = H5Screate_simple(1, dims, NULL); + + /* create a dataset creation property list; the same DCPL is used for all dsets */ + dcpl = H5Pcreate(H5P_DATASET_CREATE); + +/*------------------------------------------------------------------------- + * make datasets with fill value combinations + * H5D_FILL_TIME_IFSET + *------------------------------------------------------------------------- + */ + ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET); + assert(ret>=0); + + ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval); + assert(ret>=0); + ret=make_dset(fid,"fill_time_ifset",sid,dcpl,buf); + assert(ret>=0); +/*------------------------------------------------------------------------- + * H5D_FILL_TIME_ALLOC + *------------------------------------------------------------------------- + */ + ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC); + assert(ret>=0); + ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval); + assert(ret>=0); + + ret=make_dset(fid,"fill_time_alloc",sid,dcpl,buf); + assert(ret>=0); /*------------------------------------------------------------------------- - * Function: gent_null_space - * - * Purpose: generates dataset and attribute of null dataspace + * H5D_FILL_TIME_NEVER *------------------------------------------------------------------------- */ -static void gent_null_space(void) -{ - hid_t fid, root, dataset, space, attr; - int dset_buf = 10; - int point = 4; - - fid = H5Fcreate(FILE45, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - root = H5Gopen (fid, "/"); - - /* null space */ - space = H5Screate(H5S_NULL); + ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER); + assert(ret>=0); - /* dataset */ - dataset = H5Dcreate(fid, "dset", H5T_STD_I32BE, space, H5P_DEFAULT); - /* nothing should be written */ - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &dset_buf); + ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval); + assert(ret>=0); - /* attribute */ - attr = H5Acreate (root, "attr", H5T_NATIVE_UINT, space, H5P_DEFAULT); - H5Awrite(attr, H5T_NATIVE_INT, &point); /* Nothing can be written */ + ret=make_dset(fid,"fill_time_never",sid,dcpl,buf); + assert(ret>=0); - H5Dclose(dataset); - H5Aclose(attr); - H5Gclose(root); - H5Sclose(space); - H5Fclose(fid); +/*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ + ret=H5Sclose(sid); + assert(ret>=0); + ret=H5Pclose(dcpl); + assert(ret>=0); + ret=H5Fclose(fid); + assert(ret>=0); } + /*------------------------------------------------------------------------- * Function: main * diff --git a/tools/testfiles/tattr-2.ddl b/tools/testfiles/tattr-2.ddl index 6e1e37d..195b9ab 100644 --- a/tools/testfiles/tattr-2.ddl +++ b/tools/testfiles/tattr-2.ddl @@ -6,15 +6,15 @@ ATTRIBUTE "/attr1" { DATATYPE H5T_STD_I8BE DATASPACE SIMPLE { ( 24 ) / ( 24 ) } DATA { - 97, 116, 116, 114, 105, 98, 117, 116, 101, 32, 111, 102, 32, 114, 111, - 111, 116, 32, 103, 114, 111, 117, 112, 0 + (0): 97, 116, 116, 114, 105, 98, 117, 116, 101, 32, 111, 102, 32, 114, + (14): 111, 111, 116, 32, 103, 114, 111, 117, 112, 0 } } ATTRIBUTE "/attr4" { DATATYPE H5T_STD_I32BE DATASPACE SCALAR DATA { - 100 + (0): 100 } } ATTRIBUTE "/attr5" { @@ -26,7 +26,7 @@ ATTRIBUTE "/attr5" { } DATASPACE SCALAR DATA { - "string attribute" + (0): "string attribute" } } } diff --git a/tools/testfiles/thlink-1.ddl b/tools/testfiles/thlink-1.ddl index fd9b0bd..4f50e80 100644 --- a/tools/testfiles/thlink-1.ddl +++ b/tools/testfiles/thlink-1.ddl @@ -12,16 +12,16 @@ GROUP "/" { } GROUP "g1" { DATASET "dset2" { - HARDLINK "/g2/dset1" + HARDLINK "/dset1" } GROUP "g1.1" { DATASET "dset3" { - HARDLINK "/g2/dset1" + HARDLINK "/dset1" } } } GROUP "g2" { - HARDLINK "/g2/g1/g1.1" + HARDLINK "/g1/g1.1" } } } diff --git a/tools/testfiles/thlink-2.ddl b/tools/testfiles/thlink-2.ddl index 0ff0eec..829dbd6 100644 --- a/tools/testfiles/thlink-2.ddl +++ b/tools/testfiles/thlink-2.ddl @@ -10,9 +10,9 @@ DATASET "/g1/dset2" { } } DATASET "/dset1" { - HARDLINK "/g1/dset2" + HARDLINK "/dset1" } DATASET "/g1/g1.1/dset3" { - HARDLINK "/g1/dset2" + HARDLINK "/dset1" } } diff --git a/tools/testfiles/thlink-3.ddl b/tools/testfiles/thlink-3.ddl index a41dbc1..d4b9d39 100644 --- a/tools/testfiles/thlink-3.ddl +++ b/tools/testfiles/thlink-3.ddl @@ -10,9 +10,9 @@ DATASET "/g1/g1.1/dset3" { } } DATASET "/g1/dset2" { - HARDLINK "/g1/g1.1/dset3" + HARDLINK "/dset1" } DATASET "/dset1" { - HARDLINK "/g1/g1.1/dset3" + HARDLINK "/dset1" } } diff --git a/tools/testfiles/thlink-4.ddl b/tools/testfiles/thlink-4.ddl index 00c2a3a..4a06500 100644 --- a/tools/testfiles/thlink-4.ddl +++ b/tools/testfiles/thlink-4.ddl @@ -12,7 +12,7 @@ GROUP "/g1" { } GROUP "g1.1" { DATASET "dset3" { - HARDLINK "/g1/dset2" + HARDLINK "/dset1" } } } diff --git a/tools/testfiles/tloop-1.ddl b/tools/testfiles/tloop-1.ddl index c3d842a..8313887 100644 --- a/tools/testfiles/tloop-1.ddl +++ b/tools/testfiles/tloop-1.ddl @@ -6,12 +6,12 @@ GROUP "/" { GROUP "g1" { GROUP "g1.1" { GROUP "g2.1" { - HARDLINK "/g2/g1" + HARDLINK "/g1" } } } GROUP "g2" { - HARDLINK "/g2/g1/g1.1" + HARDLINK "/g1/g1.1" } } } |