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)
--- /dev/null
+#! /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
+
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}
+ )
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
# kill Test process
TestKiller.killProcess(runSalome.process_id)
+exit(ret)
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}
+ )
{
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();
{
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();
addToKillList.killList()
TestKiller.killProcess(runSalome.process_id)
+exit(ret)
\ No newline at end of file
)
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}
+# )
addToKillList.killList()
TestKiller.killProcess(runSalome.process_id)
+exit(ret)
\ No newline at end of file
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):
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}
+ )
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}
+ )
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>
/*!
* 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[])
return wasSucessful ? 0 : 1;
}
+*/
\ No newline at end of file
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
# kill Test process
TestKiller.killProcess(runSalome.process_id)
+exit(ret)
\ No newline at end of file
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}
+ )
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
# kill Test process
TestKiller.killProcess(runSalome.process_id)
+exit(ret)
\ No newline at end of file
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}
+ )
ret = os.spawnvp(os.P_WAIT, command[0], command)
# no process to kill
+exit(ret)
\ No newline at end of file
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}
+ )
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
# ===============================================================
# 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
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()
# kill Test process
TestKiller.killProcess(runSalome.process_id)
+exit(ret)
\ No newline at end of file
+++ /dev/null
-#! /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
-
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}
+ )
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
# kill Test process
TestKiller.killProcess(runSalome.process_id)
+exit(ret)
\ No newline at end of file