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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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