コード例 #1
0
ファイル: test_case.py プロジェクト: eilinge/dts
 def verify(self, passed, description):
     if not passed:
         if self._enable_debug:
             print RED("Error happened, dump command history...")
             self.dump_history()
             print "Error \"%s\" happened" % RED(description)
             print RED("History dump finished.")
         raise VerifyFailure(description)
コード例 #2
0
    def scan_ports_uncached_linux(self):
        """
        Scan Linux ports and collect port's pci id, mac adress, ipv6 address.
        """
        self.ports_info = []

        skipped = RED('Skipped: Unknown/not selected')
        unknow_interface = RED('Skipped: unknow_interface')

        for (pci_bus, pci_id) in self.pci_devices_info:
            if self.check_ports_available(pci_bus, pci_id) is False:
                self.logger.info("DUT: [%s %s] %s" %
                                 (pci_bus, pci_id, skipped))
                continue

            addr_array = pci_bus.split(':')
            domain_id = addr_array[0]
            bus_id = addr_array[1]
            devfun_id = addr_array[2]

            port = GetNicObj(self, domain_id, bus_id, devfun_id)
            intf = port.get_interface_name()
            if "No such file" in intf:
                self.logger.info("DUT: [%s] %s" % (pci_bus, unknow_interface))
                continue

            macaddr = port.get_mac_addr()
            if "No such file" in intf:
                self.logger.info("DUT: [%s] %s" % (pci_bus, unknow_interface))
                continue

            numa = port.socket
            # store the port info to port mapping
            self.ports_info.append({
                'port': port,
                'pci': pci_bus,
                'type': pci_id,
                'numa': numa,
                'intf': intf,
                'mac': macaddr
            })

            if not port.get_interface2_name():
                continue

            intf = port.get_interface2_name()
            macaddr = port.get_intf2_mac_addr()
            numa = port.socket
            # store the port info to port mapping
            self.ports_info.append({
                'port': port,
                'pci': pci_bus,
                'type': pci_id,
                'numa': numa,
                'intf': intf,
                'mac': macaddr
            })
コード例 #3
0
ファイル: net_device.py プロジェクト: eilinge/dts
    def enable_jumbo(self, framesize=0):
        if self.intf_name == "N/A":
            print RED("Enable jumbo must based on kernel interface!!!")
            return
        if framesize < MIN_MTU:
            print RED("Enable jumbo must over %d !!!" % MIN_MTU)
            return

        mtu = self._cal_mtu(framesize)
        cmd = "ifconfig %s mtu %d"
        self.__send_expect(cmd % (self.intf_name, mtu), "# ")
コード例 #4
0
ファイル: checkCase.py プロジェクト: eilinge/dts
    def __init__(self):
        self.dut = None
        self.comments = ''

        self.check_function_dict = {}
        self.support_function_dict = {}
        try:
            self.check_function_dict = json.load(open(filter_json_file), object_pairs_hook=collections.OrderedDict)
        except:
            print RED("Can't load check list for test cases, all case will be taken as supported")

        try:
            self.support_function_dict = json.load(open(support_json_file), object_pairs_hook=collections.OrderedDict)
        except:
            print RED("Can't load support list for test cases, all case will be taken as supported")
コード例 #5
0
    def rescan_ports_uncached_linux(self):
        unknow_interface = RED('Skipped: unknow_interface')

        for port_info in self.ports_info:
            port = port_info['port']
            intf = port.get_interface_name()
            port_info['intf'] = intf
            out = self.send_expect("ip link show %s" % intf, "# ")
            if "DOWN" in out:
                self.send_expect("ip link set %s up" % intf, "# ")
                time.sleep(5)
            port_info['mac'] = port.get_mac_addr()
            out = self.send_expect(
                "ip -family inet6 address show dev %s | awk '/inet6/ { print $2 }'"
                % intf, "# ")
            ipv6 = out.split('/')[0]
            # Unconnected ports don't have IPv6
            if ":" not in ipv6:
                ipv6 = "Not connected"

            out = self.send_expect(
                "ip -family inet address show dev %s | awk '/inet/ { print $2 }'"
                % intf, "# ")
            ipv4 = out.split('/')[0]

            port_info['ipv6'] = ipv6
            port_info['ipv4'] = ipv4
