parser.add_option('l', 'launcher', 'string', 'launcher',
_("Use this option to specify the path to a SALOME launcher to use to "
"launch the test scripts of the test base."))
-parser.add_option('m', 'module', 'list', 'modules',
- _('Indicate which module(s) to test (subdirectory of the test base).'))
-parser.add_option('t', 'type', 'list', 'types',
- _('Indicate which type(s) to test (subdirectory of the module).'))
+parser.add_option('g', 'grid', 'list', 'grids',
+ _('Indicate which grid(s) to test (subdirectory of the test base).'))
+parser.add_option('s', 'session', 'list', 'sessions',
+ _('Indicate which session(s) to test (subdirectory of the grid).'))
parser.add_option('', 'display', 'string', 'display',
_("Set the display where to launch SALOME."
"\tIf value is NO then option --show-desktop=0 will be used to launch SALOME."))
os.makedirs(outtestbase)
#logger.write(" copy testbase %s\n" % testbase, 5)
- for module_ in [m for m in os.listdir(intestbase) if os.path.isdir(
+ for grid_ in [m for m in os.listdir(intestbase) if os.path.isdir(
os.path.join(intestbase, m))]:
# ignore source configuration directories
- if module_[:4] == '.git' or module_ == 'CVS':
+ if grid_[:4] == '.git' or grid_ == 'CVS':
continue
- outmodule = os.path.join(outtestbase, module_)
- inmodule = os.path.join(intestbase, module_)
- os.makedirs(outmodule)
- #logger.write(" copy module %s\n" % module_, 5)
+ outgrid = os.path.join(outtestbase, grid_)
+ ingrid = os.path.join(intestbase, grid_)
+ os.makedirs(outgrid)
+ #logger.write(" copy grid %s\n" % grid_, 5)
- if module_ == 'RESSOURCES':
- for file_name in os.listdir(inmodule):
- if not os.path.isfile(os.path.join(inmodule,
+ if grid_ == 'RESSOURCES':
+ for file_name in os.listdir(ingrid):
+ if not os.path.isfile(os.path.join(ingrid,
file_name)):
continue
- f = open(os.path.join(outmodule, file_name), "w")
- f.write(save_file(os.path.join(inmodule, file_name),
+ f = open(os.path.join(outgrid, file_name), "w")
+ f.write(save_file(os.path.join(ingrid, file_name),
finalPath))
f.close()
else:
- for type_name in [t for t in os.listdir(inmodule) if
- os.path.isdir(os.path.join(inmodule, t))]:
- outtype = os.path.join(outmodule, type_name)
- intype = os.path.join(inmodule, type_name)
- os.makedirs(outtype)
+ for session_name in [t for t in os.listdir(ingrid) if
+ os.path.isdir(os.path.join(ingrid, t))]:
+ outsession = os.path.join(outgrid, session_name)
+ insession = os.path.join(ingrid, session_name)
+ os.makedirs(outsession)
- for file_name in os.listdir(intype):
- if not os.path.isfile(os.path.join(intype,
+ for file_name in os.listdir(insession):
+ if not os.path.isfile(os.path.join(insession,
file_name)):
continue
if file_name.endswith('result.py'):
- shutil.copy2(os.path.join(intype, file_name),
- os.path.join(outtype, file_name))
+ shutil.copy2(os.path.join(insession, file_name),
+ os.path.join(outsession, file_name))
else:
- f = open(os.path.join(outtype, file_name), "w")
- f.write(save_file(os.path.join(intype,
+ f = open(os.path.join(outsession, file_name), "w")
+ f.write(save_file(os.path.join(insession,
file_name),
finalPath))
f.close()
gn = add_simple_node(tests, "testbase")
gn.attrib['name'] = testbase
nb, nb_pass, nb_failed, nb_timeout, nb_not_run = 0, 0, 0, 0, 0
- modules = {}
- types = {}
+ grids = {}
+ sessions = {}
for test in tt[testbase]:
- #print test.module
- if not modules.has_key(test.module):
- mn = add_simple_node(gn, "module")
- mn.attrib['name'] = test.module
- modules[test.module] = mn
+ #print test.grid
+ if not grids.has_key(test.grid):
+ mn = add_simple_node(gn, "grid")
+ mn.attrib['name'] = test.grid
+ grids[test.grid] = mn
- if not types.has_key("%s/%s" % (test.module, test.type)):
- tyn = add_simple_node(mn, "type")
- tyn.attrib['name'] = test.type
- types["%s/%s" % (test.module, test.type)] = tyn
+ if not sessions.has_key("%s/%s" % (test.grid, test.session)):
+ tyn = add_simple_node(mn, "session")
+ tyn.attrib['name'] = test.session
+ sessions["%s/%s" % (test.grid, test.session)] = tyn
for script in test.script:
- tn = add_simple_node(types[
- "%s/%s" % (test.module, test.type)], "test")
- tn.attrib['type'] = test.type
+ tn = add_simple_node(sessions[
+ "%s/%s" % (test.grid, test.session)], "test")
+ tn.attrib['session'] = test.session
tn.attrib['script'] = script.name
if 'callback' in script:
try:
if "amend" in script:
amend_test = add_simple_node(amend, "atest")
- amend_test.attrib['name'] = os.path.join(test.module,
- test.type,
+ amend_test.attrib['name'] = os.path.join(test.grid,
+ test.session,
script.name)
amend_test.attrib['reason'] = script.amend.decode(
"UTF-8")
if "known_error" in script:
kf_script = add_simple_node(known_errors, "error")
- kf_script.attrib['name'] = os.path.join(test.module,
- test.type,
+ kf_script.attrib['name'] = os.path.join(test.grid,
+ test.session,
script.name)
kf_script.attrib['date'] = script.known_error.date
kf_script.attrib[
elif script.res == src.KO_STATUS:
new_err = add_simple_node(new_errors, "new_error")
- script_path = os.path.join(test.module,
- test.type, script.name)
+ script_path = os.path.join(test.grid,
+ test.session, script.name)
new_err.attrib['name'] = script_path
new_err.attrib['cmd'] = ("sat testerror %s -s %s -c 'my"
" comment' -p %s" % \
logger,
base_dir,
testbase=test_base,
- modules=options.modules,
- types=options.types,
+ grids=options.grids,
+ sessions=options.sessions,
launcher=options.launcher,
show_desktop=show_desktop)
job)
opts2=$(echo --jobs_config --name $opts2)
;;
+ test)
+ opts2=$(echo --base --display --grid --launcher --session $opts2)
+ ;;
esac
COMPREPLY=( $(compgen -W "${opts2}" -- ${cur}) )
# first argument => show available commands
if [[ ${argc} == 1 ]]
then
- opts="config log testcommand source patch prepare environ clean configure make makeinstall compile launcher run jobs job shell --help"
+ opts="config log testcommand source patch prepare environ clean configure make makeinstall compile launcher run jobs job shell test --help"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
+ test)
+ opts="--base --launcher --grid --session --display"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
*) return 0 ;;
esac
+++ /dev/null
-#!/usr/bin/env python
-#-*- coding:utf-8 -*-
-
-import os, sys, traceback
-import os.path
-import time as THEBIGTIME
-
-# set path
-toolsWay = r'${toolsWay}'
-resourcesWay = r'${resourcesWay}'
-outWay = r'${typeDir}'
-tmpDir = r'${tmpDir}'
-
-listTest = ${listTest}
-ignore = ${ignore}
-
-sys.path.append(toolsWay)
-from TOOLS import TOOLS_class
-my_tools = TOOLS_class(resourcesWay, tmpDir, toolsWay)
-
-from TOOLS import SatNotApplicableError
-
-# on set les variables d'environement
-os.environ['TT_BASE_RESSOURCES'] = resourcesWay
-sys.path.append(resourcesWay)
-
-exec_result = open(r'${resultFile}', 'w')
-exec_result.write('Open\n')
-
-__stdout__ = sys.stdout
-__stderr__ = sys.stderr
-
-for test in listTest:
- pylog = open(os.path.join(outWay, test[:-3] + ".result.py"), "w")
- testout = open(os.path.join(outWay, test[:-3] + ".out.py"), "w")
- my_tools.init()
- sys.stdout = testout
- sys.stderr = testout
-
- pylog.write('#-*- coding:utf-8 -*-\n')
- exec_result.write("Run %s " % test)
- exec_result.flush()
-
- try:
- timeStart = THEBIGTIME.time()
- execfile(os.path.join(outWay, test), globals(), locals())
- timeTest = THEBIGTIME.time() - timeStart
- except SatNotApplicableError, ex:
- status = "NA"
- reason = str(ex)
- exec_result.write("NA\n")
- timeTest = THEBIGTIME.time() - timeStart
- pylog.write('status = "NA"\n')
- pylog.write('time = "' + timeTest.__str__() + '"\n')
- pylog.write('callback = "%s"\n' % reason)
- except Exception, ex:
- status = "KO"
- reason = ""
- if ignore.has_key(test):
- status = "KF"
- reason = "Known Failure = %s\n\n" % ignore[test]
- exec_result.write("%s\n" % status)
- timeTest = THEBIGTIME.time() - timeStart
- pylog.write('status = "%s" \n' % status)
- pylog.write('time = "' + timeTest.__str__() + '"\n')
- pylog.write('callback="""' + reason)
- exc_type, exc_value, exc_traceback = sys.exc_info()
- traceback.print_exception(exc_type,
- exc_value,
- exc_traceback,
- None,
- file=pylog)
- pylog.write('"""\n')
- else:
- exec_result.write("OK\n")
- pylog.write('status = "OK"\n')
- pylog.write('time = "' + timeTest.__str__() + '"\n')
-
- testout.close()
- sys.stdout = __stdout__
- sys.stderr = __stderr__
- my_tools.writeInFiles(pylog)
- pylog.close()
-
-exec_result.write('Close\n')
-exec_result.close()
-
-if 'PY' not in '${typeName}':
- import salome_utils
- killScript = os.path.join(os.environ['KERNEL_ROOT_DIR'],
- 'bin',
- 'salome',
- 'killSalome.py')
- cmd = '{python} {killScript} {port}'.format(python=os.environ['PYTHONBIN'],
- killScript=killScript,
- port=salome_utils.getPortNumber())
- os.system(cmd)
# set path
toolsWay = r'${toolsWay}'
resourcesWay = r'${resourcesWay}'
-outWay = r'${typeDir}'
+outWay = r'${sessionDir}'
tmpDir = r'${tmpDir}'
listTest = ${listTest}
exec_result.write('Close\n')
exec_result.close()
-if 'PY' not in '${typeName}':
+if 'PY' not in '${sessionName}':
import salome_utils
killScript = os.path.join(os.environ['KERNEL_ROOT_DIR'],
'bin',
from . import fork
import src
-# directories not considered as test modules
-C_IGNORE_MODULES = ['.git', '.svn', 'RESSOURCES']
-
-C_TESTS_LIGHT_FILE = "TestsLight.txt"
+# directories not considered as test grids
+C_IGNORE_GRIDS = ['.git', '.svn', 'RESSOURCES']
# Get directory to be used for the temporary files.
#
logger,
tmp_working_dir,
testbase="",
- modules=None,
- types=None,
+ grids=None,
+ sessions=None,
launcher="",
show_desktop=True):
- self.modules = modules
+ self.grids = grids
self.config = config
self.logger = logger
self.tmp_working_dir = tmp_working_dir
- self.types = types
+ self.sessions = sessions
self.launcher = launcher
self.show_desktop = show_desktop
##
# Searches if the script is declared in known errors pyconf.
# Update the status if needed.
- def search_known_errors(self, status, test_module, test_type, test):
- test_path = os.path.join(test_module, test_type, test)
+ def search_known_errors(self, status, test_grid, test_session, test):
+ test_path = os.path.join(test_grid, test_session, test)
if not src.config_has_application(self.config):
return status, []
results = {}
for test in listTest:
resfile = os.path.join(self.currentDir,
- self.currentModule,
- self.currentType,
+ self.currentgrid,
+ self.currentsession,
test[:-3] + ".result.py")
# check if <test>.result.py file exists
expected = []
if status == src.KO_STATUS or status == src.OK_STATUS:
status, expected = self.search_known_errors(status,
- self.currentModule,
- self.currentType,
+ self.currentgrid,
+ self.currentsession,
test)
callback = ""
# check if <test>.py file exists
testfile = os.path.join(self.currentDir,
- self.currentModule,
- self.currentType,
+ self.currentgrid,
+ self.currentsession,
test)
if not os.path.exists(testfile):
# check if <test>.out.py file exists
outfile = os.path.join(self.currentDir,
- self.currentModule,
- self.currentType,
+ self.currentgrid,
+ self.currentsession,
test[:-3] + ".out.py")
if not os.path.exists(outfile):
"test",
"scriptTemplate.py"), 'r')
template = string.Template(template_file.read())
-
+
# create substitution dictionary
d = dict()
d['resourcesWay'] = os.path.join(self.currentDir, 'RESSOURCES')
d['tmpDir'] = os.path.join(self.tmp_working_dir, 'WORK')
d['toolsWay'] = os.path.join(self.config.VARS.srcDir, "test")
- d['typeDir'] = os.path.join(self.currentDir,
- self.currentModule,
- self.currentType)
+ d['sessionDir'] = os.path.join(self.currentDir,
+ self.currentgrid,
+ self.currentsession)
d['resultFile'] = os.path.join(self.tmp_working_dir,
'WORK',
'exec_result')
d['listTest'] = listTest
- d['typeName'] = self.currentType
+ d['sessionName'] = self.currentsession
d['ignore'] = ignoreList
# create script with template
# Find the getTmpDir function that gives access to *pidict file directory.
# (the *pidict file exists when SALOME is launched)
def get_tmp_dir(self):
- # Rare case where there is no KERNEL in module list
+ # Rare case where there is no KERNEL in grid list
# (for example MED_STANDALONE)
if ('APPLICATION' in self.config
and 'KERNEL' not in self.config.APPLICATION.products
shell=True,
executable='/bin/bash').communicate()[0].split()[-1]
- # import module salome_utils from KERNEL that gives
+ # import grid salome_utils from KERNEL that gives
# the right getTmpDir function
(file_, pathname, description) = imp.find_module("salome_utils",
'bin',
'salome')])
try:
- module = imp.load_module("salome_utils",
+ grid = imp.load_module("salome_utils",
file_,
pathname,
description)
- return module.getLogDir
+ return grid.getLogDir
except:
- module = imp.load_module("salome_utils",
+ grid = imp.load_module("salome_utils",
file_,
pathname,
description)
- return module.getTmpDir
+ return grid.getTmpDir
finally:
if file_:
file_.close()
return default_value
- def generate_launching_commands(self, typename):
+ def generate_launching_commands(self):
# Case where "sat test" is launched in an existing SALOME environment
if 'KERNEL_ROOT_DIR' in os.environ:
binSalome = "runSalome"
binPython = "python"
killSalome = "killSalome.py"
- # Rare case where there is no KERNEL in module list
+ # Rare case where there is no KERNEL in grid list
# (for example MED_STANDALONE)
if ('APPLICATION' in self.config and
'KERNEL' not in self.config.APPLICATION.products):
# Case where SALOME has NOT the launcher that uses the SalomeContext API
if VersionSalome < 730:
- binSalome = os.path.join(self.config.APPLI.module_appli_install_dir,
+ binSalome = os.path.join(self.config.APPLI.grid_appli_install_dir,
appdir,
"runAppli")
binPython = "python"
##
- # Runs tests of a type (using a single instance of Salome).
+ # Runs tests of a session (using a single instance of Salome).
def run_tests(self, listTest, ignoreList):
out_path = os.path.join(self.currentDir,
- self.currentModule,
- self.currentType)
- typename = "%s/%s" % (self.currentModule, self.currentType)
- time_out = self.get_test_timeout(typename,
+ self.currentgrid,
+ self.currentsession)
+ sessionname = "%s/%s" % (self.currentgrid, self.currentsession)
+ time_out = self.get_test_timeout(sessionname,
self.config.SITE.test.timeout)
time_out_salome = src.get_cfg_param(self.config.SITE.test,
tmpDir = self.get_tmp_dir()
- binSalome, binPython, killSalome = self.generate_launching_commands(
- typename)
- if self.settings.has_key("run_with_modules") \
- and self.settings["run_with_modules"].has_key(typename):
+ binSalome, binPython, killSalome = self.generate_launching_commands()
+ if self.settings.has_key("run_with_grids") \
+ and self.settings["run_with_grids"].has_key(sessionname):
binSalome = (binSalome +
- " -m %s" % self.settings["run_with_modules"][typename])
+ " -m %s" % self.settings["run_with_grids"][sessionname])
logWay = os.path.join(self.tmp_working_dir, "WORK", "log_cxx")
status = False
elapsed = -1
- if self.currentType.startswith("NOGUI_"):
+ if self.currentsession.startswith("NOGUI_"):
# runSalome -t (bash)
status, elapsed = fork.batch(binSalome, self.logger,
os.path.join(self.tmp_working_dir,
delai=time_out,
log=logWay)
- elif self.currentType.startswith("PY_"):
+ elif self.currentsession.startswith("PY_"):
# python script.py
status, elapsed = fork.batch(binPython, self.logger,
os.path.join(self.tmp_working_dir,
# create the test result to add in the config object
test_info = src.pyconf.Mapping(self.config)
test_info.testbase = self.currentTestBase
- test_info.module = self.currentModule
- test_info.type = self.currentType
+ test_info.grid = self.currentgrid
+ test_info.session = self.currentsession
test_info.script = src.pyconf.Sequence(self.config)
script_results = self.read_results(listTest, elapsed == time_out)
self.config.TESTS.append(test_info, '')
##
- # Runs all tests of a type.
- def run_type_tests(self):
+ # Runs all tests of a session.
+ def run_session_tests(self):
self.logger.write(self.write_test_margin(2), 3)
- self.logger.write("Type = %s\n" % src.printcolors.printcLabel(
- self.currentType), 3, False)
+ self.logger.write("Session = %s\n" % src.printcolors.printcLabel(
+ self.currentsession), 3, False)
# prepare list of tests to run
tests = os.listdir(os.path.join(self.currentDir,
- self.currentModule,
- self.currentType))
+ self.currentgrid,
+ self.currentsession))
tests = filter(lambda l: l.endswith(".py"), tests)
tests = sorted(tests, key=str.lower)
# build list of known failures
- cat = "%s/%s/" % (self.currentModule, self.currentType)
+ cat = "%s/%s/" % (self.currentgrid, self.currentsession)
ignoreDict = {}
for k in self.ignore_tests.keys():
if k.startswith(cat):
self.run_tests(tests, ignoreDict)
##
- # Runs all tests of a module.
- def run_module_tests(self):
+ # Runs all tests of a grid.
+ def run_grid_tests(self):
self.logger.write(self.write_test_margin(1), 3)
- self.logger.write("Module = %s\n" % src.printcolors.printcLabel(
- self.currentModule), 3, False)
+ self.logger.write("grid = %s\n" % src.printcolors.printcLabel(
+ self.currentgrid), 3, False)
- module_path = os.path.join(self.currentDir, self.currentModule)
+ grid_path = os.path.join(self.currentDir, self.currentgrid)
- types = []
- if self.types is not None:
- types = self.types # user choice
+ sessions = []
+ if self.sessions is not None:
+ sessions = self.sessions # user choice
else:
- # use all scripts in module
- types = filter(lambda l: l not in C_IGNORE_MODULES,
- os.listdir(module_path))
- types = filter(lambda l: os.path.isdir(os.path.join(module_path,
- l)), types)
-
- types = sorted(types, key=str.lower)
- for type_ in types:
- if not os.path.exists(os.path.join(module_path, type_)):
+ # use all scripts in grid
+ sessions = filter(lambda l: l not in C_IGNORE_GRIDS,
+ os.listdir(grid_path))
+ sessions = filter(lambda l: os.path.isdir(os.path.join(grid_path,
+ l)), sessions)
+
+ sessions = sorted(sessions, key=str.lower)
+ for session_ in sessions:
+ if not os.path.exists(os.path.join(grid_path, session_)):
self.logger.write(self.write_test_margin(2), 3)
- self.logger.write(src.printcolors.printcWarning("Type %s not "
- "found" % type_) + "\n", 3, False)
+ self.logger.write(src.printcolors.printcWarning("Session %s not"
+ " found" % session_) + "\n", 3, False)
else:
- self.currentType = type_
- self.run_type_tests()
+ self.currentsession = session_
+ self.run_session_tests()
##
# Runs test testbase.
else:
self.known_errors = None
- if self.modules is not None:
- modules = self.modules # given by user
+ if self.grids is not None:
+ grids = self.grids # given by user
else:
- # select all the modules (i.e. directories) in the directory
- modules = filter(lambda l: l not in C_IGNORE_MODULES,
+ # select all the grids (i.e. directories) in the directory
+ grids = filter(lambda l: l not in C_IGNORE_GRIDS,
os.listdir(self.currentDir))
- modules = filter(lambda l: os.path.isdir(
+ grids = filter(lambda l: os.path.isdir(
os.path.join(self.currentDir, l)),
- modules)
+ grids)
- modules = sorted(modules, key=str.lower)
- for module in modules:
- if not os.path.exists(os.path.join(self.currentDir, module)):
+ grids = sorted(grids, key=str.lower)
+ for grid in grids:
+ if not os.path.exists(os.path.join(self.currentDir, grid)):
self.logger.write(self.write_test_margin(1), 3)
self.logger.write(src.printcolors.printcWarning(
- "Module %s does not exist\n" % module), 3, False)
+ "grid %s does not exist\n" % grid), 3, False)
else:
- self.currentModule = module
- self.run_module_tests()
+ self.currentgrid = grid
+ self.run_grid_tests()
def run_script(self, script_name):
if ('APPLICATION' in self.config and
<table>
<!-- Header -->
<tr bgcolor="#9acd32">
- <th width="150">module</th>
+ <th width="150">grid</th>
<th width="100">success</th>
<th width="200"></th>
<th width="100">total</th>
<th width="100">Time</th>
</tr>
- <xsl:for-each select="./module">
+ <xsl:for-each select="./grid">
<xsl:variable name="total" select="count(.//test)"/>
<xsl:variable name="failureCount" select="count(.//test[@res='KO'])"/>
<xsl:variable name="successCount" select="count(.//test[@res='OK'])"/>
<br/>
<!-- Show details -->
- <xsl:for-each select="./module">
+ <xsl:for-each select="./grid">
<xsl:sort select="@name" />
- <xsl:sort select="@type" />
+ <xsl:sort select="@session" />
<div style="display:none" name="mod"><xsl:attribute name="id">mod_<xsl:value-of select="../@name"/>.<xsl:value-of select="@name"/></xsl:attribute>
- Tests of module <b><xsl:value-of select="@name"/></b>
+ Tests of grid <b><xsl:value-of select="@name"/></b>
<table width="100%">
<tr bgcolor="#9acd32">
- <th width="100">type</th>
+ <th width="100">session</th>
<th>script</th>
<th width="100">result</th>
<th width="100">time</th>
</tr>
- <xsl:for-each select="./type">
+ <xsl:for-each select="./session">
<xsl:sort select="@name" />
<tr>
</div>
</xsl:for-each>
- <xsl:for-each select="./module">
- <xsl:for-each select="./type">
+ <xsl:for-each select="./grid">
+ <xsl:for-each select="./session">
<xsl:for-each select="./test">
<div style="display:none" name="text"><xsl:attribute name="id"><xsl:value-of select="@script"/></xsl:attribute>
<PRE><xsl:value-of select="./content"/></PRE>