1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
# cerbero - a multi-platform build system for Open Source software
# Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
import shutil
import unittest
import tempfile
from cerbero.config import Platform, Distro, DistroVersion
from cerbero.packages import PackageType
from test.test_packages_common import Package1, Package4, MetaPackage, App
from test.test_build_common import create_cookbook, add_files
from test.test_packages_common import create_store
from test.test_common import DummyConfig
class Config(DummyConfig):
def __init__(self, tmp, platform):
self.prefix = tmp
self.target_platform = platform
class PackageTest(unittest.TestCase):
def setUp(self):
self.tmp = tempfile.mkdtemp()
win32config = Config(self.tmp, Platform.WINDOWS)
linuxconfig = Config(self.tmp, Platform.LINUX)
self.win32package = Package1(win32config, create_store(win32config), create_cookbook(win32config))
self.linuxpackage = Package1(linuxconfig, create_store(linuxconfig), create_cookbook(linuxconfig))
def tearDown(self):
shutil.rmtree(self.tmp)
def testPackageMode(self):
self.assertEqual(self.linuxpackage.name, 'gstreamer-test1')
self.assertEqual(self.linuxpackage.shortdesc, 'GStreamer Test')
self.linuxpackage.set_mode(PackageType.DEVEL)
self.assertEqual(self.linuxpackage.package_mode, PackageType.DEVEL)
self.assertEqual(self.linuxpackage.name, 'gstreamer-test1-devel')
self.assertEqual(self.linuxpackage.shortdesc, 'GStreamer Test (Development Files)')
def testParseFiles(self):
self.assertEqual(self.win32package._recipes_files['recipe1'], ['misc', 'libs', 'bins'])
self.assertEqual(self.win32package._recipes_files['recipe5'], ['libs'])
def testListRecipesDeps(self):
self.assertEqual(self.win32package.recipes_dependencies(), ['recipe1', 'recipe5', 'recipe2'])
self.assertEqual(self.linuxpackage.recipes_dependencies(), ['recipe1', 'recipe2'])
def testFilesList(self):
add_files(self.tmp)
winfiles = [
'README',
'bin/gst-launch.exe',
'bin/libgstreamer-win32.dll',
'bin/libgstreamer-0.10.dll',
'bin/windows.exe',
'libexec/gstreamer-0.10/pluginsloader.exe',
'windows',
'bin/libtest.dll',
]
linuxfiles = [
'README',
'bin/gst-launch',
'bin/linux',
'lib/libgstreamer-x11.so.1',
'lib/libgstreamer-0.10.so.1',
'libexec/gstreamer-0.10/pluginsloader',
'linux',
]
self.assertEqual(sorted(winfiles), sorted(self.win32package.files_list()))
self.assertEqual(sorted(linuxfiles), sorted(self.linuxpackage.files_list()))
def testDevelFilesList(self):
add_files(self.tmp)
devfiles = ['lib/libgstreamer-0.10.a', 'lib/libgstreamer-0.10.la']
linuxdevfiles = devfiles + [
'lib/libgstreamer-0.10.so',
'lib/libgstreamer-x11.a',
'lib/libgstreamer-x11.la',
'lib/libgstreamer-x11.so',
]
windevfiles = devfiles + [
'lib/libgstreamer-win32.a',
'lib/libgstreamer-win32.dll.a',
'lib/libgstreamer-win32.la',
'lib/libgstreamer-win32.def',
'lib/gstreamer-win32.lib',
'lib/libtest.a',
'lib/libtest.dll.a',
'lib/libtest.la',
'lib/libtest.def',
'lib/test.lib',
'lib/libgstreamer-0.10.dll.a',
'lib/libgstreamer-0.10.def',
'lib/gstreamer-0.10.lib',
]
self.assertEqual(sorted(windevfiles), self.win32package.devel_files_list())
self.assertEqual(sorted(linuxdevfiles), self.linuxpackage.devel_files_list())
def testSystemDependencies(self):
config = Config(self.tmp, Platform.LINUX)
config.target_distro = Distro.DEBIAN
package = Package4(config, None, None)
self.assertEqual(package.get_sys_deps(), ['python'])
config.target_distro = Distro.REDHAT
config.target_distro_version = DistroVersion.FEDORA_16
package = Package4(config, None, None)
self.assertEqual(package.get_sys_deps(), ['python27'])
class TestMetaPackages(unittest.TestCase):
def setUp(self):
self.tmp = tempfile.mkdtemp()
config = Config(self.tmp, Platform.LINUX)
self.store = create_store(config)
self.package = MetaPackage(config, self.store)
def tearDown(self):
shutil.rmtree(self.tmp)
def _compareList(self, func_name):
list_func = getattr(self.package, func_name)
packages = [self.store.get_package(x) for x in self.package.list_packages()]
files = []
for package in packages:
list_func = getattr(package, func_name)
files.extend(list_func())
list_func = getattr(self.package, func_name)
self.assertEqual(sorted(files), list_func())
def testListPackages(self):
expected = ['gstreamer-test1', 'gstreamer-test3', 'gstreamer-test-bindings', 'gstreamer-test2']
self.assertEqual(self.package.list_packages(), expected)
def testPlatfromPackages(self):
packages_attr = object.__getattribute__(self.package, 'packages')
self.assertEqual(len(packages_attr), 3)
platform_packages_attr = object.__getattribute__(self.package, 'platform_packages')
self.assertEqual(len(platform_packages_attr), 1)
self.assertEqual(len(self.package.packages), len(packages_attr) + len(platform_packages_attr))
def testFilesList(self):
self._compareList('files_list')
def testDevelFilesList(self):
self._compareList('devel_files_list')
def testAllFilesList(self):
self._compareList('all_files_list')
class AppPackageTest(unittest.TestCase):
def setUp(self):
self.tmp = tempfile.mkdtemp()
config = Config(self.tmp, Platform.LINUX)
self.store = create_store(config)
self.cookbook = create_cookbook(config)
self.app = App(config, self.store, self.cookbook)
def tearDown(self):
shutil.rmtree(self.tmp)
def testListFilesWithEmbededDepsOnLinux(self):
self.app.embed_deps = True
expected = self.app._app_recipe.files_list()
result = self.app.files_list()
self.assertEqual(expected, result)
def testListFilesWithEmbededDeps(self):
self.app.embed_deps = True
self.app.config.target_platform = Platform.WINDOWS
files = []
packages_deps = [self.store.get_package(x) for x in self.app.deps]
for dep in self.app.deps:
packages_deps.extend(self.store.get_package_deps(dep))
packages_deps = list(set(packages_deps))
for package in packages_deps:
files.extend(package.files_list())
files.extend(self.app._app_recipe.files_list())
files = sorted(set(files))
self.assertEqual(files, self.app.files_list())
def testListFilesWithoutEmbededDeps(self):
self.app.embed_deps = False
expected = self.app._app_recipe.files_list()
result = self.app.files_list()
self.assertEqual(expected, result)
def testDevelFilesList(self):
self.assertEqual(self.app.devel_files_list(), [])
def testAllFilesList(self):
self.assertEqual(self.app.files_list(), self.app.all_files_list())
|