3 from __future__
import print_function
4 from builtins
import range
10 from threading
import Thread
12 scriptPath = os.path.dirname( os.path.abspath(sys.argv[0]) )
13 if scriptPath
not in sys.path:
14 sys.path.append(scriptPath)
31 startime=
'date %s' %time.asctime()
36 if not os.path.exists(self.
dirName):
39 commandbase = command.replace(
' ',
'_').
replace(
'/',
'_')
42 executable =
'cd '+self.
dirName+
'; '+command+
' > '+logfile+
' 2>&1' 44 ret = os.system(executable)
45 exitCodes.append( ret )
47 endtime=
'date %s' %time.asctime()
48 tottime=
'%s-%s'%(endtime,startime)
52 exitcode = exitCodes[i]
54 log=
'%s : FAILED - time: %s s - exit: %s\n' %(command,tottime,exitcode)
59 log=
'%s : PASSED - time: %s s - exit: %s\n' %(command,tottime,exitcode)
80 if t.is_alive() : nActive += 1
86 self.
devPath = os.environ[
'LOCALRT'] +
'/src/' 88 if 'CMSSW_RELEASE_BASE' in os.environ
and (os.environ[
'CMSSW_RELEASE_BASE'] !=
""): self.
relPath = os.environ[
'CMSSW_RELEASE_BASE'] +
'/src/' 90 lines = {
'read312RV' : [
'cmsRun '+self.
file2Path(
'Utilities/ReleaseScripts/scripts/read312RV_cfg.py')],
91 '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,VALIDATION --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --datatier GEN-SIM-DIGI-RECO,DQMIO --beamspot Realistic8TeVCollision"],
92 '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,VALIDATION --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --datatier GEN-SIM-DIGI-RECO,DQMIO --beamspot NominalCollision2015 --era Run2_25ns"],
93 '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,VALIDATION --customise=HLTrigger/Configuration/CustomConfigs.L1THLT --datatier GEN-SIM-DIGI-RECO,DQMIO --beamspot NominalCollision2015 --era Run2_2016"],
94 'pat1' : [
'cmsRun '+self.
file2Path(
'PhysicsTools/PatAlgos/test/IntegrationTest_cfg.py')],
98 hltFlag_data =
' realData=True globalTag=@ inputFiles=@ ' 99 hltFlag_mc =
' realData=False globalTag=@ inputFiles=@ ' 100 from Configuration.HLT.addOnTestsHLT
import addOnTestsHLT
102 for key
in hltTestsToAdd:
104 hltTests[key] = [hltTestsToAdd[key][0],
105 'cmsRun '+self.
file2Path(hltTestsToAdd[key][1])+hltFlag_data,
106 hltTestsToAdd[key][2]]
108 hltTests[key] = [hltTestsToAdd[key][0],
109 'cmsRun '+self.
file2Path(hltTestsToAdd[key][1])+hltFlag_mc,
110 hltTestsToAdd[key][2]]
112 hltTests[key] = [hltTestsToAdd[key][0],
113 'cmsRun '+self.
file2Path(hltTestsToAdd[key][1]),
114 hltTestsToAdd[key][2]]
117 for dirName, command
in lines.items():
120 for dirName, commandList
in hltTests.items():
121 self.
commands[dirName] = commandList
130 fullPath = self.
relPath + rFile
131 if os.path.exists(self.
devPath + rFile): fullPath = self.
devPath + rFile
138 if not os.path.exists(
'addOnTests'):
139 os.makedirs(
'addOnTests')
140 os.chdir(
'addOnTests')
157 print(
'Preparing to run %s' %
str(command))
158 current =
testit(dirName, command)
161 time.sleep(random.randint(1,5))
170 for f
in pingle.nfail: nfail += f
171 for p
in pingle.npass: npass += p
172 report += pingle.report
176 reportSumm =
'\n %s tests passed, %s failed \n' %(npass,nfail)
179 runall_report_name=
'runall-report.log' 180 runall_report=open(runall_report_name,
'w')
181 runall_report.write(report+reportSumm)
182 runall_report.close()
185 print(
'==> in :', os.getcwd())
186 print(
' going to copy log files to logs dir ...')
187 if not os.path.exists(
'logs'):
190 cmd =
"for L in `ls "+dirName+
"/*.log`; do cp $L logs/cmsDriver-`dirname $L`_`basename $L` ; done" 191 print(
"going to ",cmd)
195 pickle.dump(self.
commands, open(
'logs/addOnTests.pkl',
'wb'), protocol=2)
203 print(
"in ", os.getcwd())
205 if not os.path.exists(tgtDir):
208 cmd =
'tar cf - addOnTests.log addOnTests/logs | (cd '+tgtDir+
' ; tar xf - ) ' 210 print(
'executing: ',cmd)
213 print(
"ERROR uploading logs:", ret, cmd)
214 except Exception
as e:
215 print(
"EXCEPTION while uploading addOnTest-logs : ",
str(e))
225 opts, args = getopt.getopt(argv,
"dj:t:", [
"nproc=",
'uploadDir=',
'tests=',
'noRun',
'dump'])
226 except getopt.GetoptError
as e:
235 for opt, arg
in opts :
236 if opt
in (
'-j',
"--nproc" ):
238 if opt
in (
"--uploadDir", ):
240 if opt
in (
'--noRun', ):
242 if opt
in (
'-d',
'--dump', ):
244 if opt
in (
'-t',
'--tests', ):
245 testList = arg.split(
",")
252 tester.runTests(testList)
254 tester.upload(uploadDir)
257 if __name__ ==
'__main__' :
def file2Path(self, rFile)
def replace(string, replacements)
def __init__(self, dirName, commandList)
def __init__(self, nThrMax=4)
def runTests(self, testList=None)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
static std::string join(char **cmd)