-
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 randconfig for choice in choice
Commit 3b9a19e ("kconfig: loop as long as we changed some symbols in randconfig") fixed randconfig where a choice contains a sub-choice. Prior to that commit, the sub-choice values were not set. I am not sure whether this is an intended feature or just something people discovered works, but it is used in the real world; drivers/usb/gadget/legacy/Kconfig is source'd in a choice context, then creates a sub-choice in it. For the test case in this commit, there are 3 possible results. Case 1: CONFIG_A=y # CONFIG_B is not set Case 2: # CONFIG_A is not set CONFIG_B=y CONFIG_C=y # CONFIG_D is not set Case 3: # CONFIG_A is not set CONFIG_B=y # CONFIG_C is not set CONFIG_D=y CONFIG_E=y So, this test iterates several times, and checks if the result is either of the three. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Ulf Magnusson <ulfalizer@gmail.com>
- Loading branch information
Masahiro Yamada
committed
Mar 25, 2018
1 parent
beaaddb
commit 3e4888c
Showing
5 changed files
with
60 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,33 @@ | ||
choice | ||
prompt "choice" | ||
|
||
config A | ||
bool "A" | ||
|
||
config B | ||
bool "B" | ||
|
||
if B | ||
choice | ||
prompt "sub choice" | ||
|
||
config C | ||
bool "C" | ||
|
||
config D | ||
bool "D" | ||
|
||
if D | ||
choice | ||
prompt "subsub choice" | ||
|
||
config E | ||
bool "E" | ||
|
||
endchoice | ||
endif # D | ||
|
||
endchoice | ||
endif # B | ||
|
||
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,16 @@ | ||
""" | ||
Set random values recursively in nested choices. | ||
Kconfig can create a choice-in-choice structure by using 'if' statement. | ||
randconfig should correctly set random choice values. | ||
Related Linux commit: 3b9a19e08960e5cdad5253998637653e592a3c29 | ||
""" | ||
|
||
|
||
def test(conf): | ||
for i in range(20): | ||
assert conf.randconfig() == 0 | ||
assert (conf.config_contains('expected_stdout0') or | ||
conf.config_contains('expected_stdout1') or | ||
conf.config_contains('expected_stdout2')) |
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,2 @@ | ||
CONFIG_A=y | ||
# CONFIG_B 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,4 @@ | ||
# CONFIG_A is not set | ||
CONFIG_B=y | ||
CONFIG_C=y | ||
# CONFIG_D 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,5 @@ | ||
# CONFIG_A is not set | ||
CONFIG_B=y | ||
# CONFIG_C is not set | ||
CONFIG_D=y | ||
CONFIG_E=y |