test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH 1/3]  Add multiple pthread test suite,
@ 2015-11-04 10:31 Lijuan Tu
  2015-11-04 10:32 ` [dts] [PATCH 2/3] Add multiple pthread test plan Lijuan Tu
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Lijuan Tu @ 2015-11-04 10:31 UTC (permalink / raw)
  To: dts

From: lijuan tu <lijuanx.a.tu@intel.com>

             There're three cases contained in this suite
             1)Basic operation
             2)Positive Test
             3)Negative Test

Signed-off-by: lijuan tu <lijuanx.a.tu@intel.com>
---
 tests/TestSuite_multiple_pthread.py | 601 ++++++++++++++++++++++++++++++++++++
 1 file changed, 601 insertions(+)
 create mode 100644 tests/TestSuite_multiple_pthread.py

diff --git a/tests/TestSuite_multiple_pthread.py b/tests/TestSuite_multiple_pthread.py
new file mode 100644
index 0000000..197fa03
--- /dev/null
+++ b/tests/TestSuite_multiple_pthread.py
@@ -0,0 +1,601 @@
+# BSD LICENSE
+#
+# Copyright(c) 2010-2014 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 Multiple Pthread Feature
+
+"""
+
+import dts
+import time
+import re
+import os
+from test_case import TestCase
+from pmd_output import PmdOutput
+
+#
+#
+# Test class.
+#
+
+
+class TestMultiplePthread(TestCase):
+
+    #
+    #
+    #
+    # Test cases.
+    #
+
+    def set_up_all(self):
+        """
+        Run at the start of each test suite.
+        """
+        self.ports = self.dut.get_ports()
+        self.portmask = dts.create_mask(self.dut.get_ports(self.nic))
+        self.verify(len(self.ports) >= 2, "Insufficient number of ports.")
+        self.ports_socket = self.dut.get_numa_id(self.ports[0])
+        self.pmdout = PmdOutput(self.dut)
+
+    def get_stats(self, portid):
+        """
+        Get packets number from port statistic.
+        """
+        output = PmdOutput(self.dut)
+        stats = output.get_pmd_stats(portid)
+        return stats
+
+    def check_forwarding(self, ports):
+        for i in range(len(ports)):
+            if i % 2 == 0:
+                self.send_packet(ports[i], ports[i + 1])
+                self.send_packet(ports[i + 1], ports[i])
+
+    def send_packet(self, txPort, rxPort):
+        """
+        Send packages according to parameters.
+        """
+        port0_stats = self.get_stats(txPort)
+        gp0tx_bytes = port0_stats['TX-bytes']
+        port1_stats = self.get_stats(rxPort)
+        gp1rx_err = port1_stats['RX-errors']
+        gp1rx_bytes = port1_stats['RX-bytes']
+        time.sleep(5)
+
+        itf = self.tester.get_interface(self.tester.get_local_port(rxPort))
+
+        destMac = self.dut.get_mac_address(txPort)
+        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()
+        time.sleep(3)
+
+        port0_stats = self.get_stats(txPort)
+        p0tx_bytes = port0_stats['TX-bytes']
+        port1_stats = self.get_stats(rxPort)
+        p1rx_err = port1_stats['RX-errors']
+        p1rx_bytes = port1_stats['RX-bytes']
+        time.sleep(5)
+
+        p0tx_bytes -= gp0tx_bytes
+        p1rx_bytes -= gp1rx_bytes
+        p1rx_err -= gp1rx_err
+
+        self.verify(p0tx_bytes == p1rx_bytes,
+                    "Wrong TX pkts p0_tx=%d, p1_rx=%d"
+                    % (p0tx_bytes, p1rx_bytes))
+
+    def set_up(self):
+        """
+        Run before each test case.
+        """
+        pass
+
+    def basic_operation(self, lcores, corelist):
+        """
+        Basic operation
+        """
+        # lcores = '0@8,(4-5)@9'
+        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
+            % (self.target, lcores, self.portmask)
+        self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
+
+        self.dut.send_expect("set fwd mac", "testpmd>")
+        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
+        self.dut.send_expect("start", "testpmd> ")
+        out = self.dut.send_expect("show config fwd", "testpmd> ")
+        for core in corelist:
+            if core.isdigit() == True:
+                self.verify("Logical Core %s " % core in out,
+                            "set corelist error: " + out)
+
+        self.check_forwarding(self.ports)
+
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args", "#")
+        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+9\s./%s/app/testpmd" \
+            % self.target
+        scanner = re.compile(result_scanner, re.DOTALL)
+        m = scanner.finditer(out)
+        if m:
+            count = 0
+            for i in m:
+                text = i.group()
+                self.dut.alt_session.send_expect(
+                    "echo '%s' > /root/temp" % text, "#")
+                out = self.dut.alt_session.send_expect(
+                    "cat /root/temp | awk '{print $2}'", "#")
+                count += 1
+            self.verify(count == 2, "Threads running error")
+
+        self.dut.send_expect("quit", "#")
+
+    def positive_1_test(self, lcores, corelist):
+        # lcores = '0@8,(4-5)@(8-11)'
+        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
+            % (self.target, lcores, self.portmask)
+        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
+        self.dut.send_expect("set fwd mac", "testpmd>")
+        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
+        self.dut.send_expect("start", "testpmd> ")
+        out = self.dut.send_expect("show config fwd", "testpmd> ")
+        for core in corelist:
+            if core.isdigit() == True:
+                self.verify("Logical Core %s " % core in out,
+                            "set corelist error:" + out)
+
+        self.check_forwarding(self.ports)
+
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
+            head -n 2 | tail -n 1 | awk '{print $4}'", "#")
+        self.verify(out == '8',
+                    "Threads running error:cpu is %s, expect 8 ." % out)
+
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
+            tail -n 2", "#")
+        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d+\s./%s/app/testpmd" \
+            % self.target
+        scanner = re.compile(result_scanner, re.DOTALL)
+        m = scanner.finditer(out)
+        if m:
+            count = 0
+            for i in m:
+                text = i.group()
+                self.dut.alt_session.send_expect(
+                    "echo '%s' > /root/temp" % text, "#")
+                out = self.dut.alt_session.send_expect(
+                    "cat /root/temp | awk '{print $4}'", "#")
+                if out == '8' or out == '9' or out == '10' or out == '11':
+                    count += 1
+            self.verify(count == 2,
+                        "Threads running error:cpu is %s, expect 2 ." % count)
+
+        self.dut.send_expect("quit", "#")
+
+    def positive_2_test(self, lcores, corelist):
+        # lcores = '1,2@(0-4,6),(3-4,6)@5,(7,8)'
+        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
+            % (self.target, lcores, self.portmask)
+        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
+        self.dut.send_expect("set fwd mac", "testpmd>")
+        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
+        self.dut.send_expect("start", "testpmd> ")
+        out = self.dut.send_expect("show config fwd", "testpmd> ")
+        for core in corelist:
+            if core.isdigit() == True:
+                self.verify("Logical Core %s " % core in out,
+                            "set corelist error: " + out)
+
+        self.check_forwarding(self.ports)
+
+        # decode lcores work cpus
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
+            head -n 2 | tail -n 1 | awk '{print $4}'", "#")
+        self.verify(out == '1',
+                    "Threads running error:cpu is %s, expect 1 ." % out)
+
+        out = self.dut.alt_session.send_expect(
+             "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
+              head -n 4 | tail -n 1 | awk '{print $4}'", "#")
+        self.verify(out == '0' or out == '1' or out == '2' or
+                    out == '3' or out == '4' or out == '6',
+                    "Threads running error")
+
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
+             head -n 7 | tail -n 3", "#")
+        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+5\s./%s/app/testpmd" \
+            % self.target
+        scanner = re.compile(result_scanner, re.DOTALL)
+        m = scanner.finditer(out)
+        if m:
+            count = 0
+            for i in m:
+                text = i.group()
+                self.dut.alt_session.send_expect(
+                    "echo '%s' > /root/temp" % text, "#")
+                out = self.dut.alt_session.send_expect(
+                    "cat /root/temp | awk '{print $4}'", "#")
+                if out == '5':
+                    count += 1
+        self.verify(count == 3,
+                    "Threads running error:cpu is %s, expect 3 ." % count)
+
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args | tail -n 2", "#")
+        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" \
+            % self.target
+        scanner = re.compile(result_scanner, re.DOTALL)
+        m = scanner.finditer(out)
+        if m:
+            count = 0
+            for i in m:
+                text = i.group()
+                self.dut.alt_session.send_expect(
+                    "echo '%s' > /root/temp" % text, "#")
+                out = self.dut.alt_session.send_expect(
+                    "cat /root/temp | awk '{print $4}'", "#")
+                if out == '8' or out == '7':
+                    count += 1
+        self.verify(count == 2,
+                    "Threads running error:cpu is %s, expect 2 ." % count)
+
+        self.dut.send_expect("quit", "#")
+
+    def positive_3_test(self, lcores, corelist):
+        # lcores = '(0,127)@(4,5)'
+        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask='%s'" \
+            % (self.target, lcores, self.portmask)
+        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
+        self.dut.send_expect("set fwd mac", "testpmd>")
+        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
+        self.dut.send_expect("start", "testpmd> ")
+        out = self.dut.send_expect("show config fwd", "testpmd> ")
+        self.verify("Logical Core 127 " in out, "set corelist error: " + out)
+
+        self.check_forwarding(self.ports)
+
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args | tail -n 2", "#")
+
+        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" \
+            % self.target
+        scanner = re.compile(result_scanner, re.DOTALL)
+        m = scanner.finditer(out)
+        if m:
+            count = 0
+            for i in m:
+                text = i.group()
+                self.dut.alt_session.send_expect(
+                    "echo '%s' > /root/temp" % text, "#")
+                out = self.dut.alt_session.send_expect(
+                    "cat /root/temp | awk '{print $4}'", "#")
+                if out == '5' or out == '4':
+                    count += 1
+        self.verify(count == 2,
+                    "Threads running error:cpu is %s, expect 2 ." % count)
+
+        self.dut.send_expect("quit", "#")
+
+    def positive_4_test(self, lcores, corelist):
+        # lcores = '(0,64-66)@(4,5)'
+        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
+            % (self.target, lcores, self.portmask)
+        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
+        self.dut.send_expect("set fwd mac", "testpmd>")
+        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
+        self.dut.send_expect("start", "testpmd> ")
+        out = self.dut.send_expect("show config fwd", "testpmd> ")
+        self.verify("Logical Core 64 " or "Logical Core 65 " in out,
+                    "set corelist error: " + out)
+
+        self.check_forwarding(self.ports)
+
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args | tail -n 4", "#")
+
+        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" \
+            % self.target
+        scanner = re.compile(result_scanner, re.DOTALL)
+        m = scanner.finditer(out)
+        if m:
+            count = 0
+            for i in m:
+                text = i.group()
+                self.dut.alt_session.send_expect(
+                    "echo '%s' > /root/temp" % text, "#")
+                out = self.dut.alt_session.send_expect(
+                    "cat /root/temp | awk '{print $4}'", "#")
+                if out == '5' or out == '4':
+                    count += 1
+        self.verify(count == 4,
+                    "Threads running error:cpu is %s, expect 4 ." % count)
+
+        self.dut.send_expect("quit", "#")
+
+    def positive_5_test(self, lcores, corelist):
+        # lcores = '2-5,6,7-9'
+        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
+            % (self.target, lcores, self.portmask)
+        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
+        self.dut.send_expect("set fwd mac", "testpmd>")
+        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
+        self.dut.send_expect("start", "testpmd> ")
+        out = self.dut.send_expect("show config fwd", "testpmd> ")
+        for core in corelist:
+            if core.isdigit() == True:
+                self.verify("Logical Core %s " % core in out,
+                            "set corelist error: " + out)
+
+        self.check_forwarding(self.ports)
+
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
+             head -n 2 | tail -n 1 | awk '{print $4}'", "#")
+        self.verify(out == '2',
+                    "Threads running error:cpu is %s, expect 2 ." % out)
+
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
+             head -n 4 | tail -n 1 | awk '{print $4}'", "#")
+        self.verify(out == '3',
+                    "Threads running error:cpu is %s, expect 3 ." % out)
+
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
+             head -n 5 | tail -n 1 | awk '{print $4}'", "#")
+        self.verify(out == '4',
+                    "Threads running error:cpu is %s, expect 4 ." % out)
+
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
+             head -n 6 | tail -n 1 | awk '{print $4}'", "#")
+        self.verify(out == '5',
+                    "Threads running error:cpu is %s, expect 5 ." % out)
+
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
+             head -n 7 | tail -n 1 | awk '{print $4}'", "#")
+        self.verify(out == '6',
+                    "Threads running error:cpu is %s, expect 6 ." % out)
+
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
+             head -n 8 | tail -n 1 | awk '{print $4}'", "#")
+        self.verify(out == '7',
+                    "Threads running error:cpu is %s, expect 7 ." % out)
+
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
+             head -n 9 | tail -n 1 | awk '{print $4}'", "#")
+        self.verify(out == '8',
+                    "Threads running error:cpu is %s, expect 8 ." % out)
+
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
+             head -n 10 | tail -n 1 | awk '{print $4}'", "#")
+        self.verify(out == '9',
+                    "Threads running error:cpu is %s, expect 9 ." % out)
+
+        self.dut.send_expect("quit", "#")
+
+    def positive_6_test(self, lcores, corelist):
+        # lcores = '2, (3-5)@ 3'
+        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
+            % (self.target, lcores, self.portmask)
+        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
+        self.dut.send_expect("set fwd mac", "testpmd>")
+        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
+        self.dut.send_expect("start", "testpmd> ")
+        out = self.dut.send_expect("show config fwd", "testpmd> ")
+        for core in corelist:
+            if core.isdigit() == True:
+                self.verify("Logical Core %s " % core in out,
+                            "set corelist error: " + out)
+
+        self.check_forwarding(self.ports)
+
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
+             head -n 2 | tail -n 1 | awk '{print $4}'", "#")
+        self.verify(out == '2',
+                    "Threads running error:cpu is %s, expect 2 ." % out)
+
+        out = self.dut.alt_session.send_expect(
+            "ps -C testpmd -L -opid,tid,%cpu,psr,args", "#")
+        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" \
+            % self.target
+        scanner = re.compile(result_scanner, re.DOTALL)
+        m = scanner.finditer(out)
+        if m:
+            count = 0
+            for i in m:
+                text = i.group()
+                self.dut.alt_session.send_expect(
+                    "echo '%s' > /root/temp" % text, "#")
+                out = self.dut.alt_session.send_expect(
+                    "cat /root/temp | awk '{print $4}'", "#")
+                if out == '3':
+                    count += 1
+        self.verify(count == 3,
+                    "Threads running error:cpu is %s, expect 3 ." % count)
+
+        self.dut.send_expect("quit", "#")
+
+    def positive_7_test(self, lcores, corelist):
+
+        # lcores = '(0,64-66)@(4,5)'
+        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
+            % (self.target, lcores, self.portmask)
+        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
+        self.dut.send_expect("set fwd mac", "testpmd>")
+        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
+        self.dut.send_expect("start", "testpmd> ")
+        self.dut.send_expect("show config fwd", "testpmd> ")
+        self.check_forwarding(self.ports)
+
+        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" \
+            % self.target
+        scanner = re.compile(result_scanner, re.DOTALL)
+        m = scanner.finditer(out)
+        self.dut.alt_session.send_expect(
+            "cd /sys/fs/cgroup/cpu/dpdk/thread0", "#")
+        if m:
+            count = 0
+            for i in m:
+                text = i.group()
+                self.dut.alt_session.send_expect(
+                    "echo '%s' > /root/temp" % text, "#")
+                out = self.dut.alt_session.send_expect(
+                    "cat /root/temp | awk '{print $4}'", "#")
+                if out == '5' or out == '4':
+                    count += 1
+        self.verify(count == 5, "Threads running error:cpu is %s, expect 5 ."
+                    % count)
+
+        self.dut.send_expect("quit", "#")
+
+    def check_negative(self, lcores):
+        """
+        """
+        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
+            % (self.target, lcores, self.portmask)
+        self.dut.send_expect(pmd_cmd, "#", 100)
+
+    def test_basic_operation(self):
+	"""
+        Basic operation
+        """
+        lcores = '0@8,(4-5)@9'
+        corelist = ['4', '5', '4,5']
+        for core in corelist:
+            self.basic_operation(lcores, core)
+
+    def test_positive_test(self):
+	"""
+        Positive Test
+        """
+
+        # item 1
+        lcores = '0@8,(4-5)@(8-11)'
+        corelist = ['4', '5', '4,5']
+        for core in corelist:
+            self.positive_1_test(lcores, core)
+
+        # item 2
+        lcores = '1,2@(0-4,6),(3-4,6)@5,(7,8)'
+        corelist = ['2', '3', '4', '6', '7', '8',
+                    '2,3', '2,4', '2,6', '2,7', '2,8',
+                    '3,4', '3,6', '3,7', '3,8',
+                    '4,6', '4,7', '4,8',
+                    '6,7', '6,8',
+                    '7,8']
+        for core in corelist:
+            self.positive_2_test(lcores, core)
+
+        # item 3
+        lcores = '(0,127)@(4,5)'
+        corelist = ['127']
+        for core in corelist:
+            self.positive_3_test(lcores, core)
+
+        # item 4
+        lcores = '(0,64-66)@(4,5)'
+        corelist = ['64', '65', '66', '64,65', '64,66', '65,66']
+        for core in corelist:
+            self.positive_4_test(lcores, core)
+
+        # item 5
+        lcores = '2-5,6,7-9'
+        corelist = ['3', '4', '5', '6', '7', '8', '9',
+                    '3,4', '3,5', '3,6', '3,7', '3,8', '3,9',
+                    '4,5', '4,6', '4,7', '4,8', '4,9',
+                    '5,6', '5,7', '5,8', '5,9',
+                    '6,7', '6,8', '6,9',
+                    '7,8', '7,9',
+                    '8,9']
+        for core in corelist:
+            self.positive_5_test(lcores, core)
+
+        # item 6
+        lcores = '2, (3-5)@ 3'
+        corelist = ['3', '4', '5', '3,4', '3,5', '4,5']
+        for core in corelist:
+            self.positive_6_test(lcores, core)
+
+        # item 7
+        lcores = '(0,7-4)@(4,5)'
+        corelist = ['7', '6', '5', '4',
+                    '7,6', '7,5', '7,4', '6,5', '6,4', '5,4']
+        for core in corelist:
+            self.positive_7_test(lcores, core)
+
+    def test_negative_test(self):
+        """
+        Negative Test
+        """
+        lcores = [
+            '(0-,4-7)@(4,5)',
+            '(-1,4-7)@(4,5)',
+            '(0,4-7-9)@(4,5)',
+            '(0,abcd)@(4,5)',
+            '(0,4-7)@(1-,5)',
+            '(0,4-7)@(-1,5)',
+            '(0,4-7)@(4,5-8-9)',
+            '(0,4-7)@(abc,5)',
+            '(0,4-7)@(4,xyz)',
+            '(0,4-7)=(8,9)',
+            '2,3@4,(0-1,,4))',
+            '[0-,4-7]@(4,5)',
+            '(0-,4-7)@[4,5]',
+            '3-4@3,2@5-6',
+            '2,,3''2--3',
+            '2,,,3''2--3']
+        for lcore in lcores:
+            self.check_negative(lcore)
+
+    def tear_down(self):
+        """
+        Run after each test case.
+        """
+        self.dut.kill_all()
+
+    def tear_down_all(self):
+        """
+        Run after each test suite.
+        """
-- 
2.1.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dts] [PATCH 2/3]  Add multiple pthread test plan
  2015-11-04 10:31 [dts] [PATCH 1/3] Add multiple pthread test suite, Lijuan Tu
@ 2015-11-04 10:32 ` Lijuan Tu
  2015-11-09  2:34   ` Liu, Yong
  2015-11-04 10:32 ` [dts] [PATCH 3/3] add multiple_pthread in executions/execution.cfg Lijuan Tu
  2015-11-09  2:42 ` [dts] [PATCH 1/3] Add multiple pthread test suite, Liu, Yong
  2 siblings, 1 reply; 6+ messages in thread
From: Lijuan Tu @ 2015-11-04 10:32 UTC (permalink / raw)
  To: dts

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 7203 bytes --]

From: lijuan tu <lijuanx.a.tu@intel.com>

Signed-off-by: lijuan tu <lijuanx.a.tu@intel.com>
---
 test_plans/multiple_pthread_test_plan.rst | 116 ++++++++++++++++++++++++++++++
 1 file changed, 116 insertions(+)
 create mode 100644 test_plans/multiple_pthread_test_plan.rst

diff --git a/test_plans/multiple_pthread_test_plan.rst b/test_plans/multiple_pthread_test_plan.rst
new file mode 100644
index 0000000..9027f37
--- /dev/null
+++ b/test_plans/multiple_pthread_test_plan.rst
@@ -0,0 +1,116 @@
+..f
+  <COPYRIGHT_TAG>
+
+===============================
+Multiple Pthread Test Instructions
+===============================
+
+Cgroup Function Test
+--------------------------
+
+Description
+-----------
+
+This test is a basic multiple pthread test which demonstrates the basics of control group. Cgroup is a Linux kernel feature that limits, accounts for and isolates the resource usage, like CPU, memory, disk I/O, network, etc of a collection of processes. Now, it's focus on the CPU usage. 
+
+Prerequisites
+-------------
+Support igb_uio driver, kernel is 3.11+. Use "modeprobe uio" "modprobe igb_uio" and then use "./tools/dpdk_nic_bind.py --bind=igb_uio device_bus_id" to bind the ports.
+
+Assuming that an Intel� DPDK build has been set up and the testpmd
+applications have been built.
+
+Os required: Linux and FreeBSD
+
+Test Case 1: Basic operation
+--------------------------
+
+To run the application, start the testpmd with the lcoress all running with threads and also the unique core assigned, command as follows::
+
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='0@8,(4-5)@9' -n 4 -- -i --portmask=0xc
+		EAL: Master lcore 0 is ready (tid=ffd4900;cpuset=[8])
+		EAL: lcore 4 is ready (tid=873e7700;cpuset=[9])
+		EAL: lcore 5 is ready (tid=873e7700;cpuset=[9])
+To check the output, we shall make sure the lcore are init on the correct cpu. e.g. Duing INIT log we can found below:
+
+The process should start successfully and display a command prompt as follows::
+
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='0@8,(4-5)@9' -n 4 -- -i --portmask=0xc
+		Checking link statuses...
+		Port 0 Link Up - speed 10000 Mbps - full-duplex
+		Port 1 Link Up - speed 10000 Mbps - full-duplex
+		Done
+
+Start the packet forwarding as follows
+	
+		testpmd>set fwd mac
+
+Before running the test, make sure the core is a unique one otherwise, the throughput will be floating on different cores, another thing is to make sure all the logic cores are running, command as follows:
+
+		testpmd>set corelist 4,5
+
+pay attention that set corelist need to be configured before start, otherwise, it will not work
+
+		testpmd>start
+
+		testpmd>show config fwd
+
+Using the command to find the threads that's running, as follows:
+	
+		ps -C testpmd -L -opid,tid,%cpu,psr,args
+
+Result as follows:
+
+	   PID    TID %CPU PSR COMMAND
+	179459 179459  0.2   8 ./x86_64-native-linuxapp-gcc/app/testpmd --lcores=0@8,(4-5)@9 -n 4 -- -i --portmask=0xc
+	179459 179460  0.0  21 ./x86_64-native-linuxapp-gcc/app/testpmd --lcores=0@8,(4-5)@9 -n 4 -- -i --portmask=0xc
+	179461  0.0  21 ./x86_64-native-linuxapp-gcc/app/testpmd --lcores=0@8,(4-5)@9 -n 4 -- -i --portmask=0xc
+	179459 179462 80.4   9 ./x86_64-native-linuxapp-gcc/app/testpmd --lcores=0@8,(4-5)@9 -n 4 -- -i --portmask=0xc
+	179459 179463  0.0   9 ./x86_64-native-linuxapp-gcc/app/testpmd --lcores=0@8,(4-5)@9 -n 4 -- -i --portmask=0xc
+
+You will see that there are two threads running on core 9. The last 2 threads are running threads, their TID will be assigned to the tasks in the folder thread0.
+
+		cd /sys/fs/cgroup/cpu/dpdk/thread0
+		echo 179462 > tasks
+		echo 179463 > tasks
+
+Assgined the percentage of cpu these two threads occupy as follows:	
+	
+		echo 10000 > cpu.cfs_quota_us
+
+This means the two threads will totally occupy 10% of the CPU and each 5%.
+
+
+Boundary Test
+-------------------------
+
+Test Case 2: Positive Test
+---------------------------------------------
+
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='0@8,(4-5)@(8-11)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='1,2@(0-4,6),(3-4,6)@5,(7,8)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,CONFIG_RTE_MAX_LCORE-1)@(4,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,64-66)@(4,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='2-5,6,7-9' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='2, (3-5)@ 3' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+        ./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,7-4)@(4,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+
+Test Case 3: Negative Test
+---------------------------------------------------
+
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0-,4-7)@(4,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(-1,4-7)@(4,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-7-9)@(4,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,abcd)@(4,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-7)@(1-,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-7)@(-1,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-7)@(4,5-8-9)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-7)@(abc,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-7)@(4,xyz)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-7)=(8,9)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='2,3@4,(0-1,,4))' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='[0-,4-7]@(4,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0-,4-7)@[4,5]' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='3-4@3,2@5-6' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='2,,3''2--3' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
+		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='2,,,3''2--3' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
-- 
2.1.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dts] [PATCH 3/3] add multiple_pthread in executions/execution.cfg
  2015-11-04 10:31 [dts] [PATCH 1/3] Add multiple pthread test suite, Lijuan Tu
  2015-11-04 10:32 ` [dts] [PATCH 2/3] Add multiple pthread test plan Lijuan Tu
