From 4afc6de5ce6098fad1ee95a5af16136d23423203 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 23 Jan 2020 13:28:23 -0500 Subject: [PATCH] test/integ/process.py: Detect Tor exiting with nonzero exitcode The take_ownership_via_{pid,controller} tests previously used "tor_process_poll() == 0" to see whether Tor had existed. This caused a misleading test failure in the case where Tor exited because of a signal, or returned a nonzero exit code: the tests would report that Tor had not exited at all. --- test/integ/process.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/test/integ/process.py b/test/integ/process.py index 274a8ec95..1a64949ee 100644 --- a/test/integ/process.py +++ b/test/integ/process.py @@ -591,8 +591,14 @@ def test_take_ownership_via_pid(tor_cmd): start_time = time.time() while time.time() - start_time < 30: - if tor_process.poll() == 0: - return # tor exited + if tor_process.poll() != None: + exitcode = tor_process.returncode + if exitcode < 0: + raise AssertionError("Tor exited with signal %d"%-exitcode) + elif exitcode > 0: + raise AssertionError("Tor exited with exit code %d"%exitcode) + else: + return # tor exited without error. time.sleep(0.01) @@ -632,8 +638,14 @@ def test_take_ownership_via_controller(tor_cmd): start_time = time.time() while time.time() - start_time < 20: - if tor_process.poll() == 0: - return # tor exited + if tor_process.poll() != None: + exitcode = tor_process.returncode + if exitcode < 0: + raise AssertionError("Tor exited with signal %d"%-exitcode) + elif exitcode > 0: + raise AssertionError("Tor exited with exit code %d"%exitcode) + else: + return # tor exited without error. time.sleep(0.01)