mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-06 14:05:39 +00:00
47ad16894c
Since commit3b9a19e089
("kconfig: loop as long as we changed some symbols in randconfig"), conf_set_all_new_symbols() is repeated until there is no more choice left to be shuffled. The motivation was to shuffle a choice nested in another choice. Although commit09d5873e4d
("kconfig: allow only 'config', 'comment', and 'if' inside 'choice'") disallowed the nested choice structure, we must still keep3b9a19e089
because there are still cases where conf_set_all_new_symbols() must iterate. scripts/kconfig/tests/choice_randomize/Kconfig is the test case. The second choice depends on 'B', which is the member of the first choice. With3b9a19e089
reverted, we would never get the pattern specified by scripts/kconfig/tests/choice_randomize/expected_config2. A real example can be found in lib/Kconfig.debug. Without3b9a19e089
, the randconfig would not shuffle the "Compressed Debug information" choice, which depends on DEBUG_INFO, which is derived from another choice "Debug information". My goal is to refactor Kconfig so that randconfig will work more simply, without using the loop. For now, let's add a test case to ensure all dependent choices are shuffled, as it is a somewhat tricky case for the current Kconfig. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
35 lines
838 B
Python
35 lines
838 B
Python
# SPDX-License-Identifier: GPL-2.0-only
|
|
"""
|
|
Randomize all dependent choices
|
|
|
|
This is a somewhat tricky case for randconfig; the visibility of one choice is
|
|
determined by a member of another choice. Randconfig should be able to generate
|
|
all possible patterns.
|
|
"""
|
|
|
|
|
|
def test(conf):
|
|
|
|
expected0 = False
|
|
expected1 = False
|
|
expected2 = False
|
|
|
|
for i in range(100):
|
|
assert conf.randconfig(seed=i) == 0
|
|
|
|
if conf.config_matches('expected_config0'):
|
|
expected0 = True
|
|
elif conf.config_matches('expected_config1'):
|
|
expected1 = True
|
|
elif conf.config_matches('expected_config2'):
|
|
expected2 = True
|
|
else:
|
|
assert False
|
|
|
|
if expected0 and expected1 and expected2:
|
|
break
|
|
|
|
assert expected0
|
|
assert expected1
|
|
assert expected2
|