示例#1
0
    def phy16q_200g_linespeed_test(self):
        self.kill_sdk_process()
        cmd = 'cd /usr/local/bin/'
        cd_prompt = self.prompt.replace('~', cmd.split('/')[-2])
        self.sendCmd(cmd, writting=False, prompt=cd_prompt)

        ret = 0
        try:
            self.send("./start_200G_bc_mode.sh \r")
            while True:
                x = self.expect([
                    cd_prompt, '\r', '\n', '^ERROR', '(?i)FAIL', '(?i)bcmLINK',
                    '(?i)PASS'
                ])
                if x == 0:
                    break
                elif x >= 3 and x <= 4:
                    ret = 1
                elif x == 5:
                    self.send("\x03")
                    ret = 1
                    break
                elif x == 6:
                    ret = 0
            time.sleep(0.2)
        except:
            UI.log("FAIL",
                   "Calling the script %s FAILED!" % "start_40G_bc_mode.sh")
            return DIAG_STATUS_FAILED
        return ret
示例#2
0
    def run(self):
        """
    Function Name: run
    Purpose: Executes the steps defined by this test case.
    """

        # initialize serial, Telnet and SSH UI with SystemMgmt APIs.
        self.__SSH = super().initUI(self.__dut.ssh_credentials,
                                    self.__dut.platform, FPGA)
        rand_value = generate_rand_hex()
        test_port = [1, 2]

        # Do not surround assignment operator = with spaces in paranthesised expressions.
        UI.log(
            'S1 Write bit patterns to this register and check the bit patterns in this register.'
        )
        self.__SSH.minicycle_raw('0x4008C', '0x0', 'write')

        self.__SSH.minicycle_raw('0x40098', '0x00000000', 'write')
        self.__SSH.minicycle_raw('0x40098', '0x00000000', 'read')

        self.__SSH.minicycle_raw('0x40098', '0xFFFFFFFF', 'write')
        self.__SSH.minicycle_raw('0x40098', '0xFFFFFFFF', 'read')

        UI.log('S2 Reset to default.')
        self.__SSH.minicycle_raw('0x40098', '0xFFFFFFFF', 'write')
        self.__SSH.minicycle_raw('0x40090', '0x00000000', 'read')
        self.__SSH.minicycle_raw('0x4008C', '0x0', 'write')
示例#3
0
    def run(self):
        """
    Function Name: run
    Purpose: Executes the steps defined by this test case.
    """

        # initialize serial, Telnet and SSH UI with SystemMgmt APIs.
        self.__TELNET = super().initUI(self.__dut.telnet_credentials,
                                       self.__dut.platform, OpenBMC)
        self.__cycle = 1
        self.__fail_count = 0
        self.__pim_count = 8

        # ==================================================================================================
        self.__TELNET.send('sudo ifconfig eth0 ' +
                           self.__dut.ssh_credentials[1] + ' netmask ' +
                           self.__dut.ssh_netmask + '\r')
        self.__TELNET.expect(self.__dut.ssh_credentials[5])

        for i in range(1, self.__cycle + 1):
            self.__TELNET.send('feutil all\r')

            while True:
                if self.__TELNET.expect([self.__dut.ssh_credentials[5], 'Fan'],
                                        timeout=180) == 0:
                    break

            UI.log(
                'CHECK', 'Cycle#' + str(i) + '/' + str(self.__cycle) +
                ': The FCM fru/FAN tray eeprom read complete.')

        UI.log(
            'CHECK', 'Cycle#' + str(i) + '/' + str(self.__cycle) +
            ': BMC_0820 Reading_PSU_information need to check.')
示例#4
0
 def get_sensor_info_from_BMC(self):
     UI.log('ACTION', 'Get all sensor information from OpenBMC')
     self.send('sensor-util all \r')
     self.expect(self.prompt)
     UI.log(
         'PASS', 'Get all sensor information from OpenBMC is PASS\n\n' +
         '=' * settings.glb.log_width)
示例#5
0
    def th3_xgkr_test(self):
        self.kill_sdk_process()
        cmd = 'cd /usr/local/accton/bin/XGKR/'
        cd_prompt = self.prompt.replace('~', cmd.split('/')[-2])
        self.sendCmd(cmd, writting=False, prompt=cd_prompt)

        ret = 0
        #bmc_util.tty_write("set_fan_speed.sh 50\r")
        try:
            self.send("./XGKR_Test \r")
            while True:
                x = self.expect([
                    cd_prompt, '\r', '\n', '^Error', 'PORT: Error:', '(?i)PASS'
                ])
                if x == 0:
                    break
                if x == 3 or x == 4:
                    ret = 1
                if x == 5:
                    ret = 0
            time.sleep(0.2)
        except:
            UI.log("FAIL", "Calling the script %s FAILED!" % "XGKR_Test")
            return DIAG_STATUS_FAILED

        return ret
