autotests: Use hostapd_map in place of wiphy_map

In the tests that only want to iterate over the hostapd interfaces,
simplify the pattern of walking through the whole wiphy_map tree by
instead using the hostapd_map variable which is already filtered to only
contain hostapd interfaces.
This commit is contained in:
Andrew Zaborowski 2019-04-20 22:29:04 +02:00 committed by Denis Kenzior
parent 576d8ad123
commit f456ac49dc
16 changed files with 53 additions and 115 deletions

View File

@ -12,7 +12,6 @@ from iwd import NetworkType
from hostapd import HostapdCLI from hostapd import HostapdCLI
from hostapd import hostapd_map from hostapd import hostapd_map
from wiphy import wiphy_map
from hwsim import Hwsim from hwsim import Hwsim
class Test(unittest.TestCase): class Test(unittest.TestCase):
@ -23,9 +22,7 @@ class Test(unittest.TestCase):
bss_hostapd = [None, None, None] bss_hostapd = [None, None, None]
bss_radio = [None, None, None] bss_radio = [None, None, None]
for wname in wiphy_map: for intf in hostapd_map.values():
wiphy = wiphy_map[wname]
intf = list(wiphy.values())[0]
if intf.config and '1' in intf.config: if intf.config and '1' in intf.config:
bss_idx = 0 bss_idx = 0
elif intf.config and '2' in intf.config: elif intf.config and '2' in intf.config:
@ -37,7 +34,7 @@ class Test(unittest.TestCase):
for path in hwsim.radios: for path in hwsim.radios:
radio = hwsim.radios[path] radio = hwsim.radios[path]
if radio.name == wname: if radio.name == intf.wiphy.name:
break break
bss_hostapd[bss_idx] = HostapdCLI(intf) bss_hostapd[bss_idx] = HostapdCLI(intf)

View File

@ -12,7 +12,6 @@ from iwd import NetworkType
from hostapd import HostapdCLI from hostapd import HostapdCLI
from hostapd import hostapd_map from hostapd import hostapd_map
from wiphy import wiphy_map
from hwsim import Hwsim from hwsim import Hwsim
import time import time
@ -25,10 +24,7 @@ class Test(unittest.TestCase):
bss_radio = [None, None, None] bss_radio = [None, None, None]
bss_hostapd = [None, None, None] bss_hostapd = [None, None, None]
for wname in wiphy_map: for intf in hostapd_map.values():
wiphy = wiphy_map[wname]
intf = list(wiphy.values())[0]
if intf.config and '1' in intf.config: if intf.config and '1' in intf.config:
bss_idx = 0 bss_idx = 0
elif intf.config and '2' in intf.config: elif intf.config and '2' in intf.config:
@ -40,7 +36,7 @@ class Test(unittest.TestCase):
for path in hwsim.radios: for path in hwsim.radios:
radio = hwsim.radios[path] radio = hwsim.radios[path]
if radio.name == wname: if radio.name == intf.wiphy.name:
break break
bss_radio[bss_idx] = radio bss_radio[bss_idx] = radio

View File

@ -12,7 +12,6 @@ from iwd import NetworkType
from hostapd import HostapdCLI from hostapd import HostapdCLI
from hostapd import hostapd_map from hostapd import hostapd_map
from wiphy import wiphy_map
from hwsim import Hwsim from hwsim import Hwsim
import time import time
@ -25,10 +24,7 @@ class Test(unittest.TestCase):
bss_radio = [None, None, None] bss_radio = [None, None, None]
bss_hostapd = [None, None, None] bss_hostapd = [None, None, None]
for wname in wiphy_map: for intf in hostapd_map.values():
wiphy = wiphy_map[wname]
intf = list(wiphy.values())[0]
if intf.config and '1' in intf.config: if intf.config and '1' in intf.config:
bss_idx = 0 bss_idx = 0
elif intf.config and '2' in intf.config: elif intf.config and '2' in intf.config:
@ -40,7 +36,7 @@ class Test(unittest.TestCase):
for path in hwsim.radios: for path in hwsim.radios:
radio = hwsim.radios[path] radio = hwsim.radios[path]
if radio.name == wname: if radio.name == intf.wiphy.name:
break break
bss_radio[bss_idx] = radio bss_radio[bss_idx] = radio

View File

