3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-20 04:19:25 +01:00

auto-t: no hostapd instance graceful failure

If a test does not need any hostapd instances but still loads
hostapd.py for some reason we want to gracefully throw an
exception rather than fail in some other manor.
This commit is contained in:
James Prestwood 2020-10-20 11:02:44 -07:00 committed by Denis Kenzior
parent 9c72d2f546
commit ebd712af4e

View File

@ -32,6 +32,10 @@ class HostapdCLI:
def _init_hostapd(self, config=None):
global ctrl_count
interface = None
self.ctrl_sock = None
if not ctx.hostapd:
raise Exception("No hostapd instances are configured")
if not config and len(ctx.hostapd.instances) > 1:
raise Exception('config must be provided if more than one hostapd instance exists')
@ -110,6 +114,9 @@ class HostapdCLI:
raise Exception('timeout waiting for control response')
def _del_hostapd(self, force=False):
if not self.ctrl_sock:
return
self.ctrl_sock.close()
os.remove(self.local_ctrl)