示例#6
0
    def pci_get_pci_cfg_base_by_bdf(self, BUS, DEV, FN, VENDOR_ID, DEVICE_ID):
        try:
            cmd_ret = self.sendCmd(
                'cat /proc/iomem | grep MMCONFIG > /dev/null', writting=False)
        except:
            UI.log("FAIL", "Can't find MMCONFIG in /proc/iomem")
            return 0, 1

        cmd_ret = self.sendCmd(
            'cat /proc/iomem | grep MMCONFIG | awk \'{print $1}\' | awk -F "-" \'{print $1}\'',
            writting=False)
        if cmd_ret != "":
            cmd_ret = cmd_ret.splitlines()

        for line in cmd_ret:
            if re.search('^\d', line):
                MMCONFIG = line
        MMCONFIG = int("0x" + MMCONFIG, 16)
        CFG_BASE = MMCONFIG + (int(BUS, 16) << 20 | int(DEV, 16) << 15
                               | int(FN, 16) << 12)
        #Verify CFG BASE
        DEVICE = self.sendCmd('mem 0x%x 32' % CFG_BASE, writting=False)
        if DEVICE != "":
            DEVICE = DEVICE.splitlines()
        DEVICE = int(DEVICE[0], 16)
        TARGET_DEVICE = (VENDOR_ID | (DEVICE_ID << 16))
        if DEVICE != TARGET_DEVICE:
            UI.log(
                "FAIL",
                "DEVICE != TARGET_DEVICE for %x:%x" % (VENDOR_ID, DEVICE_ID))
            return 0, 1

        return CFG_BASE, 0
示例#7
0
    def run(self):
        """
    Function Name: run
    Purpose: Executes the steps defined by this test case.
    """

        # initialize serial, Telnet and SSH UI with SystemMgmt APIs.
        self.__TELNET = super().initUI(self.__dut.ssh_credentials,
                                       self.__dut.platform, SONiC_API)

        prompt = self.__dut.telnet_credentials[5]
        url = 'http://210.63.221.19:8888/sonic-broadcom.bin'

        # Using API from ../lib/cli/sonic/SONiC_API to execute function
        self.__TELNET.changeImageVersion(url)

        # Using traditional method step by step to execute function.
        UI.log("ACTION", "Install SONiC image from " + url)
        self.__TELNET.send('sudo sonic_installer install -y ' + url + ' \r')
        while True:
            x = self.__TELNET.expect(['\r', prompt, 'Downloading image'])
            if x == 1:
                # Upgrade finished.
                UI.log("PASS", "Install SONiC image success.")
                break
示例#8
0
    def run(self):
        """
    Function Name: run
    Purpose: Executes the steps defined by this test case.
    """

        # initialize serial, Telnet and SSH UI with SystemMgmt APIs.
        self.__TELNET = super().initUI(self.__dut.telnet_credentials,
                                       self.__dut.platform, OpenBMC)
        self.__cycle = 1
        for i in range(1, self.__cycle + 1):
            # ==================================================================================================
            UI.log(
                'STEP#01 - cycle#' + str(i) + '/' + str(self.__cycle),
                'Verify the information of wedge system EEPROM can be read with the command.'
            )
            self.__TELNET.send('weutil\r')
            self.__TELNET.expect(self.__dut.ssh_credentials[5])

            result = re.search('(?i)Failed', self.__TELNET.getBuff(), re.M)

            if result == None:
                UI.log(
                    'PASS', 'Cycle#' + str(i) + '/' + str(self.__cycle) +
                    ': The SMB fru eeprom read complete.')
                UI.log(
                    'PASS', 'Cycle#' + str(i) + '/' + str(self.__cycle) +
                    ': BMC_0140 Reading_SMB_fru_eeprom_information is passed.')
            else:
                UI.log(
                    'FAIL', 'Cycle#' + str(i) + '/' + str(self.__cycle) +
                    ': The SMB fru eeprom read failed.')
                UI.log(
                    'FAIL', 'Cycle#' + str(i) + '/' + str(self.__cycle) +
                    ': BMC_0140 Reading_SMB_fru_eeprom_information is failed.')
