]> SALOME platform Git repositories - tools/sat.git/blob - commands/test.py
Salome HOME
bug fix
[tools/sat.git] / commands / test.py
1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3 #  Copyright (C) 2010-2012  CEA/DEN
4 #
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.
9 #
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.
14 #
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
18
19 import os
20 import sys
21 import shutil
22 import subprocess
23 import datetime
24 import gzip
25
26 try:
27     from hashlib import sha1
28 except ImportError:
29     from sha import sha as sha1
30
31 import src
32 import src.ElementTree as etree
33 from src.xmlManager import add_simple_node
34
35 # Define all possible option for the test command :  sat test <options>
36 parser = src.options.Options()
37 parser.add_option('b', 'base', 'string', 'base',
38     _("Optional: Indicate the name of the test base to use.\n\tThis name has to"
39       " be registered in your application and in a project.\n\tA path to a "
40       "test base can also be used."))
41 parser.add_option('l', 'launcher', 'string', 'launcher',
42     _("Optional: Use this option to specify the path to a SALOME launcher to "
43       "use to launch the test scripts of the test base."))
44 parser.add_option('g', 'grid', 'list', 'grids',
45     _('Optional: Indicate which grid(s) to test (subdirectory of the test '
46       'base).'))
47 parser.add_option('s', 'session', 'list', 'sessions',
48     _('Optional: indicate which session(s) to test (subdirectory of the '
49       'grid).'))
50 parser.add_option('', 'display', 'string', 'display',
51     _("Optional: set the display where to launch SALOME.\n"
52 "\tIf value is NO then option --show-desktop=0 will be used to launch SALOME."))
53
54 def description():
55     '''method that is called when salomeTools is called with --help option.
56     
57     :return: The text to display for the test command description.
58     :rtype: str
59     '''
60     return _("The test command runs a test base on a SALOME installation.\n\n"
61              "example:\nsat test SALOME-master --grid GEOM --session light")     
62
63 def parse_option(args, config):
64     """ Parse the options and do some verifications about it
65     
66     :param args List: The list of arguments of the command
67     :param config Config: The global configuration
68     :return: the options of the current command launch and the full arguments
69     :rtype: Tuple (options, args)
70     """
71     (options, args) = parser.parse_args(args)
72
73     if not options.launcher:
74         options.launcher = ""
75     elif not os.path.isabs(options.launcher):
76         if not src.config_has_application(config):
77             raise src.SatException(_("An application is required to use a "
78                                      "relative path with option --appli"))
79         options.launcher = os.path.join(config.APPLICATION.workdir,
80                                         options.launcher)
81
82         if not os.path.exists(options.launcher):
83             raise src.SatException(_("Launcher not found: %s") % 
84                                    options.launcher)
85
86     return (options, args)
87
88 def ask_a_path():
89     """ 
90     """
91     path = raw_input("enter a path where to save the result: ")
92     if path == "":
93         result = raw_input("the result will be not save. Are you sure to "
94                            "continue ? [y/n] ")
95         if result == "y":
96             return path
97         else:
98             return ask_a_path()
99
100     elif os.path.exists(path):
101         result = raw_input("Warning, the content of %s will be deleted. Are you"
102                            " sure to continue ? [y/n] " % path)
103         if result == "y":
104             return path
105         else:
106             return ask_a_path()
107     else:
108         return path
109
110 def save_file(filename, base):
111     f = open(filename, 'r')
112     content = f.read()
113     f.close()
114
115     objectname = sha1(content).hexdigest()
116
117     f = gzip.open(os.path.join(base, '.objects', objectname), 'w')
118     f.write(content)
119     f.close()
120     return objectname
121
122 def move_test_results(in_dir, what, out_dir, logger):
123     if out_dir == in_dir:
124         return
125
126     finalPath = out_dir
127     pathIsOk = False
128     while not pathIsOk:
129         try:
130             # create test results directory if necessary
131             #logger.write("FINAL = %s\n" % finalPath, 5)
132             if not os.access(finalPath, os.F_OK):
133                 #shutil.rmtree(finalPath)
134                 os.makedirs(finalPath)
135             pathIsOk = True
136         except:
137             logger.error(_("%s cannot be created.") % finalPath)
138             finalPath = ask_a_path()
139
140     if finalPath != "":
141         os.makedirs(os.path.join(finalPath, what, 'BASES'))
142
143         # check if .objects directory exists
144         if not os.access(os.path.join(finalPath, '.objects'), os.F_OK):
145             os.makedirs(os.path.join(finalPath, '.objects'))
146
147         logger.write(_('copy tests results to %s ... ') % finalPath, 3)
148         logger.flush()
149         #logger.write("\n", 5)
150
151         # copy env_info.py
152         shutil.copy2(os.path.join(in_dir, what, 'env_info.py'),
153                      os.path.join(finalPath, what, 'env_info.py'))
154
155         # for all sub directory (ie testbase) in the BASES directory
156         for testbase in os.listdir(os.path.join(in_dir, what, 'BASES')):
157             outtestbase = os.path.join(finalPath, what, 'BASES', testbase)
158             intestbase = os.path.join(in_dir, what, 'BASES', testbase)
159
160             # ignore files in root dir
161             if not os.path.isdir(intestbase):
162                 continue
163
164             os.makedirs(outtestbase)
165             #logger.write("  copy testbase %s\n" % testbase, 5)
166
167             for grid_ in [m for m in os.listdir(intestbase) if os.path.isdir(
168                                                 os.path.join(intestbase, m))]:
169                 # ignore source configuration directories
170                 if grid_[:4] == '.git' or grid_ == 'CVS':
171                     continue
172
173                 outgrid = os.path.join(outtestbase, grid_)
174                 ingrid = os.path.join(intestbase, grid_)
175                 os.makedirs(outgrid)
176                 #logger.write("    copy grid %s\n" % grid_, 5)
177
178                 if grid_ == 'RESSOURCES':
179                     for file_name in os.listdir(ingrid):
180                         if not os.path.isfile(os.path.join(ingrid,
181                                                            file_name)):
182                             continue
183                         f = open(os.path.join(outgrid, file_name), "w")
184                         f.write(save_file(os.path.join(ingrid, file_name),
185                                           finalPath))
186                         f.close()
187                 else:
188                     for session_name in [t for t in os.listdir(ingrid) if 
189                                       os.path.isdir(os.path.join(ingrid, t))]:
190                         outsession = os.path.join(outgrid, session_name)
191                         insession = os.path.join(ingrid, session_name)
192                         os.makedirs(outsession)
193                         
194                         for file_name in os.listdir(insession):
195                             if not os.path.isfile(os.path.join(insession,
196                                                                file_name)):
197                                 continue
198                             if file_name.endswith('result.py'):
199                                 shutil.copy2(os.path.join(insession, file_name),
200                                              os.path.join(outsession, file_name))
201                             else:
202                                 f = open(os.path.join(outsession, file_name), "w")
203                                 f.write(save_file(os.path.join(insession,
204                                                                file_name),
205                                                   finalPath))
206                                 f.close()
207
208     logger.write(src.printcolors.printc("OK"), 3, False)
209     logger.write("\n", 3, False)
210
211 def check_remote_machine(machine_name, logger):
212     logger.write(_("\ncheck the display on %s\n" % machine_name), 4)
213     ssh_cmd = 'ssh -o "StrictHostKeyChecking no" %s "ls"' % machine_name
214     logger.write(_("Executing the command : %s " % ssh_cmd), 4)
215     p = subprocess.Popen(ssh_cmd, 
216                          shell=True,
217                          stdin =subprocess.PIPE,
218                          stdout=subprocess.PIPE,
219                          stderr=subprocess.PIPE)
220     p.wait()
221     if p.returncode != 0:
222         logger.write(src.printcolors.printc(src.KO_STATUS) + "\n", 1)
223         logger.write("    " + src.printcolors.printcError(p.stderr.read()), 2)
224         logger.write(src.printcolors.printcWarning((
225                                     "No ssh access to the display machine.")),1)
226     else:
227         logger.write(src.printcolors.printcSuccess(src.OK_STATUS) + "\n\n", 4)
228
229 ##
230 # Creates the XML report for a product.
231 def create_test_report(config,
232                        xml_history_path,
233                        dest_path,
234                        retcode,
235                        xmlname=""):
236     # get the date and hour of the launching of the command, in order to keep
237     # history
238     date_hour = config.VARS.datehour
239     
240     # Get some information to put in the xml file
241     application_name = config.VARS.application
242     withappli = src.config_has_application(config)
243     
244     first_time = False
245     if not os.path.exists(xml_history_path):
246         first_time = True
247         root = etree.Element("salome")
248         prod_node = etree.Element("product", name=application_name, build=xmlname)
249         root.append(prod_node)
250     else:
251         root = etree.parse(xml_history_path).getroot()
252         prod_node = root.find("product")
253     
254     prod_node.attrib["history_file"] = os.path.basename(xml_history_path)
255     prod_node.attrib["global_res"] = retcode
256     
257     if withappli:
258         if not first_time:
259             for node in (prod_node.findall("version_to_download") + 
260                          prod_node.findall("out_dir")):
261                 prod_node.remove(node)
262                 
263         add_simple_node(prod_node, "version_to_download",
264                         config.APPLICATION.name)
265         
266         add_simple_node(prod_node, "out_dir", config.APPLICATION.workdir)
267
268     # add environment
269     if not first_time:
270         for node in prod_node.findall("exec"):
271                 prod_node.remove(node)
272         
273     exec_node = add_simple_node(prod_node, "exec")
274     exec_node.append(etree.Element("env", name="Host", value=config.VARS.node))
275     exec_node.append(etree.Element("env", name="Architecture",
276                                    value=config.VARS.dist))
277     exec_node.append(etree.Element("env", name="Number of processors",
278                                    value=str(config.VARS.nb_proc)))    
279     exec_node.append(etree.Element("env", name="Begin date",
280                                    value=src.parse_date(date_hour)))
281     exec_node.append(etree.Element("env", name="Command",
282                                    value=config.VARS.command))
283     exec_node.append(etree.Element("env", name="sat version",
284                                    value=config.INTERNAL.sat_version))
285
286     if 'TESTS' in config:
287         if first_time:
288             tests = add_simple_node(prod_node, "tests")
289             known_errors = add_simple_node(prod_node, "known_errors")
290             new_errors = add_simple_node(prod_node, "new_errors")
291             amend = add_simple_node(prod_node, "amend")
292         else:
293             tests = prod_node.find("tests")
294             known_errors = prod_node.find("known_errors")
295             new_errors = prod_node.find("new_errors")
296             amend = prod_node.find("amend")
297         
298         tt = {}
299         for test in config.TESTS:
300             if not tt.has_key(test.testbase):
301                 tt[test.testbase] = [test]
302             else:
303                 tt[test.testbase].append(test)
304         
305         for testbase in tt.keys():
306             if first_time:
307                 gn = add_simple_node(tests, "testbase")
308             else:
309                 gn = tests.find("testbase")
310                 # initialize all grids and session to "not executed"
311                 for mn in gn.findall("grid"):
312                     mn.attrib["executed_last_time"] = "no"
313                     for tyn in mn.findall("session"):
314                         tyn.attrib["executed_last_time"] = "no"
315                         for test_node in tyn.findall('test'):
316                             for node in test_node.getchildren():
317                                 if node.tag != "history":
318                                     test_node.remove(node)
319                             
320                             attribs_to_pop = []    
321                             for attribute in test_node.attrib:
322                                 if (attribute != "script" and 
323                                                         attribute != "res"):
324                                     attribs_to_pop.append(attribute)
325                             for attribute in attribs_to_pop:
326                                 test_node.attrib.pop(attribute)
327             
328             gn.attrib['name'] = testbase
329             nb, nb_pass, nb_failed, nb_timeout, nb_not_run = 0, 0, 0, 0, 0
330             grids = {}
331             sessions = {}
332             for test in tt[testbase]:
333                 if not grids.has_key(test.grid):
334                     if first_time:
335                         mn = add_simple_node(gn, "grid")
336                         mn.attrib['name'] = test.grid
337                     else:
338                         l_mn = gn.findall("grid")
339                         mn = None
340                         for grid_node in l_mn:
341                             if grid_node.attrib['name'] == test.grid:
342                                 mn = grid_node
343                                 break
344                         if mn == None:
345                             mn = add_simple_node(gn, "grid")
346                             mn.attrib['name'] = test.grid
347                     
348                     grids[test.grid] = mn
349                 
350                 mn.attrib["executed_last_time"] = "yes"
351                 
352                 if not sessions.has_key("%s/%s" % (test.grid, test.session)):
353                     if first_time:
354                         tyn = add_simple_node(mn, "session")
355                         tyn.attrib['name'] = test.session
356                     else:
357                         l_tyn = mn.findall("session")
358                         tyn = None
359                         for session_node in l_tyn:
360                             if session_node.attrib['name'] == test.session:
361                                 tyn = session_node
362                                 break
363                         if tyn == None:
364                             tyn = add_simple_node(mn, "session")
365                             tyn.attrib['name'] = test.session
366                         
367                     sessions["%s/%s" % (test.grid, test.session)] = tyn
368
369                 tyn.attrib["executed_last_time"] = "yes"
370
371                 for script in test.script:
372                     if first_time:
373                         tn = add_simple_node(sessions[
374                                            "%s/%s" % (test.grid, test.session)],
375                                              "test")
376                         tn.attrib['session'] = test.session
377                         tn.attrib['script'] = script.name
378                         hn = add_simple_node(tn, "history")
379                     else:
380                         l_tn = sessions["%s/%s" % (test.grid, test.session)].findall(
381                                                                          "test")
382                         tn = None
383                         for test_node in l_tn:
384                             if test_node.attrib['script'] == script['name']:
385                                 tn = test_node
386                                 break
387                         
388                         if tn == None:
389                             tn = add_simple_node(sessions[
390                                            "%s/%s" % (test.grid, test.session)],
391                                              "test")
392                             tn.attrib['session'] = test.session
393                             tn.attrib['script'] = script.name
394                             hn = add_simple_node(tn, "history")
395                         else:
396                             # Get or create the history node for the current test
397                             if len(tn.findall("history")) == 0:
398                                 hn = add_simple_node(tn, "history")
399                             else:
400                                 hn = tn.find("history")
401                             # Put the last test data into the history
402                             if 'res' in tn.attrib:
403                                 attributes = {"date_hour" : date_hour,
404                                               "res" : tn.attrib['res'] }
405                                 add_simple_node(hn,
406                                                 "previous_test",
407                                                 attrib=attributes)
408                             for node in tn:
409                                 if node.tag != "history":
410                                     tn.remove(node)
411                     
412                     if 'callback' in script:
413                         try:
414                             cnode = add_simple_node(tn, "callback")
415                             if src.architecture.is_windows():
416                                 import string
417                                 cnode.text = filter(
418                                                 lambda x: x in string.printable,
419                                                 script.callback)
420                             else:
421                                 cnode.text = script.callback.decode(
422                                                                 'string_escape')
423                         except UnicodeDecodeError as exc:
424                             zz = (script.callback[:exc.start] +
425                                   '?' +
426                                   script.callback[exc.end-2:])
427                             cnode = add_simple_node(tn, "callback")
428                             cnode.text = zz.decode("UTF-8")
429                     
430                     # Add the script content
431                     cnode = add_simple_node(tn, "content")
432                     cnode.text = script.content
433                     
434                     # Add the script execution log
435                     cnode = add_simple_node(tn, "out")
436                     cnode.text = script.out
437                     
438                     if 'amend' in script:
439                         cnode = add_simple_node(tn, "amend")
440                         cnode.text = script.amend.decode("UTF-8")
441
442                     if script.time < 0:
443                         tn.attrib['exec_time'] = "?"
444                     else:
445                         tn.attrib['exec_time'] = "%.3f" % script.time
446                     tn.attrib['res'] = script.res
447
448                     if "amend" in script:
449                         amend_test = add_simple_node(amend, "atest")
450                         amend_test.attrib['name'] = os.path.join(test.grid,
451                                                                  test.session,
452                                                                  script.name)
453                         amend_test.attrib['reason'] = script.amend.decode(
454                                                                         "UTF-8")
455
456                     # calculate status
457                     nb += 1
458                     if script.res == src.OK_STATUS: nb_pass += 1
459                     elif script.res == src.TIMEOUT_STATUS: nb_timeout += 1
460                     elif script.res == src.KO_STATUS: nb_failed += 1
461                     else: nb_not_run += 1
462
463                     if "known_error" in script:
464                         kf_script = add_simple_node(known_errors, "error")
465                         kf_script.attrib['name'] = os.path.join(test.grid,
466                                                                 test.session,
467                                                                 script.name)
468                         kf_script.attrib['date'] = script.known_error.date
469                         kf_script.attrib[
470                                     'expected'] = script.known_error.expected
471                         kf_script.attrib[
472                          'comment'] = script.known_error.comment.decode("UTF-8")
473                         kf_script.attrib['fixed'] = str(
474                                                        script.known_error.fixed)
475                         overdue = datetime.datetime.today().strftime("%Y-%m-"
476                                             "%d") > script.known_error.expected
477                         if overdue:
478                             kf_script.attrib['overdue'] = str(overdue)
479                         
480                     elif script.res == src.KO_STATUS:
481                         new_err = add_simple_node(new_errors, "new_error")
482                         script_path = os.path.join(test.grid,
483                                                    test.session, script.name)
484                         new_err.attrib['name'] = script_path
485                         new_err.attrib['cmd'] = ("sat testerror %s -s %s -c 'my"
486                                                  " comment' -p %s" % \
487                             (application_name, script_path, config.VARS.dist))
488
489
490             gn.attrib['total'] = str(nb)
491             gn.attrib['pass'] = str(nb_pass)
492             gn.attrib['failed'] = str(nb_failed)
493             gn.attrib['timeout'] = str(nb_timeout)
494             gn.attrib['not_run'] = str(nb_not_run)
495             
496             # Remove the res attribute of all tests that were not launched 
497             # this time
498             for mn in gn.findall("grid"):
499                 if mn.attrib["executed_last_time"] == "no":
500                     for tyn in mn.findall("session"):
501                         if tyn.attrib["executed_last_time"] == "no":
502                             for test_node in tyn.findall('test'):
503                                 if "res" in test_node.attrib:
504                                     test_node.attrib.pop("res")          
505     
506     if len(xmlname) == 0:
507         xmlname = application_name
508     if not xmlname.endswith(".xml"):
509         xmlname += ".xml"
510
511     src.xmlManager.write_report(os.path.join(dest_path, xmlname),
512                                 root,
513                                 "test.xsl")
514     src.xmlManager.write_report(xml_history_path,
515                                 root,
516                                 "test_history.xsl")
517     return src.OK_STATUS
518
519 def generate_history_xml_path(config, test_base):
520     """Generate the name of the xml file that contain the history of the tests
521        on the machine with the current APPLICATION and the current test base.
522     
523     :param config Config: The global configuration
524     :param test_base Str: The test base name (or path)
525     :return: the full path of the history xml file
526     :rtype: Str
527     """
528     history_xml_name = ""
529     if "APPLICATION" in config:
530         history_xml_name += config.APPLICATION.name
531         history_xml_name += "-" 
532     history_xml_name += config.VARS.dist
533     history_xml_name += "-"
534     test_base_name = test_base
535     if os.path.exists(test_base):
536         test_base_name = os.path.basename(test_base)
537     history_xml_name += test_base_name
538     history_xml_name += ".xml"
539     return os.path.join(config.USER.log_dir, "TEST", history_xml_name)
540
541 def run(args, runner, logger):
542     '''method that is called when salomeTools is called with test parameter.
543     '''
544     (options, args) = parse_option(args, runner.cfg)
545
546     with_application = False
547     if runner.cfg.VARS.application != 'None':
548         logger.write(_('Running tests on application %s\n') % 
549                             src.printcolors.printcLabel(
550                                                 runner.cfg.VARS.application), 1)
551         with_application = True
552     elif not options.base:
553         raise src.SatException(_('A test base is required. Use the --base '
554                                  'option'))
555
556     if with_application:
557         # check if environment is loaded
558         if 'KERNEL_ROOT_DIR' in os.environ:
559             logger.write(src.printcolors.printcWarning(_("WARNING: "
560                             "SALOME environment already sourced")) + "\n", 1)
561             
562         
563     elif options.launcher:
564         logger.write(src.printcolors.printcWarning(_("Running SALOME "
565                                                 "application.")) + "\n\n", 1)
566     else:
567         msg = _("Impossible to find any launcher.\nPlease specify an "
568                 "application or a launcher")
569         logger.write(src.printcolors.printcError(msg))
570         logger.write("\n")
571         return 1
572
573     # set the display
574     show_desktop = (options.display and options.display.upper() == "NO")
575     if options.display and options.display != "NO":
576         remote_name = options.display.split(':')[0]
577         if remote_name != "":
578             check_remote_machine(remote_name, logger)
579         # if explicitly set use user choice
580         os.environ['DISPLAY'] = options.display
581     elif 'DISPLAY' not in os.environ:
582         # if no display set
583         if ('display' in runner.cfg.SITE.test and 
584                                         len(runner.cfg.SITE.test.display) > 0):
585             # use default value for test tool
586             os.environ['DISPLAY'] = runner.cfg.SITE.test.display
587         else:
588             os.environ['DISPLAY'] = "localhost:0.0"
589
590     # initialization
591     #################
592     if with_application:
593         tmp_dir = runner.cfg.SITE.test.tmp_dir_with_application
594     else:
595         tmp_dir = runner.cfg.SITE.test.tmp_dir
596
597     # remove previous tmp dir
598     if os.access(tmp_dir, os.F_OK):
599         try:
600             shutil.rmtree(tmp_dir)
601         except:
602             logger.error(_("error removing TT_TMP_RESULT %s\n") 
603                                 % tmp_dir)
604
605     lines = []
606     lines.append("date = '%s'" % runner.cfg.VARS.date)
607     lines.append("hour = '%s'" % runner.cfg.VARS.hour)
608     lines.append("node = '%s'" % runner.cfg.VARS.node)
609     lines.append("arch = '%s'" % runner.cfg.VARS.dist)
610
611     if 'APPLICATION' in runner.cfg:
612         lines.append("application_info = {}")
613         lines.append("application_info['name'] = '%s'" % 
614                      runner.cfg.APPLICATION.name)
615         lines.append("application_info['tag'] = '%s'" % 
616                      runner.cfg.APPLICATION.tag)
617         lines.append("application_info['products'] = %s" % 
618                      str(runner.cfg.APPLICATION.products))
619
620     content = "\n".join(lines)
621
622     # create hash from context information
623     dirname = sha1(content.encode()).hexdigest()
624     base_dir = os.path.join(tmp_dir, dirname)
625     os.makedirs(base_dir)
626     os.environ['TT_TMP_RESULT'] = base_dir
627
628     # create env_info file
629     f = open(os.path.join(base_dir, 'env_info.py'), "w")
630     f.write(content)
631     f.close()
632
633     # create working dir and bases dir
634     working_dir = os.path.join(base_dir, 'WORK')
635     os.makedirs(working_dir)
636     os.makedirs(os.path.join(base_dir, 'BASES'))
637     os.chdir(working_dir)
638
639     if 'PYTHONPATH' not in os.environ:
640         os.environ['PYTHONPATH'] = ''
641     else:
642         for var in os.environ['PYTHONPATH'].split(':'):
643             if var not in sys.path:
644                 sys.path.append(var)
645
646     # launch of the tests
647     #####################
648     test_base = ""
649     if options.base:
650         test_base = options.base
651     elif with_application and "test_base" in runner.cfg.APPLICATION:
652         test_base = runner.cfg.APPLICATION.test_base.name
653
654     src.printcolors.print_value(logger, _('Display'), os.environ['DISPLAY'], 2)
655     src.printcolors.print_value(logger, _('Timeout'),
656                                 runner.cfg.SITE.test.timeout, 2)
657     src.printcolors.print_value(logger, _("Working dir"), base_dir, 3)
658
659     # create the test object
660     test_runner = src.test_module.Test(runner.cfg,
661                                   logger,
662                                   base_dir,
663                                   testbase=test_base,
664                                   grids=options.grids,
665                                   sessions=options.sessions,
666                                   launcher=options.launcher,
667                                   show_desktop=show_desktop)
668     
669     if not test_runner.test_base_found:
670         # Fail 
671         return 1
672         
673     # run the test
674     logger.allowPrintLevel = False
675     retcode = test_runner.run_all_tests()
676     logger.allowPrintLevel = True
677
678     logger.write(_("Tests finished"), 1)
679     logger.write("\n", 2, False)
680     
681     logger.write(_("\nGenerate the specific test log\n"), 5)
682     out_dir = os.path.join(runner.cfg.USER.log_dir, "TEST")
683     src.ensure_path_exists(out_dir)
684     name_xml_board = logger.logFileName.split(".")[0] + "board" + ".xml"
685     historic_xml_path = generate_history_xml_path(runner.cfg, test_base)
686     
687     create_test_report(runner.cfg,
688                        historic_xml_path,
689                        out_dir,
690                        retcode,
691                        xmlname = name_xml_board)
692     xml_board_path = os.path.join(out_dir, name_xml_board)
693     logger.l_logFiles.append(xml_board_path)
694     logger.add_link(os.path.join("TEST", name_xml_board),
695                     "board",
696                     retcode,
697                     "Click on the link to get the detailed test results")
698     
699     # Add the historic files into the log files list of the command
700     logger.l_logFiles.append(historic_xml_path)
701     
702     logger.write(_("Removing the temporary directory: "
703                    "rm -rf %s\n" % test_runner.tmp_working_dir), 5)
704     if os.path.exists(test_runner.tmp_working_dir):
705         shutil.rmtree(test_runner.tmp_working_dir)
706
707     return retcode
708