diff mbox series

[U-Boot,21/26] binman: Add test for u-boot-spl-bss-pad

Message ID 20171113045231.15911-22-sjg@chromium.org
State Accepted
Commit 56509843003570f57f8600642258c77d525da0e5
Delegated to: Simon Glass
Headers show
Series test: Include Python tools in test coverage | expand

Commit Message

Simon Glass Nov. 13, 2017, 4:52 a.m. UTC
Add a test that we can pad the BSS with zero bytes.

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

 tools/binman/ftest.py                |   9 +++++++++
 tools/binman/test/47_spl_bss_pad.dts |  17 +++++++++++++++++
 tools/binman/test/Makefile           |   5 ++++-
 tools/binman/test/bss_data           | Bin 0 -> 5020 bytes
 tools/binman/test/bss_data.c         |  18 ++++++++++++++++++
 tools/binman/test/bss_data.lds       |  16 ++++++++++++++++
 6 files changed, 64 insertions(+), 1 deletion(-)
 create mode 100644 tools/binman/test/47_spl_bss_pad.dts
 create mode 100755 tools/binman/test/bss_data
 create mode 100644 tools/binman/test/bss_data.c
 create mode 100644 tools/binman/test/bss_data.lds

Comments

Simon Glass Nov. 24, 2017, 1:46 a.m. UTC | #1
Add a test that we can pad the BSS with zero bytes.

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

 tools/binman/ftest.py                |   9 +++++++++
 tools/binman/test/47_spl_bss_pad.dts |  17 +++++++++++++++++
 tools/binman/test/Makefile           |   5 ++++-
 tools/binman/test/bss_data           | Bin 0 -> 5020 bytes
 tools/binman/test/bss_data.c         |  18 ++++++++++++++++++
 tools/binman/test/bss_data.lds       |  16 ++++++++++++++++
 6 files changed, 64 insertions(+), 1 deletion(-)
 create mode 100644 tools/binman/test/47_spl_bss_pad.dts
 create mode 100755 tools/binman/test/bss_data
 create mode 100644 tools/binman/test/bss_data.c
 create mode 100644 tools/binman/test/bss_data.lds

Applied to u-boot-dm thanks!
diff mbox series

Patch

diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 539ebc57f57..4e6aaad9d6b 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -88,6 +88,10 @@  class TestFunctional(unittest.TestCase):
         with open(self.TestFile('descriptor.bin')) as fd:
             TestFunctional._MakeInputFile('descriptor.bin', fd.read())
 
+        # ELF file with a '__bss_size' symbol
+        with open(self.TestFile('bss_data')) as fd:
+            TestFunctional._MakeInputFile('spl/u-boot-spl', fd.read())
+
     @classmethod
     def tearDownClass(self):
         """Remove the temporary input directory and its contents"""
@@ -814,6 +818,11 @@  class TestFunctional(unittest.TestCase):
         data = self._DoReadFile('46_intel-vbt.dts')
         self.assertEqual(VBT_DATA, data[:len(VBT_DATA)])
 
+    def testSplBssPad(self):
+        """Test that we can pad SPL's BSS with zeros"""
+        data = self._DoReadFile('47_spl_bss_pad.dts')
+        self.assertEqual(U_BOOT_SPL_DATA + (chr(0) * 10) + U_BOOT_DATA, data)
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/47_spl_bss_pad.dts b/tools/binman/test/47_spl_bss_pad.dts
new file mode 100644
index 00000000000..6bd88b83f98
--- /dev/null
+++ b/tools/binman/test/47_spl_bss_pad.dts
@@ -0,0 +1,17 @@ 
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		u-boot-spl {
+		};
+
+		u-boot-spl-bss-pad {
+		};
+
+		u-boot {
+		};
+	};
+};
diff --git a/tools/binman/test/Makefile b/tools/binman/test/Makefile
index 786d1b05778..217d13c666f 100644
--- a/tools/binman/test/Makefile
+++ b/tools/binman/test/Makefile
@@ -11,7 +11,7 @@  CFLAGS := -march=i386 -m32 -nostdlib -I ../../../include
 
 LDS_UCODE := -T u_boot_ucode_ptr.lds
 
-TARGETS = u_boot_ucode_ptr u_boot_no_ucode_ptr
+TARGETS = u_boot_ucode_ptr u_boot_no_ucode_ptr bss_data
 
 all: $(TARGETS)
 