示例#9
0
    def phy16q_linespeed_test(self):
        self.kill_sdk_process()
        cmd = 'cd /usr/local/accton/bin/LineSpeed/'
        cd_prompt = self.prompt.replace('~', cmd.split('/')[-2])
        self.sendCmd(cmd, writting=False, prompt=cd_prompt)

        ret = 0
        #bmc_util.tty_write("set_fan_speed.sh 50\r")
        try:
            self.send("./linespeed_test 16q \r")
            while True:
                x = self.expect([
                    cd_prompt, '\r', '\n', '^Error', 'PORT: Error:',
                    '(?i)FAIL', '>> PASS'
                ])
                if x == 0:
                    break
                elif x >= 3 and x <= 5:
                    ret = 1
                elif x == 6:
                    ret = 0
            time.sleep(0.2)
        except:
            UI.log("FAIL", "Calling the script %s FAILED!" % "linespeed_test")
            return DIAG_STATUS_FAILED
        return ret
示例#10
0
 def exitBMCThroughCOMe(self):
   self.send('\001')
   self.send(':quit \r\n')
   try:
     self.expect('#')
     UI.log('PASS', 'Exit OpenBMC session from Micro-server is pass.')
   except:
     UI.log('FAIL', 'Exit OpenBMC session from Micro-server is failed.')
示例#11
0
 def exitCOMeThroughBMC(self):
   self.send('\x0c')
   self.send('x \r\n')
   try:
     self.expect('#')
     UI.log('PASS', 'Exit COMe session from BMC session is pass.')
   except:
     UI.log('FAIL', 'Exit COMe session from BMC session is failed.')
示例#12
0
    def chk_string(class_obj, str_get, str_expect):
        if str_expect.lower() in str_get.lower():
            UI.log('PASS',
                   'The string ' + str_expect + ' is found in' + str_get + '.')

        else:
            UI.log(
                'FAIL', 'The string ' + str_expect + ' is not found in ' +
                str_get + '.')
示例#13
0
 def enterCOMeFromBMC(self):
   self.send('sol.sh \r\n')
   time.sleep(1)
   self.send('\r')
   try:
     self.expect('#')
     UI.log('PASS', 'Enter COMe session from BMC is pass.')
   except:
     UI.log('FAIL', 'Enter COMe session from BMC is failed.')
示例#14
0
    def run(self):
        """
    Function Name: run
    Purpose: Executes the steps defined by this test case.
    """

        # initialize serial, Telnet and SSH UI with SystemMgmt APIs.
        self.__TELNET = super().initUI(self.__dut.telnet_credentials,
                                       self.__dut.platform, OpenBMC)
        self.__cycle = 1
        self.__fail_count = 0
        for i in range(1, self.__cycle + 1):
            # ==================================================================================================
            UI.log('STEP#01 - cycle#' + str(i) + '/' + str(self.__cycle),
                   'Get COM-e MAC address from BMC.')
            self.__TELNET.send('wedge_us_mac.sh\r')
            self.__TELNET.expect(self.__dut.ssh_credentials[5])

            self.__wedge_mac = re.search(
                '(?i)wedge_us_mac.sh(.*)' + self.__dut.ssh_credentials[3],
                self.__TELNET.getBuff().replace('\n', ''), re.M)

            self.__TELNET.send('sv stop mTerm\r')
            self.__TELNET.expect(self.__dut.ssh_credentials[5])
            self.__TELNET.send('sol.sh\r')
            self.__TELNET.expect('quit.')
            self.__TELNET.send('\r')
            self.__TELNET.expect('~]# ')
            self.__TELNET.send('ifconfig eth0\r')
            self.__TELNET.expect('~]# ')

            result = re.search('(?i)' + str(self.__wedge_mac.group(1)).strip(),
                               self.__TELNET.getBuff().replace('\n', ''), re.M)

            if result == None:
                self.__fail_count += 1

                UI.log(
                    'FAIL', 'Cycle#' + str(i) + '/' + str(self.__cycle) +
                    ': Get MAC and COM-E MAC is not match.')
            else:
                UI.log(
                    'PASS', 'Cycle#' + str(i) + '/' + str(self.__cycle) +
                    ': Get MAC and COM-E MAC is match.')

            self.__TELNET.send('\x18')
            self.__TELNET.expect(self.__dut.ssh_credentials[5])

        if self.__fail_count == 0:
            UI.log(
                'PASS', 'Cycle#' + str(i) + '/' + str(self.__cycle) +
                ': BMC_0780 Get_COM-e_MAC_from_BMC is passed.')
        else:
            UI.log(
                'FAIL', 'Cycle#' + str(i) + '/' + str(self.__cycle) +
                ': BMC_0780 Get_COM-e_MAC_from_BMC is failed.')
示例#15
0
 def changeImageVersion(self, url):
   UI.log("ACTION", "Install SONiC image from " + url)
   cli = 'sudo sonic_installer install -y ' + url + '\r'
   self.send(cli)
   while True:
     x = self.expect(['\r', self.prompt])
     if x == 1 :
       UI.log("PASS", "Install SONiC image success.")
       # Upgrade finished.
       break
