]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
All tests in src directory use "make test".
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Mon, 29 Dec 2014 15:49:02 +0000 (16:49 +0100)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Mon, 29 Dec 2014 15:49:02 +0000 (16:49 +0100)
Some tests fail at this point:
LifeCycleCORBA
SALOMEDS
They need further work in order to be fixed.

25 files changed:
src/Basics/Test/CMakeLists.txt
src/Basics/Test/prepare_test.py [new file with mode: 0755]
src/KernelHelpers/Test/CMakeLists.txt
src/KernelHelpers/Test/TestKernelHelpers.py
src/LifeCycleCORBA/Test/CMakeLists.txt
src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx
src/LifeCycleCORBA/Test/TestLifeCycleCORBA.py
src/LifeCycleCORBA_SWIG/Test/CMakeLists.txt
src/LifeCycleCORBA_SWIG/Test/TestLifeCycleCORBA_SWIG.py
src/Logger/Test/TestKiller.py
src/NamingService/Test/CMakeLists.txt
src/SALOMEDS/Test/CMakeLists.txt
src/SALOMEDS/Test/TestSALOMEDS.cxx
src/SALOMEDS/Test/TestSALOMEDS.py
src/SALOMEDSImpl/Test/CMakeLists.txt
src/SALOMEDSImpl/Test/TestSALOMEDSImpl.py
src/SALOMELocalTrace/Test/CMakeLists.txt
src/SALOMELocalTrace/Test/TestSALOMELocalTrace.py
src/SALOMETraceCollector/Test/CMakeLists.txt
src/SALOMETraceCollector/Test/TestSALOMETraceCollector.py
src/UnitTests/CMakeLists.txt
src/UnitTests/UnitTests.py
src/UnitTests/prepare_test.py [deleted file]
src/Utils/Test/CMakeLists.txt
src/Utils/Test/TestUtils.py

