From f8c16b6358ff0cc9eb8013b6ef5a175e779a05e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Thu, 1 Jun 2017 18:21:47 +0200 Subject: [PATCH] Terminate test suprocess --- .../salome_tester/salome_test_driver.py | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/bin/appliskel/salome_tester/salome_test_driver.py b/bin/appliskel/salome_tester/salome_test_driver.py index 7b119d176..478d012da 100644 --- a/bin/appliskel/salome_tester/salome_test_driver.py +++ b/bin/appliskel/salome_tester/salome_test_driver.py @@ -26,18 +26,6 @@ import os import subprocess import signal -# Run test -def runTest(command): - print "Running:", " ".join(command) - p = subprocess.Popen(command) - p.communicate() - res = p.returncode - # About res value: - # A negative value -N indicates that the child was terminated by signal N (Unix only). - # On Unix, the value 11 generally corresponds to a segmentation fault. - return res -# - # Timeout management class TimeoutException(Exception): """Exception raised when test timeout is reached.""" @@ -82,7 +70,15 @@ if __name__ == "__main__": try: salome_instance = SalomeInstance.start(shutdown_servers=True) port = salome_instance.get_port() - res = runTest(test_and_args) + # Run the test + print "Running:", " ".join(test_and_args) + p = subprocess.Popen(test_and_args) + pid = p.pid + p.communicate() + res = p.returncode + # About res value: + # A negative value -N indicates that the child was terminated by signal N (Unix only). + # On Unix, the value 11 generally corresponds to a segmentation fault. except TimeoutException: print "FAILED : timeout(%s) is reached"%timeout_delay except: @@ -91,6 +87,7 @@ if __name__ == "__main__": pass try: salome_instance.stop() + os.kill(pid, signal.SIGTERM) except: pass if sys.platform == 'win32': -- 2.39.2