From 04487f575b684e9338f450083778341688871660 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Fri, 9 Oct 2020 20:08:51 +0200 Subject: [PATCH] test-runner: Reserve radios for wpa_supplicant Add support for a WPA_SUPPLICANT section in hw.conf where 'radN=' 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. --- tools/test-runner | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tools/test-runner b/tools/test-runner index 809a3905..8c06816c 100755 --- a/tools/test-runner +++ b/tools/test-runner @@ -246,10 +246,11 @@ class Process: raise Exception("Timed out waiting for socket") class Interface: - def __init__(self, name, config): + def __init__(self, name, config, radio): self.name = name self.ctrl_interface = '/var/run/hostapd/' + name self.config = config + self.radio = radio def __del__(self): Process(['iw', 'dev', self.name, 'del'], True) @@ -268,17 +269,15 @@ class Radio: print("Removing radio %s" % self.name) self.interface = None - def create_interface(self, hapd): + def create_interface(self, config, use): global intf_id ifname = 'wln%s' % intf_id intf_id += 1 - self.interface = Interface(ifname, hapd.config) - # IWD does not use interfaces in test-runner so any created - # interface is assumed to be used by hostapd. - self.use = 'hostapd' + self.interface = Interface(ifname, config, self) + self.use = use Process(['iw', 'phy', self.name, 'interface', 'add', ifname, 'type', 'managed'], True) @@ -356,7 +355,7 @@ class HostapdInstance: self.radio = radio self.config = config - self.intf = radio.create_interface(self) + self.intf = radio.create_interface(self.config, 'hostapd') self.intf.set_interface_state('up') def __del__(self): @@ -471,6 +470,7 @@ class TestContext: self.args = args self.hw_config = None self.hostapd = None + self.wpas_interfaces = None self.cur_radio_id = 0 self.cur_iface_id = 0 self.radios = [] @@ -621,6 +621,14 @@ class TestContext: 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): sim_keys = self.hw_config['SETUP'].get('sim_keys', None) if not sim_keys: @@ -688,6 +696,7 @@ class TestContext: def stop_test_processes(self): self.radios = [] self.hostapd = None + self.wpas_interfaces = None self.iwd_extra_options = None 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_radios() ctx.start_hostapd() + ctx.start_wpas_interfaces() ctx.start_ofono() if ctx.args.log: