]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Fix peerkey_sniffer_check with newer Wireshark version
authorJouni Malinen <j@w1.fi>
Sat, 24 Dec 2016 22:38:52 +0000 (00:38 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 24 Dec 2016 22:38:52 +0000 (00:38 +0200)
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>
tests/hwsim/test_peerkey.py
tests/hwsim/tshark.py

index a3d6d22ef52654110c1bf591a95478cc959aa1d0..ec182851cb8a125e0c50aad9aed9dc5b1aa3a4ef 100644 (file)
@@ -65,9 +65,26 @@ def test_peerkey_sniffer_check(dev, apdev, params):
     addr0 = dev[0].own_addr()
     addr1 = dev[1].own_addr()
 
-    out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
-                     "eapol.type == 3",
-                     display=["wlan.sa", "wlan.da", "eapol.keydes.key_info"])
+    # Wireshark renamed the EAPOL-Key key_info field, so need to try both the
+    # new and the old name to work with both versions.
+    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 ]
     stk = [ False, False, False, False ]
index 5faed5e436148cdcc0ff7f2f8669fd4b8c31bb79..d2a8c45ca24f5ef9983245a775407b941020aa8b 100644 (file)
@@ -34,15 +34,18 @@ def run_tshark(filename, filter, display=None, wait=True):
         else:
             arg.append('-V')
         cmd = subprocess.Popen(arg, stdout=subprocess.PIPE,
-                               stderr=open('/dev/null', 'w'))
+                               stderr=subprocess.PIPE)
     except Exception, e:
         logger.info("Could run run tshark check: " + str(e))
         cmd = None
         return None
 
-    out = cmd.communicate()[0]
+    output = cmd.communicate()
+    out = output[0]
     res = cmd.wait()
     if res == 1:
+        if "Some fields aren't valid" in output[1]:
+            raise Exception("Unknown tshark field")
         # remember this for efficiency
         _tshark_filter_arg = '-R'
         arg[3] = '-R'