index e512edf5cdabfc65ca026bad6bd5c52e993b9710..23f2808ccb2dd0664f93ecbeb372e3bc6ee2c805 100755 (executable)
@@ -19,3 +19,4 @@
 
 FILE(GLOB SALOMEBasics_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
 INSTALL(FILES ${SALOMEBasics_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
+SALOME_INSTALL_SCRIPTS(prepare_test.py ${SALOME_INSTALL_SCRIPT_SCRIPTS}/Tests)
diff --git a/src/Basics/Test/prepare_test.py b/src/Basics/Test/prepare_test.py
new file mode 100755 (executable)
index 0000000..d0a381f
--- /dev/null
@@ -0,0 +1,126 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+
+usage="""
+This script prepares the test environment and runs a test script:
+ - if SALOME_APPLI_PATH is not defined, create a new SALOME application
+ - launch salome
+ - launch the test script within SALOME environment
+ - kill salome
+
+ This script uses the following environment variables:
+   - SALOME_APPLI_PATH : directory of a SALOME application, target of the test
+   - ROOT_SALOME : if SALOME_APPLI_PATH is not defined, use ROOT_SALOME in
+                  order to provide a directory which contains the file
+                  salome_context.cfg and build a new application based on it.
+                  This variable is usually defined in salome_prerequisites.sh
+   - KERNEL_ROOT_DIR and YACS_ROOT_DIR : directories of modules installation
+                  Those variables are usually defined in salome_modules.sh
+ Environment variables can be passed to the script using the -d option.
+"""
+
+import os
+import sys
+import shutil
+
+class TestEnvironment:
+  def findSalomeAppli(self):
+    self.appli_dir = os.getenv("SALOME_APPLI_PATH")
+    if os.path.isdir(self.appli_dir):
+      return
+    else:
+      print "Invalid SALOME_APPLI_PATH. Trying to build a customised Salome application."
+      self.appli_dir = "appli"
+    shutil.rmtree(self.appli_dir, ignore_errors=True)
+    
+    # create config_appli.xml in current directory
+    salome_path = os.getenv("ROOT_SALOME", "")
+    salome_context_file = os.path.join(salome_path, "salome_context.cfg")
+    if not os.path.isfile(salome_context_file):
+      print "File salome_context.cfg not found."
+      print "Search path:" + salome_path
+      print "This test needs ROOT_SALOME environment variable in order to run"
+      exit(1)
+    
+    config_appli_text = '''<application>
+<context path="''' + salome_context_file + '''"/>
+<modules>
+   <module name="KERNEL" path="'''
+    kernel_path = os.getenv("KERNEL_ROOT_DIR", "")
+    if not os.path.isdir(kernel_path) :
+      print "KERNEL_ROOT_DIR not defined"
+      exit(1)
+      pass
+    
+    config_appli_text += kernel_path + '"/>'
+        
+    # some tests need YACS module.
+    yacs_path = os.getenv("YACS_ROOT_DIR", "")
+    if os.path.isdir(yacs_path):
+      config_appli_text += '''
+   <module name="YACS" path="'''
+      config_appli_text += yacs_path + '"/>'
+      pass
+    config_appli_text += '''
+</modules>
+</application>'''
+
+    f = open("config_appli.xml", 'w')
+    f.write(config_appli_text)
+    f.close()
+    
+    # create a SALOME application
+    appli_gen_file = os.path.join(kernel_path,
+                                  "bin","salome","appli_gen.py")
+    os.system(appli_gen_file + " --prefix="+self.appli_dir+
+                               " --config=config_appli.xml")
+    
+  def startSalome(self):
+    # start salome
+    import imp
+    sys.path[:0] = [os.path.join(self.appli_dir, "bin", "salome", "appliskel")]
+    self.salome_module = imp.load_source("SALOME",
+                                       os.path.join(self.appli_dir, "salome"))
+    try:
+      self.salome_module.main(["start", "-t"])
+    except SystemExit, e:
+      # There is an exit() call in salome.main. Just ignore it.
+      pass
+    
+  def runTest(self, script):
+    ret = 0
+    try:
+      ret = self.salome_module.main(["shell", script])
+    except SystemExit, e:
+      # return exit value
+      ret = e.code
+    return ret
+  
+  def tearDown(self):
+    try:
+      self.salome_module.main(["killall"])
+    except SystemExit, e:
+      pass
+    pass
+  pass #class TestEnvironment
+
+if __name__ == '__main__':
+  import argparse
+  parser = argparse.ArgumentParser(description=usage,
+                    formatter_class=argparse.RawDescriptionHelpFormatter)
+  parser.add_argument('command', help="Test command to be run.")
+  parser.add_argument('-d', '--define', action='append', help="VARIABLE=VALUE")
+
+  args = parser.parse_args()
+  for opt in args.define:
+    opts = opt.split('=', 1)
+    os.environ[opts[0]] = opts[1]
+  
+  envTest = TestEnvironment()
+  envTest.findSalomeAppli()
+  envTest.startSalome()
+  ret = envTest.runTest(args.command)
+  envTest.tearDown()
+  exit(ret)
+  pass
+
index 41313f939c975cf22e54fc11d135a9993ee1f393..ff1cfaf79298c95f6db1c33c395a5e9507314db9 100755 (executable)
@@ -66,3 +66,9 @@ SALOME_INSTALL_SCRIPTS(TestKernelHelpers.py ${SALOME_INSTALL_SCRIPT_PYTHON})
 
 FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
 INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
+
+ADD_TEST(NAME KernelHelpers
+         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_SCRIPTS}/Tests/prepare_test.py
+         ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_PYTHON}/TestKernelHelpers.py
+         -d KERNEL_ROOT_DIR=${CMAKE_INSTALL_PREFIX}
+        )
index ba69f9baa02e4e36c26b2094b25d15d5e7e6e295..c36b58a01519a6ed97b6b76bee8dc5d974948f86 100644 (file)
@@ -25,11 +25,12 @@ import sys, os,signal,string,commands
 import runSalome
 import orbmodule
 import TestKiller
+import setenv
 
 # get SALOME environment :
 
-args, modules_list, modules_root_dir = runSalome.get_config()
-runSalome.set_env(args, modules_list, modules_root_dir)
+args, modules_list, modules_root_dir = setenv.get_config()
+setenv.set_env(args, modules_list, modules_root_dir)
 
 # launch CORBA naming server
 
@@ -49,3 +50,4 @@ ret = os.spawnvp(os.P_WAIT, command[0], command)
 # kill Test process 
 
 TestKiller.killProcess(runSalome.process_id)
+exit(ret)
index 8d31c938386200c8e85748aedbe0e8f9f540dddf..df0424fc07e4442d0ce6db1148db4252beace7ec 100755 (executable)
@@ -70,3 +70,8 @@ SALOME_INSTALL_SCRIPTS(TestLifeCycleCORBA.py ${SALOME_INSTALL_SCRIPT_PYTHON})
 
 FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
 INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
+ADD_TEST(NAME LifeCycleCORBA
+         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_SCRIPTS}/Tests/prepare_test.py
+         ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_PYTHON}/TestLifeCycleCORBA.py
+         -d KERNEL_ROOT_DIR=${CMAKE_INSTALL_PREFIX}
+        )
index f95cccdb953c944ab67f2814ac9d842fead800ad..7ef4564804666c200e558820e005fc0a9d830671 100644 (file)
@@ -624,7 +624,7 @@ void  LifeCycleCORBATest::testgetLocalFile_localComputer()
 {
   SALOME_LifeCycleCORBA _LCC(&_NS);
   std::string origFileName = getenv("KERNEL_ROOT_DIR");
-  origFileName += "/lib/salome/libSalomeLifeCycleCORBA.so.0.0.0";
+  origFileName += "/idl/salome/SALOME_Types.idl";
   SALOME_FileTransferCORBA transfer( Kernel_Utils::GetHostname(),
                                      origFileName);
   std::string local = transfer.getLocalFile();
@@ -642,7 +642,7 @@ void  LifeCycleCORBATest::testgetLocalFile_remoteComputer()
 {
   SALOME_LifeCycleCORBA _LCC(&_NS);
   std::string origFileName = getenv("KERNEL_ROOT_DIR");
-  origFileName += "/lib/salome/libSalomeContainer.so.0.0.0";
+  origFileName += "/idl/salome/SALOME_Types.idl";
   SALOME_FileTransferCORBA transfer( GetRemoteHost(),
                                      origFileName);
   std::string local = transfer.getLocalFile();
index 0dbc8625fcf601d46d498bfc4e4245802f7fce98..866d4d6e80cbb9ecefd13528420964f9fe42d168 100644 (file)
@@ -86,3 +86,4 @@ launcher.Shutdown()
 addToKillList.killList()
 
 TestKiller.killProcess(runSalome.process_id)
+exit(ret)
\ No newline at end of file
index a6831e7abab25a54fcb6b4c619793ce6001bca33..27b79b8c4a41ff024eb8c653dd7bf014538b4091 100755 (executable)
@@ -26,3 +26,15 @@ SET(SCRIPTS
 )
 
 SALOME_INSTALL_SCRIPTS("${SCRIPTS}" ${SALOME_INSTALL_SCRIPT_PYTHON})
+
+ADD_TEST(NAME LifeCycleCORBA_SWIGTest
+         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_SCRIPTS}/Tests/prepare_test.py
+         ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_PYTHON}/LifeCycleCORBA_SWIGTest.py
+         -d KERNEL_ROOT_DIR=${CMAKE_INSTALL_PREFIX}
+        )
+
+#ADD_TEST(NAME TestLifeCycleCORBA_SWIG
+#         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_SCRIPTS}/Tests/prepare_test.py
+#         ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_PYTHON}/TestLifeCycleCORBA_SWIG.py
+#         -d KERNEL_ROOT_DIR=${CMAKE_INSTALL_PREFIX}
+#        )
index 089cfeae5b6130e406a5df4f168e229f6394ffb5..0e46b7f62bc0952e64e0389f634601a6fdc40b4d 100644 (file)
@@ -95,3 +95,4 @@ launcher.Shutdown()
 addToKillList.killList()
 
 TestKiller.killProcess(runSalome.process_id)
