tests: tshark: deal with "wlan_mgt" -> "wlan" rename
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>
This commit is contained in:
parent
13dc368aa9
commit
7d1ebdec18
1 changed files with 36 additions and 3 deletions
|
@ -12,10 +12,14 @@ import subprocess
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger()
|
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'
|
_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
|
global _tshark_filter_arg
|
||||||
|
|
||||||
if wait:
|
if wait:
|
||||||
|
@ -44,8 +48,21 @@ def run_tshark(filename, filter, display=None, wait=True):
|
||||||
out = output[0]
|
out = output[0]
|
||||||
res = cmd.wait()
|
res = cmd.wait()
|
||||||
if res == 1:
|
if res == 1:
|
||||||
if "Some fields aren't valid" in output[1]:
|
errmsg = "Some fields aren't valid"
|
||||||
raise Exception("Unknown tshark field")
|
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
|
# remember this for efficiency
|
||||||
_tshark_filter_arg = '-R'
|
_tshark_filter_arg = '-R'
|
||||||
arg[3] = '-R'
|
arg[3] = '-R'
|
||||||
|
@ -55,3 +72,19 @@ def run_tshark(filename, filter, display=None, wait=True):
|
||||||
cmd.wait()
|
cmd.wait()
|
||||||
|
|
||||||
return out
|
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)
|
||||||
|
|
Loading…
Reference in a new issue