| # SPDX-FileCopyrightText: The Eigen Authors | |
| # SPDX-License-Identifier: MPL-2.0 | |
| cmake_minimum_required(VERSION 3.18) | |
| if(NOT DEFINED OUTPUT_MANIFEST OR NOT EXISTS "${OUTPUT_MANIFEST}") | |
| message(FATAL_ERROR "Missing LAPACK output manifest") | |
| endif() | |
| file(STRINGS "${OUTPUT_MANIFEST}" OUTPUT_FILES) | |
| if(NOT OUTPUT_FILES) | |
| message(FATAL_ERROR "No LAPACK test output files were specified") | |
| endif() | |
| if(NOT DEFINED REPORT_FILE) | |
| set(REPORT_FILE "${CMAKE_CURRENT_BINARY_DIR}/testing_results.txt") | |
| endif() | |
| file(WRITE "${REPORT_FILE}" "") | |
| set(total_run 0) | |
| set(total_failed 0) | |
| set(total_other 0) | |
| message(STATUS "LAPACK TESTING SUMMARY") | |
| foreach(output IN LISTS OUTPUT_FILES) | |
| if(NOT EXISTS "${output}") | |
| message(FATAL_ERROR "Missing LAPACK test output: ${output}") | |
| endif() | |
| file(READ "${output}" contents) | |
| file(APPEND "${REPORT_FILE}" "${contents}") | |
| file(STRINGS "${output}" lines) | |
| set(run 0) | |
| set(failed 0) | |
| set(other 0) | |
| set(routine_errors 0) | |
| set(balance_errors 0) | |
| foreach(line IN LISTS lines) | |
| string(TOLOWER "${line}" lower) | |
| # Failed groups give their total after "out of"; successful groups give "tests run". | |
| if(line MATCHES "([0-9]+)[ \t]+out of[ \t]+([0-9]+)") | |
| math(EXPR failed "${failed} + ${CMAKE_MATCH_1}") | |
| math(EXPR run "${run} + ${CMAKE_MATCH_2}") | |
| elseif(line MATCHES "([0-9]+)[ \t]+tests[ \t]+run\\)") | |
| math(EXPR run "${run} + ${CMAKE_MATCH_1}") | |
| elseif(lower MATCHES "total number of examples tested[ \t]*=[ \t]*([0-9]+)") | |
| math(EXPR run "${run} + ${CMAKE_MATCH_1}") | |
| math(EXPR other "${other} + ${balance_errors}") | |
| set(balance_errors 0) | |
| endif() | |
| # xCHKEQ reports failing routines without an "out of" summary. | |
| if(lower MATCHES "^[ \t]*[sdcz](ge|gb|po|pp|pb)equ[ \t]+failed test with value[ \t]+") | |
| math(EXPR failed "${failed} + 1") | |
| endif() | |
| # Balance tests report example indices as well as a total error count. | |
| # An index is only evidence of an error, not the number of errors. | |
| if(lower MATCHES "number of examples where info is not 0[ \t]*=[ \t]*([0-9]+)") | |
| if(CMAKE_MATCH_1 GREATER balance_errors) | |
| set(balance_errors "${CMAKE_MATCH_1}") | |
| endif() | |
| elseif(lower MATCHES "example number where (.*info is not (zero|0)|ilo or ihi( is)? wrong)[ \t]*=[ \t]*([0-9]+)") | |
| if(CMAKE_MATCH_4 GREATER 0 AND balance_errors EQUAL 0) | |
| set(balance_errors 1) | |
| endif() | |
| endif() | |
| if(lower MATCHES "(value|ratio) of largest test error[ \t]*=[ \t]*([^ \t]+)") | |
| if(CMAKE_MATCH_2 MATCHES "inf|nan|\\*") | |
| math(EXPR failed "${failed} + 1") | |
| endif() | |
| endif() | |
| if(lower MATCHES "error code from" OR line MATCHES "(^|[ \t])INFO([ \t=]|$)") | |
| math(EXPR routine_errors "${routine_errors} + 1") | |
| elseif(lower MATCHES "([0-9]+)[ \t]+error messages recorded") | |
| # ALASUM summarizes the preceding ALAERH diagnostics; count each error once. | |
| if(CMAKE_MATCH_1 GREATER routine_errors) | |
| set(routine_errors "${CMAKE_MATCH_1}") | |
| endif() | |
| math(EXPR other "${other} + ${routine_errors}") | |
| set(routine_errors 0) | |
| endif() | |
| if(lower MATCHES "illegal|xerbla was called|failed the tests of the error exits" | |
| OR lower MATCHES "^[ \t]*error in[ \t]+") | |
| math(EXPR other "${other} + 1") | |
| endif() | |
| endforeach() | |
| math(EXPR other "${other} + ${routine_errors} + ${balance_errors}") | |
| get_filename_component(name "${output}" NAME) | |
| message(STATUS "${name}: ${run} tests, ${failed} numerical errors, ${other} other errors") | |
| # xCHKEC failure output contains diagnostics without a test-count summary. | |
| if(run EQUAL 0 AND failed EQUAL 0 AND other EQUAL 0) | |
| message(FATAL_ERROR "No LAPACK numerical tests were analyzed in: ${output}") | |
| endif() | |
| math(EXPR total_run "${total_run} + ${run}") | |
| math(EXPR total_failed "${total_failed} + ${failed}") | |
| math(EXPR total_other "${total_other} + ${other}") | |
| endforeach() | |
| message(STATUS "TOTAL: ${total_run} tests, ${total_failed} numerical errors, ${total_other} other errors") | |
| if(total_failed GREATER 0 OR total_other GREATER 0) | |
| message(FATAL_ERROR "LAPACK test output reports failures") | |
| endif() | |
| if(total_run EQUAL 0) | |
| message(FATAL_ERROR "No LAPACK numerical tests were analyzed") | |
| endif() |