Browse Source

dtoc: Avoid unwanted output during tests

At present some warnings are printed to indicate failures which are a
known part of running the tests. Suppress these.

Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass 6 years ago
parent
commit
fe57c784ad
2 changed files with 11 additions and 6 deletions
  1. 2 2
      tools/dtoc/fdt_util.py
  2. 9 4
      tools/dtoc/test_dtoc.py

+ 2 - 2
tools/dtoc/fdt_util.py

@@ -51,7 +51,7 @@ def fdt_cells_to_cpu(val, cells):
         out = out << 32 | fdt32_to_cpu(val[1])
         out = out << 32 | fdt32_to_cpu(val[1])
     return out
     return out
 
 
-def EnsureCompiled(fname):
+def EnsureCompiled(fname, capture_stderr=False):
     """Compile an fdt .dts source file into a .dtb binary blob if needed.
     """Compile an fdt .dts source file into a .dtb binary blob if needed.
 
 
     Args:
     Args:
@@ -86,7 +86,7 @@ def EnsureCompiled(fname):
     args.extend(search_list)
     args.extend(search_list)
     args.append(dts_input)
     args.append(dts_input)
     dtc = os.environ.get('DTC') or 'dtc'
     dtc = os.environ.get('DTC') or 'dtc'
-    command.Run(dtc, *args)
+    command.Run(dtc, *args, capture_stderr=capture_stderr)
     return dtb_output
     return dtb_output
 
 
 def GetInt(node, propname, default=None):
 def GetInt(node, propname, default=None):

+ 9 - 4
tools/dtoc/test_dtoc.py

@@ -47,16 +47,19 @@ C_HEADER = '''/*
 '''
 '''
 
 
 
 
-def get_dtb_file(dts_fname):
+
+def get_dtb_file(dts_fname, capture_stderr=False):
     """Compile a .dts file to a .dtb
     """Compile a .dts file to a .dtb
 
 
     Args:
     Args:
         dts_fname: Filename of .dts file in the current directory
         dts_fname: Filename of .dts file in the current directory
+        capture_stderr: True to capture and discard stderr output
 
 
     Returns:
     Returns:
         Filename of compiled file in output directory
         Filename of compiled file in output directory
     """
     """
-    return fdt_util.EnsureCompiled(os.path.join(our_path, dts_fname))
+    return fdt_util.EnsureCompiled(os.path.join(our_path, dts_fname),
+                                   capture_stderr=capture_stderr)
 
 
 
 
 class TestDtoc(unittest.TestCase):
 class TestDtoc(unittest.TestCase):
@@ -626,7 +629,8 @@ U_BOOT_DEVICE(test3) = {
 
 
     def test_bad_reg(self):
     def test_bad_reg(self):
         """Test that a reg property with an invalid type generates an error"""
         """Test that a reg property with an invalid type generates an error"""
-        dtb_file = get_dtb_file('dtoc_test_bad_reg.dts')
+        # Capture stderr since dtc will emit warnings for this file
+        dtb_file = get_dtb_file('dtoc_test_bad_reg.dts', capture_stderr=True)
         output = tools.GetOutputFilename('output')
         output = tools.GetOutputFilename('output')
         with self.assertRaises(ValueError) as e:
         with self.assertRaises(ValueError) as e:
             dtb_platdata.run_steps(['struct'], dtb_file, False, output)
             dtb_platdata.run_steps(['struct'], dtb_file, False, output)
@@ -635,7 +639,8 @@ U_BOOT_DEVICE(test3) = {
 
 
     def test_bad_reg2(self):
     def test_bad_reg2(self):
         """Test that a reg property with an invalid cell count is detected"""
         """Test that a reg property with an invalid cell count is detected"""
-        dtb_file = get_dtb_file('dtoc_test_bad_reg2.dts')
+        # Capture stderr since dtc will emit warnings for this file
+        dtb_file = get_dtb_file('dtoc_test_bad_reg2.dts', capture_stderr=True)
         output = tools.GetOutputFilename('output')
         output = tools.GetOutputFilename('output')
         with self.assertRaises(ValueError) as e:
         with self.assertRaises(ValueError) as e:
             dtb_platdata.run_steps(['struct'], dtb_file, False, output)
             dtb_platdata.run_steps(['struct'], dtb_file, False, output)