mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-17 23:34:24 +00:00
The 'choice' statement is primarily used to exclusively select one
option, but the 'optional' property allows all entries to be disabled.
In the following example, both A and B can be disabled simultaneously:
choice
prompt "choose A, B, or nothing"
optional
config A
bool "A"
config B
bool "B"
endchoice
You can achieve the equivalent outcome by other means.
A common solution is to add another option to guard the choice block.
In the following example, you can set ENABLE_A_B_CHOICE=n to disable
the entire choice block:
choice
prompt "choose A or B"
depends on ENABLE_A_B_CHOICE
config A
bool "A"
config B
bool "B"
endchoice
Another approach is to insert one more entry:
choice
prompt "choose A, B, or disable both"
config A
bool "A"
config B
bool "B"
config DISABLE_A_AND_B
bool "choose this to disable both A and B"
endchoice
Some real examples are DEBUG_INFO_NONE, INITRAMFS_COMPRESSION_NONE,
LTO_NONE, etc.
The 'optional' property is even more unnecessary for a tristate choice.
Without the 'optional' property, you can disable A and B; you can set
'm' in the choice prompt, and disable A and B individually:
choice
prompt "choose one built-in or make them modular"
config A
tristate "A"
config B
tristate "B"
endchoice
In conclusion, the 'optional' property was unneeded.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <n.schier@avm.de>
40 lines
1001 B
Python
40 lines
1001 B
Python
# SPDX-License-Identifier: GPL-2.0
|
|
"""
|
|
Basic choice tests.
|
|
|
|
The handling of 'choice' is a bit complicated part in Kconfig.
|
|
|
|
The behavior of 'y' choice is intuitive. If choice values are tristate,
|
|
the choice can be 'm' where each value can be enabled independently.
|
|
"""
|
|
|
|
|
|
def test_oldask0(conf):
|
|
assert conf.oldaskconfig() == 0
|
|
assert conf.stdout_contains('oldask0_expected_stdout')
|
|
|
|
|
|
def test_oldask1(conf):
|
|
assert conf.oldaskconfig('oldask1_config') == 0
|
|
assert conf.stdout_contains('oldask1_expected_stdout')
|
|
|
|
|
|
def test_allyes(conf):
|
|
assert conf.allyesconfig() == 0
|
|
assert conf.config_contains('allyes_expected_config')
|
|
|
|
|
|
def test_allmod(conf):
|
|
assert conf.allmodconfig() == 0
|
|
assert conf.config_contains('allmod_expected_config')
|
|
|
|
|
|
def test_allno(conf):
|
|
assert conf.allnoconfig() == 0
|
|
assert conf.config_contains('allno_expected_config')
|
|
|
|
|
|
def test_alldef(conf):
|
|
assert conf.alldefconfig() == 0
|
|
assert conf.config_contains('alldef_expected_config')
|