]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Final fix for #19007 [CEA][Windows] SALOME non regression tests on Windows rnv/19007
authorrnv <rnv@opencascade.com>
Wed, 30 Dec 2020 01:45:30 +0000 (04:45 +0300)
committerrnv <rnv@opencascade.com>
Wed, 30 Dec 2020 01:45:30 +0000 (04:45 +0300)
bin/appliskel/tests/concurrentSession/TestConcurrentSession.py
bin/appliskel/tests/concurrentSession/TestMinimalExample.py
bin/appliskel/tests/salomeTest/CTestTestfileInstall.cmake

index cda75928073ee1199569f79c463f11a650a31e6e..039b52162f55167fe26435a92ce0f962d57075d7 100755 (executable)
@@ -35,71 +35,76 @@ def new_instance(running_instances):
   running_instances.put(instance)
 #
 
+def createInstances(nb):
+  running_instances = multiprocessing.Queue()
+  processes = [
+    multiprocessing.Process(target=new_instance, args=(running_instances,))
+    for i in range(nb)
+  ]
+  return running_instances, processes
+#
+
+def terminateInstances(running_instances):
+  import time
+  timeout = time.time() + 60 * 10  # the test duration is about 50 s, we reasonably assume a max duration of 10mn
+
+  while not running_instances.empty() and time.time() < timeout:
+    instance = running_instances.get()
+    print("Terminate instance running on port", instance.get_port())
+    instance.stop()
+#
+
+def session(args=None):
+  if args is None:
+    args = []
+  try:
+    import setenv
+    setenv.main(True)
+    import runSession
+    params, args = runSession.configureSession(args, exe="salome shell")
+    return runSession.runSession(params, args)
+  except SystemExit as e:
+    if str(e) != '0':
+      logging.error(e)
+    pass
+#
+
+def appli(args=None):
+  if args is None:
+    args = []
+  try:
+    sys.argv = ['runSalome', '-t']
+    import setenv
+    setenv.main(True, exeName="salome start")
+    import runSalome
+    runSalome.runSalome()
+  except SystemExit as e:
+    if str(e) != '0':
+      logging.error(e)
+    pass
+#
+
 class TestConcurrentLaunch(unittest.TestCase):
-  def __createInstances(self, nb):
-    running_instances = multiprocessing.Queue()
-    processes = [
-      multiprocessing.Process(target=new_instance, args=(running_instances,))
-      for i in range(nb)
-      ]
-    return running_instances, processes
-  #
-  def __terminateInstances(self, running_instances):
-    import time
-    timeout = time.time() + 60*10 # the test duration is about 50 s, we reasonably assume a max duration of 10mn
-
-    while not running_instances.empty() and time.time() < timeout:
-      instance = running_instances.get()
-      print("Terminate instance running on port", instance.get_port())
-      instance.stop()
-  #
 
-  def appli(self, args=None):
-    if args is None:
-      args = []
-    try:
-      sys.argv = ['runSalome', '-t']
-      import setenv
-      setenv.main(True, exeName="salome start")
-      import runSalome
-      runSalome.runSalome()
-    except SystemExit as e:
-      if str(e) != '0':
-        logging.error(e)
-      pass
-  #
-  def session(self, args=None):
-    if args is None:
-      args = []
-    try:
-      import setenv
-      setenv.main(True)
-      import runSession
-      params, args = runSession.configureSession(args, exe="salome shell")
-      return runSession.runSession(params, args)
-    except SystemExit as e:
-      if str(e) != '0':
-        logging.error(e)
-      pass
-  #
   def test01_SingleSession(self):
     print("** Testing single session **")
-    self.session(["hello.py"])
-  #
+    session(["hello.py"])
+
   def test02_MultiSession(self):
     print("** Testing multi sessions **")
     jobs = []
     for i in range(9):
