diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2012-03-19 14:26:04 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2012-03-19 14:26:04 (GMT) |
commit | 19206f5687a4366f077ae47ae8e206f4a972144f (patch) | |
tree | 1022864b6b9015dcb035f33775d3fb0da24cddf2 /tools/h5dump | |
parent | b1a2c642a7105d808f884a27111236dd77df3ce0 (diff) | |
download | hdf5-19206f5687a4366f077ae47ae8e206f4a972144f.zip hdf5-19206f5687a4366f077ae47ae8e206f4a972144f.tar.gz hdf5-19206f5687a4366f077ae47ae8e206f4a972144f.tar.bz2 |
[svn-r22088] HDFFV-7957(7958): Correct use of ERROR_STACK for h5dump and tools.
Tested: local linux after week in trunk
Diffstat (limited to 'tools/h5dump')
-rw-r--r-- | tools/h5dump/CMakeLists.txt | 14 | ||||
-rw-r--r-- | tools/h5dump/h5dump.c | 266 | ||||
-rw-r--r-- | tools/h5dump/testh5dump.sh.in | 9 | ||||
-rwxr-xr-x | tools/h5dump/testh5dumpxml.sh.in | 4 |
4 files changed, 160 insertions, 133 deletions
diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt index 9908fd0..91e7ec6 100644 --- a/tools/h5dump/CMakeLists.txt +++ b/tools/h5dump/CMakeLists.txt @@ -126,6 +126,9 @@ IF (BUILD_TESTING) tlonglinks.ddl tloop-1.ddl tmulti.ddl + tmultifile.ddl +# tqmarkfile.ddl +# tstarfile.ddl tnamed_dtype_attr.ddl tnestcomp-1.ddl tnbit.ddl @@ -827,6 +830,12 @@ IF (BUILD_TESTING) tloop-1.out.err tmulti.out tmulti.out.err + tmultifile.out + tmultifile.out.err +# tqmarkfile.out +# tqmarkfile.out.err +# tstarfile.out +# tstarfile.out.err tnamed_dtype_attr.out tnamed_dtype_attr.out.err tnestcomp-1.out @@ -1010,6 +1019,11 @@ IF (BUILD_TESTING) ADD_H5_TEST (tarray7 0 --enable-error-stack tarray7.h5) ADD_H5_TEST (tarray8 0 --enable-error-stack tarray8.h5) + # test for wildcards in filename (does not work with cmake) + #ADD_H5_MASK_TEST (tstarfile 0 --enable-error-stack -H -d Dataset1 tarr*.h5) + #ADD_H5_MASK_TEST (tqmarkfile 0 --enable-error-stack -H -d Dataset1 tarray?.h5) + ADD_H5_TEST (tmultifile 0 --enable-error-stack -H -d Dataset1 tarray2.h5 tarray3.h5 tarray4.h5 tarray5.h5 tarray6.h5 tarray7.h5) + # test for files with empty data ADD_H5_TEST (tempty 0 --enable-error-stack tempty.h5) diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 23c8ea9..650846a 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -231,7 +231,7 @@ static void usage(const char *prog) { HDfflush(rawoutstream); - HDfprintf(rawoutstream, "usage: %s [OPTIONS] file\n", prog); + HDfprintf(rawoutstream, "usage: %s [OPTIONS] files\n", prog); HDfprintf(rawoutstream, " OPTIONS\n"); HDfprintf(rawoutstream, " -h, --help Print a usage message and exit\n"); HDfprintf(rawoutstream, " -n, --contents Print a list of the file contents and exit\n"); @@ -329,6 +329,10 @@ usage(const char *prog) HDfprintf(rawoutstream, "\n"); HDfprintf(rawoutstream, " h5dump -d /dset -M 0,1,4,3 quux.h5\n"); HDfprintf(rawoutstream, "\n"); + HDfprintf(rawoutstream, " 5) Dataset foo in files multi1.h5 multi2.h5 multi3.h5\n"); + HDfprintf(rawoutstream, "\n"); + HDfprintf(rawoutstream, " h5dump -d /foo multi1.h5 multi2.h5 multi3.h5\n"); + HDfprintf(rawoutstream, "\n"); } @@ -1453,161 +1457,161 @@ main(int argc, const char *argv[]) while(opt_ind < argc) { fname = HDstrdup(argv[opt_ind++]); - fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, driver, NULL, 0); - - if (fid < 0) { - error_msg("unable to open file \"%s\"\n", fname); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } + fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, driver, NULL, 0); - /* allocate and initialize internal data structure */ - init_prefix(&prefix, prefix_len); + if (fid < 0) { + error_msg("unable to open file \"%s\"\n", fname); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } - /* Prepare to find objects that might be targets of a reference */ - fill_ref_path_table(fid); + /* allocate and initialize internal data structure */ + init_prefix(&prefix, prefix_len); - if(doxml) { - /* initialize XML */ - /* reset prefix! */ - HDstrcpy(prefix, ""); + /* Prepare to find objects that might be targets of a reference */ + fill_ref_path_table(fid); - /* make sure the URI is initialized to something */ - if (xml_dtd_uri == NULL) { - if (useschema) { - xml_dtd_uri = DEFAULT_XSD; + if(doxml) { + /* initialize XML */ + /* reset prefix! */ + HDstrcpy(prefix, ""); + + /* make sure the URI is initialized to something */ + if (xml_dtd_uri == NULL) { + if (useschema) { + xml_dtd_uri = DEFAULT_XSD; + } + else { + xml_dtd_uri = DEFAULT_DTD; + xmlnsprefix = ""; + } } else { - xml_dtd_uri = DEFAULT_DTD; - xmlnsprefix = ""; - } - } - else { - if (useschema && HDstrcmp(xmlnsprefix,"")) { - error_msg("Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n"); - h5tools_setstatus(EXIT_FAILURE); - goto done; + if (useschema && HDstrcmp(xmlnsprefix,"")) { + error_msg("Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n"); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } } } - } - /* Get object info for root group */ - if(H5Oget_info_by_name(fid, "/", &oi, H5P_DEFAULT) < 0) { - error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - - /* Initialize object tables */ - if(table_list_add(fid, oi.fileno) < 0) { - error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - group_table = table_list.tables[0].group_table; - dset_table = table_list.tables[0].dset_table; - type_table = table_list.tables[0].type_table; - - /* does there exist unamed committed datatype */ - for (u = 0; u < type_table->nobjs; u++) - if (!type_table->objs[u].recorded) { - unamedtype = 1; - break; - } /* end if */ + /* Get object info for root group */ + if(H5Oget_info_by_name(fid, "/", &oi, H5P_DEFAULT) < 0) { + error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } - /* start to dump - display file header information */ - if (!doxml) { - begin_obj(h5tools_dump_header_format->filebegin, fname, h5tools_dump_header_format->fileblockbegin); - } - else { - HDfprintf(rawoutstream, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + /* Initialize object tables */ + if(table_list_add(fid, oi.fileno) < 0) { + error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + group_table = table_list.tables[0].group_table; + dset_table = table_list.tables[0].dset_table; + type_table = table_list.tables[0].type_table; + + /* does there exist unamed committed datatype */ + for (u = 0; u < type_table->nobjs; u++) + if (!type_table->objs[u].recorded) { + unamedtype = 1; + break; + } /* end if */ + + /* start to dump - display file header information */ + if (!doxml) { + begin_obj(h5tools_dump_header_format->filebegin, fname, h5tools_dump_header_format->fileblockbegin); + } + else { + HDfprintf(rawoutstream, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); - /* alternative first element, depending on schema or DTD. */ - if (useschema) { - if (HDstrcmp(xmlnsprefix,"") == 0) { - HDfprintf(rawoutstream, "<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\n", - xml_dtd_uri); + /* alternative first element, depending on schema or DTD. */ + if (useschema) { + if (HDstrcmp(xmlnsprefix,"") == 0) { + HDfprintf(rawoutstream, "<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\n", + xml_dtd_uri); + } + else { + /* TO DO: make -url option work in this case (may need new option) */ + char *ns; + char *indx; + + ns = HDstrdup(xmlnsprefix); + indx = HDstrrchr(ns,(int)':'); + if (indx) *indx = '\0'; + + HDfprintf(rawoutstream, "<%sHDF5-File xmlns:%s=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File\" " + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + "xsi:schemaLocation=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File " + "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\">\n",xmlnsprefix,ns); + HDfree(ns); + } } else { -/* TO DO: make -url option work in this case (may need new option) */ - char *ns; - char *indx; - - ns = HDstrdup(xmlnsprefix); - indx = HDstrrchr(ns,(int)':'); - if (indx) *indx = '\0'; - - HDfprintf(rawoutstream, "<%sHDF5-File xmlns:%s=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File\" " - "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " - "xsi:schemaLocation=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File " - "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\">\n",xmlnsprefix,ns); - HDfree(ns); + HDfprintf(rawoutstream, "<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n", xml_dtd_uri); + HDfprintf(rawoutstream, "<HDF5-File>\n"); } - } - else { - HDfprintf(rawoutstream, "<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n", xml_dtd_uri); - HDfprintf(rawoutstream, "<HDF5-File>\n"); } - } - if (!doxml) { - if (display_fi) { - HDfprintf(rawoutstream, "\n"); - dump_fcontents(fid); - end_obj(h5tools_dump_header_format->fileend,h5tools_dump_header_format->fileblockend); - HDfprintf(rawoutstream, "\n"); - goto done; + if (!doxml) { + if (display_fi) { + HDfprintf(rawoutstream, "\n"); + dump_fcontents(fid); + end_obj(h5tools_dump_header_format->fileend,h5tools_dump_header_format->fileblockend); + HDfprintf(rawoutstream, "\n"); + goto done; + } + + if (display_bb) + dump_fcpl(fid); } - if (display_bb) - dump_fcpl(fid); - } + if(display_all) { + if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) { + error_msg("unable to open root group\n"); + h5tools_setstatus(EXIT_FAILURE); + } + else { + if (!doxml) + dump_indent += COL; + dump_function_table->dump_group_function(gid, "/" ); + if (!doxml) + dump_indent -= COL; + HDfprintf(rawoutstream, "\n"); + } - if(display_all) { - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) { - error_msg("unable to open root group\n"); - h5tools_setstatus(EXIT_FAILURE); - } - else { - if (!doxml) - dump_indent += COL; - dump_function_table->dump_group_function(gid, "/" ); - if (!doxml) - dump_indent -= COL; - HDfprintf(rawoutstream, "\n"); - } + if(H5Gclose(gid) < 0) { + error_msg("unable to close root group\n"); + h5tools_setstatus(EXIT_FAILURE); + } - if(H5Gclose(gid) < 0) { - error_msg("unable to close root group\n"); - h5tools_setstatus(EXIT_FAILURE); } + else { + /* Note: this option is not supported for XML */ + if(doxml) { + error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } /* end if */ - } - else { - /* Note: this option is not supported for XML */ - if(doxml) { - error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } /* end if */ - - for(i = 0; i < argc; i++) { - if(hand[i].func) { - hand[i].func(fid, hand[i].obj, hand[i].subset_info, 1, NULL); + for(i = 0; i < argc; i++) { + if(hand[i].func) { + hand[i].func(fid, hand[i].obj, hand[i].subset_info, 1, NULL); + } } + HDfprintf(rawoutstream, "\n"); } - HDfprintf(rawoutstream, "\n"); - } - if (!doxml) { - end_obj(h5tools_dump_header_format->fileend, h5tools_dump_header_format->fileblockend); - HDfprintf(rawoutstream, "\n"); - } - else { - HDfprintf(rawoutstream, "</%sHDF5-File>\n", xmlnsprefix); - } - /* Free tables for objects */ - table_list_free(); + if (!doxml) { + end_obj(h5tools_dump_header_format->fileend, h5tools_dump_header_format->fileblockend); + HDfprintf(rawoutstream, "\n"); + } + else { + HDfprintf(rawoutstream, "</%sHDF5-File>\n", xmlnsprefix); + } + /* Free tables for objects */ + table_list_free(); if(fid >=0) if (H5Fclose(fid) < 0) diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index 06eca36..18cd5d4 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -50,6 +50,7 @@ if test -z "$srcdir"; then fi # source dirs SRC_TOOLS="$srcdir/../" + SRC_TOOLS_TESTFILES="$SRC_TOOLS/testfiles" # testfiles source dirs for tools SRC_H5LS_TESTFILES="$SRC_TOOLS_TESTFILES" @@ -242,6 +243,9 @@ $SRC_H5DUMP_TESTFILES/tlarge_objname.ddl $SRC_H5DUMP_TESTFILES/tlonglinks.ddl $SRC_H5DUMP_TESTFILES/tloop-1.ddl $SRC_H5DUMP_TESTFILES/tmulti.ddl +$SRC_H5DUMP_TESTFILES/tmultifile.ddl +$SRC_H5DUMP_TESTFILES/tqmarkfile.ddl +$SRC_H5DUMP_TESTFILES/tstarfile.ddl $SRC_H5DUMP_TESTFILES/tnamed_dtype_attr.ddl $SRC_H5DUMP_TESTFILES/tnestcomp-1.ddl $SRC_H5DUMP_TESTFILES/tnbit.ddl @@ -792,6 +796,11 @@ TOOLTEST tarray6.ddl --enable-error-stack tarray6.h5 TOOLTEST tarray7.ddl --enable-error-stack tarray7.h5 TOOLTEST tarray8.ddl --enable-error-stack tarray8.h5 +# test for wildcards in filename (does not work with cmake) +TOOLTEST3 tstarfile --enable-error-stack -H -d Dataset1 tarr*.h5 +TOOLTEST3 tqmarkfile --enable-error-stack -H -d Dataset1 tarray?.h5 +TOOLTEST tmultifile --enable-error-stack -H -d Dataset1 tarray2.h5 tarray3.h5 tarray4.h5 tarray5.h5 tarray6.h5 tarray7.h5 + # test for files with empty data TOOLTEST tempty.ddl --enable-error-stack tempty.h5 diff --git a/tools/h5dump/testh5dumpxml.sh.in b/tools/h5dump/testh5dumpxml.sh.in index 0bd01b0..1bbf232 100755 --- a/tools/h5dump/testh5dumpxml.sh.in +++ b/tools/h5dump/testh5dumpxml.sh.in @@ -71,7 +71,7 @@ TOOLTEST() { if [ ! -f $expect ]; then # Create the expect file if it doesn't yet exist. echo " CREATED" - cp $actual $expect + cp $actual $expect elif $CMP $expect $actual; then echo " PASSED" else @@ -96,7 +96,7 @@ SKIP() { ############################################################################## ############################################################################## -### T H E T E S T S ### +### T H E T E S T S ### ############################################################################## ############################################################################## |