]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
initiate application test process
authorCédric Aguerre <cedric.aguerre@edf.fr>
Mon, 16 Feb 2015 10:05:46 +0000 (11:05 +0100)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Fri, 27 Mar 2015 11:01:45 +0000 (12:01 +0100)
add commands: context, kill, test

salome extras

15 files changed:
bin/CMakeLists.txt
bin/appli_gen.py
bin/appliskel/.salome-completion.sh
bin/appliskel/CMakeLists.txt
bin/appliskel/salome_starter.py
bin/appliskel/salome_tester/CMakeLists.txt [new file with mode: 0644]
bin/appliskel/salome_tester/README [new file with mode: 0644]
bin/appliskel/salome_tester/salome_test_driver.py [new file with mode: 0644]
bin/appliskel/salome_tester/salome_test_session.py [new file with mode: 0644]
bin/runTests.py [new file with mode: 0644]
bin/salomeContext.py
bin/salomeContextUtils.py.in
bin/virtual_salome.py
src/Launcher/Test/CMakeLists.txt
src/Launcher/Test/CTestTestfileInstall.cmake [new file with mode: 0644]

index c0b21f8a4211a0b895b090d8d7d44c4da052415e..f97300c1fc54a48629fc8425c647fc67608f5d80 100755 (executable)
@@ -48,6 +48,7 @@ SET(SCRIPTS
   runSalome.py
   runSession.py
   runConsole.py
+  runTests.py
   salomeConsole.py
   ${CMAKE_CURRENT_BINARY_DIR}/salomeContextUtils.py
   salomeContext.py
index bef44c864c550d8bf3240f1c34afa339b5582ff1..9604eecf815c4d5de9e8f924a9b9b4a3a17d6dda 100644 (file)
@@ -189,7 +189,8 @@ def install(prefix, config_file, verbose=0):
             options.verbose = verbose
             options.clear = 0
             options.prefix = home_dir
-            options.module = _config[module]
+            options.module_name = module
+            options.module_path = _config[module]
             virtual_salome.link_module(options)
             pass
         pass
@@ -202,7 +203,7 @@ def install(prefix, config_file, verbose=0):
                'runAppli',           # OBSOLETE (replaced by salome)
                'runConsole',         # OBSOLETE (replaced by salome)
                'runRemote.sh',
-               'runSalomeScript',
+               'runSalomeScript',    # OBSOLETE (replaced by salome)
                'runSession',         # OBSOLETE (replaced by salome)
                'salome',
                'update_catalogs.py',
index 273878609e5cf1f96e3b019d9a426ad316354406..705129f837186475b69afae94e0c7f0765186cc3 100644 (file)
@@ -51,7 +51,7 @@ _salome()
     local cur prev command options
     COMPREPLY=( )
     _get_comp_words_by_ref -n = cur prev
-    commands='start context shell connect killall info help coffee'
+    commands='start context shell connect kill killall test info help coffee'
 
     # Algorithm:
     # If cursor is at index 1
index 11eafbe76a9ee08d92618deb223b938b58d30b13..99a628c52ba94e414c3c68df208527ee220b8570 100755 (executable)
@@ -17,6 +17,7 @@
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
+ADD_SUBDIRECTORY(salome_tester)
 ADD_SUBDIRECTORY(tests)
 
 # ===============================================================
index 676894a44d5f0f2aaf353d828c64a5062f707ee4..8465a14dc4171bcd1e514d17b668ee481ae07b20 100644 (file)
@@ -61,6 +61,7 @@ def initialize(launcherPath, launcherFile):
   os.environ['APPLI'] = appliPath # needed to convert .sh environment files
   os.environ['ABSOLUTE_APPLI_PATH'] = absoluteAppliPath
 
+  sys.path[:0] = [os.path.realpath(os.path.join(absoluteAppliPath, "bin", "salome", "test"))]
   sys.path[:0] = [os.path.realpath(os.path.join(absoluteAppliPath, "bin", "salome"))]
 
   # define folder to store omniorb config (initially in virtual application folder)
diff --git a/bin/appliskel/salome_tester/CMakeLists.txt b/bin/appliskel/salome_tester/CMakeLists.txt
new file mode 100644 (file)
index 0000000..18ed43f
--- /dev/null
@@ -0,0 +1,25 @@
+# Copyright (C) 2015  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+SET(SCRIPTS
+  salome_test_driver.py
+  salome_test_session.py
+)
+
+SALOME_INSTALL_SCRIPTS("${SCRIPTS}" ${SALOME_INSTALL_SCRIPT_SCRIPTS}/appliskel)
diff --git a/bin/appliskel/salome_tester/README b/bin/appliskel/salome_tester/README
new file mode 100644 (file)
index 0000000..d43feda
--- /dev/null
@@ -0,0 +1,38 @@
+This package contains a test driver to run component tests in a SALOME session.
+This note presents the procedure to declare tests that will be runnable from a SALOME application (through the salome command).
+
+
+I. Write, declare, build and install tests
+==========================================
+
+Each module test folder must contain:
+   - a set of test source files
+   - a CMakeLists.txt that:
+      - declare unit tests (not requiring a SALOME session) only
+      - build test files from sources if necessary
+      - install test files in <module_install_path>/bin/salome/test/
+      - install the CTestTestfileInstall.cmake file (see below) as <module_install_path>/bin/salome/test/CTestTestfile.cmake (rename file)
+   - a CTestTestfileInstall.cmake that:
+      - declare tests requiring a SALOME session
+
+The CTestTestfileInstall.cmake can also declare unit tests already declared in CMakeLists.txt. Actually CTestTestfileInstall.cmake declare all tests that will be runnable from SALOME application. This file MUST NOT use cmake environment variables.
+It can refer the ABSOLUTE_APPLI_PATH variable (automatically set when using application).
+If a test has to be run inside a SALOME session, use the salome_test_driver.py script that need as arguments a timeout, the test file to be run and its arguments.
+      SET(SALOME_TEST_DRIVER "$ENV{ABSOLUTE_APPLI_PATH}/bin/salome/appliskel/salome_test_driver.py")
+      SET(TIMEOUT        500)
+      ADD_TEST(SalomeLauncher python ${SALOME_TEST_DRIVER} ${TIMEOUT} test_launcher.py)
+Call explicitly python when using this test driver.
+
+You may want to label each test with the component they are associated to. It is useful to run tests associated to a specific component.
+      SET(COMPONENT_NAME KERNEL)
+      SET_TESTS_PROPERTIES(SalomeLauncher PROPERTIES LABELS "${COMPONENT_NAME}")
+
+
+You can have a look at KERNEL/src/Launcher/Test/ directory for a working example.
+
+
+II. Run tests
+=============
+
+Tests are run with the "salome test" command (in a terminal).
+Enter "salome test --help" for detailed usage.
diff --git a/bin/appliskel/salome_tester/salome_test_driver.py b/bin/appliskel/salome_tester/salome_test_driver.py
new file mode 100644 (file)
index 0000000..b736736
--- /dev/null
@@ -0,0 +1,96 @@
+# Copyright (C) 2015  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+"""
+Usage: salome_test_helper.py <timeout_delay> <test_file.py> [test file arguments]
+"""
+
+import sys
+import os
+import subprocess
+import signal
+
+# Run test
+def runTest(command):
+  print "Running:", " ".join(command)
+  p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+  out, err = p.communicate()
+  res = p.returncode
+
+  return res, out, err
+#
+
+# Display output and errors
+def processResult(res, out, err):
+  if out:
+    print out
+    pass
+  if err:
+    print err
+  print "Status code: ", res
+#
+
+# Timeout management
+class TimeoutException(Exception):
+  """Execption raised when test timeout is reached."""
+#
+def timeoutHandler(signum, frame):
+  raise TimeoutException()
+#
+
+if __name__ == "__main__":
+  timeout_delay = sys.argv[1]
+  args = sys.argv[2:]
+
+  # Add explicit call to python executable if a Python script is passed as
+  # first argument
+  if not args:
+    exit(0)
+  _, ext = os.path.splitext(args[0])
+  if ext == ".py":
+    test_and_args = [sys.executable] + args
+  else:
+    test_and_args = args
+
+  # Ensure OMNIORB_USER_PATH is set
+  from salomeContextUtils import setOmniOrbUserPath
+  setOmniOrbUserPath()
+
+  # Set timeout handler
+  print "Test timeout explicitely set to: %s seconds"%timeout_delay
+  signal.alarm(abs(int(timeout_delay)-10))
+  signal.signal(signal.SIGALRM, timeoutHandler)
+
+  # Run test in a new SALOME session
+  from salome_test_session import startSession, terminateSession
+  res = 1
+  try:
+    port = startSession()
+    res, out, err = runTest(test_and_args)
+    processResult(res, out, err)
+  except TimeoutException:
+    print "FAILED : timeout(%s) is reached"%timeout_delay
+  except:
+    import traceback
+    traceback.print_exc()
+    pass
+
+  terminateSession(port)
+  exit(res)
+#
diff --git a/bin/appliskel/salome_tester/salome_test_session.py b/bin/appliskel/salome_tester/salome_test_session.py
new file mode 100644 (file)
index 0000000..8f193f5
--- /dev/null
@@ -0,0 +1,76 @@
+# Copyright (C) 2015  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import sys
+import os
+
+# Example of args:
+#      args=["--gui", "--show-desktop=1", "--splash=0"]
+#      args=["--terminal","--modules=MED,PARAVIS,GUI"]
+class SalomeSession(object):
+  def __init__(self, args=[]):
+    sys.argv = ['runSalome'] + args
+
+    if "INGUI" in args:
+      # :WARNING: NOT TESTED YET
+      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 += ["--shutdown-servers=1"]
+      #sys.argv += ["--modules=MED,PARAVIS,GUI"]
+      pass
+
+    import setenv
+    setenv.main(True)
+
+    import runSalome
+    runSalome.runSalome()
+  #
+#
+
+# Run SALOME
+def startSession():
+  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
+
+  with open(log.name) as f:
+      port = int(f.readline())
+
+  os.remove(log.name)
+  return port
+#
+
+# Terminate SALOME
+def terminateSession(port):
+  import killSalomeWithPort
+  killSalomeWithPort.killMyPort(port)
+#
diff --git a/bin/runTests.py b/bin/runTests.py
new file mode 100644 (file)
index 0000000..7384e85
--- /dev/null
@@ -0,0 +1,114 @@
+# Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import os
+import sys
+import select
+import subprocess
+
+def __configureTests(args=[], exe=None):
+  if exe:
+      usage = "Usage: %s [options]"%exe
+  else:
+      usage = "Usage: %prog [options]"
+  epilog  = """\n
+Run tests of SALOME components provided with application.\n
+Principal options are:
+    -h,--help
+        Show this help message and exit.
+
+    -V,--verbose
+        Enable verbose output from tests.
+    -VV,--extra-verbose
+        Enable more verbose output from tests.
+    -Q,--quiet
+        Suppress all output.
+
+    -N,--show-only
+        Show available tests (without running them).
+
+    -R <regex>, --tests-regex <regex>
+        Run tests matching regular expression.
+    -E <regex>, --exclude-regex <regex>
+        Exclude tests matching regular expression.
+
+    -L <regex>, --label-regex <regex>
+        Run tests with labels matching regular expression.
+    -LE <regex>, --label-exclude <regex>
+        Exclude tests with labels matching regular expression.
+
+For complete description of available options, pleaser refer to ctest documentation.\n
+"""
+  if not args:
+    return []
+
+  if args[0] in ["-h", "--help"]:
+    print usage + epilog
+    sys.exit(0)
+
+  return args
+#
+
+# tests must be in ${ABSOLUTE_APPLI_PATH}/${__testSubDir}/
+__testSubDir = "bin/salome/test"
+
+# Both display process stdout&stderr to console and capture them to variables
+def __runTest(command, workdir):
+  p = subprocess.Popen(command, cwd=workdir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=1)
+  stdout = []
+  stderr = []
+
+  while True:
+    reads = [p.stdout.fileno(), p.stderr.fileno()]
+    ret = select.select(reads, [], [])
+
+    for fd in ret[0]:
+      if fd == p.stdout.fileno():
+        read = p.stdout.readline()
+        sys.stdout.write(read)
+        stdout.append(read)
+        pass
+      if fd == p.stderr.fileno():
+        read = p.stderr.readline()
+        sys.stderr.write(read)
+        stderr.append(read)
+        pass
+      pass
+
+    if p.poll() != None:
+      break
+    pass
+
+  return p.returncode, "".join(stdout), "".join(stderr)
+#
+
+def runTests(args, exe=None):
+  args = __configureTests(args, exe)
+
+  appliPath = os.getenv("ABSOLUTE_APPLI_PATH")
+  if not appliPath:
+      raise SalomeContextException("Unable to find application path. Please check that the variable ABSOLUTE_APPLI_PATH is set.")
+
+  testPath = os.path.join(appliPath, __testSubDir)
+
+  command = ["ctest"] + args
+  res, out, err = __runTest(command, testPath)
+
+  sys.exit(res)
+#
index 38e5080257768cc331e306d945ebb239cffcf158..384db9bf558e2db9f42d2ea796bf35e08cf80709 100644 (file)
@@ -40,22 +40,25 @@ Usage: salome [command] [options] [--config=<file,folder,...>]
 
 Commands:
 =========
-    start         Starts a SALOME session (through virtual application)
-    context       Initializes SALOME context.
-    shell         Initializes SALOME context, and executes scripts passed
-                  as command arguments
-    connect       Connects a Python console to the active SALOME session
-    killall       Kill all SALOME running sessions for current user
-    info          Display some information about SALOME
-    help          Show this message
-    coffee        Yes! SALOME can also make coffee!!
+    start           Starts a SALOME session (through virtual application)
+    context         Initializes SALOME context.
+    shell           Initializes SALOME context, and executes scripts passed
+                    as command arguments
+    connect         Connects a Python console to the active SALOME session
+    kill <port(s)>  Terminate SALOME session running on given ports for current user
+                    Port numbers must be separated by blank characters
+    killall         Kill *all* SALOME running sessions for current user
+    test            Run SALOME tests.
+    info            Display some information about SALOME
+    help            Show this message
+    coffee          Yes! SALOME can also make coffee!!
 
 If no command is given, default to start.
 
 Command options:
 ================
-    Use salome <command> --help to show help on command ; available for start
-    and shell commands.
+    Use salome <command> --help to show help on command ; available for commands:
+    start, shell, test.
 
 --config=<file,folder,...>
 ==========================
@@ -210,14 +213,17 @@ class SalomeContext:
     options = args[1:]
 
     availableCommands = {
-      'start' :   '_runAppli',
+      'start'   : '_runAppli',
       'context' : '_setContext',
-      'shell' :   '_runSession',
+      'shell'   : '_runSession',
       'connect' : '_runConsole',
-      'killall':  '_killAll',
-      'info':     '_showInfo',
-      'help':     '_usage',
-      'coffee' :  '_makeCoffee'
+      'kill'    : '_kill',
+      'killall' : '_killAll',
+      'test'    : '_runTests',
+      'info'    : '_showInfo',
+      'help'    : '_usage',
+      'coffee'  : '_makeCoffee',
+      'car'     : '_getCar',
       }
 
     if not command in availableCommands.keys():
@@ -324,10 +330,8 @@ class SalomeContext:
     sys.path[:0] = pythonpath
   #
 
-  def _runAppli(self, args=None):
-    if args is None:
-      args = []
-    # Initialize SALOME context
+  def _runAppli(self, args=[]):
+    # Initialize SALOME environment
     sys.argv = ['runSalome'] + args
     import setenv
     setenv.main(True)
@@ -356,9 +360,7 @@ class SalomeContext:
     return proc.communicate()
   #
 
-  def _runSession(self, args=None):
-    if args is None:
-      args = []
+  def _runSession(self, args=[]):
     sys.argv = ['runSession'] + args
     import runSession
     params, args = runSession.configureSession(args, exe="salome shell")
@@ -370,10 +372,8 @@ class SalomeContext:
     return runSession.runSession(params, args)
   #
 
-  def _runConsole(self, args=None):
-    if args is None:
-      args = []
-    # Initialize SALOME context
+  def _runConsole(self, args=[]):
+    # Initialize SALOME environment
     sys.argv = ['runConsole'] + args
     import setenv
     setenv.main(True)
@@ -383,9 +383,24 @@ class SalomeContext:
     return proc.communicate()
   #
 
-  def _killAll(self, args=None):
-    if args is None:
-      args = []
+  def _kill(self, args=[]):
+    ports = args
+    if not ports:
+      print "Port number(s) not provided to command: salome kill <port(s)>"
+      return
+
+    from multiprocessing import Process
+    from killSalomeWithPort import killMyPort
+    import tempfile
+    for port in ports:
+      with tempfile.NamedTemporaryFile():
+        p = Process(target = killMyPort, args=(port,))
+        p.start()
+        p.join()
+    pass
+  #
+
+  def _killAll(self, unused=None):
     try:
       import PortManager # mandatory
       from multiprocessing import Process
@@ -403,10 +418,18 @@ class SalomeContext:
       from killSalome import killAllPorts
       killAllPorts()
       pass
+  #
 
+  def _runTests(self, args=[]):
+    sys.argv = ['runTests']
+    import setenv
+    setenv.main(True)
+
+    import runTests
+    return runTests.runTests(args, exe="salome test")
   #
 
-  def _showInfo(self, args=None):
+  def _showInfo(self, unused=None):
     print "Running with python", platform.python_version()
     self._runAppli(["--version"])
   #
@@ -415,7 +438,7 @@ class SalomeContext:
     usage()
   #
 
-  def _makeCoffee(self, args=None):
+  def _makeCoffee(self, unused=None):
     print "                        ("
     print "                          )     ("
     print "                   ___...(-------)-....___"
@@ -426,9 +449,9 @@ class SalomeContext:
     print "       |  |    |                             |"
     print "        \\  \\   |                             |"
     print "         `\\ `\\ |                             |"
-    print "           `\\ `|                             |"
-    print "           _/ /\\                             /"
-    print "          (__/  \\                           /"
+    print "           `\\ `|            SALOME           |"
+    print "           _/ /\\            4 EVER           /"
+    print "          (__/  \\             <3            /"
     print "       _..---\"\"` \\                         /`\"\"---.._"
     print "    .-\'           \\                       /          \'-."
     print "   :               `-.__             __.-\'              :"
@@ -438,6 +461,43 @@ class SalomeContext:
     print "       \'._     \"\"\"----.....______.....----\"\"\"     _.\'"
     print "          `\"\"--..,,_____            _____,,..--\"\"`"
     print "                        `\"\"\"----\"\"\"`"
+    print ""
+    print "                    SALOME is working for you; what else?"
+    print ""
+    sys.exit(0)
+  #
+
+  def _getCar(self, unused=None):
+    print "                                              _____________"
+    print "                                  ..---:::::::-----------. ::::;;."
+    print "                               .\'\"\"\"\"\"\"                  ;;   \\  \":."
+    print "                            .\'\'                          ;     \\   \"\\__."
+    print "                          .\'                            ;;      ;   \\\\\";"
+    print "                        .\'                              ;   _____;   \\\\/"
+    print "                      .\'                               :; ;\"     \\ ___:\'."
+    print "                    .\'--...........................    : =   ____:\"    \\ \\"
+    print "               ..-\"\"                               \"\"\"\'  o\"\"\"     ;     ; :"
+    print "          .--\"\"  .----- ..----...    _.-    --.  ..-\"     ;       ;     ; ;"
+    print "       .\"\"_-     \"--\"\"-----\'\"\"    _-\"        .-\"\"         ;        ;    .-."
+    print "    .\'  .\'   SALOME             .\"         .\"              ;       ;   /. |"
+    print "   /-./\'         4 EVER <3    .\"          /           _..  ;       ;   ;;;|"
+    print "  :  ;-.______               /       _________==.    /_  \\ ;       ;   ;;;;"
+    print "  ;  / |      \"\"\"\"\"\"\"\"\"\"\".---.\"\"\"\"\"\"\"          :    /\" \". |;       ; _; ;;;"
+    print " /\"-/  |                /   /                  /   /     ;|;      ;-\" | ;\';"
+    print ":-  :   \"\"\"----______  /   /              ____.   .  .\"\'. ;;   .-\"..T\"   ."
+    print "\'. \"  ___            \"\":   \'\"\"\"\"\"\"\"\"\"\"\"\"\"\"    .   ; ;    ;; ;.\" .\"   \'--\""
+    print " \",   __ \"\"\"  \"\"---... :- - - - - - - - - \' \'  ; ;  ;    ;;\"  .\""
+    print "  /. ;  \"\"\"---___                             ;  ; ;     ;|.\"\""
+    print " :  \":           \"\"\"----.    .-------.       ;   ; ;     ;:"
+    print "  \\  \'--__               \\   \\        \\     /    | ;     ;;"
+    print "   \'-..   \"\"\"\"---___      :   .______..\\ __/..-\"\"|  ;   ; ;"
+    print "       \"\"--..       \"\"\"--\"        m l s         .   \". . ;"
+    print "             \"\"------...                  ..--\"\"      \" :"
+    print "                        \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"    \\        /"
+    print "                                               \"------\""
+    print ""
+    print "                                Drive your simulation properly with SALOME!"
+    print ""
     sys.exit(0)
   #
 
index 4d6d02ebbc89bfda9452c5fcb5bdd000a3610443..724106a6e2792fb382496a42cfa2db6870d93b83 100644 (file)
@@ -111,7 +111,7 @@ class ScriptAndArgs:
   # script: the command to be run, e.g. python <script.py>
   # args: its input parameters
   # out: its output parameters
-  def __init__(self, script = None, args = None, out = None):
+  def __init__(self, script=None, args=None, out=None):
     self.script = script
     self.args = args
     self.out = out
@@ -269,7 +269,7 @@ def formatScriptsAndArgs(scriptArgs=None):
     return command
 #
 
-# Ensure OMNIORB_USER_PATH is defined. This variable refers to a the folder in which
+# Ensure OMNIORB_USER_PATH is defined. This variable refers to a folder in which
 # SALOME will write omniOrb configuration files.
 # If OMNIORB_USER_PATH is already set, only checks write access to associated directory ;
 # an exception is raised if check fails. It allows users for choosing a specific folder.
index 773c96f570519b7c7cb2066e6813584890e052bd..0a2493121c388a4789e4548efc3df1000a3d0336 100755 (executable)
@@ -98,11 +98,11 @@ def get_lib_dir():
 def link_module(options):
     global verbose
 
-    if not options.module:
+    if not options.module_path:
         print "Option module is mandatory"
         return
 
-    module_dir=os.path.abspath(options.module)
+    module_dir=os.path.abspath(options.module_path)
     if not os.path.exists(module_dir):
         print "Module %s does not exist" % module_dir
         return
@@ -131,6 +131,7 @@ def link_module(options):
       return
 
     module_bin_dir=os.path.join(module_dir,'bin','salome')
+    module_test_dir=os.path.join(module_dir,'bin','salome', 'test')
     module_idl_dir=os.path.join(module_dir,'idl','salome')
     module_lib_dir=os.path.join(module_dir,get_lib_dir(),'salome')
     module_pvlib_dir=os.path.join(module_dir,get_lib_dir(),'paraview')
@@ -147,6 +148,7 @@ def link_module(options):
     module_sharedoc_examples=os.path.join(module_dir,'share','doc','salome','examples')
 
     bin_dir=os.path.join(home_dir,'bin','salome')
+    test_dir=os.path.join(home_dir,'bin','salome', 'test')
     idl_dir=os.path.join(home_dir,'idl','salome')
     lib_dir=os.path.join(home_dir,'lib','salome')
     pvlib_dir=os.path.join(home_dir,'lib','paraview')
@@ -164,6 +166,7 @@ def link_module(options):
 
     if options.clear:
         rmtree(bin_dir)
+        rmtree(test_dir)
         rmtree(idl_dir)
         rmtree(lib_dir)
         rmtree(lib_py_dir)
@@ -175,8 +178,10 @@ def link_module(options):
     #directory bin/salome : create it and link content
     if os.path.exists(module_bin_dir):
         mkdir(bin_dir)
+        mkdir(test_dir)
         for fn in os.listdir(module_bin_dir):
-            symlink(os.path.join(module_bin_dir, fn), os.path.join(bin_dir, fn))
+            if fn != "test":
+                symlink(os.path.join(module_bin_dir, fn), os.path.join(bin_dir, fn))
             pass
         pass
     else:
@@ -184,6 +189,19 @@ def link_module(options):
             print module_bin_dir, " doesn't exist"
         pass
 
+    #directory bin/salome/test : create it and link content
+    if os.path.exists(module_test_dir):
+        # link <appli_path>/bin/salome/test/<module> to <module_path>/bin/salome/test
+        print "link %s --> %s"%(os.path.join(test_dir, options.module_name), module_test_dir)
+        symlink(module_test_dir, os.path.join(test_dir, options.module_name))
+        # register module for testing in CTestTestfile.cmake
+        with open(os.path.join(test_dir, "CTestTestfile.cmake"), "ab") as f:
+            f.write("SUBDIRS(%s)\n"%options.module_name)
+    else:
+        if verbose:
+            print module_bin_dir, " doesn't exist"
+        pass
+
     #directory idl/salome : create it and link content
     if os.path.exists(module_idl_dir):
         mkdir(idl_dir)
@@ -216,7 +234,7 @@ def link_module(options):
         if verbose:
             print module_pvlib_dir, " doesn't exist"
         pass
-        
+
     #directory lib/pyversio/site-packages/salome : create it and link content
     if not os.path.exists(module_lib_py_dir):
         print "Python directory %s does not exist" % module_lib_py_dir
@@ -271,7 +289,7 @@ def link_module(options):
             symlink(os.path.join(module_sharedoc_tui_dir, fn), os.path.join(sharedoc_tui_dir, fn))
             pass
         pass
-      
+
     #directory share/doc/salome/examples : create it and link content
     if os.path.exists(module_sharedoc_examples):
         mkdir(sharedoc_examples_dir)
index 67563f7a11f768d0972447e53439bcfeae89780f..d77c657bed7322490b310dbd89a294f583cae9f4 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2014  CEA/DEN, EDF R&D
+# Copyright (C) 2012-2015  CEA/DEN, EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 # --- rules ---
 
 IF(NOT WIN32)
-  ADD_TEST(NAME SalomeLauncher
-           COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../UnitTests/prepare_test.py
-           ${CMAKE_CURRENT_SOURCE_DIR}/test_launcher.py
-           -d KERNEL_ROOT_DIR=${CMAKE_INSTALL_PREFIX}
-          )
+# ** Now in CTestTestfileInstall.cmake **
+# ** In this file only remain unit tests (no SALOME session is needed) **
+#  ADD_TEST(NAME SalomeLauncher
+#           COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../UnitTests/prepare_test.py
+#           ${CMAKE_CURRENT_SOURCE_DIR}/test_launcher.py
+#           -d KERNEL_ROOT_DIR=${CMAKE_INSTALL_PREFIX}
+#          )
+  INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/test_launcher.py
+          DESTINATION ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test)
+
+  INSTALL(FILES CTestTestfileInstall.cmake
+          DESTINATION ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test
+          RENAME CTestTestfile.cmake)
 ENDIF()
diff --git a/src/Launcher/Test/CTestTestfileInstall.cmake b/src/Launcher/Test/CTestTestfileInstall.cmake
new file mode 100644 (file)
index 0000000..d43734d
--- /dev/null
@@ -0,0 +1,33 @@
+# Copyright (C) 2015  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+SET(SALOME_TEST_DRIVER "$ENV{ABSOLUTE_APPLI_PATH}/bin/salome/appliskel/salome_test_driver.py")
+
+SET(COMPONENT_NAME KERNEL)
+SET(TIMEOUT        500)
+
+IF(NOT WIN32)
+  ADD_TEST(SalomeLauncher python ${SALOME_TEST_DRIVER} ${TIMEOUT} test_launcher.py)
+  SET_TESTS_PROPERTIES(SalomeLauncher PROPERTIES LABELS "${COMPONENT_NAME}"
+    #                                                 TIMEOUT 500
+    )
+  # /!\ DO NOT SET TIMEOUT PROPERTY IF USING ${SALOME_TEST_DRIVER}
+  #     BUT PASS TIMEOUT VALUE TO THE DRIVER
+
+ENDIF()