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

test-runner: Reserve radios for wpa_supplicant

Add support for a WPA_SUPPLICANT section in  hw.conf where
'radN=<config_path>' lines will only reserve radios and create
interfaces for the autotest to be able to start wpa_supplicant on them,
i.e. this prevents iwd or hostapd from being started on them but doesn't
start a wpa_supplicant instance by itself.
This commit is contained in:
Andrew Zaborowski 2020-10-09 20:08:51 +02:00 committed by Denis Kenzior
parent 313d8dbbed
commit 04487f575b

View File

@ -246,10 +246,11 @@ class Process:
raise Exception("Timed out waiting for socket") raise Exception("Timed out waiting for socket")
class Interface: class Interface:
def __init__(self, name, config): def __init__(self, name, config, radio):
self.name = name self.name = name
self.ctrl_interface = '/var/run/hostapd/' + name self.ctrl_interface = '/var/run/hostapd/' + name
self.config = config self.config = config
self.radio = radio
def __del__(self): def __del__(self):
Process(['iw', 'dev', self.name, 'del'], True) Process(['iw', 'dev', self.name, 'del'], True)
@ -268,17 +269,15 @@ class Radio:
print("Removing radio %s" % self.name) print("Removing radio %s" % self.name)
self.interface = None self.interface = None
def create_interface(self, hapd): def create_interface(self, config, use):
global intf_id global intf_id
ifname = 'wln%s' % intf_id ifname = 'wln%s' % intf_id
intf_id += 1 intf_id += 1
self.interface = Interface(ifname, hapd.config) self.interface = Interface(ifname, config, self)
# IWD does not use interfaces in test-runner so any created self.use = use
# interface is assumed to be used by hostapd.
self.use = 'hostapd'
Process(['iw', 'phy', self.name, 'interface', 'add', ifname, Process(['iw', 'phy', self.name, 'interface', 'add', ifname,
'type', 'managed'], True) 'type', 'managed'], True)
@ -356,7 +355,7 @@ class HostapdInstance:
self.radio = radio self.radio = radio
self.config = config self.config = config
self.intf = radio.create_interface(self) self.intf = radio.create_interface(self.config, 'hostapd')
self.intf.set_interface_state('up') self.intf.set_interface_state('up')
def __del__(self): def __del__(self):
@ -471,6 +470,7 @@ class TestContext:
self.args = args self.args = args
self.hw_config = None self.hw_config = None
self.hostapd = None self.hostapd = None
self.wpas_interfaces = None
self.cur_radio_id = 0 self.cur_radio_id = 0
self.cur_iface_id = 0 self.cur_iface_id = 0
self.radios = [] self.radios = []
@ -621,6 +621,14 @@ class TestContext:
self.hostapd = Hostapd(self, hapd_radios, hapd_configs, radius_config) self.hostapd = Hostapd(self, hapd_radios, hapd_configs, radius_config)
def start_wpas_interfaces(self):
if 'WPA_SUPPLICANT' not in self.hw_config:
return
settings = self.hw_config['WPA_SUPPLICANT']
wpas_radios = [rad for rad in self.radios if rad.name in settings]
self.wpas_interfaces = [rad.create_interface(settings[rad.name], 'wpas') for rad in wpas_radios]
def start_ofono(self): def start_ofono(self):
sim_keys = self.hw_config['SETUP'].get('sim_keys', None) sim_keys = self.hw_config['SETUP'].get('sim_keys', None)
if not sim_keys: if not sim_keys:
@ -688,6 +696,7 @@ class TestContext:
def stop_test_processes(self): def stop_test_processes(self):
self.radios = [] self.radios = []
self.hostapd = None self.hostapd = None
self.wpas_interfaces = None
self.iwd_extra_options = None self.iwd_extra_options = None
for p in [p for p in self.processes if p.multi_test is False]: for p in [p for p in self.processes if p.multi_test is False]:
@ -884,6 +893,7 @@ def pre_test(ctx, test):
ctx.start_dbus_monitor() ctx.start_dbus_monitor()
ctx.start_radios() ctx.start_radios()
ctx.start_hostapd() ctx.start_hostapd()
ctx.start_wpas_interfaces()
ctx.start_ofono() ctx.start_ofono()
if ctx.args.log: if ctx.args.log: