Merge lp:~lool/linaro-image-tools/mkfs-uuid into lp:linaro-image-tools/11.11
- mkfs-uuid
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Westby (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
Tentative branch; only passed testsuite, didn't create btrfs image yet
Suggestions on testing get_uuid() welcome!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
James Westby (james-w) wrote : | # |
- 262. By Loïc Minier
-
Only lookup rootfs UUID when needed.
- 263. By Loïc Minier
-
Test that get_uuid() runs blkid correctly.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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).
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
James Westby (james-w) wrote : | # |
Looks good, apart from the simple conflict.
Should blkid be added to required_commands?
Thanks,
James
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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
1 | === modified file 'debian/control' | |||
2 | --- debian/control 2011-01-19 18:53:01 +0000 | |||
3 | +++ debian/control 2011-01-26 15:52:07 +0000 | |||
4 | @@ -22,7 +22,6 @@ | |||
5 | 22 | Architecture: all | 22 | Architecture: all |
6 | 23 | Depends: ${misc:Depends}, | 23 | Depends: ${misc:Depends}, |
7 | 24 | parted, | 24 | parted, |
8 | 25 | uuid-runtime, | ||
9 | 26 | dosfstools, | 25 | dosfstools, |
10 | 27 | u-boot-tools | uboot-mkimage, | 26 | u-boot-tools | uboot-mkimage, |
11 | 28 | python, | 27 | python, |
12 | 29 | 28 | ||
13 | === modified file 'linaro-media-create' | |||
14 | --- linaro-media-create 2011-01-26 12:10:14 +0000 | |||
15 | +++ linaro-media-create 2011-01-26 15:52:07 +0000 | |||
16 | @@ -8,7 +8,6 @@ | |||
17 | 8 | 8 | ||
18 | 9 | from linaro_media_create.boards import ( | 9 | from linaro_media_create.boards import ( |
19 | 10 | board_configs, | 10 | board_configs, |
20 | 11 | ROOTFS_UUID, | ||
21 | 12 | ) | 11 | ) |
22 | 13 | from linaro_media_create.check_device import ( | 12 | from linaro_media_create.check_device import ( |
23 | 14 | confirm_device_selection_and_ensure_it_is_ready) | 13 | confirm_device_selection_and_ensure_it_is_ready) |
24 | @@ -16,6 +15,7 @@ | |||
25 | 16 | from linaro_media_create.partitions import ( | 15 | from linaro_media_create.partitions import ( |
26 | 17 | Media, | 16 | Media, |
27 | 18 | setup_partitions, | 17 | setup_partitions, |
28 | 18 | get_uuid, | ||
29 | 19 | ) | 19 | ) |
30 | 20 | from linaro_media_create.populate_boot import populate_boot | 20 | from linaro_media_create.populate_boot import populate_boot |
31 | 21 | from linaro_media_create.rootfs import populate_rootfs | 21 | from linaro_media_create.rootfs import populate_rootfs |
32 | @@ -59,7 +59,11 @@ | |||
33 | 59 | def ensure_required_commands(args): | 59 | def ensure_required_commands(args): |
34 | 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.""" |
35 | 61 | required_commands = [ | 61 | required_commands = [ |
36 | 62 | <<<<<<< TREE | ||
37 | 62 | 'mkfs.vfat', 'sfdisk', 'mkimage', 'uuidgen', 'parted'] | 63 | 'mkfs.vfat', 'sfdisk', 'mkimage', 'uuidgen', 'parted'] |
38 | 64 | ======= | ||
39 | 65 | 'mkfs.vfat', 'sfdisk', 'fdisk', 'mkimage', 'parted'] | ||
40 | 66 | >>>>>>> MERGE-SOURCE | ||
41 | 63 | if not is_arm_host(): | 67 | if not is_arm_host(): |
42 | 64 | required_commands.append('qemu-arm-static') | 68 | required_commands.append('qemu-arm-static') |
43 | 65 | required_commands.append('qemu-img') | 69 | required_commands.append('qemu-img') |
44 | @@ -105,20 +109,22 @@ | |||
45 | 105 | 109 | ||
46 | 106 | boot_partition, root_partition = setup_partitions( | 110 | boot_partition, root_partition = setup_partitions( |
47 | 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, |
50 | 108 | args.rootfs, ROOTFS_UUID, args.should_create_partitions, | 112 | args.rootfs, args.should_create_partitions, args.should_format_bootfs, |
51 | 109 | args.should_format_bootfs, args.should_format_rootfs) | 113 | args.should_format_rootfs) |
52 | 114 | |||
53 | 115 | rootfs_uuid = get_uuid(root_partition) | ||
54 | 110 | 116 | ||
55 | 111 | if args.should_format_bootfs: | 117 | if args.should_format_bootfs: |
56 | 112 | populate_boot( | 118 | populate_boot( |
59 | 113 | board_config, ROOTFS_DIR, boot_partition, BOOT_DISK, args.device, | 119 | board_config, ROOTFS_DIR, rootfs_uuid, boot_partition, BOOT_DISK, |
60 | 114 | args.is_live, args.is_lowmem, args.consoles) | 120 | args.device, args.is_live, args.is_lowmem, args.consoles) |
61 | 115 | 121 | ||
62 | 116 | if args.should_format_rootfs: | 122 | if args.should_format_rootfs: |
63 | 117 | create_swap = False | 123 | create_swap = False |
64 | 118 | if args.swap_file is not None: | 124 | if args.swap_file is not None: |
65 | 119 | create_swap = True | 125 | create_swap = True |
66 | 120 | populate_rootfs(ROOTFS_DIR, ROOT_DISK, root_partition, args.rootfs, | 126 | populate_rootfs(ROOTFS_DIR, ROOT_DISK, root_partition, args.rootfs, |
68 | 121 | ROOTFS_UUID, create_swap, str(args.swap_file), | 127 | rootfs_uuid, create_swap, str(args.swap_file), |
69 | 122 | board_config.mmc_part_offset) | 128 | board_config.mmc_part_offset) |
70 | 123 | 129 | ||
71 | 124 | print "Done creating Linaro image on %s" % args.device | 130 | print "Done creating Linaro image on %s" % args.device |
72 | 125 | 131 | ||
73 | === modified file 'linaro_media_create/__init__.py' | |||
74 | --- linaro_media_create/__init__.py 2011-01-12 21:54:55 +0000 | |||
75 | +++ linaro_media_create/__init__.py 2011-01-26 15:52:07 +0000 | |||
76 | @@ -52,8 +52,7 @@ | |||
77 | 52 | group.add_argument( | 52 | group.add_argument( |
78 | 53 | '--live', dest='is_live', action='store_true', | 53 | '--live', dest='is_live', action='store_true', |
79 | 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 ' |
82 | 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')) |
81 | 56 | 'root= option')) | ||
83 | 57 | group.add_argument( | 56 | group.add_argument( |
84 | 58 | '--live-256m', dest='is_lowmem', action=Live256MegsAction, | 57 | '--live-256m', dest='is_lowmem', action=Live256MegsAction, |
85 | 59 | help=('Create boot command for casper/live images; adds ' | 58 | help=('Create boot command for casper/live images; adds ' |
86 | 60 | 59 | ||
87 | === modified file 'linaro_media_create/boards.py' | |||
88 | --- linaro_media_create/boards.py 2011-01-25 20:04:45 +0000 | |||
89 | +++ linaro_media_create/boards.py 2011-01-26 15:52:07 +0000 | |||
90 | @@ -9,12 +9,9 @@ | |||
91 | 9 | import glob | 9 | import glob |
92 | 10 | import os | 10 | import os |
93 | 11 | import tempfile | 11 | import tempfile |
94 | 12 | import uuid | ||
95 | 13 | 12 | ||
96 | 14 | from linaro_media_create import cmd_runner | 13 | from linaro_media_create import cmd_runner |
97 | 15 | 14 | ||
98 | 16 | ROOTFS_UUID = str(uuid.uuid4()) | ||
99 | 17 | |||
100 | 18 | 15 | ||
101 | 19 | class BoardConfig(object): | 16 | class BoardConfig(object): |
102 | 20 | """The configuration used when building an image for a board.""" | 17 | """The configuration used when building an image for a board.""" |
103 | @@ -48,7 +45,7 @@ | |||
104 | 48 | return ',9,%s,*\n,,,-' % partition_type | 45 | return ',9,%s,*\n,,,-' % partition_type |
105 | 49 | 46 | ||
106 | 50 | @classmethod | 47 | @classmethod |
108 | 51 | def _get_boot_cmd(cls, is_live, is_lowmem, consoles): | 48 | def _get_boot_cmd(cls, is_live, is_lowmem, consoles, rootfs_uuid): |
109 | 52 | """Get the boot command for this board. | 49 | """Get the boot command for this board. |
110 | 53 | 50 | ||
111 | 54 | In general subclasses should not have to override this. | 51 | In general subclasses should not have to override this. |
112 | @@ -69,7 +66,7 @@ | |||
113 | 69 | serial_opts += ' %s' % cls.extra_serial_opts | 66 | serial_opts += ' %s' % cls.extra_serial_opts |
114 | 70 | 67 | ||
115 | 71 | lowmem_opt = '' | 68 | lowmem_opt = '' |
117 | 72 | boot_snippet = 'root=UUID=%s' % ROOTFS_UUID | 69 | boot_snippet = 'root=UUID=%s' % rootfs_uuid |
118 | 73 | if is_live: | 70 | if is_live: |
119 | 74 | serial_opts += ' %s' % cls.live_serial_opts | 71 | serial_opts += ' %s' % cls.live_serial_opts |
120 | 75 | boot_snippet = 'boot=casper' | 72 | boot_snippet = 'boot=casper' |
121 | @@ -91,8 +88,9 @@ | |||
122 | 91 | 88 | ||
123 | 92 | @classmethod | 89 | @classmethod |
124 | 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, |
127 | 94 | root_dir, boot_dir, boot_script, boot_device_or_file): | 91 | root_dir, rootfs_uuid, boot_dir, boot_script, |
128 | 95 | boot_cmd = cls._get_boot_cmd(is_live, is_lowmem, consoles) | 92 | boot_device_or_file): |
129 | 93 | boot_cmd = cls._get_boot_cmd(is_live, is_lowmem, consoles, rootfs_uuid) | ||
130 | 96 | cls._make_boot_files( | 94 | cls._make_boot_files( |
131 | 97 | uboot_parts_dir, boot_cmd, root_dir, boot_dir, boot_script, | 95 | uboot_parts_dir, boot_cmd, root_dir, boot_dir, boot_script, |
132 | 98 | boot_device_or_file) | 96 | boot_device_or_file) |
133 | 99 | 97 | ||
134 | === modified file 'linaro_media_create/partitions.py' | |||
135 | --- linaro_media_create/partitions.py 2011-01-25 20:04:45 +0000 | |||
136 | +++ linaro_media_create/partitions.py 2011-01-26 15:52:07 +0000 | |||
137 | @@ -1,5 +1,6 @@ | |||
138 | 1 | import atexit | 1 | import atexit |
139 | 2 | import glob | 2 | import glob |
140 | 3 | import re | ||
141 | 3 | import subprocess | 4 | import subprocess |
142 | 4 | import time | 5 | import time |
143 | 5 | 6 | ||
144 | @@ -25,9 +26,8 @@ | |||
145 | 25 | # small enough that there's not much benefit in doing that, but if it grows we | 26 | # small enough that there's not much benefit in doing that, but if it grows we |
146 | 26 | # might want to do it. | 27 | # might want to do it. |
147 | 27 | def setup_partitions(board_config, media, image_size, bootfs_label, | 28 | def setup_partitions(board_config, media, image_size, bootfs_label, |
151 | 28 | rootfs_label, rootfs_type, rootfs_uuid, | 29 | rootfs_label, rootfs_type, should_create_partitions, |
152 | 29 | should_create_partitions, should_format_bootfs, | 30 | should_format_bootfs, should_format_rootfs): |
150 | 30 | should_format_rootfs): | ||
153 | 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. |
154 | 32 | 32 | ||
155 | 33 | :param board_config: A BoardConfig class. | 33 | :param board_config: A BoardConfig class. |
156 | @@ -73,13 +73,31 @@ | |||
157 | 73 | mkfs = 'mkfs.%s' % rootfs_type | 73 | mkfs = 'mkfs.%s' % rootfs_type |
158 | 74 | ensure_partition_is_not_mounted(rootfs) | 74 | ensure_partition_is_not_mounted(rootfs) |
159 | 75 | proc = cmd_runner.run( | 75 | proc = cmd_runner.run( |
161 | 76 | [mkfs, '-U', rootfs_uuid, rootfs, '-L', rootfs_label], | 76 | [mkfs, rootfs, '-L', rootfs_label], |
162 | 77 | as_root=True) | 77 | as_root=True) |
163 | 78 | proc.wait() | 78 | proc.wait() |
164 | 79 | 79 | ||
165 | 80 | return bootfs, rootfs | 80 | return bootfs, rootfs |
166 | 81 | 81 | ||
167 | 82 | 82 | ||
168 | 83 | def get_uuid(partition): | ||
169 | 84 | """Find UUID of the given partition.""" | ||
170 | 85 | proc = cmd_runner.run( | ||
171 | 86 | ['blkid', '-o', 'udev', '-p', '-c', '/dev/null', partition], | ||
172 | 87 | as_root=True, | ||
173 | 88 | stdout=subprocess.PIPE) | ||
174 | 89 | blkid_output, _ = proc.communicate() | ||
175 | 90 | return _parse_blkid_output(blkid_output) | ||
176 | 91 | |||
177 | 92 | |||
178 | 93 | def _parse_blkid_output(output): | ||
179 | 94 | for line in output.splitlines(): | ||
180 | 95 | uuid_match = re.match("ID_FS_UUID=(.*)", line) | ||
181 | 96 | if uuid_match: | ||
182 | 97 | return uuid_match.group(1) | ||
183 | 98 | return None | ||
184 | 99 | |||
185 | 100 | |||
186 | 83 | def ensure_partition_is_not_mounted(partition): | 101 | def ensure_partition_is_not_mounted(partition): |
187 | 84 | """Ensure the given partition is not mounted, umounting if necessary.""" | 102 | """Ensure the given partition is not mounted, umounting if necessary.""" |
188 | 85 | if is_partition_mounted(partition): | 103 | if is_partition_mounted(partition): |
189 | 86 | 104 | ||
190 | === modified file 'linaro_media_create/populate_boot.py' | |||
191 | --- linaro_media_create/populate_boot.py 2011-01-13 00:00:49 +0000 | |||
192 | +++ linaro_media_create/populate_boot.py 2011-01-26 15:52:07 +0000 | |||
193 | @@ -4,8 +4,9 @@ | |||
194 | 4 | from linaro_media_create import cmd_runner | 4 | from linaro_media_create import cmd_runner |
195 | 5 | 5 | ||
196 | 6 | 6 | ||
199 | 7 | def populate_boot(board_config, chroot_dir, boot_partition, boot_disk, | 7 | def populate_boot(board_config, chroot_dir, rootfs_uuid, boot_partition, |
200 | 8 | boot_device_or_file, is_live, is_lowmem, consoles): | 8 | boot_disk, boot_device_or_file, is_live, is_lowmem, |
201 | 9 | consoles): | ||
202 | 9 | 10 | ||
203 | 10 | parts_dir = 'boot' | 11 | parts_dir = 'boot' |
204 | 11 | if is_live: | 12 | if is_live: |
205 | @@ -33,8 +34,8 @@ | |||
206 | 33 | boot_script_name=board_config.boot_script)) | 34 | boot_script_name=board_config.boot_script)) |
207 | 34 | 35 | ||
208 | 35 | board_config.make_boot_files( | 36 | board_config.make_boot_files( |
211 | 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, |
212 | 37 | boot_script, boot_device_or_file) | 38 | boot_disk, boot_script, boot_device_or_file) |
213 | 38 | 39 | ||
214 | 39 | cmd_runner.run(['sync']).wait() | 40 | cmd_runner.run(['sync']).wait() |
215 | 40 | try: | 41 | try: |
216 | 41 | 42 | ||
217 | === modified file 'linaro_media_create/tests/test_media_create.py' | |||
218 | --- linaro_media_create/tests/test_media_create.py 2011-01-25 20:04:45 +0000 | |||
219 | +++ linaro_media_create/tests/test_media_create.py 2011-01-26 15:52:07 +0000 | |||
220 | @@ -27,7 +27,6 @@ | |||
221 | 27 | make_boot_script, | 27 | make_boot_script, |
222 | 28 | make_uImage, | 28 | make_uImage, |
223 | 29 | make_uInitrd, | 29 | make_uInitrd, |
224 | 30 | ROOTFS_UUID, | ||
225 | 31 | _get_file_matching, | 30 | _get_file_matching, |
226 | 32 | _get_mlo_file, | 31 | _get_mlo_file, |
227 | 33 | _run_mkimage, | 32 | _run_mkimage, |
228 | @@ -50,6 +49,8 @@ | |||
229 | 50 | Media, | 49 | Media, |
230 | 51 | run_sfdisk_commands, | 50 | run_sfdisk_commands, |
231 | 52 | setup_partitions, | 51 | setup_partitions, |
232 | 52 | get_uuid, | ||
233 | 53 | _parse_blkid_output, | ||
234 | 53 | ) | 54 | ) |
235 | 54 | from linaro_media_create.rootfs import ( | 55 | from linaro_media_create.rootfs import ( |
236 | 55 | create_flash_kernel_config, | 56 | create_flash_kernel_config, |
237 | @@ -172,7 +173,7 @@ | |||
238 | 172 | linaro_media_create.boards, name, mock_func_creator(name))) | 173 | linaro_media_create.boards, name, mock_func_creator(name))) |
239 | 173 | 174 | ||
240 | 174 | def make_boot_files(self, config): | 175 | def make_boot_files(self, config): |
242 | 175 | config.make_boot_files('', False, False, [], '', '', '', '') | 176 | config.make_boot_files('', False, False, [], '', '', '', '', '') |
243 | 176 | 177 | ||
244 | 177 | def test_vexpress_steps(self): | 178 | def test_vexpress_steps(self): |
245 | 178 | config = linaro_media_create.boards.VexpressConfig | 179 | config = linaro_media_create.boards.VexpressConfig |
246 | @@ -235,71 +236,76 @@ | |||
247 | 235 | 236 | ||
248 | 236 | def test_vexpress(self): | 237 | def test_vexpress(self): |
249 | 237 | boot_cmd = board_configs['vexpress']._get_boot_cmd( | 238 | boot_cmd = board_configs['vexpress']._get_boot_cmd( |
251 | 238 | is_live=False, is_lowmem=False, consoles=None) | 239 | is_live=False, is_lowmem=False, consoles=None, |
252 | 240 | rootfs_uuid="deadbeef") | ||
253 | 239 | expected = ( | 241 | expected = ( |
254 | 240 | "setenv bootcmd 'fatload mmc 0:1 0x60008000 uImage; fatload mmc " | 242 | "setenv bootcmd 'fatload mmc 0:1 0x60008000 uImage; fatload mmc " |
255 | 241 | "0:1 0x81000000 uInitrd; bootm 0x60008000 0x81000000'\nsetenv " | 243 | "0:1 0x81000000 uInitrd; bootm 0x60008000 0x81000000'\nsetenv " |
256 | 242 | "bootargs ' console=tty0 console=ttyAMA0,38400n8 " | 244 | "bootargs ' console=tty0 console=ttyAMA0,38400n8 " |
258 | 243 | "root=UUID=%s rootwait ro'\nboot" % ROOTFS_UUID) | 245 | "root=UUID=deadbeef rootwait ro'\nboot") |
259 | 244 | self.assertEqual(expected, boot_cmd) | 246 | self.assertEqual(expected, boot_cmd) |
260 | 245 | 247 | ||
261 | 246 | def test_mx51evk(self): | 248 | def test_mx51evk(self): |
262 | 247 | boot_cmd = board_configs['mx51evk']._get_boot_cmd( | 249 | boot_cmd = board_configs['mx51evk']._get_boot_cmd( |
264 | 248 | is_live=False, is_lowmem=False, consoles=None) | 250 | is_live=False, is_lowmem=False, consoles=None, |
265 | 251 | rootfs_uuid="deadbeef") | ||
266 | 249 | expected = ( | 252 | expected = ( |
267 | 250 | "setenv bootcmd 'fatload mmc 0:2 0x90000000 uImage; fatload mmc " | 253 | "setenv bootcmd 'fatload mmc 0:2 0x90000000 uImage; fatload mmc " |
268 | 251 | "0:2 0x90800000 uInitrd; bootm 0x90000000 0x90800000'\nsetenv " | 254 | "0:2 0x90800000 uInitrd; bootm 0x90000000 0x90800000'\nsetenv " |
269 | 252 | "bootargs ' console=tty0 console=ttymxc0,115200n8 " | 255 | "bootargs ' console=tty0 console=ttymxc0,115200n8 " |
271 | 253 | "root=UUID=%s rootwait ro'\nboot" % ROOTFS_UUID) | 256 | "root=UUID=deadbeef rootwait ro'\nboot") |
272 | 254 | self.assertEqual(expected, boot_cmd) | 257 | self.assertEqual(expected, boot_cmd) |
273 | 255 | 258 | ||
274 | 256 | def test_ux500(self): | 259 | def test_ux500(self): |
275 | 257 | boot_cmd = board_configs['ux500']._get_boot_cmd( | 260 | boot_cmd = board_configs['ux500']._get_boot_cmd( |
277 | 258 | is_live=False, is_lowmem=False, consoles=None) | 261 | is_live=False, is_lowmem=False, consoles=None, |
278 | 262 | rootfs_uuid="deadbeef") | ||
279 | 259 | expected = ( | 263 | expected = ( |
280 | 260 | "setenv bootcmd 'fatload mmc 1:1 0x00100000 uImage; fatload mmc " | 264 | "setenv bootcmd 'fatload mmc 1:1 0x00100000 uImage; fatload mmc " |
281 | 261 | "1:1 0x08000000 uInitrd; bootm 0x00100000 0x08000000'\nsetenv " | 265 | "1:1 0x08000000 uInitrd; bootm 0x00100000 0x08000000'\nsetenv " |
282 | 262 | "bootargs ' console=tty0 console=ttyAMA2,115200n8 " | 266 | "bootargs ' console=tty0 console=ttyAMA2,115200n8 " |
284 | 263 | "root=UUID=%s rootwait ro earlyprintk rootdelay=1 fixrtc " | 267 | "root=UUID=deadbeef rootwait ro earlyprintk rootdelay=1 fixrtc " |
285 | 264 | "nocompcache mem=96M@0 mem_modem=32M@96M mem=44M@128M " | 268 | "nocompcache mem=96M@0 mem_modem=32M@96M mem=44M@128M " |
286 | 265 | "pmem=22M@172M mem=30M@194M mem_mali=32M@224M " | 269 | "pmem=22M@172M mem=30M@194M mem_mali=32M@224M " |
289 | 266 | "pmem_hwb=54M@256M hwmem=48M@302M mem=152M@360M'\nboot" | 270 | "pmem_hwb=54M@256M hwmem=48M@302M mem=152M@360M'\nboot") |
288 | 267 | % ROOTFS_UUID) | ||
290 | 268 | self.assertEqual(expected, boot_cmd) | 271 | self.assertEqual(expected, boot_cmd) |
291 | 269 | 272 | ||
292 | 270 | def test_panda(self): | 273 | def test_panda(self): |
293 | 271 | boot_cmd = board_configs['panda']._get_boot_cmd( | 274 | boot_cmd = board_configs['panda']._get_boot_cmd( |
295 | 272 | is_live=False, is_lowmem=False, consoles=None) | 275 | is_live=False, is_lowmem=False, consoles=None, |
296 | 276 | rootfs_uuid="deadbeef") | ||
297 | 273 | expected = ( | 277 | expected = ( |
298 | 274 | "setenv bootcmd 'fatload mmc 0:1 0x80200000 uImage; fatload mmc " | 278 | "setenv bootcmd 'fatload mmc 0:1 0x80200000 uImage; fatload mmc " |
299 | 275 | "0:1 0x81600000 uInitrd; bootm 0x80200000 0x81600000'\nsetenv " | 279 | "0:1 0x81600000 uInitrd; bootm 0x80200000 0x81600000'\nsetenv " |
300 | 276 | "bootargs ' console=tty0 console=ttyO2,115200n8 " | 280 | "bootargs ' console=tty0 console=ttyO2,115200n8 " |
302 | 277 | "root=UUID=%s rootwait ro earlyprintk fixrtc nocompcache " | 281 | "root=UUID=deadbeef rootwait ro earlyprintk fixrtc nocompcache " |
303 | 278 | "vram=32M omapfb.vram=0:8M mem=463M " | 282 | "vram=32M omapfb.vram=0:8M mem=463M " |
305 | 279 | "ip=none'\nboot" % ROOTFS_UUID) | 283 | "ip=none'\nboot") |
306 | 280 | self.assertEqual(expected, boot_cmd) | 284 | self.assertEqual(expected, boot_cmd) |
307 | 281 | 285 | ||
308 | 282 | def test_beagle(self): | 286 | def test_beagle(self): |
309 | 283 | boot_cmd = board_configs['beagle']._get_boot_cmd( | 287 | boot_cmd = board_configs['beagle']._get_boot_cmd( |
311 | 284 | is_live=False, is_lowmem=False, consoles=None) | 288 | is_live=False, is_lowmem=False, consoles=None, |
312 | 289 | rootfs_uuid="deadbeef") | ||
313 | 285 | expected = ( | 290 | expected = ( |
314 | 286 | "setenv bootcmd 'fatload mmc 0:1 0x80000000 uImage; " | 291 | "setenv bootcmd 'fatload mmc 0:1 0x80000000 uImage; " |
315 | 287 | "fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80000000 " | 292 | "fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80000000 " |
316 | 288 | "0x81600000'\nsetenv bootargs ' console=tty0 " | 293 | "0x81600000'\nsetenv bootargs ' console=tty0 " |
320 | 289 | "console=ttyO2,115200n8 root=UUID=%s rootwait ro earlyprintk " | 294 | "console=ttyO2,115200n8 root=UUID=deadbeef rootwait ro " |
321 | 290 | "fixrtc nocompcache vram=12M " | 295 | "earlyprintk fixrtc nocompcache vram=12M " |
322 | 291 | "omapfb.mode=dvi:1280x720MR-16@60'\nboot" % ROOTFS_UUID) | 296 | "omapfb.mode=dvi:1280x720MR-16@60'\nboot") |
323 | 292 | self.assertEqual(expected, boot_cmd) | 297 | self.assertEqual(expected, boot_cmd) |
324 | 293 | 298 | ||
325 | 294 | def test_overo(self): | 299 | def test_overo(self): |
326 | 295 | boot_cmd = board_configs['overo']._get_boot_cmd( | 300 | boot_cmd = board_configs['overo']._get_boot_cmd( |
328 | 296 | is_live=False, is_lowmem=False, consoles=None) | 301 | is_live=False, is_lowmem=False, consoles=None, |
329 | 302 | rootfs_uuid="deadbeef") | ||
330 | 297 | expected = ( | 303 | expected = ( |
331 | 298 | "setenv bootcmd 'fatload mmc 0:1 0x80000000 uImage; " | 304 | "setenv bootcmd 'fatload mmc 0:1 0x80000000 uImage; " |
332 | 299 | "fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80000000 " | 305 | "fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80000000 " |
333 | 300 | "0x81600000'\nsetenv bootargs ' console=tty0 " | 306 | "0x81600000'\nsetenv bootargs ' console=tty0 " |
336 | 301 | "console=ttyO2,115200n8 root=UUID=%s rootwait ro earlyprintk'" | 307 | "console=ttyO2,115200n8 root=UUID=deadbeef rootwait ro " |
337 | 302 | "\nboot" % ROOTFS_UUID) | 308 | "earlyprintk'\nboot") |
338 | 303 | self.assertEqual(expected, boot_cmd) | 309 | self.assertEqual(expected, boot_cmd) |
339 | 304 | 310 | ||
340 | 305 | class TestUnpackBinaryTarball(TestCaseWithFixtures): | 311 | class TestUnpackBinaryTarball(TestCaseWithFixtures): |
341 | @@ -321,6 +327,30 @@ | |||
342 | 321 | self.assertEqual(rc, 0) | 327 | self.assertEqual(rc, 0) |
343 | 322 | 328 | ||
344 | 323 | 329 | ||
345 | 330 | class TestGetUuid(TestCaseWithFixtures): | ||
346 | 331 | |||
347 | 332 | def setUp(self): | ||
348 | 333 | super(TestGetUuid, self).setUp() | ||
349 | 334 | |||
350 | 335 | def test_get_uuid(self): | ||
351 | 336 | fixture = MockCmdRunnerPopenFixture() | ||
352 | 337 | self.useFixture(fixture) | ||
353 | 338 | get_uuid("/dev/rootfs") | ||
354 | 339 | self.assertEquals( | ||
355 | 340 | [[ | ||
356 | 341 | "sudo", "blkid", "-o", "udev", "-p", "-c", "/dev/null", | ||
357 | 342 | "/dev/rootfs"]], | ||
358 | 343 | fixture.mock.calls) | ||
359 | 344 | |||
360 | 345 | def test_parse_blkid_output(self): | ||
361 | 346 | output = ( | ||
362 | 347 | "ID_FS_UUID=67d641db-ea7d-4acf-9f46-5f1f8275dce2\n" | ||
363 | 348 | "ID_FS_UUID_ENC=67d641db-ea7d-4acf-9f46-5f1f8275dce2\n" | ||
364 | 349 | "ID_FS_TYPE=ext4\n") | ||
365 | 350 | uuid = _parse_blkid_output(output) | ||
366 | 351 | self.assertEquals("67d641db-ea7d-4acf-9f46-5f1f8275dce2", uuid) | ||
367 | 352 | |||
368 | 353 | |||
369 | 324 | class TestCmdRunner(TestCaseWithFixtures): | 354 | class TestCmdRunner(TestCaseWithFixtures): |
370 | 325 | 355 | ||
371 | 326 | def test_run(self): | 356 | def test_run(self): |
372 | @@ -662,10 +692,9 @@ | |||
373 | 662 | self.useFixture(MockSomethingFixture( | 692 | self.useFixture(MockSomethingFixture( |
374 | 663 | partitions, 'get_boot_and_root_loopback_devices', | 693 | partitions, 'get_boot_and_root_loopback_devices', |
375 | 664 | lambda image: ('/dev/loop99', '/dev/loop98'))) | 694 | lambda image: ('/dev/loop99', '/dev/loop98'))) |
376 | 665 | uuid = '2e82008e-1af3-4699-8521-3bf5bac1e67a' | ||
377 | 666 | bootfs_dev, rootfs_dev = setup_partitions( | 695 | bootfs_dev, rootfs_dev = setup_partitions( |
378 | 667 | board_configs['beagle'], Media(tempfile), '2G', 'boot', | 696 | board_configs['beagle'], Media(tempfile), '2G', 'boot', |
380 | 668 | 'root', 'ext3', uuid, True, True, True) | 697 | 'root', 'ext3', True, True, True) |
381 | 669 | self.assertEqual( | 698 | self.assertEqual( |
382 | 670 | # This is the call that would create the image file. | 699 | # This is the call that would create the image file. |
383 | 671 | [['qemu-img', 'create', '-f', 'raw', tempfile, '2G'], | 700 | [['qemu-img', 'create', '-f', 'raw', tempfile, '2G'], |
384 | @@ -675,7 +704,7 @@ | |||
385 | 675 | # Make sure changes are written to disk. | 704 | # Make sure changes are written to disk. |
386 | 676 | ['sync'], | 705 | ['sync'], |
387 | 677 | ['sudo', 'mkfs.vfat', '-F', '32', bootfs_dev, '-n', 'boot'], | 706 | ['sudo', 'mkfs.vfat', '-F', '32', bootfs_dev, '-n', 'boot'], |
389 | 678 | ['sudo', 'mkfs.ext3', '-U', uuid, rootfs_dev, '-L', 'root']], | 707 | ['sudo', 'mkfs.ext3', rootfs_dev, '-L', 'root']], |
390 | 679 | popen_fixture.mock.calls) | 708 | popen_fixture.mock.calls) |
391 | 680 | 709 | ||
392 | 681 | def test_setup_partitions_for_block_device(self): | 710 | def test_setup_partitions_for_block_device(self): |
393 | @@ -694,10 +723,9 @@ | |||
394 | 694 | # Pretend our tempfile is a block device. | 723 | # Pretend our tempfile is a block device. |
395 | 695 | media.is_block_device = True | 724 | media.is_block_device = True |
396 | 696 | popen_fixture = self.useFixture(MockCmdRunnerPopenFixture()) | 725 | popen_fixture = self.useFixture(MockCmdRunnerPopenFixture()) |
397 | 697 | uuid = '2e82008e-1af3-4699-8521-3bf5bac1e67a' | ||
398 | 698 | bootfs_dev, rootfs_dev = setup_partitions( | 726 | bootfs_dev, rootfs_dev = setup_partitions( |
399 | 699 | board_configs['beagle'], media, '2G', 'boot', 'root', 'ext3', | 727 | board_configs['beagle'], media, '2G', 'boot', 'root', 'ext3', |
401 | 700 | uuid, True, True, True) | 728 | True, True, True) |
402 | 701 | self.assertEqual( | 729 | self.assertEqual( |
403 | 702 | [['sudo', 'parted', '-s', tempfile, 'mklabel', 'msdos'], | 730 | [['sudo', 'parted', '-s', tempfile, 'mklabel', 'msdos'], |
404 | 703 | ['sudo', 'sfdisk', '-D', '-H', '255', '-S', '63', tempfile], | 731 | ['sudo', 'sfdisk', '-D', '-H', '255', '-S', '63', tempfile], |
405 | @@ -707,7 +735,7 @@ | |||
406 | 707 | ['sudo', 'umount', bootfs_dev], | 735 | ['sudo', 'umount', bootfs_dev], |
407 | 708 | ['sudo', 'mkfs.vfat', '-F', '32', bootfs_dev, '-n', 'boot'], | 736 | ['sudo', 'mkfs.vfat', '-F', '32', bootfs_dev, '-n', 'boot'], |
408 | 709 | ['sudo', 'umount', rootfs_dev], | 737 | ['sudo', 'umount', rootfs_dev], |
410 | 710 | ['sudo', 'mkfs.ext3', '-U', uuid, rootfs_dev, '-L', 'root']], | 738 | ['sudo', 'mkfs.ext3', rootfs_dev, '-L', 'root']], |
411 | 711 | popen_fixture.mock.calls) | 739 | popen_fixture.mock.calls) |
412 | 712 | 740 | ||
413 | 713 | 741 |
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