+exit(ret)
\ No newline at end of file
index a9512da1b4c932350ce5786364ba8944f570896d..d878b10c4d0661f7104b6e9b71787de5863d8796 100644 (file)
@@ -35,9 +35,13 @@ def killNamingService():
     line=f.readline()
     f.close()
     port=string.split(line,':')[-1][0:4]
-    command='ps -eo pid,command | grep "omniNames -start '+str(port)+'"'
-    pid=string.split(commands.getoutput(command))[0]
-    os.kill(int(pid),signal.SIGKILL)
+    command='ps -eo pid,command | grep "omniNames -start '+str(port)+'" | grep --invert-match grep'
+    output_com = commands.getoutput(command)
+    try:
+      pid=string.split(output_com)[0]
+      os.kill(int(pid),signal.SIGKILL)
+    except:
+      print "killNamingService failed."
 
 
 def killProcess(process_id):
index 4a61d516037bba89cfe2b99eeff728ab7dde71b3..758ef09479ce91e738b9f2f6f2fd76ba9d91bc9e 100755 (executable)
@@ -72,10 +72,8 @@ SALOME_INSTALL_SCRIPTS(TestNamingService.py ${SALOME_INSTALL_SCRIPT_PYTHON})
 FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
 INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
 
-IF(NOT WIN32)
-  ADD_TEST(NAME NamingService
-           COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_SCRIPTS}/Tests/prepare_test.py
-           ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_PYTHON}/TestNamingService.py
-           -d KERNEL_ROOT_DIR=${CMAKE_INSTALL_PREFIX}
-          )
-ENDIF()
+ADD_TEST(NAME NamingService
+         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_SCRIPTS}/Tests/prepare_test.py
+         ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_PYTHON}/TestNamingService.py
+         -d KERNEL_ROOT_DIR=${CMAKE_INSTALL_PREFIX}
+        )
index babc8e91f7fe304a532ad0ded8ec21d8206d8fb2..69a3830b5c8ad347aba07b3b9c39e0813b0d92de 100755 (executable)
@@ -84,3 +84,9 @@ SALOME_INSTALL_SCRIPTS(TestSALOMEDS.py ${SALOME_INSTALL_SCRIPT_PYTHON})
 
 FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
 INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
