From patchwork Wed Sep 21 12:16:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattias Backman X-Patchwork-Id: 4217 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 33DE423F57 for ; Wed, 21 Sep 2011 12:16:18 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 2451DA1802B for ; Wed, 21 Sep 2011 12:16:18 +0000 (UTC) Received: by fxe23 with SMTP id 23so2201744fxe.11 for ; Wed, 21 Sep 2011 05:16:18 -0700 (PDT) Received: by 10.223.61.66 with SMTP id s2mr985389fah.27.1316607377929; Wed, 21 Sep 2011 05:16:17 -0700 (PDT) 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.152.18.198 with SMTP id y6cs124251lad; Wed, 21 Sep 2011 05:16:17 -0700 (PDT) Received: by 10.227.204.14 with SMTP id fk14mr624296wbb.88.1316607377343; Wed, 21 Sep 2011 05:16:17 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id fj8si4014150wbb.91.2011.09.21.05.16.17 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 21 Sep 2011 05:16:17 -0700 (PDT) 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 1R6Liq-0004Sz-Pu for ; Wed, 21 Sep 2011 12:16:16 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id BB3F7E003D for ; Wed, 21 Sep 2011 12:16: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: 433 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 433: Change format of metadata field mmc_id and make it required. Message-Id: <20110921121616.11847.47702.launchpad@ackee.canonical.com> Date: Wed, 21 Sep 2011 12:16: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="13996"; Instance="initZopeless config overlay" X-Launchpad-Hash: 595713690c2ed56a739d88c49d829df856033eb9 Merge authors: Mattias Backman (mabac) Related merge proposals: https://code.launchpad.net/~mabac/linaro-image-tools/use-mmc-id/+merge/76236 proposed by: Mattias Backman (mabac) review: Approve - Ricardo Salveti (rsalveti) review: Approve - James Westby (james-w) ------------------------------------------------------------ revno: 433 [merge] committer: Mattias Backman branch nick: linaro-image-tools timestamp: Wed 2011-09-21 14:13:25 +0200 message: Change format of metadata field mmc_id and make it required. modified: linaro_image_tools/hwpack/config.py linaro_image_tools/hwpack/tests/test_builder.py linaro_image_tools/hwpack/tests/test_config.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_image_tools/hwpack/config.py' --- linaro_image_tools/hwpack/config.py 2011-09-15 08:41:03 +0000 +++ linaro_image_tools/hwpack/config.py 2011-09-20 14:51:30 +0000 @@ -124,7 +124,6 @@ self._validate_wired_interfaces() self._validate_wireless_interfaces() self._validate_partition_layout() - self._validate_mmc_id() self._validate_boot_min_size() self._validate_root_min_size() self._validate_loader_min_size() @@ -134,6 +133,7 @@ self._validate_vmlinuz() self._validate_initrd() self._validate_dtb_file() + self._validate_mmc_id() self._validate_extra_boot_options() self._validate_boot_script() self._validate_uboot_in_boot_part() @@ -664,12 +664,13 @@ def _validate_mmc_id(self): mmc_id = self.mmc_id - if mmc_id is None: - return - try: - int(mmc_id) - except: - raise HwpackConfigError("Invalid mmc id %s" % (mmc_id)) + if not mmc_id: + raise HwpackConfigError( + "No mmc_id in the [%s] section" % \ + self.MAIN_SECTION) + else: + self._assert_matches_pattern( + r"[0-9]:[0-9]", mmc_id, "Invalid mmc_id %s" % mmc_id) def _validate_root_min_size(self): root_min_size = self.root_min_size === modified file 'linaro_image_tools/hwpack/tests/test_builder.py' --- linaro_image_tools/hwpack/tests/test_builder.py 2011-08-18 14:12:33 +0000 +++ linaro_image_tools/hwpack/tests/test_builder.py 2011-09-21 12:11:57 +0000 @@ -123,6 +123,7 @@ 'kernel_file': 'boot/vmlinuz-3.0.0-1002-linaro-omap', 'initrd_file': 'boot/initrd.img-3.0.0-1002-linaro-omap', 'boot_script': 'boot.scr', + 'mmc_id': '0:1', 'u_boot_in_boot_part': 'no'} def test_raises_on_missing_configuration(self): === modified file 'linaro_image_tools/hwpack/tests/test_config.py' --- linaro_image_tools/hwpack/tests/test_config.py 2011-08-25 06:52:35 +0000 +++ linaro_image_tools/hwpack/tests/test_config.py 2011-09-20 14:51:30 +0000 @@ -45,6 +45,7 @@ "extra_serial_options = console=tty0 console=ttyO2,115200n8\n"\ "extra_boot_options = earlyprintk fixrtc nocompcache vram=48M omapfb.vram=0:24M mem=456M@0x80000000 mem=512M@0xA0000000\n"\ "boot_script = boot.scr\n"\ + "mmc_id = 0:1\n"\ "u_boot_in_boot_part = Yes\n") valid_end = "[ubuntu]\nsources-entry = foo bar\n" @@ -247,12 +248,14 @@ "u-boot-file = u-boot.bin\n" "partition_layout = bootfs_rootfs\n"\ "kernel_file = boot/vmlinuz-3.0.0-1002-linaro-omap\n"\ + "mmc_id = 0:1\n"\ "initrd_file = boot/initrd.img-3.0.0-1002-linaro-omap\n") self.assertValidationError("No boot_script in the [hwpack] section", config) def test_validate_invalid_boot_script(self): config = self.get_config(self.valid_start_v2 + "u-boot-package = u-boot-linaro-s5pv310\n" \ + "mmc_id = 0:1\n"\ "u-boot-file = u-boot.bin\n" \ "partition_layout = bootfs_rootfs\n"\ "kernel_file = boot/vmlinuz-3.0.0-1002-linaro-omap\n"\ @@ -270,6 +273,7 @@ "initrd_file = boot/initrd.img-3.0.0-1002-linaro-omap\n"\ "boot_script = boot.scr\n"\ "u_boot_in_boot_part = No\n"\ + "mmc_id = 0:1\n"\ "dtb_file = ~~\n") self.assertValidationError("Invalid path: ~~", config) @@ -278,6 +282,7 @@ self.valid_start_v2 + "u-boot-package = u-boot-linaro-s5pv310\n" \ "u-boot-file = usr/bin/version/MLO\n" \ "partition_layout = bootfs_rootfs\n"\ + "mmc_id = 0:1\n"\ "x_loader_package = ~~\n") self.assertValidationError( "Invalid value in x_loader_package in the [hwpack] section: ~~", @@ -318,6 +323,7 @@ "kernel_file = boot/vmlinuz-3.0.0-1002-linaro-omap\n"\ "initrd_file = boot/initrd.img-3.0.0-1002-linaro-omap\n"\ "boot_script = boot.scr\n"\ + "mmc_id = 0:1\n"\ "u_boot_in_boot_part = Nope\n") self.assertValidationError("Invalid value for u_boot_in_boot_part: Nope", config) @@ -329,6 +335,7 @@ "kernel_file = boot/vmlinuz-3.0.0-1002-linaro-omap\n"\ "initrd_file = boot/initrd.img-3.0.0-1002-linaro-omap\n"\ "boot_script = boot.scr\n"\ + "mmc_id = 0:1\n"\ "u_boot_in_boot_part = True\n") self.assertValidationError("Invalid value for u_boot_in_boot_part: True", config) @@ -346,7 +353,7 @@ def test_validate_mmc_id(self): config = self.get_config(self.valid_complete_v2 + "mmc_id = x\n") - self.assertValidationError("Invalid mmc id x", config) + self.assertValidationError("Invalid mmc_id x", config) def test_validate_boot_min_size(self): config = self.get_config(self.valid_complete_v2 + @@ -510,10 +517,10 @@ def test_mmc_id(self): config = self.get_config(self.valid_complete_v2 + - "mmc_id = 1\n" + + "mmc_id = 0:1\n" + self.valid_end) config.validate() - self.assertEqual("1", config.mmc_id) + self.assertEqual("0:1", config.mmc_id) def test_boot_min_size(self): config = self.get_config(self.valid_complete_v2 + === modified file 'linaro_image_tools/media_create/boards.py' --- linaro_image_tools/media_create/boards.py 2011-09-15 11:18:09 +0000 +++ linaro_image_tools/media_create/boards.py 2011-09-21 12:11:57 +0000 @@ -290,6 +290,8 @@ cls.extra_boot_args_options = None cls.boot_script = None cls.kernel_flavors = None + cls.mmc_option = None + cls.mmc_part_offset = None cls.SAMSUNG_V310_BL1_START = None cls.SAMSUNG_V310_BL1_LEN = None cls.SAMSUNG_V310_ENV_START = None @@ -306,7 +308,6 @@ cls.wired_interfaces = cls.get_metadata_field('wired_interfaces') cls.wireless_interfaces = cls.get_metadata_field( 'wireless_interfaces') - cls.mmc_id = cls.get_metadata_field('mmc_id') cls.vmlinuz = cls.get_metadata_field('kernel_file') cls.initrd = cls.get_metadata_field('initrd_file') cls.dtb_file = cls.get_metadata_field('dtb_file') @@ -327,6 +328,10 @@ raise AssertionError("Unknown partition layout '%s'." % \ cls.partition_layout) + cls.mmc_option = cls.get_metadata_field('mmc_id') + if cls.mmc_option is not None: + cls.mmc_part_offset = int(cls.mmc_option.split(':')[1]) - 1 + boot_min_size = cls.get_metadata_field('boot_min_size') if boot_min_size is not None: cls.BOOT_MIN_SIZE_S = align_up(int(boot_min_size) * 1024 ** 2, @@ -743,7 +748,7 @@ if cls.dtb_file is not None: dtb = _get_file_matching(os.path.join(path, cls.dtb_file)) logger = logging.getLogger("linaro_image_tools") - logger.info( "Will use kernel=%s, initrd=%s, dtb=%s." % \ + logger.info("Will use kernel=%s, initrd=%s, dtb=%s." % \ (kernel, initrd, dtb)) return (kernel, initrd, dtb) raise ValueError( === modified file 'linaro_image_tools/media_create/tests/test_media_create.py' --- linaro_image_tools/media_create/tests/test_media_create.py 2011-09-15 11:18:09 +0000 +++ linaro_image_tools/media_create/tests/test_media_create.py 2011-09-20 14:51:30 +0000 @@ -376,14 +376,15 @@ linaro_image_tools.media_create.boards, 'HardwarepackHandler', self.MockHardwarepackHandler)) field_to_test = 'mmc_id' - data_to_set = '1' + data_to_set = '0:1' self.MockHardwarepackHandler.metadata_dict = { field_to_test: data_to_set, } class config(BoardConfig): pass config.set_metadata('ahwpack.tar.gz') - self.assertEquals(data_to_set, config.mmc_id) + self.assertEquals(data_to_set, config.mmc_option) + self.assertEquals(0, config.mmc_part_offset) def test_sets_boot_min_size(self): self.useFixture(MockSomethingFixture(