def main(): do_CtrlConsole = 1 do_Genconfig = 1 do_PreTest = 0 do_CopyMLFolder = 0 do_Reboot = 0 do_HDMI = 0 do_Full = 1 do_RSSI = 0 do_Temp = 0 do_Result = 0 do_RunStatus = 0 SN = '' # for do_RSSI hdmiStatus = 'FAIL' # for do_Result ResultDirectory = '' # for do_RunStatus RunStatus = 'FAIL' # --------- setting Host environment: begin --------- if do_CtrlConsole: os.system('cls') # --------- setting Host environment: end --------- if len(sys.argv) > 1: SN = str(SetDUTinfo(sys.argv[1], sys.argv[2], sys.argv[3])) #test_file = sys.argv[4] elif do_Genconfig: proc_command = 'python gui_genconfig.py' result = env.subprocess_execute(proc_command, 120).split('\n') # print result for line in result: if line.find('SerialNumber') != -1: report = line.split('SerialNumber: "')[1].replace('\n', '') SN = report.split('"')[0].replace('\n', '').lstrip() break else: SN = str(GetSerialNumber()) ''' if SN == '': env.print_error('>> Please input Serial Number... <<') quit() ''' if do_Full: env.create_result_folder(SN) if do_PreTest: test_item = '0WM_test_lists\\PreTest.yml' proc_command = 'python simple_tester.py {} False'.format(test_item) if do_Reboot: test_item = 'test_lists\\reboot.yml' proc_command = 'python simple_tester.py {}'.format(test_item) env.process_execute(proc_command) if do_HDMI: # HDMI_STATUS="$(cat /sys/class/drm/card0-HDMI-A-1/status)" # connected or disconnected test_item = 'HDMI' proc_command = 'python gui_pass_fail.py {}'.format(test_item) result = env.subprocess_execute(proc_command, 60) ''' if result.strip() == 'PASS': hdmiStatus = 'connected' else: hdmiStatus = 'disconnected' print 'HDMI_STAT={}'.format(hdmiStatus) ''' # current_folder -->> Results if not os.path.exists(env.tester_results_folder): os.makedirs(env.tester_results_folder) result_filename = os.path.join(env.tester_results_folder, 'HDMI_Status.cmd') env.touch(result_filename) with open(result_filename, 'w') as f_output_file: # f_output_file.write('HDMI_STAT={}'.format(hdmiStatus)) f_output_file.write('HDMI_STAT={}'.format(result.strip())) f_output_file.close() if do_RSSI: test_item = 'test_lists\\RSSI.yml' proc_command = 'python simple_tester.py {}'.format(test_item) env.process_execute(proc_command) if do_Temp: test_item = 'test_lists\\temp.yml' proc_command = 'python simple_tester.py {} False'.format(test_item) # --------- update serialnum in file: begin --------- # replace temp.yaml read_sn = None read_sn = str(yml_get_sn(test_item)).strip() if read_sn != 'None' and read_sn != SN: env.print_info("yaml_file: [%s] not match [%s]" % (read_sn, SN)) fileString = open(test_item, 'r').read().replace(read_sn, SN) open(test_item, 'w').write(fileString) # replace criteria_XXX.csv read_sn = None read_sn = str( env.GetItemColumnByCSV(env.criteria_file_full_path, 'RePCBASN', 'VALUE')).strip() if read_sn != 'None' and read_sn != SN: env.print_info("csv_file: [%s] not match [%s]" % (read_sn, SN)) fileString = open(env.criteria_file_full_path, 'r').read().replace(read_sn, SN) open(env.criteria_file_full_path, 'w').write(fileString) # --------- update serialnum in file: end --------- env.system_execute(proc_command) if do_Full: test_item = test_file #'0WM_test_lists\\2.Main Board.yml' proc_command = 'python simple_tester.py {} False'.format(test_item) ''' # --------- update serialnum in file: begin --------- # replace kud_evt_full.yaml read_sn = None read_sn = str( yml_get_sn(test_item) ).strip() if read_sn != 'None' and read_sn != SN: env.print_info( "yaml_file: [%s] not match [%s]" % (read_sn, SN) ) fileString = open(test_item, 'r').read().replace(read_sn, SN) open(test_item, 'w').write(fileString) # replace criteria_XXX.csv read_sn = None read_sn = str( env.GetItemColumnByCSV(env.criteria_file_full_path, 'RePCBASN', 'VALUE') ).strip() if read_sn != 'None' and read_sn != SN: env.print_info( "csv_file: [%s] not match [%s]" % (read_sn, SN) ) fileString = open(env.criteria_file_full_path, 'r').read().replace(read_sn, SN) open(env.criteria_file_full_path, 'w').write(fileString) # --------- update serialnum in file: end --------- ''' loop_time = 3 cnt = 1 while cnt <= loop_time: loop_start_time = time.time() env.print_info( '\n>>>>>>>>>>>>>>>> loop: %d begin <<<<<<<<<<<<<<<<\n' % cnt) print proc_command result = env.system_execute(proc_command, 500) env.print_info( '\n>>>>>>>>>>>>>>>> loop: %d end <<<<<<<<<<<<<<<<\n' % cnt) # total_loop_time = time.time() - loop_start_time # loop_hours = int(total_loop_time/3600) # loop_mins = int((total_loop_time/60)%60) # loop_secs = int(total_loop_time%60) # print(">>>> Elapsed Time for loop test : {} hours {} minutes {} seconds <<<<\n".format(loop_hours, loop_mins, loop_secs)) env.print_info('loop elapsed time: %#.8f seconds\n' % (time.time() - loop_start_time)) if result == 0: # system_execute return pass break else: cnt += 1 ''' if cnt < loop_time: user_continue = 'y' user_continue = raw_input('\nPress enter y to continue, n for stop...') if user_continue == 'n' or user_continue == 'N': break ''' env.print_info('>>>>>> loop count: %d <<<<<<\n' % cnt) if do_Result and (do_Full or do_Temp): if not SN: SN = GetSerialNumber() ''' if not ResultDirectory: ResultDirectory = os.path.join(env.ws_storage_folder, SN, env.result_folder_name) proc_command = 'python gui_result.py True {}'.format(ResultDirectory) ''' proc_command = 'python gui_result.py False' # env.process_execute(proc_command) result = env.subprocess_execute(proc_command, 5) if do_RunStatus: if result.find('FAIL') != -1: RunStatus = "FAIL" else: RunStatus = "PASS" if do_Full: env.backup_result_folder(SN) if do_RunStatus and do_Result: print('\n') if RunStatus == 'FAIL': # env.print_fail('\nFAIL') env.print_fail(' ***** * ***** *') env.print_fail(' * * * * *') env.print_fail(' **** ***** * *') env.print_fail(' * * * * *') env.print_fail(' * * * ***** *****') else: # env.print_pass('\nPASS') env.print_pass(' **** * **** ****') env.print_pass(' * * * * * *') env.print_pass(' **** ***** **** ****') env.print_pass(' * * * * *') env.print_pass(' * * * **** ****') print('\nGUI Runner Done.')
Logger.dut_id = Settings.get('SN') settings_content = ''.join(settings_parser(Settings, sys.argv[1])) tree_data = [] case_data = [] for idx in range(len(TestCaseTab)): if TestCaseTab[idx].test_id != 'TestDutCompleted': case_raw = "{} {} {}".format(TestCaseTab[idx].test_id, split_symbol, TestCaseTab[idx].instructions) case_data.append(case_raw) if len(sys.argv) >= 3 and sys.argv[2].lower()=='true': do_SaveAsFiles_Flog = True if do_SaveAsFiles_Flog: env.create_result_folder( Logger.dut_id ) print '[Start]' ''' # Sakia note: no effect, really implemented in test_bench.py TestCaseTab[1].values = sys.argv[2::] ''' for idx in range(len(TestCaseTab)): try: run_test(idx) while(True): job = test_bench.dispatch_next() #get on_compelet job if job != None: print job()