summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/Korigins26
-rw-r--r--testsuite.py32
2 files changed, 56 insertions, 2 deletions
diff --git a/tests/Korigins b/tests/Korigins
new file mode 100644
index 0000000..3649133
--- /dev/null
+++ b/tests/Korigins
@@ -0,0 +1,26 @@
+config MAIN_FLAG
+ bool
+
+config MAIN_FLAG_DEPENDENCY
+ bool "Main Feature Dependency"
+ default y
+ depends on MAIN_FLAG
+
+config MAIN_FLAG_SELECT
+ bool "Main Feature Dependent"
+ select MAIN_FLAG
+
+choice MULTIPLE_CHOICES
+ prompt "Multiple Choice Option"
+
+config FIRST_CHOICE
+ bool "First Choice Option"
+ depends on !MAIN_FLAG
+
+config SECOND_CHOICE
+ bool "Second Choice Option"
+
+endchoice
+
+config UNSET_FLAG
+ bool "Disabled Feature"
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