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 60B6BC433F5 for ; Sun, 27 Mar 2022 15:33:28 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A6E1F839B1; Sun, 27 Mar 2022 17:33:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="btcxOpG1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A321F8395A; Sun, 27 Mar 2022 17:32:35 +0200 (CEST) Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) (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 71F5A8396C for ; Sun, 27 Mar 2022 17:32:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=alpernebiyasak@gmail.com Received: by mail-ej1-x631.google.com with SMTP id yy13so23999876ejb.2 for ; Sun, 27 Mar 2022 08:32:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Bct4mL3ozcxTChvxCkPbDUNK1RfvDHWOd+esrXOz+bU=; b=btcxOpG1WN7Lj8H+j50T8v2CBXEUnBK+fwnTyO+iZQEvaVpbpZuJZGmvVsFOCscbNI 5ql0DmwKIlubYo8sjCtb+igavgfaO6v8Ck1NlfN8E14dhfc2A4Ae4kg284MfkgIPa8lI SbaLQTkLs8K9n6J0NLtJUr6lOXgoTIKwer3cDo6obN0DppY9eMxGOcOEBdauYH1+/3O6 KtVweiDfXI0h8+5JxnpehuSAYhHgIUktTTYRxoHjf39/yH6ChUqwf6zxVeNzJ2Eyz8sL c4+rJfE/Lqj8VGbFaDW/F1Vj0f6nWGWu7KxoHsc76n9gGZAtsF//N4hG6ALC+xLADinm NuKw== 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=Bct4mL3ozcxTChvxCkPbDUNK1RfvDHWOd+esrXOz+bU=; b=w1VVM8GXK/Wk42hbNBPlLx4WP9FK2u7PMo6Kya/p5F7UsbWUdUCns1imfwcY+Sl1dt EQaUTQZB+Arzm0GpQPwTlp+mcYVxMnkr+4JS7O43xpWFQQOuowLuldZQEOIa6TxbtJzg ey/klYMMRG9R4M0irV1vOXI0LFzKwWPNIu+6PXdB7O/iFpzSoCKjYO3U+Nac3AzQ8YN+ e/gmm28EMhcfvLM4/27Y3qjfIKWNRr+saBwnRTWLaCk1GtcB7E87vgkfCveX5ZwYyfHJ ly6XSDiuIyt0Z89SSh/ZyRxDyvRDpe+WG9M32djKDX8hhWDfKQR4MW1ovYXUp93Oy4NB AeaA== X-Gm-Message-State: AOAM532KQ9b+oxpk66/JUrOMA7OssdrCgMIWUXGm8viBn0v1/v6rNN8h n9W9Zo0WPEXqQqoa2N7nxh84Pty1igU= X-Google-Smtp-Source: ABdhPJwRFYlYeJ2oZQ6dm8+HTVOtdvGxuOAJsaWJaT04mLW9RifjFYiJ1WcA9ES4O5hMtT7JipPw0Q== X-Received: by 2002:a17:907:7202:b0:6df:83a9:67d2 with SMTP id dr2-20020a170907720200b006df83a967d2mr22422474ejc.327.1648395144114; Sun, 27 Mar 2022 08:32:24 -0700 (PDT) Received: from localhost.localdomain ([178.233.26.119]) by smtp.gmail.com with ESMTPSA id jg22-20020a170907971600b006df9ff416ccsm4639763ejc.137.2022.03.27.08.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Mar 2022 08:32:23 -0700 (PDT) From: Alper Nebi Yasak To: u-boot@lists.denx.de Cc: Simon Glass , Heiko Thiery , Jan Kiszka , Alper Nebi Yasak Subject: [PATCH 6/7] binman: Test replacing non-section entries in FIT subsections Date: Sun, 27 Mar 2022 18:31:49 +0300 Message-Id: <20220327153151.15912-7-alpernebiyasak@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220327153151.15912-1-alpernebiyasak@gmail.com> References: <20220327153151.15912-1-alpernebiyasak@gmail.com> 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 A previous patch fixes binman to correctly extract FIT subentries. This makes it easier to test replacing these entries as we can write tests using an existing helper function that relies on extracting the replaced entry. Add tests that replace leaf entries in FIT subsections with data of various sizes. Replacing the subsections or the whole FIT section does not work yet due to the section contents being re-built from unreplaced subentries' data. Signed-off-by: Alper Nebi Yasak --- tools/binman/ftest.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index a31568997f6f..43bec4a88841 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -5603,6 +5603,44 @@ def testExtractFitSubentries(self): data = control.ReadEntry(image_fname, entry_path) self.assertEqual(expected, data) + def testReplaceFitSubentryLeafSameSize(self): + """Test replacing a FIT leaf subentry with same-size data""" + new_data = b'x' * len(U_BOOT_DATA) + data, expected_fdtmap, _ = self._RunReplaceCmd( + 'fit/kernel/u-boot', new_data, + dts='233_fit_extract_replace.dts') + self.assertEqual(new_data, data) + + path, fdtmap = state.GetFdtContents('fdtmap') + self.assertIsNotNone(path) + self.assertEqual(expected_fdtmap, fdtmap) + + def testReplaceFitSubentryLeafBiggerSize(self): + """Test replacing a FIT leaf subentry with bigger-size data""" + new_data = b'ub' * len(U_BOOT_NODTB_DATA) + data, expected_fdtmap, _ = self._RunReplaceCmd( + 'fit/fdt-1/u-boot-nodtb', new_data, + dts='233_fit_extract_replace.dts') + self.assertEqual(new_data, data) + + # Will be repacked, so fdtmap must change + path, fdtmap = state.GetFdtContents('fdtmap') + self.assertIsNotNone(path) + self.assertNotEqual(expected_fdtmap, fdtmap) + + def testReplaceFitSubentryLeafSmallerSize(self): + """Test replacing a FIT leaf subentry with smaller-size data""" + new_data = b'x' + expected = new_data.ljust(len(U_BOOT_NODTB_DATA), b'\0') + data, expected_fdtmap, _ = self._RunReplaceCmd( + 'fit/fdt-1/u-boot-nodtb', new_data, + dts='233_fit_extract_replace.dts') + self.assertEqual(expected, data) + + path, fdtmap = state.GetFdtContents('fdtmap') + self.assertIsNotNone(path) + self.assertEqual(expected_fdtmap, fdtmap) + if __name__ == "__main__": unittest.main() -- 2.35.1