From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id D9815ADA2 for ; Mon, 18 May 2015 07:07:52 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 17 May 2015 22:07:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,450,1427785200"; d="scan'208";a="494900878" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 17 May 2015 22:07:51 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t4I57lCI023317; Mon, 18 May 2015 13:07:47 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t4I57i1P001397; Mon, 18 May 2015 13:07:46 +0800 Received: (from huilongx@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t4I57iGD001393; Mon, 18 May 2015 13:07:44 +0800 From: sjiajiax To: dts@dpdk.org Date: Mon, 18 May 2015 13:07:24 +0800 Message-Id: <1431925646-1314-8-git-send-email-sunx.jiajia@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1431925646-1314-1-git-send-email-sunx.jiajia@intel.com> References: <1431925646-1314-1-git-send-email-sunx.jiajia@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dts] =?utf-8?b?W+KAmGR0cy12MeKAmSA3LzldIGFkZCBzb21lIHBtZCBmdW5j?= =?utf-8?q?tions_for_tester_to_code_the_testpmd_cases?= X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2015 05:07:53 -0000 Signed-off-by: sjiajiax --- framework/pmd_output.py | 104 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 2 deletions(-) diff --git a/framework/pmd_output.py b/framework/pmd_output.py index 97274a5..642062f 100644 --- a/framework/pmd_output.py +++ b/framework/pmd_output.py @@ -32,6 +32,7 @@ import os import re import dts +from settings import TIMEOUT class PmdOutput(): @@ -42,6 +43,7 @@ class PmdOutput(): def __init__(self, dut): self.dut = dut + self.dut.testpmd = self self.rx_pkts_prefix = "RX-packets:" self.rx_missed_prefix = "RX-missed:" self.rx_bytes_prefix = "RX-bytes:" @@ -87,10 +89,108 @@ class PmdOutput(): return self.command def start_testpmd(self, cores, param='', eal_param='', socket=0): + if "--txqflags" not in param: + param += " --txqflags=0" + if socket == 0: + corelist = '0-3' + elif socket == 1: + corelist = '10-13' + else: + corelist = '0-3' core_list = self.dut.get_core_list(cores, socket) self.coremask = dts.create_mask(core_list) - command = "./%s/app/testpmd -c %s -n %d %s -- -i %s" \ - % (self.dut.target, self.coremask, self.dut.get_memory_channels(), eal_param, param) + command = "taskset -c %s ./%s/app/testpmd -c %s -n %d %s -- -i %s" \ + % (corelist, self.dut.target, self.coremask, self.dut.get_memory_channels(), eal_param, param) out = self.dut.send_expect(command, "testpmd> ", 120) self.command = command return out + + def execute_cmd(self, pmd_cmd, expected='testpmd> ', timeout=TIMEOUT, + alt_session=False, verify=False): + return self.dut.send_expect('%s' % pmd_cmd, expected, timeout=timeout, + alt_session=alt_session, verify=verify) + + def get_value_from_string(self, key_str, regx_str, string): + """ + Get some values from the given string by the regular expression. + """ + pattern = r"(?<=%s)%s" % (key_str, regx_str) + s = re.compile(pattern) + res = s.search(string) + if type(res).__name__ == 'NoneType': + return ' ' + else: + return res.group(0) + + def get_detail_from_port_info(self, key_str, regx_str, port): + """ + Get the detail info from the output of pmd cmd 'show port info '. + """ + out = self.dut.send_expect("show port info %d" % port, "testpmd> ") + find_value = self.get_value_from_string(key_str, regx_str, out) + return find_value + + def get_port_mac(self, port_id): + """ + Get the specified port MAC. + """ + return self.get_detail_from_port_info("MAC address: ", "([0-9A-F]{2}:){5}[0-9A-F]{2}", port_id) + + def get_port_connect_socket(self, port_id): + """ + Get the socket id which the specified port is connectting with. + """ + return self.get_detail_from_port_info("Connect to socket: ", "\d+", port_id) + + def get_port_memory_socket(self, port_id): + """ + Get the socket id which the specified port memory is allocated on. + """ + return self.get_detail_from_port_info("memory allocation on the socket: ", "\d+", port_id) + + def get_port_link_status(self, port_id): + """ + Get the specified port link status now. + """ + return self.get_detail_from_port_info("Link status: ", "\d+", port_id) + + def get_port_link_speed(self, port_id): + """ + Get the specified port link speed now. + """ + return self.get_detail_from_port_info("Link speed: ", "\d+", port_id) + + def get_port_link_duplex(self, port_id): + """ + Get the specified port link mode, duplex or siplex. + """ + return self.get_detail_from_port_info("Link duplex: ", "\S+", port_id) + + def get_port_promiscuous_mode(self, port_id): + """ + Get the promiscuous mode of port. + """ + return self.get_detail_from_port_info("Promiscuous mode: ", "\S+", port_id) + + def get_port_allmulticast_mode(self, port_id): + """ + Get the allmulticast mode of port. + """ + return self.get_detail_from_port_info("Allmulticast mode: ", "\S+", port_id) + + def get_port_vlan_offload(self, port_id): + """ + Function: get the port vlan settting info. + return value: + 'strip':'on' + 'filter':'on' + 'qinq':'off' + """ + vlan_info = {} + vlan_info['strip'] = self.get_detail_from_port_info( + "strip ", '\S+', port_id) + vlan_info['filter'] = self.get_detail_from_port_info( + 'filter', '\S+', port_id) + vlan_info['qinq'] = self.get_detail_from_port_info( + 'qinq\(extend\) ', '\S+', port_id) + return vlan_info -- 1.9.0