summaryrefslogtreecommitdiffstats
path: root/tools/h5dump
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2011-02-28 20:25:25 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2011-02-28 20:25:25 (GMT)
commitc6382f50c5744595d3a9ba69a04f76782f3b8672 (patch)
treec53cc31164515c7647eceb3da2dd64e745c426c6 /tools/h5dump
parent600bcf0dc3bf984c752737385e0a90ffd29feb38 (diff)
downloadhdf5-c6382f50c5744595d3a9ba69a04f76782f3b8672.zip
hdf5-c6382f50c5744595d3a9ba69a04f76782f3b8672.tar.gz
hdf5-c6382f50c5744595d3a9ba69a04f76782f3b8672.tar.bz2
[svn-r20168] BZ2048: Add -E --enable-error-stack option to h5dump.
Tested: local linux, heiwa, windows
Diffstat (limited to 'tools/h5dump')
-rw-r--r--tools/h5dump/CMakeLists.txt26
-rw-r--r--tools/h5dump/h5dump.c14
-rw-r--r--tools/h5dump/testh5dump.sh.in51
3 files changed, 88 insertions, 3 deletions
diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt
index 13cfee7..dc03f01 100644
--- a/tools/h5dump/CMakeLists.txt
+++ b/tools/h5dump/CMakeLists.txt
@@ -38,6 +38,7 @@ IF (BUILD_TESTING)
# Copy all the HDF5 files from the test directory into the source directory
# --------------------------------------------------------------------
SET (HDF5_REFERENCE_FILES
+ filter_fail.ddl
packedbits.ddl
tall-1.ddl
tall-2.ddl
@@ -220,6 +221,7 @@ IF (BUILD_TESTING)
tbin3.ddl
tbin4.ddl
out3.h5import
+ filter_fail.h5
packedbits.h5
taindices.h5
tall.h5
@@ -440,6 +442,25 @@ IF (BUILD_TESTING)
SET (last_test "H5DUMP-output-cmp-${resultfile}")
ENDMACRO (ADD_H5_EXPORT_TEST file)
+ MACRO (ADD_H5_MASK_TEST resultfile resultcode)
+ ADD_TEST (
+ NAME H5DUMP-${resultfile}
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>"
+ -D "TEST_ARGS:STRING=${ARGN}"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
+ -D "TEST_OUTPUT=${resultfile}.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_REFERENCE=${resultfile}.ddl"
+ -D "TEST_MASK_ERROR=true"
+ -P "${HDF5_RESOURCES_DIR}/runTest.cmake"
+ )
+ IF (NOT "${last_test}" STREQUAL "")
+ SET_TESTS_PROPERTIES (H5DUMP-${resultfile} PROPERTIES DEPENDS ${last_test})
+ ENDIF (NOT "${last_test}" STREQUAL "")
+ SET (last_test "H5DUMP-${resultfile}")
+ ENDMACRO (ADD_H5_MASK_TEST file)
+
MACRO (ADD_XML_SKIP_H5_TEST skipresultfile skipresultcode testtype)
IF (${testtype} STREQUAL "SKIP")
ADD_TEST (
@@ -495,6 +516,8 @@ IF (BUILD_TESTING)
NAME H5DUMP-clearall-objects
COMMAND ${CMAKE_COMMAND}
-E remove
+ filter_fail.out
+ filter_fail.out.err
packedbits.out
packedbits.out.err
tall-1.out
@@ -1048,6 +1071,9 @@ IF (BUILD_TESTING)
# test for dangling external links
ADD_H5_TEST (textlink 0 textlink.h5)
+ # test for error stack display (BZ2048)
+ ADD_H5_MASK_TEST (filter_fail 1 -E filter_fail.h5)
+
####### test for dataset packed bits ######
IF (HDF5_USE_H5DUMP_PACKED_BITS)
# Remove any output file left over from previous test run
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 6b1f576..98bd6c9 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -92,6 +92,7 @@ static int display_fi = FALSE; /*file index */
static int display_ai = TRUE; /*array index */
static int display_escape = FALSE; /*escape non printable characters */
static int display_region = FALSE; /*print region reference data */
+static int enable_error_stack= FALSE; /* re-enable error stack */
/* sort parameters */
static H5_index_t sort_by = H5_INDEX_NAME; /*sort_by [creation_order | name] */
@@ -386,7 +387,7 @@ struct handler_t {
* parameters. The long-named ones can be partially spelled. When
* adding more, make sure that they don't clash with each other.
*/
-static const char *s_opts = "hnpeyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:b*F:s:S:Aq:z:m:R";
+static const char *s_opts = "hnpeyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:b*F:s:S:Aq:z:m:RE";
static struct long_options l_opts[] = {
{ "help", no_arg, 'h' },
{ "hel", no_arg, 'h' },
@@ -499,6 +500,7 @@ static struct long_options l_opts[] = {
{ "sort_order", require_arg, 'z' },
{ "format", require_arg, 'm' },
{ "region", no_arg, 'R' },
+ { "enable-error-stack", no_arg, 'E' },
{ NULL, 0, '\0' }
};
@@ -661,6 +663,7 @@ usage(const char *prog)
fprintf(stdout, " -X S, --xml-ns=S (XML Schema) Use qualified names n the XML\n");
fprintf(stdout, " \":\": no namespace, default: \"hdf5:\"\n");
fprintf(stdout, " E.g., to dump a file called `-f', use h5dump -- -f\n");
+ fprintf(stdout, " -E, --enable-error-stack Show all HDF5 error reporting\n");
fprintf(stdout, "\n");
fprintf(stdout, " Subsetting is available by using the following options with a dataset\n");
fprintf(stdout, " attribute. Subsetting is done by selecting a hyperslab from the data.\n");
@@ -4221,6 +4224,9 @@ end_collect:
}
/** end subsetting parameters **/
+ case 'E':
+ enable_error_stack = TRUE;
+ break;
case 'h':
usage(h5tools_getprogname());
leave(EXIT_SUCCESS);
@@ -4342,12 +4348,14 @@ main(int argc, const char *argv[])
h5tools_init();
hand = parse_command_line(argc, argv);
- if ( bin_output && outfname == NULL )
- {
+ if (bin_output && outfname == NULL) {
error_msg("binary output requires a file name, use -o <filename>\n");
leave(EXIT_FAILURE);
}
+ if (enable_error_stack)
+ H5Eset_auto2(H5E_DEFAULT, func, edata);
+
/* Check for conflicting options */
if (doxml) {
if (!display_all) {
diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in
index db42cb6..96be2b9 100644
--- a/tools/h5dump/testh5dump.sh.in
+++ b/tools/h5dump/testh5dump.sh.in
@@ -196,6 +196,55 @@ TOOLTEST2() {
}
+# same as TOOLTEST but filters error stack outp
+# Extract file name, line number, version and thread IDs because they may be different
+TOOLTEST3() {
+
+ expect="$srcdir/../testfiles/$1"
+ actual="../testfiles/`basename $1 .ddl`.out"
+ actual_err="../testfiles/`basename $1 .ddl`.err"
+ actual_ext="../testfiles/`basename $1 .ddl`.ext"
+ shift
+
+ # Run test.
+ TESTING $DUMPER $@
+ (
+ echo "#############################"
+ echo "Expected output for '$DUMPER $@'"
+ echo "#############################"
+ cd $srcdir/../testfiles
+ $RUNSERIAL $DUMPER_BIN $@
+ ) >$actual 2>$actual_err
+
+ # Extract file name, line number, version and thread IDs because they may be different
+ sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \
+ -e 's/line [0-9]*/line (number)/' \
+ -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \
+ -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \
+ -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \
+ -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \
+ $actual_err > $actual_ext
+ cat $actual_ext >> $actual
+
+ if [ ! -f $expect ]; then
+ # Create the expect file if it doesn't yet exist.
+ echo " CREATED"
+ cp $actual $expect
+ elif $CMP $expect $actual; then
+ echo " PASSED"
+ else
+ echo "*FAILED*"
+ echo " Expected result (*.ddl) differs from actual result (*.out)"
+ nerrors="`expr $nerrors + 1`"
+ test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /'
+ fi
+
+ # Clean up output file
+ if test -z "$HDF5_NOCLEANUP"; then
+ rm -f $actual $actual_err
+ fi
+
+}
# Print a "SKIP" message
SKIP() {
@@ -581,6 +630,8 @@ TOOLTEST textlinkfar.ddl textlinkfar.h5
# test for dangling external links
TOOLTEST textlink.ddl textlink.h5
+# test for error stack display (BZ2048)
+TOOLTEST3 filter_fail.ddl -E filter_fail.h5
# Report test results and exit
if test $nerrors -eq 0 ; then