+
+ADD_TEST(NAME SALOMEDS
+         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_SCRIPTS}/Tests/prepare_test.py
+         ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_PYTHON}/TestSALOMEDS.py
+         -d KERNEL_ROOT_DIR=${CMAKE_INSTALL_PREFIX}
+        )
index 3b4601d410f7c3890f4b2cde6dcfcc2f09185a8d..e560ab412cddaf60e65e2c1270ec5e3bae71c757 100644 (file)
 CPPUNIT_TEST_SUITE_REGISTRATION( SALOMEDSTest );
 CPPUNIT_TEST_SUITE_REGISTRATION( SALOMEDSTest_Embedded );
 
+// --- generic Main program from Basic/Test
+
+#include "BasicMainTest.hxx"
+
+/*
 #include <cppunit/CompilerOutputter.h>
 #include <cppunit/TestResult.h>
 #include <cppunit/TestResultCollector.h>
@@ -61,7 +66,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION( SALOMEDSTest_Embedded );
 /*!
  *  Main program source for Unit Tests with cppunit package does not depend
  *  on actual tests, so we use the same for all partial unit tests.
- */
+ * /
 // ============================================================================
 
 int main(int argc, char* argv[])
@@ -181,3 +186,4 @@ int main(int argc, char* argv[])
 
   return wasSucessful ? 0 : 1;
 }
+*/
\ No newline at end of file
index fbb61ef23e43a42886cb4a8d6e344f35c8a2bf7d..68c63fdd72dff33c969f5354deac68c3f3a415c3 100644 (file)
@@ -25,11 +25,12 @@ import sys, os,signal,string,commands
 import runSalome
 import orbmodule
 import TestKiller