示例#16
0
 def setGenerateKey(self, encryption_type=""):
     prompt = super().getPrompt()
     UI.log('ACTION', 'Generate SSH public host key.')
     start = datetime.now()
     timeout = 180
     self.send('ip ssh crypto host-key generate ' + encryption_type + '\r')
     self.expect(prompt, timeout=timeout)
     end = datetime.now()
     duration = str(end - start)
     UI.log('Key generation duration: ' + duration)
示例#17
0
    def run(self):
        """
    Function Name: run
    Purpose: Executes the steps defined by this test case.
    """

        # initialize serial, Telnet and SSH UI with SystemMgmt APIs.
        self.__SSH = super().initUI(self.__dut.ssh_credentials,
                                    self.__dut.platform, FPGA)
        rand_value = generate_rand_hex()
        test_port = [1, 2]

        # Do not surround assignment operator = with spaces in paranthesised expressions.
        UI.log('S1 Trap QSFP modules to reset mode and check the register. ')
        self.__SSH.minicycle_raw('0x40070', '0xffffffff', 'write')
        self.__SSH.minicycle_raw('0x40070', '0xffffffff', 'read')

        self.__SSH.minicycle_raw('0x40070', '0x0', 'write')
        reset_port = self.__SSH.minicycle_raw('0x40070', '', 'get')[4:8]
        UI.log('The reset port is ' + reset_port)

        if hex(int(gen_bin_byport(test_port, reverse='true'),
                   2))[2:6].upper() == reset_port.upper():
            UI.log('PASS', 'The port in reset mode is correct.')
        else:
            UI.log('FAIL', 'The port in reset mode is incorrect.')
示例#18
0
  def enterBMCFromCOMe(self):
    BMC_username = '******'
    BMC_password = '******'
    BMC_prompt = '# '
    return_char = '\r'
    login_count = 0
    UI.log('ACTION', 'Enter OpenBMC session from Micro-server')
    self.send('screen /dev/ttyACM0 \r\n')
    while True:
      i = self.expect(['bmc-oob. login: '******'(?i)Password.*', BMC_prompt])
      if i == 2:
        UI.log('PASS', 'Enter OpenBMC session from Micro-server is pass.')
        break
      elif i == 0:
        self.send(BMC_username + return_char)
      elif i == 1:
        self.send(BMC_password + return_char)
        login_count += 1

      if login_count > 2:
        UI.log('FAIL', 'Can not enter OpenBMC session from Micro-server.')
        if not settings.glb.print_to_stdout:
          print('CRITICAL ALERT: Login failed. Permission denied for username/password: %s/%s'
          %(BMC_username, BMC_password))

          UI.log('CRITICAL ALERT', 'Login failed. Permission denied for username/password: %s/%s'
          %(BMC_username, BMC_password))
          break
示例#19
0
    def powerOff(self, number_list, model='ATEN'):
        prompt = super().getPrompt()

        if model == 'ATEN':
            UI.log('ACTION', 'Power OFF outlet number "' + number_list + '".')

            for number in number_list.split(','):
                number_format = str('%02d' % int(number.strip()))

                self.send('sw o' + number_format + ' off imme\r')
                time.sleep(self.__sleep_time)
                self.expect(prompt)

                time.sleep(self.__sleep_time)
示例#20
0
    def bmc_check_pcie_err(self):
        ret = DIAG_STATUS_SUCCESS

        fpga_key = "FPGA"
        th3_key = "Tomahawk 3"
        unknown_key = "Unknown"
        pcie_err_log = {
            fpga_key: [],
            th3_key: [],
            unknown_key: [],
        }
        try:
            # Check BMC log
            UI.log("### Check BMC system event log ###")
            cmd = "grep -n PCIE /mnt/data/logfile*"
            rs = self.get_process_result(cmd)
            if rs:
                for line in rs:
                    if "(Bus 00 / Dev 03 / Fun 01)" in line:
                        ret = DIAG_STATUS_FAILED
                        pcie_err_log[th3_key].append(line)
                    elif "(Bus 00 / Dev 03 / Fun 00)" in line:
                        ret = DIAG_STATUS_FAILED
                        pcie_err_log[fpga_key].append(line)
                    else:
                        if 'No such file or directory' not in line:
                            ret = DIAG_STATUS_FAILED
                            pcie_err_log[unknown_key].append(line)

            for key in sorted(pcie_err_log.keys()):
                log_ls = pcie_err_log[key]
                err_count = len(log_ls)
                print("\n===== %s PCIE error (%d) =====" % (key, err_count))
                for log in log_ls:
                    print(log)

            # Check CPU log
        except Exception as e:
            error_class = e.__class__.__name__  #取得錯誤類型
            detail = e.args[0]  #取得詳細內容
            cl, exc, tb = sys.exc_info()  #取得Call Stack
            lastCallStack = traceback.extract_tb(tb)[-1]  #取得Call Stack的最後一筆資料
            fileName = lastCallStack[0]  #取得發生的檔案名稱
            lineNum = lastCallStack[1]  #取得發生的行號
            funcName = lastCallStack[2]  #取得發生的函數名稱
            errMsg = "\n\nFile \"{}\", line {}, in {}: [{}] {}\n\n".format(
                fileName, lineNum, funcName, error_class, detail)
            print(errMsg)
            return DIAG_STATUS_FAILED
        return ret
