summaryrefslogtreecommitdiffstats
path: root/tools/test
diff options
context:
space:
mode:
authorAllen Byrne <50328838+byrnHDF@users.noreply.github.com>2023-05-17 15:41:01 (GMT)
committerGitHub <noreply@github.com>2023-05-17 15:41:01 (GMT)
commitc961ef98ffb21728cb86ae30c3e3d9a3f1053672 (patch)
treee86051bd5a9155466ce4db05d184273ff5bb0eb3 /tools/test
parent560e7d6728f2003784b550530a3424a61ade04d5 (diff)
downloadhdf5-c961ef98ffb21728cb86ae30c3e3d9a3f1053672.zip
hdf5-c961ef98ffb21728cb86ae30c3e3d9a3f1053672.tar.gz
hdf5-c961ef98ffb21728cb86ae30c3e3d9a3f1053672.tar.bz2
Add h5copy help test and verify consistency (#2902)
* Add autotools test for help
Diffstat (limited to 'tools/test')
-rw-r--r--tools/test/h5copy/CMakeTests.cmake32
-rw-r--r--tools/test/h5copy/testfiles/h5copy_help1.ddl49
-rw-r--r--tools/test/h5copy/testfiles/h5copy_help2.ddl49
-rw-r--r--tools/test/h5copy/testh5copy.sh.in42
-rw-r--r--tools/test/h5stat/testfiles/h5stat_help1.ddl2
-rw-r--r--tools/test/h5stat/testfiles/h5stat_help2.ddl2
-rw-r--r--tools/test/h5stat/testfiles/h5stat_nofile.ddl2
7 files changed, 175 insertions, 3 deletions
diff --git a/tools/test/h5copy/CMakeTests.cmake b/tools/test/h5copy/CMakeTests.cmake
index 05288b4..b47000a 100644
--- a/tools/test/h5copy/CMakeTests.cmake
+++ b/tools/test/h5copy/CMakeTests.cmake
@@ -35,6 +35,8 @@
${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/tudfilter.h5_ERR.txt
${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_plugin_fail_ERR.out.h5.txt
${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_plugin_test.out.h5.txt
+ ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_help1.ddl
+ ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_help2.ddl
)
file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles")
@@ -393,6 +395,32 @@
endif ()
endmacro ()
+ macro (ADD_SIMPLE_TEST resultfile resultcode)
+ # If using memchecker add tests without using scripts
+ if (HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (NAME H5COPY-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5copy${tgt_file_ext}> ${ARGN})
+ if (${resultcode})
+ set_tests_properties (H5COPY-${resultfile} PROPERTIES WILL_FAIL "true")
+ endif ()
+ else (HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (
+ NAME H5COPY-${resultfile}
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5copy${tgt_file_ext}>"
+ -D "TEST_ARGS=${ARGN}"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
+ -D "TEST_OUTPUT=./testfiles/${resultfile}.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_REFERENCE=./testfiles/${resultfile}.ddl"
+ -P "${HDF_RESOURCES_DIR}/runTest.cmake"
+ )
+ endif ()
+ set_tests_properties (H5COPY-${resultfile} PROPERTIES
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
+ )
+ endmacro ()
+
##############################################################################
##############################################################################
### T H E T E S T S ###
@@ -420,6 +448,10 @@
set (USE_FILTER_SZIP "true")
endif ()
+# Test for help flag
+ ADD_SIMPLE_TEST (h5copy_help1 0 -h)
+ ADD_SIMPLE_TEST (h5copy_help2 0 --help)
+
# "Test copying various forms of datasets"
ADD_H5_TEST (simple 0 ${HDF_FILE1}.h5 -v -s simple -d simple)
ADD_H5_TEST (chunk 0 ${HDF_FILE1}.h5 -v -s chunk -d chunk)
diff --git a/tools/test/h5copy/testfiles/h5copy_help1.ddl b/tools/test/h5copy/testfiles/h5copy_help1.ddl
new file mode 100644
index 0000000..418faea
--- /dev/null
+++ b/tools/test/h5copy/testfiles/h5copy_help1.ddl
@@ -0,0 +1,49 @@
+
+usage: h5copy [OPTIONS] [OBJECTS...]
+ OBJECTS
+ -i, --input input file name
+ -o, --output output file name
+ -s, --source source object name
+ -d, --destination destination object name
+ ERROR
+ --enable-error-stack Prints messages from the HDF5 error stack as they occur.
+ Optional value 2 also prints file open errors.
+ OPTIONS
+ -h, --help Print a usage message and exit
+ -p, --parents No error if existing, make parent groups as needed
+ -v, --verbose Print information about OBJECTS and OPTIONS
+ -V, --version Print version number and exit
+ -f, --flag Flag type
+
+ Flag type is one of the following strings:
+
+ shallow Copy only immediate members for groups
+
+ soft Expand soft links into new objects
+
+ ext Expand external links into new objects
+
+ ref Copy references and any referenced objects, i.e., objects
+ that the references point to.
+ Referenced objects are copied in addition to the objects
+ specified on the command line and reference datasets are
+ populated with correct reference values. Copies of referenced
+ datasets outside the copy range specified on the command line
+ will normally have a different name from the original.
+ (Default:Without this option, reference value(s) in any
+ reference datasets are set to NULL and referenced objects are
+ not copied unless they are otherwise within the copy range
+ specified on the command line.)
+
+ noattr Copy object without copying attributes
+
+ allflags Switches all flags from the default to the non-default setting
+
+ These flag types correspond to the following API symbols
+
+ H5O_COPY_SHALLOW_HIERARCHY_FLAG
+ H5O_COPY_EXPAND_SOFT_LINK_FLAG
+ H5O_COPY_EXPAND_EXT_LINK_FLAG
+ H5O_COPY_EXPAND_REFERENCE_FLAG
+ H5O_COPY_WITHOUT_ATTR_FLAG
+ H5O_COPY_ALL
diff --git a/tools/test/h5copy/testfiles/h5copy_help2.ddl b/tools/test/h5copy/testfiles/h5copy_help2.ddl
new file mode 100644
index 0000000..418faea
--- /dev/null
+++ b/tools/test/h5copy/testfiles/h5copy_help2.ddl
@@ -0,0 +1,49 @@
+
+usage: h5copy [OPTIONS] [OBJECTS...]
+ OBJECTS
+ -i, --input input file name
+ -o, --output output file name
+ -s, --source source object name
+ -d, --destination destination object name
+ ERROR
+ --enable-error-stack Prints messages from the HDF5 error stack as they occur.
+ Optional value 2 also prints file open errors.
+ OPTIONS
+ -h, --help Print a usage message and exit
+ -p, --parents No error if existing, make parent groups as needed
+ -v, --verbose Print information about OBJECTS and OPTIONS
+ -V, --version Print version number and exit
+ -f, --flag Flag type
+
+ Flag type is one of the following strings:
+
+ shallow Copy only immediate members for groups
+
+ soft Expand soft links into new objects
+
+ ext Expand external links into new objects
+
+ ref Copy references and any referenced objects, i.e., objects
+ that the references point to.
+ Referenced objects are copied in addition to the objects
+ specified on the command line and reference datasets are
+ populated with correct reference values. Copies of referenced
+ datasets outside the copy range specified on the command line
+ will normally have a different name from the original.
+ (Default:Without this option, reference value(s) in any
+ reference datasets are set to NULL and referenced objects are
+ not copied unless they are otherwise within the copy range
+ specified on the command line.)
+
+ noattr Copy object without copying attributes
+
+ allflags Switches all flags from the default to the non-default setting
+
+ These flag types correspond to the following API symbols
+
+ H5O_COPY_SHALLOW_HIERARCHY_FLAG
+ H5O_COPY_EXPAND_SOFT_LINK_FLAG
+ H5O_COPY_EXPAND_EXT_LINK_FLAG
+ H5O_COPY_EXPAND_REFERENCE_FLAG
+ H5O_COPY_WITHOUT_ATTR_FLAG
+ H5O_COPY_ALL
diff --git a/tools/test/h5copy/testh5copy.sh.in b/tools/test/h5copy/testh5copy.sh.in
index 7587c0e..1f64d15 100644
--- a/tools/test/h5copy/testh5copy.sh.in
+++ b/tools/test/h5copy/testh5copy.sh.in
@@ -60,6 +60,8 @@ $SRC_H5COPY_TESTFILES/h5copy_extlinks_trg.h5
LIST_OTHER_TEST_FILES="
$SRC_H5COPY_TESTFILES/h5copy_misc1.out
$SRC_H5COPY_TESTFILES/h5copy_misc1.err
+$SRC_H5COPY_TESTFILES/h5copy_help1.ddl
+$SRC_H5COPY_TESTFILES/h5copy_help2.ddl
"
H5COPY=../../src/h5copy/h5copy # The tool name
@@ -483,6 +485,42 @@ H5DIFFTEST_FAIL()
fi
}
+# ADD_HELP_TEST
+TOOLTEST_HELP() {
+
+ expect="$TESTDIR/$1"
+ actual="$TESTDIR/`basename $1 .ddl`.out"
+ actual_err="$TESTDIR/`basename $1 .ddl`.err"
+ shift
+
+ # Run test.
+ TESTING $H5COPY $@
+ (
+ cd $TESTDIR
+ $RUNSERIAL $H5COPY_BIN "$@"
+ ) >$actual 2>$actual_err
+
+ if [ ! -f $expectdata ]; then
+ # Create the expect data file if it doesn't yet exist.
+ echo " CREATED"
+ cp $actual $expect-CREATED
+ echo " Expected output (*.ddl) missing"
+ nerrors="`expr $nerrors + 1`"
+ elif $CMP $expect $actual; then
+ echo " PASSED"
+ else
+ echo "*FAILED*"
+ echo " Expected output (*.ddl) differs from actual output (*.out)"
+ nerrors="`expr $nerrors + 1`"
+ fi
+
+ # Clean up output file
+ if test -z "$HDF5_NOCLEANUP"; then
+ rm -f $actual $actual_err
+ fi
+
+}
+
# Copy single datasets of various forms from one group to another,
# adding object copied to the destination file each time
#
@@ -607,6 +645,10 @@ fi
# prepare for test
COPY_TESTFILES_TO_TESTDIR
+# check help text
+TOOLTEST_HELP h5copy_help1.ddl -h
+TOOLTEST_HELP h5copy_help2.ddl --help
+
# Start tests
COPY_OBJECTS
COPY_REFERENCES
diff --git a/tools/test/h5stat/testfiles/h5stat_help1.ddl b/tools/test/h5stat/testfiles/h5stat_help1.ddl
index 1f65f0d..54d6a31 100644
--- a/tools/test/h5stat/testfiles/h5stat_help1.ddl
+++ b/tools/test/h5stat/testfiles/h5stat_help1.ddl
@@ -1,4 +1,4 @@
-Usage: h5stat [OPTIONS] file
+usage: h5stat [OPTIONS] file
ERROR
--enable-error-stack Prints messages from the HDF5 error stack as they occur
diff --git a/tools/test/h5stat/testfiles/h5stat_help2.ddl b/tools/test/h5stat/testfiles/h5stat_help2.ddl
index 1f65f0d..54d6a31 100644
--- a/tools/test/h5stat/testfiles/h5stat_help2.ddl
+++ b/tools/test/h5stat/testfiles/h5stat_help2.ddl
@@ -1,4 +1,4 @@
-Usage: h5stat [OPTIONS] file
+usage: h5stat [OPTIONS] file
ERROR
--enable-error-stack Prints messages from the HDF5 error stack as they occur
diff --git a/tools/test/h5stat/testfiles/h5stat_nofile.ddl b/tools/test/h5stat/testfiles/h5stat_nofile.ddl
index 1f65f0d..54d6a31 100644
--- a/tools/test/h5stat/testfiles/h5stat_nofile.ddl
+++ b/tools/test/h5stat/testfiles/h5stat_nofile.ddl
@@ -1,4 +1,4 @@
-Usage: h5stat [OPTIONS] file
+usage: h5stat [OPTIONS] file
ERROR
--enable-error-stack Prints messages from the HDF5 error stack as they occur