source: branches/testScripts/NBcheckResult.py @ 634

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

Created new file(module) for checking the results to see if a test
was successfull. This code was moved out of nightlyBuild.py.
Added code to test if DyLP and Osi were successful based on email from
Lou.

  • Property svn:executable set to *
File size: 4.5 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    print "jp0"
77    reexp=r'.*\*\*.+SolverInterface testing issue:.*'
78    if re.compile(reexp).match(result['stderr'],1) :
79      # message found, assume test failed
80      print "jp1"
81      retVal = 1
82    if re.compile(reexp).match(result['stdout'],1) :
83      # message found, assume test failed
84      print "jp2"
85      retVal = 1
86    # Stdout should contain "Coin0008I WOODW read with 0 errors" in the last few lines
87    if not result['stdout'][-800:].find("Coin0008I WOODW read with 0 errors") :
88      print "jp3"
89      retVal = 1
90
91  return retVal
92
93#-------------------------------------------------------------------------
94#
95# Determine if config needs to be run.
96# If there is a config.log file and it indicates that it ran successfully
97# then config should not need to be rerun.
98#
99#-------------------------------------------------------------------------
100def didConfigRunOK( ) :
101  retVal=1
102  logFileName='config.log'
103  if not os.path.isfile(logFileName) :
104    retVal=0
105  else :
106    # Read logfile
107    logFilePtr = open(logFileName,'r')
108    logfile = logFilePtr.read()
109    logFilePtr.close()
110
111    # If logfile does not contain "configure: exit 0" then assume
112    # that configure needs to be rerun
113    if logfile.rfind("configure: exit 0") == -1 :
114      retVal=0
115
116  return retVal
Note: See TracBrowser for help on using the repository browser.