0
|
1 |
#
|
|
2 |
# Copyright (c) 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 "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 |
#
|
|
16 |
|
|
17 |
import sys, os, unittest
|
|
18 |
|
|
19 |
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
|
|
20 |
|
|
21 |
from testautomation.base_testcase import BaseTestCase
|
3
|
22 |
from cone.public import exceptions, plugin, api, container, utils
|
0
|
23 |
|
|
24 |
from CRMLPlugin import crml_impl
|
|
25 |
|
|
26 |
def abspath(path):
|
|
27 |
return os.path.normpath(os.path.join(ROOT_PATH, path))
|
|
28 |
|
|
29 |
class TestCrmlImpl(BaseTestCase):
|
|
30 |
|
|
31 |
def test_generate_from_project_with_rfs(self):
|
|
32 |
project_dir = abspath('gen_project')
|
|
33 |
config = 'root.confml'
|
|
34 |
output_dir = abspath('temp/gen_output1')
|
|
35 |
expected_dir = abspath('gen_expected')
|
|
36 |
|
|
37 |
self.remove_if_exists(output_dir)
|
|
38 |
|
|
39 |
prj = api.Project(api.Storage.open(project_dir))
|
|
40 |
config = prj.get_configuration(config)
|
3
|
41 |
gc = plugin.GenerationContext(configuration=config,
|
|
42 |
output=output_dir)
|
|
43 |
|
0
|
44 |
impls = plugin.get_impl_set(config, 'crml$')
|
3
|
45 |
gc.tags['target'] = ['rofs2']
|
|
46 |
gc.filtering_disabled = True
|
|
47 |
impls.generate(gc)
|
|
48 |
impls.post_generate(gc)
|
0
|
49 |
|
|
50 |
self.assert_dir_contents_equal(output_dir, expected_dir, ['.svn'])
|
|
51 |
|
|
52 |
def test_generate_from_project_without_rfs(self):
|
|
53 |
project_dir = abspath('gen_project')
|
|
54 |
config = 'root.confml'
|
|
55 |
output_dir = abspath('temp/gen_output2')
|
|
56 |
expected_dir = abspath('gen_expected')
|
|
57 |
|
|
58 |
self.remove_if_exists(output_dir)
|
|
59 |
|
|
60 |
prj = api.Project(api.Storage.open(project_dir))
|
|
61 |
config = prj.get_configuration(config)
|
3
|
62 |
gc = plugin.GenerationContext(configuration=config,
|
|
63 |
output=output_dir)
|
|
64 |
|
0
|
65 |
impls = plugin.get_impl_set(config, 'crml$')
|
3
|
66 |
gc.tags['target'] = []
|
|
67 |
gc.filtering_disabled = True
|
|
68 |
impls.generate(gc)
|
|
69 |
impls.post_generate(gc)
|
0
|
70 |
|
|
71 |
self.assert_dir_contents_equal(output_dir, expected_dir, ['.svn', 'private'])
|
|
72 |
self.assertFalse(os.path.exists(os.path.join(output_dir, 'private/100059C9/cenrep_rfs.txt')))
|
|
73 |
|
|
74 |
|
|
75 |
def test_generate_from_project_duplicate_rfs(self):
|
|
76 |
project_dir = abspath('duplicate_rfs_project')
|
|
77 |
config = 'root.confml'
|
|
78 |
output_dir = abspath('temp/duplicate_rfs_output')
|
|
79 |
expected_dir = abspath('duplicate_rfs_expected')
|
|
80 |
|
|
81 |
self.remove_if_exists(output_dir)
|
|
82 |
|
|
83 |
prj = api.Project(api.Storage.open(project_dir))
|
|
84 |
config = prj.get_configuration(config)
|
3
|
85 |
gc = plugin.GenerationContext(configuration=config,
|
|
86 |
output=output_dir)
|
0
|
87 |
impls = plugin.get_impl_set(config, 'crml$')
|
3
|
88 |
gc.tags['target'] = ['rofs2']
|
|
89 |
gc.filtering_disabled = True
|
|
90 |
impls.generate(gc)
|
|
91 |
impls.post_generate(gc)
|
0
|
92 |
|
|
93 |
self.assert_dir_contents_equal(output_dir, expected_dir, ['.svn'])
|
|
94 |
|
3
|
95 |
def test_generate_delta_cenreps(self):
|
|
96 |
project_dir = abspath('gen_project')
|
|
97 |
config = 'root2.confml'
|
|
98 |
output_dir = abspath('temp/gen_output_deltacenrep')
|
|
99 |
expected_dir = abspath('gen_expected_deltacenrep')
|
|
100 |
|
|
101 |
self.remove_if_exists(output_dir)
|
|
102 |
|
|
103 |
prj = api.Project(api.Storage.open(project_dir))
|
|
104 |
config = prj.get_configuration(config)
|
|
105 |
gc = plugin.GenerationContext(configuration=config,
|
|
106 |
output=output_dir)
|
|
107 |
# Get refs from the last layer
|
|
108 |
layer = config.get_configuration_by_index(-1)
|
|
109 |
refs = utils.distinct_array(layer.list_leaf_datas())
|
|
110 |
|
|
111 |
impls = plugin.get_impl_set(config, 'crml$')
|
|
112 |
impls = impls | plugin.get_impl_set(config, 'implml$')
|
|
113 |
impls = impls.filter_implementations(refs=refs)
|
|
114 |
|
|
115 |
gc.tags['crml'] = ['deltacenrep']
|
|
116 |
gc.changed_refs = refs
|
|
117 |
gc.filtering_disabled = True
|
|
118 |
impls.generate(gc)
|
|
119 |
impls.post_generate(gc)
|
|
120 |
|
|
121 |
output_dir = os.path.join(output_dir, 'deltacenreps')
|
|
122 |
self.assert_dir_contents_equal(output_dir, expected_dir, ['.svn'])
|