Ejemplo n.º 1
0
def bios_update(BIOS_IMG='', FOLDER='', RETRY='3'):
    if BIOS_IMG != '':
        RETRY = int(RETRY)
        retry = RETRY
        while (retry > 0):
            env.print_warn(">> run bios_update : retry %d <<" %
                           (RETRY - retry + 1))
            sticks = send_cmd('ls /run/media/').split()
            #            print sticks
            if len(sticks):
                for dev_name in sticks:
                    full_path = '/run/media/{}/{}/{}'.format(
                        dev_name, FOLDER, BIOS_IMG)
                    exist_fv = send_cmd('ls {} | wc -l'.format(full_path))
                    if len(exist_fv.split('\n')) == 1 and int(exist_fv) == 1:
                        env.print_pass("'{}' Found.".format(full_path))
                        send_cmd('mount -o remount, rw /esp')
                        send_cmd('cp {} /esp/BIOSUPDATE.fv'.format(full_path))
                        time.sleep(1)
                        exist_esp = send_cmd('ls /esp/BIOSUPDATE.fv | wc -l')
                        if len(exist_esp.split('\n')) == 1 and int(
                                exist_esp) == 1:
                            #                            print len(exist_esp.split('\n'))
                            #                            return machine_reboot(DISPLAY_ENABLE=False, DISPLAY_ENABLE=False, TIMEOUT=60)
                            return True
                        else:
                            return False
                    else:
                        env.print_fail("'{}' Not Found.".format(full_path))
            retry -= 1
    return False
Ejemplo n.º 2
0
def WriteMacAddress(item):
    mac = settings[item]
    env.print_warn("\n>> Write {} Mac Address <<".format(item))

    ser.write('ml_mac_write.sh OVERWRITE_MAC {} {}'.format(item, mac) + '\n')
    results = ''
    found = False
    initial = time.time()
    TIMEOUT = 60

    # if item == 'fpga':
    #     return 'PASS'

    while True:
        results += ser_read()
        duration = time.time() - initial

        sys.stdout.write('\rElapsed Time: %#.8f seconds' % duration)
        sys.stdout.flush()

        if not found:
            if duration > TIMEOUT:
                env.print_fail("\n>> Boot Failed <<")
                env.print_info('\rElapsed elapsed time: %#.8f seconds' %
                               duration)
                return "FAIL"
                break

            #if len(results) == 0 and duration > 3:
            #    results = send_cmd( "\n" )

            if 'wrote 0xff to register 0x00 31' in results:
                # if DISPLAY_ENABLE:
                #     env.print_log("\n\n{}".format(results))
                found = True

            if 'wrote 0xff to register 0x00 15' in results:
                found = True

        if found:
            env.print_warn("\n>> Write {} mac Success <<".format(item))
            env.print_info('\rElapsed elapsed time: %#.8f seconds' % duration)
            return "PASS"
            break

    return found
Ejemplo n.º 3
0
def machine_wait_for_boot(DISPLAY_ENABLE=False, TIMEOUT=120):
    env.print_warn("\n>> Waiting for Boot <<")
    results = ''
    found = False
    initial = time.time()

    while True:
        results += ser_read()
        duration = time.time() - initial
        if waitForLogin in results:
            print "\n", waitForLogin
            ser.write('root' + '\n')

        sys.stdout.write('\rElapsed Time: %#.8f seconds' % duration)
        sys.stdout.flush()

        if not found:
            if duration > TIMEOUT:
                env.print_fail("\n>> Boot Failed <<")
                env.print_info('\rElapsed elapsed time: %#.8f seconds' %
                               duration)
                return "FAIL"
                break

            #if len(results) == 0 and duration > 3:
            #    results = send_cmd( "\n" )

            if DefaultBootPrompt in results:
                if DISPLAY_ENABLE:
                    env.print_log("\n\n{}".format(results))
                found = True

        if found and (DefaultShellPrompt in results):
            env.print_warn("\n>> Boot Success <<")
            env.print_info('\rElapsed elapsed time: %#.8f seconds' % duration)
            return "PASS"
            time.sleep(5)
            ser.write('cd /home/root/' + '\n')
            time.sleep(5)
            break
    return found
Ejemplo n.º 4
0
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.')