test suite reviews and discussions
 help / color / mirror / Atom feed
From: "Tu, Lijuan" <lijuan.tu@intel.com>
To: "Ma, LihongX" <lihongx.ma@intel.com>, "dts@dpdk.org" <dts@dpdk.org>
Cc: "Ma, LihongX" <lihongx.ma@intel.com>
Subject: Re: [dts] [PATCH V1] tests: judge tcpdump version when use flow	direction params
Date: Wed, 12 Jun 2019 06:23:47 +0000	[thread overview]
Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BABA6B6@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <1560208062-10120-1-git-send-email-lihongx.ma@intel.com>

Applied, thanks

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of lihong
> Sent: Tuesday, June 11, 2019 7:08 AM
> To: dts@dpdk.org
> Cc: Ma, LihongX <lihongx.ma@intel.com>
> Subject: [dts] [PATCH V1] tests: judge tcpdump version when use flow
> direction params
> 
> The params of flow direction in tcpdump is varied by tcpdump version.
> So add function to get the param base on the version.
> 
> Signed-off-by: lihong <lihongx.ma@intel.com>
> ---
>  tests/TestSuite_flow_classify_softnic.py | 27 +++++++++++++++++++++++++--
>  tests/TestSuite_ip_pipeline.py           | 27 +++++++++++++++++++++++++--
>  2 files changed, 50 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/TestSuite_flow_classify_softnic.py
> b/tests/TestSuite_flow_classify_softnic.py
> index 9b339ca..88dcc7e 100644
> --- a/tests/TestSuite_flow_classify_softnic.py
> +++ b/tests/TestSuite_flow_classify_softnic.py
> @@ -120,14 +120,35 @@ class TestFlowClassifySoftnic(TestCase):
>          command = "sed -i \'/^table action/a" + cmd +
> "\' ./drivers/net/softnic/flow_classify_softnic/%s" % filename
>          self.dut.send_expect(command, "# ", 20)
> 
> +    def get_flow_direction_param_of_tcpdump(self):
> +        """
> +        get flow dirction param depend on tcpdump version
> +        """
> +        param = ""
> +        direct_param = r"(\s+)\[ (\S+) in\|out\|inout \]"
> +        out = self.tester.send_expect('tcpdump -h', '# ')
> +        for line in out.split('\n'):
> +            m = re.match(direct_param, line)
> +            if m:
> +                opt = re.search("-Q", m.group(2));
> +                if opt:
> +                    param = "-Q" + " in"
> +                else:
> +                    opt = re.search("-P", m.group(2));
> +                    if opt:
> +                        param = "-P" + " in"
> +        if len(param) == 0:
> +            self.logger.info("tcpdump not support direction choice!!!")
> +        return param
> +
>      def tcpdump_start_sniff(self, interface, filters=""):
>          """
>          Starts tcpdump in the background to sniff packets that received by
> interface.
>          """
>          command = 'rm -f /tmp/tcpdump_{0}.pcap'.format(interface)
>          self.tester.send_expect(command, '#')
> -        command = 'tcpdump -n -e -Q in -w /tmp/tcpdump_{0}.pcap -i {0} {1}
> 2>/tmp/tcpdump_{0}.out &'\
> -                  .format(interface, filters)
> +        command = 'tcpdump -n -e {0} -w /tmp/tcpdump_{1}.pcap -i {1} {2}
> 2>/tmp/tcpdump_{1}.out &'\
> +                  .format(self.param_flow_dir, interface, filters)
>          self.tester.send_expect(command, '# ')
> 
>      def tcpdump_stop_sniff(self):
> @@ -373,6 +394,8 @@ class TestFlowClassifySoftnic(TestCase):
>          self.tester_itf = self.tester.get_interface(localPort)
>          self.copy_config_files_to_dut()
> 
> +        self.param_flow_dir =
> + self.get_flow_direction_param_of_tcpdump()
> +
>      def set_up(self):
>          """
>          Run before each test case.
> diff --git a/tests/TestSuite_ip_pipeline.py b/tests/TestSuite_ip_pipeline.py
> index 390c69d..f05b5cd 100644
> --- a/tests/TestSuite_ip_pipeline.py
> +++ b/tests/TestSuite_ip_pipeline.py
> @@ -64,14 +64,35 @@ from scapy.sendrecv import sendp
> 
>  class TestIPPipeline(TestCase):
> 
> +    def get_flow_direction_param_of_tcpdump(self):
> +        """
> +        get flow dirction param depend on tcpdump version
> +        """
> +        param = ""
> +        direct_param = r"(\s+)\[ (\S+) in\|out\|inout \]"
> +        out = self.tester.send_expect('tcpdump -h', '# ')
> +        for line in out.split('\n'):
> +            m = re.match(direct_param, line)
> +            if m:
> +                opt = re.search("-Q", m.group(2));
> +                if opt:
> +                    param = "-Q" + " in"
> +                else:
> +                    opt = re.search("-P", m.group(2));
> +                    if opt:
> +                        param = "-P" + " in"
> +        if len(param) == 0:
> +            self.logger.info("tcpdump not support direction choice!!!")
> +        return param
> +
>      def tcpdump_start_sniff(self, interface, filters=""):
>          """
>          Starts tcpdump in the background to sniff packets that received by
> interface.
>          """
>          command = 'rm -f /tmp/tcpdump_{0}.pcap'.format(interface)
>          self.tester.send_expect(command, '#')
> -        command = 'tcpdump -n -e -Q in -w /tmp/tcpdump_{0}.pcap -i {0} {1}
> 2>/tmp/tcpdump_{0}.out &'\
> -                  .format(interface, filters)
> +        command = 'tcpdump -n -e {0} -w /tmp/tcpdump_{1}.pcap -i {1} {2}
> 2>/tmp/tcpdump_{1}.out &'\
> +                  .format(self.param_flow_dir, interface, filters)
>          self.tester.send_expect(command, '# ')
> 
>      def tcpdump_stop_sniff(self):
> @@ -202,6 +223,8 @@ class TestIPPipeline(TestCase):
>          out = self.dut.build_dpdk_apps("./examples/ip_pipeline")
>          self.verify("Error" not in out, "Compilation error")
> 
> +        self.param_flow_dir =
> + self.get_flow_direction_param_of_tcpdump()
> +
>      def set_up(self):
>          """
>          Run before each test case.
> --
> 2.7.4


      parent reply	other threads:[~2019-06-12  6:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-10 23:07 lihong
2019-06-11  6:34 ` Yao, BingX Y
2019-06-12  6:23 ` 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=8CE3E05A3F976642AAB0F4675D0AD20E0BABA6B6@SHSMSX101.ccr.corp.intel.com \
    --to=lijuan.tu@intel.com \
    --cc=dts@dpdk.org \
    --cc=lihongx.ma@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).