tests: Use a helper function for waiting session termination
Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
451afb4fd3
commit
2c914e2464
4 changed files with 18 additions and 55 deletions
|
@ -32,11 +32,7 @@ def test_autogo(dev):
|
||||||
autogo(dev[0])
|
autogo(dev[0])
|
||||||
connect_cli(dev[0], dev[1])
|
connect_cli(dev[0], dev[1])
|
||||||
dev[0].remove_group()
|
dev[0].remove_group()
|
||||||
ev = dev[1].wait_event(["P2P-GROUP-REMOVED"], timeout=2)
|
dev[1].wait_go_ending_session()
|
||||||
if ev is None:
|
|
||||||
raise Exception("Group removal event timed out")
|
|
||||||
if "reason=GO_ENDING_SESSION" not in ev:
|
|
||||||
raise Exception("Unexpected group removal reason")
|
|
||||||
|
|
||||||
def test_autogo_2cli(dev):
|
def test_autogo_2cli(dev):
|
||||||
"""P2P autonomous GO and two clients joining group"""
|
"""P2P autonomous GO and two clients joining group"""
|
||||||
|
@ -45,17 +41,9 @@ def test_autogo_2cli(dev):
|
||||||
connect_cli(dev[0], dev[2])
|
connect_cli(dev[0], dev[2])
|
||||||
hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
|
hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
|
||||||
dev[0].global_request("P2P_REMOVE_CLIENT " + dev[1].p2p_dev_addr())
|
dev[0].global_request("P2P_REMOVE_CLIENT " + dev[1].p2p_dev_addr())
|
||||||
ev = dev[1].wait_event(["P2P-GROUP-REMOVED"], timeout=2)
|
dev[1].wait_go_ending_session()
|
||||||
if ev is None:
|
|
||||||
raise Exception("Group removal event timed out")
|
|
||||||
if "reason=GO_ENDING_SESSION" not in ev:
|
|
||||||
raise Exception("Unexpected group removal reason")
|
|
||||||
dev[0].remove_group()
|
dev[0].remove_group()
|
||||||
ev = dev[2].wait_event(["P2P-GROUP-REMOVED"], timeout=2)
|
dev[2].wait_go_ending_session()
|
||||||
if ev is None:
|
|
||||||
raise Exception("Group removal event timed out")
|
|
||||||
if "reason=GO_ENDING_SESSION" not in ev:
|
|
||||||
raise Exception("Unexpected group removal reason")
|
|
||||||
|
|
||||||
def test_autogo_tdls(dev):
|
def test_autogo_tdls(dev):
|
||||||
"""P2P autonomous GO and two clients using TDLS"""
|
"""P2P autonomous GO and two clients using TDLS"""
|
||||||
|
|
|
@ -177,16 +177,8 @@ def test_grpform_per_sta_psk(dev):
|
||||||
hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
|
hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
|
||||||
|
|
||||||
dev[0].remove_group()
|
dev[0].remove_group()
|
||||||
ev = dev[1].wait_event(["P2P-GROUP-REMOVED"], timeout=2)
|
dev[1].wait_go_ending_session()
|
||||||
if ev is None:
|
dev[2].wait_go_ending_session()
|
||||||
raise Exception("Group removal event timed out")
|
|
||||||
if "reason=GO_ENDING_SESSION" not in ev:
|
|
||||||
raise Exception("Unexpected group removal reason")
|
|
||||||
ev = dev[2].wait_event(["P2P-GROUP-REMOVED"], timeout=2)
|
|
||||||
if ev is None:
|
|
||||||
raise Exception("Group removal event timed out")
|
|
||||||
if "reason=GO_ENDING_SESSION" not in ev:
|
|
||||||
raise Exception("Unexpected group removal reason")
|
|
||||||
|
|
||||||
def test_grpform_per_sta_psk_wps(dev):
|
def test_grpform_per_sta_psk_wps(dev):
|
||||||
"""P2P group formation with per-STA PSKs with non-P2P WPS STA"""
|
"""P2P group formation with per-STA PSKs with non-P2P WPS STA"""
|
||||||
|
@ -204,8 +196,4 @@ def test_grpform_per_sta_psk_wps(dev):
|
||||||
|
|
||||||
dev[0].remove_group()
|
dev[0].remove_group()
|
||||||
dev[2].request("DISCONNECT")
|
dev[2].request("DISCONNECT")
|
||||||
ev = dev[1].wait_event(["P2P-GROUP-REMOVED"], timeout=2)
|
dev[1].wait_go_ending_session()
|
||||||
if ev is None:
|
|
||||||
raise Exception("Group removal event timed out")
|
|
||||||
if "reason=GO_ENDING_SESSION" not in ev:
|
|
||||||
raise Exception("Unexpected group removal reason")
|
|
||||||
|
|
|
@ -42,11 +42,7 @@ def test_persistent_group(dev):
|
||||||
|
|
||||||
logger.info("Terminate persistent group")
|
logger.info("Terminate persistent group")
|
||||||
dev[0].remove_group()
|
dev[0].remove_group()
|
||||||
ev = dev[1].wait_event(["P2P-GROUP-REMOVED"], timeout=3)
|
dev[1].wait_go_ending_session()
|
||||||
if ev is None:
|
|
||||||
raise Exception("Group removal event timed out")
|
|
||||||
if "reason=GO_ENDING_SESSION" not in ev:
|
|
||||||
raise Exception("Unexpected group removal reason")
|
|
||||||
|
|
||||||
logger.info("Re-invoke persistent group from client")
|
logger.info("Re-invoke persistent group from client")
|
||||||
dev[0].request("SET persistent_reconnect 1")
|
dev[0].request("SET persistent_reconnect 1")
|
||||||
|
@ -76,11 +72,7 @@ def test_persistent_group(dev):
|
||||||
|
|
||||||
logger.info("Terminate persistent group")
|
logger.info("Terminate persistent group")
|
||||||
dev[0].remove_group()
|
dev[0].remove_group()
|
||||||
ev = dev[1].wait_event(["P2P-GROUP-REMOVED"], timeout=3)
|
dev[1].wait_go_ending_session()
|
||||||
if ev is None:
|
|
||||||
raise Exception("Group removal event timed out")
|
|
||||||
if "reason=GO_ENDING_SESSION" not in ev:
|
|
||||||
raise Exception("Unexpected group removal reason")
|
|
||||||
|
|
||||||
logger.info("Re-invoke persistent group from GO")
|
logger.info("Re-invoke persistent group from GO")
|
||||||
dev[1].request("SET persistent_reconnect 1")
|
dev[1].request("SET persistent_reconnect 1")
|
||||||
|
@ -110,11 +102,7 @@ def test_persistent_group(dev):
|
||||||
|
|
||||||
logger.info("Terminate persistent group")
|
logger.info("Terminate persistent group")
|
||||||
dev[0].remove_group()
|
dev[0].remove_group()
|
||||||
ev = dev[1].wait_event(["P2P-GROUP-REMOVED"], timeout=3)
|
dev[1].wait_go_ending_session()
|
||||||
if ev is None:
|
|
||||||
raise Exception("Group removal event timed out")
|
|
||||||
if "reason=GO_ENDING_SESSION" not in ev:
|
|
||||||
raise Exception("Unexpected group removal reason")
|
|
||||||
|
|
||||||
def test_persistent_group_per_sta_psk(dev):
|
def test_persistent_group_per_sta_psk(dev):
|
||||||
"""P2P persistent group formation and re-invocation using per-client PSK"""
|
"""P2P persistent group formation and re-invocation using per-client PSK"""
|
||||||
|
@ -158,11 +146,7 @@ def test_persistent_group_per_sta_psk(dev):
|
||||||
|
|
||||||
logger.info("Remove one of the clients from the group")
|
logger.info("Remove one of the clients from the group")
|
||||||
dev[0].global_request("P2P_REMOVE_CLIENT " + addr2)
|
dev[0].global_request("P2P_REMOVE_CLIENT " + addr2)
|
||||||
ev = dev[2].wait_event(["P2P-GROUP-REMOVED"], timeout=3)
|
dev[2].wait_go_ending_session()
|
||||||
if ev is None:
|
|
||||||
raise Exception("Group removal event timed out")
|
|
||||||
if "reason=GO_ENDING_SESSION" not in ev:
|
|
||||||
raise Exception("Unexpected group removal reason")
|
|
||||||
|
|
||||||
logger.info("Try to reconnect after having been removed from group")
|
logger.info("Try to reconnect after having been removed from group")
|
||||||
if not dev[2].discover_peer(addr0, social=True):
|
if not dev[2].discover_peer(addr0, social=True):
|
||||||
|
@ -178,11 +162,7 @@ def test_persistent_group_per_sta_psk(dev):
|
||||||
|
|
||||||
logger.info("Remove the remaining client from the group")
|
logger.info("Remove the remaining client from the group")
|
||||||
dev[0].global_request("P2P_REMOVE_CLIENT " + addr1)
|
dev[0].global_request("P2P_REMOVE_CLIENT " + addr1)
|
||||||
ev = dev[1].wait_event(["P2P-GROUP-REMOVED"], timeout=3)
|
dev[1].wait_go_ending_session()
|
||||||
if ev is None:
|
|
||||||
raise Exception("Group removal event timed out")
|
|
||||||
if "reason=GO_ENDING_SESSION" not in ev:
|
|
||||||
raise Exception("Unexpected group removal reason")
|
|
||||||
|
|
||||||
logger.info("Terminate persistent group")
|
logger.info("Terminate persistent group")
|
||||||
dev[0].remove_group()
|
dev[0].remove_group()
|
||||||
|
|
|
@ -320,6 +320,13 @@ class WpaSupplicant:
|
||||||
return ev
|
return ev
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def wait_go_ending_session(self):
|
||||||
|
ev = self.wait_event(["P2P-GROUP-REMOVED"], timeout=3)
|
||||||
|
if ev is None:
|
||||||
|
raise Exception("Group removal event timed out")
|
||||||
|
if "reason=GO_ENDING_SESSION" not in ev:
|
||||||
|
raise Exception("Unexpected group removal reason")
|
||||||
|
|
||||||
def dump_monitor(self):
|
def dump_monitor(self):
|
||||||
while self.mon.pending():
|
while self.mon.pending():
|
||||||
ev = self.mon.recv()
|
ev = self.mon.recv()
|
||||||
|
|
Loading…
Reference in a new issue