binman: Add test for u-boot-spl-bss-pad
authorSimon Glass <sjg@chromium.org>
Mon, 13 Nov 2017 04:52:25 +0000 (21:52 -0700)
committerSimon Glass <sjg@chromium.org>
Thu, 23 Nov 2017 01:05:38 +0000 (18:05 -0700)
Add a test that we can pad the BSS with zero bytes.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/binman/ftest.py
tools/binman/test/47_spl_bss_pad.dts [new file with mode: 0644]
tools/binman/test/Makefile
tools/binman/test/bss_data [new file with mode: 0755]
tools/binman/test/bss_data.c [new file with mode: 0644]
tools/binman/test/bss_data.lds [new file with mode: 0644]

index 539ebc57f57c9cd6867e941dedcd1d8df822fcd3..4e6aaad9d6b91a735cd13af4afd41feb1204a2d6 100644 (file)
@@ -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 (file)
index 0000000..6bd88b8
--- /dev/null
@@ -0,0 +1,17 @@
+/dts-v1/;
+
+/ {
+       #address-cells = <1>;
+       #size-cells = <1>;
+
+       binman {
+               u-boot-spl {
+               };
+
+               u-boot-spl-bss-pad {
+               };
+
+               u-boot {
+               };
+       };
+};
index 786d1b057782d77c45f7fa22d4e5a3d66937d88e..217d13c666f1bbe24f71e5afb937519ef7f62b92 100644 (file)
@@ -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 (executable)
index 0000000..afa2828
Binary files /dev/null and b/tools/binman/test/bss_data differ
diff --git a/tools/binman/test/bss_data.c b/tools/binman/test/bss_data.c
new file mode 100644 (file)
index 0000000..f865a9d
--- /dev/null
@@ -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 (file)
index 0000000..6b2fe09
--- /dev/null
@@ -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;
+}