示例#21
0
    def __init__(self, config):
        name = config.get('player', 'name')
        spaceship = config.get('player', 'spaceship')

        self.chat = ChatClient()
        self.display = Display()
        self.ui = UI()
        int_colors, ext_colors = {}, {}
        obj_defs = open('dat/int_obj_colors.txt', 'rb').read().split('\n')
        for line in obj_defs:
            if len(line):
                char, color = line.split('|')
                int_colors[char] = eval(color)
        obj_defs = open('dat/ext_obj_colors.txt', 'rb').read().split('\n')
        for line in obj_defs:
            if len(line):
                char, color = line.split('|')
                ext_colors[char] = eval(color)
        self.ui.set_default_colors(int_colors, ext_colors)

        self.evt_mode, self.evt_mode_desc = 'normal', ''
        self.action = ('connect', (name, spaceship))
        self.arg_type = 'tuple_of_str'
        self.require_arg = False
        self.queued_evt = False
        self.prompt = ''
        ver = 'v0.3.1-alpha'
        self.top_status_bar = ' ' * (80 - len(ver)) + ver
        self.bottom_status_bar = ''
        self.view_field, self.colors = False, {}
        self.command = None
        self.look_pointer, self.target = None, None
        self.fps = 50
        self.blinker = 0
示例#22
0
    def i2cBusTest(self):
        is_mcp2221a_used = -1

        retstr = self.sendCmd("cat %s " % DIAG_IS_MCP2221A_USED_FILE)
        if retstr != "":
            retstr = retstr.splitlines()
        is_mcp2221a_used = int(retstr[0])

        if is_mcp2221a_used == 1:
            i2c_0_device_address = ['08', '44', '48']
        else:
            i2c_0_device_address = ['74', 'e0', 'ae', 'be']

        UI.log("is_mcp2221a_used %d" % is_mcp2221a_used)

        return i2c_0_device_address
示例#23
0
  def run(self):
    """
    Function Name: run
    Purpose: Executes the steps defined by this test case.
    """

    # initialize serial, Telnet and SSH UI with SystemMgmt APIs.
    self.__TELNET = super().initUI(self.__dut.telnet_credentials, self.__dut.platform, OpenBMC)
    self.__cycle = 1
    self.__fail_count = 0
   # ==================================================================================================
    self.__TELNET.sendCmd('fpga_ver.sh')
           
    if self.__fail_count == 0:
      UI.log('PASS', 'BMC_0520 Checking IOB FPGA and DOM FPGA version. is passed.')
    else:
      UI.log('FAIL', 'BMC_0520 Checking IOB FPGA and DOM FPGA version. is failed.')
示例#24
0
 def check_cpu_log(self):
     ret = DIAG_STATUS_SUCCESS
     try:
         UI.log('### Check CPU FPGA pcie error ###')
         cmd = 'zgrep "FPGA.*b=0[1-7]" /var/log/message*'
         retstr = self.sendCmd(cmd, writting=False).splitlines()
         for i in range(0, len(retstr)):
             if cmd in retstr[i]:
                 retstr.pop(i)
             elif self.prompt in retstr[i]:
                 retstr.pop(i)
         if len(retstr):
             ret = DIAG_STATUS_FAILED
     except Exception as e:
         print(repr(e))
         return DIAG_STATUS_FAILED
     return ret
