source: branches/testScripts/NBcheckResult.py @ 681

Last change on this file since 681 was 681, checked in by jpfasano, 14 years ago

Added svn property svn:eol-style native

  • Property svn:eol-style set to native
File size: 5.6 KB
Line 
1#! /usr/bin/env python
2
3import re 
4import os 
5
6import NBprojectConfig
7
8
9#------------------------------------------------------------------------
10# Determine if a projects "make test" or unitTest ran successfully.
11# Since projects are not consistent in how they report success,
12# this function has specialized code for some projects.
13#------------------------------------------------------------------------
14def didTestFail( result, project, buildStep ) :
15  retVal = None
16
17  # If the return code is not 0, then failure
18  if result['returnCode'] != 0 :
19    retVal = "Non-zero return code of "+str(result['returnCode'])
20
21  # Many tests write a "Success" message.
22  # For test that do this, check for the success message
23  if NBprojectConfig.ALL_TESTS_COMPLETED_SUCCESSFULLY_CMDS.has_key(project) : 
24    if buildStep in NBprojectConfig.ALL_TESTS_COMPLETED_SUCCESSFULLY_CMDS[project] :
25      # Is the success message contained in the output?
26      if result['stderr'].rfind("All tests completed successfully") == -1 and \
27         result['stdout'].rfind("All tests completed successfully") == -1 :
28        # Success message not found, assume test failed
29        retVal = "The output does not contain the messages: 'All tests completed successfully'"
30
31  #---------------------------------------------------------------------
32  # Some (project,buildStep) pairs require further checking
33  # to determine if they were successful
34  #---------------------------------------------------------------------
35  # Clp's "./clp -unitTest dirNetlib=_NETLIBDIR_ -netlib"
36  if project=='Clp' and buildStep==NBprojectConfig.UNITTEST_CMD['Clp'] :
37    # Check that last netlib test case ran by looking for message of form
38    # '../../Data/Netlib/woodw took 0.47 seconds using algorithm either'
39    reexp = r"(.|\n)*(\\|/)Data(\\|/)Netlib(\\|/)woodw took (\d*\.\d*) seconds using algorithm either(.|\n)*"
40    msgTail = result['stdout'][-200:]
41    if not re.compile(reexp).match(msgTail,1) :
42      # message not found, assume test failed
43      retVal = "Did not complete the woodw testcase"
44     
45  # Cbc's "make test"
46  elif project=='Cbc' and buildStep=='make test' :
47    # Check that last the last few lines are of the form
48    # 'cbc_clp solved 2 out of 2 and took XX.XX seconds.'
49    reexp=r"(.|\n)*cbc_clp solved 2 out of 2 and took (\d*\.\d*) seconds."
50    msgTail = result['stdout'][-300:]
51    if not re.compile(reexp).match(msgTail,1) :
52      # message not found, assume test failed
53      retVal = "Did not display message 'cbc_clp solved 2 out of 2 and took XX.XX seconds.'" 
54
55  # Cbc's "./cbc -unitTest dirNetlib=_MIPLIB3DIR_ -miplib"
56  elif project=='Cbc' and buildStep==NBprojectConfig.UNITTEST_CMD['Cbc'] :
57    if result['returnCode']>=0 and result['returnCode']<=2 :
58      # return code is between 0 and 2.
59      # Return code between 1 and 44 is the number of test cases that
60      # ended because maxnodes limit reached.  John Forrest says if this
61      # is less than 3, the OK.
62      retVal=None
63    else :
64      retVal = "Return code of "+str(result['returnCode'])+" which is > 2."
65
66  # DyLP's "make test"
67  # DyLP's "./unitTest -testOsiSolverInterface -netlibDir=_NETLIBDIR_"
68  # Osi's "make test"
69  # Osi's "./unitTest -testOsiSolverInterface -netlibDir=_NETLIBDIR_"
70  elif project=='DyLP' and buildStep=='make test' or \
71       project=='DyLP' and buildStep==NBprojectConfig.UNITTEST_CMD['Osi'] or \
72       project=='Osi'  and buildStep=='make test' or \
73       project=='Osi'  and buildStep==NBprojectConfig.UNITTEST_CMD['Osi'] :
74    # Messages should not contain:
75    # "*** xxxSolverInterface testing issue: whatever the problem is"
76    reexp=r'.*\*\*.+SolverInterface testing issue:.*'
77    if re.compile(reexp).match(result['stderr'],1) :
78      # message found, assume test failed
79      retVal = "Issued message: 'SolverInterface tessting issue:'"
80    if re.compile(reexp).match(result['stdout'],1) :
81      # message found, assume test failed
82      retVal = "Issued message: 'SolverInterface tessting issue:'"
83
84    if project=='Osi'  and buildStep==NBprojectConfig.UNITTEST_CMD['Osi'] :
85
86      # Look for pattern "<solver> solved NN out of 90 and took nnn.xx seconds"
87      r=r'((.+) solved (\d+) out of 90 and took (\d*\.\d*) seconds)'
88      osisSummaryResult=re.findall(r,result['stdout'][-800:])
89      expectedOsis=['clp','sym','dylp','cbcclp']
90      for osi in osisSummaryResult :
91        if osi[1] in expectedOsis: expectedOsis.remove(osi[1])
92        numSolved = int(osi[2])
93        # Sym only solves 89 of the 90
94        if osi[1]=='sym':
95          if numSolved<89 :
96            retVal=osi[1]+\
97                 " only solved "\
98                 +osi[2]\
99                 +" out of 90 in "\
100                 +osi[3]+" seconds"
101        elif numSolved<90 :
102          retVal=osi[1]+\
103                 " only solved "\
104                 +osi[2]+\
105                 " out of 90 in "\
106                 +osi[3]+" seconds"
107      if len(expectedOsis)!=0 :
108        retVal="Osi "+expectedOsis[0]+" did not report number solved"
109
110  return retVal
111
112#-------------------------------------------------------------------------
113#
114# Determine if config needs to be run.
115# If there is a config.log file and it indicates that it ran successfully
116# then config should not need to be rerun.
117#
118#-------------------------------------------------------------------------
119def didConfigRunOK( ) :
120  retVal=1
121  logFileName='config.log'
122  if not os.path.isfile(logFileName) :
123    retVal=0
124  else :
125    # Read logfile
126    logFilePtr = open(logFileName,'r')
127    logfile = logFilePtr.read()
128    logFilePtr.close()
129
130    # If logfile does not contain "configure: exit 0" then assume
131    # that configure needs to be rerun
132    if logfile.rfind("configure: exit 0") == -1 :
133      retVal=0
134
135  return retVal
Note: See TracBrowser for help on using the repository browser.