File indexing completed on 2023-03-17 10:49:04
0001
0002
0003 from __future__ import print_function
0004 import os
0005 import time
0006 import sys
0007 from threading import Thread
0008
0009 class testit(Thread):
0010 def __init__(self,command):
0011 Thread.__init__(self)
0012 self.command=command
0013 self.status=-1
0014 self.report=''
0015 self.nfail=0
0016 self.npass=0
0017 def run(self):
0018 commandbase=''
0019 for word in self.command.split(' ')[1:]:
0020 commandbase+='%s_'%word
0021 logfile='%s.log' %commandbase[:-1]
0022 logfile = logfile.replace('/','_')
0023
0024 startime='date %s' %time.asctime()
0025 executable='%s > %s 2>&1' %(self.command,logfile)
0026
0027 exitcode=os.system(executable)
0028 endtime='date %s' %time.asctime()
0029 tottime='%s-%s'%(endtime,startime)
0030
0031 if exitcode!=0:
0032 log='%s : FAILED - time: %s s - exit: %s\n' %(self.command,tottime,exitcode)
0033 self.report+='%s\n'%log
0034 self.nfail=1
0035 self.npass=0
0036 else:
0037 log='%s : PASSED - time: %s s - exit: %s\n' %(self.command,tottime,exitcode)
0038 self.report+='%s\n'%log
0039 self.nfail=0
0040 self.npass=1
0041
0042 def main(argv) :
0043
0044 import getopt
0045
0046 try:
0047 opts, args = getopt.getopt(argv, "", ["nproc=","dohighstat",'hlt','inFile=','intbld'])
0048 except getopt.GetoptError as e:
0049 print("unknown option", str(e))
0050 sys.exit(2)
0051
0052
0053 np=1
0054 doHighStat=0
0055 hlt = False
0056 inFile = None
0057 intBld = False
0058 for opt, arg in opts :
0059 if opt == "--inFile" :
0060 inFile=arg
0061 if opt == "--nproc" :
0062 np=arg
0063 if opt == "--dohighstat" :
0064 doHighStat=1
0065 if opt in ('--hlt',):
0066 hlt = True
0067 if opt in ('--intbld',):
0068 intBld = True
0069
0070 if hlt:
0071 print("\nWARNING: option --hlt is deprecated as this is now default.\n")
0072
0073 if inFile:
0074 commands_standard_file=open(inFile,'r')
0075 lines_standard=commands_standard_file.readlines()
0076 commands_standard_file.close()
0077 lines=lines_standard
0078 else:
0079 commands_standard_file=open('cmsDriver_standard_hlt.txt','r')
0080 lines_standard=commands_standard_file.readlines()
0081 commands_standard_file.close()
0082 lines=lines_standard
0083
0084 if doHighStat==1:
0085 commands_highstat_file=open('cmsDriver_highstats_hlt.txt','r')
0086 lines_highstat=commands_highstat_file.readlines()
0087 commands_highstat_file.close()
0088
0089 lines=lines+lines_highstat
0090
0091
0092
0093 forIB = [
0094 'SingleMuPt10', 'SinglePiPt1', 'SingleElectronPt10', 'SingleGammaPt10',
0095 'MinBias', 'QCD_Pt_80_120', 'ZEE', 'BJets_Pt_50_120','TTbar',
0096
0097 'SinglePiE50HCAL', 'H130GGgluonfusion', 'QQH120Inv', 'bJpsiX',
0098 'JpsiMM', 'BsMM', 'UpsMM', 'CJets_Pt_50_120'
0099 ]
0100
0101 commands=[]
0102 for line in lines:
0103 if ( line[0]!='#' and
0104 line.replace(' ','')!='\n' ):
0105 linecomponents=line.split('@@@')
0106 if intBld and linecomponents[0].strip() not in forIB: continue
0107 command=linecomponents[1][:-1]
0108 commands.append(command)
0109 print('Will do: '+command)
0110
0111
0112 nfail=0
0113 npass=0
0114 report=''
0115
0116 clist = []
0117 cdone = []
0118 i=0
0119 print('Running in %s thread(s)' %np)
0120
0121 for command in commands:
0122 print('Preparing to run %s' %command)
0123 current = testit(command)
0124 clist.append(current)
0125 cdone.append(0)
0126 current.start()
0127
0128 i=int(np)
0129 while (int(i) >= int(np)):
0130 i=0
0131 time.sleep(10)
0132 alen=len(cdone)
0133 for j in range(0,alen):
0134 mystat=cdone[j]
0135 pingle=clist[j]
0136 isA=pingle.is_alive()
0137 if ( isA ): i+=1
0138 if ( not isA and mystat==0 ):
0139 nfail+=pingle.nfail
0140 npass+=pingle.npass
0141 report+=pingle.report
0142 cdone[j]=1
0143 print(pingle.report)
0144
0145
0146 alen=len(cdone)
0147 for j in range(0,alen):
0148 pingle=clist[j]
0149 mystat=cdone[j]
0150 if ( mystat == 0 ):
0151 pingle.join()
0152 nfail+=pingle.nfail
0153 npass+=pingle.npass
0154 report+=pingle.report
0155 print(pingle.report)
0156
0157 report+='\n %s tests passed, %s failed \n' %(npass,nfail)
0158 print(report)
0159
0160 runall_report_name='runall-report.log'
0161 runall_report=open(runall_report_name,'w')
0162 runall_report.write(report)
0163 runall_report.close()
0164
0165 if hlt:
0166 print("\nWARNING: option --hlt is deprecated as this is now default.\n")
0167
0168 if __name__ == '__main__' :
0169 main(sys.argv[1:])