-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <masahiroy@kernel.org>
- Loading branch information
Masahiro Yamada
committed
Mar 20, 2024
1 parent
47ad168
commit f2fd2aa
Showing
5 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
choice | ||
prompt "This is always invisible" | ||
depends on n | ||
|
||
config DUMMY | ||
bool "DUMMY" | ||
|
||
endchoice | ||
|
||
choice | ||
prompt "Choose A or B" | ||
|
||
config A | ||
bool "A" | ||
|
||
config B | ||
bool "B" | ||
|
||
endchoice | ||
|
||
config FOO | ||
bool "FOO" | ||
depends on A | ||
|
||
choice | ||
prompt "Choose X" | ||
depends on FOO | ||
|
||
config X | ||
bool "X" | ||
|
||
endchoice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
""" | ||
Randomize choices with correct dependencies | ||
When shuffling a choice may potentially disrupt certain dependencies, symbol | ||
values must be recalculated. | ||
Related Linux commits: | ||
- c8fb7d7e48d11520ad24808cfce7afb7b9c9f798 | ||
""" | ||
|
||
|
||
def test(conf): | ||
for i in range(20): | ||
assert conf.randconfig(seed=i) == 0 | ||
assert (conf.config_matches('expected_config0') or | ||
conf.config_matches('expected_config1') or | ||
conf.config_matches('expected_config2')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# | ||
# Automatically generated file; DO NOT EDIT. | ||
# Main menu | ||
# | ||
CONFIG_A=y | ||
# CONFIG_B is not set | ||
CONFIG_FOO=y | ||
CONFIG_X=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# | ||
# Automatically generated file; DO NOT EDIT. | ||
# Main menu | ||
# | ||
CONFIG_A=y | ||
# CONFIG_B is not set | ||
# CONFIG_FOO is not set |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# | ||
# Automatically generated file; DO NOT EDIT. | ||
# Main menu | ||
# | ||
# CONFIG_A is not set | ||
CONFIG_B=y |