Merge lp:~milo/linaro-image-tools/fix-tests into lp:linaro-image-tools/11.11

Proposed by Milo Casagrande
Status: Merged
Merged at revision: 596
Proposed branch: lp:~milo/linaro-image-tools/fix-tests
Merge into: lp:linaro-image-tools/11.11
Prerequisite: lp:~milo/linaro-image-tools/hwpack-args
Diff against target: 3377 lines (+1102/-656)
13 files modified
linaro-media-create (+0/-4)
linaro_image_tools/hwpack/config.py (+3/-3)
linaro_image_tools/hwpack/hardwarepack.py (+9/-9)
linaro_image_tools/hwpack/tests/__init__.py (+1/-1)
linaro_image_tools/hwpack/tests/test_config.py (+2/-2)
linaro_image_tools/hwpack/tests/test_config_v3.py (+2/-2)
linaro_image_tools/hwpack/tests/test_hardwarepack.py (+2/-2)
linaro_image_tools/media_create/android_boards.py (+34/-26)
linaro_image_tools/media_create/boards.py (+33/-33)
linaro_image_tools/media_create/tests/__init__.py (+21/-2)
linaro_image_tools/media_create/tests/test_android_boards.py (+480/-0)
linaro_image_tools/media_create/tests/test_media_create.py (+498/-572)
linaro_image_tools/tests/__init__.py (+17/-0)
To merge this branch: bzr merge lp:~milo/linaro-image-tools/fix-tests
Reviewer Review Type Date Requested Status
James Tunnicliffe (community) Approve
Данило Шеган (community) Approve
Review via email: mp+138241@code.launchpad.net

Commit message

Test fixes and refactoring.

Description of the change

This is the final branch with test fixes and new test added.
Some work still needs to be done though, 14 tests are still failing.

To post a comment you must log in.
595. By Milo Casagrande

Added MagicMock import, fixed one test.

596. By Milo Casagrande

Fixed almost all tests, 2 to go.

597. By Milo Casagrande

Merged hwpack-args into fix-tests.

598. By Milo Casagrande

Fixed last tests not passing.

Revision history for this message
Milo Casagrande (milo) wrote :

With the last commit all tests should be fine now. There is really the need to kill hwpack v1 though: the vast majority of the tests are dealing with the fixes for v1 or its workarounds.

599. By Milo Casagrande

Merged from pipe, after conflict resolution.

600. By Milo Casagrande

Merged hwpack-args into fix-tests.

601. By Milo Casagrande

Fixed PEP8 warning.

602. By Milo Casagrande

Added missing copyright header, fixed years.

603. By Milo Casagrande

Merged hwpack-args into fix-tests.

604. By Milo Casagrande

Fixed tests with new attribute name.

605. By Milo Casagrande

Merged hwpack-args into fix-tests.

606. By Milo Casagrande

Merged hwpack-args into fix-tests.

607. By Milo Casagrande

Fixed two tests.

608. By Milo Casagrande

Merged hwpack-args into fix-tests.

609. By Milo Casagrande

Fixed arndale tests, cleaned-up code.

610. By Milo Casagrande

Added tests for default instance values with Android boards.

Revision history for this message
Данило Шеган (danilo) wrote :

Make yaml files as strings more readable (make a template, extract into a helper function to put in only the values that you care about in a particular test, etc). Other than that, looks good.

Thanks!

review: Approve
611. By Milo Casagrande

Merged hwpack-args into fix-tests.

612. By Milo Casagrande

Refactored tests: made YAML string a little bit more readable.

613. By Milo Casagrande

Removed wrong method call.

614. By Milo Casagrande

Refactored field name, handled file opening.

615. By Milo Casagrande

Fixed problem with StringIO, now use tmp file.

616. By Milo Casagrande

Refactored and harmonized variable name.

Revision history for this message
James Tunnicliffe (dooferlad) wrote :

226 @@ -132,8 +133,9 @@
227 :return The configuration read from the file as a dictionary.
228 """
229 try:
230 - config = yaml.safe_load(hwpack)
231 - self._set_attributes(config)
232 + with open(hwpack, 'r') as hw:
233 + config = yaml.safe_load(hw)
234 + self._set_attributes(config)
235 return config
236 except yaml.YAMLError, ex:
237 logger.debug("Error loading YAML file %s" % hwpack, ex)

I believe that since we are opening a file inside the with statement, we also need to catch the IOError exception for when the file doesn't exist. Other than that, looks good.

Revision history for this message
Milo Casagrande (milo) wrote :

On Thu, Jan 3, 2013 at 12:24 PM, James Tunnicliffe
<email address hidden> wrote:
> 226 @@ -132,8 +133,9 @@
> 227 :return The configuration read from the file as a dictionary.
> 228 """
> 229 try:
> 230 - config = yaml.safe_load(hwpack)
> 231 - self._set_attributes(config)
> 232 + with open(hwpack, 'r') as hw:
> 233 + config = yaml.safe_load(hw)
> 234 + self._set_attributes(config)
> 235 return config
> 236 except yaml.YAMLError, ex:
> 237 logger.debug("Error loading YAML file %s" % hwpack, ex)
>
> I believe that since we are opening a file inside the with statement, we also need to catch the IOError exception for when the file doesn't exist. Other than that, looks good.

We are actually checking this in linaro-android-media-create, making
sure the arg passed is a real file and it exists, otherwise exit
immediately.

--
Milo Casagrande
Infrastructure Engineer
Linaro.org <www.linaro.org> │ Open source software for ARM SoCs

Revision history for this message
James Tunnicliffe (dooferlad) wrote :

I would be tempted to be ready to catch the exception anyway - could be an unreadable file (permissions) or we may change linaro-android-media-create at some point in the future and lose the existence check. I don't have a strong opinion about it though.

review: Approve
617. By Milo Casagrande

