]>
git.ipfire.org Git - people/ms/u-boot.git/blob - tools/binman/entry_test.py
2 # Copyright (c) 2016 Google, Inc
3 # Written by Simon Glass <sjg@chromium.org>
5 # SPDX-License-Identifier: GPL-2.0+
7 # Test for the Entry class
18 class TestEntry(unittest
.TestCase
):
20 binman_dir
= os
.path
.dirname(os
.path
.realpath(sys
.argv
[0]))
21 tools
.PrepareOutputDir(None)
22 fname
= fdt_util
.EnsureCompiled(
23 os
.path
.join(binman_dir
,('test/05_simple.dts')))
24 dtb
= fdt
.FdtScan(fname
)
25 return dtb
.GetNode('/binman/u-boot')
27 def test1EntryNoImportLib(self
):
28 """Test that we can import Entry subclassess successfully"""
30 sys
.modules
['importlib'] = None
33 entry
.Entry
.Create(None, self
.GetNode(), 'u-boot')
35 def test2EntryImportLib(self
):
36 del sys
.modules
['importlib']
39 entry
.Entry
.Create(None, self
.GetNode(), 'u-boot-spl')
40 tools
._RemoveOutputDir
()
43 def testEntryContents(self
):
44 """Test the Entry bass class"""
46 base_entry
= entry
.Entry(None, None, None, read_node
=False)
47 self
.assertEqual(True, base_entry
.ObtainContents())
49 def testUnknownEntry(self
):
50 """Test that unknown entry types are detected"""
52 Node
= collections
.namedtuple('Node', ['name', 'path'])
53 node
= Node('invalid-name', 'invalid-path')
54 with self
.assertRaises(ValueError) as e
:
55 entry
.Entry
.Create(None, node
, node
.name
)
56 self
.assertIn("Unknown entry type 'invalid-name' in node "
57 "'invalid-path'", str(e
.exception
))
60 if __name__
== "__main__":