]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: tshark: deal with "wlan_mgt" -> "wlan" rename
authorJohannes Berg <johannes.berg@intel.com>
Tue, 24 Oct 2017 15:11:31 +0000 (17:11 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 29 Oct 2017 14:48:05 +0000 (16:48 +0200)
Recent versions of tshark/wireshark renamed these fields, deal
with that in the tshark wrapper code.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
tests/hwsim/tshark.py

index d2a8c45ca24f5ef9983245a775407b941020aa8b..2d4389c699742a3041e39ec6238731162b0a7eff 100644 (file)
@@ -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)