+import setenv
 
 # get SALOME environment :
 
-args, modules_list, modules_root_dir = runSalome.get_config()
-runSalome.set_env(args, modules_list, modules_root_dir)
+args, modules_list, modules_root_dir = setenv.get_config()
+setenv.set_env(args, modules_list, modules_root_dir)
 
 # launch CORBA naming server
 
@@ -49,3 +50,4 @@ ret = os.spawnvp(os.P_WAIT, command[0], command)
 # kill Test process 
 
 TestKiller.killProcess(runSalome.process_id)
+exit(ret)
\ No newline at end of file
index 58569be976e77a7accdd9f0a1b749dc0ebd9880a..74b60c1e762219b0f3aa1d0e6388cca6c088676c 100755 (executable)
@@ -74,3 +74,9 @@ SALOME_INSTALL_SCRIPTS(TestSALOMEDSImpl.py ${SALOME_INSTALL_SCRIPT_PYTHON})
 
 FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
 INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
+
+ADD_TEST(NAME SALOMEDSImpl
+         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_SCRIPTS}/Tests/prepare_test.py
+         ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_PYTHON}/TestSALOMEDSImpl.py
+         -d KERNEL_ROOT_DIR=${CMAKE_INSTALL_PREFIX}
+        )
index c94e7e0ac26ef39a9aa9adbe674cb928a86f2bdd..bbf3d7f363d9401d197db14abce0cc83a42df3e1 100644 (file)
@@ -25,11 +25,12 @@ import sys, os,signal,string,commands
 import runSalome
 import orbmodule
 import TestKiller
+import setenv
 
 # get SALOME environment :
 
-args, modules_list, modules_root_dir = runSalome.get_config()
-runSalome.set_env(args, modules_list, modules_root_dir)
+args, modules_list, modules_root_dir = setenv.get_config()
+setenv.set_env(args, modules_list, modules_root_dir)
 
 # launch CORBA naming server
 
@@ -49,3 +50,4 @@ ret = os.spawnvp(os.P_WAIT, command[0], command)
 # kill Test process 
 
 TestKiller.killProcess(runSalome.process_id)
+exit(ret)
\ No newline at end of file
index 1507ee24a841ee58991a0aa045b3de470ab5af11..d9fd5984410bc15d1e85a416fcdbd5a87cb82f72 100755 (executable)
@@ -40,3 +40,8 @@ SALOME_INSTALL_SCRIPTS(TestSALOMELocalTrace.py ${SALOME_INSTALL_SCRIPT_PYTHON})
 
 FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
 INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
+ADD_TEST(NAME SALOMELocalTrace
+         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_SCRIPTS}/Tests/prepare_test.py
+         ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_PYTHON}/TestSALOMELocalTrace.py
+         -d KERNEL_ROOT_DIR=${CMAKE_INSTALL_PREFIX}
+        )
index c83ee7b70292665bbdeadcd013024711f6bf01df..6211cc0d94ed6f8b16451ec446fa47c9a1143b35 100644 (file)
@@ -37,3 +37,4 @@ command = ['TestSALOMELocalTrace']
 ret = os.spawnvp(os.P_WAIT, command[0], command)
 
 # no process to kill
+exit(ret)
\ No newline at end of file
index ae530f1d76f30d2aa843ca63ed069c3437c8fa0c..d46255806363ef07a2c168e5f8f6e9d049025b54 100755 (executable)
@@ -52,10 +52,8 @@ SALOME_INSTALL_SCRIPTS(TestSALOMETraceCollector.py ${SALOME_INSTALL_SCRIPT_PYTHO
 FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
 INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
 
-IF(NOT WIN32)
-  ADD_TEST(NAME TraceCollector
-           COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_SCRIPTS}/Tests/prepare_test.py
-           ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_PYTHON}/TestSALOMETraceCollector.py
-           -d KERNEL_ROOT_DIR=${CMAKE_INSTALL_PREFIX}
-          )
-ENDIF()
+ADD_TEST(NAME TraceCollector
+         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_SCRIPTS}/Tests/prepare_test.py
+         ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_PYTHON}/TestSALOMETraceCollector.py
+         -d KERNEL_ROOT_DIR=${CMAKE_INSTALL_PREFIX}
+        )
index 04800de65375f439c8a060ca83316bc2d75bad46..faa66cdddefb4ec6118cabaa9b8a7b27b9fa6717 100644 (file)
@@ -25,11 +25,12 @@ import sys, os,signal,string,commands
 import runSalome
 import orbmodule
 import TestKiller
