History

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.

Masahiro Yamada committed 2 years ago

Commit f2fd2aa1 parent 47ad1685 files · +71 −0Browse files

Unified · Split

5 files
  1. scripts/kconfig/tests/choice_randomize2/Kconfig +32 −0
  2. scripts/kconfig/tests/choice_randomize2/__init__.py +18 −0
  3. scripts/kconfig/tests/choice_randomize2/expected_config0 +8 −0
  4. scripts/kconfig/tests/choice_randomize2/expected_config1 +7 −0
  5. scripts/kconfig/tests/choice_randomize2/expected_config2 +6 −0
scripts/kconfig/tests/choice_randomize2/Kconfig+32−0
@@ -0,0 +1,32 @@
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
scripts/kconfig/tests/choice_randomize2/__init__.py+18−0
@@ -0,0 +1,18 @@
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'))
scripts/kconfig/tests/choice_randomize2/expected_config0+8−0
@@ -0,0 +1,8 @@
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
scripts/kconfig/tests/choice_randomize2/expected_config1+7−0
@@ -0,0 +1,7 @@
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
scripts/kconfig/tests/choice_randomize2/expected_config2+6−0
@@ -0,0 +1,6 @@
1+#
2+# Automatically generated file; DO NOT EDIT.
3+# Main menu
4+#
5+# CONFIG_A is not set
6+CONFIG_B=y