auto-t: updated autotests to use hwsim.get_radio

This removes all the duplicated code where the interfaces are iterated
and the radio/hostapd instances are created. Instead the two new APIs
are used to get each instance, e.g.:

hapd = HostapdCLI(config='ssid.conf')
radio = hwsim.get_radio('radX')
This commit is contained in:
James Prestwood 2019-06-11 09:25:54 -07:00 committed by Denis Kenzior
parent 0c554500e1
commit 65eeab1313
15 changed files with 69 additions and 257 deletions

View File

@ -19,26 +19,12 @@ class Test(unittest.TestCase):
def test_connection_success(self):
hwsim = Hwsim()
bss_hostapd = [None, None, None]
bss_radio = [None, None, None]
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:
bss_idx = 1
elif intf.config and '3' in intf.config:
bss_idx = 2
else:
continue
for path in hwsim.radios:
radio = hwsim.radios[path]
if radio.name == intf.wiphy.name:
break
bss_hostapd[bss_idx] = HostapdCLI(intf)
bss_radio[bss_idx] = radio
bss_hostapd = [ HostapdCLI(config='ssid1.conf'),
HostapdCLI(config='ssid2.conf'),
HostapdCLI(config='ssid3.conf') ]
bss_radio = [ hwsim.get_radio('rad0'),
hwsim.get_radio('rad1'),
hwsim.get_radio('rad2') ]
wd = IWD()

View File

@ -21,26 +21,12 @@ class Test(unittest.TestCase):
def test_connection_success(self):
hwsim = Hwsim()
bss_radio = [None, None, None]
bss_hostapd = [None, None, None]
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:
bss_idx = 1
elif intf.config and '3' in intf.config:
bss_idx = 2
else:
continue
for path in hwsim.radios:
radio = hwsim.radios[path]
if radio.name == intf.wiphy.name:
break
bss_radio[bss_idx] = radio
bss_hostapd[bss_idx] = HostapdCLI(intf)
bss_hostapd = [ HostapdCLI(config='ssid1.conf'),
HostapdCLI(config='ssid2.conf'),
HostapdCLI(config='ssid3.conf') ]
bss_radio = [ hwsim.get_radio('rad0'),
hwsim.get_radio('rad1'),
hwsim.get_radio('rad2') ]
rule0 = hwsim.rules.create()
rule0.source = bss_radio[0].addresses[0]

View File

@ -21,26 +21,12 @@ class Test(unittest.TestCase):
def test_connection_success(self):
hwsim = Hwsim()
bss_radio = [None, None, None]
bss_hostapd = [None, None, None]
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:
bss_idx = 1
elif intf.config and '3' in intf.config:
bss_idx = 2
else:
continue
for path in hwsim.radios:
radio = hwsim.radios[path]
if radio.name == intf.wiphy.name:
break
bss_radio[bss_idx] = radio
bss_hostapd[bss_idx] = HostapdCLI(intf)
bss_hostapd = [ HostapdCLI(config='ssid1.conf'),
HostapdCLI(config='ssid2.conf'),
HostapdCLI(config='ssid3.conf') ]
bss_radio = [ hwsim.get_radio('rad0'),
hwsim.get_radio('rad1'),
hwsim.get_radio('rad2') ]
rule0 = hwsim.rules.create()
rule0.source = bss_radio[0].addresses[0]

View File

@ -21,26 +21,12 @@ class Test(unittest.TestCase):
def test_connection_success(self):
hwsim = Hwsim()
bss_radio = [None, None, None]
bss_hostapd = [None, None, None]
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:
bss_idx = 1
elif intf.config and '3' in intf.config:
bss_idx = 2
else:
continue
for path in hwsim.radios:
radio = hwsim.radios[path]
if radio.name == intf.wiphy.name:
break
bss_radio[bss_idx] = radio
bss_hostapd[bss_idx] = HostapdCLI(intf)
bss_hostapd = [ HostapdCLI(config='ssid1.conf'),
HostapdCLI(config='ssid2.conf'),
HostapdCLI(config='ssid3.conf') ]
bss_radio = [ hwsim.get_radio('rad0'),
hwsim.get_radio('rad1'),
hwsim.get_radio('rad2') ]
rule0 = hwsim.rules.create()
rule0.source = bss_radio[0].addresses[0]

View File