示例#25
0
    def run(self):
        """
    Function Name: run
    Purpose: Executes the steps defined by this test case.
    """

        # initialize serial, Telnet and SSH UI with SystemMgmt APIs.
        self.__TELNET = super().initUI(self.__dut.telnet_credentials,
                                       self.__dut.platform, OpenBMC)
        self.__cycle = 1
        self.__fail_count = 0

        self.__TELNET.send('sudo ifconfig eth0 ' +
                           self.__dut.ssh_credentials[1] + ' netmask ' +
                           self.__dut.ssh_netmask + '\r')
        self.__TELNET.expect(self.__dut.ssh_credentials[5])

        for i in range(1, self.__cycle + 1):
            # ==================================================================================================
            UI.log('STEP#01', 'To show the I2C can be detect by BMC.')
            self.__TELNET.send('i2cget -y 10 0x6f\r')
            self.__TELNET.expect(self.__dut.ssh_credentials[5])

            result = re.search('(?i)0x', self.__TELNET.getBuff(), re.M)

            if result == None:
                self.__fail_count += 1

                UI.log(
                    'FAIL', 'Cycle#' + str(i) + '/' + str(self.__cycle) +
                    ': Can not to use the command getting the value of i2c bus.'
                )
            else:
                UI.log(
                    'PASS', 'Cycle#' + str(i) + '/' + str(self.__cycle) +
                    ': Can using the command to get the value of i2c bus.')

        if self.__fail_count == 0:
            UI.log(
                'PASS', 'Cycle#' + str(i) + '/' + str(self.__cycle) +
                ': BMC_0540 Use i2cget to access i2c busses is passed.')
        else:
            UI.log(
                'FAIL', 'Cycle#' + str(i) + '/' + str(self.__cycle) +
                ': BMC_0540 Use i2cget to access i2c bussesis failed.')
示例#26
0
    def scp(self, copy_direction, src, dst, remote_ip, username, password):
        if re.match('(?i)remote.*host', copy_direction):
            src = username + '@' + remote_ip + ':' + src
        elif re.match('(?i)host.*remote', copy_direction):
            dst = username + '@' + remote_ip + ':' + dst

        EOF = self.getEOF()
        copy_result = 'CHECK'
        copy_msg = ['Command not executed.']

        try:
            self.spawn('scp ' + src + ' ' + dst)

            while True:
                i = self.expect([
                    '(?i)password.*', '100%.*', '(?i)Error opening file',
                    '(?i)are the same file', '(?i)Permission denied', EOF
                ])

                if i == 0:
                    self.send(password + '\r')
                elif i == 1:
                    copy_result = 'PASS'
                    copy_msg[0] = 'File copied successfully.'
                    copy_msg.append('Source: ' + src)
                    copy_msg.append('Destination: ' + dst)
                elif i == 2:
                    copy_result = 'FAIL'
                    copy_msg[0] = 'Error copying file.'
                elif i == 3:
                    copy_result = 'CHECK'
                    copy_msg[0] = 'No file copied.'
                elif i == 4:
                    copy_result = 'FAIL'
                    copy_msg[0] = 'Invalid username/password.'
                elif i == 5:
                    break

        except Exception as e:
            UI.log(str(e))
            copy_result = 'FAIL'
            copy_msg[0] = 'Exception encountered while copying.'

        UI.log(copy_result, *copy_msg)
示例#27
0
    def pci_all_clear_all_aer_mask(self):
        try:
            cmd_ret = self.sendCmd('lspci -n | awk \'{printf $1 " "}\'',
                                   writting=False)
            pci_dev_list = cmd_ret.split()
        except:
            UI.log("FAIL", "get pci dev list failed")
            return 1

        try:
            cmd_ret = self.sendCmd('lspci -n | awk \'{printf $3 " "}\'',
                                   writting=False)
            pci_id_list = cmd_ret.split()
        except:
            UI.log("FAIL", "get pci dev id failed")
            return 1
        for i in range(len(pci_dev_list) - 2):
            if i == 0:
                print('\r')
            try:
                if self.prompt.replace(
                        ' ', ''
                ) not in pci_dev_list[i] or '.*root@.*' not in pci_dev_list[i]:
                    BUS = pci_dev_list[i].split(':')[0]
                    DEV = pci_dev_list[i].split(':')[1].split('.')[0]
                    FN = pci_dev_list[i].split(':')[1].split('.')[1]
                    VENDOR_ID = int("0x" + pci_id_list[i].split(':')[0], 16)
                    DEVICE_ID = int("0x" + pci_id_list[i].split(':')[1], 16)
                    PCI_BASE, ret = self.pci_get_pci_cfg_base_by_bdf(
                        BUS, DEV, FN, VENDOR_ID, DEVICE_ID)
            except Exception as e:
                pass
            if ret == 0:
                AER_BASE, ret = self.pci_get_aer_cfg_base(PCI_BASE)
                if ret == 0:
                    print("Clear %s AER mask" % pci_dev_list[i])
                    self.aer_cfg_clear_cemask(AER_BASE)
                    self.aer_cfg_clear_uemask(AER_BASE)
                else:
                    print("%s no AER mask" % pci_dev_list[i])
            else:
                return 1

        return 0