@ 2015-11-04 10:32 ` Lijuan Tu
  2015-11-09  2:42 ` [dts] [PATCH 1/3] Add multiple pthread test suite, Liu, Yong
  2 siblings, 0 replies; 6+ messages in thread
From: Lijuan Tu @ 2015-11-04 10:32 UTC (permalink / raw)
  To: dts

From: lijuan tu <lijuanx.a.tu@intel.com>

Signed-off-by: lijuan tu <lijuanx.a.tu@intel.com>
---
 executions/execution.cfg | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/executions/execution.cfg b/executions/execution.cfg
index 20d9bd6..dc97963 100644
--- a/executions/execution.cfg
+++ b/executions/execution.cfg
@@ -26,7 +26,8 @@ test_suites=
     pmdrssreta,
     pmd,
     l2fwd,
-    kni 
+    kni,
+    multiple_pthread 
 targets=
     x86_64-native-linuxapp-gcc
 parameters=nic_type=cfg:func=true
-- 
2.1.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dts] [PATCH 2/3]  Add multiple pthread test plan
  2015-11-04 10:32 ` [dts] [PATCH 2/3] Add multiple pthread test plan Lijuan Tu
@ 2015-11-09  2:34   ` Liu, Yong
  0 siblings, 0 replies; 6+ messages in thread