@ -12,7 +12,6 @@ from iwd import NetworkType
from hostapd import HostapdCLI from hostapd import HostapdCLI
from hostapd import hostapd_map from hostapd import hostapd_map
from wiphy import wiphy_map
from hwsim import Hwsim from hwsim import Hwsim
import time import time
@ -25,10 +24,7 @@ class Test(unittest.TestCase):
bss_radio = [None, None, None] bss_radio = [None, None, None]
bss_hostapd = [None, None, None] bss_hostapd = [None, None, None]
for wname in wiphy_map: for intf in hostapd_map.values():
wiphy = wiphy_map[wname]
intf = list(wiphy.values())[0]
if intf.config and '1' in intf.config: if intf.config and '1' in intf.config:
bss_idx = 0 bss_idx = 0
elif intf.config and '2' in intf.config: elif intf.config and '2' in intf.config:
@ -40,7 +36,7 @@ class Test(unittest.TestCase):
for path in hwsim.radios: for path in hwsim.radios:
radio = hwsim.radios[path] radio = hwsim.radios[path]
if radio.name == wname: if radio.name == intf.wiphy.name:
break break
bss_radio[bss_idx] = radio bss_radio[bss_idx] = radio

View File

@ -12,7 +12,6 @@ from iwd import NetworkType
from hostapd import HostapdCLI from hostapd import HostapdCLI
from hostapd import hostapd_map from hostapd import hostapd_map
from wiphy import wiphy_map
from hwsim import Hwsim from hwsim import Hwsim
import time import time
@ -25,10 +24,7 @@ class Test(unittest.TestCase):
bss_radio = [None, None, None] bss_radio = [None, None, None]
bss_hostapd = [None, None, None] bss_hostapd = [None, None, None]
for wname in wiphy_map: for intf in hostapd_map.values():
wiphy = wiphy_map[wname]
intf = list(wiphy.values())[0]
if intf.config and '1' in intf.config: if intf.config and '1' in intf.config:
bss_idx = 0 bss_idx = 0
elif intf.config and '2' in intf.config: elif intf.config and '2' in intf.config:
@ -40,7 +36,7 @@ class Test(unittest.TestCase):
for path in hwsim.radios: for path in hwsim.radios:
radio = hwsim.radios[path] radio = hwsim.radios[path]
if radio.name == wname: if radio.name == intf.wiphy.name:
break break
bss_radio[bss_idx] = radio bss_radio[bss_idx] = radio

View File

@ -18,7 +18,7 @@ class Test(unittest.TestCase):
def test_connection_success(self): def test_connection_success(self):
hostapd = None hostapd = None
for hostapd_if in list(hostapd_map.values()): for hostapd_if in hostapd_map.values():
hpd = HostapdCLI(hostapd_if) hpd = HostapdCLI(hostapd_if)
if hpd.get_config_value('ssid') == 'ssidEAP-TTLS-MSCHAP': if hpd.get_config_value('ssid') == 'ssidEAP-TTLS-MSCHAP':
hostapd = hpd hostapd = hpd

View File

@ -8,8 +8,7 @@ import iwd
from iwd import IWD from iwd import IWD
from iwd import NetworkType from iwd import NetworkType
from hwsim import Hwsim from hwsim import Hwsim
from hostapd import HostapdCLI from hostapd import HostapdCLI, hostapd_map
from wiphy import wiphy_map
import testutil import testutil
class Test(unittest.TestCase): class Test(unittest.TestCase):
@ -195,9 +194,7 @@ class Test(unittest.TestCase):
cls.bss_hostapd = [None, None] cls.bss_hostapd = [None, None]
cls.bss_radio = [None, None] cls.bss_radio = [None, None]
for wname in wiphy_map: for intf in hostapd_map.values():
wiphy = wiphy_map[wname]
intf = list(wiphy.values())[0]
if intf.config and '1' in intf.config: if intf.config and '1' in intf.config:
bss_idx = 0 bss_idx = 0
elif intf.config and '2' in intf.config: elif intf.config and '2' in intf.config:
@ -207,7 +204,7 @@ class Test(unittest.TestCase):
for path in hwsim.radios: for path in hwsim.radios:
radio = hwsim.radios[path] radio = hwsim.radios[path]
if radio.name == wname: if radio.name == intf.wiphy.name:
break break
cls.bss_hostapd[bss_idx] = HostapdCLI(intf) cls.bss_hostapd[bss_idx] = HostapdCLI(intf)

View File

