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
=== modified file 'linaro-media-create'
--- linaro-media-create 2013-01-03 13:57:23 +0000
+++ linaro-media-create 2013-01-03 13:57:23 +0000
@@ -133,7 +133,6 @@
133133
134 board_config = get_board_config(args.dev)134 board_config = get_board_config(args.dev)
135 board_config.set_metadata(args.hwpacks, args.bootloader, args.dev)135 board_config.set_metadata(args.hwpacks, args.bootloader, args.dev)
136 board_config.board(args.dev)
137 board_config.add_boot_args(args.extra_boot_args)136 board_config.add_boot_args(args.extra_boot_args)
138 board_config.add_boot_args_from_file(args.extra_boot_args_file)137 board_config.add_boot_args_from_file(args.extra_boot_args_file)
139138
@@ -152,9 +151,6 @@
152 logger.error("Do not use --no-boot or --no-part in conjunction with "151 logger.error("Do not use --no-boot or --no-part in conjunction with "
153 "--image_file.")152 "--image_file.")
154 sys.exit(1)153 sys.exit(1)
155 else:
156 # All good, move on.
157 pass
158154
159 # If --help was specified this won't execute.155 # If --help was specified this won't execute.
160 # Create temp dir and initialize rest of path vars.156 # Create temp dir and initialize rest of path vars.
161157
=== modified file 'linaro_image_tools/hwpack/config.py'
--- linaro_image_tools/hwpack/config.py 2012-12-07 08:47:58 +0000
+++ linaro_image_tools/hwpack/config.py 2013-01-03 13:57:23 +0000
@@ -296,7 +296,7 @@
296 self._validate_mmc_id()296 self._validate_mmc_id()
297 self._validate_extra_boot_options()297 self._validate_extra_boot_options()
298 self._validate_boot_script()298 self._validate_boot_script()
299 self._validate_extra_serial_opts()299 self._validate_extra_serial_options()
300 self._validate_snowball_startup_files_config()300 self._validate_snowball_startup_files_config()
301 self._validate_samsung_bl1_start()301 self._validate_samsung_bl1_start()
302 self._validate_samsung_bl1_len()302 self._validate_samsung_bl1_len()
@@ -620,7 +620,7 @@
620 join_list_with=" ")620 join_list_with=" ")
621621
622 @property622 @property
623 def extra_serial_opts(self):623 def extra_serial_options(self):
624 """Extra serial options.624 """Extra serial options.
625625
626 A str.626 A str.
@@ -1021,7 +1021,7 @@
1021 # Optional and tricky to determine a valid pattern.1021 # Optional and tricky to determine a valid pattern.
1022 pass1022 pass
10231023
1024 def _validate_extra_serial_opts(self):1024 def _validate_extra_serial_options(self):
1025 # Optional and tricky to determine a valid pattern.1025 # Optional and tricky to determine a valid pattern.
1026 pass1026 pass
10271027
10281028
=== modified file 'linaro_image_tools/hwpack/hardwarepack.py'
--- linaro_image_tools/hwpack/hardwarepack.py 2012-12-07 08:47:58 +0000
+++ linaro_image_tools/hwpack/hardwarepack.py 2013-01-03 13:57:23 +0000
@@ -128,7 +128,7 @@
128 env_dd=None, boot_script=None,128 env_dd=None, boot_script=None,
129 bootloader_file_in_boot_part=None,129 bootloader_file_in_boot_part=None,
130 uboot_dd=None, spl_in_boot_part=None, spl_dd=None,130 uboot_dd=None, spl_in_boot_part=None, spl_dd=None,
131 extra_serial_opts=None, loader_start=None,131 extra_serial_options=None, loader_start=None,
132 snowball_startup_files_config=None,132 snowball_startup_files_config=None,
133 samsung_bl1_start=None, samsung_bl1_len=None,133 samsung_bl1_start=None, samsung_bl1_len=None,
134 samsung_env_start=None, samsung_env_len=None,134 samsung_env_start=None, samsung_env_len=None,
@@ -162,7 +162,7 @@
162 self.spl_in_boot_part = spl_in_boot_part162 self.spl_in_boot_part = spl_in_boot_part
163 self.spl_dd = spl_dd163 self.spl_dd = spl_dd
164 self.env_dd = env_dd164 self.env_dd = env_dd
165 self.extra_serial_opts = extra_serial_opts165 self.extra_serial_options = extra_serial_options
166 self.snowball_startup_files_config = snowball_startup_files_config166 self.snowball_startup_files_config = snowball_startup_files_config
167 self.samsung_bl1_start = samsung_bl1_start167 self.samsung_bl1_start = samsung_bl1_start
168 self.samsung_bl1_len = samsung_bl1_len168 self.samsung_bl1_len = samsung_bl1_len
@@ -216,7 +216,7 @@
216 dtb_file=config.dtb_file,216 dtb_file=config.dtb_file,
217 env_dd=config.env_dd,217 env_dd=config.env_dd,
218 extra_boot_options=config.extra_boot_options,218 extra_boot_options=config.extra_boot_options,
219 extra_serial_opts=config.extra_serial_opts,219 extra_serial_options=config.extra_serial_options,
220 initrd_addr=config.initrd_addr,220 initrd_addr=config.initrd_addr,
221 initrd=config.initrd,221 initrd=config.initrd,
222 kernel_addr=config.kernel_addr,222 kernel_addr=config.kernel_addr,
@@ -320,12 +320,12 @@
320 metadata += dump({DTB_FILES_FIELD: self.dtb_files})320 metadata += dump({DTB_FILES_FIELD: self.dtb_files})
321 if self.boot_script is not None:321 if self.boot_script is not None:
322 metadata += dump({BOOT_SCRIPT_FIELD: self.boot_script})322 metadata += dump({BOOT_SCRIPT_FIELD: self.boot_script})
323 if self.extra_serial_opts is not None:323 if self.extra_serial_options is not None:
324 # XXX Check why and where once we get a list once a string.324 # XXX Check why and where once we get a list once a string.
325 if isinstance(self.extra_serial_opts, list):325 if isinstance(self.extra_serial_options, list):
326 extra_serial_options = " ".join(self.extra_serial_opts)326 extra_serial_options = " ".join(self.extra_serial_options)
327 else:327 else:
328 extra_serial_options = self.extra_serial_opts328 extra_serial_options = self.extra_serial_options
329 metadata += dump({329 metadata += dump({
330 EXTRA_SERIAL_OPTIONS_FIELD:330 EXTRA_SERIAL_OPTIONS_FIELD:
331 extra_serial_options})331 extra_serial_options})
@@ -417,8 +417,8 @@
417 metadata += "SPL_DD=%s\n" % self.spl_dd417 metadata += "SPL_DD=%s\n" % self.spl_dd
418 if self.env_dd is not None:418 if self.env_dd is not None:
419 metadata += "ENV_DD=%s\n" % self.env_dd419 metadata += "ENV_DD=%s\n" % self.env_dd
420 if self.extra_serial_opts is not None:420 if self.extra_serial_options is not None:
421 metadata += "EXTRA_SERIAL_OPTIONS=%s\n" % self.extra_serial_opts421 metadata += "EXTRA_SERIAL_OPTIONS=%s\n" % self.extra_serial_options
422 if self.snowball_startup_files_config is not None:422 if self.snowball_startup_files_config is not None:
423 metadata += "SNOWBALL_STARTUP_FILES_CONFIG=%s\n" % (423 metadata += "SNOWBALL_STARTUP_FILES_CONFIG=%s\n" % (
424 self.snowball_startup_files_config)424 self.snowball_startup_files_config)
425425
=== modified file 'linaro_image_tools/hwpack/tests/__init__.py'
--- linaro_image_tools/hwpack/tests/__init__.py 2012-07-25 09:00:58 +0000
+++ linaro_image_tools/hwpack/tests/__init__.py 2013-01-03 13:57:23 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2010, 2011 Linaro1# Copyright (C) 2010, 2011, 2012 Linaro
2#2#
3# Author: James Westby <james.westby@linaro.org>3# Author: James Westby <james.westby@linaro.org>
4#4#
55
=== modified file 'linaro_image_tools/hwpack/tests/test_config.py'
--- linaro_image_tools/hwpack/tests/test_config.py 2012-08-28 17:34:16 +0000
+++ linaro_image_tools/hwpack/tests/test_config.py 2013-01-03 13:57:23 +0000
@@ -503,11 +503,11 @@
503 "omapfb.vram=0:24M mem=456M@0x80000000 mem=512M@0xA0000000",503 "omapfb.vram=0:24M mem=456M@0x80000000 mem=512M@0xA0000000",
504 config.extra_boot_options)504 config.extra_boot_options)
505505
506 def test_extra_serial_opts(self):506 def test_extra_serial_options(self):
507 config = self.get_config(self.valid_complete_v2 + self.valid_end)507 config = self.get_config(self.valid_complete_v2 + self.valid_end)
508 config.validate()508 config.validate()
509 self.assertEqual("console=tty0 console=ttyO2,115200n8",509 self.assertEqual("console=tty0 console=ttyO2,115200n8",
510 config.extra_serial_opts)510 config.extra_serial_options)
511511
512 def test_boot_script(self):512 def test_boot_script(self):
513 config = self.get_config(self.valid_complete_v2 + self.valid_end)513 config = self.get_config(self.valid_complete_v2 + self.valid_end)
514514
=== modified file 'linaro_image_tools/hwpack/tests/test_config_v3.py'
--- linaro_image_tools/hwpack/tests/test_config_v3.py 2012-12-27 10:29:42 +0000
+++ linaro_image_tools/hwpack/tests/test_config_v3.py 2013-01-03 13:57:23 +0000
@@ -518,11 +518,11 @@
518 "omapfb.vram=0:24M mem=456M@0x80000000 mem=512M@0xA0000000",518 "omapfb.vram=0:24M mem=456M@0x80000000 mem=512M@0xA0000000",
519 config.extra_boot_options)519 config.extra_boot_options)
520520
521 def test_extra_serial_opts(self):521 def test_extra_serial_options(self):
522 config = self.get_config(self.valid_complete_v3 + self.valid_end)522 config = self.get_config(self.valid_complete_v3 + self.valid_end)
523 config.validate()523 config.validate()
524 self.assertEqual('console=tty0 console=ttyO2,115200n8',524 self.assertEqual('console=tty0 console=ttyO2,115200n8',
525 config.extra_serial_opts)525 config.extra_serial_options)
526526
527 def test_boot_script(self):527 def test_boot_script(self):
528 config = self.get_config(self.valid_complete_v3 + self.valid_end)528 config = self.get_config(self.valid_complete_v3 + self.valid_end)
529529
=== modified file 'linaro_image_tools/hwpack/tests/test_hardwarepack.py'
--- linaro_image_tools/hwpack/tests/test_hardwarepack.py 2012-07-23 14:44:37 +0000
+++ linaro_image_tools/hwpack/tests/test_hardwarepack.py 2013-01-03 13:57:23 +0000
@@ -257,7 +257,7 @@
257 metadata = Metadata("ahwpack", "4", "armel",257 metadata = Metadata("ahwpack", "4", "armel",
258 format=HardwarePackFormatV2())258 format=HardwarePackFormatV2())
259 metadata.add_v2_config(259 metadata.add_v2_config(
260 extra_serial_opts='console=tty0 console=ttyO2,115200n8')260 extra_serial_options='console=tty0 console=ttyO2,115200n8')
261 expected_out = ("NAME=ahwpack\nVERSION=4\n"261 expected_out = ("NAME=ahwpack\nVERSION=4\n"
262 "ARCHITECTURE=armel\nEXTRA_SERIAL_OPTIONS="262 "ARCHITECTURE=armel\nEXTRA_SERIAL_OPTIONS="
263 "console=tty0 console=ttyO2,115200n8\n")263 "console=tty0 console=ttyO2,115200n8\n")
@@ -335,7 +335,7 @@
335 format=HardwarePackFormatV3())335 format=HardwarePackFormatV3())
336 options = ['option1', 'option2,option3']336 options = ['option1', 'option2,option3']
337 # Need to call also this one!337 # Need to call also this one!
338 metadata.add_v2_config(extra_serial_opts=options)338 metadata.add_v2_config(extra_serial_options=options)
339 metadata.add_v3_config(bootloaders=None)339 metadata.add_v3_config(bootloaders=None)
340 expected_out = ("format: '3.0'\nname: ahwpack\nversion: '4'\n"340 expected_out = ("format: '3.0'\nname: ahwpack\nversion: '4'\n"
341 "architecture: armel\nextra_serial_options: option1 "341 "architecture: armel\nextra_serial_options: option1 "
342342
=== modified file 'linaro_image_tools/media_create/android_boards.py'
--- linaro_image_tools/media_create/android_boards.py 2013-01-03 13:57:23 +0000
+++ linaro_image_tools/media_create/android_boards.py 2013-01-03 13:57:23 +0000
@@ -32,6 +32,7 @@
32import logging32import logging
3333
34from linaro_image_tools import cmd_runner34from linaro_image_tools import cmd_runner
35from linaro_image_tools.hwpack.hwpack_fields import FORMAT_FIELD
35from linaro_image_tools.media_create.partitions import SECTOR_SIZE36from linaro_image_tools.media_create.partitions import SECTOR_SIZE
36from linaro_image_tools.media_create.boards import (37from linaro_image_tools.media_create.boards import (
37 BeagleConfig,38 BeagleConfig,
@@ -68,7 +69,7 @@
68 def __init__(self):69 def __init__(self):
69 super(AndroidBoardConfig, self).__init__()70 super(AndroidBoardConfig, self).__init__()
70 self.dtb_name = None71 self.dtb_name = None
71 self._extra_serial_opts = []72 self._extra_serial_options = []
72 self._android_specific_args = []73 self._android_specific_args = []
73 self._extra_boot_args_options = []74 self._extra_boot_args_options = []
74 self._live_serial_options = []75 self._live_serial_options = []
@@ -97,17 +98,17 @@
97 extra_boot_args_options = property(_get_extra_boot_args_options,98 extra_boot_args_options = property(_get_extra_boot_args_options,
98 _set_extra_boot_args_options)99 _set_extra_boot_args_options)
99100
100 def _get_extra_serial_opts(self):101 def _get_extra_serial_options(self):
101 extra_serial = self._extra_serial_opts102 extra_serial = self._extra_serial_options
102 if isinstance(extra_serial, list):103 if isinstance(extra_serial, list):
103 extra_serial = ' '.join(self._extra_serial_opts)104 extra_serial = ' '.join(self._extra_serial_options)
104 return extra_serial105 return extra_serial
105106
106 def _set_extra_serial_opts(self, value):107 def _set_extra_serial_options(self, value):
107 self._extra_serial_opts = value108 self._extra_serial_options = value
108109
109 extra_serial_opts = property(_get_extra_serial_opts,110 extra_serial_options = property(_get_extra_serial_options,
110 _set_extra_serial_opts)111 _set_extra_serial_options)
111112
112 def _get_live_serial_options(self):113 def _get_live_serial_options(self):
113 serial_options = self._live_serial_options114 serial_options = self._live_serial_options
@@ -132,13 +133,18 @@
132 :return The configuration read from the file as a dictionary.133 :return The configuration read from the file as a dictionary.
133 """134 """
134 try:135 try:
135 config = yaml.safe_load(hwpack)136 with open(hwpack, 'r') as hw:
137 config = yaml.safe_load(hw)
136 self._set_attributes(config)138 self._set_attributes(config)
137 return config139 return config
138 except yaml.YAMLError, ex:140 except yaml.YAMLError, ex:
139 logger.debug("Error loading YAML file %s" % hwpack, ex)141 logger.debug("Error loading YAML file %s" % hwpack, ex)
140 raise BoardConfigException("Error reading Android hwpack %s"142 raise BoardConfigException("Error reading Android hwpack %s"
141 % hwpack)143 % hwpack)
144 except IOError, ex:
145 logger.debug("Error reading hwpack file %s" % hwpack, ex)
146 raise BoardConfigException("Android hwpack %s could not be found"
147 % hwpack)
142148
143 def _set_attributes(self, config):149 def _set_attributes(self, config):
144 """Initialize the class attributes with the values read from the150 """Initialize the class attributes with the values read from the
@@ -147,7 +153,9 @@
147 :param config: The config read from the Android hwpack.153 :param config: The config read from the Android hwpack.
148 """154 """
149 for name, value in config.iteritems():155 for name, value in config.iteritems():
150 if hasattr(self, name):156 if name == FORMAT_FIELD:
157 setattr(self, 'hwpack_format', value)
158 elif hasattr(self, name):
151 setattr(self, name, value)159 setattr(self, name, value)
152 else:160 else:
153 logger.warning("Attribute '%s' does not belong to this "161 logger.warning("Attribute '%s' does not belong to this "
@@ -162,7 +170,7 @@
162 if self.extra_boot_args_options:170 if self.extra_boot_args_options:
163 boot_args_options += ' %s' % self.extra_boot_args_options171 boot_args_options += ' %s' % self.extra_boot_args_options
164 boot_args_options += ' %s' % self.android_specific_args172 boot_args_options += ' %s' % self.android_specific_args
165 serial_opts = self.extra_serial_opts173 serial_opts = self.extra_serial_options
166 for console in consoles:174 for console in consoles:
167 serial_opts += ' console=%s' % console175 serial_opts += ' console=%s' % console
168176
@@ -281,7 +289,7 @@
281 def __init__(self):289 def __init__(self):
282 super(AndroidBeagleConfig, self).__init__()290 super(AndroidBeagleConfig, self).__init__()
283 self._android_specific_args = 'init=/init androidboot.console=ttyO2'291 self._android_specific_args = 'init=/init androidboot.console=ttyO2'
284 self._extra_serial_opts = 'console=tty0 console=ttyO2,115200n8'292 self._extra_serial_options = 'console=tty0 console=ttyO2,115200n8'
285293
286294
287class AndroidPandaConfig(AndroidBoardConfig, PandaConfig):295class AndroidPandaConfig(AndroidBoardConfig, PandaConfig):
@@ -289,7 +297,7 @@
289 def __init__(self):297 def __init__(self):
290 super(AndroidPandaConfig, self).__init__()298 super(AndroidPandaConfig, self).__init__()
291 self.dtb_name = 'board.dtb'299 self.dtb_name = 'board.dtb'
292 self._extra_serial_opts = 'console=ttyO2,115200n8'300 self._extra_serial_options = 'console=ttyO2,115200n8'
293 self._extra_boot_args_options = (301 self._extra_boot_args_options = (
294 'earlyprintk fixrtc nocompcache vram=48M '302 'earlyprintk fixrtc nocompcache vram=48M '
295 'omapfb.vram=0:24M,1:24M mem=456M@0x80000000 mem=512M@0xA0000000')303 'omapfb.vram=0:24M,1:24M mem=456M@0x80000000 mem=512M@0xA0000000')
@@ -307,7 +315,7 @@
307 self._extra_boot_args_options = (315 self._extra_boot_args_options = (
308 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '316 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
309 'mem=22M@360M mem_issw=1M@383M mem=640M@384M vmalloc=500M')317 'mem=22M@360M mem_issw=1M@383M mem=640M@384M vmalloc=500M')
310 self._extra_serial_opts = 'console=ttyAMA2,115200n8'318 self._extra_serial_options = 'console=ttyAMA2,115200n8'
311 self.boot_script = 'boot.scr'319 self.boot_script = 'boot.scr'
312 self.fdt_high = '0x05000000'320 self.fdt_high = '0x05000000'
313 self.initrd_addr = '0x05000000'321 self.initrd_addr = '0x05000000'
@@ -323,7 +331,7 @@
323 self._extra_boot_args_options = (331 self._extra_boot_args_options = (
324 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '332 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
325 'mem=22M@360M mem_issw=1M@383M mem=640M@384M vmalloc=500M')333 'mem=22M@360M mem_issw=1M@383M mem=640M@384M vmalloc=500M')
326 self._extra_serial_opts = 'console=ttyAMA2,115200n8'334 self._extra_serial_options = 'console=ttyAMA2,115200n8'
327 self._android_specific_args = 'init=/init androidboot.console=ttyAMA2'335 self._android_specific_args = 'init=/init androidboot.console=ttyAMA2'
328 self.boot_script = 'boot.scr'336 self.boot_script = 'boot.scr'
329 self.fdt_high = '0x05000000'337 self.fdt_high = '0x05000000'
@@ -379,11 +387,11 @@
379 super(AndroidMx53LoCoConfig, self).__init__()387 super(AndroidMx53LoCoConfig, self).__init__()
380 self._extra_boot_args_options = (388 self._extra_boot_args_options = (
381 'earlyprintk rootdelay=1 fixrtc nocompcache di1_primary tve')389 'earlyprintk rootdelay=1 fixrtc nocompcache di1_primary tve')
382 self._extra_serial_opts = 'console=%s,115200n8'390 self._extra_serial_options = 'console=%s,115200n8'
383 self._android_specific_args = 'init=/init androidboot.console=%s'391 self._android_specific_args = 'init=/init androidboot.console=%s'
384392
385 def _get_extra_serial_opts(self):393 def _get_extra_serial_options(self):
386 serial_opts = self._extra_serial_opts394 serial_opts = self._extra_serial_options
387 if serial_opts:395 if serial_opts:
388 if isinstance(serial_opts, list):396 if isinstance(serial_opts, list):
389 serial_opts = ' '.join(serial_opts)397 serial_opts = ' '.join(serial_opts)
@@ -391,11 +399,11 @@
391 serial_opts = serial_opts % self.serial_tty399 serial_opts = serial_opts % self.serial_tty
392 return serial_opts400 return serial_opts
393401
394 def _set_extra_serial_opts(self, value):402 def _set_extra_serial_options(self, value):
395 self._extra_serial_opts = value403 self._extra_serial_options = value
396404
397 extra_serial_opts = property(_get_extra_serial_opts,405 extra_serial_options = property(_get_extra_serial_options,
398 _set_extra_serial_opts)406 _set_extra_serial_options)
399407
400 def _get_android_specific_args(self):408 def _get_android_specific_args(self):
401 android_args = self._android_specific_args409 android_args = self._android_specific_args
@@ -461,7 +469,7 @@
461 """Placeholder class for SMDKV310 configuration inheritance."""469 """Placeholder class for SMDKV310 configuration inheritance."""
462 def __init__(self):470 def __init__(self):
463 super(AndroidSMDKV310Config, self).__init__()471 super(AndroidSMDKV310Config, self).__init__()
464 self._extra_serial_opts = 'console=tty0 console=ttySAC1,115200n8'472 self._extra_serial_options = 'console=tty0 console=ttySAC1,115200n8'
465 self._android_specific_args = 'init=/init androidboot.console=ttySAC1'473 self._android_specific_args = 'init=/init androidboot.console=ttySAC1'
466474
467475
@@ -469,14 +477,14 @@
469 """Placeholder class for Origen configuration inheritance."""477 """Placeholder class for Origen configuration inheritance."""
470 def __init__(self):478 def __init__(self):
471 super(AndroidOrigenConfig, self).__init__()479 super(AndroidOrigenConfig, self).__init__()
472 self._extra_serial_opts = 'console=tty0 console=ttySAC2,115200n8'480 self._extra_serial_options = 'console=tty0 console=ttySAC2,115200n8'
473 self._android_specific_args = 'init=/init androidboot.console=ttySAC2'481 self._android_specific_args = 'init=/init androidboot.console=ttySAC2'
474482
475483
476class AndroidOrigenQuadConfig(AndroidSamsungConfig, OrigenQuadConfig):484class AndroidOrigenQuadConfig(AndroidSamsungConfig, OrigenQuadConfig):
477 def __init__(self):485 def __init__(self):
478 super(AndroidOrigenQuadConfig, self).__init__()486 super(AndroidOrigenQuadConfig, self).__init__()
479 self._extra_serial_opts = 'console=tty0 console=ttySAC2,115200n8'487 self._extra_serial_options = 'console=tty0 console=ttySAC2,115200n8'
480 self._android_specific_args = 'init=/init androidboot.console=ttySAC2'488 self._android_specific_args = 'init=/init androidboot.console=ttySAC2'
481489
482490
@@ -484,7 +492,7 @@
484 """Placeholder class for Vexpress configuration inheritance."""492 """Placeholder class for Vexpress configuration inheritance."""
485 def __init__(self):493 def __init__(self):
486 super(AndroidVexpressConfig, self).__init__()494 super(AndroidVexpressConfig, self).__init__()
487 self._extra_serial_opts = 'console=tty0 console=ttyAMA0,38400n8'495 self._extra_serial_options = 'console=tty0 console=ttyAMA0,38400n8'
488 self._android_specific_args = 'init=/init androidboot.console=ttyAMA0'496 self._android_specific_args = 'init=/init androidboot.console=ttyAMA0'
489497
490498
491499
=== modified file 'linaro_image_tools/media_create/boards.py'
--- linaro_image_tools/media_create/boards.py 2013-01-03 13:57:23 +0000
+++ linaro_image_tools/media_create/boards.py 2013-01-03 13:57:23 +0000
@@ -69,7 +69,7 @@
69 SAMSUNG_BL2_LEN_FIELD,69 SAMSUNG_BL2_LEN_FIELD,
70 SAMSUNG_BL2_START_FIELD,70 SAMSUNG_BL2_START_FIELD,
71 SAMSUNG_ENV_LEN_FIELD,71 SAMSUNG_ENV_LEN_FIELD,
72 SAMSUNG_ENV_START_FILED,72 SAMSUNG_ENV_START_FIELD,
73 SERIAL_TTY_FIELD,73 SERIAL_TTY_FIELD,
74 SNOWBALL_STARTUP_FILES_CONFIG_FIELD,74 SNOWBALL_STARTUP_FILES_CONFIG_FIELD,
75 SPL_DD_FIELD,75 SPL_DD_FIELD,
@@ -150,7 +150,7 @@
150 # leading underscore. It is done in this way since sublcasses use150 # leading underscore. It is done in this way since sublcasses use
151 # placeholders in the string for dinamically change values. But this151 # placeholders in the string for dinamically change values. But this
152 # is done only for hwpack v1.152 # is done only for hwpack v1.
153 self._extra_serial_opts = ''153 self._extra_serial_options = ''
154 self._live_serial_opts = ''154 self._live_serial_opts = ''
155 self.board = None155 self.board = None
156 self.boot_script = None156 self.boot_script = None
@@ -198,7 +198,7 @@
198 #198 #
199 # samsung_bl1_{start,len}: Offset and maximum size for BL1199 # samsung_bl1_{start,len}: Offset and maximum size for BL1
200 # samsung_bl2_{start,len}: Offset and maximum size for BL2200 # samsung_bl2_{start,len}: Offset and maximum size for BL2
201 # samsung_env_{start,len}: Offset and maximum size for Environment settings201 # samsung_env_{start,len}: Offset and maximum size for settings
202 #202 #
203 self.samsung_bl1_start = 1203 self.samsung_bl1_start = 1
204 self.samsung_bl1_len = 32204 self.samsung_bl1_len = 32
@@ -223,17 +223,17 @@
223 live_serial_opts = property(_get_live_serial_opts, _set_live_serial_opts)223 live_serial_opts = property(_get_live_serial_opts, _set_live_serial_opts)
224224
225 # XXX: can be removed when killing v1 hwpack.225 # XXX: can be removed when killing v1 hwpack.
226 def _get_extra_serial_opts(self):226 def _get_extra_serial_options(self):
227 return_value = self._extra_serial_opts227 return_value = self._extra_serial_options
228 if self._check_placeholder_presence(return_value, r'%s'):228 if self._check_placeholder_presence(return_value, r'%s'):
229 return_value = return_value % self.serial_tty229 return_value = return_value % self.serial_tty
230 return return_value230 return return_value
231231
232 def _set_extra_serial_opts(self, value):232 def _set_extra_serial_options(self, value):
233 self._extra_serial_opts = value233 self._extra_serial_options = value
234234
235 extra_serial_opts = property(_get_extra_serial_opts,235 extra_serial_options = property(_get_extra_serial_options,
236 _set_extra_serial_opts)236 _set_extra_serial_options)
237237
238 def get_metadata_field(self, field_name):238 def get_metadata_field(self, field_name):
239 """ Return the metadata value for field_name if it can be found.239 """ Return the metadata value for field_name if it can be found.
@@ -269,8 +269,8 @@
269 self.samsung_bl1_len = None269 self.samsung_bl1_len = None
270 self.samsung_env_len = None270 self.samsung_env_len = None
271 self.samsung_bl2_len = None271 self.samsung_bl2_len = None
272 # cls.samsung_bl2_start and cls.samsung_env_start should272 # self.samsung_bl2_start and self.samsung_env_start should
273 # be initialized to default values for backward compatibility.273 # be initialized to default value for backward compatibility.
274274
275 self.board = board275 self.board = board
276 # Set new values from metadata.276 # Set new values from metadata.
@@ -296,7 +296,7 @@
296 self.extra_boot_args_options = self.get_metadata_field(296 self.extra_boot_args_options = self.get_metadata_field(
297 EXTRA_BOOT_OPTIONS_FIELD)297 EXTRA_BOOT_OPTIONS_FIELD)
298 self.boot_script = self.get_metadata_field(BOOT_SCRIPT_FIELD)298 self.boot_script = self.get_metadata_field(BOOT_SCRIPT_FIELD)
299 self.extra_serial_opts = self.get_metadata_field(299 self.extra_serial_options = self.get_metadata_field(
300 EXTRA_SERIAL_OPTIONS_FIELD)300 EXTRA_SERIAL_OPTIONS_FIELD)
301 self.snowball_startup_files_config = self.get_metadata_field(301 self.snowball_startup_files_config = self.get_metadata_field(
302 SNOWBALL_STARTUP_FILES_CONFIG_FIELD)302 SNOWBALL_STARTUP_FILES_CONFIG_FIELD)
@@ -376,16 +376,16 @@
376 samsung_env_len = self.get_metadata_field(SAMSUNG_ENV_LEN_FIELD)376 samsung_env_len = self.get_metadata_field(SAMSUNG_ENV_LEN_FIELD)
377 if samsung_env_len:377 if samsung_env_len:
378 self.samsung_v310_env_len = int(samsung_env_len)378 self.samsung_v310_env_len = int(samsung_env_len)
379 samsung_bl2_start = \
380 self.get_metadata_field(SAMSUNG_BL2_START_FIELD)
381 if samsung_bl2_start:
382 self.samsung_bl2_start = int(samsung_bl2_start)
379 samsung_bl2_len = self.get_metadata_field(SAMSUNG_BL2_LEN_FIELD)383 samsung_bl2_len = self.get_metadata_field(SAMSUNG_BL2_LEN_FIELD)
380 if samsung_bl2_len:384 if samsung_bl2_len:
381 self.samsung_v310_bl2_len = int(samsung_bl2_len)385 self.samsung_v310_bl2_len = int(samsung_bl2_len)
382 samsung_bl2_start = self.get_metadata_field(386 samsung_env_start = \
383 SAMSUNG_BL2_START_FIELD)387 self.get_metadata_field(SAMSUNG_ENV_START_FIELD)
384 if samsung_bl2_start:388 if samsung_env_start is not None:
385 self.samsung_bl2_start = int(samsung_bl2_start)
386 samsung_env_start = self.get_metadata_field(
387 SAMSUNG_ENV_START_FILED)
388 if samsung_env_start:
389 self.samsung_env_start = int(samsung_env_start)389 self.samsung_env_start = int(samsung_env_start)
390390
391 self.bootloader_copy_files = self.hardwarepack_handler.get_field(391 self.bootloader_copy_files = self.hardwarepack_handler.get_field(
@@ -540,7 +540,7 @@
540 boot_args_options = 'rootwait ro'540 boot_args_options = 'rootwait ro'
541 if self.extra_boot_args_options:541 if self.extra_boot_args_options:
542 boot_args_options += ' %s' % self.extra_boot_args_options542 boot_args_options += ' %s' % self.extra_boot_args_options
543 serial_opts = self.extra_serial_opts543 serial_opts = self.extra_serial_options
544 for console in consoles:544 for console in consoles:
545 serial_opts += ' console=%s' % console545 serial_opts += ' console=%s' % console
546546
@@ -945,7 +945,7 @@
945 self.kernel_addr = '0x80000000'945 self.kernel_addr = '0x80000000'
946 self.load_addr = '0x80008000'946 self.load_addr = '0x80008000'
947 self._serial_tty = 'ttyO2'947 self._serial_tty = 'ttyO2'
948 self._extra_serial_opts = 'console=tty0 console=%s,115200n8'948 self._extra_serial_options = 'console=tty0 console=%s,115200n8'
949 self._live_serial_opts = 'serialtty=%s'949 self._live_serial_opts = 'serialtty=%s'
950950
951951
@@ -962,7 +962,7 @@
962 self.initrd_addr = '0x81600000'962 self.initrd_addr = '0x81600000'
963 self.kernel_addr = '0x80000000'963 self.kernel_addr = '0x80000000'
964 self.load_addr = '0x80008000'964 self.load_addr = '0x80008000'
965 self._extra_serial_opts = 'console=tty0 console=%s,115200n8'965 self._extra_serial_options = 'console=tty0 console=%s,115200n8'
966 self._serial_tty = 'ttyO2'966 self._serial_tty = 'ttyO2'
967967
968968
@@ -980,7 +980,7 @@
980 self.initrd_addr = '0x81600000'980 self.initrd_addr = '0x81600000'
981 self.kernel_addr = '0x80200000'981 self.kernel_addr = '0x80200000'
982 self.load_addr = '0x80008000'982 self.load_addr = '0x80008000'
983 self._extra_serial_opts = 'console=tty0 console=%s,115200n8'983 self._extra_serial_options = 'console=tty0 console=%s,115200n8'
984 self._live_serial_opts = 'serialtty=%s'984 self._live_serial_opts = 'serialtty=%s'
985985
986986
@@ -1019,7 +1019,7 @@
1019 self.load_addr = '0x00008000'1019 self.load_addr = '0x00008000'
1020 self.mmc_option = '1:1'1020 self.mmc_option = '1:1'
1021 self.serial_tty = 'ttyAMA2'1021 self.serial_tty = 'ttyAMA2'
1022 self._extra_serial_opts = 'console=tty0 console=%s,115200n8'1022 self._extra_serial_options = 'console=tty0 console=%s,115200n8'
1023 self._live_serial_opts = 'serialtty=%s'1023 self._live_serial_opts = 'serialtty=%s'
10241024
1025 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,1025 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
@@ -1230,7 +1230,7 @@
1230 self.mmc_option = '0:2'1230 self.mmc_option = '0:2'
1231 self.mmc_part_offset = 11231 self.mmc_part_offset = 1
1232 self.serial_tty = 'ttymxc0'1232 self.serial_tty = 'ttymxc0'
1233 self._extra_serial_opts = 'console=tty0 console=%s,115200n8'1233 self._extra_serial_options = 'console=tty0 console=%s,115200n8'
1234 self._live_serial_opts = 'serialtty=%s'1234 self._live_serial_opts = 'serialtty=%s'
12351235
1236 def get_v1_sfdisk_cmd(self, should_align_boot_part=None):1236 def get_v1_sfdisk_cmd(self, should_align_boot_part=None):
@@ -1341,7 +1341,7 @@
1341 self.kernel_flavors = ['linaro-vexpress']1341 self.kernel_flavors = ['linaro-vexpress']
1342 self.load_addr = '0x60008000'1342 self.load_addr = '0x60008000'
1343 self.serial_tty = 'ttyAMA0'1343 self.serial_tty = 'ttyAMA0'
1344 self._extra_serial_opts = 'console=tty0 console=%s,38400n8'1344 self._extra_serial_options = 'console=tty0 console=%s,38400n8'
1345 self._live_serial_opts = 'serialtty=%s'1345 self._live_serial_opts = 'serialtty=%s'
13461346
1347 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,1347 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
@@ -1390,7 +1390,7 @@
1390class SamsungConfig(BoardConfig):1390class SamsungConfig(BoardConfig):
1391 def __init__(self):1391 def __init__(self):
1392 super(SamsungConfig, self).__init__()1392 super(SamsungConfig, self).__init__()
1393 self._extra_serial_opts = None1393 self._extra_serial_options = None
13941394
1395 def get_v1_sfdisk_cmd(self, should_align_boot_part=False):1395 def get_v1_sfdisk_cmd(self, should_align_boot_part=False):
1396 # bootloaders partition needs to hold BL1, U-Boot environment, and BL21396 # bootloaders partition needs to hold BL1, U-Boot environment, and BL2
@@ -1505,7 +1505,7 @@
1505 self.mmc_option = '0:2'1505 self.mmc_option = '0:2'
1506 self.mmc_part_offset = 11506 self.mmc_part_offset = 1
1507 self.serial_tty = 'ttySAC1'1507 self.serial_tty = 'ttySAC1'
1508 self._extra_serial_opts = 'console=%s,115200n8'1508 self._extra_serial_options = 'console=%s,115200n8'
15091509
1510 def _get_boot_env(self, is_live, is_lowmem, consoles, rootfs_id,1510 def _get_boot_env(self, is_live, is_lowmem, consoles, rootfs_id,
1511 i_img_data, d_img_data):1511 i_img_data, d_img_data):
@@ -1531,7 +1531,7 @@
1531 self.mmc_option = '0:2'1531 self.mmc_option = '0:2'
1532 self.mmc_part_offset = 11532 self.mmc_part_offset = 1
1533 self.serial_tty = 'ttySAC2'1533 self.serial_tty = 'ttySAC2'
1534 self._extra_serial_opts = 'console=%s,115200n8'1534 self._extra_serial_options = 'console=%s,115200n8'
15351535
15361536
1537class OrigenQuadConfig(SamsungConfig):1537class OrigenQuadConfig(SamsungConfig):
@@ -1549,7 +1549,7 @@
1549 self.samsung_bl2_start = 491549 self.samsung_bl2_start = 49
1550 self.samsung_env_start = 10731550 self.samsung_env_start = 1073
1551 self.serial_tty = 'ttySAC2'1551 self.serial_tty = 'ttySAC2'
1552 self._extra_serial_opts = 'console=%s,115200n8'1552 self._extra_serial_options = 'console=%s,115200n8'
15531553
15541554
1555class ArndaleConfig(SamsungConfig):1555class ArndaleConfig(SamsungConfig):
@@ -1568,7 +1568,7 @@
1568 self.samsung_bl2_start = 491568 self.samsung_bl2_start = 49
1569 self.samsung_env_start = 10731569 self.samsung_env_start = 1073
1570 self.serial_tty = 'ttySAC2'1570 self.serial_tty = 'ttySAC2'
1571 self._extra_serial_opts = 'console=%s,115200n8'1571 self._extra_serial_options = 'console=%s,115200n8'
15721572
15731573
1574class I386Config(BoardConfig):1574class I386Config(BoardConfig):
@@ -1587,7 +1587,7 @@
1587 super(I386Config, self).__init__()1587 super(I386Config, self).__init__()
1588 self.kernel_flavors = ['generic', 'pae']1588 self.kernel_flavors = ['generic', 'pae']
1589 self.serial_tty = 'ttyS0'1589 self.serial_tty = 'ttyS0'
1590 self._extra_serial_opts = 'console=tty0 console=%s,115200n8'1590 self._extra_serial_options = 'console=tty0 console=%s,115200n8'
1591 self._live_serial_opts = 'serialtty=%s'1591 self._live_serial_opts = 'serialtty=%s'
15921592
1593 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,1593 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
@@ -1609,7 +1609,7 @@
16091609
1610 # generate loader config file1610 # generate loader config file
1611 loader_config = self.BOOTLOADER_CFG % (os.path.basename(k_img_data),1611 loader_config = self.BOOTLOADER_CFG % (os.path.basename(k_img_data),
1612 self.extra_serial_opts, os.path.basename(i_img_data))1612 self.extra_serial_options, os.path.basename(i_img_data))
16131613
1614 _, tmpfile = tempfile.mkstemp()1614 _, tmpfile = tempfile.mkstemp()
1615 atexit.register(os.unlink, tmpfile)1615 atexit.register(os.unlink, tmpfile)
16161616
=== modified file 'linaro_image_tools/media_create/tests/__init__.py'
--- linaro_image_tools/media_create/tests/__init__.py 2012-06-07 13:12:42 +0000
+++ linaro_image_tools/media_create/tests/__init__.py 2013-01-03 13:57:23 +0000
@@ -1,9 +1,28 @@
1# Copyright (C) 2010, 2011, 2012 Linaro
2#
3# This file is part of Linaro Image Tools.
4#
5# Linaro Image Tools is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# Linaro Image Tools is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
1import unittest18import unittest
219
320
4def test_suite():21def test_suite():
5 module_names = ['linaro_image_tools.media_create.tests.test_media_create',22 module_names = [
6 ]23 'linaro_image_tools.media_create.tests.test_media_create',
24 'linaro_image_tools.media_create.tests.test_android_boards',
25 ]
7 loader = unittest.TestLoader()26 loader = unittest.TestLoader()
8 suite = loader.loadTestsFromNames(module_names)27 suite = loader.loadTestsFromNames(module_names)
9 return suite28 return suite
1029
=== added file 'linaro_image_tools/media_create/tests/test_android_boards.py'
--- linaro_image_tools/media_create/tests/test_android_boards.py 1970-01-01 00:00:00 +0000
+++ linaro_image_tools/media_create/tests/test_android_boards.py 2013-01-03 13:57:23 +0000
@@ -0,0 +1,480 @@
1# Copyright (C) 2010, 2011 Linaro
2#
3# Author: Milo Casagrande <milo.casagrande@linaro.org>
4#
5# This file is part of Linaro Image Tools.
6#
7# Linaro Image Tools is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# Linaro Image Tools is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20from testtools import TestCase
21
22from linaro_image_tools.media_create.boards import (
23 BoardConfigException,
24 )
25
26from linaro_image_tools.media_create.android_boards import (
27 AndroidBeagleConfig,
28 get_board_config,
29 )
30
31from linaro_image_tools.testing import TestCaseWithFixtures
32from linaro_image_tools.tests.fixtures import CreateTempFileFixture
33
34
35class TestAndroidBoards(TestCase):
36 """Class to test small things in android_boards."""
37
38 def test_get_board_config(self):
39 instance = get_board_config('beagle')
40 self.assertIsInstance(instance, AndroidBeagleConfig)
41
42 def test_get_board_config_wrong(self):
43 self.assertRaises(BoardConfigException, get_board_config, 'notadevice')
44
45 def test_hwpack_not_exists(self):
46 instance = get_board_config('beagle')
47 self.assertRaises(BoardConfigException, instance.from_file, 'a_file')
48
49
50class TestAndroidBoardsHwpack(TestCaseWithFixtures):
51 """Class to test the new Android hwpack configuration file."""
52
53 # All the necessary Android hwpack fields for the tests.
54 hwpack_format = 'format: 3.0\n'
55 hwpack_dtb_name = 'dtb_name: %(dtb_name)s\n'
56 hwpack_fdt_high = "fdt_high: '%(fdt_high)s'\n"
57 hwpack_fat_size = 'fat_size: 16\n'
58 hwpack_android_args = 'android_specific_args: %(android_specific_args)s\n'
59 hwpack_extra_serial = 'extra_serial_options: %(extra_serial_options)s\n'
60 hwpack_extra_boot = ('extra_boot_args_options: '
61 '%(extra_boot_args_options)s\n')
62 hwpack_bootloader_flavor = 'bootloader_flavor: %(bootloader_flavor)s\n'
63 hwpack_initrd_addr = 'initrd_addr: \'%(initrd_addr)s\'\n'
64 hwpack_initrd_high = 'initrd_high: \'%(initrd_high)s\'\n'
65 hwpack_kernel_addr = 'kernel_addr: \'%(kernel_addr)s\'\n'
66 hwpack_load_addr = 'load_addr: \'%(load_addr)s\'\n'
67 hwpack_dtb_addr = 'dtb_addr: \'%(dtb_addr)s\'\n'
68 hwpack_boot_script = 'boot_script: %(boot_script)s\n'
69 hwpack_mmc_option = 'mmc_option: \'%(mmc_option)s\'\n'
70
71 # Some defaults YAML-like strings to use for the tests.
72 android_hwpack_base = (hwpack_format + hwpack_dtb_name)
73 android_hwpack_simple = (android_hwpack_base + hwpack_fdt_high +
74 hwpack_fat_size)
75 android_hwpack_android_args = (android_hwpack_base + hwpack_android_args)
76 android_hwpack_extra_serial = (android_hwpack_base + hwpack_extra_serial)
77 android_hwpack_extra_boot = (android_hwpack_base + hwpack_extra_boot)
78
79 android_hwpack_panda = (
80 hwpack_format + hwpack_android_args + hwpack_bootloader_flavor +
81 hwpack_dtb_addr + hwpack_dtb_name + hwpack_extra_boot +
82 hwpack_extra_serial
83 )
84
85 android_hwpack_mx6 = (
86 android_hwpack_panda + hwpack_initrd_addr + hwpack_kernel_addr +
87 hwpack_load_addr
88 )
89
90 android_hwpack_snowball_sd = (
91 hwpack_android_args + hwpack_boot_script + hwpack_dtb_addr +
92 hwpack_dtb_name + hwpack_extra_boot + hwpack_extra_serial +
93 hwpack_fdt_high + hwpack_format + hwpack_initrd_addr
94 )
95
96 android_hwpack_snowball_emmc = (
97 android_hwpack_snowball_sd + hwpack_initrd_high + hwpack_mmc_option)
98
99 def setUp(self):
100 super(TestAndroidBoardsHwpack, self).setUp()
101 # Pick a default board.
102 self.config = get_board_config('beagle')
103
104 def _get_tmp_file_name(self, content=None):
105 name = self.useFixture(CreateTempFileFixture(content)).get_file_name()
106 return name
107
108 def assertBootEnv(self, expected, config=None, board='beagle'):
109 """Helper function the boot env parameters.
110
111 :param config: The string containing the YAML configuration.
112 :type str
113 :param expected: The expected configuration.
114 :type dict
115 :param board: The name of the board to test. Defaults to beagle.
116 :type str
117 """
118 board_conf = get_board_config(board)
119 if config:
120 name = self.useFixture(CreateTempFileFixture(config)).\
121 get_file_name()
122 board_conf.from_file(name)
123 self.assertEqual(expected, board_conf._get_boot_env(consoles=[]))
124
125 def test_read_from_file(self):
126 values = {'fdt_high': '0xFFFFFFFF', 'dtb_name': 'a_name'}
127 expected = {'format': 3.0, 'dtb_name': 'a_name',
128 'fdt_high': '0xFFFFFFFF', 'fat_size': 16}
129 yaml_conf = self.android_hwpack_simple % values
130 name = self._get_tmp_file_name(yaml_conf)
131 conf = self.config.from_file(name)
132 self.assertEqual(expected, conf)
133
134 def test_android_specific_args(self):
135 """The field android_specific_args should be a concatenated string."""
136 values = {'android_specific_args': ['init=/init',
137 'androidboot.console=ttyO2'],
138 'dtb_name': 'a_name'}
139 yaml_conf = self.android_hwpack_android_args % values
140 name = self._get_tmp_file_name(yaml_conf)
141 self.config.from_file(name)
142 expected = 'init=/init androidboot.console=ttyO2'
143 self.assertEqual(expected, self.config.android_specific_args)
144
145 def test_extra_serial_options(self):
146 """The field extra_serial_options should be a concatenated string."""
147 values = {'dtb_name': 'a_name',
148 'extra_serial_options': ['console=tty0',
149 'console=ttyO2,115200n8']}
150 yaml_conf = self.android_hwpack_extra_serial % values
151 name = self._get_tmp_file_name(yaml_conf)
152 self.config.from_file(name)
153 expected = 'console=tty0 console=ttyO2,115200n8'
154 self.assertEqual(expected, self.config.extra_serial_options)
155
156 def test_extra_boot_args_options(self):
157 """The field extra_boot_args_options should be a concatenated string.
158 Testing presence of a field defined in the parent class."""
159 values = {'dtb_name': 'a_name',
160 'extra_boot_args_options': ['earlyprintk', 'mem=128M@0',
161 'mali.mali_mem=64M@128M']
162 }
163 yaml_conf = self.android_hwpack_extra_boot % values
164 name = self._get_tmp_file_name(yaml_conf)
165 self.config.from_file(name)
166 expected = 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M'
167 self.assertEqual(expected, self.config.extra_boot_args_options)
168
169 def test_android_mx6(self):
170 values = {
171 "android_specific_args": ["init=/init", "androidboot.console=%s"],
172 "bootloader_flavor": "mx6qsabrelite",
173 "dtb_addr": '0x11ff0000',
174 "dtb_name": "board.dtb",
175 "extra_boot_args_options": ["earlyprintk", "rootdelay=1",
176 "fixrtc", "nocompcache",
177 "di1_primary", "tve"],
178 "extra_serial_options": ["console=%s,115200n8"],
179 "initrd_addr": '0x12000000',
180 "kernel_addr": '0x10000000',
181 "load_addr": '0x10008000',
182 }
183 expected = {
184 'bootargs': 'console=ttymxc0,115200n8 '
185 'rootwait ro earlyprintk rootdelay=1 fixrtc '
186 'nocompcache di1_primary tve init=/init '
187 'androidboot.console=ttymxc0',
188 'bootcmd': 'fatload mmc 0:2 0x10000000 uImage; '
189 'fatload mmc 0:2 0x12000000 uInitrd; '
190 'fatload mmc 0:2 0x11ff0000 board.dtb; '
191 'bootm 0x10000000 0x12000000 0x11ff0000',
192 'fdt_high': '0xffffffff',
193 'initrd_high': '0xffffffff'}
194 config = self.android_hwpack_mx6 % values
195 self.assertBootEnv(expected, config=config, board='mx6qsabrelite')
196
197 def test_android_mx6_old(self):
198 # Old test: use the values from the class, instead of passing them.
199 expected = {
200 'bootargs': 'console=ttymxc0,115200n8 '
201 'rootwait ro earlyprintk rootdelay=1 fixrtc '
202 'nocompcache di1_primary tve init=/init '
203 'androidboot.console=ttymxc0',
204 'bootcmd': 'fatload mmc 0:2 0x10000000 uImage; '
205 'fatload mmc 0:2 0x12000000 uInitrd; '
206 'fatload mmc 0:2 0x11ff0000 board.dtb; '
207 'bootm 0x10000000 0x12000000 0x11ff0000',
208 'fdt_high': '0xffffffff',
209 'initrd_high': '0xffffffff'}
210 self.assertBootEnv(expected, board='mx6qsabrelite')
211
212 def test_panda(self):
213 values = {
214 "android_specific_args": ["init=/init",
215 "androidboot.console=ttyO2"],
216 "bootloader_flavor": "omap4_panda",
217 "dtb_addr": '0x815f0000',
218 "dtb_name": "board.dtb",
219 "extra_boot_args_options": ["earlyprintk", "fixrtc",
220 "nocompcache", "vram=48M",
221 "omapfb.vram=0:24M,1:24M",
222 "mem=456M@0x80000000",
223 "mem=512M@0xA0000000"],
224 "extra_serial_options": ["console=ttyO2,115200n8"],
225 }
226 expected = {
227 'bootargs': 'console=ttyO2,115200n8 '
228 'rootwait ro earlyprintk fixrtc '
229 'nocompcache vram=48M omapfb.vram=0:24M,1:24M '
230 'mem=456M@0x80000000 mem=512M@0xA0000000 '
231 'init=/init androidboot.console=ttyO2',
232 'bootcmd': 'fatload mmc 0:1 0x80200000 uImage; '
233 'fatload mmc 0:1 0x81600000 uInitrd; '
234 'fatload mmc 0:1 0x815f0000 board.dtb; '
235 'bootm 0x80200000 0x81600000 0x815f0000',
236 'fdt_high': '0xffffffff',
237 'initrd_high': '0xffffffff'}
238 config = self.android_hwpack_panda % values
239 self.assertBootEnv(expected, config=config, board='panda')
240
241 def test_panda_old(self):
242 # Old test: use the values from the class, instead of passing them.
243 expected = {
244 'bootargs': 'console=ttyO2,115200n8 '
245 'rootwait ro earlyprintk fixrtc '
246 'nocompcache vram=48M omapfb.vram=0:24M,1:24M '
247 'mem=456M@0x80000000 mem=512M@0xA0000000 '
248 'init=/init androidboot.console=ttyO2',
249 'bootcmd': 'fatload mmc 0:1 0x80200000 uImage; '
250 'fatload mmc 0:1 0x81600000 uInitrd; '
251 'fatload mmc 0:1 0x815f0000 board.dtb; '
252 'bootm 0x80200000 0x81600000 0x815f0000',
253 'fdt_high': '0xffffffff',
254 'initrd_high': '0xffffffff'}
255 self.assertBootEnv(expected, board='panda')
256
257 def test_android_snowball_sd(self):
258 values = {
259 "android_specific_args": ["init=/init",
260 "androidboot.console=ttyAMA2"],
261 "boot_script": "boot.scr",
262 "dtb_addr": '0x8000000',
263 "dtb_name": "board.dtb",
264 "extra_boot_args_options": ["earlyprintk", "mem=128M@0",
265 "mali.mali_mem=64M@128M",
266 "hwmem=168M@192M", "mem=22M@360M",
267 "mem_issw=1M@383M", "mem=640M@384M",
268 "vmalloc=500M"],
269 "extra_serial_options": ["console=ttyAMA2,115200n8"],
270 "fdt_high": '0x05000000',
271 "initrd_addr": '0x05000000',
272 "initrd_high": '0x06000000',
273 }
274 expected = {
275 'bootargs': 'console=ttyAMA2,115200n8 '
276 'rootwait ro earlyprintk '
277 'mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
278 'mem=22M@360M mem_issw=1M@383M mem=640M@384M '
279 'vmalloc=500M init=/init androidboot.console=ttyAMA2',
280 'bootcmd': 'fatload mmc 1:1 0x00100000 uImage; '
281 'fatload mmc 1:1 0x05000000 uInitrd; '
282 'fatload mmc 1:1 0x8000000 board.dtb; '
283 'bootm 0x00100000 0x05000000 0x8000000',
284 'fdt_high': '0x05000000',
285 'initrd_high': '0x06000000'}
286 config = self.android_hwpack_snowball_sd % values
287 self.assertBootEnv(expected, config=config, board='snowball_sd')
288
289 def test_android_snowball_sd_old(self):
290 # Old test: use the values from the class, instead of passing them.
291 expected = {
292 'bootargs': 'console=ttyAMA2,115200n8 '
293 'rootwait ro earlyprintk '
294 'mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
295 'mem=22M@360M mem_issw=1M@383M mem=640M@384M '
296 'vmalloc=500M init=/init androidboot.console=ttyAMA2',
297 'bootcmd': 'fatload mmc 1:1 0x00100000 uImage; '
298 'fatload mmc 1:1 0x05000000 uInitrd; '
299 'fatload mmc 1:1 0x8000000 board.dtb; '
300 'bootm 0x00100000 0x05000000 0x8000000',
301 'fdt_high': '0x05000000',
302 'initrd_high': '0x06000000'}
303 self.assertBootEnv(expected, board='snowball_sd')
304
305 def test_android_snowball_emmc(self):
306 values = {
307 "android_specific_args": ["init=/init",
308 "androidboot.console=ttyAMA2"],
309 "boot_script": "boot.scr",
310 "dtb_addr": '0x8000000',
311 "dtb_name": "board.dtb",
312 "extra_boot_args_options": ["earlyprintk", "mem=128M@0",
313 "mali.mali_mem=64M@128M",
314 "hwmem=168M@192M", "mem=22M@360M",
315 "mem_issw=1M@383M", "mem=640M@384M",
316 "vmalloc=500M"],
317 "extra_serial_options": ["console=ttyAMA2,115200n8"],
318 "fdt_high": '0x05000000',
319 "initrd_addr": '0x05000000',
320 "initrd_high": '0x06000000',
321 "mmc_option": '0:2'
322 }
323 expected = {
324 'bootargs': 'console=ttyAMA2,115200n8 '
325 'rootwait ro earlyprintk '
326 'mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
327 'mem=22M@360M mem_issw=1M@383M mem=640M@384M '
328 'vmalloc=500M init=/init androidboot.console=ttyAMA2',
329 'bootcmd': 'fatload mmc 0:2 0x00100000 uImage; '
330 'fatload mmc 0:2 0x05000000 uInitrd; '
331 'fatload mmc 0:2 0x8000000 board.dtb; '
332 'bootm 0x00100000 0x05000000 0x8000000',
333 'fdt_high': '0x05000000',
334 'initrd_high': '0x06000000'}
335 config = self.android_hwpack_snowball_emmc % values
336 self.assertBootEnv(expected, config, board='snowball_emmc')
337
338 def test_android_snowball_emmc_old(self):
339 # Old test: use the values from the class, instead of passing them.
340 expected = {
341 'bootargs': 'console=ttyAMA2,115200n8 '
342 'rootwait ro earlyprintk '
343 'mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
344 'mem=22M@360M mem_issw=1M@383M mem=640M@384M '
345 'vmalloc=500M init=/init androidboot.console=ttyAMA2',
346 'bootcmd': 'fatload mmc 0:2 0x00100000 uImage; '
347 'fatload mmc 0:2 0x05000000 uInitrd; '
348 'fatload mmc 0:2 0x8000000 board.dtb; '
349 'bootm 0x00100000 0x05000000 0x8000000',
350 'fdt_high': '0x05000000',
351 'initrd_high': '0x06000000'}
352 self.assertBootEnv(expected, board='snowball_emmc')
353
354 def test_android_origen(self):
355 values = {
356 "extra_serial_options": ["console=tty0", "console=ttySAC2,115200n8"],
357 "android_specific_args": ["init=/init", "androidboot.console=ttySAC2"]
358 }
359 expected = {
360 'bootargs': 'console=tty0 console=ttySAC2,115200n8 '
361 'rootwait ro init=/init androidboot.console=ttySAC2',
362 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
363 'fatload mmc 0:2 0x42000000 uInitrd; '
364 'bootm 0x40007000 0x42000000',
365 'fdt_high': '0xffffffff',
366 'initrd_high': '0xffffffff'}
367 config = ((self.hwpack_format + self.hwpack_extra_serial +
368 self.hwpack_android_args) % values)
369 self.assertBootEnv(expected, config=config, board='origen')
370
371 def test_android_origen_old(self):
372 # Old test: use the values from the class, instead of passing them.
373 expected = {
374 'bootargs': 'console=tty0 console=ttySAC2,115200n8 '
375 'rootwait ro init=/init androidboot.console=ttySAC2',
376 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
377 'fatload mmc 0:2 0x42000000 uInitrd; '
378 'bootm 0x40007000 0x42000000',
379 'fdt_high': '0xffffffff',
380 'initrd_high': '0xffffffff'}
381 self.assertBootEnv(expected, board='origen')
382
383 def test_android_origen_quad(self):
384 values = {
385 "extra_serial_options": ["console=tty0",
386 "console=ttySAC2,115200n8"],
387 "android_specific_args": ["init=/init",
388 "androidboot.console=ttySAC2"]
389 }
390 expected = {
391 'bootargs': 'console=tty0 console=ttySAC2,115200n8 '
392 'rootwait ro init=/init androidboot.console=ttySAC2',
393 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
394 'fatload mmc 0:2 0x42000000 uInitrd; '
395 'bootm 0x40007000 0x42000000',
396 'fdt_high': '0xffffffff',
397 'initrd_high': '0xffffffff'}
398 config = ((self.hwpack_format + self.hwpack_extra_serial +
399 self.hwpack_android_args) % values)
400 self.assertBootEnv(expected, config=config, board='origen_quad')
401
402 def test_android_origen_quad_old(self):
403 # Old test: use the values from the class, instead of passing them.
404 expected = {
405 'bootargs': 'console=tty0 console=ttySAC2,115200n8 '
406 'rootwait ro init=/init androidboot.console=ttySAC2',
407 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
408 'fatload mmc 0:2 0x42000000 uInitrd; '
409 'bootm 0x40007000 0x42000000',
410 'fdt_high': '0xffffffff',
411 'initrd_high': '0xffffffff'}
412 self.assertBootEnv(expected, board='origen_quad')
413
414 def test_android_vexpress(self):
415 values = {
416 "extra_serial_options": ["console=tty0",
417 "console=ttyAMA0,38400n8"],
418 "android_specific_args": ["init=/init",
419 "androidboot.console=ttyAMA0"]
420 }
421 expected = {
422 'bootargs': 'console=tty0 console=ttyAMA0,38400n8 '
423 'rootwait ro init=/init androidboot.console=ttyAMA0',
424 'bootcmd': 'fatload mmc 0:1 0x60000000 uImage; '
425 'fatload mmc 0:1 0x62000000 uInitrd; '
426 'bootm 0x60000000 0x62000000',
427 'fdt_high': '0xffffffff',
428 'initrd_high': '0xffffffff'}
429 config = ((self.hwpack_format + self.hwpack_extra_serial +
430 self.hwpack_android_args) % values)
431 self.assertBootEnv(expected, config=config, board='vexpress')
432
433 def test_android_vexpress_old(self):
434 # Old test: use the values from the class, instead of passing them.
435 expected = {
436 'bootargs': 'console=tty0 console=ttyAMA0,38400n8 '
437 'rootwait ro init=/init androidboot.console=ttyAMA0',
438 'bootcmd': 'fatload mmc 0:1 0x60000000 uImage; '
439 'fatload mmc 0:1 0x62000000 uInitrd; '
440 'bootm 0x60000000 0x62000000',
441 'fdt_high': '0xffffffff',
442 'initrd_high': '0xffffffff'}
443 self.assertBootEnv(expected, board='vexpress')
444
445 def test_android_mx5(self):
446 values = {
447 "extra_boot_args_options": ["earlyprintk", "rootdelay=1",
448 "fixrtc", "nocompcache",
449 "di1_primary", "tve"],
450 "extra_serial_options": ["console=%s,115200n8"],
451 "android_specific_args": ["init=/init", "androidboot.console=%s"]
452 }
453 expected = {
454 'bootargs': 'console=ttymxc0,115200n8 '
455 'rootwait ro earlyprintk rootdelay=1 fixrtc '
456 'nocompcache di1_primary tve init=/init '
457 'androidboot.console=ttymxc0',
458 'bootcmd': 'fatload mmc 0:2 0x70000000 uImage; '
459 'fatload mmc 0:2 0x72000000 uInitrd; '
460 'bootm 0x70000000 0x72000000',
461 'fdt_high': '0xffffffff',
462 'initrd_high': '0xffffffff'}
463 config = ((self.hwpack_format + self.hwpack_extra_boot +
464 self.hwpack_extra_serial + self.hwpack_android_args) %
465 values)
466 self.assertBootEnv(expected, config=config, board='mx53loco')
467
468 def test_android_mx5_old(self):
469 # Old test: use the values from the class, instead of passing them.
470 expected = {
471 'bootargs': 'console=ttymxc0,115200n8 '
472 'rootwait ro earlyprintk rootdelay=1 fixrtc '
473 'nocompcache di1_primary tve init=/init '
474 'androidboot.console=ttymxc0',
475 'bootcmd': 'fatload mmc 0:2 0x70000000 uImage; '
476 'fatload mmc 0:2 0x72000000 uInitrd; '
477 'bootm 0x70000000 0x72000000',
478 'fdt_high': '0xffffffff',
479 'initrd_high': '0xffffffff'}
480 self.assertBootEnv(expected, board='mx53loco')
0481
=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
--- linaro_image_tools/media_create/tests/test_media_create.py 2012-12-23 12:49:02 +0000
+++ linaro_image_tools/media_create/tests/test_media_create.py 2013-01-03 13:57:23 +0000
@@ -32,6 +32,7 @@
32import tarfile32import tarfile
33import dbus33import dbus
3434
35from mock import MagicMock
35from StringIO import StringIO36from StringIO import StringIO
36from testtools import TestCase37from testtools import TestCase
3738
@@ -50,7 +51,6 @@
50 SECTOR_SIZE,51 SECTOR_SIZE,
51 align_up,52 align_up,
52 align_partition,53 align_partition,
53 board_configs,
54 get_plain_boot_script_contents,54 get_plain_boot_script_contents,
55 make_flashable_env,55 make_flashable_env,
56 install_mx5_boot_loader,56 install_mx5_boot_loader,
@@ -63,10 +63,10 @@
63 _get_mlo_file,63 _get_mlo_file,
64 _run_mkimage,64 _run_mkimage,
65 BoardConfig,65 BoardConfig,
66 get_board_config,
66 )67 )
67from linaro_image_tools.media_create.android_boards import (68from linaro_image_tools.media_create.android_boards import (
68 AndroidSnowballEmmcConfig,69 AndroidSnowballEmmcConfig,
69 android_board_configs,
70 )70 )
71from linaro_image_tools.media_create.chroot_utils import (71from linaro_image_tools.media_create.chroot_utils import (
72 copy_file,72 copy_file,
@@ -203,7 +203,7 @@
203 return tarball203 return tarball
204204
205 def test_get_format_1(self):205 def test_get_format_1(self):
206 data = '1.0'206 data = HardwarepackHandler.FORMAT_1
207 format = "%s\n" % data207 format = "%s\n" % data
208 tarball = self.add_to_tarball(208 tarball = self.add_to_tarball(
209 [('FORMAT', format), ('metadata', self.metadata)])209 [('FORMAT', format), ('metadata', self.metadata)])
@@ -230,8 +230,8 @@
230 self.assertRaises(AssertionError, hp.get_format)230 self.assertRaises(AssertionError, hp.get_format)
231231
232 def test_mixed_formats(self):232 def test_mixed_formats(self):
233 format1 = "%s\n" % '1.0'233 format1 = "%s\n" % HardwarepackHandler.FORMAT_1
234 format2 = "%s\n" % '2.0'234 format2 = "%s\n" % HardwarepackHandler.FORMAT_2
235 tarball1 = self.add_to_tarball(235 tarball1 = self.add_to_tarball(
236 [('FORMAT', format1), ('metadata', self.metadata)],236 [('FORMAT', format1), ('metadata', self.metadata)],
237 tarball=self.tarball_fixture.get_tarball())237 tarball=self.tarball_fixture.get_tarball())
@@ -247,8 +247,8 @@
247 self.assertEquals(hp.get_format(), '1.0and2.0')247 self.assertEquals(hp.get_format(), '1.0and2.0')
248248
249 def test_identical_formats_ok(self):249 def test_identical_formats_ok(self):
250 format1 = "%s\n" % '2.0'250 format1 = "%s\n" % HardwarepackHandler.FORMAT_2
251 format2 = "%s\n" % '2.0'251 format2 = "%s\n" % HardwarepackHandler.FORMAT_2
252 tarball1 = self.add_to_tarball(252 tarball1 = self.add_to_tarball(
253 [('FORMAT', format1), ('metadata', self.metadata)],253 [('FORMAT', format1), ('metadata', self.metadata)],
254 tarball=self.tarball_fixture.get_tarball())254 tarball=self.tarball_fixture.get_tarball())
@@ -427,10 +427,9 @@
427 linaro_image_tools.media_create.boards, 'HardwarepackHandler',427 linaro_image_tools.media_create.boards, 'HardwarepackHandler',
428 self.MockHardwarepackHandler))428 self.MockHardwarepackHandler))
429429
430 class config(BoardConfig):430 board_conf = BoardConfig()
431 pass431 board_conf.set_metadata('ahwpack.tar.gz')
432 config.set_metadata('ahwpack.tar.gz')432 self.assertEquals(None, board_conf.kernel_addr)
433 self.assertEquals(None, config.kernel_addr)
434433
435 def test_sets_kernel_addr(self):434 def test_sets_kernel_addr(self):
436 self.useFixture(MockSomethingFixture(435 self.useFixture(MockSomethingFixture(
@@ -442,10 +441,9 @@
442 field_to_test: data_to_set,441 field_to_test: data_to_set,
443 }442 }
444443
445 class config(BoardConfig):444 board_conf = BoardConfig()
446 pass445 board_conf.set_metadata('ahwpack.tar.gz')
447 config.set_metadata('ahwpack.tar.gz')446 self.assertEquals(data_to_set, board_conf.kernel_addr)
448 self.assertEquals(data_to_set, config.kernel_addr)
449447
450 def test_sets_initrd_addr(self):448 def test_sets_initrd_addr(self):
451 self.useFixture(MockSomethingFixture(449 self.useFixture(MockSomethingFixture(
@@ -457,10 +455,9 @@
457 field_to_test: data_to_set,455 field_to_test: data_to_set,
458 }456 }
459457
460 class config(BoardConfig):458 board_conf = BoardConfig()
461 pass459 board_conf.set_metadata('ahwpack.tar.gz')
462 config.set_metadata('ahwpack.tar.gz')460 self.assertEquals(data_to_set, board_conf.initrd_addr)
463 self.assertEquals(data_to_set, config.initrd_addr)
464461
465 def test_sets_load_addr(self):462 def test_sets_load_addr(self):
466 self.useFixture(MockSomethingFixture(463 self.useFixture(MockSomethingFixture(
@@ -472,10 +469,9 @@
472 field_to_test: data_to_set,469 field_to_test: data_to_set,
473 }470 }
474471
475 class config(BoardConfig):472 board_conf = BoardConfig()
476 pass473 board_conf.set_metadata('ahwpack.tar.gz')
477 config.set_metadata('ahwpack.tar.gz')474 self.assertEquals(data_to_set, board_conf.load_addr)
478 self.assertEquals(data_to_set, config.load_addr)
479475
480 def test_sets_serial_tty(self):476 def test_sets_serial_tty(self):
481 self.useFixture(MockSomethingFixture(477 self.useFixture(MockSomethingFixture(
@@ -487,10 +483,9 @@
487 field_to_test: data_to_set,483 field_to_test: data_to_set,
488 }484 }
489485
490 class config(BoardConfig):486 board_conf = BoardConfig()
491 pass487 board_conf.set_metadata('ahwpack.tar.gz')
492 config.set_metadata('ahwpack.tar.gz')488 self.assertEquals(data_to_set, board_conf.serial_tty)
493 self.assertEquals(data_to_set, config.serial_tty)
494489
495 def test_sets_wired_interfaces(self):490 def test_sets_wired_interfaces(self):
496 self.useFixture(MockSomethingFixture(491 self.useFixture(MockSomethingFixture(
@@ -502,10 +497,9 @@
502 field_to_test: data_to_set,497 field_to_test: data_to_set,
503 }498 }
504499
505 class config(BoardConfig):500 board_conf = BoardConfig()
506 pass501 board_conf.set_metadata('ahwpack.tar.gz')
507 config.set_metadata('ahwpack.tar.gz')502 self.assertEquals(data_to_set, board_conf.wired_interfaces)
508 self.assertEquals(data_to_set, config.wired_interfaces)
509503
510 def test_sets_wireless_interfaces(self):504 def test_sets_wireless_interfaces(self):
511 self.useFixture(MockSomethingFixture(505 self.useFixture(MockSomethingFixture(
@@ -517,10 +511,9 @@
517 field_to_test: data_to_set,511 field_to_test: data_to_set,
518 }512 }
519513
520 class config(BoardConfig):514 board_conf = BoardConfig()
521 pass515 board_conf.set_metadata('ahwpack.tar.gz')
522 config.set_metadata('ahwpack.tar.gz')516 self.assertEquals(data_to_set, board_conf.wireless_interfaces)
523 self.assertEquals(data_to_set, config.wireless_interfaces)
524517
525 def test_sets_mmc_id(self):518 def test_sets_mmc_id(self):
526 self.useFixture(MockSomethingFixture(519 self.useFixture(MockSomethingFixture(
@@ -532,12 +525,11 @@
532 field_to_test: data_to_set,525 field_to_test: data_to_set,
533 }526 }
534527
535 class config(BoardConfig):528 board_conf = BoardConfig()
536 pass529 board_conf.set_metadata('ahwpack.tar.gz')
537 config.set_metadata('ahwpack.tar.gz')530 self.assertEquals(data_to_set, board_conf.mmc_option)
538 self.assertEquals(data_to_set, config.mmc_option)531 self.assertEquals(0, board_conf.mmc_device_id)
539 self.assertEquals(0, config.mmc_device_id)532 self.assertEquals(0, board_conf.mmc_part_offset)
540 self.assertEquals(0, config.mmc_part_offset)
541533
542 def test_sets_boot_min_size(self):534 def test_sets_boot_min_size(self):
543 self.useFixture(MockSomethingFixture(535 self.useFixture(MockSomethingFixture(
@@ -551,10 +543,9 @@
551 field_to_test: data_to_set,543 field_to_test: data_to_set,
552 }544 }
553545
554 class config(BoardConfig):546 board_conf = BoardConfig()
555 pass547 board_conf.set_metadata('ahwpack.tar.gz')
556 config.set_metadata('ahwpack.tar.gz')548 self.assertEquals(expected, board_conf.BOOT_MIN_SIZE_S)
557 self.assertEquals(expected, config.BOOT_MIN_SIZE_S)
558549
559 def test_sets_root_min_size(self):550 def test_sets_root_min_size(self):
560 self.useFixture(MockSomethingFixture(551 self.useFixture(MockSomethingFixture(
@@ -568,10 +559,9 @@
568 field_to_test: data_to_set,559 field_to_test: data_to_set,
569 }560 }
570561
571 class config(BoardConfig):562 board_conf = BoardConfig()
572 pass563 board_conf.set_metadata('ahwpack.tar.gz')
573 config.set_metadata('ahwpack.tar.gz')564 self.assertEquals(expected, board_conf.ROOT_MIN_SIZE_S)
574 self.assertEquals(expected, config.ROOT_MIN_SIZE_S)
575565
576 def test_sets_loader_min_size(self):566 def test_sets_loader_min_size(self):
577 self.useFixture(MockSomethingFixture(567 self.useFixture(MockSomethingFixture(
@@ -585,10 +575,9 @@
585 field_to_test: data_to_set,575 field_to_test: data_to_set,
586 }576 }
587577
588 class config(BoardConfig):578 board_conf = BoardConfig()
589 pass579 board_conf.set_metadata('ahwpack.tar.gz')
590 config.set_metadata('ahwpack.tar.gz')580 self.assertEquals(expected, board_conf.LOADER_MIN_SIZE_S)
591 self.assertEquals(expected, config.LOADER_MIN_SIZE_S)
592581
593 def test_sets_partition_layout_32(self):582 def test_sets_partition_layout_32(self):
594 self.useFixture(MockSomethingFixture(583 self.useFixture(MockSomethingFixture(
@@ -600,10 +589,9 @@
600 field_to_test: data_to_set,589 field_to_test: data_to_set,
601 }590 }
602591
603 class config(BoardConfig):592 board_conf = BoardConfig()
604 pass593 board_conf.set_metadata('ahwpack.tar.gz')
605 config.set_metadata('ahwpack.tar.gz')594 self.assertEquals(32, board_conf.fat_size)
606 self.assertEquals(32, config.fat_size)
607595
608 def test_sets_partition_layout_16(self):596 def test_sets_partition_layout_16(self):
609 self.useFixture(MockSomethingFixture(597 self.useFixture(MockSomethingFixture(
@@ -615,10 +603,9 @@
615 field_to_test: data_to_set,603 field_to_test: data_to_set,
616 }604 }
617605
618 class config(BoardConfig):606 board_conf = BoardConfig()
619 pass607 board_conf.set_metadata('ahwpack.tar.gz')
620 config.set_metadata('ahwpack.tar.gz')608 self.assertEquals(16, board_conf.fat_size)
621 self.assertEquals(16, config.fat_size)
622609
623 def test_sets_partition_layout_raises(self):610 def test_sets_partition_layout_raises(self):
624 self.useFixture(MockSomethingFixture(611 self.useFixture(MockSomethingFixture(
@@ -630,10 +617,9 @@
630 field_to_test: data_to_set,617 field_to_test: data_to_set,
631 }618 }
632619
633 class config(BoardConfig):620 board_conf = BoardConfig()
634 pass
635 self.assertRaises(621 self.assertRaises(
636 AssertionError, config.set_metadata, 'ahwpack.tar.gz')622 AssertionError, board_conf.set_metadata, 'ahwpack.tar.gz')
637623
638 def test_sets_copy_files(self):624 def test_sets_copy_files(self):
639 self.useFixture(MockSomethingFixture(625 self.useFixture(MockSomethingFixture(
@@ -647,10 +633,9 @@
647 field_to_test: data_to_set,633 field_to_test: data_to_set,
648 }634 }
649635
650 class config(BoardConfig):636 board_conf = BoardConfig()
651 pass637 board_conf.set_metadata('ahwpack.tar.gz')
652 config.set_metadata('ahwpack.tar.gz')638 self.assertEquals(data_to_set, board_conf.bootloader_copy_files)
653 self.assertEquals(data_to_set, config.bootloader_copy_files)
654639
655640
656class TestGetMLOFile(TestCaseWithFixtures):641class TestGetMLOFile(TestCaseWithFixtures):
@@ -697,7 +682,10 @@
697682
698683
699class TestGetSMDKSPL(TestCaseWithFixtures):684class TestGetSMDKSPL(TestCaseWithFixtures):
700 config = boards.SMDKV310Config685 def setUp(self):
686 super(TestGetSMDKSPL, self).setUp()
687 self.config = boards.SMDKV310Config()
688 self.config.hwpack_format = HardwarepackHandler.FORMAT_1
701689
702 def test_no_file_present(self):690 def test_no_file_present(self):
703 tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()691 tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
@@ -729,7 +717,10 @@
729717
730718
731class TestGetSMDKUboot(TestCaseWithFixtures):719class TestGetSMDKUboot(TestCaseWithFixtures):
732 config = boards.SMDKV310Config720 def setUp(self):
721 super(TestGetSMDKUboot, self).setUp()
722 self.config = boards.SMDKV310Config()
723 self.config.hwpack_format = HardwarepackHandler.FORMAT_1
733724
734 def test_uses_uboot_flavour(self):725 def test_uses_uboot_flavour(self):
735 chroot_dir = "chroot"726 chroot_dir = "chroot"
@@ -740,7 +731,10 @@
740731
741732
742class TestGetOrigenSPL(TestCaseWithFixtures):733class TestGetOrigenSPL(TestCaseWithFixtures):
743 config = boards.OrigenConfig734 def setUp(self):
735 super(TestGetOrigenSPL, self).setUp()
736 self.config = boards.OrigenConfig()
737 self.config.hwpack_format = HardwarepackHandler.FORMAT_1
744738
745 def test_no_file_present(self):739 def test_no_file_present(self):
746 tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()740 tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
@@ -756,11 +750,17 @@
756750
757751
758class TestGetOrigenUboot(TestGetSMDKUboot):752class TestGetOrigenUboot(TestGetSMDKUboot):
759 config = boards.OrigenConfig753 def setUp(self):
754 super(TestGetOrigenUboot, self).setUp()
755 self.config = boards.OrigenConfig()
756 self.config.hwpack_format = HardwarepackHandler.FORMAT_1
760757
761758
762class TestGetOrigenQuadSPL(TestCaseWithFixtures):759class TestGetOrigenQuadSPL(TestCaseWithFixtures):
763 config = boards.OrigenQuadConfig760 def setUp(self):
761 super(TestGetOrigenQuadSPL, self).setUp()
762 self.config = boards.OrigenQuadConfig()
763 self.config.hwpack_format = HardwarepackHandler.FORMAT_1
764764
765 def test_no_file_present(self):765 def test_no_file_present(self):
766 tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()766 tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
@@ -776,11 +776,17 @@
776776
777777
778class TestGetOrigenQuadUboot(TestGetSMDKUboot):778class TestGetOrigenQuadUboot(TestGetSMDKUboot):
779 config = boards.OrigenQuadConfig779 def setUp(self):
780 super(TestGetOrigenQuadUboot, self).setUp()
781 self.config = boards.OrigenQuadConfig()
782 self.config.hwpack_format = HardwarepackHandler.FORMAT_1
780783
781784
782class TestGetArndaleSPL(TestCaseWithFixtures):785class TestGetArndaleSPL(TestCaseWithFixtures):
783 config = boards.ArndaleConfig786 def setUp(self):
787 super(TestGetArndaleSPL, self).setUp()
788 self.config = boards.ArndaleConfig()
789 self.config.hwpack_format = HardwarepackHandler.FORMAT_1
784790
785 def test_no_file_present(self):791 def test_no_file_present(self):
786 tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()792 tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir()
@@ -818,6 +824,7 @@
818 '\x05\x00\x00\x00' '\x05\x00\x00\x00' \824 '\x05\x00\x00\x00' '\x05\x00\x00\x00' \
819 'hello' + zero + '\x00\x00\x00'825 'hello' + zero + '\x00\x00\x00'
820 self.expected = line1 + line2 + line3826 self.expected = line1 + line2 + line3
827 self.board_conf = boards.SnowballEmmcConfig()
821828
822 def create_files_structure(self, src_data):829 def create_files_structure(self, src_data):
823 ''' Creates the data structure that the tested function830 ''' Creates the data structure that the tested function
@@ -841,7 +848,7 @@
841 files = self.create_files_structure(correct_data)848 files = self.create_files_structure(correct_data)
842 filename = os.path.join(self.tempdir, 'toc')849 filename = os.path.join(self.tempdir, 'toc')
843 with open(filename, 'w') as f:850 with open(filename, 'w') as f:
844 boards.SnowballEmmcConfig.create_toc(f, files)851 self.board_conf.create_toc(f, files)
845 with open(filename, 'r') as f:852 with open(filename, 'r') as f:
846 actual = f.read()853 actual = f.read()
847 self.assertEquals(96, len(actual))854 self.assertEquals(96, len(actual))
@@ -856,7 +863,7 @@
856 files = self.create_files_structure(illegal_name_data)863 files = self.create_files_structure(illegal_name_data)
857 with open(os.path.join(self.tempdir, 'toc'), 'w') as f:864 with open(os.path.join(self.tempdir, 'toc'), 'w') as f:
858 self.assertRaises(AssertionError,865 self.assertRaises(AssertionError,
859 boards.SnowballEmmcConfig.create_toc,866 self.board_conf.create_toc,
860 f, files)867 f, files)
861868
862 def test_create_toc_error_negative_unsigned(self):869 def test_create_toc_error_negative_unsigned(self):
@@ -866,7 +873,7 @@
866 files = self.create_files_structure(illegal_unsigned_data)873 files = self.create_files_structure(illegal_unsigned_data)
867 with open(os.path.join(self.tempdir, 'toc'), 'w') as f:874 with open(os.path.join(self.tempdir, 'toc'), 'w') as f:
868 self.assertRaises(struct.error,875 self.assertRaises(struct.error,
869 boards.SnowballEmmcConfig.create_toc,876 self.board_conf.create_toc,
870 f, files)877 f, files)
871878
872879
@@ -885,6 +892,8 @@
885 os.makedirs(self.temp_bootdir_path)892 os.makedirs(self.temp_bootdir_path)
886 if not os.path.exists(self.temp_configdir_path):893 if not os.path.exists(self.temp_configdir_path):
887 os.makedirs(self.temp_configdir_path)894 os.makedirs(self.temp_configdir_path)
895 self.snowball_config = get_board_config('snowball_emmc')
896 self.snowball_config.hwpack_format = HardwarepackHandler.FORMAT_1
888897
889 def setupFiles(self):898 def setupFiles(self):
890 return self.create_test_files(self.temp_bootdir_path)899 return self.create_test_files(self.temp_bootdir_path)
@@ -910,7 +919,7 @@
910 ('UBOOT_ENV', 'u-boot-env.bin', 0, 0x00C1F000, '10')]919 ('UBOOT_ENV', 'u-boot-env.bin', 0, 0x00C1F000, '10')]
911 # Create a config file920 # Create a config file
912 cfg_file = os.path.join(921 cfg_file = os.path.join(
913 path, boards.SnowballEmmcConfig.snowball_startup_files_config)922 path, self.snowball_config.snowball_startup_files_config)
914 with open(cfg_file, 'w') as f:923 with open(cfg_file, 'w') as f:
915 for line in src_data:924 for line in src_data:
916 # Write comments, so we test that the parser can read them925 # Write comments, so we test that the parser can read them
@@ -926,8 +935,8 @@
926 f.write(line[0])935 f.write(line[0])
927 #define the expected values read from the config file936 #define the expected values read from the config file
928 expected = []937 expected = []
929 ofs = [boards.SnowballEmmcConfig.TOC_SIZE,938 ofs = [self.snowball_config.TOC_SIZE,
930 boards.SnowballEmmcConfig.TOC_SIZE + len('ISSW'), 0x160000,939 self.snowball_config.TOC_SIZE + len('ISSW'), 0x160000,
931 0x170000, 0xBA0000, 0xC1F000]940 0x170000, 0xBA0000, 0xC1F000]
932 size = [len('ISSW'), len('X-LOADER'), len('MEM_INIT'), \941 size = [len('ISSW'), len('X-LOADER'), len('MEM_INIT'), \
933 len('PWR_MGT'), len('NORMAL'), len('UBOOT_ENV')]942 len('PWR_MGT'), len('NORMAL'), len('UBOOT_ENV')]
@@ -946,13 +955,13 @@
946 def test_get_file_info_relative_path(self):955 def test_get_file_info_relative_path(self):
947 # Create a config file956 # Create a config file
948 cfg_file = os.path.join(self.temp_bootdir_path,957 cfg_file = os.path.join(self.temp_bootdir_path,
949 boards.SnowballEmmcConfig.snowball_startup_files_config)958 self.snowball_config.snowball_startup_files_config)
950 uboot_file = 'u-boot.bin'959 uboot_file = 'u-boot.bin'
951 with open(cfg_file, 'w') as f:960 with open(cfg_file, 'w') as f:
952 f.write('%s %s %i %#x %s\n' % ('NORMAL', uboot_file, 0,961 f.write('%s %s %i %#x %s\n' % ('NORMAL', uboot_file, 0,
953 0xBA0000, '9'))962 0xBA0000, '9'))
954 with open(os.path.join(self.temp_bootdir_path, uboot_file), 'w') as f:963 with open(os.path.join(self.temp_bootdir_path, uboot_file), 'w') as f:
955 file_info = boards.SnowballEmmcConfig.get_file_info(964 file_info = self.snowball_config.get_file_info(
956 self.tempdir, self.temp_bootdir_path)965 self.tempdir, self.temp_bootdir_path)
957 self.assertEquals(file_info[0]['filename'],966 self.assertEquals(file_info[0]['filename'],
958 os.path.join(self.temp_bootdir_path, uboot_file))967 os.path.join(self.temp_bootdir_path, uboot_file))
@@ -960,7 +969,7 @@
960 def test_get_file_info_abs_path(self):969 def test_get_file_info_abs_path(self):
961 # Create a config file970 # Create a config file
962 cfg_file = os.path.join(self.temp_bootdir_path,971 cfg_file = os.path.join(self.temp_bootdir_path,
963 boards.SnowballEmmcConfig.snowball_startup_files_config)972 self.snowball_config.snowball_startup_files_config)
964 uboot_dir = tempfile.mkdtemp(dir=self.tempdir)973 uboot_dir = tempfile.mkdtemp(dir=self.tempdir)
965 uboot_file = os.path.join(uboot_dir, 'u-boot.bin')974 uboot_file = os.path.join(uboot_dir, 'u-boot.bin')
966 uboot_relative_file = uboot_file.replace(self.tempdir, '')975 uboot_relative_file = uboot_file.replace(self.tempdir, '')
@@ -968,19 +977,19 @@
968 f.write('%s %s %i %#x %s\n' % (977 f.write('%s %s %i %#x %s\n' % (
969 'NORMAL', uboot_relative_file, 0, 0xBA0000, '9'))978 'NORMAL', uboot_relative_file, 0, 0xBA0000, '9'))
970 with open(uboot_file, 'w') as f:979 with open(uboot_file, 'w') as f:
971 file_info = boards.SnowballEmmcConfig.get_file_info(980 file_info = self.snowball_config.get_file_info(
972 self.tempdir, self.temp_bootdir_path)981 self.tempdir, self.temp_bootdir_path)
973 self.assertEquals(file_info[0]['filename'], uboot_file)982 self.assertEquals(file_info[0]['filename'], uboot_file)
974983
975 def test_get_file_info_raises(self):984 def test_get_file_info_raises(self):
976 # Create a config file985 # Create a config file
977 cfg_file = os.path.join(self.temp_bootdir_path,986 cfg_file = os.path.join(self.temp_bootdir_path,
978 boards.SnowballEmmcConfig.snowball_startup_files_config)987 self.snowball_config.snowball_startup_files_config)
979 with open(cfg_file, 'w') as f:988 with open(cfg_file, 'w') as f:
980 f.write('%s %s %i %#x %s\n' % ('NORMAL', 'u-boot.bin', 0,989 f.write('%s %s %i %#x %s\n' % ('NORMAL', 'u-boot.bin', 0,
981 0xBA0000, '9'))990 0xBA0000, '9'))
982 self.assertRaises(991 self.assertRaises(
983 AssertionError, boards.SnowballEmmcConfig.get_file_info,992 AssertionError, self.snowball_config.get_file_info,
984 self.tempdir, self.temp_bootdir_path)993 self.tempdir, self.temp_bootdir_path)
985994
986 def test_file_name_size(self):995 def test_file_name_size(self):
@@ -988,28 +997,28 @@
988 _, toc_filename = tempfile.mkstemp()997 _, toc_filename = tempfile.mkstemp()
989 atexit.register(os.unlink, toc_filename)998 atexit.register(os.unlink, toc_filename)
990 filedata = 'X'999 filedata = 'X'
991 bytes = boards.SnowballEmmcConfig.TOC_SIZE + 11000 bytes = self.snowball_config.TOC_SIZE + 1
992 tmpfile = open(toc_filename, 'wb')1001 tmpfile = open(toc_filename, 'wb')
993 for n in xrange(bytes):1002 for n in xrange(bytes):
994 tmpfile.write(filedata)1003 tmpfile.write(filedata)
995 tmpfile.close()1004 tmpfile.close()
996 files = self.setupFiles()1005 files = self.setupFiles()
997 self.assertRaises(AssertionError,1006 self.assertRaises(AssertionError,
998 boards.SnowballEmmcConfig.install_snowball_boot_loader,1007 self.snowball_config.install_snowball_boot_loader,
999 toc_filename, files, "boot_device_or_file",1008 toc_filename, files, "boot_device_or_file",
1000 boards.SnowballEmmcConfig.SNOWBALL_LOADER_START_S)1009 self.snowball_config.SNOWBALL_LOADER_START_S)
10011010
1002 def test_install_snowball_boot_loader_toc_dont_delete(self):1011 def test_install_snowball_boot_loader_toc_dont_delete(self):
1003 fixture = self.useFixture(MockCmdRunnerPopenFixture())1012 fixture = self.useFixture(MockCmdRunnerPopenFixture())
1004 toc_filename = self.createTempFileAsFixture()1013 toc_filename = self.createTempFileAsFixture()
1005 files = self.setupFiles()1014 files = self.setupFiles()
1006 boards.SnowballEmmcConfig.install_snowball_boot_loader(toc_filename,1015 self.snowball_config.install_snowball_boot_loader(toc_filename,
1007 files, "boot_device_or_file",1016 files, "boot_device_or_file",
1008 boards.SnowballEmmcConfig.SNOWBALL_LOADER_START_S)1017 self.snowball_config.SNOWBALL_LOADER_START_S)
1009 expected = [1018 expected = [
1010 '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \1019 '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \
1011 ' seek=%s' % (sudo_args, toc_filename,1020 ' seek=%s' % (sudo_args, toc_filename,
1012 boards.SnowballEmmcConfig.SNOWBALL_LOADER_START_S),1021 self.snowball_config.SNOWBALL_LOADER_START_S),
1013 '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \1022 '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \
1014 ' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path),1023 ' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path),
1015 '%s dd if=%s/boot_image_x-loader.bin of=boot_device_or_file' \1024 '%s dd if=%s/boot_image_x-loader.bin of=boot_device_or_file' \
@@ -1030,13 +1039,13 @@
1030 fixture = self.useFixture(MockCmdRunnerPopenFixture())1039 fixture = self.useFixture(MockCmdRunnerPopenFixture())
1031 toc_filename = self.createTempFileAsFixture()1040 toc_filename = self.createTempFileAsFixture()
1032 files = self.setupFiles()1041 files = self.setupFiles()
1033 boards.SnowballEmmcConfig.install_snowball_boot_loader(toc_filename,1042 self.snowball_config.install_snowball_boot_loader(toc_filename,
1034 files, "boot_device_or_file",1043 files, "boot_device_or_file",
1035 boards.SnowballEmmcConfig.SNOWBALL_LOADER_START_S, True)1044 self.snowball_config.SNOWBALL_LOADER_START_S, True)
1036 expected = [1045 expected = [
1037 '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \1046 '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \
1038 ' seek=%s' % (sudo_args, toc_filename,1047 ' seek=%s' % (sudo_args, toc_filename,
1039 boards.SnowballEmmcConfig.SNOWBALL_LOADER_START_S),1048 self.snowball_config.SNOWBALL_LOADER_START_S),
1040 '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \1049 '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \
1041 ' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path),1050 ' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path),
1042 '%s rm %s/boot_image_issw.bin' % (sudo_args,1051 '%s rm %s/boot_image_issw.bin' % (sudo_args,
@@ -1066,13 +1075,14 @@
1066 fixture = self.useFixture(MockCmdRunnerPopenFixture())1075 fixture = self.useFixture(MockCmdRunnerPopenFixture())
1067 toc_filename = self.createTempFileAsFixture()1076 toc_filename = self.createTempFileAsFixture()
1068 files = self.setupFiles()1077 files = self.setupFiles()
1069 AndroidSnowballEmmcConfig.install_snowball_boot_loader(1078 board_conf = AndroidSnowballEmmcConfig()
1079 board_conf.install_snowball_boot_loader(
1070 toc_filename, files, "boot_device_or_file",1080 toc_filename, files, "boot_device_or_file",
1071 AndroidSnowballEmmcConfig.SNOWBALL_LOADER_START_S)1081 board_conf.SNOWBALL_LOADER_START_S)
1072 expected = [1082 expected = [
1073 '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \1083 '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \
1074 ' seek=%s' % (sudo_args, toc_filename,1084 ' seek=%s' % (sudo_args, toc_filename,
1075 AndroidSnowballEmmcConfig.SNOWBALL_LOADER_START_S),1085 board_conf.SNOWBALL_LOADER_START_S),
1076 '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \1086 '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \
1077 ' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path),1087 ' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path),
1078 '%s dd if=%s/boot_image_x-loader.bin of=boot_device_or_file' \1088 '%s dd if=%s/boot_image_x-loader.bin of=boot_device_or_file' \
@@ -1097,11 +1107,11 @@
1097 k_img_file = os.path.join(self.tempdir, 'vmlinuz-1-ux500')1107 k_img_file = os.path.join(self.tempdir, 'vmlinuz-1-ux500')
1098 i_img_file = os.path.join(self.tempdir, 'initrd.img-1-ux500')1108 i_img_file = os.path.join(self.tempdir, 'initrd.img-1-ux500')
10991109
1100 boot_env = board_configs['snowball_emmc']._get_boot_env(1110 boot_env = self.snowball_config._get_boot_env(
1101 is_live=False, is_lowmem=False, consoles=[],1111 is_live=False, is_lowmem=False, consoles=[],
1102 rootfs_id="UUID=test_boot_env_uuid",1112 rootfs_id="UUID=test_boot_env_uuid",
1103 i_img_data=None, d_img_data=None)1113 i_img_data=None, d_img_data=None)
1104 boards.SnowballEmmcConfig._make_boot_files(boot_env, self.tempdir,1114 self.snowball_config._make_boot_files(boot_env, self.tempdir,
1105 self.temp_bootdir_path, 'boot_device_or_file', k_img_file,1115 self.temp_bootdir_path, 'boot_device_or_file', k_img_file,
1106 i_img_file, None)1116 i_img_file, None)
1107 expected = [1117 expected = [
@@ -1145,12 +1155,12 @@
1145 def test_missing_files(self):1155 def test_missing_files(self):
1146 '''When the files cannot be read, an IOError should be raised'''1156 '''When the files cannot be read, an IOError should be raised'''
1147 self.assertRaises(IOError,1157 self.assertRaises(IOError,
1148 boards.SnowballEmmcConfig.get_file_info,1158 self.snowball_config.get_file_info,
1149 self.tempdir, self.temp_bootdir_path)1159 self.tempdir, self.temp_bootdir_path)
11501160
1151 def test_normal_case(self):1161 def test_normal_case(self):
1152 expected = self.setupFiles()1162 expected = self.setupFiles()
1153 actual = boards.SnowballEmmcConfig.get_file_info(1163 actual = self.snowball_config.get_file_info(
1154 self.tempdir, self.temp_bootdir_path)1164 self.tempdir, self.temp_bootdir_path)
1155 self.assertEquals(expected, actual)1165 self.assertEquals(expected, actual)
11561166
@@ -1161,8 +1171,6 @@
1161 super(TestBootSteps, self).setUp()1171 super(TestBootSteps, self).setUp()
1162 self.funcs_calls = []1172 self.funcs_calls = []
1163 self.mock_all_boards_funcs()1173 self.mock_all_boards_funcs()
1164 boards = linaro_image_tools.media_create.boards
1165 boards.BoardConfig.hwpack_format = '1.0'
11661174
1167 def mock_all_boards_funcs(self):1175 def mock_all_boards_funcs(self):
1168 """Mock functions of boards module with a call tracer."""1176 """Mock functions of boards module with a call tracer."""
@@ -1179,169 +1187,174 @@
11791187
1180 def mock_set_appropriate_serial_tty(self, config):1188 def mock_set_appropriate_serial_tty(self, config):
11811189
1182 def set_appropriate_serial_tty_mock(cls, chroot_dir):1190 def set_appropriate_serial_tty_mock(chroot_dir):
1183 cls.serial_tty = cls._serial_tty1191 config.serial_tty = config._serial_tty
11841192
1185 self.useFixture(MockSomethingFixture(1193 config.set_appropriate_serial_tty = MagicMock(
1186 config, 'set_appropriate_serial_tty',1194 side_effect=set_appropriate_serial_tty_mock)
1187 classmethod(set_appropriate_serial_tty_mock)))
11881195
1189 def make_boot_files(self, config):1196 def make_boot_files(self, config):
1190 def _get_kflavor_files_mock(cls, path):1197 def _get_kflavor_files_mock(path):
1191 if cls.dtb_name is None:1198 if config.dtb_name is None:
1192 return (path, path, None)1199 return (path, path, None)
1193 return (path, path, path)1200 return (path, path, path)
11941201
1195 self.useFixture(MockSomethingFixture(1202 config._get_kflavor_files = MagicMock(
1196 config, '_get_kflavor_files',1203 side_effect=_get_kflavor_files_mock)
1197 classmethod(_get_kflavor_files_mock)))
11981204
1199 config.make_boot_files('', False, False, [], '', '', '', '')1205 config.make_boot_files('', False, False, [], '', '', '', '')
12001206
1201 def test_vexpress_steps(self):1207 def test_vexpress_steps(self):
1202 self.make_boot_files(boards.VexpressConfig)1208 board_conf = boards.VexpressConfig()
1209 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1210 self.make_boot_files(board_conf)
1203 expected = ['make_uImage', 'make_uInitrd']1211 expected = ['make_uImage', 'make_uInitrd']
1204 self.assertEqual(expected, self.funcs_calls)1212 self.assertEqual(expected, self.funcs_calls)
12051213
1206 def test_vexpress_a9_steps(self):1214 def test_vexpress_a9_steps(self):
1207 self.make_boot_files(boards.VexpressA9Config)1215 board_conf = boards.VexpressA9Config()
1216 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1217 self.make_boot_files(board_conf)
1208 expected = ['make_uImage', 'make_uInitrd']1218 expected = ['make_uImage', 'make_uInitrd']
1209 self.assertEqual(expected, self.funcs_calls)1219 self.assertEqual(expected, self.funcs_calls)
12101220
1211 def test_mx5_steps(self):1221 def test_mx5_steps(self):
1212 class SomeMx5Config(boards.Mx5Config):1222 board_conf = boards.Mx5Config()
1213 bootloader_flavor = 'bootloader_flavor'1223 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1214 SomeMx5Config.hardwarepack_handler = (1224 board_conf.bootloader_flavor = 'bootloader_flavor'
1225 board_conf.hardwarepack_handler = (
1215 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))1226 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
1216 SomeMx5Config.hardwarepack_handler.get_format = (1227 board_conf.hardwarepack_handler.get_format = (
1217 lambda: '1.0')1228 lambda: HardwarepackHandler.FORMAT_1)
1218 self.make_boot_files(SomeMx5Config)1229 self.make_boot_files(board_conf)
1219 expected = [1230 expected = [
1220 'install_mx5_boot_loader', 'make_uImage', 'make_uInitrd',1231 'install_mx5_boot_loader', 'make_uImage', 'make_uInitrd',
1221 'make_dtb', 'make_boot_script']1232 'make_dtb', 'make_boot_script']
1222 self.assertEqual(expected, self.funcs_calls)1233 self.assertEqual(expected, self.funcs_calls)
12231234
1224 def test_smdkv310_steps(self):1235 def test_smdkv310_steps(self):
1225 def mock_func_creator(name):1236 board_conf = boards.SMDKV310Config()
1226 return classmethod(1237 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1227 lambda *args, **kwargs: self.funcs_calls.append(name))1238 board_conf.install_samsung_boot_loader = MagicMock()
12281239 board_conf.install_samsung_boot_loader.return_value = \
1229 self.useFixture(MockSomethingFixture(1240 self.funcs_calls.append('install_samsung_boot_loader')
1230 linaro_image_tools.media_create.boards.SMDKV310Config,
1231 'install_samsung_boot_loader',
1232 mock_func_creator('install_samsung_boot_loader')))
1233 self.useFixture(MockSomethingFixture(os.path, 'exists',1241 self.useFixture(MockSomethingFixture(os.path, 'exists',
1234 lambda file: True))1242 lambda file: True))
1235 boards.SMDKV310Config.hardwarepack_handler = (1243 board_conf.hardwarepack_handler = (
1236 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))1244 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
1237 boards.SMDKV310Config.hardwarepack_handler.get_format = (1245 board_conf.hardwarepack_handler.get_format = (
1238 lambda: '1.0')1246 lambda: HardwarepackHandler.FORMAT_1)
1239 self.make_boot_files(boards.SMDKV310Config)1247 self.make_boot_files(board_conf)
1240 expected = [1248 expected = [
1241 'install_samsung_boot_loader', 'make_flashable_env', '_dd',1249 'install_samsung_boot_loader', 'make_flashable_env', '_dd',
1242 'make_uImage', 'make_uInitrd', 'make_boot_script']1250 'make_uImage', 'make_uInitrd', 'make_boot_script']
1243 self.assertEqual(expected, self.funcs_calls)1251 self.assertEqual(expected, self.funcs_calls)
12441252
1245 def test_origen_steps(self):1253 def test_origen_steps(self):
1246 def mock_func_creator(name):1254 board_conf = boards.OrigenConfig()
1247 return classmethod(1255 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1248 lambda *args, **kwargs: self.funcs_calls.append(name))1256 board_conf.install_samsung_boot_loader = MagicMock()
12491257 board_conf.install_samsung_boot_loader.return_value = \
1250 self.useFixture(MockSomethingFixture(1258 self.funcs_calls.append('install_samsung_boot_loader')
1251 linaro_image_tools.media_create.boards.OrigenConfig,
1252 'install_samsung_boot_loader',
1253 mock_func_creator('install_samsung_boot_loader')))
1254 self.useFixture(MockSomethingFixture(os.path, 'exists',1259 self.useFixture(MockSomethingFixture(os.path, 'exists',
1255 lambda file: True))1260 lambda file: True))
1256 boards.OrigenConfig.hardwarepack_handler = (1261 board_conf.hardwarepack_handler = (
1257 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))1262 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
1258 boards.OrigenConfig.hardwarepack_handler.get_format = (1263 board_conf.hardwarepack_handler.get_format = (
1259 lambda: '1.0')1264 lambda: HardwarepackHandler.FORMAT_1)
1260 self.make_boot_files(boards.OrigenConfig)1265 self.make_boot_files(board_conf)
1261 expected = [1266 expected = [
1262 'install_samsung_boot_loader', 'make_flashable_env', '_dd',1267 'install_samsung_boot_loader', 'make_flashable_env', '_dd',
1263 'make_uImage', 'make_uInitrd', 'make_boot_script']1268 'make_uImage', 'make_uInitrd', 'make_boot_script']
1264 self.assertEqual(expected, self.funcs_calls)1269 self.assertEqual(expected, self.funcs_calls)
12651270
1266 def test_origen_quad_steps(self):1271 def test_origen_quad_steps(self):
1267 def mock_func_creator(name):1272 board_conf = boards.OrigenQuadConfig()
1268 return classmethod(1273 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1269 lambda *args, **kwargs: self.funcs_calls.append(name))1274 board_conf.install_samsung_boot_loader = MagicMock()
1275 board_conf.install_samsung_boot_loader.return_value = \
1276 self.funcs_calls.append('install_samsung_boot_loader')
12701277
1271 self.useFixture(MockSomethingFixture(
1272 linaro_image_tools.media_create.boards.OrigenQuadConfig,
1273 'install_samsung_boot_loader',
1274 mock_func_creator('install_samsung_boot_loader')))
1275 self.useFixture(MockSomethingFixture(os.path, 'exists',1278 self.useFixture(MockSomethingFixture(os.path, 'exists',
1276 lambda file: True))1279 lambda file: True))
1277 boards.OrigenQuadConfig.hardwarepack_handler = (1280 board_conf.hardwarepack_handler = (
1278 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))1281 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
1279 boards.OrigenQuadConfig.hardwarepack_handler.get_format = (1282 board_conf.hardwarepack_handler.get_format = (
1280 lambda: '1.0')1283 lambda: HardwarepackHandler.FORMAT_1)
1281 self.make_boot_files(boards.OrigenQuadConfig)1284 self.make_boot_files(board_conf)
1282 expected = [1285 expected = [
1283 'install_samsung_boot_loader', 'make_flashable_env', '_dd',1286 'install_samsung_boot_loader', 'make_flashable_env', '_dd',
1284 'make_uImage', 'make_uInitrd', 'make_boot_script']1287 'make_uImage', 'make_uInitrd', 'make_boot_script']
1285 self.assertEqual(expected, self.funcs_calls)1288 self.assertEqual(expected, self.funcs_calls)
12861289
1287 def test_arndale_steps(self):1290 def test_arndale_steps(self):
1288 def mock_func_creator(name):1291 board_conf = boards.ArndaleConfig()
1289 return classmethod(1292 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1290 lambda *args, **kwargs: self.funcs_calls.append(name))1293 board_conf.install_samsung_boot_loader = MagicMock()
1294 board_conf.install_samsung_boot_loader.return_value = \
1295 self.funcs_calls.append('install_samsung_boot_loader')
12911296
1292 self.useFixture(MockSomethingFixture(
1293 linaro_image_tools.media_create.boards.ArndaleConfig,
1294 'install_samsung_boot_loader',
1295 mock_func_creator('install_samsung_boot_loader')))
1296 self.useFixture(MockSomethingFixture(os.path, 'exists',1297 self.useFixture(MockSomethingFixture(os.path, 'exists',
1297 lambda file: True))1298 lambda file: True))
1298 boards.ArndaleConfig.hardwarepack_handler = (1299 board_conf.hardwarepack_handler = (
1299 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))1300 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
1300 boards.ArndaleConfig.hardwarepack_handler.get_format = (1301 board_conf.hardwarepack_handler.get_format = (
1301 lambda: '1.0')1302 lambda: '1.0')
1302 self.make_boot_files(boards.ArndaleConfig)1303 self.make_boot_files(board_conf)
1303 expected = [1304 expected = [
1304 'install_samsung_boot_loader', 'make_flashable_env', '_dd',1305 'install_samsung_boot_loader', 'make_flashable_env', '_dd',
1305 'make_uImage', 'make_uInitrd', 'make_boot_script']1306 'make_uImage', 'make_uInitrd', 'make_boot_script']
1306 self.assertEqual(expected, self.funcs_calls)1307 self.assertEqual(expected, self.funcs_calls)
13071308
1308 def test_ux500_steps(self):1309 def test_ux500_steps(self):
1309 self.make_boot_files(boards.Ux500Config)1310 board_conf = boards.Ux500Config()
1311 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1312 self.make_boot_files(board_conf)
1310 expected = ['make_uImage', 'make_uInitrd', 'make_boot_script']1313 expected = ['make_uImage', 'make_uInitrd', 'make_boot_script']
1311 self.assertEqual(expected, self.funcs_calls)1314 self.assertEqual(expected, self.funcs_calls)
13121315
1313 def test_snowball_sd_steps(self):1316 def test_snowball_sd_steps(self):
1314 self.make_boot_files(boards.SnowballSdConfig)1317 board_conf = boards.SnowballSdConfig()
1318 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1319 self.make_boot_files(board_conf)
1315 expected = ['make_uImage', 'make_boot_script']1320 expected = ['make_uImage', 'make_boot_script']
1316 self.assertEqual(expected, self.funcs_calls)1321 self.assertEqual(expected, self.funcs_calls)
13171322
1318 def test_panda_steps(self):1323 def test_panda_steps(self):
1319 self.mock_set_appropriate_serial_tty(boards.PandaConfig)1324 board_conf = boards.PandaConfig()
1320 self.make_boot_files(boards.PandaConfig)1325 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1326 self.mock_set_appropriate_serial_tty(board_conf)
1327 self.make_boot_files(board_conf)
1321 expected = [1328 expected = [
1322 'install_omap_boot_loader', 'make_uImage', 'make_uInitrd',1329 'install_omap_boot_loader', 'make_uImage', 'make_uInitrd',
1323 'make_dtb', 'make_boot_script', 'make_boot_ini']1330 'make_dtb', 'make_boot_script', 'make_boot_ini']
1324 self.assertEqual(expected, self.funcs_calls)1331 self.assertEqual(expected, self.funcs_calls)
13251332
1326 def test_beagle_steps(self):1333 def test_beagle_steps(self):
1327 self.mock_set_appropriate_serial_tty(boards.BeagleConfig)1334 board_conf = boards.BeagleConfig()
1328 self.make_boot_files(boards.BeagleConfig)1335 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1336 self.mock_set_appropriate_serial_tty(board_conf)
1337 self.make_boot_files(board_conf)
1329 expected = [1338 expected = [
1330 'install_omap_boot_loader', 'make_uImage', 'make_uInitrd',1339 'install_omap_boot_loader', 'make_uImage', 'make_uInitrd',
1331 'make_dtb', 'make_boot_script', 'make_boot_ini']1340 'make_dtb', 'make_boot_script', 'make_boot_ini']
1332 self.assertEqual(expected, self.funcs_calls)1341 self.assertEqual(expected, self.funcs_calls)
13331342
1334 def test_igep_steps(self):1343 def test_igep_steps(self):
1335 self.mock_set_appropriate_serial_tty(boards.IgepConfig)1344 board_conf = boards.IgepConfig()
1336 self.make_boot_files(boards.IgepConfig)1345 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1346 self.mock_set_appropriate_serial_tty(board_conf)
1347 self.make_boot_files(board_conf)
1337 expected = [1348 expected = [
1338 'make_uImage', 'make_uInitrd', 'make_dtb', 'make_boot_script',1349 'make_uImage', 'make_uInitrd', 'make_dtb', 'make_boot_script',
1339 'make_boot_ini']1350 'make_boot_ini']
1340 self.assertEqual(expected, self.funcs_calls)1351 self.assertEqual(expected, self.funcs_calls)
13411352
1342 def test_overo_steps(self):1353 def test_overo_steps(self):
1343 self.mock_set_appropriate_serial_tty(boards.OveroConfig)1354 board_conf = boards.OveroConfig()
1344 self.make_boot_files(boards.OveroConfig)1355 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1356 self.mock_set_appropriate_serial_tty(board_conf)
1357 self.make_boot_files(board_conf)
1345 expected = [1358 expected = [
1346 'install_omap_boot_loader', 'make_uImage', 'make_uInitrd',1359 'install_omap_boot_loader', 'make_uImage', 'make_uInitrd',
1347 'make_dtb', 'make_boot_script', 'make_boot_ini']1360 'make_dtb', 'make_boot_script', 'make_boot_ini']
@@ -1373,20 +1386,20 @@
13731386
1374 def test_snowball_config_raises(self):1387 def test_snowball_config_raises(self):
1375 self.assertRaises(NotImplementedError,1388 self.assertRaises(NotImplementedError,
1376 boards.SnowballSdConfig.snowball_config, '')1389 boards.SnowballSdConfig().snowball_config, '')
13771390
1378 def test_beagle_raw(self):1391 def test_beagle_raw(self):
1379 self.populate_raw_partition(android_boards.AndroidBeagleConfig)1392 self.populate_raw_partition(android_boards.AndroidBeagleConfig())
1380 expected = []1393 expected = []
1381 self.assertEqual(expected, self.funcs_calls)1394 self.assertEqual(expected, self.funcs_calls)
13821395
1383 def test_panda_raw(self):1396 def test_panda_raw(self):
1384 self.populate_raw_partition(android_boards.AndroidPandaConfig)1397 self.populate_raw_partition(android_boards.AndroidPandaConfig())
1385 expected = []1398 expected = []
1386 self.assertEqual(expected, self.funcs_calls)1399 self.assertEqual(expected, self.funcs_calls)
13871400
1388 def test_snowball_sd_raw(self):1401 def test_snowball_sd_raw(self):
1389 self.populate_raw_partition(boards.SnowballSdConfig)1402 self.populate_raw_partition(boards.SnowballSdConfig())
1390 expected = []1403 expected = []
1391 self.assertEqual(expected, self.funcs_calls)1404 self.assertEqual(expected, self.funcs_calls)
13921405
@@ -1411,7 +1424,7 @@
1411 linaro_image_tools.media_create.boards.SnowballEmmcConfig,1424 linaro_image_tools.media_create.boards.SnowballEmmcConfig,
1412 'delete_file',1425 'delete_file',
1413 mock_func_creator('delete_file')))1426 mock_func_creator('delete_file')))
1414 self.populate_raw_partition(boards.SnowballEmmcConfig)1427 self.populate_raw_partition(boards.SnowballEmmcConfig())
1415 expected = ['get_file_info', 'create_toc',1428 expected = ['get_file_info', 'create_toc',
1416 'install_snowball_boot_loader', 'delete_file',1429 'install_snowball_boot_loader', 'delete_file',
1417 'delete_file']1430 'delete_file']
@@ -1423,12 +1436,12 @@
1423 self.useFixture(MockSomethingFixture(os.path, 'getsize',1436 self.useFixture(MockSomethingFixture(os.path, 'getsize',
1424 lambda file: 1))1437 lambda file: 1))
14251438
1426 self.populate_raw_partition(boards.SMDKV310Config)1439 self.populate_raw_partition(boards.SMDKV310Config())
1427 expected = ['_dd', '_dd', '_dd']1440 expected = ['_dd', '_dd', '_dd']
1428 self.assertEqual(expected, self.funcs_calls)1441 self.assertEqual(expected, self.funcs_calls)
14291442
1430 def test_mx53loco_raw(self):1443 def test_mx53loco_raw(self):
1431 self.populate_raw_partition(boards.Mx53LoCoConfig)1444 self.populate_raw_partition(boards.Mx53LoCoConfig())
1432 expected = []1445 expected = []
1433 self.assertEqual(expected, self.funcs_calls)1446 self.assertEqual(expected, self.funcs_calls)
14341447
@@ -1436,7 +1449,7 @@
1436 self.useFixture(MockSomethingFixture(os.path, 'getsize',1449 self.useFixture(MockSomethingFixture(os.path, 'getsize',
1437 lambda file: 1))1450 lambda file: 1))
14381451
1439 self.populate_raw_partition(boards.OrigenConfig)1452 self.populate_raw_partition(boards.OrigenConfig())
1440 expected = ['_dd', '_dd', '_dd']1453 expected = ['_dd', '_dd', '_dd']
1441 self.assertEqual(expected, self.funcs_calls)1454 self.assertEqual(expected, self.funcs_calls)
14421455
@@ -1444,7 +1457,7 @@
1444 self.useFixture(MockSomethingFixture(os.path, 'getsize',1457 self.useFixture(MockSomethingFixture(os.path, 'getsize',
1445 lambda file: 1))1458 lambda file: 1))
14461459
1447 self.populate_raw_partition(boards.OrigenQuadConfig)1460 self.populate_raw_partition(boards.OrigenQuadConfig())
1448 expected = ['_dd', '_dd', '_dd']1461 expected = ['_dd', '_dd', '_dd']
1449 self.assertEqual(expected, self.funcs_calls)1462 self.assertEqual(expected, self.funcs_calls)
14501463
@@ -1452,12 +1465,12 @@
1452 self.useFixture(MockSomethingFixture(os.path, 'getsize',1465 self.useFixture(MockSomethingFixture(os.path, 'getsize',
1453 lambda file: 1))1466 lambda file: 1))
14541467
1455 self.populate_raw_partition(boards.ArndaleConfig)1468 self.populate_raw_partition(boards.ArndaleConfig())
1456 expected = ['_dd', '_dd', '_dd']1469 expected = ['_dd', '_dd', '_dd']
1457 self.assertEqual(expected, self.funcs_calls)1470 self.assertEqual(expected, self.funcs_calls)
14581471
1459 def test_vexpress_a9_raw(self):1472 def test_vexpress_a9_raw(self):
1460 self.populate_raw_partition(boards.VexpressA9Config)1473 self.populate_raw_partition(boards.VexpressA9Config())
1461 expected = []1474 expected = []
1462 self.assertEqual(expected, self.funcs_calls)1475 self.assertEqual(expected, self.funcs_calls)
14631476
@@ -1472,17 +1485,17 @@
1472 config.populate_raw_partition('', '')1485 config.populate_raw_partition('', '')
14731486
1474 def test_beagle_raw(self):1487 def test_beagle_raw(self):
1475 self.populate_raw_partition(android_boards.AndroidBeagleConfig)1488 self.populate_raw_partition(android_boards.AndroidBeagleConfig())
1476 expected = []1489 expected = []
1477 self.assertEqual(expected, self.funcs_calls)1490 self.assertEqual(expected, self.funcs_calls)
14781491
1479 def test_panda_raw(self):1492 def test_panda_raw(self):
1480 self.populate_raw_partition(android_boards.AndroidPandaConfig)1493 self.populate_raw_partition(android_boards.AndroidPandaConfig())
1481 expected = []1494 expected = []
1482 self.assertEqual(expected, self.funcs_calls)1495 self.assertEqual(expected, self.funcs_calls)
14831496
1484 def test_snowball_sd_raw(self):1497 def test_snowball_sd_raw(self):
1485 self.populate_raw_partition(android_boards.AndroidSnowballSdConfig)1498 self.populate_raw_partition(android_boards.AndroidSnowballSdConfig())
1486 expected = []1499 expected = []
1487 self.assertEqual(expected, self.funcs_calls)1500 self.assertEqual(expected, self.funcs_calls)
14881501
@@ -1513,7 +1526,7 @@
1513 android_boards.AndroidSnowballEmmcConfig,1526 android_boards.AndroidSnowballEmmcConfig,
1514 'delete_file',1527 'delete_file',
1515 mock_func_creator('delete_file')))1528 mock_func_creator('delete_file')))
1516 self.populate_raw_partition(android_boards.AndroidSnowballEmmcConfig)1529 self.populate_raw_partition(android_boards.AndroidSnowballEmmcConfig())
1517 expected_calls = ['get_file_info', 'create_toc',1530 expected_calls = ['get_file_info', 'create_toc',
1518 'install_snowball_boot_loader', 'delete_file']1531 'install_snowball_boot_loader', 'delete_file']
1519 # Test that we copy the u-boot files to the local startupfiles dir.1532 # Test that we copy the u-boot files to the local startupfiles dir.
@@ -1533,14 +1546,14 @@
1533 self.useFixture(MockSomethingFixture(os.path, 'getsize',1546 self.useFixture(MockSomethingFixture(os.path, 'getsize',
1534 lambda file: 1))1547 lambda file: 1))
15351548
1536 self.populate_raw_partition(android_boards.AndroidSMDKV310Config)1549 self.populate_raw_partition(android_boards.AndroidSMDKV310Config())
1537 expected_calls = []1550 expected_calls = []
1538 # Test that we dd the files1551 # Test that we dd the files
1539 self.assertEqual(expected_commands, fixture.mock.commands_executed)1552 self.assertEqual(expected_commands, fixture.mock.commands_executed)
1540 self.assertEqual(expected_calls, self.funcs_calls)1553 self.assertEqual(expected_calls, self.funcs_calls)
15411554
1542 def test_mx53loco_raw(self):1555 def test_mx53loco_raw(self):
1543 self.populate_raw_partition(android_boards.AndroidMx53LoCoConfig)1556 self.populate_raw_partition(android_boards.AndroidMx53LoCoConfig())
1544 expected = []1557 expected = []
1545 self.assertEqual(expected, self.funcs_calls)1558 self.assertEqual(expected, self.funcs_calls)
15461559
@@ -1555,7 +1568,7 @@
1555 self.useFixture(MockSomethingFixture(os.path, 'getsize',1568 self.useFixture(MockSomethingFixture(os.path, 'getsize',
1556 lambda file: 1))1569 lambda file: 1))
15571570
1558 self.populate_raw_partition(android_boards.AndroidOrigenConfig)1571 self.populate_raw_partition(android_boards.AndroidOrigenConfig())
1559 expected = []1572 expected = []
1560 # Test that we dd the files1573 # Test that we dd the files
1561 self.assertEqual(expected_commands, fixture.mock.commands_executed)1574 self.assertEqual(expected_commands, fixture.mock.commands_executed)
@@ -1573,14 +1586,14 @@
1573 self.useFixture(MockSomethingFixture(os.path, 'getsize',1586 self.useFixture(MockSomethingFixture(os.path, 'getsize',
1574 lambda file: 1))1587 lambda file: 1))
15751588
1576 self.populate_raw_partition(android_boards.AndroidOrigenQuadConfig)1589 self.populate_raw_partition(android_boards.AndroidOrigenQuadConfig())
1577 expected = []1590 expected = []
1578 # Test that we dd the files1591 # Test that we dd the files
1579 self.assertEqual(expected_commands, fixture.mock.commands_executed)1592 self.assertEqual(expected_commands, fixture.mock.commands_executed)
1580 self.assertEqual(expected, self.funcs_calls)1593 self.assertEqual(expected, self.funcs_calls)
15811594
1582 def test_vexpress_raw(self):1595 def test_vexpress_raw(self):
1583 self.populate_raw_partition(android_boards.AndroidVexpressConfig)1596 self.populate_raw_partition(android_boards.AndroidVexpressConfig())
1584 expected = []1597 expected = []
1585 self.assertEqual(expected, self.funcs_calls)1598 self.assertEqual(expected, self.funcs_calls)
15861599
@@ -1611,25 +1624,29 @@
16111624
1612 def mock_set_appropriate_serial_tty(self, config):1625 def mock_set_appropriate_serial_tty(self, config):
16131626
1614 def set_appropriate_serial_tty_mock(cls, chroot_dir):1627 def set_appropriate_serial_tty_mock(arg):
1615 self.set_appropriate_serial_tty_called = True1628 self.set_appropriate_serial_tty_called = True
1616 cls.serial_tty = cls._serial_tty
16171629
1618 self.useFixture(MockSomethingFixture(1630 # Need to mock all the calls done from make_boot_files in order
1619 config, 'set_appropriate_serial_tty',1631 # to be able to correctly call it.
1620 classmethod(set_appropriate_serial_tty_mock)))1632 config._get_kflavor_files = MagicMock(return_value=('', '', ''))
1633 config._get_boot_env = MagicMock(return_value=None)
1634 config._make_boot_files = MagicMock()
1635 config._make_boot_files_v2 = MagicMock()
1636 config.set_appropriate_serial_tty = MagicMock(
1637 side_effect=set_appropriate_serial_tty_mock)
16211638
1622 def test_omap_make_boot_files(self):1639 def test_omap_make_boot_files(self):
1623 self.set_appropriate_serial_tty_called = False1640 self.set_appropriate_serial_tty_called = False
1624 self.mock_set_appropriate_serial_tty(board_configs['beagle'])1641
1625 self.useFixture(MockSomethingFixture(1642 board_conf = boards.BeagleConfig()
1626 boards.BoardConfig, 'make_boot_files',1643 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1627 classmethod(lambda *args: None)))1644 self.mock_set_appropriate_serial_tty(board_conf)
1628 # We don't need to worry about what's passed to make_boot_files()1645 # We don't need to worry about what's passed to make_boot_files()
1629 # because we mock the method which does the real work above and here1646 # because we mock the method which does the real work above and here
1630 # we're only interested in ensuring that OmapConfig.make_boot_files()1647 # we're only interested in ensuring that OmapConfig.make_boot_files()
1631 # calls set_appropriate_serial_tty().1648 # calls set_appropriate_serial_tty().
1632 board_configs['beagle'].make_boot_files(1649 board_conf.make_boot_files(
1633 None, None, None, None, None, None, None, None)1650 None, None, None, None, None, None, None, None)
1634 self.assertTrue(1651 self.assertTrue(
1635 self.set_appropriate_serial_tty_called,1652 self.set_appropriate_serial_tty_called,
@@ -1638,17 +1655,14 @@
1638 def test_omap_make_boot_files_v2(self):1655 def test_omap_make_boot_files_v2(self):
1639 self.set_appropriate_serial_tty_called = False1656 self.set_appropriate_serial_tty_called = False
16401657
1641 class config(boards.BeagleConfig):1658 board_conf = boards.BeagleConfig()
1642 hwpack_format = HardwarepackHandler.FORMAT_21659 board_conf.hwpack_format = HardwarepackHandler.FORMAT_2
1643 self.mock_set_appropriate_serial_tty(config)1660 self.mock_set_appropriate_serial_tty(board_conf)
1644 self.useFixture(MockSomethingFixture(
1645 boards.BoardConfig, 'make_boot_files',
1646 classmethod(lambda *args: None)))
1647 # We don't need to worry about what's passed to make_boot_files()1661 # We don't need to worry about what's passed to make_boot_files()
1648 # because we mock the method which does the real work above and here1662 # because we mock the method which does the real work above and here
1649 # we're only interested in ensuring that OmapConfig.make_boot_files()1663 # we're only interested in ensuring that OmapConfig.make_boot_files()
1650 # does not call set_appropriate_serial_tty().1664 # does not call set_appropriate_serial_tty().
1651 config.make_boot_files(1665 board_conf.make_boot_files(
1652 None, None, None, None, None, None, None, None)1666 None, None, None, None, None, None, None, None)
1653 self.assertFalse(1667 self.assertFalse(
1654 self.set_appropriate_serial_tty_called,1668 self.set_appropriate_serial_tty_called,
@@ -1659,189 +1673,219 @@
1659 boot_dir = os.path.join(tempdir, 'boot')1673 boot_dir = os.path.join(tempdir, 'boot')
1660 os.makedirs(boot_dir)1674 os.makedirs(boot_dir)
1661 open(os.path.join(boot_dir, 'vmlinuz-2.6.35-23-foo'), 'w').close()1675 open(os.path.join(boot_dir, 'vmlinuz-2.6.35-23-foo'), 'w').close()
1662 boards.BeagleConfig.set_appropriate_serial_tty(tempdir)1676 board_conf = boards.BeagleConfig()
1663 self.assertEquals('ttyS2', boards.BeagleConfig.serial_tty)1677 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1678 board_conf.set_appropriate_serial_tty(tempdir)
1679 self.assertEquals('ttyS2', board_conf.serial_tty)
16641680
1665 def test_set_appropriate_serial_tty_new_kernel(self):1681 def test_set_appropriate_serial_tty_new_kernel(self):
1666 tempdir = self.useFixture(CreateTempDirFixture()).tempdir1682 tempdir = self.useFixture(CreateTempDirFixture()).tempdir
1667 boot_dir = os.path.join(tempdir, 'boot')1683 boot_dir = os.path.join(tempdir, 'boot')
1668 os.makedirs(boot_dir)1684 os.makedirs(boot_dir)
1669 open(os.path.join(boot_dir, 'vmlinuz-2.6.36-13-foo'), 'w').close()1685 open(os.path.join(boot_dir, 'vmlinuz-2.6.36-13-foo'), 'w').close()
1670 boards.BeagleConfig.set_appropriate_serial_tty(tempdir)1686 board_conf = boards.BeagleConfig()
1671 self.assertEquals('ttyO2', boards.BeagleConfig.serial_tty)1687 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1688 board_conf.set_appropriate_serial_tty(tempdir)
1689 self.assertEquals('ttyO2', board_conf.serial_tty)
16721690
1673 def test_set_appropriate_serial_tty_three_dot_oh_kernel(self):1691 def test_set_appropriate_serial_tty_three_dot_oh_kernel(self):
1674 tempdir = self.useFixture(CreateTempDirFixture()).tempdir1692 tempdir = self.useFixture(CreateTempDirFixture()).tempdir
1675 boot_dir = os.path.join(tempdir, 'boot')1693 boot_dir = os.path.join(tempdir, 'boot')
1676 os.makedirs(boot_dir)1694 os.makedirs(boot_dir)
1677 open(os.path.join(boot_dir, 'vmlinuz-3.0-13-foo'), 'w').close()1695 open(os.path.join(boot_dir, 'vmlinuz-3.0-13-foo'), 'w').close()
1678 boards.BeagleConfig.set_appropriate_serial_tty(tempdir)1696 board_conf = boards.BeagleConfig()
1679 self.assertEquals('ttyO2', boards.BeagleConfig.serial_tty)1697 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1698 board_conf.set_appropriate_serial_tty(tempdir)
1699 self.assertEquals('ttyO2', board_conf.serial_tty)
16801700
16811701
1682class TestGetSfdiskCmd(TestCase):1702class TestGetSfdiskCmd(TestCase):
16831703
1704 def set_up_config(self, config):
1705 config.hwpack_format = HardwarepackHandler.FORMAT_1
1706
1684 def test_default(self):1707 def test_default(self):
1708 board_conf = BoardConfig()
1709 self.set_up_config(board_conf)
1685 self.assertEqual(1710 self.assertEqual(
1686 '63,106432,0x0C,*\n106496,,,-',1711 '63,106432,0x0C,*\n106496,,,-', board_conf.get_sfdisk_cmd())
1687 boards.BoardConfig.get_sfdisk_cmd())
16881712
1689 def test_default_aligned(self):1713 def test_default_aligned(self):
1714 board_conf = BoardConfig()
1715 self.set_up_config(board_conf)
1690 self.assertEqual(1716 self.assertEqual(
1691 '8192,106496,0x0C,*\n114688,,,-',1717 '8192,106496,0x0C,*\n114688,,,-',
1692 boards.BoardConfig.get_sfdisk_cmd(should_align_boot_part=True))1718 board_conf.get_sfdisk_cmd(should_align_boot_part=True))
16931719
1694 def test_mx5(self):1720 def test_mx5(self):
1721 board_conf = boards.Mx5Config()
1722 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
1695 self.assertEqual(1723 self.assertEqual(
1696 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',1724 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
1697 boards.Mx5Config.get_sfdisk_cmd())1725 board_conf.get_sfdisk_cmd())
16981726
1699 def test_snowball_sd(self):1727 def test_snowball_sd(self):
1728 board_conf = boards.SnowballSdConfig()
1729 self.set_up_config(board_conf)
1700 self.assertEqual(1730 self.assertEqual(
1701 '63,106432,0x0C,*\n106496,,,-',1731 '63,106432,0x0C,*\n106496,,,-', board_conf.get_sfdisk_cmd())
1702 boards.SnowballSdConfig.get_sfdisk_cmd())
17031732
1704 def test_snowball_emmc(self):1733 def test_snowball_emmc(self):
1734 board_conf = boards.SnowballEmmcConfig()
1735 self.set_up_config(board_conf)
1705 self.assertEqual(1736 self.assertEqual(
1706 '256,7936,0xDA\n8192,106496,0x0C,*\n114688,,,-',1737 '256,7936,0xDA\n8192,106496,0x0C,*\n114688,,,-',
1707 boards.SnowballEmmcConfig.get_sfdisk_cmd())1738 board_conf.get_sfdisk_cmd())
17081739
1709 def test_smdkv310(self):1740 def test_smdkv310(self):
1741 board_conf = get_board_config('smdkv310')
1742 self.set_up_config(board_conf)
1710 self.assertEquals(1743 self.assertEquals(
1711 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',1744 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
1712 board_configs['smdkv310'].get_sfdisk_cmd())1745 board_conf.get_sfdisk_cmd())
17131746
1714 def test_origen(self):1747 def test_origen(self):
1748 board_conf = get_board_config('origen')
1749 self.set_up_config(board_conf)
1715 self.assertEquals(1750 self.assertEquals(
1716 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',1751 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
1717 board_configs['origen'].get_sfdisk_cmd())1752 board_conf.get_sfdisk_cmd())
17181753
1719 def test_origen_quad(self):1754 def test_origen_quad(self):
1755 board_conf = get_board_config('origen_quad')
1756 self.set_up_config(board_conf)
1720 self.assertEquals(1757 self.assertEquals(
1721 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',1758 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
1722 board_configs['origen_quad'].get_sfdisk_cmd())1759 board_conf.get_sfdisk_cmd())
17231760
1724 def test_arndale(self):1761 def test_arndale(self):
1762 board_conf = get_board_config('arndale')
1763 self.set_up_config(board_conf)
1725 self.assertEquals(1764 self.assertEquals(
1726 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',1765 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
1727 board_configs['arndale'].get_sfdisk_cmd())1766 board_conf.get_sfdisk_cmd())
17281767
1729 def test_panda_android(self):1768 def test_panda_android(self):
1730 self.assertEqual(1769 self.assertEqual(
1731 '63,270272,0x0C,*\n270336,1048576,L\n1318912,524288,L\n'1770 '63,270272,0x0C,*\n270336,1048576,L\n1318912,524288,L\n'
1732 '1843200,-,E\n1843200,1048576,L\n2891776,,,-',1771 '1843200,-,E\n1843200,1048576,L\n2891776,,,-',
1733 android_boards.AndroidPandaConfig.get_sfdisk_cmd())1772 android_boards.AndroidPandaConfig().get_sfdisk_cmd())
17341773
1735 def test_origen_android(self):1774 def test_origen_android(self):
1736 self.assertEqual(1775 self.assertEqual(
1737 '1,8191,0xDA\n8253,270274,0x0C,*\n278528,1048576,L\n'1776 '1,8191,0xDA\n8253,270274,0x0C,*\n278528,1048576,L\n'
1738 '1327104,-,E\n1327104,524288,L\n1851392,1048576,L\n2899968,,,-',1777 '1327104,-,E\n1327104,524288,L\n1851392,1048576,L\n2899968,,,-',
1739 android_boards.AndroidOrigenConfig.get_sfdisk_cmd())1778 android_boards.AndroidOrigenConfig().get_sfdisk_cmd())
17401779
1741 def test_origen_quad_android(self):1780 def test_origen_quad_android(self):
1742 self.assertEqual(1781 self.assertEqual(
1743 '1,8191,0xDA\n8253,270274,0x0C,*\n278528,1048576,L\n'1782 '1,8191,0xDA\n8253,270274,0x0C,*\n278528,1048576,L\n'
1744 '1327104,-,E\n1327104,524288,L\n1851392,1048576,L\n2899968,,,-',1783 '1327104,-,E\n1327104,524288,L\n1851392,1048576,L\n2899968,,,-',
1745 android_boards.AndroidOrigenQuadConfig.get_sfdisk_cmd())1784 android_boards.AndroidOrigenQuadConfig().get_sfdisk_cmd())
17461785
1747 def test_snowball_emmc_android(self):1786 def test_snowball_emmc_android(self):
1748 self.assertEqual(1787 self.assertEqual(
1749 '256,7936,0xDA\n8192,262144,0x0C,*\n270336,1048576,L\n'1788 '256,7936,0xDA\n8192,262144,0x0C,*\n270336,1048576,L\n'
1750 '1318912,-,E\n1318912,524288,L\n1843200,1048576,L\n2891776,,,-',1789 '1318912,-,E\n1318912,524288,L\n1843200,1048576,L\n2891776,,,-',
1751 android_boards.AndroidSnowballEmmcConfig.get_sfdisk_cmd())1790 android_boards.AndroidSnowballEmmcConfig().get_sfdisk_cmd())
17521791
1753 def test_vexpress_android(self):1792 def test_vexpress_android(self):
1754 self.assertEqual(1793 self.assertEqual(
1755 '63,270272,0x0E,*\n270336,1048576,L\n1318912,524288,L\n'1794 '63,270272,0x0E,*\n270336,1048576,L\n1318912,524288,L\n'
1756 '1843200,-,E\n1843200,1048576,L\n2891776,,,-',1795 '1843200,-,E\n1843200,1048576,L\n2891776,,,-',
1757 android_boards.AndroidVexpressConfig.get_sfdisk_cmd())1796 android_boards.AndroidVexpressConfig().get_sfdisk_cmd())
17581797
1759 def test_mx5_android(self):1798 def test_mx5_android(self):
1760 self.assertEqual(1799 self.assertEqual(
1761 '1,8191,0xDA\n8192,262144,0x0C,*\n270336,1048576,L\n'1800 '1,8191,0xDA\n8192,262144,0x0C,*\n270336,1048576,L\n'
1762 '1318912,-,E\n1318912,524288,L\n1843200,1048576,L\n2891776,,,-',1801 '1318912,-,E\n1318912,524288,L\n1843200,1048576,L\n2891776,,,-',
1763 android_boards.AndroidMx53LoCoConfig.get_sfdisk_cmd())1802 android_boards.AndroidMx53LoCoConfig().get_sfdisk_cmd())
17641803
1765 def test_mx6_android(self):1804 def test_mx6_android(self):
1766 self.assertEqual(1805 self.assertEqual(
1767 '1,8191,0xDA\n8192,262144,0x0C,*\n270336,1048576,L\n'1806 '1,8191,0xDA\n8192,262144,0x0C,*\n270336,1048576,L\n'
1768 '1318912,-,E\n1318912,524288,L\n1843200,1048576,L\n2891776,,,-',1807 '1318912,-,E\n1318912,524288,L\n1843200,1048576,L\n2891776,,,-',
1769 android_boards.AndroidMx6QSabreliteConfig.get_sfdisk_cmd())1808 android_boards.AndroidMx6QSabreliteConfig().get_sfdisk_cmd())
17701809
17711810
1772class TestGetSfdiskCmdV2(TestCase):1811class TestGetSfdiskCmdV2(TestCase):
17731812
1774 def test_mx5(self):1813 def test_mx5(self):
1775 class config(boards.Mx5Config):1814 board_conf = boards.Mx5Config()
1776 partition_layout = 'reserved_bootfs_rootfs'1815 board_conf.partition_layout = 'reserved_bootfs_rootfs'
1777 self.assertEqual(1816 self.assertEqual(
1778 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',1817 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
1779 config.get_sfdisk_cmd())1818 board_conf.get_sfdisk_cmd())
17801819
1781 def test_snowball_sd(self):1820 def test_snowball_sd(self):
1782 class config(boards.SnowballSdConfig):1821 board_conf = boards.SnowballSdConfig()
1783 partition_layout = 'bootfs_rootfs'1822 board_conf.partition_layout = 'bootfs_rootfs'
1784 self.assertEqual(1823 self.assertEqual(
1785 '63,106432,0x0C,*\n106496,,,-',1824 '63,106432,0x0C,*\n106496,,,-',
1786 config.get_sfdisk_cmd())1825 board_conf.get_sfdisk_cmd())
17871826
1788 def test_snowball_emmc(self):1827 def test_snowball_emmc(self):
1789 class config(boards.SnowballEmmcConfig):1828 board_conf = boards.SnowballEmmcConfig()
1790 partition_layout = 'reserved_bootfs_rootfs'1829 board_conf.partition_layout = 'reserved_bootfs_rootfs'
1791 LOADER_START_S = (128 * 1024) / SECTOR_SIZE1830 board_conf.loader_start_s = (128 * 1024) / SECTOR_SIZE
1792 self.assertEqual(1831 self.assertEqual(
1793 '256,7936,0xDA\n8192,106496,0x0C,*\n114688,,,-',1832 '256,7936,0xDA\n8192,106496,0x0C,*\n114688,,,-',
1794 config.get_sfdisk_cmd())1833 board_conf.get_sfdisk_cmd())
17951834
1796 def test_smdkv310(self):1835 def test_smdkv310(self):
1797 class config(board_configs['smdkv310']):1836 board_conf = get_board_config('smdkv310')
1798 partition_layout = 'reserved_bootfs_rootfs'1837 board_conf.partition_layout = 'reserved_bootfs_rootfs'
1799 LOADER_MIN_SIZE_S = (boards.BoardConfig.samsung_bl1_start +1838 board_conf.LOADER_MIN_SIZE_S = (
1800 boards.BoardConfig.samsung_bl1_len +1839 board_conf.samsung_bl1_start +
1801 boards.BoardConfig.samsung_bl2_len +1840 board_conf.samsung_bl1_len +
1802 boards.BoardConfig.samsung_env_len)1841 board_conf.samsung_bl2_len +
1842 board_conf.samsung_env_len)
1803 self.assertEquals(1843 self.assertEquals(
1804 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',1844 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
1805 config.get_sfdisk_cmd())1845 board_conf.get_sfdisk_cmd())
18061846
1807 def test_origen(self):1847 def test_origen(self):
1808 class config(board_configs['origen']):1848 board_conf = get_board_config('origen')
1809 partition_layout = 'reserved_bootfs_rootfs'1849 board_conf.partition_layout = 'reserved_bootfs_rootfs'
1810 LOADER_MIN_SIZE_S = (boards.BoardConfig.samsung_bl1_start +1850 board_conf.LOADER_MIN_SIZE_S = (
1811 boards.BoardConfig.samsung_bl1_len +1851 board_conf.samsung_bl1_start +
1812 boards.BoardConfig.samsung_bl2_len +1852 board_conf.samsung_bl1_len +
1813 boards.BoardConfig.samsung_env_len)1853 board_conf.samsung_bl2_len +
1854 board_conf.samsung_env_len)
1814 self.assertEquals(1855 self.assertEquals(
1815 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',1856 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
1816 config.get_sfdisk_cmd())1857 board_conf.get_sfdisk_cmd())
18171858
1818 def test_origen_quad(self):1859 def test_origen_quad(self):
1819 class config(board_configs['origen_quad']):1860 board_conf = get_board_config('origen_quad')
1820 partition_layout = 'reserved_bootfs_rootfs'1861 board_conf.partition_layout = 'reserved_bootfs_rootfs'
1821 LOADER_MIN_SIZE_S = (boards.BoardConfig.samsung_bl1_start +1862 board_conf.LOADER_MIN_SIZE_S = (
1822 boards.BoardConfig.samsung_bl1_len +1863 board_conf.samsung_bl1_start +
1823 boards.BoardConfig.samsung_bl2_len +1864 board_conf.samsung_bl1_len +
1824 boards.BoardConfig.samsung_env_len)1865 board_conf.samsung_bl2_len +
1866 board_conf.samsung_env_len)
1825 self.assertEquals(1867 self.assertEquals(
1826 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',1868 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
1827 config.get_sfdisk_cmd())1869 board_conf.get_sfdisk_cmd())
18281870
1829 def test_arndale(self):1871 def test_arndale(self):
1830 class config(board_configs['arndale']):1872 board_conf = get_board_config('arndale')
1831 partition_layout = 'reserved_bootfs_rootfs'1873 board_conf.partition_layout = 'reserved_bootfs_rootfs'
1832 LOADER_MIN_SIZE_S = (boards.BoardConfig.samsung_bl1_start +1874 board_conf.LOADER_MIN_SIZE_S = (
1833 boards.BoardConfig.samsung_bl1_len +1875 board_conf.samsung_bl1_start +
1834 boards.BoardConfig.samsung_bl2_len +1876 board_conf.samsung_bl1_len +
1835 boards.BoardConfig.samsung_env_len)1877 board_conf.samsung_bl2_len +
1878 board_conf.samsung_env_len)
1836 self.assertEquals(1879 self.assertEquals(
1837 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',1880 '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
1838 config.get_sfdisk_cmd())1881 board_conf.get_sfdisk_cmd())
18391882
18401883
1841class TestGetBootCmd(TestCase):1884class TestGetBootCmd(TestCase):
18421885
1843 def test_vexpress(self):1886 def test_vexpress(self):
1844 boot_commands = board_configs['vexpress']._get_boot_env(1887 board_conf = get_board_config('vexpress')
1888 boot_commands = board_conf._get_boot_env(
1845 is_live=False, is_lowmem=False, consoles=['ttyXXX'],1889 is_live=False, is_lowmem=False, consoles=['ttyXXX'],
1846 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)1890 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)
1847 expected = {1891 expected = {
@@ -1855,7 +1899,8 @@
1855 self.assertEqual(expected, boot_commands)1899 self.assertEqual(expected, boot_commands)
18561900
1857 def test_vexpress_a9(self):1901 def test_vexpress_a9(self):
1858 boot_commands = board_configs['vexpress-a9']._get_boot_env(1902 board_conf = get_board_config('vexpress-a9')
1903 boot_commands = board_conf._get_boot_env(
1859 is_live=False, is_lowmem=False, consoles=['ttyXXX'],1904 is_live=False, is_lowmem=False, consoles=['ttyXXX'],
1860 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)1905 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)
1861 expected = {1906 expected = {
@@ -1869,7 +1914,8 @@
1869 self.assertEqual(expected, boot_commands)1914 self.assertEqual(expected, boot_commands)
18701915
1871 def test_mx51(self):1916 def test_mx51(self):
1872 boot_commands = boards.Mx51Config._get_boot_env(1917 board_conf = boards.Mx51Config()
1918 boot_commands = board_conf._get_boot_env(
1873 is_live=False, is_lowmem=False, consoles=[],1919 is_live=False, is_lowmem=False, consoles=[],
1874 rootfs_id="UUID=deadbeef", i_img_data="initrd",1920 rootfs_id="UUID=deadbeef", i_img_data="initrd",
1875 d_img_data="mx51.dtb")1921 d_img_data="mx51.dtb")
@@ -1885,7 +1931,8 @@
1885 self.assertEqual(expected, boot_commands)1931 self.assertEqual(expected, boot_commands)
18861932
1887 def test_smdkv310(self):1933 def test_smdkv310(self):
1888 boot_commands = board_configs['smdkv310']._get_boot_env(1934 board_conf = get_board_config('smdkv310')
1935 boot_commands = board_conf._get_boot_env(
1889 is_live=False, is_lowmem=False, consoles=[],1936 is_live=False, is_lowmem=False, consoles=[],
1890 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)1937 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)
1891 expected = {1938 expected = {
@@ -1901,7 +1948,8 @@
1901 self.assertEqual(expected, boot_commands)1948 self.assertEqual(expected, boot_commands)
19021949
1903 def test_origen(self):1950 def test_origen(self):
1904 boot_commands = board_configs['origen']._get_boot_env(1951 board_conf = get_board_config('origen')
1952 boot_commands = board_conf._get_boot_env(
1905 is_live=False, is_lowmem=False, consoles=[],1953 is_live=False, is_lowmem=False, consoles=[],
1906 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)1954 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)
1907 expected = {1955 expected = {
@@ -1915,7 +1963,8 @@
1915 self.assertEqual(expected, boot_commands)1963 self.assertEqual(expected, boot_commands)
19161964
1917 def test_origen_quad(self):1965 def test_origen_quad(self):
1918 boot_commands = board_configs['origen_quad']._get_boot_env(1966 board_conf = get_board_config('origen_quad')
1967 boot_commands = board_conf._get_boot_env(
1919 is_live=False, is_lowmem=False, consoles=[],1968 is_live=False, is_lowmem=False, consoles=[],
1920 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)1969 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)
1921 expected = {1970 expected = {
@@ -1929,7 +1978,8 @@
1929 self.assertEqual(expected, boot_commands)1978 self.assertEqual(expected, boot_commands)
19301979
1931 def test_ux500(self):1980 def test_ux500(self):
1932 boot_commands = board_configs['ux500']._get_boot_env(1981 board_conf = get_board_config('ux500')
1982 boot_commands = board_conf._get_boot_env(
1933 is_live=False, is_lowmem=False, consoles=[],1983 is_live=False, is_lowmem=False, consoles=[],
1934 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)1984 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)
1935 expected = {1985 expected = {
@@ -1947,7 +1997,8 @@
1947 self.assertEqual(expected, boot_commands)1997 self.assertEqual(expected, boot_commands)
19481998
1949 def test_snowball_emmc(self):1999 def test_snowball_emmc(self):
1950 boot_commands = board_configs['snowball_emmc']._get_boot_env(2000 board_conf = get_board_config('snowball_emmc')
2001 boot_commands = board_conf._get_boot_env(
1951 is_live=False, is_lowmem=False, consoles=[],2002 is_live=False, is_lowmem=False, consoles=[],
1952 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)2003 rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None)
1953 expected = {2004 expected = {
@@ -1968,7 +2019,7 @@
1968 # XXX: To fix bug 697824 we have to change class attributes of our2019 # XXX: To fix bug 697824 we have to change class attributes of our
1969 # OMAP board configs, and some tests do that so to make sure they2020 # OMAP board configs, and some tests do that so to make sure they
1970 # don't interfere with us we'll reset that before doing anything.2021 # don't interfere with us we'll reset that before doing anything.
1971 config = board_configs['panda']2022 config = get_board_config('panda')
1972 config.serial_tty = config._serial_tty2023 config.serial_tty = config._serial_tty
1973 boot_commands = config._get_boot_env(2024 boot_commands = config._get_boot_env(
1974 is_live=False, is_lowmem=False, consoles=[],2025 is_live=False, is_lowmem=False, consoles=[],
@@ -1991,7 +2042,7 @@
1991 # XXX: To fix bug 697824 we have to change class attributes of our2042 # XXX: To fix bug 697824 we have to change class attributes of our
1992 # OMAP board configs, and some tests do that so to make sure they2043 # OMAP board configs, and some tests do that so to make sure they
1993 # don't interfere with us we'll reset that before doing anything.2044 # don't interfere with us we'll reset that before doing anything.
1994 config = board_configs['beagle']2045 config = get_board_config('beagle')
1995 config.serial_tty = config._serial_tty2046 config.serial_tty = config._serial_tty
1996 boot_commands = config._get_boot_env(2047 boot_commands = config._get_boot_env(
1997 is_live=False, is_lowmem=False, consoles=[],2048 is_live=False, is_lowmem=False, consoles=[],
@@ -2014,7 +2065,7 @@
2014 # XXX: To fix bug 697824 we have to change class attributes of our2065 # XXX: To fix bug 697824 we have to change class attributes of our
2015 # OMAP board configs, and some tests do that so to make sure they2066 # OMAP board configs, and some tests do that so to make sure they
2016 # don't interfere with us we'll reset that before doing anything.2067 # don't interfere with us we'll reset that before doing anything.
2017 config = boards.IgepConfig2068 config = boards.IgepConfig()
2018 config.serial_tty = config._serial_tty2069 config.serial_tty = config._serial_tty
2019 boot_cmd = config._get_boot_env(2070 boot_cmd = config._get_boot_env(
2020 is_live=False, is_lowmem=False, consoles=[],2071 is_live=False, is_lowmem=False, consoles=[],
@@ -2037,7 +2088,7 @@
2037 # XXX: To fix bug 697824 we have to change class attributes of our2088 # XXX: To fix bug 697824 we have to change class attributes of our
2038 # OMAP board configs, and some tests do that so to make sure they2089 # OMAP board configs, and some tests do that so to make sure they
2039 # don't interfere with us we'll reset that before doing anything.2090 # don't interfere with us we'll reset that before doing anything.
2040 config = board_configs['overo']2091 config = get_board_config('overo')
2041 config.serial_tty = config._serial_tty2092 config.serial_tty = config._serial_tty
2042 boot_commands = config._get_boot_env(2093 boot_commands = config._get_boot_env(
2043 is_live=False, is_lowmem=False, consoles=[],2094 is_live=False, is_lowmem=False, consoles=[],
@@ -2060,12 +2111,15 @@
20602111
2061class TestExtraBootCmd(TestCaseWithFixtures):2112class TestExtraBootCmd(TestCaseWithFixtures):
20622113
2114 def setUp(self):
2115 super(TestExtraBootCmd, self).setUp()
2116 self.board_conf = BoardConfig()
2117
2063 def test_extra_boot_args_options_is_picked_by_get_boot_env(self):2118 def test_extra_boot_args_options_is_picked_by_get_boot_env(self):
2064 boot_args = 'whatever'2119 boot_args = 'whatever'
20652120
2066 class config(BoardConfig):2121 self.board_conf.extra_boot_args_options = boot_args
2067 extra_boot_args_options = boot_args2122 boot_commands = self.board_conf._get_boot_env(
2068 boot_commands = config._get_boot_env(
2069 is_live=False, is_lowmem=False, consoles=['ttyXXX'],2123 is_live=False, is_lowmem=False, consoles=['ttyXXX'],
2070 rootfs_id="UUID=deadbeef", i_img_data=None, d_img_data=None)2124 rootfs_id="UUID=deadbeef", i_img_data=None, d_img_data=None)
2071 expected = (2125 expected = (
@@ -2075,28 +2129,25 @@
2075 def test_passing_None_to_add_boot_args(self):2129 def test_passing_None_to_add_boot_args(self):
2076 boot_args = 'extra-args'2130 boot_args = 'extra-args'
20772131
2078 class config(BoardConfig):2132 self.board_conf.extra_boot_args_options = boot_args
2079 extra_boot_args_options = boot_args2133 self.board_conf.add_boot_args(None)
2080 config.add_boot_args(None)2134 self.assertEqual(boot_args, self.board_conf.extra_boot_args_options)
2081 self.assertEqual(boot_args, config.extra_boot_args_options)
20822135
2083 def test_passing_string_to_add_boot_args(self):2136 def test_passing_string_to_add_boot_args(self):
2084 boot_args = 'extra-args'2137 boot_args = 'extra-args'
2085 extra_args = 'user-args'2138 extra_args = 'user-args'
20862139
2087 class config(BoardConfig):2140 self.board_conf.extra_boot_args_options = boot_args
2088 extra_boot_args_options = boot_args2141 self.board_conf.add_boot_args(extra_args)
2089 config.add_boot_args(extra_args)
2090 self.assertEqual(2142 self.assertEqual(
2091 "%s %s" % (boot_args, extra_args), config.extra_boot_args_options)2143 "%s %s" % (boot_args, extra_args),
2144 self.board_conf.extra_boot_args_options)
20922145
2093 def test_passing_string_to_add_boot_args_with_no_default_extra_args(self):2146 def test_passing_string_to_add_boot_args_with_no_default_extra_args(self):
2094 extra_args = 'user-args'2147 extra_args = 'user-args'
20952148
2096 class config(BoardConfig):2149 self.board_conf.add_boot_args(extra_args)
2097 extra_boot_args_options = None2150 self.assertEqual(extra_args, self.board_conf.extra_boot_args_options)
2098 config.add_boot_args(extra_args)
2099 self.assertEqual(extra_args, config.extra_boot_args_options)
21002151
2101 def test_add_boot_args_from_file(self):2152 def test_add_boot_args_from_file(self):
2102 boot_args = 'extra-args'2153 boot_args = 'extra-args'
@@ -2105,19 +2156,18 @@
2105 with open(boot_arg_path, 'w') as boot_arg_file:2156 with open(boot_arg_path, 'w') as boot_arg_file:
2106 boot_arg_file.write(extra_args)2157 boot_arg_file.write(extra_args)
21072158
2108 class config(BoardConfig):2159 self.board_conf.extra_boot_args_options = boot_args
2109 extra_boot_args_options = boot_args2160 self.board_conf.add_boot_args_from_file(boot_arg_path)
2110 config.add_boot_args_from_file(boot_arg_path)
2111 self.assertEqual(2161 self.assertEqual(
2112 "%s %s" % (boot_args, extra_args), config.extra_boot_args_options)2162 "%s %s" % (boot_args, extra_args),
2163 self.board_conf.extra_boot_args_options)
21132164
2114 def test_passing_None_to_add_boot_args_from_file(self):2165 def test_passing_None_to_add_boot_args_from_file(self):
2115 boot_args = 'extra-args'2166 boot_args = 'extra-args'
21162167
2117 class config(BoardConfig):2168 self.board_conf.extra_boot_args_options = boot_args
2118 extra_boot_args_options = boot_args2169 self.board_conf.add_boot_args_from_file(None)
2119 config.add_boot_args_from_file(None)2170 self.assertEqual(boot_args, self.board_conf.extra_boot_args_options)
2120 self.assertEqual(boot_args, config.extra_boot_args_options)
21212171
2122 def test_add_boot_args_from_file_strips_whitespace_from_file(self):2172 def test_add_boot_args_from_file_strips_whitespace_from_file(self):
2123 boot_args = 'extra-args'2173 boot_args = 'extra-args'
@@ -2126,134 +2176,11 @@
2126 with open(boot_arg_path, 'w') as boot_arg_file:2176 with open(boot_arg_path, 'w') as boot_arg_file:
2127 boot_arg_file.write('\n\n \t ' + extra_args + ' \n\n')2177 boot_arg_file.write('\n\n \t ' + extra_args + ' \n\n')
21282178
2129 class config(BoardConfig):2179 self.board_conf.extra_boot_args_options = boot_args
2130 extra_boot_args_options = boot_args2180 self.board_conf.add_boot_args_from_file(boot_arg_path)
2131 config.add_boot_args_from_file(boot_arg_path)
2132 self.assertEqual(2181 self.assertEqual(
2133 "%s %s" % (boot_args, extra_args), config.extra_boot_args_options)2182 "%s %s" % (boot_args, extra_args),
21342183 self.board_conf.extra_boot_args_options)
2135
2136class TestGetBootCmdAndroid(TestCase):
2137
2138 def test_panda(self):
2139 # XXX: To fix bug 697824 we have to change class attributes of our
2140 # OMAP board configs, and some tests do that so to make sure they
2141 # don't interfere with us we'll reset that before doing anything.
2142 config = android_board_configs['panda']
2143 config.serial_tty = config._serial_tty
2144 expected = {
2145 'bootargs': 'console=ttyO2,115200n8 '
2146 'rootwait ro earlyprintk fixrtc '
2147 'nocompcache vram=48M omapfb.vram=0:24M,1:24M '
2148 'mem=456M@0x80000000 mem=512M@0xA0000000 '
2149 'init=/init androidboot.console=ttyO2',
2150 'bootcmd': 'fatload mmc 0:1 0x80200000 uImage; '
2151 'fatload mmc 0:1 0x81600000 uInitrd; '
2152 'fatload mmc 0:1 0x815f0000 board.dtb; '
2153 'bootm 0x80200000 0x81600000 0x815f0000',
2154 'fdt_high': '0xffffffff',
2155 'initrd_high': '0xffffffff'}
2156 self.assertBootEnv(config, expected)
2157
2158 def test_android_snowball_sd(self):
2159 expected = {
2160 'bootargs': 'console=ttyAMA2,115200n8 '
2161 'rootwait ro earlyprintk '
2162 'mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
2163 'mem=22M@360M mem_issw=1M@383M mem=640M@384M '
2164 'vmalloc=500M init=/init androidboot.console=ttyAMA2',
2165 'bootcmd': 'fatload mmc 1:1 0x00100000 uImage; '
2166 'fatload mmc 1:1 0x05000000 uInitrd; '
2167 'fatload mmc 1:1 0x8000000 board.dtb; '
2168 'bootm 0x00100000 0x05000000 0x8000000',
2169 'fdt_high': '0x05000000',
2170 'initrd_high': '0x06000000'}
2171 self.assertBootEnv(
2172 android_boards.AndroidSnowballSdConfig, expected)
2173
2174 def test_android_snowball_emmc(self):
2175 expected = {
2176 'bootargs': 'console=ttyAMA2,115200n8 '
2177 'rootwait ro earlyprintk '
2178 'mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
2179 'mem=22M@360M mem_issw=1M@383M mem=640M@384M '
2180 'vmalloc=500M init=/init androidboot.console=ttyAMA2',
2181 'bootcmd': 'fatload mmc 0:2 0x00100000 uImage; '
2182 'fatload mmc 0:2 0x05000000 uInitrd; '
2183 'fatload mmc 0:2 0x8000000 board.dtb; '
2184 'bootm 0x00100000 0x05000000 0x8000000',
2185 'fdt_high': '0x05000000',
2186 'initrd_high': '0x06000000'}
2187 self.assertBootEnv(
2188 android_boards.AndroidSnowballEmmcConfig, expected)
2189
2190 def test_android_origen(self):
2191 expected = {
2192 'bootargs': 'console=tty0 console=ttySAC2,115200n8 '
2193 'rootwait ro init=/init androidboot.console=ttySAC2',
2194 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
2195 'fatload mmc 0:2 0x42000000 uInitrd; '
2196 'bootm 0x40007000 0x42000000',
2197 'fdt_high': '0xffffffff',
2198 'initrd_high': '0xffffffff'}
2199 self.assertBootEnv(
2200 android_boards.AndroidOrigenConfig, expected)
2201
2202 def test_android_origen_quad(self):
2203 expected = {
2204 'bootargs': 'console=tty0 console=ttySAC2,115200n8 '
2205 'rootwait ro init=/init androidboot.console=ttySAC2',
2206 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; '
2207 'fatload mmc 0:2 0x42000000 uInitrd; '
2208 'bootm 0x40007000 0x42000000',
2209 'fdt_high': '0xffffffff',
2210 'initrd_high': '0xffffffff'}
2211 self.assertBootEnv(
2212 android_boards.AndroidOrigenQuadConfig, expected)
2213
2214 def test_android_vexpress(self):
2215 expected = {
2216 'bootargs': 'console=tty0 console=ttyAMA0,38400n8 '
2217 'rootwait ro init=/init androidboot.console=ttyAMA0',
2218 'bootcmd': 'fatload mmc 0:1 0x60000000 uImage; '
2219 'fatload mmc 0:1 0x62000000 uInitrd; '
2220 'bootm 0x60000000 0x62000000',
2221 'fdt_high': '0xffffffff',
2222 'initrd_high': '0xffffffff'}
2223 self.assertBootEnv(
2224 android_boards.AndroidVexpressConfig, expected)
2225
2226 def test_android_mx5(self):
2227 expected = {
2228 'bootargs': 'console=ttymxc0,115200n8 '
2229 'rootwait ro earlyprintk rootdelay=1 fixrtc '
2230 'nocompcache di1_primary tve init=/init '
2231 'androidboot.console=ttymxc0',
2232 'bootcmd': 'fatload mmc 0:2 0x70000000 uImage; '
2233 'fatload mmc 0:2 0x72000000 uInitrd; '
2234 'bootm 0x70000000 0x72000000',
2235 'fdt_high': '0xffffffff',
2236 'initrd_high': '0xffffffff'}
2237 self.assertBootEnv(
2238 android_boards.AndroidMx53LoCoConfig, expected)
2239
2240 def test_android_mx6(self):
2241 expected = {
2242 'bootargs': 'console=ttymxc0,115200n8 '
2243 'rootwait ro earlyprintk rootdelay=1 fixrtc '
2244 'nocompcache di1_primary tve init=/init '
2245 'androidboot.console=ttymxc0',
2246 'bootcmd': 'fatload mmc 0:2 0x10000000 uImage; '
2247 'fatload mmc 0:2 0x12000000 uInitrd; '
2248 'fatload mmc 0:2 0x11ff0000 board.dtb; '
2249 'bootm 0x10000000 0x12000000 0x11ff0000',
2250 'fdt_high': '0xffffffff',
2251 'initrd_high': '0xffffffff'}
2252 self.assertBootEnv(
2253 android_boards.AndroidMx6QSabreliteConfig, expected)
2254
2255 def assertBootEnv(self, config, expected):
2256 self.assertEqual(expected, config._get_boot_env(consoles=[]))
22572184
22582185
2259class TestUnpackBinaryTarball(TestCaseWithFixtures):2186class TestUnpackBinaryTarball(TestCaseWithFixtures):
@@ -2375,119 +2302,110 @@
2375 boards, '_get_mlo_file',2302 boards, '_get_mlo_file',
2376 lambda chroot_dir: "%s/MLO" % chroot_dir))2303 lambda chroot_dir: "%s/MLO" % chroot_dir))
23772304
2378 class config(BoardConfig):2305 board_conf = BoardConfig()
2379 pass2306 board_conf.set_metadata([])
2380 config.set_metadata([])2307 install_omap_boot_loader("chroot_dir", "boot_disk", board_conf)
2381 install_omap_boot_loader("chroot_dir", "boot_disk", config)
2382 expected = [2308 expected = [
2383 '%s cp -v chroot_dir/MLO boot_disk' % sudo_args, 'sync']2309 '%s cp -v chroot_dir/MLO boot_disk' % sudo_args, 'sync']
2384 self.assertEqual(expected, fixture.mock.commands_executed)2310 self.assertEqual(expected, fixture.mock.commands_executed)
23852311
2386 def test_install_smdk_u_boot(self):2312 def test_install_smdk_u_boot(self):
2387 fixture = self._mock_Popen()2313 fixture = self._mock_Popen()
2388 bootloader_flavor = boards.SMDKV310Config.bootloader_flavor2314 board_conf = boards.SMDKV310Config()
2315 bootloader_flavor = board_conf.bootloader_flavor
2389 self.useFixture(MockSomethingFixture(os.path, 'getsize',2316 self.useFixture(MockSomethingFixture(os.path, 'getsize',
2390 lambda file: 1))2317 lambda file: 1))
2391 boards.SMDKV310Config.install_samsung_boot_loader(2318 board_conf.install_samsung_boot_loader(
2392 "%s/%s/SPL" % ("chroot_dir", bootloader_flavor),2319 "%s/%s/SPL" % ("chroot_dir", bootloader_flavor),
2393 "%s/%s/uboot" % ("chroot_dir", bootloader_flavor), "boot_disk")2320 "%s/%s/uboot" % ("chroot_dir", bootloader_flavor), "boot_disk")
2394 expected = [2321 expected = [
2395 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '2322 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
2396 'seek=%d' % (sudo_args, bootloader_flavor,2323 'seek=%d' % (sudo_args, bootloader_flavor,
2397 boards.SMDKV310Config.samsung_bl1_start),2324 board_conf.samsung_bl1_start),
2398 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '2325 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
2399 'seek=%d' % (sudo_args, bootloader_flavor,2326 'seek=%d' % (sudo_args, bootloader_flavor,
2400 boards.SMDKV310Config.samsung_bl2_start)]2327 board_conf.samsung_bl2_start)]
2401 self.assertEqual(expected, fixture.mock.commands_executed)2328 self.assertEqual(expected, fixture.mock.commands_executed)
24022329
2330 def _set_up_board_config(self, board_name):
2331 """Internal method to set-up correctly board config, with the
2332 appropriate mock objects.
2333
2334 :param board_name: The name of the board to set-up.
2335 :return A 3-tuple: the config, the name of the bootloader, and the
2336 value of chroot_dir.
2337 """
2338 board_conf = get_board_config(board_name)
2339 bootloader_flavor = board_conf.bootloader_flavor
2340 # Made-up value to be used as the chroot directory.
2341 chroot_dir_value = 'chroot_dir'
2342 board_conf._get_samsung_spl = MagicMock()
2343 board_conf._get_samsung_spl.return_value = ("%s/%s/SPL" %
2344 (chroot_dir_value, bootloader_flavor))
2345 board_conf._get_samsung_bootloader = MagicMock()
2346 board_conf._get_samsung_bootloader.return_value = ("%s/%s/uboot" %
2347 (chroot_dir_value, bootloader_flavor))
2348 board_conf.hardwarepack_handler = (
2349 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
2350 board_conf.hardwarepack_handler.get_format = (
2351 lambda: HardwarepackHandler.FORMAT_1)
2352 return board_conf, bootloader_flavor, chroot_dir_value
2353
2403 def test_install_origen_u_boot(self):2354 def test_install_origen_u_boot(self):
2404 fixture = self._mock_Popen()2355 fixture = self._mock_Popen()
2405 bootloader_flavor = boards.OrigenConfig.bootloader_flavor2356 board_conf, bootloader_flavor, chroot_dir_value = \
2406 self.useFixture(MockSomethingFixture(2357 self._set_up_board_config('origen')
2407 boards.OrigenConfig, '_get_samsung_spl',
2408 classmethod(lambda cls, chroot_dir: "%s/%s/SPL" % (
2409 chroot_dir, bootloader_flavor))))
2410 self.useFixture(MockSomethingFixture(
2411 boards.OrigenConfig, '_get_samsung_bootloader',
2412 classmethod(lambda cls, chroot_dir: "%s/%s/uboot" % (
2413 chroot_dir, bootloader_flavor))))
2414 boards.OrigenConfig.hardwarepack_handler = (
2415 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
2416 boards.OrigenConfig.hardwarepack_handler.get_format = (
2417 lambda: '1.0')
2418 self.useFixture(MockSomethingFixture(os.path, 'getsize',2358 self.useFixture(MockSomethingFixture(os.path, 'getsize',
2419 lambda file: 1))2359 lambda file: 1))
2420 boards.OrigenConfig.install_samsung_boot_loader(2360 board_conf.install_samsung_boot_loader(
2421 boards.OrigenConfig._get_samsung_spl("chroot_dir"),2361 board_conf._get_samsung_spl(chroot_dir_value),
2422 boards.OrigenConfig._get_samsung_bootloader("chroot_dir"),2362 board_conf._get_samsung_bootloader(chroot_dir_value),
2423 "boot_disk")2363 "boot_disk")
2424 expected = [2364 expected = [
2425 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '2365 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
2426 'seek=%d' % (sudo_args, bootloader_flavor,2366 'seek=%d' % (sudo_args, bootloader_flavor,
2427 boards.OrigenConfig.samsung_bl1_start),2367 board_conf.samsung_bl1_start),
2428 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '2368 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
2429 'seek=%d' % (sudo_args, bootloader_flavor,2369 'seek=%d' % (sudo_args, bootloader_flavor,
2430 boards.OrigenConfig.samsung_bl2_start)]2370 board_conf.samsung_bl2_start)]
2431 self.assertEqual(expected, fixture.mock.commands_executed)2371 self.assertEqual(expected, fixture.mock.commands_executed)
24322372
2433 def test_install_origen_quad_u_boot(self):2373 def test_install_origen_quad_u_boot(self):
2434 fixture = self._mock_Popen()2374 fixture = self._mock_Popen()
2435 bootloader_flavor = boards.OrigenQuadConfig.bootloader_flavor2375 board_conf, bootloader_flavor, chroot_dir_value = \
2436 self.useFixture(MockSomethingFixture(2376 self._set_up_board_config('origen_quad')
2437 boards.OrigenQuadConfig, '_get_samsung_spl',
2438 classmethod(lambda cls, chroot_dir: "%s/%s/SPL" % (
2439 chroot_dir, bootloader_flavor))))
2440 self.useFixture(MockSomethingFixture(
2441 boards.OrigenQuadConfig, '_get_samsung_bootloader',
2442 classmethod(lambda cls, chroot_dir: "%s/%s/uboot" % (
2443 chroot_dir, bootloader_flavor))))
2444 boards.OrigenQuadConfig.hardwarepack_handler = (
2445 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
2446 boards.OrigenQuadConfig.hardwarepack_handler.get_format = (
2447 lambda: '1.0')
2448 self.useFixture(MockSomethingFixture(os.path, 'getsize',2377 self.useFixture(MockSomethingFixture(os.path, 'getsize',
2449 lambda file: 1))2378 lambda file: 1))
2450 boards.OrigenQuadConfig.install_samsung_boot_loader(2379 board_conf.install_samsung_boot_loader(
2451 boards.OrigenQuadConfig._get_samsung_spl("chroot_dir"),2380 board_conf._get_samsung_spl(chroot_dir_value),
2452 boards.OrigenQuadConfig._get_samsung_bootloader("chroot_dir"),2381 board_conf._get_samsung_bootloader(chroot_dir_value),
2453 "boot_disk")2382 "boot_disk")
2454 expected = [2383 expected = [
2455 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '2384 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
2456 'seek=%d' % (sudo_args, bootloader_flavor,2385 'seek=%d' % (sudo_args, bootloader_flavor,
2457 boards.OrigenQuadConfig.samsung_bl1_start),2386 board_conf.samsung_bl1_start),
2458 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '2387 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
2459 'seek=%d' % (sudo_args, bootloader_flavor,2388 'seek=%d' % (sudo_args, bootloader_flavor,
2460 boards.OrigenQuadConfig.samsung_bl2_start)]2389 board_conf.samsung_bl2_start)]
2461 self.assertEqual(expected, fixture.mock.commands_executed)2390 self.assertEqual(expected, fixture.mock.commands_executed)
24622391
2463 def test_install_arndale_u_boot(self):2392 def test_install_arndale_u_boot(self):
2464 fixture = self._mock_Popen()2393 fixture = self._mock_Popen()
2465 bootloader_flavor = boards.ArndaleConfig.bootloader_flavor2394 board_conf, bootloader_flavor, chroot_dir_value = \
2466 self.useFixture(MockSomethingFixture(2395 self._set_up_board_config('arndale')
2467 boards.ArndaleConfig, '_get_samsung_spl',
2468 classmethod(lambda cls, chroot_dir: "%s/%s/SPL" % (
2469 chroot_dir, bootloader_flavor))))
2470 self.useFixture(MockSomethingFixture(
2471 boards.ArndaleConfig, '_get_samsung_bootloader',
2472 classmethod(lambda cls, chroot_dir: "%s/%s/uboot" % (
2473 chroot_dir, bootloader_flavor))))
2474 boards.ArndaleConfig.hardwarepack_handler = (
2475 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
2476 boards.ArndaleConfig.hardwarepack_handler.get_format = (
2477 lambda: '1.0')
2478 self.useFixture(MockSomethingFixture(os.path, 'getsize',2396 self.useFixture(MockSomethingFixture(os.path, 'getsize',
2479 lambda file: 1))2397 lambda file: 1))
2480 boards.ArndaleConfig.install_samsung_boot_loader(2398 board_conf.install_samsung_boot_loader(
2481 boards.ArndaleConfig._get_samsung_spl("chroot_dir"),2399 board_conf._get_samsung_spl(chroot_dir_value),
2482 boards.ArndaleConfig._get_samsung_bootloader("chroot_dir"),2400 board_conf._get_samsung_bootloader(chroot_dir_value),
2483 "boot_disk")2401 "boot_disk")
2484 expected = [2402 expected = [
2485 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '2403 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
2486 'seek=%d' % (sudo_args, bootloader_flavor,2404 'seek=%d' % (sudo_args, bootloader_flavor,
2487 boards.ArndaleConfig.samsung_bl1_start),2405 board_conf.samsung_bl1_start),
2488 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '2406 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
2489 'seek=%d' % (sudo_args, bootloader_flavor,2407 'seek=%d' % (sudo_args, bootloader_flavor,
2490 boards.ArndaleConfig.samsung_bl2_start)]2408 board_conf.samsung_bl2_start)]
2491 self.assertEqual(expected, fixture.mock.commands_executed)2409 self.assertEqual(expected, fixture.mock.commands_executed)
24922410
2493 def test_get_plain_boot_script_contents(self):2411 def test_get_plain_boot_script_contents(self):
@@ -2544,77 +2462,77 @@
2544 flavorx = 'flavorX'2462 flavorx = 'flavorX'
2545 flavorxy = 'flavorXY'2463 flavorxy = 'flavorXY'
25462464
2547 class config(boards.BoardConfig):2465 board_conf = BoardConfig()
2548 kernel_flavors = [flavorx, flavorxy]2466 board_conf.kernel_flavors = [flavorx, flavorxy]
2549 for f in reversed(config.kernel_flavors):2467 for f in reversed(board_conf.kernel_flavors):
2550 kfile = os.path.join(tempdir, 'vmlinuz-1-%s' % f)2468 kfile = os.path.join(tempdir, 'vmlinuz-1-%s' % f)
2551 ifile = os.path.join(tempdir, 'initrd.img-1-%s' % f)2469 ifile = os.path.join(tempdir, 'initrd.img-1-%s' % f)
2552 open(kfile, "w").close()2470 open(kfile, "w").close()
2553 open(ifile, "w").close()2471 open(ifile, "w").close()
2554 self.assertEqual(2472 self.assertEqual(
2555 (kfile, ifile, None), config._get_kflavor_files(tempdir))2473 (kfile, ifile, None), board_conf._get_kflavor_files(tempdir))
25562474
2557 def test_get_dt_kflavor_files_more_specific(self):2475 def test_get_dt_kflavor_files_more_specific(self):
2558 tempdir = self.useFixture(CreateTempDirFixture()).tempdir2476 tempdir = self.useFixture(CreateTempDirFixture()).tempdir
2559 flavorx = 'flavorX'2477 flavorx = 'flavorX'
2560 flavorxy = 'flavorXY'2478 flavorxy = 'flavorXY'
25612479
2562 class config(boards.BoardConfig):2480 board_conf = BoardConfig()
2563 kernel_flavors = [flavorx, flavorxy]2481 board_conf.kernel_flavors = [flavorx, flavorxy]
2564 dtb_name = 'board_name.dtb'2482 board_conf.dtb_name = 'board_name.dtb'
2565 for f in reversed(config.kernel_flavors):2483 for f in reversed(board_conf.kernel_flavors):
2566 kfile = os.path.join(tempdir, 'vmlinuz-1-%s' % f)2484 kfile = os.path.join(tempdir, 'vmlinuz-1-%s' % f)
2567 ifile = os.path.join(tempdir, 'initrd.img-1-%s' % f)2485 ifile = os.path.join(tempdir, 'initrd.img-1-%s' % f)
2568 dt = os.path.join(tempdir, 'dt-1-%s' % f)2486 dt = os.path.join(tempdir, 'dt-1-%s' % f)
2569 os.mkdir(dt)2487 os.mkdir(dt)
2570 dfile = os.path.join(dt, config.dtb_name)2488 dfile = os.path.join(dt, board_conf.dtb_name)
2571 open(kfile, "w").close()2489 open(kfile, "w").close()
2572 open(ifile, "w").close()2490 open(ifile, "w").close()
2573 open(dfile, "w").close()2491 open(dfile, "w").close()
2574 self.assertEqual(2492 self.assertEqual(
2575 (kfile, ifile, dfile), config._get_kflavor_files(tempdir))2493 (kfile, ifile, dfile), board_conf._get_kflavor_files(tempdir))
25762494
2577 def test_get_kflavor_files_later_in_flavors(self):2495 def test_get_kflavor_files_later_in_flavors(self):
2578 tempdir = self.useFixture(CreateTempDirFixture()).tempdir2496 tempdir = self.useFixture(CreateTempDirFixture()).tempdir
2579 flavor1 = 'flavorXY'2497 flavor1 = 'flavorXY'
2580 flavor2 = 'flavorAA'2498 flavor2 = 'flavorAA'
25812499
2582 class config(boards.BoardConfig):2500 board_conf = BoardConfig()
2583 kernel_flavors = [flavor1, flavor2]2501 board_conf.kernel_flavors = [flavor1, flavor2]
2584 kfile = os.path.join(tempdir, 'vmlinuz-1-%s' % flavor1)2502 kfile = os.path.join(tempdir, 'vmlinuz-1-%s' % flavor1)
2585 ifile = os.path.join(tempdir, 'initrd.img-1-%s' % flavor1)2503 ifile = os.path.join(tempdir, 'initrd.img-1-%s' % flavor1)
2586 open(kfile, "w").close()2504 open(kfile, "w").close()
2587 open(ifile, "w").close()2505 open(ifile, "w").close()
2588 self.assertEqual(2506 self.assertEqual(
2589 (kfile, ifile, None), config._get_kflavor_files(tempdir))2507 (kfile, ifile, None), board_conf._get_kflavor_files(tempdir))
25902508
2591 def test_get_dt_kflavor_files_later_in_flavors(self):2509 def test_get_dt_kflavor_files_later_in_flavors(self):
2592 tempdir = self.useFixture(CreateTempDirFixture()).tempdir2510 tempdir = self.useFixture(CreateTempDirFixture()).tempdir
2593 flavor1 = 'flavorXY'2511 flavor1 = 'flavorXY'
2594 flavor2 = 'flavorAA'2512 flavor2 = 'flavorAA'
25952513
2596 class config(boards.BoardConfig):2514 board_conf = BoardConfig()
2597 kernel_flavors = [flavor1, flavor2]2515 board_conf.kernel_flavors = [flavor1, flavor2]
2598 dtb_name = 'board_name.dtb'2516 board_conf.dtb_name = 'board_name.dtb'
2599 kfile = os.path.join(tempdir, 'vmlinuz-1-%s' % flavor1)2517 kfile = os.path.join(tempdir, 'vmlinuz-1-%s' % flavor1)
2600 ifile = os.path.join(tempdir, 'initrd.img-1-%s' % flavor1)2518 ifile = os.path.join(tempdir, 'initrd.img-1-%s' % flavor1)
2601 dt = os.path.join(tempdir, 'dt-1-%s' % flavor1)2519 dt = os.path.join(tempdir, 'dt-1-%s' % flavor1)
2602 os.mkdir(dt)2520 os.mkdir(dt)
2603 dfile = os.path.join(dt, config.dtb_name)2521 dfile = os.path.join(dt, board_conf.dtb_name)
2604 open(kfile, "w").close()2522 open(kfile, "w").close()
2605 open(ifile, "w").close()2523 open(ifile, "w").close()
2606 open(dfile, "w").close()2524 open(dfile, "w").close()
2607 self.assertEqual(2525 self.assertEqual(
2608 (kfile, ifile, dfile), config._get_kflavor_files(tempdir))2526 (kfile, ifile, dfile), board_conf._get_kflavor_files(tempdir))
26092527
2610 def test_get_kflavor_files_raises_when_no_match(self):2528 def test_get_kflavor_files_raises_when_no_match(self):
2611 tempdir = self.useFixture(CreateTempDirFixture()).tempdir2529 tempdir = self.useFixture(CreateTempDirFixture()).tempdir
2612 flavor1 = 'flavorXY'2530 flavor1 = 'flavorXY'
2613 flavor2 = 'flavorAA'2531 flavor2 = 'flavorAA'
26142532
2615 class config(boards.BoardConfig):2533 board_conf = BoardConfig()
2616 kernel_flavors = [flavor1, flavor2]2534 board_conf.kernel_flavors = [flavor1, flavor2]
2617 self.assertRaises(ValueError, config._get_kflavor_files, tempdir)2535 self.assertRaises(ValueError, board_conf._get_kflavor_files, tempdir)
26182536
2619 def test_get_file_matching_no_files_found(self):2537 def test_get_file_matching_no_files_found(self):
2620 self.assertEqual(2538 self.assertEqual(
@@ -2647,8 +2565,6 @@
2647 # Stub time.sleep() as create_partitions() use that.2565 # Stub time.sleep() as create_partitions() use that.
2648 self.orig_sleep = time.sleep2566 self.orig_sleep = time.sleep
2649 time.sleep = lambda s: None2567 time.sleep = lambda s: None
2650 boards = linaro_image_tools.media_create.boards
2651 boards.BoardConfig.hwpack_format = '1.0'
26522568
2653 def tearDown(self):2569 def tearDown(self):
2654 super(TestCreatePartitions, self).tearDown()2570 super(TestCreatePartitions, self).tearDown()
@@ -2659,7 +2575,9 @@
2659 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())2575 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
2660 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())2576 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
26612577
2662 create_partitions(boards.Mx5Config, self.media, HEADS, SECTORS, '')2578 board_conf = boards.Mx5Config()
2579 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
2580 create_partitions(board_conf, self.media, HEADS, SECTORS, '')
26632581
2664 self.assertEqual(2582 self.assertEqual(
2665 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),2583 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
@@ -2680,8 +2598,9 @@
2680 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())2598 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
2681 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())2599 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
26822600
2683 create_partitions(2601 board_conf = get_board_config('smdkv310')
2684 board_configs['smdkv310'], self.media, HEADS, SECTORS, '')2602 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
2603 create_partitions(board_conf, self.media, HEADS, SECTORS, '')
26852604
2686 self.assertEqual(2605 self.assertEqual(
2687 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),2606 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
@@ -2701,8 +2620,9 @@
2701 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())2620 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
2702 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())2621 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
27032622
2704 create_partitions(2623 board_conf = get_board_config('origen')
2705 board_configs['origen'], self.media, HEADS, SECTORS, '')2624 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
2625 create_partitions(board_conf, self.media, HEADS, SECTORS, '')
27062626
2707 self.assertEqual(2627 self.assertEqual(
2708 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),2628 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
@@ -2722,8 +2642,10 @@
2722 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())2642 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
2723 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())2643 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
27242644
2645 board_conf = get_board_config('origen_quad')
2646 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
2725 create_partitions(2647 create_partitions(
2726 board_configs['origen_quad'], self.media, HEADS, SECTORS, '')2648 board_conf, self.media, HEADS, SECTORS, '')
27272649
2728 self.assertEqual(2650 self.assertEqual(
2729 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),2651 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
@@ -2743,8 +2665,10 @@
2743 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())2665 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
2744 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())2666 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
27452667
2668 board_conf = get_board_config('arndale')
2669 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
2746 create_partitions(2670 create_partitions(
2747 board_configs['arndale'], self.media, HEADS, SECTORS, '')2671 board_conf, self.media, HEADS, SECTORS, '')
27482672
2749 self.assertEqual(2673 self.assertEqual(
2750 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),2674 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
@@ -2763,8 +2687,9 @@
2763 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())2687 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
2764 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())2688 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
27652689
2766 create_partitions(2690 board_conf = get_board_config('beagle')
2767 board_configs['beagle'], self.media, HEADS, SECTORS, '')2691 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
2692 create_partitions(board_conf, self.media, HEADS, SECTORS, '')
27682693
2769 self.assertEqual(2694 self.assertEqual(
2770 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),2695 ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path),
@@ -2782,8 +2707,9 @@
2782 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())2707 sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
27832708
2784 tmpfile = self.createTempFileAsFixture()2709 tmpfile = self.createTempFileAsFixture()
2785 create_partitions(2710 board_conf = get_board_config('beagle')
2786 board_configs['beagle'], Media(tmpfile), HEADS, SECTORS, '')2711 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
2712 create_partitions(board_conf, Media(tmpfile), HEADS, SECTORS, '')
27872713
2788 # Unlike the test for partitioning of a regular block device, in this2714 # Unlike the test for partitioning of a regular block device, in this
2789 # case parted was not called as there's no existing partition table2715 # case parted was not called as there's no existing partition table
@@ -3017,7 +2943,7 @@
3017 self.assertEqual(2943 self.assertEqual(
3018 ("%s%d" % (tmpfile, 1), "%s%d" % (tmpfile, 2)),2944 ("%s%d" % (tmpfile, 1), "%s%d" % (tmpfile, 2)),
3019 get_boot_and_root_partitions_for_media(2945 get_boot_and_root_partitions_for_media(
3020 media, board_configs['beagle']))2946 media, get_board_config('beagle')))
30212947
3022 def test_get_boot_and_root_partitions_for_media_mx5(self):2948 def test_get_boot_and_root_partitions_for_media_mx5(self):
3023 self.useFixture(MockSomethingFixture(2949 self.useFixture(MockSomethingFixture(
@@ -3028,7 +2954,7 @@
3028 media.is_block_device = True2954 media.is_block_device = True
3029 self.assertEqual(2955 self.assertEqual(
3030 ("%s%d" % (tmpfile, 2), "%s%d" % (tmpfile, 3)),2956 ("%s%d" % (tmpfile, 2), "%s%d" % (tmpfile, 3)),
3031 get_boot_and_root_partitions_for_media(media, boards.Mx5Config))2957 get_boot_and_root_partitions_for_media(media, boards.Mx5Config()))
30322958
3033 def _create_qemu_img_with_partitions(self, sfdisk_commands, tempfile_size):2959 def _create_qemu_img_with_partitions(self, sfdisk_commands, tempfile_size):
3034 tmpfile = self.createTempFileAsFixture()2960 tmpfile = self.createTempFileAsFixture()
@@ -3142,8 +3068,12 @@
3142 self.useFixture(MockSomethingFixture(3068 self.useFixture(MockSomethingFixture(
3143 partitions, 'get_boot_and_root_loopback_devices',3069 partitions, 'get_boot_and_root_loopback_devices',
3144 lambda image: ('/dev/loop99', '/dev/loop98')))3070 lambda image: ('/dev/loop99', '/dev/loop98')))
3071
3072 board_conf = get_board_config('beagle')
3073 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
3074
3145 bootfs_dev, rootfs_dev = setup_partitions(3075 bootfs_dev, rootfs_dev = setup_partitions(
3146 board_configs['beagle'], Media(tmpfile), '2G', 'boot',3076 board_conf, Media(tmpfile), '2G', 'boot',
3147 'root', 'ext3', True, True, True)3077 'root', 'ext3', True, True, True)
3148 self.assertEqual(3078 self.assertEqual(
3149 # This is the call that would create a 2 GiB image file.3079 # This is the call that would create a 2 GiB image file.
@@ -3173,8 +3103,12 @@
3173 # Pretend our tmpfile is a block device.3103 # Pretend our tmpfile is a block device.
3174 media.is_block_device = True3104 media.is_block_device = True
3175 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())3105 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
3106
3107 board_conf = get_board_config('beagle')
3108 board_conf.hwpack_format = HardwarepackHandler.FORMAT_1
3109
3176 bootfs_dev, rootfs_dev = setup_partitions(3110 bootfs_dev, rootfs_dev = setup_partitions(
3177 board_configs['beagle'], media, '2G', 'boot', 'root', 'ext3',3111 board_conf, media, '2G', 'boot', 'root', 'ext3',
3178 True, True, True)3112 True, True, True)
3179 self.assertEqual(3113 self.assertEqual(
3180 ['%s parted -s %s mklabel msdos' % (sudo_args, tmpfile),3114 ['%s parted -s %s mklabel msdos' % (sudo_args, tmpfile),
@@ -3200,7 +3134,7 @@
3200 mock_get_udisks_device_path))3134 mock_get_udisks_device_path))
32013135
3202 tmpfile = self.createTempFileAsFixture()3136 tmpfile = self.createTempFileAsFixture()
3203 partition = board_configs['beagle'].mmc_part_offset3137 partition = get_board_config('beagle').mmc_part_offset
32043138
3205 self.useFixture(MockSomethingFixture(3139 self.useFixture(MockSomethingFixture(
3206 glob, 'glob',3140 glob, 'glob',
@@ -3243,7 +3177,7 @@
3243 mock_get_udisks_device_file))3177 mock_get_udisks_device_file))
32443178
3245 tmpfile = self.createTempFileAsFixture()3179 tmpfile = self.createTempFileAsFixture()
3246 partition = board_configs['beagle'].mmc_part_offset3180 partition = get_board_config('beagle').mmc_part_offset
32473181
3248 self.useFixture(MockSomethingFixture(3182 self.useFixture(MockSomethingFixture(
3249 glob, 'glob',3183 glob, 'glob',
@@ -3328,14 +3262,12 @@
3328 self.saved_args = args3262 self.saved_args = args
33293263
3330 def prepare_config(self, config):3264 def prepare_config(self, config):
3331 class c(config):3265 self.config = config
3332 pass
3333
3334 self.config = c
3335 self.config.boot_script = 'boot_script'3266 self.config.boot_script = 'boot_script'
3336 self.config.hardwarepack_handler = \3267 self.config.hardwarepack_handler = \
3337 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz')3268 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz')
3338 self.config.hardwarepack_handler.get_format = lambda: '1.0'3269 self.config.hardwarepack_handler.get_format = \
3270 lambda: HardwarepackHandler.FORMAT_1
3339 self.popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())3271 self.popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
3340 self.useFixture(MockSomethingFixture(3272 self.useFixture(MockSomethingFixture(
3341 self.config, 'make_boot_files', self.save_args))3273 self.config, 'make_boot_files', self.save_args))
@@ -3351,10 +3283,7 @@
3351 return None3283 return None
33523284
3353 def prepare_config_v3(self, config):3285 def prepare_config_v3(self, config):
3354 class c(config):3286 self.config = config
3355 pass
3356
3357 self.config = c
3358 self.config.boot_script = 'boot_script'3287 self.config.boot_script = 'boot_script'
3359 self.config.hardwarepack_handler = \3288 self.config.hardwarepack_handler = \
3360 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz')3289 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz')
@@ -3378,21 +3307,21 @@
3378 'boot_device_or_file', is_live, False, [])3307 'boot_device_or_file', is_live, False, [])
33793308
3380 def test_populate_boot_live(self):3309 def test_populate_boot_live(self):
3381 self.prepare_config(boards.BoardConfig)3310 self.prepare_config(BoardConfig())
3382 self.call_populate_boot(self.config, is_live=True)3311 self.call_populate_boot(self.config, is_live=True)
3383 self.assertEquals(3312 self.assertEquals(
3384 self.expected_calls, self.popen_fixture.mock.commands_executed)3313 self.expected_calls, self.popen_fixture.mock.commands_executed)
3385 self.assertEquals(self.expected_args_live, self.saved_args)3314 self.assertEquals(self.expected_args_live, self.saved_args)
33863315
3387 def test_populate_boot_regular(self):3316 def test_populate_boot_regular(self):
3388 self.prepare_config(boards.BoardConfig)3317 self.prepare_config(BoardConfig())
3389 self.call_populate_boot(self.config)3318 self.call_populate_boot(self.config)
3390 self.assertEquals(3319 self.assertEquals(
3391 self.expected_calls, self.popen_fixture.mock.commands_executed)3320 self.expected_calls, self.popen_fixture.mock.commands_executed)
3392 self.assertEquals(self.expected_args, self.saved_args)3321 self.assertEquals(self.expected_args, self.saved_args)
33933322
3394 def test_populate_boot_bootloader_flavor(self):3323 def test_populate_boot_bootloader_flavor(self):
3395 self.prepare_config(boards.BoardConfig)3324 self.prepare_config(BoardConfig())
3396 self.config.bootloader_flavor = "bootloader_flavor"3325 self.config.bootloader_flavor = "bootloader_flavor"
3397 self.call_populate_boot(self.config)3326 self.call_populate_boot(self.config)
3398 self.assertEquals(3327 self.assertEquals(
@@ -3400,7 +3329,7 @@
3400 self.assertEquals(self.expected_args, self.saved_args)3329 self.assertEquals(self.expected_args, self.saved_args)
34013330
3402 def test_populate_boot_bootloader_file_in_boot_part(self):3331 def test_populate_boot_bootloader_file_in_boot_part(self):
3403 self.prepare_config(boards.BoardConfig)3332 self.prepare_config(BoardConfig())
3404 self.config.bootloader_flavor = "bootloader_flavor"3333 self.config.bootloader_flavor = "bootloader_flavor"
3405 self.config.bootloader_file_in_boot_part = True3334 self.config.bootloader_file_in_boot_part = True
3406 self.config.bootloader = "u_boot"3335 self.config.bootloader = "u_boot"
@@ -3414,7 +3343,7 @@
3414 self.assertEquals(self.expected_args, self.saved_args)3343 self.assertEquals(self.expected_args, self.saved_args)
34153344
3416 def test_populate_boot_bootloader_file_in_boot_part_false(self):3345 def test_populate_boot_bootloader_file_in_boot_part_false(self):
3417 self.prepare_config(boards.BoardConfig)3346 self.prepare_config(BoardConfig())
3418 self.config.bootloader_flavor = "bootloader_flavor"3347 self.config.bootloader_flavor = "bootloader_flavor"
3419 self.config.bootloader_file_in_boot_part = False3348 self.config.bootloader_file_in_boot_part = False
3420 self.call_populate_boot(self.config)3349 self.call_populate_boot(self.config)
@@ -3424,7 +3353,7 @@
3424 self.assertEquals(self.expected_args, self.saved_args)3353 self.assertEquals(self.expected_args, self.saved_args)
34253354
3426 def test_populate_bootloader_copy_files(self):3355 def test_populate_bootloader_copy_files(self):
3427 self.prepare_config_v3(boards.BoardConfig)3356 self.prepare_config_v3(BoardConfig())
3428 self.config.bootloader_flavor = "bootloader_flavor"3357 self.config.bootloader_flavor = "bootloader_flavor"
3429 # Test that copy_files works per spec (puts stuff in boot partition)3358 # Test that copy_files works per spec (puts stuff in boot partition)
3430 # even if bootloader not in_boot_part.3359 # even if bootloader not in_boot_part.
@@ -3444,7 +3373,7 @@
3444 self.assertEquals(self.expected_args, self.saved_args)3373 self.assertEquals(self.expected_args, self.saved_args)
34453374
3446 def test_populate_bootloader_copy_files_bootloader_set(self):3375 def test_populate_bootloader_copy_files_bootloader_set(self):
3447 self.prepare_config_v3(boards.BoardConfig)3376 self.prepare_config_v3(BoardConfig())
3448 self.config.bootloader_flavor = "bootloader_flavor"3377 self.config.bootloader_flavor = "bootloader_flavor"
3449 # Test that copy_files works per spec (puts stuff in boot partition)3378 # Test that copy_files works per spec (puts stuff in boot partition)
3450 # even if bootloader not in_boot_part.3379 # even if bootloader not in_boot_part.
@@ -3465,7 +3394,7 @@
3465 self.assertEquals(self.expected_args, self.saved_args)3394 self.assertEquals(self.expected_args, self.saved_args)
34663395
3467 def test_populate_boot_no_bootloader_flavor(self):3396 def test_populate_boot_no_bootloader_flavor(self):
3468 self.prepare_config(boards.BoardConfig)3397 self.prepare_config(BoardConfig())
3469 self.config.bootloader_file_in_boot_part = True3398 self.config.bootloader_file_in_boot_part = True
3470 self.assertRaises(3399 self.assertRaises(
3471 AssertionError, self.call_populate_boot, self.config)3400 AssertionError, self.call_populate_boot, self.config)
@@ -3612,10 +3541,7 @@
3612 os.makedirs(os.path.join(tempdir, 'etc', 'network'))3541 os.makedirs(os.path.join(tempdir, 'etc', 'network'))
3613 if_path = os.path.join(tempdir, 'etc', 'network', 'interfaces')3542 if_path = os.path.join(tempdir, 'etc', 'network', 'interfaces')
36143543
3615 class board_config(boards.BoardConfig):3544 update_network_interfaces(tempdir, BoardConfig())
3616 pass
3617
3618 update_network_interfaces(tempdir, board_config)
3619 self.assertFalse(os.path.exists(if_path))3545 self.assertFalse(os.path.exists(if_path))
36203546
3621 def test_update_interfaces_creates_entry(self):3547 def test_update_interfaces_creates_entry(self):
@@ -3626,12 +3552,12 @@
3626 os.makedirs(os.path.join(tempdir, 'etc', 'network'))3552 os.makedirs(os.path.join(tempdir, 'etc', 'network'))
3627 if_path = os.path.join(tempdir, 'etc', 'network', 'interfaces')3553 if_path = os.path.join(tempdir, 'etc', 'network', 'interfaces')
36283554
3629 class board_config(boards.BoardConfig):3555 board_conf = BoardConfig()
3630 wired_interfaces = ['eth0']3556 board_conf.wired_interfaces = ['eth0']
36313557
3632 expected = 'auto eth0\n' \3558 expected = 'auto eth0\n' \
3633 'iface eth0 inet dhcp\n'3559 'iface eth0 inet dhcp\n'
3634 update_network_interfaces(tempdir, board_config)3560 update_network_interfaces(tempdir, board_conf)
3635 self.assertEqual(expected, open(if_path).read())3561 self.assertEqual(expected, open(if_path).read())
36363562
3637 def test_update_interfaces_creates_entries(self):3563 def test_update_interfaces_creates_entries(self):
@@ -3642,14 +3568,14 @@
3642 os.makedirs(os.path.join(tempdir, 'etc', 'network'))3568 os.makedirs(os.path.join(tempdir, 'etc', 'network'))
3643 if_path = os.path.join(tempdir, 'etc', 'network', 'interfaces')3569 if_path = os.path.join(tempdir, 'etc', 'network', 'interfaces')
36443570
3645 class board_config(boards.BoardConfig):3571 board_conf = BoardConfig()
3646 wired_interfaces = ['eth0', 'eth1']3572 board_conf.wired_interfaces = ['eth0', 'eth1']
3647 wireless_interfaces = ['wlan0']3573 board_conf.wireless_interfaces = ['wlan0']
36483574
3649 expected = 'auto %(if)s\n' \3575 expected = 'auto %(if)s\n' \
3650 'iface %(if)s inet dhcp\n'3576 'iface %(if)s inet dhcp\n'
36513577
3652 update_network_interfaces(tempdir, board_config)3578 update_network_interfaces(tempdir, board_conf)
3653 self.assertIn(expected % {'if': 'eth1'}, open(if_path).read())3579 self.assertIn(expected % {'if': 'eth1'}, open(if_path).read())
3654 self.assertIn(expected % {'if': 'eth0'}, open(if_path).read())3580 self.assertIn(expected % {'if': 'eth0'}, open(if_path).read())
3655 self.assertIn(expected % {'if': 'wlan0'}, open(if_path).read())3581 self.assertIn(expected % {'if': 'wlan0'}, open(if_path).read())
@@ -3664,13 +3590,13 @@
3664 with open(if_path, 'w') as interfaces:3590 with open(if_path, 'w') as interfaces:
3665 interfaces.write('Original contents of file.\n')3591 interfaces.write('Original contents of file.\n')
36663592
3667 class board_config(boards.BoardConfig):3593 board_conf = BoardConfig()
3668 wired_interfaces = ['eth0']3594 board_conf.wired_interfaces = ['eth0']
36693595
3670 expected = 'Original contents of file.\n' \3596 expected = 'Original contents of file.\n' \
3671 'auto eth0\n' \3597 'auto eth0\n' \
3672 'iface eth0 inet dhcp\n'3598 'iface eth0 inet dhcp\n'
3673 update_network_interfaces(tempdir, board_config)3599 update_network_interfaces(tempdir, board_conf)
3674 self.assertEqual(expected, open(if_path).read())3600 self.assertEqual(expected, open(if_path).read())
36753601
3676 def test_write_data_to_protected_file(self):3602 def test_write_data_to_protected_file(self):
36773603
=== modified file 'linaro_image_tools/tests/__init__.py'
--- linaro_image_tools/tests/__init__.py 2012-06-07 13:22:47 +0000
+++ linaro_image_tools/tests/__init__.py 2013-01-03 13:57:23 +0000
@@ -1,3 +1,20 @@
1# Copyright (C) 2010, 2011, 2012 Linaro
2#
3# This file is part of Linaro Image Tools.
4#
5# Linaro Image Tools is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# Linaro Image Tools is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
1import os18import os
2import unittest19import unittest
320

Subscribers

People subscribed via source and target branches