From: Liu, Yong @ 2015-11-09  2:34 UTC (permalink / raw)
  To: Lijuan Tu, dts

Hi Lijuan,
There's one question on this suite. In the description FreeBSD should 
also work with multiple-thread, but most commands in test plan only work 
in Linux system.

On 11/04/2015 06:32 PM, Lijuan Tu wrote:
> From: lijuan tu <lijuanx.a.tu@intel.com>
>
> Signed-off-by: lijuan tu <lijuanx.a.tu@intel.com>
> ---
>   test_plans/multiple_pthread_test_plan.rst | 116 ++++++++++++++++++++++++++++++
>   1 file changed, 116 insertions(+)
>   create mode 100644 test_plans/multiple_pthread_test_plan.rst
>
> diff --git a/test_plans/multiple_pthread_test_plan.rst b/test_plans/multiple_pthread_test_plan.rst
> new file mode 100644
> index 0000000..9027f37
> --- /dev/null
> +++ b/test_plans/multiple_pthread_test_plan.rst
> @@ -0,0 +1,116 @@
> +..f
> +  <COPYRIGHT_TAG>
> +
> +===============================
> +Multiple Pthread Test Instructions
> +===============================
> +
> +Cgroup Function Test
> +--------------------------
> +
> +Description
> +-----------
> +
> +This test is a basic multiple pthread test which demonstrates the basics of control group. Cgroup is a Linux kernel feature that limits, accounts for and isolates the resource usage, like CPU, memory, disk I/O, network, etc of a collection of processes. Now, it's focus on the CPU usage.
> +
Please limit one line to 79 characters, it will help to generate more 
readable document.
> +Prerequisites
> +-------------
> +Support igb_uio driver, kernel is 3.11+. Use "modeprobe uio" "modprobe igb_uio" and then use "./tools/dpdk_nic_bind.py --bind=igb_uio device_bus_id" to bind the ports.
> +
> +Assuming that an Intel� DPDK build has been set up and the testpmd
> +applications have been built.
> +
> +Os required: Linux and FreeBSD
For FreeBSD system, please check below comments.
> +
> +Test Case 1: Basic operation
> +--------------------------
> +
> +To run the application, start the testpmd with the lcoress all running with threads and also the unique core assigned, command as follows::
> +
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='0@8,(4-5)@9' -n 4 -- -i --portmask=0xc
> +		EAL: Master lcore 0 is ready (tid=ffd4900;cpuset=[8])
> +		EAL: lcore 4 is ready (tid=873e7700;cpuset=[9])
> +		EAL: lcore 5 is ready (tid=873e7700;cpuset=[9])
> +To check the output, we shall make sure the lcore are init on the correct cpu. e.g. Duing INIT log we can found below:
> +
> +The process should start successfully and display a command prompt as follows::
> +
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='0@8,(4-5)@9' -n 4 -- -i --portmask=0xc
> +		Checking link statuses...
> +		Port 0 Link Up - speed 10000 Mbps - full-duplex
> +		Port 1 Link Up - speed 10000 Mbps - full-duplex
> +		Done
> +
> +Start the packet forwarding as follows
> +	
> +		testpmd>set fwd mac
> +
> +Before running the test, make sure the core is a unique one otherwise, the throughput will be floating on different cores, another thing is to make sure all the logic cores are running, command as follows:

