All of lore.kernel.org
 help / color / mirror / Atom feed
From: Walter Lozano <walter.lozano@collabora.com>
To: u-boot@lists.denx.de
Subject: [PATCH 02/10] dtoc: add option to disable warnings
Date: Fri, 29 May 2020 15:15:13 -0300	[thread overview]
Message-ID: <20200529181521.22073-3-walter.lozano@collabora.com> (raw)
In-Reply-To: <20200529181521.22073-1-walter.lozano@collabora.com>

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 <walter.lozano@collabora.com>
---
 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
+                    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):
     """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)
         with open(output) as infile:
             lines = infile.read().splitlines()
         self.assertEqual(C_HEADER.splitlines() + [''], lines)
@@ -168,7 +168,7 @@ class TestDtoc(unittest.TestCase):
         """Test output from some simple nodes with various types of data"""
         dtb_file = get_dtb_file('dtoc_test_simple.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:
             data = infile.read()
         self._CheckStrings(HEADER + '''
@@ -193,7 +193,7 @@ struct dtd_sandbox_spl_test_2 {
 };
 ''', data)
 
-        dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
+        dtb_platdata.run_steps(['platdata'], dtb_file, False, output, True)
         with open(output) as infile:
             data = infile.read()
         self._CheckStrings(C_HEADER + '''
@@ -272,7 +272,7 @@ U_BOOT_DEVICE(pmic_at_9) = {
         """Test output from a node containing a phandle reference"""
         dtb_file = get_dtb_file('dtoc_test_phandle.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:
             data = infile.read()
         self._CheckStrings(HEADER + '''
@@ -284,7 +284,7 @@ struct dtd_target {
 };
 ''', data)
 
-        dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
+        dtb_platdata.run_steps(['platdata'], dtb_file, False, output, True)
         with open(output) as infile:
             data = infile.read()
         self._CheckStrings(C_HEADER + '''
@@ -344,7 +344,7 @@ U_BOOT_DEVICE(phandle_source2) = {
         """Test output from a node containing a phandle reference"""
         dtb_file = get_dtb_file('dtoc_test_phandle_single.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:
             data = infile.read()
         self._CheckStrings(HEADER + '''
@@ -360,7 +360,7 @@ struct dtd_target {
         """Test that phandle targets are generated before their references"""
         dtb_file = get_dtb_file('dtoc_test_phandle_reorder.dts')
         output = tools.GetOutputFilename('output')
-        dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
+        dtb_platdata.run_steps(['platdata'], dtb_file, False, output, True)
         with open(output) as infile:
             data = infile.read()
         self._CheckStrings(C_HEADER + '''
@@ -390,7 +390,7 @@ U_BOOT_DEVICE(phandle_source2) = {
                                 capture_stderr=True)
         output = tools.GetOutputFilename('output')
         with self.assertRaises(ValueError) as e:
-            dtb_platdata.run_steps(['struct'], dtb_file, False, output)
+            dtb_platdata.run_steps(['struct'], dtb_file, False, output, True)
         self.assertIn("Cannot parse 'clocks' in node 'phandle-source'",
                       str(e.exception))
 
@@ -400,7 +400,7 @@ U_BOOT_DEVICE(phandle_source2) = {
                                 capture_stderr=True)
         output = tools.GetOutputFilename('output')
         with self.assertRaises(ValueError) as e:
-            dtb_platdata.run_steps(['struct'], dtb_file, False, output)
+            dtb_platdata.run_steps(['struct'], dtb_file, False, output, True)
         self.assertIn("Node 'phandle-target' has no '#clock-cells' property",
                       str(e.exception))
 
@@ -408,7 +408,7 @@ U_BOOT_DEVICE(phandle_source2) = {
         """Test output from a node with multiple compatible strings"""
         dtb_file = get_dtb_file('dtoc_test_aliases.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:
             data = infile.read()
         self._CheckStrings(HEADER + '''
@@ -419,7 +419,7 @@ struct dtd_compat1 {
 #define dtd_compat3 dtd_compat1
 ''', data)
 
-        dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
+        dtb_platdata.run_steps(['platdata'], dtb_file, False, output, True)
         with open(output) as infile:
             data = infile.read()
         self._CheckStrings(C_HEADER + '''
@@ -438,7 +438,7 @@ U_BOOT_DEVICE(spl_test) = {
         """Test output from a node with a 'reg' property with na=2, ns=2"""
         dtb_file = get_dtb_file('dtoc_test_addr64.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:
             data = infile.read()
         self._CheckStrings(HEADER + '''
@@ -453,7 +453,7 @@ struct dtd_test3 {
 };
 ''', data)
 
-        dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
+        dtb_platdata.run_steps(['platdata'], dtb_file, False, output, True)
         with open(output) as infile:
             data = infile.read()
         self._CheckStrings(C_HEADER + '''
@@ -490,7 +490,7 @@ U_BOOT_DEVICE(test3) = {
         """Test output from a node with a 'reg' property with na=1, ns=1"""
         dtb_file = get_dtb_file('dtoc_test_addr32.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:
             data = infile.read()
         self._CheckStrings(HEADER + '''
@@ -502,7 +502,7 @@ struct dtd_test2 {
 };
 ''', data)
 
-        dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
+        dtb_platdata.run_steps(['platdata'], dtb_file, False, output, True)
         with open(output) as infile:
             data = infile.read()
         self._CheckStrings(C_HEADER + '''
@@ -530,7 +530,7 @@ U_BOOT_DEVICE(test2) = {
         """Test output from a node with a 'reg' property with na=2, ns=1"""
         dtb_file = get_dtb_file('dtoc_test_addr64_32.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:
             data = infile.read()
         self._CheckStrings(HEADER + '''
@@ -545,7 +545,7 @@ struct dtd_test3 {
 };
 ''', data)
 
-        dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
+        dtb_platdata.run_steps(['platdata'], dtb_file, False, output, True)
         with open(output) as infile:
             data = infile.read()
         self._CheckStrings(C_HEADER + '''
@@ -582,7 +582,7 @@ U_BOOT_DEVICE(test3) = {
         """Test output from a node with a 'reg' property with na=1, ns=2"""
         dtb_file = get_dtb_file('dtoc_test_addr32_64.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:
             data = infile.read()
         self._CheckStrings(HEADER + '''
@@ -597,7 +597,7 @@ struct dtd_test3 {
 };
 ''', data)
 
-        dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
+        dtb_platdata.run_steps(['platdata'], dtb_file, False, output, True)
         with open(output) as infile:
             data = infile.read()
         self._CheckStrings(C_HEADER + '''
@@ -636,7 +636,7 @@ U_BOOT_DEVICE(test3) = {
         dtb_file = get_dtb_file('dtoc_test_bad_reg.dts', capture_stderr=True)
         output = tools.GetOutputFilename('output')
         with self.assertRaises(ValueError) as e:
-            dtb_platdata.run_steps(['struct'], dtb_file, False, output)
+            dtb_platdata.run_steps(['struct'], dtb_file, False, output, True)
         self.assertIn("Node 'spl-test' reg property is not an int",
                       str(e.exception))
 
@@ -646,7 +646,7 @@ U_BOOT_DEVICE(test3) = {
         dtb_file = get_dtb_file('dtoc_test_bad_reg2.dts', capture_stderr=True)
         output = tools.GetOutputFilename('output')
         with self.assertRaises(ValueError) as e:
-            dtb_platdata.run_steps(['struct'], dtb_file, False, output)
+            dtb_platdata.run_steps(['struct'], dtb_file, False, output, True)
         self.assertIn("Node 'spl-test' reg property has 3 cells which is not a multiple of na + ns = 1 + 1)",
                       str(e.exception))
 
@@ -654,7 +654,7 @@ U_BOOT_DEVICE(test3) = {
         """Test that a subequent node can add a new property to a struct"""
         dtb_file = get_dtb_file('dtoc_test_add_prop.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:
             data = infile.read()
         self._CheckStrings(HEADER + '''
@@ -664,7 +664,7 @@ struct dtd_sandbox_spl_test {
 };
 ''', data)
 
-        dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
+        dtb_platdata.run_steps(['platdata'], dtb_file, False, output, True)
         with open(output) as infile:
             data = infile.read()
         self._CheckStrings(C_HEADER + '''
@@ -692,12 +692,12 @@ U_BOOT_DEVICE(spl_test2) = {
         """Test output to stdout"""
         dtb_file = get_dtb_file('dtoc_test_simple.dts')
         with test_util.capture_sys_output() as (stdout, stderr):
-            dtb_platdata.run_steps(['struct'], dtb_file, False, '-')
+            dtb_platdata.run_steps(['struct'], dtb_file, False, '-', True)
 
     def testNoCommand(self):
         """Test running dtoc without a command"""
         with self.assertRaises(ValueError) as e:
-            dtb_platdata.run_steps([], '', False, '')
+            dtb_platdata.run_steps([], '', False, '', True)
         self.assertIn("Please specify a command: struct, platdata",
                       str(e.exception))
 
@@ -706,6 +706,6 @@ U_BOOT_DEVICE(spl_test2) = {
         dtb_file = get_dtb_file('dtoc_test_simple.dts')
         output = tools.GetOutputFilename('output')
         with self.assertRaises(ValueError) as e:
-            dtb_platdata.run_steps(['invalid-cmd'], dtb_file, False, output)
+            dtb_platdata.run_steps(['invalid-cmd'], dtb_file, False, output, True)
         self.assertIn("Unknown command 'invalid-cmd': (use: struct, platdata)",
                       str(e.exception))
-- 
2.20.1

  parent reply	other threads:[~2020-05-29 18:15 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-29 18:15 [PATCH 00/10] improve OF_PLATDATA support Walter Lozano
2020-05-29 18:15 ` [PATCH 01/10] dtoc: add support to scan drivers Walter Lozano
2020-06-04 15:59   ` Simon Glass
2020-06-08 15:49     ` Walter Lozano
2020-06-11 16:15       ` Walter Lozano
2020-06-11 16:44         ` Simon Glass
2020-06-11 16:45       ` Simon Glass
2020-06-11 17:11         ` Walter Lozano
2020-06-11 17:22           ` Simon Glass
2020-06-11 19:07             ` Walter Lozano
2020-06-12  2:22               ` Simon Glass
2020-06-12 17:38                 ` Walter Lozano
2020-06-16 13:43                   ` Simon Glass
2020-05-29 18:15 ` Walter Lozano [this message]
2020-06-04 15:59   ` [PATCH 02/10] dtoc: add option to disable warnings Simon Glass
2020-06-08 15:51     ` Walter Lozano
2020-05-29 18:15 ` [PATCH 03/10] dm: doc: update of-plat with the suppor for driver aliases Walter Lozano
2020-06-04 15:59   ` Simon Glass
2020-05-29 18:15 ` [PATCH 04/10] core: drop const for struct driver_info Walter Lozano
2020-06-04 15:59   ` Simon Glass
2020-05-29 18:15 ` [PATCH 05/10] core: extend struct driver_info to point to device Walter Lozano
2020-05-29 18:56   ` Walter Lozano
2020-05-29 19:00     ` Simon Glass
2020-05-29 19:20       ` Walter Lozano
2020-05-29 20:42         ` Simon Glass
2020-06-04 15:59   ` Simon Glass
2020-06-08 15:53     ` Walter Lozano
2020-05-29 18:15 ` [PATCH 06/10] dtoc: extend dtoc to use struct driver_info when linking nodes Walter Lozano
2020-06-04 15:59   ` Simon Glass
2020-05-29 18:15 ` [PATCH 07/10] dm: doc: update of-plat with new phandle support Walter Lozano
2020-06-04 15:59   ` Simon Glass
2020-06-08 15:54     ` Walter Lozano
2020-05-29 18:15 ` [PATCH 08/10] dtoc: update tests to match new platdata Walter Lozano
2020-06-04 15:59   ` Simon Glass
2020-05-29 18:15 ` [PATCH 09/10] dtoc: update dtb_platdata to support cd-gpios Walter Lozano
2020-06-04 15:59   ` Simon Glass
2020-06-08 16:01     ` Walter Lozano
2020-06-14  2:49       ` Simon Glass
2020-05-29 18:15 ` [PATCH 10/10] dtoc add test for cd-gpios Walter Lozano
2020-06-04 15:59   ` Simon Glass
2020-05-29 18:25 ` [PATCH 00/10] improve OF_PLATDATA support Jagan Teki
2020-05-29 19:15   ` Walter Lozano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200529181521.22073-3-walter.lozano@collabora.com \
    --to=walter.lozano@collabora.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.