buildframework/helium/sf/python/pythoncore/lib/pythoncorecpythontests/test_pkg2iby.py
author lorewang
Wed, 01 Dec 2010 16:05:36 +0800
changeset 715 e0739b8406dd
parent 588 c7c26511138f
permissions -rw-r--r--
Specify extenal tool with path
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     1
#============================================================================ 
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     2
#Name        : test_ant.py 
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     3
#Part of     : Helium 
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     4
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     5
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     6
#All rights reserved.
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     7
#This component and the accompanying materials are made available
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     8
#under the terms of the License "Eclipse Public License v1.0"
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     9
#which accompanies this distribution, and is available
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    10
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    11
#
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    12
#Initial Contributors:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    13
#Nokia Corporation - initial contribution.
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    14
#
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    15
#Contributors:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    16
#
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    17
#Description:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    18
#===============================================================================
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    19
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    20
""" pkg2iby.py module tests. """
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    21
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    22
import tempfile
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    23
import os
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    24
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    25
def test_pkg2iby():
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    26
    import pkg2iby
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    27
    tmpdir = tempfile.mkdtemp()
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    28
    os.makedirs(os.path.join(tmpdir, 'epoc32', 'rom', 'include'))
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    29
    os.makedirs(os.path.join(tmpdir, 'epoc32', 'data'))
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    30
    os.makedirs(os.path.join(tmpdir, 'sf'))
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    31
    
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    32
    open(os.path.join(tmpdir, 'a.exe'), 'w').close()
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    33
    open(os.path.join(tmpdir, 'a.dat'), 'w').close()
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    34
    open(os.path.join(tmpdir, 'sf', 'a.script'), 'w').close()
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    35
    
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    36
    (f_desc, filename) = tempfile.mkstemp()
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    37
    f_file = os.fdopen(f_desc, 'w')
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    38
    f_file.write(r'"/sf/a.script"-"c:\a.script"' + '\n')
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    39
    f_file.write(r'"/a.exe"-"c:\graphics\a.exe"' + '\n')
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    40
    f_file.write(r'"/a.dat"-"c:\graphics\a.dat"' + '\n')
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    41
    f_file.close()
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    42
    
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    43
    pkg2iby.generateromcontent(tmpdir, 'tef', [filename])
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    44
    assert os.path.exists(os.path.join(tmpdir, 'epoc32', 'data', 'atsautoexec.bat'))
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    45
    assert os.path.exists(os.path.join(tmpdir, 'epoc32', 'rom', 'include', 'atsauto.iby'))
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    46