commit 5de6af9f4a1f48ba5a38e69dd4b3072f9ff3e1cb
parent cb7e9b58851ded285a66ab5b4ef699d3f7de5889
Author: James Prestwood <prestwoj@gmail.com>
Date: Thu, 26 Aug 2021 13:33:33 -0700
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.
Diffstat:
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/tools/test-runner b/tools/test-runner
@@ -377,17 +377,20 @@ class VirtualRadio(Radio):
TODO: Using D-Bus to create and destroy radios is more desireable
than the command line.
'''
- def __init__(self, name, config=None):
+
+ def __init__(self, name, cfg=None):
+ global config
+
self.disable_cipher = None
self.disable_iftype = None
- hwsim = importlib.import_module('hwsim').Hwsim()
+ self.hwsim = config.hwsim.Hwsim()
- if config:
- self.disable_iftype = config.get('iftype_disable', None)
- self.disable_cipher = config.get('cipher_disable', None)
+ if cfg:
+ self.disable_iftype = cfg.get('iftype_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,
cipher_disable=self.disable_cipher)
@@ -499,8 +502,10 @@ class Hostapd:
self.process.wait_for_socket(hapd.intf.ctrl_interface, 30)
def attach_cli(self):
+ global config
+
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):
'''
@@ -1502,6 +1507,10 @@ def run_tests():
config = importlib.import_module('config')
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:
mount('logdir', args.log, '9p', 0, 'trans=virtio,version=9p2000.L,msize=10240')
# Clear out any log files from other test runs