test suite reviews and discussions
 help / color / mirror / Atom feed
* Re: [dts] [‘dts’]     Add multiple pthread test plan     Add multiple pthread test suite,
       [not found] <1441014417-23495-1-git-send-email-lijuanx.a.tu@intel.com>
@ 2015-09-01  0:57 ` Xu, HuilongX
  0 siblings, 0 replies; only message in thread
From: Xu, HuilongX @ 2015-09-01  0:57 UTC (permalink / raw)
  To: Tu, LijuanX A, dts

Hi lijuan,
Pls see my comments  as below.
Thanks

> -----Original Message-----
> From: Tu, LijuanX A
> Sent: Monday, August 31, 2015 5:47 PM
> To: dts@dpdk.org
> Cc: Xu, HuilongX; Tang, HaifengX; Tu, LijuanX A
> Subject: [‘dts’] Add multiple pthread test plan Add multiple pthread test
> suite,
> 
>     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>
> ---
>  test_plans/multiple_pthread_test_plan.rst | 117 +++++++
>  tests/TestSuite_multiple_pthread.py       | 493
> ++++++++++++++++++++++++++++++
>  2 files changed, 610 insertions(+)
>  create mode 100644 test_plans/multiple_pthread_test_plan.rst
>  create mode 100644 tests/TestSuite_multiple_pthread.py
> 
Could you split many patches for every file changed, and add test suite in execution file?
 
> diff --git a/test_plans/multiple_pthread_test_plan.rst
> b/test_plans/multiple_pthread_test_plan.rst
> new file mode 100644
> index 0000000..ede3daa
> --- /dev/null
> +++ b/test_plans/multiple_pthread_test_plan.rst
> @@ -0,0 +1,117 @@
> +..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
> +
> +
> +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,7-
> 4)@(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
> diff --git a/tests/TestSuite_multiple_pthread.py
> b/tests/TestSuite_multiple_pthread.py
> new file mode 100644
> index 0000000..58cb991
> --- /dev/null
> +++ b/tests/TestSuite_multiple_pthread.py
> @@ -0,0 +1,493 @@
> +# 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()

Print function for debug, could you delete this code, or used self.logger to print your debug info.
> +        print self.nic, self.ports
> +        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, nic, testerports=[None, None],
> pktSize=64, received=True, crcStrip=False, vlan=False):
In your function you not check crcStrip and vlan feature, so I think you can ignore crcstrip and vlan config when you send package.
> +        """
> +        """
> +        for i in range(len(ports)):
> +            if i % 2 == 0:
> +                self.send_packet(ports[i], ports[i + 1], self.nic,
> testerports[1], pktSize, received, crcStrip=crcStrip, vlan=vlan)
> +                self.send_packet(ports[i + 1], ports[i], self.nic,
> testerports[0], pktSize, received, crcStrip=crcStrip, vlan=vlan)
> +
> +    def send_packet(self, txPort, rxPort, nic, testerports=None,
> pktSize=64, received=True, crcStrip=False, vlan=False):
> +        """
> +        Send packages according to parameters.
> +        """
> +        port0_stats = self.get_stats(txPort)
Maybe you not need check rx/tx package size, only need check rx/tx numbers. 
So you not need check rx/tx package size.

> +        gp0tx_pkts, gp0tx_bytes = [port0_stats['TX-packets'],
> port0_stats['TX-bytes']]
> +        port1_stats = self.get_stats(rxPort)
> +        gp1rx_pkts, gp1rx_err, gp1rx_bytes = [port1_stats['RX-packets'],
> port1_stats['RX-errors'], port1_stats['RX-bytes']]
> +        time.sleep(5)
> +
> +        if testerports is None:
> +            itf =
> self.tester.get_interface(self.tester.get_local_port(rxPort))
> +        else:
> +            itf = testerports
> +
> +        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_pkts, p0tx_bytes = [port0_stats['TX-packets'],
> port0_stats['TX-bytes']]
> +        port1_stats = self.get_stats(rxPort)
> +        p1rx_pkts, p1rx_err, p1rx_bytes = [port1_stats['RX-packets'],
> port1_stats['RX-errors'], port1_stats['RX-bytes']]
> +        time.sleep(5)
> +
> +        p0tx_pkts -= gp0tx_pkts
> +        p0tx_bytes -= gp0tx_bytes
> +        p1rx_pkts -= gp1rx_pkts
> +        p1rx_bytes -= gp1rx_bytes
> +        p1rx_err -= gp1rx_err
> +        if received:
> +            self.verify(p0tx_pkts == p1rx_pkts,"Wrong TX pkts p0_tx=%d,
> p1_rx=%d" % (p0tx_pkts, p1rx_pkts))
> +
> +    def set_up(self):
> +        """
> +        Run before each test case.
> +        """
> +        pass
> +
> +    def check_threads(self):
> +        """
> +            Check threads that's running.
> +        """
> +        pass
> +
> +    def basic_operation(self, lcores, corelist):
> +        """
> +        Basic operation
> +        """
Pls check you code by pep8.
> +        #lcores = '0@8,(4-5)@9'
Don't set portmask is a constant, because different test environment, portmask is different,
You can count in setup_all function.
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --
> portmask=0xc" % (self.target, lcores)
> +        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> ")
You should check fwd core list after you changed fwd core list.

> +        self.check_forwarding(self.ports, self.nic)
> +
> +        out = self.dut.alt_session.send_expect("ps -C testpmd -L -
> opid,tid,%cpu,psr,args", "#")
> +        print out
> +	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)
> +	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 $2}'", "#")
> +		count += 1
> +            self.verify(count == 2, "Threads running error")
> +
> +    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=0xc" % (self.target, lcores)
> +        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, self.nic)
> +
> +        out = self.dut.alt_session.send_expect("ps -C testpmd -L -
> opid,tid,%cpu,psr,args", "#")
You can used self.logger for write debug info to log file.
> +        print out
> +	#diff
> +        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}'", "#")
You can used "if out in ['8', '9', '10', '11']:" to replace next logic expression. 
> +		if out == '8' or out == '9' or out == '10' or out == '11':
> +                    count += 1
> +            self.verify(count == 3, "Threads running error")
> +
> +	self.dut.send_expect("quit", "#")
> +
> +    def positive_2_test(self, lcores, corelist):
> +	"""
> +	"""
> +        pmd_cmd = "./%s/app/testpmd --lcores='%s' -n 4 -- -i --
> portmask=0xc" % (self.target, lcores)
> +        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, self.nic)
> +
> +	out = self.dut.alt_session.send_expect("ps -C testpmd -L -
> opid,tid,%cpu,psr,args", "#")
> +        print out
> +
> +	# 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")
> +
> +	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}'", "#")
> +                count += 1
> +            self.verify(count == 3, "Threads running error")
> +
> +	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)
> +        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 == '8' or out == '7':
> +            	    count += 1
> +        self.verify(count == 2, "Threads running error")
> +
> +	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=0xc" % (self.target, lcores)
> +        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, self.nic)
> +
> +	out = self.dut.alt_session.send_expect("ps -C testpmd -L -
> opid,tid,%cpu,psr,args", "#")
> +        print out
> +
> +	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 == 2, "Threads running error")
> +
> +	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=0xc" % (self.target, lcores)
> +        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, self.nic)
> +
> +	out = self.dut.alt_session.send_expect("ps -C testpmd -L -
> opid,tid,%cpu,psr,args", "#")
> +	print out
> +
> +	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 == 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=0xc" % (self.target, lcores)
> +        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, self.nic)
> +
> +	out = self.dut.alt_session.send_expect("ps -C testpmd -L -
> opid,tid,%cpu,psr,args", "#")
> +        print out
> +
> +	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")
> +
> +	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")
> +
> +	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")
> +
> +	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")
> +
> +	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")
> +
> +	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")
> +
> +	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")
> +
> +	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")
> +
> +	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=0xc" % (self.target, lcores)
> +        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, self.nic)
> +
> +	out = self.dut.alt_session.send_expect("ps -C testpmd -L -
> opid,tid,%cpu,psr,args", "#")
> +        print out
> +
> +	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}'", "#")
> +        print out
> +        self.verify(out == '2', "Threads running error")
> +
> +	out = self.dut.alt_session.send_expect("ps -C testpmd -L -
> opid,tid,%cpu,psr,args", "#")
> +        print out
> +	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 == '3':
> +                    count += 1
> +        self.verify(count == 3, "Threads running error")
> +
> +	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=0xc" % (self.target, lcores)
> +        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, self.nic)
> +
> +	out = self.dut.alt_session.send_expect("ps -C testpmd -L -
> opid,tid,%cpu,psr,args", "#")
> +	print out
> +
> +	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=0xc" % (self.target, lcores)
> +        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 = ['2', '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.
> +        """
> --
> 1.9.3


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-09-01  0:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1441014417-23495-1-git-send-email-lijuanx.a.tu@intel.com>
2015-09-01  0:57 ` [dts] [‘dts’] Add multiple pthread test plan Add multiple pthread test suite, Xu, HuilongX

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