From 3b1867c023be891bb15ede04e79f5d81e319c9b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Tue, 24 May 2016 16:16:23 +0200 Subject: [PATCH] Homogeneize test process call --- .../salome_tester/salome_test_driver.py | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/bin/appliskel/salome_tester/salome_test_driver.py b/bin/appliskel/salome_tester/salome_test_driver.py index 068bf89a0..71f1629bd 100644 --- a/bin/appliskel/salome_tester/salome_test_driver.py +++ b/bin/appliskel/salome_tester/salome_test_driver.py @@ -29,27 +29,26 @@ import signal # Run test def runTest(command): print "Running:", " ".join(command) - p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = p.communicate() - res = p.returncode + p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + + while True: + try: + out = p.stdout.readline() + sys.stdout.write(out) + except: # raised IOError or OSError if output is empty + pass + + returncode = p.poll() + if not returncode is None: + sys.stdout.flush() + break + pass + # 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, out, err -# - -# Display output and errors -def processResult(res, out, err): - if out: - print out - pass - if err: - print " ** Detected error **" - print "Error code: ", res - print err, - print " ** end of message **" - pass - return res + #return res, out, err + return p.returncode # # Timeout management @@ -96,8 +95,7 @@ if __name__ == "__main__": try: salome_instance = SalomeInstance.start(shutdown_servers=True) port = salome_instance.get_port() - res, out, err = runTest(test_and_args) - res = processResult(res, out, err) + res = runTest(test_and_args) except TimeoutException: print "FAILED : timeout(%s) is reached"%timeout_delay except: -- 2.39.2