From patchwork Thu Jan 19 10:06:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattias Backman X-Patchwork-Id: 6292 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 2430C23F72 for ; Thu, 19 Jan 2012 10:06:18 +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 0515BA1811F for ; Thu, 19 Jan 2012 10:06:17 +0000 (UTC) Received: by bkbzt4 with SMTP id zt4so4061439bkb.11 for ; Thu, 19 Jan 2012 02:06:17 -0800 (PST) Received: by 10.204.41.143 with SMTP id o15mr9988475bke.63.1326967576178; Thu, 19 Jan 2012 02:06:16 -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.205.82.144 with SMTP id ac16cs4863bkc; Thu, 19 Jan 2012 02:06:15 -0800 (PST) Received: by 10.180.109.198 with SMTP id hu6mr528137wib.16.1326967574401; Thu, 19 Jan 2012 02:06:14 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id n44si8746327weq.123.2012.01.19.02.06.14 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 19 Jan 2012 02:06:14 -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 1Rnoso-0001mc-2D for ; Thu, 19 Jan 2012 10:06:14 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 078FAE14BB for ; Thu, 19 Jan 2012 10:06:14 +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: 483 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 483: Add options to linaro-android-media-create to pass in additional boot args. Message-Id: <20120119100614.31905.41459.launchpad@ackee.canonical.com> Date: Thu, 19 Jan 2012 10:06:14 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14692"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 2b3ae0c0f6e6258ebce4f05050464bd68215edca Merge authors: Mattias Backman (mabac) Related merge proposals: https://code.launchpad.net/~mabac/linaro-image-tools/bug-913819-additional-bootargs/+merge/88868 proposed by: Mattias Backman (mabac) review: Approve - James Tunnicliffe (dooferlad) ------------------------------------------------------------ revno: 483 [merge] committer: Mattias Backman branch nick: linaro-image-tools timestamp: Thu 2012-01-19 10:56:41 +0100 message: Add options to linaro-android-media-create to pass in additional boot args. modified: linaro-android-media-create linaro-media-create linaro_image_tools/media_create/__init__.py 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-android-media-create' --- linaro-android-media-create 2011-10-05 09:19:03 +0000 +++ linaro-android-media-create 2012-01-19 06:31:50 +0000 @@ -105,6 +105,8 @@ SDCARD_DISK = os.path.join(TMP_DIR, 'sdcard-disc') board_config = android_board_configs[args.board] + board_config.add_boot_args(args.extra_boot_args) + board_config.add_boot_args_from_file(args.extra_boot_args_file) if args.board == 'iMX53': # XXX: remove this and the corresponding entry in android_board_configs === modified file 'linaro-media-create' --- linaro-media-create 2011-10-19 12:19:33 +0000 +++ linaro-media-create 2012-01-17 14:50:47 +0000 @@ -119,6 +119,8 @@ board_config = board_configs[args.board] board_config.set_metadata(args.hwpacks) board_config.set_board(args.board) + board_config.add_boot_args(args.extra_boot_args) + board_config.add_boot_args_from_file(args.extra_boot_args_file) ensure_required_commands(args) === modified file 'linaro_image_tools/media_create/__init__.py' --- linaro_image_tools/media_create/__init__.py 2011-10-19 14:18:52 +0000 +++ linaro_image_tools/media_create/__init__.py 2012-01-19 06:31:50 +0000 @@ -66,6 +66,14 @@ qemu_version = "Cannot find %s." % qemu_path return "%s\n: %s" % (__version__, qemu_version) +def add_common_options(parser): + parser.add_argument( + '--extra-boot-args', dest='extra_boot_args', required=False, + help='Extra boot args.') + parser.add_argument( + '--extra-boot-args-file', dest='extra_boot_args_file', + required=False, help=('File containing extra boot arguments.')) + def get_args_parser(): """Get the ArgumentParser for the arguments given on the command line.""" parser = argparse.ArgumentParser(version='%(prog)s ' + get_version()) @@ -145,6 +153,7 @@ action='store_true', help='Assume yes to the question "Are you 100%% sure, on selecting [mmc]"') + add_common_options(parser) return parser def get_android_args_parser(): @@ -188,4 +197,5 @@ '--align-boot-part', dest='should_align_boot_part', action='store_true', help='Align boot partition too (might break older x-loaders).') + add_common_options(parser) return parser === modified file 'linaro_image_tools/media_create/boards.py' --- linaro_image_tools/media_create/boards.py 2011-12-14 13:01:43 +0000 +++ linaro_image_tools/media_create/boards.py 2012-01-18 15:27:35 +0000 @@ -207,6 +207,7 @@ mmc_part_offset = 0 uimage_path = '' fat_size = 32 + extra_serial_opts = '' _extra_serial_opts = '' _live_serial_opts = '' extra_boot_args_options = None @@ -574,6 +575,17 @@ return boot_script @classmethod + def add_boot_args(cls, extra_args): + if extra_args is not None: + cls.extra_boot_args_options += ' %s' % extra_args + + @classmethod + def add_boot_args_from_file(cls, path): + if path is not None: + with open(path, 'r') as boot_args_file: + cls.add_boot_args(boot_args_file.read().strip()) + + @classmethod def _get_bootargs(cls, is_live, is_lowmem, consoles, rootfs_uuid): """Get the bootargs for this board. === modified file 'linaro_image_tools/media_create/tests/test_media_create.py' --- linaro_image_tools/media_create/tests/test_media_create.py 2011-12-23 10:35:27 +0000 +++ linaro_image_tools/media_create/tests/test_media_create.py 2012-01-17 14:50:47 +0000 @@ -1412,6 +1412,100 @@ self.assertEqual(expected, boot_commands) +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)) + 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']) + + def test_none_file_extra_args(self): + boot_args = ''.join( + random.choice(string.ascii_lowercase) for x in range(15)) + boot_arg_path = None + 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']) + + 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)) + 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']) + + class TestGetBootCmdAndroid(TestCase): def test_panda(self): # XXX: To fix bug 697824 we have to change class attributes of our @@ -1962,7 +2056,7 @@ def wait(self): return self.returncode - fixture = self.useFixture(MockCmdRunnerPopenFixture()) + self.useFixture(MockCmdRunnerPopenFixture()) tmpfile = self.createTempFileAsFixture() media = Media(tmpfile)