commit 01c108938e62e651b52da512dbbc562cd0cb7a7a
parent 55e7caa8e0b4eb505482a9e091c7d6777e23f59a
Author: James Prestwood <prestwoj@gmail.com>
Date: Thu, 17 Dec 2020 11:36:10 -0800
test-runner: Use DBus for hwsim radios
Use the hwsim DBus API rather than command line. This both is
faster and more dynamic than doing so with the command line.
This also avoids tracking the radio ID since we can just hang
on to the radio Dbus object directly.
Diffstat:
1 file changed, 9 insertions(+), 19 deletions(-)
diff --git a/tools/test-runner b/tools/test-runner
@@ -41,7 +41,6 @@ TIOCSTTY = 0x540E
config = None
intf_id = 0
-rad_id = 0
TEST_MAX_TIMEOUT = 120
@@ -314,35 +313,26 @@ class VirtualRadio(Radio):
than the command line.
'''
def __init__(self, name, config=None):
- global rad_id
-
- super().__init__(name)
-
self.disable_cipher = None
self.disable_iftype = None
- args = ['hwsim', '--create', '--name', self.name, '--nointerface', '--p2p']
+ hwsim = importlib.import_module('hwsim').Hwsim()
if config:
- self.disable_iftype = config.get('iftype_disable', False)
- if self.disable_iftype:
- args.append('--iftype-disable')
- args.append(self.disable_iftype)
-
- self.disable_cipher = config.get('cipher_disable', False)
- if self.disable_cipher:
- args.append('--cipher-disable')
- args.append(self.disable_cipher)
+ self.disable_iftype = config.get('iftype_disable', None)
+ self.disable_cipher = config.get('cipher_disable', None)
- Process(args, wait=True)
+ self._radio = hwsim.radios.create(name, p2p_device=True,
+ iftype_disable=self.disable_iftype,
+ cipher_disable=self.disable_cipher)
- self.id = rad_id
- rad_id += 1
+ super().__init__(self._radio.name)
def __del__(self):
super().__del__()
- Process(['hwsim', '--destroy=%s' % self.id])
+ self._radio.remove()
+ self._radio = None
def __str__(self):
ret = super().__str__()