source: branches/testScripts/NBcheckResult.py @ 762

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

Added checking for *Done*** at end of smiUnitTest

  • Property svn:eol-style set to native
File size: 5.4 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# Determine if a projects "make test" or unitTest ran successfully.
15# Since projects are not consistent in how they report success,
16# this function has specialized code for some projects.
17#------------------------------------------------------------------------
18
19# Assume result is always correct
20def anythingGoes( result, project ) :
21  retVal = None
22  return retVal
23
24# Is the rc=0?
25def rc0( result, project ) :
26  retVal = None
27  # If the return code is not 0, then failure
28  if result['returnCode'] != 0 :
29    retVal = "Non-zero return code of "+str(result['returnCode'])
30  return retVal 
31   
32# Is 0<=rc<=2?
33def rc0to2( result, project ) :
34  retVal = None
35  # If the return code is not 0, then failure
36  if 0>result['returnCode'] or result['returnCode']>2 :
37    retVal = "Return code out of range. Expected: 0<=rc<=2. rc="+str(result['returnCode'])
38  return retVal
39
40# Was the standard success message written?
41def standardSuccessMessage(result,project) :
42  retVal = None
43  # Is the success message contained in the output?
44  if result['stderr'].rfind("All tests completed successfully") == -1 and \
45     result['stdout'].rfind("All tests completed successfully") == -1 :
46    # Success message not found, assume test failed
47    retVal = "The output does not contain the message: 'All tests completed successfully'"
48  return retVal
49
50# Was "*** Done! ***" written at end?
51def endWithStarDoneStar(result,project) :
52  retVal = None
53  # Is the success message contained in the output?
54  if result['stdout'][-20:].rfind("*** Done! ***") == -1 :
55    # Success message not found, assume test failed
56    retVal = "The output does not end with the message: '*** Done! ***'"
57  return retVal 
58
59# Was woodw the last netlib problem run?
60# Check that last netlib test case ran by looking for message of form
61# '../../Data/Netlib/woodw took 0.47 seconds using algorithm either'
62def endWithWoodw(result,project) :
63  retVal = None
64  reexp = r"(.|\n)*(\\|/)Data(\\|/)Netlib(\\|/)woodw took (\d*\.\d*) seconds using algorithm either(.|\n)*"
65  msgTail = result['stdout'][-200:]
66  if not re.compile(reexp).match(msgTail,1) :
67    # message not found, assume test failed
68    retVal = "Did not complete the woodw testcase"
69  return retVal
70
71# Did Cbc 'make test' write its success message?
72# Check that last the last few lines are of the form
73# 'cbc_clp solved 2 out of 2 and took XX.XX seconds.'
74def cbcMakeTestSuccessMessage(result,project) :
75  retVal=None
76  reexp=r"(.|\n)*cbc_clp solved 2 out of 2 and took (\d*\.\d*) seconds."
77  msgTail = result['stdout'][-300:]
78  if not re.compile(reexp).match(msgTail,1) :
79    # message not found, assume test failed
80    retVal = "Did not display message 'cbc_clp solved 2 out of 2 and took XX.XX seconds.'" 
81  return retVal
82
83# Messages must not contain:
84# "*** xxxSolverInterface testing issue: whatever the problem is"
85def noSolverInterfaceTestingIssueMessage(result,project):
86  retVal = None
87  reexp=r'.*\*\*.+SolverInterface testing issue:.*'
88  if re.compile(reexp).match(result['stderr'],1) :
89    # message found, assume test failed
90    retVal = "Issued message: 'SolverInterface tessting issue:'"
91  if re.compile(reexp).match(result['stdout'],1) :
92    # message found, assume test failed
93    retVal = "Issued message: 'SolverInterface tessting issue:'"
94  return retVal
95     
96
97# Look for pattern "<solver> solved NN out of 90 and took nnn.xx seconds"
98def OsiUnitTestSuccessMessages(result,project):
99  retVal = None
100  # Look for pattern "<solver> solved NN out of 90 and took nnn.xx seconds"
101  r=r'((.+) solved (\d+) out of 90 and took (\d*\.\d*) seconds)'
102  osisSummaryResult=re.findall(r,result['stdout'][-800:])
103  expectedOsis=['clp','sym','dylp','cbcclp']
104  for osi in osisSummaryResult :
105    if osi[1] in expectedOsis: expectedOsis.remove(osi[1])
106    numSolved = int(osi[2])
107    # Sym only solves 89 of the 90
108    if osi[1]=='sym':
109      if numSolved<89 :
110        retVal=osi[1]+\
111               " only solved "\
112               +osi[2]\
113               +" out of 90 in "\
114               +osi[3]+" seconds"
115    elif numSolved<90 :
116      retVal=osi[1]+\
117               " only solved "\
118               +osi[2]+\
119               " out of 90 in "\
120               +osi[3]+" seconds"
121  if len(expectedOsis)!=0 :
122        retVal="Osi "+expectedOsis[0]+" did not report number solved"
123  return retVal     
124
125
126#-------------------------------------------------------------------------
127#
128# Determine if config needs to be run.
129# If there is a config.log file and it indicates that it ran successfully
130# then config should not need to be rerun.
131#
132#-------------------------------------------------------------------------
133def didConfigRunOK( ) :
134  retVal=1
135  logFileName='config.log'
136  if not os.path.isfile(logFileName) :
137    retVal=0
138  else :
139    # Read logfile
140    logFilePtr = open(logFileName,'r')
141    logfile = logFilePtr.read()
142    logFilePtr.close()
143
144    # If logfile does not contain "configure: exit 0" then assume
145    # that configure needs to be rerun
146    if logfile.rfind("configure: exit 0") == -1 :
147      retVal=0
148
149  return retVal
Note: See TracBrowser for help on using the repository browser.