3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-23 06:02:37 +01:00

autotests: Update the wiphy_map and hostapd_map structs

In the test utilties updated the wiphy_map struct built from the
TEST_WIPHY_LIST variable to parse the new format and to use a new
structure where each wiphy is a namedtuple and each interface under it
also contains a reference to that wiphy.  The 'use' field is now
assigned to the wiphy instead of to the interface.
This commit is contained in:
Andrew Zaborowski 2019-04-20 22:29:01 +02:00 committed by Denis Kenzior
parent d1c4921b86
commit e13c749d1e
3 changed files with 18 additions and 15 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/python3 #!/usr/bin/python3
import os, os.path import os, os.path
import wiphy from wiphy import wiphy_map
import re import re
import socket import socket
@ -22,8 +22,9 @@ chan_freq_map = [
2484 2484
] ]
hostapd_map = {ifname: intf for wname, wiphy in wiphy.wiphy_map.items() hostapd_map = {ifname: intf for wname, wiphy in wiphy_map.items()
for ifname, intf in wiphy.items() if intf.use == 'hostapd'} for ifname, intf in wiphy.interface_map.items()
if wiphy.use == 'hostapd'}
class HostapdCLI: class HostapdCLI:
def __init__(self, interface): def __init__(self, interface):

View File

@ -843,8 +843,7 @@ class IWD(AsyncOpAbstract):
if start_iwd_daemon: if start_iwd_daemon:
args = [] args = []
iwd_wiphys = [wname for wname, wiphy in wiphy.wiphy_map.items() iwd_wiphys = [wname for wname, wiphy in wiphy.wiphy_map.items()
if any(intf for intf in wiphy.values() if wiphy.use == 'iwd']
if intf.use == 'iwd')]
whitelist = ','.join(iwd_wiphys) whitelist = ','.join(iwd_wiphys)
if os.environ.get('IWD_TEST_VALGRIND', None) == 'on': if os.environ.get('IWD_TEST_VALGRIND', None) == 'on':

View File

@ -4,26 +4,29 @@ import collections
wiphy_map = {} wiphy_map = {}
Wiphy = collections.namedtuple('Wiphy', ['name', 'use', 'interface_map'])
Intf = collections.namedtuple('Intf', Intf = collections.namedtuple('Intf',
['name', 'use', 'ctrl_interface', 'config']) ['name', 'wiphy', 'ctrl_interface', 'config'])
def parse_list(): def parse_list():
for entry in os.environ['TEST_WIPHY_LIST'].split('\n'): for entry in os.environ['TEST_WIPHY_LIST'].split('\n'):
wname, ifname, use_str = entry.split('=', 2) wname, use_str = entry.split('=', 1)
if wname not in wiphy_map:
wiphy_map[wname] = {}
wiphy = wiphy_map[wname]
use = use_str.split(',') use = use_str.split(',')
if wname not in wiphy_map:
wiphy_map[wname] = Wiphy(use=use[0], name=wname, interface_map={})
if len(use) <= 1:
continue
intf = {} intf = {}
intf['name'] = ifname intf['name'] = None
intf['use'] = use[0] intf['wiphy'] = wiphy_map[wname]
intf['ctrl_interface'] = None intf['ctrl_interface'] = None
intf['config'] = None intf['config'] = None
intf.update(dict([param.split('=', 1) for param in use[1:]])) intf.update(dict([param.split('=', 1) for param in use[1:]]))
wiphy[ifname] = Intf(**intf) wiphy_map[wname].interface_map[intf['name']] = Intf(**intf)
parse_list() parse_list()