Skip to content

Commit f2fd2aa

Browse files
committed
kconfig: tests: test dependency after shuffling choices
Commit c8fb7d7 ("kconfig: fix broken dependency in randconfig- generated .config") fixed the issue, but I did not add a test case. This commit adds a test case that emulates the reported situation. The test would fail without c8fb7d7. To handle the choice "choose X", FOO must be calculated beforehand. FOO depends on A, which is a member of another choice "choose A or B". Kconfig _temporarily_ assumes the value of A to proceed. The choice "choose A or B" will be shuffled later, but the result may or may not meet "FOO depends on A". Kconfig should invalidate the symbol values and recompute them. In the real example for ARCH=arm64, the choice "Instrumentation type" needs the value of CPU_BIG_ENDIAN. The choice "Endianness" will be shuffled later. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 47ad168 commit f2fd2aa

File tree

5 files changed

+71
-0
lines changed

5 files changed

+71
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
choice
2+
prompt "This is always invisible"
3+
depends on n
4+
5+
config DUMMY
6+
bool "DUMMY"
7+
8+
endchoice
9+
10+
choice
11+
prompt "Choose A or B"
12+
13+
config A
14+
bool "A"
15+
16+
config B
17+
bool "B"
18+
19+
endchoice
20+
21+
config FOO
22+
bool "FOO"
23+
depends on A
24+
25+
choice
26+
prompt "Choose X"
27+
depends on FOO
28+
29+
config X
30+
bool "X"
31+
32+
endchoice
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
"""
3+
Randomize choices with correct dependencies
4+
5+
When shuffling a choice may potentially disrupt certain dependencies, symbol
6+
values must be recalculated.
7+
8+
Related Linux commits:
9+
- c8fb7d7e48d11520ad24808cfce7afb7b9c9f798
10+
"""
11+
12+
13+
def test(conf):
14+
for i in range(20):
15+
assert conf.randconfig(seed=i) == 0
16+
assert (conf.config_matches('expected_config0') or
17+
conf.config_matches('expected_config1') or
18+
conf.config_matches('expected_config2'))
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# Automatically generated file; DO NOT EDIT.
3+
# Main menu
4+
#
5+
CONFIG_A=y
6+
# CONFIG_B is not set
7+
CONFIG_FOO=y
8+
CONFIG_X=y
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
# Automatically generated file; DO NOT EDIT.
3+
# Main menu
4+
#
5+
CONFIG_A=y
6+
# CONFIG_B is not set
7+
# CONFIG_FOO is not set
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#
2+
# Automatically generated file; DO NOT EDIT.
3+
# Main menu
4+
#
5+
# CONFIG_A is not set
6+
CONFIG_B=y

0 commit comments

Comments
 (0)