Merge lp:~salgado/linaro-image-tools/bug-710971 into lp:linaro-image-tools/11.11

Proposed by Guilherme Salgado
Status: Merged
Merged at revision: 275
Proposed branch: lp:~salgado/linaro-image-tools/bug-710971
Merge into: lp:linaro-image-tools/11.11
Diff against target: 134 lines (+63/-6)
2 files modified
linaro_media_create/boards.py (+23/-3)
linaro_media_create/tests/test_media_create.py (+40/-3)
To merge this branch: bzr merge lp:~salgado/linaro-image-tools/bug-710971
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+48154@code.launchpad.net

Description of the change

Fix the bug by making sure OmapConfig.serial_tty is never used before set_appropriate_serial_tty() is called.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Looks good, thanks.

BoardConfigs as classes rather than objects is looking increasingly creaky
IMO, but it's likely to be rewritten with hwpacks v2 anyway.

Thanks,

James

review: Approve
Revision history for this message
Guilherme Salgado (salgado) wrote :

On Tue, 2011-02-01 at 14:33 +0000, James Westby wrote:
> Review: Approve
> Looks good, thanks.
>
> BoardConfigs as classes rather than objects is looking increasingly creaky
> IMO, but it's likely to be rewritten with hwpacks v2 anyway.

That is true, but the creaky bits are part of the interim solution for
bug 697824. As you said, though, this is all going away with hwpacks
v2.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'linaro_media_create/boards.py'
--- linaro_media_create/boards.py 2011-01-28 19:50:48 +0000
+++ linaro_media_create/boards.py 2011-02-01 13:26:55 +0000
@@ -146,6 +146,15 @@
146 _serial_tty = None146 _serial_tty = None
147147
148 @classproperty148 @classproperty
149 def serial_tty(cls):
150 # This is just to make sure no callsites use .serial_tty before
151 # calling set_appropriate_serial_tty(). If we had this in the first
152 # place we'd have uncovered bug 710971 before releasing.
153 raise AttributeError(
154 "You must not use this attribute before calling "
155 "set_appropriate_serial_tty")
156
157 @classproperty
149 def live_serial_opts(cls):158 def live_serial_opts(cls):
150 return cls._live_serial_opts % cls.serial_tty159 return cls._live_serial_opts % cls.serial_tty
151160
@@ -161,18 +170,29 @@
161 we use the default value (_serial_tty).170 we use the default value (_serial_tty).
162 """171 """
163 # XXX: This is also part of our temporary hack to fix bug 697824.172 # XXX: This is also part of our temporary hack to fix bug 697824.
164 cls.serial_tty = cls._serial_tty173 cls.serial_tty = classproperty(lambda cls: cls._serial_tty)
165 vmlinuz = _get_file_matching(174 vmlinuz = _get_file_matching(
166 os.path.join(chroot_dir, 'boot', 'vmlinuz*'))175 os.path.join(chroot_dir, 'boot', 'vmlinuz*'))
167 basename = os.path.basename(vmlinuz)176 basename = os.path.basename(vmlinuz)
168 minor_version = re.match('.*2\.6\.([0-9]{2}).*', basename).group(1)177 minor_version = re.match('.*2\.6\.([0-9]{2}).*', basename).group(1)
169 if int(minor_version) < 36:178 if int(minor_version) < 36:
170 cls.serial_tty = 'ttyS2'179 cls.serial_tty = classproperty(lambda cls: 'ttyS2')
180
181 @classmethod
182 def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles,
183 root_dir, rootfs_uuid, boot_dir, boot_script,
184 boot_device_or_file):
185 # XXX: This is also part of our temporary hack to fix bug 697824; we
186 # need to call set_appropriate_serial_tty() before doing anything that
187 # may use cls.serial_tty.
188 cls.set_appropriate_serial_tty(root_dir)
189 super(OmapConfig, cls).make_boot_files(
190 uboot_parts_dir, is_live, is_lowmem, consoles, root_dir,
191 rootfs_uuid, boot_dir, boot_script, boot_device_or_file)
171192
172 @classmethod193 @classmethod
173 def _make_boot_files(cls, uboot_parts_dir, boot_cmd, chroot_dir,194 def _make_boot_files(cls, uboot_parts_dir, boot_cmd, chroot_dir,
174 boot_dir, boot_script, boot_device_or_file):195 boot_dir, boot_script, boot_device_or_file):
175 cls.set_appropriate_serial_tty(chroot_dir)
176 install_omap_boot_loader(chroot_dir, boot_dir)196 install_omap_boot_loader(chroot_dir, boot_dir)
177 make_uImage(197 make_uImage(
178 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)198 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
179199
=== modified file 'linaro_media_create/tests/test_media_create.py'
--- linaro_media_create/tests/test_media_create.py 2011-01-28 19:50:48 +0000
+++ linaro_media_create/tests/test_media_create.py 2011-02-01 13:26:55 +0000
@@ -3,7 +3,7 @@
3# Author: Guilherme Salgado <guilherme.salgado@linaro.org>3# Author: Guilherme Salgado <guilherme.salgado@linaro.org>
4#4#
5# This file is part of Linaro Image Tools.5# This file is part of Linaro Image Tools.
6# 6#
7# Linaro Image Tools is free software: you can redistribute it and/or modify7# 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 by8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or9# the Free Software Foundation, either version 3 of the License, or
@@ -42,6 +42,7 @@
42 )42 )
43import linaro_media_create43import linaro_media_create
44from linaro_media_create.boards import (44from linaro_media_create.boards import (
45 BoardConfig,
45 board_configs,46 board_configs,
46 make_boot_script,47 make_boot_script,
47 make_uImage,48 make_uImage,
@@ -248,6 +249,32 @@
248249
249class TestFixForBug697824(TestCaseWithFixtures):250class TestFixForBug697824(TestCaseWithFixtures):
250251
252 def mock_set_appropriate_serial_tty(self, config):
253
254 def set_appropriate_serial_tty_mock(cls, chroot_dir):
255 self.set_appropriate_serial_tty_called = True
256 cls.serial_tty = cls._serial_tty
257
258 self.useFixture(MockSomethingFixture(
259 config, 'set_appropriate_serial_tty',
260 classmethod(set_appropriate_serial_tty_mock)))
261
262 def test_omap_make_boot_files(self):
263 self.set_appropriate_serial_tty_called = False
264 self.mock_set_appropriate_serial_tty(board_configs['beagle'])
265 self.useFixture(MockSomethingFixture(
266 BoardConfig, 'make_boot_files',
267 classmethod(lambda *args: None)))
268 # We don't need to worry about what's passed to make_boot_files()
269 # because we mock the method which does the real work above and here
270 # we're only interested in ensuring that OmapConfig.make_boot_files()
271 # calls set_appropriate_serial_tty().
272 board_configs['beagle'].make_boot_files(
273 None, None, None, None, None, None, None, None, None)
274 self.assertTrue(
275 self.set_appropriate_serial_tty_called,
276 "make_boot_files didn't call set_appropriate_serial_tty")
277
251 def test_set_appropriate_serial_tty_old_kernel(self):278 def test_set_appropriate_serial_tty_old_kernel(self):
252 tempdir = self.useFixture(CreateTempDirFixture()).tempdir279 tempdir = self.useFixture(CreateTempDirFixture()).tempdir
253 boot_dir = os.path.join(tempdir, 'boot')280 boot_dir = os.path.join(tempdir, 'boot')
@@ -316,7 +343,12 @@
316 self.assertEqual(expected, boot_cmd)343 self.assertEqual(expected, boot_cmd)
317344
318 def test_panda(self):345 def test_panda(self):
319 boot_cmd = board_configs['panda']._get_boot_cmd(346 # XXX: To fix bug 697824 we have to change class attributes of our
347 # OMAP board configs, and some tests do that so to make sure they
348 # don't interfere with us we'll reset that before doing anything.
349 config = board_configs['panda']
350 config.serial_tty = config._serial_tty
351 boot_cmd = config._get_boot_cmd(
320 is_live=False, is_lowmem=False, consoles=None,352 is_live=False, is_lowmem=False, consoles=None,
321 rootfs_uuid="deadbeef")353 rootfs_uuid="deadbeef")
322 expected = (354 expected = (
@@ -347,7 +379,12 @@
347 self.assertEqual(expected, boot_cmd)379 self.assertEqual(expected, boot_cmd)
348380
349 def test_overo(self):381 def test_overo(self):
350 boot_cmd = board_configs['overo']._get_boot_cmd(382 # XXX: To fix bug 697824 we have to change class attributes of our
383 # OMAP board configs, and some tests do that so to make sure they
384 # don't interfere with us we'll reset that before doing anything.
385 config = board_configs['overo']
386 config.serial_tty = config._serial_tty
387 boot_cmd = config._get_boot_cmd(
351 is_live=False, is_lowmem=False, consoles=None,388 is_live=False, is_lowmem=False, consoles=None,
352 rootfs_uuid="deadbeef")389 rootfs_uuid="deadbeef")
353 expected = (390 expected = (

Subscribers

People subscribed via source and target branches