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