Catch exception on missing file, added test.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'linaro-media-create'
2--- linaro-media-create 2013-01-03 13:57:23 +0000
3+++ linaro-media-create 2013-01-03 13:57:23 +0000
4@@ -133,7 +133,6 @@
5
6 board_config = get_board_config(args.dev)
7 board_config.set_metadata(args.hwpacks, args.bootloader, args.dev)
8- board_config.board(args.dev)
9 board_config.add_boot_args(args.extra_boot_args)
10 board_config.add_boot_args_from_file(args.extra_boot_args_file)
11
12@@ -152,9 +151,6 @@
13 logger.error("Do not use --no-boot or --no-part in conjunction with "
14 "--image_file.")
15 sys.exit(1)
16- else:
17- # All good, move on.
18- pass
19
20 # If --help was specified this won't execute.
21 # Create temp dir and initialize rest of path vars.
22
23=== modified file 'linaro_image_tools/hwpack/config.py'
24--- linaro_image_tools/hwpack/config.py 2012-12-07 08:47:58 +0000
25+++ linaro_image_tools/hwpack/config.py 2013-01-03 13:57:23 +0000
26@@ -296,7 +296,7 @@
27 self._validate_mmc_id()
28 self._validate_extra_boot_options()
29 self._validate_boot_script()
30- self._validate_extra_serial_opts()
31+ self._validate_extra_serial_options()
32 self._validate_snowball_startup_files_config()
33 self._validate_samsung_bl1_start()
34 self._validate_samsung_bl1_len()
35@@ -620,7 +620,7 @@
36 join_list_with=" ")
37
38 @property
39- def extra_serial_opts(self):
40+ def extra_serial_options(self):
41 """Extra serial options.
42
43 A str.
44@@ -1021,7 +1021,7 @@
45 # Optional and tricky to determine a valid pattern.
46 pass
47
48- def _validate_extra_serial_opts(self):
49+ def _validate_extra_serial_options(self):
50 # Optional and tricky to determine a valid pattern.
51 pass
52
53
54=== modified file 'linaro_image_tools/hwpack/hardwarepack.py'
55--- linaro_image_tools/hwpack/hardwarepack.py 2012-12-07 08:47:58 +0000
56+++ linaro_image_tools/hwpack/hardwarepack.py 2013-01-03 13:57:23 +0000
57@@ -128,7 +128,7 @@
58 env_dd=None, boot_script=None,
59 bootloader_file_in_boot_part=None,
60 uboot_dd=None, spl_in_boot_part=None, spl_dd=None,
61- extra_serial_opts=None, loader_start=None,
62+ extra_serial_options=None, loader_start=None,
63 snowball_startup_files_config=None,
64 samsung_bl1_start=None, samsung_bl1_len=None,
65 samsung_env_start=None, samsung_env_len=None,
66@@ -162,7 +162,7 @@
67 self.spl_in_boot_part = spl_in_boot_part
68 self.spl_dd = spl_dd
69 self.env_dd = env_dd
70- self.extra_serial_opts = extra_serial_opts
71+ self.extra_serial_options = extra_serial_options
72 self.snowball_startup_files_config = snowball_startup_files_config
73 self.samsung_bl1_start = samsung_bl1_start
74 self.samsung_bl1_len = samsung_bl1_len
75@@ -216,7 +216,7 @@
76 dtb_file=config.dtb_file,
77 env_dd=config.env_dd,
78 extra_boot_options=config.extra_boot_options,
79- extra_serial_opts=config.extra_serial_opts,
80+ extra_serial_options=config.extra_serial_options,
81 initrd_addr=config.initrd_addr,
82 initrd=config.initrd,
83 kernel_addr=config.kernel_addr,
84@@ -320,12 +320,12 @@
85 metadata += dump({DTB_FILES_FIELD: self.dtb_files})
86 if self.boot_script is not None:
87 metadata += dump({BOOT_SCRIPT_FIELD: self.boot_script})
88- if self.extra_serial_opts is not None:
89+ if self.extra_serial_options is not None:
90 # XXX Check why and where once we get a list once a string.
91- if isinstance(self.extra_serial_opts, list):
92- extra_serial_options = " ".join(self.extra_serial_opts)
93+ if isinstance(self.extra_serial_options, list):
94+ extra_serial_options = " ".join(self.extra_serial_options)
95 else:
96- extra_serial_options = self.extra_serial_opts
97+ extra_serial_options = self.extra_serial_options
98 metadata += dump({
99 EXTRA_SERIAL_OPTIONS_FIELD:
100 extra_serial_options})
101@@ -417,8 +417,8 @@
102 metadata += "SPL_DD=%s\n" % self.spl_dd
103 if self.env_dd is not None:
104 metadata += "ENV_DD=%s\n" % self.env_dd
105- if self.extra_serial_opts is not None:
106- metadata += "EXTRA_SERIAL_OPTIONS=%s\n" % self.extra_serial_opts
107+ if self.extra_serial_options is not None:
108+ metadata += "EXTRA_SERIAL_OPTIONS=%s\n" % self.extra_serial_options
109 if self.snowball_startup_files_config is not None:
110 metadata += "SNOWBALL_STARTUP_FILES_CONFIG=%s\n" % (
111 self.snowball_startup_files_config)
112
113=== modified file 'linaro_image_tools/hwpack/tests/__init__.py'
114--- linaro_image_tools/hwpack/tests/__init__.py 2012-07-25 09:00:58 +0000
115+++ linaro_image_tools/hwpack/tests/__init__.py 2013-01-03 13:57:23 +0000
116@@ -1,4 +1,4 @@
117-# Copyright (C) 2010, 2011 Linaro
118+# Copyright (C) 2010, 2011, 2012 Linaro
119 #
120 # Author: James Westby <james.westby@linaro.org>
121 #
122
123=== modified file 'linaro_image_tools/hwpack/tests/test_config.py'
124--- linaro_image_tools/hwpack/tests/test_config.py 2012-08-28 17:34:16 +0000
125+++ linaro_image_tools/hwpack/tests/test_config.py 2013-01-03 13:57:23 +0000
126@@ -503,11 +503,11 @@
127 "omapfb.vram=0:24M mem=456M@0x80000000 mem=512M@0xA0000000",
128 config.extra_boot_options)
129
130- def test_extra_serial_opts(self):
131+ def test_extra_serial_options(self):
132 config = self.get_config(self.valid_complete_v2 + self.valid_end)
133 config.validate()
134 self.assertEqual("console=tty0 console=ttyO2,115200n8",
135- config.extra_serial_opts)
136+ config.extra_serial_options)
137
138 def test_boot_script(self):
139 config = self.get_config(self.valid_complete_v2 + self.valid_end)
140
141=== modified file 'linaro_image_tools/hwpack/tests/test_config_v3.py'
142--- linaro_image_tools/hwpack/tests/test_config_v3.py 2012-12-27 10:29:42 +0000
143+++ linaro_image_tools/hwpack/tests/test_config_v3.py 2013-01-03 13:57:23 +0000
144@@ -518,11 +518,11 @@
145 "omapfb.vram=0:24M mem=456M@0x80000000 mem=512M@0xA0000000",
146 config.extra_boot_options)
147
148- def test_extra_serial_opts(self):
149+ def test_extra_serial_options(self):
150 config = self.get_config(self.valid_complete_v3 + self.valid_end)
151 config.validate()
152 self.assertEqual('console=tty0 console=ttyO2,115200n8',
153- config.extra_serial_opts)
154+ config.extra_serial_options)
155
156 def test_boot_script(self):
157 config = self.get_config(self.valid_complete_v3 + self.valid_end)
158
159=== modified file 'linaro_image_tools/hwpack/tests/test_hardwarepack.py'
160--- linaro_image_tools/hwpack/tests/test_hardwarepack.py 2012-07-23 14:44:37 +0000
161+++ linaro_image_tools/hwpack/tests/test_hardwarepack.py 2013-01-03 13:57:23 +0000
162@@ -257,7 +257,7 @@
163 metadata = Metadata("ahwpack", "4", "armel",
164 format=HardwarePackFormatV2())
165 metadata.add_v2_config(
166- extra_serial_opts='console=tty0 console=ttyO2,115200n8')
167+ extra_serial_options='console=tty0 console=ttyO2,115200n8')
168 expected_out = ("NAME=ahwpack\nVERSION=4\n"
169 "ARCHITECTURE=armel\nEXTRA_SERIAL_OPTIONS="
170 "console=tty0 console=ttyO2,115200n8\n")
171@@ -335,7 +335,7 @@
172 format=HardwarePackFormatV3())
173 options = ['option1', 'option2,option3']
174 # Need to call also this one!
175- metadata.add_v2_config(extra_serial_opts=options)
176+ metadata.add_v2_config(extra_serial_options=options)
177 metadata.add_v3_config(bootloaders=None)
178 expected_out = ("format: '3.0'\nname: ahwpack\nversion: '4'\n"
179 "architecture: armel\nextra_serial_options: option1 "
180
181=== modified file 'linaro_image_tools/media_create/android_boards.py'
182--- linaro_image_tools/media_create/android_boards.py 2013-01-03 13:57:23 +0000
183+++ linaro_image_tools/media_create/android_boards.py 2013-01-03 13:57:23 +0000
184@@ -32,6 +32,7 @@
185 import logging
186
187 from linaro_image_tools import cmd_runner
188+from linaro_image_tools.hwpack.hwpack_fields import FORMAT_FIELD
189 from linaro_image_tools.media_create.partitions import SECTOR_SIZE
190 from linaro_image_tools.media_create.boards import (
191 BeagleConfig,
192@@ -68,7 +69,7 @@
193 def __init__(self):
194 super(AndroidBoardConfig, self).__init__()
195 self.dtb_name = None
196- self._extra_serial_opts = []
197+ self._extra_serial_options = []
198 self._android_specific_args = []
199 self._extra_boot_args_options = []
200 self._live_serial_options = []
201@@ -97,17 +98,17 @@
202 extra_boot_args_options = property(_get_extra_boot_args_options,
203 _set_extra_boot_args_options)
204
205- def _get_extra_serial_opts(self):
206- extra_serial = self._extra_serial_opts
207+ def _get_extra_serial_options(self):
208+ extra_serial = self._extra_serial_options
209 if isinstance(extra_serial, list):
210- extra_serial = ' '.join(self._extra_serial_opts)
211+ extra_serial = ' '.join(self._extra_serial_options)
212 return extra_serial
213
214- def _set_extra_serial_opts(self, value):
215- self._extra_serial_opts = value
216+ def _set_extra_serial_options(self, value):
217+ self._extra_serial_options = value
218
219- extra_serial_opts = property(_get_extra_serial_opts,
220- _set_extra_serial_opts)
221+ extra_serial_options = property(_get_extra_serial_options,
222+ _set_extra_serial_options)
223
224 def _get_live_serial_options(self):
225 serial_options = self._live_serial_options
226@@ -132,13 +133,18 @@
227 :return The configuration read from the file as a dictionary.
228 """
229 try:
230- config = yaml.safe_load(hwpack)
231+ with open(hwpack, 'r') as hw:
232+ config = yaml.safe_load(hw)
233 self._set_attributes(config)
234 return config
235 except yaml.YAMLError, ex:
236 logger.debug("Error loading YAML file %s" % hwpack, ex)
237 raise BoardConfigException("Error reading Android hwpack %s"
238 % hwpack)
239+ except IOError, ex:
240+ logger.debug("Error reading hwpack file %s" % hwpack, ex)
241+ raise BoardConfigException("Android hwpack %s could not be found"
242+ % hwpack)
243
244 def _set_attributes(self, config):
245 """Initialize the class attributes with the values read from the
246@@ -147,7 +153,9 @@
247 :param config: The config read from the Android hwpack.
248 """
249 for name, value in config.iteritems():
250- if hasattr(self, name):
251+ if name == FORMAT_FIELD:
252+ setattr(self, 'hwpack_format', value)
253+ elif hasattr(self, name):
254 setattr(self, name, value)
255 else:
256 logger.warning("Attribute '%s' does not belong to this "
257@@ -162,7 +170,7 @@
258 if self.extra_boot_args_options:
259 boot_args_options += ' %s' % self.extra_boot_args_options
260 boot_args_options += ' %s' % self.android_specific_args
261- serial_opts = self.extra_serial_opts
262+ serial_opts = self.extra_serial_options
263 for console in consoles:
264 serial_opts += ' console=%s' % console
265
266@@ -281,7 +289,7 @@
267 def __init__(self):
268 super(AndroidBeagleConfig, self).__init__()
269 self._android_specific_args = 'init=/init androidboot.console=ttyO2'
270- self._extra_serial_opts = 'console=tty0 console=ttyO2,115200n8'
271+ self._extra_serial_options = 'console=tty0 console=ttyO2,115200n8'
272
273
274 class AndroidPandaConfig(AndroidBoardConfig, PandaConfig):
275@@ -289,7 +297,7 @@
276 def __init__(self):
277 super(AndroidPandaConfig, self).__init__()
278 self.dtb_name = 'board.dtb'
279- self._extra_serial_opts = 'console=ttyO2,115200n8'
280+ self._extra_serial_options = 'console=ttyO2,115200n8'
281 self._extra_boot_args_options = (
282 'earlyprintk fixrtc nocompcache vram=48M '
283 'omapfb.vram=0:24M,1:24M mem=456M@0x80000000 mem=512M@0xA0000000')
284@@ -307,7 +315,7 @@
285 self._extra_boot_args_options = (
286 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
287 'mem=22M@360M mem_issw=1M@383M mem=640M@384M vmalloc=500M')
288- self._extra_serial_opts = 'console=ttyAMA2,115200n8'
289+ self._extra_serial_options = 'console=ttyAMA2,115200n8'
290 self.boot_script = 'boot.scr'
291 self.fdt_high = '0x05000000'
292 self.initrd_addr = '0x05000000'
293@@ -323,7 +331,7 @@
294 self._extra_boot_args_options = (
295 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
296 'mem=22M@360M mem_issw=1M@383M mem=640M@384M vmalloc=500M')
297- self._extra_serial_opts = 'console=ttyAMA2,115200n8'
298+ self._extra_serial_options = 'console=ttyAMA2,115200n8'
299 self._android_specific_args = 'init=/init androidboot.console=ttyAMA2'
300 self.boot_script = 'boot.scr'
301 self.fdt_high = '0x05000000'
302@@ -379,11 +387,11 @@
303 super(AndroidMx53LoCoConfig, self).__init__()
304 self._extra_boot_args_options = (
305 'earlyprintk rootdelay=1 fixrtc nocompcache di1_primary tve')
306- self._extra_serial_opts = 'console=%s,115200n8'
307+ self._extra_serial_options = 'console=%s,115200n8'
308 self._android_specific_args = 'init=/init androidboot.console=%s'
309
310- def _get_extra_serial_opts(self):
311- serial_opts = self._extra_serial_opts
312+ def _get_extra_serial_options(self):
313+ serial_opts = self._extra_serial_options
314 if serial_opts:
315 if isinstance(serial_opts, list):
316 serial_opts = ' '.join(serial_opts)
317@@ -391,11 +399,11 @@
318 serial_opts = serial_opts % self.serial_tty
319 return serial_opts
320
321- def _set_extra_serial_opts(self, value):
322- self._extra_serial_opts = value
323+ def _set_extra_serial_options(self, value):
324+ self._extra_serial_options = value
325
326- extra_serial_opts = property(_get_extra_serial_opts,
327- _set_extra_serial_opts)
328+ extra_serial_options = property(_get_extra_serial_options,
329+ _set_extra_serial_options)
330
331 def _get_android_specific_args(self):
332 android_args = self._android_specific_args
333@@ -461,7 +469,7 @@
334 """Placeholder class for SMDKV310 configuration inheritance."""
335 def __init__(self):
336 super(AndroidSMDKV310Config, self).__init__()
337- self._extra_serial_opts = 'console=tty0 console=ttySAC1,115200n8'
338+ self._extra_serial_options = 'console=tty0 console=ttySAC1,115200n8'
339 self._android_specific_args = 'init=/init androidboot.console=ttySAC1'
340
341
342@@ -469,14 +477,14 @@
343 """Placeholder class for Origen configuration inheritance."""
344 def __init__(self):
345 super(AndroidOrigenConfig, self).__init__()
346- self._extra_serial_opts = 'console=tty0 console=ttySAC2,115200n8'
347+ self._extra_serial_options = 'console=tty0 console=ttySAC2,115200n8'
348 self._android_specific_args = 'init=/init androidboot.console=ttySAC2'
349
350
351 class AndroidOrigenQuadConfig(AndroidSamsungConfig, OrigenQuadConfig):
352 def __init__(self):
353 super(AndroidOrigenQuadConfig, self).__init__()
354- self._extra_serial_opts = 'console=tty0 console=ttySAC2,115200n8'
355+ self._extra_serial_options = 'console=tty0 console=ttySAC2,115200n8'
356 self._android_specific_args = 'init=/init androidboot.console=ttySAC2'
357
358
359@@ -484,7 +492,7 @@
360 """Placeholder class for Vexpress configuration inheritance."""
361 def __init__(self):
362 super(AndroidVexpressConfig, self).__init__()
363- self._extra_serial_opts = 'console=tty0 console=ttyAMA0,38400n8'
364+ self._extra_serial_options = 'console=tty0 console=ttyAMA0,38400n8'
365 self._android_specific_args = 'init=/init androidboot.console=ttyAMA0'
366
367
368
369=== modified file 'linaro_image_tools/media_create/boards.py'
370--- linaro_image_tools/media_create/boards.py 2013-01-03 13:57:23 +0000
371+++ linaro_image_tools/media_create/boards.py 2013-01-03 13:57:23 +0000
372@@ -69,7 +69,7 @@
373 SAMSUNG_BL2_LEN_FIELD,
374 SAMSUNG_BL2_START_FIELD,
375 SAMSUNG_ENV_LEN_FIELD,
376- SAMSUNG_ENV_START_FILED,
377+ SAMSUNG_ENV_START_FIELD,
378 SERIAL_TTY_FIELD,
379 SNOWBALL_STARTUP_FILES_CONFIG_FIELD,
380 SPL_DD_FIELD,
381@@ -150,7 +150,7 @@
382 # leading underscore. It is done in this way since sublcasses use
383 # placeholders in the string for dinamically change values. But this
384 # is done only for hwpack v1.
385- self._extra_serial_opts = ''
386+ self._extra_serial_options = ''
387 self._live_serial_opts = ''
388 self.board = None
389 self.boot_script = None
390@@ -198,7 +198,7 @@
391 #
392 # samsung_bl1_{start,len}: Offset and maximum size for BL1
393 # samsung_bl2_{start,len}: Offset and maximum size for BL2
394- # samsung_env_{start,len}: Offset and maximum size for Environment settings
395+ # samsung_env_{start,len}: Offset and maximum size for settings
396 #
397 self.samsung_bl1_start = 1
398 self.samsung_bl1_len = 32
399@@ -223,17 +223,17 @@
400 live_serial_opts = property(_get_live_serial_opts, _set_live_serial_opts)
401
402 # XXX: can be removed when killing v1 hwpack.
403- def _get_extra_serial_opts(self):
404- return_value = self._extra_serial_opts
405+ def _get_extra_serial_options(self):
406+ return_value = self._extra_serial_options
407 if self._check_placeholder_presence(return_value, r'%s'):
408 return_value = return_value % self.serial_tty
409 return return_value
410
411- def _set_extra_serial_opts(self, value):
412- self._extra_serial_opts = value
413+ def _set_extra_serial_options(self, value):
414+ self._extra_serial_options = value
415
416- extra_serial_opts = property(_get_extra_serial_opts,
417- _set_extra_serial_opts)
418+ extra_serial_options = property(_get_extra_serial_options,
419+ _set_extra_serial_options)
420
421 def get_metadata_field(self, field_name):
422 """ Return the metadata value for field_name if it can be found.
423@@ -269,8 +269,8 @@
424 self.samsung_bl1_len = None
425 self.samsung_env_len = None
426 self.samsung_bl2_len = None
427- # cls.samsung_bl2_start and cls.samsung_env_start should
428- # be initialized to default values for backward compatibility.
429+ # self.samsung_bl2_start and self.samsung_env_start should
430+ # be initialized to default value for backward compatibility.
431
432 self.board = board
433 # Set new values from metadata.
434@@ -296,7 +296,7 @@
435 self.extra_boot_args_options = self.get_metadata_field(
436 EXTRA_BOOT_OPTIONS_FIELD)
437 self.boot_script = self.get_metadata_field(BOOT_SCRIPT_FIELD)
438- self.extra_serial_opts = self.get_metadata_field(
439+ self.extra_serial_options = self.get_metadata_field(
440 EXTRA_SERIAL_OPTIONS_FIELD)
441 self.snowball_startup_files_config = self.get_metadata_field(
442 SNOWBALL_STARTUP_FILES_CONFIG_FIELD)
443@@ -376,16 +376,16 @@
444 samsung_env_len = self.get_metadata_field(SAMSUNG_ENV_LEN_FIELD)
445 if samsung_env_len:
446 self.samsung_v310_env_len = int(samsung_env_len)
447+ samsung_bl2_start = \
448+ self.get_metadata_field(SAMSUNG_BL2_START_FIELD)
449+ if samsung_bl2_start:
450+ self.samsung_bl2_start = int(samsung_bl2_start)
451 samsung_bl2_len = self.get_metadata_field(SAMSUNG_BL2_LEN_FIELD)
452 if samsung_bl2_len:
453 self.samsung_v310_bl2_len = int(samsung_bl2_len)
454- samsung_bl2_start = self.get_metadata_field(
455- SAMSUNG_BL2_START_FIELD)
456- if samsung_bl2_start:
457- self.samsung_bl2_start = int(samsung_bl2_start)
458- samsung_env_start = self.get_metadata_field(
459- SAMSUNG_ENV_START_FILED)
460- if samsung_env_start:
461+ samsung_env_start = \
462+ self.get_metadata_field(SAMSUNG_ENV_START_FIELD)
463+ if samsung_env_start is not None:
464 self.samsung_env_start = int(samsung_env_start)
465
466 self.bootloader_copy_files = self.hardwarepack_handler.get_field(
467@@ -540,7 +540,7 @@
468 boot_args_options = 'rootwait ro'
469 if self.extra_boot_args_options:
470 boot_args_options += ' %s' % self.extra_boot_args_options
471- serial_opts = self.extra_serial_opts
472+ serial_opts = self.extra_serial_options
473 for console in consoles:
474 serial_opts += ' console=%s' % console
475
476@@ -945,7 +945,7 @@
477 self.kernel_addr = '0x80000000'
478 self.load_addr = '0x80008000'
479 self._serial_tty = 'ttyO2'
480- self._extra_serial_opts = 'console=tty0 console=%s,115200n8'
481+ self._extra_serial_options = 'console=tty0 console=%s,115200n8'
482 self._live_serial_opts = 'serialtty=%s'
483
484
485@@ -962,7 +962,7 @@
486 self.initrd_addr = '0x81600000'
487 self.kernel_addr = '0x80000000'
488 self.load_addr = '0x80008000'
489- self._extra_serial_opts = 'console=tty0 console=%s,115200n8'
490+ self._extra_serial_options = 'console=tty0 console=%s,115200n8'
491 self._serial_tty = 'ttyO2'
492
493
494@@ -980,7 +980,7 @@
495 self.initrd_addr = '0x81600000'
496 self.kernel_addr = '0x80200000'
497 self.load_addr = '0x80008000'
498- self._extra_serial_opts = 'console=tty0 console=%s,115200n8'
499+ self._extra_serial_options = 'console=tty0 console=%s,115200n8'
500 self._live_serial_opts = 'serialtty=%s'
501
502
503@@ -1019,7 +1019,7 @@
504 self.load_addr = '0x00008000'
505 self.mmc_option = '1:1'
506 self.serial_tty = 'ttyAMA2'
507- self._extra_serial_opts = 'console=tty0 console=%s,115200n8'
508+ self._extra_serial_options = 'console=tty0 console=%s,115200n8'
509 self._live_serial_opts = 'serialtty=%s'
510
511 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
512@@ -1230,7 +1230,7 @@
513 self.mmc_option = '0:2'
514 self.mmc_part_offset = 1
515 self.serial_tty = 'ttymxc0'
516- self._extra_serial_opts = 'console=tty0 console=%s,115200n8'
517+ self._extra_serial_options = 'console=tty0 console=%s,115200n8'
518 self._live_serial_opts = 'serialtty=%s'
519
520 def get_v1_sfdisk_cmd(self, should_align_boot_part=None):
521@@ -1341,7 +1341,7 @@
522 self.kernel_flavors = ['linaro-vexpress']
523 self.load_addr = '0x60008000'
524 self.serial_tty = 'ttyAMA0'
525- self._extra_serial_opts = 'console=tty0 console=%s,38400n8'
526+ self._extra_serial_options = 'console=tty0 console=%s,38400n8'
527 self._live_serial_opts = 'serialtty=%s'
528
529 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
530@@ -1390,7 +1390,7 @@
531 class SamsungConfig(BoardConfig):
532 def __init__(self):
533 super(SamsungConfig, self).__init__()
534- self._extra_serial_opts = None
535+ self._extra_serial_options = None
536
537 def get_v1_sfdisk_cmd(self, should_align_boot_part=False):
538 # bootloaders partition needs to hold BL1, U-Boot environment, and BL2
539@@ -1505,7 +1505,7 @@
540 self.mmc_option = '0:2'
541 self.mmc_part_offset = 1
542 self.serial_tty = 'ttySAC1'
543- self._extra_serial_opts = 'console=%s,115200n8'
544+ self._extra_serial_options = 'console=%s,115200n8'
545
546 def _get_boot_env(self, is_live, is_lowmem, consoles, rootfs_id,
547 i_img_data, d_img_data):
548@@ -1531,7 +1531,7 @@
549 self.mmc_option = '0:2'
550 self.mmc_part_offset = 1
551 self.serial_tty = 'ttySAC2'
552- self._extra_serial_opts = 'console=%s,115200n8'
553+ self._extra_serial_options = 'console=%s,115200n8'
554
555
556 class OrigenQuadConfig(SamsungConfig):
557@@ -1549,7 +1549,7 @@
558 self.samsung_bl2_start = 49
559 self.samsung_env_start = 1073
560 self.serial_tty = 'ttySAC2'
561- self._extra_serial_opts = 'console=%s,115200n8'
562+ self._extra_serial_options = 'console=%s,115200n8'
563
564
565 class ArndaleConfig(SamsungConfig):
566@@ -1568,7 +1568,7 @@
567 self.samsung_bl2_start = 49
568 self.samsung_env_start = 1073
569 self.serial_tty = 'ttySAC2'
570- self._extra_serial_opts = 'console=%s,115200n8'
571+ self._extra_serial_options = 'console=%s,115200n8'
572
573
574 class I386Config(BoardConfig):
575@@ -1587,7 +1587,7 @@
576 super(I386Config, self).__init__()
577 self.kernel_flavors = ['generic', 'pae']
578 self.serial_tty = 'ttyS0'
579- self._extra_serial_opts = 'console=tty0 console=%s,115200n8'
580+ self._extra_serial_options = 'console=tty0 console=%s,115200n8'
581 self._live_serial_opts = 'serialtty=%s'
582
583 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
584@@ -1609,7 +1609,7 @@
585
586 # generate loader config file
587 loader_config = self.BOOTLOADER_CFG % (os.path.basename(k_img_data),
588- self.extra_serial_opts, os.path.basename(i_img_data))
589+ self.extra_serial_options, os.path.basename(i_img_data))
590
591 _, tmpfile = tempfile.mkstemp()
592 atexit.register(os.unlink, tmpfile)
593
594=== modified file 'linaro_image_tools/media_create/tests/__init__.py'
595--- linaro_image_tools/media_create/tests/__init__.py 2012-06-07 13:12:42 +0000
596+++ linaro_image_tools/media_create/tests/__init__.py 2013-01-03 13:57:23 +0000
597@@ -1,9 +1,28 @@
598+# Copyright (C) 2010, 2011, 2012 Linaro
599+#
600+# This file is part of Linaro Image Tools.
601+#
602+# Linaro Image Tools is free software: you can redistribute it and/or modify
603+# it under the terms of the GNU General Public License as published by
604+# the Free Software Foundation, either version 3 of the License, or
605+# (at your option) any later version.
606+#
607+# Linaro Image Tools is distributed in the hope that it will be useful,
608+# but WITHOUT ANY WARRANTY; without even the implied warranty of
609+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
610+# GNU General Public License for more details.
611+#
612+# You should have received a copy of the GNU General Public License
613+# along with this program. If not, see <http://www.gnu.org/licenses/>.
614+
615 import unittest
616
617
618 def test_suite():
619- module_names = ['linaro_image_tools.media_create.tests.test_media_create',
620- ]
621+ module_names = [
622+ 'linaro_image_tools.media_create.tests.test_media_create',
623+ 'linaro_image_tools.media_create.tests.test_android_boards',
624+ ]
625 loader = unittest.TestLoader()
626 suite = loader.loadTestsFromNames(module_names)
627 return suite
628
629=== added file 'linaro_image_tools/media_create/tests/test_android_boards.py'
630--- linaro_image_tools/media_create/tests/test_android_boards.py 1970-01-01 00:00:00 +0000
631+++ linaro_image_tools/media_create/tests/test_android_boards.py 2013-01-03 13:57:23 +0000
632@@ -0,0 +1,480 @@
633+# Copyright (C) 2010, 2011 Linaro
634+#
635+# Author: Milo Casagrande <milo.casagrande@linaro.org>
636+#
637+# This file is part of Linaro Image Tools.
638+#
639+# Linaro Image Tools is free software: you can redistribute it and/or modify
640+# it under the terms of the GNU General Public License as published by
641+# the Free Software Foundation, either version 3 of the License, or
642+# (at your option) any later version.
643+#
644+# Linaro Image Tools is distributed in the hope that it will be useful,
645+# but WITHOUT ANY WARRANTY; without even the implied warranty of
646+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
647+# GNU General Public License for more details.
648+#
649+# You should have received a copy of the GNU General Public License
650+# along with this program. If not, see <http://www.gnu.org/licenses/>.
651+
652+from testtools import TestCase
653+
654+from linaro_image_tools.media_create.boards import (
655+ BoardConfigException,
656+ )
657+
658+from linaro_image_tools.media_create.android_boards import (
659+ AndroidBeagleConfig,
660+ get_board_config,
661+ )
662+
663+from linaro_image_tools.testing import TestCaseWithFixtures
664+from linaro_image_tools.tests.fixtures import CreateTempFileFixture
665+
666+
667+class TestAndroidBoards(TestCase):
668+ """Class to test small things in android_boards."""
669+
670+ def test_get_board_config(self):
671+ instance = get_board_config('beagle')
672+ self.assertIsInstance(instance, AndroidBeagleConfig)
673+
674+ def test_get_board_config_wrong(self):
675+ self.assertRaises(BoardConfigException, get_board_config, 'notadevice')
676+
677+ def test_hwpack_not_exists(self):
678+ instance = get_board_config('beagle')
679+ self.assertRaises(BoardConfigException, instance.from_file, 'a_file')
680+
681+
682+class TestAndroidBoardsHwpack(TestCaseWithFixtures):
683+ """Class to test the new Android hwpack configuration file."""
684+
685+ # All the necessary Android hwpack fields for the tests.
686+ hwpack_format = 'format: 3.0\n'
687+ hwpack_dtb_name = 'dtb_name: %(dtb_name)s\n'
688+ hwpack_fdt_high = "fdt_high: '%(fdt_high)s'\n"
689+ hwpack_fat_size = 'fat_size: 16\n'
690+ hwpack_android_args = 'android_specific_args: %(android_specific_args)s\n'
691+ hwpack_extra_serial = 'extra_serial_options: %(extra_serial_options)s\n'
692+ hwpack_extra_boot = ('extra_boot_args_options: '
693+ '%(extra_boot_args_options)s\n')
694+ hwpack_bootloader_flavor = 'bootloader_flavor: %(bootloader_flavor)s\n'
695+ hwpack_initrd_addr = 'initrd_addr: \'%(initrd_addr)s\'\n'
696+ hwpack_initrd_high = 'initrd_high: \'%(initrd_high)s\'\n'
697+ hwpack_kernel_addr = 'kernel_addr: \'%(kernel_addr)s\'\n'
698+ hwpack_load_addr = 'load_addr: \'%(load_addr)s\'\n'
699+ hwpack_dtb_addr = 'dtb_addr: \'%(dtb_addr)s\'\n'
700+ hwpack_boot_script = 'boot_script: %(boot_script)s\n'
701+ hwpack_mmc_option = 'mmc_option: \'%(mmc_option)s\'\n'
702+
703+ # Some defaults YAML-like strings to use for the tests.
704+ android_hwpack_base = (hwpack_format + hwpack_dtb_name)
705+ android_hwpack_simple = (android_hwpack_base + hwpack_fdt_high +
706+ hwpack_fat_size)
707+ android_hwpack_android_args = (android_hwpack_base + hwpack_android_args)
708+ android_hwpack_extra_serial = (android_hwpack_base + hwpack_extra_serial)
709+ android_hwpack_extra_boot = (android_hwpack_base + hwpack_extra_boot)
710+
711+ android_hwpack_panda = (
712+ hwpack_format + hwpack_android_args + hwpack_bootloader_flavor +
713+ hwpack_dtb_addr + hwpack_dtb_name + hwpack_extra_boot +
714+ hwpack_extra_serial
715+ )
716+
717+ android_hwpack_mx6 = (
718+ android_hwpack_panda + hwpack_initrd_addr + hwpack_kernel_addr +
719+ hwpack_load_addr
720+ )
721+
722+ android_hwpack_snowball_sd = (
723+ hwpack_android_args + hwpack_boot_script + hwpack_dtb_addr +
724+ hwpack_dtb_name + hwpack_extra_boot + hwpack_extra_serial +
725+ hwpack_fdt_high + hwpack_format + hwpack_initrd_addr
726+ )
727+
728+ android_hwpack_snowball_emmc = (
729+ android_hwpack_snowball_sd + hwpack_initrd_high + hwpack_mmc_option)
730+
731+ def setUp(self):
732+ super(TestAndroidBoardsHwpack, self).setUp()
733+ # Pick a default board.
734+ self.config = get_board_config('beagle')
735+
736+ def _get_tmp_file_name(self, content=None):
737+ name = self.useFixture(CreateTempFileFixture(content)).get_file_name()
738+ return name
739+
740+ def assertBootEnv(self, expected, config=None, board='beagle'):
741+ """Helper function the boot env parameters.
742+
743+ :param config: The string containing the YAML configuration.
744+ :type str
745+ :param expected: The expected configuration.
746+ :type dict
747+ :param board: The name of the board to test. Defaults to beagle.
748+ :type str
749+ """
750+ board_conf = get_board_config(board)
751+ if config:
752+ name = self.useFixture(CreateTempFileFixture(config)).\
753+ get_file_name()
754+ board_conf.from_file(name)
755+ self.assertEqual(expected, board_conf._get_boot_env(consoles=[]))
756+
757+ def test_read_from_file(self):
758+ values = {'fdt_high': '0xFFFFFFFF', 'dtb_name': 'a_name'}
759+ expected = {'format': 3.0, 'dtb_name': 'a_name',
760+ 'fdt_high': '0xFFFFFFFF', 'fat_size': 16}
761+ yaml_conf = self.android_hwpack_simple % values
762+ name = self._get_tmp_file_name(yaml_conf)
763+ conf = self.config.from_file(name)
764+ self.assertEqual(expected, conf)
765+
766+ def test_android_specific_args(self):
767+ """The field android_specific_args should be a concatenated string."""
768+ values = {'android_specific_args': ['init=/init',
769+ 'androidboot.console=ttyO2'],
770+ 'dtb_name': 'a_name'}
771+ yaml_conf = self.android_hwpack_android_args % values
772+ name = self._get_tmp_file_name(yaml_conf)
773+ self.config.from_file(name)
774+ expected = 'init=/init androidboot.console=ttyO2'
775+ self.assertEqual(expected, self.config.android_specific_args)
776+
777+ def test_extra_serial_options(self):
778+ """The field extra_serial_options should be a concatenated string."""
779+ values = {'dtb_name': 'a_name',
780+ 'extra_serial_options': ['console=tty0',
781+ 'console=ttyO2,115200n8']}
782+ yaml_conf = self.android_hwpack_extra_serial % values
783+ name = self._get_tmp_file_name(yaml_conf)
784+ self.config.from_file(name)
785+ expected = 'console=tty0 console=ttyO2,115200n8'
786+ self.assertEqual(expected, self.config.extra_serial_options)
787+
788+ def test_extra_boot_args_options(self):
789+ """The field extra_boot_args_options should be a concatenated string.
790+ Testing presence of a field defined in the parent class."""
791+ values = {'dtb_name': 'a_name',
792+ 'extra_boot_args_options': ['earlyprintk', 'mem=128M@0',
793+ 'mali.mali_mem=64M@128M']
794+ }
795+ yaml_conf = self.android_hwpack_extra_boot % values
796+ name = self._get_tmp_file_name(yaml_conf)
797+ self.config.from_file(name)
798+ expected = 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M'
799+ self.assertEqual(expected, self.config.extra_boot_args_options)
800+
801+ def test_android_mx6(self):
802+ values = {
803+ "android_specific_args": ["init=/init", "androidboot.console=%s"],
804+ "bootloader_flavor": "mx6qsabrelite",
805+ "dtb_addr": '0x11ff0000',
806+ "dtb_name": "board.dtb",
807+ "extra_boot_args_options": ["earlyprintk", "rootdelay=1",
808+ "fixrtc", "nocompcache",
809+ "di1_primary", "tve"],
810+ "extra_serial_options": ["console=%s,115200n8"],
811+ "initrd_addr": '0x12000000',
812+ "kernel_addr": '0x10000000',
813+ "load_addr": '0x10008000',
814+ }
815+ expected = {
816+ 'bootargs': 'console=ttymxc0,115200n8 '
817+ 'rootwait ro earlyprintk rootdelay=1 fixrtc '
818+ 'nocompcache di1_primary tve init=/init '
819+ 'androidboot.console=ttymxc0',
820+ 'bootcmd': 'fatload mmc 0:2 0x10000000 uImage; '
821+ 'fatload mmc 0:2 0x12000000 uInitrd; '
822+ 'fatload mmc 0:2 0x11ff0000 board.dtb; '
823+ 'bootm 0x10000000 0x12000000 0x11ff0000',
824+ 'fdt_high': '0xffffffff',
825+ 'initrd_high': '0xffffffff'}
826+ config = self.android_hwpack_mx6 % values
827+ self.assertBootEnv(expected, config=config, board='mx6qsabrelite')
828+
829+ def test_android_mx6_old(self):
830+ # Old test: use the values from the class, instead of passing them.
831+ expected = {
832+ 'bootargs': 'console=ttymxc0,115200n8 '
833+ 'rootwait ro earlyprintk rootdelay=1 fixrtc '
834+ 'nocompcache di1_primary tve init=/init '
835+ 'androidboot.console=ttymxc0',
836+ 'bootcmd': 'fatload mmc 0:2 0x10000000 uImage; '
837+ 'fatload mmc 0:2 0x12000000 uInitrd; '
838+ 'fatload mmc 0:2 0x11ff0000 board.dtb; '
839+ 'bootm 0x10000000 0x12000000 0x11ff0000',
840+ 'fdt_high': '0xffffffff',
841+ 'initrd_high': '0xffffffff'}
842+ self.assertBootEnv(expected, board='mx6qsabrelite')
843+
844+ def test_panda(self):
845+ values = {
846+ "android_specific_args": ["init=/init",
847+ "androidboot.console=ttyO2"],
848+ "bootloader_flavor": "omap4_panda",
849+ "dtb_addr": '0x815f0000',
850+ "dtb_name": "board.dtb",
851+ "extra_boot_args_options": ["earlyprintk", "fixrtc",
852+ "nocompcache", "vram=48M",
853+ "omapfb.vram=0:24M,1:24M",
854+ "mem=456M@0x80000000",
855+ "mem=512M@0xA0000000"],
856+ "extra_serial_options": ["console=ttyO2,115200n8"],
857+ }
858+ expected = {
859+ 'bootargs': 'console=ttyO2,115200n8 '
860+ 'rootwait ro earlyprintk fixrtc '
861+ 'nocompcache vram=48M omapfb.vram=0:24M,1:24M '
862+ 'mem=456M@0x80000000 mem=512M@0xA0000000 '
863+ 'init=/init androidboot.console=ttyO2',
864+ 'bootcmd': 'fatload mmc 0:1 0x80200000 uImage; '
865+ 'fatload mmc 0:1 0x81600000 uInitrd; '
866+ 'fatload mmc 0:1 0x815f0000 board.dtb; '
867+ 'bootm 0x80200000 0x81600000 0x815f0000',
868+ 'fdt_high': '0xffffffff',
869+ 'initrd_high': '0xffffffff'}
870+ config = self.android_hwpack_panda % values
871+ self.assertBootEnv(expected, config=config, board='panda')
872+
873+ def test_panda_old(self):
874+ # Old test: use the values from the class, instead of passing them.
875+ expected = {
876+ 'bootargs': 'console=ttyO2,115200n8 '
877+ 'rootwait ro earlyprintk fixrtc '
878+ 'nocompcache vram=48M omapfb.vram=0:24M,1:24M '
879+ 'mem=456M@0x80000000 mem=512M@0xA0000000 '
880+ 'init=/init androidboot.console=ttyO2',
881+ 'bootcmd': 'fatload mmc 0:1 0x80200000 uImage; '
882+ 'fatload mmc 0:1 0x81600000 uInitrd; '
883+ 'fatload mmc 0:1 0x815f0000 board.dtb; '
884+ 'bootm 0x80200000 0x81600000 0x815f0000',
885+ 'fdt_high': '0xffffffff',
886+ 'initrd_high': '0xffffffff'}
887+ self.assertBootEnv(expected, board='panda')
888+
889+ def test_android_snowball_sd(self):
890+ values = {
891+ "android_specific_args": ["init=/init",
892+ "androidboot.console=ttyAMA2"],
893+ "boot_script": "boot.scr",
894+ "dtb_addr": '0x8000000',
895+ "dtb_name": "board.dtb",
896+ "extra_boot_args_options": ["earlyprintk", "mem=128M@0",
897+ "mali.mali_mem=64M@128M",
898+ "hwmem=168M@192M", "mem=22M@360M",
899+ "mem_issw=1M@383M", "mem=640M@384M",
900+ "vmalloc=500M"],
901+ "extra_serial_options": ["console=ttyAMA2,115200n8"],
902+ "fdt_high": '0x05000000',
903+ "initrd_addr": '0x05000000',
904+ "initrd_high": '0x06000000',
905+ }
906+ expected = {
907+ 'bootargs': 'console=ttyAMA2,115200n8 '
908+ 'rootwait ro earlyprintk '
909+ 'mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
910+ 'mem=22M@360M mem_issw=1M@383M mem=640M@384M '
911+ 'vmalloc=500M init=/init androidboot.console=ttyAMA2',
912+ 'bootcmd': 'fatload mmc 1:1 0x00100000 uImage; '
913+ 'fatload mmc 1:1 0x05000000 uInitrd; '
914+ 'fatload mmc 1:1 0x8000000 board.dtb; '
915+ 'bootm 0x00100000 0x05000000 0x8000000',
916+ 'fdt_high': '0x05000000',
917+ 'initrd_high': '0x06000000'}
918+ config = self.android_hwpack_snowball_sd % values
919+ self.assertBootEnv(expected, config=config, board='snowball_sd')
920+
921+ def test_android_snowball_sd_old(self):
922+ # Old test: use the values from the class, instead of passing them.
923+ expected = {
924+ 'bootargs': 'console=ttyAMA2,115200n8 '
925+ 'rootwait ro earlyprintk '
926+ 'mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
927+ 'mem=22M@360M mem_issw=1M@383M mem=640M@384M '
928+ 'vmalloc=500M init=/init androidboot.console=ttyAMA2',
929+ 'bootcmd': 'fatload mmc 1:1 0x00100000 uImage; '
930+ 'fatload mmc 1:1 0x05000000 uInitrd; '
931+ 'fatload mmc 1:1 0x8000000 board.dtb; '
932+ 'bootm 0x00100000 0x05000000 0x8000000',
933+ 'fdt_high': '0x05000000',
934+ 'initrd_high': '0x06000000'}
935+ self.assertBootEnv(expected, board='snowball_sd')
936+
937+ def test_android_snowball_emmc(self):
938+ values = {
939+ "android_specific_args": ["init=/init",
940+ "androidboot.console=ttyAMA2"],
941+ "boot_script": "boot.scr",
942+ "dtb_addr": '0x8000000',
943+ "dtb_name": "board.dtb",
944+ "extra_boot_args_options": ["earlyprintk", "mem=128M@0",
945+ "mali.mali_mem=64M@128M",
946+ "hwmem=168M@192M", "mem=22M@360M",
947+ "mem_issw=1M@383M", "mem=640M@384M",
948+ "vmalloc=500M"],
949+ "extra_serial_options": ["console=ttyAMA2,115200n8"],
950+ "fdt_high": '0x05000000',
951+ "initrd_addr": '0x05000000',
952+ "initrd_high": '0x06000000',
953+ "mmc_option": '0:2'
954+ }
955+ expected = {
956+ 'bootargs': 'console=ttyAMA2,115200n8 '
957+ 'rootwait ro earlyprintk '
958+ 'mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
959+ 'mem=22M@360M mem_issw=1M@383M mem=640M@384M '
960+ 'vmalloc=500M init=/init androidboot.console=ttyAMA2',
961+ 'bootcmd': 'fatload mmc 0:2 0x00100000 uImage; '
962+ 'fatload mmc 0:2 0x05000000 uInitrd; '
963+ 'fatload mmc 0:2 0x8000000 board.dtb; '
964+ 'bootm 0x00100000 0x05000000 0x8000000',
965+ 'fdt_high': '0x05000000',
966+ 'initrd_high': '0x06000000'}
967+ config = self.android_hwpack_snowball_emmc % values
968+ self.assertBootEnv(expected, config, board='snowball_emmc')
969+
970+ def test_android_snowball_emmc_old(self):
971+ # Old test: use the values from the class, instead of passing them.
972+ expected = {
973+ 'bootargs': 'console=ttyAMA2,115200n8 '
974+ 'rootwait ro earlyprintk '
975+ 'mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
976+ 'mem=22M@360M mem_issw=1M@383M mem=640M@384M '
977+ 'vmalloc=500M init=/init androidboot.console=ttyAMA2',
978+ 'bootcmd': 'fatload mmc 0:2 0x00100000 uImage; '
979+ 'fatload mmc 0:2 0x05000000 uInitrd; '
980+ 'fatload mmc 0:2 0x8000000 board.dtb; '
981+ 'bootm 0x00100000 0x05000000 0x8000000',
982+ 'fdt_high': '0x05000000',
983+ 'initrd_high': '0x06000000'}
984+ self.assertBootEnv(expected, board='snowball_emmc')
985+
986+ def test_android_origen(self):
987+ values = {
988+ "extra_serial_options": ["console=tty0", "console=ttySAC2,115200n8"],
989+ "android_specific_args": ["init=/init", "androidboot.console=ttySAC2"]
990+ }
991+ expected = {
992+ 'bootargs': 'console=tty0 console=ttySAC2,115200n8 '
993+ 'rootwait ro init=/init androidboot.console=ttySAC2',
994+ 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
995+ 'fatload mmc 0:2 0x42000000 uInitrd; '
996+ 'bootm 0x40007000 0x42000000',
997+ 'fdt_high': '0xffffffff',
998+ 'initrd_high': '0xffffffff'}
999+ config = ((self.hwpack_format + self.hwpack_extra_serial +
1000+ self.hwpack_android_args) % values)
1001+ self.assertBootEnv(expected, config=config, board='origen')
1002+
1003+ def test_android_origen_old(self):
1004+ # Old test: use the values from the class, instead of passing them.
1005+ expected = {
1006+ 'bootargs': 'console=tty0 console=ttySAC2,115200n8 '
1007+ 'rootwait ro init=/init androidboot.console=ttySAC2',
1008+ 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
1009+ 'fatload mmc 0:2 0x42000000 uInitrd; '
1010+ 'bootm 0x40007000 0x42000000',
1011+ 'fdt_high': '0xffffffff',
1012+ 'initrd_high': '0xffffffff'}
1013+ self.assertBootEnv(expected, board='origen')
1014+
1015+ def test_android_origen_quad(self):
1016+ values = {
1017+ "extra_serial_options": ["console=tty0",
1018+ "console=ttySAC2,115200n8"],
1019+ "android_specific_args": ["init=/init",
1020+ "androidboot.console=ttySAC2"]
1021+ }
1022+ expected = {
1023+ 'bootargs': 'console=tty0 console=ttySAC2,115200n8 '
1024+ 'rootwait ro init=/init androidboot.console=ttySAC2',
1025+ 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
1026+ 'fatload mmc 0:2 0x42000000 uInitrd; '
1027+ 'bootm 0x40007000 0x42000000',
1028+ 'fdt_high': '0xffffffff',
1029+ 'initrd_high': '0xffffffff'}
1030+ config = ((self.hwpack_format + self.hwpack_extra_serial +
1031+ self.hwpack_android_args) % values)
1032+ self.assertBootEnv(expected, config=config, board='origen_quad')
1033+
1034+ def test_android_origen_quad_old(self):
1035+ # Old test: use the values from the class, instead of passing them.
1036+ expected = {
1037+ 'bootargs': 'console=tty0 console=ttySAC2,115200n8 '
1038+ 'rootwait ro init=/init androidboot.console=ttySAC2',
1039+ 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
1040+ 'fatload mmc 0:2 0x42000000 uInitrd; '
1041+ 'bootm 0x40007000 0x42000000',
1042+ 'fdt_high': '0xffffffff',
1043+ 'initrd_high': '0xffffffff'}
1044+ self.assertBootEnv(expected, board='origen_quad')
1045+
1046+ def test_android_vexpress(self):
1047+ values = {
1048+ "extra_serial_options": ["console=tty0",
1049+ "console=ttyAMA0,38400n8"],
1050+ "android_specific_args": ["init=/init",
1051+ "androidboot.console=ttyAMA0"]
1052+ }
1053+ expected = {
1054+ 'bootargs': 'console=tty0 console=ttyAMA0,38400n8 '
1055+ 'rootwait ro init=/init androidboot.console=ttyAMA0',
1056+ 'bootcmd': 'fatload mmc 0:1 0x60000000 uImage; '
1057+ 'fatload mmc 0:1 0x62000000 uInitrd; '
1058+ 'bootm 0x60000000 0x62000000',
1059+ 'fdt_high': '0xffffffff',
1060+ 'initrd_high': '0xffffffff'}
1061+ config = ((self.hwpack_format + self.hwpack_extra_serial +
1062+ self.hwpack_android_args) % values)
1063+ self.assertBootEnv(expected, config=config, board='vexpress')
1064+
1065+ def test_android_vexpress_old(self):
1066+ # Old test: use the values from the class, instead of passing them.
1067+ expected = {
1068+ 'bootargs': 'console=tty0 console=ttyAMA0,38400n8 '
1069+ 'rootwait ro init=/init androidboot.console=ttyAMA0',
1070+ 'bootcmd': 'fatload mmc 0:1 0x60000000 uImage; '
1071+ 'fatload mmc 0:1 0x62000000 uInitrd; '
1072+ 'bootm 0x60000000 0x62000000',
1073+ 'fdt_high': '0xffffffff',
1074+ 'initrd_high': '0xffffffff'}
1075+ self.assertBootEnv(expected, board='vexpress')
1076+
1077+ def test_android_mx5(self):
1078+ values = {
1079+ "extra_boot_args_options": ["earlyprintk", "rootdelay=1",
1080+ "fixrtc", "nocompcache",
1081+ "di1_primary", "tve"],
1082+ "extra_serial_options": ["console=%s,115200n8"],
1083+ "android_specific_args": ["init=/init", "androidboot.console=%s"]
1084+ }
1085+ expected = {
1086+ 'bootargs': 'console=ttymxc0,115200n8 '
1087+ 'rootwait ro earlyprintk rootdelay=1 fixrtc '
1088+ 'nocompcache di1_primary tve init=/init '
1089+ 'androidboot.console=ttymxc0',
1090+ 'bootcmd': 'fatload mmc 0:2 0x70000000 uImage; '
1091+ 'fatload mmc 0:2 0x72000000 uInitrd; '
1092+ 'bootm 0x70000000 0x72000000',
1093+ 'fdt_high': '0xffffffff',
1094+ 'initrd_high': '0xffffffff'}
1095+ config = ((self.hwpack_format + self.hwpack_extra_boot +
1096+ self.hwpack_extra_serial + self.hwpack_android_args) %
1097+ values)
1098+ self.assertBootEnv(expected, config=config, board='mx53loco')
1099+
1100+ def test_android_mx5_old(self):
1101+ # Old test: use the values from the class, instead of passing them.
1102+ expected = {
1103+ 'bootargs': 'console=ttymxc0,115200n8 '
1104+ 'rootwait ro earlyprintk rootdelay=1 fixrtc '
1105+ 'nocompcache di1_primary tve init=/init '
1106+ 'androidboot.console=ttymxc0',
1107+ 'bootcmd': 'fatload mmc 0:2 0x70000000 uImage; '
1108+ 'fatload mmc 0:2 0x72000000 uInitrd; '
1109+ 'bootm 0x70000000 0x72000000',
1110+ 'fdt_high': '0xffffffff',
1111+ 'initrd_high': '0xffffffff'}
1112+ self.assertBootEnv(expected, board='mx53loco')
1113
1114=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
1115--- linaro_image_tools/media_create/tests/test_media_create.py 2012-12-23 12:49:02 +0000
1116+++ linaro_image_tools/media_create/tests/test_media_create.py 2013-01-03 13:57:23 +0000
1117@@ -32,6 +32,7 @@
1118 import tarfile
1119 import dbus
1120
1121+from mock import MagicMock
1122 from StringIO import StringIO
1123 from testtools import TestCase
1124
1125@@ -50,7 +51,6 @@
1126 SECTOR_SIZE,
1127 align_up,
1128 align_partition,
1129- board_configs,
1130 get_plain_boot_script_contents,
1131 make_flashable_env,
1132 install_mx5_boot_loader,
1133@@ -63,10 +63,10 @@
1134 _get_mlo_file,
1135 _run_mkimage,
1136 BoardConfig,
1137+ get_board_config,
1138 )
1139 from linaro_image_tools.media_create.android_boards import (
1140 AndroidSnowballEmmcConfig,
1141- android_board_configs,
1142 )
1143 from linaro_image_tools.media_create.chroot_utils import (
1144 copy_file,
1145@@ -203,7 +203,7 @@
1146 return tarball
1147
1148 def test_get_format_1(self):
1149- data = '1.0'
1150+ data = HardwarepackHandler.FORMAT_1
1151 format = "%s\n" % data
1152 tarball = self.add_to_tarball(
1153 [('FORMAT', format), ('metadata', self.metadata)])
1154@@ -230,8 +230,8 @@
1155 self.assertRaises(AssertionError, hp.get_format)
1156
1157 def test_mixed_formats(self):
1158- format1 = "%s\n" % '1.0'
1159- format2 = "%s\n" % '2.0'
1160+ format1 = "%s\n" % HardwarepackHandler.FORMAT_1
1161+ format2 = "%s\n" % HardwarepackHandler.FORMAT_2
1162 tarball1 = self.add_to_tarball(
1163 [('FORMAT', format1), ('metadata', self.metadata)],
1164 tarball=self.tarball_fixture.get_tarball())
1165@@ -247,8 +247,8 @@
1166 self.assertEquals(hp.get_format(), '1.0and2.0')
1167
1168 def test_identical_formats_ok(self):
1169- format1 = "%s\n" % '2.0'
1170- format2 = "%s\n" % '2.0'
1171+ format1 = "%s\n" % HardwarepackHandler.FORMAT_2
1172+ format2 = "%s\n" % HardwarepackHandler.FORMAT_2
1173 tarball1 = self.add_to_tarball(
1174 [('FORMAT', format1), ('metadata', self.metadata)],
1175 tarball=self.tarball_fixture.get_tarball())
1176@@ -427,10 +427,9 @@
1177 linaro_image_tools.media_create.boards, 'HardwarepackHandler',
1178 self.MockHardwarepackHandler))
1179
1180- class config(BoardConfig):
1181- pass
1182- config.set_metadata('ahwpack.tar.gz')
1183- self.assertEquals(None, config.kernel_addr)
1184+ board_conf = BoardConfig()
1185+ board_conf.set_metadata('ahwpack.tar.gz')
1186+ self.assertEquals(None, board_conf.kernel_addr)
1187
1188 def test_sets_kernel_addr(self):
1189 self.useFixture(MockSomethingFixture(
1190@@ -442,10 +441,9 @@
1191 field_to_test: data_to_set,
1192 }
1193
1194- class config(BoardConfig):
1195- pass
1196- config.set_metadata('ahwpack.tar.gz')
1197- self.assertEquals(data_to_set, config.kernel_addr)
1198+ board_conf = BoardConfig()
1199+ board_conf.set_metadata('ahwpack.tar.gz')
1200+ self.assertEquals(data_to_set, board_conf.kernel_addr)
1201
1202 def test_sets_initrd_addr(self):
1203 self.useFixture(MockSomethingFixture(
1204@@ -457,10 +455,9 @@
1205 field_to_test: data_to_set,
1206 }
1207
1208- class config(BoardConfig):
1209- pass
1210- config.set_metadata('ahwpack.tar.gz')
1211- self.assertEquals(data_to_set, config.initrd_addr)
1212+ board_conf = BoardConfig()
1213+ board_conf.set_metadata('ahwpack.tar.gz')
1214+ self.assertEquals(data_to_set, board_conf.initrd_addr)
1215
1216 def test_sets_load_addr(self):
1217 self.useFixture(MockSomethingFixture(
1218@@ -472,10 +469,9 @@
1219 field_to_test: data_to_set,
1220 }
1221
1222- class config(BoardConfig):
1223- pass
1224- config.set_metadata('ahwpack.tar.gz')
1225- self.assertEquals(data_to_set, config.load_addr)
1226+ board_conf = BoardConfig()
1227+ board_conf.set_metadata('ahwpack.tar.gz')
1228+ self.assertEquals(data_to_set, board_conf.load_addr)
1229
1230 def test_sets_serial_tty(self):
1231 self.useFixture(MockSomethingFixture(
1232@@ -487,10 +483,9 @@
1233 field_to_test: data_to_set,
1234 }
1235
1236- class config(BoardConfig):
1237- pass
1238- config.set_metadata('ahwpack.tar.gz')
1239- self.assertEquals(data_to_set, config.serial_tty)
1240+ board_conf = BoardConfig()
1241+ board_conf.set_metadata('ahwpack.tar.gz')
1242+ self.assertEquals(data_to_set, board_conf.serial_tty)
1243
1244 def test_sets_wired_interfaces(self):
1245 self.useFixture(MockSomethingFixture(
1246@@ -502,10 +497,9 @@
1247 field_to_test: data_to_set,
1248 }
1249
1250- class config(BoardConfig):
1251- pass
1252- config.set_metadata('ahwpack.tar.gz')
1253- self.assertEquals(data_to_set, config.wired_interfaces)
1254+ board_conf = BoardConfig()
1255+ board_conf.set_metadata('ahwpack.tar.gz')
1256+ self.assertEquals(data_to_set, board_conf.wired_interfaces)
1257
1258 def test_sets_wireless_interfaces(self):
1259 self.useFixture(MockSomethingFixture(
1260@@ -517,10 +511,9 @@
1261 field_to_test: data_to_set,
1262 }
1263
1264- class config(BoardConfig):
1265- pass
1266- config.set_metadata('ahwpack.tar.gz')
1267- self.assertEquals(data_to_set, config.wireless_interfaces)
1268+ board_conf = BoardConfig()
1269+ board_conf.set_metadata('ahwpack.tar.gz')
1270+ self.assertEquals(data_to_set, board_conf.wireless_interfaces)
1271
1272 def test_sets_mmc_id(self):
1273 self.useFixture(MockSomethingFixture(
1274@@ -532,12 +525,11 @@
1275 field_to_test: data_to_set,
1276 }
1277
1278- class config(BoardConfig):
1279- pass
1280- config.set_metadata('ahwpack.tar.gz')
1281- self.assertEquals(data_to_set, config.mmc_option)
1282- self.assertEquals(0, config.mmc_device_id)
1283- self.assertEquals(0, config.mmc_part_offset)
1284+ board_conf = BoardConfig()
1285+ board_conf.set_metadata('ahwpack.tar.gz')
1286+ self.assertEquals(data_to_set, board_conf.mmc_option)
1287+ self.assertEquals(0, board_conf.mmc_device_id)
1288+ self.assertEquals(0, board_conf.mmc_part_offset)
1289
1290 def test_sets_boot_min_size(self):
1291 self.useFixture(MockSomethingFixture(
1292@@ -551,10 +543,9 @@
1293 field_to_test: data_to_set,
1294 }
1295
1296- class config(BoardConfig):
1297- pass
1298- config.set_metadata('ahwpack.tar.gz')
1299- self.assertEquals(expected, config.BOOT_MIN_SIZE_S)
1300+ board_conf = BoardConfig()
1301+ board_conf.set_metadata('ahwpack.tar.gz')
1302+ self.assertEquals(expected, board_conf.BOOT_MIN_SIZE_S)
1303
1304 def test_sets_root_min_size(self):
1305 self.useFixture(MockSomethingFixture(
1306@@ -568,10 +559,9 @@
1307 field_to_test: data_to_set,
1308 }
1309
1310- class config(BoardConfig):
1311- pass
1312- config.set_metadata('ahwpack.tar.gz')
1313- self.assertEquals(expected, config.ROOT_MIN_SIZE_S)
1314+ board_conf = BoardConfig()
1315+ board_conf.set_metadata('ahwpack.tar.gz')
1316+ self.assertEquals(expected, board_conf.ROOT_MIN_SIZE_S)
1317
1318 def test_sets_loader_min_size(self):
1319 self.useFixture(MockSomethingFixture(
1320@@ -585,10 +575,9 @@
1321 field_to_test: data_to_set,
1322 }
1323
1324- class config(BoardConfig):
1325- pass
1326- config.set_metadata('ahwpack.tar.gz')
1327- self.assertEquals(expected, config.LOADER_MIN_SIZE_S)
1328+ board_conf = BoardConfig()
1329+ board_conf.set_metadata('ahwpack.tar.gz')
1330+ self.assertEquals(expected, board_conf.LOADER_MIN_SIZE_S)
1331
1332 def test_sets_partition_layout_32(self):
1333 self.useFixture(MockSomethingFixture(
1334@@ -600,10 +589,9 @@
1335 field_to_test: data_to_set,
1336 }
1337
1338- class config(BoardConfig):
1339- pass
1340- config.set_metadata('ahwpack.tar.gz')
1341- self.assertEquals(32, config.fat_size)
1342+ board_conf = BoardConfig()
1343+ board_conf.set_metadata('ahwpack.tar.gz')
1344+ self.assertEquals(32, board_conf.fat_size)
1345
1346 def test_sets_partition_layout_16(self):
1347 self.useFixture(MockSomethingFixture(
1348@@ -615,10 +603,9 @@
1349 field_to_test: data_to_set,
1350 }
1351
1352- class config(BoardConfig):
1353- pass
1354- config.set_metadata('ahwpack.tar.gz')
1355- self.assertEquals(16, config.fat_size)
1356+ board_conf = BoardConfig()
1357+ board_conf.set_metadata('ahwpack.tar.gz')
1358+ self.assertEquals(16, board_conf.fat_size)
1359
1360 def test_sets_partition_layout_raises(self):
1361 self.useFixture(MockSomethingFixture(
1362@@ -630,10 +617,9 @@
1363 field_to_test: data_to_set,
1364 }
1365
1366- class config(BoardConfig):
1367- pass
1368+ board_conf = BoardConfig()
1369 self.assertRaises(
1370- AssertionError, config.set_metadata, 'ahwpack.tar.gz')
1371+ AssertionError, board_conf.set_metadata, 'ahwpack.tar.gz')
1372
1373 def test_sets_copy_files(self):
1374 self.useFixture(MockSomethingFixture(
1375@@ -647,10 +633,9 @@
1376 field_to_test: data_to_set,
1377 }
1378
1379- class config(BoardConfig):
1380- pass
1381- config.set_metadata('ahwpack.tar.gz')
1382- self.assertEquals(data_to_set, config.bootloader_copy_files)
1383+ board_conf = BoardConfig()
1384+ board_conf.set_metadata('ahwpack.tar.gz')
1385+ self.assertEquals(data_to_set, board_conf.bootloader_copy_files)
1386
1387
1388 class TestGetMLOFile(TestCaseWithFixtures):
1389@@ -697,7 +682,10 @@
1390
1391
1392 class TestGetSMDKSPL(TestCaseWithFixtures):
1393- config = boards.SMDKV310Config
1394+ def setUp(self):
1395+ super(TestGetSMDKSPL, self).setUp()
1396+ self.config = boards.SMDKV310Config()
1397+ self.config.hwpack_format = HardwarepackHandler.FORMAT_1
1398
1399 def test_no_file_present(self):
1400 tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
1401@@ -729,7 +717,10 @@
1402
1403
1404 class TestGetSMDKUboot(TestCaseWithFixtures):
1405- config = boards.SMDKV310Config
1406+ def setUp(self):
1407+ super(TestGetSMDKUboot, self).setUp()
1408+ self.config = boards.SMDKV310Config()
1409+ self.config.hwpack_format = HardwarepackHandler.FORMAT_1
1410
1411 def test_uses_uboot_flavour(self):
1412 chroot_dir = "chroot"
1413@@ -740,7 +731,10 @@
1414
1415
1416 class TestGetOrigenSPL(TestCaseWithFixtures):
1417- config = boards.OrigenConfig
1418+ def setUp(self):
1419+ super(TestGetOrigenSPL, self).setUp()
1420+ self.config = boards.OrigenConfig()
1421+ self.config.hwpack_format = HardwarepackHandler.FORMAT_1
1422
1423 def test_no_file_present(self):
1424 tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
1425@@ -756,11 +750,17 @@
1426
1427
1428 class TestGetOrigenUboot(TestGetSMDKUboot):
1429- config = boards.OrigenConfig
1430+ def setUp(self):
1431+ super(TestGetOrigenUboot, self).setUp()
1432+ self.config = boards.OrigenConfig()
1433+ self.config.hwpack_format = HardwarepackHandler.FORMAT_1
1434
1435
1436 class TestGetOrigenQuadSPL(TestCaseWithFixtures):
1437- config = boards.OrigenQuadConfig
1438+ def setUp(self):
1439+ super(TestGetOrigenQuadSPL, self).setUp()
1440+ self.config = boards.OrigenQuadConfig()
1441+ self.config.hwpack_format = HardwarepackHandler.FORMAT_1
1442
1443 def test_no_file_present(self):
1444 tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
1445@@ -776,11 +776,17 @@
1446
1447
1448 class TestGetOrigenQuadUboot(TestGetSMDKUboot):
1449- config = boards.OrigenQuadConfig
1450+ def setUp(self):
1451+ super(TestGetOrigenQuadUboot, self).setUp()
1452+ self.config = boards.OrigenQuadConfig()
1453+ self.config.hwpack_format = HardwarepackHandler.FORMAT_1
1454
1455
1456 class TestGetArndaleSPL(TestCaseWithFixtures):
1457- config = boards.ArndaleConfig
1458+ def setUp(self):
1459+ super(TestGetArndaleSPL, self).setUp()
1460+ self.config = boards.ArndaleConfig()
1461+ self.config.hwpack_format = HardwarepackHandler.FORMAT_1
1462
1463 def test_no_file_present(self):
1464 tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
1465@@ -818,6 +824,7 @@
1466 '\x05\x00\x00\x00' '\x05\x00\x00\x00' \
1467 'hello' + zero + '\x00\x00\x00'
1468 self.expected = line1 + line2 + line3
1469+ self.board_conf = boards.SnowballEmmcConfig()
1470
1471 def create_files_structure(self, src_data):
1472 ''' Creates the data structure that the tested function
1473@@ -841,7 +848,7 @@
1474 files = self.create_files_structure(correct_data)
1475 filename = os.path.join(self.tempdir, 'toc')
1476 with open(filename, 'w') as f:
1477- boards.SnowballEmmcConfig.create_toc(f, files)
1478+ self.board_conf.create_toc(f, files)
1479 with open(filename, 'r') as f:
1480 actual = f.read()
1481 self.assertEquals(96, len(actual))
1482@@ -856,7 +863,7 @@
1483 files = self.create_files_structure(illegal_name_data)
1484 with open(os.path.join(self.tempdir, 'toc'), 'w') as f:
1485 self.assertRaises(AssertionError,
1486- boards.SnowballEmmcConfig.create_toc,
1487+ self.board_conf.create_toc,
1488 f, files)
1489
1490 def test_create_toc_error_negative_unsigned(self):
1491@@ -866,7 +873,7 @@
1492 files = self.create_files_structure(illegal_unsigned_data)
1493 with open(os.path.join(self.tempdir, 'toc'), 'w') as f:
1494 self.assertRaises(struct.error,
1495- boards.SnowballEmmcConfig.create_toc,
1496+ self.board_conf.create_toc,
1497 f, files)
1498
1499
1500@@ -885,6 +892,8 @@
1501 os.makedirs(self.temp_bootdir_path)
1502 if not os.path.exists(self.temp_configdir_path):
1503 os.makedirs(self.temp_configdir_path)
1504+ self.snowball_config = get_board_config('snowball_emmc')
1505+ self.snowball_config.hwpack_format = HardwarepackHandler.FORMAT_1
1506
1507 def setupFiles(self):
1508 return self.create_test_files(self.temp_bootdir_path)
1509@@ -910,7 +919,7 @@
1510 ('UBOOT_ENV', 'u-boot-env.bin', 0, 0x00C1F000, '10')]
1511 # Create a config file
1512 cfg_file = os.path.join(
1513- path, boards.SnowballEmmcConfig.snowball_startup_files_config)
1514+ path, self.snowball_config.snowball_startup_files_config)
1515 with open(cfg_file, 'w') as f:
1516 for line in src_data:
1517 # Write comments, so we test that the parser can read them
1518@@ -926,8 +935,8 @@
1519 f.write(line[0])
1520 #define the expected values read from the config file
1521 expected = []
1522- ofs = [boards.SnowballEmmcConfig.TOC_SIZE,
1523- boards.SnowballEmmcConfig.TOC_SIZE + len('ISSW'), 0x160000,
1524+ ofs = [self.snowball_config.TOC_SIZE,
1525+ self.snowball_config.TOC_SIZE + len('ISSW'), 0x160000,
1526 0x170000, 0xBA0000, 0xC1F000]
1527 size = [len('ISSW'), len('X-LOADER'), len('MEM_INIT'), \
1528 len('PWR_MGT'), len('NORMAL'), len('UBOOT_ENV')]
1529@@ -946,13 +955,13 @@
1530 def test_get_file_info_relative_path(self):
1531 # Create a config file
1532 cfg_file = os.path.join(self.temp_bootdir_path,
1533- boards.SnowballEmmcConfig.snowball_startup_files_config)
1534+ self.snowball_config.snowball_startup_files_config)
1535 uboot_file = 'u-boot.bin'
1536 with open(cfg_file, 'w') as f:
1537 f.write('%s %s %i %#x %s\n' % ('NORMAL', uboot_file, 0,
1538 0xBA0000, '9'))
1539 with open(os.path.join(self.temp_bootdir_path, uboot_file), 'w') as f:
1540- file_info = boards.SnowballEmmcConfig.get_file_info(
1541+ file_info = self.snowball_config.get_file_info(
1542 self.tempdir, self.temp_bootdir_path)
1543 self.assertEquals(file_info[0]['filename'],
1544 os.path.join(self.temp_bootdir_path, uboot_file))
1545@@ -960,7 +969,7 @@
1546 def test_get_file_info_abs_path(self):
1547 # Create a config file
1548 cfg_file = os.path.join(self.temp_bootdir_path,
1549- boards.SnowballEmmcConfig.snowball_startup_files_config)
1550+ self.snowball_config.snowball_startup_files_config)
1551 uboot_dir = tempfile.mkdtemp(dir=self.tempdir)
1552 uboot_file = os.path.join(uboot_dir, 'u-boot.bin')
1553 uboot_relative_file = uboot_file.replace(self.tempdir, '')
1554@@ -968,19 +977,19 @@
1555 f.write('%s %s %i %#x %s\n' % (
1556 'NORMAL', uboot_relative_file, 0, 0xBA0000, '9'))
1557 with open(uboot_file, 'w') as f:
1558- file_info = boards.SnowballEmmcConfig.get_file_info(
1559+ file_info = self.snowball_config.get_file_info(
1560 self.tempdir, self.temp_bootdir_path)
1561 self.assertEquals(file_info[0]['filename'], uboot_file)
1562
1563 def test_get_file_info_raises(self):
1564 # Create a config file
1565 cfg_file = os.path.join(self.temp_bootdir_path,
1566- boards.SnowballEmmcConfig.snowball_startup_files_config)
1567+ self.snowball_config.snowball_startup_files_config)
1568 with open(cfg_file, 'w') as f:
1569 f.write('%s %s %i %#x %s\n' % ('NORMAL', 'u-boot.bin', 0,
1570 0xBA0000, '9'))
1571 self.assertRaises(
1572- AssertionError, boards.SnowballEmmcConfig.get_file_info,
1573+ AssertionError, self.snowball_config.get_file_info,
1574 self.tempdir, self.temp_bootdir_path)
1575
1576 def test_file_name_size(self):
1577@@ -988,28 +997,28 @@
1578 _, toc_filename = tempfile.mkstemp()
1579 atexit.register(os.unlink, toc_filename)
1580 filedata = 'X'
1581- bytes = boards.SnowballEmmcConfig.TOC_SIZE + 1
1582+ bytes = self.snowball_config.TOC_SIZE + 1
1583 tmpfile = open(toc_filename, 'wb')
1584 for n in xrange(bytes):
1585 tmpfile.write(filedata)
1586 tmpfile.close()
1587 files = self.setupFiles()
1588 self.assertRaises(AssertionError,
1589- boards.SnowballEmmcConfig.install_snowball_boot_loader,
1590+ self.snowball_config.install_snowball_boot_loader,
1591 toc_filename, files, "boot_device_or_file",
1592- boards.SnowballEmmcConfig.SNOWBALL_LOADER_START_S)
1593+ self.snowball_config.SNOWBALL_LOADER_START_S)
1594
1595 def test_install_snowball_boot_loader_toc_dont_delete(self):
1596 fixture = self.useFixture(MockCmdRunnerPopenFixture())
1597 toc_filename = self.createTempFileAsFixture()
1598 files = self.setupFiles()
1599- boards.SnowballEmmcConfig.install_snowball_boot_loader(toc_filename,
1600+ self.snowball_config.install_snowball_boot_loader(toc_filename,
1601 files, "boot_device_or_file",
1602- boards.SnowballEmmcConfig.SNOWBALL_LOADER_START_S)
1603+ self.snowball_config.SNOWBALL_LOADER_START_S)
1604 expected = [
1605 '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \
1606 ' seek=%s' % (sudo_args, toc_filename,
1607- boards.SnowballEmmcConfig.SNOWBALL_LOADER_START_S),
1608+ self.snowball_config.SNOWBALL_LOADER_START_S),
1609 '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \
1610 ' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path),
1611 '%s dd if=%s/boot_image_x-loader.bin of=boot_device_or_file' \
1612@@ -1030,13 +1039,13 @@
1613 fixture = self.useFixture(MockCmdRunnerPopenFixture())
1614 toc_filename = self.createTempFileAsFixture()
1615 files = self.setupFiles()
1616- boards.SnowballEmmcConfig.install_snowball_boot_loader(toc_filename,
1617+ self.snowball_config.install_snowball_boot_loader(toc_filename,
1618 files, "boot_device_or_file",
1619- boards.SnowballEmmcConfig.SNOWBALL_LOADER_START_S, True)
1620+ self.snowball_config.SNOWBALL_LOADER_START_S, True)
1621 expected = [
1622 '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \
1623 ' seek=%s' % (sudo_args, toc_filename,
1624- boards.SnowballEmmcConfig.SNOWBALL_LOADER_START_S),
1625+ self.snowball_config.SNOWBALL_LOADER_START_S),
1626 '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \
1627 ' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path),
1628 '%s rm %s/boot_image_issw.bin' % (sudo_args,
1629@@ -1066,13 +1075,14 @@
1630 fixture = self.useFixture(MockCmdRunnerPopenFixture())
1631 toc_filename = self.createTempFileAsFixture()
1632 files = self.setupFiles()
1633- AndroidSnowballEmmcConfig.install_snowball_boot_loader(
1634+ board_conf = AndroidSnowballEmmcConfig()
1635+ board_conf.install_snowball_boot_loader(
1636 toc_filename, files, "boot_device_or_file",
1637- AndroidSnowballEmmcConfig.SNOWBALL_LOADER_START_S)
1638+ board_conf.SNOWBALL_LOADER_START_S)
1639 expected = [
1640 '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \
1641 ' seek=%s' % (sudo_args, toc_filename,
1642- AndroidSnowballEmmcConfig.SNOWBALL_LOADER_START_S),
1643+ board_conf.SNOWBALL_LOADER_START_S),
1644 '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \
1645 ' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path),
1646 '%s dd if=%s/boot_image_x-loader.bin of=boot_device_or_file' \
1647@@ -1097,11 +1107,11 @@
1648 k_img_file = os.path.join(self.tempdir, 'vmlinuz-1-ux500')
1649 i_img_file = os.path.join(self.tempdir, 'initrd.img-1-ux500')
1650
1651- boot_env = board_configs['snowball_emmc']._get_boot_env(
1652+ boot_env = self.snowball_config._get_boot_env(
1653 is_live=False, is_lowmem=False, consoles=[],
1654 rootfs_id="UUID=test_boot_env_uuid",
1655 i_img_data=None, d_img_data=None)
1656- boards.SnowballEmmcConfig._make_boot_files(boot_env, self.tempdir,
1657+ self.snowball_config._make_boot_files(boot_env, self.tempdir,
1658 self.temp_bootdir_path, 'boot_device_or_file', k_img_file,
1659 i_img_file, None)
1660 expected = [
1661@@ -1145,12 +1155,12 @@
1662 def test_missing_files(self):
1663 '''When the files cannot be read, an IOError should be raised'''
1664 self.assertRaises(IOError,
1665- boards.SnowballEmmcConfig.get_file_info,
1666+ self.snowball_config.get_file_info,
1667 self.tempdir, self.temp_bootdir_path)
1668
1669 def test_normal_case(self):
1670 expected = self.setupFiles()
1671- actual = boards.SnowballEmmcConfig.get_file_info(
1672+ actual = self.snowball_config.get_file_info(
1673 self.tempdir, self.temp_bootdir_path)
1674 self.assertEquals(expected, actual)
1675
1676@@ -1161,8 +1171,6 @@
1677 super(TestBootSteps, self).setUp()
1678 self.funcs_calls = []
1679 self.mock_all_boards_funcs()
1680- boards = linaro_image_tools.media_create.boards
1681- boards.BoardConfig.hwpack_format = '1.0'
1682
1683 def mock_all_boards_funcs(self):
1684 """Mock functions of boards module with a call tracer."""
1685@@ -1179,169 +1187,174 @@
1686
1687 def mock_set_appropriate_serial_tty(self, config):
1688
1689- def set_appropriate_serial_tty_mock(cls, chroot_dir):
1690- cls.serial_tty = cls._serial_tty
1691+ def set_appropriate_serial_tty_mock(chroot_dir):
1692+ config.serial_tty = config._serial_tty
1693
1694- self.useFixture(MockSomethingFixture(
1695- config, 'set_appropriate_serial_tty',
1696- classmethod(set_appropriate_serial_tty_mock)))
1697+ config.set_appropriate_serial_tty = MagicMock(
1698+ side_effect=set_appropriate_serial_tty_mock)
1699
1700 def make_boot_files(self, config):
1701- def _get_kflavor_files_mock(cls, path):
1702- if cls.dtb_name is None:
1703+ def _get_kflavor_files_mock(path):
1704+ if config.dtb_name is None:
1705 return (path, path, None)
1706 return (path, path, path)
1707
1708- self.useFixture(MockSomethingFixture(
1709- config, '_get_kflavor_files',
1710- classmethod(_get_kflavor_files_mock)))
1711+ config._get_kflavor_files = MagicMock(
1712+ side_effect=_get_kflavor_files_mock)
1713
1714 config.make_boot_files('', False, False, [], '', '', '', '')
1715
1716 def test_vexpress_steps(self):
1717- self.make_boot_files(boards.VexpressConfig)
1718+ board_conf = boards.VexpressConfig()
1719+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1720+ self.make_boot_files(board_conf)
1721 expected = ['make_uImage', 'make_uInitrd']
1722 self.assertEqual(expected, self.funcs_calls)
1723
1724 def test_vexpress_a9_steps(self):
1725- self.make_boot_files(boards.VexpressA9Config)
1726+ board_conf = boards.VexpressA9Config()
1727+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1728+ self.make_boot_files(board_conf)
1729 expected = ['make_uImage', 'make_uInitrd']
1730 self.assertEqual(expected, self.funcs_calls)
1731
1732 def test_mx5_steps(self):
1733- class SomeMx5Config(boards.Mx5Config):
1734- bootloader_flavor = 'bootloader_flavor'
1735- SomeMx5Config.hardwarepack_handler = (
1736+ board_conf = boards.Mx5Config()
1737+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1738+ board_conf.bootloader_flavor = 'bootloader_flavor'
1739+ board_conf.hardwarepack_handler = (
1740 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
1741- SomeMx5Config.hardwarepack_handler.get_format = (
1742- lambda: '1.0')
1743- self.make_boot_files(SomeMx5Config)
1744+ board_conf.hardwarepack_handler.get_format = (
1745+ lambda: HardwarepackHandler.FORMAT_1)
1746+ self.make_boot_files(board_conf)
1747 expected = [
1748 'install_mx5_boot_loader', 'make_uImage', 'make_uInitrd',
1749 'make_dtb', 'make_boot_script']
1750 self.assertEqual(expected, self.funcs_calls)
1751
1752 def test_smdkv310_steps(self):
1753- def mock_func_creator(name):
1754- return classmethod(
1755- lambda *args, **kwargs: self.funcs_calls.append(name))
1756-
1757- self.useFixture(MockSomethingFixture(
1758- linaro_image_tools.media_create.boards.SMDKV310Config,
1759- 'install_samsung_boot_loader',
1760- mock_func_creator('install_samsung_boot_loader')))
1761+ board_conf = boards.SMDKV310Config()
1762+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1763+ board_conf.install_samsung_boot_loader = MagicMock()
1764+ board_conf.install_samsung_boot_loader.return_value = \
1765+ self.funcs_calls.append('install_samsung_boot_loader')
1766 self.useFixture(MockSomethingFixture(os.path, 'exists',
1767 lambda file: True))
1768- boards.SMDKV310Config.hardwarepack_handler = (
1769+ board_conf.hardwarepack_handler = (
1770 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
1771- boards.SMDKV310Config.hardwarepack_handler.get_format = (
1772- lambda: '1.0')
1773- self.make_boot_files(boards.SMDKV310Config)
1774+ board_conf.hardwarepack_handler.get_format = (
1775+ lambda: HardwarepackHandler.FORMAT_1)
1776+ self.make_boot_files(board_conf)
1777 expected = [
1778 'install_samsung_boot_loader', 'make_flashable_env', '_dd',
1779 'make_uImage', 'make_uInitrd', 'make_boot_script']
1780 self.assertEqual(expected, self.funcs_calls)
1781
1782 def test_origen_steps(self):
1783- def mock_func_creator(name):
1784- return classmethod(
1785- lambda *args, **kwargs: self.funcs_calls.append(name))
1786-
1787- self.useFixture(MockSomethingFixture(
1788- linaro_image_tools.media_create.boards.OrigenConfig,
1789- 'install_samsung_boot_loader',
1790- mock_func_creator('install_samsung_boot_loader')))
1791+ board_conf = boards.OrigenConfig()
1792+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1793+ board_conf.install_samsung_boot_loader = MagicMock()
1794+ board_conf.install_samsung_boot_loader.return_value = \
1795+ self.funcs_calls.append('install_samsung_boot_loader')
1796 self.useFixture(MockSomethingFixture(os.path, 'exists',
1797 lambda file: True))
1798- boards.OrigenConfig.hardwarepack_handler = (
1799+ board_conf.hardwarepack_handler = (
1800 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
1801- boards.OrigenConfig.hardwarepack_handler.get_format = (
1802- lambda: '1.0')
1803- self.make_boot_files(boards.OrigenConfig)
1804+ board_conf.hardwarepack_handler.get_format = (
1805+ lambda: HardwarepackHandler.FORMAT_1)
1806+ self.make_boot_files(board_conf)
1807 expected = [
1808 'install_samsung_boot_loader', 'make_flashable_env', '_dd',
1809 'make_uImage', 'make_uInitrd', 'make_boot_script']
1810 self.assertEqual(expected, self.funcs_calls)
1811
1812 def test_origen_quad_steps(self):
1813- def mock_func_creator(name):
1814- return classmethod(
1815- lambda *args, **kwargs: self.funcs_calls.append(name))
1816+ board_conf = boards.OrigenQuadConfig()
1817+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1818+ board_conf.install_samsung_boot_loader = MagicMock()
1819+ board_conf.install_samsung_boot_loader.return_value = \
1820+ self.funcs_calls.append('install_samsung_boot_loader')
1821
1822- self.useFixture(MockSomethingFixture(
1823- linaro_image_tools.media_create.boards.OrigenQuadConfig,
1824- 'install_samsung_boot_loader',
1825- mock_func_creator('install_samsung_boot_loader')))
1826 self.useFixture(MockSomethingFixture(os.path, 'exists',
1827 lambda file: True))
1828- boards.OrigenQuadConfig.hardwarepack_handler = (
1829+ board_conf.hardwarepack_handler = (
1830 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
1831- boards.OrigenQuadConfig.hardwarepack_handler.get_format = (
1832- lambda: '1.0')
1833- self.make_boot_files(boards.OrigenQuadConfig)
1834+ board_conf.hardwarepack_handler.get_format = (
1835+ lambda: HardwarepackHandler.FORMAT_1)
1836+ self.make_boot_files(board_conf)
1837 expected = [
1838 'install_samsung_boot_loader', 'make_flashable_env', '_dd',
1839 'make_uImage', 'make_uInitrd', 'make_boot_script']
1840 self.assertEqual(expected, self.funcs_calls)
1841
1842 def test_arndale_steps(self):
1843- def mock_func_creator(name):
1844- return classmethod(
1845- lambda *args, **kwargs: self.funcs_calls.append(name))
1846+ board_conf = boards.ArndaleConfig()
1847+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1848+ board_conf.install_samsung_boot_loader = MagicMock()
1849+ board_conf.install_samsung_boot_loader.return_value = \
1850+ self.funcs_calls.append('install_samsung_boot_loader')
1851
1852- self.useFixture(MockSomethingFixture(
1853- linaro_image_tools.media_create.boards.ArndaleConfig,
1854- 'install_samsung_boot_loader',
1855- mock_func_creator('install_samsung_boot_loader')))
1856 self.useFixture(MockSomethingFixture(os.path, 'exists',
1857 lambda file: True))
1858- boards.ArndaleConfig.hardwarepack_handler = (
1859+ board_conf.hardwarepack_handler = (
1860 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
1861- boards.ArndaleConfig.hardwarepack_handler.get_format = (
1862+ board_conf.hardwarepack_handler.get_format = (
1863 lambda: '1.0')
1864- self.make_boot_files(boards.ArndaleConfig)
1865+ self.make_boot_files(board_conf)
1866 expected = [
1867 'install_samsung_boot_loader', 'make_flashable_env', '_dd',
1868 'make_uImage', 'make_uInitrd', 'make_boot_script']
1869 self.assertEqual(expected, self.funcs_calls)
1870
1871 def test_ux500_steps(self):
1872- self.make_boot_files(boards.Ux500Config)
1873+ board_conf = boards.Ux500Config()
1874+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1875+ self.make_boot_files(board_conf)
1876 expected = ['make_uImage', 'make_uInitrd', 'make_boot_script']
1877 self.assertEqual(expected, self.funcs_calls)
1878
1879 def test_snowball_sd_steps(self):
1880- self.make_boot_files(boards.SnowballSdConfig)
1881+ board_conf = boards.SnowballSdConfig()
1882+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1883+ self.make_boot_files(board_conf)
1884 expected = ['make_uImage', 'make_boot_script']
1885 self.assertEqual(expected, self.funcs_calls)
1886
1887 def test_panda_steps(self):
1888- self.mock_set_appropriate_serial_tty(boards.PandaConfig)
1889- self.make_boot_files(boards.PandaConfig)
1890+ board_conf = boards.PandaConfig()
1891+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1892+ self.mock_set_appropriate_serial_tty(board_conf)
1893+ self.make_boot_files(board_conf)
1894 expected = [
1895 'install_omap_boot_loader', 'make_uImage', 'make_uInitrd',
1896 'make_dtb', 'make_boot_script', 'make_boot_ini']
1897 self.assertEqual(expected, self.funcs_calls)
1898
1899 def test_beagle_steps(self):
1900- self.mock_set_appropriate_serial_tty(boards.BeagleConfig)
1901- self.make_boot_files(boards.BeagleConfig)
1902+ board_conf = boards.BeagleConfig()
1903+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1904+ self.mock_set_appropriate_serial_tty(board_conf)
1905+ self.make_boot_files(board_conf)
1906 expected = [
1907 'install_omap_boot_loader', 'make_uImage', 'make_uInitrd',
1908 'make_dtb', 'make_boot_script', 'make_boot_ini']
1909 self.assertEqual(expected, self.funcs_calls)
1910
1911 def test_igep_steps(self):
1912- self.mock_set_appropriate_serial_tty(boards.IgepConfig)
1913- self.make_boot_files(boards.IgepConfig)
1914+ board_conf = boards.IgepConfig()
1915+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1916+ self.mock_set_appropriate_serial_tty(board_conf)
1917+ self.make_boot_files(board_conf)
1918 expected = [
1919 'make_uImage', 'make_uInitrd', 'make_dtb', 'make_boot_script',
1920 'make_boot_ini']
1921 self.assertEqual(expected, self.funcs_calls)
1922
1923 def test_overo_steps(self):
1924- self.mock_set_appropriate_serial_tty(boards.OveroConfig)
1925- self.make_boot_files(boards.OveroConfig)
1926+ board_conf = boards.OveroConfig()
1927+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1928+ self.mock_set_appropriate_serial_tty(board_conf)
1929+ self.make_boot_files(board_conf)
1930 expected = [
1931 'install_omap_boot_loader', 'make_uImage', 'make_uInitrd',
1932 'make_dtb', 'make_boot_script', 'make_boot_ini']
1933@@ -1373,20 +1386,20 @@
1934
1935 def test_snowball_config_raises(self):
1936 self.assertRaises(NotImplementedError,
1937- boards.SnowballSdConfig.snowball_config, '')
1938+ boards.SnowballSdConfig().snowball_config, '')
1939
1940 def test_beagle_raw(self):
1941- self.populate_raw_partition(android_boards.AndroidBeagleConfig)
1942+ self.populate_raw_partition(android_boards.AndroidBeagleConfig())
1943 expected = []
1944 self.assertEqual(expected, self.funcs_calls)
1945
1946 def test_panda_raw(self):
1947- self.populate_raw_partition(android_boards.AndroidPandaConfig)
1948+ self.populate_raw_partition(android_boards.AndroidPandaConfig())
1949 expected = []
1950 self.assertEqual(expected, self.funcs_calls)
1951
1952 def test_snowball_sd_raw(self):
1953- self.populate_raw_partition(boards.SnowballSdConfig)
1954+ self.populate_raw_partition(boards.SnowballSdConfig())
1955 expected = []
1956 self.assertEqual(expected, self.funcs_calls)
1957
1958@@ -1411,7 +1424,7 @@
1959 linaro_image_tools.media_create.boards.SnowballEmmcConfig,
1960 'delete_file',
1961 mock_func_creator('delete_file')))
1962- self.populate_raw_partition(boards.SnowballEmmcConfig)
1963+ self.populate_raw_partition(boards.SnowballEmmcConfig())
1964 expected = ['get_file_info', 'create_toc',
1965 'install_snowball_boot_loader', 'delete_file',
1966 'delete_file']
1967@@ -1423,12 +1436,12 @@
1968 self.useFixture(MockSomethingFixture(os.path, 'getsize',
1969 lambda file: 1))
1970
1971- self.populate_raw_partition(boards.SMDKV310Config)
1972+ self.populate_raw_partition(boards.SMDKV310Config())
1973 expected = ['_dd', '_dd', '_dd']
1974 self.assertEqual(expected, self.funcs_calls)
1975
1976 def test_mx53loco_raw(self):
1977- self.populate_raw_partition(boards.Mx53LoCoConfig)
1978+ self.populate_raw_partition(boards.Mx53LoCoConfig())
1979 expected = []
1980 self.assertEqual(expected, self.funcs_calls)
1981
1982@@ -1436,7 +1449,7 @@
1983 self.useFixture(MockSomethingFixture(os.path, 'getsize',
1984 lambda file: 1))
1985
1986- self.populate_raw_partition(boards.OrigenConfig)
1987+ self.populate_raw_partition(boards.OrigenConfig())
1988 expected = ['_dd', '_dd', '_dd']
1989 self.assertEqual(expected, self.funcs_calls)
1990
1991@@ -1444,7 +1457,7 @@
1992 self.useFixture(MockSomethingFixture(os.path, 'getsize',
1993 lambda file: 1))
1994
1995- self.populate_raw_partition(boards.OrigenQuadConfig)
1996+ self.populate_raw_partition(boards.OrigenQuadConfig())
1997 expected = ['_dd', '_dd', '_dd']
1998 self.assertEqual(expected, self.funcs_calls)
1999
2000@@ -1452,12 +1465,12 @@
2001 self.useFixture(MockSomethingFixture(os.path, 'getsize',
2002 lambda file: 1))
2003
2004- self.populate_raw_partition(boards.ArndaleConfig)
2005+ self.populate_raw_partition(boards.ArndaleConfig())
2006 expected = ['_dd', '_dd', '_dd']
2007 self.assertEqual(expected, self.funcs_calls)
2008
2009 def test_vexpress_a9_raw(self):
2010- self.populate_raw_partition(boards.VexpressA9Config)
2011+ self.populate_raw_partition(boards.VexpressA9Config())
2012 expected = []
2013 self.assertEqual(expected, self.funcs_calls)
2014
2015@@ -1472,17 +1485,17 @@
2016 config.populate_raw_partition('', '')
2017
2018 def test_beagle_raw(self):
2019- self.populate_raw_partition(android_boards.AndroidBeagleConfig)
2020+ self.populate_raw_partition(android_boards.AndroidBeagleConfig())
2021 expected = []
2022 self.assertEqual(expected, self.funcs_calls)
2023
2024 def test_panda_raw(self):
2025- self.populate_raw_partition(android_boards.AndroidPandaConfig)
2026+ self.populate_raw_partition(android_boards.AndroidPandaConfig())
2027 expected = []
2028 self.assertEqual(expected, self.funcs_calls)
2029
2030 def test_snowball_sd_raw(self):
2031- self.populate_raw_partition(android_boards.AndroidSnowballSdConfig)
2032+ self.populate_raw_partition(android_boards.AndroidSnowballSdConfig())
2033 expected = []
2034 self.assertEqual(expected, self.funcs_calls)
2035
2036@@ -1513,7 +1526,7 @@
2037 android_boards.AndroidSnowballEmmcConfig,
2038 'delete_file',
2039 mock_func_creator('delete_file')))
2040- self.populate_raw_partition(android_boards.AndroidSnowballEmmcConfig)
2041+ self.populate_raw_partition(android_boards.AndroidSnowballEmmcConfig())
2042 expected_calls = ['get_file_info', 'create_toc',
2043 'install_snowball_boot_loader', 'delete_file']
2044 # Test that we copy the u-boot files to the local startupfiles dir.
2045@@ -1533,14 +1546,14 @@
2046 self.useFixture(MockSomethingFixture(os.path, 'getsize',
2047 lambda file: 1))
2048
2049- self.populate_raw_partition(android_boards.AndroidSMDKV310Config)
2050+ self.populate_raw_partition(android_boards.AndroidSMDKV310Config())
2051 expected_calls = []
2052 # Test that we dd the files
2053 self.assertEqual(expected_commands, fixture.mock.commands_executed)
2054 self.assertEqual(expected_calls, self.funcs_calls)
2055
2056 def test_mx53loco_raw(self):
2057- self.populate_raw_partition(android_boards.AndroidMx53LoCoConfig)
2058+ self.populate_raw_partition(android_boards.AndroidMx53LoCoConfig())
2059 expected = []
2060 self.assertEqual(expected, self.funcs_calls)
2061
2062@@ -1555,7 +1568,7 @@
2063 self.useFixture(MockSomethingFixture(os.path, 'getsize',
2064 lambda file: 1))
2065
2066- self.populate_raw_partition(android_boards.AndroidOrigenConfig)
2067+ self.populate_raw_partition(android_boards.AndroidOrigenConfig())
2068 expected = []
2069 # Test that we dd the files
2070 self.assertEqual(expected_commands, fixture.mock.commands_executed)
2071@@ -1573,14 +1586,14 @@
2072 self.useFixture(MockSomethingFixture(os.path, 'getsize',
2073 lambda file: 1))
2074
2075- self.populate_raw_partition(android_boards.AndroidOrigenQuadConfig)
2076+ self.populate_raw_partition(android_boards.AndroidOrigenQuadConfig())
2077 expected = []
2078 # Test that we dd the files
2079 self.assertEqual(expected_commands, fixture.mock.commands_executed)
2080 self.assertEqual(expected, self.funcs_calls)
2081
2082 def test_vexpress_raw(self):
2083- self.populate_raw_partition(android_boards.AndroidVexpressConfig)
2084+ self.populate_raw_partition(android_boards.AndroidVexpressConfig())
2085 expected = []
2086 self.assertEqual(expected, self.funcs_calls)
2087
2088@@ -1611,25 +1624,29 @@
2089
2090 def mock_set_appropriate_serial_tty(self, config):
2091
2092- def set_appropriate_serial_tty_mock(cls, chroot_dir):
2093+ def set_appropriate_serial_tty_mock(arg):
2094 self.set_appropriate_serial_tty_called = True
2095- cls.serial_tty = cls._serial_tty
2096
2097- self.useFixture(MockSomethingFixture(
2098- config, 'set_appropriate_serial_tty',
2099- classmethod(set_appropriate_serial_tty_mock)))
2100+ # Need to mock all the calls done from make_boot_files in order
2101+ # to be able to correctly call it.
2102+ config._get_kflavor_files = MagicMock(return_value=('', '', ''))
2103+ config._get_boot_env = MagicMock(return_value=None)
2104+ config._make_boot_files = MagicMock()
2105+ config._make_boot_files_v2 = MagicMock()
2106+ config.set_appropriate_serial_tty = MagicMock(
2107+ side_effect=set_appropriate_serial_tty_mock)
2108
2109 def test_omap_make_boot_files(self):
2110 self.set_appropriate_serial_tty_called = False
2111- self.mock_set_appropriate_serial_tty(board_configs['beagle'])
2112- self.useFixture(MockSomethingFixture(
2113- boards.BoardConfig, 'make_boot_files',
2114- classmethod(lambda *args: None)))
2115+
2116+ board_conf = boards.BeagleConfig()
2117+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
2118+ self.mock_set_appropriate_serial_tty(board_conf)
2119 # We don't need to worry about what's passed to make_boot_files()
2120 # because we mock the method which does the real work above and here
2121 # we're only interested in ensuring that OmapConfig.make_boot_files()
2122 # calls set_appropriate_serial_tty().
2123- board_configs['beagle'].make_boot_files(
2124+ board_conf.make_boot_files(
2125 None, None, None, None, None, None, None, None)
2126 self.assertTrue(
2127 self.set_appropriate_serial_tty_called,
2128@@ -1638,17 +1655,14 @@
2129 def test_omap_make_boot_files_v2(self):
2130 self.set_appropriate_serial_tty_called = False
2131
2132- class config(boards.BeagleConfig):
2133- hwpack_format = HardwarepackHandler.FORMAT_2
2134- self.mock_set_appropriate_serial_tty(config)
2135- self.useFixture(MockSomethingFixture(
2136- boards.BoardConfig, 'make_boot_files',
2137- classmethod(lambda *args: None)))
2138+ board_conf = boards.BeagleConfig()
2139+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_2
2140+ self.mock_set_appropriate_serial_tty(board_conf)
2141 # We don't need to worry about what's passed to make_boot_files()
2142 # because we mock the method which does the real work above and here
2143 # we're only interested in ensuring that OmapConfig.make_boot_files()
2144 # does not call set_appropriate_serial_tty().
2145- config.make_boot_files(
2146+ board_conf.make_boot_files(
2147 None, None, None, None, None, None, None, None)
2148 self.assertFalse(
2149 self.set_appropriate_serial_tty_called,
2150@@ -1659,189 +1673,219 @@
2151 boot_dir = os.path.join(tempdir, 'boot')
2152 os.makedirs(boot_dir)
2153 open(os.path.join(boot_dir, 'vmlinuz-2.6.35-23-foo'), 'w').close()
2154- boards.BeagleConfig.set_appropriate_serial_tty(tempdir)
2155- self.assertEquals('ttyS2', boards.BeagleConfig.serial_tty)
2156+ board_conf = boards.BeagleConfig()
2157+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
2158+ board_conf.set_appropriate_serial_tty(tempdir)
2159+ self.assertEquals('ttyS2', board_conf.serial_tty)
2160
2161 def test_set_appropriate_serial_tty_new_kernel(self):
2162 tempdir = self.useFixture(CreateTempDirFixture()).tempdir
2163 boot_dir = os.path.join(tempdir, 'boot')
2164 os.makedirs(boot_dir)
2165 open(os.path.join(boot_dir, 'vmlinuz-2.6.36-13-foo'), 'w').close()
2166- boards.BeagleConfig.set_appropriate_serial_tty(tempdir)
2167- self.assertEquals('ttyO2', boards.BeagleConfig.serial_tty)
2168+ board_conf = boards.BeagleConfig()
2169+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
2170+ board_conf.set_appropriate_serial_tty(tempdir)
2171+ self.assertEquals('ttyO2', board_conf.serial_tty)
2172
2173 def test_set_appropriate_serial_tty_three_dot_oh_kernel(self):
2174 tempdir = self.useFixture(CreateTempDirFixture()).tempdir
2175 boot_dir = os.path.join(tempdir, 'boot')
2176 os.makedirs(boot_dir)
2177 open(os.path.join(boot_dir, 'vmlinuz-3.0-13-foo'), 'w').close()
2178- boards.BeagleConfig.set_appropriate_serial_tty(tempdir)
2179- self.assertEquals('ttyO2', boards.BeagleConfig.serial_tty)
2180+ board_conf = boards.BeagleConfig()
2181+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
2182+ board_conf.set_appropriate_serial_tty(tempdir)
2183+ self.assertEquals('ttyO2', board_conf.serial_tty)
2184
2185
2186 class TestGetSfdiskCmd(TestCase):
2187
2188+ def set_up_config(self, config):
2189+ config.hwpack_format = HardwarepackHandler.FORMAT_1
2190+
2191 def test_default(self):
2192+ board_conf = BoardConfig()
2193+ self.set_up_config(board_conf)
2194 self.assertEqual(
2195- '63,106432,0x0C,*\n106496,,,-',
2196- boards.BoardConfig.get_sfdisk_cmd())
2197+ '63,106432,0x0C,*\n106496,,,-', board_conf.get_sfdisk_cmd())
2198
2199 def test_default_aligned(self):
2200+ board_conf = BoardConfig()
2201+ self.set_up_config(board_conf)
2202 self.assertEqual(
2203 '8192,106496,0x0C,*\n114688,,,-',
2204- boards.BoardConfig.get_sfdisk_cmd(should_align_boot_part=True))
2205+ board_conf.get_sfdisk_cmd(should_align_boot_part=True))
2206
2207 def test_mx5(self):
2208+ board_conf = boards.Mx5Config()
2209+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
2210 self.assertEqual(
2211 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
2212- boards.Mx5Config.get_sfdisk_cmd())
2213+ board_conf.get_sfdisk_cmd())
2214
2215 def test_snowball_sd(self):
2216+ board_conf = boards.SnowballSdConfig()
2217+ self.set_up_config(board_conf)
2218 self.assertEqual(
2219- '63,106432,0x0C,*\n106496,,,-',
2220- boards.SnowballSdConfig.get_sfdisk_cmd())
2221+ '63,106432,0x0C,*\n106496,,,-', board_conf.get_sfdisk_cmd())
2222
2223 def test_snowball_emmc(self):
2224+ board_conf = boards.SnowballEmmcConfig()
2225+ self.set_up_config(board_conf)
2226 self.assertEqual(
2227 '256,7936,0xDA\n8192,106496,0x0C,*\n114688,,,-',
2228- boards.SnowballEmmcConfig.get_sfdisk_cmd())
2229+ board_conf.get_sfdisk_cmd())
2230
2231 def test_smdkv310(self):
2232+ board_conf = get_board_config('smdkv310')
2233+ self.set_up_config(board_conf)
2234 self.assertEquals(
2235 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
2236- board_configs['smdkv310'].get_sfdisk_cmd())
2237+ board_conf.get_sfdisk_cmd())
2238
2239 def test_origen(self):
2240+ board_conf = get_board_config('origen')
2241+ self.set_up_config(board_conf)
2242 self.assertEquals(
2243 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
2244- board_configs['origen'].get_sfdisk_cmd())
2245+ board_conf.get_sfdisk_cmd())
2246
2247 def test_origen_quad(self):
2248+ board_conf = get_board_config('origen_quad')
2249+ self.set_up_config(board_conf)
2250 self.assertEquals(
2251 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
2252- board_configs['origen_quad'].get_sfdisk_cmd())
2253+ board_conf.get_sfdisk_cmd())
2254
2255 def test_arndale(self):
2256+ board_conf = get_board_config('arndale')
2257+ self.set_up_config(board_conf)
2258 self.assertEquals(
2259 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
2260- board_configs['arndale'].get_sfdisk_cmd())
2261+ board_conf.get_sfdisk_cmd())
2262
2263 def test_panda_android(self):
2264 self.assertEqual(
2265 '63,270272,0x0C,*\n270336,1048576,L\n1318912,524288,L\n'
2266 '1843200,-,E\n1843200,1048576,L\n2891776,,,-',
2267- android_boards.AndroidPandaConfig.get_sfdisk_cmd())
2268+ android_boards.AndroidPandaConfig().get_sfdisk_cmd())
2269
2270 def test_origen_android(self):
2271 self.assertEqual(
2272 '1,8191,0xDA\n8253,270274,0x0C,*\n278528,1048576,L\n'
2273 '1327104,-,E\n1327104,524288,L\n1851392,1048576,L\n2899968,,,-',
2274- android_boards.AndroidOrigenConfig.get_sfdisk_cmd())
2275+ android_boards.AndroidOrigenConfig().get_sfdisk_cmd())
2276
2277 def test_origen_quad_android(self):
2278 self.assertEqual(
2279 '1,8191,0xDA\n8253,270274,0x0C,*\n278528,1048576,L\n'
2280 '1327104,-,E\n1327104,524288,L\n1851392,1048576,L\n2899968,,,-',
2281- android_boards.AndroidOrigenQuadConfig.get_sfdisk_cmd())
2282+ android_boards.AndroidOrigenQuadConfig().get_sfdisk_cmd())
2283
2284 def test_snowball_emmc_android(self):
2285 self.assertEqual(
2286 '256,7936,0xDA\n8192,262144,0x0C,*\n270336,1048576,L\n'
2287 '1318912,-,E\n1318912,524288,L\n1843200,1048576,L\n2891776,,,-',
2288- android_boards.AndroidSnowballEmmcConfig.get_sfdisk_cmd())
2289+ android_boards.AndroidSnowballEmmcConfig().get_sfdisk_cmd())
2290
2291 def test_vexpress_android(self):
2292 self.assertEqual(
2293 '63,270272,0x0E,*\n270336,1048576,L\n1318912,524288,L\n'
2294 '1843200,-,E\n1843200,1048576,L\n2891776,,,-',
2295- android_boards.AndroidVexpressConfig.get_sfdisk_cmd())
2296+ android_boards.AndroidVexpressConfig().get_sfdisk_cmd())
2297
2298 def test_mx5_android(self):
2299 self.assertEqual(
2300 '1,8191,0xDA\n8192,262144,0x0C,*\n270336,1048576,L\n'
2301 '1318912,-,E\n1318912,524288,L\n1843200,1048576,L\n2891776,,,-',
2302- android_boards.AndroidMx53LoCoConfig.get_sfdisk_cmd())
2303+ android_boards.AndroidMx53LoCoConfig().get_sfdisk_cmd())
2304
2305 def test_mx6_android(self):
2306 self.assertEqual(
2307 '1,8191,0xDA\n8192,262144,0x0C,*\n270336,1048576,L\n'
2308 '1318912,-,E\n1318912,524288,L\n1843200,1048576,L\n2891776,,,-',
2309- android_boards.AndroidMx6QSabreliteConfig.get_sfdisk_cmd())
2310+ android_boards.AndroidMx6QSabreliteConfig().get_sfdisk_cmd())
2311
2312
2313 class TestGetSfdiskCmdV2(TestCase):
2314
2315 def test_mx5(self):
2316- class config(boards.Mx5Config):
2317- partition_layout = 'reserved_bootfs_rootfs'
2318+ board_conf = boards.Mx5Config()
2319+ board_conf.partition_layout = 'reserved_bootfs_rootfs'
2320 self.assertEqual(
2321 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
2322- config.get_sfdisk_cmd())
2323+ board_conf.get_sfdisk_cmd())
2324
2325 def test_snowball_sd(self):
2326- class config(boards.SnowballSdConfig):
2327- partition_layout = 'bootfs_rootfs'
2328+ board_conf = boards.SnowballSdConfig()
2329+ board_conf.partition_layout = 'bootfs_rootfs'
2330 self.assertEqual(
2331 '63,106432,0x0C,*\n106496,,,-',
2332- config.get_sfdisk_cmd())
2333+ board_conf.get_sfdisk_cmd())
2334
2335 def test_snowball_emmc(self):
2336- class config(boards.SnowballEmmcConfig):
2337- partition_layout = 'reserved_bootfs_rootfs'
2338- LOADER_START_S = (128 * 1024) / SECTOR_SIZE
2339+ board_conf = boards.SnowballEmmcConfig()
2340+ board_conf.partition_layout = 'reserved_bootfs_rootfs'
2341+ board_conf.loader_start_s = (128 * 1024) / SECTOR_SIZE
2342 self.assertEqual(
2343 '256,7936,0xDA\n8192,106496,0x0C,*\n114688,,,-',
2344- config.get_sfdisk_cmd())
2345+ board_conf.get_sfdisk_cmd())
2346
2347 def test_smdkv310(self):
2348- class config(board_configs['smdkv310']):
2349- partition_layout = 'reserved_bootfs_rootfs'
2350- LOADER_MIN_SIZE_S = (boards.BoardConfig.samsung_bl1_start +
2351- boards.BoardConfig.samsung_bl1_len +
2352- boards.BoardConfig.samsung_bl2_len +
2353- boards.BoardConfig.samsung_env_len)
2354+ board_conf = get_board_config('smdkv310')
2355+ board_conf.partition_layout = 'reserved_bootfs_rootfs'
2356+ board_conf.LOADER_MIN_SIZE_S = (
2357+ board_conf.samsung_bl1_start +
2358+ board_conf.samsung_bl1_len +
2359+ board_conf.samsung_bl2_len +
2360+ board_conf.samsung_env_len)
2361 self.assertEquals(
2362 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
2363- config.get_sfdisk_cmd())
2364+ board_conf.get_sfdisk_cmd())
2365
2366 def test_origen(self):
2367- class config(board_configs['origen']):
2368- partition_layout = 'reserved_bootfs_rootfs'
2369- LOADER_MIN_SIZE_S = (boards.BoardConfig.samsung_bl1_start +
2370- boards.BoardConfig.samsung_bl1_len +
2371- boards.BoardConfig.samsung_bl2_len +
2372- boards.BoardConfig.samsung_env_len)
2373+ board_conf = get_board_config('origen')
2374+ board_conf.partition_layout = 'reserved_bootfs_rootfs'
2375+ board_conf.LOADER_MIN_SIZE_S = (
2376+ board_conf.samsung_bl1_start +
2377+ board_conf.samsung_bl1_len +
2378+ board_conf.samsung_bl2_len +
2379+ board_conf.samsung_env_len)
2380 self.assertEquals(
2381 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
2382- config.get_sfdisk_cmd())
2383+ board_conf.get_sfdisk_cmd())
2384
2385 def test_origen_quad(self):
2386- class config(board_configs['origen_quad']):
2387- partition_layout = 'reserved_bootfs_rootfs'
2388- LOADER_MIN_SIZE_S = (boards.BoardConfig.samsung_bl1_start +
2389- boards.BoardConfig.samsung_bl1_len +
2390- boards.BoardConfig.samsung_bl2_len +
2391- boards.BoardConfig.samsung_env_len)
2392+ board_conf = get_board_config('origen_quad')
2393+ board_conf.partition_layout = 'reserved_bootfs_rootfs'
2394+ board_conf.LOADER_MIN_SIZE_S = (
2395+ board_conf.samsung_bl1_start +
2396+ board_conf.samsung_bl1_len +
2397+ board_conf.samsung_bl2_len +
2398+ board_conf.samsung_env_len)
2399 self.assertEquals(
2400 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
2401- config.get_sfdisk_cmd())
2402+ board_conf.get_sfdisk_cmd())
2403
2404 def test_arndale(self):
2405- class config(board_configs['arndale']):
2406- partition_layout = 'reserved_bootfs_rootfs'
2407- LOADER_MIN_SIZE_S = (boards.BoardConfig.samsung_bl1_start +
2408- boards.BoardConfig.samsung_bl1_len +
2409- boards.BoardConfig.samsung_bl2_len +
2410- boards.BoardConfig.samsung_env_len)
2411+ board_conf = get_board_config('arndale')
2412+ board_conf.partition_layout = 'reserved_bootfs_rootfs'
2413+ board_conf.LOADER_MIN_SIZE_S = (
2414+ board_conf.samsung_bl1_start +
2415+ board_conf.samsung_bl1_len +
2416+ board_conf.samsung_bl2_len +
2417+ board_conf.samsung_env_len)
2418 self.assertEquals(
2419 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
2420- config.get_sfdisk_cmd())
2421+ board_conf.get_sfdisk_cmd())
2422
2423
2424 class TestGetBootCmd(TestCase):
2425
2426 def test_vexpress(self):
2427- boot_commands = board_configs['vexpress']._get_boot_env(
2428+ board_conf = get_board_config('vexpress')
2429+ boot_commands = board_conf._get_boot_env(
2430 is_live=False, is_lowmem=False, consoles=['ttyXXX'],
2431 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)
2432 expected = {
2433@@ -1855,7 +1899,8 @@
2434 self.assertEqual(expected, boot_commands)
2435
2436 def test_vexpress_a9(self):
2437- boot_commands = board_configs['vexpress-a9']._get_boot_env(
2438+ board_conf = get_board_config('vexpress-a9')
2439+ boot_commands = board_conf._get_boot_env(
2440 is_live=False, is_lowmem=False, consoles=['ttyXXX'],
2441 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)
2442 expected = {
2443@@ -1869,7 +1914,8 @@
2444 self.assertEqual(expected, boot_commands)
2445
2446 def test_mx51(self):
2447- boot_commands = boards.Mx51Config._get_boot_env(
2448+ board_conf = boards.Mx51Config()
2449+ boot_commands = board_conf._get_boot_env(
2450 is_live=False, is_lowmem=False, consoles=[],
2451 rootfs_id="UUID=deadbeef", i_img_data="initrd",
2452 d_img_data="mx51.dtb")
2453@@ -1885,7 +1931,8 @@
2454 self.assertEqual(expected, boot_commands)
2455
2456 def test_smdkv310(self):
2457- boot_commands = board_configs['smdkv310']._get_boot_env(
2458+ board_conf = get_board_config('smdkv310')
2459+ boot_commands = board_conf._get_boot_env(
2460 is_live=False, is_lowmem=False, consoles=[],
2461 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)
2462 expected = {
2463@@ -1901,7 +1948,8 @@
2464 self.assertEqual(expected, boot_commands)
2465
2466 def test_origen(self):
2467- boot_commands = board_configs['origen']._get_boot_env(
2468+ board_conf = get_board_config('origen')
2469+ boot_commands = board_conf._get_boot_env(
2470 is_live=False, is_lowmem=False, consoles=[],
2471 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)
2472 expected = {
2473@@ -1915,7 +1963,8 @@
2474 self.assertEqual(expected, boot_commands)
2475
2476 def test_origen_quad(self):
2477- boot_commands = board_configs['origen_quad']._get_boot_env(
2478+ board_conf = get_board_config('origen_quad')
2479+ boot_commands = board_conf._get_boot_env(
2480 is_live=False, is_lowmem=False, consoles=[],
2481 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)
2482 expected = {
2483@@ -1929,7 +1978,8 @@
2484 self.assertEqual(expected, boot_commands)
2485
2486 def test_ux500(self):
2487- boot_commands = board_configs['ux500']._get_boot_env(
2488+ board_conf = get_board_config('ux500')
2489+ boot_commands = board_conf._get_boot_env(
2490 is_live=False, is_lowmem=False, consoles=[],
2491 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)
2492 expected = {
2493@@ -1947,7 +1997,8 @@
2494 self.assertEqual(expected, boot_commands)
2495
2496 def test_snowball_emmc(self):
2497- boot_commands = board_configs['snowball_emmc']._get_boot_env(
2498+ board_conf = get_board_config('snowball_emmc')
2499+ boot_commands = board_conf._get_boot_env(
2500 is_live=False, is_lowmem=False, consoles=[],
2501 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)
2502 expected = {
2503@@ -1968,7 +2019,7 @@
2504 # XXX: To fix bug 697824 we have to change class attributes of our
2505 # OMAP board configs, and some tests do that so to make sure they
2506 # don't interfere with us we'll reset that before doing anything.
2507- config = board_configs['panda']
2508+ config = get_board_config('panda')
2509 config.serial_tty = config._serial_tty
2510 boot_commands = config._get_boot_env(
2511 is_live=False, is_lowmem=False, consoles=[],
2512@@ -1991,7 +2042,7 @@
2513 # XXX: To fix bug 697824 we have to change class attributes of our
2514 # OMAP board configs, and some tests do that so to make sure they
2515 # don't interfere with us we'll reset that before doing anything.
2516- config = board_configs['beagle']
2517+ config = get_board_config('beagle')
2518 config.serial_tty = config._serial_tty
2519 boot_commands = config._get_boot_env(
2520 is_live=False, is_lowmem=False, consoles=[],
2521@@ -2014,7 +2065,7 @@
2522 # XXX: To fix bug 697824 we have to change class attributes of our
2523 # OMAP board configs, and some tests do that so to make sure they
2524 # don't interfere with us we'll reset that before doing anything.
2525- config = boards.IgepConfig
2526+ config = boards.IgepConfig()
2527 config.serial_tty = config._serial_tty
2528 boot_cmd = config._get_boot_env(
2529 is_live=False, is_lowmem=False, consoles=[],
2530@@ -2037,7 +2088,7 @@
2531 # XXX: To fix bug 697824 we have to change class attributes of our
2532 # OMAP board configs, and some tests do that so to make sure they
2533 # don't interfere with us we'll reset that before doing anything.
2534- config = board_configs['overo']
2535+ config = get_board_config('overo')
2536 config.serial_tty = config._serial_tty
2537 boot_commands = config._get_boot_env(
2538 is_live=False, is_lowmem=False, consoles=[],
2539@@ -2060,12 +2111,15 @@
2540
2541 class TestExtraBootCmd(TestCaseWithFixtures):
2542
2543+ def setUp(self):
2544+ super(TestExtraBootCmd, self).setUp()
2545+ self.board_conf = BoardConfig()
2546+
2547 def test_extra_boot_args_options_is_picked_by_get_boot_env(self):
2548 boot_args = 'whatever'
2549
2550- class config(BoardConfig):
2551- extra_boot_args_options = boot_args
2552- boot_commands = config._get_boot_env(
2553+ self.board_conf.extra_boot_args_options = boot_args
2554+ boot_commands = self.board_conf._get_boot_env(
2555 is_live=False, is_lowmem=False, consoles=['ttyXXX'],
2556 rootfs_id="UUID=deadbeef", i_img_data=None, d_img_data=None)
2557 expected = (
2558@@ -2075,28 +2129,25 @@
2559 def test_passing_None_to_add_boot_args(self):
2560 boot_args = 'extra-args'
2561
2562- class config(BoardConfig):
2563- extra_boot_args_options = boot_args
2564- config.add_boot_args(None)
2565- self.assertEqual(boot_args, config.extra_boot_args_options)
2566+ self.board_conf.extra_boot_args_options = boot_args
2567+ self.board_conf.add_boot_args(None)
2568+ self.assertEqual(boot_args, self.board_conf.extra_boot_args_options)
2569
2570 def test_passing_string_to_add_boot_args(self):
2571 boot_args = 'extra-args'
2572 extra_args = 'user-args'
2573
2574- class config(BoardConfig):
2575- extra_boot_args_options = boot_args
2576- config.add_boot_args(extra_args)
2577+ self.board_conf.extra_boot_args_options = boot_args
2578+ self.board_conf.add_boot_args(extra_args)
2579 self.assertEqual(
2580- "%s %s" % (boot_args, extra_args), config.extra_boot_args_options)
2581+ "%s %s" % (boot_args, extra_args),
2582+ self.board_conf.extra_boot_args_options)
2583
2584 def test_passing_string_to_add_boot_args_with_no_default_extra_args(self):
2585 extra_args = 'user-args'
2586
2587- class config(BoardConfig):
2588- extra_boot_args_options = None
2589- config.add_boot_args(extra_args)
2590- self.assertEqual(extra_args, config.extra_boot_args_options)
2591+ self.board_conf.add_boot_args(extra_args)
2592+ self.assertEqual(extra_args, self.board_conf.extra_boot_args_options)
2593
2594 def test_add_boot_args_from_file(self):
2595 boot_args = 'extra-args'
2596@@ -2105,19 +2156,18 @@
2597 with open(boot_arg_path, 'w') as boot_arg_file:
2598 boot_arg_file.write(extra_args)
2599
2600- class config(BoardConfig):
2601- extra_boot_args_options = boot_args
2602- config.add_boot_args_from_file(boot_arg_path)
2603+ self.board_conf.extra_boot_args_options = boot_args
2604+ self.board_conf.add_boot_args_from_file(boot_arg_path)
2605 self.assertEqual(
2606- "%s %s" % (boot_args, extra_args), config.extra_boot_args_options)
2607+ "%s %s" % (boot_args, extra_args),
2608+ self.board_conf.extra_boot_args_options)
2609
2610 def test_passing_None_to_add_boot_args_from_file(self):
2611 boot_args = 'extra-args'
2612
2613- class config(BoardConfig):
2614- extra_boot_args_options = boot_args
2615- config.add_boot_args_from_file(None)
2616- self.assertEqual(boot_args, config.extra_boot_args_options)
2617+ self.board_conf.extra_boot_args_options = boot_args
2618+ self.board_conf.add_boot_args_from_file(None)
2619+ self.assertEqual(boot_args, self.board_conf.extra_boot_args_options)
2620
2621 def test_add_boot_args_from_file_strips_whitespace_from_file(self):
2622 boot_args = 'extra-args'
2623@@ -2126,134 +2176,11 @@
2624 with open(boot_arg_path, 'w') as boot_arg_file:
2625 boot_arg_file.write('\n\n \t ' + extra_args + ' \n\n')
2626
2627- class config(BoardConfig):
2628- extra_boot_args_options = boot_args
2629- config.add_boot_args_from_file(boot_arg_path)
2630+ self.board_conf.extra_boot_args_options = boot_args
2631+ self.board_conf.add_boot_args_from_file(boot_arg_path)
2632 self.assertEqual(
2633- "%s %s" % (boot_args, extra_args), config.extra_boot_args_options)
2634-
2635-
2636-class TestGetBootCmdAndroid(TestCase):
2637-
2638- def test_panda(self):
2639- # XXX: To fix bug 697824 we have to change class attributes of our
2640- # OMAP board configs, and some tests do that so to make sure they
2641- # don't interfere with us we'll reset that before doing anything.
2642- config = android_board_configs['panda']
2643- config.serial_tty = config._serial_tty
2644- expected = {
2645- 'bootargs': 'console=ttyO2,115200n8 '
2646- 'rootwait ro earlyprintk fixrtc '
2647- 'nocompcache vram=48M omapfb.vram=0:24M,1:24M '
2648- 'mem=456M@0x80000000 mem=512M@0xA0000000 '
2649- 'init=/init androidboot.console=ttyO2',
2650- 'bootcmd': 'fatload mmc 0:1 0x80200000 uImage; '
2651- 'fatload mmc 0:1 0x81600000 uInitrd; '
2652- 'fatload mmc 0:1 0x815f0000 board.dtb; '
2653- 'bootm 0x80200000 0x81600000 0x815f0000',
2654- 'fdt_high': '0xffffffff',
2655- 'initrd_high': '0xffffffff'}
2656- self.assertBootEnv(config, expected)
2657-
2658- def test_android_snowball_sd(self):
2659- expected = {
2660- 'bootargs': 'console=ttyAMA2,115200n8 '
2661- 'rootwait ro earlyprintk '
2662- 'mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
2663- 'mem=22M@360M mem_issw=1M@383M mem=640M@384M '
2664- 'vmalloc=500M init=/init androidboot.console=ttyAMA2',
2665- 'bootcmd': 'fatload mmc 1:1 0x00100000 uImage; '
2666- 'fatload mmc 1:1 0x05000000 uInitrd; '
2667- 'fatload mmc 1:1 0x8000000 board.dtb; '
2668- 'bootm 0x00100000 0x05000000 0x8000000',
2669- 'fdt_high': '0x05000000',
2670- 'initrd_high': '0x06000000'}
2671- self.assertBootEnv(
2672- android_boards.AndroidSnowballSdConfig, expected)
2673-
2674- def test_android_snowball_emmc(self):
2675- expected = {
2676- 'bootargs': 'console=ttyAMA2,115200n8 '
2677- 'rootwait ro earlyprintk '
2678- 'mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
2679- 'mem=22M@360M mem_issw=1M@383M mem=640M@384M '
2680- 'vmalloc=500M init=/init androidboot.console=ttyAMA2',
2681- 'bootcmd': 'fatload mmc 0:2 0x00100000 uImage; '
2682- 'fatload mmc 0:2 0x05000000 uInitrd; '
2683- 'fatload mmc 0:2 0x8000000 board.dtb; '
2684- 'bootm 0x00100000 0x05000000 0x8000000',
2685- 'fdt_high': '0x05000000',
2686- 'initrd_high': '0x06000000'}
2687- self.assertBootEnv(
2688- android_boards.AndroidSnowballEmmcConfig, expected)
2689-
2690- def test_android_origen(self):
2691- expected = {
2692- 'bootargs': 'console=tty0 console=ttySAC2,115200n8 '
2693- 'rootwait ro init=/init androidboot.console=ttySAC2',
2694- 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
2695- 'fatload mmc 0:2 0x42000000 uInitrd; '
2696- 'bootm 0x40007000 0x42000000',
2697- 'fdt_high': '0xffffffff',
2698- 'initrd_high': '0xffffffff'}
2699- self.assertBootEnv(
2700- android_boards.AndroidOrigenConfig, expected)
2701-
2702- def test_android_origen_quad(self):
2703- expected = {
2704- 'bootargs': 'console=tty0 console=ttySAC2,115200n8 '
2705- 'rootwait ro init=/init androidboot.console=ttySAC2',
2706- 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
2707- 'fatload mmc 0:2 0x42000000 uInitrd; '
2708- 'bootm 0x40007000 0x42000000',
2709- 'fdt_high': '0xffffffff',
2710- 'initrd_high': '0xffffffff'}
2711- self.assertBootEnv(
2712- android_boards.AndroidOrigenQuadConfig, expected)
2713-
2714- def test_android_vexpress(self):
2715- expected = {
2716- 'bootargs': 'console=tty0 console=ttyAMA0,38400n8 '
2717- 'rootwait ro init=/init androidboot.console=ttyAMA0',
2718- 'bootcmd': 'fatload mmc 0:1 0x60000000 uImage; '
2719- 'fatload mmc 0:1 0x62000000 uInitrd; '
2720- 'bootm 0x60000000 0x62000000',
2721- 'fdt_high': '0xffffffff',
2722- 'initrd_high': '0xffffffff'}
2723- self.assertBootEnv(
2724- android_boards.AndroidVexpressConfig, expected)
2725-
2726- def test_android_mx5(self):
2727- expected = {
2728- 'bootargs': 'console=ttymxc0,115200n8 '
2729- 'rootwait ro earlyprintk rootdelay=1 fixrtc '
2730- 'nocompcache di1_primary tve init=/init '
2731- 'androidboot.console=ttymxc0',
2732- 'bootcmd': 'fatload mmc 0:2 0x70000000 uImage; '
2733- 'fatload mmc 0:2 0x72000000 uInitrd; '
2734- 'bootm 0x70000000 0x72000000',
2735- 'fdt_high': '0xffffffff',
2736- 'initrd_high': '0xffffffff'}
2737- self.assertBootEnv(
2738- android_boards.AndroidMx53LoCoConfig, expected)
2739-
2740- def test_android_mx6(self):
2741- expected = {
2742- 'bootargs': 'console=ttymxc0,115200n8 '
2743- 'rootwait ro earlyprintk rootdelay=1 fixrtc '
2744- 'nocompcache di1_primary tve init=/init '
2745- 'androidboot.console=ttymxc0',
2746- 'bootcmd': 'fatload mmc 0:2 0x10000000 uImage; '
2747- 'fatload mmc 0:2 0x12000000 uInitrd; '
2748- 'fatload mmc 0:2 0x11ff0000 board.dtb; '
2749- 'bootm 0x10000000 0x12000000 0x11ff0000',
2750- 'fdt_high': '0xffffffff',
2751- 'initrd_high': '0xffffffff'}
2752- self.assertBootEnv(
2753- android_boards.AndroidMx6QSabreliteConfig, expected)
2754-
2755- def assertBootEnv(self, config, expected):
2756- self.assertEqual(expected, config._get_boot_env(consoles=[]))
2757+ "%s %s" % (boot_args, extra_args),
2758+ self.board_conf.extra_boot_args_options)
2759
2760
2761 class TestUnpackBinaryTarball(TestCaseWithFixtures):
2762@@ -2375,119 +2302,110 @@
2763 boards, '_get_mlo_file',
2764 lambda chroot_dir: "%s/MLO" % chroot_dir))
2765
2766- class config(BoardConfig):
2767- pass
2768- config.set_metadata([])
2769- install_omap_boot_loader("chroot_dir", "boot_disk", config)
2770+ board_conf = BoardConfig()
2771+ board_conf.set_metadata([])
2772+ install_omap_boot_loader("chroot_dir", "boot_disk", board_conf)
2773 expected = [
2774 '%s cp -v chroot_dir/MLO boot_disk' % sudo_args, 'sync']
2775 self.assertEqual(expected, fixture.mock.commands_executed)
2776
2777 def test_install_smdk_u_boot(self):
2778 fixture = self._mock_Popen()
2779- bootloader_flavor = boards.SMDKV310Config.bootloader_flavor
2780+ board_conf = boards.SMDKV310Config()
2781+ bootloader_flavor = board_conf.bootloader_flavor
2782 self.useFixture(MockSomethingFixture(os.path, 'getsize',
2783 lambda file: 1))
2784- boards.SMDKV310Config.install_samsung_boot_loader(
2785+ board_conf.install_samsung_boot_loader(
2786 "%s/%s/SPL" % ("chroot_dir", bootloader_flavor),
2787 "%s/%s/uboot" % ("chroot_dir", bootloader_flavor), "boot_disk")
2788 expected = [
2789 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
2790 'seek=%d' % (sudo_args, bootloader_flavor,
2791- boards.SMDKV310Config.samsung_bl1_start),
2792+ board_conf.samsung_bl1_start),
2793 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
2794 'seek=%d' % (sudo_args, bootloader_flavor,
2795- boards.SMDKV310Config.samsung_bl2_start)]
2796+ board_conf.samsung_bl2_start)]
2797 self.assertEqual(expected, fixture.mock.commands_executed)
2798
2799+ def _set_up_board_config(self, board_name):
2800+ """Internal method to set-up correctly board config, with the
2801+ appropriate mock objects.
2802+
2803+ :param board_name: The name of the board to set-up.
2804+ :return A 3-tuple: the config, the name of the bootloader, and the
2805+ value of chroot_dir.
2806+ """
2807+ board_conf = get_board_config(board_name)
2808+ bootloader_flavor = board_conf.bootloader_flavor
2809+ # Made-up value to be used as the chroot directory.
2810+ chroot_dir_value = 'chroot_dir'
2811+ board_conf._get_samsung_spl = MagicMock()
2812+ board_conf._get_samsung_spl.return_value = ("%s/%s/SPL" %
2813+ (chroot_dir_value, bootloader_flavor))
2814+ board_conf._get_samsung_bootloader = MagicMock()
2815+ board_conf._get_samsung_bootloader.return_value = ("%s/%s/uboot" %
2816+ (chroot_dir_value, bootloader_flavor))
2817+ board_conf.hardwarepack_handler = (
2818+ TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
2819+ board_conf.hardwarepack_handler.get_format = (
2820+ lambda: HardwarepackHandler.FORMAT_1)
2821+ return board_conf, bootloader_flavor, chroot_dir_value
2822+
2823 def test_install_origen_u_boot(self):
2824 fixture = self._mock_Popen()
2825- bootloader_flavor = boards.OrigenConfig.bootloader_flavor
2826- self.useFixture(MockSomethingFixture(
2827- boards.OrigenConfig, '_get_samsung_spl',
2828- classmethod(lambda cls, chroot_dir: "%s/%s/SPL" % (
2829- chroot_dir, bootloader_flavor))))
2830- self.useFixture(MockSomethingFixture(
2831- boards.OrigenConfig, '_get_samsung_bootloader',
2832- classmethod(lambda cls, chroot_dir: "%s/%s/uboot" % (
2833- chroot_dir, bootloader_flavor))))
2834- boards.OrigenConfig.hardwarepack_handler = (
2835- TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
2836- boards.OrigenConfig.hardwarepack_handler.get_format = (
2837- lambda: '1.0')
2838+ board_conf, bootloader_flavor, chroot_dir_value = \
2839+ self._set_up_board_config('origen')
2840 self.useFixture(MockSomethingFixture(os.path, 'getsize',
2841 lambda file: 1))
2842- boards.OrigenConfig.install_samsung_boot_loader(
2843- boards.OrigenConfig._get_samsung_spl("chroot_dir"),
2844- boards.OrigenConfig._get_samsung_bootloader("chroot_dir"),
2845+ board_conf.install_samsung_boot_loader(
2846+ board_conf._get_samsung_spl(chroot_dir_value),
2847+ board_conf._get_samsung_bootloader(chroot_dir_value),
2848 "boot_disk")
2849 expected = [
2850 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
2851 'seek=%d' % (sudo_args, bootloader_flavor,
2852- boards.OrigenConfig.samsung_bl1_start),
2853+ board_conf.samsung_bl1_start),
2854 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
2855 'seek=%d' % (sudo_args, bootloader_flavor,
2856- boards.OrigenConfig.samsung_bl2_start)]
2857+ board_conf.samsung_bl2_start)]
2858 self.assertEqual(expected, fixture.mock.commands_executed)
2859
2860 def test_install_origen_quad_u_boot(self):
2861 fixture = self._mock_Popen()
2862- bootloader_flavor = boards.OrigenQuadConfig.bootloader_flavor
2863- self.useFixture(MockSomethingFixture(
2864- boards.OrigenQuadConfig, '_get_samsung_spl',
2865- classmethod(lambda cls, chroot_dir: "%s/%s/SPL" % (
2866- chroot_dir, bootloader_flavor))))
2867- self.useFixture(MockSomethingFixture(
2868- boards.OrigenQuadConfig, '_get_samsung_bootloader',
2869- classmethod(lambda cls, chroot_dir: "%s/%s/uboot" % (
2870- chroot_dir, bootloader_flavor))))
2871- boards.OrigenQuadConfig.hardwarepack_handler = (
2872- TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
2873- boards.OrigenQuadConfig.hardwarepack_handler.get_format = (
2874- lambda: '1.0')
2875+ board_conf, bootloader_flavor, chroot_dir_value = \
2876+ self._set_up_board_config('origen_quad')
2877 self.useFixture(MockSomethingFixture(os.path, 'getsize',
2878 lambda file: 1))
2879- boards.OrigenQuadConfig.install_samsung_boot_loader(
2880- boards.OrigenQuadConfig._get_samsung_spl("chroot_dir"),
2881- boards.OrigenQuadConfig._get_samsung_bootloader("chroot_dir"),
2882+ board_conf.install_samsung_boot_loader(
2883+ board_conf._get_samsung_spl(chroot_dir_value),
2884+ board_conf._get_samsung_bootloader(chroot_dir_value),
2885 "boot_disk")
2886 expected = [
2887 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
2888 'seek=%d' % (sudo_args, bootloader_flavor,
2889- boards.OrigenQuadConfig.samsung_bl1_start),
2890+ board_conf.samsung_bl1_start),
2891 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
2892 'seek=%d' % (sudo_args, bootloader_flavor,
2893- boards.OrigenQuadConfig.samsung_bl2_start)]
2894+ board_conf.samsung_bl2_start)]
2895 self.assertEqual(expected, fixture.mock.commands_executed)
2896
2897 def test_install_arndale_u_boot(self):
2898 fixture = self._mock_Popen()
2899- bootloader_flavor = boards.ArndaleConfig.bootloader_flavor
2900- self.useFixture(MockSomethingFixture(
2901- boards.ArndaleConfig, '_get_samsung_spl',
2902- classmethod(lambda cls, chroot_dir: "%s/%s/SPL" % (
2903- chroot_dir, bootloader_flavor))))
2904- self.useFixture(MockSomethingFixture(
2905- boards.ArndaleConfig, '_get_samsung_bootloader',
2906- classmethod(lambda cls, chroot_dir: "%s/%s/uboot" % (
2907- chroot_dir, bootloader_flavor))))
2908- boards.ArndaleConfig.hardwarepack_handler = (
2909- TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
2910- boards.ArndaleConfig.hardwarepack_handler.get_format = (
2911- lambda: '1.0')
2912+ board_conf, bootloader_flavor, chroot_dir_value = \
2913+ self._set_up_board_config('arndale')
2914 self.useFixture(MockSomethingFixture(os.path, 'getsize',
2915 lambda file: 1))
2916- boards.ArndaleConfig.install_samsung_boot_loader(
2917- boards.ArndaleConfig._get_samsung_spl("chroot_dir"),
2918- boards.ArndaleConfig._get_samsung_bootloader("chroot_dir"),
2919+ board_conf.install_samsung_boot_loader(
2920+ board_conf._get_samsung_spl(chroot_dir_value),
2921+ board_conf._get_samsung_bootloader(chroot_dir_value),
2922 "boot_disk")
2923 expected = [
2924 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
2925 'seek=%d' % (sudo_args, bootloader_flavor,
2926- boards.ArndaleConfig.samsung_bl1_start),
2927+ board_conf.samsung_bl1_start),
2928 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
2929 'seek=%d' % (sudo_args, bootloader_flavor,
2930- boards.ArndaleConfig.samsung_bl2_start)]
2931+ board_conf.samsung_bl2_start)]
2932 self.assertEqual(expected, fixture.mock.commands_executed)
2933
2934 def test_get_plain_boot_script_contents(self):
2935@@ -2544,77 +2462,77 @@
2936 flavorx = 'flavorX'
2937 flavorxy = 'flavorXY'
2938
2939- class config(boards.BoardConfig):
2940- kernel_flavors = [flavorx, flavorxy]
2941- for f in reversed(config.kernel_flavors):
2942+ board_conf = BoardConfig()
2943+ board_conf.kernel_flavors = [flavorx, flavorxy]
2944+ for f in reversed(board_conf.kernel_flavors):
2945 kfile = os.path.join(tempdir, 'vmlinuz-1-%s' % f)
2946 ifile = os.path.join(tempdir, 'initrd.img-1-%s' % f)
2947 open(kfile, "w").close()
2948 open(ifile, "w").close()
2949 self.assertEqual(
2950- (kfile, ifile, None), config._get_kflavor_files(tempdir))
2951+ (kfile, ifile, None), board_conf._get_kflavor_files(tempdir))
2952
2953 def test_get_dt_kflavor_files_more_specific(self):
2954 tempdir = self.useFixture(CreateTempDirFixture()).tempdir
2955 flavorx = 'flavorX'
2956 flavorxy = 'flavorXY'
2957
2958- class config(boards.BoardConfig):
2959- kernel_flavors = [flavorx, flavorxy]
2960- dtb_name = 'board_name.dtb'
2961- for f in reversed(config.kernel_flavors):
2962+ board_conf = BoardConfig()
2963+ board_conf.kernel_flavors = [flavorx, flavorxy]
2964+ board_conf.dtb_name = 'board_name.dtb'
2965+ for f in reversed(board_conf.kernel_flavors):
2966 kfile = os.path.join(tempdir, 'vmlinuz-1-%s' % f)
2967 ifile = os.path.join(tempdir, 'initrd.img-1-%s' % f)
2968 dt = os.path.join(tempdir, 'dt-1-%s' % f)
2969 os.mkdir(dt)
2970- dfile = os.path.join(dt, config.dtb_name)
2971+ dfile = os.path.join(dt, board_conf.dtb_name)
2972 open(kfile, "w").close()
2973 open(ifile, "w").close()
2974 open(dfile, "w").close()
2975 self.assertEqual(
2976- (kfile, ifile, dfile), config._get_kflavor_files(tempdir))
2977+ (kfile, ifile, dfile), board_conf._get_kflavor_files(tempdir))
2978
2979 def test_get_kflavor_files_later_in_flavors(self):
2980 tempdir = self.useFixture(CreateTempDirFixture()).tempdir
2981 flavor1 = 'flavorXY'
2982 flavor2 = 'flavorAA'
2983
2984- class config(boards.BoardConfig):
2985- kernel_flavors = [flavor1, flavor2]
2986+ board_conf = BoardConfig()
2987+ board_conf.kernel_flavors = [flavor1, flavor2]
2988 kfile = os.path.join(tempdir, 'vmlinuz-1-%s' % flavor1)
2989 ifile = os.path.join(tempdir, 'initrd.img-1-%s' % flavor1)
2990 open(kfile, "w").close()
2991 open(ifile, "w").close()
2992 self.assertEqual(
2993- (kfile, ifile, None), config._get_kflavor_files(tempdir))
2994+ (kfile, ifile, None), board_conf._get_kflavor_files(tempdir))
2995
2996 def test_get_dt_kflavor_files_later_in_flavors(self):
2997 tempdir = self.useFixture(CreateTempDirFixture()).tempdir
2998 flavor1 = 'flavorXY'
2999 flavor2 = 'flavorAA'
3000
3001- class config(boards.BoardConfig):
3002- kernel_flavors = [flavor1, flavor2]
3003- dtb_name = 'board_name.dtb'
3004+ board_conf = BoardConfig()
3005+ board_conf.kernel_flavors = [flavor1, flavor2]
3006+ board_conf.dtb_name = 'board_name.dtb'
3007 kfile = os.path.join(tempdir, 'vmlinuz-1-%s' % flavor1)
3008 ifile = os.path.join(tempdir, 'initrd.img-1-%s' % flavor1)
3009 dt = os.path.join(tempdir, 'dt-1-%s' % flavor1)
3010 os.mkdir(dt)
3011- dfile = os.path.join(dt, config.dtb_name)
3012+ dfile = os.path.join(dt, board_conf.dtb_name)
3013 open(kfile, "w").close()
3014 open(ifile, "w").close()
3015 open(dfile, "w").close()
3016 self.assertEqual(
3017- (kfile, ifile, dfile), config._get_kflavor_files(tempdir))
3018+ (kfile, ifile, dfile), board_conf._get_kflavor_files(tempdir))
3019
3020 def test_get_kflavor_files_raises_when_no_match(self):
3021 tempdir = self.useFixture(CreateTempDirFixture()).tempdir
3022 flavor1 = 'flavorXY'
3023 flavor2 = 'flavorAA'
3024
3025- class config(boards.BoardConfig):
3026- kernel_flavors = [flavor1, flavor2]
3027- self.assertRaises(ValueError, config._get_kflavor_files, tempdir)
3028+ board_conf = BoardConfig()
3029+ board_conf.kernel_flavors = [flavor1, flavor2]
3030+ self.assertRaises(ValueError, board_conf._get_kflavor_files, tempdir)
3031
3032 def test_get_file_matching_no_files_found(self):
3033 self.assertEqual(
3034@@ -2647,8 +2565,6 @@
3035 # Stub time.sleep() as create_partitions() use that.
3036 self.orig_sleep = time.sleep
3037 time.sleep = lambda s: None
3038- boards = linaro_image_tools.media_create.boards
3039- boards.BoardConfig.hwpack_format = '1.0'
3040
3041 def tearDown(self):
3042 super(TestCreatePartitions, self).tearDown()
3043@@ -2659,7 +2575,9 @@
3044 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
3045 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
3046
3047- create_partitions(boards.Mx5Config, self.media, HEADS, SECTORS, '')
3048+ board_conf = boards.Mx5Config()
3049+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
3050+ create_partitions(board_conf, self.media, HEADS, SECTORS, '')
3051
3052 self.assertEqual(
3053 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
3054@@ -2680,8 +2598,9 @@
3055 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
3056 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
3057
3058- create_partitions(
3059- board_configs['smdkv310'], self.media, HEADS, SECTORS, '')
3060+ board_conf = get_board_config('smdkv310')
3061+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
3062+ create_partitions(board_conf, self.media, HEADS, SECTORS, '')
3063
3064 self.assertEqual(
3065 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
3066@@ -2701,8 +2620,9 @@
3067 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
3068 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
3069
3070- create_partitions(
3071- board_configs['origen'], self.media, HEADS, SECTORS, '')
3072+ board_conf = get_board_config('origen')
3073+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
3074+ create_partitions(board_conf, self.media, HEADS, SECTORS, '')
3075
3076 self.assertEqual(
3077 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
3078@@ -2722,8 +2642,10 @@
3079 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
3080 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
3081
3082+ board_conf = get_board_config('origen_quad')
3083+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
3084 create_partitions(
3085- board_configs['origen_quad'], self.media, HEADS, SECTORS, '')
3086+ board_conf, self.media, HEADS, SECTORS, '')
3087
3088 self.assertEqual(
3089 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
3090@@ -2743,8 +2665,10 @@
3091 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
3092 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
3093
3094+ board_conf = get_board_config('arndale')
3095+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
3096 create_partitions(
3097- board_configs['arndale'], self.media, HEADS, SECTORS, '')
3098+ board_conf, self.media, HEADS, SECTORS, '')
3099
3100 self.assertEqual(
3101 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
3102@@ -2763,8 +2687,9 @@
3103 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
3104 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
3105
3106- create_partitions(
3107- board_configs['beagle'], self.media, HEADS, SECTORS, '')
3108+ board_conf = get_board_config('beagle')
3109+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
3110+ create_partitions(board_conf, self.media, HEADS, SECTORS, '')
3111
3112 self.assertEqual(
3113 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
3114@@ -2782,8 +2707,9 @@
3115 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
3116
3117 tmpfile = self.createTempFileAsFixture()
3118- create_partitions(
3119- board_configs['beagle'], Media(tmpfile), HEADS, SECTORS, '')
3120+ board_conf = get_board_config('beagle')
3121+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
3122+ create_partitions(board_conf, Media(tmpfile), HEADS, SECTORS, '')
3123
3124 # Unlike the test for partitioning of a regular block device, in this
3125 # case parted was not called as there's no existing partition table
3126@@ -3017,7 +2943,7 @@
3127 self.assertEqual(
3128 ("%s%d" % (tmpfile, 1), "%s%d" % (tmpfile, 2)),
3129 get_boot_and_root_partitions_for_media(
3130- media, board_configs['beagle']))
3131+ media, get_board_config('beagle')))
3132
3133 def test_get_boot_and_root_partitions_for_media_mx5(self):
3134 self.useFixture(MockSomethingFixture(
3135@@ -3028,7 +2954,7 @@
3136 media.is_block_device = True
3137 self.assertEqual(
3138 ("%s%d" % (tmpfile, 2), "%s%d" % (tmpfile, 3)),
3139- get_boot_and_root_partitions_for_media(media, boards.Mx5Config))
3140+ get_boot_and_root_partitions_for_media(media, boards.Mx5Config()))
3141
3142 def _create_qemu_img_with_partitions(self, sfdisk_commands, tempfile_size):
3143 tmpfile = self.createTempFileAsFixture()
3144@@ -3142,8 +3068,12 @@
3145 self.useFixture(MockSomethingFixture(
3146 partitions, 'get_boot_and_root_loopback_devices',
3147 lambda image: ('/dev/loop99', '/dev/loop98')))
3148+
3149+ board_conf = get_board_config('beagle')
3150+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
3151+
3152 bootfs_dev, rootfs_dev = setup_partitions(
3153- board_configs['beagle'], Media(tmpfile), '2G', 'boot',
3154+ board_conf, Media(tmpfile), '2G', 'boot',
3155 'root', 'ext3', True, True, True)
3156 self.assertEqual(
3157 # This is the call that would create a 2 GiB image file.
3158@@ -3173,8 +3103,12 @@
3159 # Pretend our tmpfile is a block device.
3160 media.is_block_device = True
3161 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
3162+
3163+ board_conf = get_board_config('beagle')
3164+ board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
3165+
3166 bootfs_dev, rootfs_dev = setup_partitions(
3167- board_configs['beagle'], media, '2G', 'boot', 'root', 'ext3',
3168+ board_conf, media, '2G', 'boot', 'root', 'ext3',
3169 True, True, True)
3170 self.assertEqual(
3171 ['%s parted -s %s mklabel msdos' % (sudo_args, tmpfile),
3172@@ -3200,7 +3134,7 @@
3173 mock_get_udisks_device_path))
3174
3175 tmpfile = self.createTempFileAsFixture()
3176- partition = board_configs['beagle'].mmc_part_offset
3177+ partition = get_board_config('beagle').mmc_part_offset
3178
3179 self.useFixture(MockSomethingFixture(
3180 glob, 'glob',
3181@@ -3243,7 +3177,7 @@
3182 mock_get_udisks_device_file))
3183
3184 tmpfile = self.createTempFileAsFixture()
3185- partition = board_configs['beagle'].mmc_part_offset
3186+ partition = get_board_config('beagle').mmc_part_offset
3187
3188 self.useFixture(MockSomethingFixture(
3189 glob, 'glob',
3190@@ -3328,14 +3262,12 @@
3191 self.saved_args = args
3192
3193 def prepare_config(self, config):
3194- class c(config):
3195- pass
3196-
3197- self.config = c
3198+ self.config = config
3199 self.config.boot_script = 'boot_script'
3200 self.config.hardwarepack_handler = \
3201 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz')
3202- self.config.hardwarepack_handler.get_format = lambda: '1.0'
3203+ self.config.hardwarepack_handler.get_format = \
3204+ lambda: HardwarepackHandler.FORMAT_1
3205 self.popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
3206 self.useFixture(MockSomethingFixture(
3207 self.config, 'make_boot_files', self.save_args))
3208@@ -3351,10 +3283,7 @@
3209 return None
3210
3211 def prepare_config_v3(self, config):
3212- class c(config):
3213- pass
3214-
3215- self.config = c
3216+ self.config = config
3217 self.config.boot_script = 'boot_script'
3218 self.config.hardwarepack_handler = \
3219 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz')
3220@@ -3378,21 +3307,21 @@
3221 'boot_device_or_file', is_live, False, [])
3222
3223 def test_populate_boot_live(self):
3224- self.prepare_config(boards.BoardConfig)
3225+ self.prepare_config(BoardConfig())
3226 self.call_populate_boot(self.config, is_live=True)
3227 self.assertEquals(
3228 self.expected_calls, self.popen_fixture.mock.commands_executed)
3229 self.assertEquals(self.expected_args_live, self.saved_args)
3230
3231 def test_populate_boot_regular(self):
3232- self.prepare_config(boards.BoardConfig)
3233+ self.prepare_config(BoardConfig())
3234 self.call_populate_boot(self.config)
3235 self.assertEquals(
3236 self.expected_calls, self.popen_fixture.mock.commands_executed)
3237 self.assertEquals(self.expected_args, self.saved_args)
3238
3239 def test_populate_boot_bootloader_flavor(self):
3240- self.prepare_config(boards.BoardConfig)
3241+ self.prepare_config(BoardConfig())
3242 self.config.bootloader_flavor = "bootloader_flavor"
3243 self.call_populate_boot(self.config)
3244 self.assertEquals(
3245@@ -3400,7 +3329,7 @@
3246 self.assertEquals(self.expected_args, self.saved_args)
3247
3248 def test_populate_boot_bootloader_file_in_boot_part(self):
3249- self.prepare_config(boards.BoardConfig)
3250+ self.prepare_config(BoardConfig())
3251 self.config.bootloader_flavor = "bootloader_flavor"
3252 self.config.bootloader_file_in_boot_part = True
3253 self.config.bootloader = "u_boot"
3254@@ -3414,7 +3343,7 @@
3255 self.assertEquals(self.expected_args, self.saved_args)
3256
3257 def test_populate_boot_bootloader_file_in_boot_part_false(self):
3258- self.prepare_config(boards.BoardConfig)
3259+ self.prepare_config(BoardConfig())
3260 self.config.bootloader_flavor = "bootloader_flavor"
3261 self.config.bootloader_file_in_boot_part = False
3262 self.call_populate_boot(self.config)
3263@@ -3424,7 +3353,7 @@
3264 self.assertEquals(self.expected_args, self.saved_args)
3265
3266 def test_populate_bootloader_copy_files(self):
3267- self.prepare_config_v3(boards.BoardConfig)
3268+ self.prepare_config_v3(BoardConfig())
3269 self.config.bootloader_flavor = "bootloader_flavor"
3270 # Test that copy_files works per spec (puts stuff in boot partition)
3271 # even if bootloader not in_boot_part.
3272@@ -3444,7 +3373,7 @@
3273 self.assertEquals(self.expected_args, self.saved_args)
3274
3275 def test_populate_bootloader_copy_files_bootloader_set(self):
3276- self.prepare_config_v3(boards.BoardConfig)
3277+ self.prepare_config_v3(BoardConfig())
3278 self.config.bootloader_flavor = "bootloader_flavor"
3279 # Test that copy_files works per spec (puts stuff in boot partition)
3280 # even if bootloader not in_boot_part.
3281@@ -3465,7 +3394,7 @@
3282 self.assertEquals(self.expected_args, self.saved_args)
3283
3284 def test_populate_boot_no_bootloader_flavor(self):
3285- self.prepare_config(boards.BoardConfig)
3286+ self.prepare_config(BoardConfig())
3287 self.config.bootloader_file_in_boot_part = True
3288 self.assertRaises(
3289 AssertionError, self.call_populate_boot, self.config)
3290@@ -3612,10 +3541,7 @@
3291 os.makedirs(os.path.join(tempdir, 'etc', 'network'))
3292 if_path = os.path.join(tempdir, 'etc', 'network', 'interfaces')
3293
3294- class board_config(boards.BoardConfig):
3295- pass
3296-
3297- update_network_interfaces(tempdir, board_config)
3298+ update_network_interfaces(tempdir, BoardConfig())
3299 self.assertFalse(os.path.exists(if_path))
3300
3301 def test_update_interfaces_creates_entry(self):
3302@@ -3626,12 +3552,12 @@
3303 os.makedirs(os.path.join(tempdir, 'etc', 'network'))
3304 if_path = os.path.join(tempdir, 'etc', 'network', 'interfaces')
3305
3306- class board_config(boards.BoardConfig):
3307- wired_interfaces = ['eth0']
3308+ board_conf = BoardConfig()
3309+ board_conf.wired_interfaces = ['eth0']
3310
3311 expected = 'auto eth0\n' \
3312 'iface eth0 inet dhcp\n'
3313- update_network_interfaces(tempdir, board_config)
3314+ update_network_interfaces(tempdir, board_conf)
3315 self.assertEqual(expected, open(if_path).read())
3316
3317 def test_update_interfaces_creates_entries(self):
3318@@ -3642,14 +3568,14 @@
3319 os.makedirs(os.path.join(tempdir, 'etc', 'network'))
3320 if_path = os.path.join(tempdir, 'etc', 'network', 'interfaces')
3321
3322- class board_config(boards.BoardConfig):
3323- wired_interfaces = ['eth0', 'eth1']
3324- wireless_interfaces = ['wlan0']
3325+ board_conf = BoardConfig()
3326+ board_conf.wired_interfaces = ['eth0', 'eth1']
3327+ board_conf.wireless_interfaces = ['wlan0']
3328
3329 expected = 'auto %(if)s\n' \
3330 'iface %(if)s inet dhcp\n'
3331
3332- update_network_interfaces(tempdir, board_config)
3333+ update_network_interfaces(tempdir, board_conf)
3334 self.assertIn(expected % {'if': 'eth1'}, open(if_path).read())
3335 self.assertIn(expected % {'if': 'eth0'}, open(if_path).read())
3336 self.assertIn(expected % {'if': 'wlan0'}, open(if_path).read())
3337@@ -3664,13 +3590,13 @@
3338 with open(if_path, 'w') as interfaces:
3339 interfaces.write('Original contents of file.\n')
3340
3341- class board_config(boards.BoardConfig):
3342- wired_interfaces = ['eth0']
3343+ board_conf = BoardConfig()
3344+ board_conf.wired_interfaces = ['eth0']
3345
3346 expected = 'Original contents of file.\n' \
3347 'auto eth0\n' \
3348 'iface eth0 inet dhcp\n'
3349- update_network_interfaces(tempdir, board_config)
3350+ update_network_interfaces(tempdir, board_conf)
3351 self.assertEqual(expected, open(if_path).read())
3352
3353 def test_write_data_to_protected_file(self):
3354
3355=== modified file 'linaro_image_tools/tests/__init__.py'
3356--- linaro_image_tools/tests/__init__.py 2012-06-07 13:22:47 +0000
3357+++ linaro_image_tools/tests/__init__.py 2013-01-03 13:57:23 +0000
3358@@ -1,3 +1,20 @@
3359+# Copyright (C) 2010, 2011, 2012 Linaro
3360+#
3361+# This file is part of Linaro Image Tools.
3362+#
3363+# Linaro Image Tools is free software: you can redistribute it and/or modify
3364+# it under the terms of the GNU General Public License as published by
3365+# the Free Software Foundation, either version 3 of the License, or
3366+# (at your option) any later version.
3367+#
3368+# Linaro Image Tools is distributed in the hope that it will be useful,
3369+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3370+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3371+# GNU General Public License for more details.
3372+#
3373+# You should have received a copy of the GNU General Public License
3374+# along with this program. If not, see <http://www.gnu.org/licenses/>.
3375+
3376 import os
3377 import unittest
3378

Subscribers

People subscribed via source and target branches