Please limit one line to 79 characters.
> +
> +		testpmd>set corelist 4,5
> +
> +pay attention that set corelist need to be configured before start, otherwise, it will not work
> +
> +		testpmd>start
> +
> +		testpmd>show config fwd
> +
> +Using the command to find the threads that's running, as follows:
> +	
> +		ps -C testpmd -L -opid,tid,%cpu,psr,args
> +
This is command may not work on Freebsd system. If this test plan work 
for Freebsd system, i think you need change the description.

> +Result as follows:
> +
> +	   PID    TID %CPU PSR COMMAND
> +	179459 179459  0.2   8 ./x86_64-native-linuxapp-gcc/app/testpmd --lcores=0@8,(4-5)@9 -n 4 -- -i --portmask=0xc
> +	179459 179460  0.0  21 ./x86_64-native-linuxapp-gcc/app/testpmd --lcores=0@8,(4-5)@9 -n 4 -- -i --portmask=0xc
> +	179461  0.0  21 ./x86_64-native-linuxapp-gcc/app/testpmd --lcores=0@8,(4-5)@9 -n 4 -- -i --portmask=0xc
> +	179459 179462 80.4   9 ./x86_64-native-linuxapp-gcc/app/testpmd --lcores=0@8,(4-5)@9 -n 4 -- -i --portmask=0xc
> +	179459 179463  0.0   9 ./x86_64-native-linuxapp-gcc/app/testpmd --lcores=0@8,(4-5)@9 -n 4 -- -i --portmask=0xc
> +
> +You will see that there are two threads running on core 9. The last 2 threads are running threads, their TID will be assigned to the tasks in the folder thread0.
> +
> +		cd /sys/fs/cgroup/cpu/dpdk/thread0
> +		echo 179462 > tasks
> +		echo 179463 > tasks

Please check whether the sys file system attributes existed on FreeBSD 
system.

> +
> +Assgined the percentage of cpu these two threads occupy as follows:	
> +	
> +		echo 10000 > cpu.cfs_quota_us
> +
> +This means the two threads will totally occupy 10% of the CPU and each 5%.
> +
> +
> +Boundary Test
> +-------------------------
> +
> +Test Case 2: Positive Test
> +---------------------------------------------
> +
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='0@8,(4-5)@(8-11)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='1,2@(0-4,6),(3-4,6)@5,(7,8)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,CONFIG_RTE_MAX_LCORE-1)@(4,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,64-66)@(4,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='2-5,6,7-9' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='2, (3-5)@ 3' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +        ./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,7-4)@(4,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +
> +Test Case 3: Negative Test
> +---------------------------------------------------
> +
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0-,4-7)@(4,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(-1,4-7)@(4,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-7-9)@(4,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,abcd)@(4,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-7)@(1-,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-7)@(-1,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-7)@(4,5-8-9)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-7)@(abc,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-7)@(4,xyz)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-7)=(8,9)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='2,3@4,(0-1,,4))' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='[0-,4-7]@(4,5)' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0-,4-7)@[4,5]' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='3-4@3,2@5-6' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='2,,3''2--3' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32
> +		./x86_64-native-linuxapp-gcc/app/testpmd --lcores='2,,,3''2--3' -n 4 -- -i --txfreet=32 --rxfreet=32 --txqflags=0xf01 --txrst=32

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dts] [PATCH 1/3]  Add multiple pthread test suite,
  2015-11-04 10:31 [dts] [PATCH 1/3] Add multiple pthread test suite, Lijuan Tu
  2015-11-04 10:32 ` [dts] [PATCH 2/3] Add multiple pthread test plan Lijuan Tu
  2015-11-04 10:32 ` [dts] [PATCH 3/3] add multiple_pthread in executions/execution.cfg Lijuan Tu
@ 2015-11-09  2:42 ` Liu, Yong
  2015-11-09  2:46   ` Tu, LijuanX A
  2 siblings, 1 reply; 6+ messages in thread
From: Liu, Yong @ 2015-11-09  2:42 UTC (permalink / raw)
  To: Lijuan Tu, dts

Lijuan,
You may need one function to strip lcore of one application. This 
function will reduce lots of redundant codes.
The function should like below. Further more, it's better to implement 
it in crb.py and support both FreeBSD and Linux.

def strip_lcore_byname(app_name="testpmd")
     lcores = []
     ...
     return lcores


