587
|
1 |
#============================================================================
|
|
2 |
#Name : test_compilation.py
|
|
3 |
#Part of : Helium
|
|
4 |
|
|
5 |
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
6 |
#All rights reserved.
|
|
7 |
#This component and the accompanying materials are made available
|
|
8 |
#under the terms of the License "Eclipse Public License v1.0"
|
|
9 |
#which accompanies this distribution, and is available
|
|
10 |
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
11 |
#
|
|
12 |
#Initial Contributors:
|
|
13 |
#Nokia Corporation - initial contribution.
|
|
14 |
#
|
|
15 |
#Contributors:
|
|
16 |
#
|
|
17 |
#Description:
|
|
18 |
#===============================================================================
|
588
|
19 |
"""test compilation """
|
|
20 |
|
628
|
21 |
# pylint: disable=R0201
|
587
|
22 |
|
|
23 |
import unittest
|
|
24 |
import compilation
|
|
25 |
import logging
|
|
26 |
import os
|
|
27 |
import sysdef.api
|
|
28 |
import tempfile
|
|
29 |
from shutil import rmtree
|
|
30 |
|
|
31 |
_logger = logging.getLogger('test.compilation')
|
|
32 |
logging.basicConfig(level=logging.INFO)
|
|
33 |
|
|
34 |
class CompilationTest(unittest.TestCase):
|
|
35 |
""" Unit test case for compilation.py """
|
588
|
36 |
def test_read_op_bins_per_unt_empty_logs_lst(self):
|
587
|
37 |
""" Testing read_output_binaries_per_unit method with empty log list """
|
|
38 |
sysdefpath = os.path.join(os.environ['TEST_DATA'], 'data', 'compile', 'sysdefs', 'canonical_system_definition.xml')
|
|
39 |
sysDef = sysdef.api.SystemDefinition(sysdefpath)
|
|
40 |
bsl = compilation.BinarySizeLogger(sysDef)
|
|
41 |
self.assertRaises(Exception, bsl.read_output_binaries_per_unit, "")
|
|
42 |
|
|
43 |
def test_read_output_binaries_per_unit(self):
|
|
44 |
""" Testing read_output_binaries_per_unit method """
|
|
45 |
sysdefpath = os.path.join(os.environ['TEST_DATA'], 'data', 'compile', 'sysdefs', 'canonical_system_definition.xml')
|
|
46 |
sysDef = sysdef.api.SystemDefinition(sysdefpath)
|
|
47 |
bsl = compilation.BinarySizeLogger(sysDef)
|
|
48 |
loglist = os.path.join(os.environ['TEST_DATA'], 'data', 'compile', 'logs', 'test_build.log')
|
|
49 |
bsl.read_output_binaries_per_unit(loglist.split(';'))
|
|
50 |
|
588
|
51 |
def test_read_bin_sizes_rom_op_empty_logs_lst(self):
|
587
|
52 |
""" Testing read_binary_sizes_in_rom_output_logs method with empty log list """
|
|
53 |
sysdefpath = os.path.join(os.environ['TEST_DATA'], 'data', 'compile', 'sysdefs', 'canonical_system_definition.xml')
|
|
54 |
sysDef = sysdef.api.SystemDefinition(sysdefpath)
|
|
55 |
bsl = compilation.BinarySizeLogger(sysDef)
|
|
56 |
self.assertRaises(Exception, bsl.read_binary_sizes_in_rom_output_logs, "")
|
|
57 |
|
|
58 |
def test_read_binary_sizes_in_rom_output_logs(self):
|
|
59 |
""" Testing read_binary_sizes_in_rom_output_logs method """
|
|
60 |
sysdefpath = os.path.join(os.environ['TEST_DATA'], 'data', 'compile', 'sysdefs', 'canonical_system_definition.xml')
|
|
61 |
sysDef = sysdef.api.SystemDefinition(sysdefpath)
|
|
62 |
bsl = compilation.BinarySizeLogger(sysDef)
|
|
63 |
loglist = os.path.join(os.environ['TEST_DATA'], 'data', 'compile', 'logs', 'test_build.log')
|
|
64 |
bsl.read_output_binaries_per_unit(loglist.split(';'))
|
|
65 |
romloglist = os.path.join(os.environ['TEST_DATA'], 'data', 'compile', 'logs', 'test_rom.log')
|
|
66 |
bsl.read_binary_sizes_in_rom_output_logs(romloglist.split(';'))
|
|
67 |
|
|
68 |
def test_write2csvfile(self):
|
|
69 |
""" Testing write2csvfile method """
|
|
70 |
sysdefpath = os.path.join(os.environ['TEST_DATA'], 'data', 'compile', 'sysdefs', 'canonical_system_definition.xml')
|
|
71 |
sysDef = sysdef.api.SystemDefinition(sysdefpath)
|
|
72 |
bsl = compilation.BinarySizeLogger(sysDef)
|
|
73 |
tmpdir = tempfile.mkdtemp()
|
|
74 |
output = os.path.join(tmpdir, 'test_flash_image_size_data.csv')
|
|
75 |
sysdeflist = os.path.join(os.environ['TEST_DATA'], 'data', 'compile', 'sysdefs', 'build.sysdef.xml') + ", " + os.path.join(os.environ['TEST_DATA'], 'data', 'compile', 'sysdefs', 'layers.sysdef.xml')
|
|
76 |
bsl.write2csvfile(output, sysdeflist.split(','))
|
|
77 |
tempFile = open(output,'r')
|
|
78 |
contents = tempFile.readlines()
|
|
79 |
tempFile.close()
|
|
80 |
rmtree(tmpdir)
|
|
81 |
assert len(contents) > 0
|