From f514d8f23de4aada7e6f9f4d9de731b43912a77a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 24 Aug 2019 07:22:54 -0600 Subject: [PATCH] binman: Use the Makefile for u_boot_ucode_ptr Remove this file from git and instead build it using the Makefile. Update tools.GetInputFilename() to support reading files from an absolute path, so that we can read the Elf test files easily. Also make sure that the temp directory is report in ELF tests as this was commented out. Signed-off-by: Simon Glass --- tools/binman/elf_test.py | 19 +++++++++++++++---- tools/binman/ftest.py | 14 +++++++------- tools/binman/test/Makefile | 2 +- tools/binman/test/u_boot_ucode_ptr | Bin 4175 -> 0 bytes tools/binman/test/u_boot_ucode_ptr.lds | 3 ++- tools/patman/tools.py | 2 +- 6 files changed, 26 insertions(+), 14 deletions(-) delete mode 100755 tools/binman/test/u_boot_ucode_ptr diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py index 736b931fd5..403ca2b412 100644 --- a/tools/binman/elf_test.py +++ b/tools/binman/elf_test.py @@ -75,18 +75,29 @@ def BuildElfTestFiles(target_dir): class TestElf(unittest.TestCase): @classmethod - def setUpClass(self): + def setUpClass(cls): + cls._indir = tempfile.mkdtemp(prefix='elf.') tools.SetInputDirs(['.']) + BuildElfTestFiles(cls._indir) + + @classmethod + def tearDownClass(cls): + if cls._indir: + shutil.rmtree(cls._indir) + + @classmethod + def ElfTestFile(cls, fname): + return os.path.join(cls._indir, fname) def testAllSymbols(self): """Test that we can obtain a symbol from the ELF file""" - fname = os.path.join(binman_dir, 'test', 'u_boot_ucode_ptr') + fname = self.ElfTestFile('u_boot_ucode_ptr') syms = elf.GetSymbols(fname, []) self.assertIn('.ucode', syms) def testRegexSymbols(self): """Test that we can obtain from the ELF file by regular expression""" - fname = os.path.join(binman_dir, 'test', 'u_boot_ucode_ptr') + fname = self.ElfTestFile('u_boot_ucode_ptr') syms = elf.GetSymbols(fname, ['ucode']) self.assertIn('.ucode', syms) syms = elf.GetSymbols(fname, ['missing']) @@ -201,7 +212,7 @@ class TestElf(unittest.TestCase): self.assertEqual(elf.ElfInfo(b'\0\0' + expected[2:], load, entry, len(expected)), elf.DecodeElf(data, load + 2)) - #shutil.rmtree(outdir) + shutil.rmtree(outdir) if __name__ == '__main__': diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index fad62bb04f..e7ade0fddf 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -152,8 +152,8 @@ class TestFunctional(unittest.TestCase): elf_test.BuildElfTestFiles(cls._elf_testdir) # ELF file with a '_dt_ucode_base_size' symbol - with open(cls.TestFile('u_boot_ucode_ptr'), 'rb') as fd: - TestFunctional._MakeInputFile('u-boot', fd.read()) + TestFunctional._MakeInputFile('u-boot', + tools.ReadFile(cls.ElfTestFile('u_boot_ucode_ptr'))) # Intel flash descriptor file with open(cls.TestFile('descriptor.bin'), 'rb') as fd: @@ -489,7 +489,7 @@ class TestFunctional(unittest.TestCase): Filename of ELF file to use as SPL """ # TODO(sjg@chromium.org): Drop this when all Elf files use ElfTestFile() - if src_fname in ['bss_data']: + if src_fname in ['bss_data', 'u_boot_ucode_ptr']: fname = cls.ElfTestFile(src_fname) else: fname = cls.TestFile(src_fname) @@ -1101,8 +1101,8 @@ class TestFunctional(unittest.TestCase): finally: # Put the original file back - with open(self.TestFile('u_boot_ucode_ptr'), 'rb') as fd: - TestFunctional._MakeInputFile('u-boot', fd.read()) + TestFunctional._MakeInputFile('u-boot', + tools.ReadFile(self.ElfTestFile('u_boot_ucode_ptr'))) def testMicrocodeNotInImage(self): """Test that microcode must be placed within the image""" @@ -1818,8 +1818,8 @@ class TestFunctional(unittest.TestCase): u-boot-tpl.dtb with the microcode removed the microcode """ - with open(self.TestFile('u_boot_ucode_ptr'), 'rb') as fd: - TestFunctional._MakeInputFile('tpl/u-boot-tpl', fd.read()) + TestFunctional._MakeInputFile('tpl/u-boot-tpl', + tools.ReadFile(self.ElfTestFile('u_boot_ucode_ptr'))) first, pos_and_size = self._RunMicrocodeTest('093_x86_tpl_ucode.dts', U_BOOT_TPL_NODTB_DATA) self.assertEqual(b'tplnodtb with microc' + pos_and_size + diff --git a/tools/binman/test/Makefile b/tools/binman/test/Makefile index ce1c2f900c..fd660eac6e 100644 --- a/tools/binman/test/Makefile +++ b/tools/binman/test/Makefile @@ -10,7 +10,7 @@ VPATH := $(SRC) CFLAGS := -march=i386 -m32 -nostdlib -I ../../../include -LDS_UCODE := -T u_boot_ucode_ptr.lds +LDS_UCODE := -T $(SRC)u_boot_ucode_ptr.lds LDS_BINMAN := -T u_boot_binman_syms.lds LDS_BINMAN_BAD := -T u_boot_binman_syms_bad.lds diff --git a/tools/binman/test/u_boot_ucode_ptr b/tools/binman/test/u_boot_ucode_ptr deleted file mode 100755 index dbfb184cecfbcf55cf43ed4f4ac0ee90a7364d93..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4175 zcmeHKze~eV5WfDv>Y%NqTOB%ds7Rl!MiB>>qFqFAD7b~B30kpLh}je}Vs) zgM)i3QgG0CU(yE=7YE1p!Ew2t@9xWVH@o|LsZ@#-(v%@sqt7rjSl=(i5rZlmsZoxy zQ9SaF!jM>&I0rHVXMs3_>*wPh=u>4I0zc&NRXVJG0rgz2p&8H&Xa+O`ngPv#Wh9TCMV?U7?UiPJBvzCKcpQta-m##SW0$~TeGpF8jNCaKqaY=Oj ze&6*ZKlNvnIWxzC`EXm}&a5V?u^%8_A>)8o(X9qLQXD z#1~o6OQFqqJIY{<8~_@#DLmzgZrQ+Xi@EVGZrnMRWWNeKSJ|ha`YAi9u{Z4aQjhnG z?c~ddtBklhOXCp#9(;g{)Q?Fq+c>PTU-d6wo4~YvUz*V$GtcEfbjfs-ZCgXv9QLkU KGKbO{NcskUZF7hK diff --git a/tools/binman/test/u_boot_ucode_ptr.lds b/tools/binman/test/u_boot_ucode_ptr.lds index 0cf9b762b5..cf4d1b8bbd 100644 --- a/tools/binman/test/u_boot_ucode_ptr.lds +++ b/tools/binman/test/u_boot_ucode_ptr.lds @@ -9,9 +9,10 @@ ENTRY(_start) SECTIONS { - . = 0xfffffdf0; + . = 0xfffffe14; _start = .; .ucode : { *(.ucode) } + .interp : { *(.interp*) } } diff --git a/tools/patman/tools.py b/tools/patman/tools.py index 0952681579..4a7fcdad21 100644 --- a/tools/patman/tools.py +++ b/tools/patman/tools.py @@ -125,7 +125,7 @@ def GetInputFilename(fname): Returns: The full path of the filename, within the input directory """ - if not indir: + if not indir or fname[:1] == '/': return fname for dirname in indir: pathname = os.path.join(dirname, fname) -- 2.25.1