From mboxrd@z Thu Jan 1 00:00:00 1970 From: Walter Lozano Date: Mon, 8 Jun 2020 12:51:20 -0300 Subject: [PATCH 02/10] dtoc: add option to disable warnings In-Reply-To: References: <20200529181521.22073-1-walter.lozano@collabora.com> <20200529181521.22073-3-walter.lozano@collabora.com> Message-ID: <569c3d52-4727-bfef-d12e-ae690ac9b63f@collabora.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Simon, On 4/6/20 12:59, Simon Glass wrote: > Hi Walter, > > On Fri, 29 May 2020 at 12:15, Walter Lozano wrote: >> As dtoc now performs checks for valid driver names, when running dtoc >> tests several warnings arise as these tests don't use valid driver >> names. >> >> This patch adds an option to disable those warning, which is only >> intended for running tests. >> >> Signed-off-by: Walter Lozano >> --- >> tools/dtoc/dtb_platdata.py | 11 +++++--- >> tools/dtoc/test_dtoc.py | 54 +++++++++++++++++++------------------- >> 2 files changed, 34 insertions(+), 31 deletions(-) >> >> diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py >> index 23cfda2f88..0a54188348 100644 >> --- a/tools/dtoc/dtb_platdata.py >> +++ b/tools/dtoc/dtb_platdata.py >> @@ -141,17 +141,19 @@ class DtbPlatdata(object): >> _valid_nodes: A list of Node object with compatible strings >> _include_disabled: true to include nodes marked status = "disabled" >> _outfile: The current output file (sys.stdout or a real file) >> + _warning_disabled: true to disable warnings about driver names not found >> _lines: Stashed list of output lines for outputting in the future >> _aliases: Dict that hold aliases for compatible strings >> _drivers: List of valid driver names found in drivers/ >> _driver_aliases: Dict that holds aliases for driver names >> """ >> - def __init__(self, dtb_fname, include_disabled): >> + def __init__(self, dtb_fname, include_disabled, warning_disable): >> self._fdt = None >> self._dtb_fname = dtb_fname >> self._valid_nodes = None >> self._include_disabled = include_disabled >> self._outfile = None >> + self._warning_disable = warning_disable >> self._lines = [] >> self._aliases = {} >> self._drivers = [] >> @@ -177,7 +179,8 @@ class DtbPlatdata(object): >> compat_c_old = compat_c >> compat_c = self._driver_aliases.get(compat_c) >> if not compat_c: >> - print('WARNING: the driver %s was not found in the driver list' % (compat_c_old)) >> + if not self._warning_disable: # pragma: no cover > Need coverage for this. No problem! > >> + print('WARNING: the driver %s was not found in the driver list' % (compat_c_old)) >> compat_c = compat_c_old >> else: # pragma: no cover >> aliases_c = [compat_c_old] + aliases_c >> @@ -623,7 +626,7 @@ class DtbPlatdata(object): >> nodes_to_output.remove(node) >> >> >> -def run_steps(args, dtb_file, include_disabled, output): >> +def run_steps(args, dtb_file, include_disabled, output, warning_disable = False): > no spaces around = Sure. >> """Run all the steps of the dtoc tool >> >> Args: >> @@ -635,7 +638,7 @@ def run_steps(args, dtb_file, include_disabled, output): >> if not args: >> raise ValueError('Please specify a command: struct, platdata') >> >> - plat = DtbPlatdata(dtb_file, include_disabled) >> + plat = DtbPlatdata(dtb_file, include_disabled, warning_disable) >> plat.scan_drivers() >> plat.scan_dtb() >> plat.scan_tree() >> diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py >> index 8498e8303c..a9b605cac8 100755 >> --- a/tools/dtoc/test_dtoc.py >> +++ b/tools/dtoc/test_dtoc.py >> @@ -154,12 +154,12 @@ class TestDtoc(unittest.TestCase): >> """Test output from a device tree file with no nodes""" >> dtb_file = get_dtb_file('dtoc_test_empty.dts') >> output = tools.GetOutputFilename('output') >> - dtb_platdata.run_steps(['struct'], dtb_file, False, output) >> + dtb_platdata.run_steps(['struct'], dtb_file, False, output, True) >> with open(output) as infile: >> lines = infile.read().splitlines() >> self.assertEqual(HEADER.splitlines(), lines) >> >> - dtb_platdata.run_steps(['platdata'], dtb_file, False, output) >> + dtb_platdata.run_steps(['platdata'], dtb_file, False, output, True) > Can you create run_test which calls run_steps with that set that to > True, to avoid adding the param everywhere in this file? Sure, no problem. Thanks! Regards, Walter