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 526DDA00E6 for ; Tue, 11 Jun 2019 08:29:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 45F741C273; Tue, 11 Jun 2019 08:29:23 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 7FEA81C272 for ; Tue, 11 Jun 2019 08:29:21 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jun 2019 23:29:20 -0700 X-ExtLoop1: 1 Received: from ubuntu.sh.intel.com ([10.67.119.68]) by orsmga003.jf.intel.com with ESMTP; 10 Jun 2019 23:29:19 -0700 From: lihong To: dts@dpdk.org Cc: lihong Date: Tue, 11 Jun 2019 07:07:42 +0800 Message-Id: <1560208062-10120-1-git-send-email-lihongx.ma@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [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" 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 --- 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