1 | #! /usr/bin/env python |
---|
2 | |
---|
3 | import re |
---|
4 | import os |
---|
5 | |
---|
6 | import 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 | #------------------------------------------------------------------------ |
---|
14 | def didTestFail( result, project, buildStep ) : |
---|
15 | retVal = 0 |
---|
16 | |
---|
17 | # If the return code is not 0, then failure |
---|
18 | if result['returnCode'] != 0 : |
---|
19 | retVal = 1 |
---|
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 = 1 |
---|
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 = 1 |
---|
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 = 1 |
---|
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=0 |
---|
63 | else : |
---|
64 | retVal=1 |
---|
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 = 1 |
---|
80 | if re.compile(reexp).match(result['stdout'],1) : |
---|
81 | # message found, assume test failed |
---|
82 | retVal = 1 |
---|
83 | |
---|
84 | if project=='DyLP' and buildStep==NBprojectConfig.UNITTEST_CMD['Osi'] or \ |
---|
85 | project=='Osi' and buildStep==NBprojectConfig.UNITTEST_CMD['Osi'] : |
---|
86 | |
---|
87 | # Look for pattern "<solver> solved NN out of 90 and took nnn.xx seconds" |
---|
88 | r=r'((.+) solved (\d+) out of 90 and took (\d*\.\d*) seconds)' |
---|
89 | osisSummaryResult=re.findall(r,result['stdout'][-800:]) |
---|
90 | for osi in osisSummaryResult : |
---|
91 | if int(osi[2])<90 : |
---|
92 | #print osi[1]+" ran "+osi[2]+" out of 90 in "+osi[3]+" seconds" |
---|
93 | retVal=1 |
---|
94 | |
---|
95 | return retVal |
---|
96 | |
---|
97 | #------------------------------------------------------------------------- |
---|
98 | # |
---|
99 | # Determine if config needs to be run. |
---|
100 | # If there is a config.log file and it indicates that it ran successfully |
---|
101 | # then config should not need to be rerun. |
---|
102 | # |
---|
103 | #------------------------------------------------------------------------- |
---|
104 | def didConfigRunOK( ) : |
---|
105 | retVal=1 |
---|
106 | logFileName='config.log' |
---|
107 | if not os.path.isfile(logFileName) : |
---|
108 | retVal=0 |
---|
109 | else : |
---|
110 | # Read logfile |
---|
111 | logFilePtr = open(logFileName,'r') |
---|
112 | logfile = logFilePtr.read() |
---|
113 | logFilePtr.close() |
---|
114 | |
---|
115 | # If logfile does not contain "configure: exit 0" then assume |
---|
116 | # that configure needs to be rerun |
---|
117 | if logfile.rfind("configure: exit 0") == -1 : |
---|
118 | retVal=0 |
---|
119 | |
---|
120 | return retVal |
---|