autotests: Add utility script to parse interface configuration

This commit is contained in:
Andrew Zaborowski 2017-03-26 03:16:52 +02:00 committed by Denis Kenzior
parent 80ac510be0
commit 76339a8184
1 changed files with 29 additions and 0 deletions

29
autotests/util/wiphy.py Normal file
View File

@ -0,0 +1,29 @@
#! /usr/bin/python3
import os
import collections
wiphy_map = {}
Intf = collections.namedtuple('Intf',
['name', 'use', '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]
use = use_str.split(',')
intf = {}
intf['name'] = ifname
intf['use'] = use[0]
intf['ctrl_interface'] = None
intf['config'] = None
intf.update(dict([param.split('=', 1) for param in use[1:]]))
wiphy[ifname] = Intf(**intf)
parse_list()