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
1=== modified file 'linaro_media_create/boards.py'
2--- linaro_media_create/boards.py 2011-01-28 19:50:48 +0000
3+++ linaro_media_create/boards.py 2011-02-01 13:26:55 +0000
4@@ -146,6 +146,15 @@
5 _serial_tty = None
6
7 @classproperty
8+ def serial_tty(cls):
9+ # This is just to make sure no callsites use .serial_tty before
10+ # calling set_appropriate_serial_tty(). If we had this in the first
11+ # place we'd have uncovered bug 710971 before releasing.
12+ raise AttributeError(
13+ "You must not use this attribute before calling "
14+ "set_appropriate_serial_tty")
15+
16+ @classproperty
17 def live_serial_opts(cls):
18 return cls._live_serial_opts % cls.serial_tty
19
20@@ -161,18 +170,29 @@
21 we use the default value (_serial_tty).
22 """
23 # XXX: This is also part of our temporary hack to fix bug 697824.
24- cls.serial_tty = cls._serial_tty
25+ cls.serial_tty = classproperty(lambda cls: cls._serial_tty)
26 vmlinuz = _get_file_matching(
27 os.path.join(chroot_dir, 'boot', 'vmlinuz*'))
28 basename = os.path.basename(vmlinuz)
29 minor_version = re.match('.*2\.6\.([0-9]{2}).*', basename).group(1)
30 if int(minor_version) < 36:
31- cls.serial_tty = 'ttyS2'
32+ cls.serial_tty = classproperty(lambda cls: 'ttyS2')
33+
34+ @classmethod
35+ def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles,
36+ root_dir, rootfs_uuid, boot_dir, boot_script,
37+ boot_device_or_file):
38+ # XXX: This is also part of our temporary hack to fix bug 697824; we
39+ # need to call set_appropriate_serial_tty() before doing anything that
40+ # may use cls.serial_tty.
41+ cls.set_appropriate_serial_tty(root_dir)
42+ super(OmapConfig, cls).make_boot_files(
43+ uboot_parts_dir, is_live, is_lowmem, consoles, root_dir,
44+ rootfs_uuid, boot_dir, boot_script, boot_device_or_file)
45
46 @classmethod
47 def _make_boot_files(cls, uboot_parts_dir, boot_cmd, chroot_dir,
48 boot_dir, boot_script, boot_device_or_file):
49- cls.set_appropriate_serial_tty(chroot_dir)
50 install_omap_boot_loader(chroot_dir, boot_dir)
51 make_uImage(
52 cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
53
54=== modified file 'linaro_media_create/tests/test_media_create.py'
55--- linaro_media_create/tests/test_media_create.py 2011-01-28 19:50:48 +0000
56+++ linaro_media_create/tests/test_media_create.py 2011-02-01 13:26:55 +0000
57@@ -3,7 +3,7 @@
58 # Author: Guilherme Salgado <guilherme.salgado@linaro.org>
59 #
60 # This file is part of Linaro Image Tools.
61-#
62+#
63 # Linaro Image Tools is free software: you can redistribute it and/or modify
64 # it under the terms of the GNU General Public License as published by
65 # the Free Software Foundation, either version 3 of the License, or
66@@ -42,6 +42,7 @@
67 )
68 import linaro_media_create
69 from linaro_media_create.boards import (
70+ BoardConfig,
71 board_configs,
72 make_boot_script,
73 make_uImage,
74@@ -248,6 +249,32 @@
75
76 class TestFixForBug697824(TestCaseWithFixtures):
77
78+ def mock_set_appropriate_serial_tty(self, config):
79+
80+ def set_appropriate_serial_tty_mock(cls, chroot_dir):
81+ self.set_appropriate_serial_tty_called = True
82+ cls.serial_tty = cls._serial_tty
83+
84+ self.useFixture(MockSomethingFixture(
85+ config, 'set_appropriate_serial_tty',
86+ classmethod(set_appropriate_serial_tty_mock)))
87+
88+ def test_omap_make_boot_files(self):
89+ self.set_appropriate_serial_tty_called = False
90+ self.mock_set_appropriate_serial_tty(board_configs['beagle'])
91+ self.useFixture(MockSomethingFixture(
92+ BoardConfig, 'make_boot_files',
93+ classmethod(lambda *args: None)))
94+ # We don't need to worry about what's passed to make_boot_files()
95+ # because we mock the method which does the real work above and here
96+ # we're only interested in ensuring that OmapConfig.make_boot_files()
97+ # calls set_appropriate_serial_tty().
98+ board_configs['beagle'].make_boot_files(
99+ None, None, None, None, None, None, None, None, None)
100+ self.assertTrue(
101+ self.set_appropriate_serial_tty_called,
102+ "make_boot_files didn't call set_appropriate_serial_tty")
103+
104 def test_set_appropriate_serial_tty_old_kernel(self):
105 tempdir = self.useFixture(CreateTempDirFixture()).tempdir
106 boot_dir = os.path.join(tempdir, 'boot')
107@@ -316,7 +343,12 @@
108 self.assertEqual(expected, boot_cmd)
109
110 def test_panda(self):
111- boot_cmd = board_configs['panda']._get_boot_cmd(
112+ # XXX: To fix bug 697824 we have to change class attributes of our
113+ # OMAP board configs, and some tests do that so to make sure they
114+ # don't interfere with us we'll reset that before doing anything.
115+ config = board_configs['panda']
116+ config.serial_tty = config._serial_tty
117+ boot_cmd = config._get_boot_cmd(
118 is_live=False, is_lowmem=False, consoles=None,
119 rootfs_uuid="deadbeef")
120 expected = (
121@@ -347,7 +379,12 @@
122 self.assertEqual(expected, boot_cmd)
123
124 def test_overo(self):
125- boot_cmd = board_configs['overo']._get_boot_cmd(
126+ # XXX: To fix bug 697824 we have to change class attributes of our
127+ # OMAP board configs, and some tests do that so to make sure they
128+ # don't interfere with us we'll reset that before doing anything.
129+ config = board_configs['overo']
130+ config.serial_tty = config._serial_tty
131+ boot_cmd = config._get_boot_cmd(
132 is_live=False, is_lowmem=False, consoles=None,
133 rootfs_uuid="deadbeef")
134 expected = (

Subscribers

People subscribed via source and target branches