Blame view
tools/binman/entry_test.py
1.76 KB
4f44304b0 binman: Add basic... |
1 2 3 4 5 6 7 8 9 |
# # 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 |
934cdcfb1 binman: Add tests... |
10 11 |
import os import sys |
4f44304b0 binman: Add basic... |
12 |
import unittest |
934cdcfb1 binman: Add tests... |
13 14 15 |
import fdt import fdt_util import tools |
4f44304b0 binman: Add basic... |
16 |
class TestEntry(unittest.TestCase): |
934cdcfb1 binman: Add tests... |
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
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 |
4f44304b0 binman: Add basic... |
40 41 |
def testEntryContents(self): """Test the Entry bass class""" |
4d5994f91 binman: Set up 'e... |
42 |
import entry |
4f44304b0 binman: Add basic... |
43 44 45 46 47 |
base_entry = entry.Entry(None, None, None, read_node=False) self.assertEqual(True, base_entry.ObtainContents()) def testUnknownEntry(self): """Test that unknown entry types are detected""" |
4d5994f91 binman: Set up 'e... |
48 |
import entry |
4f44304b0 binman: Add basic... |
49 50 51 52 53 54 |
Node = collections.namedtuple('Node', ['name', 'path']) node = Node('invalid-name', 'invalid-path') with self.assertRaises(ValueError) as e: entry.Entry.Create(None, node, node.name) self.assertIn("Unknown entry type 'invalid-name' in node " "'invalid-path'", str(e.exception)) |
9fc60b497 binman: Add a mai... |
55 56 57 58 |
if __name__ == "__main__": unittest.main() |