summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/h5dump/CMakeLists.txt35
-rw-r--r--tools/h5dump/testh5dump.sh.in132
-rw-r--r--tools/testfiles/tstr2bin2.exp1
-rw-r--r--tools/testfiles/tstr2bin6.exp1
4 files changed, 156 insertions, 13 deletions
diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt
index 03efa58..05c6363 100644
--- a/tools/h5dump/CMakeLists.txt
+++ b/tools/h5dump/CMakeLists.txt
@@ -184,6 +184,14 @@ IF (BUILD_TESTING)
${HDF5_TOOLS_SRC_DIR}/testfiles/h5dump-help.txt
${HDF5_TOOLS_SRC_DIR}/testfiles/out3.h5import
)
+ SET (HDF5_REFERENCE_EXP_FILES
+# tall-6.exp
+# tnoddlfile.exp
+# trawdatafile.exp
+ tstr2bin2.exp
+ tstr2bin6.exp
+# twithddlfile.exp
+ )
SET (HDF5_REFERENCE_TEST_FILES
${HDF5_TOOLS_SRC_DIR}/testfiles/charsets.h5
${HDF5_TOOLS_SRC_DIR}/testfiles/filter_fail.h5
@@ -315,6 +323,20 @@ IF (BUILD_TESTING)
ARGS -E copy_if_different ${tst_h5_file} ${dest}
)
ENDFOREACH (tst_h5_file ${HDF5_REFERENCE_TEST_FILES})
+
+ FOREACH (tst_exp_file ${HDF5_REFERENCE_EXP_FILES})
+ IF (WIN32 AND NOT CYGWIN)
+ FILE (READ ${HDF5_TOOLS_SRC_DIR}/testfiles/${tst_exp_file} TEST_STREAM)
+ FILE (WRITE ${PROJECT_BINARY_DIR}/testfiles/${tst_exp_file} "${TEST_STREAM}")
+ ELSE (WIN32 AND NOT CYGWIN)
+ ADD_CUSTOM_COMMAND (
+ TARGET h5dump
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ ARGS -E copy_if_different ${HDF5_TOOLS_SRC_DIR}/testfiles/${tst_exp_file} ${PROJECT_BINARY_DIR}/testfiles/${tst_exp_file}
+ )
+ ENDIF (WIN32 AND NOT CYGWIN)
+ ENDFOREACH (tst_exp_file ${HDF5_REFERENCE_EXP_FILES})
FOREACH (tst_other_file ${HDF5_REFERENCE_FILES})
GET_FILENAME_COMPONENT(fname "${tst_other_file}" NAME)
@@ -664,9 +686,9 @@ IF (BUILD_TESTING)
MACRO (ADD_H5_EXPORT_TEST resultfile targetfile resultcode)
ADD_TEST (
NAME H5DUMP-output-${resultfile}
- COMMAND $<TARGET_FILE:h5dump> ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile}.txt ${PROJECT_BINARY_DIR}/testfiles/${targetfile}
+ COMMAND $<TARGET_FILE:h5dump> ${ARGN} ${resultfile}.txt ${targetfile}
)
- SET_TESTS_PROPERTIES (H5DUMP-output-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles")
+ SET_TESTS_PROPERTIES (H5DUMP-output-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles")
IF (NOT "${last_test}" STREQUAL "")
SET_TESTS_PROPERTIES (H5DUMP-output-${resultfile} PROPERTIES DEPENDS ${last_test})
ENDIF (NOT "${last_test}" STREQUAL "")
@@ -675,8 +697,9 @@ IF (BUILD_TESTING)
ADD_TEST (
NAME H5DUMP-output-cmp-${resultfile}
COMMAND ${CMAKE_COMMAND}
- -E compare_files ${PROJECT_BINARY_DIR}/testfiles/${resultfile}.txt ${PROJECT_BINARY_DIR}/testfiles/${resultfile}.exp
+ -E compare_files ${resultfile}.txt ${resultfile}.exp
)
+ SET_TESTS_PROPERTIES (H5DUMP-output-cmp-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles")
IF (NOT "${last_test}" STREQUAL "")
SET_TESTS_PROPERTIES (H5DUMP-output-cmp-${resultfile} PROPERTIES DEPENDS ${last_test})
ENDIF (NOT "${last_test}" STREQUAL "")
@@ -1028,6 +1051,8 @@ IF (BUILD_TESTING)
tstr-1.out.err
tstr-2.out
tstr-2.out.err
+ tstr2bin2.txt
+ tstr2bin6.txt
tstring.out
tstring.out.err
tstring2.out
@@ -1312,6 +1337,10 @@ IF (BUILD_TESTING)
# test for binary output
ADD_H5_TEST (tbin1LE 0 --enable-error-stack -d integer -o out1LE.bin -b LE tbinary.h5)
+ # test for string binary output
+ ADD_H5_EXPORT_TEST (tstr2bin2 tstr2.h5 0 --enable-error-stack -d /g2/dset2 -b -o)
+ ADD_H5_EXPORT_TEST (tstr2bin6 tstr2.h5 0 --enable-error-stack -d /g6/dset6 -b -o)
+
# NATIVE default. the NATIVE test can be validated with h5import/h5diff
ADD_H5_TEST (tbin1 0 --enable-error-stack -d integer -o out1.bin -b tbinary.h5)
IF (NOT "${last_test}" STREQUAL "")
diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in
index 1dbda52..18ed854 100644
--- a/tools/h5dump/testh5dump.sh.in
+++ b/tools/h5dump/testh5dump.sh.in
@@ -283,6 +283,8 @@ $SRC_H5DUMP_TESTFILES/tslink-D.ddl
$SRC_H5DUMP_TESTFILES/tsplit_file.ddl
$SRC_H5DUMP_TESTFILES/tstr-1.ddl
$SRC_H5DUMP_TESTFILES/tstr-2.ddl
+$SRC_H5DUMP_TESTFILES/tstr2bin2.exp
+$SRC_H5DUMP_TESTFILES/tstr2bin6.exp
$SRC_H5DUMP_TESTFILES/tstring.ddl
$SRC_H5DUMP_TESTFILES/tstring2.ddl
$SRC_H5DUMP_TESTFILES/tstringe.ddl
@@ -379,7 +381,7 @@ TESTING() {
# the actual output file is calculated by replacing the `.ddl' with
# `.out'. The actual output is not removed if $HDF5_NOCLEANUP has a
# non-zero value.
-#
+# ADD_H5_TEST
TOOLTEST() {
expect="$TESTDIR/$1"
actual="$TESTDIR/`basename $1 .ddl`.out"
@@ -426,6 +428,7 @@ TOOLTEST() {
# same as TOOLTEST1 but compares generated file to expected output
# and compares the generated data file to the expected data file
# used for the binary tests that expect a full path in -o without -b
+# ADD_H5_EXPORT_TEST
TOOLTEST2() {
expectdata="$TESTDIR/$1"
@@ -474,6 +477,111 @@ TOOLTEST2() {
}
+# same as TOOLTEST2 but compares generated file to expected ddl file
+# and compares the generated data file to the expected data file
+# used for the binary tests that expect a full path in -o without -b
+# ADD_H5_TEST_EXPORT
+TOOLTEST2A() {
+
+ expectdata="$TESTDIR/$1"
+ expect="$TESTDIR/`basename $1 .exp`.ddl"
+ actualdata="$TESTDIR/`basename $1 .exp`.txt"
+ actual="$TESTDIR/`basename $1 .exp`.out"
+ actual_err="$TESTDIR/`basename $1 .exp`.err"
+ shift
+ expectmeta="$TESTDIR/$1"
+ actualmeta="$TESTDIR/`basename $1 .ddl`.txt"
+ shift
+
+ # Run test.
+ TESTING $DUMPER $@
+ (
+ cd $TESTDIR
+ $RUNSERIAL $DUMPER_BIN "$@"
+ ) >$actual 2>$actual_err
+ cat $actual_err >> $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
+ if [ ! -f $expectdata ]; then
+ # Create the expect data file if it doesn't yet exist.
+ echo " CREATED"
+ cp $actualdata $expectdata
+ elif $CMP $expectdata $actualdata; then
+ if [ ! -f $expectmeta ]; then
+ # Create the expect meta file if it doesn't yet exist.
+ echo " CREATED"
+ cp $actualmeta $expectmeta
+ elif $CMP $expectmeta $actualmeta; then
+ echo " PASSED"
+ else
+ echo "*FAILED*"
+ echo " Expected metafile (*.ddl) differs from actual metafile (*.txt)"
+ nerrors="`expr $nerrors + 1`"
+ test yes = "$verbose" && $DIFF $expectmeta $actualmeta |sed 's/^/ /'
+ fi
+ else
+ echo "*FAILED*"
+ echo " Expected datafile (*.exp) differs from actual datafile (*.txt)"
+ nerrors="`expr $nerrors + 1`"
+ test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /'
+ fi
+ 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 $actualdata $actual_err $actualmeta
+ fi
+
+}
+
+# same as TOOLTEST2 but only compares the generated data file to the expected data file
+# used for the binary tests that expect a full path in -o with -b
+# ADD_H5_EXPORT_TEST
+TOOLTEST2B() {
+
+ expectdata="$TESTDIR/$1"
+ actualdata="$TESTDIR/`basename $1 .exp`.txt"
+ actual="$TESTDIR/`basename $1 .exp`.out"
+ actual_err="$TESTDIR/`basename $1 .exp`.err"
+ shift
+
+ # Run test.
+ TESTING $DUMPER $@
+ (
+ cd $TESTDIR
+ $RUNSERIAL $DUMPER_BIN "$@"
+ ) >$actual 2>$actual_err
+ cat $actual_err >> $actual
+
+ if [ ! -f $expectdata ]; then
+ # Create the expect data file if it doesn't yet exist.
+ echo " CREATED"
+ cp $actualdata $expectdata
+ elif $CMP $expectdata $actualdata; then
+ echo " PASSED"
+ else
+ echo "*FAILED*"
+ echo " Expected datafile (*.exp) differs from actual datafile (*.txt)"
+ nerrors="`expr $nerrors + 1`"
+ test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /'
+ fi
+
+ # Clean up output file
+ if test -z "$HDF5_NOCLEANUP"; then
+ rm -f $actual $actualdata $actual_err
+ fi
+
+}
+
# same as TOOLTEST but filters error stack outp
# Extract file name, line number, version and thread IDs because they may be different
TOOLTEST3() {
@@ -531,6 +639,7 @@ TOOLTEST3() {
# same as TOOLTEST3 but filters error stack output and compares to an error file
# Extract file name, line number, version and thread IDs because they may be different
+# ADD_H5ERR_MASK_TEST
TOOLTEST4() {
expect="$TESTDIR/$1"
@@ -661,7 +770,7 @@ IMPORTTEST()
##############################################################################
##############################################################################
-### T H E T E S T S ###
+### T H E T E S T S ###
##############################################################################
##############################################################################
# prepare for test
@@ -769,7 +878,7 @@ TOOLTEST tarray8.ddl --enable-error-stack tarray8.h5
# test for wildcards in filename (does not work with cmake)
# inconsistent across platforms TOOLTEST3 tstarfile.ddl --enable-error-stack -H -d Dataset1 tarr*.h5
-TOOLTEST4 tqmarkfile.ddl --enable-error-stack -H -d Dataset1 tarray?.h5
+#TOOLTEST4 tqmarkfile.ddl --enable-error-stack -H -d Dataset1 tarray?.h5
TOOLTEST tmultifile.ddl --enable-error-stack -H -d Dataset1 tarray2.h5 tarray3.h5 tarray4.h5 tarray5.h5 tarray6.h5 tarray7.h5
# test for files with empty data
@@ -909,17 +1018,21 @@ TOOLTEST zerodim.ddl --enable-error-stack zerodim.h5
TOOLTEST tvms.ddl --enable-error-stack tvms.h5
# test for binary output
-TOOLTEST tbin1.ddl --enable-error-stack -d integer -o out1.bin -b LE tbinary.h5
+TOOLTEST tbin1.ddl --enable-error-stack -d integer -o out1.bin -b LE tbinary.h5
+
+# test for string binary output
+TOOLTEST2B tstr2bin2.exp --enable-error-stack -d /g2/dset2 -b -o tstr2bin2.txt tstr2.h5
+TOOLTEST2B tstr2bin6.exp --enable-error-stack -d /g6/dset6 -b -o tstr2bin6.txt tstr2.h5
# NATIVE default. the NATIVE test can be validated with h5import/h5diff
-TOOLTEST tbin1.ddl --enable-error-stack -d integer -o out1.bin -b tbinary.h5
+TOOLTEST tbin1.ddl --enable-error-stack -d integer -o out1.bin -b tbinary.h5
IMPORTTEST out1.bin -c out3.h5import -o out1.h5
DIFFTEST tbinary.h5 out1.h5 /integer /integer
# Same but use h5dump as input to h5import
IMPORTTEST out1.bin -c tbin1.ddl -o out1D.h5
DIFFTEST tbinary.h5 out1D.h5 /integer /integer
-TOOLTEST tbin2.ddl --enable-error-stack -b BE -d float -o out2.bin tbinary.h5
+TOOLTEST tbin2.ddl --enable-error-stack -b BE -d float -o out2.bin tbinary.h5
# the NATIVE test can be validated with h5import/h5diff
TOOLTEST tbin3.ddl --enable-error-stack -d integer -o out3.bin -b NATIVE tbinary.h5
@@ -939,12 +1052,11 @@ if test -z "$HDF5_NOCLEANUP"; then
fi
# test for dataset region references
-TOOLTEST tdatareg.ddl --enable-error-stack tdatareg.h5
+TOOLTEST tdatareg.ddl --enable-error-stack tdatareg.h5
TOOLTEST4 tdataregR.ddl --enable-error-stack -R tdatareg.h5
-TOOLTEST tattrreg.ddl --enable-error-stack tattrreg.h5
+TOOLTEST tattrreg.ddl --enable-error-stack tattrreg.h5
TOOLTEST4 tattrregR.ddl --enable-error-stack -R tattrreg.h5
-
-TOOLTEST2 tbinregR.exp --enable-error-stack -d /Dataset1 -s 0 -R -y -o tbinregR.txt tdatareg.h5
+TOOLTEST2 tbinregR.exp --enable-error-stack -d /Dataset1 -s 0 -R -y -o tbinregR.txt tdatareg.h5
# Clean up text output files
if test -z "$HDF5_NOCLEANUP"; then
diff --git a/tools/testfiles/tstr2bin2.exp b/tools/testfiles/tstr2bin2.exp
new file mode 100644
index 0000000..5d4c544
--- /dev/null
+++ b/tools/testfiles/tstr2bin2.exp
@@ -0,0 +1 @@
+This is row 0 of type H5T_STR_NULLTERM of string This is row 1 of type H5T_STR_NULLTERM of string This is row 2 of type H5T_STR_NULLTERM of string This is row 3 of type H5T_STR_NULLTERM of string This is row 4 of type H5T_STR_NULLTERM of string This is row 5 of type H5T_STR_NULLTERM of string This is row 6 of type H5T_STR_NULLTERM of string This is row 7 of type H5T_STR_NULLTERM of string This is row 8 of type H5T_STR_NULLTERM of string This is row 9 of type H5T_STR_NULLTERM of string \ No newline at end of file
diff --git a/tools/testfiles/tstr2bin6.exp b/tools/testfiles/tstr2bin6.exp
new file mode 100644
index 0000000..5c6c22a
--- /dev/null
+++ b/tools/testfiles/tstr2bin6.exp
@@ -0,0 +1 @@
+This is row 0 of type H5T_STR_SPACEPAD of string aThis is row 1 of type H5T_STR_SPACEPAD of string aThis is row 2 of type H5T_STR_SPACEPAD of string aThis is row 3 of type H5T_STR_SPACEPAD of string aThis is row 4 of type H5T_STR_SPACEPAD of string aThis is row 5 of type H5T_STR_SPACEPAD of string aThis is row 6 of type H5T_STR_SPACEPAD of string aThis is row 7 of type H5T_STR_SPACEPAD of string aThis is row 8 of type H5T_STR_SPACEPAD of string aThis is row 9 of type H5T_STR_SPACEPAD of string a \ No newline at end of file