From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Tom Rini <trini@konsulko.com>,
Rasmus Villemoes <rasmus.villemoes@prevas.dk>,
Simon Glass <sjg@chromium.org>,
Alper Nebi Yasak <alpernebiyasak@gmail.com>
Subject: [PATCH v5 04/16] binman: Use an exit code when blobs are missing
Date: Wed, 9 Nov 2022 19:14:42 -0700 [thread overview]
Message-ID: <20221110021455.1004335-5-sjg@chromium.org> (raw)
In-Reply-To: <20221110021455.1004335-1-sjg@chromium.org>
At present binman returns success when told to handle missing/faked blobs
or missing bintools. This is confusing since in fact the resulting image
cannot work.
Use exit code 103 to signal this problem, with a -W option to convert
it to a warning.
Rename the flag to --ignore-missing since it controls bintools also.
Add documentation about exit codes while we are here.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v5:
- Add a note that -W requires -M
- Update ftest use of -W to avoid confusion
- Update exit-status docs to mention -W also
- Rename flag to --ignore-missing
- Update commit message
- Correct help for -M flag
tools/binman/binman.rst | 22 ++++++++++++++++++++++
tools/binman/cmdline.py | 5 ++++-
tools/binman/control.py | 9 ++++++++-
tools/binman/ftest.py | 19 +++++++++++++++++--
4 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst
index fda16f1992d..16508d6ba58 100644
--- a/tools/binman/binman.rst
+++ b/tools/binman/binman.rst
@@ -1461,6 +1461,10 @@ space-separated list of directories to search for binary blobs::
odroid-c4/build/board/hardkernel/odroidc4/firmware \
odroid-c4/build/scp_task" binman ...
+Note that binman fails with exit code 103 when there are missing blobs. If you
+wish binman to continue anyway, you can pass `-W` to binman.
+
+
Code coverage
-------------
@@ -1472,6 +1476,24 @@ To enable Python test coverage on Debian-type distributions (e.g. Ubuntu)::
$ sudo apt-get install python-coverage python3-coverage python-pytest
+Exit status
+-----------
+
+Binman produces the following exit codes:
+
+0
+ Success
+
+1
+ Any sort of failure - see output for more details
+
+103
+ There are missing external blobs or bintools. This is only returned if
+ -M is passed to binman, otherwise missing blobs return an exit status of 1.
+ Note, if -W is passed as well as -M, then this is converted into a warning
+ and will return an exit status of 0 instead.
+
+
Error messages
--------------
diff --git a/tools/binman/cmdline.py b/tools/binman/cmdline.py
index 1d1ca43993d..986d6f1a315 100644
--- a/tools/binman/cmdline.py
+++ b/tools/binman/cmdline.py
@@ -114,7 +114,7 @@ controlled by a description in the board device tree.'''
build_parser.add_argument('-m', '--map', action='store_true',
default=False, help='Output a map file for each image')
build_parser.add_argument('-M', '--allow-missing', action='store_true',
- default=False, help='Allow external blobs to be missing')
+ default=False, help='Allow external blobs and bintools to be missing')
build_parser.add_argument('-n', '--no-expanded', action='store_true',
help="Don't use 'expanded' versions of entries where available; "
"normally 'u-boot' becomes 'u-boot-expanded', for example")
@@ -128,6 +128,9 @@ controlled by a description in the board device tree.'''
default=False, help='Update the binman node with offset/size info')
build_parser.add_argument('--update-fdt-in-elf', type=str,
help='Update an ELF file with the output dtb: infile,outfile,begin_sym,end_sym')
+ build_parser.add_argument(
+ '-W', '--ignore-missing', action='store_true', default=False,
+ help='Return success even if there are missing blobs/bintools (requires -M)')
subparsers.add_parser(
'bintool-docs', help='Write out bintool documentation (see bintool.rst)')
diff --git a/tools/binman/control.py b/tools/binman/control.py
index bfe63a15204..964c6984f9b 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -741,8 +741,15 @@ def Binman(args):
data = state.GetFdtForEtype('u-boot-dtb').GetContents()
elf.UpdateFile(*elf_params, data)
+ # This can only be True if -M is provided, since otherwise binman
+ # would have raised an error already
if invalid:
- tout.warning("\nSome images are invalid")
+ msg = '\nSome images are invalid'
+ if args.ignore_missing:
+ tout.warning(msg)
+ else:
+ tout.error(msg)
+ return 103
# Use this to debug the time take to pack the image
#state.TimingShow()
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index e849d96587c..62ee86b9b75 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -340,7 +340,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=''):
+ force_missing_bintools='', ignore_missing=False):
"""Run binman with a given test file
Args:
@@ -403,6 +403,8 @@ class TestFunctional(unittest.TestCase):
args.append('-a%s=%s' % (arg, value))
if allow_missing:
args.append('-M')
+ if ignore_missing:
+ args.append('-W')
if allow_fake_blobs:
args.append('--fake-ext-blobs')
if force_missing_bintools:
@@ -3725,9 +3727,22 @@ class TestFunctional(unittest.TestCase):
def testExtblobMissingOk(self):
"""Test an image with an missing external blob that is allowed"""
with test_util.capture_sys_output() as (stdout, stderr):
- self._DoTestFile('158_blob_ext_missing.dts', allow_missing=True)
+ ret = self._DoTestFile('158_blob_ext_missing.dts',
+ allow_missing=True)
+ self.assertEqual(103, ret)
err = stderr.getvalue()
self.assertRegex(err, "Image 'main-section'.*missing.*: blob-ext")
+ self.assertIn('Some images are invalid', err)
+
+ def testExtblobMissingOkFlag(self):
+ """Test an image with an missing external blob allowed with -W"""
+ with test_util.capture_sys_output() as (stdout, stderr):
+ ret = self._DoTestFile('158_blob_ext_missing.dts',
+ allow_missing=True, ignore_missing=True)
+ self.assertEqual(0, ret)
+ err = stderr.getvalue()
+ self.assertRegex(err, "Image 'main-section'.*missing.*: blob-ext")
+ self.assertIn('Some images are invalid', err)
def testExtblobMissingOkSect(self):
"""Test an image with an missing external blob that is allowed"""
--
2.38.1.431.g37b22c650d-goog
next prev parent reply other threads:[~2022-11-10 2:16 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-10 2:14 [PATCH v5 00/16] buildman: Correct various issues with missing blobs Simon Glass
2022-11-10 2:14 ` [PATCH v5 01/16] image: Correct strncpy() warning with image_set_name() Simon Glass
2022-11-23 2:12 ` Simon Glass
2022-11-10 2:14 ` [PATCH v5 02/16] Makefile: Correct the binman rule Simon Glass
2022-11-10 8:01 ` Pali Rohár
2022-11-10 20:40 ` Simon Glass
2022-11-23 2:11 ` Simon Glass
2022-11-10 2:14 ` [PATCH v5 03/16] doc: Correct the path to the Makefile documentation Simon Glass
2022-11-23 2:11 ` Simon Glass
2022-11-10 2:14 ` Simon Glass [this message]
2022-11-23 2:11 ` [PATCH v5 04/16] binman: Use an exit code when blobs are missing Simon Glass
2022-11-10 2:14 ` [PATCH v5 05/16] buildman: Convert documentation to rST Simon Glass
2022-11-23 2:11 ` Simon Glass
2022-11-10 2:14 ` [PATCH v5 06/16] buildman: Drop mention of MAKEALL Simon Glass
2022-11-23 2:11 ` Simon Glass
2022-11-10 2:14 ` [PATCH v5 07/16] buildman: Update the arc toolchain Simon Glass
2022-11-23 2:11 ` Simon Glass
2022-11-10 2:14 ` [PATCH v5 08/16] buildman: Update the default settings file Simon Glass
2022-11-23 2:11 ` Simon Glass
2022-11-10 2:14 ` [PATCH v5 09/16] buildman: Drop mention of old architectures Simon Glass
2022-11-23 2:11 ` Simon Glass
2022-11-10 2:14 ` [PATCH v5 10/16] buildman: Detect binman reporting missing blobs Simon Glass
2022-11-23 2:11 ` Simon Glass
2022-12-05 23:13 ` Peter Robinson
2022-12-05 23:23 ` Tom Rini
2022-12-05 23:29 ` Peter Robinson
2022-12-05 23:34 ` Tom Rini
2022-12-05 23:43 ` Peter Robinson
2022-12-05 23:46 ` Tom Rini
2022-12-05 23:49 ` Peter Robinson
2022-12-05 23:55 ` Simon Glass
2022-12-05 23:56 ` Tom Rini
2022-12-05 23:57 ` Simon Glass
2022-11-10 2:14 ` [PATCH v5 11/16] binman: Add a separate section about environment variables Simon Glass
2022-11-23 2:11 ` Simon Glass
2022-11-10 2:14 ` [PATCH v5 12/16] global: Do not default to faking missing binaries for buildman Simon Glass
2022-11-23 2:11 ` Simon Glass
2022-11-10 2:14 ` [PATCH v5 13/16] buildman: Ensure config_fname is inited Simon Glass
2022-11-23 2:11 ` Simon Glass
2022-11-10 2:14 ` [PATCH v5 14/16] buildman: Reinstate removal of temp output dir in tests Simon Glass
2022-11-23 2:11 ` Simon Glass
2022-11-10 2:14 ` [PATCH v5 15/16] buildman: Add --allow-missing flag to allow missing blobs Simon Glass
2022-11-23 2:11 ` Simon Glass
2022-11-10 2:14 ` [PATCH v5 16/16] binman: Add documentation for the command line args Simon Glass
2022-11-23 2:11 ` 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=20221110021455.1004335-5-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=alpernebiyasak@gmail.com \
--cc=rasmus.villemoes@prevas.dk \
--cc=trini@konsulko.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.