tests: Fix peerkey_sniffer_check with newer Wireshark version

Wireshark renamed eapol.keydes.key_info to
wlan_rsna_eapol.keydes.key_info and that broke this test case when
upgrading Wireshark. Fix this by trying to use both the new and the old
name.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2016-12-25 00:38:52 +02:00
parent 6219943d57
commit 2db07d16bf
2 changed files with 25 additions and 5 deletions

View file

@ -65,9 +65,26 @@ def test_peerkey_sniffer_check(dev, apdev, params):
addr0 = dev[0].own_addr() addr0 = dev[0].own_addr()
addr1 = dev[1].own_addr() addr1 = dev[1].own_addr()
out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"), # Wireshark renamed the EAPOL-Key key_info field, so need to try both the
"eapol.type == 3", # new and the old name to work with both versions.
display=["wlan.sa", "wlan.da", "eapol.keydes.key_info"]) try_other = False
try:
out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
"eapol.type == 3",
display=["wlan.sa", "wlan.da",
"wlan_rsna_eapol.keydes.key_info"])
except Exception, e:
if "Unknown tshark field" in str(e):
try_other = True
pass
else:
raise
if try_other:
out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
"eapol.type == 3",
display=["wlan.sa", "wlan.da",
"eapol.keydes.key_info"],
wait=False)
smk = [ False, False, False, False, False ] smk = [ False, False, False, False, False ]
stk = [ False, False, False, False ] stk = [ False, False, False, False ]

View file

@ -34,15 +34,18 @@ def run_tshark(filename, filter, display=None, wait=True):
else: else:
arg.append('-V') arg.append('-V')
cmd = subprocess.Popen(arg, stdout=subprocess.PIPE, cmd = subprocess.Popen(arg, stdout=subprocess.PIPE,
stderr=open('/dev/null', 'w')) stderr=subprocess.PIPE)
except Exception, e: except Exception, e:
logger.info("Could run run tshark check: " + str(e)) logger.info("Could run run tshark check: " + str(e))
cmd = None cmd = None
return None return None
out = cmd.communicate()[0] output = cmd.communicate()
out = output[0]
res = cmd.wait() res = cmd.wait()
if res == 1: if res == 1:
if "Some fields aren't valid" in output[1]:
raise Exception("Unknown tshark field")
# remember this for efficiency # remember this for efficiency
_tshark_filter_arg = '-R' _tshark_filter_arg = '-R'
arg[3] = '-R' arg[3] = '-R'