3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-10-04 02:18:49 +02:00

auto-t: cleanup dhcpd.leases[~] in testNetconfig

This commit is contained in:
James Prestwood 2021-08-13 13:26:09 -07:00 committed by Denis Kenzior
parent 5c14742a87
commit 382b73c11a
2 changed files with 16 additions and 4 deletions

View File

@ -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)

View File

@ -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)