コード例 #6
0
ファイル: config.py プロジェクト: amzn/amzn-ec2-ena-utilities
    def load_case_config(self, case_name=""):
        case_cfg = self.suite_cfg.copy()
        if self.suite_conf is None:
            return case_cfg

        try:
            case_confs = self.suite_conf.load_section(case_name)
        except:
            print RED("Failed to find case[%s] in the case config" % section_name)
            return case_cfg

        if case_confs is None:
            return case_cfg

        conf = dict(case_confs)
        for key, data_string in conf.items():
            if data_string.startswith("value_int:"):
                value = data_string[len("value_int:"):]
                case_cfg[key] = int(value)
            elif data_string.startswith("value_hex:"):
                value = data_string[len("value_hex:"):]
                case_cfg[key] = int(value, 16)
            elif data_string.startswith("list_int:"):
                value = data_string[len("list_int:"):]
                datas = value.split(',')
                int_list = map(lambda x: int(x), datas)
                case_cfg[key] = int_list
            elif data_string.startswith("list_str:"):
                value = data_string[len("list_str:"):]
                str_list = value.split(',')
                case_cfg[key] = str_list
            else:
                case_cfg[key] = data_string

        return case_cfg
コード例 #7
0
    def _connect_host(self, dut_id=0):
        """
        Create connection to assigned crb, parameter dut_id will be used in
        parallel_lock thus can assure isolated locks for each crb.
        Parallel ssh connections are limited to MaxStartups option in SSHD
        configuration file. By default concurrent number is 10, so default
        threads number is limited to 8 which less than 10. Lock number can
        be modified along with MaxStartups value.
        """
        try:
            self.session = pxssh.pxssh()
            if ':' in self.host:
                self.ip = self.host.split(':')[0]
                self.port = int(self.host.split(':')[1])
                self.session.login(self.ip,
                                   self.username,
                                   self.password,
                                   original_prompt='[$#>]',
                                   port=self.port,
                                   login_timeout=20)
            else:
                self.session.login(self.host,
                                   self.username,
                                   self.password,
                                   original_prompt='[$#>]')
            self.send_expect('stty -echo', '#')
            self.send_expect('stty columns 1000', "#")
        except Exception as e:
            print RED(e)
            if getattr(self, 'port', None):
                suggestion = "\nSuggession: Check if the firewall on [ %s ] " % \
                    self.ip + "is stopped\n"
                print GREEN(suggestion)

            raise SSHConnectionException(self.host)
コード例 #8
0
    def __init__(self, host, username, password):
        self.magic_prompt = "MAGIC PROMPT"
        try:
            self.session = pxssh.pxssh()
            self.host = host
            self.username = username
            self.password = password
            if ':' in host:
                self.ip = host.split(':')[0]
                self.port = int(host.split(':')[1])
                self.session.login(self.ip, self.username,
                                   self.password, original_prompt='[$#>]',
                                   port=self.port, login_timeout=20)
            else:
                self.session.login(self.host, self.username,
                                   self.password, original_prompt='[$#>]')
            self.send_expect('stty -echo', '# ', timeout=2)
        except Exception, e:
            print RED(e)
            if getattr(self, 'port', None):
                suggestion = "\nSuggession: Check if the fireware on [ %s ] " % \
                    self.ip + "is stoped\n"
                print GREEN(suggestion)

            raise SSHConnectionException(host)
