3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-25 09:39:25 +01:00

auto-t: update tests to use set_address/group_neighbors

This reduces the big blocks of copied code with a few function calls.
This commit is contained in:
James Prestwood 2022-08-22 10:01:48 -07:00 committed by Denis Kenzior
parent 3439d09817
commit 4545f80e58
8 changed files with 19 additions and 144 deletions

View File

@ -66,28 +66,10 @@ class Test(unittest.TestCase):
cls.bss_hostapd = [ HostapdCLI(config='ft-eap-ccmp-1.conf'),
HostapdCLI(config='ft-eap-ccmp-2.conf') ]
# Set interface addresses to those expected by hostapd config files
os.system('ip link set dev "' + cls.bss_hostapd[0].ifname + '" down')
os.system('ip link set dev "' + cls.bss_hostapd[0].ifname + \
'" address 12:00:00:00:00:01 up')
os.system('ip link set dev "' + cls.bss_hostapd[1].ifname + '" down')
os.system('ip link set dev "' + cls.bss_hostapd[1].ifname + \
'" address 12:00:00:00:00:02 up')
cls.bss_hostapd[0].set_address('12:00:00:00:00:01')
cls.bss_hostapd[1].set_address('12:00:00:00:00:02')
cls.bss_hostapd[0].reload()
cls.bss_hostapd[0].wait_for_event("AP-ENABLED")
cls.bss_hostapd[1].reload()
cls.bss_hostapd[1].wait_for_event("AP-ENABLED")
# Fill in the neighbor AP tables in both BSSes. By default each
# instance knows only about current BSS, even inside one hostapd
# process.
# FT still works without the neighbor AP table but neighbor reports
# have to be disabled in the .conf files
cls.bss_hostapd[0].set_neighbor('12:00:00:00:00:02', 'TestFT',
'1200000000028f0000005102060603000000')
cls.bss_hostapd[1].set_neighbor('12:00:00:00:00:01', 'TestFT',
'1200000000018f0000005101060603000000')
HostapdCLI.group_neighbors(*cls.bss_hostapd)
@classmethod
def tearDownClass(cls):

View File

@ -128,26 +128,10 @@ class Test(unittest.TestCase):
cls.bss_hostapd = [ HostapdCLI(config='ft-eap-ccmp-1.conf'),
HostapdCLI(config='ft-eap-ccmp-2.conf') ]
# Set interface addresses to those expected by hostapd config files
os.system('ip link set dev "' + cls.bss_hostapd[0].ifname + '" down')
os.system('ip link set dev "' + cls.bss_hostapd[0].ifname + '" addr 12:00:00:00:00:01 up')
os.system('ip link set dev "' + cls.bss_hostapd[1].ifname + '" down')
os.system('ip link set dev "' + cls.bss_hostapd[1].ifname + '" addr 12:00:00:00:00:02 up')
cls.bss_hostapd[0].set_address('12:00:00:00:00:01')
cls.bss_hostapd[1].set_address('12:00:00:00:00:02')
cls.bss_hostapd[0].reload()
cls.bss_hostapd[0].wait_for_event("AP-ENABLED")
cls.bss_hostapd[1].reload()
cls.bss_hostapd[1].wait_for_event("AP-ENABLED")
# Fill in the neighbor AP tables in both BSSes. By default each
# instance knows only about current BSS, even inside one hostapd
# process.
# FT still works without the neighbor AP table but neighbor reports
# have to be disabled in the .conf files
cls.bss_hostapd[0].set_neighbor('12:00:00:00:00:02', 'TestFT',
'1200000000028f0000005102060603000000')
cls.bss_hostapd[1].set_neighbor('12:00:00:00:00:01', 'TestFT',
'1200000000018f0000005101060603000000')
HostapdCLI.group_neighbors(*cls.bss_hostapd)
@classmethod
def tearDownClass(cls):

View File

