22
33## \file TestCase.py
44# \brief Python class for automated regression testing of SU2 examples
5- # \author A. Aranake, A. Campos, T. Economon, T. Lukaczyk
6- # \version 3.2.9 "eagle "
5+ # \author A. Aranake, A. Campos, T. Economon, T. Lukaczyk, S. Padron
6+ # \version 4.0.0 "Cardinal "
77#
8- # SU2 Lead Developers: Dr. Francisco Palacios ([email protected] ). 8+ # SU2 Lead Developers: Dr. Francisco Palacios ([email protected] ). 99# Dr. Thomas D. Economon ([email protected] ). 1010#
1111# SU2 Developers: Prof. Juan J. Alonso's group at Stanford University.
2929# You should have received a copy of the GNU Lesser General Public
3030# License along with SU2. If not, see <http://www.gnu.org/licenses/>.
3131
32- import sys ,time , os , subprocess , datetime , signal , os .path
33-
32+ import time , os , subprocess , datetime
3433
3534class TestCase :
3635
3736 def __init__ (self ,tag_in ):
3837
39- datestamp = time .strftime ("%Y%m%d" , time .gmtime ())
40- self .tag = "%s_%s" % (tag_in ,datestamp ) # Input, string tag that identifies this run
38+ self .tag = tag_in # Input, string tag that identifies this run
4139
4240 # Configuration file path/filename
4341 self .cfg_dir = "."
@@ -48,14 +46,13 @@ def __init__(self,tag_in):
4846 self .test_vals = []
4947
5048 # These can be optionally varied
51- # self.su2_dir = "."
5249 self .su2_exec = "SU2_CFD"
5350 self .timeout = 300
5451 self .tol = 0.001
55- self .outputdir = "."
5652
5753 def run_test (self ):
5854
55+ print '==================== Start Test: %s ====================' % self .tag
5956 passed = True
6057 exceed_tol = False
6158 timed_out = False
@@ -80,8 +77,8 @@ def run_test(self):
8077 while process .poll () is None :
8178 time .sleep (0.1 )
8279 now = datetime .datetime .now ()
83-
84- if ( now - start ). seconds > self .timeout :
80+ running_time = ( now - start ). seconds
81+ if running_time > self .timeout :
8582 try :
8683 process .kill ()
8784 os .system ('killall %s' % self .su2_exec ) # In case of parallel execution
@@ -133,8 +130,6 @@ def run_test(self):
133130 if iter_missing :
134131 passed = False
135132
136- print '=========================================================\n '
137-
138133 # Write the test results
139134 #for j in output:
140135 # print j
@@ -143,6 +138,8 @@ def run_test(self):
143138 print "%s: PASSED" % self .tag
144139 else :
145140 print "%s: FAILED" % self .tag
141+ print 'Output for the failed case'
142+ subprocess .call (['cat' , logfilename ])
146143
147144 print 'execution command: %s' % command
148145
@@ -173,8 +170,11 @@ def run_test(self):
173170 print 'delta_vals: ' ,
174171 for j in delta_vals :
175172 print '%f,' % j ,
176- print '\n '
177-
173+ print '\n ' ,
174+
175+ print 'test duration: %.2f min' % (running_time / 60.0 )
176+ print '==================== End Test: %s ====================\n ' % self .tag
177+
178178 os .chdir (workdir )
179179 return passed
180180
@@ -190,7 +190,7 @@ def adjust_iter(self):
190190 # Rewrite the file with a .autotest extension
191191 self .cfg_file = "%s.autotest" % self .cfg_file
192192 file_out = open (self .cfg_file ,'w' )
193- file_out .write ('%% This file automatically generated by cruise control \n ' )
193+ file_out .write ('%% This file automatically generated by the regression script \n ' )
194194 file_out .write ('%% Number of iterations changed to %d\n ' % (self .test_iter + 1 ))
195195 for line in lines :
196196 if not line .startswith ("EXT_ITER" ):
0 commit comments