From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: u-boot@lists.denx.de
Subject: [PATCH 2/5] binman: Show an error when a file is missing
Date: Fri, 4 Sep 2020 12:33:48 +0300 [thread overview]
Message-ID: <20200904093348.GH1891694@smile.fi.intel.com> (raw)
In-Reply-To: <20200904012856.1175506-3-sjg@chromium.org>
On Thu, Sep 03, 2020 at 07:28:53PM -0600, Simon Glass wrote:
> The recent support for missing external binaries does not show an error
> message when a file is genuinely missing (i.e. it is missing but not
> marked as 'external'). This means that when -m is passed to binman, it
> will never report a missing file.
>
> Fix this and add a test.
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
One note below.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> tools/binman/etype/blob.py | 7 ++++---
> tools/binman/ftest.py | 7 +++++++
> tools/binman/test/173_missing_blob.dts | 14 ++++++++++++++
> 3 files changed, 25 insertions(+), 3 deletions(-)
> create mode 100644 tools/binman/test/173_missing_blob.dts
>
> diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py
> index c5f97c85a38..66cf243976e 100644
> --- a/tools/binman/etype/blob.py
> +++ b/tools/binman/etype/blob.py
> @@ -37,13 +37,14 @@ class Entry_blob(Entry):
>
> def ObtainContents(self):
> self._filename = self.GetDefaultFilename()
> - self._pathname = tools.GetInputFilename(self._filename,
> - self.section.GetAllowMissing())
> + self._pathname = tools.GetInputFilename(
> + self._filename, self.external and self.section.GetAllowMissing())
I hope you know that 'and' has a bit different semantics in Python than in C for example.
And why to move first parameter to new line?
> # Allow the file to be missing
> - if self.external and not self._pathname:
> + if not self._pathname:
> self.SetContents(b'')
> self.missing = True
> return True
> +
> self.ReadBlobContents()
> return True
>
> diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
> index 95b17d0b749..91225459162 100644
> --- a/tools/binman/ftest.py
> +++ b/tools/binman/ftest.py
> @@ -3708,5 +3708,12 @@ class TestFunctional(unittest.TestCase):
> self.assertIn('Wibble test', err)
> self.assertIn('Another test', err)
>
> + def testMissingBlob(self):
> + """Test handling of a blob containing a missing file"""
> + with self.assertRaises(ValueError) as e:
> + self._DoTestFile('173_missing_blob.dts', allow_missing=True)
> + self.assertIn("Filename 'missing' not found in input path",
> + str(e.exception))
> +
> if __name__ == "__main__":
> unittest.main()
> diff --git a/tools/binman/test/173_missing_blob.dts b/tools/binman/test/173_missing_blob.dts
> new file mode 100644
> index 00000000000..ffb655a1cb4
> --- /dev/null
> +++ b/tools/binman/test/173_missing_blob.dts
> @@ -0,0 +1,14 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +
> +/dts-v1/;
> +
> +/ {
> + #address-cells = <1>;
> + #size-cells = <1>;
> +
> + binman {
> + blob {
> + filename = "missing";
> + };
> + };
> +};
> --
> 2.28.0.526.ge36021eeef-goog
>
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2020-09-04 9:33 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-04 1:28 [PATCH 0/5] edison: Support for writing an xFSTK image Simon Glass
2020-09-04 1:28 ` [PATCH 1/5] x86: Use multiple images Simon Glass
2020-09-04 9:30 ` Andy Shevchenko
2020-09-04 1:28 ` [PATCH 2/5] binman: Show an error when a file is missing Simon Glass
2020-09-04 9:33 ` Andy Shevchenko [this message]
2020-09-07 1:43 ` Simon Glass
2020-09-07 9:05 ` Andy Shevchenko
2020-09-07 13:57 ` Simon Glass
2020-09-04 1:28 ` [PATCH 3/5] binman: Support adding a U-Boot environment Simon Glass
2020-09-04 9:37 ` Andy Shevchenko
2020-09-04 1:28 ` [PATCH 4/5] x86: edison: Generate an image suitable for xFSTK Simon Glass
2020-09-04 9:39 ` Andy Shevchenko
2020-09-04 1:28 ` [PATCH 5/5] x86: edison: Add documentation for using am xFSTK image Simon Glass
2020-09-04 9:43 ` Andy Shevchenko
2020-09-04 9:46 ` [PATCH 0/5] edison: Support for writing an " Andy Shevchenko
2020-09-05 3:23 ` Simon Glass
2020-09-07 8:04 ` Andy Shevchenko
2020-09-07 13:57 ` Simon Glass
2020-09-07 14:12 ` Tom Rini
2020-09-07 14:15 ` Simon Glass
2020-09-07 15:10 ` Andy Shevchenko
2020-09-22 7:11 ` Bin Meng
2020-09-22 22:03 ` Simon Glass
2020-09-24 3:22 ` Bin Meng
2020-09-24 3:27 ` Bin Meng
2020-09-25 1:00 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200904093348.GH1891694@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox