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 | |
---|
8 | import re |
---|
9 | import os |
---|
10 | |
---|
11 | import 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 |
---|
20 | def anythingGoes( result, project ) : |
---|
21 | retVal = None |
---|
22 | return retVal |
---|
23 | |
---|
24 | # Is the rc=0? |
---|
25 | def 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? |
---|
33 | def 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? |
---|
41 | def 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 messages: 'All tests completed successfully'" |
---|
48 | return retVal |
---|
49 | |
---|
50 | # Was woodw the last netlib problem run? |
---|
51 | # Check that last netlib test case ran by looking for message of form |
---|
52 | # '../../Data/Netlib/woodw took 0.47 seconds using algorithm either' |
---|
53 | def endWithWoodw(result,project) : |
---|
54 | retVal = None |
---|
55 | reexp = r"(.|\n)*(\\|/)Data(\\|/)Netlib(\\|/)woodw took (\d*\.\d*) seconds using algorithm either(.|\n)*" |
---|
56 | msgTail = result['stdout'][-200:] |
---|
57 | if not re.compile(reexp).match(msgTail,1) : |
---|
58 | # message not found, assume test failed |
---|
59 | retVal = "Did not complete the woodw testcase" |
---|
60 | return retVal |
---|
61 | |
---|
62 | # Did Cbc 'make test' write its success message? |
---|
63 | # Check that last the last few lines are of the form |
---|
64 | # 'cbc_clp solved 2 out of 2 and took XX.XX seconds.' |
---|
65 | def cbcMakeTestSuccessMessage(result,project) : |
---|
66 | retVal=None |
---|
67 | reexp=r"(.|\n)*cbc_clp solved 2 out of 2 and took (\d*\.\d*) seconds." |
---|
68 | msgTail = result['stdout'][-300:] |
---|
69 | if not re.compile(reexp).match(msgTail,1) : |
---|
70 | # message not found, assume test failed |
---|
71 | retVal = "Did not display message 'cbc_clp solved 2 out of 2 and took XX.XX seconds.'" |
---|
72 | return retVal |
---|
73 | |
---|
74 | # Messages must not contain: |
---|
75 | # "*** xxxSolverInterface testing issue: whatever the problem is" |
---|
76 | def noSolverInterfaceTestingIssueMessage(result,project): |
---|
77 | retVal = None |
---|
78 | reexp=r'.*\*\*.+SolverInterface testing issue:.*' |
---|
79 | if re.compile(reexp).match(result['stderr'],1) : |
---|
80 | # message found, assume test failed |
---|
81 | retVal = "Issued message: 'SolverInterface tessting issue:'" |
---|
82 | if re.compile(reexp).match(result['stdout'],1) : |
---|
83 | # message found, assume test failed |
---|
84 | retVal = "Issued message: 'SolverInterface tessting issue:'" |
---|
85 | return retVal |
---|
86 | |
---|
87 | |
---|
88 | # Look for pattern "<solver> solved NN out of 90 and took nnn.xx seconds" |
---|
89 | def OsiUnitTestSuccessMessages(result,project): |
---|
90 | retVal = None |
---|
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 | return retVal |
---|
115 | |
---|
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 | #------------------------------------------------------------------------- |
---|
124 | def 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 |
---|