summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt6
-rw-r--r--MANIFEST1
-rw-r--r--config/cmake/grepTest.cmake61
-rw-r--r--tools/h5repack/CMakeLists.txt77
4 files changed, 139 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b45f13c..b8bfb33 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -522,11 +522,11 @@ ENDIF (WIN32)
# Note: Currently CMake only allows configuring of threadsafe on WINDOWS.
#-----------------------------------------------------------------------------
IF (WIN32)
-OPTION (HDF5_ENABLE_THREADSAFE "Enable Threadsafety" OFF)
-IF (HDF5_ENABLE_THREADSAFE)
+ OPTION (HDF5_ENABLE_THREADSAFE "Enable Threadsafety" OFF)
+ IF (HDF5_ENABLE_THREADSAFE)
SET (H5_HAVE_WIN_THREADS 1)
SET (H5_HAVE_THREADSAFE 1)
-ENDIF (HDF5_ENABLE_THREADSAFE)
+ ENDIF (HDF5_ENABLE_THREADSAFE)
ENDIF (WIN32)
#-----------------------------------------------------------------------------
diff --git a/MANIFEST b/MANIFEST
index 628e770..63e9e10 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1926,6 +1926,7 @@
./config/cmake/HDF5Macros.cmake
./config/cmake/libhdf5.settings.cmake.in
./config/cmake/cacheinit.cmake
+./config/cmake/grepTest.cmake
./config/cmake/runTest.cmake
./config/cmake/CTestCustom.ctest
./config/cmake/ConfigureChecks.cmake
diff --git a/config/cmake/grepTest.cmake b/config/cmake/grepTest.cmake
new file mode 100644
index 0000000..cc3a9b4
--- /dev/null
+++ b/config/cmake/grepTest.cmake
@@ -0,0 +1,61 @@
+# runTest.cmake executes a command and captures the output in a file. File is then compared
+# against a reference file. Exit status of command can also be compared.
+
+# arguments checking
+IF (NOT TEST_PROGRAM)
+ MESSAGE (FATAL_ERROR "Require TEST_PROGRAM to be defined")
+ENDIF (NOT TEST_PROGRAM)
+#IF (NOT TEST_ARGS)
+# MESSAGE (STATUS "Require TEST_ARGS to be defined")
+#ENDIF (NOT TEST_ARGS)
+IF (NOT TEST_FOLDER)
+ MESSAGE ( FATAL_ERROR "Require TEST_FOLDER to be defined")
+ENDIF (NOT TEST_FOLDER)
+IF (NOT TEST_OUTPUT)
+ MESSAGE (FATAL_ERROR "Require TEST_OUTPUT to be defined")
+ENDIF (NOT TEST_OUTPUT)
+#IF (NOT TEST_EXPECT)
+# MESSAGE (STATUS "Require TEST_EXPECT to be defined")
+#ENDIF (NOT TEST_EXPECT)
+IF (NOT TEST_FILTER)
+ MESSAGE (STATUS "Require TEST_FILTER to be defined")
+ENDIF (NOT TEST_FILTER)
+IF (NOT TEST_REFERENCE)
+ MESSAGE (FATAL_ERROR "Require TEST_REFERENCE to be defined")
+ENDIF (NOT TEST_REFERENCE)
+
+MESSAGE (STATUS "COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}")
+
+# run the test program, capture the stdout/stderr and the result var
+EXECUTE_PROCESS (
+ COMMAND ${TEST_PROGRAM} ${TEST_ARGS}
+ WORKING_DIRECTORY ${TEST_FOLDER}
+ RESULT_VARIABLE TEST_RESULT
+ OUTPUT_FILE ${TEST_OUTPUT}
+ ERROR_FILE ${TEST_OUTPUT}.err
+ OUTPUT_VARIABLE TEST_ERROR
+ ERROR_VARIABLE TEST_ERROR
+)
+
+MESSAGE (STATUS "COMMAND Result: ${TEST_RESULT}")
+MESSAGE (STATUS "COMMAND Error: ${TEST_ERROR}")
+
+# now grep the output with the reference
+FILE (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM)
+
+STRING(REGEX MATCH "${TEST_FILTER}" TEST_MATCH ${TEST_STREAM})
+IF (${TEST_EXPECT})
+ STRING(LENGTH "${TEST_MATCH}" TEST_RESULT)
+ IF (NOT ${TEST_RESULT} STREQUAL "0")
+ MESSAGE (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did contain ${TEST_REFERENCE}")
+ ENDIF (NOT ${TEST_RESULT} STREQUAL "0")
+ELSE (${TEST_EXPECT})
+ STRING(COMPARE EQUAL "${TEST_REFERENCE}" "${TEST_MATCH}" TEST_RESULT)
+ IF (${TEST_RESULT} STREQUAL "0")
+ MESSAGE (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did not contain ${TEST_REFERENCE}")
+ ENDIF (${TEST_RESULT} STREQUAL "0")
+ENDIF (${TEST_EXPECT})
+
+# everything went fine...
+MESSAGE ("Passed: The output of ${TEST_PROGRAM} matched")
+
diff --git a/tools/h5repack/CMakeLists.txt b/tools/h5repack/CMakeLists.txt
index 618c4a1..be2844d 100644
--- a/tools/h5repack/CMakeLists.txt
+++ b/tools/h5repack/CMakeLists.txt
@@ -81,6 +81,7 @@ IF (BUILD_TESTING)
h5repack_hlink.h5
h5repack_layout.h5
h5repack_layouto.h5
+ h5repack_layout2.h5
h5repack_named_dtypes.h5
h5repack_nbit.h5
h5repack_objs.h5
@@ -148,7 +149,7 @@ IF (BUILD_TESTING)
COMMAND $<TARGET_FILE:h5diff> ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out.${testfile}
)
ENDIF (${testtype} STREQUAL "SKIP")
- ENDMACRO (ADD_H5_TEST testname testfile testtype)
+ ENDMACRO (ADD_H5_TEST)
MACRO (ADD_H5_CMP_TEST testname testfilter testtype resultcode resultfile)
IF (${testtype} STREQUAL "SKIP")
@@ -170,7 +171,53 @@ IF (BUILD_TESTING)
-P "${HDF5_RESOURCES_DIR}/runTest.cmake"
)
ENDIF (${testtype} STREQUAL "SKIP")
- ENDMACRO (ADD_H5_CMP_TEST file)
+ ENDMACRO (ADD_H5_CMP_TEST)
+
+ MACRO (ADD_H5_VERIFY_TEST testname testtype resultcode testfile testdset testfilter)
+ IF (${testtype} STREQUAL "SKIP")
+ ADD_TEST (
+ NAME H5REPACK_VERIFY_LAYOUT-${testname}
+ COMMAND ${CMAKE_COMMAND} -E echo "SKIP -d ${testdset} -pH ${PROJECT_BINARY_DIR}/testfiles/out.${resultfile}"
+ )
+ ELSE (${testtype} STREQUAL "SKIP")
+ IF (${resultcode} STREQUAL "0")
+ ADD_TEST (
+ NAME H5REPACK_VERIFY_LAYOUT-${testname}
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>"
+ -D "TEST_ARGS:STRING=-d;${testdset};-pH;testfiles/out.${testfile}"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
+ -D "TEST_OUTPUT=${testfile}-v.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_FILTER:STRING=${testfilter}"
+ -D "TEST_REFERENCE=${testfilter}"
+ -P "${HDF5_RESOURCES_DIR}/grepTest.cmake"
+ )
+ ELSE (${resultcode} STREQUAL "0")
+ IF (${testfilter} STREQUAL "CHUNKED")
+ SET (nottestfilter "(CONTIGUOUS|COMPACT)")
+ ENDIF (${testfilter} STREQUAL "CHUNKED")
+ IF (${testfilter} STREQUAL "CONTIGUOUS")
+ SET (nottestfilter "(CHUNK|COMPACT)")
+ ENDIF (${testfilter} STREQUAL "CONTIGUOUS")
+ IF (${testfilter} STREQUAL "COMPACT")
+ SET (nottestfilter "(CONTIGUOUS|CHUNK)")
+ ENDIF (${testfilter} STREQUAL "COMPACT")
+ ADD_TEST (
+ NAME H5REPACK_VERIFY_LAYOUT_ALL-${testname}
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>"
+ -D "TEST_ARGS:STRING=-pH;testfiles/out.${testfile}"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
+ -D "TEST_OUTPUT=${testfile}-v.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_FILTER:STRING=${nottestfilter}"
+ -D "TEST_REFERENCE=${testfilter}"
+ -P "${HDF5_RESOURCES_DIR}/grepTest.cmake"
+ )
+ ENDIF (${resultcode} STREQUAL "0")
+ ENDIF (${testtype} STREQUAL "SKIP")
+ ENDMACRO (ADD_H5_VERIFY_TEST)
##############################################################################
##############################################################################
@@ -199,6 +246,7 @@ IF (BUILD_TESTING)
SET (FILE14 h5repack_layouto.h5 ) # A file with an older version of the layout message (copy of test/tlayouto.h5)
SET (FILE15 h5repack_named_dtypes.h5)
SET (FILE16 tfamily%05d.h5) # located in common testfiles folder
+ SET (FILE18 h5repack_layout2.h5)
SET (FILE_REF h5repack_refs.h5)
SET (FILE_ATTR_REF h5repack_attr_refs.h5)
@@ -496,26 +544,47 @@ ADD_H5_TEST (deflate_file ${TESTTYPE} ${arg})
#########################################################
ADD_H5_TEST (dset2_chunk_20x10 "TEST" ${FILE4} --layout=dset2:CHUNK=20x10)
+ADD_H5_VERIFY_TEST (dset2_chunk_20x10 "TEST" 0 ${FILE4} dset2 CHUNKED)
ADD_H5_TEST (chunk_20x10 "TEST" ${FILE4} -l CHUNK=20x10)
+ADD_H5_VERIFY_TEST (chunk_20x10 "TEST" 1 ${FILE4} null CHUNKED)
ADD_H5_TEST (dset2_conti "TEST" ${FILE4} -l dset2:CONTI)
+ADD_H5_VERIFY_TEST (dset2_conti "TEST" 0 ${FILE4} dset2 CONTIGUOUS)
ADD_H5_TEST (conti "TEST" ${FILE4} -l CONTI)
+ADD_H5_VERIFY_TEST (conti "TEST" 1 ${FILE4} null CONTIGUOUS)
ADD_H5_TEST (dset2_compa "TEST" ${FILE4} -l dset2:COMPA)
+ADD_H5_VERIFY_TEST (dset2_compa "TEST" 0 ${FILE4} dset2 COMPACT)
ADD_H5_TEST (compa "TEST" ${FILE4} -l COMPA)
-
+ADD_H5_VERIFY_TEST (compa "TEST" 1 ${FILE4} null COMPACT)
################################################################
# layout conversions (file has no filters)
###############################################################
ADD_H5_TEST (dset_compa_conti "TEST" ${FILE4} -l dset_compact:CONTI)
+ADD_H5_VERIFY_TEST (dset_compa_conti "TEST" 0 ${FILE4} dset_compact CONTIGUOUS)
ADD_H5_TEST (dset_compa_chunk "TEST" ${FILE4} -l dset_compact:CHUNK=2x5)
+ADD_H5_VERIFY_TEST (dset_compa_chunk "TEST" 0 ${FILE4} dset_compact CHUNKED)
ADD_H5_TEST (dset_compa_compa "TEST" ${FILE4} -l dset_compact:COMPA)
+ADD_H5_VERIFY_TEST (dset_compa_compa "TEST" 0 ${FILE4} dset_compact COMPACT)
ADD_H5_TEST (dset_conti_compa "TEST" ${FILE4} -l dset_contiguous:COMPA)
+ADD_H5_VERIFY_TEST (dset_conti_compa "TEST" 0 ${FILE4} dset_contiguous COMPACT)
ADD_H5_TEST (dset_conti_chunk "TEST" ${FILE4} -l dset_contiguous:CHUNK=3x6)
+ADD_H5_VERIFY_TEST (dset_conti_chunk "TEST" 0 ${FILE4} dset_contiguous CHUNKED)
ADD_H5_TEST (dset_conti_conti "TEST" ${FILE4} -l dset_contiguous:CONTI)
+ADD_H5_VERIFY_TEST (dset_conti_conti "TEST" 0 ${FILE4} dset_contiguous CONTIGUOUS)
ADD_H5_TEST (chunk_compa "TEST" ${FILE4} -l dset_chunk:COMPA)
+ADD_H5_VERIFY_TEST (chunk_compa "TEST" 0 ${FILE4} dset_chunk COMPACT)
ADD_H5_TEST (chunk_conti "TEST" ${FILE4} -l dset_chunk:CONTI)
+ADD_H5_VERIFY_TEST (chunk_conti "TEST" 0 ${FILE4} dset_chunk CONTIGUOUS)
ADD_H5_TEST (chunk_18x13 "TEST" ${FILE4} -l dset_chunk:CHUNK=18x13)
+ADD_H5_VERIFY_TEST (chunk_18x13 "TEST" 0 ${FILE4} dset_chunk CHUNKED)
+
+# test convert small size dataset ( < 1k) to compact layout without -m
+ADD_H5_TEST (contig_small_compa "TEST" ${FILE18} -l contig_small:COMPA)
+ADD_H5_VERIFY_TEST (contig_small_compa "TEST" 0 ${FILE18} contig_small COMPACT)
+
+ADD_H5_TEST (contig_small_fixed_compa "TEST" ${FILE18} -l chunked_small_fixed:COMPA)
+ADD_H5_VERIFY_TEST (contig_small_fixed_compa "TEST" 0 ${FILE18} chunked_small_fixed COMPACT)
# Native option
# Do not use FILE1, as the named dtype will be converted to native, and h5diff will
@@ -531,6 +600,7 @@ IF (NOT USE_FILTER_DEFLATE)
SET (TESTTYPE "SKIP")
ENDIF (NOT USE_FILTER_DEFLATE)
ADD_H5_TEST (layout_long_switches ${TESTTYPE} ${arg})
+ADD_H5_VERIFY_TEST (layout_long_switches ${TESTTYPE} 1 ${FILE4} null CHUNKED)
# latest file format with short switches. use FILE4=h5repack_layout.h5 (no filters)
SET (arg ${FILE4} -l CHUNK=20x10 -f GZIP=1 -m 10 -n -L -c 8 -d 6 -s 8[:dtype])
@@ -539,6 +609,7 @@ IF (NOT USE_FILTER_DEFLATE)
SET (TESTTYPE "SKIP")
ENDIF (NOT USE_FILTER_DEFLATE)
ADD_H5_TEST (layout_short_switches ${TESTTYPE} ${arg})
+ADD_H5_VERIFY_TEST (layout_short_switches ${TESTTYPE} 1 ${FILE4} null CHUNKED)
# several global filters
SET (arg ${FILE4} --filter GZIP=1 --filter SHUF)