test suite reviews and discussions
 help / color / mirror / Atom feed
From: "Tu, Lijuan" <lijuan.tu@intel.com>
To: "Han, YingyaX" <yingyax.han@intel.com>, "dts@dpdk.org" <dts@dpdk.org>
Cc: "Han, YingyaX" <yingyax.han@intel.com>
Subject: Re: [dts] [PATCH V1]tests/multiple_pthread: add test suite
Date: Sat, 12 Oct 2019 05:35:41 +0000	[thread overview]
Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BB3EA25@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <20190927162805.5337-1-yingyax.han@intel.com>

Applied, thanks

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of hanyingya
> Sent: Saturday, September 28, 2019 12:28 AM
> To: dts@dpdk.org
> Cc: Han, YingyaX <yingyax.han@intel.com>
> Subject: [dts] [PATCH V1]tests/multiple_pthread: add test suite
> 
> Signed-off-by: hanyingya <yingyax.han@intel.com>
> ---
>  tests/TestSuite_multiple_pthread.py | 240 ++++++++++++++++++++++++++++
>  1 file changed, 240 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..1ea71a5
> --- /dev/null
> +++ b/tests/TestSuite_multiple_pthread.py
> @@ -0,0 +1,240 @@
> +# BSD LICENSE
> +#
> +# Copyright(c) 2019 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.
> +
> +import time
> +import os
> +import re
> +import random
> +import string
> +import utils
> +from test_case import TestCase
> +
> +
> +class TestMultiplePthread(TestCase):
> +
> +    def set_up_all(self):
> +        """
> +        Run at the start of each test suite.
> +        """
> +        self.verify(self.dut.get_os_type() == 'linux', "Test suite currently only
> supports Linux platforms")
> +        self.dut_ports = self.dut.get_ports(self.nic)
> +        global valports
> +        valports = [_ for _ in self.dut_ports if self.tester.get_local_port(_) != -1]
> +        # Verify that enough ports are available
> +        self.verify(len(valports) >= 1, "Insufficient ports for testing")
> +        # get socket and cores
> +        self.socket = self.dut.get_numa_id(self.dut_ports[0])
> +        self.cores = self.dut.get_core_list("1S/8C/1T", socket=self.socket)
> +        self.verify(self.cores is not None, "Requested 8 cores failed")
> +        self.out_view = {'header': [], 'data': []}
> +
> +    def set_up(self):
> +        """
> +        Run before each test case.
> +        """
> +        pass
> +
> +    def destroy_packets_session(self):
> +        """
> +        close send packets session.
> +        """
> +        for i in valports:
> +            self.tester.create_session(name="%s" % i).send_expect("^C", "#")
> +
> + self.tester.destroy_session(self.tester.create_session(name="%s" % i))
> +
> +    def send_packet(self):
> +        """
> +        create sessions and Send packets continuous.
> +        """
> +        for index in valports:
> +            localPort = self.tester.get_local_port(index)
> +            iface = self.tester.get_interface(localPort)
> +            self.send_packets_session = self.tester.create_session(name="%s" %
> index)
> +            packet = r'sendp([Ether()/IP(src="1.2.3.4", dst="192.168.0.%d")],
> iface="%s", loop=1)' % (index, iface)
> +            self.send_packets_session.send_expect("scapy", ">>>")
> +            self.send_packets_session.send_command(packet)
> +
> +    def get_cores_statistic(self, cmdline):
> +        """
> +        Get cpu and thread statistics.
> +        """
> +        mutiple_pthread_session = self.dut.new_session()
> +        out = mutiple_pthread_session.send_expect("ps -C testpmd -L -
> opid,tid,%cpu,psr,args", "#", 20)
> +        m = cmdline.replace('"', '', 2)
> +        out_list = out.split(m)
> +        mutiple_pthread_session.send_expect("^C", "#")
> +        return out_list
> +
> +    def verify_before_send_packets(self, out_list):
> +        """
> +        handle out info before send packets and recode the status.
> +        """
> +        for data in out_list:
> +            if data != '':
> +                data_row = re.findall(r'[\d\.]+', data)
> +                if data_row[0] == data_row[1]:
> +                    self.verify(data_row[2] > 0, "master thread are not running")
> +                    # add data to the table
> +                self.result_table_add(data_row)
> +                self.out_view['data'].append(data_row)
> +
> +    def verify_after_send_packets(self, out_list, lcore_list):
> +        """
> +        handle out info after send packets and verify the core's status.
> +        """
> +        for data in out_list:
> +            if data != '':
> +                data_row = re.findall(r'[\d\.]+', data)
> +                for lcore in lcore_list:
> +                    if data_row[3] == lcore:
> +                        self.verify(data_row[2] > 0, "TID:%s not running" %
> data_row[1])
> +                self.result_table_add(data_row)
> +                self.out_view['data'].append(data_row)
> +        # print table
> +        self.result_table_print()
> +
> +    def multiple_pthread_test(self, lcores, cpu_list, lcore_list):
> +        """
> +        multiple pthread test according to lcores, cpus, etc.
> +        """
> +        header_row = ["PID", "TID", "%CPU", "PSRF"]
> +        self.out_view['header'] = header_row
> +        self.result_table_create(header_row)
> +        self.out_view['data'] = []
> +
> +        cmdline = './x86_64-native-linuxapp-gcc/app/testpmd --lcores="%s" -n
> 4 -- -i' % lcores
> +        # start application
> +        self.dut.send_expect(cmdline, "testpmd", 60)
> +
> +        out_list = self.get_cores_statistic(cmdline)
> +        self.verify_before_send_packets(out_list)
> +
> +        # set testpmd corelist
> +        m = ""
> +        for cpu in cpu_list:
> +            m += "%s," % cpu
> +        setline = "set corelist %s" % m[:-1]
> +        self.dut.send_expect(setline, "testpmd> ")
> +        self.dut.send_expect("start", "testpmd> ")
> +        out = self.dut.send_expect("show config fwd", "testpmd> ")
> +        # check fwd config
> +        if len(cpu_list) >= 2:
> +            for core in cpu_list[:2]:
> +                self.verify('Logical Core %s' % core in out, "set corelist config failed")
> +        else:
> +            for core in cpu_list:
> +                self.verify('Logical Core %s' % core in out, "set corelist config failed")
> +        self.send_packet()
> +        # get cpu statictis and verify the result
> +        out_list = self.get_cores_statistic(cmdline)
> +        self.verify_after_send_packets(out_list, lcore_list)
> +        # quit application
> +        self.dut.send_expect("stop", "testpmd> ")
> +        self.dut.send_expect("quit", "# ", 30)
> +        self.destroy_packets_session()
> +
> +    def test_basic_operation(self):
> +        """
> +        Test an basic operation.
> +        """
> +        # prepare cmdline
> +        n = random.sample(self.cores, 5)
> +        n.sort()
> +        lcores = "%s@%s,(%s,%s)@%s" % (n[0], n[1], n[2], n[3], n[4])
> +        self.multiple_pthread_test(lcores, n[2:4], [n[1], n[4]])
> +
> +    def test_positive(self):
> +        """
> +        Test an random parameter from an defined table which has a couple of
> valid lcore parameters.
> +        """
> +        n = self.cores
> +        CONFIG_RTE_MAX_LCORE = 128
> +        test_list = [
> +                     {"lcores": "(%s,%s)@(%s,%s)" % (n[0],
> CONFIG_RTE_MAX_LCORE-1, n[1], n[2]),
> +                      "cpu_list":[CONFIG_RTE_MAX_LCORE-1],
> +                      "core_list":n[1:3]},
> +                     {"lcores": "%s@%s,(%s,%s)@(%s,%s,%s,%s)" % (n[0], n[1], n[2],
> n[3], n[4], n[5], n[6], n[7]),
> +                      "cpu_list":n[2:4],
> +                      "core_list":n[4:]},
> +                     {"lcores": "(%s,%s,%s,%s)@(%s,%s)" % (n[0], n[1], n[2], n[3],
> n[4], n[5]),
> +                      "cpu_list":n[1:3],
> +                      "core_list":n[4:6]},
> +                     {"lcores": "%s,(%s,%s,%s)@%s" % (n[0], n[1], n[2], n[3], n[4]),
> +                      "cpu_list":n[1:4],
> +                      "core_list":n[4:5]},
> +                     {"lcores": "(%s,%s,%s,%s,%s)@(%s,%s)" % (n[0], n[1], n[2], n[3],
> n[4], n[5], n[6]),
> +                      "cpu_list":n[1:5],
> +                      "core_list":n[5:7]},
> +                     {"lcores":
> "%s,%s@(%s,%s,%s,%s,%s,%s),(%s,%s,%s)@%s,(%s,%s)"
> +                                % (n[0], n[1], n[0], n[1], n[2], n[3], n[4], n[5], n[2], n[3],
> n[5], n[4], n[6], n[7]),
> +                      "cpu_list":[n[1], n[2], n[3], n[5]],
> +                      "core_list":n[1:6]}
> +                     ]
> +        params_list = random.sample(test_list, 1)
> +        params = params_list[0]
> +        self.multiple_pthread_test(params["lcores"],
> + params["cpu_list"], params["core_list"])
> +
> +    def test_negative(self):
> +        """
> +        Test an random parameter from an defined table which has a couple of
> invalid lcore parameters.
> +        """
> +        cmdline_list = ["./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0-
> ,4-7)@(4,5)' -n 4 -- -i",
> +                        "./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(-1,4-
> 7)@(4,5)' -n 4 -- -i",
> +                        "./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-7-
> 9)@(4,5)' -n 4 -- -i",
> +                        "./x86_64-native-linuxapp-gcc/app/testpmd --
> lcores='(0,abcd)@(4,5)' -n 4 -- -i",
> +                        "./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-
> 7)@(1-,5)' -n 4 -- -i",
> +                        "./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-
> 7)@(-1,5)' -n 4 -- -i",
> +                        "./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-
> 7)@(4,5-8-9)' -n 4 -- -i",
> +                        "./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-
> 7)@(abc,5)' -n 4 -- -i",
> +                        "./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-
> 7)@(4,xyz)' -n 4 -- -i",
> +                        "./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0,4-
> 7)=(8,9)' -n 4 -- -i",
> +                        "./x86_64-native-linuxapp-gcc/app/testpmd --lcores='2,3 at
> 4,(0-1,,4))' -n 4 -- -i",
> +                        "./x86_64-native-linuxapp-gcc/app/testpmd --lcores='[0-,4-
> 7]@(4,5)' -n 4 -- -i",
> +                        "./x86_64-native-linuxapp-gcc/app/testpmd --lcores='(0-,4-
> 7)@[4,5]' -n 4 -- -i",
> +                        "./x86_64-native-linuxapp-gcc/app/testpmd --lcores='3-4 at
> 3,2 at 5-6' -n 4 -- -i",
> +                        "./x86_64-native-linuxapp-gcc/app/testpmd --lcores='2,,3''2--
> 3' -n 4 -- -i",
> +                        "./x86_64-native-linuxapp-gcc/app/testpmd
> + --lcores='2,,,3''2--3' -n 4 -- -i"]
> +
> +        cmdline = random.sample(cmdline_list, 1)
> +        out = self.dut.send_expect(cmdline[0], "#", 60)
> +        self.verify("invalid parameter" in out, "it's a valid
> + parameter")
> +
> +    def tear_down(self):
> +        """
> +        Run after each test case.
> +        """
> +        self.dut.kill_all()
> +
> +    def tear_down_all(self):
> +        """
> +        Run after each test suite.
> +        """
> +        pass
> --
> 2.17.1


      reply	other threads:[~2019-10-12  5:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-27 16:28 hanyingya
2019-10-12  5:35 ` Tu, Lijuan [this message]

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=8CE3E05A3F976642AAB0F4675D0AD20E0BB3EA25@SHSMSX101.ccr.corp.intel.com \
    --to=lijuan.tu@intel.com \
    --cc=dts@dpdk.org \
    --cc=yingyax.han@intel.com \
    /path/to/YOUR_REPLY

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

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