mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-25 17:59:25 +01:00
auto-t: fix error handling in testHotspot
testHotspot suffered from improper cleanup and if a single test failed all subsequent tests would fail due to IWD still running since IWD() was never cleaned up. In addition the PSK agent and hwsim rules are now set onto the cls object and removed in tearDownClass()
This commit is contained in:
parent
8e5a68f407
commit
07fc7905ca
@ -17,19 +17,9 @@ from time import sleep
|
|||||||
class Test(unittest.TestCase):
|
class Test(unittest.TestCase):
|
||||||
|
|
||||||
def test_connection_success(self):
|
def test_connection_success(self):
|
||||||
hwsim = Hwsim()
|
wd = self.wd
|
||||||
|
hapd = self.hapd
|
||||||
bss_radio = hwsim.get_radio('rad0')
|
rule0 = self.rule0
|
||||||
rule0 = hwsim.rules.create()
|
|
||||||
rule0.source = bss_radio.addresses[0]
|
|
||||||
rule0.bidirectional = True
|
|
||||||
|
|
||||||
wd = IWD(True)
|
|
||||||
|
|
||||||
hapd = HostapdCLI(config='ssidHotspot.conf')
|
|
||||||
|
|
||||||
psk_agent = PSKAgent('abc', ('domain\\user', 'testpasswd'))
|
|
||||||
wd.register_psk_agent(psk_agent)
|
|
||||||
|
|
||||||
devices = wd.list_devices(1)
|
devices = wd.list_devices(1)
|
||||||
device = devices[0]
|
device = devices[0]
|
||||||
@ -82,17 +72,35 @@ class Test(unittest.TestCase):
|
|||||||
condition = 'not obj.connected'
|
condition = 'not obj.connected'
|
||||||
wd.wait_for_object_condition(ordered_network.network_object, condition)
|
wd.wait_for_object_condition(ordered_network.network_object, condition)
|
||||||
|
|
||||||
wd.unregister_psk_agent(psk_agent)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
|
cls.hwsim = Hwsim()
|
||||||
|
|
||||||
|
bss_radio = cls.hwsim.get_radio('rad0')
|
||||||
|
cls.rule0 = cls.hwsim.rules.create()
|
||||||
|
cls.rule0.source = bss_radio.addresses[0]
|
||||||
|
cls.rule0.bidirectional = True
|
||||||
|
|
||||||
|
cls.hapd = HostapdCLI(config='ssidHotspot.conf')
|
||||||
|
|
||||||
IWD.copy_to_hotspot('example.conf')
|
IWD.copy_to_hotspot('example.conf')
|
||||||
IWD.copy_to_storage('anqp_enabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf')
|
IWD.copy_to_storage('anqp_enabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf')
|
||||||
|
|
||||||
|
cls.wd = IWD(True)
|
||||||
|
cls.psk_agent = PSKAgent('abc', ('domain\\user', 'testpasswd'))
|
||||||
|
cls.wd.register_psk_agent(cls.psk_agent)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
IWD.clear_storage()
|
IWD.clear_storage()
|
||||||
|
|
||||||
|
cls.wd.unregister_psk_agent(cls.psk_agent)
|
||||||
|
cls.psk_agent = None
|
||||||
os.remove('/tmp/main.conf')
|
os.remove('/tmp/main.conf')
|
||||||
|
|
||||||
|
cls.hwsim.rules.remove_all()
|
||||||
|
cls.hwsim = None
|
||||||
|
cls.wd = None
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main(exit=True)
|
unittest.main(exit=True)
|
||||||
|
@ -14,7 +14,7 @@ import testutil
|
|||||||
class Test(unittest.TestCase):
|
class Test(unittest.TestCase):
|
||||||
|
|
||||||
def test_connection_success(self):
|
def test_connection_success(self):
|
||||||
wd = IWD(True, '/tmp')
|
wd = self.wd
|
||||||
|
|
||||||
hapd_hotspot = HostapdCLI(config='ssidHotspot.conf')
|
hapd_hotspot = HostapdCLI(config='ssidHotspot.conf')
|
||||||
hapd_wpa = HostapdCLI(config='ssidWPA2-1.conf')
|
hapd_wpa = HostapdCLI(config='ssidWPA2-1.conf')
|
||||||
@ -111,10 +111,14 @@ class Test(unittest.TestCase):
|
|||||||
IWD.copy_to_storage('ssidWPA2-1.psk')
|
IWD.copy_to_storage('ssidWPA2-1.psk')
|
||||||
IWD.copy_to_storage('anqp_enabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf')
|
IWD.copy_to_storage('anqp_enabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf')
|
||||||
|
|
||||||
|
cls.wd = IWD(True)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
IWD.clear_storage()
|
IWD.clear_storage()
|
||||||
os.remove('/tmp/main.conf')
|
os.remove('/tmp/main.conf')
|
||||||
|
|
||||||
|
cls.wd = None
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main(exit=True)
|
unittest.main(exit=True)
|
||||||
|
@ -15,7 +15,7 @@ import testutil
|
|||||||
class Test(unittest.TestCase):
|
class Test(unittest.TestCase):
|
||||||
|
|
||||||
def test_connection_success(self):
|
def test_connection_success(self):
|
||||||
wd = IWD(True, '/tmp')
|
wd = self.wd
|
||||||
|
|
||||||
hapd = HostapdCLI(config='ssidHotspot.conf')
|
hapd = HostapdCLI(config='ssidHotspot.conf')
|
||||||
|
|
||||||
@ -52,10 +52,14 @@ class Test(unittest.TestCase):
|
|||||||
IWD.copy_to_hotspot('hessid.conf')
|
IWD.copy_to_hotspot('hessid.conf')
|
||||||
IWD.copy_to_storage('anqp_disabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf')
|
IWD.copy_to_storage('anqp_disabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf')
|
||||||
|
|
||||||
|
cls.wd = IWD(True)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
IWD.clear_storage()
|
IWD.clear_storage()
|
||||||
os.remove('/tmp/main.conf')
|
os.remove('/tmp/main.conf')
|
||||||
|
|
||||||
|
cls.wd = None
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main(exit=True)
|
unittest.main(exit=True)
|
||||||
|
@ -15,7 +15,7 @@ import testutil
|
|||||||
class Test(unittest.TestCase):
|
class Test(unittest.TestCase):
|
||||||
|
|
||||||
def test_connection_success(self):
|
def test_connection_success(self):
|
||||||
wd = IWD(True, '/tmp')
|
wd = self.wd
|
||||||
|
|
||||||
hapd = HostapdCLI(config='ssidHotspot.conf')
|
hapd = HostapdCLI(config='ssidHotspot.conf')
|
||||||
|
|
||||||
@ -52,10 +52,14 @@ class Test(unittest.TestCase):
|
|||||||
IWD.copy_to_hotspot('example.conf')
|
IWD.copy_to_hotspot('example.conf')
|
||||||
IWD.copy_to_storage('anqp_enabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf')
|
IWD.copy_to_storage('anqp_enabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf')
|
||||||
|
|
||||||
|
cls.wd = IWD(True)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
IWD.clear_storage()
|
IWD.clear_storage()
|
||||||
os.remove('/tmp/main.conf')
|
os.remove('/tmp/main.conf')
|
||||||
|
|
||||||
|
cls.wd = None
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main(exit=True)
|
unittest.main(exit=True)
|
||||||
|
@ -15,13 +15,10 @@ import testutil
|
|||||||
class Test(unittest.TestCase):
|
class Test(unittest.TestCase):
|
||||||
|
|
||||||
def test_connection_success(self):
|
def test_connection_success(self):
|
||||||
wd = IWD(True, '/tmp')
|
wd = self.wd
|
||||||
|
|
||||||
hapd = HostapdCLI(config='ssidHotspot.conf')
|
hapd = HostapdCLI(config='ssidHotspot.conf')
|
||||||
|
|
||||||
psk_agent = PSKAgent('abc', ('domain\\user', 'testpasswd'))
|
|
||||||
wd.register_psk_agent(psk_agent)
|
|
||||||
|
|
||||||
devices = wd.list_devices(1)
|
devices = wd.list_devices(1)
|
||||||
device = devices[0]
|
device = devices[0]
|
||||||
|
|
||||||
@ -45,17 +42,22 @@ class Test(unittest.TestCase):
|
|||||||
condition = 'not obj.connected'
|
condition = 'not obj.connected'
|
||||||
wd.wait_for_object_condition(ordered_network.network_object, condition)
|
wd.wait_for_object_condition(ordered_network.network_object, condition)
|
||||||
|
|
||||||
wd.unregister_psk_agent(psk_agent)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
IWD.copy_to_hotspot('roaming.conf')
|
IWD.copy_to_hotspot('roaming.conf')
|
||||||
IWD.copy_to_storage('anqp_disabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf')
|
IWD.copy_to_storage('anqp_disabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf')
|
||||||
|
|
||||||
|
cls.wd = IWD(True)
|
||||||
|
cls.psk_agent = PSKAgent('abc', ('domain\\user', 'testpasswd'))
|
||||||
|
cls.wd.register_psk_agent(cls.psk_agent)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
IWD.clear_storage()
|
IWD.clear_storage()
|
||||||
os.remove('/tmp/main.conf')
|
os.remove('/tmp/main.conf')
|
||||||
|
|
||||||
|
cls.wd.unregister_psk_agent(cls.psk_agent)
|
||||||
|
cls.wd = None
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main(exit=True)
|
unittest.main(exit=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user