From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id A0EA7A00E6 for ; Wed, 12 Jun 2019 08:23:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5EFB81D133; Wed, 12 Jun 2019 08:23:53 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 2DAC01D12E for ; Wed, 12 Jun 2019 08:23:50 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jun 2019 23:23:50 -0700 X-ExtLoop1: 1 Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga004.fm.intel.com with ESMTP; 11 Jun 2019 23:23:50 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 11 Jun 2019 23:23:50 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 11 Jun 2019 23:23:49 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.104]) by shsmsx102.ccr.corp.intel.com ([169.254.2.33]) with mapi id 14.03.0439.000; Wed, 12 Jun 2019 14:23:47 +0800 From: "Tu, Lijuan" To: "Ma, LihongX" , "dts@dpdk.org" CC: "Ma, LihongX" Thread-Topic: [dts] [PATCH V1] tests: judge tcpdump version when use flow direction params Thread-Index: AQHVIB8RIvdTCmNSQ06UW3M2d2S7XaaXjoEA Date: Wed, 12 Jun 2019 06:23:47 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BABA6B6@SHSMSX101.ccr.corp.intel.com> References: <1560208062-10120-1-git-send-email-lihongx.ma@intel.com> In-Reply-To: <1560208062-10120-1-git-send-email-lihongx.ma@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjQ3ODQxNzktN2YwMC00ZWJlLWEzODQtYmQyN2M1N2VlYTMzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiZURScDdBK1JqNUlcL0lhS1MrQkpreWtZWVROZ2FWZTlORTFsVkxSQW5iYThEdmg4dEZ5YmY0QTRyMG9zeEFWRnQifQ== x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V1] tests: judge tcpdump version when use flow direction params X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" 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 > Subject: [dts] [PATCH V1] tests: judge tcpdump version when use flow > direction params >=20 > The params of flow direction in tcpdump is varied by tcpdump version. > So add function to get the param base on the version. >=20 > Signed-off-by: lihong > --- > tests/TestSuite_flow_classify_softnic.py | 27 +++++++++++++++++++++++++-= - > tests/TestSuite_ip_pipeline.py | 27 +++++++++++++++++++++++++-= - > 2 files changed, 50 insertions(+), 4 deletions(-) >=20 > 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 =3D "sed -i \'/^table action/a" + cmd + > "\' ./drivers/net/softnic/flow_classify_softnic/%s" % filename > self.dut.send_expect(command, "# ", 20) >=20 > + def get_flow_direction_param_of_tcpdump(self): > + """ > + get flow dirction param depend on tcpdump version > + """ > + param =3D "" > + direct_param =3D r"(\s+)\[ (\S+) in\|out\|inout \]" > + out =3D self.tester.send_expect('tcpdump -h', '# ') > + for line in out.split('\n'): > + m =3D re.match(direct_param, line) > + if m: > + opt =3D re.search("-Q", m.group(2)); > + if opt: > + param =3D "-Q" + " in" > + else: > + opt =3D re.search("-P", m.group(2)); > + if opt: > + param =3D "-P" + " in" > + if len(param) =3D=3D 0: > + self.logger.info("tcpdump not support direction choice!!!") > + return param > + > def tcpdump_start_sniff(self, interface, filters=3D""): > """ > Starts tcpdump in the background to sniff packets that received = by > interface. > """ > command =3D 'rm -f /tmp/tcpdump_{0}.pcap'.format(interface) > self.tester.send_expect(command, '#') > - command =3D 'tcpdump -n -e -Q in -w /tmp/tcpdump_{0}.pcap -i {0}= {1} > 2>/tmp/tcpdump_{0}.out &'\ > - .format(interface, filters) > + command =3D '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, '# ') >=20 > def tcpdump_stop_sniff(self): > @@ -373,6 +394,8 @@ class TestFlowClassifySoftnic(TestCase): > self.tester_itf =3D self.tester.get_interface(localPort) > self.copy_config_files_to_dut() >=20 > + self.param_flow_dir =3D > + 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 >=20 > class TestIPPipeline(TestCase): >=20 > + def get_flow_direction_param_of_tcpdump(self): > + """ > + get flow dirction param depend on tcpdump version > + """ > + param =3D "" > + direct_param =3D r"(\s+)\[ (\S+) in\|out\|inout \]" > + out =3D self.tester.send_expect('tcpdump -h', '# ') > + for line in out.split('\n'): > + m =3D re.match(direct_param, line) > + if m: > + opt =3D re.search("-Q", m.group(2)); > + if opt: > + param =3D "-Q" + " in" > + else: > + opt =3D re.search("-P", m.group(2)); > + if opt: > + param =3D "-P" + " in" > + if len(param) =3D=3D 0: > + self.logger.info("tcpdump not support direction choice!!!") > + return param > + > def tcpdump_start_sniff(self, interface, filters=3D""): > """ > Starts tcpdump in the background to sniff packets that received = by > interface. > """ > command =3D 'rm -f /tmp/tcpdump_{0}.pcap'.format(interface) > self.tester.send_expect(command, '#') > - command =3D 'tcpdump -n -e -Q in -w /tmp/tcpdump_{0}.pcap -i {0}= {1} > 2>/tmp/tcpdump_{0}.out &'\ > - .format(interface, filters) > + command =3D '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, '# ') >=20 > def tcpdump_stop_sniff(self): > @@ -202,6 +223,8 @@ class TestIPPipeline(TestCase): > out =3D self.dut.build_dpdk_apps("./examples/ip_pipeline") > self.verify("Error" not in out, "Compilation error") >=20 > + self.param_flow_dir =3D > + self.get_flow_direction_param_of_tcpdump() > + > def set_up(self): > """ > Run before each test case. > -- > 2.7.4