示例#28
0
    def run(self):
        """
    Function Name: run
    Purpose: Executes the steps defined by this test case.
    """

        # initialize serial, Telnet and SSH UI with SystemMgmt APIs.
        self.__SSH = super().initUI(self.__dut.ssh_credentials,
                                    self.__dut.platform, FPGA)
        rand_value = generate_rand_hex()
        pim_card = "1"
        test_port = [1, 2]

        # Do not surround assignment operator = with spaces in paranthesised expressions.
        UI.log('S1 Reset the MDIO Interrupt Status.')
        self.__SSH.minicycle_raw('0x40084', '0x0', 'write')
        self.__SSH.minicycle_raw('0x4009c', '0x0', 'write')
        print('Wait for 120 seconds.')
        time.sleep(120)

        UI.log('S2 Write 0x0 to this register to trap PHYs in the reset mode.')
        self.__SSH.minicycle_raw('0x4009c', '0xFFFF0000', 'write')
        self.__SSH.minicycle_raw('0x40084', '0xf', 'write')

        print('Wait for 120 seconds.')
        time.sleep(120)

        UI.log('S3 Invoke minicycle.py to get PHY ID.')
        self.__SSH.minicycle_mdio(pim=pim_card,
                                  way='read',
                                  check_value='Fail to get PHY ID')
        time.sleep(5)

        UI.log('S4 Write 0xFFFFFFFF to release PHYs from reset mode.')
        self.__SSH.minicycle_raw('0x4009C', '0xFFFFFFFF', 'write')
        print('Wait for 120 seconds.')
        time.sleep(120)

        UI.log(
            'S5 Invoke minicycle.py to get PHY ID. Make sure all the transactions succeed.'
        )
        self.__SSH.minicycle_mdio(pim=pim_card, way='read', check_value='0x')
        time.sleep(5)
示例#29
0
    def run(self):
        """
    Function Name: run
    Purpose: Executes the steps defined by this test case.
    """

        # initialize serial, Telnet and TELNET UI with SystemMgmt APIs.
        self.__SSH = super().initUI(self.__dut.ssh_credentials,
                                    self.__dut.platform, OpenBMC)
        self.__fail_count = 0

        # Do not surround assignment operator = with spaces in paranthesised expressions.
        self.__SSH.send('sensor-util all \r')
        self.__SSH.expect(self.prompt, timeout=180)

        if self.__fail_count == 0:
            UI.log('PASS', 'BMC_0070 Monitoring All Sensors is passed.')
        else:
            UI.log('FAIL', 'BMC_0070 Monitoring All Sensors is failed.')
示例#30
0
    def run(self):
        """
    Function Name: run
    Purpose: Executes the steps defined by this test case.
    """

        # initialize serial, Telnet and SSH UI with SystemMgmt APIs.
        self.__TELNET = super().initUI(self.__dut.telnet_credentials,
                                       self.__dut.platform, OpenBMC)
        self.__cycle = 1
        self.__pim_count = 8
        self.__fail_count = 0

        # ==================================================================================================
        self.__TELNET.send('sudo ifconfig eth0 ' +
                           self.__dut.ssh_credentials[1] + ' netmask ' +
                           self.__dut.ssh_netmask + '\r')
        self.__TELNET.expect(self.__dut.ssh_credentials[5])

        for i in range(1, self.__cycle + 1):
            # ==================================================================================================
            UI.log('STEP#01 - cycle#' + str(i) + '/' + str(self.__cycle),
                   'Read information about COM-e BIOS and BIC version.')
            self.__TELNET.send('fw-util scm --version\r')
            self.__TELNET.expect(self.__dut.ssh_credentials[5])

            # result = re.search('(?i)BIOS Version', self.__TELNET.getBuff(), re.M)

            # if result == None:
            # UI.log('FAIL', 'Cycle#' + str(i) + '/' + str(self.__cycle) + ': COM-e BIOS and BIC read failure.')
            # else:
            # self.__fail_count += 1

            # UI.log('PASS', 'Cycle#' + str(i) + '/' + str(self.__cycle) + ': COM-e BIOS and BIC read success.')

            # if self.__fail_count == 0:
            # UI.log('PASS', 'Cycle#' + str(i) + '/' + str(self.__cycle) + ': BMC_0700 Read_COM_e_CPLD_and_BIC_version is passed.')
            # else:
            # UI.log('FAIL', 'Cycle#' + str(i) + '/' + str(self.__cycle) + ': BMC_0700 Read_COM_e_CPLD_and_BIC_version is failed.')

            UI.log(
                'CHECK', 'Cycle#' + str(i) + '/' + str(self.__cycle) +
                ': BMC_0700 Read_COM_e_CPLD_and_BIC_version need to check.')
