From patchwork Tue Jun 14 09:49:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattias Backman X-Patchwork-Id: 1894 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.47.109) by localhost6.localdomain6 with IMAP4-SSL; 14 Jun 2011 16:46:27 -0000 Delivered-To: patches@linaro.org Received: by 10.52.183.130 with SMTP id em2cs52702vdc; Tue, 14 Jun 2011 02:49:14 -0700 (PDT) Received: by 10.227.197.201 with SMTP id el9mr6158592wbb.22.1308044953630; Tue, 14 Jun 2011 02:49:13 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id es19si14838232wbb.31.2011.06.14.02.49.13; Tue, 14 Jun 2011 02:49:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QWQFF-0004Ji-1X for ; Tue, 14 Jun 2011 09:49:13 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 0A7D62E8048 for ; Tue, 14 Jun 2011 09:49:13 +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: 356 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 356: Merge lp:~mabac/linaro-image-tools/fewer-magic-numbers-in-tests; refactor partitioning tests. Message-Id: <20110614094913.14176.72715.launchpad@loganberry.canonical.com> Date: Tue, 14 Jun 2011 09:49:13 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13216"; Instance="initZopeless config overlay" X-Launchpad-Hash: 75bc2f2d07c7073776714318d6d9d1de7e3e0a0b Merge authors: Mattias Backman (mabac) Related merge proposals: https://code.launchpad.net/~mabac/linaro-image-tools/fewer-magic-numbers-in-tests/+merge/64160 proposed by: Mattias Backman (mabac) review: Approve - Guilherme Salgado (salgado) ------------------------------------------------------------ revno: 356 [merge] committer: Mattias Backman branch nick: linaro-image-tools timestamp: Tue 2011-06-14 11:45:13 +0200 message: Merge lp:~mabac/linaro-image-tools/fewer-magic-numbers-in-tests; refactor partitioning tests. modified: 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/tests/test_media_create.py' --- linaro_image_tools/media_create/tests/test_media_create.py 2011-06-14 08:01:43 +0000 +++ linaro_image_tools/media_create/tests/test_media_create.py 2011-06-14 09:45:13 +0000 @@ -880,6 +880,12 @@ # Stub time.sleep() as create_partitions() use that. self.orig_sleep = time.sleep time.sleep = lambda s: None + self.linux_image_size = 30 * 1024**2 + self.linux_offsets_and_sizes = [ + (16384 * SECTOR_SIZE, 15746 * SECTOR_SIZE), + (32768 * SECTOR_SIZE, (self.linux_image_size - + 32768 * SECTOR_SIZE)) + ] self.android_image_size = 256 * 1024**2 # Extended partition info takes 32 sectors from the first ext partition ext_part_size = 32 @@ -902,7 +908,7 @@ def _create_tmpfile(self): # boot part at +8 MiB, root part at +16 MiB return self._create_qemu_img_with_partitions( - '16384,15746,0x0C,*\n32768,,,-', '30M') + '16384,15746,0x0C,*\n32768,,,-', '%s' % self.linux_image_size) def _create_android_tmpfile(self): # boot, system, cache, (extended), userdata and sdcard partitions @@ -927,8 +933,8 @@ vfat_size, vfat_offset, linux_size, linux_offset = ( calculate_partition_size_and_offset(tmpfile)) self.assertEqual( - [8061952L, 8388608L, 14680064L, 16777216L], - [vfat_size, vfat_offset, linux_size, linux_offset]) + self.linux_offsets_and_sizes, + [(vfat_offset, vfat_size), (linux_offset, linux_size)]) def test_calculate_android_partition_size_and_offset(self): tmpfile = self._create_android_tmpfile() @@ -942,7 +948,8 @@ def test_partition_numbering(self): # another Linux partition at +24 MiB after the boot/root parts tmpfile = self._create_qemu_img_with_partitions( - '16384,15746,0x0C,*\n32768,15427,,-\n49152,,,-', '30M') + '16384,15746,0x0C,*\n32768,15427,,-\n49152,,,-', + '%s' % self.linux_image_size) vfat_size, vfat_offset, linux_size, linux_offset = ( calculate_partition_size_and_offset(tmpfile)) # check that the linux partition offset starts at +16 MiB so that it's @@ -1012,10 +1019,9 @@ # it calls losetup correctly. get_boot_and_root_loopback_devices(tmpfile) self.assertEqual( - ['%s losetup -f --show %s --offset 8388608 --sizelimit 8061952' - % (sudo_args, tmpfile), - '%s losetup -f --show %s --offset 16777216 --sizelimit 14680064' - % (sudo_args, tmpfile)], + ['%s losetup -f --show %s --offset %s --sizelimit %s' + % (sudo_args, tmpfile, offset, size) for (offset, size) in + self.linux_offsets_and_sizes], popen_fixture.mock.commands_executed) # get_boot_and_root_loopback_devices will also setup two exit handlers