3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-10-04 02:18:49 +02:00

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.
This commit is contained in:
James Prestwood 2019-06-05 14:02:25 -07:00 committed by Denis Kenzior
parent 55a077d399
commit 35f06ef87a

View File

@ -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)