summaryrefslogtreecommitdiffstats
path: root/config/cmake/volTest.cmake
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2019-01-01 01:19:39 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2019-01-01 01:19:39 (GMT)
commit07b76068a4517f874fc5584049178ed5f61e3cea (patch)
tree7223c8f107c0e21c38c0482962dbb2584345a74e /config/cmake/volTest.cmake
parente8108d76992ba43fbdfda01b262e9121ad00d2ed (diff)
parentfa6077332b36f3af0042561ccff29faef7f09e34 (diff)
downloadhdf5-07b76068a4517f874fc5584049178ed5f61e3cea.zip
hdf5-07b76068a4517f874fc5584049178ed5f61e3cea.tar.gz
hdf5-07b76068a4517f874fc5584049178ed5f61e3cea.tar.bz2
Merge branch 'develop' into vfd_init_cleanup
Diffstat (limited to 'config/cmake/volTest.cmake')
-rw-r--r--config/cmake/volTest.cmake76
1 files changed, 76 insertions, 0 deletions
diff --git a/config/cmake/volTest.cmake b/config/cmake/volTest.cmake
new file mode 100644
index 0000000..27da8a5
--- /dev/null
+++ b/config/cmake/volTest.cmake
@@ -0,0 +1,76 @@
+#
+# Copyright by The HDF Group.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
+#
+# volTest.cmake executes a command and captures the output in a file. Command uses specified VOL.
+# Exit status of command can also be compared.
+
+# arguments checking
+if (NOT TEST_PROGRAM)
+ message (FATAL_ERROR "Require TEST_PROGRAM to be defined")
+endif ()
+if (NOT TEST_FOLDER)
+ message ( FATAL_ERROR "Require TEST_FOLDER to be defined")
+endif ()
+if (NOT TEST_VOL)
+ message (FATAL_ERROR "Require TEST_VOL to be defined")
+endif ()
+
+if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT})
+ file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT})
+endif ()
+
+if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.err)
+ file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}.err)
+endif ()
+
+# if there is not an error reference file add the error output to the stdout file
+#if (NOT TEST_ERRREF)
+# set (ERROR_APPEND 1)
+#endif ()
+
+message (STATUS "USING ${TEST_VOL} ON COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}")
+
+set (ENV{HDF5_VOL_CONNECTOR} "${TEST_VOL}")
+
+# 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}.out
+ ERROR_FILE ${TEST_OUTPUT}.err
+ OUTPUT_VARIABLE TEST_OUT
+ ERROR_VARIABLE TEST_ERROR
+)
+
+message (STATUS "COMMAND Result: ${TEST_RESULT}")
+
+# if the .err file exists and ERRROR_APPEND is enabled
+if (ERROR_APPEND AND EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.err)
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM)
+ file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT}.out "${TEST_STREAM}")
+endif ()
+
+# if the return value is !=${TEST_EXPECT} bail out
+if (NOT "${TEST_RESULT}" STREQUAL "${TEST_EXPECT}")
+ if (NOT TEST_NOERRDISPLAY)
+ if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.out)
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.out TEST_STREAM)
+ message (STATUS "Output USING ${TEST_VOL}:\n${TEST_STREAM}")
+ endif ()
+ endif ()
+ message (FATAL_ERROR "Failed: Test program ${TEST_PROGRAM} exited != ${TEST_EXPECT}.\n${TEST_ERROR}")
+endif ()
+
+message (STATUS "COMMAND Error: ${TEST_ERROR}")
+
+# everything went fine...
+message ("Passed: The ${TEST_PROGRAM} program used vol ${TEST_VOL}")