@ -199,26 +199,10 @@ class Test(unittest.TestCase):
cls.rule2.source = rad0.addresses[0]
cls.rule2.signal = -7000
# Set interface addresses to those expected by hostapd config files
os.system('ip link set dev "' + cls.bss_hostapd[0].ifname + '" down')
os.system('ip link set dev "' + cls.bss_hostapd[0].ifname + '" addr 12:00:00:00:00:01 up')
os.system('ip link set dev "' + cls.bss_hostapd[1].ifname + '" down')
os.system('ip link set dev "' + cls.bss_hostapd[1].ifname + '" addr 12:00:00:00:00:02 up')
cls.bss_hostapd[0].set_address('12:00:00:00:00:01')
cls.bss_hostapd[1].set_address('12:00:00:00:00:02')
cls.bss_hostapd[0].reload()
cls.bss_hostapd[0].wait_for_event("AP-ENABLED")
cls.bss_hostapd[1].reload()
cls.bss_hostapd[1].wait_for_event("AP-ENABLED")
# Fill in the neighbor AP tables in both BSSes. By default each
# instance knows only about current BSS, even inside one hostapd
# process.
# FT still works without the neighbor AP table but neighbor reports
# have to be disabled in the .conf files
cls.bss_hostapd[0].set_neighbor('12:00:00:00:00:02', 'TestFT',
'1200000000028f0000005102060603000000')
cls.bss_hostapd[1].set_neighbor('12:00:00:00:00:01', 'TestFT',
'1200000000018f0000005101060603000000')
HostapdCLI.group_neighbors(*cls.bss_hostapd)
@classmethod
def tearDownClass(cls):

View File

@ -46,10 +46,7 @@ class Test(unittest.TestCase):
self.validate()
def test_ap_disconnect_neighbors(self):
self.bss_hostapd[0].set_neighbor('12:00:00:00:00:02', 'TestFT',
'1200000000028f0000005102060603000000')
self.bss_hostapd[1].set_neighbor('12:00:00:00:00:01', 'TestFT',
'1200000000018f0000005101060603000000')
HostapdCLI.group_neighbors(*self.bss_hostapd)
self.validate()
@ -85,11 +82,8 @@ class Test(unittest.TestCase):
cls.rule0.signal = -8000
cls.rule0.enabled = True
# Set interface addresses to those expected by hostapd config files
os.system('ip link set dev "' + cls.bss_hostapd[0].ifname + '" down')
os.system('ip link set dev "' + cls.bss_hostapd[0].ifname + '" addr 12:00:00:00:00:01 up')
os.system('ip link set dev "' + cls.bss_hostapd[1].ifname + '" down')
os.system('ip link set dev "' + cls.bss_hostapd[1].ifname + '" addr 12:00:00:00:00:02 up')
cls.bss_hostapd[0].set_address('12:00:00:00:00:01')
cls.bss_hostapd[1].set_address('12:00:00:00:00:02')
@classmethod
def tearDownClass(cls):

View File

@ -17,18 +17,7 @@ class Test(unittest.TestCase):
bss0_addr = bss_hostapd[0].bssid
bss1_addr = bss_hostapd[1].bssid
# Fill in the neighbor AP tables in both BSSes. By default each
# instance knows only about current BSS, even inside one hostapd
# process.
# Roaming still works without the neighbor AP table but neighbor
# reports have to be disabled in the .conf files
bss0_nr = ''.join(bss0_addr.split(':')) + \
'8f0000005101060603000000'
bss1_nr = ''.join(bss1_addr.split(':')) + \
'8f0000005102060603000000'
bss_hostapd[0].set_neighbor(bss1_addr, 'TestPreauth', bss1_nr)
bss_hostapd[1].set_neighbor(bss0_addr, 'TestPreauth', bss0_nr)
HostapdCLI.group_neighbors(*bss_hostapd)
wd = IWD(True)

View File

@ -36,20 +36,7 @@ class Test(unittest.TestCase):
rule1.bidirectional = True
rule1.enabled = True
# Fill in the neighbor AP tables in both BSSes. By default each
# instance knows only about current BSS, even inside one hostapd
# process.
# Roaming still works without the neighbor AP table but neighbor
# reports have to be disabled in the .conf files
bss0_nr = ''.join(bss_radio[0].addresses[0].split(':')) + \
'8f0000005101060603000000'
bss1_nr = ''.join(bss_radio[1].addresses[0].split(':')) + \
'8f0000005102060603000000'
bss_hostapd[0].set_neighbor(bss_radio[1].addresses[0], 'TestRoamRetry',
bss1_nr)
bss_hostapd[1].set_neighbor(bss_radio[0].addresses[0], 'TestRoamRetry',
bss0_nr)
HostapdCLI.group_neighbors(*bss_hostapd)
# Start in the vicinity of BSS 0, check that iwd connects to BSS 0
rule0.signal = -2000

