From 069b94b733a7b05736ed05d51808487e5d81944f Mon Sep 17 00:00:00 2001 From: Artem Zhidkov Date: Tue, 7 Apr 2020 14:29:34 +0300 Subject: [PATCH] Update HDF testing engine to avoid hanging if X client is unavalable. --- test.hdfs/test.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/test.hdfs/test.py b/test.hdfs/test.py index 69b88b668..0c2f27e7a 100644 --- a/test.hdfs/test.py +++ b/test.hdfs/test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python if __name__ == '__main__': - from subprocess import Popen + import subprocess from time import sleep import sys, os @@ -17,25 +17,26 @@ if __name__ == '__main__': except: pass - proc = Popen([salomeKernelDir + "/bin/salome/runSalome.py", "--modules", "SHAPER,GEOM", "--gui", "--ns-port-log=" + portlogfile, sourceDir + "/test_hdf.py", "args:" + testfile + "," + portlogfile + "," + testlogfile + "," + salomeKernelDir + "," + sourceDir]) - - iter = 0 - while not os.path.exists(portlogfile) and iter < 100: - sleep(0.1) - iter += 1 + isOk = True + error = "" - while os.path.exists(portlogfile): - sleep(0.1) + proc = subprocess.Popen([salomeKernelDir + "/bin/salome/runSalome.py", "--modules", "SHAPER,GEOM", "--gui", "--ns-port-log=" + portlogfile, sourceDir + "/test_hdf.py", "args:" + testfile + "," + portlogfile + "," + testlogfile + "," + salomeKernelDir + "," + sourceDir], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + try: + proc.communicate(timeout = 300) + except TimeoutExpired: + isOk = False + proc.kill() + out, err = proc.communicate() + error = "Killed by CPU limit." + print(err) - isOk = True with open(testlogfile, 'r') as inputFile: s = inputFile.read() print(s) - for line in s: - isOk = isOk and s.find("FAIL") < 0 + isOk = isOk and s.find("FAIL") < 0 try: os.remove(testlogfile) except: pass - assert isOk, "Test failed" + assert isOk, "Test failed. {}".format(error) -- 2.39.2