test-runner: add better Hostapd cleanup

There were a few issues with the cleanup of Hostapd. First the
process was only being killed, which did not actually remove
the process from the list.

In addition, with EAP-SIM/AKA tests, hostapd created sim_db
unix socket files which it does not clean up.
This commit is contained in:
James Prestwood 2021-02-25 14:00:59 -08:00 committed by Denis Kenzior
parent bf9d2b6c52
commit 11f0abebe6
1 changed files with 13 additions and 1 deletions

View File

@ -449,6 +449,8 @@ class Hostapd:
process since hostapd can be started with multiple config files.
'''
def __init__(self, ctx, radios, configs, radius):
self.ctx = ctx
if len(configs) != len(radios):
raise Exception("Config (%d) and radio (%d) list length not equal" % \
(len(configs), len(radios)))
@ -531,7 +533,17 @@ class Hostapd:
dbg("Failed to remove %s" % self.global_ctrl_iface)
self.instances = None
self.process.kill()
# Hostapd may have already been stopped
if self.process:
self.ctx.stop_process(self.process)
self.ctx = None
# Hostapd creates simdb sockets for EAP-SIM/AKA tests but does not
# clean them up.
for f in glob("/tmp/eap_sim_db*"):
os.remove(f)
dbus_count = 0