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): def test_connection_success(self):
hwsim = Hwsim() hwsim = Hwsim()
bss_hostapd = [None, None, None] bss_hostapd = [ HostapdCLI(config='ssid1.conf'),
bss_radio = [None, None, None] HostapdCLI(config='ssid2.conf'),
HostapdCLI(config='ssid3.conf') ]
for intf in hostapd_map.values(): bss_radio = [ hwsim.get_radio('rad0'),
if intf.config and '1' in intf.config: hwsim.get_radio('rad1'),
bss_idx = 0 hwsim.get_radio('rad2') ]
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
wd = IWD() wd = IWD()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -18,12 +18,8 @@ class Test(unittest.TestCase):
def test_connection_success(self): def test_connection_success(self):
hwsim = Hwsim() hwsim = Hwsim()
intf = list(hostapd_map.values())[0] hostapd = HostapdCLI(config='ssidCCMP.conf')
hostapd = HostapdCLI(intf) radio = hwsim.get_radio('rad0')
for path in hwsim.radios:
radio = hwsim.radios[path]
if radio.name == intf.wiphy.name:
break
wd = IWD() wd = IWD()