3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 13:02:44 +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
import os, os.path
import wiphy
from wiphy import wiphy_map
import re
import socket
@ -22,8 +22,9 @@ chan_freq_map = [
2484
]
hostapd_map = {ifname: intf for wname, wiphy in wiphy.wiphy_map.items()
for ifname, intf in wiphy.items() if intf.use == 'hostapd'}
hostapd_map = {ifname: intf for wname, wiphy in wiphy_map.items()
for ifname, intf in wiphy.interface_map.items()
if wiphy.use == 'hostapd'}
class HostapdCLI:
def __init__(self, interface):

View File

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

View File

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