commit 382b73c11adf0b64b95baa2a4e756dd24c42574a
parent 5c14742a87631c2628d15724e2bb8880e8edf09a
Author: James Prestwood <prestwoj@gmail.com>
Date: Fri, 13 Aug 2021 13:26:09 -0700
auto-t: cleanup dhcpd.leases[~] in testNetconfig
Diffstat:
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/autotests/testNetconfig/connection_test.py b/autotests/testNetconfig/connection_test.py
@@ -48,6 +48,13 @@ class Test(unittest.TestCase):
@classmethod
def setUpClass(cls):
+ def remove_lease():
+ try:
+ os.remove('/tmp/dhcpd.leases')
+ os.remove('/tmp/dhcpd.leases~')
+ except:
+ pass
+
hapd = HostapdCLI()
# TODO: This could be moved into test-runner itself if other tests ever
# require this functionality (p2p, FILS, etc.). Since its simple
@@ -57,14 +64,13 @@ class Test(unittest.TestCase):
ctx.start_process(['touch', '/tmp/dhcpd.leases'], wait=True)
cls.dhcpd_pid = ctx.start_process(['dhcpd', '-f', '-cf', '/tmp/dhcpd.conf',
'-lf', '/tmp/dhcpd.leases',
- hapd.ifname])
+ hapd.ifname], cleanup=remove_lease)
@classmethod
def tearDownClass(cls):
IWD.clear_storage()
ctx.stop_process(cls.dhcpd_pid)
cls.dhcpd_pid = None
- os.remove('/tmp/dhcpd.leases')
if __name__ == '__main__':
unittest.main(exit=True)
diff --git a/autotests/testNetconfig/static_test.py b/autotests/testNetconfig/static_test.py
@@ -75,6 +75,13 @@ class Test(unittest.TestCase):
@classmethod
def setUpClass(cls):
+ def remove_lease():
+ try:
+ os.remove('/tmp/dhcpd.leases')
+ os.remove('/tmp/dhcpd.leases~')
+ except:
+ pass
+
hapd = HostapdCLI()
# TODO: This could be moved into test-runner itself if other tests ever
# require this functionality (p2p, FILS, etc.). Since its simple
@@ -84,14 +91,13 @@ class Test(unittest.TestCase):
ctx.start_process(['touch', '/tmp/dhcpd.leases'], wait=True)
cls.dhcpd_pid = ctx.start_process(['dhcpd', '-f', '-cf', '/tmp/dhcpd.conf',
'-lf', '/tmp/dhcpd.leases',
- hapd.ifname])
+ hapd.ifname], cleanup=remove_lease)
IWD.copy_to_storage('ssidTKIP.psk', '/tmp/storage')
@classmethod
def tearDownClass(cls):
IWD.clear_storage()
cls.dhcpd_pid.kill()
- os.system('rm -rf /tmp/dhcpd.leases')
if __name__ == '__main__':
unittest.main(exit=True)