8 from threading
import Thread
10 scriptPath = os.path.dirname( os.path.abspath(sys.argv[0]) )
11 print "scriptPath:", scriptPath
12 if scriptPath
not in sys.path:
13 sys.path.append(scriptPath)
30 startime=
'date %s' %time.asctime()
33 startDir = os.getcwd()
37 if not os.path.exists(self.
dirName):
40 commandbase = command.replace(
' ',
'_').
replace(
'/',
'_')
41 logfile=
'%s.log' % commandbase[:150].
replace(
"'",
'').
replace(
'../',
'')
43 if os.path.exists( os.path.join(os.environ[
'CMS_PATH'],
'cmsset_default.sh') ) :
44 executable =
'source $CMS_PATH/cmsset_default.sh; eval `scram run -sh`;'
46 executable =
'source $CMS_PATH/sw/cmsset_default.sh; eval `scram run -sh`;'
48 executable +=
'cd '+self.
dirName+
';'
49 executable +=
'%s > %s 2>&1' %(command, logfile)
51 ret = os.system(executable)
52 exitCodes.append( ret )
54 endtime=
'date %s' %time.asctime()
55 tottime=
'%s-%s'%(endtime,startime)
59 exitcode = exitCodes[i]
61 log=
'%s : FAILED - time: %s s - exit: %s\n' %(command,tottime,exitcode)
66 log=
'%s : PASSED - time: %s s - exit: %s\n' %(command,tottime,exitcode)
88 if t.isAlive() : nActive += 1
94 cmd =
'ln -s /afs/cern.ch/user/a/andreasp/public/IBTests/read*.py .'
101 tstPkgs = {
'FastSimulation' : [
'Configuration' ],
102 'HLTrigger' : [
'Configuration' ],
103 'PhysicsTools' : [
'PatAlgos' ],
108 pkgPath = os.environ[
'CMSSW_BASE'] +
'/src/'
109 relPath =
'$CMSSW_RELEASE_BASE/src/'
111 for tstSys
in tstPkgs:
112 if not os.path.exists(pkgPath + tstSys):
113 cmd =
'ln -s ' + relPath + tstSys +
' .;'
115 print 'setting up symlink for ' + tstSys +
' using ' + cmd
120 for tstPkg
in tstPkgs[tstSys]:
121 if not os.path.exists(pkgPath + tstSys +
"/" + tstPkg):
122 cmd =
'mkdir -p ' + tstSys +
'; ln -s ' + relPath + tstSys +
'/' + tstPkg +
' ' + tstSys +
';'
124 cmd =
'mkdir -p ' + tstSys +
'; ln -s ' + pkgPath + tstSys +
'/' + tstPkg +
' ' + tstSys +
';'
126 print 'setting up symlink for ' + tstSys +
'/' + tstPkg +
' using ' + cmd
137 if not os.environ.has_key(
'CMS_PATH'):
138 cmsPath =
'/afs/cern.ch/cms'
139 print "setting default for CMS_PATH to", cmsPath
140 os.environ[
'CMS_PATH'] = cmsPath
142 lines = {
'read312RV' : [
'cmsRun ../read312RV_cfg.py'],
143 'fastsim1' : [
'cmsRun ../FastSimulation/Configuration/test/IntegrationTestFake_cfg.py'],
144 'fastsim2' : [
'cmsRun ../FastSimulation/Configuration/test/IntegrationTest_cfg.py'],
146 'fastsim4' : [
'cmsRun ../FastSimulation/Configuration/test/IntegrationTestWithHLT_cfg.py'],
147 'pat1' : [
'cmsRun ../PhysicsTools/PatAlgos/test/IntegrationTest_cfg.py'],
150 hltTests = {
'hlt1' : [
'cmsDriver.py TTbar_Tauola.cfi -s GEN,SIM,DIGI,L1,DIGI2RAW -n 10 --conditions auto:startup --relval 9000,50 --datatier "GEN-SIM-RAW" --eventcontent RAW --fileout file:RelVal_DigiL1Raw_GRun.root',
151 'cmsRun ../HLTrigger/Configuration/test/OnLine_HLT_GRun.py' ],
152 'hlt2' : [
'cmsDriver.py TTbar_Tauola.cfi -s GEN,SIM,DIGI,L1,DIGI2RAW -n 10 --conditions auto:starthi --relval 9000,50 --datatier "GEN-SIM-RAW" --eventcontent RAW --fileout file:RelVal_DigiL1Raw_HIon.root',
153 'cmsRun ../HLTrigger/Configuration/test/OnLine_HLT_HIon.py'],
154 'hlt3' : [
'cmsRun ../HLTrigger/Configuration/test/OnData_HLT_GRun.py'],
155 'hlt4' : [
'cmsRun ../HLTrigger/Configuration/test/OnData_HLT_HIon.py'],
162 if not os.path.exists(
'addOnTests'):
163 os.makedirs(
'addOnTests')
164 os.chdir(
'addOnTests')
168 for dirName, command
in lines.items():
169 commands[dirName] = command
172 for dirName, commandList
in hltTests.items():
174 commands[dirName] = cmds
180 print 'Running in %s thread(s)' % self.
maxThreads
182 for dirName, command
in commands.items():
189 print 'Preparing to run %s' % str(command)
190 current =
testit(dirName, command)
191 self.threadList.append(current)
193 time.sleep(random.randint(1,5))
202 for f
in pingle.nfail: nfail += f
203 for p
in pingle.npass: npass += p
204 report += pingle.report
208 reportSumm =
'\n %s tests passed, %s failed \n' %(npass,nfail)
211 runall_report_name=
'runall-report.log'
212 runall_report=open(runall_report_name,
'w')
213 runall_report.write(report+reportSumm)
214 runall_report.close()
217 print '==> in :', os.getcwd()
218 print ' going to copy log files to logs dir ...'
219 if not os.path.exists(
'logs'):
221 for dirName
in commands.keys():
222 cmd =
"for L in `ls "+dirName+
"/*.log`; do cp $L logs/cmsDriver-`dirname $L`_`basename $L` ; done"
223 print "going to ",cmd
227 pickle.dump(commands, open(
'logs/addOnTests.pkl',
'w') )
235 print "in ", os.getcwd()
241 if not os.path.exists(tgtDir):
244 cmd =
'tar cf - addOnTests.log addOnTests/logs | (cd '+tgtDir+
' ; tar xf - ) '
246 print 'executing: ',cmd
249 print "ERROR uploading logs:", ret, cmd
251 print "EXCEPTION while uploading addOnTest-logs : ", str(e)
261 opts, args = getopt.getopt(argv,
"j:", [
"nproc=",
'uploadDir=',
'noRun'])
262 except getopt.GetoptError, e:
263 print "unknown option", str(e)
272 for opt, arg
in opts :
273 if opt
in (
'-j',
"--nproc" ):
275 if opt
in (
"--uploadDir", ):
277 if opt
in (
'--noRun', ):
284 tester.upload(uploadDir)
287 if __name__ ==
'__main__' :