def write_edid(swcregconf, scalercode, edidfile, qd): edid = swcregconf.qdcode2edid(scalercode) log.logger.info("The new edid is:" + edid) edidobj = switchconfig.SwitchConfigOperation(edidfile, 0) block0 = edidobj.getEdid(edid, '0') block1 = edidobj.getEdid(edid, '1') # 4.2 write edid: qd.write_edid_block('0', str(block0)) qd.write_edid_block('1', str(block1)) # 4.3 apply edid qd.apply_edid()
def execute_test(cmdoptions, cmdargs): """ Execute the test; :param cmdoptions: :param cmdargs: :return: """ print("Your Test will be start after 3 seconds, please wait...") process() #Get config from the data sheet: config_d = switchconfig.SwitchConfigOperation(SWITCHCONFIG, 1).load_config() log.logger.info(config_d) filename = config_d['ConfigFilePath'] edidfile = config_d['EdidFilePath'] log.logger.info(cmdoptions) tn = telnet.TelnetApp(config_d['MasterIP'],config_d['MasterUsername'],config_d['MasterPassword']) log.logger.info("switch_ip:"+config_d['SwitchIP']+"switch_username:"******"Switch_pwd:" \ +config_d['SwitchPassword']) tnswitch = telnet.TelnetApp(config_d['SwitchIP'],config_d['SwitchUsername'],config_d['SwitchPassword']) swcregconf = switchconfig.SwitchConfigOperation(filename, 0) qd = qdoperation.Quantum780Operation() #inportlist = {'HDMI1':'1','HDMI2':'2'] inportdic = init_port(config_d['InputPortType']) log.logger.info("The input port type is:%s."% inportdic) #outportlist = ['HDMI1':'1','HDMI2':'2'} outportdic = init_port(config_d['OutputPortType']) log.logger.info("The output port type is:%s."% outportdic) #Test Step: #Initialize QD generator log.logger.info("Start initialize Quantum Data!") qd.sent_qd_generator('1080p60', cmdoptions.patternname, \ cmdoptions.colorspace, \ cmdoptions.deepcolor, \ cmdoptions.outport, \ cmdoptions.hdcp) #Initialize SUT default input and output log.logger.info("Start initialize DUT in/out port!") cmd_dut = ''.join('ci' + inportdic['HDMI1'] + 'o' + outportdic['HDMI1']) cmd_sw = ''.join('ci'+outportdic['HDMI1']+'oall') tn.send_thor_cmd(config_d['SutDPS'], cmd_dut) tnswitch.send_thor_cmd(config_d['SwitchDPS'], cmd_sw) log.logger.info("Testing begin...") repetitions = int(cmdoptions.repetitions) log.logger.info("The inputlist is %s" % get_inputlist(swcregconf, cmdoptions.timing)) while(repetitions): #execute repetions for qdcode in get_inputlist(swcregconf, cmdoptions.timing): log.logger.info("The current input timing is %s" % qdcode) #Set input timing qd.sent_qd_generator(qdcode) #Check the input timing check_input_timing(qd,qdcode,swcregconf) #Set Dut switch paraeters, paser "--random"; if cmdoptions.random != None: time.sleep(cmdoptions.interval) cmd_dut,cmd_sw = rand_switch_port(cmdoptions.random, inportdic, outportdic ) log.logger.info("Switch the DUT port is: %s" % cmd_dut) tn.send_thor_cmd(config_d['SutDPS'], cmd_dut) log.logger.info("Switch the Switch port is: %s" % cmd_sw) tnswitch.send_thor_cmd(config_d['SwitchDPS'], cmd_sw) #If bypass, Yes:dectected;Not:set output timing if 'bypass' == cmdoptions.scaletiming: log.logger.info("The scaler mode is %s" % cmdoptions.scaletiming) #Set DUT output: bypass; tn.send_thor_cmd(config_d['SutDPS'],'VIDOUT_SCALE-BYPASS') #Set QD input port log.logger.info("Set QD analyze port!") qd.set_input_signal(0) #HDMI #Check the output check_output_timing(qd,qdcode,swcregconf) elif 'all'== cmdoptions.scaletiming or 'random'==cmdoptions.scaletiming: log.logger.info("The scaler mode is %s" % cmdoptions.scaletiming) for scalercode in get_outputlist(swcregconf, cmdoptions.scaletiming): #"for" set aspect Ratio log.logger.info("Set Scaler Out timing to %s!" % scalercode) # set scaler to auto tn.send_thor_cmd(config_d['SutDPS'], 'vidout_scale-auto') # set qd input port log.logger.info("Set QD analyze port!") qd.set_input_signal(0) #input hdmi # write edid write_edid(swcregconf, scalercode, edidfile, qd) # check output paras check_output_timing(qd,scalercode,swcregconf) else: log.logger.info("The scaler mode is %s" % cmdoptions.scaletiming) log.logger.info("Set Scaler Out timing to %s!" % cmdoptions.scaletiming) scalercode = cmdoptions.scaletiming # set scaler to manual tn.send_thor_cmd(config_d['SutDPS'], 'vidout_scale-manual') # set scaler output timing code = swcregconf.getTimingExpect(scalercode) #write edid to sink #write_edid(swcregconf, scalercode, edidfile, qd) #VIDOUT_RES_REF cmd=''.join('VIDOUT_RES_REF-'+code['HRES']+'x'+code['VRES']+','+str(int(float(code['VRAT'])))) log.logger.info("The manual scaler timing out is %s" % cmd) tn.send_thor_cmd(config_d['SutDPS'], cmd) #Check output paras check_output_timing(qd,scalercode,swcregconf) repetitions = repetitions-1 log.logger.info("Test Completed!")
def execute_test(cmdoptions, cmdargs): """ Execute the test; :param cmdoptions: :param cmdargs: :return: """ global INPCOUNT, OUTPCOUNT, INFCOUNT, OUTFCOUNT, TESTPARAS, outport, outporttype print("Your Test will be start after 3 seconds, please wait...") loadProcess() #Get config from the data sheet: config_d = switchconfig.SwitchConfigOperation(SWITCHCONFIG, 1).load_config() log.logger.info(config_d) filename = config_d['ConfigFilePath'] edidfile = config_d['EdidFilePath'] log.logger.info(cmdoptions) tn = telnet.TelnetApp(config_d['MasterIP'], config_d['MasterUsername'], config_d['MasterPassword']) log.logger.info("switch_ip:"+config_d['SwitchIP']+"switch_username:"******"Switch_pwd:" \ +config_d['SwitchPassword']) swcregconf = switchconfig.SwitchConfigOperation(filename, 0) swcolorconfig = switchconfig.SwitchConfigOperation(filename, 2) qd = qdoperation.Quantum780Operation() inportdic = initPort(config_d['InputPortType']) log.logger.info("The input port type is:%s." % inportdic) outportdic = initPort(config_d['OutputPortType']) log.logger.info("The output port type is:%s." % outportdic) # initialize the port; outport = config_d['SutDPS'].split(":")[1] #Test Step: #Ignore HDMI proctocal test parametres; if cmdoptions.ignore != "None": qd.TESTPARAS.remove(cmdoptions.ignore) swcregconf.TESTPARAS.remove(cmdoptions.ignore) #Initialize QD generator, default:1080p log.logger.info("Start initialize Quantum Data!") qd.sent_qd_generator('1080p60', cmdoptions.patternname, \ cmdoptions.colorspace, \ cmdoptions.deepcolor, \ cmdoptions.outport, \ cmdoptions.hdcp) #Initialize SUT default input and output log.logger.info("Start initialize DUT in/out port!") inport = inportdic['HDMI1'] inporttype = 'HDMI1' outport = outportdic['HDMI1'] outporttype = 'HDMI1' cmd_dut = ''.join('ci' + inportdic['HDMI1'] + 'o' + outportdic['HDMI1']) # Set Switch output switchport = "".join(re.findall(r"\d", outporttype)) cmd_sw = ''.join('ci' + switchport + 'oall') tn.send_thor_cmd(config_d['SutDPS'], cmd_dut) tn.send_thor_cmd(config_d['SwitchDPS'], cmd_sw) log.logger.info("Hey,Testing Start......") repetitions = int(cmdoptions.repetitions) ar = cmdoptions.aspectratio incolor = cmdoptions.colorspace outcolor = cmdoptions.outcolorspace aspectratio = cmdoptions.aspectratio # Execute repetions while (repetitions): for qdcode in getTimingList(swcregconf, cmdoptions.timing, 37): log.logger.info("The current input timing is %s" % qdcode) # Get the input code to get h,v incode = swcregconf.getTimingExpect(qdcode) #Set input timing qd.sent_qd_generator(qdcode) #If input skip protocal test if 'protocal' == cmdoptions.skip: pass else: #Check the input timing only if checkTiming(qd, qdcode, swcregconf, 'input'): INPCOUNT = INPCOUNT + 1 else: INFCOUNT = INFCOUNT + 1 #Set Dut switch paraeters, paser "--random"; if cmdoptions.random != None: time.sleep(int(cmdoptions.interval)) cmd_dut, cmd_sw, outport, outporttype, inporttype = randSwitchPort( cmdoptions.random, inportdic, outportdic) log.logger.info("The input port is %s" % inporttype) log.logger.info("The output port is %s" % outporttype) #Check if input port support HDBT Big 4K if isHdbtSupport(cmdoptions, qdcode, inporttype): pass else: continue #input support log.logger.info("Switch the DUT port is: %s" % cmd_dut) tn.send_thor_cmd(config_d['SutDPS'], cmd_dut) log.logger.info("Switch the Switch port is: %s" % cmd_sw) tn.send_thor_cmd(config_d['SwitchDPS'], cmd_sw) #If bypass, Yes:dectected;Not:set output timing if 'bypass' == cmdoptions.scaletiming: log.logger.info("The scaler mode is %s" % cmdoptions.scaletiming) #Set DUT output: bypass;Set port to output if cmdoptions.random != 'None': newdps = config_d['SutDPS'].replace( ":1:", ":" + outport + ":") log.logger.info("The new SUT DPS is %s" % newdps) tn.send_thor_cmd(newdps, 'VIDOUT_SCALE-BYPASS') else: tn.send_thor_cmd(config_d['SutDPS'], 'VIDOUT_SCALE-BYPASS') #Set QD input port log.logger.info("Set QD analyze port!") setQdInputport(qd, outporttype) # HDBT can not support 4096x2160@50/60 YCbCr/RGB input or output if isHdbtSupport(cmdoptions, qdcode, outporttype): pass else: continue #If output skip protocal/pattern test if 'protocal' == cmdoptions.skip: #check bypass pattern pixelcount = qd.query_pixelErrCount(100) if pixelcount: print("Bypass no pixel error, pass") else: print("Bypass has %s pixel error!" % pixelcount) elif 'pattern' == cmdoptions.skip: #Check the output if checkTiming(qd, qdcode, swcregconf, 'output'): OUTPCOUNT = OUTPCOUNT + 1 else: OUTFCOUNT = OUTFCOUNT + 1 else: #Check the output if checkTiming(qd, qdcode, swcregconf, 'output'): OUTPCOUNT = OUTPCOUNT + 1 else: OUTFCOUNT = OUTFCOUNT + 1 #check bypass pattern pixelcount = qd.query_pixelErrCount(100) if pixelcount: print("Bypass no pixel error, pass") else: print("Bypass has %s pixel error!" % pixelcount) elif 'auto' == cmdoptions.scaletiming: #or 'random'==cmdoptions.scaletiming: log.logger.info("The scaler mode is %s" % cmdoptions.scaletiming) for scalercode in getTimingList(swcregconf, cmdoptions.scaletiming, 38): #HDBT can not support 4096x2160@50/60 YCbCr/RGB input or output if isHdbtSupport(cmdoptions, scalercode, outporttype): pass else: continue log.logger.info("Set Scaler Out timing to %s!" % scalercode) # set scaler to auto if cmdoptions.random != 'None': newdps = config_d['SutDPS'].replace( ":1:", ":" + outport + ":") log.logger.info("The new SUT DPS is %s" % newdps) tn.send_thor_cmd(newdps, 'vidout_scale-auto') else: newdps = config_d['SutDPS'] tn.send_thor_cmd(newdps, 'vidout_scale-auto') #"for" set aspect Ratio arcmd = 'vidout_aspect_ratio-' + ar tn.send_thor_cmd(newdps, arcmd) log.logger.info("Set aspectratio to %s !" % ar) #set output colorspace cscmd = 'vidout_color_space-' + outcolor tn.send_thor_cmd(newdps, cscmd) log.logger.info("Set output colorspace to %s !" % outcolor) #get the output timing code to get h,v; outcode = swcregconf.getTimingExpect(scalercode) # set qd input port log.logger.info("Set QD analyze port!") setQdInputport(qd, outporttype) # write edid writeEdid(swcregconf, scalercode, edidfile, qd) # if output skip protocal test if 'protocal' == cmdoptions.skip: # check pattern #checkPattern(qd, incode, outcode, swcregconf, ar, colorspace, swcolorconfig) checkPattern(qd, qdcode, scalercode, incode, outcode, aspectratio, incolor, outcolor, swcolorconfig, colorimetry='auto') elif 'pattern' == cmdoptions.skip: # check output paras if checkTiming(qd, scalercode, swcregconf, 'output'): OUTPCOUNT = OUTPCOUNT + 1 else: OUTFCOUNT = OUTFCOUNT + 1 else: # check output paras if checkTiming(qd, scalercode, swcregconf, 'output'): OUTPCOUNT = OUTPCOUNT + 1 else: OUTFCOUNT = OUTFCOUNT + 1 # check pattern #checkPattern(qd, incode, outcode, swcregconf, ar, colorspace, swcolorconfig) checkPattern(qd, qdcode, scalercode, incode, outcode, aspectratio, incolor, outcolor, swcolorconfig, colorimetry='auto') else: log.logger.info("The scaler mode is %s" % cmdoptions.scaletiming) #scalercode = cmdoptions.scaletiming for scalercode in getTimingList(swcregconf, cmdoptions.scaletiming, 38): # HDBT can not support 4096x2160@50/60 YCbCr/RGB input or output if isHdbtSupport(cmdoptions, scalercode, outporttype): pass else: continue log.logger.info("Set Scaler Out timing to %s!" % scalercode) # set scaler to manual if cmdoptions.random != 'None': #config_d['SutDPS'] = config_d['SutDPS'].replace(":1:", ":" + outport + ":") need know why not? newdps = config_d['SutDPS'].replace( ":1:", ":" + outport + ":") log.logger.info("The new SUT DPS is %s" % newdps) #tn.send_thor_cmd(config_d['SutDPS'], 'vidout_scale-manual') tn.send_thor_cmd(newdps, 'vidout_scale-manual') else: newdps = config_d['SutDPS'] tn.send_thor_cmd(newdps, 'vidout_scale-manual') #"for" set aspect Ratio arcmd = 'vidout_aspect_ratio-' + ar tn.send_thor_cmd(newdps, arcmd) log.logger.info("Set aspectratio to %s !" % ar) #set output colorspac cscmd = 'vidout_color_space-' + outcolor tn.send_thor_cmd(newdps, cscmd) log.logger.info("Set output colorspace to %s !" % outcolor) # set scaler output timing outcode = swcregconf.getTimingExpect(scalercode) #write edid to sink #writeEdid(swcregconf, scalercode, edidfile, qd) #VIDOUT_RES_REF cmd = ''.join('VIDOUT_RES_REF-' + outcode['HRES'] + 'x' + outcode['VRES'] + ',' + str(round(float(outcode['VRAT'])))) log.logger.info("The manual scaler timing out is %s" % cmd) tn.send_thor_cmd(newdps, cmd) #Set QD input port log.logger.info("Set QD analyze port!") setQdInputport(qd, outporttype) # if output skip protocal test if 'protocal' == cmdoptions.skip: # check pattern #checkPattern(qd, incode, outcode, swcregconf, ar, colorspace, swcolorconfig) checkPattern(qd, qdcode, scalercode, incode, outcode, aspectratio, incolor, outcolor, swcolorconfig, colorimetry='auto') elif 'pattern' == cmdoptions.skip: # check output paras if checkTiming(qd, scalercode, swcregconf, 'output'): OUTPCOUNT = OUTPCOUNT + 1 else: OUTFCOUNT = OUTFCOUNT + 1 else: # check output paras if checkTiming(qd, scalercode, swcregconf, 'output'): OUTPCOUNT = OUTPCOUNT + 1 else: OUTFCOUNT = OUTFCOUNT + 1 # check pattern #checkPattern(qd, incode, outcode, swcregconf, ar, colorspace, swcolorconfig) checkPattern(qd, qdcode, scalercode, incode, outcode, aspectratio, incolor, outcolor, swcolorconfig, colorimetry='auto') repetitions = repetitions - 1 #Calculate all test result log.logger.info("OK,All Test Completed! Total: "+str(INPCOUNT+INFCOUNT+OUTPCOUNT+OUTFCOUNT)+" cases, "\ +str(INPCOUNT+OUTPCOUNT)+" was PASS, " +str(INFCOUNT+OUTFCOUNT)+" was FAIL!") log.logger.info("INPUT RESULT:"+str(INPCOUNT)+" is PASS, "+str(INFCOUNT)+" is FAIL. "\ "OUTPUT RESULT:"+str(OUTPCOUNT)+" is PASS, "+str(OUTFCOUNT)+" is FAIL")
def executeTest(cmdoptions, cmdargs): """ Execute the test; :param cmdoptions: :param cmdargs: :return: """ global INPCOUNT, OUTPCOUNT, INFCOUNT, OUTFCOUNT, PATPCOUNT, PATFCOUNT, TESTPARAS, outport, outporttype print("Your Test will be start after 3 seconds, please wait...") loadProcess() starttime = time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime()) time1 = datetime.now() #Get config vars from the data sheet: config_d = switchconfig.SwitchConfigOperation(SWITCHCONFIG, 1).load_config() log.logger.info(config_d) filename = BASEDIR + "\\" + config_d['ConfigFilePath'] edidfile = BASEDIR + "\\" + config_d['EdidFilePath'] log.logger.info(cmdoptions) tn = telnet.TelnetApp(config_d['MasterIP'], config_d['MasterUsername'], config_d['MasterPassword']) log.logger.info("switch_ip:"+config_d['SwitchIP']+"switch_username:"******"Switch_pwd:" \ +config_d['SwitchPassword']) swcregconf = switchconfig.SwitchConfigOperation(filename, 0) swcolorconfig = switchconfig.SwitchConfigOperation(filename, 2) #qd = qdoperation.Quantum780Operation() inportdic = initPort(config_d['InputPortType']) log.logger.info("The input port type is:%s." % inportdic) outportdic = initPort(config_d['OutputPortType']) log.logger.info("The output port type is:%s." % outportdic) repetitions = int(cmdoptions.repetitions) ar = cmdoptions.aspectratio incolor = cmdoptions.colorspace outcolor = cmdoptions.outcolorspace if 'YCbCr444' == outcolor: outputcolor = 'YUV444' else: outputcolor = outcolor aspectratio = cmdoptions.aspectratio hdcpout = cmdoptions.hdcpout hdcpin = cmdoptions.hdcpin hdcpdut = cmdoptions.hdcpdut # initialize the port; outport = config_d['SutDPS'].split(":")[1] #Test Step: #Ignore HDMI proctocal test parametres; if cmdoptions.ignore != "None": #qd.TESTPARAS.remove(cmdoptions.ignore) swcregconf.TESTPARAS.remove(cmdoptions.ignore) #Initialize QD generator, default:1080p log.logger.info("Start initialize Quantum Data!") # qd.sent_qd_generator('1080p60', cmdoptions.patternname, \ # cmdoptions.colorspace, \ # cmdoptions.deepcolor, \ # cmdoptions.outport, \ # cmdoptions.hdcpout) #qd.switch_hpformats('0') #disable hotplug formats #Initialize SUT default input and output log.logger.info("Start initialize DUT in/out port!") inport = inportdic['HDMI1'] inporttype = 'HDMI1' outport = outportdic['HDMI1'] outporttype = 'HDMI1' cmd_dut = ''.join('ci' + inportdic['HDMI1'] + 'o' + outportdic['HDMI1']) # Set Switch output switchport = "".join(re.findall(r"\d", outporttype)) cmd_sw = ''.join('ci' + switchport + 'oall') tn.send_thor_cmd(config_d['SutDPS'], cmd_dut) tn.send_thor_cmd(config_d['SwitchDPS'], cmd_sw) # Initial RX HDCP to follow tn.send_thor_cmd(config_d['SutDPS'], 'VIDOUT_HDCP-FOLLOW') log.logger.info("Hey,Testing Start......") # Execute repetions while (repetitions): # for qdcode in getTimingList(swcregconf, cmdoptions.timing, 37): # log.logger.info("The current input timing is %s" % qdcode) # # Get the input code to get h,v # incode= swcregconf.getTimingExpect(qdcode) # #Set input timing # qd.sent_qd_generator(qdcode) # #If input skip protocal test # if 'protocal' == cmdoptions.skip: # pass # else: # #Check the input timing only # if checkTiming(qd, qdcode, swcregconf, 'input'): # INPCOUNT = INPCOUNT+1 # else:INFCOUNT = INFCOUNT+1 #Set Dut switch paraeters, paser "--random"; if cmdoptions.random != None: time.sleep(int(cmdoptions.interval)) cmd_dut, cmd_sw, outport, outporttype, inporttype = randSwitchPort( cmdoptions.random, inportdic, outportdic) log.logger.info("The input port is %s" % inporttype) log.logger.info("The output port is %s" % outporttype) # #Check if input port support HDBT Big 4K # if isHdbtSupport(cmdoptions, qdcode, inporttype): # pass # else: # continue #input support log.logger.info("Switch the DUT port is: %s" % cmd_dut) tn.send_thor_cmd(config_d['SutDPS'], cmd_dut) log.logger.info("Switch the Switch port is: %s" % cmd_sw) tn.send_thor_cmd(config_d['SwitchDPS'], cmd_sw) # Config hdcp, if duthdcp was not follow, then execute hdcpdut, or hdcpin if hdcpdut != 'follow': #log.logger.info("Set The DUT HDCP to %s" % hdcpdut) if 'None' == hdcpdut: #configHDCP(qd, "None") log.logger.info("Set The DUT HDCP to %s" % hdcpdut) tn.send_thor_cmd(config_d['SutDPS'], 'VIDOUT_HDCP-NO HDCP') #qd.hdcp_generator("0") elif '14' == hdcpdut: #configHDCP(qd, "14") log.logger.info("Set The DUT HDCP to %s" % hdcpdut) tn.send_thor_cmd(config_d['SutDPS'], 'VIDOUT_HDCP-HDCP1.4') #qd.hdcp_generator("1") elif '22' == hdcpdut: #configHDCP(qd, "22") log.logger.info("Set The DUT HDCP to %s" % hdcpdut) tn.send_thor_cmd(config_d['SutDPS'], 'VIDOUT_HDCP-HDCP2.2') #qd.hdcp_generator("2") else: raise ("Unknow hdcp ICSP command parameters!") else: pass #configHDCP(qd, hdcpin) #If bypass, Yes:dectected;Not:set output timing if 'bypass' == cmdoptions.scaletiming: log.logger.info("The bypass scaler mode is %s" % cmdoptions.scaletiming) #Set DUT output: bypass;Set port to output if cmdoptions.random != 'None': newdps = config_d['SutDPS'].replace(":1:", ":" + outport + ":") log.logger.info("The new SUT DPS is %s" % newdps) tn.send_thor_cmd(newdps, 'VIDOUT_SCALE-BYPASS') else: tn.send_thor_cmd(config_d['SutDPS'], 'VIDOUT_SCALE-BYPASS') #Set QD input port # log.logger.info("Set QD analyze port!") # setQdInputport(qd, outporttype) # # HDBT can not support 4096x2160@50/60 YCbCr/RGB input or output # if isHdbtSupport(cmdoptions, qdcode, outporttype): # pass # else: # continue #If output skip protocal/pattern test # if 'protocal' == cmdoptions.skip: # #check bypass pattern # pixelcount = qd.query_pixelErrCount(100) # if '0'!= pixelcount: # pixelcount = qd.query_pixelErrCount(100) # if '0' == pixelcount: # PATPCOUNT = PATPCOUNT + 1 # log.logger.info("Bypass no pixel error, PASS") # tcolor.cprint("Bypass Test PASS", 'GREEN') # else: # PATFCOUNT = PATFCOUNT + 1 # log.logger.info("Bypass has %s pixel error, FAIL" % pixelcount) # tcolor.cprint("Bypass Test FAIL", 'RED') # else: # PATPCOUNT = PATPCOUNT + 1 # log.logger.info("Bypass no pixel error, PASS") # tcolor.cprint("Bypass Test PASS", 'GREEN') # elif 'pattern' == cmdoptions.skip: # #Check the output # if checkTiming(qd, qdcode, swcregconf, 'output'): # OUTPCOUNT = OUTPCOUNT+1 # else:OUTFCOUNT = OUTFCOUNT+1 # else: # #Check the output # if checkTiming(qd, qdcode, swcregconf, 'output'): # OUTPCOUNT = OUTPCOUNT+1 # else:OUTFCOUNT = OUTFCOUNT+1 # #check bypass pattern # pixelcount = qd.query_pixelErrCount(100) # if '0'!= pixelcount: # pixelcount = qd.query_pixelErrCount(100) # if '0' == pixelcount: # PATPCOUNT = PATPCOUNT + 1 # log.logger.info("Bypass no pixel error, PASS") # tcolor.cprint("Bypass Test PASS", 'GREEN') # else: # PATFCOUNT = PATFCOUNT + 1 # log.logger.info("Bypass has %s pixel error, FAIL" % pixelcount) # tcolor.cprint("Bypass Test FAIL", 'RED') # else: # PATPCOUNT = PATPCOUNT + 1 # log.logger.info("Bypass no pixel error, PASS") # tcolor.cprint("Bypass Test PASS", 'GREEN') # elif 'auto'== cmdoptions.scaletiming: #or 'random'==cmdoptions.scaletiming: # log.logger.info("The auto scaler mode is %s" % cmdoptions.scaletiming) # for scalercode in getTimingList(swcregconf, cmdoptions.scaletiming, 38): # #HDBT can not support 4096x2160@50/60 YCbCr/RGB input or output # if isHdbtSupport(cmdoptions, scalercode, outporttype): # pass # else: # continue # log.logger.info("Set Scaler Out timing to %s!" % scalercode) # # set scaler to auto # if cmdoptions.random != 'None': # newdps = config_d['SutDPS'].replace(":1:", ":" + outport + ":") # log.logger.info("The new SUT DPS is %s" % newdps) # tn.send_thor_cmd(newdps, 'vidout_scale-auto') # else: # newdps = config_d['SutDPS'] # tn.send_thor_cmd(newdps, 'vidout_scale-auto') # #"for" set aspect Ratio # arcmd='vidout_aspect_ratio-'+ar # tn.send_thor_cmd(newdps, arcmd) # log.logger.info("Set aspectratio to %s !" % ar) # #set output colorspace # cscmd = 'vidout_color_space-'+outputcolor # tn.send_thor_cmd(newdps, cscmd) # log.logger.info("Set output colorspace to %s !" % outcolor) # #get the output timing code to get h,v; # outcode = swcregconf.getTimingExpect(scalercode) # # set qd input port # log.logger.info("Set QD analyze port!") # setQdInputport(qd, outporttype) # # write edid # writeEdid(swcregconf, scalercode, edidfile, qd) # # if output skip protocal test # if 'protocal' == cmdoptions.skip: # #check pattern # #checkPattern(qd, incode, outcode, swcregconf, ar, colorspace, swcolorconfig) # if checkPattern(qd, qdcode, scalercode, incode, outcode, aspectratio, incolor, outcolor, swcolorconfig, # colorimetry='auto'): # PATPCOUNT=PATPCOUNT+1 # else:PATFCOUNT=PATFCOUNT+1 # elif 'pattern' == cmdoptions.skip: # # check output paras # if checkTiming(qd, scalercode, swcregconf, 'output'): # OUTPCOUNT = OUTPCOUNT + 1 # else: # OUTFCOUNT = OUTFCOUNT + 1 # else: # # check output paras # if checkTiming(qd, scalercode, swcregconf, 'output'): # OUTPCOUNT = OUTPCOUNT + 1 # else: # OUTFCOUNT = OUTFCOUNT + 1 # # check pattern # #checkPattern(qd, incode, outcode, swcregconf, ar, colorspace, swcolorconfig) # if checkPattern(qd, qdcode, scalercode, incode, outcode, aspectratio, incolor, outcolor, swcolorconfig, # colorimetry='auto'): # PATPCOUNT=PATPCOUNT+1 # else:PATFCOUNT=PATFCOUNT+1 else: log.logger.info("The manual scaler mode is %s" % cmdoptions.scaletiming) #scalercode = cmdoptions.scaletiming for scalercode in getTimingList(swcregconf, cmdoptions.scaletiming, 38): # HDBT can not support 4096x2160@50/60 YCbCr/RGB input or output if isHdbtSupport(cmdoptions, scalercode, outporttype): pass else: continue log.logger.info("Set Scaler Out timing to %s!" % scalercode) # set scaler to manual if cmdoptions.random != 'None': #config_d['SutDPS'] = config_d['SutDPS'].replace(":1:", ":" + outport + ":") need know why not? newdps = config_d['SutDPS'].replace( ":1:", ":" + outport + ":") log.logger.info("The new SUT DPS is %s" % newdps) #tn.send_thor_cmd(config_d['SutDPS'], 'vidout_scale-manual') tn.send_thor_cmd(newdps, 'vidout_scale-manual') else: newdps = config_d['SutDPS'] tn.send_thor_cmd(newdps, 'vidout_scale-manual') #"for" set aspect Ratio arcmd = 'vidout_aspect_ratio-' + ar tn.send_thor_cmd(newdps, arcmd) log.logger.info("Set aspectratio to %s !" % ar) #set output colorspac cscmd = 'vidout_color_space-' + outputcolor tn.send_thor_cmd(newdps, cscmd) log.logger.info("Set output colorspace to %s !" % outcolor) # set scaler output timing outcode = swcregconf.getTimingExpect(scalercode) #write edid to sink #writeEdid(swcregconf, scalercode, edidfile, qd) #VIDOUT_RES_REF cmd = ''.join('VIDOUT_RES_REF-' + outcode['HRES'] + 'x' + outcode['VRES'] + ',' + str(round(float(outcode['VRAT'])))) log.logger.info("The manual scaler timing out is %s" % cmd) tn.send_thor_cmd(newdps, cmd) #Set QD input port # log.logger.info("Set QD analyze port!") # setQdInputport(qd, outporttype) # if output skip protocal test # if 'protocal' == cmdoptions.skip: # #check pattern # #checkPattern(qd, incode, outcode, swcregconf, ar, colorspace, swcolorconfig) # if checkPattern(qd, qdcode, scalercode, incode, outcode, aspectratio, incolor, outcolor, swcolorconfig, # colorimetry='auto'): # PATPCOUNT=PATPCOUNT+1 # else:PATFCOUNT=PATFCOUNT+1 # elif 'pattern' == cmdoptions.skip: # # check output paras # if checkTiming(qd, scalercode, swcregconf, 'output'): # OUTPCOUNT = OUTPCOUNT + 1 # else: # OUTFCOUNT = OUTFCOUNT + 1 # else: # # check output paras # if checkTiming(qd, scalercode, swcregconf, 'output'): # OUTPCOUNT = OUTPCOUNT + 1 # else: # OUTFCOUNT = OUTFCOUNT + 1 # # check pattern # #checkPattern(qd, incode, outcode, swcregconf, ar, colorspace, swcolorconfig) # if checkPattern(qd, qdcode, scalercode, incode, outcode, aspectratio, incolor, outcolor, swcolorconfig, # colorimetry='auto'): # PATPCOUNT=PATPCOUNT+1 # else:PATFCOUNT=PATFCOUNT+1 repetitions = repetitions - 1 #Calculate all test result log.logger.info("OK,All Test Completed! Total: %d "%(INPCOUNT+INFCOUNT+OUTPCOUNT+OUTFCOUNT+PATPCOUNT+PATFCOUNT)+" cases, %d"\ %(INPCOUNT+OUTPCOUNT+PATPCOUNT)+" is PASS, %d" %(INFCOUNT+OUTFCOUNT+PATFCOUNT)+" is FAIL!") log.logger.info("INPUT Timing RESULT:%d"%(INPCOUNT)+" is PASS, %d"%(INFCOUNT)+" is FAIL. "\ "OUTPUT Timing RESULT: %d"%(OUTPCOUNT)+" is PASS, %d"%(OUTFCOUNT)+" is FAIL."\ "PATTERN TEST RESULT: %d"%(PATPCOUNT)+" is PASS, %d"%(PATFCOUNT)+" is FAIL.") endtime = time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime()) time2 = datetime.now() duration = calduration(time1, time2) totalnumber = INPCOUNT + INFCOUNT + OUTPCOUNT + OUTFCOUNT + PATPCOUNT + PATFCOUNT passnumber = INPCOUNT + OUTPCOUNT + PATPCOUNT failnumber = INFCOUNT + OUTFCOUNT + PATFCOUNT notrunnumber = totalnumber - passnumber - failnumber # writetoreport(duration:'00:11:03', starttime:'2019-05-30_20-13-05',endtime:'2019-06-02_00-02-33', # total:2(total), passnumber:2(pass), failnumber:0(fail), notrunnumber:0(notrun), hwversion:'V0.2',swversion:'V1.0.1',phase:'EV') return duration, starttime, endtime, totalnumber, passnumber, failnumber, notrunnumber
def main(): global passnumber, failnumber #select case; basedir = (os.path.dirname(os.path.abspath(__file__))) #basedir = "C:\\Simon\\BannekerTest" filename = basedir + "\\TestCaseManagement.xlsx" xmlfile = basedir + "\\log\\" + "tmp.xml" htmlfile = basedir + "\\log\\" + "index.html" sw = switchconfig.SwitchConfigOperation(filename, 0) casecmd_list, casename_list, casenum_list = sw.getCaseInfo(4) caselines = sw.getTestCaseRowNumber(4) #handle history logfile, first copy , then delete os.system('del ' + basedir + "\\Report.xml " + r"/Q") os.system('del ' + basedir + "\\log " + r"/Q") #run case; starttime = time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime()) time1 = datetime.now() for i in range(len(casecmd_list)): os.system(basedir + "\\" + casecmd_list[i] + " " + casenum_list[i]) endtime = time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime()) time2 = datetime.now() duration = calduration(time1, time2) #get the case result; tmplog = basedir + "\\log\\" + "tmp.log" for index, line in enumerate(open(tmplog, 'r')): dicres = loads(line) if dicres['failnumber'] >= 1: #write the result back to excel; sw.setCellValue(caselines[index], 6, "FAIL") sw.saveModify(filename) else: #write the result back to excel; sw.setCellValue(caselines[index], 6, "PASS") sw.saveModify(filename) #compare result expectRes = sw.getTestResult(5) dectetRes = sw.getTestResult(6) for i in range(len(expectRes)): if expectRes[i] != dectetRes[i]: failnumber += 1 else: passnumber += 1 #create report totalnumber = sw.getRowsLenth() - 1 notrunnumber = totalnumber - passnumber - failnumber hwversion = "RXDV3" swversion = "R5.0" phase = "PV" writeobj = write2dashboard.writetoreport(duration, starttime, endtime, totalnumber, passnumber, failnumber, notrunnumber, hwversion, swversion, phase) xmlpath = basedir + "\\log\\Report.xml" writeobj.writeInfoToXml(xmlpath) project = writeobj.output['project'] sku = writeobj.output['sku'] testjob = writeobj.output['testjob'] brand = writeobj.output['brand'] tester = writeobj.output['tester'] logpath = basedir + "\\log" uploadpath = "C:\\JenkinsTestReports\\workspace\\" + project + "\\" + sku + "\\" + testjob + "\\" + starttime createReportXml(filename=xmlfile,brand=brand,project=project,sku=sku,testjob=testjob,duration=duration,starttime=starttime,\ endtime=endtime,testcasecount=totalnumber,pass_count=passnumber,fail_count=failnumber,norun_count=notrunnumber,\ hw_version=hwversion,sw_version=swversion,phase=phase) for idx, row in enumerate(open(tmplog, 'r')): dic_log = loads(row) ##dicres:{"passnumber": 1, "failnumber": 0, "notrunnumber": 0, "duration":00:11:03, "casenum":013}## ##sw.getCellValue of the row## casenum = dic_log['casenum'] casename = sw.getCellValue(caselines[idx], 2) casecmd = sw.getCellValue(caselines[idx], 3) casetot = int( dic_log['failnumber']) + int(dic_log['passnumber'] + int(dic_log['notrunnumber'])) casepass = dic_log['passnumber'] casefail = dic_log['failnumber'] casetime = dic_log['duration'] updateXML(filename=xmlfile, casename=casename, casenum=casenum, casecmd=casecmd,casetot=casetot,\ casepass=casepass,casefail=casefail,casetime=casetime) creatindexhtml(xmlfile, htmlfile) os.system('del ' + basedir + "\\log\\tmp.* " + r"/Q") #delete all tmp files uploadTestResult(logpath, uploadpath) os.system("xcopy /s " + filename + " " + "\"" + uploadpath + "\"")
def executeTest(cmdoptions, cmdargs): """ Execute the test; :param cmdoptions: :param cmdargs: :return: """ global INPCOUNT, OUTPCOUNT,INFCOUNT,OUTFCOUNT, PATPCOUNT, PATFCOUNT, TESTPARAS, outport, outporttype print("Your Test will be start after 3 seconds, please wait...") loadProcess() #Get config vars from the data sheet: config_d = switchconfig.SwitchConfigOperation(SWITCHCONFIG, 1).load_config() log.logger.info(config_d) filename = BASEDIR+"\\"+config_d['ConfigFilePath'] edidfile = BASEDIR+"\\"+config_d['EdidFilePath'] log.logger.info(cmdoptions) tn = telnet.TelnetApp(config_d['MasterIP'],config_d['MasterUsername'],config_d['MasterPassword']) log.logger.info("switch_ip:"+config_d['SwitchIP']+"switch_username:"******"Switch_pwd:" \ +config_d['SwitchPassword']) swcregconf = switchconfig.SwitchConfigOperation(filename, 0) swcolorconfig = switchconfig.SwitchConfigOperation(filename, 2) qd = qdoperation.Quantum780Operation() inportdic = initPort(config_d['InputPortType']) log.logger.info("The input port type is:%s."% inportdic) outportdic = initPort(config_d['OutputPortType']) log.logger.info("The output port type is:%s."% outportdic) repetitions = int(cmdoptions.repetitions) ar = cmdoptions.aspectratio incolor = cmdoptions.colorspace outcolor = cmdoptions.outcolorspace if 'YCbCr444'==outcolor: outputcolor = 'YUV444' else: outputcolor = outcolor aspectratio = cmdoptions.aspectratio patterntest = cmdoptions.patterntest #hdcpout = cmdoptions.hdcpout hdcpin = cmdoptions.hdcpin hdcpdut = cmdoptions.hdcpdut #initialize the port; outport = config_d['SutDPS'].split(":")[1] #Test Step: #Initialize QD generator, default:1080p log.logger.info("Start initialize Quantum Data!") qd.sent_qd_generator('1080p60', cmdoptions.patternname, \ cmdoptions.colorspace, \ cmdoptions.deepcolor, \ cmdoptions.outport, \ cmdoptions.hdcpout) qd.switch_hpformats('0') #disable hotplug formats #Initialize SUT default input and output log.logger.info("Start initialize DUT in/out port!") inport = inportdic['HDMI1'] inporttype = 'HDMI1' outport = outportdic['HDMI1'] outporttype = 'HDMI1' cmd_dut = ''.join('ci' + inportdic['HDMI1'] + 'o' + outportdic['HDMI1']) # Set Switch output switchport = "".join(re.findall(r"\d", outporttype)) cmd_sw = ''.join('ci' + switchport + 'oall') tn.send_thor_cmd(config_d['SutDPS'], cmd_dut) tn.send_thor_cmd(config_d['SwitchDPS'], cmd_sw) # Initial RX HDCP to follow tn.send_thor_cmd(config_d['SutDPS'], 'VIDOUT_HDCP-FOLLOW') log.logger.info("Hey,Testing Start......") # Execute repetions while(repetitions): for qdcode in getTimingList(swcregconf, cmdoptions.timing, 37): log.logger.info("The current input timing is %s" % qdcode) # Get the input code to get h,v incode= swcregconf.getTimingExpect(qdcode) #Set input timing qd.sent_qd_generator(qdcode) #Set Dut switch paraeters, paser "--random"; if cmdoptions.random != None: time.sleep(int(cmdoptions.interval)) cmd_dut,cmd_sw, outport, outporttype, inporttype = randSwitchPort(cmdoptions.random, inportdic, outportdic) log.logger.info("The input port is %s" % inporttype) log.logger.info("The output port is %s" % outporttype) #Check if input port support HDBT Big 4K if isHdbtSupport(cmdoptions, qdcode, inporttype): pass else: continue #input support log.logger.info("Switch the DUT port is: %s" % cmd_dut) tn.send_thor_cmd(config_d['SutDPS'], cmd_dut) log.logger.info("Switch the Switch port is: %s" % cmd_sw) tn.send_thor_cmd(config_d['SwitchDPS'], cmd_sw) # Config hdcp, if duthdcp was not follow, then execute hdcpdut, or hdcpin if hdcpdut != 'follow': if 'None' == hdcpdut: tn.send_thor_cmd(config_d['SutDPS'], 'VIDOUT_HDCP-NO HDCP') elif '14' == hdcpdut: tn.send_thor_cmd(config_d['SutDPS'], 'VIDOUT_HDCP-HDCP1.4') elif '22' == hdcpdut: tn.send_thor_cmd(config_d['SutDPS'], 'VIDOUT_HDCP-HDCP2.2') else: raise ("Unknow hdcp ICSP command parameters!") else: configHDCP(qd, hdcpin) #Set scaler mode if 'auto'== cmdoptions.scaletiming: #or 'random'==cmdoptions.scaletiming: log.logger.info("The auto scaler mode is %s" % cmdoptions.scaletiming) for scalercode in getTimingList(swcregconf, cmdoptions.scaletiming, 38): #HDBT can not support 4096x2160@50/60 YCbCr/RGB input or output if isHdbtSupport(cmdoptions, scalercode, outporttype): pass else: continue log.logger.info("Set Scaler Out timing to %s!" % scalercode) # set scaler to auto if cmdoptions.random != 'None': newdps = config_d['SutDPS'].replace(":1:", ":" + outport + ":") log.logger.info("The new SUT DPS is %s" % newdps) tn.send_thor_cmd(newdps, 'vidout_scale-auto') else: newdps = config_d['SutDPS'] tn.send_thor_cmd(newdps, 'vidout_scale-auto') #Set aspect Ratio arcmd='vidout_aspect_ratio-'+ar tn.send_thor_cmd(newdps, arcmd) log.logger.info("Set aspectratio to %s !" % ar) #set output colorspace cscmd = 'vidout_color_space-'+outputcolor tn.send_thor_cmd(newdps, cscmd) log.logger.info("Set output colorspace to %s !" % outcolor) outcode = swcregconf.getTimingExpect(scalercode) # set qd input port log.logger.info("Set QD analyze port!") setQdInputport(qd, outporttype) # write edid writeEdid(swcregconf, scalercode, edidfile, qd) #check pattern if checkPattern(qd, qdcode, scalercode, incode, outcode, patterntest, incolor, outcolor, swcolorconfig, colorimetry='auto'): PATPCOUNT=PATPCOUNT+1 else:PATFCOUNT=PATFCOUNT+1 else: log.logger.info("The manual scaler mode is %s" % cmdoptions.scaletiming) #scalercode = cmdoptions.scaletiming for scalercode in getTimingList(swcregconf, cmdoptions.scaletiming, 38): # HDBT can not support 4096x2160@50/60 YCbCr/RGB input or output if isHdbtSupport(cmdoptions, scalercode, outporttype): pass else: continue log.logger.info("Set Scaler Out timing to %s!" % scalercode) # set scaler to manual if cmdoptions.random != 'None': #config_d['SutDPS'] = config_d['SutDPS'].replace(":1:", ":" + outport + ":") need know why not? newdps = config_d['SutDPS'].replace(":1:", ":" + outport + ":") log.logger.info("The new SUT DPS is %s" % newdps) #tn.send_thor_cmd(config_d['SutDPS'], 'vidout_scale-manual') tn.send_thor_cmd(newdps, 'vidout_scale-manual') else: newdps = config_d['SutDPS'] tn.send_thor_cmd(newdps, 'vidout_scale-manual') #"for" set aspect Ratio arcmd='vidout_aspect_ratio-'+ar tn.send_thor_cmd(newdps, arcmd) log.logger.info("Set aspectratio to %s !" % ar) #set output colorspac cscmd = 'vidout_color_space-'+outputcolor tn.send_thor_cmd(newdps, cscmd) log.logger.info("Set output colorspace to %s !" % outcolor) # set scaler output timing outcode = swcregconf.getTimingExpect(scalercode) cmd=''.join('VIDOUT_RES_REF-'+outcode['HRES']+'x'+outcode['VRES']+','+str(round(float(outcode['VRAT'])))) log.logger.info("The manual scaler timing out is %s" % cmd) tn.send_thor_cmd(newdps, cmd) #Set pattern test pattern pcmd = 'vidout_testpat-' + patterntest tn.send_thor_cmd(newdps, pcmd) log.logger.info("The %s pattern test!"% patterntest) #Set QD input port log.logger.info("Set QD analyze port!") setQdInputport(qd, outporttype) #Check pattern if checkPattern(qd, qdcode, scalercode, incode, outcode, patterntest, incolor, outcolor, swcolorconfig, colorimetry='auto'): PATPCOUNT=PATPCOUNT+1 else:PATFCOUNT=PATFCOUNT+1 repetitions = repetitions-1 #Calculate all test result log.logger.info("OK,All Test Completed! Total: %d "%(INPCOUNT+INFCOUNT+OUTPCOUNT+OUTFCOUNT+PATPCOUNT+PATFCOUNT)+" cases, %d"\ %(INPCOUNT+OUTPCOUNT+PATPCOUNT)+" is PASS, %d" %(INFCOUNT+OUTFCOUNT+PATFCOUNT)+" is FAIL!") log.logger.info("INPUT Timing RESULT:%d"%(INPCOUNT)+" is PASS, %d"%(INFCOUNT)+" is FAIL. "\ "OUTPUT Timing RESULT: %d"%(OUTPCOUNT)+" is PASS, %d"%(OUTFCOUNT)+" is FAIL."\ "PATTERN TEST RESULT: %d"%(PATPCOUNT)+" is PASS, %d"%(PATFCOUNT)+" is FAIL.") totalnumber = INPCOUNT+INFCOUNT+OUTPCOUNT+OUTFCOUNT+PATPCOUNT+PATFCOUNT passnumber = INPCOUNT+OUTPCOUNT+PATPCOUNT failnumber = INFCOUNT+OUTFCOUNT+PATFCOUNT notrunnumber = totalnumber-passnumber-failnumber return passnumber, failnumber, notrunnumber