Skip to content

Commit 95de62d

Browse files
pillo79tejlmand
authored andcommitted
kconfiglib: add origin test
This patch adds a test for the origin feature added in the series. Signed-off-by: Luca Burelli <[email protected]>
1 parent f58717e commit 95de62d

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

tests/Korigins

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
config MAIN_FLAG
2+
bool
3+
4+
config MAIN_FLAG_DEPENDENCY
5+
bool "Main Feature Dependency"
6+
default y
7+
depends on MAIN_FLAG
8+
9+
config MAIN_FLAG_SELECT
10+
bool "Main Feature Dependent"
11+
select MAIN_FLAG
12+
13+
choice MULTIPLE_CHOICES
14+
prompt "Multiple Choice Option"
15+
16+
config FIRST_CHOICE
17+
bool "First Choice Option"
18+
depends on !MAIN_FLAG
19+
20+
config SECOND_CHOICE
21+
bool "Second Choice Option"
22+
23+
endchoice
24+
25+
config UNSET_FLAG
26+
bool "Disabled Feature"

testsuite.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,8 +1040,8 @@ def verify_help(node, s):
10401040
""")
10411041

10421042

1043-
print("Testing locations, source/rsource/gsource/grsource, and "
1044-
"Kconfig.kconfig_filenames")
1043+
print("Testing locations, origins, source/rsource/gsource/grsource, "
1044+
"and Kconfig.kconfig_filenames")
10451045

10461046
def verify_locations(nodes, *expected_locs):
10471047
verify(len(nodes) == len(expected_locs),
@@ -1173,6 +1173,34 @@ def verify_locations(nodes, *expected_locs):
11731173
else:
11741174
fail("'rsource' with missing file did not raise exception")
11751175

1176+
# Tests origins
1177+
1178+
c = Kconfig("tests/Korigins", warn=False)
1179+
c.syms["MAIN_FLAG_SELECT"].set_value(2, 'here')
1180+
1181+
expected = [
1182+
('MAIN_FLAG', ('select', ['MAIN_FLAG_SELECT'])),
1183+
('MAIN_FLAG_DEPENDENCY',
1184+
('default', (os.path.abspath('Kconfiglib/tests/Korigins'), 6))),
1185+
('MAIN_FLAG_SELECT', ('assign', 'here')),
1186+
('SECOND_CHOICE', ('default', None)),
1187+
('UNSET_FLAG', ('unset', None)),
1188+
]
1189+
1190+
for node in c.node_iter(True):
1191+
if not isinstance(node.item, Symbol):
1192+
continue
1193+
1194+
if node.item.origin is None:
1195+
continue
1196+
1197+
exp_name, exp_origin = expected.pop(0)
1198+
verify_equal(node.item.name, exp_name)
1199+
verify_equal(node.item.origin, exp_origin)
1200+
1201+
if len(expected) != 0:
1202+
fail("origin test mismatch")
1203+
11761204
# Test a tricky case involving symlinks. $srctree is tests/symlink, which
11771205
# points to tests/sub/sub, meaning tests/symlink/.. != tests/. Previously,
11781206
# using 'rsource' from a file sourced with an absolute path triggered an

0 commit comments

Comments
 (0)