summaryrefslogtreecommitdiff
path: root/testsuite.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-08-23 02:43:00 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2018-08-24 01:01:36 +0200
commit13884e934ec8eda928234c6506ae27f0334ec31b (patch)
tree0f42365dad68240c5ebe0d81f7a7327affd1bf20 /testsuite.py
parent4b8805df373abebdf8e940b9511b2602640ff518 (diff)
Show include paths in menuconfig symbol information
Add a MenuNode.include_path attribute that holds a tuple of (filename, linenr) tuples, giving the locations of the 'source' statements via which the node's Kconfig file was included, starting from the top-level Kconfig file. Use MenuNode.include_path to give the include path for symbols and other items in the help display in the menuconfig interface. This is useful for figuring out how Kconfig files are organized, and when reorganizing things.
Diffstat (limited to 'testsuite.py')
-rw-r--r--testsuite.py46
1 files changed, 44 insertions, 2 deletions
diff --git a/testsuite.py b/testsuite.py
index a610c4b..1c49209 100644
--- a/testsuite.py
+++ b/testsuite.py
@@ -1041,9 +1041,9 @@ g
except KconfigError as e:
verify_equal(str(e), """
tests/Krecursive2:1: Recursive 'source' of 'tests/Krecursive1' detected. Check that environment variables are set correctly.
-Backtrace:
-tests/Krecursive2:1
+Include path:
tests/Krecursive1:1
+tests/Krecursive2:1
"""[:-1])
except:
fail("recursive 'source' raised wrong exception")
@@ -1108,6 +1108,48 @@ tests/Krecursive1:1
os.environ.pop("srctree", None)
+ print("Testing MenuNode.include_path")
+
+ os.environ["srctree"] = "Kconfiglib/tests"
+
+ c = Kconfig("Kinclude_path")
+
+ def verify_node_path(node, *expected):
+ if node.include_path != expected:
+ fail("Wrong include path for node {!r}. Got {}, expected {}."
+ .format(node, node.include_path, expected))
+
+ def verify_sym_path(sym_name, node_i, *expected):
+ verify_node_path(c.syms[sym_name].nodes[node_i], *expected)
+
+ verify_sym_path("TOP", 0)
+ verify_sym_path("TOP", 1)
+ verify_sym_path("TOP", 2)
+
+ verify_sym_path("ONE_DOWN", 0, ("Kinclude_path", 4))
+ verify_sym_path("ONE_DOWN", 1, ("Kinclude_path", 4))
+ verify_sym_path("ONE_DOWN", 2, ("Kinclude_path", 4))
+ verify_sym_path("ONE_DOWN", 3, ("Kinclude_path", 9))
+ verify_sym_path("ONE_DOWN", 4, ("Kinclude_path", 9))
+ verify_sym_path("ONE_DOWN", 5, ("Kinclude_path", 9))
+
+ verify_sym_path("TWO_DOWN", 0,
+ ('Kinclude_path', 4), ('Kinclude_path_sourced_1', 4))
+ verify_sym_path("TWO_DOWN", 1,
+ ('Kinclude_path', 4), ('Kinclude_path_sourced_1', 9))
+ verify_sym_path("TWO_DOWN", 2,
+ ('Kinclude_path', 9), ('Kinclude_path_sourced_1', 4))
+ verify_sym_path("TWO_DOWN", 3,
+ ('Kinclude_path', 9), ('Kinclude_path_sourced_1', 9))
+
+ verify_node_path(c.top_node)
+ verify_node_path(c.menus[0], ('Kinclude_path', 4), ('Kinclude_path_sourced_1', 4))
+ verify_node_path(c.comments[0], ('Kinclude_path', 4), ('Kinclude_path_sourced_1', 4))
+ verify_node_path(c.choices[0].nodes[0], ('Kinclude_path', 4), ('Kinclude_path_sourced_1', 4))
+
+ os.environ.pop("srctree", None)
+
+
print("Testing Kconfig.choices/menus/comments")
c = Kconfig("Kconfiglib/tests/Kitemlists")