]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Terminate sigma_dut more forcefully if needed
authorJouni Malinen <j@w1.fi>
Sat, 4 Nov 2023 10:31:23 +0000 (12:31 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 4 Nov 2023 10:31:23 +0000 (12:31 +0200)
Wait for stdout/stderr in a more robust manner to avoid blocking the
pipes and kill the sigma_dut process if it fails to terminate cleanly.

Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/test_sigma_dut.py

index 515afae69e49e5cdd104b3ac4465a8ea83baffed..e36e7923a8527d5a0f0e2537f33d69f0ca82f61c 100644 (file)
@@ -164,10 +164,17 @@ def stop_sigma_dut(sigma):
     sigma_log_output(cmd)
     logger.debug("Terminating sigma_dut process")
     cmd.terminate()
-    cmd.wait()
-    out, err = cmd.communicate()
-    logger.debug("sigma_dut stdout: " + str(out.decode()))
-    logger.debug("sigma_dut stderr: " + str(err.decode()))
+    try:
+        out, err = cmd.communicate(timeout=200)
+        logger.debug("sigma_dut stdout: " + str(out.decode()))
+        logger.debug("sigma_dut stderr: " + str(err.decode()))
+    except subprocess.TimeoutExpired:
+        logger.debug("sigma_dut termination timed out")
+        cmd.kill()
+        out, err = cmd.communicate()
+        logger.debug("sigma_dut stdout: " + str(out.decode()))
+        logger.debug("sigma_dut stderr: " + str(err.decode()))
+
     subprocess.call(["ip", "addr", "del", "dev", sigma['ifname'],
                      "127.0.0.11/24"],
                     stderr=open('/dev/null', 'w'))