-      p = multiprocessing.Process(target=self.session, args=(["hello.py"],))
+      p = multiprocessing.Process(target=session, args=(["hello.py"],))
       jobs.append(p)
       p.start()
 
     for j in jobs:
       j.join()
   #
+
   def test03_SingleAppli(self):
     print("** Testing single appli **")
-    running_instances, processes = self.__createInstances(1)
+    running_instances, processes = createInstances(1)
     for p in processes:
       p.start()
       pass
@@ -107,12 +112,13 @@ class TestConcurrentLaunch(unittest.TestCase):
       p.join()
       pass
 
-    self.session(["hello.py"])
-    self.__terminateInstances(running_instances)
+    session(["hello.py"])
+    terminateInstances(running_instances)
   #
+
   def test04_MultiAppli(self):
     print("** Testing multi appli **")
-    running_instances, processes = self.__createInstances(9)
+    running_instances, processes = createInstances(9)
     for p in processes:
       p.start()
       pass
@@ -120,8 +126,8 @@ class TestConcurrentLaunch(unittest.TestCase):
       p.join()
       pass
 
-    self.session(["hello.py"])
-    self.__terminateInstances(running_instances)
+    session(["hello.py"])
+    terminateInstances(running_instances)
   #
 #
 
index ab9d44ccf5f139a28c124d237f5a9fa9fa5abef3..03309ed01d6d3d9781ec70985cebe22dadcd787e 100755 (executable)
@@ -24,7 +24,8 @@ import multiprocessing
 import unittest
 import logging
 
-def port_reservation(obtained_ports, preferred=None, test=None, expected=None):
+
+def port_reservation(obtained_ports, preferred=None, name = None, messages=None, expected=None):
   from PortManager import getPort
   if preferred:
     port = getPort(preferred)
@@ -34,16 +35,23 @@ def port_reservation(obtained_ports, preferred=None, test=None, expected=None):
 
   obtained_ports.put(port)
 
-  if expected:
-    test.assertTrue(port == expected, "used = %s, expected = %s"%(port, expected))
+  if expected and messages:
+    _name = name + " : " if name else ""
+    if port != expected:
+      messages.put(_name + "used port= %s, expected port = %s"%(port, expected))
+    else:
+      messages.put(_name + "OK")
 #
 
+
 class TestMinimalExample(unittest.TestCase):
+
   def testSequential(self):
     from PortManager import releasePort, getBusyPorts
     print("\nBEGIN testSequential")
     print("Busy ports", getBusyPorts())
     obtained_ports = multiprocessing.Queue()