示例#31
0
    def beginLog(self, file_name=''):
        if file_name == '':
            file_name = self.__name

        self.__log_name = file_name + '.log'

        if not os.path.exists(self.__log_path):
            os.makedirs(self.__log_path)

        UI.openLog(self.__log_path + '/' + self.__log_name)
        UI.logTitle('INITIALIZING SCRIPT ' + self.__name)

        if self.__headline != '':
            UI.log('HEADLINE', *self.__headline)

        if self.__purpose != '':
            UI.log('PURPOSE', *self.__purpose)

        self.__start = datetime.now()
        UI.log('BEGIN LOG', 'Start time: ' + str(self.__start).split('.')[0])
示例#32
0
class GameClient(object):

    def __init__(self, config):
        name = config.get('player', 'name')
        spaceship = config.get('player', 'spaceship')

        self.chat = ChatClient()
        self.display = Display()
        self.ui = UI()
        int_colors, ext_colors = {}, {}
        obj_defs = open('dat/int_obj_colors.txt', 'rb').read().split('\n')
        for line in obj_defs:
            if len(line):
                char, color = line.split('|')
                int_colors[char] = eval(color)
        obj_defs = open('dat/ext_obj_colors.txt', 'rb').read().split('\n')
        for line in obj_defs:
            if len(line):
                char, color = line.split('|')
                ext_colors[char] = eval(color)
        self.ui.set_default_colors(int_colors, ext_colors)

        self.evt_mode, self.evt_mode_desc = 'normal', ''
        self.action = ('connect', (name, spaceship))
        self.arg_type = 'tuple_of_str'
        self.require_arg = False
        self.queued_evt = False
        self.prompt = ''
        ver = 'v0.3.1-alpha'
        self.top_status_bar = ' ' * (80 - len(ver)) + ver
        self.bottom_status_bar = ''
        self.view_field, self.colors = False, {}
        self.command = None
        self.look_pointer, self.target = None, None
        self.fps = 50
        self.blinker = 0

    def main(self):
        if self.action and not self.require_arg:
            command = getattr(self.command, 'queue_' + self.arg_type)
            command(self.action[0], self.action[1])
            self.action, self.arg_type = False, False
        if not self.view_field:
            return
        events = event.get(self.evt_mode)
        if events:
            self.evt_mode, evt, evt_arg, self.arg_type = events
        else:
            evt, evt_arg = None, None
        if self.evt_mode == 'normal' and len(self.evt_mode_desc):
            self.evt_mode_desc = ''
        if evt == 'quit':
            self.command.stop()
        elif evt == 'arg' and self.require_arg:
            self.action = (self.action, evt_arg) if evt_arg else 0
            self.evt_mode_desc = ''
            self.require_arg = False
        elif evt == 'activate':
            self.action = evt
            self.evt_mode_desc = 'Activate.. (direction)'
            self.require_arg = True
        elif evt == 'look':
            self.evt_mode_desc = 'Look... (direction)'
            self.action = (evt, evt_arg)
        elif evt == 'look_done':
            self.evt_mode_desc = ''
            self.action = (evt, evt_arg)
        elif evt == 'insert':
            self.prompt += evt_arg
        elif evt == 'backspace' and self.prompt:
            self.prompt = self.prompt[: - evt_arg]
        elif evt == 'return' and self.prompt:
            self.action = (self.queued_evt, self.prompt)
            self.queued_evt = False
            self.prompt, self.evt_mode, self.evt_mode_desc = '', 'normal', ''
        elif evt in ['say', 'equip', 'drop', 'unequip']:
            if evt == 'say':
                self.evt_mode_desc = 'Say...'
            elif evt == 'equip':
                self.evt_mode_desc = 'Equip... (item, slot)'
            elif evt == 'drop':
                self.evt_mode_desc = 'Drop... (item name)'
            elif evt == 'unequip':
                self.evt_mode_desc = 'Unequip... (slot)'
            self.queued_evt = evt
        elif (evt, evt_arg) != (None, None):
            self.action = (evt, evt_arg)

        self.blinker = self.blinker + 1 if self.blinker < self.fps else 0
        surface = self.ui.compose(
            self.view_field, self.colors,
            self.chat.get_log(), self.prompt,
            self.evt_mode, self.evt_mode_desc,
            self.bottom_status_bar, self.top_status_bar,
            self.target if self.blinker < self.fps / 2 else None,
            self.look_pointer if self.blinker < self.fps / 2 else None)
        self.display.draw(surface)
        self.display.update()

    #--------------------------------------------------------------------------
    # state accessors

    def add_chat_messages(self, messages):
        self.chat.add_multiple(messages)

    def set_bottom_status_bar(self, text):
        self.bottom_status_bar = text

    def set_command(self, command):
        self.command = command

    def set_look_pointer(self, (x, y)):
        self.look_pointer = (x, y)
        self.blinker = 0