]>
git.ipfire.org Git - people/ms/u-boot.git/blob - tools/binman/binman.py
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 sys
.path
.append(os
.path
.join(our_path
, '../patman'))
21 sys
.path
.append(os
.path
.join(our_path
, '../dtoc'))
22 sys
.path
.append(os
.path
.join(our_path
, '../'))
24 # Also allow entry-type modules to be brought in from the etype directory.
25 sys
.path
.append(os
.path
.join(our_path
, 'etype'))
32 """Run the functional tests and any embedded doctests"""
39 result
= unittest
.TestResult()
41 suite
= doctest
.DocTestSuite(module
)
44 sys
.argv
= [sys
.argv
[0]]
45 for module
in (func_test
.TestFunctional
, fdt_test
.TestFdt
,
46 entry_test
.TestEntry
):
47 suite
= unittest
.TestLoader().loadTestsFromTestCase(module
)
51 for test
, err
in result
.errors
:
53 for test
, err
in result
.failures
:
56 def RunTestCoverage():
57 """Run the tests and check that we get 100% coverage"""
58 # This uses the build output from sandbox_spl to get _libfdt.so
59 cmd
= ('PYTHONPATH=%s/sandbox_spl/tools coverage run '
60 '--include "tools/binman/*.py" --omit "*test*,*binman.py" '
61 'tools/binman/binman.py -t' % options
.build_dir
)
63 stdout
= command
.Output('coverage', 'report')
64 coverage
= stdout
.splitlines()[-1].split(' ')[-1]
65 if coverage
!= '100%':
67 print "Type 'coverage html' to get a report in htmlcov/index.html"
68 raise ValueError('Coverage error: %s, but should be 100%%' % coverage
)
71 def RunBinman(options
, args
):
72 """Main entry point to binman once arguments are parsed
75 options: Command-line options
76 args: Non-option arguments
80 # For testing: This enables full exception traces.
84 sys
.tracebacklimit
= 0
89 elif options
.test_coverage
:
92 elif options
.full_help
:
93 pager
= os
.getenv('PAGER')
96 fname
= os
.path
.join(os
.path
.dirname(os
.path
.realpath(sys
.argv
[0])),
98 command
.Run(pager
, fname
)
102 ret_code
= control
.Binman(options
, args
)
103 except Exception as e
:
104 print 'binman: %s' % e
107 traceback
.print_exc()
112 if __name__
== "__main__":
113 (options
, args
) = cmdline
.ParseArgs(sys
.argv
)
114 ret_code
= RunBinman(options
, args
)