And running:
./scripts/kconfig/conf --randconfig Config.test.in
does properly randomise the two choice symbols (and the two booleans).
However, running:
KCONFIG_ALLCONFIG=config.defaults \
./scripts/kconfig/conf --randconfig Config.test.in
does *not* reandomise the two choice entries, and only CHOICE_OPTIONA
will ever be selected. (OPTIONA will always be set (expected), and
OPTIONB will be be properly randomised (expected).)
This patch defers setting that a choice has a value until a symbol for
that choice is indeed set, so that choices are properly randomised when
KCONFIG_ALLCONFIG is set, but not if a symbol for that choice is set.
Also, as a side-efect, this patch fixes the following case:
which could previously generate such .config files:
---8<--- ---8<---
CONFIG_OPTION_A=y CONFIG_OPTION_A=y
CONFIG_OPTION_B=y # CONFIG_OPTION_B is not set
# CONFIG_OPTION_C is not set CONFIG_OPTION_C=y
---8<--- ---8<---
Ie., the first entry in a choice is always set, plus zero or one of
the other options may be set.
This patch ensures that only one option may be set for a choice.
Reported-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Cc: Michal Marek <mmarek@suse.cz> Cc: Sam Ravnborg <sam@ravnborg.org> Cc: Arnaud Lacombe <lacombar@gmail.com>
---
Changes v2 -> v3
- ensure only one symbol is set in a choice
Changes v1 -> v2:
- further postpone setting that a choice has a value until
one is indeed set
- do not print symbols that are part of an invisible choice