From patchwork Wed Jan 25 11:55:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guilherme Salgado X-Patchwork-Id: 6404 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2F38323E81 for ; Wed, 25 Jan 2012 11:55:19 +0000 (UTC) Received: from mail-bk0-f52.google.com (mail-bk0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id 07353A183BD for ; Wed, 25 Jan 2012 11:55:19 +0000 (UTC) Received: by bkar19 with SMTP id r19so5184086bka.11 for ; Wed, 25 Jan 2012 03:55:18 -0800 (PST) Received: by 10.205.120.17 with SMTP id fw17mr6689024bkc.74.1327492518689; Wed, 25 Jan 2012 03:55:18 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.204.130.220 with SMTP id u28cs5913bks; Wed, 25 Jan 2012 03:55:18 -0800 (PST) Received: by 10.180.8.103 with SMTP id q7mr27838822wia.1.1327492517122; Wed, 25 Jan 2012 03:55:17 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id l3si160952wed.120.2012.01.25.03.55.16 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 Jan 2012 03:55:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1Rq1Rc-0004Ak-K5 for ; Wed, 25 Jan 2012 11:55:16 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 8DE32E017D for ; Wed, 25 Jan 2012 11:55:16 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: linaro-image-tools X-Launchpad-Branch: ~linaro-image-tools/linaro-image-tools/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 487 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 487: Make sure the new --extra-boot-args argument works when the extra_boot_args_options attribute of ... Message-Id: <20120125115516.21494.45891.launchpad@ackee.canonical.com> Date: Wed, 25 Jan 2012 11:55:16 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14719"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 08b15a1fad860ec3fd24c3621d7bfc3f78e2efae X-Gm-Message-State: ALoCoQkwDVE5YbDCwMCbnT7VrPyMaD5KBgrfI6C9OlK15YUKouXQQMsrHxTHBpnBF7b2p1jWPcd5 Merge authors: Guilherme Salgado (salgado) Related merge proposals: https://code.launchpad.net/~salgado/linaro-image-tools/fix-913819/+merge/89975 proposed by: Guilherme Salgado (salgado) review: Approve - Mattias Backman (mabac) ------------------------------------------------------------ revno: 487 [merge] committer: Guilherme Salgado branch nick: trunk timestamp: Wed 2012-01-25 08:52:33 -0300 message: Make sure the new --extra-boot-args argument works when the extra_boot_args_options attribute of the board config is set to None modified: linaro_image_tools/media_create/boards.py linaro_image_tools/media_create/tests/test_media_create.py --- lp:linaro-image-tools https://code.launchpad.net/~linaro-image-tools/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-image-tools/linaro-image-tools/trunk/+edit-subscription === modified file 'linaro_image_tools/media_create/boards.py' --- linaro_image_tools/media_create/boards.py 2012-01-18 15:27:35 +0000 +++ linaro_image_tools/media_create/boards.py 2012-01-24 18:40:27 +0000 @@ -577,7 +577,10 @@ @classmethod def add_boot_args(cls, extra_args): if extra_args is not None: - cls.extra_boot_args_options += ' %s' % extra_args + if cls.extra_boot_args_options is None: + cls.extra_boot_args_options = extra_args + else: + cls.extra_boot_args_options += ' %s' % extra_args @classmethod def add_boot_args_from_file(cls, path): === modified file 'linaro_image_tools/media_create/tests/test_media_create.py' --- linaro_image_tools/media_create/tests/test_media_create.py 2012-01-17 14:50:47 +0000 +++ linaro_image_tools/media_create/tests/test_media_create.py 2012-01-24 18:40:27 +0000 @@ -1414,96 +1414,70 @@ class TestExtraBootCmd(TestCaseWithFixtures): - def test_no_extra_args(self): - boot_args = ''.join( - random.choice(string.ascii_lowercase) for x in range(15)) - class config(BoardConfig): - extra_boot_args_options = boot_args - boot_commands = config._get_boot_env( - is_live=False, is_lowmem=False, consoles=['ttyXXX'], - rootfs_uuid="deadbeef", d_img_data=None) - expected = ' '.join([' console=ttyXXX root=UUID=deadbeef rootwait ro', - boot_args]) - self.assertEqual(expected, boot_commands['bootargs']) - - def test_none_extra_args(self): - boot_args = ''.join( - random.choice(string.ascii_lowercase) for x in range(15)) - extra_args = None - class config(BoardConfig): - extra_boot_args_options = boot_args - config.add_boot_args(extra_args) - boot_commands = config._get_boot_env( - is_live=False, is_lowmem=False, consoles=['ttyXXX'], - rootfs_uuid="deadbeef", d_img_data=None) - expected = ' '.join([' console=ttyXXX root=UUID=deadbeef rootwait ro', - boot_args]) - self.assertEqual(expected, boot_commands['bootargs']) - - def test_string_extra_args(self): - boot_args = ''.join( - random.choice(string.ascii_lowercase) for x in range(15)) - extra_args = ''.join( - random.choice(string.ascii_lowercase) for x in range(15)) - class config(BoardConfig): - extra_boot_args_options = boot_args - config.add_boot_args(extra_args) - boot_commands = config._get_boot_env( - is_live=False, is_lowmem=False, consoles=['ttyXXX'], - rootfs_uuid="deadbeef", d_img_data=None) - expected = ' '.join([' console=ttyXXX root=UUID=deadbeef rootwait ro', - boot_args, extra_args]) - self.assertEqual(expected, boot_commands['bootargs']) - - def test_file_extra_args(self): - boot_args = ''.join( - random.choice(string.ascii_lowercase) for x in range(15)) - extra_args = ''.join( - random.choice(string.ascii_lowercase) for x in range(15)) + def test_extra_boot_args_options_is_picked_by_get_boot_env(self): + boot_args = 'whatever' + class config(BoardConfig): + extra_boot_args_options = boot_args + boot_commands = config._get_boot_env( + is_live=False, is_lowmem=False, consoles=['ttyXXX'], + rootfs_uuid="deadbeef", d_img_data=None) + expected = ( + ' console=ttyXXX root=UUID=deadbeef rootwait ro %s' % boot_args) + self.assertEqual(expected, boot_commands['bootargs']) + + def test_passing_None_to_add_boot_args(self): + boot_args = 'extra-args' + class config(BoardConfig): + extra_boot_args_options = boot_args + config.add_boot_args(None) + self.assertEqual(boot_args, config.extra_boot_args_options) + + def test_passing_string_to_add_boot_args(self): + boot_args = 'extra-args' + extra_args = 'user-args' + class config(BoardConfig): + extra_boot_args_options = boot_args + config.add_boot_args(extra_args) + self.assertEqual( + "%s %s" % (boot_args, extra_args), config.extra_boot_args_options) + + def test_passing_string_to_add_boot_args_with_no_default_extra_args(self): + extra_args = 'user-args' + class config(BoardConfig): + extra_boot_args_options = None + config.add_boot_args(extra_args) + self.assertEqual(extra_args, config.extra_boot_args_options) + + def test_add_boot_args_from_file(self): + boot_args = 'extra-args' + extra_args = 'user-args' boot_arg_path = self.createTempFileAsFixture() with open(boot_arg_path, 'w') as boot_arg_file: boot_arg_file.write(extra_args) class config(BoardConfig): extra_boot_args_options = boot_args config.add_boot_args_from_file(boot_arg_path) - boot_commands = config._get_boot_env( - is_live=False, is_lowmem=False, consoles=['ttyXXX'], - rootfs_uuid="deadbeef", d_img_data=None) - expected = ' '.join([' console=ttyXXX root=UUID=deadbeef rootwait ro', - boot_args, extra_args]) - self.assertEqual(expected, boot_commands['bootargs']) + self.assertEqual( + "%s %s" % (boot_args, extra_args), config.extra_boot_args_options) - def test_none_file_extra_args(self): - boot_args = ''.join( - random.choice(string.ascii_lowercase) for x in range(15)) - boot_arg_path = None + def test_passing_None_to_add_boot_args_from_file(self): + boot_args = 'extra-args' class config(BoardConfig): extra_boot_args_options = boot_args - config.add_boot_args_from_file(boot_arg_path) - boot_commands = config._get_boot_env( - is_live=False, is_lowmem=False, consoles=['ttyXXX'], - rootfs_uuid="deadbeef", d_img_data=None) - expected = ' '.join([' console=ttyXXX root=UUID=deadbeef rootwait ro', - boot_args]) - self.assertEqual(expected, boot_commands['bootargs']) + config.add_boot_args_from_file(None) + self.assertEqual(boot_args, config.extra_boot_args_options) - def test_whitespace_file_extra_args(self): - boot_args = ''.join( - random.choice(string.ascii_lowercase) for x in range(15)) - extra_args = ''.join( - random.choice(string.ascii_lowercase) for x in range(15)) + def test_add_boot_args_from_file_strips_whitespace_from_file(self): + boot_args = 'extra-args' + extra_args = 'user-args' boot_arg_path = self.createTempFileAsFixture() with open(boot_arg_path, 'w') as boot_arg_file: boot_arg_file.write('\n\n \t ' + extra_args + ' \n\n') class config(BoardConfig): extra_boot_args_options = boot_args config.add_boot_args_from_file(boot_arg_path) - boot_commands = config._get_boot_env( - is_live=False, is_lowmem=False, consoles=['ttyXXX'], - rootfs_uuid="deadbeef", d_img_data=None) - expected = ' '.join([' console=ttyXXX root=UUID=deadbeef rootwait ro', - boot_args, extra_args]) - self.assertEqual(expected, boot_commands['bootargs']) + self.assertEqual( + "%s %s" % (boot_args, extra_args), config.extra_boot_args_options) class TestGetBootCmdAndroid(TestCase):