From cefd9595669c6623984091290d539fa1f815409b Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 4 Nov 2023 12:31:23 +0200 Subject: [PATCH] tests: Terminate sigma_dut more forcefully if needed 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 --- tests/hwsim/test_sigma_dut.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/hwsim/test_sigma_dut.py b/tests/hwsim/test_sigma_dut.py index 515afae69..e36e7923a 100644 --- a/tests/hwsim/test_sigma_dut.py +++ b/tests/hwsim/test_sigma_dut.py @@ -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'))