コード例 #9
0
    def case_skip(self, case_name):
        """
        Check whether test case and DUT match skip criteria
        Return True if it is possible to skip the case
        """
        skip_flag = False
        self.comments = ""

        if self.dut is None:
            print RED("No Dut assigned before case skip check")
            return skip_flag

        if case_name in self.check_function_dict.keys():
            case_checks = self.check_function_dict[case_name]
            # each case may have several checks
            for case_check in case_checks:
                # init result for each check
                skip_flag = False
                for key in case_check.keys():
                    # some items like "Bug ID" and "Comments" do not need check
                    try:
                        if 'Comments' == key:
                            continue
                        if 'Bug ID' == key:
                            continue
                        check_function = getattr(self,
                                                 '_check_%s' % key.lower())
                    except:
                        print RED(
                            "case_skip: can't check %s type in case name %s" %
                            (key, case_name))

                    # skip this check if any item not matched
                    if check_function(case_check[key]):
                        skip_flag = True
                    else:
                        skip_flag = False
                        break

                # if all items matched, this case should skip
                if skip_flag:
                    if 'Comments' in case_check.keys():
                        self.comments = case_check['Comments']
                    return skip_flag

        return skip_flag
コード例 #10
0
ファイル: config.py プロジェクト: amzn/amzn-ec2-ena-utilities
    def load_ixia_config(self):
        port_reg = r'card=(\d+),port=(\d+)'
        groups = self.ixia_conf.get_sections()
        if not groups:
            return self.ixia_cfg

        for group in groups:
            ixia_group = {}
            ixia_confs = self.ixia_conf.load_section(group)
            if not ixia_confs:
                continue

            # convert file configuration to dts ixiacfg
            for conf in ixia_confs:
                key, value = conf
                if key == 'ixia_version':
                    ixia_group['Version'] = value
                elif key == 'ixia_ip':
                    ixia_group['IP'] = value
                elif key == 'ixia_ports':
                    ports = self.ixia_conf.load_config(value)
                    ixia_ports = []
                    for port in ports:
                        m = re.match(port_reg, port)
                        if m:
                            ixia_port = {}
                            ixia_port["card"] = int(m.group(1))
                            ixia_port["port"] = int(m.group(2))
                            ixia_ports.append(ixia_port)
                    ixia_group['Ports'] = ixia_ports
                elif key == 'ixia_enable_rsfec':
                    ixia_group['enable_rsfec'] = value

            if 'Version' not in ixia_group:
                print RED('ixia configuration file requires ixia_version option')
                continue
            if 'IP' not in ixia_group:
                print RED('ixia configuration file requires ixia_ip option')
                continue
            if 'Ports' not in ixia_group:
                print RED('ixia configuration file requires ixia_ports option')
                continue

            self.ixia_cfg[group] = ixia_group

        return self.ixia_cfg
コード例 #11
0
    def case_support(self, case_name):
        """
        Check whether test case and DUT match support criteria
        Return False if test case not supported
        """
        support_flag = True
        self.comments = ""

        if self.dut is None:
            print RED("No Dut assigned before case support check")
            return support_flag

        if case_name in self.support_function_dict.keys():
            # each case may have several supports
            case_supports = self.support_function_dict[case_name]
            for case_support in case_supports:
                # init result for each check
                support_flag = True
                for key in case_support.keys():
                    # some items like "Bug ID" and "Comments" do not need check
                    try:
                        if 'Comments' == key:
                            continue
                        if 'Bug ID' == key:
                            continue
                        check_function = getattr(self,
                                                 '_check_%s' % key.lower())
                    except:
                        print RED(
                            "case_skip: can't check %s type in case name %s" %
                            (key, case_name))

                    # skip this case if any item not matched
                    if check_function(case_support[key]):
                        support_flag = True
                    else:
                        support_flag = False
                        break

            if support_flag is False:
                if 'Comments' in case_support.keys():
                    self.comments = case_support['Comments']
                return support_flag

        return support_flag
