Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kconfig: tests: test dependency after shuffling choices

Commit c8fb7d7e48d1 ("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 c8fb7d7e48d1.

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>

+71
+32
scripts/kconfig/tests/choice_randomize2/Kconfig
··· 1 + choice 2 + prompt "This is always invisible" 3 + depends on n 4 + 5 + config DUMMY 6 + bool "DUMMY" 7 + 8 + endchoice 9 + 10 + choice 11 + prompt "Choose A or B" 12 + 13 + config A 14 + bool "A" 15 + 16 + config B 17 + bool "B" 18 + 19 + endchoice 20 + 21 + config FOO 22 + bool "FOO" 23 + depends on A 24 + 25 + choice 26 + prompt "Choose X" 27 + depends on FOO 28 + 29 + config X 30 + bool "X" 31 + 32 + endchoice
+18
scripts/kconfig/tests/choice_randomize2/__init__.py
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + """ 3 + Randomize choices with correct dependencies 4 + 5 + When shuffling a choice may potentially disrupt certain dependencies, symbol 6 + values must be recalculated. 7 + 8 + Related Linux commits: 9 + - c8fb7d7e48d11520ad24808cfce7afb7b9c9f798 10 + """ 11 + 12 + 13 + def test(conf): 14 + for i in range(20): 15 + assert conf.randconfig(seed=i) == 0 16 + assert (conf.config_matches('expected_config0') or 17 + conf.config_matches('expected_config1') or 18 + conf.config_matches('expected_config2'))
+8
scripts/kconfig/tests/choice_randomize2/expected_config0
··· 1 + # 2 + # Automatically generated file; DO NOT EDIT. 3 + # Main menu 4 + # 5 + CONFIG_A=y 6 + # CONFIG_B is not set 7 + CONFIG_FOO=y 8 + CONFIG_X=y
+7
scripts/kconfig/tests/choice_randomize2/expected_config1
··· 1 + # 2 + # Automatically generated file; DO NOT EDIT. 3 + # Main menu 4 + # 5 + CONFIG_A=y 6 + # CONFIG_B is not set 7 + # CONFIG_FOO is not set
+6
scripts/kconfig/tests/choice_randomize2/expected_config2
··· 1 + # 2 + # Automatically generated file; DO NOT EDIT. 3 + # Main menu 4 + # 5 + # CONFIG_A is not set 6 + CONFIG_B=y