buildframework/helium/tools/common/python/lib/cpythontest/test_packageiad.py
author wbernard
Wed, 23 Dec 2009 19:29:07 +0200
changeset 179 d8ac696cc51f
permissions -rw-r--r--
helium_7.0-r14027
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     1
#============================================================================ 
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     2
#Name        : test_packageiad.py 
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     3
#Part of     : Helium 
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     4
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     5
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     6
#All rights reserved.
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     7
#This component and the accompanying materials are made available
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     8
#under the terms of the License "Eclipse Public License v1.0"
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     9
#which accompanies this distribution, and is available
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    10
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    11
#
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    12
#Initial Contributors:
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    13
#Nokia Corporation - initial contribution.
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    14
#
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    15
#Contributors:
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    16
#
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    17
#Description:
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    18
#===============================================================================
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    19
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    20
""" Test cases for packageiad.
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    21
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    22
"""
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    23
import sys
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    24
import os
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    25
import filecmp
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    26
import xml.dom.minidom
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    27
import logging
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    28
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    29
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    30
logger = logging.getLogger('test.ccm_results')
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    31
logging.basicConfig(level=logging.INFO)
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    32
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    33
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    34
def setup_module():
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    35
    """ Creates some test data files for file-related testing. """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    36
    
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    37
    
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    38
def teardown_module():
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    39
    """ Cleans up test data files for file-related testing. """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    40
    if os.path.exists('testPackage.zip') and os.path.isfile('testPackage.zip'): 
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    41
        os.remove('testPackage.zip')
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    42
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    43
    
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    44
#def test_package_main(self):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    45
    """ Test the package IAD class.
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    46
    sys.path.append(os.path.join(os.environ['HELIUM_HOME'], 'tools', 'iad'))
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    47
    iad = __import__('packageiad')
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    48
    sysdef = os.path.join(os.environ['HELIUM_HOME'], 'tests', 'data', 'packageiad', 'layers.sysdef.xml')
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    49
    sysdefconfigs = "developer_mc_4032"
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    50
    builddrive = os.path.join(os.environ['HELIUM_HOME'], 'tests', 'data', 'packageiad')
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    51
    result = iad.main(sysdef, sysdefconfigs, builddrive) """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    52
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    53
#def test_package_processSisDir(self):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    54
    """ Test the packageiad test_package_processSisDir method.
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    55
    sys.path.append(os.path.join(os.environ['HELIUM_HOME'], 'tools', 'iad'))
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    56
    iad = __import__('packageiad')
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    57
    packager = iad.IADPackager()    #init the packager
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    58
    builddrive = os.path.join(os.environ['HELIUM_HOME'], 'tests', 'data', 'packageiad')
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    59
    buildDirs = os.path.join(os.environ['HELIUM_HOME'], 'tests', 'data', 'packageiad', 'sis\\')
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    60
    packager.processSisDir(buildDirs, builddrive + "\\epoc32\\tools\\makesis.exe") """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    61
    
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    62
def test_createPackage():
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    63
    """ test the create package method """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    64
    #load up the python file
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    65
    sys.path.append(os.path.join(os.environ['HELIUM_HOME'], 'tools', 'iad'))
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    66
    iad = __import__('packageiad')
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    67
    packager = iad.IADPackager()    #init the packager
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    68
    topDir = os.path.join(os.environ['HELIUM_HOME'], 'tests', 'data', 'packageiad', 'sis')
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    69
    packageName = 'testPackage'
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    70
    currentDir = os.getcwd()
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    71
    packager.createPackage(topDir, packageName)
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    72
    if not os.path.exists('testPackage.zip') and not os.path.isfile('testPackage.zip'):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    73
        logger.info("testPackage.zip file not created")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    74
        assert (os.path.exists('testPackage.zip') and os.path.isfile('testPackage.zip'))
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    75
    os.chdir(currentDir)
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    76
    
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    77
def test_getLayers():
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    78
    """ test getLayers in packageIAD """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    79
    sys.path.append(os.path.join(os.environ['HELIUM_HOME'], 'tools', 'iad'))
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    80
    iad = __import__('packageiad')
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    81
    sysdefFile = os.path.join(os.environ['HELIUM_HOME'], 'tests', 'data', 'packageiad', 'layers.sysdef.xml')
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    82
    sysdef = xml.dom.minidom.parse (sysdefFile)
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    83
    configurations = sysdef.getElementsByTagName ("configuration")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    84
    layers = sysdef.getElementsByTagName ("layer")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    85
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    86
    bldDirs = []
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    87
    
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    88
    packager = iad.IADPackager()
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    89
    
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    90
    for configuration in configurations :
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    91
        packager.getLayer (configuration, layers, bldDirs)