コード例 #12
0
    def init_core_list(self):
        self.cores = []
        cpuinfo = self.send_expect(
            "grep --color=never \"processor\""
            " /proc/cpuinfo", "#")
        cpuinfo = cpuinfo.split('\r\n')
        if self.cpu_topo != '':
            topo_reg = r"(\d)S/(\d)C/(\d)T"
            m = re.match(topo_reg, self.cpu_topo)
            if m:
                socks = int(m.group(1))
                cores = int(m.group(2))
                threads = int(m.group(3))
                total = socks * cores * threads
                cores_persock = cores * threads
                total_phycores = socks * cores
                # cores should match cpu_topo
                if total != len(cpuinfo):
                    print RED("Core number not matched!!!")
                else:
                    for core in range(total):
                        thread = core / total_phycores
                        phy_core = core % total_phycores
                        # if this core is hyper core
                        if thread:
                            idx = core % total_phycores
                            socket = idx / cores
                        else:
                            socket = core / cores

                        # tricky here, socket must be string
                        self.cores.append({
                            'thread': core,
                            'socket': str(socket),
                            'core': phy_core
                        })
                    self.number_of_cores = len(self.cores)
                    return

        # default core map
        for line in cpuinfo:
            m = re.search("processor\t: (\d+)", line)
            if m:
                thread = m.group(1)
                socket = 0
                core = thread
            self.cores.append({
                'thread': thread,
                'socket': socket,
                'core': core
            })

        self.number_of_cores = len(self.cores)
コード例 #13
0
    def scan_ports_uncached_freebsd(self):
        """
        Scan Freebsd ports and collect port's pci id, mac adress, ipv6 address.
        """
        self.ports_info = []

        skipped = RED('Skipped: Unknown/not selected')

        for (pci_bus, pci_id) in self.pci_devices_info:

            if not settings.accepted_nic(pci_id):
                self.logger.info("DUT: [%s %s] %s" %
                                 (pci_bus, pci_id, skipped))
                continue
            addr_array = pci_bus.split(':')
            domain_id = addr_array[0]
            bus_id = addr_array[1]
            devfun_id = addr_array[2]
            port = GetNicObj(self, domain_id, bus_id, devfun_id)
            intf = port.get_interface_name()

            macaddr = port.get_mac_addr()
            ipv6 = port.get_ipv6_addr()

            if ipv6 is None:
                ipv6 = "Not available"

            self.logger.warning("NUMA not available on FreeBSD")

            self.logger.info("DUT: [%s %s] %s %s" %
                             (pci_bus, pci_id, intf, ipv6))

            # convert bsd format to linux format
            pci_split = pci_bus.split(':')
            pci_bus_id = hex(int(pci_split[0]))[2:]
            if len(pci_split[1]) == 1:
                pci_dev_str = "0" + pci_split[1]
            else:
                pci_dev_str = pci_split[1]

            pci_str = "%s:%s.%s" % (pci_bus_id, pci_dev_str, pci_split[2])

            # store the port info to port mapping
            self.ports_info.append({
                'port': port,
                'pci': pci_str,
                'type': pci_id,
                'intf': intf,
                'mac': macaddr,
                'ipv6': ipv6,
                'numa': -1
            })
コード例 #14
0
ファイル: config.py プロジェクト: amzn/amzn-ec2-ena-utilities
    def load_ports_config(self, crbIP):
        self.ports_cfg = {}
        if self.port_conf is None:
            return

        ports = self.port_conf.load_section(crbIP)
        if ports is None:
            return
        key, config = ports[0]
        confs = self.port_conf.load_config(config)

        for config in confs:
            port_param = self.port_conf.load_param(config)

            # port config for vm in virtualization scenario
            if 'dev_idx' in port_param:
                keys = port_param.keys()
                keys.remove('dev_idx')
                self.ports_cfg[port_param['dev_idx']] = {
                    key: port_param[key] for key in keys}
                continue

            # check pci BDF validity
            if 'pci' not in port_param:
                print RED("PCI configuration could not be found")
                continue
            m = re.match(self.pci_regex, port_param['pci'])
            if m is None:
                print RED("Invalid PCI address configuration")
                continue

            keys = port_param.keys()
            keys.remove('pci')
            self.ports_cfg[port_param['pci']] = {
                key: port_param[key] for key in keys}
            if 'numa' in self.ports_cfg[port_param['pci']]:
                numa_str = self.ports_cfg[port_param['pci']]['numa']
                self.ports_cfg[port_param['pci']]['numa'] = int(numa_str)
コード例 #15
0
ファイル: config.py プロジェクト: amzn/amzn-ec2-ena-utilities
    def load_global_config(self, section_name='global'):
        global_cfg = self.global_cfg.copy()
        try:
            section_confs = self.global_conf.load_section(section_name)
        except:
            print RED("Failed to find section[%s] in the global config" % section_name)
            return global_cfg

        if section_confs is None:
            return global_cfg

        global_cfg = dict(section_confs)

        return global_cfg
