1
- #! /usr/bin/env python
2
- # -*- coding: utf-8 -*-
1
+ #!/usr/bin/env python3
3
2
4
3
5
4
###############################################################################
6
5
# lapack_testing.py
7
6
###############################################################################
8
7
9
- from __future__ import print_function
10
8
from subprocess import Popen , STDOUT , PIPE
11
9
import os , sys , math
12
10
import getopt
13
11
# Arguments
14
12
try :
15
13
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" ])
17
15
18
16
except getopt .error as msg :
19
17
print (msg )
20
18
print ("for help use --help" )
21
19
sys .exit (2 )
22
20
23
- short_summary = 0
24
- with_file = 1
25
- just_errors = 0
21
+ short_summary = False
22
+ with_file = True
23
+ just_errors = False
26
24
prec = 'x'
27
25
test = 'all'
28
- only_numbers = 0
26
+ only_numbers = False
29
27
test_dir = 'TESTING'
30
28
bin_dir = 'bin/Release'
31
29
34
32
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]" )
35
33
print (" - h is to print this message" )
36
34
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 ) )
39
37
print (" LEVEL OF OUTPUT" )
40
- print (" - x is to print a detailed summary" )
41
38
print (" - e is to print only the error summary" )
42
39
print (" - s is to print a short summary" )
43
40
print (" - n is to print the numbers of failing tests (turn on summary mode)" )
67
64
sys .exit (0 )
68
65
else :
69
66
if o in ("-s" , "--short" ):
70
- short_summary = 1
67
+ short_summary = True
71
68
if o in ("-r" , "--run" ):
72
- with_file = 0
69
+ with_file = False
73
70
if o in ("-e" , "--error" ):
74
- just_errors = 1
71
+ just_errors = True
75
72
if o in ( '-p' , '--prec' ):
76
73
prec = a
77
74
if o in ( '-b' , '--bin' ):
81
78
if o in ( '-t' , '--test' ):
82
79
test = a
83
80
if o in ( '-n' , '--number' ):
84
- only_numbers = 1
85
- short_summary = 1
81
+ only_numbers = True
82
+ short_summary = True
86
83
87
84
# process options
88
85
89
- abs_bin_dir = os .path .normpath ( os . path . join ( os . getcwd (), bin_dir ) )
86
+ abs_bin_dir = os .path .abspath ( bin_dir )
90
87
91
88
os .chdir (test_dir )
92
89
@@ -108,7 +105,7 @@ def run_summary_test( f, cmdline, short_summary):
108
105
nb_test_illegal = 0
109
106
nb_test_info = 0
110
107
111
- if ( with_file ) :
108
+ if with_file :
112
109
if not os .path .exists (cmdline ):
113
110
error_message = cmdline + " file not found"
114
111
r = 1
@@ -145,16 +142,16 @@ def run_summary_test( f, cmdline, short_summary):
145
142
whereisrun = words_in_line .index ("run)" )
146
143
nb_test_run += int (words_in_line [whereisrun - 2 ])
147
144
if (line .find ("out of" )!= - 1 ):
148
- if ( short_summary == 0 ) : print (line , end = ' ' )
145
+ if not short_summary : print (line , end = ' ' )
149
146
whereisout = words_in_line .index ("out" )
150
147
nb_test_fail += int (words_in_line [whereisout - 1 ])
151
148
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 = ' ' )
153
150
nb_test_illegal += 1
154
151
if (line .find (" INFO" )!= - 1 ):
155
- if ( short_summary == 0 ): print (line , end = ' ' )
152
+ if not short_summary : print (line , end = ' ' )
156
153
nb_test_info += 1
157
- if ( with_file == 1 ) :
154
+ if with_file :
158
155
pipe .close ()
159
156
160
157
f .flush ();
@@ -169,7 +166,7 @@ def run_summary_test( f, cmdline, short_summary):
169
166
except IOError :
170
167
f = sys .stdout
171
168
172
- if ( short_summary == 0 ) :
169
+ if not short_summary :
173
170
print (" " )
174
171
print ("---------------- Testing LAPACK Routines ----------------" )
175
172
print (" " )
@@ -219,7 +216,7 @@ def run_summary_test( f, cmdline, short_summary):
219
216
letter = dtypes [0 ][dtype ]
220
217
name = dtypes [1 ][dtype ]
221
218
222
- if ( short_summary == 0 ) :
219
+ if not short_summary :
223
220
print (" " )
224
221
print ("------------------------- %s ------------------------" % name )
225
222
print (" " )
@@ -252,7 +249,7 @@ def run_summary_test( f, cmdline, short_summary):
252
249
# NEED TO SKIP SOME PRECISION (namely s and c) FOR PROTO MIXED PRECISION TESTING
253
250
if dtest == 17 and (letter == "s" or letter == "c" ):
254
251
continue
255
- if ( with_file == 1 ) :
252
+ if with_file :
256
253
cmdbase = dtests [2 ][dtest ]+ ".out"
257
254
else :
258
255
if dtest == 16 :
@@ -267,7 +264,7 @@ def run_summary_test( f, cmdline, short_summary):
267
264
else :
268
265
# EIG TESTS
269
266
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 :
271
268
print ("Testing " + name + " " + dtests [1 ][dtest ]+ "-" + cmdbase , end = ' ' )
272
269
# Run the process: either to read the file or run the LAPACK testing
273
270
nb_test = run_summary_test (f , cmdbase , short_summary )
@@ -277,19 +274,19 @@ def run_summary_test( f, cmdline, short_summary):
277
274
list_results [3 ][dtype ]+= nb_test [3 ]
278
275
got_error = nb_test [1 ]+ nb_test [2 ]+ nb_test [3 ]
279
276
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 :
282
279
print ("passed: " + str (nb_test [0 ]))
283
- if ( nb_test [1 ]> 0 ) :
280
+ if nb_test [1 ] > 0 :
284
281
print ("failing to pass the threshold: " + str (nb_test [1 ]))
285
- if ( nb_test [2 ]> 0 ) :
282
+ if nb_test [2 ] > 0 :
286
283
print ("Illegal Error: " + str (nb_test [2 ]))
287
- if ( nb_test [3 ]> 0 ) :
284
+ if nb_test [3 ] > 0 :
288
285
print ("Info Error: " + str (nb_test [3 ]))
289
- if ( got_error > 0 and just_errors == 1 ) :
286
+ if got_error > 0 and just_errors :
290
287
print ("ERROR IS LOCATED IN " + name + " " + dtests [1 ][dtest ]+ " [ " + cmdbase + " ]" )
291
288
print ("" )
292
- if ( just_errors == 0 ) :
289
+ if not just_errors :
293
290
print ("" )
294
291
# elif (got_error>0):
295
292
# 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):
307
304
list_results [2 ][4 ]+= list_results [2 ][dtype ]
308
305
list_results [3 ][4 ]+= list_results [3 ][dtype ]
309
306
310
- if only_numbers == 1 :
307
+ if only_numbers :
311
308
print (str (list_results [1 ][4 ])+ "\n " + str (list_results [2 ][4 ]+ list_results [3 ][4 ]))
312
309
else :
313
310
print (summary )
0 commit comments