tests: Make pmksa_cache_expiration more robust
Wait for hostapd to enter the PTKINITDONE state before checking connectivity. This is needed to avoid a race condition with UML time-travel. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
fd0465b85e
commit
0075df74df
2 changed files with 13 additions and 0 deletions
|
@ -271,6 +271,18 @@ class Hostapd:
|
|||
if addr and addr not in ev:
|
||||
raise Exception("Unexpected STA address in connection event: " + ev)
|
||||
|
||||
def wait_ptkinitdone(self, addr, timeout=2):
|
||||
while timeout > 0:
|
||||
sta = self.get_sta(addr)
|
||||
if 'hostapdWPAPTKState' not in sta:
|
||||
raise Exception("GET_STA did not return hostapdWPAPTKState")
|
||||
state = sta['hostapdWPAPTKState']
|
||||
if state == "11":
|
||||
return
|
||||
os.sleep(0.1)
|
||||
timeout -= 0.1
|
||||
raise Exception("Timeout while waiting for PTKINITDONE")
|
||||
|
||||
def get_status(self):
|
||||
res = self.request("STATUS")
|
||||
lines = res.splitlines()
|
||||
|
|
|
@ -353,6 +353,7 @@ def test_pmksa_cache_expiration(dev, apdev):
|
|||
pmksa2 = dev[0].get_pmksa(bssid)
|
||||
if pmksa['pmkid'] == pmksa2['pmkid']:
|
||||
raise Exception("PMKID did not change")
|
||||
hapd.wait_ptkinitdone(dev[0].own_addr())
|
||||
hwsim_utils.test_connectivity(dev[0], hapd)
|
||||
|
||||
def test_pmksa_cache_expiration_disconnect(dev, apdev):
|
||||
|
|
Loading…
Reference in a new issue