Merge lp:~salgado/linaro-image-tools/consolidate-board-config into lp:linaro-image-tools/11.11

Proposed by Guilherme Salgado
Status: Merged
Merged at revision: 238
Proposed branch: lp:~salgado/linaro-image-tools/consolidate-board-config
Merge into: lp:linaro-image-tools/11.11
Prerequisite: lp:~salgado/linaro-image-tools/config-class
Diff against target: 555 lines (+201/-158)
4 files modified
linaro-media-create (+2/-2)
linaro_media_create/boards.py (+177/-10)
linaro_media_create/populate_boot.py (+5/-129)
linaro_media_create/tests/test_media_create.py (+17/-17)
To merge this branch: bzr merge lp:~salgado/linaro-image-tools/consolidate-board-config
Reviewer Review Type Date Requested Status
Linaro Maintainers Pending
Review via email: mp+46062@code.launchpad.net

Description of the change

Move board-specific stuff from populate_boot.py to boards.py

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'linaro-media-create'
--- linaro-media-create 2011-01-13 01:04:08 +0000
+++ linaro-media-create 2011-01-13 01:04:08 +0000
@@ -100,8 +100,8 @@
100100
101 if args.should_format_bootfs:101 if args.should_format_bootfs:
102 populate_boot(102 populate_boot(
103 args.board, board_config, ROOTFS_DIR, boot_partition, BOOT_DISK,103 board_config, ROOTFS_DIR, boot_partition, BOOT_DISK, args.device,
104 args.device, TMP_DIR, args.is_live, args.is_lowmem, args.consoles)104 args.is_live, args.is_lowmem, args.consoles)
105105
106 if args.should_format_rootfs:106 if args.should_format_rootfs:
107 create_swap = False107 create_swap = False
108108
=== modified file 'linaro_media_create/boards.py'
--- linaro_media_create/boards.py 2011-01-13 01:04:08 +0000
+++ linaro_media_create/boards.py 2011-01-13 01:04:08 +0000
@@ -1,35 +1,48 @@
1"""Configuration for boards supported by linaro-media-create.1"""Configuration for boards supported by linaro-media-create.
22
3To add support for a new board, you just need to create a subclass of3To add support for a new board, you need to create a subclass of
4BoardConfig and set appropriate values for its variables.4BoardConfig, set appropriate values for its variables and add it to
5board_configs at the bottom of this file.
5"""6"""
67
8import atexit
9import glob
10import os
11import tempfile
7import uuid12import uuid
813
14from linaro_media_create import cmd_runner
15
9ROOTFS_UUID = str(uuid.uuid4())16ROOTFS_UUID = str(uuid.uuid4())
1017
1118
12class BoardConfig(object):19class BoardConfig(object):
13 """The configuration used when building an image for a board."""20 """The configuration used when building an image for a board."""
21 # These attributes may not need to be redefined on some subclasses.
14 uboot_flavor = None22 uboot_flavor = None
15 mmc_option = '0:1'23 mmc_option = '0:1'
16 mmc_part_offset = 024 mmc_part_offset = 0
17 extra_serial_opts = None25 fat_size = 32
18 live_serial_opts = None26 extra_serial_opts = ''
27 live_serial_opts = ''
28 extra_boot_args_options = None
29
30 # These attributes must be defined on all subclasses.
19 kernel_addr = None31 kernel_addr = None
20 initrd_addr = None32 initrd_addr = None
21 load_addr = None33 load_addr = None
22 sub_arch = None34 sub_arch = None
23 boot_script = None35 boot_script = None
24 extra_boot_args_options = None
25 fat_size = 32
2636
27 @classmethod37 @classmethod
28 def get_boot_cmd(cls, is_live, is_lowmem, consoles):38 def _get_boot_cmd(cls, is_live, is_lowmem, consoles):
29 """Get the boot command for this board."""39 """Get the boot command for this board.
40
41 In general subclasses should not have to override this.
42 """
30 boot_args_options = 'rootwait ro'43 boot_args_options = 'rootwait ro'
31 if cls.extra_boot_args_options:44 if cls.extra_boot_args_options is not None:
32 boot_args_options += " %s" % cls.extra_boot_args_options45 boot_args_options += ' %s' % cls.extra_boot_args_options
33 serial_opts = ''46 serial_opts = ''
34 if consoles is not None:47 if consoles is not None:
35 for console in consoles:48 for console in consoles:
@@ -63,6 +76,24 @@
63 "%(boot_snippet)s %(boot_args_options)s'\n"76 "%(boot_snippet)s %(boot_args_options)s'\n"
64 "boot" % replacements)77 "boot" % replacements)
6578
79 @classmethod
80 def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles,
81 root_dir, boot_dir, boot_script, boot_device_or_file):
82 boot_cmd = cls._get_boot_cmd(is_live, is_lowmem, consoles)
83 cls._make_boot_files(
84 uboot_parts_dir, boot_cmd, root_dir, boot_dir, boot_script,
85 boot_device_or_file)
86
87 @classmethod
88 def _make_boot_files(cls, uboot_parts_dir, boot_cmd, root_dir, boot_dir,
89 boot_script, boot_device_or_file):
90 """Make the necessary boot files for this board.
91
92 This is usually board-specific so ought to be defined in every
93 subclass.
94 """
95 raise NotImplementedError()
96
6697
67class BeagleConfig(BoardConfig):98class BeagleConfig(BoardConfig):
68 uboot_flavor = 'omap3_beagle'99 uboot_flavor = 'omap3_beagle'
@@ -77,6 +108,17 @@
77 'earlyprintk fixrtc nocompcache vram=12M omapfb.debug=y '108 'earlyprintk fixrtc nocompcache vram=12M omapfb.debug=y '
78 'omapfb.mode=dvi:1280x720MR-16@60')109 'omapfb.mode=dvi:1280x720MR-16@60')
79110
111 @classmethod
112 def _make_boot_files(cls, uboot_parts_dir, boot_cmd, chroot_dir,
113 boot_dir, boot_script, boot_device_or_file):
114 mlo_file = os.path.join(
115 chroot_dir, 'usr', 'lib', 'x-loader-omap', 'MLO')
116 install_omap_boot_loader(mlo_file, boot_dir)
117 make_uImage(cls.load_addr, uboot_parts_dir, cls.sub_arch, boot_dir)
118 make_uInitrd(uboot_parts_dir, cls.sub_arch, boot_dir)
119 make_boot_script(boot_cmd, boot_script)
120 make_boot_ini(boot_script, boot_dir)
121
80122
81class PandaConfig(BoardConfig):123class PandaConfig(BoardConfig):
82 uboot_flavor = 'omap4_panda'124 uboot_flavor = 'omap4_panda'
@@ -91,10 +133,29 @@
91 'earlyprintk fixrtc nocompcache vram = 32M omapfb.debug = y '133 'earlyprintk fixrtc nocompcache vram = 32M omapfb.debug = y '
92 'omapfb.vram = 0:8M mem = 463M ip = none')134 'omapfb.vram = 0:8M mem = 463M ip = none')
93135
136 @classmethod
137 def _make_boot_files(cls, uboot_parts_dir, boot_cmd, chroot_dir,
138 boot_dir, boot_script, boot_device_or_file):
139 mlo_file = os.path.join(
140 chroot_dir, 'usr', 'lib', 'x-loader-omap4', 'MLO')
141 install_omap_boot_loader(mlo_file, boot_dir)
142 make_uImage(cls.load_addr, uboot_parts_dir, cls.sub_arch, boot_dir)
143 make_uInitrd(uboot_parts_dir, cls.sub_arch, boot_dir)
144 make_boot_script(boot_cmd, boot_script)
145 make_boot_ini(boot_script, boot_dir)
146
94147
95class IgepConfig(BeagleConfig):148class IgepConfig(BeagleConfig):
96 uboot_flavor = None149 uboot_flavor = None
97150
151 @classmethod
152 def _make_boot_files(cls, uboot_parts_dir, boot_cmd, chroot_dir,
153 boot_dir, boot_script, boot_device_or_file):
154 make_uImage(cls.load_addr, uboot_parts_dir, cls.sub_arch, boot_dir)
155 make_uInitrd(uboot_parts_dir, cls.sub_arch, boot_dir)
156 make_boot_script(boot_cmd, boot_script)
157 make_boot_ini(boot_script, boot_dir)
158
98159
99class Ux500Config(BoardConfig):160class Ux500Config(BoardConfig):
100 extra_serial_opts = 'console = tty0 console = ttyAMA2,115200n8'161 extra_serial_opts = 'console = tty0 console = ttyAMA2,115200n8'
@@ -111,6 +172,13 @@
111 'hwmem = 48M@302M mem = 152M@360M')172 'hwmem = 48M@302M mem = 152M@360M')
112 mmc_option = '1:1'173 mmc_option = '1:1'
113174
175 @classmethod
176 def _make_boot_files(cls, uboot_parts_dir, boot_cmd, chroot_dir,
177 boot_dir, boot_script, boot_device_or_file):
178 make_uImage(cls.load_addr, uboot_parts_dir, cls.sub_arch, boot_dir)
179 make_uInitrd(uboot_parts_dir, cls.sub_arch, boot_dir)
180 make_boot_script(boot_cmd, boot_script)
181
114182
115class Mx51evkConfig(BoardConfig):183class Mx51evkConfig(BoardConfig):
116 extra_serial_opts = 'console = tty0 console = ttymxc0,115200n8'184 extra_serial_opts = 'console = tty0 console = ttymxc0,115200n8'
@@ -123,6 +191,16 @@
123 mmc_part_offset = 1191 mmc_part_offset = 1
124 mmc_option = '0:2'192 mmc_option = '0:2'
125193
194 @classmethod
195 def _make_boot_files(cls, uboot_parts_dir, boot_cmd, chroot_dir,
196 boot_dir, boot_script, boot_device_or_file):
197 uboot_file = os.path.join(
198 chroot_dir, 'usr', 'lib', 'u-boot', 'mx51evk', 'u-boot.imx')
199 install_mx51evk_boot_loader(uboot_file, boot_device_or_file)
200 make_uImage(cls.load_addr, uboot_parts_dir, cls.sub_arch, boot_dir)
201 make_uInitrd(uboot_parts_dir, cls.sub_arch, boot_dir)
202 make_boot_script(boot_cmd, boot_script)
203
126204
127class VexpressConfig(BoardConfig):205class VexpressConfig(BoardConfig):
128 uboot_flavor = 'ca9x4_ct_vxp'206 uboot_flavor = 'ca9x4_ct_vxp'
@@ -137,6 +215,12 @@
137 # only allows for FAT16215 # only allows for FAT16
138 fat_size = 16216 fat_size = 16
139217
218 @classmethod
219 def _make_boot_files(cls, uboot_parts_dir, boot_cmd, chroot_dir,
220 boot_dir, boot_script):
221 make_uImage(cls.load_addr, uboot_parts_dir, cls.sub_arch, boot_dir)
222 make_uInitrd(uboot_parts_dir, cls.sub_arch, boot_dir)
223
140224
141board_configs = {225board_configs = {
142 'beagle': BeagleConfig,226 'beagle': BeagleConfig,
@@ -146,3 +230,86 @@
146 'ux500': Ux500Config,230 'ux500': Ux500Config,
147 'mx51evk': Mx51evkConfig,231 'mx51evk': Mx51evkConfig,
148 }232 }
233
234
235def _run_mkimage(img_type, load_addr, entry_point, name, img_data, img,
236 stdout=None, as_root=True):
237 cmd = ['mkimage',
238 '-A', 'arm',
239 '-O', 'linux',
240 '-T', img_type,
241 '-C', 'none',
242 '-a', load_addr,
243 '-e', load_addr,
244 '-n', name,
245 '-d', img_data,
246 img]
247 proc = cmd_runner.run(cmd, as_root=as_root, stdout=stdout)
248 proc.wait()
249 return proc.returncode
250
251
252def _get_file_matching(regex):
253 """Return a file whose path matches the given regex.
254
255 If zero or more than one files match, raise a ValueError.
256 """
257 files = glob.glob(regex)
258 if len(files) == 1:
259 return files[0]
260 elif len(files) == 0:
261 raise ValueError(
262 "No files found matching '%s'; can't continue" % regex)
263 else:
264 # TODO: Could ask the user to chosse which file to use instead of
265 # raising an exception.
266 raise ValueError("Too many files matching '%s' found." % regex)
267
268
269def make_uImage(load_addr, uboot_parts_dir, sub_arch, boot_disk):
270 img_data = _get_file_matching(
271 '%s/vmlinuz-*-%s' % (uboot_parts_dir, sub_arch))
272 img = '%s/uImage' % boot_disk
273 return _run_mkimage(
274 'kernel', load_addr, load_addr, 'Linux', img_data, img)
275
276
277def make_uInitrd(uboot_parts_dir, sub_arch, boot_disk):
278 img_data = _get_file_matching(
279 '%s/initrd.img-*-%s' % (uboot_parts_dir, sub_arch))
280 img = '%s/uInitrd' % boot_disk
281 return _run_mkimage('ramdisk', '0', '0', 'initramfs', img_data, img)
282
283
284def make_boot_script(boot_script_data, boot_script):
285 # Need to save the boot script data into a file that will be passed to
286 # mkimage.
287 _, tmpfile = tempfile.mkstemp()
288 atexit.register(os.unlink, tmpfile)
289 with open(tmpfile, 'w') as fd:
290 fd.write(boot_script_data)
291 return _run_mkimage(
292 'script', '0', '0', 'boot script', tmpfile, boot_script)
293
294
295def install_mx51evk_boot_loader(imx_file, boot_device_or_file):
296 proc = cmd_runner.run([
297 "dd",
298 "if=%s" % imx_file,
299 "of=%s" % boot_device_or_file,
300 "bs=1024",
301 "seek=1",
302 "conv=notrunc"], as_root=True)
303 proc.wait()
304
305
306def install_omap_boot_loader(mlo_file, boot_disk):
307 cmd_runner.run(["cp", "-v", mlo_file, boot_disk], as_root=True).wait()
308 # XXX: Is this really needed?
309 cmd_runner.run(["sync"]).wait()
310
311
312def make_boot_ini(boot_script, boot_disk):
313 proc = cmd_runner.run(
314 ["cp", "-v", boot_script, "%s/boot.ini" % boot_disk], as_root=True)
315 proc.wait()
149316
=== modified file 'linaro_media_create/populate_boot.py'
--- linaro_media_create/populate_boot.py 2011-01-13 01:04:08 +0000
+++ linaro_media_create/populate_boot.py 2011-01-13 01:04:08 +0000
@@ -1,94 +1,11 @@
1import errno1import errno
2import glob
3import os2import os
43
5from linaro_media_create import cmd_runner4from linaro_media_create import cmd_runner
65
76
8def _run_mkimage(img_type, load_addr, entry_point, name, img_data, img,7def populate_boot(board_config, chroot_dir, boot_partition, boot_disk,
9 stdout=None, as_root=True):8 boot_device_or_file, is_live, is_lowmem, consoles):
10 cmd = ['mkimage',
11 '-A', 'arm',
12 '-O', 'linux',
13 '-T', img_type,
14 '-C', 'none',
15 '-a', load_addr,
16 '-e', load_addr,
17 '-n', name,
18 '-d', img_data,
19 img]
20 proc = cmd_runner.run(cmd, as_root=as_root, stdout=stdout)
21 proc.wait()
22 return proc.returncode
23
24
25def _get_file_matching(regex):
26 """Return a file whose path matches the given regex.
27
28 If zero or more than one files match, raise a ValueError.
29 """
30 files = glob.glob(regex)
31 if len(files) == 1:
32 return files[0]
33 elif len(files) == 0:
34 raise ValueError(
35 "No files found matching '%s'; can't continue" % regex)
36 else:
37 # TODO: Could ask the user to chosse which file to use instead of
38 # raising an exception.
39 raise ValueError("Too many files matching '%s' found." % regex)
40
41
42def make_uImage(load_addr, uboot_parts_dir, sub_arch, boot_disk):
43 img_data = _get_file_matching(
44 '%s/vmlinuz-*-%s' % (uboot_parts_dir, sub_arch))
45 img = '%s/uImage' % boot_disk
46 return _run_mkimage(
47 'kernel', load_addr, load_addr, 'Linux', img_data, img)
48
49
50def make_uInitrd(uboot_parts_dir, sub_arch, boot_disk):
51 img_data = _get_file_matching(
52 '%s/initrd.img-*-%s' % (uboot_parts_dir, sub_arch))
53 img = '%s/uInitrd' % boot_disk
54 return _run_mkimage('ramdisk', '0', '0', 'initramfs', img_data, img)
55
56
57def make_boot_script(boot_script_data, tmp_dir, boot_script):
58 # Need to save the boot script data into a file that will be passed to
59 # mkimage.
60 data_file = '%s/boot.cmd' % tmp_dir
61 with open(data_file, 'w') as fd:
62 fd.write(boot_script_data)
63 return _run_mkimage(
64 'script', '0', '0', 'boot script', data_file, boot_script)
65
66
67def install_mx51evk_boot_loader(imx_file, boot_device_or_file):
68 proc = cmd_runner.run([
69 "dd",
70 "if=%s" % imx_file,
71 "of=%s" % boot_device_or_file,
72 "bs=1024",
73 "seek=1",
74 "conv=notrunc"], as_root=True)
75 proc.wait()
76
77
78def install_omap_boot_loader(mlo_file, boot_disk):
79 cmd_runner.run(["cp", "-v", mlo_file, boot_disk], as_root=True).wait()
80 # XXX: Is this really needed?
81 cmd_runner.run(["sync"]).wait()
82
83
84def make_boot_ini(boot_script, boot_disk):
85 proc = cmd_runner.run(
86 ["cp", "-v", boot_script, "%s/boot.ini" % boot_disk], as_root=True)
87 proc.wait()
88
89
90def populate_boot(board, board_config, chroot_dir, boot_partition, boot_disk,
91 boot_device_or_file, tmp_dir, is_live, is_lowmem, consoles):
929
93 parts_dir = 'boot'10 parts_dir = 'boot'
94 if is_live:11 if is_live:
@@ -115,50 +32,9 @@
115 dict(boot_disk=boot_disk,32 dict(boot_disk=boot_disk,
116 boot_script_name=board_config.boot_script))33 boot_script_name=board_config.boot_script))
11734
118 load_addr = board_config.load_addr35 board_config.make_boot_files(
119 sub_arch = board_config.sub_arch36 uboot_parts_dir, is_live, is_lowmem, consoles, chroot_dir, boot_disk,
120 boot_cmd = board_config.get_boot_cmd(is_live, is_lowmem, consoles)37 boot_script, boot_device_or_file)
121
122 # TODO: Once linaro-media-create is fully ported to python, we should
123 # split this into several board-specific functions that are defined
124 # somewhere else and just called here.
125 if board in ["beagle", "panda"]:
126 xloader_dir = 'x-loader-omap'
127 if board == "panda":
128 xloader_dir = 'x-loader-omap4'
129 mlo_file = os.path.join(
130 chroot_dir, 'usr', 'lib', xloader_dir, 'MLO')
131 install_omap_boot_loader(mlo_file, boot_disk)
132 make_uImage(load_addr, uboot_parts_dir, sub_arch, boot_disk)
133 make_uInitrd(uboot_parts_dir, sub_arch, boot_disk)
134 make_boot_script(boot_cmd, tmp_dir, boot_script)
135 make_boot_ini(boot_script, boot_disk)
136
137 elif board == "igep":
138 make_uImage(load_addr, uboot_parts_dir, sub_arch, boot_disk)
139 make_uInitrd(uboot_parts_dir, sub_arch, boot_disk)
140 make_boot_script(boot_cmd, tmp_dir, boot_script)
141 make_boot_ini(boot_script, boot_disk)
142
143 elif board == "ux500":
144 make_uImage(load_addr, uboot_parts_dir, sub_arch, boot_disk)
145 make_uInitrd(uboot_parts_dir, sub_arch, boot_disk)
146 make_boot_script(boot_cmd, tmp_dir, boot_script)
147
148 elif board == "vexpress":
149 make_uImage(load_addr, uboot_parts_dir, sub_arch, boot_disk)
150 make_uInitrd(uboot_parts_dir, sub_arch, boot_disk)
151
152 elif board == "mx51evk":
153 install_mx51evk_boot_loader(
154 "binary/usr/lib/u-boot/mx51evk/u-boot.imx", boot_device_or_file)
155 make_uImage(load_addr, uboot_parts_dir, sub_arch, boot_disk)
156 make_uInitrd(uboot_parts_dir, sub_arch, boot_disk)
157 make_boot_script(boot_cmd, tmp_dir, boot_script)
158
159 else:
160 raise AssertionError(
161 "Internal error; missing support for board: %s" % board)
16238
163 cmd_runner.run(['sync']).wait()39 cmd_runner.run(['sync']).wait()
164 try:40 try:
16541
=== modified file 'linaro_media_create/tests/test_media_create.py'
--- linaro_media_create/tests/test_media_create.py 2011-01-13 01:04:08 +0000
+++ linaro_media_create/tests/test_media_create.py 2011-01-13 01:04:08 +0000
@@ -6,6 +6,7 @@
6import string6import string
7import subprocess7import subprocess
8import sys8import sys
9import tempfile
9import time10import time
1011
11from testtools import TestCase12from testtools import TestCase
@@ -16,13 +17,18 @@
16 check_device,17 check_device,
17 cmd_runner,18 cmd_runner,
18 ensure_command,19 ensure_command,
19 populate_boot,20 boards,
20 partitions,21 partitions,
21 rootfs,22 rootfs,
22 )23 )
23from linaro_media_create.boards import (24from linaro_media_create.boards import (
24 board_configs,25 board_configs,
26 make_boot_script,
27 make_uImage,
28 make_uInitrd,
25 ROOTFS_UUID,29 ROOTFS_UUID,
30 _get_file_matching,
31 _run_mkimage,
26 )32 )
27from linaro_media_create.hwpack import (33from linaro_media_create.hwpack import (
28 copy_file,34 copy_file,
@@ -43,13 +49,6 @@
43 run_sfdisk_commands,49 run_sfdisk_commands,
44 setup_partitions,50 setup_partitions,
45 )51 )
46from linaro_media_create.populate_boot import (
47 make_boot_script,
48 make_uImage,
49 make_uInitrd,
50 _get_file_matching,
51 _run_mkimage,
52 )
53from linaro_media_create.remove_binary_dir import remove_dir52from linaro_media_create.remove_binary_dir import remove_dir
54from linaro_media_create.rootfs import (53from linaro_media_create.rootfs import (
55 create_flash_kernel_config,54 create_flash_kernel_config,
@@ -96,7 +95,7 @@
96class TestGetBootCmd(TestCase):95class TestGetBootCmd(TestCase):
9796
98 def test_vexpress(self):97 def test_vexpress(self):
99 boot_cmd = board_configs['vexpress'].get_boot_cmd(98 boot_cmd = board_configs['vexpress']._get_boot_cmd(
100 is_live=False, is_lowmem=False, consoles=None)99 is_live=False, is_lowmem=False, consoles=None)
101 expected = (100 expected = (
102 "setenv bootcmd 'fatload mmc 0:1 0x60008000 uImage; fatload mmc "101 "setenv bootcmd 'fatload mmc 0:1 0x60008000 uImage; fatload mmc "
@@ -106,7 +105,7 @@
106 self.assertEqual(expected, boot_cmd)105 self.assertEqual(expected, boot_cmd)
107106
108 def test_mx51evk(self):107 def test_mx51evk(self):
109 boot_cmd = board_configs['mx51evk'].get_boot_cmd(108 boot_cmd = board_configs['mx51evk']._get_boot_cmd(
110 is_live=False, is_lowmem=False, consoles=None)109 is_live=False, is_lowmem=False, consoles=None)
111 expected = (110 expected = (
112 "setenv bootcmd 'fatload mmc 0:2 0x90000000 uImage; fatload mmc "111 "setenv bootcmd 'fatload mmc 0:2 0x90000000 uImage; fatload mmc "
@@ -116,7 +115,7 @@
116 self.assertEqual(expected, boot_cmd)115 self.assertEqual(expected, boot_cmd)
117116
118 def test_ux500(self):117 def test_ux500(self):
119 boot_cmd = board_configs['ux500'].get_boot_cmd(118 boot_cmd = board_configs['ux500']._get_boot_cmd(
120 is_live=False, is_lowmem=False, consoles=None)119 is_live=False, is_lowmem=False, consoles=None)
121 expected = (120 expected = (
122 "setenv bootcmd 'fatload mmc 1:1 0x00100000 uImage; fatload mmc "121 "setenv bootcmd 'fatload mmc 1:1 0x00100000 uImage; fatload mmc "
@@ -130,7 +129,7 @@
130 self.assertEqual(expected, boot_cmd)129 self.assertEqual(expected, boot_cmd)
131130
132 def test_panda(self):131 def test_panda(self):
133 boot_cmd = board_configs['panda'].get_boot_cmd(132 boot_cmd = board_configs['panda']._get_boot_cmd(
134 is_live=False, is_lowmem=False, consoles=None)133 is_live=False, is_lowmem=False, consoles=None)
135 expected = (134 expected = (
136 "setenv bootcmd 'fatload mmc 0:1 0x80200000 uImage; fatload mmc "135 "setenv bootcmd 'fatload mmc 0:1 0x80200000 uImage; fatload mmc "
@@ -142,7 +141,7 @@
142 self.assertEqual(expected, boot_cmd)141 self.assertEqual(expected, boot_cmd)
143142
144 def test_beagle(self):143 def test_beagle(self):
145 boot_cmd = board_configs['beagle'].get_boot_cmd(144 boot_cmd = board_configs['beagle']._get_boot_cmd(
146 is_live=False, is_lowmem=False, consoles=None)145 is_live=False, is_lowmem=False, consoles=None)
147 expected = (146 expected = (
148 "setenv bootcmd 'fatload mmc 0:1 0x80000000 uImage; "147 "setenv bootcmd 'fatload mmc 0:1 0x80000000 uImage; "
@@ -229,7 +228,7 @@
229228
230 def _mock_get_file_matching(self):229 def _mock_get_file_matching(self):
231 self.useFixture(MockSomethingFixture(230 self.useFixture(MockSomethingFixture(
232 populate_boot, '_get_file_matching',231 boards, '_get_file_matching',
233 lambda regex: regex))232 lambda regex: regex))
234233
235 def _mock_Popen(self):234 def _mock_Popen(self):
@@ -258,14 +257,15 @@
258 self.assertEqual([expected], fixture.mock.calls)257 self.assertEqual([expected], fixture.mock.calls)
259258
260 def test_make_boot_script(self):259 def test_make_boot_script(self):
260 self.useFixture(MockSomethingFixture(
261 tempfile, 'mkstemp', lambda: (-1, '/tmp/random-abxzr')))
261 self._mock_get_file_matching()262 self._mock_get_file_matching()
262 fixture = self._mock_Popen()263 fixture = self._mock_Popen()
263 tempdir = self.useFixture(CreateTempDirFixture()).tempdir264 make_boot_script('boot script data', 'boot_script')
264 make_boot_script('boot script data', tempdir, 'boot_script')
265 expected = [265 expected = [
266 'sudo', 'mkimage', '-A', 'arm', '-O', 'linux', '-T', 'script',266 'sudo', 'mkimage', '-A', 'arm', '-O', 'linux', '-T', 'script',
267 '-C', 'none', '-a', '0', '-e', '0', '-n', 'boot script',267 '-C', 'none', '-a', '0', '-e', '0', '-n', 'boot script',
268 '-d', '%s/boot.cmd' % tempdir, 'boot_script']268 '-d', '/tmp/random-abxzr', 'boot_script']
269 self.assertEqual([expected], fixture.mock.calls)269 self.assertEqual([expected], fixture.mock.calls)
270270
271 def test_get_file_matching(self):271 def test_get_file_matching(self):

Subscribers

People subscribed via source and target branches