aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Davis <afd@ti.com>2023-07-22 00:14:44 +0530
committerTom Rini <trini@konsulko.com>2023-07-21 19:36:59 -0400
commit15432ea611e637872afd743e0261c087ccd5768a (patch)
tree978418e3e29f248fa3698b56d9d61499db7aba57
parent1ee652ab2f356c8a775bc4878f32f26f29a4c941 (diff)
downloadu-boot-15432ea611e637872afd743e0261c087ccd5768a.zip
u-boot-15432ea611e637872afd743e0261c087ccd5768a.tar.gz
u-boot-15432ea611e637872afd743e0261c087ccd5768a.tar.bz2
binman: Overwrite symlink if it already exists
Without this re-building will fail with an error when trying to create the symlink for the second time with an already exists error. Signed-off-by: Andrew Davis <afd@ti.com> [n-francis@ti.com: Added support for test output dir and testcase] Signed-off-by: Neha Malcom Francis <n-francis@ti.com>
-rw-r--r--tools/binman/ftest.py18
-rw-r--r--tools/binman/image.py2
2 files changed, 18 insertions, 2 deletions
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 5b13623..3e8091e 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -353,7 +353,7 @@ class TestFunctional(unittest.TestCase):
use_expanded=False, verbosity=None, allow_missing=False,
allow_fake_blobs=False, extra_indirs=None, threads=None,
test_section_timeout=False, update_fdt_in_elf=None,
- force_missing_bintools='', ignore_missing=False):
+ force_missing_bintools='', ignore_missing=False, output_dir=None):
"""Run binman with a given test file
Args:
@@ -384,6 +384,7 @@ class TestFunctional(unittest.TestCase):
update_fdt_in_elf: Value to pass with --update-fdt-in-elf=xxx
force_missing_tools (str): comma-separated list of bintools to
regard as missing
+ output_dir: Specific output directory to use for image using -O
Returns:
int return code, 0 on success
@@ -430,6 +431,8 @@ class TestFunctional(unittest.TestCase):
if extra_indirs:
for indir in extra_indirs:
args += ['-I', indir]
+ if output_dir:
+ args += ['-O', output_dir]
return self._DoBinman(*args)
def _SetupDtb(self, fname, outfile='u-boot.dtb'):
@@ -6174,7 +6177,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
str(e.exception))
def testSymlink(self):
- """Test that image files can be named"""
+ """Test that image files can be symlinked"""
retcode = self._DoTestFile('259_symlink.dts', debug=True, map=True)
self.assertEqual(0, retcode)
image = control.images['test_image']
@@ -6183,6 +6186,17 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
self.assertTrue(os.path.islink(sname))
self.assertEqual(os.readlink(sname), fname)
+ def testSymlinkOverwrite(self):
+ """Test that symlinked images can be overwritten"""
+ testdir = TestFunctional._MakeInputDir('symlinktest')
+ self._DoTestFile('259_symlink.dts', debug=True, map=True, output_dir=testdir)
+ # build the same image again in the same directory so that existing symlink is present
+ self._DoTestFile('259_symlink.dts', debug=True, map=True, output_dir=testdir)
+ fname = tools.get_output_filename('test_image.bin')
+ sname = tools.get_output_filename('symlink_to_test.bin')
+ self.assertTrue(os.path.islink(sname))
+ self.assertEqual(os.readlink(sname), fname)
+
def testSymbolsElf(self):
"""Test binman can assign symbols embedded in an ELF file"""
if not elf.ELF_TOOLS:
diff --git a/tools/binman/image.py b/tools/binman/image.py
index 8ebf71d..e77b5d0 100644
--- a/tools/binman/image.py
+++ b/tools/binman/image.py
@@ -182,6 +182,8 @@ class Image(section.Entry_section):
# Create symlink to file if symlink given
if self._symlink is not None:
sname = tools.get_output_filename(self._symlink)
+ if os.path.islink(sname):
+ os.remove(sname)
os.symlink(fname, sname)
def WriteMap(self):