]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Update HDF testing engine to avoid hanging if X client is unavalable.
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Tue, 7 Apr 2020 11:29:34 +0000 (14:29 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Tue, 7 Apr 2020 11:29:34 +0000 (14:29 +0300)
test.hdfs/test.py

index 69b88b668745590f02d826913e9762816947eaf6..0c2f27e7a1745a84e2581f92e1c215190686a4cb 100644 (file)
@@ -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)