All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
To: u-boot@lists.denx.de
Cc: Simon Glass <sjg@chromium.org>,
	Heiko Thiery <heiko.thiery@gmail.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Alper Nebi Yasak <alpernebiyasak@gmail.com>
Subject: [PATCH 6/7] binman: Test replacing non-section entries in FIT subsections
Date: Sun, 27 Mar 2022 18:31:49 +0300	[thread overview]
Message-ID: <20220327153151.15912-7-alpernebiyasak@gmail.com> (raw)
In-Reply-To: <20220327153151.15912-1-alpernebiyasak@gmail.com>

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 <alpernebiyasak@gmail.com>
---

 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


  parent reply	other threads:[~2022-03-27 15:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-27 15:31 [PATCH 0/7] binman: Fix replacing FIT subentries Alper Nebi Yasak
2022-03-27 15:31 ` [PATCH 1/7] binman: Fix unique names having '/.' for images read from files Alper Nebi Yasak
2022-04-19 21:54   ` Simon Glass
2022-03-27 15:31 ` [PATCH 2/7] binman: Collect bintools for images when replacing entries Alper Nebi Yasak
2022-04-19 21:54   ` Simon Glass
2022-03-27 15:31 ` [PATCH 3/7] binman: Don't reset offset/size if image doesn't allow repacking Alper Nebi Yasak
2022-04-19 21:54   ` Simon Glass
2022-03-27 15:31 ` [PATCH 4/7] binman: Remove '/images/' fragment from FIT subentry paths Alper Nebi Yasak
2022-03-27 15:31 ` [PATCH 5/7] binman: Create FIT subentries in the FIT section, not its parent Alper Nebi Yasak
2022-04-19 21:54   ` Simon Glass
2022-03-27 15:31 ` Alper Nebi Yasak [this message]
2022-04-19 21:54   ` [PATCH 6/7] binman: Test replacing non-section entries in FIT subsections Simon Glass
2022-03-27 15:31 ` [PATCH 7/7] binman: Refuse to replace sections for now Alper Nebi Yasak
2022-04-19 21:54   ` Simon Glass
2022-04-23 15:46     ` Alper Nebi Yasak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220327153151.15912-7-alpernebiyasak@gmail.com \
    --to=alpernebiyasak@gmail.com \
    --cc=heiko.thiery@gmail.com \
    --cc=jan.kiszka@siemens.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.