コード例 #16
0
    def __init__(self, log_path):
        self.log_path = log_path

        try:
            self.log_handler = open(self.log_path, 'r')
        except:
            print RED("Failed to logfile %s" % log_path)
            return None

        self.suite_pattern = re.compile(_TESTSUITE_NAME_FORMAT_PATTERN)
        self.end_pattern = re.compile(_TESTSUITE_ENDED_FORMAT_PATTERN)
        self.case_pattern = re.compile(_TESTCASE_NAME_FORMAT_PATTERN)
        self.result_pattern = re.compile(_TESTCASE_RESULT_FORMAT_PATTERN)

        self.loglist = self.parse_logfile()
        self.log_handler.close()
コード例 #17
0
def config_ixia():
    global version
    global ixia_ip
    global ixia_ports

    print('============================================================')
    print 'Setting IXIA port for performance validation'
    ixia_ports = []
    if ixia is None or ixia == '':
        print RED("Performance request configure IXIA group in "
                  "'DUT&Tester crb' first!!!")
        return False

    version_option = {
        'prompt': 'IXIA Server version',
        'type': 'string',
        'help': 'Please input version of IxServer',
        'default': '6.62'
    }
    opt = Option(**version_option)
    version = opt.parse_input()

    ixiaip_option = {
        'prompt': 'IXIA ip address',
        'type': 'ip',
        'help': 'Please input ip address of IXIA',
        'default': '127.0.0.1'
    }
    opt = Option(**ixiaip_option)
    ixia_ip = opt.parse_input()

    ixiaport_option = {
        'prompt': 'IXIA ports which are members of this ' + 'ports group',
        'type': 'string',
        'help':
        'Please input IXIA ports, format is ' + 'card1.port1,card2.port2',
        'default': ''
    }
    opt = Option(**ixiaport_option)
    port_opt = opt.parse_input()
    ports = port_opt.split(',')
    for port in ports:
        ixia_port = port.split('.')
        if len(ixia_port) == 2:
            ixia_ports.append((ixia_port[0], ixia_port[1]))

    return True
コード例 #18
0
    def load_portmap(self):
        """
        Generate port mapping base on loaded port configuration
        """
        port_num = len(self.ports_info)
        self.ports_map = [-1] * port_num
        for key in self.ports_cfg.keys():
            index = int(key)
            if index >= port_num:
                print RED("Can not found [%d ]port info" % index)
                continue

            if 'peer' in self.ports_cfg[key].keys():
                tester_pci = self.ports_cfg[key]['peer']
                # find tester_pci index
                pci_idx = self.tester.get_local_index(tester_pci)
                self.ports_map[index] = pci_idx
コード例 #19
0
ファイル: config.py プロジェクト: amzn/amzn-ec2-ena-utilities
    def load_virt_config(self, name):
        self.virt_cfgs = []

        try:
            virt_confs = self.virt_conf.load_section(name)
        except:
            print RED("Failed to find section[%s] in the virt config" % section_name)
            return

        for virt_conf in virt_confs:
            virt_cfg = {}
            virt_params = []
            key, config = virt_conf
            confs = self.virt_conf.load_config(config)
            for config in confs:
                virt_params.append(self.load_virt_param(config))
            virt_cfg[key] = virt_params
            self.virt_cfgs.append(virt_cfg)
コード例 #20
0
    def send_expect(self, command, expected, timeout=15, verify=False):

        try:
            ret = self.send_expect_base(command, expected, timeout)
            if verify:
                ret_status = self.send_expect_base("echo $?", expected,
                                                   timeout)
                if not int(ret_status):
                    return ret
                else:
                    self.logger.error("Command: %s failure!" % command)
                    self.logger.error(ret)
                    return int(ret_status)
            else:
                return ret
        except Exception as e:
            print RED("Exception happened in [%s] and output is [%s]" %
                      (command, self.get_output_before()))
            raise (e)