+    messages = multiprocessing.Queue()
 
     processes = [
       multiprocessing.Process(target=port_reservation, args=(obtained_ports,))
@@ -58,17 +66,19 @@ class TestMinimalExample(unittest.TestCase):
 
     print("Busy ports", getBusyPorts())
     # Try to get specific port number
-    p = multiprocessing.Process(target=port_reservation, args=(obtained_ports, 2872, self, 2872,))
+    p = multiprocessing.Process(target=port_reservation, args=(obtained_ports, 2872, "testSequential 2872",
+                                                               messages, 2872,))
     p.start()
     p.join()
 
     # Try to get specific port number
-    p = multiprocessing.Process(target=port_reservation, args=(obtained_ports, 2812, self,))
+    p = multiprocessing.Process(target=port_reservation, args=(obtained_ports, 2812,))
     p.start()
     p.join()
 
     # Try to get specific port number
-    p = multiprocessing.Process(target=port_reservation, args=(obtained_ports, 2899, self, 2899,))
+    p = multiprocessing.Process(target=port_reservation, args=(obtained_ports, 2899, "testSequential 2899:1",
+                                                               messages, 2899,))
     p.start()
     p.join()
 
@@ -79,10 +89,17 @@ class TestMinimalExample(unittest.TestCase):
     p.join()
 
     # Try to get specific port number
-    p = multiprocessing.Process(target=port_reservation, args=(obtained_ports, 2899, self, 2899,))
+    p = multiprocessing.Process(target=port_reservation, args=(obtained_ports, 2899, "testSequential 2899:2",
+                                                               messages, 2899,))
     p.start()
     p.join()
 
+    # Check results
+    while not messages.empty():
+      message = messages.get()
+      if "OK" not in message:
+        self.fail(message)
+
     # Release ports
     print("Busy ports", getBusyPorts())
     while not obtained_ports.empty():
@@ -100,6 +117,7 @@ class TestMinimalExample(unittest.TestCase):
     print("\nBEGIN testConcurrent")
     print("Busy ports", getBusyPorts())
     obtained_ports = multiprocessing.Queue()
+    messages = multiprocessing.Queue()
     processes = [
       multiprocessing.Process(target=port_reservation, args=(obtained_ports,))
 
@@ -107,7 +125,8 @@ class TestMinimalExample(unittest.TestCase):
       ]
 
     # Try to get specific port number
-    p = multiprocessing.Process(target=port_reservation, args=(obtained_ports, 2872, self, 2872,))
+    p = multiprocessing.Process(target=port_reservation, args=(obtained_ports, 2872, "testSequential 2872",
+                                                               messages, 2872,))
     processes.append(p)
 
     # Try to get specific port number
@@ -124,6 +143,12 @@ class TestMinimalExample(unittest.TestCase):
     for p in processes:
       p.join()
 
+    # Check results
+    while not messages.empty():
+      message = messages.get()
+      if "OK" not in message:
+        self.fail(message)
+
     # Release ports
     print("Busy ports", getBusyPorts())
     while not obtained_ports.empty():
index 80bca2c9ba0e53feb3a7e852a2d4eb3ff86129b8..8b468ea232661b9e9462e6497d4536b58d76a1a2 100644 (file)
 
 SET(tname salome_test)
 
-SET(TEST_NAME ${COMPONENT_NAME}_SALOME_TEST_${tname}_bash)
-ADD_TEST(${TEST_NAME} bash ${tname}.sh)
-SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}" TIMEOUT ${TIMEOUT} WILL_FAIL ON)
+IF (WIN32)
+  SET(PY_EXEC $ENV{PYTHONBIN})
+ELSE()
+  SET(PY_EXEC python)
+ENDIF()
 
-SET(TEST_NAME ${COMPONENT_NAME}_SALOME_TEST_${tname}_shell)
-ADD_TEST(${TEST_NAME} bash ${tname}_in_shell.sh)
-SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}" TIMEOUT ${TIMEOUT} WILL_FAIL ON)
+IF(NOT WIN32)
+  SET(TEST_NAME ${COMPONENT_NAME}_SALOME_TEST_${tname}_bash)
+  ADD_TEST(${TEST_NAME} bash ${tname}.sh)
+  SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}" TIMEOUT ${TIMEOUT} WILL_FAIL ON)
+
+  SET(TEST_NAME ${COMPONENT_NAME}_SALOME_TEST_${tname}_shell)
+  ADD_TEST(${TEST_NAME} bash ${tname}_in_shell.sh)
+  SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}" TIMEOUT ${TIMEOUT} WILL_FAIL ON)
+ENDIF()
 
 SET(TEST_NAME ${COMPONENT_NAME}_SALOME_TEST_${tname}_py)
-ADD_TEST(${TEST_NAME} python ${tname}.py)
+ADD_TEST(${TEST_NAME} ${PY_EXEC} ${tname}.py)
 SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}" TIMEOUT ${TIMEOUT} WILL_FAIL ON)
 
 SET(TEST_NAME ${COMPONENT_NAME}_SALOME_TEST_${tname}_driver)
-ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ${tname}.py)
+ADD_TEST(${TEST_NAME} ${PY_EXEC} ${SALOME_TEST_DRIVER} ${TIMEOUT} ${tname}.py)
 SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}" TIMEOUT ${TIMEOUT} WILL_FAIL ON)