summaryrefslogtreecommitdiffstats
path: root/tools/h5stat
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2010-02-12 19:34:30 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2010-02-12 19:34:30 (GMT)
commit1bc5ffb9658fe930d462927dbce0d6a2d69e9315 (patch)
tree5fc57d46e8854f4acff56d47aee885a72c582434 /tools/h5stat
parente3b4922d8d211878b43d8130b86c0926fac2cd7b (diff)
downloadhdf5-1bc5ffb9658fe930d462927dbce0d6a2d69e9315.zip
hdf5-1bc5ffb9658fe930d462927dbce0d6a2d69e9315.tar.gz
hdf5-1bc5ffb9658fe930d462927dbce0d6a2d69e9315.tar.bz2
[svn-r18240] Changes to h5stat in response to bug 1778:
1. Gather attribute information for named datatype 2. Revert names of long options back to original 3. Add new tests & *ddl for testing -G, -D, -T, -A options h5committested.
Diffstat (limited to 'tools/h5stat')
-rw-r--r--tools/h5stat/h5stat.c138
-rw-r--r--tools/h5stat/testfiles/h5stat_filters-D.ddl8
-rw-r--r--tools/h5stat/testfiles/h5stat_filters-T.ddl13
-rw-r--r--tools/h5stat/testfiles/h5stat_help1.ddl12
-rw-r--r--tools/h5stat/testfiles/h5stat_help2.ddl12
-rw-r--r--tools/h5stat/testfiles/h5stat_newgrat-A.ddl10
-rw-r--r--tools/h5stat/testfiles/h5stat_newgrat-G.ddl8
-rw-r--r--tools/h5stat/testh5stat.sh.in6
8 files changed, 129 insertions, 78 deletions
diff --git a/tools/h5stat/h5stat.c b/tools/h5stat/h5stat.c
index 3c8242a..87f7b41 100644
--- a/tools/h5stat/h5stat.c
+++ b/tools/h5stat/h5stat.c
@@ -124,7 +124,7 @@ static int display_all = TRUE;
static int display_file = FALSE; /* display file information */
static int display_group = FALSE; /* display groups information */
static int display_dset = FALSE; /* display datasets information */
-static int display_dset_dtype_info = FALSE; /* display datasets' datatype information */
+static int display_dset_dtype_meta = FALSE; /* display datasets' datatype information */
static int display_attr = FALSE; /* display attributes information */
static int display_free_sections = FALSE; /* display free space information */
static int display_summary = FALSE; /* display summary of file space information */
@@ -141,72 +141,77 @@ struct handler_t {
};
-static const char *s_opts ="aDdFfhGgsSTO:v";
+static const char *s_opts ="ADdFfhGgsSTO:V";
+/* e.g. "filemetadata" has to precedue "file"; "groupmetadata" has to precede "group" etc. */
static struct long_options l_opts[] = {
{"help", no_arg, 'h'},
{"hel", no_arg, 'h'},
{"he", no_arg, 'h'},
+ {"filemetadata", no_arg, 'F'},
+ {"filemetadat", no_arg, 'F'},
+ {"filemetada", no_arg, 'F'},
+ {"filemetad", no_arg, 'F'},
+ {"filemeta", no_arg, 'F'},
+ {"filemet", no_arg, 'F'},
+ {"fileme", no_arg, 'F'},
+ {"filem", no_arg, 'F'},
{"file", no_arg, 'f'},
{"fil", no_arg, 'f'},
{"fi", no_arg, 'f'},
- {"FILEmetadata", no_arg, 'F'},
- {"FILEmetadat", no_arg, 'F'},
- {"FILEmetada", no_arg, 'F'},
- {"FILEmetad", no_arg, 'F'},
- {"FILEmeta", no_arg, 'F'},
- {"FILEmet", no_arg, 'F'},
- {"FILEme", no_arg, 'F'},
- {"FILEm", no_arg, 'F'},
+ {"groupmetadata", no_arg, 'G'},
+ {"groupmetadat", no_arg, 'G'},
+ {"groupmetada", no_arg, 'G'},
+ {"groupmetad", no_arg, 'G'},
+ {"groupmeta", no_arg, 'G'},
+ {"groupmet", no_arg, 'G'},
+ {"groupme", no_arg, 'G'},
+ {"groupm", no_arg, 'G'},
{"group", no_arg, 'g'},
{"grou", no_arg, 'g'},
{"gro", no_arg, 'g'},
{"gr", no_arg, 'g'},
- {"GROUPmetadata", no_arg, 'G'},
- {"GROUPmetadat", no_arg, 'G'},
- {"GROUPmetada", no_arg, 'G'},
- {"GROUPmetad", no_arg, 'G'},
- {"GROUPmeta", no_arg, 'G'},
- {"GROUPmet", no_arg, 'G'},
- {"GROUPme", no_arg, 'G'},
- {"GROUPm", no_arg, 'G'},
+ {"dsetmetadata", no_arg, 'D'},
+ {"dsetmetadat", no_arg, 'D'},
+ {"dsetmetada", no_arg, 'D'},
+ {"dsetmetad", no_arg, 'D'},
+ {"dsetmeta", no_arg, 'D'},
+ {"dsetmet", no_arg, 'D'},
+ {"dsetme", no_arg, 'D'},
+ {"dsetm", no_arg, 'D'},
{"dset", no_arg, 'd'},
{"dse", no_arg, 'd'},
{"ds", no_arg, 'd'},
- {"DSETmetadata", no_arg, 'D'},
- {"DSETmetadat", no_arg, 'D'},
- {"DSETmetada", no_arg, 'D'},
- {"DSETmetad", no_arg, 'D'},
- {"DSETmeta", no_arg, 'D'},
- {"DSETmet", no_arg, 'D'},
- {"DSETme", no_arg, 'D'},
- {"DSETm", no_arg, 'D'},
- {"DSETtypeinfo", no_arg, 'T'},
- {"DSETtypeinf", no_arg, 'T'},
- {"DSETtypein", no_arg, 'T'},
- {"DSETtypei", no_arg, 'T'},
- {"DSETtype", no_arg, 'T'},
- {"DSETtyp", no_arg, 'T'},
- {"DSETty", no_arg, 'T'},
- {"DSETt", no_arg, 'T'},
+ {"dtypemetadata", no_arg, 'T'},
+ {"dtypemetadat", no_arg, 'T'},
+ {"dtypemetada", no_arg, 'T'},
+ {"dtypemetad", no_arg, 'T'},
+ {"dtypemeta", no_arg, 'T'},
+ {"dtypemet", no_arg, 'T'},
+ {"dtypeme", no_arg, 'T'},
+ {"dtypem", no_arg, 'T'},
+ {"dtype", no_arg, 'T'},
+ {"dtyp", no_arg, 'T'},
+ {"dty", no_arg, 'T'},
+ {"dt", no_arg, 'T'},
{ "object", require_arg, 'O' },
{ "objec", require_arg, 'O' },
{ "obje", require_arg, 'O' },
{ "obj", require_arg, 'O' },
{ "ob", require_arg, 'O' },
- { "version", no_arg, 'v' },
- { "versio", no_arg, 'v' },
- { "versi", no_arg, 'v' },
- { "vers", no_arg, 'v' },
- { "ver", no_arg, 'v' },
- { "ve", no_arg, 'v' },
- { "attribute", no_arg, 'a' },
- { "attribut", no_arg, 'a' },
- { "attribu", no_arg, 'a' },
- { "attrib", no_arg, 'a' },
- { "attri", no_arg, 'a' },
- { "attr", no_arg, 'a' },
- { "att", no_arg, 'a' },
- { "at", no_arg, 'a' },
+ { "version", no_arg, 'V' },
+ { "versio", no_arg, 'V' },
+ { "versi", no_arg, 'V' },
+ { "vers", no_arg, 'V' },
+ { "ver", no_arg, 'V' },
+ { "ve", no_arg, 'V' },
+ { "attribute", no_arg, 'A' },
+ { "attribut", no_arg, 'A' },
+ { "attribu", no_arg, 'A' },
+ { "attrib", no_arg, 'A' },
+ { "attri", no_arg, 'A' },
+ { "attr", no_arg, 'A' },
+ { "att", no_arg, 'A' },
+ { "at", no_arg, 'A' },
{ "freespace", no_arg, 's' },
{ "freespac", no_arg, 's' },
{ "freespa", no_arg, 's' },
@@ -239,15 +244,15 @@ static void usage(const char *prog)
fprintf(stdout, "\n");
fprintf(stdout, " OPTIONS\n");
fprintf(stdout, " -h, --help Print a usage message and exit\n");
- fprintf(stdout, " -v, --version Print version number and exit\n");
+ fprintf(stdout, " -V, --version Print version number and exit\n");
fprintf(stdout, " -f, --file Print file information\n");
- fprintf(stdout, " -F, --FILEmetadata Print file space information for file's metadata\n");
+ fprintf(stdout, " -F, --filemetadata Print file space information for file's metadata\n");
fprintf(stdout, " -g, --group Print group information\n");
- fprintf(stdout, " -G, --GROUPmetadata Print file space information for groups' metadata\n");
+ fprintf(stdout, " -G, --groupmetadata Print file space information for groups' metadata\n");
fprintf(stdout, " -d, --dset Print dataset information\n");
- fprintf(stdout, " -D, --DSETmetadata Print file space information for datasets' metadata\n");
- fprintf(stdout, " -T, --DSETtypeinfo Print datasets' datatype information\n");
- fprintf(stdout, " -a, --attribute Print attribute information\n");
+ fprintf(stdout, " -D, --dsetmetadata Print file space information for datasets' metadata\n");
+ fprintf(stdout, " -T, --dtypemetadata Print datasets' datatype information\n");
+ fprintf(stdout, " -A, --attribute Print attribute information\n");
fprintf(stdout, " -s, --freespace Print free space information\n");
fprintf(stdout, " -S, --summary Print summary of file space information\n");
}
@@ -613,6 +618,8 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
static herr_t
datatype_stats(iter_t *iter, const H5O_info_t *oi)
{
+ herr_t ret;
+
/* Gather statistics about this type of object */
iter->uniq_dtypes++;
@@ -620,6 +627,10 @@ datatype_stats(iter_t *iter, const H5O_info_t *oi)
iter->dtype_ohdr_info.total_size += oi->hdr.space.total;
iter->dtype_ohdr_info.free_size += oi->hdr.space.free;
+ /* Update attribute metadata info */
+ ret = attribute_stats(iter, oi);
+ assert(ret >= 0);
+
return 0;
} /* end datatype_stats() */
@@ -804,12 +815,11 @@ parse_command_line(int argc, const char *argv[])
usage(progname);
leave(EXIT_SUCCESS);
- case 'v':
+ case 'V':
print_version(progname);
leave(EXIT_SUCCESS);
break;
-
case 'F':
display_all = FALSE;
display_file_metadata = TRUE;
@@ -842,10 +852,10 @@ parse_command_line(int argc, const char *argv[])
case 'T':
display_all = FALSE;
- display_dset_dtype_info = TRUE;
+ display_dset_dtype_meta = TRUE;
break;
- case 'a':
+ case 'A':
display_all = FALSE;
display_attr = TRUE;
break;
@@ -1076,7 +1086,6 @@ print_dataset_info(const iter_t *iter)
{
unsigned long power; /* Temporary "power" for bins */
unsigned long total; /* Total count for various statistics */
- size_t dtype_size; /* Size of encoded datatype */
unsigned u; /* Local index variable */
if(iter->uniq_dsets > 0) {
@@ -1147,7 +1156,7 @@ print_dataset_info(const iter_t *iter)
/*-------------------------------------------------------------------------
- * Function: print_dset_dtype_info
+ * Function: print_dset_dtype_meta
*
* Purpose: Prints datasets' datatype information
*
@@ -1164,9 +1173,8 @@ print_dataset_info(const iter_t *iter)
*-------------------------------------------------------------------------
*/
static herr_t
-print_dset_dtype_info(const iter_t *iter)
+print_dset_dtype_meta(const iter_t *iter)
{
- unsigned long power; /* Temporary "power" for bins */
unsigned long total; /* Total count for various statistics */
size_t dtype_size; /* Size of encoded datatype */
unsigned u; /* Local index variable */
@@ -1189,7 +1197,7 @@ print_dset_dtype_info(const iter_t *iter)
}
return 0;
-} /* print_dset_dtype_info() */
+} /* print_dset_dtype_meta() */
/*-------------------------------------------------------------------------
@@ -1447,7 +1455,7 @@ print_file_statistics(const iter_t *iter)
display_file = TRUE;
display_group = TRUE;
display_dset = TRUE;
- display_dset_dtype_info = TRUE;
+ display_dset_dtype_meta = TRUE;
display_attr = TRUE;
display_free_sections = TRUE;
display_summary = TRUE;
@@ -1464,7 +1472,7 @@ print_file_statistics(const iter_t *iter)
if(!display_all && display_group_metadata) print_group_metadata(iter);
if(display_dset) print_dataset_info(iter);
- if(display_dset_dtype_info) print_dset_dtype_info(iter);
+ if(display_dset_dtype_meta) print_dset_dtype_meta(iter);
if(!display_all && display_dset_metadata) print_dset_metadata(iter);
if(display_attr) print_attr_info(iter);
diff --git a/tools/h5stat/testfiles/h5stat_filters-D.ddl b/tools/h5stat/testfiles/h5stat_filters-D.ddl
new file mode 100644
index 0000000..decfb81
--- /dev/null
+++ b/tools/h5stat/testfiles/h5stat_filters-D.ddl
@@ -0,0 +1,8 @@
+#############################
+Expected output for 'h5stat -D h5stat_filters.h5'
+#############################
+Filename: h5stat_filters.h5
+File space information for datasets' metadata (in bytes):
+ Object headers (total/unused): 4136/1344
+ Index for Chunked datasets: 31392
+ Heap: 72
diff --git a/tools/h5stat/testfiles/h5stat_filters-T.ddl b/tools/h5stat/testfiles/h5stat_filters-T.ddl
new file mode 100644
index 0000000..189eaa6
--- /dev/null
+++ b/tools/h5stat/testfiles/h5stat_filters-T.ddl
@@ -0,0 +1,13 @@
+#############################
+Expected output for 'h5stat -T h5stat_filters.h5'
+#############################
+Filename: h5stat_filters.h5
+Dataset datatype information:
+ # of unique datatypes used by datasets: 2
+ Dataset datatype #0:
+ Count (total/named) = (14/0)
+ Size (desc./elmt) = (14/4)
+ Dataset datatype #1:
+ Count (total/named) = (1/0)
+ Size (desc./elmt) = (14/4)
+ Total dataset datatype count: 15
diff --git a/tools/h5stat/testfiles/h5stat_help1.ddl b/tools/h5stat/testfiles/h5stat_help1.ddl
index e70fef1..5665b35 100644
--- a/tools/h5stat/testfiles/h5stat_help1.ddl
+++ b/tools/h5stat/testfiles/h5stat_help1.ddl
@@ -5,14 +5,14 @@ Usage: h5stat [OPTIONS] file
OPTIONS
-h, --help Print a usage message and exit
- -v, --version Print version number and exit
+ -V, --version Print version number and exit
-f, --file Print file information
- -F, --FILEmetadata Print file space information for file's metadata
+ -F, --filemetadata Print file space information for file's metadata
-g, --group Print group information
- -G, --GROUPmetadata Print file space information for groups' metadata
+ -G, --groupmetadata Print file space information for groups' metadata
-d, --dset Print dataset information
- -D, --DSETmetadata Print file space information for datasets' metadata
- -T, --DSETtypeinfo Print datasets' datatype information
- -a, --attribute Print attribute information
+ -D, --dsetmetadata Print file space information for datasets' metadata
+ -T, --dtypemetadata Print datasets' datatype information
+ -A, --attribute Print attribute information
-s, --freespace Print free space information
-S, --summary Print summary of file space information
diff --git a/tools/h5stat/testfiles/h5stat_help2.ddl b/tools/h5stat/testfiles/h5stat_help2.ddl
index fbfdd14..3fb303a 100644
--- a/tools/h5stat/testfiles/h5stat_help2.ddl
+++ b/tools/h5stat/testfiles/h5stat_help2.ddl
@@ -5,14 +5,14 @@ Usage: h5stat [OPTIONS] file
OPTIONS
-h, --help Print a usage message and exit
- -v, --version Print version number and exit
+ -V, --version Print version number and exit
-f, --file Print file information
- -F, --FILEmetadata Print file space information for file's metadata
+ -F, --filemetadata Print file space information for file's metadata
-g, --group Print group information
- -G, --GROUPmetadata Print file space information for groups' metadata
+ -G, --groupmetadata Print file space information for groups' metadata
-d, --dset Print dataset information
- -D, --DSETmetadata Print file space information for datasets' metadata
- -T, --DSETtypeinfo Print datasets' datatype information
- -a, --attribute Print attribute information
+ -D, --dsetmetadata Print file space information for datasets' metadata
+ -T, --dtypemetadata Print datasets' datatype information
+ -A, --attribute Print attribute information
-s, --freespace Print free space information
-S, --summary Print summary of file space information
diff --git a/tools/h5stat/testfiles/h5stat_newgrat-A.ddl b/tools/h5stat/testfiles/h5stat_newgrat-A.ddl
new file mode 100644
index 0000000..70f9a82
--- /dev/null
+++ b/tools/h5stat/testfiles/h5stat_newgrat-A.ddl
@@ -0,0 +1,10 @@
+#############################
+Expected output for 'h5stat -A h5stat_newgrat.h5'
+#############################
+Filename: h5stat_newgrat.h5
+Small # of attributes:
+ Total # of objects with small # of attributes: 0
+Attribute bins:
+ # of objects with 100 - 999 attributes: 1
+ Total # of objects with attributes: 1
+ Max. # of attributes to objects: 100
diff --git a/tools/h5stat/testfiles/h5stat_newgrat-G.ddl b/tools/h5stat/testfiles/h5stat_newgrat-G.ddl
new file mode 100644
index 0000000..ecebdef
--- /dev/null
+++ b/tools/h5stat/testfiles/h5stat_newgrat-G.ddl
@@ -0,0 +1,8 @@
+#############################
+Expected output for 'h5stat -G h5stat_newgrat.h5'
+#############################
+Filename: h5stat_newgrat.h5
+File space information for groups' metadata (in bytes):
+ Object headers (total/unused): 5145147/3220092
+ B-tree/List: 470054
+ Heap: 739045
diff --git a/tools/h5stat/testh5stat.sh.in b/tools/h5stat/testh5stat.sh.in
index e387eb1..7369d45 100644
--- a/tools/h5stat/testh5stat.sh.in
+++ b/tools/h5stat/testh5stat.sh.in
@@ -123,12 +123,16 @@ TOOLTEST h5stat_filters-F.ddl -F h5stat_filters.h5
TOOLTEST h5stat_filters-d.ddl -d h5stat_filters.h5
TOOLTEST h5stat_filters-g.ddl -g h5stat_filters.h5
TOOLTEST h5stat_filters-dT.ddl -dT h5stat_filters.h5
+TOOLTEST h5stat_filters-D.ddl -D h5stat_filters.h5
+TOOLTEST h5stat_filters-T.ddl -T h5stat_filters.h5
+#
# h5stat_tsohm.h5 is a copy of ../../../test/tsohm.h5 generated by tsohm.c
# as of release 1.8.0-alpha4
TOOLTEST h5stat_tsohm.ddl h5stat_tsohm.h5
# h5stat_newgrat.h5 is generated by h5stat_gentest.c
TOOLTEST h5stat_newgrat.ddl h5stat_newgrat.h5
-
+TOOLTEST h5stat_newgrat-G.ddl -G h5stat_newgrat.h5
+TOOLTEST h5stat_newgrat-A.ddl -A h5stat_newgrat.h5
if test $nerrors -eq 0 ; then
echo "All $TESTNAME tests passed."