Salome HOME
fixed bos#38593 - middle point was incorrectly loaded
[modules/shaper.git] / test.hdfs / testme.py
1 #!/usr/bin/env python3
2
3 # Copyright (C) 2020-2023  CEA, EDF
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 #
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #
21
22 if __name__ == '__main__':
23
24   import subprocess
25   from time import sleep
26   import sys, os
27   import tempfile
28
29   testTimeout = 600
30   if len(sys.argv) > 3:
31     testTimeout = int(sys.argv[1])
32     hdffile = sys.argv[2]
33     testdatafile = sys.argv[3]
34   else:
35     hdffile = sys.argv[1]
36     testdatafile = sys.argv[2]
37
38   tempfile = tempfile.NamedTemporaryFile()
39   hdffile_basename = os.path.basename(hdffile)
40   test_hdfpy = "test_hdf.py"
41   if not os.path.exists(test_hdfpy):
42     # add absolute path in SHAPER install directory
43     test_hdfpy = os.path.join(os.getenv("SHAPER_ROOT_DIR"), "bin", "salome", "test", "HDFs", test_hdfpy)
44     if not os.path.exists(test_hdfpy):
45       raise Exception("test_hdf.py could not be found. Check your environment.")
46   testlogfile = tempfile.name + "_" + hdffile_basename.replace(".", "_")
47   tempfile.close()
48
49   isOk = True
50   error = ""
51
52   proc = subprocess.Popen(["runSalome.py", "--modules", "SHAPER,GEOM,SHAPERSTUDY", "--gui", "--splash", "0", test_hdfpy, "args:" + hdffile + "," + testdatafile + "," + testlogfile])
53   try:
54     proc.communicate(timeout = testTimeout)
55   except subprocess.TimeoutExpired:
56     isOk = False
57     import salome_utils
58     port = salome_utils.getPortNumber()
59     import killSalomeWithPort
60     killSalomeWithPort.killMyPort(port)
61     error = "Killed by CPU limit."
62
63   assert isOk, "Test failed. {}".format(error)
64
65   with open(testlogfile, 'r') as inputFile:
66     s = inputFile.read()
67     #print("logfile: ", s)
68     if s.find("FAIL") > 0:
69       isOk = False
70       error = s
71     elif s.find("OK") < 0:
72       isOk = False
73       error = "Test not ended until OK. Maybe a SIGSEGV."
74
75   try:
76     os.remove(testlogfile)
77   except:
78     pass
79
80   assert isOk, "Test failed. {}".format(error)