From patchwork Thu Nov 10 02:14:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1701961 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Q+ViwDa5; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N757Y1Tqsz23lT for ; Thu, 10 Nov 2022 13:16:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ED896850FB; Thu, 10 Nov 2022 03:16:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Q+ViwDa5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 59AAA850E6; Thu, 10 Nov 2022 03:16:13 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 72702850EB for ; Thu, 10 Nov 2022 03:16:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd31.google.com with SMTP id 63so285619iov.8 for ; Wed, 09 Nov 2022 18:16:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9zRvJhmP5gt71y30A1MF2Lwu8uQqFtZAzEs15Es3llM=; b=Q+ViwDa5BCLwpi/uYTtNom/t78BU/w/gQDL92qqtSJBOpiUtFSOO7ld5xkyyr1LS02 bgxp/fY1vmlWobfKUKaibEiGpFISNlhDGiqH3xppAmX+kl6ilAIRCwfyjetMoKLm9r82 SmOGek/uspNH6/n8Hv9aj+XZP2PgMaWA983qA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9zRvJhmP5gt71y30A1MF2Lwu8uQqFtZAzEs15Es3llM=; b=4K6Rg8/QPGlpXQAlzr6SYEN7c58H5G5cgnwx70CjxrANqOmcfGIDAg9IbNWBjA5fF7 3l9mAFprxcMepPORaBKV1l1pRzeR9iaFqerHX7SGpXrv/YsBGIcOX57l9Sn1rQH6npQh EBmF8rd9F4d31eqP7kqL2KsX2DP3X+cWtDAJu7ocOD0KN5VDoak/wPxCQAxN6QJrWNCK lnKTmG0gLUbvibYo13m8rQw0ZHcgfskkfkMM9xTyhLOScz3cc4q3lLmtdpavPO0QiIz6 kn894Rs0SrCzvcUVCXvODg/JME5ywmE5OgCrPS2gh9k97sqneuEaXvnPSPGAp00KGm/o zO8w== X-Gm-Message-State: ACrzQf2P6im/nPwnI66P5OBXMhzmOinCjuJ0bArtjE+F3TGxSy16krcW VHZeHpEweFCIyohzL2JM6khHN1Pku0xOKA== X-Google-Smtp-Source: AMsMyM4yd5Z5f9XUjDULBiGPQHObGlYMw09P2t+b7z12CQhF18hBCdc0tARUQt34J/d6pWTb+37Quw== X-Received: by 2002:a02:6f54:0:b0:375:76da:1c95 with SMTP id b20-20020a026f54000000b0037576da1c95mr23188369jae.42.1668046564801; Wed, 09 Nov 2022 18:16:04 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id z23-20020a056638215700b003636b73cf29sm5352785jaj.8.2022.11.09.18.16.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 18:16:04 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Rasmus Villemoes , Simon Glass , Alper Nebi Yasak Subject: [PATCH v5 04/16] binman: Use an exit code when blobs are missing Date: Wed, 9 Nov 2022 19:14:42 -0700 Message-Id: <20221110021455.1004335-5-sjg@chromium.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221110021455.1004335-1-sjg@chromium.org> References: <20221110021455.1004335-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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 Signed-off-by: Simon Glass --- 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"""