def SetDataCollectionPath(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: SetDataCollectionPath # Input: Takes no argument # Description: Sets up path to save UDAS waveform # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ # SetOutputDirectory function is used to set the Automation logs output directory location logger.info("Setting Logs Location for saving UDAS") dateTimeStrPath = "Automation\\Logs\\" + str(datetime.now().strftime('%Y-%m-%d_%H-%M-%S')) kratosPcLocalPath = "C:\\" + dateTimeStrPath self.logsPath = "\\\\" + TestSuiteConfig.KratosIpAddress + "\\C$\\" + dateTimeStrPath logger.info('KRATOS : Log directory path : ' + self.logsPath) result =self.kratosHandler.SetOutputDirectory(kratosPcLocalPath) if result.HasError(): logger.error("Error in setting up UDAS logs location : " + result.ErrorMessage()) recoveryResult = self.KratosErrorHandler() return recoveryResult return StatusResult.Success()
def RebootDevice(self) : """ #------------------------------------------------------------------------------------------------------------------- # Name: RebootDevice # Input: Takes no argument # Description: Reboots Device by switching Power & USB # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ logger.info("Turning Off Device") result = self.PowerOff() if result.HasError(): return result result = self.UsbOff() if result.HasError(): return result time.sleep(2) logger.info("Booting up Device") result = self.PowerOn() if result.HasError(): return result result = self.UsbOn() if result.HasError(): return result return result
def __init__(self, setAcqConfig = True): self.retryOnErrorCount = 0 self.kratosHandler = KratosHandler(TestSuiteConfig.KratosIpAddress) logger.info( "Connecting to KRATOSLITE Machine, IP is:" + self.kratosHandler.kratosPcIpAddress + "Kratoslite PC name is: " + TestSuiteConfig.KratosPcName) result = self.KratosSetup() if result.HasError(): raise Exception(result.ErrorMessage()) # SetPowerConfiguration function is used to configure the Voltage, Current & OVP values on KRATOS result = self.SetPowerConfiguration() if result.HasError(): raise Exception(result.ErrorMessage()) if setAcqConfig: # SetAcquisitionConfiguration function is used to set Acquisition parameters on KRATOS. result = self.SetAcquisitionConfiguration() if result.HasError(): raise Exception(result.ErrorMessage()) result = self.SetDefaultOptions() if result.HasError(): raise Exception(result.ErrorMessage()) self.udasDir = TestCaseConfig.ReportsPath + '\\UDAS'
def GetThermalValue(self, para, startRow=0, endRow=0, target="cpuss0-max-step"): logger.info("Calculating Average Thermal Value") FPSColumn = -1 totalFPS = 0 countFPS = 0 rowNumber = 0 averageThermalValue = -1 TsensLog = "" files = os.listdir(os.path.join(para.TestCaseFolder, "logs")) if len(files) == 0: logger.warning("There is no tsens logger") return averageThermalValue for file in files: fileFullPath = os.path.join( os.path.join(para.TestCaseFolder, "logs"), file) if os.path.splitext(file)[1].lower() == ".csv": TsensLog = fileFullPath if TsensLog == "": logger.warning("There is no tsens logger csv file") return averageThermalValue try: with open(TsensLog, 'r') as f: reader = csv.reader(f) for row in reader: if FPSColumn == -1: i = 0 for item in row: if item == target: FPSColumn = i break i += 1 else: if rowNumber >= startRow: #logger.info(row) if row == []: break if endRow == 0: totalFPS += int(row[FPSColumn]) countFPS += 1 else: if rowNumber <= endRow: totalFPS += int(row[FPSColumn]) countFPS += 1 else: break rowNumber += 1 f.close() averageThermalValue = round( (float(totalFPS) / float(countFPS) / 1000.0), 2) except Exception as e: logger.error("Error in calculating average FPS: " + str(e)) averageThermalValue = -1 logger.info("Average FPS: " + str(averageThermalValue)) return averageThermalValue
def WriteExcel(self, para, ThermalLogName): """write data""" if 'KratosLite' or 'Kratos' in TestSuiteConfig.HardwareType: avgCurrent = self.AnalyzingPowerResult(para) avgVoltage = self.GetAvgCurrentAndVoltage() """解析dhry.txt""" for parent, dirs, filenames in os.walk(self.target_dir): for filename in filenames: if filename == 'dhry.txt': [loop, time, thread] = self.dhry_file_parser(parent, filename) perf = int(loop) / float(time) / 1757 EndTime = Decimal(time) ThermalValue = self.GetThermalValue(para, 24, endRow=int(EndTime), target=ThermalLogName) logger.info("Appending test case data into Excel") logger.info("dhry dir: " + str(self.target_dir)) excelHandle = ExcelHandle( os.path.join(TestSuiteConfig.ReportsPath, "CPUTestSummary.xls")) excelHandle.GetSheetHandle("CPUTest") tcInfo = [ para.case_name, str(avgCurrent), str(avgVoltage), loop, time, thread, str(round(perf, 2)), str(ThermalValue) ] logger.info(tcInfo) excelHandle.WriteRow(*tcInfo, beginColumn=0, style="body") excelHandle.SaveFile() excelHandle = None elif 'Monitor' in TestSuiteConfig.HardwareType: file_name = os.path.join(self.PowerHandler.collect_dir, self.PowerHandler.save_name + '.pt4') logger.info(file_name) st = 0 et = 50 avgCurrent = PowerMonitorParser().pt_csv(file_name, 'pt4', st, et) logger.info("Appending test case data into Excel") excelHandle = ExcelHandle( os.path.join(TestSuiteConfig.ReportsPath, "CPUTestSummary.xls")) excelHandle.GetSheetHandle("CPUTest") tcInfo = [ para.case_name, para.GPU_power_f, str(round(avgCurrent, 2)), "4.0" ] excelHandle.WriteRow(*tcInfo, beginColumn=0, style="body") excelHandle.SaveFile() excelHandle = None
def KratosErrorHandler(self): """ ------------------------------------------------------------------------- # Name: KratosErrorHandler # Input: Takes no argument # Description: Ping and restart Kratos Application for Recovery # Return: StatusResult.Error ------------------------------------------------------------------------- """ self.retryOnErrorCount = self.retryOnErrorCount + 1 if self.retryOnErrorCount > 3 : return StatusResult.Error("Failled to Handle Error and Restart Kratos after Max Tries.") try: logger.info("Entered Kratos Error Handling") kratosRecovery = KratosRecovery() result = kratosRecovery.PingKratos(TestSuiteConfig.KratosIpAddress, 3600) if result.HasError() : logger.error("Could Not Ping Kratos Machine in 60 Minutes.") return result result = kratosRecovery.RestartKratos(TestSuiteConfig.KratosIpAddress) logger.info("Rebooting Kratos Software and Test Device") if result.HasError(): return result logger.info("Re-Configuring Kratos") result = self.KratosSetup() if result.HasError(): return result # SetConfigurationFile function is used to recall the cfg file saved by user on Kratos configFile = TestCaseConfig.ChannelConfiguration if TestCaseConfig.ChannelConfiguration else TestSuiteConfig.ChannelConfiguration result = self.SetConfigurationFile(configFile) if result.HasError(): raise Exception(result.ErrorMessage()) # SetPowerConfiguration function is used to configure the Voltage, Current & OVP values on KRATOS result = self.SetPowerConfiguration() if result.HasError(): raise Exception(result.ErrorMessage()) # SetAcquisitionConfiguration function is used to set Acquisition parameters on KRATOS. result = self.SetAcquisitionConfiguration() if result.HasError(): raise Exception(result.ErrorMessage()) result = self.SetDefaultOptions() if result.HasError(): raise Exception(result.ErrorMessage()) logger.info("Booting up Device") result = self.PowerOn() if result.HasError(): return result result = self.UsbOn() if result.HasError(): return result except Exception as e: logger.error(str(e)) return StatusResult.Error("Failing This Attempt To Retry Test After Kratos Restart")
def RunCommandsSequentially(command): """ #------------------------------------------------------------------------------------------------------------------- # Name: RunCommandsSequentially # Input: Takes list as an argument # command : list of commands to be executed # Description: Executes the adb shell commands # Return: Returns an Object of Status.Result() class, result. result have two attributes Status and CmdResult # storing objects of StatusResult and CommandLineResult respectively #------------------------------------------------------------------------------------------------------------------- """ result = Result() out = None try: procId = subprocess.Popen(command[0], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf8') cmd = command[1] for i in range(2, len(command)): cmd = cmd + '\n' + command[i] out, error = procId.communicate(cmd) ''' executing commands sequentially in adb shell procId.communicate method will return tuple-(output,error) out variable will have output of executed commands error variable will have error message ''' #If you want to display the output on screen then uncomment the following line logger.info("Command output : " + str(out)) except Exception as e: #If any error comes while executing command, add it to StatusResult() and return Result() result.CmdResult.AddResult('Exception Occurred @ ' + str(command) + str(e)) result.Status.AddError('Exception Occurred @ ' + str(command) + str(e)) return result if out is None: #If no output is received then add result as no output received and return result object result.CmdResult.AddResult('No output received') return result else: #If result variable is not None then add that output in results and return result object result.CmdResult.AddResult(out) return result
def SetUsbConnection(enable): """ #------------------------------------------------------------------------------------------------------------------- # Name: SetUsbConnection # Input: Takes argument : # enable: true / false # Description: Enables/Disables the USB Connection on Kratos #------------------------------------------------------------------------------------------------------------------- """ logger.info("Setting USB Connection to : " + enable) methodString = enable while (True): result = QcUsbSwitch.SendCommandAndGetResponse(methodString) if not result.Status.HasError(): break return result
def StartMeasurement(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: StartMeasurement # Input: Takes no argument # Description: Starts power measurement on KRATOS # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ logger.info('KRATOS : Starting measurement') # SendSwTrigger function is used to send Software trigger to DUT result = self.kratosHandler.SendSwTrigger() if result.HasError(): logger.error("Error in Sending Software Trigger / Starting measurement : " + result.ErrorMessage()) recoveryResult = self.KratosErrorHandler() return recoveryResult return StatusResult.Success()
def UsbOff(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: UsbOff # Input: Takes no argument # Description: Disable USB on KRATOS # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ # Disconnecting the USB by passing argument - false logger.info('KRATOSLITE: USB OFF') result = QcUsbSwitch.SetUsbConnection('usb_off') if result.Status.HasError(): logger.error("Error in Turning OFF USB : " + result.CmdResult.Output) return result.Status return StatusResult.Success()
def SetPowerConfiguration(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: SetPowerConfiguration # Input: Takes no argument # Description: Sets up power configuration parameters Voltage, Current, OVP # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ logger.info("Setting Voltage, Current & OVP : " + TestSuiteConfig.VoltageLevel + ", " + TestSuiteConfig.CurrentLimit + ", " + TestSuiteConfig.OVPLimit) # ConfigurePowerSupply function is used to configure the Voltage, Current & OVP values on KRATOS result =self.kratosHandler.ConfigurePowerSupply(TestSuiteConfig.VoltageLevel, TestSuiteConfig.CurrentLimit, TestSuiteConfig.OVPLimit) if result.HasError(): logger.error("Error in Configuring Power Supply : " + result.ErrorMessage()) recoveryResult = self.KratosErrorHandler() return recoveryResult return StatusResult.Success()
def StopMeasurement(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: StopMeasurement # Input: Takes no argument # Description: Stops power measurement on KRATOS # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ # StopAcquisition function is used to stop capturing waveforms on KRATOS while the test case runs on DUT logger.info('KRATOS : Stopping measurement') result = self.kratosHandler.StopAcquisition() if result.HasError(): logger.error("Error in Stopping Acquisition : " + result.ErrorMessage()) recoveryResult = self.KratosErrorHandler() return recoveryResult return self.WaitForIdle()
def UsbOn(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: UsbOn # Input: Takes no argument # Description: Enable USB on KRATOS # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ # Connecting the USB by passing argument - True logger.info('KRATOSLITE: USB ON') result = QcUsbSwitch.SetUsbConnection('usb_on') if result.Status.HasError(): logger.error("Error in Turning ON USB : " + result.CmdResult.Output) return result.Status logger.info('Waiting for 10 Seconds for USB to stabilise') time.sleep(10) return StatusResult.Success()
def StartAcquisition(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: StartAcquisition # Input: Takes no argument # Description: Makes KRATOS to start power measurement # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ # StartAcquisition function is used to start capturing waveforms on Kratos while the test case runs on DUT logger.info('KRATOS : Preparing to start measurement') result = self.kratosHandler.StartAcquisition() if result.HasError(): logger.error("Error in Starting Acquisition : " + result.ErrorMessage()) recoveryResult = self.KratosErrorHandler() return recoveryResult return StatusResult.Success()
def UsbOff(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: UsbOff # Input: Takes no argument # Description: Disable USB on KRATOS # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ # Disconnecting the USB by passing argument - false logger.info('KRATOS: USB OFF') result = self.kratosHandler.SetUsbConnection('false') if result.HasError(): logger.error("Error in Turning OFF USB : " + result.ErrorMessage()) recoveryResult = self.KratosErrorHandler() return recoveryResult return StatusResult.Success()
def SetAcquisitionConfiguration(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: SetAcquisitionConfiguration # Input: Takes no argument # Description: Sets up Acquisition configuration parameters AccuracyMode, SampleRate, MeasurementDuration, etc # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ samplingRate = TestCaseConfig.SampleRate if (TestCaseConfig.SampleRate != '') else TestSuiteConfig.SampleRate logger.info("Configuring Acquisition Parameters : " + TestSuiteConfig.AccuracyMode + ", " + samplingRate + ", " + str(TestCaseConfig.MeasurementDuration) + ", MANUAL") # SetAcquisitionParameters function is used to configure the parameters AccuracyMode, SampleRate, MeasurementDuration, etc on KRATOS result = self.kratosHandler.SetAcquisitionParameters(TestSuiteConfig.AccuracyMode, samplingRate, str(TestCaseConfig.MeasurementDuration), "MANUAL") if result.HasError(): logger.error("Error in configuring Acquisition Parameters : " + result.ErrorMessage()) recoveryResult = self.KratosErrorHandler() return recoveryResult return StatusResult.Success()
def RemoveWaveforms(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: RemoveWaveforms # Input: Takes no argument # Description: Removes the UDAS waveform logs location within the Kratos PC # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ logger.info("Removing waveform Directory : " + self.logsPath + " from Kratos PC") try: files = os.listdir(self.logsPath) for file in files: os.remove(os.path.join(self.logsPath, file)) except Exception as e: return StatusResult.Error('Failed to remove waveform directory from Kratos PC', str(e)) logger.info("Removing waveform directory from Kratos PC Completed") return StatusResult.Success()
def PowerOff(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: PowerOff # Input: Takes no argument # Description: Power Off KRATOS card # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ # SetPowerSupplyOutput function is used to turn on/off the power supply on device under test. True to turn on, False to turn off the device. # Powering OFF the device by passing argument - false logger.info('KRATOS: POWER OFF') result =self.kratosHandler.SetPowerSupplyOutput('false') if result.HasError(): logger.error("Error in Powering OFF Device : " + result.ErrorMessage()) recoveryResult = self.KratosErrorHandler() return recoveryResult return StatusResult.Success()
def CopyUdasLogs(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: CopyUdasLogs # Input: Takes no argument # Description: Copy UDAS waveform from Default location to Logs location # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ logger.info("UDAS Directory : " + self.udasDir) logger.info("Copying UDAS waveform from Default location to Logs location") try : os.makedirs(self.udasDir) except OSError : if not os.path.exists(self.udasDir) : return StatusResult.Error("Error in creating UDAS Directory on Automation PC : " + self.udasDir) try: files = os.listdir(self.logsPath) for file in files: shutil.copy(os.path.join(self.logsPath, file), os.path.join(self.udasDir, file)) except Exception as e: return StatusResult.Error('Failed to copy UDAS waveform : ', str(e)) logger.info("Copying UDAS waveform Completed") return StatusResult.Success()
def GetPlotStatistics(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: GetPlotStatistics # Input: Takes no argument # Description: Prints measured power number # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ logger.info("Reading Measured Power Numbers") statisticsList = [1,2] result = self.kratosHandler.GetSinglePlotStatistics(statisticsList) if result.HasError(): logger.error("Error in Reading Power Numbers : " + result.CmdResult.Output) recoveryResult = self.KratosErrorHandler() return recoveryResult logger.info("Measured Current : " + statisticsList[0]) logger.info("Measured Voltage : " + statisticsList[1]) TestCasePowerMetrics.MeasuredCurrent = str(statisticsList[0]) TestCasePowerMetrics.AverageVoltage = str(statisticsList[1]) return StatusResult.Success()
def __init__(self, setAcqConfig = True): """ #------------------------------------------------------------------------------------------------------------------- # Name: __init__ # Description: Initializes KratosHandler class object, sets power supply parameters and Acquisition parameters #------------------------------------------------------------------------------------------------------------------- """ self.retryOnErrorCount = 0 if not TestSuiteConfig.KratosIpAddress : result = self.GetKratosIP(TestSuiteConfig.KratosPcName) if result.HasError(): raise Exception(result.ErrorMessage()) self.kratosHandler = KratosHandler(TestSuiteConfig.KratosIpAddress) if setAcqConfig: logger.info( "Connecting to KRATOS Machine") result = self.KratosSetup() if result.HasError(): raise Exception(result.ErrorMessage()) # SetPowerConfiguration function is used to configure the Voltage, Current & OVP values on KRATOS result = self.SetPowerConfiguration() if result.HasError(): raise Exception(result.ErrorMessage()) # SetAcquisitionConfiguration function is used to set Acquisition parameters on KRATOS. result = self.SetAcquisitionConfiguration() if result.HasError(): raise Exception(result.ErrorMessage()) result = self.SetDefaultOptions() if result.HasError(): raise Exception(result.ErrorMessage()) self.udasDir = TestCaseConfig.ReportsPath + '\\UDAS'
def UsbOn(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: UsbOn # Input: Takes no argument # Description: Enable USB on KRATOS # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ # Connecting the USB by passing argument - True logger.info('KRATOS: USB ON') result = self.kratosHandler.SetUsbConnection('true') if result.HasError(): logger.error("Error in Turning ON USB : " + result.ErrorMessage()) recoveryResult = self.KratosErrorHandler() return recoveryResult logger.info('Waiting for 10 Seconds for USB to stabilise') time.sleep(10) return StatusResult.Success()
def GetKratosIP(self, name): """ #------------------------------------------------------------------------------------------------------------------- # Name: GetKratosIP # Input: Takes one argument # name : KRATOS host name # Description: Gets KRATOS IP address from KRATOS host name # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ if (name is "") or ('kratos' not in name.lower()): return StatusResult.Error('KRATOS error: ', ' Incorrect KRATOS name') try: ipAddress = socket.gethostbyname(name) except Exception as e: logger.error('KRATOS : Failed to get KRATOS IP address') return StatusResult.Error(str(e)) TestSuiteConfig.KratosIpAddress = str(ipAddress) logger.info('KRATOS : ' + 'Name - ' + name + ', IP address - ' + TestSuiteConfig.KratosIpAddress) return StatusResult.Success()
def SetConfigurationFile(self, configFile): """ #------------------------------------------------------------------------------------------------------------------- # Name: SetConfigurationFile # Input: Takes one argument # configFile: UDAS configuration file path for KRATOS # Description: Sets up channel configuration for KRATOS # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ logger.info("Loading KRATOS Channel Configuration : " + configFile) if not configFile.endswith('.udas'): return StatusResult.Error('KRATOS : ', 'Incorrect Configuration file for KRATOS, UDAS file needed') result =self.kratosHandler.LoadChannelConfiguration("C:\\rcm\\cfg\\"+ configFile) if result.HasError(): logger.error("Error in Loading Channel Configuration : " + result.ErrorMessage()) recoveryResult = self.KratosErrorHandler() return recoveryResult return StatusResult.Success()
def OutPutAllreceivedInfo2Log(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: OutPutAllreceivedInfo # Input: Takes one argument, calling object of CommandLineResult # Description: Prints all string lines from OutputLines to logger output #------------------------------------------------------------------------------------------------------------------- """ logger.info("==========Here Are All Log Info (Head)==========") for line in self.OutputLines: logger.info(line.strip(' \t\n\r')) logger.info("==========Here Are All Log Info (End)==========")
def SingleCycleTest(self, para): """ TODO :return: """ if para.CPU_power_f not in self.power_core_avail_freq or para.CPU_perf_f not in self.perf_core_avail_freq or para.CPU_super_f not in self.super_core_avail_freq: logger.info("ERROR Frequency, please give new one:", para.CPU_power_f, para.CPU_perf_f, para.CPU_super_f, para.CPU_coremask) exit() self.set_frequency_all(para.CPU_power_f, para.CPU_super_f, para.CPU_perf_f, para.CPU_coremask) self.set_core(para.CPU_coremask) if self.get_core_status() is not para.CPU_coremask: logger.info("setting online : " + self.get_core_status() + "To : " + para.CPU_coremask) self.remove_log() self.run_log(para.log_ctlog_time) self.run_dhry(para.Dhry_loop, para.Dhry_thread, para.Dhry_delay, para) TestLogFolder = os.path.join(TestSuiteConfig.ReportsPath, "Interation" + str(para.flag)) logger.info("Create test log folder %s" % TestLogFolder) if not os.path.exists(TestLogFolder): os.mkdir(TestLogFolder) para.TestCaseFolder = os.path.join(TestSuiteConfig.ReportsPath, "Interation" + str(para.flag), para.case_name) logger.info("Create test report folder %s" % para.TestCaseFolder) if not os.path.exists(para.TestCaseFolder): os.mkdir(para.TestCaseFolder) self.PowerHandler.start_measure(TestCaseConfig.MeasurementDuration, para.case_name, para.TestCaseFolder) self.collect_log(para.TestCaseFolder) self.target_dir = self.collect_log(para.TestCaseFolder) self.remove_log()
def GetCalibrationStatus(self, calStatusList): """ #------------------------------------------------------------------------------------------------------------------- # Name: GetCalibrationStatus # Input: Takes one argument, calStatusList # calStatusList : empty list, to return Calibration Status # Description: Stops power measurement on KRATOS # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ result = self.kratosHandler.CheckCalibrationStatus(calStatusList) if result.HasError() : logger.error("Error in checking KRATOS calibration status : " + result.ErrorMessage()) recoveryResult = self.KratosErrorHandler() return recoveryResult logger.info("Self Calibration : " + calStatusList[0]) logger.info("DMM Calibration : " + calStatusList[1]) logger.info("MUX Calibration : " + calStatusList[2]) return StatusResult.Success()
def target_case_test(self, para): logger.info( "-----------------Start %d st interation for dhrystone testing, current freq is %s------------------------" % (self.Interation, para.case_name)) Maxretry = 3 while (Maxretry): self.SingleCycleTest(para) if TestSuiteConfig.KratosErrorHandler == True: logger.warning( "There is exception about kratos handler, will re-test this case!" ) logger.info("Current retry time is %d" % (4 - Maxretry)) self.InitEnvironmnet() TestSuiteConfig.KratosErrorHandler = False Maxretry = Maxretry - 1 continue else: break logger.info( "-----------------End %d st interation for dhrystone testing, current freq is %s------------------------" % (self.Interation, para.case_name)) self.Interation = self.Interation + 1
def AnalyzingPowerResult(self, para): cmdResult = CommandLine.RunCommand( CommonApplicationUtilities._ToolsPath + "UDASDataAnalysis\\UDASDataAnalysis.exe VBAT 1 " + str(int(13 * 10**9)) + "-" + str(int(15 * 10**9)) + " " + os.path.join(para.TestCaseFolder.replace('/', '\\'), "UDAS"), 600, True) logger.info(cmdResult.CmdResult.Output) if "Error" in cmdResult.CmdResult.Output: logger.error("Fail to analyze power data: " + cmdResult.CmdResult.Output) else: cmdResult.CmdResult.OutputLines = [ x for x in cmdResult.CmdResult.OutputLines if x != '' ] plane_current_avg = cmdResult.CmdResult.OutputLines[0].split( '-')[0].split(',')[0] # plane_current_min = cmdResult.CmdResult.OutputLines[0].split('-')[0].split(',')[1] # plane_current_max = cmdResult.CmdResult.OutputLines[0].split('-')[0].split(',')[2] logger.info("I_Avg, I_Min, I_Max, V_Avg, V_Min, V_Max") logger.info(plane_current_avg) return plane_current_avg
def InitEnvironmnet(self): if 'KratosLite' in TestSuiteConfig.HardwareType: try: #self.PowerHandler = KratosLite() self.PowerHandler = PTTKratoslite() result = self.PowerHandler.SetConfigurationFile( TestSuiteConfig.ChannelConfiguration) # if result.HasError(): # return result result = self.PowerHandler.PowerOn() result = self.PowerHandler.UsbOn() result = Adb.IsDeviceDetected() if result.HasError(): logger.info("set usb on again") QcUsbSwitch.SetUsbConnection('usb_on') result = Adb.IsDeviceDetected() logger.info("second time: " + str(result.IsSuccess())) else: logger.info("first time: " + str(result.IsSuccess())) result = Adb.SetAdbRoot() if result.HasError(): return result result = Adb.SetAdbRemount() if result.HasError(): return result except Exception as e: return StatusResult.Error('Failed to initialize KRATOSLITE: ', str(e)) elif 'Kratos' in TestSuiteConfig.HardwareType: logger.info("----------supply with Kratos--------------") try: #self.PowerHandler = Kratos() self.PowerHandler = PTTKratos() result = self.PowerHandler.SetConfigurationFile( TestSuiteConfig.ChannelConfiguration) # if result.HasError(): # return result result = self.PowerHandler.PowerOn() result = self.PowerHandler.UsbOn() except Exception as e: logger.info(str(e)) return StatusResult.Error('Failed to initialize KRATOS: ', str(e)) elif 'Monitor' in TestSuiteConfig.HardwareType: try: self.PowerHandler = PTTPowerMonitor() except Exception as e: logger.info(str(e)) return StatusResult.Error( 'Failed to initialize PowerMonitor: ', str(e)) else: logger.error( "Can't support hardware type, please check TestSuiteConfig.HardwareType" ) return logger.info(TestSuiteConfig.HardwareType + " : initialization successful.") logger.info("Waiting for device ...") result = Adb.WaitForDevice(30) logger.info("wait for device ready...") result = AdbSettings.ReMountDevice() if result.HasError(): logger.error("Unable to set root & remount privileges") self.Wakelock() self.Discharging() logger.info("Disable charging & Enable wakelock")