buildframework/helium/sf/python/pythoncore/lib/pythoncorecpythontests/test_sis.py
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 587 85df38eb4012
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
#============================================================================ 
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
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    26
import amara
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
import configuration
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
import sis
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
_logger = logging.getLogger('test.sis')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
class ArchivePreBuilderTest(unittest.TestCase):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
    """ Tests for sis module. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
    def test_sis_v1(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
        """ V1 config format. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
        data = {'name': 'foo',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
                'path': 'bar'}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
        tree = self._setup_test_case(data)
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    40
        assert tree.xml_xpath("/project/target[@name='stage1']/parallel/*/arg/@line")[0] == '-v foo.pkg foo.sis'
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
    def test_sis_v2(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
        """ V2 config format. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
        data = {'input': 'foo.pkg'}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
        tree = self._setup_test_case(data)
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    46
        assert tree.xml_xpath("/project/target[@name='stage1']/parallel/*/arg/@line")[0] == '-v foo.pkg foo.sis'
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
    def test_sis_v2_1(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
        """ V2 config format for sisx. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
        data = {'input': 'foo.pkg', 'output': 'foo.sisx'}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
        tree = self._setup_test_case(data)
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    52
        assert tree.xml_xpath("/project/target[@name='stage1']/parallel/*/arg/@line")[0] == '-v foo.pkg foo.sis'
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    53
        assert tree.xml_xpath("/project/target[@name='stage2']/parallel/*/arg/@line")[0] == '-v foo.sis foo.sisx cert1 key1'
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
    def _setup_test_case(self, additional_data):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
        """ Setup test case based on varying inputs. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
        data = {'makesis.tool': 'makesis',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
                'signsis.tool': 'signsis',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
                'key': 'key1',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
                'cert': 'cert1',
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    61
                'build.sisfiles.dir': 'dir'}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
        data.update(additional_data)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
        config = configuration.ConfigurationSet([configuration.Configuration(data)])
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
        sis_prebuilder = sis.SisPreBuilder(config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
        tmpfile = os.path.join(tempfile.mkdtemp(), 'test.xml')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
        sis_prebuilder.write(tmpfile)
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    67
        tree = amara.parse(open(tmpfile))
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
        return tree
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
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