Merge lp:~lool/linaro-image-tools/mkfs-uuid into lp:linaro-image-tools/11.11

Proposed by Loïc Minier
Status: Merged
Merged at revision: 263
Proposed branch: lp:~lool/linaro-image-tools/mkfs-uuid
Merge into: lp:linaro-image-tools/11.11
Diff against target: 411 lines (+99/-50) (has conflicts)
7 files modified
debian/control (+0/-1)
linaro-media-create (+12/-6)
linaro_media_create/__init__.py (+1/-2)
linaro_media_create/boards.py (+5/-7)
linaro_media_create/partitions.py (+22/-4)
linaro_media_create/populate_boot.py (+5/-4)
linaro_media_create/tests/test_media_create.py (+54/-26)
Text conflict in linaro-media-create
To merge this branch: bzr merge lp:~lool/linaro-image-tools/mkfs-uuid
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+47487@code.launchpad.net

Description of the change

Tentative branch; only passed testsuite, didn't create btrfs image yet

Suggestions on testing get_uuid() welcome!

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Looks good so far.

For a get_uuid() test I would use the subprocess mocking again to ensure that
it calls the correct thing. It would be testing that at multiple layers, but
I think that's just the price we have to pay here.

Thanks,

James

262. By Loïc Minier

Only lookup rootfs UUID when needed.

263. By Loïc Minier

Test that get_uuid() runs blkid correctly.

Revision history for this message
Loïc Minier (lool) wrote :

But ignoring the return value then -- ok; I guess otherwise I would have to introduce a new Popen mock which supports returning some pre-defined output in communicate().

I've pushed an additional test now, and a cleanup; I'll test the branch now with real images now.

Revision history for this message
James Westby (james-w) wrote :

On Wed, 26 Jan 2011 12:29:09 -0000, Loïc Minier <email address hidden> wrote:
> But ignoring the return value then -- ok; I guess otherwise I would
> have to introduce a new Popen mock which supports returning some
> pre-defined output in communicate().

I didn't realise that was missing. I assumed that you would be doing
that.

I don't think it's super critical, but would be nice to have.

Thanks,

James

264. By Loïc Minier

Use blkid -p to force probing and ignore the cache in this case since it's
useless; call blkid within sudo as it needs direct device access.

Revision history for this message
Loïc Minier (lool) wrote :

With the latest change to use blkid -p (and sudo and -c /dev/null), and with a workaround for the UDisk race issue (time.sleep(5) after creating the rootfs), things are working reliably and I can create an ext3 image and boot it in QEMU.

I tried creating a btrfs image, but I'm using an older hwpack has the latest one doesn't work in QEMU; it fails to insmod btrfs and then falls over. I did however confirm that the proper UUID is set in boot.scr, in etc/fstab, and matches the rootfs' UUID (I manually loop-mounted it to check).

Revision history for this message
James Westby (james-w) wrote :

Looks good, apart from the simple conflict.

Should blkid be added to required_commands?

Thanks,

James

review: Approve
Revision history for this message
Loïc Minier (lool) wrote :