@@ -21,6 +21,9 @@  u_boot_no_ucode_ptr: u_boot_no_ucode_ptr.c
 u_boot_ucode_ptr: CFLAGS += $(LDS_UCODE)
 u_boot_ucode_ptr: u_boot_ucode_ptr.c
 
+bss_data: CFLAGS += bss_data.lds
+bss_data: bss_data.c
+
 clean:
 	rm -f $(TARGETS)
 
diff --git a/tools/binman/test/bss_data b/tools/binman/test/bss_data
new file mode 100755
index 0000000000000000000000000000000000000000..afa28282aa157f6717c1ba244ecbfc6e1b081734
GIT binary patch
literal 5020
zcmeHLyKWOf6uoP&!GJ+|Af+(H7C{(6hJ>s{1O*}i;vz!9k|7jmvEv0>!j5FGr4S(=
z1rl`m016r?sner~AE2ip9R*N@0-1AWb`nc8lqu#)$M-R39(#6N?0tS?>89s-Vl5+C
zVfN$CU=YG@j+l{90?A29j!9mR>*@<XFTe^W5IGjX=X`p3hjGA1SOyLOtTX>YU@kF<
zm|&e)-boq-EK+#s=ZTZ35qA7G#*zMGT%X&LM}8Jqyj7L$-{T)<zJ0y(_Vh>Z{jc>)
zoA)Lv)i*nzb0r)u1JV{C_dj{X>=n-E`M(bagY)oQhvscm#Cw|eiUr?)4Z<nZh%N9m
z=h}(<tIYiI-10UUoZ-wV;1qBQI0c*nP64NYQ@|<U6mSYS1)Ks0M}ZQKvbeBtIVe@@
z{Z7&kLN%wtsf&G`%{-e4)pV$4&zic3>OE;EwK{y#HNI)1&RP<yN1eW^_gjw}Q>})m
zBwkNM#m(qpx7LoMW}~~GiE7l6ny7lOCu()A-HtoS|Lal&^)SHCcil&Tp9HMgPjH0-
zzvtN-*hQ~l7v6r;Bi!p{glWw6bl(A!hIw|q`5|6_-b4W29BS4qZwUqN%N~U8gQR^A
zrZmf|AkG8i1!zb3;PIVU3)0{&JlC5}bMnrmF&)Q<Q9$nrPrCr#109(ka%l8?R%_)k
z^iEJbiUPs&VX7PfhSyse7rBm_HM^e8hdtj5bJI~W`kUPBOr1?`cA%anPt}1QCfA)M
zt&hodCyAl9EN;T^Iehs!uw(Sh3-I>2Mv+e-r`{#_QQVFIo;@!(Jhvxj;Qe&}5sc3w
z=l$WG7=v<r=lkP1xr)3z#1~xah!<R~N)$2awKn3tszkk{)=lh?j@z|XN1|B&E26m5
FkiP*om$v`_

literal 0
HcmV?d00001

diff --git a/tools/binman/test/bss_data.c b/tools/binman/test/bss_data.c
new file mode 100644
index 00000000000..f865a9d9f67
--- /dev/null
+++ b/tools/binman/test/bss_data.c
@@ -0,0 +1,18 @@ 
+/*
+ * Copyright (c) 2016 Google, Inc
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ *
+ * Simple program to create a _dt_ucode_base_size symbol which can be read
+ * by 'nm'. This is used by binman tests.
+ */
+
+int bss_data[10];
+int __bss_size = sizeof(bss_data);
+
+int main()
+{
+	bss_data[2] = 2;
+
+	return 0;
+}
diff --git a/tools/binman/test/bss_data.lds b/tools/binman/test/bss_data.lds
new file mode 100644
index 00000000000..6b2fe09d351
--- /dev/null
+++ b/tools/binman/test/bss_data.lds
@@ -0,0 +1,16 @@ 
+/*
+ * Copyright (c) 2016 Google, Inc
+ *
+ * SPDX-License-Identifier:      GPL-2.0+
+ */
+
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+OUTPUT_ARCH(i386)
+ENTRY(_start)
+
+SECTIONS
+{
+	. = 0xfffffdf0;
+	_start = .;
+	__bss_size = 10;
+}