binman: Correct pylint errors
Fix pylint errors that can be fixed and mask those that seem to be incorrect. A complication with binman is that it tries to avoid importing libfdt (or anything that imports it) unless needed, so that things like help still work if it is missing. Note that two tests are duplicated in binman and two others have duplicate names, so both of these issues are fixed also. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
8a455fc08f
commit
8d2ef3e993
@ -7,7 +7,7 @@
|
||||
|
||||
import argparse
|
||||
from argparse import ArgumentParser
|
||||
import state
|
||||
from binman import state
|
||||
|
||||
def make_extract_parser(subparsers):
|
||||
"""make_extract_parser: Make a subparser for the 'extract' command
|
||||
|
@ -20,6 +20,10 @@ from binman import elf
|
||||
from patman import command
|
||||
from patman import tout
|
||||
|
||||
# These are imported if needed since they import libfdt
|
||||
state = None
|
||||
Image = None
|
||||
|
||||
# List of images we plan to create
|
||||
# Make this global so that it can be referenced from tests
|
||||
images = OrderedDict()
|
||||
@ -41,6 +45,8 @@ def _ReadImageDesc(binman_node, use_expanded):
|
||||
Returns:
|
||||
OrderedDict of Image objects, each of which describes an image
|
||||
"""
|
||||
# For Image()
|
||||
# pylint: disable=E1102
|
||||
images = OrderedDict()
|
||||
if 'multiple-images' in binman_node.props:
|
||||
for node in binman_node.subnodes:
|
||||
|
@ -116,7 +116,7 @@ class TestElf(unittest.TestCase):
|
||||
entry = FakeEntry(10)
|
||||
section = FakeSection()
|
||||
with self.assertRaises(ValueError) as e:
|
||||
syms = elf.LookupAndWriteSymbols('missing-file', entry, section)
|
||||
elf.LookupAndWriteSymbols('missing-file', entry, section)
|
||||
self.assertIn("Filename 'missing-file' not found in input path",
|
||||
str(e.exception))
|
||||
|
||||
@ -126,7 +126,7 @@ class TestElf(unittest.TestCase):
|
||||
section = FakeSection()
|
||||
elf_fname = self.ElfTestFile('u_boot_binman_syms')
|
||||
with self.assertRaises(ValueError) as e:
|
||||
syms = elf.LookupAndWriteSymbols(elf_fname, entry, section)
|
||||
elf.LookupAndWriteSymbols(elf_fname, entry, section)
|
||||
self.assertIn('entry_path has offset 4 (size 8) but the contents size '
|
||||
'is a', str(e.exception))
|
||||
|
||||
@ -139,8 +139,7 @@ class TestElf(unittest.TestCase):
|
||||
entry = FakeEntry(10)
|
||||
section = FakeSection()
|
||||
elf_fname = self.ElfTestFile('u_boot_binman_syms_bad')
|
||||
self.assertEqual(elf.LookupAndWriteSymbols(elf_fname, entry, section),
|
||||
None)
|
||||
elf.LookupAndWriteSymbols(elf_fname, entry, section)
|
||||
|
||||
def testBadSymbolSize(self):
|
||||
"""Test that an attempt to use an 8-bit symbol are detected
|
||||
@ -152,7 +151,7 @@ class TestElf(unittest.TestCase):
|
||||
section = FakeSection()
|
||||
elf_fname =self.ElfTestFile('u_boot_binman_syms_size')
|
||||
with self.assertRaises(ValueError) as e:
|
||||
syms = elf.LookupAndWriteSymbols(elf_fname, entry, section)
|
||||
elf.LookupAndWriteSymbols(elf_fname, entry, section)
|
||||
self.assertIn('has size 1: only 4 and 8 are supported',
|
||||
str(e.exception))
|
||||
|
||||
@ -165,7 +164,7 @@ class TestElf(unittest.TestCase):
|
||||
entry = FakeEntry(24)
|
||||
section = FakeSection(sym_value=None)
|
||||
elf_fname = self.ElfTestFile('u_boot_binman_syms')
|
||||
syms = elf.LookupAndWriteSymbols(elf_fname, entry, section)
|
||||
elf.LookupAndWriteSymbols(elf_fname, entry, section)
|
||||
self.assertEqual(tools.get_bytes(255, 20) + tools.get_bytes(ord('a'), 4),
|
||||
entry.data)
|
||||
|
||||
@ -177,7 +176,7 @@ class TestElf(unittest.TestCase):
|
||||
section = FakeSection()
|
||||
elf_fname = self.ElfTestFile('u_boot_binman_syms')
|
||||
with test_util.capture_sys_output() as (stdout, stderr):
|
||||
syms = elf.LookupAndWriteSymbols(elf_fname, entry, section)
|
||||
elf.LookupAndWriteSymbols(elf_fname, entry, section)
|
||||
self.assertTrue(len(stdout.getvalue()) > 0)
|
||||
finally:
|
||||
tout.init(tout.WARNING)
|
||||
|
@ -19,6 +19,8 @@ from patman import tout
|
||||
|
||||
modules = {}
|
||||
|
||||
# This is imported if needed
|
||||
state = None
|
||||
|
||||
# An argument which can be passed to entries on the command line, in lieu of
|
||||
# device-tree properties.
|
||||
|
@ -5,6 +5,7 @@
|
||||
# Test for the Entry class
|
||||
|
||||
import collections
|
||||
import importlib
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
@ -32,11 +33,7 @@ class TestEntry(unittest.TestCase):
|
||||
def _ReloadEntry(self):
|
||||
global entry
|
||||
if entry:
|
||||
if sys.version_info[0] >= 3:
|
||||
import importlib
|
||||
importlib.reload(entry)
|
||||
else:
|
||||
reload(entry)
|
||||
importlib.reload(entry)
|
||||
else:
|
||||
from binman import entry
|
||||
|
||||
|
@ -8,6 +8,9 @@
|
||||
from binman.entry import Entry
|
||||
from binman.etype.blob import Entry_blob
|
||||
|
||||
# This is imported if needed
|
||||
state = None
|
||||
|
||||
class Entry_blob_dtb(Entry_blob):
|
||||
"""A blob that holds a device tree
|
||||
|
||||
|
@ -7,6 +7,9 @@
|
||||
|
||||
from binman.etype.section import Entry_section
|
||||
|
||||
# This is imported if needed
|
||||
state = None
|
||||
|
||||
class Entry_blob_phase(Entry_section):
|
||||
"""Section that holds a phase binary
|
||||
|
||||
|
@ -12,6 +12,9 @@ from binman.cbfs_util import CbfsWriter
|
||||
from binman.entry import Entry
|
||||
from dtoc import fdt_util
|
||||
|
||||
# This is imported if needed
|
||||
state = None
|
||||
|
||||
class Entry_cbfs(Entry):
|
||||
"""Coreboot Filesystem (CBFS)
|
||||
|
||||
|
@ -15,6 +15,11 @@ from patman import tout
|
||||
FDTMAP_MAGIC = b'_FDTMAP_'
|
||||
FDTMAP_HDR_LEN = 16
|
||||
|
||||
# These is imported if needed
|
||||
Fdt = None
|
||||
libfdt = None
|
||||
state = None
|
||||
|
||||
def LocateFdtmap(data):
|
||||
"""Search an image for an fdt map
|
||||
|
||||
|
@ -13,6 +13,8 @@ from binman.etype.section import Entry_section
|
||||
from dtoc import fdt_util
|
||||
from patman import tools
|
||||
|
||||
# This is imported if needed
|
||||
state = None
|
||||
|
||||
class Entry_files(Entry_section):
|
||||
"""A set of files arranged in a section
|
||||
|
@ -163,6 +163,7 @@ class Entry_section(Entry):
|
||||
self._sort = False
|
||||
self._skip_at_start = None
|
||||
self._end_4gb = False
|
||||
self._ignore_missing = False
|
||||
|
||||
def ReadNode(self):
|
||||
"""Read properties from the section node"""
|
||||
|
@ -9,6 +9,9 @@ from binman.entry import Entry
|
||||
from binman.etype.blob_dtb import Entry_blob_dtb
|
||||
from patman import tools
|
||||
|
||||
# This is imported if needed
|
||||
state = None
|
||||
|
||||
class Entry_u_boot_dtb_with_ucode(Entry_blob_dtb):
|
||||
"""A U-Boot device tree file, with the microcode removed
|
||||
|
||||
|
@ -991,7 +991,7 @@ class TestFunctional(unittest.TestCase):
|
||||
self.assertIn("Section '/binman': Size 0x7 (7) does not match "
|
||||
"align-size 0x8 (8)", str(e.exception))
|
||||
|
||||
def testPackAlignPowerOf2(self):
|
||||
def testPackAlignPowerOf2Inv(self):
|
||||
"""Test that invalid image alignment is detected"""
|
||||
with self.assertRaises(ValueError) as e:
|
||||
self._DoTestFile('020_pack_inv_image_align_power2.dts')
|
||||
@ -3714,7 +3714,7 @@ class TestFunctional(unittest.TestCase):
|
||||
err = stderr.getvalue()
|
||||
self.assertRegex(err, "Image 'main-section'.*missing.*: intel-ifwi")
|
||||
|
||||
def testPackOverlap(self):
|
||||
def testPackOverlapZero(self):
|
||||
"""Test that zero-size overlapping regions are ignored"""
|
||||
self._DoTestFile('160_pack_overlap_zero.dts')
|
||||
|
||||
@ -4095,13 +4095,6 @@ class TestFunctional(unittest.TestCase):
|
||||
self.assertIn("Generator node requires 'fit,fdt-list' property",
|
||||
str(e.exception))
|
||||
|
||||
def testFitFdtEmptyList(self):
|
||||
"""Test handling of an empty 'of-list' entry arg"""
|
||||
entry_args = {
|
||||
'of-list': '',
|
||||
}
|
||||
data = self._DoReadFileDtb('170_fit_fdt.dts', entry_args=entry_args)[0]
|
||||
|
||||
def testFitFdtMissing(self):
|
||||
"""Test handling of a missing 'default-dt' entry arg"""
|
||||
entry_args = {
|
||||
@ -4986,16 +4979,6 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
|
||||
self.assertEqual('rot-cert', fent.fip_type)
|
||||
self.assertEqual(b'aa', fent.data)
|
||||
|
||||
def testFipOther(self):
|
||||
"""Basic FIP with something that isn't a external blob"""
|
||||
data = self._DoReadFile('204_fip_other.dts')
|
||||
hdr, fents = fip_util.decode_fip(data)
|
||||
|
||||
self.assertEqual(2, len(fents))
|
||||
fent = fents[1]
|
||||
self.assertEqual('rot-cert', fent.fip_type)
|
||||
self.assertEqual(b'aa', fent.data)
|
||||
|
||||
def testFipNoType(self):
|
||||
"""FIP with an entry of an unknown type"""
|
||||
with self.assertRaises(ValueError) as e:
|
||||
|
Loading…
Reference in New Issue
Block a user