On 11/04/2015 06:31 PM, Lijuan Tu wrote:
> From: lijuan tu <lijuanx.a.tu@intel.com>
>
>               There're three cases contained in this suite
>               1)Basic operation
>               2)Positive Test
>               3)Negative Test
>
> Signed-off-by: lijuan tu <lijuanx.a.tu@intel.com>
> ---
>   tests/TestSuite_multiple_pthread.py | 601 ++++++++++++++++++++++++++++++++++++
>   1 file changed, 601 insertions(+)
>   create mode 100644 tests/TestSuite_multiple_pthread.py
>
> diff --git a/tests/TestSuite_multiple_pthread.py b/tests/TestSuite_multiple_pthread.py
> new file mode 100644
> index 0000000..197fa03
> --- /dev/null
> +++ b/tests/TestSuite_multiple_pthread.py
> @@ -0,0 +1,601 @@
> +# BSD LICENSE
> +#
> +# Copyright(c) 2010-2014 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 Multiple Pthread Feature
> +
> +"""
> +
> +import dts
> +import time
> +import re
> +import os
> +from test_case import TestCase
> +from pmd_output import PmdOutput
> +
> +#
> +#
> +# Test class.
> +#
> +
> +
> +class TestMultiplePthread(TestCase):
> +
> +    #
> +    #
> +    #
> +    # Test cases.
> +    #
> +
> +    def set_up_all(self):
> +        """
> +        Run at the start of each test suite.
> +        """
> +        self.ports = self.dut.get_ports()
> +        self.portmask = dts.create_mask(self.dut.get_ports(self.nic))
> +        self.verify(len(self.ports) >= 2, "Insufficient number of ports.")
> +        self.ports_socket = self.dut.get_numa_id(self.ports[0])
> +        self.pmdout = PmdOutput(self.dut)
> +
> +    def get_stats(self, portid):
> +        """
> +        Get packets number from port statistic.
> +        """
> +        output = PmdOutput(self.dut)
> +        stats = output.get_pmd_stats(portid)
> +        return stats
> +
> +    def check_forwarding(self, ports):
> +        for i in range(len(ports)):
> +            if i % 2 == 0:
> +                self.send_packet(ports[i], ports[i + 1])
> +                self.send_packet(ports[i + 1], ports[i])
> +
> +    def send_packet(self, txPort, rxPort):
> +        """
> +        Send packages according to parameters.
> +        """
> +        port0_stats = self.get_stats(txPort)
> +        gp0tx_bytes = port0_stats['TX-bytes']
> +        port1_stats = self.get_stats(rxPort)
> +        gp1rx_err = port1_stats['RX-errors']
> +        gp1rx_bytes = port1_stats['RX-bytes']
> +        time.sleep(5)
> +
> +        itf = self.tester.get_interface(self.tester.get_local_port(rxPort))
> +
> +        destMac = self.dut.get_mac_address(txPort)
> +        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()
> +        time.sleep(3)
> +
> +        port0_stats = self.get_stats(txPort)
> +        p0tx_bytes = port0_stats['TX-bytes']
> +        port1_stats = self.get_stats(rxPort)
> +        p1rx_err = port1_stats['RX-errors']
> +        p1rx_bytes = port1_stats['RX-bytes']
> +        time.sleep(5)
> +
> +        p0tx_bytes -= gp0tx_bytes
> +        p1rx_bytes -= gp1rx_bytes
> +        p1rx_err -= gp1rx_err
> +
> +        self.verify(p0tx_bytes == p1rx_bytes,
> +                    "Wrong TX pkts p0_tx=%d, p1_rx=%d"
> +                    % (p0tx_bytes, p1rx_bytes))
> +
> +    def set_up(self):
> +        """
> +        Run before each test case.
> +        """
> +        pass
> +
> +    def basic_operation(self, lcores, corelist):
> +        """
> +        Basic operation
> +        """
> +        # lcores = '0@8,(4-5)@9'
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
> +            % (self.target, lcores, self.portmask)
> +        self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
> +
> +        self.dut.send_expect("set fwd mac", "testpmd>")
> +        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
> +        self.dut.send_expect("start", "testpmd> ")
> +        out = self.dut.send_expect("show config fwd", "testpmd> ")
> +        for core in corelist:
> +            if core.isdigit() == True:
> +                self.verify("Logical Core %s " % core in out,
> +                            "set corelist error: " + out)
> +
> +        self.check_forwarding(self.ports)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args", "#")
> +        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+9\s./%s/app/testpmd" \
> +            % self.target
> +        scanner = re.compile(result_scanner, re.DOTALL)
> +        m = scanner.finditer(out)
> +        if m:
> +            count = 0
> +            for i in m:
> +                text = i.group()
> +                self.dut.alt_session.send_expect(
> +                    "echo '%s' > /root/temp" % text, "#")
> +                out = self.dut.alt_session.send_expect(
> +                    "cat /root/temp | awk '{print $2}'", "#")
> +                count += 1
> +            self.verify(count == 2, "Threads running error")
> +
Most cases need the function that can strip the lcores used by testpmd.
It's better implement it as one function, that can be called by test cases.


> +        self.dut.send_expect("quit", "#")
> +
> +    def positive_1_test(self, lcores, corelist):
> +        # lcores = '0@8,(4-5)@(8-11)'
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
> +            % (self.target, lcores, self.portmask)
> +        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
> +        self.dut.send_expect("set fwd mac", "testpmd>")
> +        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
> +        self.dut.send_expect("start", "testpmd> ")
> +        out = self.dut.send_expect("show config fwd", "testpmd> ")
> +        for core in corelist:
> +            if core.isdigit() == True:
> +                self.verify("Logical Core %s " % core in out,
> +                            "set corelist error:" + out)
> +
> +        self.check_forwarding(self.ports)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +            head -n 2 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '8',
> +                    "Threads running error:cpu is %s, expect 8 ." % out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +            tail -n 2", "#")
> +        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d+\s./%s/app/testpmd" \
> +            % self.target
> +        scanner = re.compile(result_scanner, re.DOTALL)
> +        m = scanner.finditer(out)
> +        if m:
> +            count = 0
> +            for i in m:
> +                text = i.group()
> +                self.dut.alt_session.send_expect(
> +                    "echo '%s' > /root/temp" % text, "#")
> +                out = self.dut.alt_session.send_expect(
> +                    "cat /root/temp | awk '{print $4}'", "#")
> +                if out == '8' or out == '9' or out == '10' or out == '11':
> +                    count += 1
> +            self.verify(count == 2,
> +                        "Threads running error:cpu is %s, expect 2 ." % count)
> +
> +        self.dut.send_expect("quit", "#")
> +
> +    def positive_2_test(self, lcores, corelist):
> +        # lcores = '1,2@(0-4,6),(3-4,6)@5,(7,8)'
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
> +            % (self.target, lcores, self.portmask)
> +        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
> +        self.dut.send_expect("set fwd mac", "testpmd>")
> +        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
> +        self.dut.send_expect("start", "testpmd> ")
> +        out = self.dut.send_expect("show config fwd", "testpmd> ")
> +        for core in corelist:
> +            if core.isdigit() == True:
> +                self.verify("Logical Core %s " % core in out,
> +                            "set corelist error: " + out)
> +
> +        self.check_forwarding(self.ports)
> +
> +        # decode lcores work cpus
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +            head -n 2 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '1',
> +                    "Threads running error:cpu is %s, expect 1 ." % out)
> +
> +        out = self.dut.alt_session.send_expect(
> +             "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +              head -n 4 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '0' or out == '1' or out == '2' or
> +                    out == '3' or out == '4' or out == '6',
> +                    "Threads running error")
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 7 | tail -n 3", "#")
> +        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+5\s./%s/app/testpmd" \
> +            % self.target
> +        scanner = re.compile(result_scanner, re.DOTALL)
> +        m = scanner.finditer(out)
> +        if m:
> +            count = 0
> +            for i in m:
> +                text = i.group()
> +                self.dut.alt_session.send_expect(
> +                    "echo '%s' > /root/temp" % text, "#")
> +                out = self.dut.alt_session.send_expect(
> +                    "cat /root/temp | awk '{print $4}'", "#")
> +                if out == '5':
> +                    count += 1
> +        self.verify(count == 3,
> +                    "Threads running error:cpu is %s, expect 3 ." % count)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | tail -n 2", "#")
> +        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" \
> +            % self.target
> +        scanner = re.compile(result_scanner, re.DOTALL)
> +        m = scanner.finditer(out)
> +        if m:
> +            count = 0
> +            for i in m:
> +                text = i.group()
> +                self.dut.alt_session.send_expect(
> +                    "echo '%s' > /root/temp" % text, "#")
> +                out = self.dut.alt_session.send_expect(
> +                    "cat /root/temp | awk '{print $4}'", "#")
> +                if out == '8' or out == '7':
> +                    count += 1
> +        self.verify(count == 2,
> +                    "Threads running error:cpu is %s, expect 2 ." % count)
> +
> +        self.dut.send_expect("quit", "#")
> +
> +    def positive_3_test(self, lcores, corelist):
> +        # lcores = '(0,127)@(4,5)'
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask='%s'" \
> +            % (self.target, lcores, self.portmask)
> +        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
> +        self.dut.send_expect("set fwd mac", "testpmd>")
> +        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
> +        self.dut.send_expect("start", "testpmd> ")
> +        out = self.dut.send_expect("show config fwd", "testpmd> ")
> +        self.verify("Logical Core 127 " in out, "set corelist error: " + out)
> +
> +        self.check_forwarding(self.ports)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | tail -n 2", "#")
> +
> +        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" \
> +            % self.target
> +        scanner = re.compile(result_scanner, re.DOTALL)
> +        m = scanner.finditer(out)
> +        if m:
> +            count = 0
> +            for i in m:
> +                text = i.group()
> +                self.dut.alt_session.send_expect(
> +                    "echo '%s' > /root/temp" % text, "#")
> +                out = self.dut.alt_session.send_expect(
> +                    "cat /root/temp | awk '{print $4}'", "#")
> +                if out == '5' or out == '4':
> +                    count += 1
> +        self.verify(count == 2,
> +                    "Threads running error:cpu is %s, expect 2 ." % count)
> +
> +        self.dut.send_expect("quit", "#")
> +
> +    def positive_4_test(self, lcores, corelist):
> +        # lcores = '(0,64-66)@(4,5)'
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
> +            % (self.target, lcores, self.portmask)
> +        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
> +        self.dut.send_expect("set fwd mac", "testpmd>")
> +        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
> +        self.dut.send_expect("start", "testpmd> ")
> +        out = self.dut.send_expect("show config fwd", "testpmd> ")
> +        self.verify("Logical Core 64 " or "Logical Core 65 " in out,
> +                    "set corelist error: " + out)
> +
> +        self.check_forwarding(self.ports)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | tail -n 4", "#")
> +
> +        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" \
> +            % self.target
> +        scanner = re.compile(result_scanner, re.DOTALL)
> +        m = scanner.finditer(out)
> +        if m:
> +            count = 0
> +            for i in m:
> +                text = i.group()
> +                self.dut.alt_session.send_expect(
> +                    "echo '%s' > /root/temp" % text, "#")
> +                out = self.dut.alt_session.send_expect(
> +                    "cat /root/temp | awk '{print $4}'", "#")
> +                if out == '5' or out == '4':
> +                    count += 1
> +        self.verify(count == 4,
> +                    "Threads running error:cpu is %s, expect 4 ." % count)
> +
> +        self.dut.send_expect("quit", "#")
> +
> +    def positive_5_test(self, lcores, corelist):
> +        # lcores = '2-5,6,7-9'
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
> +            % (self.target, lcores, self.portmask)
> +        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
> +        self.dut.send_expect("set fwd mac", "testpmd>")
> +        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
> +        self.dut.send_expect("start", "testpmd> ")
> +        out = self.dut.send_expect("show config fwd", "testpmd> ")
> +        for core in corelist:
> +            if core.isdigit() == True:
> +                self.verify("Logical Core %s " % core in out,
> +                            "set corelist error: " + out)
> +
> +        self.check_forwarding(self.ports)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 2 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '2',
> +                    "Threads running error:cpu is %s, expect 2 ." % out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 4 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '3',
> +                    "Threads running error:cpu is %s, expect 3 ." % out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 5 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '4',
> +                    "Threads running error:cpu is %s, expect 4 ." % out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 6 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '5',
> +                    "Threads running error:cpu is %s, expect 5 ." % out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 7 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '6',
> +                    "Threads running error:cpu is %s, expect 6 ." % out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 8 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '7',
> +                    "Threads running error:cpu is %s, expect 7 ." % out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 9 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '8',
> +                    "Threads running error:cpu is %s, expect 8 ." % out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 10 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '9',
> +                    "Threads running error:cpu is %s, expect 9 ." % out)
> +
> +        self.dut.send_expect("quit", "#")
> +
> +    def positive_6_test(self, lcores, corelist):
> +        # lcores = '2, (3-5)@ 3'
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
> +            % (self.target, lcores, self.portmask)
> +        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
> +        self.dut.send_expect("set fwd mac", "testpmd>")
> +        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
> +        self.dut.send_expect("start", "testpmd> ")
> +        out = self.dut.send_expect("show config fwd", "testpmd> ")
> +        for core in corelist:
> +            if core.isdigit() == True:
> +                self.verify("Logical Core %s " % core in out,
> +                            "set corelist error: " + out)
> +
> +        self.check_forwarding(self.ports)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 2 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '2',
> +                    "Threads running error:cpu is %s, expect 2 ." % out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args", "#")
> +        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" \
> +            % self.target
> +        scanner = re.compile(result_scanner, re.DOTALL)
> +        m = scanner.finditer(out)
> +        if m:
> +            count = 0
> +            for i in m:
> +                text = i.group()
> +                self.dut.alt_session.send_expect(
> +                    "echo '%s' > /root/temp" % text, "#")
> +                out = self.dut.alt_session.send_expect(
> +                    "cat /root/temp | awk '{print $4}'", "#")
> +                if out == '3':
> +                    count += 1
> +        self.verify(count == 3,
> +                    "Threads running error:cpu is %s, expect 3 ." % count)
> +
> +        self.dut.send_expect("quit", "#")
> +
> +    def positive_7_test(self, lcores, corelist):
> +
> +        # lcores = '(0,64-66)@(4,5)'
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
> +            % (self.target, lcores, self.portmask)
> +        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
> +        self.dut.send_expect("set fwd mac", "testpmd>")
> +        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
> +        self.dut.send_expect("start", "testpmd> ")
> +        self.dut.send_expect("show config fwd", "testpmd> ")
> +        self.check_forwarding(self.ports)
> +
> +        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" \
> +            % self.target
> +        scanner = re.compile(result_scanner, re.DOTALL)
> +        m = scanner.finditer(out)
> +        self.dut.alt_session.send_expect(
> +            "cd /sys/fs/cgroup/cpu/dpdk/thread0", "#")
> +        if m:
> +            count = 0
> +            for i in m:
> +                text = i.group()
> +                self.dut.alt_session.send_expect(
> +                    "echo '%s' > /root/temp" % text, "#")
> +                out = self.dut.alt_session.send_expect(
> +                    "cat /root/temp | awk '{print $4}'", "#")
> +                if out == '5' or out == '4':
> +                    count += 1
> +        self.verify(count == 5, "Threads running error:cpu is %s, expect 5 ."
> +                    % count)
> +
> +        self.dut.send_expect("quit", "#")
> +
> +    def check_negative(self, lcores):
> +        """
> +        """
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
> +            % (self.target, lcores, self.portmask)
> +        self.dut.send_expect(pmd_cmd, "#", 100)
> +
> +    def test_basic_operation(self):
> +	"""
> +        Basic operation
> +        """
> +        lcores = '0@8,(4-5)@9'
> +        corelist = ['4', '5', '4,5']
> +        for core in corelist:
> +            self.basic_operation(lcores, core)
> +
> +    def test_positive_test(self):
> +	"""
> +        Positive Test
> +        """
> +
> +        # item 1
> +        lcores = '0@8,(4-5)@(8-11)'
> +        corelist = ['4', '5', '4,5']
> +        for core in corelist:
> +            self.positive_1_test(lcores, core)
> +
> +        # item 2
> +        lcores = '1,2@(0-4,6),(3-4,6)@5,(7,8)'
> +        corelist = ['2', '3', '4', '6', '7', '8',
> +                    '2,3', '2,4', '2,6', '2,7', '2,8',
> +                    '3,4', '3,6', '3,7', '3,8',
> +                    '4,6', '4,7', '4,8',
> +                    '6,7', '6,8',
> +                    '7,8']
> +        for core in corelist:
> +            self.positive_2_test(lcores, core)
> +
> +        # item 3
> +        lcores = '(0,127)@(4,5)'
> +        corelist = ['127']
> +        for core in corelist:
> +            self.positive_3_test(lcores, core)
> +
> +        # item 4
> +        lcores = '(0,64-66)@(4,5)'
> +        corelist = ['64', '65', '66', '64,65', '64,66', '65,66']
> +        for core in corelist:
> +            self.positive_4_test(lcores, core)
> +
> +        # item 5
> +        lcores = '2-5,6,7-9'
> +        corelist = ['3', '4', '5', '6', '7', '8', '9',
> +                    '3,4', '3,5', '3,6', '3,7', '3,8', '3,9',
> +                    '4,5', '4,6', '4,7', '4,8', '4,9',
> +                    '5,6', '5,7', '5,8', '5,9',
> +                    '6,7', '6,8', '6,9',
> +                    '7,8', '7,9',
> +                    '8,9']
> +        for core in corelist:
> +            self.positive_5_test(lcores, core)
> +
> +        # item 6
> +        lcores = '2, (3-5)@ 3'
> +        corelist = ['3', '4', '5', '3,4', '3,5', '4,5']
> +        for core in corelist:
> +            self.positive_6_test(lcores, core)
> +
> +        # item 7
> +        lcores = '(0,7-4)@(4,5)'
> +        corelist = ['7', '6', '5', '4',
> +                    '7,6', '7,5', '7,4', '6,5', '6,4', '5,4']
> +        for core in corelist:
> +            self.positive_7_test(lcores, core)
> +
> +    def test_negative_test(self):
> +        """
> +        Negative Test
> +        """
> +        lcores = [
> +            '(0-,4-7)@(4,5)',
> +            '(-1,4-7)@(4,5)',
> +            '(0,4-7-9)@(4,5)',
> +            '(0,abcd)@(4,5)',
> +            '(0,4-7)@(1-,5)',
> +            '(0,4-7)@(-1,5)',
> +            '(0,4-7)@(4,5-8-9)',
> +            '(0,4-7)@(abc,5)',
> +            '(0,4-7)@(4,xyz)',
> +            '(0,4-7)=(8,9)',
> +            '2,3@4,(0-1,,4))',
> +            '[0-,4-7]@(4,5)',
> +            '(0-,4-7)@[4,5]',
> +            '3-4@3,2@5-6',
> +            '2,,3''2--3',
> +            '2,,,3''2--3']
> +        for lcore in lcores:
> +            self.check_negative(lcore)
> +
> +    def tear_down(self):
> +        """
> +        Run after each test case.
> +        """
> +        self.dut.kill_all()
> +
> +    def tear_down_all(self):
> +        """
> +        Run after each test suite.
> +        """

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dts] [PATCH 1/3]  Add multiple pthread test suite,
  2015-11-09  2:42 ` [dts] [PATCH 1/3] Add multiple pthread test suite, Liu, Yong
@ 2015-11-09  2:46   ` Tu, LijuanX A
  0 siblings, 0 replies; 6+ messages in thread
From: Tu, LijuanX A @ 2015-11-09  2:46 UTC (permalink / raw)
  To: Liu, Yong, dts

Thanks for your advise ,I will do it as soon as possible

-----Original Message-----
From: Liu, Yong 
Sent: Monday, November 09, 2015 10:42 AM
To: Tu, LijuanX A; dts@dpdk.org
Subject: Re: [dts] [PATCH 1/3] Add multiple pthread test suite,

Lijuan,
You may need one function to strip lcore of one application. This function will reduce lots of redundant codes.
The function should like below. Further more, it's better to implement it in crb.py and support both FreeBSD and Linux.

def strip_lcore_byname(app_name="testpmd")
     lcores = []
     ...
     return lcores


On 11/04/2015 06:31 PM, Lijuan Tu wrote:
> From: lijuan tu <lijuanx.a.tu@intel.com>
>
>               There're three cases contained in this suite
>               1)Basic operation
>               2)Positive Test
>               3)Negative Test
>
> Signed-off-by: lijuan tu <lijuanx.a.tu@intel.com>
> ---
>   tests/TestSuite_multiple_pthread.py | 601 ++++++++++++++++++++++++++++++++++++
>   1 file changed, 601 insertions(+)
>   create mode 100644 tests/TestSuite_multiple_pthread.py
>
> diff --git a/tests/TestSuite_multiple_pthread.py 
> b/tests/TestSuite_multiple_pthread.py
> new file mode 100644
> index 0000000..197fa03
> --- /dev/null
> +++ b/tests/TestSuite_multiple_pthread.py
> @@ -0,0 +1,601 @@
> +# BSD LICENSE
> +#
> +# Copyright(c) 2010-2014 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 Multiple Pthread Feature
> +
> +"""
> +
> +import dts
> +import time
> +import re
> +import os
> +from test_case import TestCase
> +from pmd_output import PmdOutput
> +
> +#
> +#
> +# Test class.
> +#
> +
> +
> +class TestMultiplePthread(TestCase):
> +
> +    #
> +    #
> +    #
> +    # Test cases.
> +    #
> +
> +    def set_up_all(self):
> +        """
> +        Run at the start of each test suite.
> +        """
> +        self.ports = self.dut.get_ports()
> +        self.portmask = dts.create_mask(self.dut.get_ports(self.nic))
> +        self.verify(len(self.ports) >= 2, "Insufficient number of ports.")
> +        self.ports_socket = self.dut.get_numa_id(self.ports[0])
> +        self.pmdout = PmdOutput(self.dut)
> +
> +    def get_stats(self, portid):
> +        """
> +        Get packets number from port statistic.
> +        """
> +        output = PmdOutput(self.dut)
> +        stats = output.get_pmd_stats(portid)
> +        return stats
> +
> +    def check_forwarding(self, ports):
> +        for i in range(len(ports)):
> +            if i % 2 == 0:
> +                self.send_packet(ports[i], ports[i + 1])
> +                self.send_packet(ports[i + 1], ports[i])
> +
> +    def send_packet(self, txPort, rxPort):
> +        """
> +        Send packages according to parameters.
> +        """
> +        port0_stats = self.get_stats(txPort)
> +        gp0tx_bytes = port0_stats['TX-bytes']
> +        port1_stats = self.get_stats(rxPort)
> +        gp1rx_err = port1_stats['RX-errors']
> +        gp1rx_bytes = port1_stats['RX-bytes']
> +        time.sleep(5)
> +
> +        itf = 
> + self.tester.get_interface(self.tester.get_local_port(rxPort))
> +
> +        destMac = self.dut.get_mac_address(txPort)
> +        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()
> +        time.sleep(3)
> +
> +        port0_stats = self.get_stats(txPort)
> +        p0tx_bytes = port0_stats['TX-bytes']
> +        port1_stats = self.get_stats(rxPort)
> +        p1rx_err = port1_stats['RX-errors']
> +        p1rx_bytes = port1_stats['RX-bytes']
> +        time.sleep(5)
> +
> +        p0tx_bytes -= gp0tx_bytes
> +        p1rx_bytes -= gp1rx_bytes
> +        p1rx_err -= gp1rx_err
> +
> +        self.verify(p0tx_bytes == p1rx_bytes,
> +                    "Wrong TX pkts p0_tx=%d, p1_rx=%d"
> +                    % (p0tx_bytes, p1rx_bytes))
> +
> +    def set_up(self):
> +        """
> +        Run before each test case.
> +        """
> +        pass
> +
> +    def basic_operation(self, lcores, corelist):
> +        """
> +        Basic operation
> +        """
> +        # lcores = '0@8,(4-5)@9'
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
> +            % (self.target, lcores, self.portmask)
> +        self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
> +
> +        self.dut.send_expect("set fwd mac", "testpmd>")
> +        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
> +        self.dut.send_expect("start", "testpmd> ")
> +        out = self.dut.send_expect("show config fwd", "testpmd> ")
> +        for core in corelist:
> +            if core.isdigit() == True:
> +                self.verify("Logical Core %s " % core in out,
> +                            "set corelist error: " + out)
> +
> +        self.check_forwarding(self.ports)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args", "#")
> +        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+9\s./%s/app/testpmd" \
> +            % self.target
> +        scanner = re.compile(result_scanner, re.DOTALL)
> +        m = scanner.finditer(out)
> +        if m:
> +            count = 0
> +            for i in m:
> +                text = i.group()
> +                self.dut.alt_session.send_expect(
> +                    "echo '%s' > /root/temp" % text, "#")
> +                out = self.dut.alt_session.send_expect(
> +                    "cat /root/temp | awk '{print $2}'", "#")
> +                count += 1
> +            self.verify(count == 2, "Threads running error")
> +
Most cases need the function that can strip the lcores used by testpmd.
It's better implement it as one function, that can be called by test cases.


