Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B6AF6C433FE for ; Sat, 5 Nov 2022 23:06:03 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AAD218523E; Sun, 6 Nov 2022 00:05:21 +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="NUntU5zH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B1B41851F1; Sun, 6 Nov 2022 00:05:03 +0100 (CET) Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (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 9C1EB85205 for ; Sun, 6 Nov 2022 00:04:56 +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-il1-x12c.google.com with SMTP id x16so4275605ilm.5 for ; Sat, 05 Nov 2022 16:04:56 -0700 (PDT) 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=EDQBng/6vDlO60lyXV6UD3ndoK/rqePfvkRJvDt62kY=; b=NUntU5zHgynLqZzuEN0hHwq9/PyxLHgkRX9STfuXKwkH+uv38lXZeuiMfa4Y4fUc+s yk26xQwxWWLB+cMOZmd53CXzawwq8Dm2Igkg1UmGuqFdbCbU/BnpoHS2LUSLifbFbfFX J2o6iJTcfWFOx5xLlz9Zph49v0O5CJL4140Uw= 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=EDQBng/6vDlO60lyXV6UD3ndoK/rqePfvkRJvDt62kY=; b=jTQnoYD0CFYcqeiQcSdyCKoG54U9QLNjopZC6+rDIZaAy1S/oTAjiYCxpSDxJmoV2I 3sCeYBZCSjDmtqeiESHqLDRnGTjohnQeuNVJra0xC8PKNosIlQd+KJW62uQN1uyVH302 XnOxciAm72wDeCSUgixmB5SVhKQy4nR11/O4Kln9I2pYKkkt8IO3aU6J9e+8amb/w1qD Ne3GuFnFLsxzOgAGVth7s+M9IH6Y6AmfiKDqdPNuK2mjzGFz4h5O2cHKTylu3xmjb1PL 8Z7YT7UzqcNifVVeTTvtAEA22XGHhZ2YoGLjVFoKYJTAcd2sTBC9a/qTNk/9P71jnRXA R6wQ== X-Gm-Message-State: ACrzQf2GYpews4PVmmOhVs4StL6uqZ4zN5DJb6QrzqpmDNpd+O8bt8RC G2/Dl/sAHuJfArAlV0PXVXFc163dUgus+Q== X-Google-Smtp-Source: AMsMyM7WQsUnYUNr3QUvpEnsaCizesHEB7xt1JErBZshtK781GwMKsFPdYuS5tUWdpq2WUe96Qq4Kg== X-Received: by 2002:a92:6e04:0:b0:300:47e:68f1 with SMTP id j4-20020a926e04000000b00300047e68f1mr24851015ilc.107.1667689495025; Sat, 05 Nov 2022 16:04:55 -0700 (PDT) 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 a10-20020a92ce4a000000b0030014a5556bsm1271957ilr.69.2022.11.05.16.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 16:04:54 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Rasmus Villemoes , Tom Rini , Simon Glass , Alper Nebi Yasak Subject: [PATCH v3 3/9] binman: Use an exit code when blobs are missing Date: Sat, 5 Nov 2022 17:04:33 -0600 Message-Id: <20221105230439.549139-4-sjg@chromium.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221105230439.549139-1-sjg@chromium.org> References: <20221105230439.549139-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 blobs. This is confusing this 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. Add documentation about exit codes while we are here. Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/binman.rst | 21 +++++++++++++++++++++ tools/binman/cmdline.py | 3 +++ tools/binman/control.py | 7 ++++++- tools/binman/ftest.py | 20 ++++++++++++++++++-- 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst index fda16f1992d..30ced31e43b 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,23 @@ 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 in an exit status of + 1. + + Error messages -------------- diff --git a/tools/binman/cmdline.py b/tools/binman/cmdline.py index 1d1ca43993d..144c0c916a2 100644 --- a/tools/binman/cmdline.py +++ b/tools/binman/cmdline.py @@ -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-blobs', action='store_true', default=False, + help='Return success even if there are missing blobs') 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..8b94db60113 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -742,7 +742,12 @@ def Binman(args): elf.UpdateFile(*elf_params, data) if invalid: - tout.warning("\nSome images are invalid") + msg = '\nSome images are invalid' + if args.ignore_missing_blobs: + 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..fc38a2efccd 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_blobs=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_blobs: + args.append('-W') if allow_fake_blobs: args.append('--fake-ext-blobs') if force_missing_bintools: @@ -3725,9 +3727,23 @@ 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_blobs=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