From patchwork Thu Aug 11 14:04:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1665582 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=SL9I7Ydq; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M3T9Z0Nnvz9sG0 for ; Fri, 12 Aug 2022 00:05:53 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 03B2B84955; Thu, 11 Aug 2022 16:04:43 +0200 (CEST) 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="SL9I7Ydq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 443E784953; Thu, 11 Aug 2022 16:04:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 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 DB86684957 for ; Thu, 11 Aug 2022 16:04:26 +0200 (CEST) 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 g14so9980170ile.11 for ; Thu, 11 Aug 2022 07:04:26 -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; bh=mx+v7pr5DGQLN+QZFFEE+cI4Ny/Xx2m/vhod+YHQhcY=; b=SL9I7YdqbMhfHzW4dLi3FL7IEnLxm/B+0d3sihOrZR9jwfFgCoZiaFUe/USuEoRJef DIFlLQwj6bexSdugW5YTyzp+u8zXihekDFLH1FhH+uwtNNfyscQBBmPRmpR4KoJlAjsF 2GfinWlNyE6N26ybxy/8lKz4dqp/ovqpNLd/4= 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; bh=mx+v7pr5DGQLN+QZFFEE+cI4Ny/Xx2m/vhod+YHQhcY=; b=u1psu4oixwCfm2h4MdCKvEczXJU8koPHoKKXowMxSp/jmVvaVR089pLieLG5mhhvCX 6/0SFP8PBedxojlVcKdqxX8rhl8kyjINYFH+UN/ECEMAec25+WuvMtIxjtAH/vGMzunc Z2PQcNRC5ulnz0nAgk42XoDkhOB6HnypHqklbRfb3d8W/zqhT+gHTLCq0HPEkoVTQmqc S40FNJ+7y5c4ukeU+jhNTqQOzUKpRTjbvMdDosqkqku2ZXlpHdSMk+SuR22JL3bQdoDz SKIVsoLrWHEuSzyqKn5oMJ2rJi9NZGpSPssu2Yvi7E5gkytYb+f9Qyjo9uXXUsKAYj0t e0NA== X-Gm-Message-State: ACgBeo28jHS20siRPzgODZZa2VpjXYV76cFItasueQJkAYD/sDjSGtwy fyuZzGZSrz7Z65BdSc/yInxgRkehJeGbrg== X-Google-Smtp-Source: AA6agR4hzgFnKzjbq0FzWNhsfJPv1110frdftuvZbt2cK0BrQpaUbDlLRxmtch0T5A4oDTnOpnnuww== X-Received: by 2002:a92:2a0a:0:b0:2d9:2571:f57e with SMTP id r10-20020a922a0a000000b002d92571f57emr14807936ile.154.1660226665265; Thu, 11 Aug 2022 07:04:25 -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 o9-20020a056e0214c900b002de990656f5sm3284667ilk.32.2022.08.11.07.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 07:04:24 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Alper Nebi Yasak , Marek Vasut , Philippe Reynes , Simon Glass Subject: [PATCH 05/11] binman: Add a function to check for missing properties Date: Thu, 11 Aug 2022 08:04:06 -0600 Message-Id: <20220811140412.1671844-6-sjg@chromium.org> X-Mailer: git-send-email 2.37.1.559.g78731f0fdb-goog In-Reply-To: <20220811140412.1671844-1-sjg@chromium.org> References: <20220811140412.1671844-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 Add a new function to Entry to check for missing properties, since this is likely to be come a common requirement. Signed-off-by: Simon Glass --- tools/binman/entry.py | 16 ++++++++++++++++ tools/binman/etype/fill.py | 3 +-- tools/binman/ftest.py | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 41f0eb58ae0..3be074ccd66 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -1179,3 +1179,19 @@ features to produce new behaviours. if not os.path.exists(cls.fake_dir): os.mkdir(cls.fake_dir) tout.notice(f"Fake-blob dir is '{cls.fake_dir}'") + + def ensure_props(self, prop_list): + """Raise an exception if properties are missing + + Args: + prop_list (list of str): List of properties to check for + + Raises: + ValueError: Any property is missing + """ + not_present = [] + for prop in prop_list: + if not prop in self._node.props: + not_present.append(prop) + if not_present: + self.Raise(f"'{self.etype}' entry is missing properties: {' '.join(not_present)}") diff --git a/tools/binman/etype/fill.py b/tools/binman/etype/fill.py index cd382799199..0b068ba3268 100644 --- a/tools/binman/etype/fill.py +++ b/tools/binman/etype/fill.py @@ -26,8 +26,7 @@ class Entry_fill(Entry): def ReadNode(self): super().ReadNode() - if self.size is None: - self.Raise("'fill' entry must have a size property") + self.ensure_props(['size']) self.fill_value = fdt_util.GetByte(self._node, 'fill-byte', 0) def ObtainContents(self): diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index c8bab5c9416..4f696c68600 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -1693,7 +1693,7 @@ class TestFunctional(unittest.TestCase): """Test for an fill entry type with no size""" with self.assertRaises(ValueError) as e: self._DoReadFile('070_fill_no_size.dts') - self.assertIn("'fill' entry must have a size property", + self.assertIn("'fill' entry is missing properties: size", str(e.exception)) def _HandleGbbCommand(self, pipe_list):