From mboxrd@z Thu Jan 1 00:00:00 1970 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 9A00BC433EF for ; Wed, 23 Feb 2022 23:04:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 55A1083D66; Thu, 24 Feb 2022 00:03:22 +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="U6DWlSMQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AFFE883CE5; Thu, 24 Feb 2022 00:01:22 +0100 (CET) Received: from mail-oo1-xc2d.google.com (mail-oo1-xc2d.google.com [IPv6:2607:f8b0:4864:20::c2d]) (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 12A2483D10 for ; Thu, 24 Feb 2022 00:01:11 +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-oo1-xc2d.google.com with SMTP id y15-20020a4a650f000000b0031c19e9fe9dso771112ooc.12 for ; Wed, 23 Feb 2022 15:01:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lUd9ut0FEeiqHRLrKEOvIcjTTmhFbUEnIfnPlz9MsN0=; b=U6DWlSMQJKcs9NqKN4AKmn8+w2rE68iY7H/5+hf3WxulSnh0rlfa6ohv924IXkI/g6 sWt10QKmHPKY0HEd11LWGb1owm/+6FW9nIzOIzhj3nR8ACaVkNE3ogIZRbxfiwb1j8If nvuAUj6HmbLd4AUq6eOQ7VMxiG89GLqcCxaeQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lUd9ut0FEeiqHRLrKEOvIcjTTmhFbUEnIfnPlz9MsN0=; b=HWbH3fRlR54N8R5FkcWUyRUM2yVz16+jEyjGguPkgjMi853zIRrbcCVHjyBiUl0LT4 3UpSpG7Pq7prTwWYd0eMyMAbJNhBI2p4SVzBtByvxgGSPdNfZmzPCDHL+CnFvf0bn2/P QM+W4399YAH3tySNTffqt4I8RoBC6Tcuw+/1TN6Ra20K/5T1scPB9Yp8OHbY6pKKFKOw 87xF/FPIMspNT6Cab2ALDXQwxzEy8Yoq3mURrh/Nl6Y1ktDzJran74P7j9vWfubnG69g XAwiXpX5hrCIK7XVVHjn8d7akm7+oDxDEbjKisjL/H/h1ob+CKSffmziCeIervWyYGEy LW3w== X-Gm-Message-State: AOAM5301e0zZZWmmDpILNRwtKv5KHxTo6Sh1SLKLM3liGk6CsV05Yyj0 NDwD2t4cCQWEVRkAuQhIwlOfqQYnpghmJA== X-Google-Smtp-Source: ABdhPJxN4h03n8tlY9KOdlv8zF6PE8qq7NJqPyPWeU2SkF8v2T/+vorcKLI7O6/3J7Zo7pzvjDNysA== X-Received: by 2002:a05:6870:832a:b0:cc:f848:1651 with SMTP id p42-20020a056870832a00b000ccf8481651mr865223oae.347.1645657269619; Wed, 23 Feb 2022 15:01:09 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id o2sm427507otl.9.2022.02.23.15.01.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 15:01:09 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Ivan Mikhaylov , Tom Rini , Philippe Reynes , Roger Quadros , Alper Nebi Yasak , huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich Subject: [PATCH v2 17/25] binman: Add a consistent way to report errors with fit Date: Wed, 23 Feb 2022 16:00:32 -0700 Message-Id: <20220223230040.159317-18-sjg@chromium.org> X-Mailer: git-send-email 2.35.1.574.g5d30c73bfb-goog In-Reply-To: <20220223230040.159317-1-sjg@chromium.org> References: <20220223230040.159317-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.5 at phobos.denx.de X-Virus-Status: Clean Add a new function to handling reporting errors within a particular subnode of the FIT description. This can be used to make the format of these errors consistent. Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/etype/fit.py | 33 +++++++++++++++++++++++++-------- tools/binman/ftest.py | 2 +- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index 70966028e8..50a9179f9f 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -186,11 +186,11 @@ class Entry_fit(Entry_section): def ReadNode(self): super().ReadNode() - def _get_operation(self, subnode): + def _get_operation(self, base_node, node): """Get the operation referenced by a subnode Args: - subnode (Node): Subnode (of the FIT) to check + node (Node): Subnode (of the FIT) to check Returns: int: Operation to perform @@ -198,12 +198,13 @@ class Entry_fit(Entry_section): Raises: ValueError: Invalid operation name """ - oper_name = subnode.props.get('fit,operation') + oper_name = node.props.get('fit,operation') if not oper_name: return OP_GEN_FDT_NODES oper = OPERATIONS.get(oper_name.value) - if not oper: - self.Raise(f"Unknown operation '{oper_name.value}'") + if oper is None: + self._raise(base_node, node, + f"Unknown operation '{oper_name.value}'") return oper def ReadEntries(self): @@ -273,6 +274,20 @@ class Entry_fit(Entry_section): return tools.read_file(output_fname) + def _raise(self, base_node, node, msg): + """Raise an error with a paticular FIT subnode + + Args: + base_node (Node): Base Node of the FIT (with 'description' property) + node (Node): FIT subnode containing the error + msg (str): Message to report + + Raises: + ValueError, as requested + """ + rel_path = node.path[len(base_node.path) + 1:] + self.Raise(f"subnode '{rel_path}': {msg}") + def _build_input(self): """Finish the FIT by adding the 'data' properties to it @@ -356,7 +371,7 @@ class Entry_fit(Entry_section): else: self.Raise("Generator node requires 'fit,fdt-list' property") - def _gen_node(subnode, depth, in_images): + def _gen_node(base_node, subnode, depth, in_images): """Generate nodes from a template This creates one node for each member of self._fdts using the @@ -366,12 +381,14 @@ class Entry_fit(Entry_section): first. Args: + base_node (Node): Base Node of the FIT (with 'description' + property) subnode (Node): Generator node to process depth (int): Current node depth (0 is the base 'fit' node) in_images (bool): True if this is inside the 'images' node, so that 'data' properties should be generated """ - oper = self._get_operation(subnode) + oper = self._get_operation(base_node, subnode) if oper == OP_GEN_FDT_NODES: _gen_fdt_nodes(subnode, depth, in_images) @@ -412,7 +429,7 @@ class Entry_fit(Entry_section): elif self.GetImage().generate and subnode.name.startswith('@'): subnode_path = f'{rel_path}/{subnode.name}' entry = self._entries.get(subnode_path) - _gen_node(subnode, depth, in_images) + _gen_node(base_node, subnode, depth, in_images) if entry: del self._entries[subnode_path] else: diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 106027d245..16463518aa 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -5319,7 +5319,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap """Check handling of an FDT map when the section cannot be found""" with self.assertRaises(ValueError) as exc: self._DoReadFileDtb('224_fit_bad_oper.dts') - self.assertIn("Node '/binman/fit': Unknown operation 'unknown'", + self.assertIn("Node '/binman/fit': subnode 'images/@fdt-SEQ': Unknown operation 'unknown'", str(exc.exception)) def test_uses_expand_size(self): -- 2.35.1.574.g5d30c73bfb-goog