summaryrefslogtreecommitdiffstats
path: root/tools/test/h5ls
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2018-12-13 17:22:04 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2018-12-13 17:22:04 (GMT)
commit35102212097f6f56e7d40fd910e1e200c17327bc (patch)
tree82102a9ca8c680ecf87bf8a39baf6d7bc5fa5e5a /tools/test/h5ls
parent88e514a6e51d0e3fedd855f7b2fbff74f1b5c802 (diff)
downloadhdf5-35102212097f6f56e7d40fd910e1e200c17327bc.zip
hdf5-35102212097f6f56e7d40fd910e1e200c17327bc.tar.gz
hdf5-35102212097f6f56e7d40fd910e1e200c17327bc.tar.bz2
HDFFV-10632 separate stderr and stdout in tests
Diffstat (limited to 'tools/test/h5ls')
-rw-r--r--tools/test/h5ls/CMakeTests.cmake52
-rw-r--r--tools/test/h5ls/errfiles/nosuchfile.err1
-rw-r--r--tools/test/h5ls/errfiles/textlinksrc-nodangle-1.err2
-rw-r--r--tools/test/h5ls/errfiles/tgroup-1.err2
-rw-r--r--tools/test/h5ls/testh5ls.sh.in11
5 files changed, 63 insertions, 5 deletions
diff --git a/tools/test/h5ls/CMakeTests.cmake b/tools/test/h5ls/CMakeTests.cmake
index 488b271..116d097 100644
--- a/tools/test/h5ls/CMakeTests.cmake
+++ b/tools/test/h5ls/CMakeTests.cmake
@@ -47,6 +47,12 @@
${HDF5_TOOLS_DIR}/testfiles/tdset_idx.h5
)
+ set (LIST_ERR_TEST_FILES
+ ${HDF5_TOOLS_DIR}/test/h5ls/errfiles/nosuchfile.err
+ ${HDF5_TOOLS_DIR}/test/h5ls/errfiles/textlinksrc-nodangle-1.err
+ ${HDF5_TOOLS_DIR}/test/h5ls/errfiles/tgroup-1.err
+ )
+
set (LIST_OTHER_TEST_FILES
${HDF5_TOOLS_DIR}/testfiles/help-1.ls
${HDF5_TOOLS_DIR}/testfiles/help-2.ls
@@ -116,6 +122,10 @@
get_filename_component(fname "${listfiles}" NAME)
HDFTEST_COPY_FILE("${listfiles}" "${PROJECT_BINARY_DIR}/testfiles/${fname}" "h5ls_files")
endforeach ()
+ foreach (listfiles ${LIST_ERR_TEST_FILES})
+ get_filename_component(fname "${listfiles}" NAME)
+ HDFTEST_COPY_FILE("${listfiles}" "${PROJECT_BINARY_DIR}/testfiles/${fname}" "h5ls_files")
+ endforeach ()
add_custom_target(h5ls_files ALL COMMENT "Copying files needed by h5ls tests" DEPENDS ${h5ls_files_list})
##############################################################################
@@ -159,6 +169,42 @@
endif ()
endmacro ()
+ macro (ADD_H5_ERR_TEST resultfile resultcode)
+ # If using memchecker add tests without using scripts
+ if (HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (NAME H5LS-${resultfile} COMMAND $<TARGET_FILE:h5ls> ${ARGN})
+ set_tests_properties (H5LS-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles")
+ if ("${resultcode}" STREQUAL "1")
+ set_tests_properties (H5LS-${resultfile} PROPERTIES WILL_FAIL "true")
+ endif ()
+ if (NOT "${last_test}" STREQUAL "")
+ set_tests_properties (H5LS-${resultfile} PROPERTIES DEPENDS ${last_test})
+ endif ()
+ else ()
+ # Remove any output file left over from previous test run
+ add_test (
+ NAME H5LS-${resultfile}-clear-objects
+ COMMAND ${CMAKE_COMMAND}
+ -E remove
+ testfiles/${resultfile}.out
+ testfiles/${resultfile}.out.err
+ )
+ add_test (
+ NAME H5LS-${resultfile}
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5ls>"
+ -D "TEST_ARGS=${ARGN}"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
+ -D "TEST_OUTPUT=${resultfile}.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_REFERENCE=${resultfile}.ls"
+ -D "TEST_ERRREF=${resultfile}.err"
+ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
+ )
+ set_tests_properties (H5LS-${resultfile} PROPERTIES DEPENDS H5LS-${resultfile}-clear-objects)
+ endif ()
+ endmacro ()
+
macro (ADD_H5_UD_TEST testname resultcode resultfile)
if (NOT HDF5_ENABLE_USING_MEMCHECKER)
# Remove any output file left over from previous test run
@@ -341,7 +387,7 @@
# test for displaying groups
# The following combination of arguments is expected to return an error message
# and return value 1
- ADD_H5_TEST (tgroup-1 1 -w80 -r -g tgroup.h5)
+ ADD_H5_ERR_TEST (tgroup-1 1 -w80 -r -g tgroup.h5)
ADD_H5_TEST (tgroup-2 0 -w80 -g tgroup.h5/g1)
# test for files with groups that have long comments
@@ -382,7 +428,7 @@
# tests for no-dangling-links
# if this option is given on dangling link, h5ls should return exit code 1
# when used alone , expect to print out help and return exit code 1
- ADD_H5_TEST (textlinksrc-nodangle-1 1 -w80 --no-dangling-links textlinksrc.h5)
+ ADD_H5_ERR_TEST (textlinksrc-nodangle-1 1 -w80 --no-dangling-links textlinksrc.h5)
# external dangling link - expected exit code 1
ADD_H5_TEST (textlinksrc-nodangle-2 1 -w80 --follow-symlinks --no-dangling-links textlinksrc.h5)
# soft dangling link - expected exit code 1
@@ -444,7 +490,7 @@
endif ()
# test for non-existing file
- ADD_H5_TEST (nosuchfile 1 nosuchfile.h5)
+ ADD_H5_ERR_TEST (nosuchfile 1 nosuchfile.h5)
# test for variable length data types in verbose mode
if (H5_WORDS_BIGENDIAN)
diff --git a/tools/test/h5ls/errfiles/nosuchfile.err b/tools/test/h5ls/errfiles/nosuchfile.err
new file mode 100644
index 0000000..8c4ee42
--- /dev/null
+++ b/tools/test/h5ls/errfiles/nosuchfile.err
@@ -0,0 +1 @@
+nosuchfile.h5: unable to open file
diff --git a/tools/test/h5ls/errfiles/textlinksrc-nodangle-1.err b/tools/test/h5ls/errfiles/textlinksrc-nodangle-1.err
new file mode 100644
index 0000000..8991fc1
--- /dev/null
+++ b/tools/test/h5ls/errfiles/textlinksrc-nodangle-1.err
@@ -0,0 +1,2 @@
+Error: --no-dangling-links must be used along with --follow-symlinks option!
+
diff --git a/tools/test/h5ls/errfiles/tgroup-1.err b/tools/test/h5ls/errfiles/tgroup-1.err
new file mode 100644
index 0000000..ba4cf07
--- /dev/null
+++ b/tools/test/h5ls/errfiles/tgroup-1.err
@@ -0,0 +1,2 @@
+Error: 'recursive' option not compatible with 'group info' option!
+
diff --git a/tools/test/h5ls/testh5ls.sh.in b/tools/test/h5ls/testh5ls.sh.in
index 8c6551b..353f1bb 100644
--- a/tools/test/h5ls/testh5ls.sh.in
+++ b/tools/test/h5ls/testh5ls.sh.in
@@ -53,6 +53,7 @@ SRC_H5REPACK_TESTFILES="$SRC_TOOLS/test/h5repack/testfiles"
SRC_H5JAM_TESTFILES="$SRC_TOOLS/test/h5jam/testfiles"
SRC_H5STAT_TESTFILES="$SRC_TOOLS/test/h5stat/testfiles"
SRC_H5IMPORT_TESTFILES="$SRC_TOOLS/test/h5import/testfiles"
+SRC_H5LS_ERRFILES="$SRC_TOOLS/test/h5ls/errfiles"
TESTDIR=./testfiles
test -d $TESTDIR || mkdir $TESTDIR
@@ -93,6 +94,12 @@ $SRC_H5LS_TESTFILES/tvldtypes1.h5
$SRC_H5LS_TESTFILES/tdset_idx.h5
"
+LIST_ERROR_TEST_FILES="
+$SRC_H5LS_ERRFILES/nosuchfile.err
+$SRC_H5LS_ERRFILES/textlinksrc-nodangle-1.err
+$SRC_H5LS_ERRFILES/tgroup-1.err
+"
+
LIST_OTHER_TEST_FILES="
$SRC_H5LS_TESTFILES/help-1.ls
$SRC_H5LS_TESTFILES/help-2.ls
@@ -228,8 +235,9 @@ TESTING() {
# $2 and on -- argument for the h5ls tool
TOOLTEST() {
expect="$TESTDIR/$1"
+ expect_err="$TESTDIR/`basename $1 .ls`.err"
actual="$TESTDIR/`basename $1 .ls`.out"
- actual_err="$TESTDIR/`basename $1 .ls`.err"
+ actual_err="$TESTDIR/`basename $1 .ls`.out.err"
actual_sav=${actual}-sav
actual_err_sav=${actual_err}-sav
shift
@@ -251,7 +259,6 @@ TOOLTEST() {
STDOUT_FILTER $actual
cp $actual_err $actual_err_sav
STDERR_FILTER $actual_err
- cat $actual_err >> $actual
if [ $h5haveexitcode = 'yes' -a $exitcode -ne $retvalexpect ]; then
echo "*FAILED*"
nerrors="`expr $nerrors + 1`"