tests: Check wait_event argument type

It was clearly too easy to get unexpected behavior by accidentially
passing in a string instead of a list of strings to these functions, so
enforce the correct type to notice such issues automatically.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2019-08-07 12:41:12 +03:00 committed by Jouni Malinen
parent 12c5c2404e
commit d1fb06c947
2 changed files with 6 additions and 0 deletions

View file

@ -246,6 +246,8 @@ class Hostapd:
logger.debug(self.dbg + ": " + ev) logger.debug(self.dbg + ": " + ev)
def wait_event(self, events, timeout): def wait_event(self, events, timeout):
if not isinstance(events, list):
raise Exception("Hostapd.wait_event() called with incorrect events argument type")
start = os.times()[4] start = os.times()[4]
while True: while True:
while self.mon.pending(): while self.mon.pending():

View file

@ -838,6 +838,8 @@ class WpaSupplicant:
raise Exception("P2P_CONNECT failed") raise Exception("P2P_CONNECT failed")
def _wait_event(self, mon, pfx, events, timeout): def _wait_event(self, mon, pfx, events, timeout):
if not isinstance(events, list):
raise Exception("WpaSupplicant._wait_event() called with incorrect events argument type")
start = os.times()[4] start = os.times()[4]
while True: while True:
while mon.pending(): while mon.pending():
@ -864,6 +866,8 @@ class WpaSupplicant:
events, timeout) events, timeout)
def wait_group_event(self, events, timeout=10): def wait_group_event(self, events, timeout=10):
if not isinstance(events, list):
raise Exception("WpaSupplicant.wait_group_event() called with incorrect events argument type")
if self.group_ifname and self.group_ifname != self.ifname: if self.group_ifname and self.group_ifname != self.ifname:
if self.gctrl_mon is None: if self.gctrl_mon is None:
return None return None