test suite reviews and discussions
 help / color / mirror / Atom feed
From: "Jiajia, Sun" <sunx.jiajia@intel.com>
To: dts@dpdk.org
Subject: [dts] [PATCH v2 13/19] Add some base functions to get the device info in the testpmd
Date: Fri, 22 May 2015 17:04:06 +0800	[thread overview]
Message-ID: <1432285452-14286-14-git-send-email-sunx.jiajia@intel.com> (raw)
In-Reply-To: <1432285452-14286-1-git-send-email-sunx.jiajia@intel.com>

From: sjiajiax <sunx.jiajia@intel.com>

Signed-off-by: sjiajiax <sunx.jiajia@intel.com>
---
 framework/pmd_output.py | 92 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)

diff --git a/framework/pmd_output.py b/framework/pmd_output.py
index 473339d..4ccdd0d 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:"
@@ -113,3 +115,93 @@ class PmdOutput():
         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):
+        return self.dut.send_expect('%s' % pmd_cmd, expected, timeout=timeout,
+                                    alt_session=alt_session)
+
+    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 <port num>'.
+        """
+        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.3

  parent reply	other threads:[~2015-05-22  9:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22  9:03 [dts] [PATCH v2 00/19] *** Enable virtualization test for dts framework *** Jiajia, Sun
2015-05-22  9:03 ` [dts] [PATCH v2 01/19] Abstract the NIC device as the single class NetDevice Jiajia, Sun
2015-05-22  9:03 ` [dts] [PATCH v2 02/19] Add a base module for virtual test Jiajia, Sun
2015-05-22  9:03 ` [dts] [PATCH v2 03/19] Add QEMU KVM module based on virt_base module for KVM test cases Jiajia, Sun
2015-05-22  9:03 ` [dts] [PATCH v2 04/19] Add a module to manage the host resource Jiajia, Sun
2015-05-22  9:03 ` [dts] [PATCH v2 05/19] Add a module to instantiate the VM Jiajia, Sun
2015-05-25  6:10   ` Qiu, Michael
2015-05-25  9:14     ` Jiajia, SunX
2015-05-26  9:07       ` Qiu, Michael
2015-05-27  1:36         ` Jiajia, SunX
2015-05-22  9:03 ` [dts] [PATCH v2 06/19] Add a third-party module of qemu-guest-agent to manage VM Jiajia, Sun
2015-05-22  9:04 ` [dts] [PATCH v2 07/19] Move some general functions from dts.py to utils.py and settings.py Jiajia, Sun
2015-05-22  9:04 ` [dts] [PATCH v2 08/19] Add and move some functions because of the virtual tests and network device instantiation Jiajia, Sun
2015-05-22  9:04 ` [dts] [PATCH v2 09/19] Change and add some functions to support virtual test Jiajia, Sun
2015-05-22  9:04 ` [dts] [PATCH v2 10/19] add some exceptions to support framwork to handle virtual test exceptions Jiajia, Sun
2015-05-22  9:04 ` [dts] [PATCH v2 11/19] Add some codes to support virtual test log Jiajia, Sun
2015-05-22  9:04 ` [dts] [PATCH v2 12/19] Add some codes to make session to support virtual test Jiajia, Sun
2015-05-22  9:04 ` Jiajia, Sun [this message]
2015-05-22  9:04 ` [dts] [PATCH v2 14/19] Change some codes to support network device instantiation and virtualization test Jiajia, Sun
2015-05-22  9:04 ` [dts] [PATCH v2 15/19] Add some codes to support network instantiation in the tester module Jiajia, Sun
2015-05-22  9:04 ` [dts] [PATCH v2 16/19] Make test_case know its suite name Jiajia, Sun
2015-05-22  9:04 ` [dts] [PATCH v2 17/19] Add a global virtualization config and a config related to SRIOV KVM suite Jiajia, Sun
2015-05-22  9:04 ` [dts] [PATCH v2 18/19] Add a test plan of how to test SRIOV on the KVM ENV Jiajia, Sun
2015-05-22  9:04 ` [dts] [PATCH v2 19/19] Add a test suite to verify the SRIOV feature " Jiajia, Sun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432285452-14286-14-git-send-email-sunx.jiajia@intel.com \
    --to=sunx.jiajia@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).