From ebd712af4e8b48ffc1c5e3139cbc1d0999aeeb6e Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Tue, 20 Oct 2020 11:02:44 -0700 Subject: [PATCH] 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. --- autotests/util/hostapd.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/autotests/util/hostapd.py b/autotests/util/hostapd.py index 7c0d8385..cf82c010 100644 --- a/autotests/util/hostapd.py +++ b/autotests/util/hostapd.py @@ -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)