Beispiel #1
0
  def run_test(self, masterTbl, tst, iTest, num_tests):
    fn_envA = ['testDir', 'outputDir', 'resultFn',   'testdescriptFn',
               'cmdResultFn', 'messageFn', 'runtimeFn']
    envA    = ('idtag',   'test_name',  'packageName', 'packageDir',
               'TARGET', 'target', 'tag')
    envTbl  = {}

    projectDir = masterTbl['projectDir']
    for v in fn_envA:
      envTbl[v] = fullFn(projectDir, tst.get(v))

    for v in envA:
      envTbl[v] = tst.get(v)

    envTbl['projectDir'] = masterTbl['projectDir']
    job_submit_method    = tst.get('job_submit_method')

    job = JobSubmitBase.build(job_submit_method, masterTbl)

    try:
      run_script = tst.expand_run_script(envTbl, job)
    except Exception as e:
      to_stderr("Problem: ", "Failed to create job script for test file: ",tst.get('fn'),"\n")
      raise
      #print(e)
      #sys.exit(-1)

    cwd = os.getcwd()
    os.chdir(envTbl['outputDir'])


    resultFn = fullFn(projectDir, tst.get('resultFn'))

    write_table(resultFn, resultTbl['started'])

    stime = { 'T0' : time.time(), 'T1' : -1 }
    runtimeFn = fullFn(projectDir, tst.get('runtimeFn'))
    write_table(runtimeFn, stime)

    idtag    = tst.get('idtag')
    scriptFn = idtag + ".script"
    f        = open(scriptFn,"w")
    f.write(tst.top_of_script())
    f.write(run_script)
    f.close()

    st = os.stat(scriptFn)
    os.chmod(scriptFn,st.st_mode | stat.S_IEXEC)
    ident      = tst.get('id')
    background = tst.get('background') or (job_submit_method == "BATCH")
    tst.set('runInBackground', background)

    job.msg('Started', iTest, num_tests, ident, envTbl['resultFn'], background)
    job.runtest(scriptFn = scriptFn, idtag = idtag, background = background)
    job.msg('Finished', iTest, num_tests, ident, envTbl['resultFn'], background)

    os.chdir(cwd)
Beispiel #2
0
  def create_output_dirs(self, projectDir, tstT):

    for ident in tstT:
      tst       = tstT[ident]
      my_dir    = fullFn(projectDir, tst.get('outputDir'))
      if (not os.path.isdir(my_dir)):
        os.makedirs(my_dir)

    for ident in tstT:
      tst       = tstT[ident]
      resultFn  = fullFn(projectDir, tst.get('resultFn'))
      runtimeFn = fullFn(projectDir, tst.get('runtimeFn'))
      write_table(resultFn,  resultTbl['notrun'])
      write_table(runtimeFn, runtimeT)
