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

test-runner: only import Hwsim/HostapdCLI once

These modules only needed to be imported a single time for the entire
run of tests. This is significantly cheaper in terms of memory and
should prevent random OOM exceptions.
This commit is contained in:
James Prestwood 2021-08-26 13:33:33 -07:00 committed by Denis Kenzior
parent cb7e9b5885
commit 5de6af9f4a

View File

@ -377,17 +377,20 @@ class VirtualRadio(Radio):
TODO: Using D-Bus to create and destroy radios is more desireable TODO: Using D-Bus to create and destroy radios is more desireable
than the command line. than the command line.
''' '''
def __init__(self, name, config=None):
def __init__(self, name, cfg=None):
global config
self.disable_cipher = None self.disable_cipher = None
self.disable_iftype = None self.disable_iftype = None
hwsim = importlib.import_module('hwsim').Hwsim() self.hwsim = config.hwsim.Hwsim()
if config: if cfg:
self.disable_iftype = config.get('iftype_disable', None) self.disable_iftype = cfg.get('iftype_disable', None)
self.disable_cipher = config.get('cipher_disable', None) self.disable_cipher = cfg.get('cipher_disable', None)
self._radio = hwsim.radios.create(name, p2p_device=True, self._radio = self.hwsim.radios.create(name, p2p_device=True,
iftype_disable=self.disable_iftype, iftype_disable=self.disable_iftype,
cipher_disable=self.disable_cipher) cipher_disable=self.disable_cipher)
@ -499,8 +502,10 @@ class Hostapd:
self.process.wait_for_socket(hapd.intf.ctrl_interface, 30) self.process.wait_for_socket(hapd.intf.ctrl_interface, 30)
def attach_cli(self): def attach_cli(self):
global config
for hapd in self.instances: for hapd in self.instances:
hapd.cli = importlib.import_module('hostapd').HostapdCLI(config=hapd.config) hapd.cli = config.hostapd.HostapdCLI(config=hapd.config)
def _rewrite_config(self, config): def _rewrite_config(self, config):
''' '''
@ -1502,6 +1507,10 @@ def run_tests():
config = importlib.import_module('config') config = importlib.import_module('config')
config.ctx = TestContext(args) config.ctx = TestContext(args)
# Must import these after config so ctx gets set
config.hwsim = importlib.import_module('hwsim')
config.hostapd = importlib.import_module('hostapd')
if args.log: if args.log:
mount('logdir', args.log, '9p', 0, 'trans=virtio,version=9p2000.L,msize=10240') mount('logdir', args.log, '9p', 0, 'trans=virtio,version=9p2000.L,msize=10240')
# Clear out any log files from other test runs # Clear out any log files from other test runs