From patchwork Thu Mar 17 20:29:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Lo=C3=AFc_Minier?= X-Patchwork-Id: 661 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:44:29 -0000 Delivered-To: patches@linaro.org Received: by 10.151.46.5 with SMTP id y5cs50463ybj; Thu, 17 Mar 2011 13:29:21 -0700 (PDT) Received: by 10.216.62.77 with SMTP id x55mr211262wec.59.1300393760475; Thu, 17 Mar 2011 13:29:20 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id f49si5452391wef.133.2011.03.17.13.29.19; Thu, 17 Mar 2011 13:29:20 -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 1Q0Jot-0006to-K4 for ; Thu, 17 Mar 2011 20:29:19 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 95D162E80F1 for ; Thu, 17 Mar 2011 20:29:19 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: linaro-image-tools X-Launchpad-Branch: ~linaro-maintainers/linaro-image-tools/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 299 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-maintainers/linaro-image-tools/trunk] Rev 299: Merge lp:~lool/linaro-image-tools/chs-align-tests; don't hardcode heads and Message-Id: <20110317202919.29952.89972.launchpad@loganberry.canonical.com> Date: Thu, 17 Mar 2011 20:29:19 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="12611"; Instance="initZopeless config overlay" X-Launchpad-Hash: a569b521c0d98c9c8b29e7aa45e960b15ee1c139 Merge authors: Loïc Minier (lool) Related merge proposals: https://code.launchpad.net/~lool/linaro-image-tools/chs-align-tests/+merge/53874 proposed by: Loïc Minier (lool) review: Approve - Guilherme Salgado (salgado) ------------------------------------------------------------ revno: 299 [merge] committer: Loïc Minier branch nick: linaro-image-tools timestamp: Thu 2011-03-17 21:28:27 +0100 message: Merge lp:~lool/linaro-image-tools/chs-align-tests; don't hardcode heads and sectoes in tests. modified: linaro_media_create/tests/test_media_create.py --- lp:linaro-image-tools https://code.launchpad.net/~linaro-maintainers/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-maintainers/linaro-image-tools/trunk/+edit-subscription === modified file 'linaro_media_create/tests/test_media_create.py' --- linaro_media_create/tests/test_media_create.py 2011-03-12 09:31:11 +0000 +++ linaro_media_create/tests/test_media_create.py 2011-03-17 18:30:07 +0000 @@ -67,6 +67,8 @@ temporarily_overwrite_file_on_dir, ) from linaro_media_create.partitions import ( + HEADS, + SECTORS, calculate_partition_size_and_offset, convert_size_to_bytes, create_partitions, @@ -770,7 +772,7 @@ popen_fixture = self.useFixture(MockCmdRunnerPopenFixture()) sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture()) - create_partitions(boards.Mx5Config, self.media, 128, 32, '') + create_partitions(boards.Mx5Config, self.media, HEADS, SECTORS, '') self.assertEqual( ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path), @@ -780,8 +782,8 @@ # every time we run sfdisk it actually repartitions the device, # erasing any partitions created previously. self.assertEqual( - [('1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', 128, 32, '', - self.media.path)], + [('1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', HEADS, SECTORS, + '', self.media.path)], sfdisk_fixture.mock.calls) def test_create_partitions_for_smdkv310(self): @@ -790,7 +792,7 @@ sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture()) create_partitions( - board_configs['smdkv310'], self.media, 128, 32, '') + board_configs['smdkv310'], self.media, HEADS, SECTORS, '') self.assertEqual( ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path), @@ -800,22 +802,23 @@ # every time we run sfdisk it actually repartitions the device, # erasing any partitions created previously. self.assertEqual( - [('1,221183,0xDA\n221184,106496,0x0C,*\n327680,,,-', 128, 32, '', - self.media.path)], sfdisk_fixture.mock.calls) + [('1,221183,0xDA\n221184,106496,0x0C,*\n327680,,,-', HEADS, + SECTORS, '', self.media.path)], sfdisk_fixture.mock.calls) def test_create_partitions_for_beagle(self): popen_fixture = self.useFixture(MockCmdRunnerPopenFixture()) sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture()) create_partitions( - board_configs['beagle'], self.media, 128, 32, '') + board_configs['beagle'], self.media, HEADS, SECTORS, '') self.assertEqual( ['%s parted -s %s mklabel msdos' % (sudo_args, self.media.path), 'sync'], popen_fixture.mock.commands_executed) self.assertEqual( - [('63,106432,0x0C,*\n106496,,,-', 128, 32, '', self.media.path)], + [('63,106432,0x0C,*\n106496,,,-', HEADS, SECTORS, '', + self.media.path)], sfdisk_fixture.mock.calls) def test_create_partitions_with_img_file(self): @@ -824,7 +827,7 @@ tmpfile = self.createTempFileAsFixture() create_partitions( - board_configs['beagle'], Media(tmpfile), 128, 32, '') + board_configs['beagle'], Media(tmpfile), HEADS, SECTORS, '') # Unlike the test for partitioning of a regular block device, in this # case parted was not called as there's no existing partition table @@ -832,7 +835,7 @@ self.assertEqual(['sync'], popen_fixture.mock.commands_executed) self.assertEqual( - [('63,106432,0x0C,*\n106496,,,-', 128, 32, '', tmpfile)], + [('63,106432,0x0C,*\n106496,,,-', HEADS, SECTORS, '', tmpfile)], sfdisk_fixture.mock.calls) def test_run_sfdisk_commands(self): @@ -842,7 +845,7 @@ stdout=subprocess.PIPE) proc.communicate() stdout, stderr = run_sfdisk_commands( - '2,16063,0xDA', 128, 32, '', tmpfile, as_root=False, + '2,16063,0xDA', HEADS, SECTORS, '', tmpfile, as_root=False, stderr=subprocess.PIPE) self.assertIn('Successfully wrote the new partition table', stdout) @@ -851,7 +854,7 @@ self.assertRaises( cmd_runner.SubcommandNonZeroReturnValue, run_sfdisk_commands, - ',1,0xDA', 128, 32, '', tmpfile, as_root=False, + ',1,0xDA', HEADS, SECTORS, '', tmpfile, as_root=False, stderr=subprocess.PIPE) @@ -929,7 +932,7 @@ stdout=subprocess.PIPE) proc.communicate() stdout, stderr = run_sfdisk_commands( - sfdisk_commands, 128, 32, '', tmpfile, as_root=False, + sfdisk_commands, HEADS, SECTORS, '', tmpfile, as_root=False, # Throw away stderr as sfdisk complains a lot when operating on a # qemu image. stderr=subprocess.PIPE) @@ -1009,8 +1012,8 @@ # This is the call that would create a 2 GiB image file. ['qemu-img create -f raw %s 2147483648' % tmpfile, # This call would partition the image file. - '%s sfdisk --force -D -uS -H 128 -S 32 -C 1024 %s' % ( - sudo_args, tmpfile), + '%s sfdisk --force -D -uS -H %s -S %s -C 1024 %s' % ( + sudo_args, HEADS, SECTORS, tmpfile), # Make sure changes are written to disk. 'sync', '%s mkfs.vfat -F 32 %s -n boot' % (sudo_args, bootfs_dev), @@ -1036,8 +1039,8 @@ True, True, True) self.assertEqual( ['%s parted -s %s mklabel msdos' % (sudo_args, tmpfile), - '%s sfdisk --force -D -uS -H 128 -S 32 %s' % ( - sudo_args, tmpfile), + '%s sfdisk --force -D -uS -H %s -S %s %s' % ( + sudo_args, HEADS, SECTORS, tmpfile), 'sync', # Since the partitions are mounted, setup_partitions will umount # them before running mkfs.