mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-25 14:10:43 +00:00
binman: Enable bintool tests including cmdline processing
The tests rely on having at least 5 bintool implementions. Now that we have this, enable them. Add tests for the binman 'tool' subcommand. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
e1b7e4ddb6
commit
56ee85eef1
2 changed files with 36 additions and 3 deletions
|
@ -17,6 +17,8 @@ import struct
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
import unittest.mock
|
||||||
|
import urllib.error
|
||||||
|
|
||||||
from binman import bintool
|
from binman import bintool
|
||||||
from binman import cbfs_util
|
from binman import cbfs_util
|
||||||
|
@ -4991,6 +4993,36 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
|
||||||
err = stderr.getvalue()
|
err = stderr.getvalue()
|
||||||
self.assertRegex(err, "Image 'main-section'.*faked.*: blob-ext-list")
|
self.assertRegex(err, "Image 'main-section'.*faked.*: blob-ext-list")
|
||||||
|
|
||||||
|
def testListBintools(self):
|
||||||
|
args = ['tool', '--list']
|
||||||
|
with test_util.capture_sys_output() as (stdout, _):
|
||||||
|
self._DoBinman(*args)
|
||||||
|
out = stdout.getvalue().splitlines()
|
||||||
|
self.assertTrue(len(out) >= 2)
|
||||||
|
|
||||||
|
def testFetchBintools(self):
|
||||||
|
def fail_download(url):
|
||||||
|
"""Take the tools.Download() function by raising an exception"""
|
||||||
|
raise urllib.error.URLError('my error')
|
||||||
|
|
||||||
|
args = ['tool']
|
||||||
|
with self.assertRaises(ValueError) as e:
|
||||||
|
self._DoBinman(*args)
|
||||||
|
self.assertIn("Invalid arguments to 'tool' subcommand",
|
||||||
|
str(e.exception))
|
||||||
|
|
||||||
|
args = ['tool', '--fetch']
|
||||||
|
with self.assertRaises(ValueError) as e:
|
||||||
|
self._DoBinman(*args)
|
||||||
|
self.assertIn('Please specify bintools to fetch', str(e.exception))
|
||||||
|
|
||||||
|
args = ['tool', '--fetch', '_testing']
|
||||||
|
with unittest.mock.patch.object(tools, 'Download',
|
||||||
|
side_effect=fail_download):
|
||||||
|
with test_util.capture_sys_output() as (stdout, _):
|
||||||
|
self._DoBinman(*args)
|
||||||
|
self.assertIn('failed to fetch with all methods', stdout.getvalue())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -68,6 +68,7 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath):
|
||||||
name to execute (as in 'binman test testSections', for example)
|
name to execute (as in 'binman test testSections', for example)
|
||||||
toolpath: List of paths to use for tools
|
toolpath: List of paths to use for tools
|
||||||
"""
|
"""
|
||||||
|
from binman import bintool_test
|
||||||
from binman import cbfs_util_test
|
from binman import cbfs_util_test
|
||||||
from binman import elf_test
|
from binman import elf_test
|
||||||
from binman import entry_test
|
from binman import entry_test
|
||||||
|
@ -85,9 +86,9 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath):
|
||||||
test_util.RunTestSuites(
|
test_util.RunTestSuites(
|
||||||
result, debug, verbosity, test_preserve_dirs, processes, test_name,
|
result, debug, verbosity, test_preserve_dirs, processes, test_name,
|
||||||
toolpath,
|
toolpath,
|
||||||
[entry_test.TestEntry, ftest.TestFunctional, fdt_test.TestFdt,
|
[bintool_test.TestBintool, entry_test.TestEntry, ftest.TestFunctional,
|
||||||
elf_test.TestElf, image_test.TestImage, cbfs_util_test.TestCbfs,
|
fdt_test.TestFdt, elf_test.TestElf, image_test.TestImage,
|
||||||
fip_util_test.TestFip])
|
cbfs_util_test.TestCbfs, fip_util_test.TestFip])
|
||||||
|
|
||||||
return test_util.ReportResult('binman', test_name, result)
|
return test_util.ReportResult('binman', test_name, result)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue