From cb3dbb0fe1636e79ddf6f834501280396d02cacb Mon Sep 17 00:00:00 2001 From: Christoph Conrads Date: Sat, 13 Feb 2021 17:43:29 +0000 Subject: [PATCH 1/8] lapack_testing.py: python2 explicit in hashbang Use `python2` explicitly in the hashbang instead of just `python` because Ubuntu 20.04 does not ship with a `python` executable any longer. --- lapack_testing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lapack_testing.py b/lapack_testing.py index 8b0af0de15..0de5216479 100755 --- a/lapack_testing.py +++ b/lapack_testing.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2 # -*- coding: utf-8 -*- From e20af999270008173ef1f652c470eabbd34a9b18 Mon Sep 17 00:00:00 2001 From: Christoph Conrads Date: Sat, 20 Feb 2021 18:52:18 +0000 Subject: [PATCH 2/8] lapack_testing.py: convert to Python3 --- lapack_testing.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lapack_testing.py b/lapack_testing.py index 0de5216479..0de8576dfc 100755 --- a/lapack_testing.py +++ b/lapack_testing.py @@ -1,12 +1,10 @@ -#! /usr/bin/env python2 -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 ############################################################################### # lapack_testing.py ############################################################################### -from __future__ import print_function from subprocess import Popen, STDOUT, PIPE import os, sys, math import getopt From 2b1eabfdfdffe9a42f2013ba5d7b89a5a0a5e67e Mon Sep 17 00:00:00 2001 From: Christoph Conrads Date: Sat, 20 Feb 2021 19:14:35 +0000 Subject: [PATCH 3/8] lapack_testing.py: remove nonexistent flag in doc The `-x` flag was never a valid short option for the `getopt` command line parser. --- lapack_testing.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lapack_testing.py b/lapack_testing.py index 0de8576dfc..7b02ed648d 100755 --- a/lapack_testing.py +++ b/lapack_testing.py @@ -35,7 +35,6 @@ print(" - d [dir] is to indicate where is the LAPACK testing directory (.out files). By default, the script will use .") print(" - b [bin] is to indicate where is the LAPACK binary files are located. By default, the script will use .") print(" LEVEL OF OUTPUT") - print(" - x is to print a detailed summary") print(" - e is to print only the error summary") print(" - s is to print a short summary") print(" - n is to print the numbers of failing tests (turn on summary mode)") From 7672c5fe571c61277aaad8cb3ce0c6ebfff23022 Mon Sep 17 00:00:00 2001 From: Christoph Conrads Date: Sat, 20 Feb 2021 19:39:47 +0000 Subject: [PATCH 4/8] lapack_testing.py: add missing arguments to getopt The getopt command line parser did not expect arguments after the `--bin` and `--dir` options. --- lapack_testing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lapack_testing.py b/lapack_testing.py index 7b02ed648d..0651514fd1 100755 --- a/lapack_testing.py +++ b/lapack_testing.py @@ -11,7 +11,7 @@ # Arguments try: opts, args = getopt.getopt(sys.argv[1:], "hd:b:srep:t:n", - ["help", "dir", "bin", "short", "run", "error","prec=","test=","number"]) + ["help", "dir=", "bin=", "short", "run", "error","prec=","test=","number"]) except getopt.error as msg: print(msg) From 95e4515b4445987bac2de3ffb6c479362debda4f Mon Sep 17 00:00:00 2001 From: Christoph Conrads Date: Sat, 20 Feb 2021 19:42:11 +0000 Subject: [PATCH 5/8] lapack_testing.py: use idiomatic path normalization --- lapack_testing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lapack_testing.py b/lapack_testing.py index 0651514fd1..1de260b643 100755 --- a/lapack_testing.py +++ b/lapack_testing.py @@ -83,7 +83,7 @@ # process options -abs_bin_dir=os.path.normpath(os.path.join(os.getcwd(),bin_dir)) +abs_bin_dir=os.path.abspath(bin_dir) os.chdir(test_dir) From 89e8b8940090f6dc8ca951ae6b79cf00e25cd789 Mon Sep 17 00:00:00 2001 From: Christoph Conrads Date: Sat, 20 Feb 2021 19:51:53 +0000 Subject: [PATCH 6/8] lapack_testing.py: help show actual default values --- lapack_testing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lapack_testing.py b/lapack_testing.py index 1de260b643..a4ef39a2c8 100755 --- a/lapack_testing.py +++ b/lapack_testing.py @@ -32,8 +32,8 @@ print(sys.argv[0]+" [-h|--help] [-d dir |--dir dir] [-s |--short] [-r |--run] [-e |--error] [-p p |--prec p] [-t test |--test test] [-n | --number]") print(" - h is to print this message") print(" - r is to use to run the LAPACK tests then analyse the output (.out files). By default, the script will not run all the LAPACK tests") - print(" - d [dir] is to indicate where is the LAPACK testing directory (.out files). By default, the script will use .") - print(" - b [bin] is to indicate where is the LAPACK binary files are located. By default, the script will use .") + print(" - d [dir] indicates the location of the LAPACK testing directory (.out files). By default, the script will use {:s}.".format(test_dir)) + print(" - b [bin] indicates the location of the LAPACK binary files. By default, the script will use {:s}.".format(bin_dir)) print(" LEVEL OF OUTPUT") print(" - e is to print only the error summary") print(" - s is to print a short summary") From cda6bf69baf231063bd5d6d54ed445953d877faa Mon Sep 17 00:00:00 2001 From: Christoph Conrads Date: Sat, 20 Feb 2021 19:52:48 +0000 Subject: [PATCH 7/8] lapack_testing.py: use more idiomatic Python style Remove C-isms: * remove unnecessary braces in "if" conditions * use booleans instead of 0/1 variables --- lapack_testing.py | 52 +++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/lapack_testing.py b/lapack_testing.py index a4ef39a2c8..666865abf2 100755 --- a/lapack_testing.py +++ b/lapack_testing.py @@ -18,12 +18,12 @@ print("for help use --help") sys.exit(2) -short_summary=0 -with_file=1 -just_errors = 0 +short_summary = False +with_file = True +just_errors = False prec='x' test='all' -only_numbers=0 +only_numbers = False test_dir='TESTING' bin_dir='bin/Release' @@ -64,11 +64,11 @@ sys.exit(0) else: if o in ("-s", "--short"): - short_summary = 1 + short_summary = True if o in ("-r", "--run"): - with_file = 0 + with_file = False if o in ("-e", "--error"): - just_errors = 1 + just_errors = True if o in ( '-p', '--prec' ): prec = a if o in ( '-b', '--bin' ): @@ -78,8 +78,8 @@ if o in ( '-t', '--test' ): test = a if o in ( '-n', '--number' ): - only_numbers = 1 - short_summary = 1 + only_numbers = True + short_summary = True # process options @@ -105,7 +105,7 @@ def run_summary_test( f, cmdline, short_summary): nb_test_illegal=0 nb_test_info=0 - if (with_file): + if with_file: if not os.path.exists(cmdline): error_message=cmdline+" file not found" r=1 @@ -142,16 +142,16 @@ def run_summary_test( f, cmdline, short_summary): whereisrun=words_in_line.index("run)") nb_test_run+=int(words_in_line[whereisrun-2]) if (line.find("out of")!=-1): - if (short_summary==0): print(line, end=' ') + if not short_summary: print(line, end=' ') whereisout= words_in_line.index("out") nb_test_fail+=int(words_in_line[whereisout-1]) if ((line.find("illegal")!=-1) or (line.find("Illegal")!=-1)): - if (short_summary==0):print(line, end=' ') + if not short_summary: print(line, end=' ') nb_test_illegal+=1 if (line.find(" INFO")!=-1): - if (short_summary==0):print(line, end=' ') + if not short_summary: print(line, end=' ') nb_test_info+=1 - if (with_file==1): + if with_file: pipe.close() f.flush(); @@ -166,7 +166,7 @@ def run_summary_test( f, cmdline, short_summary): except IOError: f = sys.stdout -if (short_summary==0): +if not short_summary: print(" ") print("---------------- Testing LAPACK Routines ----------------") print(" ") @@ -216,7 +216,7 @@ def run_summary_test( f, cmdline, short_summary): letter = dtypes[0][dtype] name = dtypes[1][dtype] - if (short_summary==0): + if not short_summary: print(" ") print("------------------------- %s ------------------------" % name) print(" ") @@ -249,7 +249,7 @@ def run_summary_test( f, cmdline, short_summary): # NEED TO SKIP SOME PRECISION (namely s and c) FOR PROTO MIXED PRECISION TESTING if dtest==17 and (letter=="s" or letter=="c"): continue - if (with_file==1): + if with_file: cmdbase=dtests[2][dtest]+".out" else: if dtest==16: @@ -264,7 +264,7 @@ def run_summary_test( f, cmdline, short_summary): else: # EIG TESTS cmdbase="xeigtst"+letter+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out" - if (not just_errors and not short_summary): + if not just_errors and not short_summary: print("Testing "+name+" "+dtests[1][dtest]+"-"+cmdbase, end=' ') # Run the process: either to read the file or run the LAPACK testing nb_test = run_summary_test(f, cmdbase, short_summary) @@ -274,19 +274,19 @@ def run_summary_test( f, cmdline, short_summary): list_results[3][dtype]+=nb_test[3] got_error=nb_test[1]+nb_test[2]+nb_test[3] - if (not short_summary): - if (nb_test[0]>0 and just_errors==0): + if not short_summary: + if nb_test[0] > 0 and not just_errors: print("passed: "+str(nb_test[0])) - if (nb_test[1]>0): + if nb_test[1] > 0: print("failing to pass the threshold: "+str(nb_test[1])) - if (nb_test[2]>0): + if nb_test[2] > 0: print("Illegal Error: "+str(nb_test[2])) - if (nb_test[3]>0): + if nb_test[3] > 0: print("Info Error: "+str(nb_test[3])) - if (got_error>0 and just_errors==1): + if got_error > 0 and just_errors: print("ERROR IS LOCATED IN "+name+" "+dtests[1][dtest]+" [ "+cmdbase+" ]") print("") - if (just_errors==0): + if not just_errors: print("") # elif (got_error>0): # print dtests[2][dtest]+".out \t"+str(nb_test[1])+"\t"+str(nb_test[2])+"\t"+str(nb_test[3]) @@ -304,7 +304,7 @@ def run_summary_test( f, cmdline, short_summary): list_results[2][4]+=list_results[2][dtype] list_results[3][4]+=list_results[3][dtype] -if only_numbers==1: +if only_numbers: print(str(list_results[1][4])+"\n"+str(list_results[2][4]+list_results[3][4])) else: print(summary) From a51f8baa5af84fc73c642f618005900fbed086f8 Mon Sep 17 00:00:00 2001 From: Christoph Conrads Date: Sat, 20 Feb 2021 21:08:23 +0000 Subject: [PATCH 8/8] CMake: update, improve test summary invocation * search for a Python3 interpreter for the test summary * replace an unnecessary macro invocation with a function * make summary depend on all other tests Making the summary depend on all other tests fixes test execution in random order (e.g., with `ctest --schedule-random`). --- CMakeLists.txt | 11 ++++++----- CTestCustom.cmake.in | 5 ++--- TESTING/CMakeLists.txt | 36 ++++++++++++++++++++++-------------- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eba8bf4bc1..e577fb38ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,13 +179,14 @@ option(BUILD_TESTING "Build tests" ${_is_coverage_build}) include(CTest) message(STATUS "Build tests: ${BUILD_TESTING}") -# lapack_testing.py uses features from python 2.7 and greater if(BUILD_TESTING) - set(_msg "Looking for Python >= 2.7 needed for summary tests") + set(_msg "Looking for Python3 needed for summary tests") message(STATUS "${_msg}") - find_package(PythonInterp 2.7 QUIET) - if(PYTHONINTERP_FOUND) - message(STATUS "${_msg} - found (${PYTHON_VERSION_STRING})") + # find_package(PythonInterp 3) cannot be used because /usr/bin/python may be + # a Python2 interpreter. + find_program(PYTHON_EXECUTABLE python3) + if(PYTHON_EXECUTABLE) + message(STATUS "${_msg} - found") else() message(STATUS "${_msg} - not found (skipping summary tests)") endif() diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index 45fb1ccda7..01f15db240 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -46,10 +46,9 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION "Warning: File .* has modification time .* in the future" ) -# Only rung post test if suitable python interpreter was found -set(PYTHONINTERP_FOUND @PYTHONINTERP_FOUND@) +# Only run post test if suitable python interpreter was found set(PYTHON_EXECUTABLE @PYTHON_EXECUTABLE@) -if(PYTHONINTERP_FOUND) +if(PYTHON_EXECUTABLE) set(CTEST_CUSTOM_POST_TEST "${PYTHON_EXECUTABLE} ./lapack_testing.py -s -d TESTING") endif() diff --git a/TESTING/CMakeLists.txt b/TESTING/CMakeLists.txt index d5ca950131..96cdacf821 100644 --- a/TESTING/CMakeLists.txt +++ b/TESTING/CMakeLists.txt @@ -6,7 +6,20 @@ if(MSVC_VERSION) endif() add_subdirectory(LIN) add_subdirectory(EIG) -macro(add_lapack_test output input target) + + +# Only run this test if python 3 is found +if(PYTHON_EXECUTABLE) + message(STATUS "Running Summary") + file(COPY ${LAPACK_SOURCE_DIR}/lapack_testing.py DESTINATION ${LAPACK_BINARY_DIR}) + add_test( + NAME LAPACK_Test_Summary + WORKING_DIRECTORY ${LAPACK_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} "lapack_testing.py" + ) +endif() + +function(add_lapack_test output input target) set(TEST_INPUT "${LAPACK_SOURCE_DIR}/TESTING/${input}") set(TEST_OUTPUT "${LAPACK_BINARY_DIR}/TESTING/${output}") string(REPLACE "." "_" input_name ${input}) @@ -18,8 +31,15 @@ macro(add_lapack_test output input target) -DOUTPUT=${TEST_OUTPUT} -DINTDIR=${CMAKE_CFG_INTDIR} -P "${LAPACK_SOURCE_DIR}/TESTING/runtest.cmake") + + if(PYTHONINTERP_FOUND) + set_property( + TEST LAPACK_Test_Summary + APPEND PROPERTY DEPENDS LAPACK-${testName} + ) + endif() endif() -endmacro() +endfunction() if(BUILD_SINGLE) add_lapack_test(stest.out stest.in xlintsts) @@ -156,15 +176,3 @@ if(BUILD_COMPLEX AND BUILD_COMPLEX16) # ======== COMPLEX-COMPLEX16 LIN TESTS ======================== add_lapack_test(zctest.out zctest.in xlintstzc) endif() - -# ============================================================================== -# Only run this test if python 2.7 or greater is found -if(PYTHONINTERP_FOUND) - message(STATUS "Running Summary") - file(COPY ${LAPACK_SOURCE_DIR}/lapack_testing.py DESTINATION ${LAPACK_BINARY_DIR}) - add_test( - NAME LAPACK_Test_Summary - WORKING_DIRECTORY ${LAPACK_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "lapack_testing.py" - ) -endif()