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 # Python 2/3 compatibility for execfile function
23 def execfile(somefile, global_vars, local_vars):
24 with open(somefile) as f:
25 code = compile(f.read(), somefile, 'exec')
26 exec(code, global_vars, local_vars)
40 # directories not considered as test grids
41 C_IGNORE_GRIDS = ['.git', '.svn', 'RESSOURCES']
45 # Get directory to be used for the temporary files.
47 def getTmpDirDEFAULT():
48 if src.architecture.is_windows():
49 directory = os.getenv("TEMP")
51 # for Linux: use /tmp/logs/{user} folder
52 directory = os.path.join( '/tmp', 'logs', os.getenv("USER", "unknown"))
68 self.tmp_working_dir = tmp_working_dir
69 self.sessions = sessions
70 self.launcher = launcher
71 self.show_desktop = show_desktop
73 res = self.prepare_testbase(testbase)
74 self.test_base_found = True
77 self.test_base_found = False
80 self.known_errors = None
82 # create section for results
83 self.config.TESTS = src.pyconf.Sequence(self.config)
89 self.nb_acknoledge = 0
91 def _copy_dir(self, source, target):
92 if self.config.VARS.python >= "2.6":
93 shutil.copytree(source, target,
95 ignore=shutil.ignore_patterns('.git*','.svn*'))
97 shutil.copytree(source, target,
100 def prepare_testbase_from_dir(self, testbase_name, testbase_dir):
101 self.logger.write(_("get test base from dir: %s\n") % \
102 src.printcolors.printcLabel(testbase_dir), 3)
103 if not os.access(testbase_dir, os.X_OK):
104 raise src.SatException(_("testbase %(name)s (%(dir)s) does not "
105 "exist ...\n") % { 'name': testbase_name,
106 'dir': testbase_dir })
108 self._copy_dir(testbase_dir,
109 os.path.join(self.tmp_working_dir, 'BASES', testbase_name))
111 def prepare_testbase_from_git(self,
116 _("get test base '%(testbase)s' with '%(tag)s' tag from git\n") % {
117 "testbase" : src.printcolors.printcLabel(testbase_name),
118 "tag" : src.printcolors.printcLabel(testbase_tag)},
121 def set_signal(): # pragma: no cover
122 """see http://bugs.python.org/issue1652"""
124 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
126 cmd = "git clone --depth 1 %(base)s %(dir)s"
127 cmd += " && cd %(dir)s"
128 if testbase_tag=='master':
129 cmd += " && git fetch origin %(branch)s"
131 cmd += " && git fetch origin %(branch)s:%(branch)s"
132 cmd += " && git checkout %(branch)s"
133 cmd = cmd % { 'branch': testbase_tag,
134 'base': testbase_base,
135 'dir': testbase_name }
137 self.logger.write("> %s\n" % cmd, 5)
138 if src.architecture.is_windows():
139 # preexec_fn not supported on windows platform
140 res = subprocess.call(cmd,
141 cwd=os.path.join(self.tmp_working_dir, 'BASES'),
143 stdout=self.logger.logTxtFile,
144 stderr=subprocess.PIPE)
146 res = subprocess.call(cmd,
147 cwd=os.path.join(self.tmp_working_dir, 'BASES'),
149 preexec_fn=set_signal,
150 stdout=self.logger.logTxtFile,
151 stderr=subprocess.PIPE)
153 raise src.SatException(_("Error: unable to get test base "
154 "'%(name)s' from git '%(repo)s'.") % \
155 { 'name': testbase_name,
156 'repo': testbase_base })
159 self.logger.error(_("git is not installed. exiting...\n"))
162 def prepare_testbase_from_svn(self, user, testbase_name, testbase_base):
163 self.logger.write(_("get test base '%s' from svn\n") % \
164 src.printcolors.printcLabel(testbase_name), 3)
166 def set_signal(): # pragma: no cover
167 """see http://bugs.python.org/issue1652"""
169 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
171 cmd = "svn checkout --username %(user)s %(base)s %(dir)s"
172 cmd = cmd % { 'user': user,
173 'base': testbase_base,
174 'dir': testbase_name }
176 # Get the application environment
177 self.logger.write(_("Set the application environment\n"), 5)
178 env_appli = src.environment.SalomeEnviron(self.config,
179 src.environment.Environ(dict(os.environ)))
180 env_appli.set_application_env(self.logger)
182 self.logger.write("> %s\n" % cmd, 5)
183 if src.architecture.is_windows():
184 # preexec_fn not supported on windows platform
185 res = subprocess.call(cmd,
186 cwd=os.path.join(self.tmp_working_dir, 'BASES'),
188 stdout=self.logger.logTxtFile,
189 stderr=subprocess.PIPE)
191 res = subprocess.call(cmd,
192 cwd=os.path.join(self.tmp_working_dir, 'BASES'),
194 preexec_fn=set_signal,
195 stdout=self.logger.logTxtFile,
196 stderr=subprocess.PIPE,
197 env=env_appli.environ.environ,)
200 raise src.SatException(_("Error: unable to get test base '%(nam"
201 "e)s' from svn '%(repo)s'.") % \
202 { 'name': testbase_name,
203 'repo': testbase_base })
206 self.logger.error(_("svn is not installed. exiting...\n"))
210 # Configure tests base.
211 def prepare_testbase(self, test_base_name):
212 src.printcolors.print_value(self.logger,
216 self.logger.write("\n", 3, False)
218 # search for the test base
219 test_base_info = None
220 for project_name in self.config.PROJECTS.projects:
221 project_info = self.config.PROJECTS.projects[project_name]
222 if "test_bases" not in project_info:
224 for t_b_info in project_info.test_bases:
225 if t_b_info.name == test_base_name:
226 test_base_info = t_b_info
228 if not test_base_info:
229 if os.path.exists(test_base_name):
230 self.prepare_testbase_from_dir("DIR", test_base_name)
231 self.currentTestBase = "DIR"
234 if not test_base_info:
235 message = (_("########## ERROR: test base '%s' not found\n") %
237 self.logger.write("%s\n" % src.printcolors.printcError(message))
240 if test_base_info.get_sources == "dir":
241 self.prepare_testbase_from_dir(test_base_name,
242 test_base_info.info.dir)
243 elif test_base_info.get_sources == "git":
244 self.prepare_testbase_from_git(test_base_name,
245 test_base_info.info.base,
246 self.config.APPLICATION.test_base.tag)
247 elif test_base_info.get_sources == "svn":
248 svn_user = src.get_cfg_param(test_base_info.info,
250 self.config.USER.svn_user)
251 self.prepare_testbase_from_svn(svn_user,
253 test_base_info.info.base)
255 raise src.SatException(_("unknown source type '%(type)s' for test b"
256 "ase '%(base)s' ...\n") % {
257 'type': test_base_info.get_sources,
258 'base': test_base_name })
260 self.currentTestBase = test_base_name
263 # Searches if the script is declared in known errors pyconf.
264 # Update the status if needed.
265 def search_known_errors(self, status, test_grid, test_session, test):
266 test_path = os.path.join(test_grid, test_session, test)
267 if not src.config_has_application(self.config):
270 if self.known_errors is None:
273 platform = self.config.VARS.arch
274 application = self.config.VARS.application
275 error = self.known_errors.get_error(test_path, application, platform)
279 if status == src.OK_STATUS:
282 self.known_errors.fix_error(error)
284 #testerror.write_test_failures(
285 # self.config.TOOLS.testerror.file_path,
286 # self.known_errors.errors)
287 return status, [ error.date,
293 self.known_errors.unfix_error(error)
295 #testerror.write_test_failures(self.config.TOOLS.testerror.file_path,
296 # self.known_errors.errors)
298 delta = self.known_errors.get_expecting_days(error)
299 kfres = [ error.date, error.expected, error.comment, error.fixed ]
301 return src.KO_STATUS, kfres
302 return src.KNOWNFAILURE_STATUS, kfres
305 # Read the *.result.py files.
306 def read_results(self, listTest, has_timed_out):
308 for test in listTest:
309 resfile = os.path.join(self.currentDir,
312 test[:-3] + ".result.py")
314 # check if <test>.result.py file exists
315 if not os.path.exists(resfile):
316 results[test] = ["?", -1, "", []]
319 execfile(resfile, gdic, ldic)
321 status = src.TIMEOUT_STATUS
322 if not has_timed_out:
323 status = src.KO_STATUS
325 if ldic.has_key('status'):
326 status = ldic['status']
329 if status == src.KO_STATUS or status == src.OK_STATUS:
330 status, expected = self.search_known_errors(status,
336 if ldic.has_key('callback'):
337 callback = ldic['callback']
338 elif status == src.KO_STATUS:
342 if ldic.has_key('time'):
344 exec_time = float(ldic['time'])
348 results[test] = [status, exec_time, callback, expected]
350 # check if <test>.py file exists
351 testfile = os.path.join(self.currentDir,
356 if not os.path.exists(testfile):
357 results[test].append('')
359 text = open(testfile, "r").read()
360 results[test].append(text)
362 # check if <test>.out.py file exists
363 outfile = os.path.join(self.currentDir,
366 test[:-3] + ".out.py")
368 if not os.path.exists(outfile):
369 results[test].append('')
371 text = open(outfile, "r").read()
372 results[test].append(text)
377 # Generates the script to be run by Salome.
378 # This python script includes init and close statements and a loop
379 # calling all the scripts of a single directory.
380 def generate_script(self, listTest, script_path, ignoreList):
382 template_file = open(os.path.join(self.config.VARS.srcDir,
384 "scriptTemplate.py"), 'r')
385 template = string.Template(template_file.read())
387 # create substitution dictionary
389 d['resourcesWay'] = os.path.join(self.currentDir, 'RESSOURCES')
390 d['tmpDir'] = os.path.join(self.tmp_working_dir, 'WORK')
391 d['toolsWay'] = os.path.join(self.config.VARS.srcDir, "test")
392 d['sessionDir'] = os.path.join(self.currentDir,
395 d['resultFile'] = os.path.join(self.tmp_working_dir,
398 d['listTest'] = listTest
399 d['sessionName'] = self.currentsession
400 d['ignore'] = ignoreList
402 # create script with template
403 script = open(script_path, 'w')
404 script.write(template.safe_substitute(d))
407 # Find the getTmpDir function that gives access to *pidict file directory.
408 # (the *pidict file exists when SALOME is launched)
409 def get_tmp_dir(self):
410 # Rare case where there is no KERNEL in grid list
411 # (for example MED_STANDALONE)
412 if ('APPLICATION' in self.config
413 and 'KERNEL' not in self.config.APPLICATION.products
414 and 'KERNEL_ROOT_DIR' not in os.environ):
415 return getTmpDirDEFAULT
417 # Case where "sat test" is launched in an existing SALOME environment
418 if 'KERNEL_ROOT_DIR' in os.environ:
419 root_dir = os.environ['KERNEL_ROOT_DIR']
421 if ('APPLICATION' in self.config
422 and 'KERNEL' in self.config.APPLICATION.products):
423 root_dir = src.product.get_product_config(self.config,
424 "KERNEL").install_dir
426 # Case where there the appli option is called (with path to launcher)
427 if len(self.launcher) > 0:
428 # There are two cases : The old application (runAppli)
430 launcherName = os.path.basename(self.launcher)
431 launcherDir = os.path.dirname(self.launcher)
432 if launcherName == 'runAppli':
434 cmd = "for i in " + launcherDir + "/env.d/*.sh; do source ${i};"
435 " done ; echo $KERNEL_ROOT_DIR"
438 cmd = ("echo -e 'import os\nprint os.environ[\"KERNEL_" +
439 "ROOT_DIR\"]' > tmpscript.py; %s shell" +
440 " tmpscript.py") % self.launcher
441 root_dir = subprocess.Popen(cmd,
442 stdout=subprocess.PIPE,
444 executable='/bin/bash').communicate()[0].split()[-1]
446 # import grid salome_utils from KERNEL that gives
447 # the right getTmpDir function
449 (file_, pathname, description) = imp.find_module("salome_utils",
450 [os.path.join(root_dir,
454 grid = imp.load_module("salome_utils",
458 return grid.getLogDir
460 grid = imp.load_module("salome_utils",
464 return grid.getTmpDir
470 def get_test_timeout(self, test_name, default_value):
471 if ("timeout" in self.settings and
472 test_name in self.settings["timeout"]):
473 return self.settings["timeout"][test_name]
477 def generate_launching_commands(self):
478 # Case where "sat test" is launched in an existing SALOME environment
479 if 'KERNEL_ROOT_DIR' in os.environ:
480 binSalome = "runSalome"
482 killSalome = "killSalome.py"
484 # Rare case where there is no KERNEL in grid list
485 # (for example MED_STANDALONE)
486 if ('APPLICATION' in self.config and
487 'KERNEL' not in self.config.APPLICATION.products):
488 binSalome = "runSalome"
490 killSalome = "killSalome.py"
491 src.environment.load_environment(self.config, False, self.logger)
492 return binSalome, binPython, killSalome
494 # Case where there the appli option is called (with path to launcher)
495 if len(self.launcher) > 0:
496 # There are two cases : The old application (runAppli)
498 launcherName = os.path.basename(self.launcher)
499 launcherDir = os.path.dirname(self.launcher)
500 if launcherName == 'runAppli':
502 binSalome = self.launcher
503 binPython = ("for i in " +
505 "/env.d/*.sh; do source ${i}; done ; python")
506 killSalome = ("for i in " +
508 "/env.d/*.sh; do source ${i}; done ; killSalome.py'")
509 return binSalome, binPython, killSalome
512 binSalome = self.launcher
513 binPython = self.launcher + ' shell'
514 killSalome = self.launcher + ' killall'
515 return binSalome, binPython, killSalome
517 # SALOME version detection and APPLI repository detection
518 VersionSalome = src.get_salome_version(self.config)
520 if "APPLI" in self.config and "application_name" in self.config.APPLI:
521 appdir = self.config.APPLI.application_name
523 # Case where SALOME has NOT the launcher that uses the SalomeContext API
524 if VersionSalome < 730:
525 binSalome = os.path.join(self.config.APPLICATION.workdir,
529 killSalome = "killSalome.py"
530 src.environment.load_environment(self.config, False, self.logger)
531 return binSalome, binPython, killSalome
533 # Case where SALOME has the launcher that uses the SalomeContext API
534 if VersionSalome >= 730:
535 if 'profile' not in self.config.APPLICATION:
536 # Before revision of application concept
537 launcher_name = self.config.APPLI.launch_alias_name
538 binSalome = os.path.join(self.config.APPLICATION.workdir,
542 # After revision of application concept
543 launcher_name = self.config.APPLICATION.profile.launcher_name
544 binSalome = os.path.join(self.config.APPLICATION.workdir,
547 if src.architecture.is_windows():
550 binPython = binSalome + ' shell'
551 killSalome = binSalome + ' killall'
552 return binSalome, binPython, killSalome
554 return binSalome, binPython, killSalome
558 # Runs tests of a session (using a single instance of Salome).
559 def run_tests(self, listTest, ignoreList):
560 out_path = os.path.join(self.currentDir,
563 sessionname = "%s/%s" % (self.currentgrid, self.currentsession)
564 time_out = self.get_test_timeout(sessionname,
567 time_out_salome = src.get_cfg_param(self.config.SITE.test,
571 # generate wrapper script
572 script_path = os.path.join(out_path, 'wrapperScript.py')
573 self.generate_script(listTest, script_path, ignoreList)
575 tmpDir = self.get_tmp_dir()
577 binSalome, binPython, killSalome = self.generate_launching_commands()
578 if self.settings.has_key("run_with_grids") \
579 and self.settings["run_with_grids"].has_key(sessionname):
580 binSalome = (binSalome +
581 " -m %s" % self.settings["run_with_grids"][sessionname])
583 logWay = os.path.join(self.tmp_working_dir, "WORK", "log_cxx")
587 if self.currentsession.startswith("NOGUI_"):
588 # runSalome -t (bash)
589 status, elapsed = fork.batch(binSalome, self.logger,
590 os.path.join(self.tmp_working_dir,
593 "--shutdown-server=1",
598 elif self.currentsession.startswith("PY_"):
600 status, elapsed = fork.batch(binPython, self.logger,
601 os.path.join(self.tmp_working_dir,
604 delai=time_out, log=logWay)
608 if self.show_desktop: opt = "--show-desktop=0"
609 status, elapsed = fork.batch_salome(binSalome,
612 self.tmp_working_dir,
615 "--shutdown-server=1",
621 delaiapp=time_out_salome)
623 self.logger.write("status = %s, elapsed = %s\n" % (status, elapsed),
626 # create the test result to add in the config object
627 test_info = src.pyconf.Mapping(self.config)
628 test_info.testbase = self.currentTestBase
629 test_info.grid = self.currentgrid
630 test_info.session = self.currentsession
631 test_info.script = src.pyconf.Sequence(self.config)
633 script_results = self.read_results(listTest, elapsed == time_out)
634 for sr in sorted(script_results.keys()):
637 # create script result
638 script_info = src.pyconf.Mapping(self.config)
639 script_info.name = sr
640 script_info.res = script_results[sr][0]
641 script_info.time = script_results[sr][1]
642 if script_info.res == src.TIMEOUT_STATUS:
643 script_info.time = time_out
644 if script_info.time < 1e-3: script_info.time = 0
646 callback = script_results[sr][2]
647 if script_info.res != src.OK_STATUS and len(callback) > 0:
648 script_info.callback = callback
650 kfres = script_results[sr][3]
652 script_info.known_error = src.pyconf.Mapping(self.config)
653 script_info.known_error.date = kfres[0]
654 script_info.known_error.expected = kfres[1]
655 script_info.known_error.comment = kfres[2]
656 script_info.known_error.fixed = kfres[3]
658 script_info.content = script_results[sr][4]
659 script_info.out = script_results[sr][5]
661 # add it to the list of results
662 test_info.script.append(script_info, '')
664 # display the results
665 if script_info.time > 0:
666 exectime = "(%7.3f s)" % script_info.time
670 sp = "." * (35 - len(script_info.name))
671 self.logger.write(self.write_test_margin(3), 3)
672 self.logger.write("script %s %s %s %s\n" % (
673 src.printcolors.printcLabel(script_info.name),
675 src.printcolors.printc(script_info.res),
677 if script_info and len(callback) > 0:
678 self.logger.write("Exception in %s\n%s\n" % \
680 src.printcolors.printcWarning(callback)), 2, False)
682 if script_info.res == src.OK_STATUS:
684 elif script_info.res == src.KNOWNFAILURE_STATUS:
685 self.nb_acknoledge += 1
686 elif script_info.res == src.TIMEOUT_STATUS:
688 elif script_info.res == src.NA_STATUS:
690 elif script_info.res == "?":
693 self.config.TESTS.append(test_info, '')
696 # Runs all tests of a session.
697 def run_session_tests(self):
699 self.logger.write(self.write_test_margin(2), 3)
700 self.logger.write("Session = %s\n" % src.printcolors.printcLabel(
701 self.currentsession), 3, False)
703 # prepare list of tests to run
704 tests = os.listdir(os.path.join(self.currentDir,
706 self.currentsession))
707 tests = filter(lambda l: l.endswith(".py"), tests)
708 tests = sorted(tests, key=str.lower)
710 # build list of known failures
711 cat = "%s/%s/" % (self.currentgrid, self.currentsession)
713 for k in self.ignore_tests.keys():
714 if k.startswith(cat):
715 ignoreDict[k[len(cat):]] = self.ignore_tests[k]
717 self.run_tests(tests, ignoreDict)
720 # Runs all tests of a grid.
721 def run_grid_tests(self):
722 self.logger.write(self.write_test_margin(1), 3)
723 self.logger.write("grid = %s\n" % src.printcolors.printcLabel(
724 self.currentgrid), 3, False)
726 grid_path = os.path.join(self.currentDir, self.currentgrid)
729 if self.sessions is not None:
730 sessions = self.sessions # user choice
732 # use all scripts in grid
733 sessions = filter(lambda l: l not in C_IGNORE_GRIDS,
734 os.listdir(grid_path))
735 sessions = filter(lambda l: os.path.isdir(os.path.join(grid_path,
738 sessions = sorted(sessions, key=str.lower)
739 for session_ in sessions:
740 if not os.path.exists(os.path.join(grid_path, session_)):
741 self.logger.write(self.write_test_margin(2), 3)
742 self.logger.write(src.printcolors.printcWarning("Session %s not"
743 " found" % session_) + "\n", 3, False)
745 self.currentsession = session_
746 self.run_session_tests()
749 # Runs test testbase.
750 def run_testbase_tests(self):
751 res_dir = os.path.join(self.currentDir, "RESSOURCES")
752 os.environ['PYTHONPATH'] = (res_dir +
754 os.environ['PYTHONPATH'])
755 os.environ['TT_BASE_RESSOURCES'] = res_dir
756 src.printcolors.print_value(self.logger,
757 "TT_BASE_RESSOURCES",
760 self.logger.write("\n", 4, False)
762 self.logger.write(self.write_test_margin(0), 3)
763 testbase_label = "Test base = %s\n" % src.printcolors.printcLabel(
764 self.currentTestBase)
765 self.logger.write(testbase_label, 3, False)
766 self.logger.write("-" * len(src.printcolors.cleancolor(testbase_label)),
768 self.logger.write("\n", 3, False)
771 settings_file = os.path.join(res_dir, "test_settings.py")
772 if os.path.exists(settings_file):
774 execfile(settings_file, gdic, ldic)
775 self.logger.write(_("Load test settings\n"), 3)
776 self.settings = ldic['settings_dic']
777 self.ignore_tests = ldic['known_failures_list']
778 if isinstance(self.ignore_tests, list):
779 self.ignore_tests = {}
780 self.logger.write(src.printcolors.printcWarning("known_failur"
781 "es_list must be a dictionary (not a list)") + "\n", 1, False)
783 self.ignore_tests = {}
784 self.settings.clear()
786 # read known failures pyconf
787 if "testerror" in self.config.SITE:
789 #self.known_errors = testerror.read_test_failures(
790 # self.config.TOOLS.testerror.file_path,
794 self.known_errors = None
796 if self.grids is not None:
797 grids = self.grids # given by user
799 # select all the grids (i.e. directories) in the directory
800 grids = filter(lambda l: l not in C_IGNORE_GRIDS,
801 os.listdir(self.currentDir))
802 grids = filter(lambda l: os.path.isdir(
803 os.path.join(self.currentDir, l)),
806 grids = sorted(grids, key=str.lower)
808 if not os.path.exists(os.path.join(self.currentDir, grid)):
809 self.logger.write(self.write_test_margin(1), 3)
810 self.logger.write(src.printcolors.printcWarning(
811 "grid %s does not exist\n" % grid), 3, False)
813 self.currentgrid = grid
814 self.run_grid_tests()
816 def run_script(self, script_name):
817 if ('APPLICATION' in self.config and
818 script_name in self.config.APPLICATION):
819 script = self.config.APPLICATION[script_name]
823 self.logger.write("\n", 2, False)
824 if not os.path.exists(script):
825 self.logger.write(src.printcolors.printcWarning("WARNING: scrip"
826 "t not found: %s" % script) + "\n", 2)
828 self.logger.write(src.printcolors.printcHeader("----------- sta"
829 "rt %s" % script_name) + "\n", 2)
830 self.logger.write("Run script: %s\n" % script, 2)
831 subprocess.Popen(script, shell=True).wait()
832 self.logger.write(src.printcolors.printcHeader("----------- end"
833 " %s" % script_name) + "\n", 2)
835 def run_all_tests(self):
836 initTime = datetime.datetime.now()
838 self.run_script('test_setup')
839 self.logger.write("\n", 2, False)
841 self.logger.write(src.printcolors.printcHeader(
842 _("=== STARTING TESTS")) + "\n", 2)
843 self.logger.write("\n", 2, False)
844 self.currentDir = os.path.join(self.tmp_working_dir,
846 self.currentTestBase)
847 self.run_testbase_tests()
849 # calculate total execution time
850 totalTime = datetime.datetime.now() - initTime
851 totalTime -= datetime.timedelta(microseconds=totalTime.microseconds)
852 self.logger.write("\n", 2, False)
853 self.logger.write(src.printcolors.printcHeader(_("=== END TESTS")), 2)
854 self.logger.write(" %s\n" % src.printcolors.printcInfo(str(totalTime)),
861 self.run_script('test_cleanup')
862 self.logger.write("\n", 2, False)
865 res_count = "%d / %d" % (self.nb_succeed,
866 self.nb_run - self.nb_acknoledge)
868 res_out = _("Tests Results: %(succeed)d / %(total)d\n") % \
869 { 'succeed': self.nb_succeed, 'total': self.nb_run }
870 if self.nb_succeed == self.nb_run:
871 res_out = src.printcolors.printcSuccess(res_out)
873 res_out = src.printcolors.printcError(res_out)
874 self.logger.write(res_out, 1)
876 if self.nb_timeout > 0:
877 self.logger.write(_("%d tests TIMEOUT\n") % self.nb_timeout, 1)
878 res_count += " TO: %d" % self.nb_timeout
879 if self.nb_not_run > 0:
880 self.logger.write(_("%d tests not executed\n") % self.nb_not_run, 1)
881 res_count += " NR: %d" % self.nb_not_run
883 status = src.OK_STATUS
884 if self.nb_run - self.nb_succeed - self.nb_acknoledge > 0:
885 status = src.KO_STATUS
886 elif self.nb_acknoledge:
887 status = src.KNOWNFAILURE_STATUS
889 self.logger.write(_("Status: %s\n" % status), 3)
891 return self.nb_run - self.nb_succeed - self.nb_acknoledge
894 # Write margin to show test results.
895 def write_test_margin(self, tab):
898 return "| " * (tab - 1) + "+ "