From patchwork Mon Oct 26 23:40:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1388221 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=WRBt7+FO; 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 4CKs306nVDz9sV1 for ; Tue, 27 Oct 2020 10:47:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5882782550; Tue, 27 Oct 2020 00:42:04 +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="WRBt7+FO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 278198250D; Tue, 27 Oct 2020 00:41:10 +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-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) (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 8F53B824D7 for ; Tue, 27 Oct 2020 00:40:50 +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-xd33.google.com with SMTP id k6so13020258ior.2 for ; Mon, 26 Oct 2020 16:40:50 -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=EBF3BTgW93MXxjgVz1zPt/NmCtSEMDH4uQPXHxZBFfY=; b=WRBt7+FOnqu8jV8DOhLlmFfGegVNM0HFFzScyz91NiiTcK1NscWM782zIfETheMzvF m2uRxzDKZEGKhKmFaoh8Rqc7SkgI0ATQWLqRp+MeWO96hL1ln4xRt9ICBYk5mHk6spOJ FRx3rlP1oUz5D47fYGkuzB4mMRrcJFzGPf/nE= 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=EBF3BTgW93MXxjgVz1zPt/NmCtSEMDH4uQPXHxZBFfY=; b=uFH3weYVj64I9pBBNUsqoSG+geLCq+/DYwdzt3+ckfBZCXLjnlp0c6O8dbPOjwMbrf o/7hnnGaFZ/Ji2Vj0asav7Hx1d33yzH+YIm5JlSceyCRel9GJOXP3fXtDzTmte9m/VD5 VMTgNidSDBPSDlWn3PEaNtCgtJ4uJLX+tV2RJWW3yu1vkUWFrvq79PiqmKL5ewKhvNPD aNqoJwyaclNwZ+XZb7Iyo4W7ErOGHS+Tzy+1hMxnx9riV6ODD8aVGDwrvHT33TRWS627 sqI5sBYVa9ZrUKtUk4ovTzfdbznNEGeXHuNUPW1OOJH3IB7H553Dd5t3ZYgyMTJn9QB5 nrAA== X-Gm-Message-State: AOAM53070r1e+9J4m2finfXDeyHhrc4vWj1XODRGLelta9vUfUbAIFbM 9h8mUeEqZW/Q0Lhb0Ku2dI5vmbiZJ/RfEhGV X-Google-Smtp-Source: ABdhPJzww6D6sa31ckomxu0I85EAaPvsX5bS+CoL4RLoyckQFO09nZouC2j6K57rNiQ4NXqyT8cHkw== X-Received: by 2002:a6b:1646:: with SMTP id 67mr12337934iow.189.1603755644315; Mon, 26 Oct 2020 16:40:44 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 16:40:43 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Alper Nebi Yasak , Simon Glass Subject: [PATCH v2 17/28] binman: Store the original data before compression Date: Mon, 26 Oct 2020 17:40:15 -0600 Message-Id: <20201026234026.1903778-17-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 When compressing an entry, the original uncompressed data is overwritten. Store it so it is available if needed. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/entry.py | 7 ++++++- tools/binman/ftest.py | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 0421129c031..d701eaff8fd 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -60,7 +60,10 @@ class Entry(object): the containing section, 0 if none. The pad bytes become part of the entry. data: Contents of entry (string of bytes). This does not include - padding created by pad_before or pad_after + padding created by pad_before or pad_after. If the entry is + compressed, this contains the compressed data. + uncomp_data: Original uncompressed data, if this entry is compressed, + else None compress: Compression algoithm used (e.g. 'lz4'), 'none' if none orig_offset: Original offset value read from node orig_size: Original size value read from node @@ -83,6 +86,7 @@ class Entry(object): self.pre_reset_size = None self.uncomp_size = None self.data = None + self.uncomp_data = None self.contents_size = 0 self.align = None self.align_size = None @@ -856,6 +860,7 @@ features to produce new behaviours. Returns: Compressed data (first word is the compressed size) """ + self.uncomp_data = indata if self.compress != 'none': self.uncomp_size = len(indata) data = tools.Compress(indata, self.compress) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 830b610890f..4c94bea6f00 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -1810,6 +1810,18 @@ class TestFunctional(unittest.TestCase): props = self._GetPropTree(dtb, ['size', 'uncomp-size']) orig = self._decompress(data) self.assertEquals(COMPRESS_DATA, orig) + + # Do a sanity check on various fields + image = control.images['image'] + entries = image.GetEntries() + self.assertEqual(1, len(entries)) + + entry = entries['blob'] + self.assertEqual(COMPRESS_DATA, entry.uncomp_data) + self.assertEqual(len(COMPRESS_DATA), entry.uncomp_size) + orig = self._decompress(entry.data) + self.assertEqual(orig, entry.uncomp_data) + expected = { 'blob:uncomp-size': len(COMPRESS_DATA), 'blob:size': len(data),