From patchwork Mon Oct 26 23:40:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1388212 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: 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=iBK9uzk7; 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CKs0H5pX9z9sTf for ; Tue, 27 Oct 2020 10:45:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2A83B82529; Tue, 27 Oct 2020 00:41:16 +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="iBK9uzk7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C2E91824E7; Tue, 27 Oct 2020 00:40:55 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) (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 26301824AE for ; Tue, 27 Oct 2020 00:40:47 +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-x130.google.com with SMTP id p10so10948906ile.3 for ; Mon, 26 Oct 2020 16:40:47 -0700 (PDT) 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=Z2oRU+GwvEAu9aQNZvqbsrcZqMwlmgnndD+79rairl0=; b=iBK9uzk7/aQwMeJrempleWsIDnS07x4aBn5F/mFZrFU3yRnBzyQHtJmRdcMhwsiSj6 gExww4Bq+xuMvVCbvqGBzZVYMttGO0AT8Y7eSHIOcYyyV7kCjbRYgMyYD+wc3QTyH2wf h2tlqR97oaIkiDeaFk3gL4DKPbKEL6xNRv7ZY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z2oRU+GwvEAu9aQNZvqbsrcZqMwlmgnndD+79rairl0=; b=LoGfhM/ovwB8FJKoGVS001yL7VQncwN5UGJKONyxB9IhLb/eb1Pw1rtNrD7V6ErLRb 0+44lQnjzAgIROv/KYoFxzkc2dFyO4/uxujjTe0DTDYW9hWw268aLlL4qFZciYQx2pkr jXG/u3SAY9ScEuC99xAI1Cnyf5JdK5JZWghfWWWlpWjMuG1XG+YtTGSxyTfCdRFIe4Ck jH696qUvkNdFr1fXzwDxE7fwFaKHUEZeJc2wnRNi38xo5xoURdjlB5+wJBM3sGkQvTd7 DN5jw8S0FEiqT2Hw8OR7XfbuQn85CAxYXMlcBii+Xft41Iu4cPZvIFqafNrpQU6ZdU9U Ydyg== X-Gm-Message-State: AOAM532UhQxoJ08sSbTU8ZmPZo9mFcY0WVJpLDFlhjcicOJAwfwMQcvm miCmCdbvBSobs5n1//HCyjDWlp6nlvU3IALI X-Google-Smtp-Source: ABdhPJxb3CWh8VWIkYlZ3ACl8cQL2ADLHrvi3j8Vm6+7ChpRLtaRPtdNTMvk9q5Bi2BG/mhFPVJUBw== X-Received: by 2002:a92:96c3:: with SMTP id g186mr12201668ilh.10.1603755645234; Mon, 26 Oct 2020 16:40:45 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id e17sm7066857ile.60.2020.10.26.16.40.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 16:40:44 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Alper Nebi Yasak , Simon Glass Subject: [PATCH v2 18/28] binman: Set section contents in GetData() Date: Mon, 26 Oct 2020 17:40:16 -0600 Message-Id: <20201026234026.1903778-18-sjg@chromium.org> X-Mailer: git-send-email 2.29.0.rc2.309.g374f81d7ae-goog In-Reply-To: <20201026234026.1903778-1-sjg@chromium.org> References: <20201026234026.1903778-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean Section contents is not set up when ObtainContents() is called, since packing often changes the layout of the contents. Ensure that the contents are correctly recorded by making this function regenerate the section. It is normally only called by the parent section (when packing) or by the top-level image code, when writing out the image. So the performance impact is fairly small. Now that sections have their contents in their 'data' property, update testSkipAtStartSectionPad() to check it. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v2: - Update testSkipAtStartSectionPad() to check section.data tools/binman/entry.py | 6 ++++++ tools/binman/etype/section.py | 14 +++++++++++++- tools/binman/ftest.py | 4 +++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/tools/binman/entry.py b/tools/binman/entry.py index d701eaff8fd..01a5fde84ed 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -437,6 +437,12 @@ class Entry(object): return self._node.path def GetData(self): + """Get the contents of an entry + + Returns: + bytes content of the entry, excluding any padding. If the entry is + compressed, the compressed data is returned + """ self.Detail('GetData: size %s' % ToHexSize(self.data)) return self.data diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index c423a22c80f..6e6f6749727 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -226,7 +226,19 @@ class Entry_section(Entry): return section.GetPaddedDataForEntry(self) def GetData(self): - return self._BuildSectionData() + """Get the contents of an entry + + This builds the contents of the section, stores this as the contents of + the section and returns it + + Returns: + bytes content of the section, made up for all all of its subentries. + This excludes any padding. If the section is compressed, the + compressed data is returned + """ + data = self._BuildSectionData() + self.SetContents(data) + return data def GetOffsets(self): """Handle entries that want to set the offset/size of other entries diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 4c94bea6f00..6f47deac3b6 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -1822,6 +1822,8 @@ class TestFunctional(unittest.TestCase): orig = self._decompress(entry.data) self.assertEqual(orig, entry.uncomp_data) + self.assertEqual(image.data, entry.data) + expected = { 'blob:uncomp-size': len(COMPRESS_DATA), 'blob:size': len(data), @@ -3890,7 +3892,7 @@ class TestFunctional(unittest.TestCase): section = entries['section'] self.assertEqual(0, section.offset) self.assertEqual(len(all), section.size) - self.assertIsNone(section.data) + self.assertEqual(U_BOOT_DATA, section.data) self.assertEqual(all, section.GetPaddedData()) entry = section.GetEntries()['u-boot']