From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0074.outbound.protection.outlook.com [104.47.1.74]) by dpdk.org (Postfix) with ESMTP id 223C91B23C for ; Mon, 6 Nov 2017 08:59:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=tYreIRTsuhAm5nOrgrPPbJ9865tdkAAAfEfZ2/JYC3Q=; b=pHrYwu9oM2E1MQeTc8eT5nyWgYnt262gwGSGLTV3g+8TXnqqsiLGKPat1eEZ6AZSe4Eiyw9pmGUd4xFjtc0yLrSox5Bj68lXUBAfIAqILY8L+eNGk+uCNqVjtwCNc3yq7ecafZkhqVgqyQObkl4toFJOUFLUYeeM6QHvHwVIjLU= Received: from HE1PR08MB2809.eurprd08.prod.outlook.com (10.170.246.148) by HE1PR08MB2809.eurprd08.prod.outlook.com (10.170.246.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.197.13; Mon, 6 Nov 2017 07:59:58 +0000 Received: from HE1PR08MB2809.eurprd08.prod.outlook.com ([fe80::203a:195:bc89:903d]) by HE1PR08MB2809.eurprd08.prod.outlook.com ([fe80::203a:195:bc89:903d%13]) with mapi id 15.20.0197.019; Mon, 6 Nov 2017 07:59:58 +0000 From: Herbert Guan To: "Liu, Yong" CC: "dts@dpdk.org" Thread-Topic: [PATCH] framework: enhance the tcpdump direction option parsing 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 Thread-Index: AQHTVtSVDP9BQbUV7U2Sj2Sj7GaZtaMG/Hyw Date: Mon, 6 Nov 2017 07:59:57 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Herbert.Guan@arm.com; x-originating-ip: [113.29.88.7] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; HE1PR08MB2809; 6:ktgM7hHV8YANZ//1cgRQ6CYiHWbybZCOH06+U2J4YFc4nkhJtuTED5/hvDndY5rd4pxvqf9RFp4sY3yDCdP2gQ/ORCIf4rquAiGKtLFrW3Vx8mcRaaPkUpuysRgh6Vyz3oEVwHzuNeZWb++cyEOOIu0wkJiRF/VQvFgOHiRepe8vxW5/S90kSzjcuGHg8zwFJT8e2+hSl8FU6xUddmsYONDUZL/iWyf8d/GwChxyxqdSXwmDsV5tXRMtC6WgF6b7cf82zqDExy90ZyXL88n+9zAJkUfdx7TH4OFVbQ0q0zTNADnkdWicGQrnHm44HJm0tDfzW3DkvmQGg11y8plbnowzWwTZ1iP13FouZsU2SVg=; 5:TDdaptGzOPvlDUUzizFI1IFqzi1x6VJVJOYtBN5iTgiYNTBadyJ2VHjdEVYMjD78lv/WUUl8p0FEkR3arXCUKmmWZ+Cb0YUfXxWxuasd5sqefe1YVxOlJRqy2GDS/ujL11oyslYIc9RrI/qfJ7l+x0B4BmHhzmJ56O0sCq/oVTo=; 24:wTLy2W6NSk7tbjfC+R03ctNRKBK47hS4Dpr+fZb8sAKdLf5LDtUe6FF+FTTZHZSuWvAdXmh4s/56TqgjqzyLELx7Mk45v8a+QN7iTyYz648=; 7:hNI6Jm8kmwv+wnYEjDnA19Tu15EMu8limyHnm0o8rzuZ/xsw9Ah85OjCVpDCDQXpKECl/tb3m2B9uusB5ha2PViv3pf2avwO/UuIJaulVEbaUnnU6k0bc6G8Xc22seI0nG5HRXc1tav2peutqqck6EFNXeL6tHzTUZwOvB0YfaosnNhu0eRfVpUnDtUyHhxVjAiYzaUvlGYfTcyXEIm54Fmbf7/4UdQNNt2hD83zblZTRANHuCTcX79JwgPgHWp0 x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 2057cbe3-01a0-42ca-8039-08d524ec5fc7 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199); SRVR:HE1PR08MB2809; x-ms-traffictypediagnostic: HE1PR08MB2809: x-exchange-antispam-report-test: UriScan:(180628864354917); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231021)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123555025)(20161123558100)(20161123564025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:HE1PR08MB2809; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:HE1PR08MB2809; x-forefront-prvs: 048396AFA0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(346002)(376002)(199003)(189002)(40434004)(13464003)(105586002)(86362001)(15650500001)(53546010)(6506006)(72206003)(6436002)(478600001)(229853002)(102836003)(6116002)(74316002)(3846002)(3280700002)(25786009)(5660300001)(305945005)(8936002)(3660700001)(2906002)(33656002)(2900100001)(106356001)(101416001)(7736002)(189998001)(66066001)(81156014)(6916009)(81166006)(54356999)(14454004)(50986999)(7696004)(5890100001)(5250100002)(9686003)(97736004)(316002)(53936002)(68736007)(4326008)(55016002)(6246003)(99286004)(219693003)(44473003); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR08MB2809; H:HE1PR08MB2809.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2057cbe3-01a0-42ca-8039-08d524ec5fc7 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Nov 2017 07:59:57.7928 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR08MB2809 Subject: Re: [dts] [PATCH] framework: enhance the tcpdump direction option parsing 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 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:59:59 -0000 Sorry, this message has problems with subject. I've corrected it and sent = out another mail. Please ignore this one. Thanks, Herbert -----Original Message----- From: Herbert Guan [mailto:herbert.guan@arm.com] Sent: Monday, November 6, 2017 15:55 To: dts@dpdk.org Cc: Herbert Guan Subject: [PATCH] framework: enhance the tcpdump direction option parsing So= me tcpdump versions (such as 4.9.0-5.el7) is providing help message about d= irection option with both '-P' and '-Q': " [ -Q|-P in|out|inout ]". This fo= rmat cause option parse fail. This ... 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..4ee51= dd 100755 --- a/framework/packet.py +++ b/framework/packet.py @@ -787,14 +787,20 @@ def sniff_packets(intf, count=3D0, timeout=3D5, filte= rs=3D[]): sniff all packets for certain port in certain seconds """ param =3D "" - direct_param =3D r"(\s+)\[ -(\w) in\|out\|inout \]" + direct_param =3D r"(\s+)\[ (\S+) in\|out\|inout \]" tcpdump_help =3D subprocess.check_output("tcpdump -h; echo 0", stderr=3Dsubprocess.STDOUT, shell=3DTrue) for line in tcpdump_help.split('\n'): m =3D re.match(direct_param, line) if m: - param =3D "-" + m.group(2) + " in" + 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: print "tcpdump not support direction chioce!!!" -- 1.8.3.1 IMPORTANT NOTICE: The contents of this email and any attachments are confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you.