summaryrefslogtreecommitdiff
path: root/tools/dtoc/test_src_scan.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-02-03 16:01:10 +0300
committerSimon Glass <sjg@chromium.org>2021-03-22 09:23:27 +0300
commit337d6972f5f5294971db52809f83c0454cb4e7ba (patch)
tree88828d958b7e3f7fbc92fb101e8e10acea276c9f /tools/dtoc/test_src_scan.py
parent074197aadfef2cfe437ecc1fe057ef21f4eef0da (diff)
downloadu-boot-337d6972f5f5294971db52809f83c0454cb4e7ba.tar.xz
dtoc: Set up the uclasses that are used
We only care about uclasses that are actually used. This is determined by the drivers that use them. Check all the used drivers and build a list of 'valid' uclasses. Also add references to the uclasses so we can generate C code that uses them. Attach a uclass to each valid driver. For the tests, now that we have uclasses we must create an explicit test for the case where a node does not have one. This should only happen if the source code does not build, or the source-code scanning fails to find it. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/test_src_scan.py')
-rw-r--r--tools/dtoc/test_src_scan.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/dtoc/test_src_scan.py b/tools/dtoc/test_src_scan.py
index 598ff256a6..d32aa58400 100644
--- a/tools/dtoc/test_src_scan.py
+++ b/tools/dtoc/test_src_scan.py
@@ -466,3 +466,20 @@ U_BOOT_DRIVER(%s) = {
with test_util.capture_sys_output() as (stdout, _):
scan.mark_used([node])
self.assertEqual('', stdout.getvalue().strip())
+
+ def test_sequence(self):
+ """Test assignment of sequence numnbers"""
+ scan = src_scan.Scanner(None, False, None, '')
+ node = FakeNode()
+ uc = src_scan.UclassDriver('UCLASS_I2C')
+ node.uclass = uc
+ node.driver = True
+ node.seq = -1
+ node.path = 'mypath'
+ uc.alias_num_to_node[2] = node
+
+ # This should assign 3 (after the 2 that exists)
+ seq = scan.assign_seq(node)
+ self.assertEqual(3, seq)
+ self.assertEqual({'mypath': 3}, uc.alias_path_to_num)
+ self.assertEqual({2: node, 3: node}, uc.alias_num_to_node)