2017-04-18 03:32:16 +08:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2010-10-08 01:18:14 +08:00
|
|
|
# vfdTest.cmake executes a command and captures the output in a file. Command uses specified VFD.
|
|
|
|
# Exit status of command can also be compared.
|
2010-09-22 01:22:43 +08:00
|
|
|
|
|
|
|
# arguments checking
|
2014-03-12 05:14:57 +08:00
|
|
|
if (NOT TEST_PROGRAM)
|
|
|
|
message (FATAL_ERROR "Require TEST_PROGRAM to be defined")
|
2017-01-11 07:09:53 +08:00
|
|
|
endif ()
|
2014-03-12 05:14:57 +08:00
|
|
|
if (NOT TEST_FOLDER)
|
|
|
|
message ( FATAL_ERROR "Require TEST_FOLDER to be defined")
|
2017-01-11 07:09:53 +08:00
|
|
|
endif ()
|
2014-03-12 05:14:57 +08:00
|
|
|
if (NOT TEST_VFD)
|
|
|
|
message (FATAL_ERROR "Require TEST_VFD to be defined")
|
2017-01-11 07:09:53 +08:00
|
|
|
endif ()
|
2014-03-12 05:14:57 +08:00
|
|
|
|
2017-01-12 04:02:34 +08:00
|
|
|
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
|
2018-12-03 23:35:59 +08:00
|
|
|
#if (NOT TEST_ERRREF)
|
|
|
|
# set (ERROR_APPEND 1)
|
|
|
|
#endif ()
|
2014-03-12 05:14:57 +08:00
|
|
|
|
|
|
|
message (STATUS "USING ${TEST_VFD} ON COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}")
|
|
|
|
|
|
|
|
set (ENV{HDF5_DRIVER} "${TEST_VFD}")
|
2017-01-12 04:02:34 +08:00
|
|
|
|
2010-09-22 01:22:43 +08:00
|
|
|
# run the test program, capture the stdout/stderr and the result var
|
2017-01-12 04:02:34 +08:00
|
|
|
execute_process (
|
2010-09-22 01:22:43 +08:00
|
|
|
COMMAND ${TEST_PROGRAM} ${TEST_ARGS}
|
|
|
|
WORKING_DIRECTORY ${TEST_FOLDER}
|
2017-01-12 04:02:34 +08:00
|
|
|
RESULT_VARIABLE TEST_RESULT
|
2010-11-02 06:10:50 +08:00
|
|
|
OUTPUT_FILE ${TEST_OUTPUT}_${TEST_VFD}.out
|
|
|
|
ERROR_FILE ${TEST_OUTPUT}_${TEST_VFD}.err
|
2015-10-03 01:55:08 +08:00
|
|
|
OUTPUT_VARIABLE TEST_OUT
|
2010-09-22 01:22:43 +08:00
|
|
|
ERROR_VARIABLE TEST_ERROR
|
|
|
|
)
|
|
|
|
|
2014-03-12 05:14:57 +08:00
|
|
|
message (STATUS "COMMAND Result: ${TEST_RESULT}")
|
2010-09-22 01:22:43 +08:00
|
|
|
|
2017-01-12 04:02:34 +08:00
|
|
|
# if the .err file exists and ERRROR_APPEND is enabled
|
2016-02-24 04:50:02 +08:00
|
|
|
if (ERROR_APPEND AND EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}_${TEST_VFD}.err)
|
2014-03-19 00:21:46 +08:00
|
|
|
file (READ ${TEST_FOLDER}/${TEST_OUTPUT}_${TEST_VFD}.err TEST_STREAM)
|
2015-10-03 01:55:08 +08:00
|
|
|
file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT}_${TEST_VFD}.out "${TEST_STREAM}")
|
2017-01-11 07:09:53 +08:00
|
|
|
endif ()
|
2010-11-02 06:10:50 +08:00
|
|
|
|
2010-09-22 01:22:43 +08:00
|
|
|
# if the return value is !=${TEST_EXPECT} bail out
|
2017-10-03 01:39:15 +08:00
|
|
|
if (NOT "${TEST_RESULT}" STREQUAL "${TEST_EXPECT}")
|
2017-01-12 04:02:34 +08:00
|
|
|
if (NOT TEST_NOERRDISPLAY)
|
|
|
|
if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}_${TEST_VFD}.out)
|
|
|
|
file (READ ${TEST_FOLDER}/${TEST_OUTPUT}_${TEST_VFD}.out TEST_STREAM)
|
2017-10-03 01:39:15 +08:00
|
|
|
message (STATUS "Output USING ${TEST_VFD}:\n${TEST_STREAM}")
|
|
|
|
endif ()
|
2017-03-02 04:47:53 +08:00
|
|
|
endif ()
|
2017-01-12 04:02:34 +08:00
|
|
|
message (FATAL_ERROR "Failed: Test program ${TEST_PROGRAM} exited != ${TEST_EXPECT}.\n${TEST_ERROR}")
|
2017-01-11 07:09:53 +08:00
|
|
|
endif ()
|
2010-09-22 01:22:43 +08:00
|
|
|
|
2017-01-12 04:02:34 +08:00
|
|
|
message (STATUS "COMMAND Error: ${TEST_ERROR}")
|
|
|
|
|
2010-09-22 01:22:43 +08:00
|
|
|
# everything went fine...
|
2014-03-12 05:14:57 +08:00
|
|
|
message ("Passed: The ${TEST_PROGRAM} program used vfd ${TEST_VFD}")
|