commit e13c749d1e266fa26dbb649e07464c2af15558f7
parent d1c4921b8677e862ef3531c41f53dd3c50c671f9
Author: Andrew Zaborowski <andrew.zaborowski@intel.com>
Date: Sat, 20 Apr 2019 22:29:01 +0200
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.
Diffstat:
3 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/autotests/util/hostapd.py b/autotests/util/hostapd.py
@@ -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):
diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py
@@ -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':
diff --git a/autotests/util/wiphy.py b/autotests/util/wiphy.py
@@ -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)
+ wname, use_str = entry.split('=', 1)
+ use = use_str.split(',')
if wname not in wiphy_map:
- wiphy_map[wname] = {}
- wiphy = wiphy_map[wname]
+ wiphy_map[wname] = Wiphy(use=use[0], name=wname, interface_map={})
- use = use_str.split(',')
+ 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()