I am not sure what we keep in required_commands these days; in the case of Debian/Ubuntu it's guaranteed to be there

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2011-01-19 18:53:01 +0000
+++ debian/control 2011-01-26 15:52:07 +0000
@@ -22,7 +22,6 @@
22Architecture: all22Architecture: all
23Depends: ${misc:Depends},23Depends: ${misc:Depends},
24 parted,24 parted,
25 uuid-runtime,
26 dosfstools,25 dosfstools,
27 u-boot-tools | uboot-mkimage,26 u-boot-tools | uboot-mkimage,
28 python,27 python,
2928
=== modified file 'linaro-media-create'
--- linaro-media-create 2011-01-26 12:10:14 +0000
+++ linaro-media-create 2011-01-26 15:52:07 +0000
@@ -8,7 +8,6 @@
88
9from linaro_media_create.boards import (9from linaro_media_create.boards import (
10 board_configs,10 board_configs,
11 ROOTFS_UUID,
12 )11 )
13from linaro_media_create.check_device import (12from linaro_media_create.check_device import (
14 confirm_device_selection_and_ensure_it_is_ready)13 confirm_device_selection_and_ensure_it_is_ready)
@@ -16,6 +15,7 @@
16from linaro_media_create.partitions import (15from linaro_media_create.partitions import (
17 Media,16 Media,
18 setup_partitions,17 setup_partitions,
18 get_uuid,
19 )19 )
20from linaro_media_create.populate_boot import populate_boot20from linaro_media_create.populate_boot import populate_boot
21from linaro_media_create.rootfs import populate_rootfs21from linaro_media_create.rootfs import populate_rootfs
@@ -59,7 +59,11 @@
59def ensure_required_commands(args):59def ensure_required_commands(args):
60 """Ensure we have the commands that we know are going to be used."""60 """Ensure we have the commands that we know are going to be used."""
61 required_commands = [61 required_commands = [
62<<<<<<< TREE
62 'mkfs.vfat', 'sfdisk', 'mkimage', 'uuidgen', 'parted']63 'mkfs.vfat', 'sfdisk', 'mkimage', 'uuidgen', 'parted']
64=======
65 'mkfs.vfat', 'sfdisk', 'fdisk', 'mkimage', 'parted']
66>>>>>>> MERGE-SOURCE
63 if not is_arm_host():67 if not is_arm_host():
64 required_commands.append('qemu-arm-static')68 required_commands.append('qemu-arm-static')
65 required_commands.append('qemu-img')69 required_commands.append('qemu-img')
@@ -105,20 +109,22 @@
105109
106 boot_partition, root_partition = setup_partitions(110 boot_partition, root_partition = setup_partitions(
107 board_config, media, args.image_size, args.boot_label, args.rfs_label,111 board_config, media, args.image_size, args.boot_label, args.rfs_label,
108 args.rootfs, ROOTFS_UUID, args.should_create_partitions,112 args.rootfs, args.should_create_partitions, args.should_format_bootfs,
109 args.should_format_bootfs, args.should_format_rootfs)113 args.should_format_rootfs)
114
115 rootfs_uuid = get_uuid(root_partition)
110116
111 if args.should_format_bootfs:117 if args.should_format_bootfs:
112 populate_boot(118 populate_boot(
113 board_config, ROOTFS_DIR, boot_partition, BOOT_DISK, args.device,119 board_config, ROOTFS_DIR, rootfs_uuid, boot_partition, BOOT_DISK,
114 args.is_live, args.is_lowmem, args.consoles)120 args.device, args.is_live, args.is_lowmem, args.consoles)
115121
116 if args.should_format_rootfs:122 if args.should_format_rootfs:
117 create_swap = False123 create_swap = False
118 if args.swap_file is not None:124 if args.swap_file is not None:
119 create_swap = True125 create_swap = True
120 populate_rootfs(ROOTFS_DIR, ROOT_DISK, root_partition, args.rootfs,126 populate_rootfs(ROOTFS_DIR, ROOT_DISK, root_partition, args.rootfs,
121 ROOTFS_UUID, create_swap, str(args.swap_file),127 rootfs_uuid, create_swap, str(args.swap_file),
122 board_config.mmc_part_offset)128 board_config.mmc_part_offset)
123129
124 print "Done creating Linaro image on %s" % args.device130 print "Done creating Linaro image on %s" % args.device
125131
=== modified file 'linaro_media_create/__init__.py'
--- linaro_media_create/__init__.py 2011-01-12 21:54:55 +0000
+++ linaro_media_create/__init__.py 2011-01-26 15:52:07 +0000
@@ -52,8 +52,7 @@
52 group.add_argument(52 group.add_argument(
53 '--live', dest='is_live', action='store_true',53 '--live', dest='is_live', action='store_true',
54 help=('Create boot command for casper/live images; if this is not '54 help=('Create boot command for casper/live images; if this is not '
55 'provided a UUID for the rootfs is generated and used as the '55 'provided the UUID for the rootfs is used as the root= option'))
56 'root= option'))
57 group.add_argument(56 group.add_argument(
58 '--live-256m', dest='is_lowmem', action=Live256MegsAction,57 '--live-256m', dest='is_lowmem', action=Live256MegsAction,
59 help=('Create boot command for casper/live images; adds '58 help=('Create boot command for casper/live images; adds '
6059
=== modified file 'linaro_media_create/boards.py'
--- linaro_media_create/boards.py 2011-01-25 20:04:45 +0000
+++ linaro_media_create/boards.py 2011-01-26 15:52:07 +0000
@@ -9,12 +9,9 @@
9import glob9import glob
10import os10import os
11import tempfile11import tempfile
12import uuid
1312
14from linaro_media_create import cmd_runner13from linaro_media_create import cmd_runner
1514
16ROOTFS_UUID = str(uuid.uuid4())
17
1815
19class BoardConfig(object):16class BoardConfig(object):
20 """The configuration used when building an image for a board."""17 """The configuration used when building an image for a board."""
@@ -48,7 +45,7 @@
48 return ',9,%s,*\n,,,-' % partition_type45 return ',9,%s,*\n,,,-' % partition_type
4946
50 @classmethod47 @classmethod
51 def _get_boot_cmd(cls, is_live, is_lowmem, consoles):48 def _get_boot_cmd(cls, is_live, is_lowmem, consoles, rootfs_uuid):
52 """Get the boot command for this board.49 """Get the boot command for this board.
5350
54 In general subclasses should not have to override this.51 In general subclasses should not have to override this.
@@ -69,7 +66,7 @@
69 serial_opts += ' %s' % cls.extra_serial_opts66 serial_opts += ' %s' % cls.extra_serial_opts
7067
71 lowmem_opt = ''68 lowmem_opt = ''
72 boot_snippet = 'root=UUID=%s' % ROOTFS_UUID69 boot_snippet = 'root=UUID=%s' % rootfs_uuid
73 if is_live:70 if is_live:
74 serial_opts += ' %s' % cls.live_serial_opts71 serial_opts += ' %s' % cls.live_serial_opts
75 boot_snippet = 'boot=casper'72 boot_snippet = 'boot=casper'
@@ -91,8 +88,9 @@
9188
92 @classmethod89 @classmethod
93 def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles,90 def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles,
94 root_dir, boot_dir, boot_script, boot_device_or_file):91 root_dir, rootfs_uuid, boot_dir, boot_script,
95 boot_cmd = cls._get_boot_cmd(is_live, is_lowmem, consoles)92 boot_device_or_file):
93 boot_cmd = cls._get_boot_cmd(is_live, is_lowmem, consoles, rootfs_uuid)
96 cls._make_boot_files(94 cls._make_boot_files(
97 uboot_parts_dir, boot_cmd, root_dir, boot_dir, boot_script,95 uboot_parts_dir, boot_cmd, root_dir, boot_dir, boot_script,
98 boot_device_or_file)96 boot_device_or_file)
9997
=== modified file 'linaro_media_create/partitions.py'
--- linaro_media_create/partitions.py 2011-01-25 20:04:45 +0000
+++ linaro_media_create/partitions.py 2011-01-26 15:52:07 +0000
@@ -1,5 +1,6 @@
1import atexit1import atexit
2import glob2import glob
3import re
3import subprocess4import subprocess
4import time5import time
56
@@ -25,9 +26,8 @@
25# small enough that there's not much benefit in doing that, but if it grows we26# small enough that there's not much benefit in doing that, but if it grows we
26# might want to do it.27# might want to do it.
27def setup_partitions(board_config, media, image_size, bootfs_label,28def setup_partitions(board_config, media, image_size, bootfs_label,
28 rootfs_label, rootfs_type, rootfs_uuid,29 rootfs_label, rootfs_type, should_create_partitions,
29 should_create_partitions, should_format_bootfs,30 should_format_bootfs, should_format_rootfs):
30 should_format_rootfs):
31 """Make sure the given device is partitioned to boot the given board.31 """Make sure the given device is partitioned to boot the given board.
3232
33 :param board_config: A BoardConfig class.33 :param board_config: A BoardConfig class.
@@ -73,13 +73,31 @@
73 mkfs = 'mkfs.%s' % rootfs_type73 mkfs = 'mkfs.%s' % rootfs_type
74 ensure_partition_is_not_mounted(rootfs)74 ensure_partition_is_not_mounted(rootfs)
75 proc = cmd_runner.run(75 proc = cmd_runner.run(
76 [mkfs, '-U', rootfs_uuid, rootfs, '-L', rootfs_label],76 [mkfs, rootfs, '-L', rootfs_label],
77 as_root=True)77 as_root=True)
78 proc.wait()78 proc.wait()
7979
80 return bootfs, rootfs80 return bootfs, rootfs
8181
8282
83def get_uuid(partition):
84 """Find UUID of the given partition."""
85 proc = cmd_runner.run(
86 ['blkid', '-o', 'udev', '-p', '-c', '/dev/null', partition],
87 as_root=True,
88 stdout=subprocess.PIPE)
89 blkid_output, _ = proc.communicate()
90 return _parse_blkid_output(blkid_output)
91
92
93def _parse_blkid_output(output):
94 for line in output.splitlines():
95 uuid_match = re.match("ID_FS_UUID=(.*)", line)
96 if uuid_match:
97 return uuid_match.group(1)
98 return None
99
100
83def ensure_partition_is_not_mounted(partition):101def ensure_partition_is_not_mounted(partition):
84 """Ensure the given partition is not mounted, umounting if necessary."""102 """Ensure the given partition is not mounted, umounting if necessary."""
85 if is_partition_mounted(partition):103 if is_partition_mounted(partition):
86104
=== modified file 'linaro_media_create/populate_boot.py'
--- linaro_media_create/populate_boot.py 2011-01-13 00:00:49 +0000
+++ linaro_media_create/populate_boot.py 2011-01-26 15:52:07 +0000
@@ -4,8 +4,9 @@
4from linaro_media_create import cmd_runner4from linaro_media_create import cmd_runner
55
66
7def populate_boot(board_config, chroot_dir, boot_partition, boot_disk,7def populate_boot(board_config, chroot_dir, rootfs_uuid, boot_partition,
8 boot_device_or_file, is_live, is_lowmem, consoles):8 boot_disk, boot_device_or_file, is_live, is_lowmem,
9 consoles):
910
10 parts_dir = 'boot'11 parts_dir = 'boot'
11 if is_live:12 if is_live:
@@ -33,8 +34,8 @@
33 boot_script_name=board_config.boot_script))34 boot_script_name=board_config.boot_script))
3435
35 board_config.make_boot_files(36 board_config.make_boot_files(
36 uboot_parts_dir, is_live, is_lowmem, consoles, chroot_dir, boot_disk,37 uboot_parts_dir, is_live, is_lowmem, consoles, chroot_dir, rootfs_uuid,
37 boot_script, boot_device_or_file)38 boot_disk, boot_script, boot_device_or_file)
3839
39 cmd_runner.run(['sync']).wait()40 cmd_runner.run(['sync']).wait()
40 try:41 try:
4142
=== modified file 'linaro_media_create/tests/test_media_create.py'
--- linaro_media_create/tests/test_media_create.py 2011-01-25 20:04:45 +0000
+++ linaro_media_create/tests/test_media_create.py 2011-01-26 15:52:07 +0000
@@ -27,7 +27,6 @@
27 make_boot_script,27 make_boot_script,
28 make_uImage,28 make_uImage,
29 make_uInitrd,29 make_uInitrd,
30 ROOTFS_UUID,
31 _get_file_matching,30 _get_file_matching,
32 _get_mlo_file,31 _get_mlo_file,
33 _run_mkimage,32 _run_mkimage,
@@ -50,6 +49,8 @@
50 Media,49 Media,
51 run_sfdisk_commands,50 run_sfdisk_commands,
52 setup_partitions,51 setup_partitions,
52 get_uuid,
53 _parse_blkid_output,
53 )54 )
54from linaro_media_create.rootfs import (55from linaro_media_create.rootfs import (
55 create_flash_kernel_config,56 create_flash_kernel_config,
@@ -172,7 +173,7 @@
172 linaro_media_create.boards, name, mock_func_creator(name)))173 linaro_media_create.boards, name, mock_func_creator(name)))
173174
174 def make_boot_files(self, config):175 def make_boot_files(self, config):
175 config.make_boot_files('', False, False, [], '', '', '', '')176 config.make_boot_files('', False, False, [], '', '', '', '', '')
176177
177 def test_vexpress_steps(self):178 def test_vexpress_steps(self):
178 config = linaro_media_create.boards.VexpressConfig179 config = linaro_media_create.boards.VexpressConfig
@@ -235,71 +236,76 @@
235236
236 def test_vexpress(self):237 def test_vexpress(self):
237 boot_cmd = board_configs['vexpress']._get_boot_cmd(238 boot_cmd = board_configs['vexpress']._get_boot_cmd(
238 is_live=False, is_lowmem=False, consoles=None)239 is_live=False, is_lowmem=False, consoles=None,
240 rootfs_uuid="deadbeef")
239 expected = (241 expected = (
240 "setenv bootcmd 'fatload mmc 0:1 0x60008000 uImage; fatload mmc "242 "setenv bootcmd 'fatload mmc 0:1 0x60008000 uImage; fatload mmc "
241 "0:1 0x81000000 uInitrd; bootm 0x60008000 0x81000000'\nsetenv "243 "0:1 0x81000000 uInitrd; bootm 0x60008000 0x81000000'\nsetenv "
242 "bootargs ' console=tty0 console=ttyAMA0,38400n8 "244 "bootargs ' console=tty0 console=ttyAMA0,38400n8 "
243 "root=UUID=%s rootwait ro'\nboot" % ROOTFS_UUID)245 "root=UUID=deadbeef rootwait ro'\nboot")
244 self.assertEqual(expected, boot_cmd)246 self.assertEqual(expected, boot_cmd)
245247
246 def test_mx51evk(self):248 def test_mx51evk(self):
247 boot_cmd = board_configs['mx51evk']._get_boot_cmd(249 boot_cmd = board_configs['mx51evk']._get_boot_cmd(
248 is_live=False, is_lowmem=False, consoles=None)250 is_live=False, is_lowmem=False, consoles=None,
251 rootfs_uuid="deadbeef")
249 expected = (252 expected = (
250 "setenv bootcmd 'fatload mmc 0:2 0x90000000 uImage; fatload mmc "253 "setenv bootcmd 'fatload mmc 0:2 0x90000000 uImage; fatload mmc "
251 "0:2 0x90800000 uInitrd; bootm 0x90000000 0x90800000'\nsetenv "254 "0:2 0x90800000 uInitrd; bootm 0x90000000 0x90800000'\nsetenv "
252 "bootargs ' console=tty0 console=ttymxc0,115200n8 "255 "bootargs ' console=tty0 console=ttymxc0,115200n8 "
253 "root=UUID=%s rootwait ro'\nboot" % ROOTFS_UUID)256 "root=UUID=deadbeef rootwait ro'\nboot")
254 self.assertEqual(expected, boot_cmd)257 self.assertEqual(expected, boot_cmd)
255258
256 def test_ux500(self):259 def test_ux500(self):
257 boot_cmd = board_configs['ux500']._get_boot_cmd(260 boot_cmd = board_configs['ux500']._get_boot_cmd(
258 is_live=False, is_lowmem=False, consoles=None)261 is_live=False, is_lowmem=False, consoles=None,
262 rootfs_uuid="deadbeef")
259 expected = (263 expected = (
260 "setenv bootcmd 'fatload mmc 1:1 0x00100000 uImage; fatload mmc "264 "setenv bootcmd 'fatload mmc 1:1 0x00100000 uImage; fatload mmc "
261 "1:1 0x08000000 uInitrd; bootm 0x00100000 0x08000000'\nsetenv "265 "1:1 0x08000000 uInitrd; bootm 0x00100000 0x08000000'\nsetenv "
262 "bootargs ' console=tty0 console=ttyAMA2,115200n8 "266 "bootargs ' console=tty0 console=ttyAMA2,115200n8 "
263 "root=UUID=%s rootwait ro earlyprintk rootdelay=1 fixrtc "267 "root=UUID=deadbeef rootwait ro earlyprintk rootdelay=1 fixrtc "
264 "nocompcache mem=96M@0 mem_modem=32M@96M mem=44M@128M "268 "nocompcache mem=96M@0 mem_modem=32M@96M mem=44M@128M "
265 "pmem=22M@172M mem=30M@194M mem_mali=32M@224M "269 "pmem=22M@172M mem=30M@194M mem_mali=32M@224M "
266 "pmem_hwb=54M@256M hwmem=48M@302M mem=152M@360M'\nboot"270 "pmem_hwb=54M@256M hwmem=48M@302M mem=152M@360M'\nboot")
267 % ROOTFS_UUID)
268 self.assertEqual(expected, boot_cmd)271 self.assertEqual(expected, boot_cmd)
269272
270 def test_panda(self):273 def test_panda(self):
271 boot_cmd = board_configs['panda']._get_boot_cmd(274 boot_cmd = board_configs['panda']._get_boot_cmd(
272 is_live=False, is_lowmem=False, consoles=None)275 is_live=False, is_lowmem=False, consoles=None,
276 rootfs_uuid="deadbeef")
273 expected = (277 expected = (
274 "setenv bootcmd 'fatload mmc 0:1 0x80200000 uImage; fatload mmc "278 "setenv bootcmd 'fatload mmc 0:1 0x80200000 uImage; fatload mmc "
275 "0:1 0x81600000 uInitrd; bootm 0x80200000 0x81600000'\nsetenv "279 "0:1 0x81600000 uInitrd; bootm 0x80200000 0x81600000'\nsetenv "
276 "bootargs ' console=tty0 console=ttyO2,115200n8 "280 "bootargs ' console=tty0 console=ttyO2,115200n8 "
277 "root=UUID=%s rootwait ro earlyprintk fixrtc nocompcache "281 "root=UUID=deadbeef rootwait ro earlyprintk fixrtc nocompcache "
278 "vram=32M omapfb.vram=0:8M mem=463M "282 "vram=32M omapfb.vram=0:8M mem=463M "
279 "ip=none'\nboot" % ROOTFS_UUID)283 "ip=none'\nboot")
280 self.assertEqual(expected, boot_cmd)284 self.assertEqual(expected, boot_cmd)
281285
282 def test_beagle(self):286 def test_beagle(self):
283 boot_cmd = board_configs['beagle']._get_boot_cmd(287 boot_cmd = board_configs['beagle']._get_boot_cmd(
284 is_live=False, is_lowmem=False, consoles=None)288 is_live=False, is_lowmem=False, consoles=None,
289 rootfs_uuid="deadbeef")
285 expected = (290 expected = (
286 "setenv bootcmd 'fatload mmc 0:1 0x80000000 uImage; "291 "setenv bootcmd 'fatload mmc 0:1 0x80000000 uImage; "
287 "fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80000000 "292 "fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80000000 "
288 "0x81600000'\nsetenv bootargs ' console=tty0 "293 "0x81600000'\nsetenv bootargs ' console=tty0 "
289 "console=ttyO2,115200n8 root=UUID=%s rootwait ro earlyprintk "294 "console=ttyO2,115200n8 root=UUID=deadbeef rootwait ro "
290 "fixrtc nocompcache vram=12M "295 "earlyprintk fixrtc nocompcache vram=12M "
291 "omapfb.mode=dvi:1280x720MR-16@60'\nboot" % ROOTFS_UUID)296 "omapfb.mode=dvi:1280x720MR-16@60'\nboot")
292 self.assertEqual(expected, boot_cmd)297 self.assertEqual(expected, boot_cmd)
293298
294 def test_overo(self):299 def test_overo(self):
295 boot_cmd = board_configs['overo']._get_boot_cmd(300 boot_cmd = board_configs['overo']._get_boot_cmd(
296 is_live=False, is_lowmem=False, consoles=None)301 is_live=False, is_lowmem=False, consoles=None,
302 rootfs_uuid="deadbeef")
297 expected = (303 expected = (
298 "setenv bootcmd 'fatload mmc 0:1 0x80000000 uImage; "304 "setenv bootcmd 'fatload mmc 0:1 0x80000000 uImage; "
299 "fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80000000 "305 "fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80000000 "
300 "0x81600000'\nsetenv bootargs ' console=tty0 "306 "0x81600000'\nsetenv bootargs ' console=tty0 "
301 "console=ttyO2,115200n8 root=UUID=%s rootwait ro earlyprintk'"307 "console=ttyO2,115200n8 root=UUID=deadbeef rootwait ro "
302 "\nboot" % ROOTFS_UUID)308 "earlyprintk'\nboot")
303 self.assertEqual(expected, boot_cmd)309 self.assertEqual(expected, boot_cmd)
304310
305class TestUnpackBinaryTarball(TestCaseWithFixtures):311class TestUnpackBinaryTarball(TestCaseWithFixtures):
@@ -321,6 +327,30 @@
321 self.assertEqual(rc, 0)327 self.assertEqual(rc, 0)
322328
323329
330class TestGetUuid(TestCaseWithFixtures):
331
332 def setUp(self):
333 super(TestGetUuid, self).setUp()
334
335 def test_get_uuid(self):
336 fixture = MockCmdRunnerPopenFixture()
337 self.useFixture(fixture)
338 get_uuid("/dev/rootfs")
339 self.assertEquals(
340 [[
341 "sudo", "blkid", "-o", "udev", "-p", "-c", "/dev/null",
342 "/dev/rootfs"]],
343 fixture.mock.calls)
344
345 def test_parse_blkid_output(self):
346 output = (
347 "ID_FS_UUID=67d641db-ea7d-4acf-9f46-5f1f8275dce2\n"
348 "ID_FS_UUID_ENC=67d641db-ea7d-4acf-9f46-5f1f8275dce2\n"
349 "ID_FS_TYPE=ext4\n")
350 uuid = _parse_blkid_output(output)
351 self.assertEquals("67d641db-ea7d-4acf-9f46-5f1f8275dce2", uuid)
352
353
324class TestCmdRunner(TestCaseWithFixtures):354class TestCmdRunner(TestCaseWithFixtures):
325355
326 def test_run(self):356 def test_run(self):
@@ -662,10 +692,9 @@
662 self.useFixture(MockSomethingFixture(692 self.useFixture(MockSomethingFixture(
663 partitions, 'get_boot_and_root_loopback_devices',693 partitions, 'get_boot_and_root_loopback_devices',
664 lambda image: ('/dev/loop99', '/dev/loop98')))694 lambda image: ('/dev/loop99', '/dev/loop98')))
665 uuid = '2e82008e-1af3-4699-8521-3bf5bac1e67a'
666 bootfs_dev, rootfs_dev = setup_partitions(695 bootfs_dev, rootfs_dev = setup_partitions(
667 board_configs['beagle'], Media(tempfile), '2G', 'boot',696 board_configs['beagle'], Media(tempfile), '2G', 'boot',
668 'root', 'ext3', uuid, True, True, True)697 'root', 'ext3', True, True, True)
669 self.assertEqual(698 self.assertEqual(
670 # This is the call that would create the image file.699 # This is the call that would create the image file.
671 [['qemu-img', 'create', '-f', 'raw', tempfile, '2G'],700 [['qemu-img', 'create', '-f', 'raw', tempfile, '2G'],
@@ -675,7 +704,7 @@
675 # Make sure changes are written to disk.704 # Make sure changes are written to disk.
676 ['sync'],705 ['sync'],
677 ['sudo', 'mkfs.vfat', '-F', '32', bootfs_dev, '-n', 'boot'],706 ['sudo', 'mkfs.vfat', '-F', '32', bootfs_dev, '-n', 'boot'],
678 ['sudo', 'mkfs.ext3', '-U', uuid, rootfs_dev, '-L', 'root']],707 ['sudo', 'mkfs.ext3', rootfs_dev, '-L', 'root']],
679 popen_fixture.mock.calls)708 popen_fixture.mock.calls)
680709
681 def test_setup_partitions_for_block_device(self):710 def test_setup_partitions_for_block_device(self):
@@ -694,10 +723,9 @@
694 # Pretend our tempfile is a block device.723 # Pretend our tempfile is a block device.
695 media.is_block_device = True724 media.is_block_device = True
696 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())725 popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
697 uuid = '2e82008e-1af3-4699-8521-3bf5bac1e67a'
698 bootfs_dev, rootfs_dev = setup_partitions(726 bootfs_dev, rootfs_dev = setup_partitions(
699 board_configs['beagle'], media, '2G', 'boot', 'root', 'ext3',727 board_configs['beagle'], media, '2G', 'boot', 'root', 'ext3',
700 uuid, True, True, True)728 True, True, True)
701 self.assertEqual(729 self.assertEqual(
702 [['sudo', 'parted', '-s', tempfile, 'mklabel', 'msdos'],730 [['sudo', 'parted', '-s', tempfile, 'mklabel', 'msdos'],
703 ['sudo', 'sfdisk', '-D', '-H', '255', '-S', '63', tempfile],731 ['sudo', 'sfdisk', '-D', '-H', '255', '-S', '63', tempfile],
@@ -707,7 +735,7 @@
707 ['sudo', 'umount', bootfs_dev],735 ['sudo', 'umount', bootfs_dev],
708 ['sudo', 'mkfs.vfat', '-F', '32', bootfs_dev, '-n', 'boot'],736 ['sudo', 'mkfs.vfat', '-F', '32', bootfs_dev, '-n', 'boot'],
709 ['sudo', 'umount', rootfs_dev],737 ['sudo', 'umount', rootfs_dev],
710 ['sudo', 'mkfs.ext3', '-U', uuid, rootfs_dev, '-L', 'root']],738 ['sudo', 'mkfs.ext3', rootfs_dev, '-L', 'root']],
711 popen_fixture.mock.calls)739 popen_fixture.mock.calls)
712740
713741

Subscribers

People subscribed via source and target branches