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 6D88BC433FE for ; Mon, 7 Nov 2022 23:29:45 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7AAAE8504E; Tue, 8 Nov 2022 00:29:13 +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="clDv9GxV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 57A998502D; Tue, 8 Nov 2022 00:29:06 +0100 (CET) Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) (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 986638502D for ; Tue, 8 Nov 2022 00:28:58 +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-xd2b.google.com with SMTP id s10so8361850ioa.5 for ; Mon, 07 Nov 2022 15:28:58 -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=EDQBng/6vDlO60lyXV6UD3ndoK/rqePfvkRJvDt62kY=; b=clDv9GxVF/shnceOdhMQF86eLO6UgmH/KANtFCBRLQK8vCVcG3r8x2OUFE4TJT2sV2 VRFVbT4Y7dpl73ClUq2qlRmSfJqajKioNih4h5rurRrRq+wD5GTEiNerYEXJOVJ6fDQY RfjDssIaXoQA12if1nhZFzpK18uyUkI0Ogeuo= 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=IHL2yxZ4JxlcCtqLqWs340CDR6iHMtDn2VHMOc/CMfe5FBYpLtsJ/cF2dxPOFtFo4E toeauGTM/gib3UxzAfahb1SaxCkUn/QAVJPm/hAspZlhF+I+VdVXEci2Hdlzlgsrqctf Mvcid2D+osvRVw5/V6jd5lmtTR2gUUcSrhvvfBeMortbQOWLywrDthXvDuzvg5KEHFsP 3uGef5NuI9fmgFJnKQ1SUHtWG/bYCyz9l1nwXic9faDTZQHopBtycwn5ZzYQTSScu5kA xrq2LRR3vO7xGwc4pTv5PDxoFy+YyYGgt99acwFV2Nn1oO+6jMmd7YMZ40zzfK+AOGGX Qk+w== X-Gm-Message-State: ANoB5pmrVdtF7RJVwmOe7zf9W/V17KMX/QZvmpYp9sk2otGoyANWGWvq 7nPO6Ws/S9NhVLJjCpqxH4N1Bm/Jas332Q== X-Google-Smtp-Source: AA0mqf6RadVLOOCdMjanc1cZAV0LEya2IHJ9P4aQUH2/JO+XUnXfGIIfPM0X8zf95UlKKtuKbk3WVA== X-Received: by 2002:a6b:6908:0:b0:6dd:2d6e:18f1 with SMTP id e8-20020a6b6908000000b006dd2d6e18f1mr321821ioc.92.1667863736971; Mon, 07 Nov 2022 15:28:56 -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 o126-20020a022284000000b00363f8e0ab41sm3217739jao.152.2022.11.07.15.28.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 15:28:56 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Rasmus Villemoes , Simon Glass , Alper Nebi Yasak Subject: [PATCH v4 03/11] binman: Use an exit code when blobs are missing Date: Mon, 7 Nov 2022 16:28:39 -0700 Message-Id: <20221107232847.753769-4-sjg@chromium.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221107232847.753769-1-sjg@chromium.org> References: <20221107232847.753769-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