summaryrefslogtreecommitdiff
path: root/testsuite.py
diff options
context:
space:
mode:
authorLuca Burelli <l.burelli@arduino.cc>2025-09-19 11:17:39 +0200
committerTorsten Tejlmand Rasmussen <torsten.rasmussen@nordicsemi.no>2025-10-20 12:34:58 +0200
commit95de62d808f4447da2456201d226969e5815b459 (patch)
tree85ff45245a69ad6bfc5053d81047f5546432d4cf /testsuite.py
parentf58717e3ccec4caa8c5c4bb7a1e731d5bbc9728e (diff)
kconfiglib: add origin test
This patch adds a test for the origin feature added in the series. Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
Diffstat (limited to 'testsuite.py')
-rw-r--r--testsuite.py32
1 files changed, 30 insertions, 2 deletions
diff --git a/testsuite.py b/testsuite.py
index a4ea556..b4f5e2b 100644
--- a/testsuite.py
+++ b/testsuite.py
@@ -1040,8 +1040,8 @@ g
""")
- print("Testing locations, source/rsource/gsource/grsource, and "
- "Kconfig.kconfig_filenames")
+ print("Testing locations, origins, source/rsource/gsource/grsource, "
+ "and Kconfig.kconfig_filenames")
def verify_locations(nodes, *expected_locs):
verify(len(nodes) == len(expected_locs),
@@ -1173,6 +1173,34 @@ tests/Krecursive2:1
else:
fail("'rsource' with missing file did not raise exception")
+ # Tests origins
+
+ c = Kconfig("tests/Korigins", warn=False)
+ c.syms["MAIN_FLAG_SELECT"].set_value(2, 'here')
+
+ expected = [
+ ('MAIN_FLAG', ('select', ['MAIN_FLAG_SELECT'])),
+ ('MAIN_FLAG_DEPENDENCY',
+ ('default', (os.path.abspath('Kconfiglib/tests/Korigins'), 6))),
+ ('MAIN_FLAG_SELECT', ('assign', 'here')),
+ ('SECOND_CHOICE', ('default', None)),
+ ('UNSET_FLAG', ('unset', None)),
+ ]
+
+ for node in c.node_iter(True):
+ if not isinstance(node.item, Symbol):
+ continue
+
+ if node.item.origin is None:
+ continue
+
+ exp_name, exp_origin = expected.pop(0)
+ verify_equal(node.item.name, exp_name)
+ verify_equal(node.item.origin, exp_origin)
+
+ if len(expected) != 0:
+ fail("origin test mismatch")
+
# Test a tricky case involving symlinks. $srctree is tests/symlink, which
# points to tests/sub/sub, meaning tests/symlink/.. != tests/. Previously,
# using 'rsource' from a file sourced with an absolute path triggered an