buildframework/helium/sf/python/pythoncore/lib/ats3/__init__.py
author wbernard
Tue, 27 Apr 2010 08:33:08 +0300
changeset 587 85df38eb4012
child 588 c7c26511138f
child 618 df88fead2976
permissions -rw-r--r--
helium_9.0-a7879c935424
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
# -*- encoding: latin-1 -*-
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
#============================================================================ 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
#Name        : __init__.py 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
#Part of     : Helium 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
#All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
#This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
#under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
#which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
#Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
#Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
#Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
#Description:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
#===============================================================================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
"""ATS3 test drop generation."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
#W0142 => * and ** were used
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
#R*    => will be fixed while refactoring
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
#F0401 => pylint didn't find "path" module
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
#C0302 => Too many lines
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
from optparse import OptionParser
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
import ats3.testconfigurator as acp
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
import ats3.dropgenerator as adg
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
import logging
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
import os
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
import re
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
import ats3.parsers as parser
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
from path import path # pylint: disable-msg=F0401
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
_logger = logging.getLogger('ats')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
class Configuration(object):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
    """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
    ATS3 drop generation configuration.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
    """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
    def __init__(self, opts, tsrc_paths):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
        """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
        Initialize from optparse configuration options.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
        """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
        self._opts = opts
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
        c_parser = parser.CppParser()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
        temp_dict = {}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
        pkg_parser = parser.PkgFileParser()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
        # Customize some attributes from how optparse leaves them.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
        self.build_drive = path(self._opts.build_drive)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
        self.file_store = path(self._opts.file_store)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
        self.flash_images = split_paths(self._opts.flash_images)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
        self.sis_files = split_paths(self._opts.sis_files)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
        self.config_file = self._opts.config
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    61
        self.obey_pkgfiles = to_bool(self._opts.obey_pkgfiles)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
        self.hti = to_bool(self._opts.hti)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
        self.specific_pkg = self._opts.specific_pkg
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
        if self.specific_pkg == '':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
            self.specific_pkg = None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
        self.tsrc_paths_dict = {}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
        ats_nd = self._opts.ctc_run_process_params.strip()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
        if ats_nd != "":
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
            ats_nd = ats_nd.split("#")[0].strip()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
            if ats_nd == "":
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
                self._opts.ctc_run_process_params = ""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
                _logger.warning("Property \'ats.ctc.host\' is not set. Code coverage measurement report(s) will not be created.")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
                
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
        main_comps = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
                
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
        for tsrc in tsrc_paths:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
            hrh = os.path.join(self.build_drive + os.sep, 'epoc32', 'include', 'feature_settings.hrh')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
            if os.path.exists(hrh):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    80
                temp_dict = c_parser.get_cpp_output(path(tsrc), "d", hrh)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
            else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    82
                temp_dict = c_parser.get_cpp_output(path(tsrc), "d")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    83
            for t_key, t_value in temp_dict.items():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    84
                self.tsrc_paths_dict[t_key] = t_value
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    85
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    86
        #preparing a list of main components
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    87
        for main_component in self.tsrc_paths_dict.keys():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    88
            if self.obey_pkgfiles == "True":
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    89
                if pkg_parser.get_pkg_files(main_component) != []:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    90
                    main_comps.append(main_component)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    91
            else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    92
                main_comps.append(main_component)    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    93
                    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    94
                    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    95
        self.tsrc_paths = main_comps
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    96
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    97
    def __getattr__(self, attr):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    98
        return getattr(self._opts, attr)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    99
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   100
    def __str__(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   101
        dump = "Configuration:\n"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   102
        seen = set()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   103
        for key, value in vars(self).items():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   104
            if not key.startswith("_"):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   105
                dump += "\t%s = %s\n" % (key, value)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   106
                seen.add(key)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   107
        for key, value in vars(self._opts).items():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   108
            if key not in seen:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   109
                dump += "\t%s = %s\n" % (key, value)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   110
                seen.add(key)                
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   111
        return dump
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   112
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   113
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   114
class Ats3TestPlan(object):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   115
    """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   116
    Tells ATS3 server what to test and how.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   117
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   118
    The ATS3 test plan from which the test.xml file can be written. The test
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   119
    plan captures all the data related to a test run: flashing, installation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   120
    of data files and configuration files, test cases, and the notifications.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   121
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   122
    """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   123
    EMAIL_SUBJECT = (u"ATS3 report for §RUN_NAME§ §RUN_START_DATE§ "
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   124
                     u"§RUN_START_TIME§")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   125
    REPORT_PATH = u"§RUN_NAME§" + os.sep + u"§RUN_START_DATE§_§RUN_START_TIME§"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   126
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   127
    def __init__(self, config):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   128
        self.diamonds_build_url = config.diamonds_build_url
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   129
        self.ctc_run_process_params = config.ctc_run_process_params
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   130
        self.testrun_name = config.testrun_name
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   131
        self.harness = config.harness
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   132
        self.device_type = config.device_type
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   133
        self.device_hwid = config.device_hwid
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   134
        self.plan_name = config.plan_name
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   135
        self.report_email = config.report_email
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   136
        self.file_store = config.file_store
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   137
        self.test_timeout = config.test_timeout
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   138
        self.eunitexerunner_flags = config.eunitexerunner_flags
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   139
        self.sets = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   140
        self.src_dst = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   141
        self.pmd_files = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   142
        self.trace_activation_files = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   143
        self.trace_enabled = to_bool(config.trace_enabled)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   144
        self.ctc_enabled = to_bool(config.ctc_enabled)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   145
        self.multiset_enabled = to_bool(config.multiset_enabled)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   146
        self.monsym_files = config.monsym_files
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   147
        self.hti = config.hti
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   148
        self.component_path = ""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   149
        self.custom_dir = None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   150
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   151
    def insert_set(self, data_files=None, config_files=None, 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   152
                   engine_ini_file=None,  image_files=None, sis_files=None,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   153
                   testmodule_files=None, test_timeout=None,eunitexerunner_flags=None , test_harness=None,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   154
                   src_dst=None, pmd_files=None, trace_activation_files=None, custom_dir=None, component_path=None):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   155
        """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   156
        Insert a test set into the test plan.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   157
        """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   158
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   159
        if not custom_dir is None:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   160
            self.custom_dir = custom_dir
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   161
        if data_files is None:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   162
            data_files = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   163
        if config_files is None:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   164
            config_files = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   165
        if image_files is None:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   166
            image_files = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   167
        if sis_files is None:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   168
            sis_files = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   169
        if testmodule_files is None:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   170
            testmodule_files = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   171
        if test_timeout is None:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   172
            test_timeout = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   173
        if test_harness is None:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   174
            test_harness = self.harness
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   175
        if src_dst is None:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   176
            src_dst = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   177
        if pmd_files is None:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   178
            pmd_files = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   179
        if trace_activation_files is None:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   180
            trace_activation_files = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   181
        if component_path is None:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   182
            component_path = self.component_path
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   183
            
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   184
        setd = dict(name="set%d" % len(self.sets),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   185
                    image_files=image_files, engine_ini_file=engine_ini_file, ctc_enabled=self.ctc_enabled, component_path=component_path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   186
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   187
        setd = dict(setd, custom_dir=custom_dir)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   188
        if sis_files:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   189
            setd = dict(setd, sis_files=sis_files, test_timeout=test_timeout, eunitexerunner_flags=eunitexerunner_flags, test_harness=test_harness, )
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   190
        else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   191
            setd = dict(setd, data_files=data_files, config_files=config_files,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   192
                        testmodule_files=testmodule_files, test_timeout=test_timeout, eunitexerunner_flags=eunitexerunner_flags, test_harness=test_harness,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   193
                        src_dst=src_dst)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   194
        if self.trace_enabled != "":
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   195
            if self.trace_enabled.lower() == "true":
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   196
                setd = dict(setd, pmd_files=pmd_files, 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   197
                            trace_path=self.file_store.joinpath(self.REPORT_PATH, "traces", setd["name"], "tracelog.blx"),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   198
                            trace_activation_files=trace_activation_files)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   199
            else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   200
                setd = dict(setd, pmd_files=[], 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   201
                            trace_path="",trace_activation_files=[])
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   202
        self.sets.append(setd)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   203
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   204
    def set_plan_harness(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   205
        """setting up test harness for a plan"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   206
        eunit = False
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   207
        stif = False
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   208
        stifunit = False
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   209
        for setd in self.sets:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   210
            if setd["test_harness"] == "STIF":
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   211
                stif = True
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   212
            elif setd["test_harness"] == "EUNIT":
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   213
                eunit = True
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   214
            elif setd["test_harness"] == "STIFUNIT":
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   215
                stifunit = True
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   216
                
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   217
        if eunit and stif:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   218
            self.harness = "MULTI_HARNESS"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   219
        elif eunit:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   220
            self.harness = "EUNIT"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   221
        elif stif:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   222
            self.harness = "STIF"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   223
        elif stifunit:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   224
            self.harness = "STIFUNIT"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   225
        else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   226
            self.harness = "GENERIC"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   227
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   228
    @property
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   229
    def post_actions(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   230
        """ATS3 post actions."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   231
        actions = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   232
        temp_var = ""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   233
        include_ctc_runprocess = False
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   234
        report_path = self.file_store.joinpath(self.REPORT_PATH)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   235
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   236
        if self.ctc_enabled and adg.CTC_PATHS_LIST != [] and self.monsym_files != "" and not "${" in self.monsym_files:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   237
            include_ctc_runprocess = True
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   238
            ctc_params = "--ctcdata_files="
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   239
            for cdl in adg.CTC_PATHS_LIST:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   240
                ctc_params += cdl + '\\ctcdata.txt' + ";"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   241
                temp_var = cdl
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   242
            
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   243
            drop_count = self.ctc_run_process_params.rsplit("#", 1)[1]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   244
            temp_var = temp_var.split("ctc_helium"+os.sep)[1]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   245
            diamonds_id = temp_var.split(os.sep)[0]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   246
            drop_id = temp_var.split(os.sep)[1].split(os.sep)[0]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   247
            drop_id = re.findall(".*drop(\d*)", drop_id.lower())[0] #extracting int part of drop name
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   248
           
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   249
            ctc_params += r" --monsym_files=" + self.monsym_files
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   250
            ctc_params += r" --diamonds_build_id=" + diamonds_id
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   251
            ctc_params += r" --drop_id=" + drop_id
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   252
            ctc_params += r" --total_amount_of_drops=" + drop_count
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   253
            
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   254
            runprocess_action = ("RunProcessAction", 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   255
                            (("file", r"catsctc2html/catsctc2html.exe"), #this line will be executing on Windows machine.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   256
                             ("parameters", ctc_params)))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   257
            
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   258
            email_url = " CTC report can be found from: " + self.diamonds_build_url
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   259
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   260
            email_action = ("SendEmailAction", 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   261
                            (("subject", self.EMAIL_SUBJECT),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   262
                             ("type", "ATS3_REPORT"),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   263
                             ("send-files", "true"),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   264
                             ("additional-description", email_url),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   265
                             ("to", self.report_email)))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   266
        else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   267
            email_action = ("SendEmailAction", 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   268
                            (("subject", self.EMAIL_SUBJECT),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   269
                             ("type", "ATS3_REPORT"),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   270
                             ("send-files", "true"),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   271
                             ("to", self.report_email)))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   272
        ats3_report = ("FileStoreAction", 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   273
                       (("to-folder", report_path.joinpath("ATS3_REPORT")),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   274
                        ("report-type", "ATS3_REPORT"),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   275
                        ("date-format", "yyyyMMdd"),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   276
                        ("time-format", "HHmmss")))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   277
        stif_report = ("FileStoreAction", 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   278
                       (("to-folder", report_path.joinpath("STIF_REPORT")),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   279
                        ("report-type", "STIF_COMPONENT_REPORT_ALL_CASES"),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   280
                        ("run-log", "true"),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   281
                        ("date-format", "yyyyMMdd"),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   282
                        ("time-format", "HHmmss")))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   283
        eunit_report = ("FileStoreAction", 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   284
                       (("to-folder", report_path.joinpath("EUNIT_REPORT")),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   285
                        ("report-type", "EUNIT_COMPONENT_REPORT_ALL_CASES"),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   286
                        ("run-log", "true"),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   287
                        ("date-format", "yyyyMMdd"),
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   288
                        ("time-format", "HHmmss")))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   289
        diamonds_action = ("DiamondsAction", ())
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   290
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   291
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   292
        if include_ctc_runprocess:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   293
            actions.append(runprocess_action)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   294
            
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   295
        if self.diamonds_build_url:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   296
            actions.append(diamonds_action)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   297
        if self.file_store:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   298
            actions.append(ats3_report)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   299
            if self.harness == "STIF":
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   300
                actions.append(stif_report)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   301
            elif self.harness == "EUNIT":
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   302
                actions.append(eunit_report)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   303
        if self.report_email:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   304
            actions.append(email_action)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   305
        return actions               
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   306
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   307
    def __getitem__(self, key):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   308
        return self.__dict__[key]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   309
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   310
def encode_for_xml(unicode_data, encoding='ascii'):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   311
    """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   312
    Encode unicode_data for use as XML or HTML, with characters outside
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   313
    of the encoding converted to XML numeric character references.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   314
    """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   315
    try:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   316
        return unicode_data.encode(encoding, 'xmlcharrefreplace')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   317
    except ValueError:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   318
        # ValueError is raised if there are unencodable chars in the
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   319
        # data and the 'xmlcharrefreplace' error handler is not found.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   320
        # Pre-2.3 Python doesn't support the 'xmlcharrefreplace' error
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   321
        # handler, so we'll emulate it.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   322
        return _xmlcharref_encode(unicode_data, encoding)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   323
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   324
def _xmlcharref_encode(unicode_data, encoding):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   325
    """Emulate Python 2.3's 'xmlcharrefreplace' encoding error handler."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   326
    chars = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   327
    # Step through the unicode_data string one character at a time in
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   328
    # order to catch unencodable characters:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   329
    for char in unicode_data:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   330
        try:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   331
            chars.append(char.encode(encoding, 'strict'))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   332
        except UnicodeError:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   333
            chars.append('&#%i;' % ord(char))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   334
    return ''.join(chars)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   335
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   336
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   337
def create_drop(config):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   338
    """Create a test drop."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   339
    _logger.debug("initialize test plan")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   340
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   341
    test_plan = Ats3TestPlan(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   342
    component_parser = acp.Ats3ComponentParser(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   343
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   344
    for tsrc in config.tsrc_paths:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   345
        lst_check_harness = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   346
        _logger.info("inspecting tsrc path: %s" % tsrc)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   347
        #checking if there are components without harness
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   348
        for sub_component in config.tsrc_paths_dict[tsrc]['content'].keys():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   349
            _harness_ = config.tsrc_paths_dict[tsrc]['content'][sub_component]['harness']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   350
            if _harness_ != "":
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   351
                lst_check_harness.append(_harness_)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   352
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   353
        #if component has harness then insert to test set 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   354
        if len(lst_check_harness) > 0:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   355
            component_parser.insert_test_set(test_plan, path(tsrc), config.tsrc_paths_dict)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   356
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   357
    test_plan.set_plan_harness()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   358
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   359
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   360
    #Checking if any non executable set exists
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   361
    #if yes, delete the set
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   362
    tesplan_counter = 0
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   363
    for plan_sets in test_plan.sets:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   364
        tesplan_counter += 1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   365
        exe_flag = False
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   366
        for srcanddst in plan_sets['src_dst']:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   367
            _ext = srcanddst[0].rsplit(".")[1]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   368
            #the list below are the files which are executable
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   369
            #if none exists, set is not executable
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   370
            for mat in ["dll", "ini", "cfg", "exe", "script"]:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   371
                if mat == _ext.lower():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   372
                    exe_flag = True
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   373
                    break
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   374
            if exe_flag: 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   375
                break
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   376
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   377
        if not exe_flag: #the set does not have executable, deleting the set
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   378
            _logger.info(plan_sets['component_path'] + ' has no executables so not including in xml')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   379
            del test_plan.sets[tesplan_counter - 1]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   380
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   381
    if config.ats4_enabled.lower() == 'true':
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   382
        generator = adg.Ats3TemplateTestDropGenerator()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   383
    else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   384
        generator = adg.Ats3TestDropGenerator()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   385
    _logger.info("generating drop file: %s" % config.drop_file)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   386
    generator.generate(test_plan, output_file=config.drop_file, config_file=config.config_file)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   387
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   388
def split_paths(arg, delim=","):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   389
    """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   390
    Split the string by delim, removing extra whitespace.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   391
    """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   392
    return [path(part.strip()) 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   393
            for part in arg.split(delim) if part.strip()]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   394
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   395
def to_bool(param):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   396
    """setting a true or false based on a param value"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   397
    param = str(param).lower()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   398
    if "true" == param or "t" == param or "1" == param:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   399
        return "True"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   400
    else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   401
        return "False"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   402
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   403
def main():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   404
    """Main entry point."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   405
    cli = OptionParser(usage="%prog [options] TSRC1 [TSRC2 [TSRC3 ...]]")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   406
    cli.add_option("--build-drive", help="Build area root drive")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   407
    cli.add_option("--data-dir", help="Data directory name", action="append", 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   408
                   default=[])
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   409
    cli.add_option("--device-type", help="Device type (e.g. 'PRODUCT')", 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   410
                   default="unknown")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   411
    cli.add_option("--device-hwid", help="Device hwid", 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   412
                   default="")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   413
    cli.add_option("--trace-enabled", help="Tracing enabled", default="False")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   414
    cli.add_option("--ctc-enabled", help="CTC enabled", default="False")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   415
    cli.add_option("--multiset-enabled", help="Multiset enabled", default="False")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   416
    cli.add_option("--diamonds-build-url", help="Diamonds build url")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   417
    cli.add_option("--ctc-run-process-params", help="ctc parameters include ctc host, drop id and total number of drops, separated by '#'")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   418
    cli.add_option("--drop-file", help="Name for the final drop zip file",
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   419
                   default="ATS3Drop.zip")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   420
    cli.add_option("--file-store", help="Destination path for reports.",
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   421
                   default="")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   422
    cli.add_option("--flash-images", help="Paths to the flash image files",
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   423
                   default="")     
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   424
    cli.add_option("--minimum-flash-images", help="Minimum amount of flash images",
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   425
                   default=2)    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   426
    cli.add_option("--harness", help="Test harness (default: %default)",
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   427
                   default="")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   428
    cli.add_option("--report-email", help="Email notification receivers", 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   429
                   default="")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   430
    cli.add_option("--plan-name", help="Name of the test plan", 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   431
                   default="plan")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   432
    cli.add_option("--sis-files", help="Paths to the sis files",
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   433
                   default="")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   434
    cli.add_option("--monsym-files", help="Paths to MON.sym files, for ctc useage",
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   435
                   default="")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   436
    cli.add_option("--target-platform", help="Target platform (default: %default)",
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   437
                   default="armv5 urel")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   438
    cli.add_option("--test-timeout", help="Test execution timeout value (default: %default)",
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   439
                   default="60")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   440
    cli.add_option("--eunitexerunner-flags", help="Eunitexerunner flags",
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   441
                   default="")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   442
    cli.add_option("--testrun-name", help="Name of the test run", 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   443
                   default="run")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   444
    cli.add_option("--config", help="Path to the config file",
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   445
                   default="")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   446
    cli.add_option("--specific-pkg", help="Text in name of pkg files to use", default='')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   447
    cli.add_option("--ats4-enabled", help="ATS4 enabled", default="False")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   448
    cli.add_option("--obey-pkgfiles", help="If this option is True, then only test components having PKG file are executable and if the compnents don't have PKG files they will be ignored.", default="False")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   449
    cli.add_option("--verbose", help="Increase output verbosity", action="store_true", default=False)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   450
    cli.add_option("--hti", help="HTI enabled", default="True")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   451
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   452
    opts, tsrc_paths = cli.parse_args()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   453
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   454
    if not tsrc_paths:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   455
        cli.error("no tsrc directories given")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   456
    if not opts.build_drive:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   457
        cli.error("no build drive given")      
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   458
    if len(opts.flash_images.split(",")) < int(opts.minimum_flash_images):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   459
        cli.error("Not enough flash files: %i defined, %i needed" % (len(opts.flash_images.split(",")), int(opts.minimum_flash_images) ))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   460
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   461
    if opts.verbose:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   462
        _logger.setLevel(logging.DEBUG)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   463
        logging.basicConfig(level=logging.DEBUG)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   464
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   465
    config = Configuration(opts, tsrc_paths)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   466
    create_drop(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   467
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   468
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   469
if __name__ == "__main__":
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   470
    main()