[PATCH v2 03/28] binman: Add tests for skip-at-start sections

Simon Glass sjg at chromium.org
Tue Oct 27 00:40:01 CET 2020


At present this feature is tested view the end-at-4gb feature. Add some
tests of its own, including the operation of padding.

The third test here shows binman's current, inconsistent approach to
padding in the top-level section. Future patches in this series will
address this.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v2:
- Add new tests for skip-at-start sections

 tools/binman/ftest.py                         | 59 +++++++++++++++++++
 tools/binman/test/177_skip_at_start.dts       | 19 ++++++
 tools/binman/test/178_skip_at_start_pad.dts   | 21 +++++++
 .../test/179_skip_at_start_section_pad.dts    | 22 +++++++
 4 files changed, 121 insertions(+)
 create mode 100644 tools/binman/test/177_skip_at_start.dts
 create mode 100644 tools/binman/test/178_skip_at_start_pad.dts
 create mode 100644 tools/binman/test/179_skip_at_start_section_pad.dts

diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index d23967e603d..adc16038d99 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -3752,6 +3752,65 @@ class TestFunctional(unittest.TestCase):
         self.assertIn("too small to hold data (need %#x more bytes)" % short,
                       str(e.exception))
 
+    def testSkipAtStart(self):
+        """Test handling of skip-at-start section"""
+        data = self._DoReadFile('177_skip_at_start.dts')
+        self.assertEqual(U_BOOT_DATA, data)
+
+        image = control.images['image']
+        entries = image.GetEntries()
+        section = entries['section']
+        self.assertEqual(0, section.offset)
+        self.assertEqual(len(U_BOOT_DATA), section.size)
+        self.assertEqual(U_BOOT_DATA, section.GetData())
+
+        entry = section.GetEntries()['u-boot']
+        self.assertEqual(16, entry.offset)
+        self.assertEqual(len(U_BOOT_DATA), entry.size)
+        self.assertEqual(U_BOOT_DATA, entry.data)
+
+    def testSkipAtStartPad(self):
+        """Test handling of skip-at-start section with padded entry"""
+        data = self._DoReadFile('178_skip_at_start_pad.dts')
+        before = tools.GetBytes(0, 8)
+        after = tools.GetBytes(0, 4)
+        all = before + U_BOOT_DATA + after
+        self.assertEqual(all, data)
+
+        image = control.images['image']
+        entries = image.GetEntries()
+        section = entries['section']
+        self.assertEqual(0, section.offset)
+        self.assertEqual(len(all), section.size)
+        self.assertEqual(all, section.GetData())
+
+        entry = section.GetEntries()['u-boot']
+        self.assertEqual(16, entry.offset)
+        self.assertEqual(len(all), entry.size)
+        self.assertEqual(U_BOOT_DATA, entry.data)
+
+    def testSkipAtStartSectionPad(self):
+        """Test handling of skip-at-start section with padding"""
+        data = self._DoReadFile('179_skip_at_start_section_pad.dts')
+        before = tools.GetBytes(0, 8)
+        after = tools.GetBytes(0, 4)
+        all = before + U_BOOT_DATA + after
+
+        # This is not correct, but it is what binman currently produces
+        self.assertEqual(tools.GetBytes(0, 16) + U_BOOT_DATA + after, data)
+
+        image = control.images['image']
+        entries = image.GetEntries()
+        section = entries['section']
+        self.assertEqual(0, section.offset)
+        self.assertEqual(len(all), section.size)
+        self.assertIsNone(section.data)
+        self.assertEqual(all, section.GetData())
+
+        entry = section.GetEntries()['u-boot']
+        self.assertEqual(16, entry.offset)
+        self.assertEqual(len(U_BOOT_DATA), entry.size)
+        self.assertEqual(U_BOOT_DATA, entry.data)
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/177_skip_at_start.dts b/tools/binman/test/177_skip_at_start.dts
new file mode 100644
index 00000000000..021460b1a04
--- /dev/null
+++ b/tools/binman/test/177_skip_at_start.dts
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 NXP
+ */
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		section {
+			skip-at-start = <16>;
+			u-boot {
+			};
+		};
+	};
+};
diff --git a/tools/binman/test/178_skip_at_start_pad.dts b/tools/binman/test/178_skip_at_start_pad.dts
new file mode 100644
index 00000000000..deda3c862e9
--- /dev/null
+++ b/tools/binman/test/178_skip_at_start_pad.dts
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 NXP
+ */
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		section {
+			skip-at-start = <16>;
+			u-boot {
+				pad-before = <8>;
+				pad-after = <4>;
+			};
+		};
+	};
+};
diff --git a/tools/binman/test/179_skip_at_start_section_pad.dts b/tools/binman/test/179_skip_at_start_section_pad.dts
new file mode 100644
index 00000000000..bf2f8f69b4d
--- /dev/null
+++ b/tools/binman/test/179_skip_at_start_section_pad.dts
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 NXP
+ */
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		section {
+			skip-at-start = <16>;
+			pad-before = <8>;
+			pad-after = <4>;
+
+			u-boot {
+			};
+		};
+	};
+};
-- 
2.29.0.rc2.309.g374f81d7ae-goog



More information about the U-Boot mailing list