summaryrefslogtreecommitdiffstats
path: root/config/cmake/jrunTest.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'config/cmake/jrunTest.cmake')
-rw-r--r--config/cmake/jrunTest.cmake42
1 files changed, 28 insertions, 14 deletions
diff --git a/config/cmake/jrunTest.cmake b/config/cmake/jrunTest.cmake
index 23f297c..44ac15b 100644
--- a/config/cmake/jrunTest.cmake
+++ b/config/cmake/jrunTest.cmake
@@ -9,7 +9,7 @@
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
-# runTest.cmake executes a command and captures the output in a file. File is then compared
+# jrunTest.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.
cmake_policy(SET CMP0007 NEW)
@@ -24,7 +24,7 @@ if (NOT TEST_LIBRARY_DIRECTORY)
message (STATUS "Require TEST_LIBRARY_DIRECTORY to be defined")
endif ()
if (NOT TEST_FOLDER)
- message ( FATAL_ERROR "Require TEST_FOLDER to be defined")
+ message (FATAL_ERROR "Require TEST_FOLDER to be defined")
endif ()
if (NOT TEST_OUTPUT)
message (FATAL_ERROR "Require TEST_OUTPUT to be defined")
@@ -51,6 +51,8 @@ message (STATUS "COMMAND: ${TEST_TESTER} -Xmx1024M -Dorg.slf4j.simpleLogger.defa
if (WIN32 AND NOT MINGW)
set (ENV{PATH} "$ENV{PATH}\\;${TEST_LIBRARY_DIRECTORY}")
+else ()
+ set (ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:${TEST_LIBRARY_DIRECTORY}")
endif ()
# run the test program, capture the stdout/stderr and the result var
@@ -64,6 +66,7 @@ execute_process (
RESULT_VARIABLE TEST_RESULT
OUTPUT_FILE ${TEST_OUTPUT}
ERROR_FILE ${TEST_OUTPUT}.err
+ OUTPUT_VARIABLE TEST_OUT
ERROR_VARIABLE TEST_ERROR
)
@@ -126,11 +129,22 @@ if (NOT TEST_SKIP_COMPARE)
file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}")
endif ()
- # now compare the output with the reference
- execute_process (
- COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_FOLDER}/${TEST_REFERENCE}
- RESULT_VARIABLE TEST_RESULT
- )
+ if (NOT TEST_SORT_COMPARE)
+ # now compare the output with the reference
+ execute_process (
+ COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_FOLDER}/${TEST_REFERENCE}
+ RESULT_VARIABLE TEST_RESULT
+ )
+ else ()
+ file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} v1)
+ file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} v2)
+ list (SORT v1)
+ list (SORT v2)
+ if (NOT v1 STREQUAL v2)
+ set(TEST_RESULT 1)
+ endif ()
+ endif ()
+
if (TEST_RESULT)
set (TEST_RESULT 0)
file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} test_act)
@@ -142,10 +156,10 @@ if (NOT TEST_SKIP_COMPARE)
foreach (line RANGE 0 ${_FP_LEN})
list (GET test_act ${line} str_act)
list (GET test_ref ${line} str_ref)
- if (NOT ${str_act} STREQUAL ${str_ref})
- if (NOT str_act STREQUAL "")
+ if (NOT str_act STREQUAL str_ref)
+ if (str_act)
set (TEST_RESULT 1)
- message ("line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n")
+ message (STATUS "line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n")
endif ()
endif ()
endforeach ()
@@ -194,10 +208,10 @@ if (NOT TEST_SKIP_COMPARE)
foreach (line RANGE 0 ${_FP_LEN})
list (GET test_act ${line} str_act)
list (GET test_ref ${line} str_ref)
- if (NOT ${str_act} STREQUAL ${str_ref})
- if (NOT ${str_act} STREQUAL "")
+ if (NOT str_act STREQUAL str_ref)
+ if (str_act)
set (TEST_RESULT 1)
- message ("line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n")
+ message (STATUS "line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n")
endif ()
endif ()
endforeach ()
@@ -245,5 +259,5 @@ if (TEST_GREP_COMPARE)
endif ()
# everything went fine...
-message ("${TEST_PROGRAM} Passed")
+message (STATUS "${TEST_PROGRAM} Passed")