From: Herbert Guan <herbert.guan@arm.com>
To: dts@dpdk.org, jianbo.liu@linaro.org
Cc: Herbert Guan <herbert.guan@arm.com>
Subject: [dts] [PATCH] tests/tx_preparation: auto-detect tcpdump parameter format
Date: Fri, 4 Aug 2017 15:02:04 +0800 [thread overview]
Message-ID: <1501830124-31059-1-git-send-email-herbert.guan@arm.com> (raw)
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 <herbert.guan@arm.com>
---
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
next reply other threads:[~2017-08-04 7:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-04 7:02 Herbert Guan [this message]
2017-08-07 12:09 ` Liu, Yong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1501830124-31059-1-git-send-email-herbert.guan@arm.com \
--to=herbert.guan@arm.com \
--cc=dts@dpdk.org \
--cc=jianbo.liu@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).