test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH] tests/tx_preparation: auto-detect tcpdump parameter format
@ 2017-08-04  7:02 Herbert Guan
  2017-08-07 12:09 ` Liu, Yong
  0 siblings, 1 reply; 2+ messages in thread
From: Herbert Guan @ 2017-08-04  7:02 UTC (permalink / raw)
  To: dts, jianbo.liu; +Cc: Herbert Guan

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dts] [PATCH] tests/tx_preparation: auto-detect tcpdump parameter format
  2017-08-04  7:02 [dts] [PATCH] tests/tx_preparation: auto-detect tcpdump parameter format Herbert Guan
@ 2017-08-07 12:09 ` Liu, Yong
  0 siblings, 0 replies; 2+ messages in thread
From: Liu, Yong @ 2017-08-07 12:09 UTC (permalink / raw)
  To: Herbert Guan, dts, jianbo.liu

Thanks Herbert. Applied.

On 08/04/2017 03:02 PM, Herbert Guan wrote:
> 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>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-07  3:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-04  7:02 [dts] [PATCH] tests/tx_preparation: auto-detect tcpdump parameter format Herbert Guan
2017-08-07 12:09 ` Liu, Yong

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).