From patchwork Thu Jan 27 18:43:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guilherme Salgado X-Patchwork-Id: 30 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:39:21 -0000 Delivered-To: patches@linaro.org Received: by 10.147.124.10 with SMTP id b10cs17492yan; Thu, 27 Jan 2011 10:43:32 -0800 (PST) Received: by 10.216.51.67 with SMTP id a45mr6919965wec.19.1296153811255; Thu, 27 Jan 2011 10:43:31 -0800 (PST) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id o4si27880809wee.150.2011.01.27.10.43.29; Thu, 27 Jan 2011 10:43:31 -0800 (PST) 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 1PiWob-0004mO-HU for ; Thu, 27 Jan 2011 18:43:29 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 7F7882E8056 for ; Thu, 27 Jan 2011 18:43:29 +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: 264 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-maintainers/linaro-image-tools/trunk] Rev 264: Add a test to make sure ensure_partition_is_not_mounted is not called when generating image files Message-Id: <20110127184329.25975.3615.launchpad@loganberry.canonical.com> Date: Thu, 27 Jan 2011 18:43:29 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="12263"; Instance="initZopeless config overlay" X-Launchpad-Hash: cac1e28a398afc09b33efc450689c37f82d59fec Merge authors: Guilherme Salgado (salgado) Related merge proposals: https://code.launchpad.net/~salgado/linaro-image-tools/bug-701678/+merge/47688 proposed by: Guilherme Salgado (salgado) review: Approve - James Westby (james-w) ------------------------------------------------------------ revno: 264 [merge] fixes bug(s): https://launchpad.net/bugs/701678 https://launchpad.net/bugs/705571 committer: Guilherme Salgado branch nick: trunk timestamp: Thu 2011-01-27 16:41:26 -0200 message: Add a test to make sure ensure_partition_is_not_mounted is not called when generating image files modified: linaro_media_create/partitions.py 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/partitions.py' --- linaro_media_create/partitions.py 2011-01-26 18:03:50 +0000 +++ linaro_media_create/partitions.py 2011-01-27 16:39:37 +0000 @@ -54,15 +54,16 @@ if media.is_block_device: bootfs, rootfs = get_boot_and_root_partitions_for_media( media, board_config) - else: - bootfs, rootfs = get_boot_and_root_loopback_devices(media.path) - - if should_format_bootfs: - print "\nFormating boot partition\n" # It looks like KDE somehow automounts the partitions after you # repartition a disk so we need to unmount them here to create the # filesystem. ensure_partition_is_not_mounted(bootfs) + ensure_partition_is_not_mounted(rootfs) + else: + bootfs, rootfs = get_boot_and_root_loopback_devices(media.path) + + if should_format_bootfs: + print "\nFormating boot partition\n" proc = cmd_runner.run( ['mkfs.vfat', '-F', str(board_config.fat_size), bootfs, '-n', bootfs_label], @@ -72,7 +73,6 @@ if should_format_rootfs: print "\nFormating root partition\n" mkfs = 'mkfs.%s' % rootfs_type - ensure_partition_is_not_mounted(rootfs) proc = cmd_runner.run( [mkfs, rootfs, '-L', rootfs_label], as_root=True) === modified file 'linaro_media_create/tests/test_media_create.py' --- linaro_media_create/tests/test_media_create.py 2011-01-26 18:03:50 +0000 +++ linaro_media_create/tests/test_media_create.py 2011-01-27 17:19:03 +0000 @@ -161,7 +161,7 @@ self.mock_all_boards_funcs() def mock_all_boards_funcs(self): - """Mock all functions of linaro_media_create.boards with a call tracer.""" + """Mock functions of linaro_media_create.boards with a call tracer.""" def mock_func_creator(name): return lambda *args, **kwargs: self.funcs_calls.append(name) @@ -680,8 +680,15 @@ popen_fixture = self.useFixture(MockCmdRunnerPopenFixture()) self.useFixture(MockSomethingFixture( sys, 'stdout', open('/dev/null', 'w'))) + def ensure_partition_not_mounted(part): + raise AssertionError( + "ensure_partition_is_not_mounted must not be called when " + "generating image files. It makes no sense to do that and " + "it depends on UDisks, thus making it hard to run on a " + "chroot") self.useFixture(MockSomethingFixture( - partitions, 'is_partition_mounted', lambda part: False)) + partitions, + 'ensure_partition_is_not_mounted', ensure_partition_not_mounted)) self.useFixture(MockSomethingFixture( partitions, 'get_boot_and_root_loopback_devices', lambda image: ('/dev/loop99', '/dev/loop98'))) @@ -724,8 +731,8 @@ # Since the partitions are mounted, setup_partitions will umount # them before running mkfs. ['sudo', 'umount', bootfs_dev], - ['sudo', 'mkfs.vfat', '-F', '32', bootfs_dev, '-n', 'boot'], ['sudo', 'umount', rootfs_dev], + ['sudo', 'mkfs.vfat', '-F', '32', bootfs_dev, '-n', 'boot'], ['sudo', 'mkfs.ext3', rootfs_dev, '-L', 'root']], popen_fixture.mock.calls)