@ -9,8 +9,7 @@ from iwd import IWD
from iwd import PSKAgent from iwd import PSKAgent
from iwd import NetworkType from iwd import NetworkType
from hwsim import Hwsim from hwsim import Hwsim
from hostapd import HostapdCLI from hostapd import HostapdCLI, hostapd_map
from wiphy import wiphy_map
import testutil import testutil
class Test(unittest.TestCase): class Test(unittest.TestCase):
@ -204,9 +203,7 @@ class Test(unittest.TestCase):
cls.bss_hostapd = [None, None] cls.bss_hostapd = [None, None]
cls.bss_radio = [None, None] cls.bss_radio = [None, None]
for wname in wiphy_map: for intf in hostapd_map.values():
wiphy = wiphy_map[wname]
intf = list(wiphy.values())[0]
if intf.config and '1' in intf.config: if intf.config and '1' in intf.config:
bss_idx = 0 bss_idx = 0
elif intf.config and '2' in intf.config: elif intf.config and '2' in intf.config:
@ -216,7 +213,7 @@ class Test(unittest.TestCase):
for path in hwsim.radios: for path in hwsim.radios:
radio = hwsim.radios[path] radio = hwsim.radios[path]
if radio.name == wname: if radio.name == intf.wiphy.name:
break break
cls.bss_hostapd[bss_idx] = HostapdCLI(intf) cls.bss_hostapd[bss_idx] = HostapdCLI(intf)

View File

@ -9,8 +9,7 @@ from iwd import IWD
from iwd import PSKAgent from iwd import PSKAgent
from iwd import NetworkType from iwd import NetworkType
from hwsim import Hwsim from hwsim import Hwsim
from hostapd import HostapdCLI from hostapd import HostapdCLI, hostapd_map
from wiphy import wiphy_map
import testutil import testutil
class Test(unittest.TestCase): class Test(unittest.TestCase):
@ -154,9 +153,7 @@ class Test(unittest.TestCase):
cls.bss_hostapd = [None, None, None] cls.bss_hostapd = [None, None, None]
cls.bss_radio = [None, None, None] cls.bss_radio = [None, None, None]
for wname in wiphy_map: for intf in hostapd_map.values():
wiphy = wiphy_map[wname]
intf = list(wiphy.values())[0]
if intf.config and '1' in intf.config: if intf.config and '1' in intf.config:
bss_idx = 0 bss_idx = 0
elif intf.config and '2' in intf.config: elif intf.config and '2' in intf.config:
@ -168,7 +165,7 @@ class Test(unittest.TestCase):
for path in hwsim.radios: for path in hwsim.radios:
radio = hwsim.radios[path] radio = hwsim.radios[path]
if radio.name == wname: if radio.name == intf.wiphy.name:
break break
cls.bss_hostapd[bss_idx] = HostapdCLI(intf) cls.bss_hostapd[bss_idx] = HostapdCLI(intf)

View File

@ -9,8 +9,7 @@ from iwd import IWD
from iwd import PSKAgent from iwd import PSKAgent
from iwd import NetworkType from iwd import NetworkType
from hwsim import Hwsim from hwsim import Hwsim
from hostapd import HostapdCLI from hostapd import HostapdCLI, hostapd_map
from wiphy import wiphy_map
import testutil import testutil
from time import sleep from time import sleep
@ -57,31 +56,21 @@ class Test(unittest.TestCase):
ht_radio = None ht_radio = None
vht_radio = None vht_radio = None
for wname in wiphy_map: for intf in hostapd_map.values():
wiphy = wiphy_map[wname] for path in hwsim.radios:
intf = list(wiphy.values())[0] radio = hwsim.radios[path]
if intf.config and intf.config == 'non-ht-vht.conf': if radio.name == intf.wiphy.name:
break
if intf.config == 'non-ht-vht.conf':
non_ht_hostapd = HostapdCLI(intf) non_ht_hostapd = HostapdCLI(intf)
non_ht_radio = radio
for path in hwsim.radios: elif intf.config == 'ht.conf':
radio = hwsim.radios[path]
if radio.name == wname:
non_ht_radio = radio
elif intf.config and intf.config == 'ht.conf':
ht_hostapd = HostapdCLI(intf) ht_hostapd = HostapdCLI(intf)
ht_radio = radio
for path in hwsim.radios: elif intf.config == 'vht.conf':
radio = hwsim.radios[path]
if radio.name == wname:
ht_radio = radio
elif intf.config and intf.config == 'vht.conf':
vht_hostapd = HostapdCLI(intf) vht_hostapd = HostapdCLI(intf)
vht_radio = radio
for path in hwsim.radios:
radio = hwsim.radios[path]
if radio.name == wname:
vht_radio = radio
else: else:
continue continue

View File

@ -9,7 +9,7 @@ from iwd import IWD
from iwd import NetworkType from iwd import NetworkType
import testutil import testutil
from wiphy import wiphy_map import hostapd
from hwsim import Hwsim from hwsim import Hwsim
class Test(unittest.TestCase): class Test(unittest.TestCase):
@ -19,16 +19,11 @@ class Test(unittest.TestCase):
bss_radio = None bss_radio = None
for wname in wiphy_map: intf = list(hostapd.hostapd_map.values())[0]
wiphy = wiphy_map[wname] for path in hwsim.radios:
intf = list(wiphy.values())[0] radio = hwsim.radios[path]
if intf.config == 'ssidOWE.conf': if radio.name == intf.wiphy.name:
for path in hwsim.radios: bss_radio = radio
radio = hwsim.radios[path]
if radio.name == wname:
bss_radio = radio
else:
continue
self.assertIsNotNone(bss_radio) self.assertIsNotNone(bss_radio)