コード例 #21
0
    def __init__(self, host, username, password, ssh_key=None):
        self.magic_prompt = "MAGIC PROMPT"
        try:
            SSHPexpect.connections += 1
            ssh_options = {}
            path = '{}/ssh_{}_{}.log'.format(settings.FOLDERS['Output'], host,
                                             SSHPexpect.connections)
            self.logfile = open(path, 'w')
            self.session = pxssh.pxssh(logfile=self.logfile)
            self.host = host
            self.username = username
            self.password = password
            self.ssh_key = ssh_key
            if ':' in host:
                self.ip = host.split(':')[0]
                self.port = int(host.split(':')[1])
                self.session.login(self.ip,
                                   self.username,
                                   self.password,
                                   original_prompt='[$#>]',
                                   port=self.port,
                                   login_timeout=20,
                                   ssh_key=ssh_key)
            else:
                self.session.login(self.host,
                                   self.username,
                                   self.password,
                                   original_prompt='[$#>]',
                                   ssh_key=ssh_key)
            self.send_expect("PS1='# '", '# ')
            self.send_expect('stty -echo', '# ', timeout=2)
            self.session.sendline("sudo su")
            self.session.expect('#')
            self.send_expect("PS1='# '", '# ')
        except Exception, e:
            print RED(e)
            if getattr(self, 'port', None):
                suggestion = "\nSuggession: Check if the fireware on [ %s ] " % \
                    self.ip + "is stoped\n"
                print GREEN(suggestion)

            raise SSHConnectionException(host)
コード例 #22
0
    def rescan_ports_uncached_freebsd(self):
        unknow_interface = RED('Skipped: unknow_interface')

        for port_info in self.ports_info:
            port = port_info['port']
            intf = port.get_interface_name()
            if "No such file" in intf:
                self.logger.info("DUT: [%s] %s" % (pci_bus, unknow_interface))
                continue
            self.send_expect("ifconfig %s up" % intf, "# ")
            time.sleep(5)
            macaddr = port.get_mac_addr()
            ipv6 = port.get_ipv6_addr()
            # Unconnected ports don't have IPv6
            if ipv6 is None:
                ipv6 = "Not connected"

            port_info['mac'] = macaddr
            port_info['intf'] = intf
            port_info['ipv6'] = ipv6
コード例 #23
0
def config_ports():
    global dut_ports
    dut_ports = []
    add_more = True
    pci_regex = "([\da-f]{4}:[\da-f]{2}:[\da-f]{2}.\d{1})$"
    ixia_regex = r'(\d).(\d)'

    print('============================================================')
    print("Manually configure DUT port mapping")
    if not dut_ip:
        print RED("Need to configuure 'DUT&Tester crb' first!!!")
        return False

    while add_more:
        pci_option = {
            'prompt': 'DUT port pci address',
            'type': 'string',
            'help': 'Please input DUT pci address xxxx:xx:xx.x',
            'default': ''
        }
        opt = Option(**pci_option)
        dut_addr = opt.parse_input()
        m = re.match(pci_regex, dut_addr)
        if not m:
            print RED("Pci address should follow Domain+BDF format!!!")
            continue

        if ixia and ixia != '':
            pci_option = {
                'prompt': 'Choose Tester IXIA port',
                'type': 'choice',
                'options': ixia_ports,
                'help': 'Please choice IXIA port',
                'default': '0'
            }
            opt = Option(**pci_option)
            test_addr = opt.parse_input()
            card, port = test_addr
            test_addr = 'IXIA%s.%s' % (card, port)
        else:
            pci_option = {
                'prompt': 'Tester port pci address',
                'type': 'string',
                'help': 'Please input tester pci address xxxx:xx:xx.x',
                'default': ''
            }
            opt = Option(**pci_option)
            test_addr = opt.parse_input()
            m = re.match(pci_regex, test_addr)
            if not m:
                print RED("Pci address should follow Domain+BDF format!!!")
                continue

        dut_port = {}
        dut_port[dut_addr] = test_addr
        dut_ports.append(dut_port)

        add_option = {
            'prompt': 'Whether configure another dut port',
            'type': 'bool',
            'help': 'If need more port input "Yes", otherwise ' + 'input "No"',
            'default': 'No'
        }
        opt = Option(**add_option)
        add_more = opt.parse_input()

        if not add_more:
            continue

    return True
