buildframework/helium/sf/python/pythoncore/lib/pythoncorecpythontests/test_sis.py
author wbernard
Thu, 22 Jul 2010 17:08:43 +0300
branchhelium-9.0
changeset 618 df88fead2976
parent 587 85df38eb4012
child 628 7c4a911dc066
permissions -rw-r--r--
helium_9.0.5-4399343f4f50
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
#============================================================================ 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
#Name        : test_sis.py 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
#Part of     : Helium 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
#All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
#This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
#under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
#which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
#Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
#Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
#Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
#Description:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
#===============================================================================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
""" Test sis module. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
import logging
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
import unittest
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
import tempfile
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
import os
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
from lxml import etree
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
import configuration
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
import sis
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
_logger = logging.getLogger('test.sis')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
class ArchivePreBuilderTest(unittest.TestCase):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
    """ Tests for sis module. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
    def test_sis_v1(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
        """ V1 config format. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
        data = {'name': 'foo',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
                'path': 'bar'}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
        tree = self._setup_test_case(data)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
        assert tree.xpath("/project/target[@name='stage1']/parallel/*/arg/@line")[0] == '-v foo.pkg foo.sis'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
    def test_sis_v2(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
        """ V2 config format. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
        data = {'input': 'foo.pkg'}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
        tree = self._setup_test_case(data)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
        assert tree.xpath("/project/target[@name='stage1']/parallel/*/arg/@line")[0] == '-v foo.pkg foo.sis'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
    def test_sis_v2_1(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
        """ V2 config format for sisx. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
        data = {'input': 'foo.pkg', 'output': 'foo.sisx'}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
        tree = self._setup_test_case(data)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
        assert tree.xpath("/project/target[@name='stage1']/parallel/*/arg/@line")[0] == '-v foo.pkg foo.sis'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
        assert tree.xpath("/project/target[@name='stage2']/parallel/*/arg/@line")[0] == '-v foo.sis foo.sisx cert1 key1'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
    def _setup_test_case(self, additional_data):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
        """ Setup test case based on varying inputs. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
        data = {'makesis.tool': 'makesis',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
                'signsis.tool': 'signsis',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    61
                'key': 'key1',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
                'cert': 'cert1',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
                'build.sisfiles.dir': 'dir'}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
        data.update(additional_data)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
        config = configuration.ConfigurationSet([configuration.Configuration(data)])
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
        sis_prebuilder = sis.SisPreBuilder(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
        tmpfile = os.path.join(tempfile.mkdtemp(), 'test.xml')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
        sis_prebuilder.write(tmpfile)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
        tree = etree.parse(tmpfile)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
        return tree
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76