View File

@ -9,8 +9,7 @@ from iwd import IWD
from iwd import PSKAgent from iwd import PSKAgent
from iwd import NetworkType from iwd import NetworkType
from hwsim import Hwsim from hwsim import Hwsim
from hostapd import HostapdCLI from hostapd import HostapdCLI, hostapd_map
from wiphy import wiphy_map
import testutil import testutil
class Test(unittest.TestCase): class Test(unittest.TestCase):
@ -19,9 +18,7 @@ class Test(unittest.TestCase):
bss_hostapd = [None, None] bss_hostapd = [None, None]
bss_radio = [None, None] bss_radio = [None, None]
for wname in wiphy_map: for intf in hostapd_map.values():
wiphy = wiphy_map[wname]
intf = list(wiphy.values())[0]
if intf.config and '1' in intf.config: if intf.config and '1' in intf.config:
bss_idx = 0 bss_idx = 0
elif intf.config and '2' in intf.config: elif intf.config and '2' in intf.config:
@ -31,7 +28,7 @@ class Test(unittest.TestCase):
for path in hwsim.radios: for path in hwsim.radios:
radio = hwsim.radios[path] radio = hwsim.radios[path]
if radio.name == wname: if radio.name == intf.wiphy.name:
break break
bss_hostapd[bss_idx] = HostapdCLI(intf) bss_hostapd[bss_idx] = HostapdCLI(intf)

View File

@ -16,7 +16,7 @@ class Test(unittest.TestCase):
def validate_connection(self, wd): def validate_connection(self, wd):
hostapd_if = None hostapd_if = None
for hostapd in list(hostapd_map.values()): for hostapd in hostapd_map.values():
if hostapd.config == 'ssidSAE.conf': if hostapd.config == 'ssidSAE.conf':
hostapd_if = hostapd.name hostapd_if = hostapd.name

View File

@ -16,7 +16,7 @@ class Test(unittest.TestCase):
def validate_connection(self, wd): def validate_connection(self, wd):
hostapd_if = None hostapd_if = None
for hostapd in list(hostapd_map.values()): for hostapd in hostapd_map.values():
if hostapd.config == 'ssidSAE-20.conf': if hostapd.config == 'ssidSAE-20.conf':
hostapd_if = hostapd.name hostapd_if = hostapd.name

View File

@ -9,8 +9,7 @@ from iwd import IWD
from iwd import PSKAgent from iwd import PSKAgent
from iwd import NetworkType from iwd import NetworkType
from hwsim import Hwsim from hwsim import Hwsim
from hostapd import HostapdCLI from hostapd import HostapdCLI, hostapd_map
from wiphy import wiphy_map
from time import sleep from time import sleep
@ -19,18 +18,12 @@ class Test(unittest.TestCase):
def test_connection_success(self): def test_connection_success(self):
hwsim = Hwsim() hwsim = Hwsim()
hostapd = None intf = list(hostapd_map.values())[0]
radio = None hostapd = HostapdCLI(intf)
for path in hwsim.radios:
for wname in wiphy_map: radio = hwsim.radios[path]
wiphy = wiphy_map[wname] if radio.name == intf.wiphy.name:
intf = list(wiphy.values())[0] break
if intf.use == 'hostapd':
hostapd = HostapdCLI(intf)
for path in hwsim.radios:
if hwsim.radios[path].name == wname:
radio = hwsim.radios[path]
break
wd = IWD() wd = IWD()

View File

@ -8,20 +8,12 @@ import iwd
from iwd import IWD from iwd import IWD
from iwd import PSKAgent from iwd import PSKAgent
from iwd import NetworkType from iwd import NetworkType
from hostapd import HostapdCLI from hostapd import HostapdCLI, hostapd_map
from wiphy import wiphy_map
class Test(unittest.TestCase): class Test(unittest.TestCase):
def test_connection_success(self): def test_connection_success(self):
hostapd = None hostapd = HostapdCLI(list(hostapd_map.values())[0])
for wname in wiphy_map:
wiphy = wiphy_map[wname]
intf = list(wiphy.values())[0]
if intf.use == 'hostapd':
hostapd = HostapdCLI(intf)
break
wd = IWD() wd = IWD()