> +        self.dut.send_expect("quit", "#")
> +
> +    def positive_1_test(self, lcores, corelist):
> +        # lcores = '0@8,(4-5)@(8-11)'
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
> +            % (self.target, lcores, self.portmask)
> +        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
> +        self.dut.send_expect("set fwd mac", "testpmd>")
> +        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
> +        self.dut.send_expect("start", "testpmd> ")
> +        out = self.dut.send_expect("show config fwd", "testpmd> ")
> +        for core in corelist:
> +            if core.isdigit() == True:
> +                self.verify("Logical Core %s " % core in out,
> +                            "set corelist error:" + out)
> +
> +        self.check_forwarding(self.ports)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +            head -n 2 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '8',
> +                    "Threads running error:cpu is %s, expect 8 ." % 
> + out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +            tail -n 2", "#")
> +        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d+\s./%s/app/testpmd" \
> +            % self.target
> +        scanner = re.compile(result_scanner, re.DOTALL)
> +        m = scanner.finditer(out)
> +        if m:
> +            count = 0
> +            for i in m:
> +                text = i.group()
> +                self.dut.alt_session.send_expect(
> +                    "echo '%s' > /root/temp" % text, "#")
> +                out = self.dut.alt_session.send_expect(
> +                    "cat /root/temp | awk '{print $4}'", "#")
> +                if out == '8' or out == '9' or out == '10' or out == '11':
> +                    count += 1
> +            self.verify(count == 2,
> +                        "Threads running error:cpu is %s, expect 2 ." 
> + % count)
> +
> +        self.dut.send_expect("quit", "#")
> +
> +    def positive_2_test(self, lcores, corelist):
> +        # lcores = '1,2@(0-4,6),(3-4,6)@5,(7,8)'
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
> +            % (self.target, lcores, self.portmask)
> +        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
> +        self.dut.send_expect("set fwd mac", "testpmd>")
> +        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
> +        self.dut.send_expect("start", "testpmd> ")
> +        out = self.dut.send_expect("show config fwd", "testpmd> ")
> +        for core in corelist:
> +            if core.isdigit() == True:
> +                self.verify("Logical Core %s " % core in out,
> +                            "set corelist error: " + out)
> +
> +        self.check_forwarding(self.ports)
> +
> +        # decode lcores work cpus
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +            head -n 2 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '1',
> +                    "Threads running error:cpu is %s, expect 1 ." % 
> + out)
> +
> +        out = self.dut.alt_session.send_expect(
> +             "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +              head -n 4 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '0' or out == '1' or out == '2' or
> +                    out == '3' or out == '4' or out == '6',
> +                    "Threads running error")
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 7 | tail -n 3", "#")
> +        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+5\s./%s/app/testpmd" \
> +            % self.target
> +        scanner = re.compile(result_scanner, re.DOTALL)
> +        m = scanner.finditer(out)
> +        if m:
> +            count = 0
> +            for i in m:
> +                text = i.group()
> +                self.dut.alt_session.send_expect(
> +                    "echo '%s' > /root/temp" % text, "#")
> +                out = self.dut.alt_session.send_expect(
> +                    "cat /root/temp | awk '{print $4}'", "#")
> +                if out == '5':
> +                    count += 1
> +        self.verify(count == 3,
> +                    "Threads running error:cpu is %s, expect 3 ." % 
> + count)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | tail -n 2", "#")
> +        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" \
> +            % self.target
> +        scanner = re.compile(result_scanner, re.DOTALL)
> +        m = scanner.finditer(out)
> +        if m:
> +            count = 0
> +            for i in m:
> +                text = i.group()
> +                self.dut.alt_session.send_expect(
> +                    "echo '%s' > /root/temp" % text, "#")
> +                out = self.dut.alt_session.send_expect(
> +                    "cat /root/temp | awk '{print $4}'", "#")
> +                if out == '8' or out == '7':
> +                    count += 1
> +        self.verify(count == 2,
> +                    "Threads running error:cpu is %s, expect 2 ." % 
> + count)
> +
> +        self.dut.send_expect("quit", "#")
> +
> +    def positive_3_test(self, lcores, corelist):
> +        # lcores = '(0,127)@(4,5)'
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask='%s'" \
> +            % (self.target, lcores, self.portmask)
> +        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
> +        self.dut.send_expect("set fwd mac", "testpmd>")
> +        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
> +        self.dut.send_expect("start", "testpmd> ")
> +        out = self.dut.send_expect("show config fwd", "testpmd> ")
> +        self.verify("Logical Core 127 " in out, "set corelist error: 
> + " + out)
> +
> +        self.check_forwarding(self.ports)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | tail -n 2", 
> + "#")
> +
> +        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" \
> +            % self.target
> +        scanner = re.compile(result_scanner, re.DOTALL)
> +        m = scanner.finditer(out)
> +        if m:
> +            count = 0
> +            for i in m:
> +                text = i.group()
> +                self.dut.alt_session.send_expect(
> +                    "echo '%s' > /root/temp" % text, "#")
> +                out = self.dut.alt_session.send_expect(
> +                    "cat /root/temp | awk '{print $4}'", "#")
> +                if out == '5' or out == '4':
> +                    count += 1
> +        self.verify(count == 2,
> +                    "Threads running error:cpu is %s, expect 2 ." % 
> + count)
> +
> +        self.dut.send_expect("quit", "#")
> +
> +    def positive_4_test(self, lcores, corelist):
> +        # lcores = '(0,64-66)@(4,5)'
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
> +            % (self.target, lcores, self.portmask)
> +        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
> +        self.dut.send_expect("set fwd mac", "testpmd>")
> +        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
> +        self.dut.send_expect("start", "testpmd> ")
> +        out = self.dut.send_expect("show config fwd", "testpmd> ")
> +        self.verify("Logical Core 64 " or "Logical Core 65 " in out,
> +                    "set corelist error: " + out)
> +
> +        self.check_forwarding(self.ports)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | tail -n 4", 
> + "#")
> +
> +        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" \
> +            % self.target
> +        scanner = re.compile(result_scanner, re.DOTALL)
> +        m = scanner.finditer(out)
> +        if m:
> +            count = 0
> +            for i in m:
> +                text = i.group()
> +                self.dut.alt_session.send_expect(
> +                    "echo '%s' > /root/temp" % text, "#")
> +                out = self.dut.alt_session.send_expect(
> +                    "cat /root/temp | awk '{print $4}'", "#")
> +                if out == '5' or out == '4':
> +                    count += 1
> +        self.verify(count == 4,
> +                    "Threads running error:cpu is %s, expect 4 ." % 
> + count)
> +
> +        self.dut.send_expect("quit", "#")
> +
> +    def positive_5_test(self, lcores, corelist):
> +        # lcores = '2-5,6,7-9'
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
> +            % (self.target, lcores, self.portmask)
> +        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
> +        self.dut.send_expect("set fwd mac", "testpmd>")
> +        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
> +        self.dut.send_expect("start", "testpmd> ")
> +        out = self.dut.send_expect("show config fwd", "testpmd> ")
> +        for core in corelist:
> +            if core.isdigit() == True:
> +                self.verify("Logical Core %s " % core in out,
> +                            "set corelist error: " + out)
> +
> +        self.check_forwarding(self.ports)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 2 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '2',
> +                    "Threads running error:cpu is %s, expect 2 ." % 
> + out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 4 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '3',
> +                    "Threads running error:cpu is %s, expect 3 ." % 
> + out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 5 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '4',
> +                    "Threads running error:cpu is %s, expect 4 ." % 
> + out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 6 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '5',
> +                    "Threads running error:cpu is %s, expect 5 ." % 
> + out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 7 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '6',
> +                    "Threads running error:cpu is %s, expect 6 ." % 
> + out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 8 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '7',
> +                    "Threads running error:cpu is %s, expect 7 ." % 
> + out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 9 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '8',
> +                    "Threads running error:cpu is %s, expect 8 ." % 
> + out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 10 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '9',
> +                    "Threads running error:cpu is %s, expect 9 ." % 
> + out)
> +
> +        self.dut.send_expect("quit", "#")
> +
> +    def positive_6_test(self, lcores, corelist):
> +        # lcores = '2, (3-5)@ 3'
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
> +            % (self.target, lcores, self.portmask)
> +        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
> +        self.dut.send_expect("set fwd mac", "testpmd>")
> +        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
> +        self.dut.send_expect("start", "testpmd> ")
> +        out = self.dut.send_expect("show config fwd", "testpmd> ")
> +        for core in corelist:
> +            if core.isdigit() == True:
> +                self.verify("Logical Core %s " % core in out,
> +                            "set corelist error: " + out)
> +
> +        self.check_forwarding(self.ports)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args | \
> +             head -n 2 | tail -n 1 | awk '{print $4}'", "#")
> +        self.verify(out == '2',
> +                    "Threads running error:cpu is %s, expect 2 ." % 
> + out)
> +
> +        out = self.dut.alt_session.send_expect(
> +            "ps -C testpmd -L -opid,tid,%cpu,psr,args", "#")
> +        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" \
> +            % self.target
> +        scanner = re.compile(result_scanner, re.DOTALL)
> +        m = scanner.finditer(out)
> +        if m:
> +            count = 0
> +            for i in m:
> +                text = i.group()
> +                self.dut.alt_session.send_expect(
> +                    "echo '%s' > /root/temp" % text, "#")
> +                out = self.dut.alt_session.send_expect(
> +                    "cat /root/temp | awk '{print $4}'", "#")
> +                if out == '3':
> +                    count += 1
> +        self.verify(count == 3,
> +                    "Threads running error:cpu is %s, expect 3 ." % 
> + count)
> +
> +        self.dut.send_expect("quit", "#")
> +
> +    def positive_7_test(self, lcores, corelist):
> +
> +        # lcores = '(0,64-66)@(4,5)'
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
> +            % (self.target, lcores, self.portmask)
> +        out = self.dut.send_expect(pmd_cmd, "testpmd> ", 100)
> +        self.dut.send_expect("set fwd mac", "testpmd>")
> +        self.dut.send_expect("set corelist %s" % corelist, "testpmd> ")
> +        self.dut.send_expect("start", "testpmd> ")
> +        self.dut.send_expect("show config fwd", "testpmd> ")
> +        self.check_forwarding(self.ports)
> +
> +        result_scanner = "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" \
> +            % self.target
> +        scanner = re.compile(result_scanner, re.DOTALL)
> +        m = scanner.finditer(out)
> +        self.dut.alt_session.send_expect(
> +            "cd /sys/fs/cgroup/cpu/dpdk/thread0", "#")
> +        if m:
> +            count = 0
> +            for i in m:
> +                text = i.group()
> +                self.dut.alt_session.send_expect(
> +                    "echo '%s' > /root/temp" % text, "#")
> +                out = self.dut.alt_session.send_expect(
> +                    "cat /root/temp | awk '{print $4}'", "#")
> +                if out == '5' or out == '4':
> +                    count += 1
> +        self.verify(count == 5, "Threads running error:cpu is %s, expect 5 ."
> +                    % count)
> +
> +        self.dut.send_expect("quit", "#")
> +
> +    def check_negative(self, lcores):
> +        """
> +        """
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --portmask=%s" \
> +            % (self.target, lcores, self.portmask)
> +        self.dut.send_expect(pmd_cmd, "#", 100)
> +
> +    def test_basic_operation(self):
> +	"""
> +        Basic operation
> +        """
> +        lcores = '0@8,(4-5)@9'
> +        corelist = ['4', '5', '4,5']
> +        for core in corelist:
> +            self.basic_operation(lcores, core)
> +
> +    def test_positive_test(self):
> +	"""
> +        Positive Test
> +        """
> +
> +        # item 1
> +        lcores = '0@8,(4-5)@(8-11)'
> +        corelist = ['4', '5', '4,5']
> +        for core in corelist:
> +            self.positive_1_test(lcores, core)
> +
> +        # item 2
> +        lcores = '1,2@(0-4,6),(3-4,6)@5,(7,8)'
> +        corelist = ['2', '3', '4', '6', '7', '8',
> +                    '2,3', '2,4', '2,6', '2,7', '2,8',
> +                    '3,4', '3,6', '3,7', '3,8',
> +                    '4,6', '4,7', '4,8',
> +                    '6,7', '6,8',
> +                    '7,8']
> +        for core in corelist:
> +            self.positive_2_test(lcores, core)
> +
> +        # item 3
> +        lcores = '(0,127)@(4,5)'
> +        corelist = ['127']
> +        for core in corelist:
> +            self.positive_3_test(lcores, core)
> +
> +        # item 4
> +        lcores = '(0,64-66)@(4,5)'
> +        corelist = ['64', '65', '66', '64,65', '64,66', '65,66']
> +        for core in corelist:
> +            self.positive_4_test(lcores, core)
> +
> +        # item 5
> +        lcores = '2-5,6,7-9'
> +        corelist = ['3', '4', '5', '6', '7', '8', '9',
> +                    '3,4', '3,5', '3,6', '3,7', '3,8', '3,9',
> +                    '4,5', '4,6', '4,7', '4,8', '4,9',
> +                    '5,6', '5,7', '5,8', '5,9',
> +                    '6,7', '6,8', '6,9',
> +                    '7,8', '7,9',
> +                    '8,9']
> +        for core in corelist:
> +            self.positive_5_test(lcores, core)
> +
> +        # item 6
> +        lcores = '2, (3-5)@ 3'
> +        corelist = ['3', '4', '5', '3,4', '3,5', '4,5']
> +        for core in corelist:
> +            self.positive_6_test(lcores, core)
> +
> +        # item 7
> +        lcores = '(0,7-4)@(4,5)'
> +        corelist = ['7', '6', '5', '4',
> +                    '7,6', '7,5', '7,4', '6,5', '6,4', '5,4']
> +        for core in corelist:
> +            self.positive_7_test(lcores, core)
> +
> +    def test_negative_test(self):
> +        """
> +        Negative Test
> +        """
> +        lcores = [
> +            '(0-,4-7)@(4,5)',
> +            '(-1,4-7)@(4,5)',
> +            '(0,4-7-9)@(4,5)',
> +            '(0,abcd)@(4,5)',
> +            '(0,4-7)@(1-,5)',
> +            '(0,4-7)@(-1,5)',
> +            '(0,4-7)@(4,5-8-9)',
> +            '(0,4-7)@(abc,5)',
> +            '(0,4-7)@(4,xyz)',
> +            '(0,4-7)=(8,9)',
> +            '2,3@4,(0-1,,4))',
> +            '[0-,4-7]@(4,5)',
> +            '(0-,4-7)@[4,5]',
> +            '3-4@3,2@5-6',
> +            '2,,3''2--3',
> +            '2,,,3''2--3']
> +        for lcore in lcores:
> +            self.check_negative(lcore)
> +
> +    def tear_down(self):
> +        """
> +        Run after each test case.
> +        """
> +        self.dut.kill_all()
> +
> +    def tear_down_all(self):
> +        """
> +        Run after each test suite.
> +        """

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-11-09  2:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-04 10:31 [dts] [PATCH 1/3] Add multiple pthread test suite, Lijuan Tu
2015-11-04 10:32 ` [dts] [PATCH 2/3] Add multiple pthread test plan Lijuan Tu
2015-11-09  2:34   ` Liu, Yong
2015-11-04 10:32 ` [dts] [PATCH 3/3] add multiple_pthread in executions/execution.cfg Lijuan Tu
2015-11-09  2:42 ` [dts] [PATCH 1/3] Add multiple pthread test suite, Liu, Yong
2015-11-09  2:46   ` Tu, LijuanX A

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).