diff --git a/tests/hwsim/test_ap_track.py b/tests/hwsim/test_ap_track.py index 75664a4ce..69c96d824 100644 --- a/tests/hwsim/test_ap_track.py +++ b/tests/hwsim/test_ap_track.py @@ -11,6 +11,7 @@ import time import hostapd from wpasupplicant import WpaSupplicant +from utils import parse_ie def test_ap_track_sta(dev, apdev): """Dualband AP tracking unconnected stations""" @@ -110,8 +111,15 @@ def _test_ap_track_sta_no_probe_resp(dev, apdev): dev[0].scan(freq=2437, type="ONLY") dev[0].scan(freq=2437, type="ONLY") - if dev[0].get_bss(bssid): - raise Exception("2.4 GHz AP found unexpectedly") + bss = dev[0].get_bss(bssid) + if bss: + ie = parse_ie(bss['ie']) + # Check whether this is from a Beacon frame (TIM element included) since + # it is possible that a Beacon frame was received during the active + # scan. This test should fail only if a Probe Response frame was + # received. + if 5 not in ie: + raise Exception("2.4 GHz AP found unexpectedly") def test_ap_track_sta_no_auth(dev, apdev): """Dualband AP rejecting authentication from dualband STA on 2.4 GHz""" diff --git a/tests/hwsim/utils.py b/tests/hwsim/utils.py index 479923cea..69d3cff39 100644 --- a/tests/hwsim/utils.py +++ b/tests/hwsim/utils.py @@ -4,7 +4,9 @@ # This software may be distributed under the terms of the BSD license. # See README for more details. +import binascii import os +import struct import time import remotehost @@ -102,3 +104,15 @@ def get_phy(ap, ifname=None): phy = "phy" + words[1] break return phy + +def parse_ie(buf): + ret = {} + data = binascii.unhexlify(buf) + while len(data) >= 2: + ie,elen = struct.unpack('BB', data[0:2]) + data = data[2:] + if elen > len(data): + break + ret[ie] = data[0:elen] + data = data[elen:] + return ret