[PATCH 3/4] binman: Have faked binaries live in the output directory.

Tom Rini
2022-01-12T00:15:14Z

In general, and for Azure specifically, we need to have files created in
the output directory and cannot assume a writable source directory.
Rework the faked blob support to put the faked binary in to the output
directory and then stop the test from deleting the now non-existent
file.

Cc: Heiko Thiery <heiko.thiery@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
---
tools/binman/etype/blob.py | 4 +++-
tools/binman/ftest.py | 1 -
2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py
index 65ebb2ecf4d8..ca8023b1a0b2 100644
--- a/tools/binman/etype/blob.py
+++ b/tools/binman/etype/blob.py
@@ -39,11 +39,13 @@ class Entry_blob(Entry):

def ObtainContents(self):
if self.allow_fake and not pathlib.Path(self._filename).is_file():
+ self._filename = tools.GetOutputFilename(self._filename)
with open(self._filename, "wb") as out:
out.truncate(1024)
self.faked = True
+ else:
+ self._filename = self.GetDefaultFilename()

- self._filename = self.GetDefaultFilename()
self._pathname = tools.GetInputFilename(self._filename,
self.external and self.section.GetAllowMissing())
# Allow the file to be missing
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index a9b7880f362f..d03ce6f05f8d 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -4675,7 +4675,6 @@ class TestFunctional(unittest.TestCase):
err = stderr.getvalue()
self.assertRegex(err,
"Image '.*' has faked external blobs and is non-functional: .*")
- os.remove('binman_faking_test_blob')

def testVersion(self):
"""Test we can get the binman version"""
--
2.25.1