From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by dpdk.org (Postfix) with ESMTP id DFBA01B23C for ; Mon, 6 Nov 2017 08:57:52 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EC5CB80D; Sun, 5 Nov 2017 23:57:51 -0800 (PST) Received: from lenovo-a010984.shanghai.arm.com (lenovo-a010984.shanghai.arm.com [10.169.40.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7D1F13F246; Sun, 5 Nov 2017 23:57:51 -0800 (PST) From: Herbert Guan To: dts@dpdk.org Cc: Herbert Guan Date: Mon, 6 Nov 2017 15:57:37 +0800 Message-Id: <1509955057-26004-1-git-send-email-herbert.guan@arm.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dts] [PATCH] framework: enhance the tcpdump direction option parsing 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: , X-List-Received-Date: Mon, 06 Nov 2017 07:57:53 -0000 Some tcpdump versions (such as 4.9.0-5.el7) is providing help message about direction option with both '-P' and '-Q': " [ -Q|-P in|out|inout ]". This format cause option parse fail. This patch can enhance the direction option parsing and fix it. Jira: ENTNET-552 Change-Id: I5835912905311d90ce4ee9897fa9c83a0266aa01 Signed-off-by: Herbert Guan --- framework/packet.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/framework/packet.py b/framework/packet.py index 1907612..4ee51dd 100755 --- a/framework/packet.py +++ b/framework/packet.py @@ -787,14 +787,20 @@ def sniff_packets(intf, count=0, timeout=5, filters=[]): sniff all packets for certain port in certain seconds """ param = "" - direct_param = r"(\s+)\[ -(\w) in\|out\|inout \]" + direct_param = r"(\s+)\[ (\S+) in\|out\|inout \]" tcpdump_help = subprocess.check_output("tcpdump -h; echo 0", stderr=subprocess.STDOUT, shell=True) for line in tcpdump_help.split('\n'): m = re.match(direct_param, line) if m: - param = "-" + m.group(2) + " in" + 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: print "tcpdump not support direction chioce!!!" -- 1.8.3.1