コード例 #24
0
def config_execution():
    global driver_name
    global suites
    global target
    global nic_type

    print('============================================================')
    print "Setting execution plan"
    if not dut_ip:
        print RED("Need to configure 'DUT&Tester crb' first!!!")
        return False
    # default execution
    driver_name = 'igb_uio'
    target = 'x86_64-native-linuxapp-gcc'
    targets = [
        'x86_64-native-linuxapp-gcc', 'x86_64-native-linuxapp-icc',
        'i686-native-linuxapp-gcc', 'i686-native-linuxapp-icc',
        'x86_64-native-bsdapp-gcc', 'x86_64-native-bsdapp-clang',
        'arm64-armv8a-linuxapp-gcc', 'arm64-dpaa2-linuxapp-gcc',
        'arm64-thunderx-linuxapp-gcc', 'arm64-xgene1-linuxapp-gcc'
    ]
    nic_type = 'cfg'

    exec_option = {
        'prompt': 'Choose default or manually',
        'type': 'choice',
        'help':
        'Gernerate execution file base on default or ' + 'manually configured',
        'options':
        ['default execution file', 'manually configure execution file'],
        'default': '0'
    }
    opt = Option(**exec_option)
    opt.parse_input()
    index = opt.choice
    if index == 0:
        autoexec_option = {
            'prompt': 'Choose one of them',
            'type': 'choice',
            'help': 'Choose one of below reference ' + 'configuration file',
            'options': executions,
            'default': '3'
        }
        opt = Option(**autoexec_option)
        auto_execution = opt.parse_input()
        load_execution('executions/' + auto_execution)
    else:
        suites_option = {
            'prompt': 'Choose suites to run',
            'type': 'multichoice',
            'help': 'Suites in DTS',
            'options': suites,
            'default': 'all'
        }
        opt = Option(**suites_option)
        suites = opt.parse_input()

    nics = ['cfg']
    nics += NICS.keys()
    nic_option = {
        'prompt': 'Choose one of nics',
        'type': 'choice',
        'help': 'Choose one of dpdk support NIC',
        'options': nics,
        'default': '0'
    }
    opt = Option(**nic_option)
    nic_type = opt.parse_input()

    target_option = {
        'prompt': 'Choose target for execution',
        'type': 'choice',
        'help': 'Choose one of dpdk targets',
        'options': targets,
        'default': '0'
    }
    opt = Option(**target_option)
    target = opt.parse_input()

    driver_option = {
        'prompt': 'Choose one of them',
        'type': 'choice',
        'help': 'Choose one of dpdk support driver',
        'options': ['igb_uio', 'vfio-pci'],
        'default': '0'
    }
    opt = Option(**driver_option)
    driver_name = opt.parse_input()

    return True
