diff mbox

[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
State Accepted
Headers show

Commit Message

Mattias Backman Sept. 21, 2011, 12:16 p.m. UTC
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 <mattias.backman@linaro.org>
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
diff mbox

Patch

=== 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(