Esempio n. 1
0
def build_tstT(fn, test_descript, epoch):
  tstT = {}

  for idx, v in enumerate(test_descript.get('tests',[])):
    tst         = Tst(v, fn, test_descript, epoch, idx)
    ident       = tst.get('id')
    tstT[ident] = tst

  return tstT
Esempio n. 2
0
File: util.py Progetto: TACC/Themis
def build_test_reportT(human_data, masterTbl):
  test_reportT = {
    'HumanData'    : human_data.split("\n"),
    'date'         : masterTbl['date'],
    'currentEpoch' : masterTbl['currentEpoch'],
    'origEpoch'    : masterTbl['origEpoch'],
    'machType'     : masterTbl['os_mach'],
    'hostname'     : masterTbl['hostname'],
    'target'       : masterTbl['target'],
    'version'      : masterTbl['ThemisVersion'],
    'testA'        : []
    }
  testfieldA = Tst.test_fields()

  rptT = masterTbl['rptT']
  
  testA = test_reportT['testA']

  for ident in rptT:
    tst = rptT[ident]
    test_dataT = {}
    for key in testfieldA:
      test_dataT[key] = tst.get(key)

    testA.append(test_dataT)
  return test_reportT
Esempio n. 3
0
  def setup_restart(self, name, value):
    restart_valueT = {}
    test_resultT   = Tst.test_result_values()

    for v in value:
      v = v.lower()
      if (v == "wrong"):
        for vv in test_resultT:
          restart_valueT[vv] = (test_resultT[vv] < test_resultT['passed'])
      elif (test_resultT[v]):
        restart_valueT[v] = True
    self.__restart_valueT = restart_valueT
Esempio n. 4
0
  def read_rtm_file(self, fn):
    masterTbl  = MasterTbl()
    rptT       = json.loads(open(fn).read())
    testA      = rptT['testA']
    projectDir = masterTbl['projectDir']

    fileA = []
    for tst in testA:
      ident = tst['id']
      m = testDirPat.search(ident)
      
      if (not m):
        m      = fnIdPat.search(ident)
        my_dir = "./"
        fn     = m.group(1)
        idTag  = m.group(2)
      else:
        my_dir = m.group(1)
        fn     = m.group(2)
        idTag  = m.group(3)

      fileA.append(os.path.join(projectDir,my_dir, fn + ".desc"))

    for fn in fileA:
      self.read_test_descript(fn)
      
    tstkeyA = Tst.test_fields()
    candidateTstT = masterTbl['candidateTstT']

    #--------------------------------------------------------
    #  Copy results from previous run to current test.
    #  Active is controlled by user input not last run.
    for v in testA:
      ident       = v['id']
      tst         = candidateTstT[ident]
      v['active'] = tst.get('active')
      for key in tstkeyA:
        tst.set(key,v[key])
Esempio n. 5
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)
Esempio n. 6
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