commit 35f06ef87aa100aa53521c3c68ef9c1bde506ad1
parent 55a077d399a9701967d26226dfb771531793b3ba
Author: James Prestwood <james.prestwood@linux.intel.com>
Date: Wed, 5 Jun 2019 14:02:25 -0700
auto-t: hostapd: allow CLI to lookup by config file
There is a common interface lookup in many tests in order to initialize
the HostapdCLI object e.g.:
for intf in hostapd_map.values():
if intf.config == 'ssidOWE.conf':
hapd = HostapdCLI(intf)
break
Instead of having to do this in every test, HostapdCLI will now
optionally take a config file (config=<file>). The interface object
will still be prefered (i.e. supplying an interface will not even
check the config file) as to not break existing tests. But if only
a config file is supplied the lookup is done internally.
There are some tests that do still need the interface, as they do
an interface lookup to initialize both hostapd and hwsim at the
same time.
Diffstat:
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/autotests/util/hostapd.py b/autotests/util/hostapd.py
@@ -27,7 +27,16 @@ hostapd_map = {ifname: intf for wname, wiphy in wiphy_map.items()
if wiphy.use == 'hostapd'}
class HostapdCLI:
- def __init__(self, interface):
+ def __init__(self, interface=None, config=None):
+ if not interface and not config:
+ raise Exception('interface or config must be provided')
+
+ if not interface:
+ for intf in hostapd_map.values():
+ if intf.config == config:
+ interface = intf
+ break
+
self.ifname = interface.name
self.socket_path = os.path.dirname(interface.ctrl_interface)