tests: Work around tshark bug in wpas_mesh_max_peering

It looks like tshark parser was broken at some point for
wlan.mesh.config.cap which is now (tshark 2.6.3) pointing to incorrect
field (same as wlan.mesh.config.ps_protocol). This used to work with
tshark 2.2.6.

For now, assume the capability field ends up being the last octet of the
frame.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2018-10-17 12:33:11 +03:00 committed by Jouni Malinen
parent e384b156dc
commit 2cbaf0de22
2 changed files with 45 additions and 1 deletions

View file

@ -10,12 +10,13 @@ import os
import struct import struct
import subprocess import subprocess
import time import time
import json
import hwsim_utils import hwsim_utils
import hostapd import hostapd
from wpasupplicant import WpaSupplicant from wpasupplicant import WpaSupplicant
from utils import HwsimSkip, alloc_fail, fail_test, wait_fail_trigger from utils import HwsimSkip, alloc_fail, fail_test, wait_fail_trigger
from tshark import run_tshark from tshark import run_tshark, run_tshark_json
from test_ap_ht import set_world_reg from test_ap_ht import set_world_reg
from hwsim_utils import set_group_map from hwsim_utils import set_group_map
@ -837,9 +838,12 @@ def test_wpas_mesh_max_peering(dev, apdev, params):
pkts = out.splitlines() pkts = out.splitlines()
one = [ 0, 0, 0 ] one = [ 0, 0, 0 ]
zero = [ 0, 0, 0 ] zero = [ 0, 0, 0 ]
all_cap_one = True
for pkt in pkts: for pkt in pkts:
addr, cap = pkt.split('\t') addr, cap = pkt.split('\t')
cap = int(cap, 16) cap = int(cap, 16)
if cap != 1:
all_cap_one = False
if addr == addr0: if addr == addr0:
idx = 0 idx = 0
elif addr == addr1: elif addr == addr1:
@ -854,6 +858,30 @@ def test_wpas_mesh_max_peering(dev, apdev, params):
zero[idx] += 1 zero[idx] += 1
logger.info("one: " + str(one)) logger.info("one: " + str(one))
logger.info("zero: " + str(zero)) logger.info("zero: " + str(zero))
if all_cap_one:
# It looks like tshark parser was broken at some point for
# wlan.mesh.config.cap which is now (tshark 2.6.3) pointing to incorrect
# field (same as wlan.mesh.config.ps_protocol). This used to work with
# tshark 2.2.6.
#
# For now, assume the capability field ends up being the last octet of
# the frame.
one = [ 0, 0, 0 ]
zero = [ 0, 0, 0 ]
addrs = [ addr0, addr1, addr2 ]
for idx in range(3):
addr = addrs[idx]
out = run_tshark_json(capfile, filt + " && wlan.sa == " + addr)
pkts = json.loads(out)
for pkt in pkts:
frame = pkt["_source"]["layers"]["frame_raw"][0]
cap = int(frame[-2:], 16)
if cap & 0x01:
one[idx] += 1
else:
zero[idx] += 1
logger.info("one: " + str(one))
logger.info("zero: " + str(zero))
if zero[0] == 0: if zero[0] == 0:
raise Exception("Accepting Additional Mesh Peerings not cleared") raise Exception("Accepting Additional Mesh Peerings not cleared")
if one[0] == 0: if one[0] == 0:

View file

@ -99,3 +99,19 @@ def run_tshark(filename, filter, display=None, wait=True):
return _run_tshark(filename, filter.replace('wlan_mgt', 'wlan'), return _run_tshark(filename, filter.replace('wlan_mgt', 'wlan'),
[x.replace('wlan_mgt', 'wlan') for x in display], [x.replace('wlan_mgt', 'wlan') for x in display],
wait) wait)
def run_tshark_json(filename, filter):
arg = [ "tshark", "-r", filename,
_tshark_filter_arg, filter ]
arg.append('-Tjson')
arg.append('-x')
try:
cmd = subprocess.Popen(arg, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
except Exception, e:
logger.info("Could run run tshark: " + str(e))
return None
output = cmd.communicate()
out = output[0]
res = cmd.wait()
return out