test suite reviews and discussions
 help / color / mirror / Atom feed
From: huilongx xu <huilongx.xu@intel.com>
To: dts@dpdk.org
Cc: jingguox.fu@intel.com
Subject: [dts] [dts 3/5] [v2] add dynamic config test script
Date: Thu, 21 May 2015 16:30:18 +0800	[thread overview]
Message-ID: <1432197020-12725-4-git-send-email-huilongx.xu@intel.com> (raw)
In-Reply-To: <1432197020-12725-1-git-send-email-huilongx.xu@intel.com>

From: huilong xu <huilongx.xu@intel.com>


Signed-off-by: huilong xu <huilongx.xu@intel.com>
---
 tests/TestSuite_dynamic_config.py |  262 +++++++++++++++++++++++++++++++++++++
 1 files changed, 262 insertions(+), 0 deletions(-)
 create mode 100644 tests/TestSuite_dynamic_config.py

diff --git a/tests/TestSuite_dynamic_config.py b/tests/TestSuite_dynamic_config.py
new file mode 100644
index 0000000..d1ad49c
--- /dev/null
+++ b/tests/TestSuite_dynamic_config.py
@@ -0,0 +1,262 @@
+# BSD LICENSE
+#
+# Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#   * Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#   * Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#   * Neither the name of Intel Corporation nor the names of its
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""
+DPDK Test suite.
+
+Test the dynamic driver configuration feature.
+
+"""
+
+import dts
+
+from test_case import TestCase
+
+#
+#
+# Test class.
+#
+
+
+class TestDynamicConfig(TestCase):
+
+    #
+    #
+    #
+    # Test cases.
+    #
+
+    def set_up_all(self):
+        """
+        Run at the start of each test suite.
+
+
+        Dynamic config Prerequistites
+        """
+
+        # Based on h/w type, choose how many ports to use
+        self.dut_ports = self.dut.get_ports(self.nic)
+        print self.dut_ports
+
+        # Verify that enough ports are available
+        if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]:
+            self.verify(len(self.dut_ports) >= 2, "Insufficient ports")
+        else:
+            self.verify(len(self.dut_ports) >= 1, "Insufficient ports")
+
+        # Prepare cores and ports
+        cores = self.dut.get_core_list('1S/2C/2T')
+        coreMask = dts.create_mask(cores)
+        if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]:
+            portMask = dts.create_mask(self.dut_ports[:2])
+        else:
+            portMask = dts.create_mask([self.dut_ports[0]])
+
+        # launch app
+        cmd = "./%s/build/app/test-pmd/testpmd -c %s -n 3 -- -i --rxpt=0 \
+        --rxht=0 --rxwt=0 --txpt=39 --txht=0 --txwt=0 --portmask=%s" % (self.target, coreMask, portMask)
+
+        self.dut.send_expect("%s" % cmd, "testpmd> ", 120)
+
+        # get dest address from self.target port
+        out = self.dut.send_expect(
+            "show port info %d" % self.dut_ports[0], "testpmd> ")
+
+        self.dest = self.dut.get_mac_address(self.dut_ports[0])
+        mac_scanner = r"MAC address: (([\dA-F]{2}:){5}[\dA-F]{2})"
+
+        ret = dts.regexp(out, mac_scanner)
+
+        self.verify(ret is not None, "MAC address not found")
+        self.verify(cmp(ret.lower(), self.dest) == 0, "MAC address wrong")
+        self.verify("Promiscuous mode: enabled" in out,
+                    "wrong default promiscuous value")
+        if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]:
+            self.dut.send_expect("start", "testpmd> ", 120)
+
+    def dynamic_config_send_packet(self, portid, destMac="00:11:22:33:44:55"):
+        """
+        Send 1 packet to portid
+        """
+
+        itf = self.tester.get_interface(self.tester.get_local_port(portid))
+
+        self.tester.scapy_foreground()
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s", src="52:00:00:00:00:00")], iface="%s")' % (destMac, itf))
+
+        self.tester.scapy_execute()
+
+    def set_up(self):
+        """
+        Run before each test case.
+        """
+        pass
+
+    def test_dynamic_config_default_mode(self):
+        """
+        Dynamic config default mode test
+        """
+
+        portid = self.dut_ports[0]
+
+        # get the current rx statistic
+        out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ")
+        cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)")
+
+        # send one packet with different MAC address than the portid
+        self.dynamic_config_send_packet(portid)
+
+        pre_rxpkt = cur_rxpkt
+        out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ")
+        cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)")
+
+        # check the pakcet increasment
+        self.verify(int(cur_rxpkt) == int(pre_rxpkt)
+                    + 1, "1st packet increasement check error")
+
+        # send one packet with the portid MAC address
+        self.dynamic_config_send_packet(portid, self.dest)
+
+        pre_rxpkt = cur_rxpkt
+        out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ")
+        cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)")
+
+        # check the pakcet increasment
+        self.verify(int(cur_rxpkt) == int(pre_rxpkt)
+                    + 1, "2nd packet increasement check error")
+
+    def test_dynamic_config_disable_promiscuous(self):
+        """
+        Dynamic config disable promiscuous test
+        """
+
+        portid = self.dut_ports[0]
+        if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]:
+            self.dut.send_expect("set promisc all off", "testpmd> ")
+            out = self.dut.send_expect(
+                "show port stats %d" % self.dut_ports[1], "testpmd> ")
+            cur_rxpkt = dts.regexp(out, "TX-packets: ([0-9]+)")
+
+            self.dynamic_config_send_packet(portid)
+            pre_rxpkt = cur_rxpkt
+            out = self.dut.send_expect(
+                "show port stats %d" % self.dut_ports[1], "testpmd> ")
+            cur_rxpkt = dts.regexp(out, "TX-packets: ([0-9]+)")
+            self.verify(int(cur_rxpkt) == int(
+                pre_rxpkt), "1st packet increasment error")
+            self.dynamic_config_send_packet(portid, self.dest)
+            pre_rxpkt = cur_rxpkt
+            out = self.dut.send_expect(
+                "show port stats %d" % self.dut_ports[1], "testpmd> ")
+            cur_rxpkt = dts.regexp(out, "TX-packets: ([0-9]+)")
+            self.verify(int(cur_rxpkt) == int(
+                pre_rxpkt) + 1, "2nd packet increasment error")
+        else:
+            self.dut.send_expect("set promisc %d off" % portid, "testpmd> ")
+
+            # get the current rx statistic
+            out = self.dut.send_expect(
+                "show port stats %d" % portid, "testpmd> ")
+            cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)")
+
+            # send one packet with different MAC address than the portid
+            self.dynamic_config_send_packet(portid)
+
+            pre_rxpkt = cur_rxpkt
+            out = self.dut.send_expect(
+                "show port stats %d" % portid, "testpmd> ")
+            cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)")
+
+            # check the pakcet increasment
+            self.verify(int(cur_rxpkt) == int(
+                pre_rxpkt), "1st packet increasment error")
+
+            # send one packet with the portid MAC address
+            self.dynamic_config_send_packet(portid, self.dest)
+
+            pre_rxpkt = cur_rxpkt
+            out = self.dut.send_expect(
+                "show port stats %d" % portid, "testpmd> ")
+            cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)")
+
+            # check the pakcet increasment
+            self.verify(int(cur_rxpkt) == int(
+                pre_rxpkt) + 1, "2nd packet increasment error")
+
+    def test_dynamic_config_enable_promiscuous(self):
+        """
+        Dynamic config enable promiscuous test
+        """
+
+        portid = self.dut_ports[0]
+
+        self.dut.send_expect("set promisc %d on" % portid, "testpmd> ")
+
+        # get the current rx statistic
+        out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ")
+        cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)")
+
+        # send one packet with different MAC address than the portid
+        self.dynamic_config_send_packet(portid)
+
+        pre_rxpkt = cur_rxpkt
+        out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ")
+        cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)")
+
+        # check the pakcet increasment
+        self.verify(int(cur_rxpkt) == int(pre_rxpkt)
+                    + 1, "1st packet increasment error")
+
+        # send one packet with the portid MAC address
+        self.dynamic_config_send_packet(portid, self.dest)
+
+        pre_rxpkt = cur_rxpkt
+        out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ")
+        cur_rxpkt = dts.regexp(out, "RX-packets: ([0-9]+)")
+
+        # check the pakcet increasment
+        self.verify(int(cur_rxpkt) == int(pre_rxpkt)
+                    + 1, "2nd packet increasment error")
+
+        self.dut.send_expect("quit", "# ", 30)
+
+    def tear_down(self):
+        """
+        Run after each test case.
+        """
+        pass
+
+    def tear_down_all(self):
+        """
+        Run after each test suite.
+        """
+        pass
-- 
1.7.4.4

  parent reply	other threads:[~2015-05-21  8:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-21  8:30 [dts] [dts 0/5] [v2] add dynamic config test and update checksum offload test code huilongx xu
2015-05-21  8:30 ` [dts] [dts 1/5] [v2] add dynamic config test in default test huilongx xu
2015-05-21  8:30 ` [dts] [dts 2/5] [v2] add dynamic config test plan huilongx xu
2015-05-21  8:30 ` huilongx xu [this message]
2015-05-21  8:30 ` [dts] [dts 4/5] [v2] update checksum offload test code huilongx xu
2015-05-21  8:30 ` [dts] [dts 5/5] [v2] add fortville nic test config huilongx xu

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=1432197020-12725-4-git-send-email-huilongx.xu@intel.com \
    --to=huilongx.xu@intel.com \
    --cc=dts@dpdk.org \
    --cc=jingguox.fu@intel.com \
    /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).