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")
|
|
|
|
endif (NOT TEST_PROGRAM)
|
|
|
|
#if (NOT TEST_ARGS)
|
|
|
|
# message (STATUS "Require TEST_ARGS to be defined")
|
|
|
|
#endif (NOT TEST_ARGS)
|
|
|
|
#if (NOT TEST_EXPECT)
|
|
|
|
# message (STATUS "Require TEST_EXPECT to be defined")
|
|
|
|
#endif (NOT TEST_EXPECT)
|
|
|
|
if (NOT TEST_FOLDER)
|
|
|
|
message ( FATAL_ERROR "Require TEST_FOLDER to be defined")
|
|
|
|
endif (NOT TEST_FOLDER)
|
|
|
|
if (NOT TEST_VFD)
|
|
|
|
message (FATAL_ERROR "Require TEST_VFD to be defined")
|
|
|
|
endif (NOT TEST_VFD)
|
|
|
|
|
|
|
|
set (ERROR_APPEND 1)
|
|
|
|
|
|
|
|
message (STATUS "USING ${TEST_VFD} ON COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}")
|
|
|
|
|
|
|
|
set (ENV{HDF5_DRIVER} "${TEST_VFD}")
|
2010-09-22 01:22:43 +08:00
|
|
|
# run the test program, capture the stdout/stderr and the result var
|
|
|
|
EXECUTE_PROCESS (
|
|
|
|
COMMAND ${TEST_PROGRAM} ${TEST_ARGS}
|
|
|
|
WORKING_DIRECTORY ${TEST_FOLDER}
|
2010-11-02 06:10:50 +08:00
|
|
|
OUTPUT_FILE ${TEST_OUTPUT}_${TEST_VFD}.out
|
|
|
|
ERROR_FILE ${TEST_OUTPUT}_${TEST_VFD}.err
|
2010-09-22 01:22:43 +08:00
|
|
|
OUTPUT_VARIABLE TEST_ERROR
|
|
|
|
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
|
|
|
|
2014-03-12 05:14:57 +08:00
|
|
|
if (ERROR_APPEND)
|
2014-03-19 00:21:46 +08:00
|
|
|
file (READ ${TEST_FOLDER}/${TEST_OUTPUT}_${TEST_VFD}.err TEST_STREAM)
|
|
|
|
file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT}_${TEST_VFD}.out "${TEST_STREAM}")
|
2014-03-12 05:14:57 +08:00
|
|
|
endif (ERROR_APPEND)
|
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
|
2014-03-12 05:14:57 +08:00
|
|
|
if (NOT ${TEST_RESULT} STREQUAL ${TEST_EXPECT})
|
|
|
|
message ( FATAL_ERROR "Failed: Test program ${TEST_PROGRAM} exited != ${TEST_EXPECT}.\n${TEST_ERROR}")
|
|
|
|
endif (NOT ${TEST_RESULT} STREQUAL ${TEST_EXPECT})
|
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}")
|
2010-09-22 01:22:43 +08:00
|
|
|
|