=== modified file 'linaro_image_tools/media_create/boards.py'
@@ -759,7 +759,7 @@
# Populate created raw partition with TOC and startup files.
config_files_path = os.path.join(chroot_dir, 'boot')
_, toc_filename = tempfile.mkstemp()
- new_files = cls.get_file_info(config_files_path)
+ new_files = cls.get_file_info(chroot_dir)
with open(toc_filename, 'wb') as toc:
cls.create_toc(toc, new_files)
cls.install_snowball_boot_loader(toc_filename, new_files,
@@ -820,19 +820,26 @@
f.write(data)
@classmethod
- def get_file_info(cls, bin_dir):
+ def get_file_info(cls, chroot_dir):
''' Fills in the offsets of files that are located in
non-absolute memory locations depending on their sizes.'
Also fills in file sizes'''
ofs = cls.TOC_SIZE
files = []
+ bin_dir = os.path.join(chroot_dir, 'boot')
with open(os.path.join(bin_dir, cls.SNOWBALL_STARTUP_FILES_CONFIG),
'r') as info_file:
for line in info_file:
file_data = line.split()
if file_data[0][0] == '#':
continue
- filename = os.path.join(bin_dir, file_data[1])
+ if file_data[1].startswith('/'):
+ filename = os.path.join(chroot_dir,
+ file_data[1].lstrip('/'))
+ else:
+ filename = os.path.join(bin_dir, file_data[1])
+ assert os.path.exists(filename), "File %s does not exist, " \
+ "please check the startfiles config file." % file_data[1]
address = long(file_data[3], 16)
if address != 0:
ofs = address
=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
@@ -716,6 +716,45 @@
i += 1
return expected
+ def test_get_file_info_relative_path(self):
+ # Create a config file
+ cfg_file = os.path.join(self.temp_bootdir_path,
+ boards.SnowballEmmcConfig.SNOWBALL_STARTUP_FILES_CONFIG)
+ uboot_file = 'u-boot.bin'
+ with open(cfg_file, 'w') as f:
+ f.write('%s %s %i %#x %s\n' % ('NORMAL', uboot_file, 0,
+ 0xBA0000, '9'))
+ with open(os.path.join(self.temp_bootdir_path, uboot_file), 'w') as f:
+ file_info = boards.SnowballEmmcConfig.get_file_info(
+ self.tempdir)
+ self.assertEquals(file_info[0]['filename'],
+ os.path.join(self.temp_bootdir_path, uboot_file))
+
+ def test_get_file_info_abs_path(self):
+ # Create a config file
+ cfg_file = os.path.join(self.temp_bootdir_path,
+ boards.SnowballEmmcConfig.SNOWBALL_STARTUP_FILES_CONFIG)
+ uboot_dir = tempfile.mkdtemp(dir=self.tempdir)
+ uboot_file = os.path.join(uboot_dir, 'u-boot.bin')
+ uboot_relative_file = uboot_file.replace(self.tempdir, '')
+ with open(cfg_file, 'w') as f:
+ f.write('%s %s %i %#x %s\n' % ('NORMAL', uboot_relative_file, 0,
+ 0xBA0000, '9'))
+ with open(uboot_file, 'w') as f:
+ file_info = boards.SnowballEmmcConfig.get_file_info(
+ self.tempdir)
+ self.assertEquals(file_info[0]['filename'], uboot_file)
+
+ def test_get_file_info_raises(self):
+ # Create a config file
+ cfg_file = os.path.join(self.temp_bootdir_path,
+ boards.SnowballEmmcConfig.SNOWBALL_STARTUP_FILES_CONFIG)
+ with open(cfg_file, 'w') as f:
+ f.write('%s %s %i %#x %s\n' % ('NORMAL', 'u-boot.bin', 0,
+ 0xBA0000, '9'))
+ self.assertRaises(AssertionError, boards.SnowballEmmcConfig.get_file_info,
+ self.tempdir)
+
def test_file_name_size(self):
''' Test using a to large toc file '''
_, toc_filename = tempfile.mkstemp()
@@ -829,7 +868,7 @@
def test_normal_case(self):
expected = self.setupFiles()
actual = boards.SnowballEmmcConfig.get_file_info(
- self.temp_bootdir_path)
+ self.tempdir)
self.assertEquals(expected, actual)