]>
git.ipfire.org Git - people/ms/u-boot.git/blob - tools/binman/binman.py
09dc36a3f7913b356c1d5eaf0a68ad76eeaf61da
3 # Copyright (c) 2016 Google, Inc
4 # Written by Simon Glass <sjg@chromium.org>
6 # SPDX-License-Identifier: GPL-2.0+
8 # Creates binary images from input files controlled by a description
11 """See README for more information"""
18 # Bring in the patman and dtoc libraries
19 our_path
= os
.path
.dirname(os
.path
.realpath(__file__
))
20 for dirname
in ['../patman', '../dtoc', '..']:
21 sys
.path
.insert(0, os
.path
.join(our_path
, dirname
))
23 # Bring in the libfdt module
24 sys
.path
.insert(0, 'tools')
26 # Also allow entry-type modules to be brought in from the etype directory.
27 sys
.path
.insert(0, os
.path
.join(our_path
, 'etype'))
34 """Run the functional tests and any embedded doctests"""
41 result
= unittest
.TestResult()
43 suite
= doctest
.DocTestSuite(module
)
46 sys
.argv
= [sys
.argv
[0]]
47 for module
in (func_test
.TestFunctional
, fdt_test
.TestFdt
,
48 entry_test
.TestEntry
):
49 suite
= unittest
.TestLoader().loadTestsFromTestCase(module
)
53 for test
, err
in result
.errors
:
55 for test
, err
in result
.failures
:
58 def RunTestCoverage():
59 """Run the tests and check that we get 100% coverage"""
60 # This uses the build output from sandbox_spl to get _libfdt.so
61 cmd
= ('PYTHONPATH=%s/sandbox_spl/tools coverage run '
62 '--include "tools/binman/*.py" --omit "*test*,*binman.py" '
63 'tools/binman/binman.py -t' % options
.build_dir
)
65 stdout
= command
.Output('coverage', 'report')
66 coverage
= stdout
.splitlines()[-1].split(' ')[-1]
67 if coverage
!= '100%':
69 print "Type 'coverage html' to get a report in htmlcov/index.html"
70 raise ValueError('Coverage error: %s, but should be 100%%' % coverage
)
73 def RunBinman(options
, args
):
74 """Main entry point to binman once arguments are parsed
77 options: Command-line options
78 args: Non-option arguments
82 # For testing: This enables full exception traces.
86 sys
.tracebacklimit
= 0
91 elif options
.test_coverage
:
94 elif options
.full_help
:
95 pager
= os
.getenv('PAGER')
98 fname
= os
.path
.join(os
.path
.dirname(os
.path
.realpath(sys
.argv
[0])),
100 command
.Run(pager
, fname
)
104 ret_code
= control
.Binman(options
, args
)
105 except Exception as e
:
106 print 'binman: %s' % e
109 traceback
.print_exc()
114 if __name__
== "__main__":
115 (options
, args
) = cmdline
.ParseArgs(sys
.argv
)
116 ret_code
= RunBinman(options
, args
)