3
|
1 |
#
|
|
2 |
# Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
# raptor_xml_unit module
|
|
16 |
# This module tests the identification and parsing of XML metadata files
|
|
17 |
#
|
|
18 |
|
|
19 |
import os
|
|
20 |
import raptor
|
|
21 |
import generic_path
|
|
22 |
import raptor_xml
|
|
23 |
import unittest
|
|
24 |
|
|
25 |
class TestRaptorXML(unittest.TestCase):
|
|
26 |
|
|
27 |
def setUp(self):
|
|
28 |
self.__logger = raptor.Raptor()
|
|
29 |
self.__nullSysDefRoot = generic_path.Path("smoke_suite/test_resources")
|
|
30 |
self.__sysDefRoot = generic_path.Join(os.environ[raptor.env],"test/smoke_suite/test_resources")
|
|
31 |
self.__sysDefFileRoot = generic_path.Join(os.environ[raptor.env], "test/metadata/system")
|
|
32 |
|
|
33 |
def testSystemDefinitionProcessing(self):
|
|
34 |
# Make formatting neater
|
|
35 |
print
|
|
36 |
expectedBldInfs = [generic_path.Join(self.__sysDefRoot, "simple/bld.inf"),\
|
|
37 |
generic_path.Join(self.__sysDefRoot, "basics/helloworld/Bld.inf")]
|
|
38 |
|
|
39 |
sysdefs = ["1.4.1", "1.3.1", "1.5.1"]
|
|
40 |
for sysdef in sysdefs:
|
|
41 |
systemModel = raptor_xml.SystemModel(self.__logger,
|
|
42 |
generic_path.Join(self.__sysDefFileRoot,
|
|
43 |
"system_definition_" + sysdef + ".xml"), self.__sysDefRoot)
|
|
44 |
self.__compareFileLists(expectedBldInfs, systemModel.GetAllComponents())
|
|
45 |
|
|
46 |
|
|
47 |
sourceroot = ""
|
|
48 |
if os.environ.has_key('SOURCEROOT'):
|
|
49 |
sourceroot = os.environ['SOURCEROOT']
|
|
50 |
os.environ['SOURCEROOT'] = self.__sysDefRoot.GetLocalString()
|
|
51 |
systemModel = raptor_xml.SystemModel(self.__logger, generic_path.Join(self.__sysDefFileRoot, "system_definition_2.0.0.xml"), self.__nullSysDefRoot)
|
|
52 |
self.__compareFileLists(expectedBldInfs, systemModel.GetAllComponents())
|
|
53 |
|
|
54 |
del os.environ["SOURCEROOT"]
|
|
55 |
systemModel = raptor_xml.SystemModel(self.__logger, generic_path.Join(self.__sysDefFileRoot, "system_definition_2.0.0.xml"), self.__sysDefRoot)
|
|
56 |
self.__compareFileLists(expectedBldInfs, systemModel.GetAllComponents())
|
|
57 |
|
|
58 |
os.environ["SOURCEROOT"] = 'i_am_not_a_valid_path_at_all'
|
|
59 |
systemModel = raptor_xml.SystemModel(self.__logger, generic_path.Join(self.__sysDefFileRoot, "system_definition_2.0.0.xml"), self.__sysDefRoot)
|
|
60 |
self.__compareFileLists(expectedBldInfs, systemModel.GetAllComponents())
|
|
61 |
|
|
62 |
|
|
63 |
del os.environ["SOURCEROOT"]
|
|
64 |
systemModel = raptor_xml.SystemModel(self.__logger, generic_path.Join(self.__sysDefFileRoot, "system_definition_3.0.0.xml"), self.__sysDefRoot)
|
|
65 |
self.__compareFileLists([], systemModel.GetAllComponents())
|
|
66 |
|
|
67 |
|
|
68 |
systemModel = raptor_xml.SystemModel(self.__logger, generic_path.Join(self.__sysDefFileRoot, "system_definition_multi_layers.xml"), self.__sysDefRoot)
|
|
69 |
|
|
70 |
expectedBldInfs = [ generic_path.Join(self.__sysDefRoot, "simple/bld.inf"),\
|
|
71 |
generic_path.Join(self.__sysDefRoot, "simple_dll/bld.inf"),\
|
|
72 |
generic_path.Join(self.__sysDefRoot, "simple_export/bld.inf"),\
|
|
73 |
generic_path.Join(self.__sysDefRoot, "simple_gui/Bld.inf"),\
|
|
74 |
generic_path.Join(self.__sysDefRoot, "simple_implib/bld.inf"),\
|
|
75 |
generic_path.Join(self.__sysDefRoot, "simple_lib/bld.inf"),\
|
|
76 |
generic_path.Join(self.__sysDefRoot, "simple_stringtable/bld.inf"),\
|
|
77 |
generic_path.Join(self.__sysDefRoot, "simple_test/bld.inf")]
|
|
78 |
self.__compareFileLists(expectedBldInfs, systemModel.GetAllComponents())
|
|
79 |
|
|
80 |
expectedBldInfs = [ generic_path.Join(self.__sysDefRoot, "simple_export/bld.inf"),\
|
|
81 |
generic_path.Join(self.__sysDefRoot, "simple_gui/Bld.inf")]
|
|
82 |
self.__compareFileLists(expectedBldInfs, systemModel.GetLayerComponents("Second Layer"))
|
|
83 |
|
|
84 |
self.__compareFileLists([], systemModel.GetLayerComponents("Fifth Layer"))
|
|
85 |
|
|
86 |
self.__compareFileLists([], systemModel.GetLayerComponents("Sixth Layer"))
|
|
87 |
|
|
88 |
|
|
89 |
# Probably redundant, but return local environment (at least its dictionary) to pre-test state
|
|
90 |
os.environ["SOURCEROOT"] = sourceroot
|
|
91 |
|
|
92 |
def __compareFileLists (self, aListOne, aListTwo):
|
|
93 |
|
|
94 |
self.assertEquals(len(aListOne), len(aListTwo))
|
|
95 |
|
|
96 |
i = 0
|
|
97 |
while i < len(aListOne) :
|
|
98 |
self.assertEquals(aListOne[i].GetLocalString().lower(), aListTwo[i].GetLocalString().lower())
|
|
99 |
i = i + 1
|
|
100 |
|
|
101 |
# run all the tests
|
|
102 |
|
|
103 |
from raptor_tests import SmokeTest
|
|
104 |
|
|
105 |
def run():
|
|
106 |
t = SmokeTest()
|
|
107 |
t.id = "999"
|
|
108 |
t.name = "raptor_xml_unit"
|
|
109 |
|
|
110 |
tests = unittest.makeSuite(TestRaptorXML)
|
|
111 |
result = unittest.TextTestRunner(verbosity=2).run(tests)
|
|
112 |
|
|
113 |
if result.wasSuccessful():
|
|
114 |
t.result = SmokeTest.PASS
|
|
115 |
else:
|
|
116 |
t.result = SmokeTest.FAIL
|
|
117 |
|
|
118 |
return t
|