-
Notifications
You must be signed in to change notification settings - Fork 27
/
test.cmake
40 lines (36 loc) · 1.31 KB
/
test.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# A CMake script for running Couenne tests.
# Translated from grandTest.sh for portability.
message("Testing Couenne:\n")
set(test_dir ${CMAKE_CURRENT_LIST_DIR}/Couenne/test)
file(GLOB configs ${test_dir}/config_files/*)
list(SORT configs)
file(GLOB files ${test_dir}/data/*.nl)
list(SORT files)
file(READ ${test_dir}/couenne.opt.base base_opt)
set(failed FALSE)
foreach (config ${configs})
file(READ ${config} config_opt)
get_filename_component(method ${config} NAME)
message("Testing ${method}:")
foreach (file ${files})
file(COPY ${file} DESTINATION .)
get_filename_component(name ${file} NAME_WE)
file(READ ${test_dir}/data/${name}.obj file_opt)
file(WRITE couenne.opt "${base_opt}${config_opt}couenne_check ${file_opt}")
execute_process(COMMAND ${CMAKE_ARGV3} ${name} OUTPUT_VARIABLE out)
if (out MATCHES "Global Optimum Test .* OK")
message("${CMAKE_MATCH_0}")
else ()
message("Global Optimum Test on ${name} FAILED!\n")
message(" ---- 8< ---- Start of test program output ---- 8< ----")
message("${out}")
message(" ---- 8< ---- End of test program output ---- 8< ----")
set(failed TRUE)
endif ()
file(REMOVE ${name}.nl ${name}.sol couenne.opt)
endforeach ()
message("")
endforeach ()
if (failed)
message(FATAL_ERROR "Test failed.")
endif ()