[PATCH] hwsim tests: tshark: deal with "wlan_mgt" -> "wlan" rename
Johannes Berg
johannes at sipsolutions.net
Tue Oct 24 08:11:31 PDT 2017
From: Johannes Berg <johannes.berg at intel.com>
Recent versions of tshark/wireshark renamed these fields, deal
with that in the tshark wrapper code.
Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
tests/hwsim/tshark.py | 39 ++++++++++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
diff --git a/tests/hwsim/tshark.py b/tests/hwsim/tshark.py
index d2a8c45ca24f..2d4389c69974 100644
--- a/tests/hwsim/tshark.py
+++ b/tests/hwsim/tshark.py
@@ -12,10 +12,14 @@ import subprocess
import logging
logger = logging.getLogger()
+class UnknownFieldsException(Exception):
+ def __init__(self, fields):
+ Exception.__init__(self, "unknown tshark fields %s" % ','.join(fields))
+ self.fields = fields
_tshark_filter_arg = '-Y'
-def run_tshark(filename, filter, display=None, wait=True):
+def _run_tshark(filename, filter, display=None, wait=True):
global _tshark_filter_arg
if wait:
@@ -44,8 +48,21 @@ def run_tshark(filename, filter, display=None, wait=True):
out = output[0]
res = cmd.wait()
if res == 1:
- if "Some fields aren't valid" in output[1]:
- raise Exception("Unknown tshark field")
+ errmsg = "Some fields aren't valid"
+ if errmsg in output[1]:
+ errors = output[1].split('\n')
+ fields = []
+ collect = False
+ for f in errors:
+ if collect:
+ f = f.strip()
+ if f:
+ fields.append(f)
+ continue
+ if errmsg in f:
+ collect = True
+ continue
+ raise UnknownFieldsException(fields)
# remember this for efficiency
_tshark_filter_arg = '-R'
arg[3] = '-R'
@@ -55,3 +72,19 @@ def run_tshark(filename, filter, display=None, wait=True):
cmd.wait()
return out
+
+def run_tshark(filename, filter, display=None, wait=True):
+ if display is None: display = []
+ try:
+ return _run_tshark(filename, filter, display, wait)
+ except UnknownFieldsException, e:
+ all_wlan_mgt = True
+ for f in e.fields:
+ if not f.startswith('wlan_mgt.'):
+ all_wlan_mgt = False
+ break
+ if not all_wlan_mgt:
+ raise
+ return _run_tshark(filename, filter.replace('wlan_mgt', 'wlan'),
+ [x.replace('wlan_mgt', 'wlan') for x in display],
+ wait)
--
2.14.2
More information about the Hostap
mailing list