+import setenv
 
 # get SALOME environment :
 
-args, modules_list, modules_root_dir = runSalome.get_config()
-runSalome.set_env(args, modules_list, modules_root_dir)
+args, modules_list, modules_root_dir = setenv.get_config()
+setenv.set_env(args, modules_list, modules_root_dir)
 
 # launch CORBA naming server
 
index 158be534d9854d722cf11efd5e8f12b76bafb663..e7065e34f81d5e648c37eb15f6c9e48b2ff063f3 100755 (executable)
@@ -32,13 +32,7 @@ INCLUDE_DIRECTORIES(
 # ===============================================================
 
 # Executable scripts to be installed
-SET(py_SCRIPTS
-    UnitTests.py
-    prepare_test.py
-)
-
 SALOME_INSTALL_SCRIPTS(UnitTests.py ${SALOME_INSTALL_SCRIPT_SCRIPTS})
-SALOME_INSTALL_SCRIPTS(prepare_test.py ${SALOME_INSTALL_SCRIPT_SCRIPTS}/Tests)
 
 # ===============================================================
 # Executables targets
@@ -100,3 +94,10 @@ ENDIF()
 ADD_EXECUTABLE(UnitTests UnitTests.cxx)
 TARGET_LINK_LIBRARIES(UnitTests ${COMMON_LIBS})
 INSTALL(TARGETS UnitTests DESTINATION ${SALOME_INSTALL_BINS})
+IF(NOT WIN32)
+  ADD_TEST(NAME UnitTests
+           COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_SCRIPTS}/Tests/prepare_test.py
+           ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_PYTHON}/UnitTests.py
+           -d KERNEL_ROOT_DIR=${CMAKE_INSTALL_PREFIX}
+          )
+ENDIF()
index fa6f91e2ae07b6e26836842bcf0b975294d4a16b..32b6efceb0f7e5f51bde847636614915871247fb 100644 (file)
@@ -83,3 +83,4 @@ launcher.Shutdown()
 # kill Test process
 
 TestKiller.killProcess(runSalome.process_id)
