| # SPDX-FileCopyrightText: The Eigen Authors | |
| # SPDX-License-Identifier: MPL-2.0 | |
| find_program(BASH_EXECUTABLE bash) | |
| if(NOT UNIX OR NOT BASH_EXECUTABLE) | |
| message(STATUS "[${SCENARIO}] skipped: the BLAS shell runner needs Unix and bash") | |
| return() | |
| endif() | |
| set(runner "${EIGEN_SOURCE_DIR}/blas/testing/runblastest.sh") | |
| # A stand-in driver that emits the real drivers' result formats and exits zero | |
| # even when a numerical check fails. Keep paths with spaces in the invocation. | |
| set(driver_dir "${WORK_DIR}/driver output") | |
| file(MAKE_DIRECTORY "${driver_dir}") | |
| file(WRITE "${driver_dir}/driver" [=[#!/bin/bash | |
| cat stdout.txt | |
| cat stderr.txt >&2 | |
| if [[ -f summary.txt ]]; then cp summary.txt "${0##*/}.summ"; fi | |
| exit "$(cat status.txt)" | |
| ]=]) | |
| foreach(precision s d c z) | |
| foreach(level 1 2 3) | |
| configure_file("${driver_dir}/driver" "${driver_dir}/${precision}blat${level}" COPYONLY) | |
| bs_run(WHAT "make BLAS stand-in executable" | |
| COMMAND chmod +x "${driver_dir}/${precision}blat${level}") | |
| endforeach() | |
| endforeach() | |
| file(WRITE "${driver_dir}/input file.dat" "stand-in input\n") | |
| set(level1 " Test of subprogram number 7 SNRM2\n ----- PASS -----\n") | |
| set(level23 " SGEMM PASSED THE COMPUTATIONAL TESTS ( 10 CALLS)\n END OF TESTS\n") | |
| foreach(precision s d c z) | |
| foreach(level 1 2 3) | |
| set(test_name "${precision}blat${level}") | |
| foreach(case passed numerical error_exit fatal suspect abandoned process empty incomplete missing_summary stale_summary stderr) | |
| set(stdout "") | |
| set(stderr "") | |
| set(summary "${level23}") | |
| set(status 0) | |
| set(expected FAILURE) | |
| if(level EQUAL 1) | |
| set(stdout "${level1}") | |
| endif() | |
| if(case STREQUAL "passed") | |
| set(expected 0) | |
| elseif(case STREQUAL "numerical") | |
| if(level EQUAL 1) | |
| string(REPLACE "----- PASS -----" "FAIL" stdout "${stdout}") | |
| else() | |
| string(APPEND summary " ******* SGEMM FAILED ON CALL NUMBER: 1\n") | |
| endif() | |
| elseif(case STREQUAL "process") | |
| set(status 1) | |
| set(stderr "driver process failed\n") | |
| elseif(case STREQUAL "empty") | |
| set(stdout "") | |
| set(summary "") | |
| elseif(case STREQUAL "incomplete") | |
| string(APPEND stdout " Test of subprogram number 8 SASUM\n") | |
| string(REPLACE " END OF TESTS\n" "" summary "${summary}") | |
| elseif(case MATCHES "^(missing|stale)_summary$") | |
| if(level EQUAL 1) | |
| continue() | |
| endif() | |
| elseif(case STREQUAL "stderr") | |
| set(stderr " ******* FATAL ERROR - TESTS ABANDONED *******\n") | |
| else() | |
| if(case STREQUAL "error_exit") | |
| set(diagnostic " ******* SGEMM FAILED THE TESTS OF ERROR-EXITS *******\n") | |
| elseif(case STREQUAL "fatal") | |
| set(diagnostic " ******* FATAL ERROR - PARAMETER NUMBER 1 WAS CHANGED INCORRECTLY *******\n") | |
| elseif(case STREQUAL "suspect") | |
| set(diagnostic " ******* BUT WITH MAXIMUM TEST RATIO 51.0 - SUSPECT *******\n") | |
| else() | |
| set(diagnostic " ******* TESTS ABANDONED *******\n") | |
| endif() | |
| if(level EQUAL 1) | |
| string(APPEND stdout "${diagnostic}") | |
| else() | |
| string(APPEND summary "${diagnostic}") | |
| endif() | |
| endif() | |
| file(WRITE "${driver_dir}/stdout.txt" "${stdout}") | |
| file(WRITE "${driver_dir}/stderr.txt" "${stderr}") | |
| file(WRITE "${driver_dir}/status.txt" "${status}") | |
| file(REMOVE "${driver_dir}/summary.txt" "${driver_dir}/${test_name}.summ") | |
| if(NOT level EQUAL 1 AND NOT case MATCHES "^(missing|stale)_summary$") | |
| file(WRITE "${driver_dir}/summary.txt" "${summary}") | |
| elseif(case STREQUAL "stale_summary") | |
| file(WRITE "${driver_dir}/${test_name}.summ" "${level23}") | |
| endif() | |
| bs_run(WHAT "BLAS runner ${test_name}: ${case}" EXPECT_RESULT ${expected} OUTPUT_VARIABLE output | |
| COMMAND "${CMAKE_COMMAND}" -E chdir "${driver_dir}" "${BASH_EXECUTABLE}" "${runner}" | |
| "${test_name}" "${driver_dir}/input file.dat") | |
| if(case STREQUAL "numerical" AND NOT output MATCHES "FAIL") | |
| bs_fail("the numerical failure was not preserved in the diagnostic: ${output}") | |
| endif() | |
| endforeach() | |
| endforeach() | |
| endforeach() |