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