]> SALOME platform Git repositories - modules/shaper.git/blob - test.hdfs/testme.py
Salome HOME
[GITHUB #2] problem in export dialog - difference in STEP vs BREP
[modules/shaper.git] / test.hdfs / testme.py
1 #!/usr/bin/env python3
2
3 # Copyright (C) 2020-2024  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 if __name__ == '__main__':
22
23   import subprocess
24   from time import sleep
25   import sys, os
26   import tempfile
27   import platform
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   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)
56   try:
57     proc.communicate(timeout = testTimeout)
58   except subprocess.TimeoutExpired:
59     isOk = False
60     import salome_utils
61     port = salome_utils.getPortNumber()
62     import killSalomeWithPort
63     killSalomeWithPort.killMyPort(port)
64     error = "Killed by CPU limit."
65
66   assert isOk, "Test failed. {}".format(error)
67
68   with open(testlogfile, 'r') as inputFile:
69     s = inputFile.read()
70     #print("logfile: ", s)
71     if s.find("FAIL") > 0:
72       isOk = False
73       error = s
74     elif s.find("OK") < 0:
75       isOk = False
76       error = "Test not ended until OK. Maybe a SIGSEGV."
77
78   try:
79     os.remove(testlogfile)
80   except:
81     pass
82
83   assert isOk, "Test failed. {}".format(error)