1- #! /usr/bin/env python
2- # -*- coding: utf-8 -*-
1+ #!/usr/bin/env python3
32
43
54###############################################################################
65# lapack_testing.py
76###############################################################################
87
9- from __future__ import print_function
108from subprocess import Popen , STDOUT , PIPE
119import os , sys , math
1210import getopt
1311# Arguments
1412try :
1513 opts , args = getopt .getopt (sys .argv [1 :], "hd:b:srep:t:n" ,
16- ["help" , "dir" , "bin" , "short" , "run" , "error" ,"prec=" ,"test=" ,"number" ])
14+ ["help" , "dir= " , "bin= " , "short" , "run" , "error" ,"prec=" ,"test=" ,"number" ])
1715
1816except getopt .error as msg :
1917 print (msg )
2018 print ("for help use --help" )
2119 sys .exit (2 )
2220
23- short_summary = 0
24- with_file = 1
25- just_errors = 0
21+ short_summary = False
22+ with_file = True
23+ just_errors = False
2624prec = 'x'
2725test = 'all'
28- only_numbers = 0
26+ only_numbers = False
2927test_dir = 'TESTING'
3028bin_dir = 'bin/Release'
3129
3432 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]" )
3533 print (" - h is to print this message" )
3634 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" )
37- print (" - d [dir] is to indicate where is the LAPACK testing directory (.out files). By default, the script will use ." )
38- print (" - b [bin] is to indicate where is the LAPACK binary files are located . By default, the script will use ." )
35+ print (" - d [dir] indicates the location of the LAPACK testing directory (.out files). By default, the script will use {:s}." . format ( test_dir ) )
36+ print (" - b [bin] indicates the location of the LAPACK binary files. By default, the script will use {:s}." . format ( bin_dir ) )
3937 print (" LEVEL OF OUTPUT" )
40- print (" - x is to print a detailed summary" )
4138 print (" - e is to print only the error summary" )
4239 print (" - s is to print a short summary" )
4340 print (" - n is to print the numbers of failing tests (turn on summary mode)" )
6764 sys .exit (0 )
6865 else :
6966 if o in ("-s" , "--short" ):
70- short_summary = 1
67+ short_summary = True
7168 if o in ("-r" , "--run" ):
72- with_file = 0
69+ with_file = False
7370 if o in ("-e" , "--error" ):
74- just_errors = 1
71+ just_errors = True
7572 if o in ( '-p' , '--prec' ):
7673 prec = a
7774 if o in ( '-b' , '--bin' ):
8178 if o in ( '-t' , '--test' ):
8279 test = a
8380 if o in ( '-n' , '--number' ):
84- only_numbers = 1
85- short_summary = 1
81+ only_numbers = True
82+ short_summary = True
8683
8784# process options
8885
89- abs_bin_dir = os .path .normpath ( os . path . join ( os . getcwd (), bin_dir ) )
86+ abs_bin_dir = os .path .abspath ( bin_dir )
9087
9188os .chdir (test_dir )
9289
@@ -108,7 +105,7 @@ def run_summary_test( f, cmdline, short_summary):
108105 nb_test_illegal = 0
109106 nb_test_info = 0
110107
111- if ( with_file ) :
108+ if with_file :
112109 if not os .path .exists (cmdline ):
113110 error_message = cmdline + " file not found"
114111 r = 1
@@ -145,16 +142,16 @@ def run_summary_test( f, cmdline, short_summary):
145142 whereisrun = words_in_line .index ("run)" )
146143 nb_test_run += int (words_in_line [whereisrun - 2 ])
147144 if (line .find ("out of" )!= - 1 ):
148- if ( short_summary == 0 ) : print (line , end = ' ' )
145+ if not short_summary : print (line , end = ' ' )
149146 whereisout = words_in_line .index ("out" )
150147 nb_test_fail += int (words_in_line [whereisout - 1 ])
151148 if ((line .find ("illegal" )!= - 1 ) or (line .find ("Illegal" )!= - 1 )):
152- if ( short_summary == 0 ): print (line , end = ' ' )
149+ if not short_summary : print (line , end = ' ' )
153150 nb_test_illegal += 1
154151 if (line .find (" INFO" )!= - 1 ):
155- if ( short_summary == 0 ): print (line , end = ' ' )
152+ if not short_summary : print (line , end = ' ' )
156153 nb_test_info += 1
157- if ( with_file == 1 ) :
154+ if with_file :
158155 pipe .close ()
159156
160157 f .flush ();
@@ -169,7 +166,7 @@ def run_summary_test( f, cmdline, short_summary):
169166except IOError :
170167 f = sys .stdout
171168
172- if ( short_summary == 0 ) :
169+ if not short_summary :
173170 print (" " )
174171 print ("---------------- Testing LAPACK Routines ----------------" )
175172 print (" " )
@@ -219,7 +216,7 @@ def run_summary_test( f, cmdline, short_summary):
219216 letter = dtypes [0 ][dtype ]
220217 name = dtypes [1 ][dtype ]
221218
222- if ( short_summary == 0 ) :
219+ if not short_summary :
223220 print (" " )
224221 print ("------------------------- %s ------------------------" % name )
225222 print (" " )
@@ -252,7 +249,7 @@ def run_summary_test( f, cmdline, short_summary):
252249 # NEED TO SKIP SOME PRECISION (namely s and c) FOR PROTO MIXED PRECISION TESTING
253250 if dtest == 17 and (letter == "s" or letter == "c" ):
254251 continue
255- if ( with_file == 1 ) :
252+ if with_file :
256253 cmdbase = dtests [2 ][dtest ]+ ".out"
257254 else :
258255 if dtest == 16 :
@@ -267,7 +264,7 @@ def run_summary_test( f, cmdline, short_summary):
267264 else :
268265 # EIG TESTS
269266 cmdbase = "xeigtst" + letter + " < " + dtests [0 ][dtest ]+ ".in > " + dtests [2 ][dtest ]+ ".out"
270- if ( not just_errors and not short_summary ) :
267+ if not just_errors and not short_summary :
271268 print ("Testing " + name + " " + dtests [1 ][dtest ]+ "-" + cmdbase , end = ' ' )
272269 # Run the process: either to read the file or run the LAPACK testing
273270 nb_test = run_summary_test (f , cmdbase , short_summary )
@@ -277,19 +274,19 @@ def run_summary_test( f, cmdline, short_summary):
277274 list_results [3 ][dtype ]+= nb_test [3 ]
278275 got_error = nb_test [1 ]+ nb_test [2 ]+ nb_test [3 ]
279276
280- if ( not short_summary ) :
281- if ( nb_test [0 ]> 0 and just_errors == 0 ) :
277+ if not short_summary :
278+ if nb_test [0 ] > 0 and not just_errors :
282279 print ("passed: " + str (nb_test [0 ]))
283- if ( nb_test [1 ]> 0 ) :
280+ if nb_test [1 ] > 0 :
284281 print ("failing to pass the threshold: " + str (nb_test [1 ]))
285- if ( nb_test [2 ]> 0 ) :
282+ if nb_test [2 ] > 0 :
286283 print ("Illegal Error: " + str (nb_test [2 ]))
287- if ( nb_test [3 ]> 0 ) :
284+ if nb_test [3 ] > 0 :
288285 print ("Info Error: " + str (nb_test [3 ]))
289- if ( got_error > 0 and just_errors == 1 ) :
286+ if got_error > 0 and just_errors :
290287 print ("ERROR IS LOCATED IN " + name + " " + dtests [1 ][dtest ]+ " [ " + cmdbase + " ]" )
291288 print ("" )
292- if ( just_errors == 0 ) :
289+ if not just_errors :
293290 print ("" )
294291# elif (got_error>0):
295292# print dtests[2][dtest]+".out \t"+str(nb_test[1])+"\t"+str(nb_test[2])+"\t"+str(nb_test[3])
@@ -307,7 +304,7 @@ def run_summary_test( f, cmdline, short_summary):
307304 list_results [2 ][4 ]+= list_results [2 ][dtype ]
308305 list_results [3 ][4 ]+= list_results [3 ][dtype ]
309306
310- if only_numbers == 1 :
307+ if only_numbers :
311308 print (str (list_results [1 ][4 ])+ "\n " + str (list_results [2 ][4 ]+ list_results [3 ][4 ]))
312309else :
313310 print (summary )
0 commit comments