@ -21,26 +21,12 @@ class Test(unittest.TestCase):
def test_connection_success(self):
hwsim = Hwsim()
bss_radio = [None, None, None]
bss_hostapd = [None, None, None]
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:
bss_idx = 1
elif intf.config and '3' in intf.config:
bss_idx = 2
else:
continue
for path in hwsim.radios:
radio = hwsim.radios[path]
if radio.name == intf.wiphy.name:
break
bss_radio[bss_idx] = radio
bss_hostapd[bss_idx] = HostapdCLI(intf)
bss_hostapd = [ HostapdCLI(config='ssid1.conf'),
HostapdCLI(config='ssid2.conf'),
HostapdCLI(config='ssid3.conf') ]
bss_radio = [ hwsim.get_radio('rad0'),
hwsim.get_radio('rad1'),
hwsim.get_radio('rad2') ]
rule0 = hwsim.rules.create()
rule0.source = bss_radio[0].addresses[0]

View File

@ -192,23 +192,10 @@ class Test(unittest.TestCase):
hwsim = Hwsim()
cls.bss_hostapd = [None, None]
cls.bss_radio = [None, None]
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:
bss_idx = 1
else:
continue
for path in hwsim.radios:
radio = hwsim.radios[path]
if radio.name == intf.wiphy.name:
break
cls.bss_hostapd[bss_idx] = HostapdCLI(intf)
cls.bss_radio[bss_idx] = radio
cls.bss_hostapd = [ HostapdCLI(config='ft-eap-ccmp-1.conf'),
HostapdCLI(config='ft-eap-ccmp-2.conf') ]
cls.bss_radio = [ hwsim.get_radio('rad0'),
hwsim.get_radio('rad1') ]
# Set interface addresses to those expected by hostapd config files
os.system('ifconfig "' + cls.bss_hostapd[0].ifname +

View File

@ -147,23 +147,10 @@ class Test(unittest.TestCase):
hwsim = Hwsim()
cls.bss_hostapd = [None, None]
cls.bss_radio = [None, None]
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:
bss_idx = 1
else:
continue
for path in hwsim.radios:
radio = hwsim.radios[path]
if radio.name == intf.wiphy.name:
break
cls.bss_hostapd[bss_idx] = HostapdCLI(intf)
cls.bss_radio[bss_idx] = radio
cls.bss_hostapd = [ HostapdCLI(config='ft-eap-ccmp-1.conf'),
HostapdCLI(config='ft-eap-ccmp-2.conf') ]
cls.bss_radio = [ hwsim.get_radio('rad0'),
hwsim.get_radio('rad1') ]
# Set interface addresses to those expected by hostapd config files
os.system('ifconfig "' + cls.bss_hostapd[0].ifname +

View File

@ -147,23 +147,10 @@ class Test(unittest.TestCase):
hwsim = Hwsim()
cls.bss_hostapd = [None, None]
cls.bss_radio = [None, None]
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:
bss_idx = 1
else:
continue
for path in hwsim.radios:
radio = hwsim.radios[path]
if radio.name == intf.wiphy.name:
break
cls.bss_hostapd[bss_idx] = HostapdCLI(intf)
cls.bss_radio[bss_idx] = radio
cls.bss_hostapd = [ HostapdCLI(config='ft-eap-ccmp-1.conf'),
HostapdCLI(config='ft-eap-ccmp-2.conf') ]
cls.bss_radio = [ hwsim.get_radio('rad0'),
hwsim.get_radio('rad1') ]
# Set interface addresses to those expected by hostapd config files
os.system('ifconfig "' + cls.bss_hostapd[0].ifname +

View File

@ -120,23 +120,10 @@ class Test(unittest.TestCase):
def setUpClass(cls):
hwsim = Hwsim()
cls.bss_hostapd = [None, None]
cls.bss_radio = [None, None]
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:
bss_idx = 1
else:
continue
for path in hwsim.radios:
radio = hwsim.radios[path]
if radio.name == intf.wiphy.name:
break
cls.bss_hostapd[bss_idx] = HostapdCLI(intf)
cls.bss_radio[bss_idx] = radio
cls.bss_hostapd = [ HostapdCLI(config='ft-psk-ccmp-1.conf'),
HostapdCLI(config='ft-psk-ccmp-2.conf') ]
cls.bss_radio = [ hwsim.get_radio('rad0'),
hwsim.get_radio('rad1') ]
# Set interface addresses to those expected by hostapd config files
os.system('ifconfig "' + cls.bss_hostapd[0].ifname +

View File

@ -201,23 +201,10 @@ class Test(unittest.TestCase):
def setUpClass(cls):
hwsim = Hwsim()
cls.bss_hostapd = [None, None]
cls.bss_radio = [None, None]
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:
bss_idx = 1
else:
continue
for path in hwsim.radios:
radio = hwsim.radios[path]
if radio.name == intf.wiphy.name:
break
cls.bss_hostapd[bss_idx] = HostapdCLI(intf)
cls.bss_radio[bss_idx] = radio
cls.bss_hostapd = [ HostapdCLI(config='ft-psk-ccmp-1.conf'),
HostapdCLI(config='ft-psk-ccmp-2.conf') ]
cls.bss_radio = [ hwsim.get_radio('rad0'),
hwsim.get_radio('rad1') ]
# Set interface addresses to those expected by hostapd config files
os.system('ifconfig "' + cls.bss_hostapd[0].ifname +

View File

@ -151,25 +151,12 @@ class Test(unittest.TestCase):
def setUpClass(cls):
hwsim = Hwsim()
cls.bss_hostapd = [None, None, None]
cls.bss_radio = [None, None, None]
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:
bss_idx = 1
elif intf.config and '3' in intf.config:
bss_idx = 2
else:
continue
for path in hwsim.radios:
radio = hwsim.radios[path]
if radio.name == intf.wiphy.name:
break
cls.bss_hostapd[bss_idx] = HostapdCLI(intf)
cls.bss_radio[bss_idx] = radio
cls.bss_hostapd = [ HostapdCLI(config='ft-sae-1.conf'),
HostapdCLI(config='ft-sae-2.conf'),
HostapdCLI(config='ft-psk-3.conf') ]
cls.bss_radio = [ hwsim.get_radio('rad0'),
hwsim.get_radio('rad1'),
hwsim.get_radio('rad2') ]
# Set interface addresses to those expected by hostapd config files
os.system('ifconfig "' + cls.bss_hostapd[0].ifname +

View File

@ -50,29 +50,12 @@ class Test(unittest.TestCase):
def test_connection_success(self):
hwsim = Hwsim()
non_ht_hostapd = None
ht_hostapd = None
non_ht_radio = None
ht_radio = None
vht_radio = None
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)
non_ht_radio = radio
elif intf.config == 'ht.conf':
ht_hostapd = HostapdCLI(intf)
ht_radio = radio
elif intf.config == 'vht.conf':
vht_hostapd = HostapdCLI(intf)
vht_radio = radio
else:
continue
non_ht_hostapd = HostapdCLI(config='non-ht-vht.conf')
ht_hostapd = HostapdCLI(config='ht.conf')
vht_hostapd = HostapdCLI(config='vht.conf')
non_ht_radio = hwsim.get_radio('rad0')
ht_radio = hwsim.get_radio('rad1')
vht_radio = hwsim.get_radio('rad2')
self.assertIsNotNone(non_ht_hostapd)
self.assertIsNotNone(ht_hostapd)

View File

@ -17,13 +17,7 @@ class Test(unittest.TestCase):
def test_connection_success(self):
hwsim = Hwsim()
bss_radio = None
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
bss_radio = hwsim.get_radio('rad0')
self.assertIsNotNone(bss_radio)

View File

@ -16,23 +16,10 @@ class Test(unittest.TestCase):
def test_preauth_success(self):
hwsim = Hwsim()
bss_hostapd = [None, None]
bss_radio = [None, None]
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:
bss_idx = 1
else:
continue
for path in hwsim.radios:
radio = hwsim.radios[path]
if radio.name == intf.wiphy.name:
break
bss_hostapd[bss_idx] = HostapdCLI(intf)
bss_radio[bss_idx] = radio
bss_hostapd = [ HostapdCLI(config='eaptls-preauth-1.conf'),
HostapdCLI(config='eaptls-preauth-2.conf') ]
bss_radio = [ hwsim.get_radio('rad0'),
hwsim.get_radio('rad1') ]
rule0 = hwsim.rules.create()
rule0.source = bss_radio[0].addresses[0]

View File

@ -18,12 +18,8 @@ class Test(unittest.TestCase):
def test_connection_success(self):
hwsim = Hwsim()
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
hostapd = HostapdCLI(config='ssidCCMP.conf')
radio = hwsim.get_radio('rad0')
wd = IWD()