View File

@ -35,20 +35,7 @@ class Test(unittest.TestCase):
rule1.bidirectional = True
rule1.enabled = True
# Fill in the neighbor AP tables in both BSSes. By default each
# instance knows only about current BSS, even inside one hostapd
# process.
# Roaming still works without the neighbor AP table but neighbor
# reports have to be disabled in the .conf files
bss0_nr = ''.join(bss_radio[0].addresses[0].split(':')) + \
'8f0000005101060603000000'
bss1_nr = ''.join(bss_radio[1].addresses[0].split(':')) + \
'8f0000005102060603000000'
bss_hostapd[0].set_neighbor(bss_radio[1].addresses[0], 'TestRoamRetry',
bss1_nr)
bss_hostapd[1].set_neighbor(bss_radio[0].addresses[0], 'TestRoamRetry',
bss0_nr)
HostapdCLI.group_neighbors(*bss_hostapd)
# Start in the vicinity of BSS 0, check that iwd connects to BSS 0
rule0.signal = -2000

View File

@ -120,43 +120,11 @@ class Test(unittest.TestCase):
HostapdCLI(config='ft-sae-2.conf'),
HostapdCLI(config='ft-psk-3.conf') ]
ctx.start_process(['ip', 'link', 'set', 'dev', cls.bss_hostapd[0].ifname, 'down']).wait()
ctx.start_process(['ip', 'link', 'set', 'dev', cls.bss_hostapd[0].ifname, \
'addr', '12:00:00:00:00:01', 'up']).wait()
ctx.start_process(['ip', 'link', 'set', 'dev', cls.bss_hostapd[1].ifname, 'down']).wait()
ctx.start_process(['ip', 'link', 'set', 'dev', cls.bss_hostapd[1].ifname, \
'addr', '12:00:00:00:00:02', 'up']).wait()
ctx.start_process(['ip', 'link', 'set', 'dev', cls.bss_hostapd[2].ifname, 'down']).wait()
ctx.start_process(['ip', 'link', 'set', 'dev', cls.bss_hostapd[2].ifname, \
'addr', '12:00:00:00:00:03', 'up']).wait()
cls.bss_hostapd[0].set_address('12:00:00:00:00:01')
cls.bss_hostapd[1].set_address('12:00:00:00:00:02')
cls.bss_hostapd[2].set_address('12:00:00:00:00:03')
# Set interface addresses to those expected by hostapd config files
cls.bss_hostapd[0].reload()
cls.bss_hostapd[0].wait_for_event("AP-ENABLED")
cls.bss_hostapd[1].reload()
cls.bss_hostapd[1].wait_for_event("AP-ENABLED")
cls.bss_hostapd[2].reload()
cls.bss_hostapd[2].wait_for_event("AP-ENABLED")
# Fill in the neighbor AP tables in both BSSes. By default each
# instance knows only about current BSS, even inside one hostapd
# process.
# FT still works without the neighbor AP table but neighbor reports
# have to be disabled in the .conf files
cls.bss_hostapd[0].set_neighbor('12:00:00:00:00:02', 'TestFT',
'1200000000028f0000005102060603000000')
cls.bss_hostapd[0].set_neighbor('12:00:00:00:00:03', 'TestFT',
'1200000000038f0000005102060603000000')
cls.bss_hostapd[1].set_neighbor('12:00:00:00:00:01', 'TestFT',
'1200000000018f0000005101060603000000')
cls.bss_hostapd[1].set_neighbor('12:00:00:00:00:03', 'TestFT',
'1200000000038f0000005101060603000000')
cls.bss_hostapd[2].set_neighbor('12:00:00:00:00:01', 'TestFT',
'1200000000018f0000005101060603000000')
cls.bss_hostapd[2].set_neighbor('12:00:00:00:00:02', 'TestFT',
'1200000000028f0000005101060603000000')
HostapdCLI.group_neighbors(*cls.bss_hostapd)
IWD.copy_to_storage('TestFT.psk')