From patchwork Tue Feb 1 14:57:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guilherme Salgado X-Patchwork-Id: 51 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:39:33 -0000 Delivered-To: patches@linaro.org Received: by 10.147.124.5 with SMTP id b5cs108402yan; Tue, 1 Feb 2011 06:57:35 -0800 (PST) Received: by 10.216.56.79 with SMTP id l57mr694003wec.86.1296572254325; Tue, 01 Feb 2011 06:57:34 -0800 (PST) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id b13si33985291wer.105.2011.02.01.06.57.33; Tue, 01 Feb 2011 06:57:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1PkHfh-0007FA-B8 for ; Tue, 01 Feb 2011 14:57:33 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 528572E80AD for ; Tue, 1 Feb 2011 14:57:33 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: linaro-image-tools X-Launchpad-Branch: ~linaro-maintainers/linaro-image-tools/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 275 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-maintainers/linaro-image-tools/trunk] Rev 275: Fix bug 710971 by making sure OmapConfig.serial_tty is never used before set_appropriate_serial_t... Message-Id: <20110201145733.7254.65206.launchpad@loganberry.canonical.com> Date: Tue, 01 Feb 2011 14:57:33 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="12274"; Instance="initZopeless config overlay" X-Launchpad-Hash: e3e629a26eead378720cced68e8ea3790cb2b787 Merge authors: Guilherme Salgado (salgado) Related merge proposals: https://code.launchpad.net/~salgado/linaro-image-tools/bug-710971/+merge/48154 proposed by: Guilherme Salgado (salgado) review: Approve - James Westby (james-w) ------------------------------------------------------------ revno: 275 [merge] committer: Guilherme Salgado branch nick: trunk timestamp: Tue 2011-02-01 12:53:09 -0200 message: Fix bug 710971 by making sure OmapConfig.serial_tty is never used before set_appropriate_serial_tty() is called. modified: linaro_media_create/boards.py linaro_media_create/tests/test_media_create.py --- lp:linaro-image-tools https://code.launchpad.net/~linaro-maintainers/linaro-image-tools/trunk You are subscribed to branch lp:linaro-image-tools. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-maintainers/linaro-image-tools/trunk/+edit-subscription === 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:16:43 +0000 @@ -146,6 +146,15 @@ _serial_tty = None @classproperty + def serial_tty(cls): + # This is just to make sure no callsites use .serial_tty before + # calling set_appropriate_serial_tty(). If we had this in the first + # place we'd have uncovered bug 710971 before releasing. + raise AttributeError( + "You must not use this attribute before calling " + "set_appropriate_serial_tty") + + @classproperty def live_serial_opts(cls): return cls._live_serial_opts % cls.serial_tty @@ -161,18 +170,29 @@ we use the default value (_serial_tty). """ # XXX: This is also part of our temporary hack to fix bug 697824. - cls.serial_tty = cls._serial_tty + cls.serial_tty = classproperty(lambda cls: cls._serial_tty) vmlinuz = _get_file_matching( os.path.join(chroot_dir, 'boot', 'vmlinuz*')) basename = os.path.basename(vmlinuz) minor_version = re.match('.*2\.6\.([0-9]{2}).*', basename).group(1) if int(minor_version) < 36: - cls.serial_tty = 'ttyS2' + cls.serial_tty = classproperty(lambda cls: 'ttyS2') + + @classmethod + def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles, + root_dir, rootfs_uuid, boot_dir, boot_script, + boot_device_or_file): + # XXX: This is also part of our temporary hack to fix bug 697824; we + # need to call set_appropriate_serial_tty() before doing anything that + # may use cls.serial_tty. + cls.set_appropriate_serial_tty(root_dir) + super(OmapConfig, cls).make_boot_files( + uboot_parts_dir, is_live, is_lowmem, consoles, root_dir, + rootfs_uuid, boot_dir, boot_script, boot_device_or_file) @classmethod def _make_boot_files(cls, uboot_parts_dir, boot_cmd, chroot_dir, boot_dir, boot_script, boot_device_or_file): - cls.set_appropriate_serial_tty(chroot_dir) install_omap_boot_loader(chroot_dir, boot_dir) make_uImage( cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir) === 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:16:43 +0000 @@ -3,7 +3,7 @@ # Author: Guilherme Salgado # # This file is part of Linaro Image Tools. -# +# # Linaro Image Tools is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or @@ -42,6 +42,7 @@ ) import linaro_media_create from linaro_media_create.boards import ( + BoardConfig, board_configs, make_boot_script, make_uImage, @@ -248,6 +249,32 @@ class TestFixForBug697824(TestCaseWithFixtures): + def mock_set_appropriate_serial_tty(self, config): + + def set_appropriate_serial_tty_mock(cls, chroot_dir): + self.set_appropriate_serial_tty_called = True + cls.serial_tty = cls._serial_tty + + self.useFixture(MockSomethingFixture( + config, 'set_appropriate_serial_tty', + classmethod(set_appropriate_serial_tty_mock))) + + def test_omap_make_boot_files(self): + self.set_appropriate_serial_tty_called = False + self.mock_set_appropriate_serial_tty(board_configs['beagle']) + self.useFixture(MockSomethingFixture( + BoardConfig, 'make_boot_files', + classmethod(lambda *args: None))) + # We don't need to worry about what's passed to make_boot_files() + # because we mock the method which does the real work above and here + # we're only interested in ensuring that OmapConfig.make_boot_files() + # calls set_appropriate_serial_tty(). + board_configs['beagle'].make_boot_files( + None, None, None, None, None, None, None, None, None) + self.assertTrue( + self.set_appropriate_serial_tty_called, + "make_boot_files didn't call set_appropriate_serial_tty") + def test_set_appropriate_serial_tty_old_kernel(self): tempdir = self.useFixture(CreateTempDirFixture()).tempdir boot_dir = os.path.join(tempdir, 'boot') @@ -316,7 +343,12 @@ self.assertEqual(expected, boot_cmd) def test_panda(self): - boot_cmd = board_configs['panda']._get_boot_cmd( + # XXX: To fix bug 697824 we have to change class attributes of our + # OMAP board configs, and some tests do that so to make sure they + # don't interfere with us we'll reset that before doing anything. + config = board_configs['panda'] + config.serial_tty = config._serial_tty + boot_cmd = config._get_boot_cmd( is_live=False, is_lowmem=False, consoles=None, rootfs_uuid="deadbeef") expected = ( @@ -347,7 +379,12 @@ self.assertEqual(expected, boot_cmd) def test_overo(self): - boot_cmd = board_configs['overo']._get_boot_cmd( + # XXX: To fix bug 697824 we have to change class attributes of our + # OMAP board configs, and some tests do that so to make sure they + # don't interfere with us we'll reset that before doing anything. + config = board_configs['overo'] + config.serial_tty = config._serial_tty + boot_cmd = config._get_boot_cmd( is_live=False, is_lowmem=False, consoles=None, rootfs_uuid="deadbeef") expected = (