diff mbox

[Branch,~linaro-image-tools/linaro-image-tools/trunk] Rev 389: Avoid an error if the kernel version doesn't match 2.6.*.

Message ID 20110726153531.2571.37026.launchpad@loganberry.canonical.com
State Accepted
Headers show

Commit Message

James Westby July 26, 2011, 3:35 p.m. UTC
Merge authors:
  James Westby <jw2328@jameswestby.net>
Related merge proposals:
  https://code.launchpad.net/~james-w/linaro-image-tools/fix-three-dot-oh/+merge/69302
  proposed by: James Westby (james-w)
  review: Approve - Guilherme Salgado (salgado)
------------------------------------------------------------
revno: 389 [merge]
committer: James Westby <james.westby@linaro.org>
branch nick: trunk
timestamp: Tue 2011-07-26 16:33:42 +0100
message:
  Avoid an error if the kernel version doesn't match 2.6.*.
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
diff mbox

Patch

=== modified file 'linaro_image_tools/media_create/boards.py'
--- linaro_image_tools/media_create/boards.py	2011-07-25 16:48:37 +0000
+++ linaro_image_tools/media_create/boards.py	2011-07-26 15:20:56 +0000
@@ -552,9 +552,12 @@ 
         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 = classproperty(lambda cls: 'ttyS2')
+        match = re.match('.*2\.6\.([0-9]{2}).*', basename)
+        # Assume if it doesn't match that it is 3.0 or later.
+        if match is not None:
+            minor_version = match.group(1)
+            if int(minor_version) < 36:
+                cls.serial_tty = classproperty(lambda cls: 'ttyS2')
 
     @classmethod
     def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles,

=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
--- linaro_image_tools/media_create/tests/test_media_create.py	2011-07-26 12:10:08 +0000
+++ linaro_image_tools/media_create/tests/test_media_create.py	2011-07-26 15:20:56 +0000
@@ -1039,6 +1039,14 @@ 
         boards.BeagleConfig.set_appropriate_serial_tty(tempdir)
         self.assertEquals('ttyO2', boards.BeagleConfig.serial_tty)
 
+    def test_set_appropriate_serial_tty_three_dot_oh_kernel(self):
+        tempdir = self.useFixture(CreateTempDirFixture()).tempdir
+        boot_dir = os.path.join(tempdir, 'boot')
+        os.makedirs(boot_dir)
+        open(os.path.join(boot_dir, 'vmlinuz-3.0-13-foo'), 'w').close()
+        boards.BeagleConfig.set_appropriate_serial_tty(tempdir)
+        self.assertEquals('ttyO2', boards.BeagleConfig.serial_tty)
+
 
 class TestGetSfdiskCmd(TestCase):