source: branches/testScripts/NBcheckResult.py @ 638

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

Working on Lou's suggestion on testing success from Osi. This commit is mostly to move code from windows to linux

  • Property svn:executable set to *
File size: 4.7 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 = 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    # Stdout should contain "Coin0008I WOODW read with 0 errors" in the last few lines
84    if not result['stdout'][-800:].find("Coin0008I WOODW read with 0 errors") :
85      retVal = 1
86    # Look for pattern "<solver> solved NN out of 90 and took nnn seconds"
87    r=r'(solved \d+ out of 90 and took nnn seconds)'
88    osisSummaryResult=re.findall(r,result['stdout'][-800:])
89    print 'JP0'
90    for osi in osisSummaryResult :
91      print osi
92                       
93   
94   
95   
96
97  return retVal
98
99#-------------------------------------------------------------------------
100#
101# Determine if config needs to be run.
102# If there is a config.log file and it indicates that it ran successfully
103# then config should not need to be rerun.
104#
105#-------------------------------------------------------------------------
106def didConfigRunOK( ) :
107  retVal=1
108  logFileName='config.log'
109  if not os.path.isfile(logFileName) :
110    retVal=0
111  else :
112    # Read logfile
113    logFilePtr = open(logFileName,'r')
114    logfile = logFilePtr.read()
115    logFilePtr.close()
116
117    # If logfile does not contain "configure: exit 0" then assume
118    # that configure needs to be rerun
119    if logfile.rfind("configure: exit 0") == -1 :
120      retVal=0
121
122  return retVal
Note: See TracBrowser for help on using the repository browser.