]> git.sur5r.net Git - u-boot/blobdiff - tools/binman/entry_test.py
db410c: Added pre-relocation attribute to pinctrl
[u-boot] / tools / binman / entry_test.py
index 85c4196892fc948b236210c45f0321d048b40043..6fa735ed5967641ef247cd06c3c46acb0b9da6eb 100644 (file)
@@ -1,15 +1,43 @@
-#
+# SPDX-License-Identifier: GPL-2.0+
 # Copyright (c) 2016 Google, Inc
 # Written by Simon Glass <sjg@chromium.org>
 #
-# SPDX-License-Identifier:      GPL-2.0+
-#
 # Test for the Entry class
 
 import collections
+import os
+import sys
 import unittest
 
+import fdt
+import fdt_util
+import tools
+
 class TestEntry(unittest.TestCase):
+    def GetNode(self):
+        binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
+        tools.PrepareOutputDir(None)
+        fname = fdt_util.EnsureCompiled(
+            os.path.join(binman_dir,('test/05_simple.dts')))
+        dtb = fdt.FdtScan(fname)
+        return dtb.GetNode('/binman/u-boot')
+
+    def test1EntryNoImportLib(self):
+        """Test that we can import Entry subclassess successfully"""
+
+        sys.modules['importlib'] = None
+        global entry
+        import entry
+        entry.Entry.Create(None, self.GetNode(), 'u-boot')
+
+    def test2EntryImportLib(self):
+        del sys.modules['importlib']
+        global entry
+        reload(entry)
+        entry.Entry.Create(None, self.GetNode(), 'u-boot-spl')
+        tools._RemoveOutputDir()
+        del entry
+
     def testEntryContents(self):
         """Test the Entry bass class"""
         import entry
@@ -25,3 +53,7 @@ class TestEntry(unittest.TestCase):
             entry.Entry.Create(None, node, node.name)
         self.assertIn("Unknown entry type 'invalid-name' in node "
                       "'invalid-path'", str(e.exception))
+
+
+if __name__ == "__main__":
+    unittest.main()