diff options
authorJouni Malinen <jouni@qca.qualcomm.com>2016-08-22 10:17:44 (GMT)
committerJouni Malinen <j@w1.fi>2016-08-22 14:44:05 (GMT)
commitd952f021361c428d7c9e947d57c3bf4a1706f69c (patch)
parent7509b550f6fbdb1a336c554d00afab2ec5d9e4a0 (diff)
tests: Make FST kill_pid() more robust
It looks like the attempt to read the process id from a PID file can return empty data. This resulted in kill_pid() failing to kill the process and all the following FST test cases using the extra interface failing. While the PID file is really supposed to have a valid PID value when we get this far, it is better to try multiple times to avoid failing large number of test cases. The current os_daemonize() implementation ends up calling daemon() first and then writing the PID file from the remaining process that is running in the background. This leaves a short race condition where an external process that started hostapd/wpa_supplicant could end up trying to read the PID file before it has been written. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/hwsim/test_fst_config.py b/tests/hwsim/test_fst_config.py
index 73ceea4..03287b2 100644
--- a/tests/hwsim/test_fst_config.py
+++ b/tests/hwsim/test_fst_config.py
@@ -234,9 +234,17 @@ class FstLauncher:
pid = -1
- pf = file(pidfile, 'r')
- pid = int(pf.read().strip())
- pf.close()
+ for i in range(3):
+ pf = file(pidfile, 'r')
+ pidtxt = pf.read().strip()
+ self.logger.debug("kill_pid: %s: '%s'" % (pidfile, pidtxt))
+ pf.close()
+ try:
+ pid = int(pidtxt)
+ break
+ except Exception, e:
+ self.logger.debug("kill_pid: No valid PID found: %s" % str(e))
+ time.sleep(1)
self.logger.debug("kill_pid %s --> pid %d" % (pidfile, pid))
os.kill(pid, signal.SIGTERM)
for i in range(10):