source: branches/testScripts/NBcheckResult.py @ 718

Last change on this file since 718 was 718, checked in by jpfasano, 12 years ago

Added comment about licensing

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