3 # Copyright (C) 2010-2013 CEA/DEN
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 import os, sys, datetime, shutil, string
24 # directories not considered as test modules
25 C_IGNORE_MODULES = ['.git', '.svn', 'RESSOURCES']
27 C_TESTS_SOURCE_DIR = "Tests"
28 C_TESTS_LIGHT_FILE = "TestsLight.txt"
30 # Get directory to be used for the temporary files.
32 def getTmpDirDEFAULT():
33 if src.architecture.is_windows():
34 directory = os.getenv("TEMP")
36 # for Linux: use /tmp/logs/{user} folder
37 directory = os.path.join( '/tmp', 'logs', os.getenv("USER", "unknown"))
53 self.modules = modules
56 self.sessionDir = sessionDir
61 self.show_desktop = show_desktop
65 self.logger.write("\n", 3, False)
66 self.prepare_grid_from_dir("DIR", self.dir)
67 self.currentGrid = "DIR"
69 self.prepare_grid(grid)
72 self.known_errors = None
74 # create section for results
75 self.config.TESTS = src.pyconf.Sequence(self.config)
81 self.nb_acknoledge = 0
83 def _copy_dir(self, source, target):
84 if self.config.VARS.python >= "2.6":
85 shutil.copytree(source, target,
87 ignore=shutil.ignore_patterns('.git*','.svn*'))
89 shutil.copytree(source, target,
92 def prepare_grid_from_dir(self, grid_name, grid_dir):
93 self.logger.write(_("get grid from dir: %s\n") % src.printcolors.printcLabel(grid_dir), 3)
94 if not os.access(grid_dir, os.X_OK):
95 raise src.SatException(_("testbase %(name)s (%(dir)s) does not exist ...\n") % \
96 { 'name': grid_name, 'dir': grid_dir })
98 self._copy_dir(grid_dir, os.path.join(self.sessionDir, 'BASES', grid_name))
100 def prepare_grid_from_git(self, grid_name, grid_base, grid_tag):
102 _("get grid '%(grid)s' with '%(tag)s' tag from git\n") % {
103 "grid" : src.printcolors.printcLabel(grid_name),
104 "tag" : src.printcolors.printcLabel(grid_tag)},
107 def set_signal(): # pragma: no cover
108 """see http://bugs.python.org/issue1652"""
110 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
112 cmd = "git clone --depth 1 %(base)s %(dir)s"
113 cmd += " && cd %(dir)s"
114 if grid_tag=='master':
115 cmd += " && git fetch origin %(branch)s"
117 cmd += " && git fetch origin %(branch)s:%(branch)s"
118 cmd += " && git checkout %(branch)s"
119 cmd = cmd % { 'branch': grid_tag, 'base': grid_base, 'dir': grid_name }
121 self.logger.write("> %s\n" % cmd, 5)
122 if src.architecture.is_windows():
123 # preexec_fn not supported on windows platform
124 res = subprocess.call(cmd,
125 cwd=os.path.join(self.sessionDir, 'BASES'),
127 stdout=self.logger.logTxtFile,
128 stderr=subprocess.PIPE)
130 res = subprocess.call(cmd,
131 cwd=os.path.join(self.sessionDir, 'BASES'),
133 preexec_fn=set_signal,
134 stdout=self.logger.logTxtFile,
135 stderr=subprocess.PIPE)
137 raise src.SatException(_("Error: unable to get test base '%(name)s' from git '%(repo)s'.") % \
138 { 'name': grid_name, 'repo': grid_base })
141 self.logger.error(_("git is not installed. exiting...\n"))
144 def prepare_grid_from_svn(self, user, grid_name, grid_base):
145 self.logger.write(_("get grid '%s' from svn\n") % src.printcolors.printcLabel(grid_name), 3)
147 def set_signal(): # pragma: no cover
148 """see http://bugs.python.org/issue1652"""
150 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
152 cmd = "svn checkout --username %(user)s %(base)s %(dir)s"
153 cmd = cmd % { 'user': user, 'base': grid_base, 'dir': grid_name }
155 self.logger.write("> %s\n" % cmd, 5)
156 if src.architecture.is_windows():
157 # preexec_fn not supported on windows platform
158 res = subprocess.call(cmd,
159 cwd=os.path.join(self.sessionDir, 'BASES'),
161 stdout=self.logger.logTxtFile,
162 stderr=subprocess.PIPE)
164 res = subprocess.call(cmd,
165 cwd=os.path.join(self.sessionDir, 'BASES'),
167 preexec_fn=set_signal,
168 stdout=self.logger.logTxtFile,
169 stderr=subprocess.PIPE)
172 raise src.SatException(_("Error: unable to get test base '%(nam"
173 "e)s' from svn '%(repo)s'.") % \
174 { 'name': grid_name, 'repo': grid_base })
177 self.logger.error(_("svn is not installed. exiting...\n"))
181 # Configure tests base.
182 def prepare_grid(self, grid_name):
183 src.printcolors.print_value(self.logger,
187 self.logger.write("\n", 3, False)
189 # search for the grid
190 test_base_info = None
191 for project_name in self.config.PROJECTS.projects:
192 project_info = self.config.PROJECTS.projects[project_name]
193 for t_b_info in project_info.test_bases:
194 if t_b_info.name == grid_name:
195 test_base_info = t_b_info
197 if not test_base_info:
198 message = _("########## WARNING: grid '%s' not found\n") % grid_name
199 raise src.SatException(message)
201 if test_base_info.get_sources == "dir":
202 self.prepare_grid_from_dir(grid_name, test_base_info.info.dir)
203 elif test_base_info.get_sources == "git":
204 self.prepare_grid_from_git(grid_name,
205 test_base_info.info.base,
206 self.config.APPLICATION.test_base.tag)
207 elif test_base_info.get_sources == "svn":
208 svn_user = src.get_cfg_param(test_base_info.svn_info,
210 self.config.USER.svn_user)
211 self.prepare_grid_from_svn(svn_user,
213 test_base_info.info.base)
215 raise src.SatException(_("unknown source type '%(type)s' for testb"
216 "ase '%(grid)s' ...\n") % {
217 'type': test_base_info.get_sources,
220 self.currentGrid = grid_name
223 # Searches if the script is declared in known errors pyconf.
224 # Update the status if needed.
225 def search_known_errors(self, status, test_module, test_type, test):
226 test_path = os.path.join(test_module, test_type, test)
227 if not src.config_has_application(self.config):
230 if self.known_errors is None:
233 platform = self.config.VARS.arch
234 application = self.config.VARS.application
235 error = self.known_errors.get_error(test_path, application, platform)
239 if status == src.OK_STATUS:
242 self.known_errors.fix_error(error)
244 #testerror.write_test_failures(
245 # self.config.TOOLS.testerror.file_path,
246 # self.known_errors.errors)
247 return status, [ error.date,
253 self.known_errors.unfix_error(error)
255 #testerror.write_test_failures(self.config.TOOLS.testerror.file_path,
256 # self.known_errors.errors)
258 delta = self.known_errors.get_expecting_days(error)
259 kfres = [ error.date, error.expected, error.comment, error.fixed ]
261 return src.KO_STATUS, kfres
262 return src.KNOWNFAILURE_STATUS, kfres
265 # Read the *.result.py files.
266 def read_results(self, listTest, has_timed_out):
268 for test in listTest:
269 resfile = os.path.join(self.currentDir,
272 test[:-3] + ".result.py")
274 # check if <test>.result.py file exists
275 if not os.path.exists(resfile):
276 results[test] = ["?", -1, "", []]
279 execfile(resfile, gdic, ldic)
281 status = src.TIMEOUT_STATUS
282 if not has_timed_out:
283 status = src.KO_STATUS
285 if ldic.has_key('status'):
286 status = ldic['status']
289 if status == src.KO_STATUS or status == src.OK_STATUS:
290 status, expected = self.search_known_errors(status,
296 if ldic.has_key('callback'):
297 callback = ldic['callback']
298 elif status == src.KO_STATUS:
302 if ldic.has_key('time'):
304 exec_time = float(ldic['time'])
308 results[test] = [status, exec_time, callback, expected]
313 # Generates the script to be run by Salome.
314 # This python script includes init and close statements and a loop
315 # calling all the scripts of a single directory.
316 def generate_script(self, listTest, script_path, ignoreList):
318 template_file = open(os.path.join(self.config.VARS.srcDir,
320 "scriptTemplate.py"), 'r')
321 template = string.Template(template_file.read())
323 # create substitution dictionary
325 d['resourcesWay'] = os.path.join(self.currentDir, 'RESSOURCES')
326 d['tmpDir'] = os.path.join(self.sessionDir, 'WORK')
327 d['toolsWay'] = os.path.join(self.config.VARS.srcDir, "test")
328 d['typeDir'] = os.path.join(self.currentDir,
331 d['resultFile'] = os.path.join(self.sessionDir, 'WORK', 'exec_result')
332 d['listTest'] = listTest
333 d['typeName'] = self.currentType
334 d['ignore'] = ignoreList
336 # create script with template
337 script = open(script_path, 'w')
338 script.write(template.safe_substitute(d))
341 # Find the getTmpDir function that gives access to *pidict file directory.
342 # (the *pidict file exists when SALOME is launched)
343 def get_tmp_dir(self):
344 # Rare case where there is no KERNEL in module list
345 # (for example MED_STANDALONE)
346 if ('APPLICATION' in self.config
347 and 'KERNEL' not in self.config.APPLICATION.products
348 and 'KERNEL_ROOT_DIR' not in os.environ):
349 return getTmpDirDEFAULT
351 # Case where "sat test" is launched in an existing SALOME environment
352 if 'KERNEL_ROOT_DIR' in os.environ:
353 root_dir = os.environ['KERNEL_ROOT_DIR']
355 if ('APPLICATION' in self.config
356 and 'KERNEL' in self.config.APPLICATION.products):
357 root_dir = src.product.get_product_config(self.config,
358 "KERNEL").install_dir
360 # Case where there the appli option is called (with path to launcher)
361 if len(self.appli) > 0:
362 # There are two cases : The old application (runAppli)
364 launcherName = os.path.basename(self.appli)
365 launcherDir = os.path.dirname(self.appli)
366 if launcherName == 'runAppli':
368 cmd = "for i in " + launcherDir + "/env.d/*.sh; do source ${i};"
369 " done ; echo $KERNEL_ROOT_DIR"
372 cmd = "echo -e 'import os\nprint os.environ[\"KERNEL_ROOT_DIR\""
373 "]' > tmpscript.py; %s shell tmpscript.py" % self.appli
374 root_dir = subprocess.Popen(cmd,
375 stdout=subprocess.PIPE,
377 executable='/bin/bash').communicate()[0].split()[-1]
379 # import module salome_utils from KERNEL that gives
380 # the right getTmpDir function
382 (file_, pathname, description) = imp.find_module("salome_utils",
383 [os.path.join(root_dir,
387 module = imp.load_module("salome_utils",
391 return module.getLogDir
393 module = imp.load_module("salome_utils",
397 return module.getTmpDir
403 def get_test_timeout(self, test_name, default_value):
404 if (self.settings.has_key("timeout") and
405 self.settings["timeout"].has_key(test_name)):
406 return self.settings["timeout"][test_name]
410 def generate_launching_commands(self, typename):
411 # Case where "sat test" is launched in an existing SALOME environment
412 if 'KERNEL_ROOT_DIR' in os.environ:
413 binSalome = "runSalome"
415 killSalome = "killSalome.py"
417 # Rare case where there is no KERNEL in module list
418 # (for example MED_STANDALONE)
419 if ('APPLICATION' in self.config and
420 'KERNEL' not in self.config.APPLICATION.products):
421 binSalome = "runSalome"
423 killSalome = "killSalome.py"
424 src.environment.load_environment(self.config, False, self.logger)
425 return binSalome, binPython, killSalome
427 # Case where there the appli option is called (with path to launcher)
428 if len(self.appli) > 0:
429 # There are two cases : The old application (runAppli)
431 launcherName = os.path.basename(self.appli)
432 launcherDir = os.path.dirname(self.appli)
433 if launcherName == 'runAppli':
435 binSalome = self.appli
436 binPython = ("for i in " +
438 "/env.d/*.sh; do source ${i}; done ; python")
439 killSalome = ("for i in " +
441 "/env.d/*.sh; do source ${i}; done ; killSalome.py'")
442 return binSalome, binPython, killSalome
445 binSalome = self.appli
446 binPython = self.appli + ' shell'
447 killSalome = self.appli + ' killall'
448 return binSalome, binPython, killSalome
450 # SALOME version detection and APPLI repository detection
451 VersionSalome = src.get_salome_version(self.config)
453 if "APPLI" in self.config and "application_name" in self.config.APPLI:
454 appdir = self.config.APPLI.application_name
456 # Case where SALOME has NOT the launcher that uses the SalomeContext API
457 if VersionSalome < 730:
458 binSalome = os.path.join(self.config.APPLI.module_appli_install_dir,
462 killSalome = "killSalome.py"
463 src.environment.load_environment(self.config, False, self.logger)
464 return binSalome, binPython, killSalome
466 # Case where SALOME has the launcher that uses the SalomeContext API
467 if VersionSalome >= 730:
468 if 'profile' not in self.config.APPLICATION:
469 # Before revision of application concept
470 launcher_name = self.config.APPLI.launch_alias_name
471 binSalome = os.path.join(self.config.APPLICATION.workdir,
475 # After revision of application concept
476 launcher_name = self.config.APPLICATION.profile.launcher_name
477 binSalome = os.path.join(self.config.APPLICATION.workdir,
480 if src.architecture.is_windows():
483 binPython = binSalome + ' shell'
484 killSalome = binSalome + ' killall'
485 return binSalome, binPython, killSalome
487 return binSalome, binPython, killSalome
491 # Runs tests of a type (using a single instance of Salome).
492 def run_tests(self, listTest, ignoreList):
493 out_path = os.path.join(self.currentDir,
496 typename = "%s/%s" % (self.currentModule, self.currentType)
497 time_out = self.get_test_timeout(typename,
498 self.config.SITE.test.timeout)
500 time_out_salome = src.get_cfg_param(self.config.SITE.test,
502 self.config.SITE.test.timeout)
504 # generate wrapper script
505 script_path = os.path.join(out_path, 'wrapperScript.py')
506 self.generate_script(listTest, script_path, ignoreList)
508 tmpDir = self.get_tmp_dir()
510 binSalome, binPython, killSalome = self.generate_launching_commands(
512 if self.settings.has_key("run_with_modules") \
513 and self.settings["run_with_modules"].has_key(typename):
514 binSalome = (binSalome +
515 " -m %s" % self.settings["run_with_modules"][typename])
517 logWay = os.path.join(self.sessionDir, "WORK", "log_cxx")
521 if self.currentType.startswith("NOGUI_"):
522 # runSalome -t (bash)
523 status, ellapsed = fork.batch(binSalome, self.logger,
524 os.path.join(self.sessionDir, "WORK"),
526 "--shutdown-server=1",
531 elif self.currentType.startswith("PY_"):
533 status, ellapsed = fork.batch(binPython, self.logger,
534 os.path.join(self.sessionDir, "WORK"),
536 delai=time_out, log=logWay)
540 if self.show_desktop: opt = "--show-desktop=0"
541 status, ellapsed = fork.batch_salome(binSalome,
543 os.path.join(self.sessionDir,
546 "--shutdown-server=1",
552 delaiapp=time_out_salome)
554 self.logger.write("status = %s, ellapsed = %s\n" % (status, ellapsed),
557 # create the test result to add in the config object
558 test_info = src.pyconf.Mapping(self.config)
559 test_info.grid = self.currentGrid
560 test_info.module = self.currentModule
561 test_info.type = self.currentType
562 test_info.script = src.pyconf.Sequence(self.config)
564 script_results = self.read_results(listTest, ellapsed == time_out)
565 for sr in sorted(script_results.keys()):
568 # create script result
569 script_info = src.pyconf.Mapping(self.config)
570 script_info.name = sr
571 script_info.res = script_results[sr][0]
572 script_info.time = script_results[sr][1]
573 if script_info.res == src.TIMEOUT_STATUS:
574 script_info.time = time_out
575 if script_info.time < 1e-3: script_info.time = 0
577 callback = script_results[sr][2]
578 if script_info.res != src.OK_STATUS and len(callback) > 0:
579 script_info.callback = callback
581 kfres = script_results[sr][3]
583 script_info.known_error = src.pyconf.Mapping(self.config)
584 script_info.known_error.date = kfres[0]
585 script_info.known_error.expected = kfres[1]
586 script_info.known_error.comment = kfres[2]
587 script_info.known_error.fixed = kfres[3]
589 # add it to the list of results
590 test_info.script.append(script_info, '')
592 # display the results
593 if script_info.time > 0:
594 exectime = "(%7.3f s)" % script_info.time
598 sp = "." * (35 - len(script_info.name))
599 self.logger.write(self.write_test_margin(3), 3)
600 self.logger.write("script %s %s %s %s\n" % (
601 src.printcolors.printcLabel(script_info.name),
603 src.printcolors.printc(script_info.res),
605 if script_info and len(callback) > 0:
606 self.logger.write("Exception in %s\n%s\n" % \
608 src.printcolors.printcWarning(callback)), 2, False)
610 if script_info.res == src.OK_STATUS:
612 elif script_info.res == src.KNOWNFAILURE_STATUS:
613 self.nb_acknoledge += 1
614 elif script_info.res == src.TIMEOUT_STATUS:
616 elif script_info.res == src.NA_STATUS:
618 elif script_info.res == "?":
621 self.config.TESTS.append(test_info, '')
624 # Runs all tests of a type.
625 def run_type_tests(self, light_test):
627 if not any(map(lambda l: l.startswith(self.currentType),
629 # no test to run => skip
632 self.logger.write(self.write_test_margin(2), 3)
633 self.logger.write("Type = %s\n" % src.printcolors.printcLabel(
634 self.currentType), 3, False)
636 # prepare list of tests to run
637 tests = os.listdir(os.path.join(self.currentDir,
640 tests = filter(lambda l: l.endswith(".py"), tests)
641 tests = sorted(tests, key=str.lower)
644 tests = filter(lambda l: os.path.join(self.currentType,
645 l) in light_test, tests)
647 # build list of known failures
648 cat = "%s/%s/" % (self.currentModule, self.currentType)
650 for k in self.ignore_tests.keys():
651 if k.startswith(cat):
652 ignoreDict[k[len(cat):]] = self.ignore_tests[k]
654 self.run_tests(tests, ignoreDict)
657 # Runs all tests of a module.
658 def run_module_tests(self):
659 self.logger.write(self.write_test_margin(1), 3)
660 self.logger.write("Module = %s\n" % src.printcolors.printcLabel(
661 self.currentModule), 3, False)
663 module_path = os.path.join(self.currentDir, self.currentModule)
666 if self.types is not None:
667 types = self.types # user choice
669 # use all scripts in module
670 types = filter(lambda l: l not in C_IGNORE_MODULES,
671 os.listdir(module_path))
672 types = filter(lambda l: os.path.isdir(os.path.join(module_path,
675 # in batch mode keep only modules with NOGUI or PY
676 if self.mode == "batch":
677 types = filter(lambda l: ("NOGUI" in l or "PY" in l), types)
681 light_path = os.path.join(module_path, C_TESTS_LIGHT_FILE)
682 if not os.path.exists(light_path):
684 msg = src.printcolors.printcWarning(_("List of light tests not"
685 " found: %s") % light_path)
686 self.logger.write(msg + "\n")
689 light_file = open(light_path, "r")
690 light_test = map(lambda l: l.strip(), light_file.readlines())
692 types = sorted(types, key=str.lower)
694 if not os.path.exists(os.path.join(module_path, type_)):
695 self.logger.write(self.write_test_margin(2), 3)
696 self.logger.write(src.printcolors.printcWarning("Type %s not "
697 "found" % type_) + "\n", 3, False)
699 self.currentType = type_
700 self.run_type_tests(light_test)
704 def run_grid_tests(self):
705 res_dir = os.path.join(self.currentDir, "RESSOURCES")
706 os.environ['PYTHONPATH'] = (res_dir +
708 os.environ['PYTHONPATH'])
709 os.environ['TT_BASE_RESSOURCES'] = res_dir
710 src.printcolors.print_value(self.logger,
711 "TT_BASE_RESSOURCES",
714 self.logger.write("\n", 4, False)
716 self.logger.write(self.write_test_margin(0), 3)
717 grid_label = "Grid = %s\n" % src.printcolors.printcLabel(
719 self.logger.write(grid_label, 3, False)
720 self.logger.write("-" * len(src.printcolors.cleancolor(grid_label)), 3)
721 self.logger.write("\n", 3, False)
724 settings_file = os.path.join(res_dir, "test_settings.py")
725 if os.path.exists(settings_file):
727 execfile(settings_file, gdic, ldic)
728 self.logger.write(_("Load test settings\n"), 3)
729 self.settings = ldic['settings_dic']
730 self.ignore_tests = ldic['known_failures_list']
731 if isinstance(self.ignore_tests, list):
732 self.ignore_tests = {}
733 self.logger.write(src.printcolors.printcWarning("known_failur"
734 "es_list must be a dictionary (not a list)") + "\n", 1, False)
736 self.ignore_tests = {}
737 self.settings.clear()
739 # read known failures pyconf
740 if "testerror" in self.config.SITE:
742 #self.known_errors = testerror.read_test_failures(
743 # self.config.TOOLS.testerror.file_path,
747 self.known_errors = None
749 if self.modules is not None:
750 modules = self.modules # given by user
752 # select all the modules (i.e. directories) in the directory
753 modules = filter(lambda l: l not in C_IGNORE_MODULES,
754 os.listdir(self.currentDir))
755 modules = filter(lambda l: os.path.isdir(
756 os.path.join(self.currentDir, l)),
759 modules = sorted(modules, key=str.lower)
760 for module in modules:
761 if not os.path.exists(os.path.join(self.currentDir, module)):
762 self.logger.write(self.write_test_margin(1), 3)
763 self.logger.write(src.printcolors.printcWarning(
764 "Module %s does not exist\n" % module), 3, False)
766 self.currentModule = module
767 self.run_module_tests()
769 def run_script(self, script_name):
770 if 'APPLICATION' in self.config and script_name in self.config.APPLICATION:
771 script = self.config.APPLICATION[script_name]
775 self.logger.write("\n", 2, False)
776 if not os.path.exists(script):
777 self.logger.write(src.printcolors.printcWarning("WARNING: scrip"
778 "t not found: %s" % script) + "\n", 2)
780 self.logger.write(src.printcolors.printcHeader("----------- sta"
781 "rt %s" % script_name) + "\n", 2)
782 self.logger.write("Run script: %s\n" % script, 2)
783 subprocess.Popen(script, shell=True).wait()
784 self.logger.write(src.printcolors.printcHeader("----------- end"
785 " %s" % script_name) + "\n", 2)
787 def run_all_tests(self, session_name=""):
788 initTime = datetime.datetime.now()
790 self.run_script('test_setup')
791 self.logger.write("\n", 2, False)
793 self.logger.write(src.printcolors.printcHeader(
794 _("=== STARTING TESTS")) + "\n", 2)
795 self.logger.write("\n", 2, False)
796 self.currentDir = os.path.join(self.sessionDir,
799 self.run_grid_tests()
801 # calculate total execution time
802 totalTime = datetime.datetime.now() - initTime
803 totalTime -= datetime.timedelta(microseconds=totalTime.microseconds)
804 self.logger.write("\n", 2, False)
805 self.logger.write(src.printcolors.printcHeader(_("=== END TESTS")), 2)
806 self.logger.write(" %s\n" % src.printcolors.printcInfo(str(totalTime)),
813 self.run_script('test_cleanup')
814 self.logger.write("\n", 2, False)
817 res_count = "%d / %d" % (self.nb_succeed,
818 self.nb_run - self.nb_acknoledge)
820 res_out = _("Tests Results: %(succeed)d / %(total)d\n") % \
821 { 'succeed': self.nb_succeed, 'total': self.nb_run }
822 if self.nb_succeed == self.nb_run:
823 res_out = src.printcolors.printcSuccess(res_out)
825 res_out = src.printcolors.printcError(res_out)
826 self.logger.write(res_out, 1)
828 if self.nb_timeout > 0:
829 self.logger.write(_("%d tests TIMEOUT\n") % self.nb_timeout, 1)
830 res_count += " TO: %d" % self.nb_timeout
831 if self.nb_not_run > 0:
832 self.logger.write(_("%d tests not executed\n") % self.nb_not_run, 1)
833 res_count += " NR: %d" % self.nb_not_run
835 status = src.OK_STATUS
836 if self.nb_run - self.nb_succeed - self.nb_acknoledge > 0:
837 status = src.KO_STATUS
838 elif self.nb_acknoledge:
839 status = src.KNOWNFAILURE_STATUS
841 self.logger.write(_("Status: %s\n" % status), 3)
843 if session_name is not None and len(session_name) > 0:
844 self.config.RESULTS.test["session"] = session_name
846 return self.nb_run - self.nb_succeed - self.nb_acknoledge
849 # Write margin to show test results.
850 def write_test_margin(self, tab):
853 return "| " * (tab - 1) + "+ "