u-boot/tools/binman/entry_test.py
Tom Rini 83d290c56f SPDX: Convert all of our single license tags to Linux Kernel style
When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from.  So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry.  Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents.  There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>
2018-05-07 09:34:12 -04:00

59 lines
1.7 KiB
Python

# SPDX-License-Identifier: GPL-2.0+
# Copyright (c) 2016 Google, Inc
# Written by Simon Glass <sjg@chromium.org>
#
# 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
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"""
import entry
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))
if __name__ == "__main__":
unittest.main()