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 A64EA2C18 for ; Fri, 4 Aug 2017 09:02:29 +0200 (CEST) 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 9D80B2B; Fri, 4 Aug 2017 00:02:28 -0700 (PDT) Received: from localhost.localdomain.com (unknown [10.169.40.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0F4C23F3E1; Fri, 4 Aug 2017 00:02:27 -0700 (PDT) From: Herbert Guan To: dts@dpdk.org, jianbo.liu@linaro.org Cc: Herbert Guan Date: Fri, 4 Aug 2017 15:02:04 +0800 Message-Id: <1501830124-31059-1-git-send-email-herbert.guan@arm.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dts] [PATCH] tests/tx_preparation: auto-detect tcpdump parameter format 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: Fri, 04 Aug 2017 07:02:30 -0000 tcpdump is expect -P or -Q on different versions. Use script to detect the expected option format automatically to satisfy all versions of tcpdump. Signed-off-by: Herbert Guan --- tests/TestSuite_tx_preparation.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/TestSuite_tx_preparation.py b/tests/TestSuite_tx_preparation.py index b71f305..3c3080f 100644 --- a/tests/TestSuite_tx_preparation.py +++ b/tests/TestSuite_tx_preparation.py @@ -41,6 +41,8 @@ Test tx preparation feature import os import time import dut +import re +import subprocess from config import PortConf from test_case import TestCase from pmd_output import PmdOutput @@ -97,9 +99,18 @@ class TestTX_preparation(TestCase): def start_tcpdump(self, rxItf): + param = "" + direct_param = r"(\s+)\[ -(\w) 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" self.tester.send_expect("rm -rf ./getPackageByTcpdump.cap", "#") - self.tester.send_expect("tcpdump -Q in -i %s -n -e -vv -w\ - ./getPackageByTcpdump.cap 2> /dev/null& " % rxItf, "#") + self.tester.send_expect("tcpdump %s -i %s -n -e -vv -w\ + ./getPackageByTcpdump.cap 2> /dev/null& " % (param,rxItf), "#") def get_tcpdump_package(self): self.tester.send_expect("killall tcpdump", "#") -- 1.8.3.1