+exit(ret)
\ No newline at end of file
diff --git a/src/UnitTests/prepare_test.py b/src/UnitTests/prepare_test.py
deleted file mode 100755 (executable)
index 71a296a..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
-usage="""
-This script prepares the test environment and runs a test script:
- - clean and create test directory
- - create a SALOME application
- - launch salome
- - launch the test script within SALOME environment
- - kill salome
-
- This script uses the following environment variables:
-   - ROOT_SALOME : directory which contains salome_context.cfg.
-                  This variable is usually defined in salome_prerequisites.sh
-   - KERNEL_ROOT_DIR and YACS_ROOT_DIR : directories of modules installation
-                  Those variables are usually defined in salome_modules.sh
- Environment variables can be passed to the script using the -d option.
-"""
-
-import os
-import sys
-
-class TestEnvironment:
-  def setUp(self):
-    import shutil
-    shutil.rmtree("appli", ignore_errors=True)
-    
-    # create config_appli.xml in current directory
-    salome_path = os.getenv("ROOT_SALOME", "")
-    salome_context_file = os.path.join(salome_path, "salome_context.cfg")
-    if not os.path.isfile(salome_context_file):
-      print "File salome_context.cfg not found."
-      print "Search path:" + salome_path
-      print "This test needs ROOT_SALOME environment variable in order to run"
-      exit(1)
-    
-    config_appli_text = '''<application>
-<context path="''' + salome_context_file + '''"/>
-<modules>
-   <module name="KERNEL" path="'''
-    kernel_path = os.getenv("KERNEL_ROOT_DIR", "")
-    if not os.path.isdir(kernel_path) :
-      print "KERNEL_ROOT_DIR not defined"
-      exit(1)
-      pass
-    
-    config_appli_text += kernel_path + '"/>'
-        
-    # some tests need YACS module.
-    yacs_path = os.getenv("YACS_ROOT_DIR", "")
-    if os.path.isdir(yacs_path):
-      config_appli_text += '''
-   <module name="YACS" path="'''
-      config_appli_text += yacs_path + '"/>'
-      pass
-    config_appli_text += '''
-</modules>
-</application>'''
-
-    f = open("config_appli.xml", 'w')
-    f.write(config_appli_text)
-    f.close()
-    
-    # create a SALOME application
-    appli_gen_file = os.path.join(kernel_path,
-                                  "bin","salome","appli_gen.py")
-    appli_dir = "appli"
-    os.system(appli_gen_file + " --prefix="+appli_dir+
-                               " --config=config_appli.xml")
-    
-    # start salome
-    import imp
-    sys.path[:0] = [os.path.join(appli_dir, "bin", "salome", "appliskel")]
-    self.salome_module = imp.load_source("SALOME", os.path.join(appli_dir, "salome"))
-    try:
-      self.salome_module.main(["start", "-t"])
-    except SystemExit, e:
-      # There is an exit() call in salome.main. Just ignore it.
-      pass
-    
-  def run(self, script):
-    ret = 0
-    try:
-      ret = self.salome_module.main(["shell", script])
-    except SystemExit, e:
-      # return exit value
-      ret = e.code
-    return ret
-  
-  def tearDown(self):
-    try:
-      self.salome_module.main(["killall"])
-    except SystemExit, e:
-      pass
-    pass
-  pass #class TestEnvironment
-
-if __name__ == '__main__':
-  import argparse
-  parser = argparse.ArgumentParser(description=usage,
-                    formatter_class=argparse.RawDescriptionHelpFormatter)
-  parser.add_argument('command', help="Test command to be run.")
-  parser.add_argument('-d', '--define', action='append', help="VARIABLE=VALUE")
-
-  args = parser.parse_args()
-  for opt in args.define:
-    opts = opt.split('=', 1)
-    os.environ[opts[0]] = opts[1]
-  
-  envTest = TestEnvironment()
-  envTest.setUp()
-  ret = envTest.run(args.command)
-  envTest.tearDown()
-  exit(ret)
-  pass
-
index 8f49727ff1977a1fb9ec48128b8a39d1ede04fce..8fc7bbe583a403c58d3a870b5e93bd9f2c6c8a60 100755 (executable)
@@ -54,3 +54,9 @@ SALOME_INSTALL_SCRIPTS(TestUtils.py ${SALOME_INSTALL_SCRIPT_PYTHON})
 
 FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
 INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
+
+ADD_TEST(NAME Utils
+         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_SCRIPTS}/Tests/prepare_test.py
+         ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_SCRIPT_PYTHON}/TestUtils.py
+         -d KERNEL_ROOT_DIR=${CMAKE_INSTALL_PREFIX}
+        )
index b61203b5381d07e611b4c64d263516ac6fa7ffa1..a8485f795540071121979b8fcbbcc040ddea5ab5 100644 (file)
@@ -25,11 +25,12 @@ import sys, os,signal,string,commands
 import runSalome
 import orbmodule
 import TestKiller
+import setenv
 
 # get SALOME environment :
 
-args, modules_list, modules_root_dir = runSalome.get_config()
-runSalome.set_env(args, modules_list, modules_root_dir)
+args, modules_list, modules_root_dir = setenv.get_config()
+setenv.set_env(args, modules_list, modules_root_dir)
 
 # launch CORBA naming server
 
@@ -49,3 +50,4 @@ ret = os.spawnvp(os.P_WAIT, command[0], command)
 # kill Test process
 
 TestKiller.killProcess(runSalome.process_id)
+exit(ret)
\ No newline at end of file