tools: patman: Convert Python tools to use absolute imports
Subsystems (2)
v2 cover tools: patman: Convert Python tools to use absolute imports
At present the Python tools use relative paths to find modules they use from another tool. This means we need to adjust the sys.path variable at times. It also makes installing the tools (with python setup.py install) more difficult, since once installed the path of the executable (e.g. /usr/bin) is not the same as where the modules are installed (e.g. /usr/local/lib/python3.6/dist-packages).
It is better to use absolute paths. This series makes this adjustment, with 'tools/' as the base directory. Once the tools are installed, things work correctly.
Changes in v2:
- Expand to convert all Python tools in U-Boot
Simon Glass (14):
patman: Rename the main module
rmboard: Move to Python 3
patman: Drop references to __future__
patman: Drop Python 2 StringIO code
buildman: Rename the main module
dtoc: Rename the main module
binman: Rename the main module
Add a 'make tcheck' option to test tools
patman: Drop the python2 code in test coverage
patman: Move test running/reporting to test_util
buildman: Move to absolute imports
binman: Move to absolute imports
patman: Move to absolute imports
patman: Tidy up sys.path changes
Makefile | 6 +-
test/run | 26 ++--
tools/binman/binman | 2 +-
tools/binman/cbfs_util.py | 8 +-
tools/binman/cbfs_util_test.py | 12 +-
tools/binman/control.py | 20 ++-
tools/binman/elf.py | 8 +-
tools/binman/elf_test.py | 10 +-
tools/binman/entry.py | 22 +--
tools/binman/entry_test.py | 12 +-
tools/binman/etype/__init__.py | 0
tools/binman/etype/_testing.py | 6 +-
tools/binman/etype/blob.py | 8 +-
tools/binman/etype/blob_dtb.py | 6 +-
tools/binman/etype/blob_named_by_arg.py | 4 +-
tools/binman/etype/cbfs.py | 10 +-
tools/binman/etype/cros_ec_rw.py | 2 +-
tools/binman/etype/fdtmap.py | 10 +-
tools/binman/etype/files.py | 8 +-
tools/binman/etype/fill.py | 6 +-
tools/binman/etype/fmap.py | 10 +-
tools/binman/etype/gbb.py | 8 +-
tools/binman/etype/image_header.py | 4 +-
tools/binman/etype/intel_cmc.py | 4 +-
tools/binman/etype/intel_descriptor.py | 4 +-
tools/binman/etype/intel_fit.py | 2 +-
tools/binman/etype/intel_fit_ptr.py | 2 +-
tools/binman/etype/intel_fsp.py | 4 +-
tools/binman/etype/intel_fsp_m.py | 4 +-
tools/binman/etype/intel_fsp_s.py | 4 +-
tools/binman/etype/intel_fsp_t.py | 4 +-
tools/binman/etype/intel_ifwi.py | 8 +-
tools/binman/etype/intel_me.py | 4 +-
tools/binman/etype/intel_mrc.py | 4 +-
tools/binman/etype/intel_refcode.py | 4 +-
tools/binman/etype/intel_vbt.py | 4 +-
tools/binman/etype/intel_vga.py | 4 +-
.../etype/powerpc_mpc85xx_bootpg_resetvec.py | 4 +-
tools/binman/etype/section.py | 10 +-
tools/binman/etype/text.py | 6 +-
tools/binman/etype/u_boot.py | 4 +-
tools/binman/etype/u_boot_dtb.py | 4 +-
tools/binman/etype/u_boot_dtb_with_ucode.py | 10 +-
tools/binman/etype/u_boot_elf.py | 8 +-
tools/binman/etype/u_boot_img.py | 4 +-
tools/binman/etype/u_boot_nodtb.py | 4 +-
tools/binman/etype/u_boot_spl.py | 7 +-
tools/binman/etype/u_boot_spl_bss_pad.py | 10 +-
tools/binman/etype/u_boot_spl_dtb.py | 4 +-
tools/binman/etype/u_boot_spl_elf.py | 4 +-
tools/binman/etype/u_boot_spl_nodtb.py | 4 +-
.../binman/etype/u_boot_spl_with_ucode_ptr.py | 6 +-
tools/binman/etype/u_boot_tpl.py | 7 +-
tools/binman/etype/u_boot_tpl_dtb.py | 4 +-
.../binman/etype/u_boot_tpl_dtb_with_ucode.py | 5 +-
tools/binman/etype/u_boot_tpl_elf.py | 4 +-
.../binman/etype/u_boot_tpl_with_ucode_ptr.py | 10 +-
tools/binman/etype/u_boot_ucode.py | 6 +-
tools/binman/etype/u_boot_with_ucode_ptr.py | 12 +-
tools/binman/etype/vblock.py | 6 +-
tools/binman/etype/x86_reset16.py | 4 +-
tools/binman/etype/x86_reset16_spl.py | 4 +-
tools/binman/etype/x86_reset16_tpl.py | 4 +-
tools/binman/etype/x86_start16.py | 4 +-
tools/binman/etype/x86_start16_spl.py | 4 +-
tools/binman/etype/x86_start16_tpl.py | 4 +-
tools/binman/fdt_test.py | 8 +-
tools/binman/fmap_util.py | 2 +-
tools/binman/ftest.py | 49 ++++---
tools/binman/image.py | 18 ++-
tools/binman/image_test.py | 2 +-
tools/binman/{binman.py => main.py} | 110 ++++-----------
tools/binman/state.py | 10 +-
tools/buildman/builder.py | 12 +-
tools/buildman/builderthread.py | 4 +-
tools/buildman/buildman | 2 +-
tools/buildman/control.py | 20 +--
tools/buildman/func_test.py | 18 +--
tools/buildman/{buildman.py => main.py} | 27 ++--
tools/buildman/test.py | 23 ++--
tools/buildman/toolchain.py | 8 +-
tools/dtoc/dtb_platdata.py | 6 +-
tools/dtoc/dtoc | 2 +-
tools/dtoc/fdt.py | 4 +-
tools/dtoc/fdt_util.py | 4 +-
tools/dtoc/{dtoc.py => main.py} | 10 +-
tools/dtoc/test_dtoc.py | 12 +-
tools/dtoc/test_fdt.py | 17 +--
tools/genboardscfg.py | 3 +-
tools/moveconfig.py | 8 +-
tools/patman/checkpatch.py | 8 +-
tools/patman/command.py | 5 +-
tools/patman/func_test.py | 15 +--
tools/patman/get_maintainer.py | 5 +-
tools/patman/gitutil.py | 12 +-
tools/patman/{patman.py => main.py} | 27 ++--
tools/patman/patchstream.py | 8 +-
tools/patman/patman | 2 +-
tools/patman/project.py | 2 +-
tools/patman/series.py | 12 +-
tools/patman/settings.py | 13 +-
tools/patman/terminal.py | 2 -
tools/patman/test.py | 10 +-
tools/patman/test_util.py | 125 ++++++++++++++++--
tools/patman/tools.py | 6 +-
tools/patman/tout.py | 4 +-
tools/rmboard.py | 7 +-
107 files changed, 529 insertions(+), 544 deletions(-)
delete mode 100644 tools/binman/etype/__init__.py
rename tools/binman/{binman.py => main.py} (54%)
rename tools/buildman/{buildman.py => main.py} (76%)
rename tools/dtoc/{dtoc.py => main.py} (94%)
rename tools/patman/{patman.py => main.py} (93%)Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v2 1/14 patman: Rename the main module
Python does not like the module name being the same as the module directory. To allow patman modules to be used from other tools, rename it.
---
Changes in v2: None
tools/patman/{patman.py => main.py} | 27 ++++++++++++++-------------
tools/patman/patman | 2 +-
2 files changed, 15 insertions(+), 14 deletions(-)
rename tools/patman/{patman.py => main.py} (93%)tools/patman/main.py renamed from tools/patman/patman.py +14 -13
@@ -12,19 +12,20 @@ import re import sys import unittest +if __name__ == "__main__": + # Allow 'from patman import xxx to work' + our_path = os.path.dirname(os.path.realpath(__file__)) + sys.path.append(os.path.join(our_path, '..')) + # Our modules -try: - from patman import checkpatch, command, gitutil, patchstream, \ - project, settings, terminal, test -except ImportError: - import checkpatch - import command - import gitutil - import patchstream - import project - import settings - import terminal - import test +from patman import checkpatch +from patman import command +from patman import gitutil +from patman import patchstream +from patman import project +from patman import settings +from patman import terminal +from patman import test parser = OptionParser()
@@ -85,7 +86,7 @@ if __name__ != "__main__": # Run our meagre tests elif options.test: import doctest - import func_test + from patman import func_test sys.argv = [sys.argv[0]] result = unittest.TestResult()
tools/patman/patman +1 -1
@@ -1 +1 @@ -patman.py +main.py
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v2 1/14 patman: Rename the main module
Python does not like the module name being the same as the module directory. To allow patman modules to be used from other tools, rename it.
---
Changes in v2: None
tools/patman/{patman.py => main.py} | 27 ++++++++++++++-------------
tools/patman/patman | 2 +-
2 files changed, 15 insertions(+), 14 deletions(-)
rename tools/patman/{patman.py => main.py} (93%)Applied to u-boot-dm, thanks!
PATCH v2 2/14 rmboard: Move to Python 3
In reply to Simon GlassThis script already works with Python 3. Make it use that by default so that it can import the patman libraries.
---
Changes in v2: None
tools/rmboard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/rmboard.py +1 -1
@@ -1,4 +1,4 @@ -#! /usr/bin/python +#! /usr/bin/python3 # SPDX-License-Identifier: GPL-2.0+ # Copyright 2019 Google LLC #
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v2 2/14 rmboard: Move to Python 3
This script already works with Python 3. Make it use that by default so that it can import the patman libraries.
---
Changes in v2: None
tools/rmboard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm, thanks!
PATCH v2 3/14 patman: Drop references to __future__
In reply to Simon GlassWe don't need these now that the tools using Python 3. Drop them.
---
Changes in v2: None
tools/binman/binman.py | 2 -- tools/binman/cbfs_util.py | 2 -- tools/binman/cbfs_util_test.py | 2 -- tools/binman/control.py | 2 -- tools/binman/elf.py | 2 -- tools/binman/entry.py | 2 -- tools/binman/etype/section.py | 2 -- tools/binman/ftest.py | 2 -- tools/binman/image.py | 2 -- tools/buildman/buildman.py | 2 -- tools/dtoc/dtoc.py | 2 -- tools/dtoc/test_dtoc.py | 2 -- tools/dtoc/test_fdt.py | 2 -- tools/patman/series.py | 2 -- tools/patman/settings.py | 2 -- tools/patman/terminal.py | 2 -- tools/patman/test_util.py | 2 -- tools/patman/tools.py | 2 -- tools/patman/tout.py | 2 -- tools/rmboard.py | 2 -- 20 files changed, 40 deletions(-)
tools/binman/binman.py +0 -2
@@ -9,8 +9,6 @@ """See README for more information""" -from __future__ import print_function - from distutils.sysconfig import get_python_lib import glob import multiprocessing
tools/binman/cbfs_util.py +0 -2
@@ -15,8 +15,6 @@ Currently supported: raw and stage types with compression, padding empty areas with empty files, fixed-offset files """ -from __future__ import print_function - from collections import OrderedDict import io import struct
tools/binman/cbfs_util_test.py +0 -2
@@ -9,8 +9,6 @@ These create and read various CBFSs and compare the results with expected values and with cbfstool """ -from __future__ import print_function - import io import os import shutil
tools/binman/control.py +0 -2
@@ -5,8 +5,6 @@ # Creates binary images from input files controlled by a description # -from __future__ import print_function - from collections import OrderedDict import os import sys
tools/binman/elf.py +0 -2
@@ -5,8 +5,6 @@ # Handle various things related to ELF images # -from __future__ import print_function - from collections import namedtuple, OrderedDict import command import io
tools/binman/entry.py +0 -2
@@ -4,8 +4,6 @@ # Base class for all entries # -from __future__ import print_function - from collections import namedtuple import importlib import os
tools/binman/etype/section.py +0 -2
@@ -8,8 +8,6 @@ Sections are entries which can contain other entries. This allows hierarchical images to be created. """ -from __future__ import print_function - from collections import OrderedDict import re import sys
tools/binman/ftest.py +0 -2
@@ -6,8 +6,6 @@ # # python -m unittest func_test.TestFunctional.testHelp -from __future__ import print_function - import hashlib from optparse import OptionParser import os
tools/binman/image.py +0 -2
@@ -5,8 +5,6 @@ # Class for an image, the output of binman # -from __future__ import print_function - from collections import OrderedDict import fnmatch from operator import attrgetter
tools/buildman/buildman.py +0 -2
@@ -6,8 +6,6 @@ """See README for more information""" -from __future__ import print_function - import multiprocessing import os import re
tools/dtoc/dtoc.py +0 -2
@@ -25,8 +25,6 @@ options. For more information about the use of this options and tool please see doc/driver-model/of-plat.txt """ -from __future__ import print_function - from optparse import OptionParser import os import sys
tools/dtoc/test_dtoc.py +0 -2
@@ -9,8 +9,6 @@ This includes unit tests for some functions and functional tests for the dtoc tool. """ -from __future__ import print_function - import collections import os import struct
tools/dtoc/test_fdt.py +0 -2
@@ -4,8 +4,6 @@ # Written by Simon Glass <[email protected]> # -from __future__ import print_function - from optparse import OptionParser import glob import os
tools/patman/series.py +0 -2
@@ -2,8 +2,6 @@ # Copyright (c) 2011 The Chromium OS Authors. # -from __future__ import print_function - import itertools import os
tools/patman/settings.py +0 -2
@@ -2,8 +2,6 @@ # Copyright (c) 2011 The Chromium OS Authors. # -from __future__ import print_function - try: import configparser as ConfigParser except:
tools/patman/terminal.py +0 -2
@@ -7,8 +7,6 @@ This module handles terminal interaction including ANSI color codes. """ -from __future__ import print_function - import os import re import shutil
tools/patman/test_util.py +0 -2
@@ -3,8 +3,6 @@ # Copyright (c) 2016 Google, Inc # -from __future__ import print_function - from contextlib import contextmanager import glob import os
tools/patman/tools.py +0 -2
@@ -3,8 +3,6 @@ # Copyright (c) 2016 Google, Inc # -from __future__ import print_function - import command import glob import os
tools/patman/tout.py +0 -2
@@ -4,8 +4,6 @@ # Terminal output logging. # -from __future__ import print_function - import sys import terminal
tools/rmboard.py +0 -2
@@ -23,8 +23,6 @@ This script works by: Search for ## to update the commit message manually. """ -from __future__ import print_function - import glob import os import re
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v2 3/14 patman: Drop references to __future__
We don't need these now that the tools using Python 3. Drop them.
---
Changes in v2: None
tools/binman/binman.py | 2 -- tools/binman/cbfs_util.py | 2 -- tools/binman/cbfs_util_test.py | 2 -- tools/binman/control.py | 2 -- tools/binman/elf.py | 2 -- tools/binman/entry.py | 2 -- tools/binman/etype/section.py | 2 -- tools/binman/ftest.py | 2 -- tools/binman/image.py | 2 -- tools/buildman/buildman.py | 2 -- tools/dtoc/dtoc.py | 2 -- tools/dtoc/test_dtoc.py | 2 -- tools/dtoc/test_fdt.py | 2 -- tools/patman/series.py | 2 -- tools/patman/settings.py | 2 -- tools/patman/terminal.py | 2 -- tools/patman/test_util.py | 2 -- tools/patman/tools.py | 2 -- tools/patman/tout.py | 2 -- tools/rmboard.py | 2 -- 20 files changed, 40 deletions(-)
Applied to u-boot-dm, thanks!
PATCH v2 4/14 patman: Drop Python 2 StringIO code
In reply to Simon GlassWe can rely on Python 3 now, so drop the workaround for importing StringIO.
---
Changes in v2: None
tools/patman/func_test.py | 5 +---- tools/patman/settings.py | 5 +---- tools/patman/test_util.py | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-)
tools/patman/func_test.py +1 -4
@@ -12,10 +12,7 @@ import sys import tempfile import unittest -try: - from StringIO import StringIO -except ImportError: - from io import StringIO +from io import StringIO import gitutil import patchstream
tools/patman/settings.py +1 -4
@@ -34,10 +34,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser): - Merge general default settings/aliases with project-specific ones. # Sample config used for tests below... - >>> try: - ... from StringIO import StringIO - ... except ImportError: - ... from io import StringIO + >>> from io import StringIO >>> sample_config = ''' ... [alias] ... me: Peter P. <[email protected]>
tools/patman/test_util.py +1 -4
@@ -10,10 +10,7 @@ import sys import command -try: - from StringIO import StringIO -except ImportError: - from io import StringIO +from io import StringIO PYTHON = 'python%d' % sys.version_info[0]
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v2 4/14 patman: Drop Python 2 StringIO code
We can rely on Python 3 now, so drop the workaround for importing StringIO.
---
Changes in v2: None
tools/patman/func_test.py | 5 +---- tools/patman/settings.py | 5 +---- tools/patman/test_util.py | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-)
Applied to u-boot-dm, thanks!
PATCH v2 5/14 buildman: Rename the main module
In reply to Simon GlassPython does not like the module name being the same as the module directory. To allow buildman modules to be used from other tools, rename it.
---
Changes in v2: None
tools/buildman/buildman | 2 +-
tools/buildman/{buildman.py => main.py} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename tools/buildman/{buildman.py => main.py} (100%)tools/buildman/buildman +1 -1
@@ -1 +1 @@ -buildman.py +main.py
tools/buildman/main.py renamed from tools/buildman/buildman.py +0 -0
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v2 5/14 buildman: Rename the main module
Python does not like the module name being the same as the module directory. To allow buildman modules to be used from other tools, rename it.
---
Changes in v2: None
tools/buildman/buildman | 2 +-
tools/buildman/{buildman.py => main.py} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename tools/buildman/{buildman.py => main.py} (100%)Applied to u-boot-dm, thanks!
PATCH v2 6/14 dtoc: Rename the main module
In reply to Simon GlassPython does not like the module name being the same as the module directory. To allow dtoc modules to be used from other tools, rename it.
---
Changes in v2: None
tools/dtoc/dtoc | 2 +-
tools/dtoc/{dtoc.py => main.py} | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
rename tools/dtoc/{dtoc.py => main.py} (98%)tools/dtoc/dtoc +1 -1
@@ -1 +1 @@ -dtoc.py +main.py
tools/dtoc/main.py renamed from tools/dtoc/dtoc.py +1 -1
@@ -77,7 +77,7 @@ def run_tests(args): def RunTestCoverage(): """Run the tests and check that we get 100% coverage""" sys.argv = [sys.argv[0]] - test_util.RunTestCoverage('tools/dtoc/dtoc.py', '/dtoc.py', + test_util.RunTestCoverage('tools/dtoc/dtoc', '/main.py', ['tools/patman/*.py', '*/fdt*', '*test*'], options.build_dir)
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v2 6/14 dtoc: Rename the main module
Python does not like the module name being the same as the module directory. To allow dtoc modules to be used from other tools, rename it.
---
Changes in v2: None
tools/dtoc/dtoc | 2 +-
tools/dtoc/{dtoc.py => main.py} | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
rename tools/dtoc/{dtoc.py => main.py} (98%)Applied to u-boot-dm, thanks!
PATCH v2 7/14 binman: Rename the main module
In reply to Simon GlassPython does not like the module name being the same as the module directory. To allow buildman modules to be used from other tools, rename it.
---
Changes in v2: None
tools/binman/binman | 2 +-
tools/binman/ftest.py | 6 +++---
tools/binman/{binman.py => main.py} | 4 ++--
tools/patman/test_util.py | 2 +-
4 files changed, 7 insertions(+), 7 deletions(-)
rename tools/binman/{binman.py => main.py} (98%)tools/binman/binman +1 -1
@@ -1 +1 @@ -binman.py +main.py
tools/binman/ftest.py +3 -3
@@ -15,7 +15,7 @@ import sys import tempfile import unittest -import binman +import main import cbfs_util import cmdline import command
@@ -1428,14 +1428,14 @@ class TestFunctional(unittest.TestCase): def testEntryDocs(self): """Test for creation of entry documentation""" with test_util.capture_sys_output() as (stdout, stderr): - control.WriteEntryDocs(binman.GetEntryModules()) + control.WriteEntryDocs(main.GetEntryModules()) self.assertTrue(len(stdout.getvalue()) > 0) def testEntryDocsMissing(self): """Test handling of missing entry documentation""" with self.assertRaises(ValueError) as e: with test_util.capture_sys_output() as (stdout, stderr): - control.WriteEntryDocs(binman.GetEntryModules(), 'u_boot') + control.WriteEntryDocs(main.GetEntryModules(), 'u_boot') self.assertIn('Documentation is missing for modules: u_boot', str(e.exception))
tools/binman/main.py renamed from tools/binman/binman.py +2 -2
@@ -155,8 +155,8 @@ def RunTestCoverage(): glob_list = GetEntryModules(False) all_set = set([os.path.splitext(os.path.basename(item))[0] for item in glob_list if '_testing' not in item]) - test_util.RunTestCoverage('tools/binman/binman.py', None, - ['*test*', '*binman.py', 'tools/patman/*', 'tools/dtoc/*'], + test_util.RunTestCoverage('tools/binman/binman', None, + ['*test*', '*main.py', 'tools/patman/*', 'tools/dtoc/*'], args.build_dir, all_set) def RunBinman(args):
tools/patman/test_util.py +1 -1
@@ -41,7 +41,7 @@ def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None): glob_list = [] glob_list += exclude_list glob_list += ['*libfdt.py', '*site-packages*', '*dist-packages*'] - test_cmd = 'test' if 'binman.py' in prog else '-t' + test_cmd = 'test' if 'binman' in prog else '-t' cmd = ('PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools %s-coverage run ' '--omit "%s" %s %s -P1' % (build_dir, PYTHON, ','.join(glob_list), prog, test_cmd))
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v2 7/14 binman: Rename the main module
Python does not like the module name being the same as the module directory. To allow buildman modules to be used from other tools, rename it.
---
Changes in v2: None
tools/binman/binman | 2 +-
tools/binman/ftest.py | 6 +++---
tools/binman/{binman.py => main.py} | 4 ++--
tools/patman/test_util.py | 2 +-
4 files changed, 7 insertions(+), 7 deletions(-)
rename tools/binman/{binman.py => main.py} (98%)Applied to u-boot-dm, thanks!
PATCH v2 8/14 Add a 'make tcheck' option to test tools
In reply to Simon GlassRunning all the unit tests takes a while and is not useful when you are just modifying the tools. Add an option to run only the tools tests.
---
Changes in v2: None
Makefile | 6 +++++- test/run | 26 ++++++++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-)
Makefile +5 -1
@@ -512,7 +512,7 @@ dt_h := include/generated/dt.h no-dot-config-targets := clean clobber mrproper distclean \ help %docs check% coccicheck \ - ubootversion backup tests check qcheck + ubootversion backup tests check qcheck tcheck config-targets := 0 mixed-targets := 0
@@ -2096,6 +2096,7 @@ help: @echo '' @echo ' check - Run all automated tests that use sandbox' @echo ' qcheck - Run quick automated tests that use sandbox' + @echo ' tcheck - Run quick automated tests on tools' @echo '' @echo 'Other generic targets:' @echo ' all - Build all necessary images depending on configuration'
@@ -2141,6 +2142,9 @@ tests check: qcheck: $(srctree)/test/run quick +tcheck: + $(srctree)/test/run tools + # Documentation targets # --------------------------------------------------------------------------- DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \
test/run +16 -10
@@ -15,22 +15,29 @@ run_test() { # SKip slow tests if requested [ "$1" == "quick" ] && mark_expr="not slow" +[ "$1" == "quick" ] && skip=--skip-net-tests +[ "$1" == "tools" ] && tools_only=y failures=0 -# Run all tests that the standard sandbox build can support -run_test "sandbox" ./test/py/test.py --bd sandbox --build -m "${mark_expr}" +if [ -z "$tools_only" ]; then + # Run all tests that the standard sandbox build can support + run_test "sandbox" ./test/py/test.py --bd sandbox --build \ + -m "${mark_expr}" +fi # Run tests which require sandbox_spl run_test "sandbox_spl" ./test/py/test.py --bd sandbox_spl --build \ - -k 'test_ofplatdata or test_handoff' + -k 'test_ofplatdata or test_handoff' -# Run tests for the flat-device-tree version of sandbox. This is a special -# build which does not enable CONFIG_OF_LIVE for the live device tree, so we can -# check that functionality is the same. The standard sandbox build (above) uses -# CONFIG_OF_LIVE. -run_test "sandbox_flattree" ./test/py/test.py --bd sandbox_flattree --build \ - -k test_ut +if [ -z "$tools_only" ]; then + # Run tests for the flat-device-tree version of sandbox. This is a special + # build which does not enable CONFIG_OF_LIVE for the live device tree, so we can + # check that functionality is the same. The standard sandbox build (above) uses + # CONFIG_OF_LIVE. + run_test "sandbox_flattree" ./test/py/test.py --bd sandbox_flattree \ + --build -k test_ut +fi # Set up a path to dtc (device-tree compiler) and libfdt.py, a library it # provides and which is built by the sandbox_spl config. Also set up the path
@@ -43,7 +50,6 @@ TOOLS_DIR=build-sandbox_spl/tools run_test "binman" ./tools/binman/binman --toolpath ${TOOLS_DIR} test run_test "patman" ./tools/patman/patman --test -[ "$1" == "quick" ] && skip=--skip-net-tests run_test "buildman" ./tools/buildman/buildman -t ${skip} run_test "fdt" ./tools/dtoc/test_fdt -t run_test "dtoc" ./tools/dtoc/dtoc -t
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v2 8/14 Add a 'make tcheck' option to test tools
Running all the unit tests takes a while and is not useful when you are just modifying the tools. Add an option to run only the tools tests.
---
Changes in v2: None
Makefile | 6 +++++- test/run | 26 ++++++++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-)
Applied to u-boot-dm, thanks!
PATCH v2 9/14 patman: Drop the python2 code in test coverage
In reply to Simon GlassWe don't need to run test coverage with Python 2 now. Drop the special-case code.
---
Changes in v2: None
tools/patman/test_util.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
tools/patman/test_util.py +8 -7
@@ -12,8 +12,6 @@ import command from io import StringIO -PYTHON = 'python%d' % sys.version_info[0] - def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None): """Run tests and check that we get 100% coverage
@@ -42,11 +40,14 @@ def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None): glob_list += exclude_list glob_list += ['*libfdt.py', '*site-packages*', '*dist-packages*'] test_cmd = 'test' if 'binman' in prog else '-t' - cmd = ('PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools %s-coverage run ' - '--omit "%s" %s %s -P1' % (build_dir, PYTHON, ','.join(glob_list), + prefix = '' + if build_dir: + prefix = 'PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools ' % build_dir + cmd = ('%spython3-coverage run ' + '--omit "%s" %s %s -P1' % (prefix, ','.join(glob_list), prog, test_cmd)) os.system(cmd) - stdout = command.Output('%s-coverage' % PYTHON, 'report') + stdout = command.Output('python3-coverage', 'report') lines = stdout.splitlines() if required: # Convert '/path/to/name.py' just the module name 'name'
@@ -65,8 +66,8 @@ def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None): print(coverage) if coverage != '100%': print(stdout) - print("Type '%s-coverage html' to get a report in " - 'htmlcov/index.html' % PYTHON) + print("Type 'python3-coverage html' to get a report in " + 'htmlcov/index.html') print('Coverage error: %s, but should be 100%%' % coverage) ok = False if not ok:
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v2 9/14 patman: Drop the python2 code in test coverage
We don't need to run test coverage with Python 2 now. Drop the special-case code.
---
Changes in v2: None
tools/patman/test_util.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
Applied to u-boot-dm, thanks!
PATCH v2 10/14 patman: Move test running/reporting to test_util
In reply to Simon GlassThis code is useful in other tools. Move it into a common file so it can be shared.
---
Changes in v2: None
tools/binman/main.py | 78 +++-------------------------- tools/patman/test_util.py | 100 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 70 deletions(-)
tools/binman/main.py +8 -70
@@ -11,7 +11,6 @@ from distutils.sysconfig import get_python_lib import glob -import multiprocessing import os import site import sys
@@ -37,11 +36,6 @@ sys.path.append(get_python_lib()) import cmdline import command -use_concurrent = True -try: - from concurrencytest import ConcurrentTestSuite, fork_for_tests -except: - use_concurrent = False import control import test_util
@@ -71,73 +65,17 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath): import doctest result = unittest.TestResult() - for module in []: - suite = doctest.DocTestSuite(module) - suite.run(result) - - sys.argv = [sys.argv[0]] - if debug: - sys.argv.append('-D') - if verbosity: - sys.argv.append('-v%d' % verbosity) - if toolpath: - for path in toolpath: - sys.argv += ['--toolpath', path] + test_name = args and args[0] or None # Run the entry tests first ,since these need to be the first to import the # 'entry' module. - test_name = args and args[0] or None - suite = unittest.TestSuite() - loader = unittest.TestLoader() - for module in (entry_test.TestEntry, ftest.TestFunctional, fdt_test.TestFdt, - elf_test.TestElf, image_test.TestImage, - cbfs_util_test.TestCbfs): - # Test the test module about our arguments, if it is interested - if hasattr(module, 'setup_test_args'): - setup_test_args = getattr(module, 'setup_test_args') - setup_test_args(preserve_indir=test_preserve_dirs, - preserve_outdirs=test_preserve_dirs and test_name is not None, - toolpath=toolpath, verbosity=verbosity) - if test_name: - try: - suite.addTests(loader.loadTestsFromName(test_name, module)) - except AttributeError: - continue - else: - suite.addTests(loader.loadTestsFromTestCase(module)) - if use_concurrent and processes != 1: - concurrent_suite = ConcurrentTestSuite(suite, - fork_for_tests(processes or multiprocessing.cpu_count())) - concurrent_suite.run(result) - else: - suite.run(result) - - # Remove errors which just indicate a missing test. Since Python v3.5 If an - # ImportError or AttributeError occurs while traversing name then a - # synthetic test that raises that error when run will be returned. These - # errors are included in the errors accumulated by result.errors. - if test_name: - errors = [] - for test, err in result.errors: - if ("has no attribute '%s'" % test_name) not in err: - errors.append((test, err)) - result.testsRun -= 1 - result.errors = errors - - print(result) - for test, err in result.errors: - print(test.id(), err) - for test, err in result.failures: - print(err, result.failures) - if result.skipped: - print('%d binman test%s SKIPPED:' % - (len(result.skipped), 's' if len(result.skipped) > 1 else '')) - for skip_info in result.skipped: - print('%s: %s' % (skip_info[0], skip_info[1])) - if result.errors or result.failures: - print('binman tests FAILED') - return 1 - return 0 + test_util.RunTestSuites( + result, debug, verbosity, test_preserve_dirs, processes, test_name, + toolpath, + [entry_test.TestEntry, ftest.TestFunctional, fdt_test.TestFdt, + elf_test.TestElf, image_test.TestImage, cbfs_util_test.TestCbfs]) + + return test_util.ReportResult('binman', test_name, result) def GetEntryModules(include_testing=True): """Get a set of entry class implementations
tools/patman/test_util.py +100 -0
116 lines not on this page · raw message
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v2 10/14 patman: Move test running/reporting to test_util
This code is useful in other tools. Move it into a common file so it can be shared.
---
Changes in v2: None
tools/binman/main.py | 78 +++-------------------------- tools/patman/test_util.py | 100 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 70 deletions(-)
Applied to u-boot-dm, thanks!
PATCH v2 11/14 buildman: Move to absolute imports
In reply to Simon GlassAt present buildman sets the python path on startup so that it can access the libraries it needs. If we convert to use absolute imports this is not necessary.
Move buildman to use absolute imports. Also adjust moveconfig.py too since it uses some buildman modules and cannot work without this.
---
Changes in v2: None
tools/buildman/builder.py | 4 ++-- tools/buildman/control.py | 12 ++++++------ tools/buildman/func_test.py | 9 +++++---- tools/buildman/main.py | 20 ++++++++++---------- tools/buildman/test.py | 12 ++++++------ tools/buildman/toolchain.py | 2 +- tools/moveconfig.py | 8 ++++---- 7 files changed, 34 insertions(+), 33 deletions(-)
tools/buildman/builder.py +2 -2
@@ -17,12 +17,12 @@ import sys import threading import time -import builderthread +from buildman import builderthread +from buildman import toolchain import command import gitutil import terminal from terminal import Print -import toolchain """ Theory of Operation
tools/buildman/control.py +6 -6
@@ -5,18 +5,18 @@ import multiprocessing import os import shutil +import subprocess import sys -import board -import bsettings -from builder import Builder +from buildman import board +from buildman import bsettings +from buildman import toolchain +from buildman.builder import Builder +import command import gitutil import patchstream import terminal from terminal import Print -import toolchain -import command -import subprocess def GetPlural(count): """Returns a plural 's' if count is not 1"""
tools/buildman/func_test.py +5 -4
@@ -8,11 +8,12 @@ import sys import tempfile import unittest -import board -import bsettings -import cmdline +from buildman import board +from buildman import bsettings +from buildman import cmdline +from buildman import control +from buildman import toolchain import command -import control import gitutil import terminal import toolchain
tools/buildman/main.py +10 -10
@@ -6,6 +6,7 @@ """See README for more information""" +import doctest import multiprocessing import os import re
@@ -14,20 +15,19 @@ import unittest # Bring in the patman libraries our_path = os.path.dirname(os.path.realpath(__file__)) -sys.path.insert(1, os.path.join(our_path, '../patman')) +sys.path.insert(1, os.path.join(our_path, '..')) +sys.path.insert(2, os.path.join(our_path, '../patman')) # Our modules -import board -import bsettings -import builder -import checkpatch -import cmdline -import control -import doctest -import gitutil +from buildman import board +from buildman import bsettings +from buildman import builder +from buildman import cmdline +from buildman import control +from buildman import toolchain import patchstream +import gitutil import terminal -import toolchain def RunTests(skip_net_tests): import func_test
tools/buildman/test.py +6 -6
@@ -13,15 +13,15 @@ import unittest our_path = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(our_path, '../patman')) -import board -import bsettings -import builder -import control -import command +from buildman import board +from buildman import bsettings +from buildman import builder +from buildman import control +from buildman import toolchain import commit +import command import terminal import test_util -import toolchain import tools use_network = True
tools/buildman/toolchain.py +1 -1
@@ -10,7 +10,7 @@ import sys import tempfile import urllib.request, urllib.error, urllib.parse -import bsettings +from buildman import bsettings import command import terminal import tools
tools/moveconfig.py +4 -4
@@ -314,11 +314,11 @@ import tempfile import threading import time -sys.path.append(os.path.join(os.path.dirname(__file__), 'buildman')) +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) sys.path.append(os.path.join(os.path.dirname(__file__), 'patman')) -import bsettings -import kconfiglib -import toolchain +from buildman import bsettings +from buildman import kconfiglib +from buildman import toolchain SHOW_GNU_MAKE = 'scripts/show-gnu-make' SLEEP_TIME=0.03
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v2 11/14 buildman: Move to absolute imports
At present buildman sets the python path on startup so that it can access the libraries it needs. If we convert to use absolute imports this is not necessary.
Move buildman to use absolute imports. Also adjust moveconfig.py too since it uses some buildman modules and cannot work without this.
---
Changes in v2: None
tools/buildman/builder.py | 4 ++-- tools/buildman/control.py | 12 ++++++------ tools/buildman/func_test.py | 9 +++++---- tools/buildman/main.py | 20 ++++++++++---------- tools/buildman/test.py | 12 ++++++------ tools/buildman/toolchain.py | 2 +- tools/moveconfig.py | 8 ++++---- 7 files changed, 34 insertions(+), 33 deletions(-)
Applied to u-boot-dm, thanks!
PATCH v2 12/14 binman: Move to absolute imports
In reply to Simon GlassAt present binman sets the python path on startup so that it can access the libraries it needs. If we convert to use absolute imports this is not necessary.
Move binman to use absolute imports. This enables removable of the path adjusting in Entry also.
---
Changes in v2: None
tools/binman/cbfs_util.py | 2 +- tools/binman/cbfs_util_test.py | 6 +-- tools/binman/control.py | 12 +++--- tools/binman/elf.py | 2 +- tools/binman/elf_test.py | 2 +- tools/binman/entry.py | 16 +++----- tools/binman/entry_test.py | 10 ++--- tools/binman/etype/__init__.py | 0 tools/binman/etype/_testing.py | 4 +- tools/binman/etype/blob.py | 4 +- tools/binman/etype/blob_dtb.py | 6 +-- tools/binman/etype/blob_named_by_arg.py | 4 +- tools/binman/etype/cbfs.py | 10 ++--- tools/binman/etype/cros_ec_rw.py | 2 +- tools/binman/etype/fdtmap.py | 6 +-- tools/binman/etype/files.py | 6 +-- tools/binman/etype/fill.py | 4 +- tools/binman/etype/fmap.py | 6 +-- tools/binman/etype/gbb.py | 4 +- tools/binman/etype/image_header.py | 4 +- tools/binman/etype/intel_cmc.py | 4 +- tools/binman/etype/intel_descriptor.py | 4 +- tools/binman/etype/intel_fit.py | 2 +- tools/binman/etype/intel_fit_ptr.py | 2 +- tools/binman/etype/intel_fsp.py | 4 +- tools/binman/etype/intel_fsp_m.py | 4 +- tools/binman/etype/intel_fsp_s.py | 4 +- tools/binman/etype/intel_fsp_t.py | 4 +- tools/binman/etype/intel_ifwi.py | 6 +-- tools/binman/etype/intel_me.py | 4 +- tools/binman/etype/intel_mrc.py | 4 +- tools/binman/etype/intel_refcode.py | 4 +- tools/binman/etype/intel_vbt.py | 4 +- tools/binman/etype/intel_vga.py | 4 +- .../etype/powerpc_mpc85xx_bootpg_resetvec.py | 4 +- tools/binman/etype/section.py | 4 +- tools/binman/etype/text.py | 4 +- tools/binman/etype/u_boot.py | 4 +- tools/binman/etype/u_boot_dtb.py | 4 +- tools/binman/etype/u_boot_dtb_with_ucode.py | 8 ++-- tools/binman/etype/u_boot_elf.py | 6 +-- tools/binman/etype/u_boot_img.py | 4 +- tools/binman/etype/u_boot_nodtb.py | 4 +- tools/binman/etype/u_boot_spl.py | 7 ++-- tools/binman/etype/u_boot_spl_bss_pad.py | 6 +-- tools/binman/etype/u_boot_spl_dtb.py | 4 +- tools/binman/etype/u_boot_spl_elf.py | 4 +- tools/binman/etype/u_boot_spl_nodtb.py | 4 +- .../binman/etype/u_boot_spl_with_ucode_ptr.py | 6 +-- tools/binman/etype/u_boot_tpl.py | 7 ++-- tools/binman/etype/u_boot_tpl_dtb.py | 4 +- .../binman/etype/u_boot_tpl_dtb_with_ucode.py | 5 +-- tools/binman/etype/u_boot_tpl_elf.py | 4 +- .../binman/etype/u_boot_tpl_with_ucode_ptr.py | 6 +-- tools/binman/etype/u_boot_ucode.py | 4 +- tools/binman/etype/u_boot_with_ucode_ptr.py | 10 ++--- tools/binman/etype/vblock.py | 4 +- tools/binman/etype/x86_reset16.py | 4 +- tools/binman/etype/x86_reset16_spl.py | 4 +- tools/binman/etype/x86_reset16_tpl.py | 4 +- tools/binman/etype/x86_start16.py | 4 +- tools/binman/etype/x86_start16_spl.py | 4 +- tools/binman/etype/x86_start16_tpl.py | 4 +- tools/binman/fdt_test.py | 6 +-- tools/binman/ftest.py | 37 ++++++++++--------- tools/binman/image.py | 12 +++--- tools/binman/image_test.py | 2 +- tools/binman/main.py | 23 ++++++------ tools/binman/state.py | 6 +-- tools/patman/main.py | 20 +++++----- 70 files changed, 198 insertions(+), 213 deletions(-) delete mode 100644 tools/binman/etype/__init__.py
tools/binman/cbfs_util.py +1 -1
@@ -20,8 +20,8 @@ import io import struct import sys +from binman import elf import command -import elf import tools # Set to True to enable printing output while working
tools/binman/cbfs_util_test.py +3 -3
@@ -16,9 +16,9 @@ import struct import tempfile import unittest -import cbfs_util -from cbfs_util import CbfsWriter -import elf +from binman import cbfs_util +from binman.cbfs_util import CbfsWriter +from binman import elf import test_util import tools
tools/binman/control.py +6 -6
@@ -10,9 +10,9 @@ import os import sys import tools -import cbfs_util +from binman import cbfs_util +from binman import elf import command -import elf import tout # List of images we plan to create
@@ -60,7 +60,7 @@ def WriteEntryDocs(modules, test_missing=None): to show as missing even if it is present. Should be set to None in normal use. """ - from entry import Entry + from binman.entry import Entry Entry.WriteDocs(modules, test_missing)
@@ -334,8 +334,8 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt): """ # Import these here in case libfdt.py is not available, in which case # the above help option still works. - import fdt - import fdt_util + from dtoc import fdt + from dtoc import fdt_util global images # Get the device tree ready by compiling it and copying the compiled
@@ -473,7 +473,7 @@ def Binman(args): # Put these here so that we can import this module without libfdt from image import Image - import state + from binman import state if args.cmd in ['ls', 'extract', 'replace']: try:
tools/binman/elf.py +1 -1
@@ -6,7 +6,6 @@ # from collections import namedtuple, OrderedDict -import command import io import os import re
@@ -14,6 +13,7 @@ import shutil import struct import tempfile +import command import tools import tout
tools/binman/elf_test.py +1 -1
@@ -10,8 +10,8 @@ import sys import tempfile import unittest +from binman import elf import command -import elf import test_util import tools import tout
tools/binman/entry.py +5 -11
@@ -9,9 +9,9 @@ import importlib import os import sys -import fdt_util +from dtoc import fdt_util import tools -from tools import ToHex, ToHexSize +from patman.tools import ToHex, ToHexSize import tout modules = {}
@@ -63,7 +63,7 @@ class Entry(object): def __init__(self, section, etype, node, name_prefix=''): # Put this here to allow entry-docs and help to work without libfdt global state - import state + from binman import state self.section = section self.etype = etype
@@ -108,15 +108,11 @@ class Entry(object): # Import the module if we have not already done so. if not module: - old_path = sys.path - sys.path.insert(0, os.path.join(our_path, 'etype')) try: - module = importlib.import_module(module_name) + module = importlib.import_module('binman.etype.' + module_name) except ImportError as e: raise ValueError("Unknown entry type '%s' in node '%s' (expected etype/%s.py, error '%s'" % (etype, node_path, module_name, e)) - finally: - sys.path = old_path modules[module_name] = module # Look up the expected class name
@@ -590,9 +586,7 @@ features to produce new behaviours. modules.remove('_testing') missing = [] for name in modules: - if name.startswith('__'): - continue - module = Entry.Lookup(name, name) + module = Entry.Lookup('WriteDocs', name) docs = getattr(module, '__doc__') if test_missing == name: docs = None
tools/binman/entry_test.py +5 -5
@@ -9,9 +9,9 @@ import os import sys import unittest -import entry -import fdt -import fdt_util +from binman import entry +from dtoc import fdt +from dtoc import fdt_util import tools class TestEntry(unittest.TestCase):
@@ -37,11 +37,11 @@ class TestEntry(unittest.TestCase): else: reload(entry) else: - import entry + from binman import entry def testEntryContents(self): """Test the Entry bass class""" - import entry + from binman import entry base_entry = entry.Entry(None, None, None) self.assertEqual(True, base_entry.ObtainContents())
tools/binman/etype/__init__.py deleted +0 -0
tools/binman/etype/_testing.py +2 -2
@@ -7,8 +7,8 @@ from collections import OrderedDict -from entry import Entry, EntryArg -import fdt_util +from binman.entry import Entry, EntryArg +from dtoc import fdt_util import tools
tools/binman/etype/blob.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for blobs, which are binary objects read from files # -from entry import Entry -import fdt_util +from binman.entry import Entry +from dtoc import fdt_util import tools import tout
tools/binman/etype/blob_dtb.py +3 -3
@@ -5,8 +5,8 @@ # Entry-type module for U-Boot device tree files # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_blob_dtb(Entry_blob): """A blob that holds a device tree
@@ -18,7 +18,7 @@ class Entry_blob_dtb(Entry_blob): def __init__(self, section, etype, node): # Put this here to allow entry-docs and help to work without libfdt global state - import state + from binman import state Entry_blob.__init__(self, section, etype, node)
tools/binman/etype/blob_named_by_arg.py +2 -2
@@ -8,8 +8,8 @@ from collections import OrderedDict -from blob import Entry_blob -from entry import EntryArg +from binman.etype.blob import Entry_blob +from binman.entry import EntryArg class Entry_blob_named_by_arg(Entry_blob):
tools/binman/etype/cbfs.py +5 -5
@@ -7,10 +7,10 @@ from collections import OrderedDict -import cbfs_util -from cbfs_util import CbfsWriter -from entry import Entry -import fdt_util +from binman import cbfs_util +from binman.cbfs_util import CbfsWriter +from binman.entry import Entry +from dtoc import fdt_util class Entry_cbfs(Entry): """Entry containing a Coreboot Filesystem (CBFS)
@@ -165,7 +165,7 @@ class Entry_cbfs(Entry): def __init__(self, section, etype, node): # Put this here to allow entry-docs and help to work without libfdt global state - import state + from binman import state Entry.__init__(self, section, etype, node) self._cbfs_arg = fdt_util.GetString(node, 'cbfs-arch', 'x86')
tools/binman/etype/cros_ec_rw.py +1 -1
@@ -5,7 +5,7 @@ # Entry-type module for a Chromium OS EC image (read-write section) # -from blob_named_by_arg import Entry_blob_named_by_arg +from binman.etype.blob_named_by_arg import Entry_blob_named_by_arg class Entry_cros_ec_rw(Entry_blob_named_by_arg):
tools/binman/etype/fdtmap.py +3 -3
@@ -8,7 +8,7 @@ This handles putting an FDT into the image with just the information about the image. """ -from entry import Entry +from binman.entry import Entry import tools import tout
@@ -82,8 +82,8 @@ class Entry_fdtmap(Entry): global Fdt import libfdt - import state - from fdt import Fdt + from binman import state + from dtoc.fdt import Fdt Entry.__init__(self, section, etype, node)
tools/binman/etype/files.py +3 -3
@@ -9,8 +9,8 @@ import glob import os -from section import Entry_section -import fdt_util +from binman.etype.section import Entry_section +from dtoc import fdt_util import tools
@@ -30,7 +30,7 @@ class Entry_files(Entry_section): def __init__(self, section, etype, node): # Put this here to allow entry-docs and help to work without libfdt global state - import state + from binman import state Entry_section.__init__(self, section, etype, node) self._pattern = fdt_util.GetString(self._node, 'pattern')
tools/binman/etype/fill.py +2 -2
@@ -3,8 +3,8 @@ # Written by Simon Glass <[email protected]> # -from entry import Entry -import fdt_util +from binman.entry import Entry +from dtoc import fdt_util import tools class Entry_fill(Entry):
tools/binman/etype/fmap.py +3 -3
@@ -5,10 +5,10 @@ # Entry-type module for a Flash map, as used by the flashrom SPI flash tool # -from entry import Entry -import fmap_util +from binman.entry import Entry +from binman import fmap_util import tools -from tools import ToHexSize +from patman.tools import ToHexSize import tout
tools/binman/etype/gbb.py +2 -2
@@ -9,9 +9,9 @@ from collections import OrderedDict import command -from entry import Entry, EntryArg +from binman.entry import Entry, EntryArg -import fdt_util +from dtoc import fdt_util import tools # Build GBB flags.
tools/binman/etype/image_header.py +2 -2
@@ -11,8 +11,8 @@ image. import struct -from entry import Entry -import fdt_util +from binman.entry import Entry +from dtoc import fdt_util IMAGE_HEADER_MAGIC = b'BinM' IMAGE_HEADER_LEN = 8
tools/binman/etype/intel_cmc.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for Intel Chip Microcode binary blob # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_intel_cmc(Entry_blob): """Entry containing an Intel Chipset Micro Code (CMC) file
tools/binman/etype/intel_descriptor.py +2 -2
@@ -7,8 +7,8 @@ import struct -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob FD_SIGNATURE = struct.pack('<L', 0x0ff0a55a) MAX_REGIONS = 5
tools/binman/etype/intel_fit.py +1 -1
@@ -7,7 +7,7 @@ import struct -from blob import Entry_blob +from binman.etype.blob import Entry_blob class Entry_intel_fit(Entry_blob): """Intel Firmware Image Table (FIT)
tools/binman/etype/intel_fit_ptr.py +1 -1
@@ -7,7 +7,7 @@ import struct -from blob import Entry_blob +from binman.etype.blob import Entry_blob class Entry_intel_fit_ptr(Entry_blob): """Intel Firmware Image Table (FIT) pointer
tools/binman/etype/intel_fsp.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for Intel Firmware Support Package binary blob # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_intel_fsp(Entry_blob): """Entry containing an Intel Firmware Support Package (FSP) file
tools/binman/etype/intel_fsp_m.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for Intel Firmware Support Package binary blob (M section) # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_intel_fsp_m(Entry_blob): """Entry containing Intel Firmware Support Package (FSP) memory init
tools/binman/etype/intel_fsp_s.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for Intel Firmware Support Package binary blob (S section) # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_intel_fsp_s(Entry_blob): """Entry containing Intel Firmware Support Package (FSP) silicon init
tools/binman/etype/intel_fsp_t.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for Intel Firmware Support Package binary blob (T section) # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_intel_fsp_t(Entry_blob): """Entry containing Intel Firmware Support Package (FSP) temp ram init
tools/binman/etype/intel_ifwi.py +3 -3
@@ -7,9 +7,9 @@ from collections import OrderedDict -from entry import Entry -from blob import Entry_blob -import fdt_util +from binman.entry import Entry +from binman.etype.blob import Entry_blob +from dtoc import fdt_util import tools class Entry_intel_ifwi(Entry_blob):
tools/binman/etype/intel_me.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for Intel Management Engine binary blob # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_intel_me(Entry_blob): """Entry containing an Intel Management Engine (ME) file
tools/binman/etype/intel_mrc.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for Intel Memory Reference Code binary blob # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_intel_mrc(Entry_blob): """Entry containing an Intel Memory Reference Code (MRC) file
tools/binman/etype/intel_refcode.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for Intel Memory Reference Code binary blob # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_intel_refcode(Entry_blob): """Entry containing an Intel Reference Code file
tools/binman/etype/intel_vbt.py +2 -2
@@ -4,8 +4,8 @@ # Entry-type module for Intel Video BIOS Table binary blob # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_intel_vbt(Entry_blob): """Entry containing an Intel Video BIOS Table (VBT) file
tools/binman/etype/intel_vga.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for x86 VGA ROM binary blob # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_intel_vga(Entry_blob): """Entry containing an Intel Video Graphics Adaptor (VGA) file
tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py +2 -2
@@ -4,8 +4,8 @@ # Entry-type module for the PowerPC mpc85xx bootpg and resetvec code for U-Boot # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_powerpc_mpc85xx_bootpg_resetvec(Entry_blob): """PowerPC mpc85xx bootpg + resetvec code for U-Boot
tools/binman/etype/section.py +2 -2
@@ -12,8 +12,8 @@ from collections import OrderedDict import re import sys -from entry import Entry -import fdt_util +from binman.entry import Entry +from dtoc import fdt_util import tools import tout
tools/binman/etype/text.py +2 -2
@@ -5,8 +5,8 @@ from collections import OrderedDict -from entry import Entry, EntryArg -import fdt_util +from binman.entry import Entry, EntryArg +from dtoc import fdt_util import tools
tools/binman/etype/u_boot.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for U-Boot binary # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_u_boot(Entry_blob): """U-Boot flat binary
tools/binman/etype/u_boot_dtb.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for U-Boot device tree # -from entry import Entry -from blob_dtb import Entry_blob_dtb +from binman.entry import Entry +from binman.etype.blob_dtb import Entry_blob_dtb class Entry_u_boot_dtb(Entry_blob_dtb): """U-Boot device tree
tools/binman/etype/u_boot_dtb_with_ucode.py +4 -4
@@ -5,8 +5,8 @@ # Entry-type module for U-Boot device tree with the microcode removed # -from entry import Entry -from blob_dtb import Entry_blob_dtb +from binman.entry import Entry +from binman.etype.blob_dtb import Entry_blob_dtb import tools class Entry_u_boot_dtb_with_ucode(Entry_blob_dtb):
@@ -26,7 +26,7 @@ class Entry_u_boot_dtb_with_ucode(Entry_blob_dtb): def __init__(self, section, etype, node): # Put this here to allow entry-docs and help to work without libfdt global state - import state + from binman import state Entry_blob_dtb.__init__(self, section, etype, node) self.ucode_data = b''
@@ -44,7 +44,7 @@ class Entry_u_boot_dtb_with_ucode(Entry_blob_dtb): def ProcessFdt(self, fdt): # So the module can be loaded without it - import fdt + from dtoc import fdt # If the section does not need microcode, there is nothing to do ucode_dest_entry = self.section.FindEntryType(
tools/binman/etype/u_boot_elf.py +3 -3
@@ -5,10 +5,10 @@ # Entry-type module for U-Boot ELF image # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob -import fdt_util +from dtoc import fdt_util import tools class Entry_u_boot_elf(Entry_blob):
tools/binman/etype/u_boot_img.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for U-Boot binary # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_u_boot_img(Entry_blob): """U-Boot legacy image
tools/binman/etype/u_boot_nodtb.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for 'u-boot-nodtb.bin' # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_u_boot_nodtb(Entry_blob): """U-Boot flat binary without device tree appended
tools/binman/etype/u_boot_spl.py +3 -4
@@ -5,10 +5,9 @@ # Entry-type module for spl/u-boot-spl.bin # -import elf - -from entry import Entry -from blob import Entry_blob +from binman import elf +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_u_boot_spl(Entry_blob): """U-Boot SPL binary
tools/binman/etype/u_boot_spl_bss_pad.py +3 -3
@@ -7,10 +7,10 @@ # to it will appear to SPL to be@the end of BSS rather than the start. # +from binman import elf +from binman.entry import Entry import command -import elf -from entry import Entry -from blob import Entry_blob +from binman.etype.blob import Entry_blob import tools class Entry_u_boot_spl_bss_pad(Entry_blob):
tools/binman/etype/u_boot_spl_dtb.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for U-Boot device tree in SPL (Secondary Program Loader) # -from entry import Entry -from blob_dtb import Entry_blob_dtb +from binman.entry import Entry +from binman.etype.blob_dtb import Entry_blob_dtb class Entry_u_boot_spl_dtb(Entry_blob_dtb): """U-Boot SPL device tree
tools/binman/etype/u_boot_spl_elf.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for U-Boot SPL ELF image # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_u_boot_spl_elf(Entry_blob): """U-Boot SPL ELF image
tools/binman/etype/u_boot_spl_nodtb.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for 'u-boot-nodtb.bin' # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_u_boot_spl_nodtb(Entry_blob): """SPL binary without device tree appended
tools/binman/etype/u_boot_spl_with_ucode_ptr.py +1 -5
@@ -7,11 +7,7 @@ import struct -import command -from entry import Entry -from blob import Entry_blob -from u_boot_with_ucode_ptr import Entry_u_boot_with_ucode_ptr -import tools +from binman.etype.u_boot_with_ucode_ptr import Entry_u_boot_with_ucode_ptr class Entry_u_boot_spl_with_ucode_ptr(Entry_u_boot_with_ucode_ptr): """U-Boot SPL with embedded microcode pointer
tools/binman/etype/u_boot_tpl.py +3 -4
@@ -5,10 +5,9 @@ # Entry-type module for tpl/u-boot-tpl.bin # -import elf - -from entry import Entry -from blob import Entry_blob +from binman import elf +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_u_boot_tpl(Entry_blob): """U-Boot TPL binary
tools/binman/etype/u_boot_tpl_dtb.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for U-Boot device tree in TPL (Tertiary Program Loader) # -from entry import Entry -from blob_dtb import Entry_blob_dtb +from binman.entry import Entry +from binman.etype.blob_dtb import Entry_blob_dtb class Entry_u_boot_tpl_dtb(Entry_blob_dtb): """U-Boot TPL device tree
tools/binman/etype/u_boot_tpl_dtb_with_ucode.py +1 -4
@@ -5,10 +5,7 @@ # Entry-type module for U-Boot device tree with the microcode removed # -import control -from entry import Entry -from u_boot_dtb_with_ucode import Entry_u_boot_dtb_with_ucode -import tools +from binman.etype.u_boot_dtb_with_ucode import Entry_u_boot_dtb_with_ucode class Entry_u_boot_tpl_dtb_with_ucode(Entry_u_boot_dtb_with_ucode): """U-Boot TPL with embedded microcode pointer
tools/binman/etype/u_boot_tpl_elf.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for U-Boot TPL ELF image # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_u_boot_tpl_elf(Entry_blob): """U-Boot TPL ELF image
tools/binman/etype/u_boot_tpl_with_ucode_ptr.py +3 -3
@@ -8,9 +8,9 @@ import struct import command -from entry import Entry -from blob import Entry_blob -from u_boot_with_ucode_ptr import Entry_u_boot_with_ucode_ptr +from binman.entry import Entry +from binman.etype.blob import Entry_blob +from binman.etype.u_boot_with_ucode_ptr import Entry_u_boot_with_ucode_ptr import tools class Entry_u_boot_tpl_with_ucode_ptr(Entry_u_boot_with_ucode_ptr):
tools/binman/etype/u_boot_ucode.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for a U-Boot binary with an embedded microcode pointer # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob import tools class Entry_u_boot_ucode(Entry_blob):
tools/binman/etype/u_boot_with_ucode_ptr.py +5 -5
@@ -7,12 +7,12 @@ import struct -import command -import elf -from entry import Entry -from blob import Entry_blob -import fdt_util +from binman import elf +from binman.entry import Entry +from binman.etype.blob import Entry_blob +from dtoc import fdt_util import tools +import command class Entry_u_boot_with_ucode_ptr(Entry_blob): """U-Boot with embedded microcode pointer
tools/binman/etype/vblock.py +2 -2
@@ -9,9 +9,9 @@ from collections import OrderedDict import os -from entry import Entry, EntryArg +from binman.entry import Entry, EntryArg -import fdt_util +from dtoc import fdt_util import tools class Entry_vblock(Entry):
tools/binman/etype/x86_reset16.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for the 16-bit x86 reset code for U-Boot # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_x86_reset16(Entry_blob): """x86 16-bit reset code for U-Boot
tools/binman/etype/x86_reset16_spl.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for the 16-bit x86 reset code for U-Boot # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_x86_reset16_spl(Entry_blob): """x86 16-bit reset code for U-Boot
tools/binman/etype/x86_reset16_tpl.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for the 16-bit x86 reset code for U-Boot # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_x86_reset16_tpl(Entry_blob): """x86 16-bit reset code for U-Boot
tools/binman/etype/x86_start16.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for the 16-bit x86 start-up code for U-Boot # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_x86_start16(Entry_blob): """x86 16-bit start-up code for U-Boot
tools/binman/etype/x86_start16_spl.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for the 16-bit x86 start-up code for U-Boot SPL # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_x86_start16_spl(Entry_blob): """x86 16-bit start-up code for SPL
tools/binman/etype/x86_start16_tpl.py +2 -2
@@ -5,8 +5,8 @@ # Entry-type module for the 16-bit x86 start-up code for U-Boot TPL # -from entry import Entry -from blob import Entry_blob +from binman.entry import Entry +from binman.etype.blob import Entry_blob class Entry_x86_start16_tpl(Entry_blob): """x86 16-bit start-up code for TPL
tools/binman/fdt_test.py +3 -3
@@ -9,9 +9,9 @@ import sys import tempfile import unittest -import fdt -from fdt import FdtScan -import fdt_util +from dtoc import fdt +from dtoc import fdt_util +from dtoc.fdt import FdtScan import tools class TestFdt(unittest.TestCase):
tools/binman/ftest.py +19 -18
@@ -6,6 +6,7 @@ # # python -m unittest func_test.TestFunctional.testHelp +import gzip import hashlib from optparse import OptionParser import os
@@ -15,22 +16,21 @@ import sys import tempfile import unittest -import main -import cbfs_util -import cmdline +from binman import cbfs_util +from binman import cmdline +from binman import control +from binman import elf +from binman import elf_test +from binman import fmap_util +from binman import main +from binman import state +from dtoc import fdt +from dtoc import fdt_util +from binman.etype import fdtmap +from binman.etype import image_header +from image import Image import command -import control -import elf -import elf_test -import fdt -from etype import fdtmap -from etype import image_header -import fdt_util -import fmap_util import test_util -import gzip -from image import Image -import state import tools import tout
@@ -101,7 +101,7 @@ class TestFunctional(unittest.TestCase): @classmethod def setUpClass(cls): global entry - import entry + from binman import entry # Handle the case where argv[0] is 'python' cls._binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
@@ -1288,8 +1288,8 @@ class TestFunctional(unittest.TestCase): with self.assertRaises(ValueError) as e: self._DoReadFile('057_unknown_contents.dts', True) self.assertIn("Image '/binman': Internal error: Could not complete " - "processing of contents: remaining [<_testing.Entry__testing ", - str(e.exception)) + "processing of contents: remaining [" + "<binman.etype._testing.Entry__testing ", str(e.exception)) def testBadChangeSize(self): """Test that trying to change the size of an entry fails"""
@@ -1336,7 +1336,8 @@ class TestFunctional(unittest.TestCase): with self.assertRaises(ValueError) as e: self._DoReadFileDtb('061_fdt_update_bad.dts', update_dtb=True) self.assertIn('Could not complete processing of Fdt: remaining ' - '[<_testing.Entry__testing', str(e.exception)) + '[<binman.etype._testing.Entry__testing', + str(e.exception)) def testEntryArgs(self): """Test passing arguments to entries from the command line"""
tools/binman/image.py +6 -6
@@ -12,12 +12,12 @@ import os import re import sys -from entry import Entry -from etype import fdtmap -from etype import image_header -from etype import section -import fdt -import fdt_util +from binman.entry import Entry +from binman.etype import fdtmap +from binman.etype import image_header +from binman.etype import section +from dtoc import fdt +from dtoc import fdt_util import tools import tout
tools/binman/image_test.py +1 -1
@@ -7,7 +7,7 @@ import unittest from image import Image -from test_util import capture_sys_output +from patman.test_util import capture_sys_output class TestImage(unittest.TestCase): def testInvalidFormat(self):
tools/binman/main.py +11 -12
@@ -20,8 +20,8 @@ import unittest # Bring in the patman and dtoc libraries (but don't override the first path # in PYTHONPATH) our_path = os.path.dirname(os.path.realpath(__file__)) -for dirname in ['../patman', '../dtoc', '..', '../concurrencytest']: - sys.path.insert(2, os.path.join(our_path, dirname)) +for dirname in ['../patman', '../dtoc', '../concurrencytest', '..']: + sys.path.insert(2, os.path.realpath(os.path.join(our_path, dirname))) # Bring in the libfdt module sys.path.insert(2, 'scripts/dtc/pylibfdt')
@@ -34,9 +34,8 @@ sys.path.insert(2, os.path.join(our_path, # that is not available in a virtualenv. sys.path.append(get_python_lib()) -import cmdline -import command -import control +from binman import cmdline +from binman import control import test_util def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath):
@@ -55,13 +54,13 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath): name to execute (as in 'binman test testSections', for example) toolpath: List of paths to use for tools """ - import cbfs_util_test - import elf_test - import entry_test - import fdt_test - import ftest - import image_test - import test + from binman import cbfs_util_test + from binman import elf_test + from binman import entry_test + from binman import fdt_test + from binman import ftest + from binman import image_test + from binman import test import doctest result = unittest.TestResult()
tools/binman/state.py +3 -3
@@ -8,7 +8,7 @@ import hashlib import re -import fdt +from dtoc import fdt import os import tools import tout
@@ -167,8 +167,8 @@ def Prepare(images, dtb): global output_fdt_info, main_dtb, fdt_path_prefix # Import these here in case libfdt.py is not available, in which case # the above help option still works. - import fdt - import fdt_util + from dtoc import fdt + from dtoc import fdt_util # If we are updating the DTBs we need to put these updated versions # where Entry_blob_dtb can find them. We can ignore 'u-boot.dtb'
tools/patman/main.py +10 -10
@@ -13,19 +13,19 @@ import sys import unittest if __name__ == "__main__": - # Allow 'from patman import xxx to work' + # Allow 'import xxx to work' our_path = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(our_path, '..')) # Our modules -from patman import checkpatch -from patman import command -from patman import gitutil -from patman import patchstream -from patman import project -from patman import settings -from patman import terminal -from patman import test +import checkpatch +import command +import gitutil +import patchstream +import project +import settings +import terminal +import test parser = OptionParser()
@@ -86,7 +86,7 @@ if __name__ != "__main__": # Run our meagre tests elif options.test: import doctest - from patman import func_test + import func_test sys.argv = [sys.argv[0]] result = unittest.TestResult()
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v2 12/14 binman: Move to absolute imports
At present binman sets the python path on startup so that it can access the libraries it needs. If we convert to use absolute imports this is not necessary.
Move binman to use absolute imports. This enables removable of the path adjusting in Entry also.
---
Changes in v2: None
tools/binman/cbfs_util.py | 2 +- tools/binman/cbfs_util_test.py | 6 +-- tools/binman/control.py | 12 +++--- tools/binman/elf.py | 2 +- tools/binman/elf_test.py | 2 +- tools/binman/entry.py | 16 +++----- tools/binman/entry_test.py | 10 ++--- tools/binman/etype/__init__.py | 0 tools/binman/etype/_testing.py | 4 +- tools/binman/etype/blob.py | 4 +- tools/binman/etype/blob_dtb.py | 6 +-- tools/binman/etype/blob_named_by_arg.py | 4 +- tools/binman/etype/cbfs.py | 10 ++--- tools/binman/etype/cros_ec_rw.py | 2 +- tools/binman/etype/fdtmap.py | 6 +-- tools/binman/etype/files.py | 6 +-- tools/binman/etype/fill.py | 4 +- tools/binman/etype/fmap.py | 6 +-- tools/binman/etype/gbb.py | 4 +- tools/binman/etype/image_header.py | 4 +- tools/binman/etype/intel_cmc.py | 4 +- tools/binman/etype/intel_descriptor.py | 4 +- tools/binman/etype/intel_fit.py | 2 +- tools/binman/etype/intel_fit_ptr.py | 2 +- tools/binman/etype/intel_fsp.py | 4 +- tools/binman/etype/intel_fsp_m.py | 4 +- tools/binman/etype/intel_fsp_s.py | 4 +- tools/binman/etype/intel_fsp_t.py | 4 +- tools/binman/etype/intel_ifwi.py | 6 +-- tools/binman/etype/intel_me.py | 4 +- tools/binman/etype/intel_mrc.py | 4 +- tools/binman/etype/intel_refcode.py | 4 +- tools/binman/etype/intel_vbt.py | 4 +- tools/binman/etype/intel_vga.py | 4 +- .../etype/powerpc_mpc85xx_bootpg_resetvec.py | 4 +- tools/binman/etype/section.py | 4 +- tools/binman/etype/text.py | 4 +- tools/binman/etype/u_boot.py | 4 +- tools/binman/etype/u_boot_dtb.py | 4 +- tools/binman/etype/u_boot_dtb_with_ucode.py | 8 ++-- tools/binman/etype/u_boot_elf.py | 6 +-- tools/binman/etype/u_boot_img.py | 4 +- tools/binman/etype/u_boot_nodtb.py | 4 +- tools/binman/etype/u_boot_spl.py | 7 ++-- tools/binman/etype/u_boot_spl_bss_pad.py | 6 +-- tools/binman/etype/u_boot_spl_dtb.py | 4 +- tools/binman/etype/u_boot_spl_elf.py | 4 +- tools/binman/etype/u_boot_spl_nodtb.py | 4 +- .../binman/etype/u_boot_spl_with_ucode_ptr.py | 6 +-- tools/binman/etype/u_boot_tpl.py | 7 ++-- tools/binman/etype/u_boot_tpl_dtb.py | 4 +- .../binman/etype/u_boot_tpl_dtb_with_ucode.py | 5 +-- tools/binman/etype/u_boot_tpl_elf.py | 4 +- .../binman/etype/u_boot_tpl_with_ucode_ptr.py | 6 +-- tools/binman/etype/u_boot_ucode.py | 4 +- tools/binman/etype/u_boot_with_ucode_ptr.py | 10 ++--- tools/binman/etype/vblock.py | 4 +- tools/binman/etype/x86_reset16.py | 4 +- tools/binman/etype/x86_reset16_spl.py | 4 +- tools/binman/etype/x86_reset16_tpl.py | 4 +- tools/binman/etype/x86_start16.py | 4 +- tools/binman/etype/x86_start16_spl.py | 4 +- tools/binman/etype/x86_start16_tpl.py | 4 +- tools/binman/fdt_test.py | 6 +-- tools/binman/ftest.py | 37 ++++++++++--------- tools/binman/image.py | 12 +++--- tools/binman/image_test.py | 2 +- tools/binman/main.py | 23 ++++++------ tools/binman/state.py | 6 +-- tools/patman/main.py | 20 +++++----- 70 files changed, 198 insertions(+), 213 deletions(-) delete mode 100644 tools/binman/etype/__init__.py
Applied to u-boot-dm, thanks!
PATCH v2 13/14 patman: Move to absolute imports
In reply to Simon GlassAt present patman sets the python path on startup so that it can access the libraries it needs. If we convert to use absolute imports this is not necessary.
Move patman to use absolute imports. This requires changes in tools which use the patman libraries (which is most of them).
---
Changes in v2:
- Expand to convert all Python tools in U-Boot
tools/binman/cbfs_util.py | 4 ++-- tools/binman/cbfs_util_test.py | 4 ++-- tools/binman/control.py | 6 +++--- tools/binman/elf.py | 6 +++--- tools/binman/elf_test.py | 8 ++++---- tools/binman/entry.py | 4 ++-- tools/binman/entry_test.py | 2 +- tools/binman/etype/_testing.py | 2 +- tools/binman/etype/blob.py | 4 ++-- tools/binman/etype/fdtmap.py | 4 ++-- tools/binman/etype/files.py | 2 +- tools/binman/etype/fill.py | 2 +- tools/binman/etype/fmap.py | 4 ++-- tools/binman/etype/gbb.py | 4 ++-- tools/binman/etype/intel_ifwi.py | 2 +- tools/binman/etype/section.py | 4 ++-- tools/binman/etype/text.py | 2 +- tools/binman/etype/u_boot_dtb_with_ucode.py | 2 +- tools/binman/etype/u_boot_elf.py | 2 +- tools/binman/etype/u_boot_spl_bss_pad.py | 4 ++-- .../binman/etype/u_boot_tpl_with_ucode_ptr.py | 4 ++-- tools/binman/etype/u_boot_ucode.py | 2 +- tools/binman/etype/u_boot_with_ucode_ptr.py | 4 ++-- tools/binman/etype/vblock.py | 2 +- tools/binman/fdt_test.py | 2 +- tools/binman/fmap_util.py | 2 +- tools/binman/ftest.py | 8 ++++---- tools/binman/image.py | 4 ++-- tools/binman/main.py | 2 +- tools/binman/state.py | 4 ++-- tools/buildman/builder.py | 8 ++++---- tools/buildman/builderthread.py | 4 ++-- tools/buildman/control.py | 10 +++++----- tools/buildman/func_test.py | 9 ++++----- tools/buildman/main.py | 6 +++--- tools/buildman/test.py | 10 +++++----- tools/buildman/toolchain.py | 6 +++--- tools/dtoc/dtb_platdata.py | 6 +++--- tools/dtoc/fdt.py | 4 ++-- tools/dtoc/fdt_util.py | 4 ++-- tools/dtoc/main.py | 5 +++-- tools/dtoc/test_dtoc.py | 10 +++++----- tools/dtoc/test_fdt.py | 12 ++++++------ tools/patman/checkpatch.py | 8 +++++--- tools/patman/command.py | 5 +++-- tools/patman/func_test.py | 8 ++++---- tools/patman/get_maintainer.py | 5 +++-- tools/patman/gitutil.py | 12 ++++++------ tools/patman/main.py | 18 +++++++++--------- tools/patman/patchstream.py | 8 ++++---- tools/patman/project.py | 2 +- tools/patman/series.py | 10 +++++----- tools/patman/settings.py | 6 +++--- tools/patman/test.py | 10 +++++----- tools/patman/test_util.py | 3 ++- tools/patman/tools.py | 4 ++-- tools/patman/tout.py | 2 +- tools/rmboard.py | 2 +- 58 files changed, 154 insertions(+), 149 deletions(-)
tools/binman/cbfs_util.py +2 -2
@@ -21,8 +21,8 @@ import struct import sys from binman import elf -import command -import tools +from patman import command +from patman import tools # Set to True to enable printing output while working DEBUG = False
tools/binman/cbfs_util_test.py +2 -2
@@ -19,8 +19,8 @@ import unittest from binman import cbfs_util from binman.cbfs_util import CbfsWriter from binman import elf -import test_util -import tools +from patman import test_util +from patman import tools U_BOOT_DATA = b'1234' U_BOOT_DTB_DATA = b'udtb'
tools/binman/control.py +3 -3
@@ -8,12 +8,12 @@ from collections import OrderedDict import os import sys -import tools +from patman import tools from binman import cbfs_util from binman import elf -import command -import tout +from patman import command +from patman import tout # List of images we plan to create # Make this global so that it can be referenced from tests
tools/binman/elf.py +3 -3
@@ -13,9 +13,9 @@ import shutil import struct import tempfile -import command -import tools -import tout +from patman import command +from patman import tools +from patman import tout ELF_TOOLS = True try:
tools/binman/elf_test.py +4 -4
@@ -11,10 +11,10 @@ import tempfile import unittest from binman import elf -import command -import test_util -import tools -import tout +from patman import command +from patman import test_util +from patman import tools +from patman import tout binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
tools/binman/entry.py +2 -2
@@ -10,9 +10,9 @@ import os import sys from dtoc import fdt_util -import tools +from patman import tools from patman.tools import ToHex, ToHexSize -import tout +from patman import tout modules = {}
tools/binman/entry_test.py +1 -1
@@ -12,7 +12,7 @@ import unittest from binman import entry from dtoc import fdt from dtoc import fdt_util -import tools +from patman import tools class TestEntry(unittest.TestCase): def setUp(self):
tools/binman/etype/_testing.py +1 -1
@@ -9,7 +9,7 @@ from collections import OrderedDict from binman.entry import Entry, EntryArg from dtoc import fdt_util -import tools +from patman import tools class Entry__testing(Entry):
tools/binman/etype/blob.py +2 -2
@@ -7,8 +7,8 @@ from binman.entry import Entry from dtoc import fdt_util -import tools -import tout +from patman import tools +from patman import tout class Entry_blob(Entry): """Entry containing an arbitrary binary blob
tools/binman/etype/fdtmap.py +2 -2
@@ -9,8 +9,8 @@ image. """ from binman.entry import Entry -import tools -import tout +from patman import tools +from patman import tout FDTMAP_MAGIC = b'_FDTMAP_' FDTMAP_HDR_LEN = 16
tools/binman/etype/files.py +1 -1
@@ -11,7 +11,7 @@ import os from binman.etype.section import Entry_section from dtoc import fdt_util -import tools +from patman import tools class Entry_files(Entry_section):
tools/binman/etype/fill.py +1 -1
@@ -5,7 +5,7 @@ from binman.entry import Entry from dtoc import fdt_util -import tools +from patman import tools class Entry_fill(Entry): """An entry which is filled to a particular byte value
tools/binman/etype/fmap.py +2 -2
@@ -7,9 +7,9 @@ from binman.entry import Entry from binman import fmap_util -import tools +from patman import tools from patman.tools import ToHexSize -import tout +from patman import tout class Entry_fmap(Entry):
tools/binman/etype/gbb.py +2 -2
@@ -8,11 +8,11 @@ from collections import OrderedDict -import command +from patman import command from binman.entry import Entry, EntryArg from dtoc import fdt_util -import tools +from patman import tools # Build GBB flags. # (src/platform/vboot_reference/firmware/include/gbb_header.h)
tools/binman/etype/intel_ifwi.py +1 -1
@@ -10,7 +10,7 @@ from collections import OrderedDict from binman.entry import Entry from binman.etype.blob import Entry_blob from dtoc import fdt_util -import tools +from patman import tools class Entry_intel_ifwi(Entry_blob): """Entry containing an Intel Integrated Firmware Image (IFWI) file
tools/binman/etype/section.py +2 -2
@@ -14,8 +14,8 @@ import sys from binman.entry import Entry from dtoc import fdt_util -import tools -import tout +from patman import tools +from patman import tout class Entry_section(Entry):
tools/binman/etype/text.py +1 -1
@@ -7,7 +7,7 @@ from collections import OrderedDict from binman.entry import Entry, EntryArg from dtoc import fdt_util -import tools +from patman import tools class Entry_text(Entry):
tools/binman/etype/u_boot_dtb_with_ucode.py +1 -1
@@ -7,7 +7,7 @@ from binman.entry import Entry from binman.etype.blob_dtb import Entry_blob_dtb -import tools +from patman import tools class Entry_u_boot_dtb_with_ucode(Entry_blob_dtb): """A U-Boot device tree file, with the microcode removed
tools/binman/etype/u_boot_elf.py +1 -1
@@ -9,7 +9,7 @@ from binman.entry import Entry from binman.etype.blob import Entry_blob from dtoc import fdt_util -import tools +from patman import tools class Entry_u_boot_elf(Entry_blob): """U-Boot ELF image
tools/binman/etype/u_boot_spl_bss_pad.py +2 -2
@@ -9,9 +9,9 @@ from binman import elf from binman.entry import Entry -import command +from patman import command from binman.etype.blob import Entry_blob -import tools +from patman import tools class Entry_u_boot_spl_bss_pad(Entry_blob): """U-Boot SPL binary padded with a BSS region
tools/binman/etype/u_boot_tpl_with_ucode_ptr.py +2 -2
@@ -7,11 +7,11 @@ import struct -import command +from patman import command from binman.entry import Entry from binman.etype.blob import Entry_blob from binman.etype.u_boot_with_ucode_ptr import Entry_u_boot_with_ucode_ptr -import tools +from patman import tools class Entry_u_boot_tpl_with_ucode_ptr(Entry_u_boot_with_ucode_ptr): """U-Boot TPL with embedded microcode pointer
tools/binman/etype/u_boot_ucode.py +1 -1
@@ -7,7 +7,7 @@ from binman.entry import Entry from binman.etype.blob import Entry_blob -import tools +from patman import tools class Entry_u_boot_ucode(Entry_blob): """U-Boot microcode block
tools/binman/etype/u_boot_with_ucode_ptr.py +2 -2
@@ -11,8 +11,8 @@ from binman import elf from binman.entry import Entry from binman.etype.blob import Entry_blob from dtoc import fdt_util -import tools -import command +from patman import tools +from patman import command class Entry_u_boot_with_ucode_ptr(Entry_blob): """U-Boot with embedded microcode pointer
tools/binman/etype/vblock.py +1 -1
@@ -12,7 +12,7 @@ import os from binman.entry import Entry, EntryArg from dtoc import fdt_util -import tools +from patman import tools class Entry_vblock(Entry): """An entry which contains a Chromium OS verified boot block
tools/binman/fdt_test.py +1 -1
@@ -12,7 +12,7 @@ import unittest from dtoc import fdt from dtoc import fdt_util from dtoc.fdt import FdtScan -import tools +from patman import tools class TestFdt(unittest.TestCase): @classmethod
tools/binman/fmap_util.py +1 -1
@@ -10,7 +10,7 @@ import collections import struct import sys -import tools +from patman import tools # constants imported from lib/fmap.h FMAP_SIGNATURE = b'__FMAP__'
tools/binman/ftest.py +4 -4
@@ -29,10 +29,10 @@ from dtoc import fdt_util from binman.etype import fdtmap from binman.etype import image_header from image import Image -import command -import test_util -import tools -import tout +from patman import command +from patman import test_util +from patman import tools +from patman import tout # Contents of test files, corresponding to different entry types U_BOOT_DATA = b'1234'
tools/binman/image.py +2 -2
@@ -18,8 +18,8 @@ from binman.etype import image_header from binman.etype import section from dtoc import fdt from dtoc import fdt_util -import tools -import tout +from patman import tools +from patman import tout class Image(section.Entry_section): """A Image, representing an output from binman
tools/binman/main.py +1 -1
@@ -36,7 +36,7 @@ sys.path.append(get_python_lib()) from binman import cmdline from binman import control -import test_util +from patman import test_util def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath): """Run the functional tests and any embedded doctests
tools/binman/state.py +2 -2
@@ -10,8 +10,8 @@ import re from dtoc import fdt import os -import tools -import tout +from patman import tools +from patman import tout # Records the device-tree files known to binman, keyed by entry type (e.g. # 'u-boot-spl-dtb'). These are the output FDT files, which can be updated by
tools/buildman/builder.py +4 -4
@@ -19,10 +19,10 @@ import time from buildman import builderthread from buildman import toolchain -import command -import gitutil -import terminal -from terminal import Print +from patman import command +from patman import gitutil +from patman import terminal +from patman.terminal import Print """ Theory of Operation
tools/buildman/builderthread.py +2 -2
@@ -9,8 +9,8 @@ import shutil import sys import threading -import command -import gitutil +from patman import command +from patman import gitutil RETURN_CODE_RETRY = -1
tools/buildman/control.py +5 -5
@@ -12,11 +12,11 @@ from buildman import board from buildman import bsettings from buildman import toolchain from buildman.builder import Builder -import command -import gitutil -import patchstream -import terminal -from terminal import Print +from patman import command +from patman import gitutil +from patman import patchstream +from patman import terminal +from patman.terminal import Print def GetPlural(count): """Returns a plural 's' if count is not 1"""
tools/buildman/func_test.py +4 -5
@@ -13,11 +13,10 @@ from buildman import bsettings from buildman import cmdline from buildman import control from buildman import toolchain -import command -import gitutil -import terminal -import toolchain -import tools +from patman import command +from patman import gitutil +from patman import terminal +from patman import tools settings_data = ''' # Buildman settings file
tools/buildman/main.py +3 -3
@@ -25,9 +25,9 @@ from buildman import builder from buildman import cmdline from buildman import control from buildman import toolchain -import patchstream -import gitutil -import terminal +from patman import patchstream +from patman import gitutil +from patman import terminal def RunTests(skip_net_tests): import func_test
tools/buildman/test.py +5 -5
@@ -18,11 +18,11 @@ from buildman import bsettings from buildman import builder from buildman import control from buildman import toolchain -import commit -import command -import terminal -import test_util -import tools +from patman import commit +from patman import command +from patman import terminal +from patman import test_util +from patman import tools use_network = True
tools/buildman/toolchain.py +3 -3
@@ -11,9 +11,9 @@ import tempfile import urllib.request, urllib.error, urllib.parse from buildman import bsettings -import command -import terminal -import tools +from patman import command +from patman import terminal +from patman import tools (PRIORITY_FULL_PREFIX, PRIORITY_PREFIX_GCC, PRIORITY_PREFIX_GCC_PATH, PRIORITY_CALC) = list(range(4))
tools/dtoc/dtb_platdata.py +3 -3
@@ -15,9 +15,9 @@ import collections import copy import sys -import fdt -import fdt_util -import tools +from dtoc import fdt +from dtoc import fdt_util +from patman import tools # When we see these properties we ignore them - i.e. do not create a structure member PROP_IGNORE_LIST = [
tools/dtoc/fdt.py +2 -2
@@ -8,10 +8,10 @@ import struct import sys -import fdt_util +from dtoc import fdt_util import libfdt from libfdt import QUIET_NOTFOUND -import tools +from patman import tools # This deals with a device tree, presenting it as an assortment of Node and # Prop objects, representing nodes and properties, respectively. This file
tools/dtoc/fdt_util.py +2 -2
@@ -13,8 +13,8 @@ import struct import sys import tempfile -import command -import tools +from patman import command +from patman import tools def fdt32_to_cpu(val): """Convert a device tree cell to an integer
tools/dtoc/main.py +3 -2
@@ -33,14 +33,15 @@ import unittest # Bring in the patman libraries our_path = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(our_path, '../patman')) +sys.path.append(os.path.join(our_path, '..')) # Bring in the libfdt module sys.path.insert(0, 'scripts/dtc/pylibfdt') sys.path.insert(0, os.path.join(our_path, '../../build-sandbox_spl/scripts/dtc/pylibfdt')) -import dtb_platdata -import test_util +from dtoc import dtb_platdata +from patman import test_util def run_tests(args): """Run all the test we have for dtoc
tools/dtoc/test_dtoc.py +5 -5
@@ -14,15 +14,15 @@ import os import struct import unittest -import dtb_platdata +from dtoc import dtb_platdata from dtb_platdata import conv_name_to_c from dtb_platdata import get_compat_name from dtb_platdata import get_value from dtb_platdata import tab_to -import fdt -import fdt_util -import test_util -import tools +from dtoc import fdt +from dtoc import fdt_util +from patman import test_util +from patman import tools our_path = os.path.dirname(os.path.realpath(__file__))
tools/dtoc/test_fdt.py +6 -6
@@ -17,14 +17,14 @@ our_path = os.path.dirname(os.path.realpath(__file__)) for dirname in ['../patman', '..']: sys.path.insert(0, os.path.join(our_path, dirname)) -import command -import fdt +from dtoc import fdt +from dtoc import fdt_util +from dtoc.fdt_util import fdt32_to_cpu from fdt import TYPE_BYTE, TYPE_INT, TYPE_STRING, TYPE_BOOL, BytesToValue -import fdt_util -from fdt_util import fdt32_to_cpu import libfdt -import test_util -import tools +from patman import command +from patman import test_util +from patman import tools def _GetPropertyValue(dtb, node, prop_name): """Low-level function to get the property value based on its offset
tools/patman/checkpatch.py +5 -3
@@ -3,12 +3,14 @@ # import collections -import command -import gitutil import os import re import sys -import terminal + +from patman import command +from patman import gitutil +from patman import terminal +from patman import tools def FindCheckPatch(): top_level = gitutil.GetTopLevel()
tools/patman/command.py +3 -2
@@ -3,8 +3,9 @@ # import os -import cros_subprocess -import tools + +from patman import cros_subprocess +from patman import tools """Shell command ease-ups for Python."""
tools/patman/func_test.py +4 -4
@@ -14,10 +14,10 @@ import unittest from io import StringIO -import gitutil -import patchstream -import settings -import tools +from patman import gitutil +from patman import patchstream +from patman import settings +from patman import tools @contextlib.contextmanager
tools/patman/get_maintainer.py +3 -2
@@ -2,10 +2,11 @@ # Copyright (c) 2012 The Chromium OS Authors. # -import command -import gitutil import os +from patman import command +from patman import gitutil + def FindGetMaintainer(): """Look for the get_maintainer.pl script.
tools/patman/gitutil.py +6 -6
@@ -2,17 +2,17 @@ # Copyright (c) 2011 The Chromium OS Authors. # -import command import re import os -import series import subprocess import sys -import terminal -import checkpatch -import settings -import tools +from patman import checkpatch +from patman import command +from patman import series +from patman import settings +from patman import terminal +from patman import tools # True to use --no-decorate - we check this in Setup() use_no_decorate = True
tools/patman/main.py +9 -9
@@ -18,14 +18,14 @@ if __name__ == "__main__": sys.path.append(os.path.join(our_path, '..')) # Our modules -import checkpatch -import command -import gitutil -import patchstream -import project -import settings -import terminal -import test +from patman import checkpatch +from patman import command +from patman import gitutil +from patman import patchstream +from patman import project +from patman import settings +from patman import terminal +from patman import test parser = OptionParser()
@@ -86,7 +86,7 @@ if __name__ != "__main__": # Run our meagre tests elif options.test: import doctest - import func_test + from patman import func_test sys.argv = [sys.argv[0]] result = unittest.TestResult()
tools/patman/patchstream.py +4 -4
@@ -9,10 +9,10 @@ import re import shutil import tempfile -import command -import commit -import gitutil -from series import Series +from patman import command +from patman import commit +from patman import gitutil +from patman.series import Series # Tags that we detect and remove re_remove = re.compile('^BUG=|^TEST=|^BRANCH=|^Review URL:'
tools/patman/project.py +1 -1
@@ -4,7 +4,7 @@ import os.path -import gitutil +from patman import gitutil def DetectProject(): """Autodetect the name of the current project.
tools/patman/series.py +5 -5
@@ -5,11 +5,11 @@ import itertools import os -import get_maintainer -import gitutil -import settings -import terminal -import tools +from patman import get_maintainer +from patman import gitutil +from patman import settings +from patman import terminal +from patman import tools # Series-xxx tags that we understand valid_series = ['to', 'cc', 'version', 'changes', 'prefix', 'notes', 'name',
tools/patman/settings.py +3 -3
@@ -10,9 +10,9 @@ except: import os import re -import command -import gitutil -import tools +from patman import command +from patman import gitutil +from patman import tools """Default settings per-project.
tools/patman/test.py +5 -5
@@ -8,11 +8,11 @@ import os import tempfile import unittest -import checkpatch -import gitutil -import patchstream -import series -import commit +from patman import checkpatch +from patman import gitutil +from patman import patchstream +from patman import series +from patman import commit class TestPatch(unittest.TestCase):
tools/patman/test_util.py +2 -1
@@ -10,7 +10,8 @@ import os import sys import unittest -import command +from patman import command +from patman import test_util from io import StringIO
tools/patman/tools.py +2 -2
@@ -3,7 +3,6 @@ # Copyright (c) 2016 Google, Inc # -import command import glob import os import shutil
@@ -11,7 +10,8 @@ import struct import sys import tempfile -import tout +from patman import command +from patman import tout # Output directly (generally this is temporary) outdir = None
tools/patman/tout.py +1 -1
@@ -6,7 +6,7 @@ import sys -import terminal +from patman import terminal # Output verbosity levels that we support ERROR, WARNING, NOTICE, INFO, DETAIL, DEBUG = range(6)
tools/rmboard.py +1 -1
@@ -32,7 +32,7 @@ import sys our_path = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(our_path, '../tools/patman')) -import command +from patman import command def rm_kconfig_include(path): """Remove a path from Kconfig files
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v2 13/14 patman: Move to absolute imports
At present patman sets the python path on startup so that it can access the libraries it needs. If we convert to use absolute imports this is not necessary.
Move patman to use absolute imports. This requires changes in tools which use the patman libraries (which is most of them).
---
Changes in v2:
- Expand to convert all Python tools in U-Boot
tools/binman/cbfs_util.py | 4 ++-- tools/binman/cbfs_util_test.py | 4 ++-- tools/binman/control.py | 6 +++--- tools/binman/elf.py | 6 +++--- tools/binman/elf_test.py | 8 ++++---- tools/binman/entry.py | 4 ++-- tools/binman/entry_test.py | 2 +- tools/binman/etype/_testing.py | 2 +- tools/binman/etype/blob.py | 4 ++-- tools/binman/etype/fdtmap.py | 4 ++-- tools/binman/etype/files.py | 2 +- tools/binman/etype/fill.py | 2 +- tools/binman/etype/fmap.py | 4 ++-- tools/binman/etype/gbb.py | 4 ++-- tools/binman/etype/intel_ifwi.py | 2 +- tools/binman/etype/section.py | 4 ++-- tools/binman/etype/text.py | 2 +- tools/binman/etype/u_boot_dtb_with_ucode.py | 2 +- tools/binman/etype/u_boot_elf.py | 2 +- tools/binman/etype/u_boot_spl_bss_pad.py | 4 ++-- .../binman/etype/u_boot_tpl_with_ucode_ptr.py | 4 ++-- tools/binman/etype/u_boot_ucode.py | 2 +- tools/binman/etype/u_boot_with_ucode_ptr.py | 4 ++-- tools/binman/etype/vblock.py | 2 +- tools/binman/fdt_test.py | 2 +- tools/binman/fmap_util.py | 2 +- tools/binman/ftest.py | 8 ++++---- tools/binman/image.py | 4 ++-- tools/binman/main.py | 2 +- tools/binman/state.py | 4 ++-- tools/buildman/builder.py | 8 ++++---- tools/buildman/builderthread.py | 4 ++-- tools/buildman/control.py | 10 +++++----- tools/buildman/func_test.py | 9 ++++----- tools/buildman/main.py | 6 +++--- tools/buildman/test.py | 10 +++++----- tools/buildman/toolchain.py | 6 +++--- tools/dtoc/dtb_platdata.py | 6 +++--- tools/dtoc/fdt.py | 4 ++-- tools/dtoc/fdt_util.py | 4 ++-- tools/dtoc/main.py | 5 +++-- tools/dtoc/test_dtoc.py | 10 +++++----- tools/dtoc/test_fdt.py | 12 ++++++------ tools/patman/checkpatch.py | 8 +++++--- tools/patman/command.py | 5 +++-- tools/patman/func_test.py | 8 ++++---- tools/patman/get_maintainer.py | 5 +++-- tools/patman/gitutil.py | 12 ++++++------ tools/patman/main.py | 18 +++++++++--------- tools/patman/patchstream.py | 8 ++++---- tools/patman/project.py | 2 +- tools/patman/series.py | 10 +++++----- tools/patman/settings.py | 6 +++--- tools/patman/test.py | 10 +++++----- tools/patman/test_util.py | 3 ++- tools/patman/tools.py | 4 ++-- tools/patman/tout.py | 2 +- tools/rmboard.py | 2 +- 58 files changed, 154 insertions(+), 149 deletions(-)
Applied to u-boot-dm, thanks!
PATCH v2 14/14 patman: Tidy up sys.path changes
In reply to Simon GlassNow that we are using absolute paths we can remove some of the sys.path mangling that appears in the tools.
We only need to add the path to 'tools/' so that everything can find modules relative to that directory.
The special paths for finding pylibfdt remain.
---
Changes in v2: None
tools/binman/main.py | 5 +++-- tools/buildman/main.py | 3 +-- tools/buildman/test.py | 1 - tools/dtoc/main.py | 1 - tools/dtoc/test_fdt.py | 3 +-- tools/genboardscfg.py | 3 +-- tools/moveconfig.py | 2 -- tools/patman/main.py | 2 +- tools/rmboard.py | 1 - 9 files changed, 7 insertions(+), 14 deletions(-)
tools/binman/main.py +3 -2
@@ -20,8 +20,9 @@ import unittest # Bring in the patman and dtoc libraries (but don't override the first path # in PYTHONPATH) our_path = os.path.dirname(os.path.realpath(__file__)) -for dirname in ['../patman', '../dtoc', '../concurrencytest', '..']: - sys.path.insert(2, os.path.realpath(os.path.join(our_path, dirname))) +sys.path.insert(2, os.path.join(our_path, '..')) + +from patman import test_util # Bring in the libfdt module sys.path.insert(2, 'scripts/dtc/pylibfdt')
tools/buildman/main.py +1 -2
@@ -16,7 +16,6 @@ import unittest # Bring in the patman libraries our_path = os.path.dirname(os.path.realpath(__file__)) sys.path.insert(1, os.path.join(our_path, '..')) -sys.path.insert(2, os.path.join(our_path, '../patman')) # Our modules from buildman import board
@@ -35,7 +34,7 @@ def RunTests(skip_net_tests): import doctest result = unittest.TestResult() - for module in ['toolchain', 'gitutil']: + for module in ['buildman.toolchain', 'patman.gitutil']: suite = doctest.DocTestSuite(module) suite.run(result)
tools/buildman/test.py +0 -1
@@ -11,7 +11,6 @@ import unittest # Bring in the patman libraries our_path = os.path.dirname(os.path.realpath(__file__)) -sys.path.append(os.path.join(our_path, '../patman')) from buildman import board from buildman import bsettings
tools/dtoc/main.py +0 -1
@@ -32,7 +32,6 @@ import unittest # Bring in the patman libraries our_path = os.path.dirname(os.path.realpath(__file__)) -sys.path.append(os.path.join(our_path, '../patman')) sys.path.append(os.path.join(our_path, '..')) # Bring in the libfdt module
tools/dtoc/test_fdt.py +1 -2
@@ -14,8 +14,7 @@ import unittest # Bring in the patman libraries our_path = os.path.dirname(os.path.realpath(__file__)) -for dirname in ['../patman', '..']: - sys.path.insert(0, os.path.join(our_path, dirname)) +sys.path.insert(1, os.path.join(our_path, '..')) from dtoc import fdt from dtoc import fdt_util
tools/genboardscfg.py +1 -2
@@ -22,8 +22,7 @@ import sys import tempfile import time -sys.path.insert(1, os.path.join(os.path.dirname(__file__), 'buildman')) -import kconfiglib +from buildman import kconfiglib ### constant variables ### OUTPUT_FILE = 'boards.cfg'
tools/moveconfig.py +0 -2
@@ -314,8 +314,6 @@ import tempfile import threading import time -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -sys.path.append(os.path.join(os.path.dirname(__file__), 'patman')) from buildman import bsettings from buildman import kconfiglib from buildman import toolchain
tools/patman/main.py +1 -1
@@ -13,7 +13,7 @@ import sys import unittest if __name__ == "__main__": - # Allow 'import xxx to work' + # Allow 'from patman import xxx to work' our_path = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(our_path, '..'))
tools/rmboard.py +0 -1
@@ -30,7 +30,6 @@ import sys # Bring in the patman libraries our_path = os.path.dirname(os.path.realpath(__file__)) -sys.path.append(os.path.join(our_path, '../tools/patman')) from patman import command
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v2 14/14 patman: Tidy up sys.path changes
Now that we are using absolute paths we can remove some of the sys.path mangling that appears in the tools.
We only need to add the path to 'tools/' so that everything can find modules relative to that directory.
The special paths for finding pylibfdt remain.
---
Changes in v2: None
tools/binman/main.py | 5 +++-- tools/buildman/main.py | 3 +-- tools/buildman/test.py | 1 - tools/dtoc/main.py | 1 - tools/dtoc/test_fdt.py | 3 +-- tools/genboardscfg.py | 3 +-- tools/moveconfig.py | 2 -- tools/patman/main.py | 2 +- tools/rmboard.py | 1 - 9 files changed, 7 insertions(+), 14 deletions(-)
Applied to u-boot-dm, thanks!