コード例 #25
0
    def scan_ports_uncached_linux(self):
        """
        Scan Linux ports and collect port's pci id, mac address, ipv6 address.
        """
        self.ports_info = []

        skipped = RED('Skipped: Unknown/not selected')
        unknow_interface = RED('Skipped: unknow_interface')

        domain_id = "0000"
        bus_id = "01"
        devfun_id = "00.0"
        port = GetNicObj(self, domain_id, bus_id, devfun_id)
        port.socket = 0  # set to 0 as numa node in ls2088 is returning -1
        self.ports_info = [{
            'intf': 'eth0',
            'source': 'dpaa2',
            'mac': 'b2:c8:30:9e:a6:0b',
            'pci': 'nxp_NA',
            'numa': 1,
            'peer': '0001:00:00.0',
            'type': 'nxp:NA',
            'port': port
        }, {
            'intf': 'eth1',
            'source': 'dpaa2',
            'mac': 'b2:c8:30:9e:a6:0c',
            'pci': 'nxp_NA',
            'numa': 1,
            'peer': '0001:01:00.0',
            'type': 'nxp:NA',
            'port': port
        }]

        for (pci_bus, pci_id) in self.pci_devices_info:
            if self.check_ports_available(pci_bus, pci_id) is False:
                self.logger.info("DUT: [%s %s] %s" %
                                 (pci_bus, pci_id, skipped))
                continue

            addr_array = pci_bus.split(':')
            domain_id = addr_array[0]
            bus_id = addr_array[1]
            devfun_id = addr_array[2]

            port = GetNicObj(self, domain_id, bus_id, devfun_id)
            intf = port.get_interface_name()
            if "No such file" in intf:
                self.logger.info("DUT: [%s] %s" % (pci_bus, unknow_interface))
                continue

            macaddr = port.get_mac_addr()
            if "No such file" in intf:
                self.logger.info("DUT: [%s] %s" % (pci_bus, unknow_interface))
                continue

            numa = port.socket
            # store the port info to port mapping
            self.ports_info.append({
                'port': port,
                'pci': pci_bus,
                'type': pci_id,
                'numa': numa,
                'intf': intf,
                'mac': macaddr
            })

            if not port.get_interface2_name():
                continue

            intf = port.get_interface2_name()
            macaddr = port.get_intf2_mac_addr()
            numa = port.socket
            # store the port info to port mapping
            self.ports_info.append({
                'port': port,
                'pci': pci_bus,
                'type': pci_id,
                'numa': numa,
                'intf': intf,
                'mac': macaddr
            })
コード例 #26
0
    def map_available_ports_uncached(self):
        """
        Generate network connection mapping list.
        """
        nrPorts = len(self.ports_info)
        if nrPorts == 0:
            return

        remove = []
        self.ports_map = [-1] * nrPorts

        hits = [False] * len(self.tester.ports_info)

        for vmPort in range(nrPorts):
            vmpci = self.ports_info[vmPort]['pci']
            peer = self.get_peer_pci(vmPort)
            # if peer pci configured
            if peer is not None:
                for remotePort in range(len(self.tester.ports_info)):
                    if self.tester.ports_info[remotePort]['pci'] == peer:
                        hits[remotePort] = True
                        self.ports_map[vmPort] = remotePort
                        break
                if self.ports_map[vmPort] == -1:
                    self.logger.error("CONFIGURED TESTER PORT CANNOT FOUND!!!")
                else:
                    continue  # skip ping6 map

            # strip pci address on host for pass-through device
            hostpci = 'N/A'
            for pci_map in self.hyper.pci_maps:
                if vmpci == pci_map['guestpci']:
                    hostpci = pci_map['hostpci']
                    break

            # auto ping port map
            for remotePort in range(len(self.tester.ports_info)):
                # for two vfs connected to same tester port
                # need skip ping from devices on same pf device
                remotepci = self.tester.ports_info[remotePort]['pci']
                port_type = self.tester.ports_info[remotePort]['type']
                # IXIA port should not check whether has vfs
                if port_type != 'ixia':
                    remoteport = self.tester.ports_info[remotePort]['port']
                    vfs = []
                    # vm_dut and tester in same dut
                    host_ip = self.crb['IP'].split(':')[0]
                    if self.crb['tester IP'] == host_ip:
                        vfs = remoteport.get_sriov_vfs_pci()
                        # if hostpci is vf of tester port
                        if hostpci == remotepci or hostpci in vfs:
                            print RED("Skip ping from same PF device")
                            continue

                ipv6 = self.get_ipv6_address(vmPort)
                if ipv6 == "Not connected":
                    continue

                out = self.tester.send_ping6(remotePort, ipv6,
                                             self.get_mac_address(vmPort))

                if ('64 bytes from' in out):
                    self.logger.info("PORT MAP: [dut %d: tester %d]" %
                                     (vmPort, remotePort))
                    self.ports_map[vmPort] = remotePort
                    hits[remotePort] = True
                    continue
コード例 #27
0
ファイル: gdb.py プロジェクト: amzn/amzn-ec2-ena-utilities
 def add_tbreak(self, func_name):
     out = self.send("tbreak {}".format(func_name))
     if "not defined" in out:
         print(RED("Cannot find {}".format(func_name)))
         return -1
     return 0