Salome HOME
Merge branch 'csgroup_IS2'
[modules/shaper.git] / test.hdfs / testme.py
1 #!/usr/bin/env python3
2
3 # Copyright (C) 2020-2021  CEA/DEN, EDF R&D
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   tempdir = tempfile.gettempdir()
39   portlogfile = tempdir + "/.salome_port"
40   testlogfile = tempdir + "/test.log"
41   # remove port file if any
42   try:
43     os.remove(portlogfile)
44   except:
45     pass
46
47   isOk = True
48   error = ""
49
50   proc = subprocess.Popen(["runSalome.py", "--modules", "SHAPER,GEOM,SHAPERSTUDY", "--gui", "--splash", "0", "--ns-port-log=" + portlogfile, "test_hdf.py", "args:" + hdffile + "," + testdatafile + "," + portlogfile + "," + testlogfile], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
51   try:
52     proc.communicate(timeout = testTimeout)
53   except TimeoutExpired:
54     isOk = False
55     proc.kill()
56     out, err = proc.communicate()
57     error = "Killed by CPU limit."
58     print(err)
59
60   with open(testlogfile, 'r') as inputFile:
61     s = inputFile.read()
62     print(s)
63     isOk = isOk and s.find("FAIL") < 0
64   try:
65     os.remove(testlogfile)
66   except:
67     pass
68
69   assert isOk, "Test failed. {}".format(error)