summaryrefslogtreecommitdiff
path: root/tools/binman/elf_test.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-08-24 16:22:53 +0300
committerSimon Glass <sjg@chromium.org>2019-10-15 17:40:02 +0300
commit53e22bf38c202d5ef3bc092d55095c672994a15b (patch)
treee147ce74f9452e82c14c1006f134f314f3f2d65f /tools/binman/elf_test.py
parent180f556b090c2e3c84c904d3e6bc884acb423e1f (diff)
downloadu-boot-53e22bf38c202d5ef3bc092d55095c672994a15b.tar.xz
binman: Use the Makefile to build ELF test files
At present the ELF test files are checked into the U-Boot tree. This is covenient since the files never change and can be used on non-x86 platforms. However it is not good practice to check in binaries and in this case it does not seem essential. Update the binman test-file Makefile to support having source in a different directory. Adjust binman to run it to build bss_data, as a start. We can add other files as needed. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/elf_test.py')
-rw-r--r--tools/binman/elf_test.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py
index cc6e9c5128..736b931fd5 100644
--- a/tools/binman/elf_test.py
+++ b/tools/binman/elf_test.py
@@ -50,6 +50,29 @@ class FakeSection:
return self.sym_value
+def BuildElfTestFiles(target_dir):
+ """Build ELF files used for testing in binman
+
+ This compiles and links the test files into the specified directory. It the
+ Makefile and source files in the binman test/ directory.
+
+ Args:
+ target_dir: Directory to put the files into
+ """
+ if not os.path.exists(target_dir):
+ os.mkdir(target_dir)
+ testdir = os.path.join(binman_dir, 'test')
+
+ # If binman is involved from the main U-Boot Makefile the -r and -R
+ # flags are set in MAKEFLAGS. This prevents this Makefile from working
+ # correctly. So drop any make flags here.
+ if 'MAKEFLAGS' in os.environ:
+ del os.environ['MAKEFLAGS']
+ tools.Run('make', '-C', target_dir, '-f',
+ os.path.join(testdir, 'Makefile'), 'SRC=%s/' % testdir,
+ 'bss_data', 'u_boot_ucode_ptr')
+
+
class TestElf(unittest.TestCase):
@classmethod
def setUpClass(self):