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.
This commit is contained in:
James Prestwood 2020-12-17 11:36:10 -08:00 committed by Denis Kenzior
parent 55e7caa8e0
commit 01c108938e
1 changed files with 9 additions and 19 deletions

View File

@ -41,7 +41,6 @@ TIOCSTTY = 0x540E
config = None config = None
intf_id = 0 intf_id = 0
rad_id = 0
TEST_MAX_TIMEOUT = 120 TEST_MAX_TIMEOUT = 120
@ -314,35 +313,26 @@ class VirtualRadio(Radio):
than the command line. than the command line.
''' '''
def __init__(self, name, config=None): def __init__(self, name, config=None):
global rad_id
super().__init__(name)
self.disable_cipher = None self.disable_cipher = None
self.disable_iftype = None self.disable_iftype = None
args = ['hwsim', '--create', '--name', self.name, '--nointerface', '--p2p'] hwsim = importlib.import_module('hwsim').Hwsim()
if config: if config:
self.disable_iftype = config.get('iftype_disable', False) self.disable_iftype = config.get('iftype_disable', None)
if self.disable_iftype: self.disable_cipher = config.get('cipher_disable', None)
args.append('--iftype-disable')
args.append(self.disable_iftype)
self.disable_cipher = config.get('cipher_disable', False) self._radio = hwsim.radios.create(name, p2p_device=True,
if self.disable_cipher: iftype_disable=self.disable_iftype,
args.append('--cipher-disable') cipher_disable=self.disable_cipher)
args.append(self.disable_cipher)
Process(args, wait=True) super().__init__(self._radio.name)
self.id = rad_id
rad_id += 1
def __del__(self): def __del__(self):
super().__del__() super().__del__()
Process(['hwsim', '--destroy=%s' % self.id]) self._radio.remove()
self._radio = None
def __str__(self): def __str__(self):
ret = super().__str__() ret = super().__str__()