mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-25 09:39:25 +01:00
autotests: Remove del wd at the end function pattern
Don't use del wd to dereference the IWD instance at the end of the function where it has been defined in the first place as at this point wd is about to have its reference count decreased anyway (the variable's scope is ending) so it's pointless (but didn't hurt). Relying on the __del__ destructor to kill the IWD process in those tests it has been started in the constructor is a bit of a hack in the first place, because the destructor is called on garbage collection and even through CPython does this on the refcount reaching 0, this is not documented and there's no guideline on when it should happen or if it should happen at all. So it could be argued that we should keep the del wd statemenets to be able to easily replace all of them with a call to a new method. But most of them are not placed so that they're guaranteed to happen on test success or failure. It would probably be easier to do this and other housekeeping in a base class and make the tests its subclasses. Also some of these tests don't really need to launch iwd themselves, since IWD now tracks changes in the known network files I think IWD only really needs to be killed between tests when main.conf changes.
This commit is contained in:
parent
f456ac49dc
commit
c73575585b
@ -31,10 +31,7 @@ class Test(unittest.TestCase):
|
||||
def test_connection_success(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
finally:
|
||||
del wd
|
||||
self.validate_connection(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -33,10 +33,7 @@ class Test(unittest.TestCase):
|
||||
def test_connection_failure(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
finally:
|
||||
del wd
|
||||
self.validate_connection(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -32,10 +32,7 @@ class Test(unittest.TestCase):
|
||||
def test_connection_success(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
finally:
|
||||
del wd
|
||||
self.validate_connection(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -101,8 +101,6 @@ class Test(unittest.TestCase):
|
||||
|
||||
wd.unregister_psk_agent(psk_agent)
|
||||
|
||||
del wd
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
pass
|
||||
|
@ -98,8 +98,6 @@ class Test(unittest.TestCase):
|
||||
condition = 'obj.connected'
|
||||
wd.wait_for_object_condition(ordered_network.network_object, condition)
|
||||
|
||||
del wd
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
pass
|
||||
|
@ -153,8 +153,6 @@ class Test(unittest.TestCase):
|
||||
|
||||
wd.unregister_psk_agent(psk_agent)
|
||||
|
||||
del wd
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
IWD.copy_to_storage('main.conf')
|
||||
|
@ -133,8 +133,6 @@ class Test(unittest.TestCase):
|
||||
|
||||
wd.unregister_psk_agent(psk_agent)
|
||||
|
||||
del wd
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
IWD.copy_to_storage('main.conf')
|
||||
|
@ -71,10 +71,4 @@ class TestConnectAutoconnect(unittest.TestCase):
|
||||
def validate(self, ssid, autoconnect, throws = None, use_agent = False):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.validate_connection(wd, ssid, autoconnect, throws, use_agent)
|
||||
except:
|
||||
del wd
|
||||
raise
|
||||
|
||||
del wd
|
||||
self.validate_connection(wd, ssid, autoconnect, throws, use_agent)
|
||||
|
@ -52,13 +52,8 @@ class Test(unittest.TestCase):
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
except:
|
||||
del wd
|
||||
raise
|
||||
|
||||
wd.unregister_psk_agent(psk_agent)
|
||||
|
||||
del wd
|
||||
finally:
|
||||
wd.unregister_psk_agent(psk_agent)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -45,13 +45,7 @@ class Test(unittest.TestCase):
|
||||
def test_connection_success(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
except:
|
||||
del wd
|
||||
raise
|
||||
|
||||
del wd
|
||||
self.validate_connection(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -46,14 +46,7 @@ class Test(unittest.TestCase):
|
||||
def test_connection_success(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
except:
|
||||
del wd
|
||||
raise
|
||||
|
||||
del wd
|
||||
|
||||
self.validate_connection(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -48,13 +48,8 @@ class Test(unittest.TestCase):
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
except:
|
||||
del wd
|
||||
finally:
|
||||
auth.stop()
|
||||
raise
|
||||
|
||||
del wd
|
||||
auth.stop()
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -44,13 +44,7 @@ class Test(unittest.TestCase):
|
||||
def test_connection_success(self):
|
||||
wd = IWD(True, '/tmp/IWD-Frag')
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
except:
|
||||
del wd
|
||||
raise
|
||||
|
||||
del wd
|
||||
self.validate_connection(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -44,13 +44,7 @@ class Test(unittest.TestCase):
|
||||
def test_connection_success(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
except:
|
||||
del wd
|
||||
raise
|
||||
|
||||
del wd
|
||||
self.validate_connection(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -44,13 +44,7 @@ class Test(unittest.TestCase):
|
||||
def test_connection_success(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
except:
|
||||
del wd
|
||||
raise
|
||||
|
||||
del wd
|
||||
self.validate_connection(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -71,13 +71,7 @@ class Test(unittest.TestCase):
|
||||
def test_connection_success(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
except:
|
||||
del wd
|
||||
raise
|
||||
|
||||
del wd
|
||||
self.validate_connection(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -43,13 +43,7 @@ class Test(unittest.TestCase):
|
||||
def test_connection_success(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
except:
|
||||
del wd
|
||||
raise
|
||||
|
||||
del wd
|
||||
self.validate_connection(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -73,10 +73,7 @@ class Test(unittest.TestCase):
|
||||
def test_connection_success(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
finally:
|
||||
del wd
|
||||
self.validate_connection(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -31,13 +31,9 @@ class Test(unittest.TestCase):
|
||||
wd.wait_for_object_condition(device, condition)
|
||||
|
||||
def test_connection_success(self):
|
||||
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.four_digit_pin_success(wd)
|
||||
finally:
|
||||
del wd
|
||||
self.four_digit_pin_success(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -32,10 +32,7 @@ class Test(unittest.TestCase):
|
||||
def test_connection_success(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.push_button_success(wd)
|
||||
finally:
|
||||
del wd
|
||||
self.push_button_success(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -73,11 +73,5 @@ class TestConnectAutoconnect(unittest.TestCase):
|
||||
wait_periodic_scan = False):
|
||||
wd = IWD(True, '/tmp')
|
||||
|
||||
try:
|
||||
self.validate_connection(wd, ssid, autoconnect, throws, use_agent,
|
||||
wait_periodic_scan)
|
||||
except:
|
||||
del wd
|
||||
raise
|
||||
|
||||
del wd
|
||||
self.validate_connection(wd, ssid, autoconnect, throws, use_agent,
|
||||
wait_periodic_scan)
|
||||
|
@ -75,13 +75,7 @@ class Test(unittest.TestCase):
|
||||
def test_known_networks(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.list_removal_and_addition(wd)
|
||||
except:
|
||||
del wd
|
||||
raise
|
||||
|
||||
del wd
|
||||
self.list_removal_and_addition(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -86,35 +86,17 @@ class TestMFP(unittest.TestCase):
|
||||
def test_iwd_mfp0(self):
|
||||
wd = IWD(True, '/tmp/IWD-MFP0')
|
||||
|
||||
try:
|
||||
self.stage_iwd(wd, '/tmp/IWD-MFP0')
|
||||
except:
|
||||
del wd
|
||||
raise
|
||||
|
||||
del wd
|
||||
self.stage_iwd(wd, '/tmp/IWD-MFP0')
|
||||
|
||||
def test_iwd_mfp1(self):
|
||||
wd = IWD(True, '/tmp/IWD-MFP1')
|
||||
|
||||
try:
|
||||
self.stage_iwd(wd, '/tmp/IWD-MFP1')
|
||||
except:
|
||||
del wd
|
||||
raise
|
||||
|
||||
del wd
|
||||
self.stage_iwd(wd, '/tmp/IWD-MFP1')
|
||||
|
||||
def test_iwd_mfp2(self):
|
||||
wd = IWD(True, '/tmp/IWD-MFP2')
|
||||
|
||||
try:
|
||||
self.stage_iwd(wd, '/tmp/IWD-MFP2')
|
||||
except:
|
||||
del wd
|
||||
raise
|
||||
|
||||
del wd
|
||||
self.stage_iwd(wd, '/tmp/IWD-MFP2')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(exit=True)
|
||||
|
@ -48,10 +48,7 @@ class Test(unittest.TestCase):
|
||||
def test_connection_success(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
finally:
|
||||
del wd
|
||||
self.validate_connection(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -62,10 +62,7 @@ class Test(unittest.TestCase):
|
||||
def test_connection_success(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
finally:
|
||||
del wd
|
||||
self.validate_connection(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -68,10 +68,7 @@ class Test(unittest.TestCase):
|
||||
def test_connection_success(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
finally:
|
||||
del wd
|
||||
self.validate_connection(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -43,10 +43,7 @@ class Test(unittest.TestCase):
|
||||
def test_connection_success(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
finally:
|
||||
del wd
|
||||
self.validate_connection(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -68,10 +68,7 @@ class Test(unittest.TestCase):
|
||||
def test_connection_success(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.validate_connection(wd)
|
||||
finally:
|
||||
del wd
|
||||
self.validate_connection(wd)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -54,13 +54,7 @@ class Test(unittest.TestCase):
|
||||
def test_scan(self):
|
||||
wd = IWD(True, '/tmp')
|
||||
|
||||
try:
|
||||
self.validate_scan(wd)
|
||||
except:
|
||||
del wd
|
||||
raise
|
||||
|
||||
del wd
|
||||
self.validate_scan(wd)
|
||||
|
||||
for ssid, seen in self.dict.items():
|
||||
self.assertEqual(seen, True)
|
||||
|
@ -55,18 +55,11 @@ class Test(unittest.TestCase):
|
||||
def test_scan(self):
|
||||
wd = IWD(True, '/tmp')
|
||||
|
||||
try:
|
||||
self.validate_scan(wd)
|
||||
except:
|
||||
del wd
|
||||
raise
|
||||
|
||||
del wd
|
||||
self.validate_scan(wd)
|
||||
|
||||
for ssid, seen in self.dict.items():
|
||||
self.assertEqual(seen, True)
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
IWD.copy_to_storage('ssid_hidden_0.open')
|
||||
|
@ -40,10 +40,7 @@ class Test(unittest.TestCase):
|
||||
def test_scan(self):
|
||||
wd = IWD(True)
|
||||
|
||||
try:
|
||||
self.validate_quick_scan(wd)
|
||||
finally:
|
||||
del wd
|
||||
self.validate_quick_scan(wd)
|
||||
|
||||
# Only ssid_open_1 and ssid_open_2 should be discovered.
|
||||
self.assertEqual(self.dict['ssid_open_1'], True)
|
||||
|
@ -60,8 +60,6 @@ class Test(unittest.TestCase):
|
||||
self.assertRaises(iwd.InvalidFormatEx, network.connect)
|
||||
wd.unregister_psk_agent(psk_agent)
|
||||
|
||||
del wd
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
IWD.clear_storage()
|
||||
|
Loading…
Reference in New Issue
Block a user