mirror of
				https://xff.cz/git/u-boot/
				synced 2025-10-30 18:05:48 +01:00 
			
		
		
		
	binman: Support enabling debug in tests
The elf module can provide some debugging information to assist with figuring out what is going wrong. This is also useful in tests. Update the -D option so that it is passed through to tests as well. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
		| @@ -31,7 +31,7 @@ import cmdline | |||||||
| import command | import command | ||||||
| import control | import control | ||||||
|  |  | ||||||
| def RunTests(): | def RunTests(debug): | ||||||
|     """Run the functional tests and any embedded doctests""" |     """Run the functional tests and any embedded doctests""" | ||||||
|     import elf_test |     import elf_test | ||||||
|     import entry_test |     import entry_test | ||||||
| @@ -46,6 +46,8 @@ def RunTests(): | |||||||
|         suite.run(result) |         suite.run(result) | ||||||
|  |  | ||||||
|     sys.argv = [sys.argv[0]] |     sys.argv = [sys.argv[0]] | ||||||
|  |     if debug: | ||||||
|  |         sys.argv.append('-D') | ||||||
|  |  | ||||||
|     # Run the entry tests first ,since these need to be the first to import the |     # Run the entry tests first ,since these need to be the first to import the | ||||||
|     # 'entry' module. |     # 'entry' module. | ||||||
| @@ -111,7 +113,7 @@ def RunBinman(options, args): | |||||||
|         sys.tracebacklimit = 0 |         sys.tracebacklimit = 0 | ||||||
|  |  | ||||||
|     if options.test: |     if options.test: | ||||||
|         ret_code = RunTests() |         ret_code = RunTests(options.debug) | ||||||
|  |  | ||||||
|     elif options.test_coverage: |     elif options.test_coverage: | ||||||
|         RunTestCoverage() |         RunTestCoverage() | ||||||
|   | |||||||
| @@ -12,6 +12,7 @@ import sys | |||||||
| import tools | import tools | ||||||
|  |  | ||||||
| import command | import command | ||||||
|  | import elf | ||||||
| import fdt | import fdt | ||||||
| import fdt_util | import fdt_util | ||||||
| from image import Image | from image import Image | ||||||
| @@ -89,6 +90,8 @@ def Binman(options, args): | |||||||
|  |  | ||||||
|     try: |     try: | ||||||
|         tout.Init(options.verbosity) |         tout.Init(options.verbosity) | ||||||
|  |         if options.debug: | ||||||
|  |             elf.debug = True | ||||||
|         try: |         try: | ||||||
|             tools.SetInputDirs(options.indir) |             tools.SetInputDirs(options.indir) | ||||||
|             tools.PrepareOutputDir(options.outdir, options.preserve) |             tools.PrepareOutputDir(options.outdir, options.preserve) | ||||||
|   | |||||||
| @@ -14,6 +14,9 @@ import struct | |||||||
|  |  | ||||||
| import tools | import tools | ||||||
|  |  | ||||||
|  | # This is enabled from control.py | ||||||
|  | debug = False | ||||||
|  |  | ||||||
| Symbol = namedtuple('Symbol', ['section', 'address', 'size', 'weak']) | Symbol = namedtuple('Symbol', ['section', 'address', 'size', 'weak']) | ||||||
|  |  | ||||||
| # Used for tests which don't have an ELF file to read | # Used for tests which don't have an ELF file to read | ||||||
|   | |||||||
| @@ -136,7 +136,10 @@ class TestFunctional(unittest.TestCase): | |||||||
|         Returns: |         Returns: | ||||||
|             Return value (0 for success) |             Return value (0 for success) | ||||||
|         """ |         """ | ||||||
|         (options, args) = cmdline.ParseArgs(list(args)) |         args = list(args) | ||||||
|  |         if '-D' in sys.argv: | ||||||
|  |             args = args + ['-D'] | ||||||
|  |         (options, args) = cmdline.ParseArgs(args) | ||||||
|         options.pager = 'binman-invalid-pager' |         options.pager = 'binman-invalid-pager' | ||||||
|         options.build_dir = self._indir |         options.build_dir = self._indir | ||||||
|  |  | ||||||
| @@ -144,14 +147,16 @@ class TestFunctional(unittest.TestCase): | |||||||
|         # options.verbosity = tout.DEBUG |         # options.verbosity = tout.DEBUG | ||||||
|         return control.Binman(options, args) |         return control.Binman(options, args) | ||||||
|  |  | ||||||
|     def _DoTestFile(self, fname): |     def _DoTestFile(self, fname, debug=False): | ||||||
|         """Run binman with a given test file |         """Run binman with a given test file | ||||||
|  |  | ||||||
|         Args: |         Args: | ||||||
|             fname: Device tree source filename to use (e.g. 05_simple.dts) |             fname: Device tree source filename to use (e.g. 05_simple.dts) | ||||||
|         """ |         """ | ||||||
|         return self._DoBinman('-p', '-I', self._indir, |         args = ['-p', '-I', self._indir, '-d', self.TestFile(fname)] | ||||||
|                               '-d', self.TestFile(fname)) |         if debug: | ||||||
|  |             args.append('-D') | ||||||
|  |         return self._DoBinman(*args) | ||||||
|  |  | ||||||
|     def _SetupDtb(self, fname, outfile='u-boot.dtb'): |     def _SetupDtb(self, fname, outfile='u-boot.dtb'): | ||||||
|         """Set up a new test device-tree file |         """Set up a new test device-tree file | ||||||
| @@ -363,6 +368,10 @@ class TestFunctional(unittest.TestCase): | |||||||
|         data = self._DoReadFile('05_simple.dts') |         data = self._DoReadFile('05_simple.dts') | ||||||
|         self.assertEqual(U_BOOT_DATA, data) |         self.assertEqual(U_BOOT_DATA, data) | ||||||
|  |  | ||||||
|  |     def testSimpleDebug(self): | ||||||
|  |         """Test a simple binman run with debugging enabled""" | ||||||
|  |         data = self._DoTestFile('05_simple.dts', debug=True) | ||||||
|  |  | ||||||
|     def testDual(self): |     def testDual(self): | ||||||
|         """Test that we can handle creating two images |         """Test that we can handle creating two images | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user