Beispiel #3
0
  def execute(self, *args, **kwargs):
    masterTbl   = MasterTbl()
    rows, width = getTerminalSize()
    projectDir  = masterTbl['projectDir']
    rptT        = masterTbl['rptT']
    humanDataA  = []
    tstSummaryT = masterTbl['tstSummaryT']
    totalTime   = time.strftime("%T", time.gmtime(masterTbl['totalTestTime']))
    totalTime  += ("%.2f" % (masterTbl['totalTestTime'] - 
                   int(masterTbl['totalTestTime'])))[1:]
    
    
    testresultT = Tst.test_result_values()
    tstSummaryT = masterTbl['tstSummaryT']
    
    HDR = "*"*width
    TR  = "*** Test Results"
    TS  = "*** Test Summary"
    TRl = width - len(TR) - 3
    TR  = TR + " "*TRl + "***" 
    TS  = TS + " "*TRl + "***"
    
    humanDataA.append(0)
    humanDataA.append(HDR)
    humanDataA.append(TR)
    humanDataA.append(HDR)
    humanDataA.append(" ")
    humanDataA.append(0)

        
    humanDataA.append(2)
    humanDataA.append(["Date:",            masterTbl['date']])
    humanDataA.append(["TARGET:",          masterTbl['target']])
    humanDataA.append(["Themis Version:",  masterTbl['ThemisVersion']])
    humanDataA.append(["Total Test Time:", totalTime])
    humanDataA.append(-2)

    humanDataA.append(0)
    humanDataA.append(HDR)
    humanDataA.append(TS)
    humanDataA.append(HDR)
    humanDataA.append(" ")
    humanDataA.append(0)

    humanDataA.append(2)
    humanDataA.append(["Total: ", tstSummaryT['total']])
    for k in tstSummaryT:
      count = tstSummaryT[k]
      if (k != "total" and count > 0):
        humanDataA.append([k+":", count])
    humanDataA.append(-2)

    humanDataA.append(0)
    humanDataA.append(" ")
    humanDataA.append(0)

    humanDataA.append(5)
    humanDataA.append(["*******","*","****","*********","***************"])
    humanDataA.append(["Results","R","Time","Test Name","version/message"])
    humanDataA.append(["*******","*","****","*********","***************"])
   
    resultA = []
    
    for ident in rptT:
      tst    = rptT[ident]
      aFlag  = " "
      if (tst.get("active")): aFlag = "R"
      result  = tst.get('result')
      runtime = tst.get('strRuntime')
      rIdx    = str(10 - testresultT.get(result,0)) + "_" + ident
      txt     = " "
      if (result in testresultT):
        resultA.append((rIdx, result, aFlag, runtime,  ident, txt))
    
    resultA = sorted(resultA, key = lambda result: result[0])
    
    for v in resultA:
      humanDataA.append(v[1:])
    humanDataA.append(-5)
    
    humanDataA.append(0)
    humanDataA.append(" ")
    humanDataA.append(0)

    if(tstSummaryT['total'] != tstSummaryT['passed']):
      humanDataA.append(2)
      humanDataA.append(["*******",  "****************"])
      humanDataA.append(["Results",  "Output Directory"])
      humanDataA.append(["*******",  "****************"])
      
      resultA = []

      for ident in rptT:
        tst    = rptT[ident]
        result = tst.get('result')
        if (result != "passed" and result in testresultT):
          resultA.append((result, fullFn(projectDir, tst.get('outputDir'))))
      resultA = sorted(resultA, key = lambda result: result[0] + "-" + result[1])

      for v in resultA:
        humanDataA.append(v)
      humanDataA.append(-2)

    humanData = self.format_human_data(humanDataA)
    if (tstSummaryT['total'] > 0):
      print(humanData)

      testreportT = build_test_reportT(humanData, masterTbl)
      write_table(masterTbl['tstReportFn'], testreportT)
Beispiel #4
0
  def execute(self, *args, **kwargs):
    masterTbl  = MasterTbl()
    projectDir = masterTbl['projectDir']
    tstT       = masterTbl['tstT']
    rptT       = masterTbl['rptT']

    tstSummaryT = {}
    testValueT  = Tst.test_result_values()

    for k in testValueT:
      tstSummaryT[k] = 0
    tstSummaryT['total'] = 0

    masterTbl['error']         = 0
    masterTbl['diffCnt']       = 0
    masterTbl['failCnt']       = 0
    masterTbl['totalTestTime'] = 0.0

    epoch = masterTbl['currentEpoch']
    if (not tstT):
      epoch = masterTbl['origEpoch']

    status = 'passed'
    if (not rptT):
      status = ' '

    for ident in rptT:
      tst = rptT[ident]

      resultFn = fullFn(projectDir, tst.get('resultFn'))

      resultT  = json.loads(open(resultFn).read())
      result   = resultT['testresult']
      tst.set('result', result)

      if (not result in testValueT):
        Error("Unknown test result: ",result," from: ",resultFn)

      tstSummaryT[result]  += 1
      tstSummaryT['total'] += 1

      if (testValueT[result] < testValueT[status]):
        status = result

      if (result != "passed"):
        masterTbl['errors'] += 1

      if (result == "diff"):
        masterTbl['diffCnt'] += 1

      if (result == "failed"):
        masterTbl['failCnt'] += 1

      runtimeFn = fullFn(projectDir, tst.get('runtimeFn'))
      runtimeT = json.loads(open(runtimeFn).read())
      

      if (runtimeT['T0'] < 0 or runtimeT['T1'] < 0):
        t       = -1.0
        tstTime = "****"
      else:
        t       = runtimeT['T1'] - runtimeT['T0']
        tstTime = "%10.3f" % t
        tstTime = tstTime.strip()
        masterTbl['totalTestTime'] += t

      tst.set('runtime',    t)
      tst.set('strRuntime', tstTime)

      for k in runtimeT:
        tst.set(k, runtimeT[k])

    if (masterTbl['totalTestTime'] <= 0):
      masterTbl['errors'] = 0
    masterTbl['tstSummaryT'] = tstSummaryT
    masterTbl['status']      = status
    masterTbl['epoch']       = epoch