buildframework/helium/tools/common/python/lib/cpythontest/test_sis.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_sis.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 sis module. """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    21
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    22
import logging
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    23
import unittest
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    24
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    25
from lxml import etree
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    26
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    27
import configuration
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    28
import sis
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    29
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    30
_logger = logging.getLogger('test.sis')
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    31
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    32
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    33
class ArchivePreBuilderTest(unittest.TestCase):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    34
    """ Tests for sis module. """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    35
    
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    36
    def test_sis_v1(self):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    37
        """ V1 config format. """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    38
        data = {'name': 'foo',
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    39
                'path': 'bar'}
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    40
        tree = self._setup_test_case(data)
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    41
        assert tree.xpath("/project/target[@name='stage1']/parallel/*/arg/@line")[0] == '-v foo.pkg foo.sis'
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    42
        
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    43
    def test_sis_v2(self):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    44
        """ V2 config format. """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    45
        data = {'input': 'foo.pkg'}
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    46
        tree = self._setup_test_case(data)
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    47
        assert tree.xpath("/project/target[@name='stage1']/parallel/*/arg/@line")[0] == '-v foo.pkg foo.sis'
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    48
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    49
    def test_sis_v2_1(self):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    50
        """ V2 config format for sisx. """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    51
        data = {'input': 'foo.pkg', 'output': 'foo.sisx'}
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    52
        tree = self._setup_test_case(data)
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    53
        assert tree.xpath("/project/target[@name='stage1']/parallel/*/arg/@line")[0] == '-v foo.pkg foo.sis'
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    54
        assert tree.xpath("/project/target[@name='stage2']/parallel/*/arg/@line")[0] == '-v foo.sis foo.sisx cert1 key1'
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    55
        
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    56
    def _setup_test_case(self, additional_data):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    57
        """ Setup test case based on varying inputs. """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    58
        data = {'makesis.tool': 'makesis',
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    59
                'signsis.tool': 'signsis',
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    60
                'key': 'key1',
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    61
                'cert': 'cert1',
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    62
                'build.sisfiles.dir': 'dir'}
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    63
        data.update(additional_data)
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    64
        config = configuration.ConfigurationSet([configuration.Configuration(data)])
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    65
        sis_prebuilder = sis.SisPreBuilder(config)
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    66
        sis_prebuilder.write('test.xml')
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    67
        
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    68
        tree = etree.parse('test.xml')
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    69
        return tree
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    70
    
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    71
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    72
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    73
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    74
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    75