]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dtoc: Add a unit test for BytesToValue()
authorSimon Glass <sjg@chromium.org>
Sat, 18 May 2019 04:00:41 +0000 (22:00 -0600)
committerSimon Glass <sjg@chromium.org>
Wed, 10 Jul 2019 22:52:58 +0000 (16:52 -0600)
Add a simple unit test for one of the cases of this function, so that any
fault can be seen directly, rather than appearing through the failure of
another test.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/dtoc/test_fdt.py

index a5234ce1e88d1a6a9e6ff78d35bdaadc21d7f8cb..32a020bad2e7407bb9775dd8899ef4668e927c0c 100755 (executable)
@@ -19,7 +19,7 @@ for dirname in ['../patman', '..']:
 
 import command
 import fdt
-from fdt import TYPE_BYTE, TYPE_INT, TYPE_STRING, TYPE_BOOL
+from fdt import TYPE_BYTE, TYPE_INT, TYPE_STRING, TYPE_BOOL, BytesToValue
 import fdt_util
 from fdt_util import fdt32_to_cpu
 import libfdt
@@ -121,6 +121,10 @@ class TestFdt(unittest.TestCase):
         node = self.dtb.GetNode('/spl-test')
         self.assertEqual(self.dtb, node.GetFdt())
 
+    def testBytesToValue(self):
+        self.assertEqual(BytesToValue(b'this\0is\0'),
+                         (TYPE_STRING, ['this', 'is']))
+
 class TestNode(unittest.TestCase):
     """Test operation of the Node class"""