]> SALOME platform Git repositories - modules/paravis.git/commitdiff
Salome HOME
update test execution procedure
authorCédric Aguerre <cedric.aguerre@edf.fr>
Wed, 28 Jan 2015 14:30:13 +0000 (15:30 +0100)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Fri, 27 Mar 2015 14:45:33 +0000 (15:45 +0100)
update test execution procedure

test/VisuPrs/CMakeLists.txt
test/VisuPrs/Util/paravistest.py
test/VisuPrs/Util/paravistesthelper.py

index d52cb03c807d751bb57366c7c627b2bc7da12b31..8c20cbda9e97e8a65f3f3682f76bb81bff364a92 100644 (file)
@@ -17,7 +17,8 @@
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-SET(TIMEOUT 10000)
+#SET(TIMEOUT 10000)
+SET(TIMEOUT 900)
 SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
 
 IF(NOT WIN32)
@@ -30,7 +31,7 @@ ENDIF(NOT WIN32)
 
 SET(PARAVIS_TEST_HELPER_FILE ${PROJECT_SOURCE_DIR}/test/VisuPrs/Util/paravistesthelper.py)
 
-SET(TEST_DIRECTORIES 
+SET(TEST_DIRECTORIES
   Util
   2D_viewer
   3D_viewer
@@ -54,7 +55,7 @@ SET(TEST_DIRECTORIES
   imps
   dump_study
 )
-  
+
 FOREACH(test_dir ${TEST_DIRECTORIES})
   ADD_SUBDIRECTORY(${test_dir})
 ENDFOREACH()
index 36e9e220795c3b6bad20a72cc3029da93307cbf2..ac5db92efda498de1240560d818d2ddf222b9690 100755 (executable)
@@ -29,9 +29,6 @@ import tempfile
 import getpass
 from datetime import date
 
-import salome
-
-
 # Auxiliary variables
 
 # Data directory
@@ -76,34 +73,6 @@ class RepresentationType:
         return cls._type2name[type]
 
 
-class SalomeSession(object):
-    def __init__(self):
-        import runSalome
-        import sys
-        if "INGUI" in sys.argv:
-            sys.argv += ["--gui"]
-            sys.argv += ["--show-desktop=1"]
-            sys.argv += ["--splash=0"]
-            #sys.argv += ["--standalone=study"]
-            #sys.argv += ["--embedded=SalomeAppEngine,cppContainer,registry,moduleCatalog"]
-       else:
-            sys.argv += ["--terminal"]
-        sys.argv += ["--modules=MED,PARAVIS"]
-        clt, d = runSalome.main()
-        port = d['port']
-        self.port = port
-        return
-
-    #VTN: workaround for crash on CentOS.6.3.64
-    #def __del__(self):
-        #os.system('killSalomeWithPort.py {0}'.format(self.port))
-        #os.system('killSalomeWithPort.py ' + self.port)
-        #import killSalomeWithPort
-        #killSalomeWithPort.killMyPort(self.port)
-        #return
-    pass
-
-
 # Auxiliary functions
 def test_values(value, et_value, check_error=0):
     """Test values."""
@@ -219,7 +188,7 @@ def compare_lists(value, et_value, check_error=0, eps=1e-04):
     else:
         for i in range(et_length):
             if abs(et_value[i]) > 1:
-                MAX = abs(eps*et_value[i])           
+                MAX = abs(eps*et_value[i])
             else:
                 MAX = eps
             if abs(et_value[i] - value[i])> MAX:
@@ -260,14 +229,14 @@ def TimeStampId(proxy):
         iterations[field_short_name] = [entity, timestamp_nb]
 
     return mesh_name, iterations
-    
-    
+
+
 def Import_Med_Field(paravis, file, field_names, check_errors=0, prs=[]):
     """Builds presentations on the given fields of the MED file.
     Originally defined in VISU_TEST/Grids/visu/ImportMedField/begin file.
-    
+
     Arguments:
-      paravis      : PARAVIS instance     
+      paravis      : PARAVIS instance
       file_name    : the full path to med file
       field_names  : the list of field names (for ex: ["pression","temperature","vitesse"])
       prs          : [[0,1,...], [], []]; empty list (sublist(s)) is ignored
@@ -283,11 +252,11 @@ def Import_Med_Field(paravis, file, field_names, check_errors=0, prs=[]):
                      9-VISU.TSCALARMAPONDEFORMEDSHAPE
     """
     import presentations
-    
+
     nb_errors = 0
-    
+
     print "File: ", file
-    
+
     # check the file accessibility
     if not os.access(file, os.F_OK):
         msg = "File " + file + " does not exist!!!"
@@ -297,56 +266,56 @@ def Import_Med_Field(paravis, file, field_names, check_errors=0, prs=[]):
     paravis.ImportFile(file)
     proxy = presentations.pvs.GetActiveSource()
     if proxy is None:
-       raise RuntimeError, "ERROR!!! Can't import file!!!"  
-    
+        raise RuntimeError, "ERROR!!! Can't import file!!!"
+
     for i in range(len(field_names)):
         print "Name of the field: ", field_names[i]
-        
-       if len(prs) != 0:
-           if len(prs[i]) != 0:
-               mesh_name, iterations = TimeStampId(proxy)
-                
-               if iterations.has_key(field_names[i]):
-                   entity = iterations[field_names[i]][0]
-                   iteration = iterations[field_names[i]][1]
-               else:
-                   msg="There is no information about TimeStampId of the " + field_names[i] + " field!!!"
-                   raise RuntimeError, msg
-
-               err = nb_errors
-                
-               for type in prs[i]:
-                   if type==0:
-                       if presentations.GaussPointsOnField(proxy, entity, field_names[i], iteration) is None:
-                           print "ERROR!!! Created GaussPoints presentation is None!!!"; nb_errors+=1
-                   if type==1:
-                       if presentations.ScalarMapOnField(proxy, entity, field_names[i], iteration) is None:
-                           print "ERROR!!! Created ScalarMap presentation is None!!!"; nb_errors+=1
-                   if type==2:
-                       if presentations.IsoSurfacesOnField(proxy, entity, field_names[i], iteration) is None:
-                           print "ERROR!!! Created IsoSurfaces presentation is None!!!"; nb_errors+=1
-                   if type==3:
-                       if presentations.CutPlanesOnField(proxy, entity, field_names[i], iteration) is None:
-                           print "ERROR!!! Created CutPlanes presentation is None!!!"; nb_errors+=1
-                   if type==4:
-                       if presentations.CutLinesOnField(proxy, entity, field_names[i], iteration) is None:
-                           print "ERROR!!! Created CutLines presentation is None!!!"; nb_errors+=1
-                   if type==5:
-                       if presentations.DeformedShapeOnField(proxy, entity, field_names[i], iteration) is None:
-                           print "ERROR!!! Created DeformedShape presentation is None!!!"; nb_errors+=1
-                   if type==6:
-                       if presentations.VectorsOnField(proxy, entity, field_names[i], iteration) is None:
-                           print "ERROR!!! Created Vectors presentation is None!!!"; nb_errors+=1
-                   if type==7:
-                       if presentations.StreamLinesOnField(proxy, entity, field_names[i], iteration) is None:
-                           print "ERROR!!! Created StreamLines presentation is None!!!"; nb_errors+=1
-                   if type==8:
-                       if presentations.Plot3DOnField(proxy, entity, field_names[i], iteration) is None:
-                           print "ERROR!!! Created Plot3D presentation is None!!!"; nb_errors+=1
-                   if type==9:
-                       if presentations.DeformedShapeAndScalarMapOnField(proxy, entity, field_names[i], iteration) is None:
-                           print "ERROR!!! Created ScalarMapOnDeformedShape presentation is None!!!"; nb_errors+=1
-                            
+
+        if len(prs) != 0:
+            if len(prs[i]) != 0:
+                mesh_name, iterations = TimeStampId(proxy)
+
+                if iterations.has_key(field_names[i]):
+                    entity = iterations[field_names[i]][0]
+                    iteration = iterations[field_names[i]][1]
+                else:
+                    msg="There is no information about TimeStampId of the " + field_names[i] + " field!!!"
+                    raise RuntimeError, msg
+
+                err = nb_errors
+
+                for type in prs[i]:
+                    if type==0:
+                        if presentations.GaussPointsOnField(proxy, entity, field_names[i], iteration) is None:
+                            print "ERROR!!! Created GaussPoints presentation is None!!!"; nb_errors+=1
+                    if type==1:
+                        if presentations.ScalarMapOnField(proxy, entity, field_names[i], iteration) is None:
+                            print "ERROR!!! Created ScalarMap presentation is None!!!"; nb_errors+=1
+                    if type==2:
+                        if presentations.IsoSurfacesOnField(proxy, entity, field_names[i], iteration) is None:
+                            print "ERROR!!! Created IsoSurfaces presentation is None!!!"; nb_errors+=1
+                    if type==3:
+                        if presentations.CutPlanesOnField(proxy, entity, field_names[i], iteration) is None:
+                            print "ERROR!!! Created CutPlanes presentation is None!!!"; nb_errors+=1
+                    if type==4:
+                        if presentations.CutLinesOnField(proxy, entity, field_names[i], iteration) is None:
+                            print "ERROR!!! Created CutLines presentation is None!!!"; nb_errors+=1
+                    if type==5:
+                        if presentations.DeformedShapeOnField(proxy, entity, field_names[i], iteration) is None:
+                            print "ERROR!!! Created DeformedShape presentation is None!!!"; nb_errors+=1
+                    if type==6:
+                        if presentations.VectorsOnField(proxy, entity, field_names[i], iteration) is None:
+                            print "ERROR!!! Created Vectors presentation is None!!!"; nb_errors+=1
+                    if type==7:
+                        if presentations.StreamLinesOnField(proxy, entity, field_names[i], iteration) is None:
+                            print "ERROR!!! Created StreamLines presentation is None!!!"; nb_errors+=1
+                    if type==8:
+                        if presentations.Plot3DOnField(proxy, entity, field_names[i], iteration) is None:
+                            print "ERROR!!! Created Plot3D presentation is None!!!"; nb_errors+=1
+                    if type==9:
+                        if presentations.DeformedShapeAndScalarMapOnField(proxy, entity, field_names[i], iteration) is None:
+                            print "ERROR!!! Created ScalarMapOnDeformedShape presentation is None!!!"; nb_errors+=1
+
                 # check if number of errors has increased
                 if err == nb_errors:
                     print "Presentation(s) creation...OK"
@@ -359,22 +328,12 @@ def Import_Med_Field(paravis, file, field_names, check_errors=0, prs=[]):
 def delete_with_inputs(obj):
     """Deletes the given object with all its inputs"""
     import pvsimple
-    
+
     obj_to_delete = obj
     while obj_to_delete is not None:
         tmp_obj = obj_to_delete
         obj_to_delete = None
         if hasattr(tmp_obj, 'Input'):
             obj_to_delete = tmp_obj.Input
-        
-        pvsimple.Delete(tmp_obj)
-
-# Run Salome
-salome_session = SalomeSession()
-salome.salome_init()
-session_server = salome.naming_service.Resolve('/Kernel/Session')
-if session_server:
-    session_server.emitMessage("connect_to_study")
-    session_server.emitMessage("activate_viewer/ParaView")
-    pass
 
+        pvsimple.Delete(tmp_obj)
index 1e49a8de7cf13803bf8df6a3e83635ec2eecc433..f638b605247223fbc83fb9bd802c543bea2b7962 100644 (file)
@@ -17,7 +17,6 @@
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-import searchFreePort
 import subprocess
 import sys, os
 import signal
@@ -30,29 +29,98 @@ if not os.getenv("OMNIORB_USER_PATH"):
 ## <<< TEMP ###
 
 
-args = {}
-searchFreePort.searchFreePort(args)
-port = args['port']
-try:
-    import PortManager
-    PortManager.releasePort(os.environ['NSPORT'])
-except ImportError:
+class SalomeSession(object):
+    def __init__(self, args=[]):
+        sys.argv = ['runSalome'] + args
+
+        if "INGUI" in args:
+            sys.argv += ["--gui"]
+            sys.argv += ["--show-desktop=1"]
+            sys.argv += ["--splash=0"]
+            #sys.argv += ["--standalone=study"]
+            #sys.argv += ["--embedded=SalomeAppEngine,cppContainer,registry,moduleCatalog"]
+        else:
+            sys.argv += ["--terminal"]
+        sys.argv += ["--modules=MED,PARAVIS,GUI"]
+
+        import setenv
+        setenv.main(True)
+
+        import runSalome
+        runSalome.runSalome()
     pass
+#
+
+port = 0
+
+def run_test(command):
+  # Run SALOME
+  import tempfile
+  log = tempfile.NamedTemporaryFile(suffix='_nsport.log', delete=False)
+  log.close()
+  import salome
+  salome_session = SalomeSession(args=["--ns-port-log=%s"%log.name])
+  salome.salome_init()
+  session_server = salome.naming_service.Resolve('/Kernel/Session')
+  if session_server:
+      session_server.emitMessage("connect_to_study")
+      session_server.emitMessage("activate_viewer/ParaView")
+      pass
+
+  global port
+  with open(log.name) as f:
+      port = int(f.readline())
+
+  # Run test
+  #res = subprocess.check_call(command)
+  p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+  _out, _err = p.communicate()
+  res = p.returncode
+
+  # Exit SALOME
+  killSalomeWithPort.killMyPort(port)
+  os.remove(log.name)
+
+  # :TRICKY: Special case of returncode=127
+  # When using paraview in SALOME environment, the following error
+  # systematicallty appears when exiting paraview (it's also true when using
+  # PARAVIS and exiting SALOME):
+  # Inconsistency detected by ld.so: dl-close.c: 738: _dl_close: Assertion `map->l_init_called' failed!
+  # For PARAVIS tests purpose, paraview functionalities are accessed in each
+  # test; these tests are run in the above subprocess call.
+  # The assertion error implies a subprocess return code of 127, and the test
+  # status is considered as "failed".
+  # The tricky part here is to discard such return codes, waiting for a fix
+  # maybe in paraview...
+  if res == 127 and _err.startswith("Inconsistency detected by ld.so: dl-close.c"):
+      print "    ** THE FOLLOWING MESSAGE IS NOT CONSIDERED WHEN ANALYZING TEST SUCCESSFULNESS **"
+      print _err
+      print "    ** end of message **"
+      res = 0;
+  elif _err:
+      print "    ** Detected error **"
+      print "Error code: ", res
+      print _err
+      print "    ** end of message **"
+      pass
+
+  return res
+#
 
 def timeout_handler(signum, frame):
     print "FAILED : timeout(" + sys.argv[1] + ") is reached"
     killSalomeWithPort.killMyPort(port)
     exit(1)
-
+#
 signal.alarm(abs(int(sys.argv[1])-10))
 signal.signal(signal.SIGALRM, timeout_handler)
 
 res = 1
 try:
-    res = subprocess.check_call([sys.executable]+sys.argv[2:])
+    res = run_test([sys.executable]+sys.argv[2:])
 except:
+    #import traceback
+    #traceback.print_exc()
     pass
 
-killSalomeWithPort.killMyPort(port)
-
 exit(res)