binman: Skip elf tests if python elftools is not available
Skip tests which requires python elftools if the tool is not available. Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
d626e825f5
commit
6ac7a83e4d
@ -122,6 +122,8 @@ class TestElf(unittest.TestCase):
|
|||||||
|
|
||||||
def testOutsideFile(self):
|
def testOutsideFile(self):
|
||||||
"""Test a symbol which extends outside the entry area is detected"""
|
"""Test a symbol which extends outside the entry area is detected"""
|
||||||
|
if not elf.ELF_TOOLS:
|
||||||
|
self.skipTest('Python elftools not available')
|
||||||
entry = FakeEntry(10)
|
entry = FakeEntry(10)
|
||||||
section = FakeSection()
|
section = FakeSection()
|
||||||
elf_fname = self.ElfTestFile('u_boot_binman_syms')
|
elf_fname = self.ElfTestFile('u_boot_binman_syms')
|
||||||
@ -147,6 +149,8 @@ class TestElf(unittest.TestCase):
|
|||||||
Only 32 and 64 bits are supported, since we need to store an offset
|
Only 32 and 64 bits are supported, since we need to store an offset
|
||||||
into the image.
|
into the image.
|
||||||
"""
|
"""
|
||||||
|
if not elf.ELF_TOOLS:
|
||||||
|
self.skipTest('Python elftools not available')
|
||||||
entry = FakeEntry(10)
|
entry = FakeEntry(10)
|
||||||
section = FakeSection()
|
section = FakeSection()
|
||||||
elf_fname =self.ElfTestFile('u_boot_binman_syms_size')
|
elf_fname =self.ElfTestFile('u_boot_binman_syms_size')
|
||||||
@ -161,6 +165,8 @@ class TestElf(unittest.TestCase):
|
|||||||
This should produce -1 values for all thress symbols, taking up the
|
This should produce -1 values for all thress symbols, taking up the
|
||||||
first 16 bytes of the image.
|
first 16 bytes of the image.
|
||||||
"""
|
"""
|
||||||
|
if not elf.ELF_TOOLS:
|
||||||
|
self.skipTest('Python elftools not available')
|
||||||
entry = FakeEntry(28)
|
entry = FakeEntry(28)
|
||||||
section = FakeSection(sym_value=None)
|
section = FakeSection(sym_value=None)
|
||||||
elf_fname = self.ElfTestFile('u_boot_binman_syms')
|
elf_fname = self.ElfTestFile('u_boot_binman_syms')
|
||||||
@ -172,6 +178,8 @@ class TestElf(unittest.TestCase):
|
|||||||
|
|
||||||
def testDebug(self):
|
def testDebug(self):
|
||||||
"""Check that enabling debug in the elf module produced debug output"""
|
"""Check that enabling debug in the elf module produced debug output"""
|
||||||
|
if not elf.ELF_TOOLS:
|
||||||
|
self.skipTest('Python elftools not available')
|
||||||
try:
|
try:
|
||||||
tout.init(tout.DEBUG)
|
tout.init(tout.DEBUG)
|
||||||
entry = FakeEntry(24)
|
entry = FakeEntry(24)
|
||||||
@ -281,6 +289,8 @@ class TestElf(unittest.TestCase):
|
|||||||
|
|
||||||
def test_read_segments_bad_data(self):
|
def test_read_segments_bad_data(self):
|
||||||
"""Test for read_loadable_segments() with an invalid ELF file"""
|
"""Test for read_loadable_segments() with an invalid ELF file"""
|
||||||
|
if not elf.ELF_TOOLS:
|
||||||
|
self.skipTest('Python elftools not available')
|
||||||
fname = self.ElfTestFile('embed_data')
|
fname = self.ElfTestFile('embed_data')
|
||||||
with self.assertRaises(ValueError) as e:
|
with self.assertRaises(ValueError) as e:
|
||||||
elf.read_loadable_segments(tools.get_bytes(100, 100))
|
elf.read_loadable_segments(tools.get_bytes(100, 100))
|
||||||
@ -288,6 +298,8 @@ class TestElf(unittest.TestCase):
|
|||||||
|
|
||||||
def test_get_file_offset(self):
|
def test_get_file_offset(self):
|
||||||
"""Test GetFileOffset() gives the correct file offset for a symbol"""
|
"""Test GetFileOffset() gives the correct file offset for a symbol"""
|
||||||
|
if not elf.ELF_TOOLS:
|
||||||
|
self.skipTest('Python elftools not available')
|
||||||
fname = self.ElfTestFile('embed_data')
|
fname = self.ElfTestFile('embed_data')
|
||||||
syms = elf.GetSymbols(fname, ['embed'])
|
syms = elf.GetSymbols(fname, ['embed'])
|
||||||
addr = syms['embed'].address
|
addr = syms['embed'].address
|
||||||
@ -314,6 +326,8 @@ class TestElf(unittest.TestCase):
|
|||||||
|
|
||||||
def test_get_symbol_from_address(self):
|
def test_get_symbol_from_address(self):
|
||||||
"""Test GetSymbolFromAddress()"""
|
"""Test GetSymbolFromAddress()"""
|
||||||
|
if not elf.ELF_TOOLS:
|
||||||
|
self.skipTest('Python elftools not available')
|
||||||
fname = self.ElfTestFile('elf_sections')
|
fname = self.ElfTestFile('elf_sections')
|
||||||
sym_name = 'calculate'
|
sym_name = 'calculate'
|
||||||
syms = elf.GetSymbols(fname, [sym_name])
|
syms = elf.GetSymbols(fname, [sym_name])
|
||||||
|
@ -4807,6 +4807,8 @@ class TestFunctional(unittest.TestCase):
|
|||||||
|
|
||||||
def testUpdateFdtInElf(self):
|
def testUpdateFdtInElf(self):
|
||||||
"""Test that we can update the devicetree in an ELF file"""
|
"""Test that we can update the devicetree in an ELF file"""
|
||||||
|
if not elf.ELF_TOOLS:
|
||||||
|
self.skipTest('Python elftools not available')
|
||||||
infile = elf_fname = self.ElfTestFile('u_boot_binman_embed')
|
infile = elf_fname = self.ElfTestFile('u_boot_binman_embed')
|
||||||
outfile = os.path.join(self._indir, 'u-boot.out')
|
outfile = os.path.join(self._indir, 'u-boot.out')
|
||||||
begin_sym = 'dtb_embed_begin'
|
begin_sym = 'dtb_embed_begin'
|
||||||
@ -4858,6 +4860,8 @@ class TestFunctional(unittest.TestCase):
|
|||||||
|
|
||||||
def testUpdateFdtInElfNoSyms(self):
|
def testUpdateFdtInElfNoSyms(self):
|
||||||
"""Test that missing symbols are detected with --update-fdt-in-elf"""
|
"""Test that missing symbols are detected with --update-fdt-in-elf"""
|
||||||
|
if not elf.ELF_TOOLS:
|
||||||
|
self.skipTest('Python elftools not available')
|
||||||
infile = elf_fname = self.ElfTestFile('u_boot_binman_embed')
|
infile = elf_fname = self.ElfTestFile('u_boot_binman_embed')
|
||||||
outfile = ''
|
outfile = ''
|
||||||
begin_sym = 'wrong_begin'
|
begin_sym = 'wrong_begin'
|
||||||
@ -4871,6 +4875,8 @@ class TestFunctional(unittest.TestCase):
|
|||||||
|
|
||||||
def testUpdateFdtInElfTooSmall(self):
|
def testUpdateFdtInElfTooSmall(self):
|
||||||
"""Test that an over-large dtb is detected with --update-fdt-in-elf"""
|
"""Test that an over-large dtb is detected with --update-fdt-in-elf"""
|
||||||
|
if not elf.ELF_TOOLS:
|
||||||
|
self.skipTest('Python elftools not available')
|
||||||
infile = elf_fname = self.ElfTestFile('u_boot_binman_embed_sm')
|
infile = elf_fname = self.ElfTestFile('u_boot_binman_embed_sm')
|
||||||
outfile = os.path.join(self._indir, 'u-boot.out')
|
outfile = os.path.join(self._indir, 'u-boot.out')
|
||||||
begin_sym = 'dtb_embed_begin'
|
begin_sym = 'dtb_embed_begin'
|
||||||
@ -5344,6 +5350,8 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
|
|||||||
|
|
||||||
def testFitSplitElf(self):
|
def testFitSplitElf(self):
|
||||||
"""Test an image with an FIT with an split-elf operation"""
|
"""Test an image with an FIT with an split-elf operation"""
|
||||||
|
if not elf.ELF_TOOLS:
|
||||||
|
self.skipTest('Python elftools not available')
|
||||||
entry_args = {
|
entry_args = {
|
||||||
'of-list': 'test-fdt1 test-fdt2',
|
'of-list': 'test-fdt1 test-fdt2',
|
||||||
'default-dt': 'test-fdt2',
|
'default-dt': 'test-fdt2',
|
||||||
@ -5421,6 +5429,8 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
|
|||||||
|
|
||||||
def testFitSplitElfBadElf(self):
|
def testFitSplitElfBadElf(self):
|
||||||
"""Test a FIT split-elf operation with an invalid ELF file"""
|
"""Test a FIT split-elf operation with an invalid ELF file"""
|
||||||
|
if not elf.ELF_TOOLS:
|
||||||
|
self.skipTest('Python elftools not available')
|
||||||
TestFunctional._MakeInputFile('bad.elf', tools.get_bytes(100, 100))
|
TestFunctional._MakeInputFile('bad.elf', tools.get_bytes(100, 100))
|
||||||
entry_args = {
|
entry_args = {
|
||||||
'of-list': 'test-fdt1 test-fdt2',
|
'of-list': 'test-fdt1 test-fdt2',
|
||||||
@ -5440,6 +5450,8 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
|
|||||||
|
|
||||||
def testFitSplitElfBadDirective(self):
|
def testFitSplitElfBadDirective(self):
|
||||||
"""Test a FIT split-elf invalid fit,xxx directive in an image node"""
|
"""Test a FIT split-elf invalid fit,xxx directive in an image node"""
|
||||||
|
if not elf.ELF_TOOLS:
|
||||||
|
self.skipTest('Python elftools not available')
|
||||||
err = self._check_bad_fit('227_fit_bad_dir.dts')
|
err = self._check_bad_fit('227_fit_bad_dir.dts')
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
"Node '/binman/fit': subnode 'images/@atf-SEQ': Unknown directive 'fit,something'",
|
"Node '/binman/fit': subnode 'images/@atf-SEQ': Unknown directive 'fit,something'",
|
||||||
@ -5447,6 +5459,8 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
|
|||||||
|
|
||||||
def testFitSplitElfBadDirectiveConfig(self):
|
def testFitSplitElfBadDirectiveConfig(self):
|
||||||
"""Test a FIT split-elf with invalid fit,xxx directive in config"""
|
"""Test a FIT split-elf with invalid fit,xxx directive in config"""
|
||||||
|
if not elf.ELF_TOOLS:
|
||||||
|
self.skipTest('Python elftools not available')
|
||||||
err = self._check_bad_fit('228_fit_bad_dir_config.dts')
|
err = self._check_bad_fit('228_fit_bad_dir_config.dts')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"Node '/binman/fit': subnode 'configurations/@config-SEQ': Unknown directive 'fit,config'",
|
"Node '/binman/fit': subnode 'configurations/@config-SEQ': Unknown directive 'fit,config'",
|
||||||
@ -5480,6 +5494,8 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
|
|||||||
|
|
||||||
def testFitSplitElfMissing(self):
|
def testFitSplitElfMissing(self):
|
||||||
"""Test an split-elf FIT with a missing ELF file"""
|
"""Test an split-elf FIT with a missing ELF file"""
|
||||||
|
if not elf.ELF_TOOLS:
|
||||||
|
self.skipTest('Python elftools not available')
|
||||||
out, err = self.checkFitSplitElf(allow_missing=True)
|
out, err = self.checkFitSplitElf(allow_missing=True)
|
||||||
self.assertRegex(
|
self.assertRegex(
|
||||||
err,
|
err,
|
||||||
@ -5490,6 +5506,8 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
|
|||||||
|
|
||||||
def testFitSplitElfFaked(self):
|
def testFitSplitElfFaked(self):
|
||||||
"""Test an split-elf FIT with faked ELF file"""
|
"""Test an split-elf FIT with faked ELF file"""
|
||||||
|
if not elf.ELF_TOOLS:
|
||||||
|
self.skipTest('Python elftools not available')
|
||||||
out, err = self.checkFitSplitElf(allow_missing=True, allow_fake_blobs=True)
|
out, err = self.checkFitSplitElf(allow_missing=True, allow_fake_blobs=True)
|
||||||
self.assertRegex(
|
self.assertRegex(
|
||||||
err,
|
err,
|
||||||
|
Loading…
Reference in New Issue
Block a user