3 # Copyright (C) 2020-2024 CEA, EDF
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.
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.
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
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 if __name__ == '__main__':
24 from time import sleep
31 testTimeout = int(sys.argv[1])
33 testdatafile = sys.argv[3]
36 testdatafile = sys.argv[2]
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(".", "_")
51 runSalome = os.path.join(os.getenv("KERNEL_ROOT_DIR"), "bin", "salome", "runSalome.py")
52 cmd= [runSalome , "--modules", "SHAPER,GEOM,SHAPERSTUDY", "--gui", "--splash", "0", test_hdfpy, "args:" + hdffile + "," + testdatafile + "," + testlogfile]
53 if platform.system() == "Windows" :
54 cmd = ["python3", *cmd]
55 proc = subprocess.Popen(cmd)
57 proc.communicate(timeout = testTimeout)
58 except subprocess.TimeoutExpired:
61 port = salome_utils.getPortNumber()
62 import killSalomeWithPort
63 killSalomeWithPort.killMyPort(port)
64 error = "Killed by CPU limit."
66 assert isOk, "Test failed. {}".format(error)
68 with open(testlogfile, 'r') as inputFile:
70 #print("logfile: ", s)
71 if s.find("FAIL") > 0:
74 elif s.find("OK") < 0:
76 error = "Test not ended until OK. Maybe a SIGSEGV."
79 os.remove(testlogfile)
83 assert isOk, "Test failed. {}".format(error)