CMS 3D CMS Logo

addOnTests.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 from __future__ import print_function
4 import os
5 import time
6 import sys
7 import re
8 import random
9 from threading import Thread
10 
11 scriptPath = os.path.dirname( os.path.abspath(sys.argv[0]) )
12 if scriptPath not in sys.path:
13  sys.path.append(scriptPath)
14 
15 
16 class testit(Thread):
17  def __init__(self,dirName, commandList):
18  Thread.__init__(self)
19  self.dirName = dirName
20  self.commandList = commandList
21  self.status=-1
22  self.report=''
23  self.nfail=[]
24  self.npass=[]
25 
26  return
27 
28  def run(self):
29 
30  startime='date %s' %time.asctime()
31  exitCodes = []
32 
33  for command in self.commandList:
34 
35  if not os.path.exists(self.dirName):
36  os.makedirs(self.dirName)
37 
38  commandbase = command.replace(' ','_').replace('/','_')
39  logfile='%s.log' % commandbase[:150].replace("'",'').replace('"','').replace('../','')
40 
41  executable = 'cd '+self.dirName+'; '+command+' > '+logfile+' 2>&1'
42 
43  ret = os.system(executable)
44  exitCodes.append( ret )
45 
46  endtime='date %s' %time.asctime()
47  tottime='%s-%s'%(endtime,startime)
48 
49  for i in range(len(self.commandList)):
50  command = self.commandList[i]
51  exitcode = exitCodes[i]
52  if exitcode != 0:
53  log='%s : FAILED - time: %s s - exit: %s\n' %(command,tottime,exitcode)
54  self.report+='%s\n'%log
55  self.nfail.append(1)
56  self.npass.append(0)
57  else:
58  log='%s : PASSED - time: %s s - exit: %s\n' %(command,tottime,exitcode)
59  self.report+='%s\n'%log
60  self.nfail.append(0)
61  self.npass.append(1)
62 
63  return
64 
66 
67  def __init__(self, nThrMax=4):
68 
69  self.threadList = []
70  self.maxThreads = nThrMax
71  self.prepare()
72 
73  return
74 
75  def activeThreads(self):
76 
77  nActive = 0
78  for t in self.threadList:
79  if t.isAlive() : nActive += 1
80 
81  return nActive
82 
83  def prepare(self):
84 
85  self.devPath = os.environ['LOCALRT'] + '/src/'
86  self.relPath = self.devPath
87  if 'CMSSW_RELEASE_BASE' in os.environ and (os.environ['CMSSW_RELEASE_BASE'] != ""): self.relPath = os.environ['CMSSW_RELEASE_BASE'] + '/src/'
88 
89  lines = { 'read312RV' : ['cmsRun '+self.file2Path('Utilities/ReleaseScripts/scripts/read312RV_cfg.py')],
90  'fastsim' : ["cmsDriver.py TTbar_8TeV_TuneCUETP8M1_cfi --conditions auto:run1_mc --fast -n 100 --eventcontent AODSIM,DQM --relval 100000,1000 -s GEN,SIM,RECOBEFMIX,DIGI:pdigi_valid,L1,DIGI2RAW,L1Reco,RECO,EI,VALIDATION --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --datatier GEN-SIM-DIGI-RECO,DQMIO --beamspot Realistic8TeVCollision"],
91  'fastsim1' : ["cmsDriver.py TTbar_13TeV_TuneCUETP8M1_cfi --conditions auto:run2_mc_l1stage1 --fast -n 100 --eventcontent AODSIM,DQM --relval 100000,1000 -s GEN,SIM,RECOBEFMIX,DIGI:pdigi_valid,L1,DIGI2RAW,L1Reco,RECO,EI,VALIDATION --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --datatier GEN-SIM-DIGI-RECO,DQMIO --beamspot NominalCollision2015 --era Run2_25ns"],
92  'fastsim2' : ["cmsDriver.py TTbar_13TeV_TuneCUETP8M1_cfi --conditions auto:run2_mc --fast -n 100 --eventcontent AODSIM,DQM --relval 100000,1000 -s GEN,SIM,RECOBEFMIX,DIGI:pdigi_valid,L1,DIGI2RAW,L1Reco,RECO,EI,VALIDATION --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --datatier GEN-SIM-DIGI-RECO,DQMIO --beamspot NominalCollision2015 --era Run2_2016"],
93  'pat1' : ['cmsRun '+self.file2Path('PhysicsTools/PatAlgos/test/IntegrationTest_cfg.py')],
94  }
95 
96  hltFlag_data = ' realData=True globalTag=@ inputFiles=@ '
97  hltFlag_mc = ' realData=False globalTag=@ inputFiles=@ '
98 
99  hltTests = {
100  'hlt_mc_Fake' : ['cmsDriver.py TTbar_Tauola_8TeV_TuneCUETP8M1_cfi -s GEN,SIM,DIGI,L1,DIGI2RAW --mc --scenario=pp -n 10 --conditions auto:run1_mc_Fake --relval 9000,50 --datatier "GEN-SIM-RAW" --eventcontent RAWSIM --customise=HLTrigger/Configuration/CustomConfigs.L1T --fileout file:RelVal_Raw_Fake_MC.root',
101  'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_Fake.py')+hltFlag_mc,
102  'cmsDriver.py RelVal -s HLT:Fake,RAW2DIGI,L1Reco,RECO --mc --scenario=pp -n 10 --conditions auto:run1_mc_Fake --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --processName=HLTRECO --filein file:RelVal_Raw_Fake_MC.root --fileout file:RelVal_Raw_Fake_MC_HLT_RECO.root'],
103  'hlt_mc_Fake1': ['cmsDriver.py TTbar_Tauola_13TeV_TuneCUETP8M1_cfi -s GEN,SIM,DIGI,L1,DIGI2RAW --mc --scenario=pp -n 10 --conditions auto:run2_mc_Fake1 --relval 9000,50 --datatier "GEN-SIM-RAW" --eventcontent RAWSIM --customise=HLTrigger/Configuration/CustomConfigs.L1T --era Run2_25ns --fileout file:RelVal_Raw_Fake1_MC.root',
104  'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_Fake1.py')+hltFlag_mc,
105  'cmsDriver.py RelVal -s HLT:Fake1,RAW2DIGI,L1Reco,RECO --mc --scenario=pp -n 10 --conditions auto:run2_mc_Fake1 --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --era Run2_25ns --processName=HLTRECO --filein file:RelVal_Raw_Fake1_MC.root --fileout file:RelVal_Raw_Fake1_MC_HLT_RECO.root'],
106  'hlt_mc_Fake2': ['cmsDriver.py TTbar_Tauola_13TeV_TuneCUETP8M1_cfi -s GEN,SIM,DIGI,L1,DIGI2RAW --mc --scenario=pp -n 10 --conditions auto:run2_mc_Fake2 --relval 9000,50 --datatier "GEN-SIM-RAW" --eventcontent RAWSIM --customise=HLTrigger/Configuration/CustomConfigs.L1T --era Run2_2016 --fileout file:RelVal_Raw_Fake2_MC.root',
107  'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_Fake2.py')+hltFlag_mc,
108  'cmsDriver.py RelVal -s HLT:Fake2,RAW2DIGI,L1Reco,RECO --mc --scenario=pp -n 10 --conditions auto:run2_mc_Fake2 --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --era Run2_2016 --processName=HLTRECO --filein file:RelVal_Raw_Fake2_MC.root --fileout file:RelVal_Raw_Fake2_MC_HLT_RECO.root'],
109  'hlt_mc_2018v36' : ['cmsDriver.py TTbar_Tauola_13TeV_TuneCUETP8M1_cfi -s GEN,SIM,DIGI,L1,DIGI2RAW --mc --scenario=pp -n 10 --conditions auto:run2_mc_2018v36 --relval 9000,50 --datatier "GEN-SIM-RAW" --eventcontent RAWSIM --customise=HLTrigger/Configuration/CustomConfigs.L1T --era Run2_2018 --fileout file:RelVal_Raw_2018v36_MC.root',
110  'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_2018v36.py')+hltFlag_mc,
111  'cmsDriver.py RelVal -s HLT:2018v36,RAW2DIGI,L1Reco,RECO --mc --scenario=pp -n 10 --conditions auto:run2_mc_2018v36 --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --era Run2_2018 --processName=HLTRECO --filein file:RelVal_Raw_2018v36_MC.root --fileout file:RelVal_Raw_2018v36_MC_HLT_RECO.root'],
112  'hlt_mc_GRun' : ['cmsDriver.py TTbar_Tauola_13TeV_TuneCUETP8M1_cfi -s GEN,SIM,DIGI,L1,DIGI2RAW --mc --scenario=pp -n 10 --conditions auto:run2_mc_GRun --relval 9000,50 --datatier "GEN-SIM-RAW" --eventcontent RAWSIM --customise=HLTrigger/Configuration/CustomConfigs.L1T --era Run2_2018 --fileout file:RelVal_Raw_GRun_MC.root',
113  'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_GRun.py')+hltFlag_mc,
114  'cmsDriver.py RelVal -s HLT:GRun,RAW2DIGI,L1Reco,RECO --mc --scenario=pp -n 10 --conditions auto:run2_mc_GRun --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --era Run2_2018 --processName=HLTRECO --filein file:RelVal_Raw_GRun_MC.root --fileout file:RelVal_Raw_GRun_MC_HLT_RECO.root'],
115  'hlt_mc_HIon' : ['cmsDriver.py TTbar_Tauola_13TeV_TuneCUETP8M1_cfi -s GEN,SIM,DIGI,L1,DIGI2RAW --mc --scenario=pp -n 10 --conditions auto:run2_mc_HIon --relval 9000,50 --datatier "GEN-SIM-RAW" --eventcontent RAWSIM --customise=HLTrigger/Configuration/CustomConfigs.L1T --era Run2_2018_pp_on_AA --fileout file:RelVal_Raw_HIon_MC.root',
116  'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_HIon.py')+hltFlag_mc,
117  'cmsDriver.py RelVal -s HLT:HIon,RAW2DIGI,L1Reco,RECO --mc --scenario=pp -n 10 --conditions auto:run2_mc_HIon --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --era Run2_2018_pp_on_AA --processName=HLTRECO --filein file:RelVal_Raw_HIon_MC.root --fileout file:RelVal_Raw_HIon_MC_HLT_RECO.root'],
118  'hlt_mc_PIon' : ['cmsDriver.py TTbar_Tauola_13TeV_TuneCUETP8M1_cfi -s GEN,SIM,DIGI,L1,DIGI2RAW --mc --scenario=pp -n 10 --conditions auto:run2_mc_PIon --relval 9000,50 --datatier "GEN-SIM-RAW" --eventcontent RAWSIM --customise=HLTrigger/Configuration/CustomConfigs.L1T --era Run2_2018 --fileout file:RelVal_Raw_PIon_MC.root',
119  'cmsRun ' + self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_PIon.py')+hltFlag_mc,
120  'cmsDriver.py RelVal -s HLT:PIon,RAW2DIGI,L1Reco,RECO --mc --scenario=pp -n 10 --conditions auto:run2_mc_PIon --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --era Run2_2018 --processName=HLTRECO --filein file:RelVal_Raw_PIon_MC.root --fileout file:RelVal_Raw_PIon_MC_HLT_RECO.root'],
121  'hlt_mc_PRef' : ['cmsDriver.py TTbar_Tauola_13TeV_TuneCUETP8M1_cfi -s GEN,SIM,DIGI,L1,DIGI2RAW --mc --scenario=pp -n 10 --conditions auto:run2_mc_PRef --relval 9000,50 --datatier "GEN-SIM-RAW" --eventcontent RAWSIM --customise=HLTrigger/Configuration/CustomConfigs.L1T --era Run2_2018 --fileout file:RelVal_Raw_PRef_MC.root',
122  'cmsRun ' + self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_PRef.py')+hltFlag_mc,
123  'cmsDriver.py RelVal -s HLT:PRef,RAW2DIGI,L1Reco,RECO --mc --scenario=pp -n 10 --conditions auto:run2_mc_PRef --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --era Run2_2018 --processName=HLTRECO --filein file:RelVal_Raw_PRef_MC.root --fileout file:RelVal_Raw_PRef_MC_HLT_RECO.root'],
124  'hlt_data_Fake' : ['cmsDriver.py RelVal -s L1REPACK:GT1 --data --scenario=pp -n 10 --conditions auto:run1_hlt_Fake --relval 9000,50 --datatier "RAW" --eventcontent RAW --customise=HLTrigger/Configuration/CustomConfigs.L1T --fileout file:RelVal_Raw_Fake_DATA.root --filein /store/data/Run2012A/MuEG/RAW/v1/000/191/718/14932935-E289-E111-830C-5404A6388697.root',
125  'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_Fake.py')+hltFlag_data,
126  'cmsDriver.py RelVal -s HLT:Fake,RAW2DIGI,L1Reco,RECO --data --scenario=pp -n 10 --conditions auto:run1_data_Fake --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --processName=HLTRECO --filein file:RelVal_Raw_Fake_DATA.root --fileout file:RelVal_Raw_Fake_DATA_HLT_RECO.root'],
127  'hlt_data_Fake1': ['cmsDriver.py RelVal -s L1REPACK:GCTGT --data --scenario=pp -n 10 --conditions auto:run2_hlt_Fake1 --relval 9000,50 --datatier "RAW" --eventcontent RAW --customise=HLTrigger/Configuration/CustomConfigs.L1T --era Run2_25ns --fileout file:RelVal_Raw_Fake1_DATA.root --filein /store/data/Run2015D/MuonEG/RAW/v1/000/256/677/00000/80950A90-745D-E511-92FD-02163E011C5D.root',
128  'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_Fake1.py')+hltFlag_data,
129  'cmsDriver.py RelVal -s HLT:Fake1,RAW2DIGI,L1Reco,RECO --data --scenario=pp -n 10 --conditions auto:run2_data_Fake1 --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --era Run2_25ns --processName=HLTRECO --filein file:RelVal_Raw_Fake1_DATA.root --fileout file:RelVal_Raw_Fake1_DATA_HLT_RECO.root'],
130  'hlt_data_Fake2': ['cmsDriver.py RelVal -s L1REPACK:Full --data --scenario=pp -n 10 --conditions auto:run2_hlt_Fake2 --relval 9000,50 --datatier "RAW" --eventcontent RAW --customise=HLTrigger/Configuration/CustomConfigs.L1T --era Run2_2016 --fileout file:RelVal_Raw_Fake2_DATA.root --filein /store/data/Run2016B/JetHT/RAW/v1/000/272/762/00000/C666CDE2-E013-E611-B15A-02163E011DBE.root',
131  'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_Fake2.py')+hltFlag_data,
132  'cmsDriver.py RelVal -s HLT:Fake2,RAW2DIGI,L1Reco,RECO --data --scenario=pp -n 10 --conditions auto:run2_data_Fake2 --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --era Run2_2016 --processName=HLTRECO --filein file:RelVal_Raw_Fake2_DATA.root --fileout file:RelVal_Raw_Fake2_DATA_HLT_RECO.root'],
133  'hlt_data_2018v36' : ['cmsDriver.py RelVal -s L1REPACK:Full --data --scenario=pp -n 10 --conditions auto:run2_hlt_2018v36 --relval 9000,50 --datatier "RAW" --eventcontent RAW --customise=HLTrigger/Configuration/CustomConfigs.L1T --era Run2_2018 --fileout file:RelVal_Raw_2018v36_DATA.root --filein /store/data/Run2017A/HLTPhysics4/RAW/v1/000/295/606/00000/36DE5E0A-3645-E711-8FA1-02163E01A43B.root',
134  'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_2018v36.py')+hltFlag_data,
135  'cmsDriver.py RelVal -s HLT:2018v36,RAW2DIGI,L1Reco,RECO --data --scenario=pp -n 10 --conditions auto:run2_data_2018v36 --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --era Run2_2018 --processName=HLTRECO --filein file:RelVal_Raw_2018v36_DATA.root --fileout file:RelVal_Raw_2018v36_DATA_HLT_RECO.root'],
136  'hlt_data_GRun' : ['cmsDriver.py RelVal -s L1REPACK:Full --data --scenario=pp -n 10 --conditions auto:run2_hlt_GRun --relval 9000,50 --datatier "RAW" --eventcontent RAW --customise=HLTrigger/Configuration/CustomConfigs.L1T --era Run2_2018 --fileout file:RelVal_Raw_GRun_DATA.root --filein /store/data/Run2017A/HLTPhysics4/RAW/v1/000/295/606/00000/36DE5E0A-3645-E711-8FA1-02163E01A43B.root',
137  'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_GRun.py')+hltFlag_data,
138  'cmsDriver.py RelVal -s HLT:GRun,RAW2DIGI,L1Reco,RECO --data --scenario=pp -n 10 --conditions auto:run2_data_GRun --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --era Run2_2018 --processName=HLTRECO --filein file:RelVal_Raw_GRun_DATA.root --fileout file:RelVal_Raw_GRun_DATA_HLT_RECO.root'],
139  'hlt_data_HIon' : ['cmsDriver.py RelVal -s L1REPACK:Full --data --scenario=pp -n 10 --conditions auto:run2_hlt_HIon --relval 9000,50 --datatier "RAW" --eventcontent RAW --customise=HLTrigger/Configuration/CustomConfigs.L1T --era Run2_2018_pp_on_AA --fileout file:RelVal_Raw_HIon_DATA.root --filein /store/data/Run2018D/HIMinimumBias0/RAW/v1/000/325/112/00000/660F62BB-9932-D645-A4A4-0BBBDA3963E8.root --customise_commands=\'from FWCore.ParameterSet.MassReplace import massSearchReplaceAnyInputTag; massSearchReplaceAnyInputTag(process.SimL1Emulator,"rawDataCollector","rawDataRepacker",False,True)\'',
140  'cmsRun '+self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_HIon.py')+hltFlag_data,
141  'cmsDriver.py RelVal -s HLT:HIon,RAW2DIGI,L1Reco,RECO --data --scenario=pp -n 10 --conditions auto:run2_data_HIon --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --era Run2_2018_pp_on_AA --processName=HLTRECO --filein file:RelVal_Raw_HIon_DATA.root --fileout file:RelVal_Raw_HIon_DATA_HLT_RECO.root'],
142  'hlt_data_PIon' : ['cmsDriver.py RelVal -s L1REPACK:Full --data --scenario=pp -n 10 --conditions auto:run2_hlt_PIon --relval 9000,50 --datatier "RAW" --customise=HLTrigger/Configuration/CustomConfigs.L1T --era Run2_2018 --eventcontent RAW --fileout file:RelVal_Raw_PIon_DATA.root --filein /store/data/Run2017A/HLTPhysics4/RAW/v1/000/295/606/00000/36DE5E0A-3645-E711-8FA1-02163E01A43B.root',
143  'cmsRun ' + self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_PIon.py')+hltFlag_data,
144  'cmsDriver.py RelVal -s HLT:PIon,RAW2DIGI,L1Reco,RECO --data --scenario=pp -n 10 --conditions auto:run2_data_PIon --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --era Run2_2018 --processName=HLTRECO --filein file:RelVal_Raw_PIon_DATA.root --fileout file:RelVal_Raw_PIon_DATA_HLT_RECO.root'],
145  'hlt_data_PRef' : ['cmsDriver.py RelVal -s L1REPACK:Full --data --scenario=pp -n 10 --conditions auto:run2_hlt_PRef --relval 9000,50 --datatier "RAW" --customise=HLTrigger/Configuration/CustomConfigs.L1T --era Run2_2018 --eventcontent RAW --fileout file:RelVal_Raw_PRef_DATA.root --filein /store/data/Run2017A/HLTPhysics4/RAW/v1/000/295/606/00000/36DE5E0A-3645-E711-8FA1-02163E01A43B.root',
146  'cmsRun ' + self.file2Path('HLTrigger/Configuration/test/OnLine_HLT_PRef.py')+hltFlag_data,
147  'cmsDriver.py RelVal -s HLT:PRef,RAW2DIGI,L1Reco,RECO --data --scenario=pp -n 10 --conditions auto:run2_data_PRef --relval 9000,50 --datatier "RAW-HLT-RECO" --eventcontent FEVTDEBUGHLT --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --era Run2_2018 --processName=HLTRECO --filein file:RelVal_Raw_PRef_DATA.root --fileout file:RelVal_Raw_PRef_DATA_HLT_RECO.root'],
148  }
149 
150  self.commands={}
151  for dirName, command in lines.items():
152  self.commands[dirName] = command
153 
154  for dirName, commandList in hltTests.items():
155  self.commands[dirName] = commandList
156  return
157 
158  def dumpTest(self):
159  print(",".join(self.commands.keys()))
160  return
161 
162  def file2Path(self,rFile):
163 
164  fullPath = self.relPath + rFile
165  if os.path.exists(self.devPath + rFile): fullPath = self.devPath + rFile
166  return fullPath
167 
168  def runTests(self, testList = None):
169 
170  actDir = os.getcwd()
171 
172  if not os.path.exists('addOnTests'):
173  os.makedirs('addOnTests')
174  os.chdir('addOnTests')
175 
176  nfail=0
177  npass=0
178  report=''
179 
180  print('Running in %s thread(s)' % self.maxThreads)
181 
182  for dirName, command in self.commands.items():
183 
184  if testList and not dirName in testList:
185  del self.commands[dirName]
186  continue
187 
188  # make sure we don't run more than the allowed number of threads:
189  while self.activeThreads() >= self.maxThreads:
190  time.sleep(10)
191  continue
192 
193  print('Preparing to run %s' % str(command))
194  current = testit(dirName, command)
195  self.threadList.append(current)
196  current.start()
197  time.sleep(random.randint(1,5)) # try to avoid race cond by sleeping random amount of time [1,5] sec
198 
199  # wait until all threads are finished
200  while self.activeThreads() > 0:
201  time.sleep(5)
202 
203  # all threads are done now, check status ...
204  for pingle in self.threadList:
205  pingle.join()
206  for f in pingle.nfail: nfail += f
207  for p in pingle.npass: npass += p
208  report += pingle.report
209  print(pingle.report)
210  sys.stdout.flush()
211 
212  reportSumm = '\n %s tests passed, %s failed \n' %(npass,nfail)
213  print(reportSumm)
214 
215  runall_report_name='runall-report.log'
216  runall_report=open(runall_report_name,'w')
217  runall_report.write(report+reportSumm)
218  runall_report.close()
219 
220  # get the logs to the logs dir:
221  print('==> in :', os.getcwd())
222  print(' going to copy log files to logs dir ...')
223  if not os.path.exists('logs'):
224  os.makedirs('logs')
225  for dirName in self.commands:
226  cmd = "for L in `ls "+dirName+"/*.log`; do cp $L logs/cmsDriver-`dirname $L`_`basename $L` ; done"
227  print("going to ",cmd)
228  os.system(cmd)
229 
230  import pickle
231  pickle.dump(self.commands, open('logs/addOnTests.pkl', 'w') )
232 
233  os.chdir(actDir)
234 
235  return
236 
237  def upload(self, tgtDir):
238 
239  print("in ", os.getcwd())
240 
241  if not os.path.exists(tgtDir):
242  os.makedirs(tgtDir)
243 
244  cmd = 'tar cf - addOnTests.log addOnTests/logs | (cd '+tgtDir+' ; tar xf - ) '
245  try:
246  print('executing: ',cmd)
247  ret = os.system(cmd)
248  if ret != 0:
249  print("ERROR uploading logs:", ret, cmd)
250  except Exception as e:
251  print("EXCEPTION while uploading addOnTest-logs : ", str(e))
252 
253  return
254 
255 
256 def main(argv) :
257 
258  import getopt
259 
260  try:
261  opts, args = getopt.getopt(argv, "dj:t:", ["nproc=", 'uploadDir=', 'tests=','noRun','dump'])
262  except getopt.GetoptError as e:
263  print("unknown option", str(e))
264  sys.exit(2)
265 
266  np = 4
267  uploadDir = None
268  runTests = True
269  testList = None
270  dump = False
271  for opt, arg in opts :
272  if opt in ('-j', "--nproc" ):
273  np=int(arg)
274  if opt in ("--uploadDir", ):
275  uploadDir = arg
276  if opt in ('--noRun', ):
277  runTests = False
278  if opt in ('-d','--dump', ):
279  dump = True
280  if opt in ('-t','--tests', ):
281  testList = arg.split(",")
282 
283  tester = StandardTester(np)
284  if dump:
285  tester.dumpTest()
286  else:
287  if runTests:
288  tester.runTests(testList)
289  if uploadDir:
290  tester.upload(uploadDir)
291  return
292 
293 if __name__ == '__main__' :
294  main(sys.argv[1:])
def file2Path(self, rFile)
Definition: addOnTests.py:162
def upload(self, tgtDir)
Definition: addOnTests.py:237
def replace(string, replacements)
def main(argv)
Definition: addOnTests.py:256
def __init__(self, dirName, commandList)
Definition: addOnTests.py:17
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65
def __init__(self, nThrMax=4)
Definition: addOnTests.py:67
def runTests(self, testList=None)
Definition: addOnTests.py:168
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
Definition: main.py:1
#define str(s)
def run(self)
Definition: addOnTests.py:28