buildframework/helium/sf/python/pythoncore/lib/pythoncorecpythontests/test_matti2.py
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
     1
# -*- coding: latin-1 -*-
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
     2
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
     3
#============================================================================ 
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
     4
#Name        : test_matti2.py 
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
     5
#Part of     : Helium 
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
     6
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
     7
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
     8
#All rights reserved.
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
     9
#This component and the accompanying materials are made available
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    10
#under the terms of the License "Eclipse Public License v1.0"
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    11
#which accompanies this distribution, and is available
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    12
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    13
#
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    14
#Initial Contributors:
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    15
#Nokia Corporation - initial contribution.
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    16
#
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    17
#Contributors:
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    18
#
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    19
#Description:
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    20
#===============================================================================
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    21
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    22
""" Testing MATTI framework. """
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    23
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    24
# pylint: disable=E1101
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    25
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    26
import logging
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    27
logging.getLogger().setLevel(logging.INFO)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    28
import os
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    29
#import shutil
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    30
from path import path
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    31
import ats3.matti2
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    32
import tempfile
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    33
import zipfile
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    34
import platform
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    35
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    36
TEST_PATH = None
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    37
TEST_FILES = {}
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    38
MATTI = None
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    39
OUTPUT = None
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    40
SISFILES = None
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    41
TOTAL_TESTS_COUNT = 3
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    42
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    43
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    44
class Bunch(object):
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    45
    """ Configuration object. Argument from constructor are converted into class attributes. """
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    46
    def __init__(self, **kwargs):
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    47
        self.__dict__.update(kwargs)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    48
        
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    49
class SetUp(object):
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    50
    """ Setup the module. """
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    51
    
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    52
    def __init__(self):
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    53
        """ Setup test environment. """
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    54
        global TEST_PATH, MATTI, OUTPUT, SISFILES
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    55
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    56
        TEST_PATH = path(tempfile.mkdtemp())
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    57
        component = TEST_PATH
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    58
        component.joinpath("matti").makedirs()
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    59
        for path_parts in (("matti_testcases", "profile", "all.sip"),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    60
                           ("matti_testcases", "profile", "bat.sip"),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    61
                           ("matti_testcases", "profile", "fute.sip"),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    62
                           ("matti_testcases", "hwdata", "paths.pkg"),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    63
                           ("matti_testcases", "hwdata", "file1.txt"),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    64
                           ("matti_testcases", "hwdata", "settings.ini"),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    65
                           ("matti_testcases", "matti_parameters", "matti_parameters.xml"),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    66
                           ("matti_testcases", "unit_test1.rb"),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    67
                           ("matti_testcases", "unit_test2.rb"),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    68
                           ("output", "images", "image1.fpsx"),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    69
                           ("output", "images", "image2.fpsx"),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    70
                           ("sisfiles", "abc.sis"),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    71
                           ("sisfiles", "xyz.sis"),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    72
                           ("output", "ats", "temp.txt")):
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    73
            filepath = component.joinpath(*path_parts)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    74
            if not filepath.parent.exists():
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    75
                filepath.parent.makedirs()
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    76
            filepath.touch()
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    77
            TEST_FILES.setdefault(path_parts[1], []).append(filepath)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    78
        
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    79
        OUTPUT = component.joinpath(r"output")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    80
        MATTI = component.joinpath("matti_testcases")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    81
        SISFILES = component.joinpath(r"sisfiles")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    82
        
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    83
        if not filepath.parent.exists():
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    84
            filepath.parent.makedirs()
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    85
        filepath.touch()
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    86
        
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    87
        #mtc => matti_testcases
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    88
        mtc = component.joinpath("matti_testcases")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    89
        mtc.joinpath("unit_test1.rb").write_text("unit_tests")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    90
        mtc.joinpath("unit_test2.rb").write_text("unit_tests")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    91
    
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    92
        # profiles
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    93
        profiles = component.joinpath("matti_testcases", "profile")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    94
        profiles.joinpath("all.sip").write_text("sip profile")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    95
        profiles.joinpath("bat.sip").write_text("sip profile")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    96
        profiles.joinpath("fute.sip").write_text("sip profile")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    97
        
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    98
        #hwdata => hardware data
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
    99
        profiles = component.joinpath("matti_testcases", "hwdata")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   100
        profiles.joinpath("file1.txt").write_text("data file")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   101
        profiles.joinpath("settings.ini").write_text("settings initialization file")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   102
        profiles.joinpath("paths.pkg").write_text(
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   103
            r"""
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   104
            ;Language - standard language definitions
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   105
            &EN
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   106
            
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   107
            ; standard SIS file header
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   108
            #{"BTEngTestApp"},(0x04DA27D5),1,0,0
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   109
            
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   110
            ;Supports Series 60 v 3.0
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   111
            (0x101F7961), 0, 0, 0, {"Series60ProductID"}
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   112
            
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   113
            ;Localized Vendor Name
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   114
            %{"BTEngTestApp"}
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   115
            
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   116
            ;Unique Vendor name
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   117
            :"Nokia"
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   118
            
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   119
            ; Files to copy
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   120
    
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   121
            "[PKG_LOC]\file1.txt"-"C:\Private\10202BE9\PERSISTS\file1.txt"
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   122
            "[PKG_LOC]\settings.ini"-"c:\sys\settings.ini"
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   123
            """.replace('\\', os.sep))
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   124
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   125
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   126
def teardown_module(test_run_count):
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   127
    """ stuff to do after running the tests """
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   128
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   129
    if test_run_count == 0:
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   130
        path(TEST_PATH).rmtree()  
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   131
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   132
class TestMattiTestPlan(SetUp):
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   133
    """ test MattiDrop.py """
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   134
    global OUTPUT, MATTI, SISFILES
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   135
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   136
    def __init__(self):
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   137
        """initialize Matti Tests"""
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   138
        SetUp.__init__(self)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   139
        self.file_store = OUTPUT
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   140
        self.test_asset_path = MATTI
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   141
        self.matti_sis_files = r"%s/abc.sis#f:\data\abc.sis#c:\abc.sis, %s/xyz.sis#f:\data\abc.sis#f:\xyz.sis" % (SISFILES, SISFILES)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   142
        self.build_drive = "j:"
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   143
        self.drop_file = path(r"%s/ats/ATSMattiDrop.zip" %OUTPUT).normpath()
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   144
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   145
        image_files = r"%s/images/image1.fpsx, %s/images/image2.fpsx " % (OUTPUT, OUTPUT)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   146
        self.flash_images = image_files 
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   147
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   148
        self.template_loc = os.path.join(os.environ['TEST_DATA'], 'data/matti/matti_template.xml')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   149
        self.template_loc = os.path.normpath(self.template_loc)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   150
        self.matti_parameters = ""
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   151
        self.config = None
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   152
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   153
    def read_xml(self, file_location, zip_file=False):
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   154
        """reads test.xml file if a path is given"""
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   155
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   156
        xml_text = ""
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   157
        file_location = path(file_location)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   158
        if zip_file:
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   159
            if zipfile.is_zipfile(file_location):
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   160
                myzip = zipfile.ZipFile(file_location, 'r')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   161
                xml_text = myzip.read('test.xml')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   162
                myzip.close()
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   163
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   164
        else:
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   165
            hnd = open(file_location, 'r')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   166
            for line in hnd.readlines():
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   167
                xml_text = xml_text + line
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   168
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   169
        return xml_text
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   170
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   171
    def test_xml_with_all_parameters(self):
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   172
        """ test Matti2.py with all parameters present and correct and sierra is enabled"""
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   173
        global TOTAL_TESTS_COUNT
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   174
        opts = Bunch(build_drive=self.build_drive,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   175
                     drop_file=path(r"%s/ats/ATSMattiDrop1.zip" %OUTPUT).normpath(),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   176
                     flash_images=self.flash_images,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   177
                     matti_sis_files=self.matti_sis_files,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   178
                     testasset_location=self.test_asset_path,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   179
                     template_loc=self.template_loc,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   180
                     sierra_enabled="True",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   181
                     test_profiles="bat, fute",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   182
                     matti_parameters="",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   183
                     matti_timeout="1200",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   184
                     sierra_parameters="--teardown",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   185
                     file_store=self.file_store,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   186
                     report_email="firstname.lastname@domain.com",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   187
                     testrun_name="matti test run",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   188
                     alias_name="alias",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   189
                     device_type="new_device",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   190
                     diamonds_build_url="http://diamonds.com/1234",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   191
                     email_format="simplelogger",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   192
                     email_subject="Matti test report",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   193
                     verbode="false")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   194
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   195
        self.config = ats3.matti2.Configuration(opts)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   196
        ats3.matti2.create_drop(self.config)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   197
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   198
        xml_loc = os.path.join(os.environ['TEST_DATA'], 'data/matti/test_all_present.xml')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   199
        stored_xml = self.read_xml(xml_loc, False).strip()
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   200
        drop_loc = os.path.join(OUTPUT, 'ats/ATSMattiDrop1.zip')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   201
        generated_xml = self.read_xml(drop_loc, True).strip()
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   202
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   203
        if platform.system().lower() == "linux":
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   204
            assert stored_xml.replace('\r', '') in generated_xml
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   205
        else:
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   206
            assert stored_xml in generated_xml
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   207
            
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   208
        TOTAL_TESTS_COUNT -= 1
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   209
        teardown_module(TOTAL_TESTS_COUNT)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   210
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   211
    def test_xml_if_sierra_is_not_enabled(self):
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   212
        """ test Matti2.py with all parameters present and correct and sierra is not enabled (or false)"""
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   213
        global TOTAL_TESTS_COUNT
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   214
        opts = Bunch(build_drive=self.build_drive,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   215
                     drop_file=path(r"%s/ats/ATSMattiDrop2.zip" %OUTPUT).normpath(),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   216
                     flash_images=self.flash_images,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   217
                     matti_sis_files=self.matti_sis_files,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   218
                     testasset_location=self.test_asset_path,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   219
                     template_loc=self.template_loc,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   220
                     sierra_enabled="False",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   221
                     test_profiles="bat, fute",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   222
                     matti_parameters="",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   223
                     matti_timeout="1200",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   224
                     sierra_parameters="--teardown",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   225
                     file_store=self.file_store,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   226
                     report_email="firstname.lastname@domain.com",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   227
                     testrun_name="matti test run",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   228
                     alias_name="alias",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   229
                     device_type="new_device",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   230
                     diamonds_build_url="http://diamonds.com/1234",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   231
                     email_format="simplelogger",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   232
                     email_subject="Matti test report",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   233
                     verbode="false")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   234
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   235
        self.config = ats3.matti2.Configuration(opts)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   236
        ats3.matti2.create_drop(self.config)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   237
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   238
        xml_loc = os.path.join(os.environ['TEST_DATA'], 'data/matti/test_all_present_sierra_disabled.xml')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   239
        stored_xml = self.read_xml(xml_loc, False).strip()
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   240
        drop_loc = os.path.join(OUTPUT, 'ats/ATSMattiDrop2.zip')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   241
        generated_xml = self.read_xml(drop_loc, True).strip()
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   242
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   243
        if platform.system().lower() == "linux":
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   244
            assert stored_xml.replace('\r', '') in generated_xml
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   245
        else:
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   246
            assert stored_xml in generated_xml
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   247
        
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   248
        TOTAL_TESTS_COUNT -= 1
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   249
        teardown_module(TOTAL_TESTS_COUNT)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   250
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   251
    def test_xml_if_sierra_is_enabled_template_location_is_missing(self):
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   252
        """ test Matti2.py with all parameters present and correct and if sierra is enabled but template location is used as default one"""
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   253
        global TOTAL_TESTS_COUNT
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   254
        opts = Bunch(build_drive=self.build_drive,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   255
                     drop_file=path(r"%s/ats/ATSMattiDrop3.zip" %OUTPUT).normpath(),
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   256
                     flash_images=self.flash_images,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   257
                     matti_sis_files=self.matti_sis_files,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   258
                     testasset_location=self.test_asset_path,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   259
                     template_loc="",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   260
                     sierra_enabled="True",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   261
                     test_profiles="bat, fute",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   262
                     matti_parameters="",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   263
                     matti_timeout="1200",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   264
                     sierra_parameters="--teardown",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   265
                     file_store=self.file_store,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   266
                     report_email="firstname.lastname@domain.com",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   267
                     testrun_name="matti test run",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   268
                     alias_name="alias",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   269
                     device_type="new_device",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   270
                     diamonds_build_url="http://diamonds.com/1234",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   271
                     email_format="simplelogger",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   272
                     email_subject="Matti test report",
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   273
                     verbode="false")
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   274
        
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   275
        self.config = ats3.matti2.Configuration(opts)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   276
        ats3.matti2.create_drop(self.config)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   277
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   278
        xml_loc = os.path.join(os.environ['TEST_DATA'], 'data/matti/test_all_present.xml')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   279
        stored_xml = self.read_xml(xml_loc, False).strip()
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   280
        drop_loc = os.path.join(OUTPUT, 'ats/ATSMattiDrop3.zip')
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   281
        generated_xml = self.read_xml(drop_loc, True).strip()
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   282
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   283
        if platform.system().lower() == "linux":
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   284
            assert stored_xml.replace('\r', '') in generated_xml
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   285
        else:
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   286
            assert stored_xml in generated_xml
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   287
        
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   288
        TOTAL_TESTS_COUNT -= 1
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   289
        teardown_module(TOTAL_TESTS_COUNT)        
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   290
        
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   291
        
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   292
        
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   293
        
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents:
diff changeset
   294